mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
configure annotations button: guess project after creation (IDEA-132950)
This commit is contained in:
+2
-17
@@ -15,14 +15,11 @@
|
||||
*/
|
||||
package com.intellij.codeInspection.deadCode;
|
||||
|
||||
import com.intellij.codeInspection.GlobalInspectionContext;
|
||||
import com.intellij.codeInspection.InspectionsBundle;
|
||||
import com.intellij.codeInspection.ex.EntryPointsManager;
|
||||
import com.intellij.codeInspection.ex.EntryPointsManagerImpl;
|
||||
import com.intellij.codeInspection.reference.EntryPoint;
|
||||
import com.intellij.codeInspection.unusedSymbol.UnusedSymbolLocalInspection;
|
||||
import com.intellij.codeInspection.unusedSymbol.UnusedSymbolLocalInspectionBase;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectManager;
|
||||
import com.intellij.ui.components.JBTabbedPane;
|
||||
import org.jetbrains.annotations.TestOnly;
|
||||
|
||||
@@ -53,17 +50,6 @@ public class UnusedDeclarationInspection extends UnusedDeclarationInspectionBase
|
||||
return tabs;
|
||||
}
|
||||
|
||||
private Project guessProject() {
|
||||
final GlobalInspectionContext context = getContext();
|
||||
Project project = context == null ? null : context.getProject();
|
||||
|
||||
if (project == null) {
|
||||
Project[] openProjects = ProjectManager.getInstance().getOpenProjects();
|
||||
project = openProjects.length == 0 ? ProjectManager.getInstance().getDefaultProject() : openProjects[0];
|
||||
}
|
||||
return project;
|
||||
}
|
||||
|
||||
private class OptionsPanel extends JPanel {
|
||||
private final JCheckBox myMainsCheckbox;
|
||||
private final JCheckBox myAppletToEntries;
|
||||
@@ -141,8 +127,7 @@ public class UnusedDeclarationInspection extends UnusedDeclarationInspectionBase
|
||||
gc.gridy++;
|
||||
add(myNonJavaCheckbox, gc);
|
||||
|
||||
Project project = guessProject();
|
||||
JButton configureAnnotations = EntryPointsManager.getInstance(project).createConfigureAnnotationsBtn();
|
||||
JButton configureAnnotations = EntryPointsManagerImpl.createConfigureAnnotationsButton();
|
||||
gc.fill = GridBagConstraints.NONE;
|
||||
gc.gridy++;
|
||||
gc.insets.top = 10;
|
||||
|
||||
@@ -28,6 +28,7 @@ import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer;
|
||||
import com.intellij.codeInspection.util.SpecialAnnotationsUtil;
|
||||
import com.intellij.openapi.components.*;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectUtil;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import org.jdom.Element;
|
||||
|
||||
@@ -73,11 +74,15 @@ public class EntryPointsManagerImpl extends EntryPointsManagerBase implements Pe
|
||||
|
||||
@Override
|
||||
public JButton createConfigureAnnotationsBtn() {
|
||||
return createConfigureAnnotationsButton();
|
||||
}
|
||||
|
||||
public static JButton createConfigureAnnotationsButton() {
|
||||
final JButton configureAnnotations = new JButton("Configure annotations...");
|
||||
configureAnnotations.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
configureAnnotations();
|
||||
getInstance(ProjectUtil.guessCurrentProject(configureAnnotations)).configureAnnotations();
|
||||
}
|
||||
});
|
||||
return configureAnnotations;
|
||||
|
||||
+2
-3
@@ -29,10 +29,10 @@ import com.intellij.codeInsight.FileModificationService;
|
||||
import com.intellij.codeInsight.daemon.GroupNames;
|
||||
import com.intellij.codeInspection.*;
|
||||
import com.intellij.codeInspection.ex.EntryPointsManager;
|
||||
import com.intellij.codeInspection.ex.EntryPointsManagerImpl;
|
||||
import com.intellij.codeInspection.reference.*;
|
||||
import com.intellij.codeInspection.unusedSymbol.UnusedSymbolLocalInspectionBase;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectUtil;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.search.PsiReferenceProcessor;
|
||||
@@ -234,8 +234,7 @@ public class UnusedParametersInspection extends GlobalJavaBatchInspectionTool {
|
||||
@Override
|
||||
public JComponent createOptionsPanel() {
|
||||
final JPanel panel = new JPanel(new GridBagLayout());
|
||||
Project project = ProjectUtil.guessCurrentProject(panel);
|
||||
panel.add(EntryPointsManager.getInstance(project).createConfigureAnnotationsBtn(),
|
||||
panel.add(EntryPointsManagerImpl.createConfigureAnnotationsButton(),
|
||||
new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
|
||||
new Insets(0, 0, 0, 0), 0, 0));
|
||||
return panel;
|
||||
|
||||
@@ -29,6 +29,8 @@ import com.intellij.psi.PsiElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
public abstract class EntryPointsManager implements Disposable {
|
||||
public static EntryPointsManager getInstance(Project project) {
|
||||
@@ -50,6 +52,10 @@ public abstract class EntryPointsManager implements Disposable {
|
||||
|
||||
public abstract void configureAnnotations();
|
||||
|
||||
/**
|
||||
* {@link com.intellij.codeInspection.ex.EntryPointsManagerImpl#createConfigureAnnotationsButton()} should be used instead
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract JButton createConfigureAnnotationsBtn();
|
||||
|
||||
public abstract boolean isEntryPoint(@NotNull PsiElement element);
|
||||
|
||||
Reference in New Issue
Block a user