diff --git a/java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/jikes/JikesConfigurable.java b/java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/jikes/JikesConfigurable.java
index d9cc3f71b7a3..e5e5115108a7 100644
--- a/java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/jikes/JikesConfigurable.java
+++ b/java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/jikes/JikesConfigurable.java
@@ -22,6 +22,7 @@ import com.intellij.openapi.fileChooser.FileChooserDescriptor;
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory;
import com.intellij.openapi.options.Configurable;
import com.intellij.openapi.options.ConfigurationException;
+import com.intellij.openapi.ui.TextFieldWithBrowseButton;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.ui.RawCommandLineEditor;
@@ -34,19 +35,18 @@ import java.io.File;
* @author Eugene Zhuravlev
* Date: Mar 30, 2004
*/
-public class JikesConfigurable implements Configurable{
+public class JikesConfigurable implements Configurable {
private JPanel myPanel;
private JCheckBox myCbDebuggingInfo;
private JCheckBox myCbDeprecation;
- private JCheckBox myCbGenerateNoWarnings ;
+ private JCheckBox myCbGenerateNoWarnings;
private RawCommandLineEditor myAdditionalOptionsField;
- private JTextField myPathField;
- private JButton myJikesPathFieldBrowseButton;
+ private TextFieldWithBrowseButton myPathField;
private final JikesSettings myJikesSettings;
public JikesConfigurable(JikesSettings jikesSettings) {
myJikesSettings = jikesSettings;
- myJikesPathFieldBrowseButton.addActionListener(new ActionListener() {
+ myPathField.getButton().addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFileNoJarsDescriptor();
VirtualFile file = FileChooser.chooseFile(myPathField, descriptor, null);
diff --git a/java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/jikes/JikesOptionsPanel.form b/java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/jikes/JikesOptionsPanel.form
index ca0dbdd1fd4d..cf2cfb167190 100644
--- a/java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/jikes/JikesOptionsPanel.form
+++ b/java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/jikes/JikesOptionsPanel.form
@@ -3,7 +3,7 @@
-
+
@@ -46,14 +46,20 @@
-
-
+
+
-
+
+
+
+
+
+
+
@@ -62,39 +68,10 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
diff --git a/java/compiler/impl/src/com/intellij/compiler/options/ComparingUtils.java b/java/compiler/impl/src/com/intellij/compiler/options/ComparingUtils.java
index b85d0c1f94cf..bac1d24e9a48 100644
--- a/java/compiler/impl/src/com/intellij/compiler/options/ComparingUtils.java
+++ b/java/compiler/impl/src/com/intellij/compiler/options/ComparingUtils.java
@@ -15,6 +15,7 @@
*/
package com.intellij.compiler.options;
+import com.intellij.openapi.ui.TextFieldWithBrowseButton;
import com.intellij.ui.RawCommandLineEditor;
import javax.swing.*;
@@ -24,6 +25,10 @@ import javax.swing.*;
* Date: Mar 30, 2004
*/
public class ComparingUtils {
+ public static boolean isModified(TextFieldWithBrowseButton field, String value) {
+ return !field.getText().equals(value);
+ }
+
public static boolean isModified(JCheckBox checkBox, boolean value) {
return checkBox.isSelected() != value;
}
diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/AnnotationsEditor.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/AnnotationsEditor.java
index 082ecbaef263..0f0e88489a7e 100644
--- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/AnnotationsEditor.java
+++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/AnnotationsEditor.java
@@ -22,23 +22,17 @@ import com.intellij.openapi.project.ProjectBundle;
import com.intellij.openapi.roots.AnnotationOrderRootType;
import com.intellij.openapi.util.IconLoader;
import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.ui.ColoredTableCellRenderer;
-import com.intellij.ui.ScrollPaneFactory;
-import com.intellij.ui.TableUtil;
+import com.intellij.ui.*;
import com.intellij.ui.components.JBLabel;
+import com.intellij.ui.table.JBTable;
import com.intellij.util.ArrayUtil;
import com.intellij.util.ui.ItemRemovable;
-import com.intellij.util.ui.Table;
import com.intellij.util.ui.UIUtil;
import javax.swing.*;
import javax.swing.border.Border;
-import javax.swing.event.ListSelectionEvent;
-import javax.swing.event.ListSelectionListener;
import javax.swing.table.DefaultTableModel;
import java.awt.*;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
import java.util.List;
/**
@@ -48,8 +42,6 @@ import java.util.List;
*/
public class AnnotationsEditor extends ModuleElementsEditor {
private JTable myTable;
- private JButton myAddPathButton;
- private JButton myRemoveButton;
public static final String NAME = ProjectBundle.message("project.roots.external.annotations.tab.title");
public static final Icon ICON = IconLoader.getIcon("/modules/annotation.png");
@@ -82,10 +74,8 @@ public class AnnotationsEditor extends ModuleElementsEditor {
}
public JComponent createComponentImpl() {
- final JPanel mainPanel = new JPanel(new BorderLayout(5, 10));
- mainPanel.setPreferredSize(new Dimension(-1, 200));
final DefaultTableModel tableModel = createModel();
- myTable = new Table(tableModel);
+ myTable = new JBTable(tableModel);
myTable.setIntercellSpacing(new Dimension(0, 0));
myTable.setDefaultRenderer(TableItem.class, new MyRenderer());
myTable.setShowGrid(false);
@@ -94,43 +84,43 @@ public class AnnotationsEditor extends ModuleElementsEditor {
myTable.setShowVerticalLines(false);
myTable.getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
- myAddPathButton = new JButton(ProjectBundle.message("module.javadoc.add.path.button"));
- myAddPathButton.addActionListener(new AddPathActionListener());
-
-
- myRemoveButton = new JButton(ProjectBundle.message("module.javadoc.remove.button"));
- myRemoveButton.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- final List removedItems = TableUtil.removeSelectedItems(myTable);
- if (removedItems.size() > 0) {
+ JPanel tablePanel = ToolbarDecorator.createDecorator(myTable)
+ .setAddAction(new AnActionButtonRunnable() {
+ @Override
+ public void run(AnActionButton button) {
+ FileChooserDescriptor myDescriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
+ myDescriptor.setTitle(ProjectBundle.message("add.external.annotations.path.title"));
+ myDescriptor.setDescription(ProjectBundle.message("add.external.annotations.path.description"));
+ VirtualFile[] files = FileChooser.chooseFiles(myTable, myDescriptor);
+ final MyTableModel tableModel = (MyTableModel)myTable.getModel();
+ boolean changes = false;
+ for (final VirtualFile file : files) {
+ if (file != null) {
+ tableModel.addTableItem(new TableItem(file));
+ changes = true;
+ }
+ }
+ if (changes) {
saveData();
+ TableUtil.selectRows(myTable, new int[] {tableModel.getRowCount() - 1});
}
}
- });
-
- final JPanel panel = new JPanel(new GridBagLayout());
- panel.add(myAddPathButton, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
- panel.add(myRemoveButton, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 1.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(4, 0, 0, 0), 0, 0));
-
- mainPanel.add(ScrollPaneFactory.createScrollPane(myTable), BorderLayout.CENTER);
- mainPanel.add(panel, BorderLayout.EAST);
- mainPanel.add(new JBLabel(ProjectBundle.message("project.roots.external.annotations.description"), UIUtil.ComponentStyle.SMALL, UIUtil.FontColor.BRIGHTER), BorderLayout.NORTH);
-
- myTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
- public void valueChanged(ListSelectionEvent e) {
- if (e.getValueIsAdjusting()) {
- return;
+ }).setRemoveAction(new AnActionButtonRunnable() {
+ @Override
+ public void run(AnActionButton button) {
+ final List removedItems = TableUtil.removeSelectedItems(myTable);
+ if (removedItems.size() > 0) {
+ saveData();
+ }
}
- final int selectedIndex = myTable.getSelectedRow();
- myRemoveButton.setEnabled(selectedIndex >= 0);
- }
- });
- if (tableModel.getRowCount() > 0) {
- TableUtil.selectRows(myTable, new int[] {0});
- }
- else {
- myRemoveButton.setEnabled(false);
- }
+ }).createPanel();
+
+
+ final JPanel mainPanel = new JPanel(new BorderLayout());
+
+ mainPanel.add(tablePanel, BorderLayout.CENTER);
+ mainPanel.add(new JBLabel(ProjectBundle.message("project.roots.external.annotations.description"), UIUtil.ComponentStyle.SMALL,
+ UIUtil.FontColor.BRIGHTER), BorderLayout.NORTH);
return mainPanel;
}
@@ -147,7 +137,6 @@ public class AnnotationsEditor extends ModuleElementsEditor {
if (myTable != null) {
final DefaultTableModel tableModel = createModel();
myTable.setModel(tableModel);
- myRemoveButton.setEnabled(tableModel.getRowCount() > 0);
}
}
@@ -189,38 +178,4 @@ public class AnnotationsEditor extends ModuleElementsEditor {
addRow(new Object[] {item});
}
}
-
- private abstract class MyAddAction implements ActionListener {
- protected abstract VirtualFile[] getFiles();
-
- public void actionPerformed(ActionEvent e) {
- VirtualFile[] files = getFiles();
- final MyTableModel tableModel = (MyTableModel)myTable.getModel();
- boolean changes = false;
- for (final VirtualFile file : files) {
- if (file != null) {
- tableModel.addTableItem(new TableItem(file));
- changes = true;
- }
- }
- if (changes) {
- saveData();
- TableUtil.selectRows(myTable, new int[] {tableModel.getRowCount() - 1});
- }
- }
- }
-
- private class AddPathActionListener extends MyAddAction{
- private final FileChooserDescriptor myDescriptor;
-
- public AddPathActionListener() {
- myDescriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
- myDescriptor.setTitle(ProjectBundle.message("add.external.annotations.path.title"));
- myDescriptor.setDescription(ProjectBundle.message("add.external.annotations.path.description"));
- }
-
- protected VirtualFile[] getFiles() {
- return FileChooser.chooseFiles(myTable, myDescriptor);
- }
- }
}
diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/JavadocEditor.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/JavadocEditor.java
index 4cbb4489199b..aed4f1931ebc 100644
--- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/JavadocEditor.java
+++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/JavadocEditor.java
@@ -15,6 +15,7 @@
*/
package com.intellij.openapi.roots.ui.configuration;
+import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.fileChooser.FileChooser;
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory;
@@ -23,35 +24,27 @@ import com.intellij.openapi.projectRoots.ui.Util;
import com.intellij.openapi.roots.JavadocOrderRootType;
import com.intellij.openapi.util.IconLoader;
import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.ui.ColoredTableCellRenderer;
-import com.intellij.ui.ScrollPaneFactory;
-import com.intellij.ui.TableUtil;
+import com.intellij.ui.*;
import com.intellij.ui.components.JBLabel;
+import com.intellij.ui.table.JBTable;
import com.intellij.util.ArrayUtil;
+import com.intellij.util.PlatformIcons;
import com.intellij.util.ui.ItemRemovable;
-import com.intellij.util.ui.Table;
import com.intellij.util.ui.UIUtil;
import javax.swing.*;
import javax.swing.border.Border;
-import javax.swing.event.ListSelectionEvent;
-import javax.swing.event.ListSelectionListener;
import javax.swing.table.DefaultTableModel;
import java.awt.*;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
import java.util.List;
/**
* @author Eugene Zhuravlev
- * Date: Oct 4, 2003
- * Time: 6:54:57 PM
+ * Date: Oct 4, 2003
+ * Time: 6:54:57 PM
*/
public class JavadocEditor extends ModuleElementsEditor {
private JTable myTable;
- private JButton myAddPathButton;
- private JButton myAddUrlButton;
- private JButton myRemoveButton;
public static final String NAME = ProjectBundle.message("module.javadoc.title");
public static final Icon ICON = IconLoader.getIcon("/modules/javadoc.png");
@@ -84,9 +77,8 @@ public class JavadocEditor extends ModuleElementsEditor {
}
public JComponent createComponentImpl() {
- final JPanel mainPanel = new JPanel(new BorderLayout(5, 10));
final DefaultTableModel tableModel = createModel();
- myTable = new Table(tableModel);
+ myTable = new JBTable(tableModel);
myTable.setIntercellSpacing(new Dimension(0, 0));
myTable.setDefaultRenderer(TableItem.class, new MyRenderer());
myTable.setShowGrid(false);
@@ -95,46 +87,59 @@ public class JavadocEditor extends ModuleElementsEditor {
myTable.setShowVerticalLines(false);
myTable.getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
- myAddPathButton = new JButton(ProjectBundle.message("module.javadoc.add.path.button"));
- myAddPathButton.addActionListener(new AddPathActionListener());
-
- myAddUrlButton = new JButton(ProjectBundle.message("module.javadoc.add.url.button"));
- myAddUrlButton.addActionListener(new AddUrlActionListener());
-
- myRemoveButton = new JButton(ProjectBundle.message("module.javadoc.remove.button"));
- myRemoveButton.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- final List removedItems = TableUtil.removeSelectedItems(myTable);
- if (removedItems.size() > 0) {
- saveData();
+ JPanel tablePanel = ToolbarDecorator.createDecorator(myTable)
+ .setAddAction(new AnActionButtonRunnable() {
+ @Override
+ public void run(AnActionButton button) {
+ FileChooserDescriptor myDescriptor = FileChooserDescriptorFactory.createMultipleJavaPathDescriptor();
+ myDescriptor.setTitle(ProjectBundle.message("module.javadoc.add.path.title"));
+ myDescriptor.setDescription(ProjectBundle.message("module.javadoc.add.path.prompt"));
+ VirtualFile[] files = FileChooser.chooseFiles(myTable, myDescriptor);
+ final MyTableModel tableModel = (MyTableModel)myTable.getModel();
+ boolean changes = false;
+ for (final VirtualFile file : files) {
+ if (file != null) {
+ tableModel.addTableItem(new TableItem(file));
+ changes = true;
+ }
+ }
+ if (changes) {
+ saveData();
+ TableUtil.selectRows(myTable, new int[]{tableModel.getRowCount() - 1});
+ }
}
- }
- });
-
- final JPanel panel = new JPanel(new GridBagLayout());
- panel.add(myAddPathButton, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
- panel.add(myAddUrlButton, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(4, 0, 0, 0), 0, 0));
- panel.add(myRemoveButton, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 1.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(4, 0, 0, 0), 0, 0));
-
- mainPanel.add(ScrollPaneFactory.createScrollPane(myTable), BorderLayout.CENTER);
- mainPanel.add(panel, BorderLayout.EAST);
- mainPanel.add(new JBLabel(ProjectBundle.message("project.roots.javadoc.tab.description"), UIUtil.ComponentStyle.SMALL, UIUtil.FontColor.BRIGHTER), BorderLayout.NORTH);
-
- myTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
- public void valueChanged(ListSelectionEvent e) {
- if (e.getValueIsAdjusting()) {
- return;
+ }).addExtraAction(new AnActionButton(ProjectBundle.message("module.javadoc.add.url.button"), PlatformIcons.TABLE_URL) {
+ @Override
+ public void actionPerformed(AnActionEvent e) {
+ VirtualFile[] files = new VirtualFile[]{Util.showSpecifyJavadocUrlDialog(myTable)};
+ final MyTableModel tableModel = (MyTableModel)myTable.getModel();
+ boolean changes = false;
+ for (final VirtualFile file : files) {
+ if (file != null) {
+ tableModel.addTableItem(new TableItem(file));
+ changes = true;
+ }
+ }
+ if (changes) {
+ saveData();
+ TableUtil.selectRows(myTable, new int[]{tableModel.getRowCount() - 1});
+ }
}
- final int selectedIndex = myTable.getSelectedRow();
- myRemoveButton.setEnabled(selectedIndex >= 0);
- }
- });
- if (tableModel.getRowCount() > 0) {
- TableUtil.selectRows(myTable, new int[] {0});
- }
- else {
- myRemoveButton.setEnabled(false);
- }
+ }).setRemoveAction(new AnActionButtonRunnable() {
+ @Override
+ public void run(AnActionButton button) {
+ final List removedItems = TableUtil.removeSelectedItems(myTable);
+ if (removedItems.size() > 0) {
+ saveData();
+ }
+ }
+ }).createPanel();
+
+ final JPanel mainPanel = new JPanel(new BorderLayout());
+ mainPanel.add(tablePanel, BorderLayout.CENTER);
+ mainPanel.add(
+ new JBLabel(ProjectBundle.message("project.roots.javadoc.tab.description"), UIUtil.ComponentStyle.SMALL, UIUtil.FontColor.BRIGHTER),
+ BorderLayout.NORTH);
return mainPanel;
}
@@ -151,7 +156,6 @@ public class JavadocEditor extends ModuleElementsEditor {
if (myTable != null) {
final DefaultTableModel tableModel = createModel();
myTable.setModel(tableModel);
- myRemoveButton.setEnabled(tableModel.getRowCount() > 0);
}
}
@@ -170,7 +174,7 @@ public class JavadocEditor extends ModuleElementsEditor {
}
}
- private static class MyTableModel extends DefaultTableModel implements ItemRemovable{
+ private static class MyTableModel extends DefaultTableModel implements ItemRemovable {
public String getColumnName(int column) {
return null;
}
@@ -192,48 +196,7 @@ public class JavadocEditor extends ModuleElementsEditor {
}
public void addTableItem(TableItem item) {
- addRow(new Object[] {item});
+ addRow(new Object[]{item});
}
}
-
- private abstract class MyAddAction implements ActionListener {
- protected abstract VirtualFile[] getFiles();
-
- public void actionPerformed(ActionEvent e) {
- VirtualFile[] files = getFiles();
- final MyTableModel tableModel = (MyTableModel)myTable.getModel();
- boolean changes = false;
- for (final VirtualFile file : files) {
- if (file != null) {
- tableModel.addTableItem(new TableItem(file));
- changes = true;
- }
- }
- if (changes) {
- saveData();
- TableUtil.selectRows(myTable, new int[] {tableModel.getRowCount() - 1});
- }
- }
- }
-
- private class AddUrlActionListener extends MyAddAction{
- protected VirtualFile[] getFiles() {
- return new VirtualFile[] {Util.showSpecifyJavadocUrlDialog(myTable)};
- }
- }
-
- private class AddPathActionListener extends MyAddAction{
- private final FileChooserDescriptor myDescriptor;
-
- public AddPathActionListener() {
- myDescriptor = FileChooserDescriptorFactory.createMultipleJavaPathDescriptor();
- myDescriptor.setTitle(ProjectBundle.message("module.javadoc.add.path.title"));
- myDescriptor.setDescription(ProjectBundle.message("module.javadoc.add.path.prompt"));
- }
-
- protected VirtualFile[] getFiles() {
- final VirtualFile[] files = FileChooser.chooseFiles(myTable, myDescriptor);
- return (files != null)? files : VirtualFile.EMPTY_ARRAY;
- }
- }
-}
+}
\ No newline at end of file
diff --git a/java/java-impl/src/com/intellij/codeInsight/ExternalAnnotationsManagerImpl.java b/java/java-impl/src/com/intellij/codeInsight/ExternalAnnotationsManagerImpl.java
index b86759580bca..8722fdfd04be 100644
--- a/java/java-impl/src/com/intellij/codeInsight/ExternalAnnotationsManagerImpl.java
+++ b/java/java-impl/src/com/intellij/codeInsight/ExternalAnnotationsManagerImpl.java
@@ -79,14 +79,13 @@ import java.io.IOException;
import java.util.*;
import java.util.List;
import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.atomic.AtomicReference;
public class ExternalAnnotationsManagerImpl extends ExternalAnnotationsManager {
@NotNull public static final Icon ICON = IconLoader.getIcon("/modules/annotation.png");
private static final Logger LOG = Logger.getInstance("#" + ExternalAnnotationsManagerImpl.class.getName());
@NotNull private final ConcurrentMap> myExternalAnnotations = new ConcurrentWeakValueHashMap>();
- @NotNull private final AtomicReference myHasAnyAnnotationsRoots = new AtomicReference(ThreeState.UNSURE);
+ @NotNull private volatile ThreeState myHasAnyAnnotationsRoots = ThreeState.UNSURE;
@NotNull private static final List NULL = new ArrayList();
private final PsiManager myPsiManager;
@@ -94,38 +93,42 @@ public class ExternalAnnotationsManagerImpl extends ExternalAnnotationsManager {
myPsiManager = psiManager;
final MessageBusConnection connection = project.getMessageBus().connect(project);
connection.subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootListener() {
+ @Override
public void beforeRootsChange(ModuleRootEvent event) {
}
+ @Override
public void rootsChanged(ModuleRootEvent event) {
myExternalAnnotations.clear();
- myHasAnyAnnotationsRoots.set(ThreeState.UNSURE);
+ myHasAnyAnnotationsRoots = ThreeState.UNSURE;
}
});
}
private ThreeState hasAnyAnnotationsRoots() {
- if (myHasAnyAnnotationsRoots.get() == ThreeState.UNSURE) {
+ if (myHasAnyAnnotationsRoots == ThreeState.UNSURE) {
final Module[] modules = ModuleManager.getInstance(myPsiManager.getProject()).getModules();
for (Module module : modules) {
for (OrderEntry entry : ModuleRootManager.getInstance(module).getOrderEntries()) {
final String[] urls = AnnotationOrderRootType.getUrls(entry);
if (urls.length > 0) {
- myHasAnyAnnotationsRoots.set(ThreeState.YES);
+ myHasAnyAnnotationsRoots = ThreeState.YES;
return ThreeState.YES;
}
}
}
- myHasAnyAnnotationsRoots.set(ThreeState.NO);
+ myHasAnyAnnotationsRoots = ThreeState.NO;
}
- return myHasAnyAnnotationsRoots.get();
+ return myHasAnyAnnotationsRoots;
}
+ @Override
@Nullable
public PsiAnnotation findExternalAnnotation(@NotNull final PsiModifierListOwner listOwner, @NotNull final String annotationFQN) {
return collectExternalAnnotations(listOwner).get(annotationFQN);
}
+ @Override
@Nullable
public PsiAnnotation[] findExternalAnnotations(@NotNull final PsiModifierListOwner listOwner) {
final Map result = collectExternalAnnotations(listOwner);
@@ -135,11 +138,11 @@ public class ExternalAnnotationsManagerImpl extends ExternalAnnotationsManager {
@NotNull
private Map collectExternalAnnotations(@NotNull final PsiModifierListOwner listOwner) {
if (hasAnyAnnotationsRoots() == ThreeState.NO) return Collections.emptyMap();
- final Map result = new HashMap();
- final List files = findExternalAnnotationsFile(listOwner);
+ final List files = findExternalAnnotationsFiles(listOwner);
if (files == null) {
return Collections.emptyMap();
}
+ final Map result = new HashMap();
for (XmlFile file : files) {
if (!file.isValid()) continue;
final XmlDocument document = file.getDocument();
@@ -168,7 +171,7 @@ public class ExternalAnnotationsManagerImpl extends ExternalAnnotationsManager {
"@" + annotationFQN + (buf.length() > 0 ? "(" + StringUtil.trimStart(buf.toString(), ",") + ")" : "");
try {
result.put(annotationFQN,
- JavaPsiFacade.getInstance(listOwner.getProject()).getElementFactory().createAnnotationFromText(
+ JavaPsiFacade.getInstance(myPsiManager.getProject()).getElementFactory().createAnnotationFromText(
annotationText, null));
}
catch (IncorrectOperationException e) {
@@ -186,11 +189,12 @@ public class ExternalAnnotationsManagerImpl extends ExternalAnnotationsManager {
}
+ @Override
public void annotateExternally(@NotNull final PsiModifierListOwner listOwner,
@NotNull final String annotationFQName,
@NotNull final PsiFile fromFile,
final PsiNameValuePair[] value) {
- final Project project = listOwner.getProject();
+ final Project project = myPsiManager.getProject();
final PsiFile containingFile = listOwner.getContainingFile();
if (!(containingFile instanceof PsiJavaFile)) {
return;
@@ -215,6 +219,7 @@ public class ExternalAnnotationsManagerImpl extends ExternalAnnotationsManager {
return;
}
SwingUtilities.invokeLater(new Runnable() {
+ @Override
public void run() {
setupRootAndAnnotateExternally(entry, project, listOwner, annotationFQName, fromFile, packageName, virtualFile, value);
}
@@ -240,9 +245,10 @@ public class ExternalAnnotationsManagerImpl extends ExternalAnnotationsManager {
return;
}
new WriteCommandAction(project) {
+ @Override
protected void run(final Result result) throws Throwable {
appendChosenAnnotationsRoot(entry, file);
- final List xmlFiles = findExternalAnnotationsFile(listOwner);
+ final List xmlFiles = findExternalAnnotationsFiles(listOwner);
if (xmlFiles != null) { //file already exists under appeared content root
if (!CodeInsightUtilBase.preparePsiElementForWrite(xmlFiles.get(0))) return;
annotateExternally(listOwner, annotationFQName, xmlFiles.get(0), fromFile, value);
@@ -314,7 +320,7 @@ public class ExternalAnnotationsManagerImpl extends ExternalAnnotationsManager {
@NotNull final PsiFile fromFile,
final PsiNameValuePair[] value) {
final XmlFile[] annotationsXml = new XmlFile[1];
- List xmlFiles = findExternalAnnotationsFile(listOwner);
+ List xmlFiles = findExternalAnnotationsFiles(listOwner);
if (xmlFiles != null) {
for (XmlFile xmlFile : xmlFiles) {
final VirtualFile vXmlFile = xmlFile.getVirtualFile();
@@ -330,6 +336,7 @@ public class ExternalAnnotationsManagerImpl extends ExternalAnnotationsManager {
final List annotationFiles = new ArrayList(xmlFiles);
new WriteCommandAction(project) {
+ @Override
protected void run(final Result result) throws Throwable {
if (annotationsXml[0] == null) {
annotationsXml[0] = createAnnotationsXml(file, packageName);
@@ -343,8 +350,9 @@ public class ExternalAnnotationsManagerImpl extends ExternalAnnotationsManager {
}.execute();
}
+ @Override
public boolean deannotate(@NotNull final PsiModifierListOwner listOwner, @NotNull final String annotationFQN) {
- final List files = findExternalAnnotationsFile(listOwner);
+ final List files = findExternalAnnotationsFiles(listOwner);
if (files != null) {
for (XmlFile file : files) {
if (file.isValid()) {
@@ -359,7 +367,7 @@ public class ExternalAnnotationsManagerImpl extends ExternalAnnotationsManager {
if (Comparing.strEqual(className, externalName) || Comparing.strEqual(className, oldExternalName)) {
for (XmlTag annotationTag : tag.getSubTags()) {
if (Comparing.strEqual(annotationTag.getAttributeValue("name"), annotationFQN)) {
- if (ReadonlyStatusHandler.getInstance(file.getProject())
+ if (ReadonlyStatusHandler.getInstance(myPsiManager.getProject())
.ensureFilesWritable(file.getVirtualFile()).hasReadonlyFiles()) {
return false;
}
@@ -386,11 +394,12 @@ public class ExternalAnnotationsManagerImpl extends ExternalAnnotationsManager {
return false;
}
+ @Override
@NotNull
public AnnotationPlace chooseAnnotationsPlace(@NotNull final PsiElement element) {
if (!element.isPhysical()) return AnnotationPlace.IN_CODE; //element just created
if (!element.getManager().isInProject(element)) return AnnotationPlace.EXTERNAL;
- final Project project = element.getProject();
+ final Project project = myPsiManager.getProject();
final PsiFile containingFile = element.getContainingFile();
final VirtualFile virtualFile = containingFile.getVirtualFile();
LOG.assertTrue(virtualFile != null);
@@ -472,7 +481,7 @@ public class ExternalAnnotationsManagerImpl extends ExternalAnnotationsManager {
myExternalAnnotations.clear();
}
- private static void annotateExternally(final PsiModifierListOwner listOwner,
+ private void annotateExternally(final PsiModifierListOwner listOwner,
final String annotationFQName,
@Nullable final XmlFile xmlFile,
@NotNull PsiFile codeUsageFile,
@@ -492,7 +501,8 @@ public class ExternalAnnotationsManagerImpl extends ExternalAnnotationsManager {
break;
}
}
- tag.add(XmlElementFactory.getInstance(xmlFile.getProject()).createTagFromText(createAnnotationTag(annotationFQName, values)));
+ tag.add(XmlElementFactory.getInstance(myPsiManager.getProject()).createTagFromText(
+ createAnnotationTag(annotationFQName, values)));
return;
}
}
@@ -500,7 +510,7 @@ public class ExternalAnnotationsManagerImpl extends ExternalAnnotationsManager {
"- \n";
text += createAnnotationTag(annotationFQName, values);
text += "
";
- rootTag.add(XmlElementFactory.getInstance(xmlFile.getProject()).createTagFromText(text));
+ rootTag.add(XmlElementFactory.getInstance(myPsiManager.getProject()).createTagFromText(text));
}
}
}
@@ -520,13 +530,13 @@ public class ExternalAnnotationsManagerImpl extends ExternalAnnotationsManager {
if (values != null) {
text = " \n";
text += StringUtil.join(values, new Function() {
+ @NonNls
@NotNull
@Override
public String fun(@NotNull PsiNameValuePair pair) {
- if (pair.getName() != null) {
- return "";
- }
- return "";
+ return "";
}
}, " \n");
text += " ";
@@ -572,8 +582,8 @@ public class ExternalAnnotationsManagerImpl extends ExternalAnnotationsManager {
}
@Nullable
- private List findExternalAnnotationsFile(@NotNull PsiModifierListOwner listOwner) {
- final Project project = listOwner.getProject();
+ private List findExternalAnnotationsFiles(@NotNull PsiModifierListOwner listOwner) {
+ final Project project = myPsiManager.getProject();
final PsiFile containingFile = listOwner.getContainingFile();
if (!(containingFile instanceof PsiJavaFile)) {
return null;
@@ -672,15 +682,18 @@ public class ExternalAnnotationsManagerImpl extends ExternalAnnotationsManager {
init();
}
+ @Override
protected String getOkActionName() {
return ADD_IN_CODE;
}
+ @Override
@NotNull
protected String getCancelActionName() {
return CommonBundle.getCancelButtonText();
}
+ @Override
@NotNull
@SuppressWarnings({"NonStaticInitializer"})
protected Action[] createActions() {
@@ -692,6 +705,7 @@ public class ExternalAnnotationsManagerImpl extends ExternalAnnotationsManager {
assignMnemonic(externalName, this);
}
+ @Override
public void actionPerformed(final ActionEvent e) {
if (canBeHidden()) {
setToBeShown(toBeShown(), true);
@@ -701,20 +715,24 @@ public class ExternalAnnotationsManagerImpl extends ExternalAnnotationsManager {
}, getCancelAction()};
}
+ @Override
protected boolean isToBeShown() {
return CodeStyleSettingsManager.getSettings(myProject).USE_EXTERNAL_ANNOTATIONS;
}
+ @Override
protected void setToBeShown(boolean value, boolean onOk) {
CodeStyleSettingsManager.getSettings(myProject).USE_EXTERNAL_ANNOTATIONS = value;
}
+ @Override
protected JComponent createNorthPanel() {
final JPanel northPanel = (JPanel)super.createNorthPanel();
northPanel.add(new JLabel(MESSAGE), BorderLayout.CENTER);
return northPanel;
}
+ @Override
protected boolean shouldSaveOptionsOnCancel() {
return true;
}
diff --git a/java/java-impl/src/com/intellij/unscramble/UnscrambleListener.java b/java/java-impl/src/com/intellij/unscramble/UnscrambleListener.java
index 23afeba19ed8..2612500f018e 100644
--- a/java/java-impl/src/com/intellij/unscramble/UnscrambleListener.java
+++ b/java/java-impl/src/com/intellij/unscramble/UnscrambleListener.java
@@ -33,8 +33,6 @@ public class UnscrambleListener implements ApplicationActivationListener {
@Override
public void applicationActivated(final IdeFrame ideFrame) {
- if (SystemInfo.isMac) return;
-
final Runnable processClipboard = new Runnable() {
@Override
public void run() {
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/JavaDummyHolder.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/JavaDummyHolder.java
index d03ec0fc0972..9580c45d0276 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/JavaDummyHolder.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/JavaDummyHolder.java
@@ -35,7 +35,7 @@ public class JavaDummyHolder extends DummyHolder implements PsiImportHolder {
private Map myPseudoImports = EMPTY;
public JavaDummyHolder(@NotNull PsiManager manager, TreeElement contentElement, PsiElement context) {
- super(manager, contentElement, context, null, null, JavaLanguage.INSTANCE);
+ super(manager, contentElement, context, null, null, language(context, JavaLanguage.INSTANCE));
}
public JavaDummyHolder(@NotNull PsiManager manager, CharTable table, boolean validity) {
@@ -43,15 +43,15 @@ public class JavaDummyHolder extends DummyHolder implements PsiImportHolder {
}
public JavaDummyHolder(@NotNull PsiManager manager, PsiElement context) {
- super(manager, null, context, null, null, JavaLanguage.INSTANCE);
+ super(manager, null, context, null, null, language(context, JavaLanguage.INSTANCE));
}
public JavaDummyHolder(@NotNull PsiManager manager, TreeElement contentElement, PsiElement context, CharTable table) {
- super(manager, contentElement, context, table, null, JavaLanguage.INSTANCE);
+ super(manager, contentElement, context, table, null, language(context, JavaLanguage.INSTANCE));
}
public JavaDummyHolder(@NotNull PsiManager manager, PsiElement context, CharTable table) {
- super(manager, null, context, table, null, JavaLanguage.INSTANCE);
+ super(manager, null, context, table, null, language(context, JavaLanguage.INSTANCE));
}
public JavaDummyHolder(@NotNull PsiManager manager, final CharTable table) {
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/JavaDocElementType.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/JavaDocElementType.java
index acd68f964221..4c4776cb1653 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/JavaDocElementType.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/JavaDocElementType.java
@@ -16,6 +16,7 @@
package com.intellij.psi.impl.source.tree;
import com.intellij.lang.ASTNode;
+import com.intellij.lang.Language;
import com.intellij.lang.PsiBuilder;
import com.intellij.lang.java.JavaLanguage;
import com.intellij.lang.java.parser.JavaParserUtil;
@@ -120,7 +121,7 @@ public interface JavaDocElementType {
}
@Override
- public boolean isParsable(final CharSequence buffer, final Project project) {
+ public boolean isParsable(final CharSequence buffer, Language fileLanguage, final Project project) {
final JavaLexer lexer = new JavaLexer(LanguageLevelProjectExtension.getInstance(project).getLanguageLevel());
lexer.start(buffer);
if (lexer.getTokenType() == DOC_COMMENT) {
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/JavaElementType.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/JavaElementType.java
index de737552382a..1dd8689c4fd0 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/JavaElementType.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/JavaElementType.java
@@ -165,7 +165,7 @@ public interface JavaElementType {
}
@Override
- public int getErrorsCount(final CharSequence seq, final Project project) {
+ public int getErrorsCount(final CharSequence seq, Language fileLanguage, final Project project) {
final Lexer lexer = new JavaLexer(LanguageLevel.HIGHEST);
lexer.start(seq);
diff --git a/java/testFramework/src/com/intellij/testFramework/fixtures/JavaCodeInsightFixtureTestCase.java b/java/testFramework/src/com/intellij/testFramework/fixtures/JavaCodeInsightFixtureTestCase.java
index c2dd1a155a13..4fc029dcd86c 100644
--- a/java/testFramework/src/com/intellij/testFramework/fixtures/JavaCodeInsightFixtureTestCase.java
+++ b/java/testFramework/src/com/intellij/testFramework/fixtures/JavaCodeInsightFixtureTestCase.java
@@ -44,7 +44,7 @@ public abstract class JavaCodeInsightFixtureTestCase extends UsefulTestCase{
protected void setUp() throws Exception {
super.setUp();
- final TestFixtureBuilder projectBuilder = IdeaTestFixtureFactory.getFixtureFactory().createFixtureBuilder();
+ final TestFixtureBuilder projectBuilder = IdeaTestFixtureFactory.getFixtureFactory().createFixtureBuilder(getName());
myFixture = JavaTestFixtureFactory.getFixtureFactory().createCodeInsightFixture(projectBuilder.getFixture());
final JavaModuleFixtureBuilder moduleFixtureBuilder = projectBuilder.addModule(JavaModuleFixtureBuilder.class);
moduleFixtureBuilder.addSourceContentRoot(myFixture.getTempDirPath());
diff --git a/java/testFramework/src/com/intellij/testFramework/fixtures/JavaTestFixtureFactory.java b/java/testFramework/src/com/intellij/testFramework/fixtures/JavaTestFixtureFactory.java
index b7b03b1de9df..5ae19176c25b 100644
--- a/java/testFramework/src/com/intellij/testFramework/fixtures/JavaTestFixtureFactory.java
+++ b/java/testFramework/src/com/intellij/testFramework/fixtures/JavaTestFixtureFactory.java
@@ -15,6 +15,8 @@
*/
package com.intellij.testFramework.fixtures;
+import org.jetbrains.annotations.NotNull;
+
/**
* @author yole
*/
@@ -41,8 +43,15 @@ public abstract class JavaTestFixtureFactory {
public abstract JavaCodeInsightTestFixture createCodeInsightFixture(IdeaProjectTestFixture projectFixture, TempDirTestFixture tempDirFixture);
+ /**
+ *
+ * @deprecated use {@link JavaTestFixtureFactory#createFixtureBuilder(String)}
+ */
//also implicitly initializes ourInstance and registers java module fixture builder
public static TestFixtureBuilder createFixtureBuilder() {
return IdeaTestFixtureFactory.getFixtureFactory().createFixtureBuilder();
}
+ public static TestFixtureBuilder createFixtureBuilder(@NotNull String name) {
+ return IdeaTestFixtureFactory.getFixtureFactory().createFixtureBuilder(name);
+ }
}
diff --git a/jps/jps-builders/src/org/jetbrains/jps/incremental/ModuleLevelBuilder.java b/jps/jps-builders/src/org/jetbrains/jps/incremental/ModuleLevelBuilder.java
index 106045201bee..4c4a3e7f78f4 100644
--- a/jps/jps-builders/src/org/jetbrains/jps/incremental/ModuleLevelBuilder.java
+++ b/jps/jps-builders/src/org/jetbrains/jps/incremental/ModuleLevelBuilder.java
@@ -2,17 +2,16 @@ package org.jetbrains.jps.incremental;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.Key;
+import com.intellij.openapi.util.Pair;
import org.jetbrains.ether.dependencyView.Mappings;
import org.jetbrains.jps.Module;
import org.jetbrains.jps.ModuleChunk;
+import org.jetbrains.jps.ProjectPaths;
import org.jetbrains.jps.incremental.messages.ProgressMessage;
import java.io.File;
import java.io.IOException;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
+import java.util.*;
/**
* Use {@link BuilderService} to register implementations of this class
@@ -103,6 +102,18 @@ public abstract class ModuleLevelBuilder extends Builder {
context.processMessage(new ProgressMessage("Found " + newlyAffectedFiles.size() + " affected files"));
if (!newlyAffectedFiles.isEmpty()) {
+
+
+ if (LOG.isDebugEnabled()) {
+ final List> wrongFiles = checkAffectedFilesInCorrectModules(context, chunk, newlyAffectedFiles);
+ if (!wrongFiles.isEmpty()) {
+ LOG.debug("Wrong affected files for module chunk " + chunk.getName() + ": ");
+ for (Pair pair : wrongFiles) {
+ LOG.debug("\t[" + pair.second.getName() + "] " + pair.first.getPath());
+ }
+ }
+ }
+
for (File file : newlyAffectedFiles) {
context.markDirtyIfNotDeleted(file);
}
@@ -135,6 +146,45 @@ public abstract class ModuleLevelBuilder extends Builder {
}
}
+
+ private static List> checkAffectedFilesInCorrectModules(CompileContext context, ModuleChunk currentChunk, Collection affected) {
+ if (affected.isEmpty()) {
+ return Collections.emptyList();
+ }
+
+ final Set chunkModules = currentChunk.getModules();
+ final Map> cache = new HashMap>();
+ final List> result = new ArrayList>();
+
+ for (File file : affected) {
+ final RootDescriptor moduleAndRoot = context.getModuleAndRoot(file);
+ if (moduleAndRoot == null) {
+ continue;
+ }
+ final Module moduleOfFile = moduleAndRoot.module;
+ if (chunkModules.contains(moduleOfFile)) {
+ continue;
+ }
+ Set moduleOfFileWithDependencies = cache.get(moduleOfFile);
+ if (moduleOfFileWithDependencies == null) {
+ moduleOfFileWithDependencies = ProjectPaths.getModulesWithDependentsRecursively(moduleOfFile, true);
+ cache.put(moduleOfFile, moduleOfFileWithDependencies);
+ }
+ if (intersects(moduleOfFileWithDependencies, chunkModules)) {
+ continue;
+ }
+ result.add(Pair.create(file, moduleOfFile));
+ }
+ return result;
+ }
+
+ private static boolean intersects(Set set1, Set set2) {
+ if (set1.size() < set2.size()) {
+ return new HashSet(set1).removeAll(set2);
+ }
+ return new HashSet(set2).removeAll(set1);
+ }
+
private static boolean chunkContainsAffectedFiles(CompileContext context, ModuleChunk chunk, final Set affected) throws IOException {
final Set chunkModules = new HashSet(chunk.getModules());
if (!chunkModules.isEmpty()) {
diff --git a/jps/model/src/org/jetbrains/jps/ProjectPaths.java b/jps/model/src/org/jetbrains/jps/ProjectPaths.java
index 2ac7addc9112..f4eb61024a37 100644
--- a/jps/model/src/org/jetbrains/jps/ProjectPaths.java
+++ b/jps/model/src/org/jetbrains/jps/ProjectPaths.java
@@ -181,6 +181,16 @@ public class ProjectPaths {
return sourcePaths;
}
+ public static Set getModulesWithDependentsRecursively(final Module module, final boolean includeTests) {
+ final Set result = new HashSet();
+ collectPathsRecursively(module, ClasspathKind.compile(includeTests), new HashSet(), new PathsGetter() {
+ public void apply(Module module, ClasspathKind kind) {
+ result.add(module);
+ }
+ });
+ return result;
+ }
+
private interface PathsGetter {
void apply(Module module, ClasspathKind kind);
}
diff --git a/platform/core-api/src/com/intellij/psi/tree/IReparseableElementType.java b/platform/core-api/src/com/intellij/psi/tree/IReparseableElementType.java
index f8cda346ad84..5a1636d9b4b5 100644
--- a/platform/core-api/src/com/intellij/psi/tree/IReparseableElementType.java
+++ b/platform/core-api/src/com/intellij/psi/tree/IReparseableElementType.java
@@ -42,11 +42,11 @@ public class IReparseableElementType extends ILazyParseableElementType {
* chameleon node.
*
* @param buffer the content to parse.
- * @param project the project containing the content.
- * @return true if the content is valid, false if not
+ * @param fileLanguage language of the file
+ * @param project the project containing the content. @return true if the content is valid, false if not
*/
- public boolean isParsable(CharSequence buffer, final Project project) {
+ public boolean isParsable(CharSequence buffer, Language fileLanguage, final Project project) {
return false;
}
}
diff --git a/platform/core-impl/src/com/intellij/psi/impl/source/DummyHolder.java b/platform/core-impl/src/com/intellij/psi/impl/source/DummyHolder.java
index 4bd9b53cb2c1..1a1a5111c878 100644
--- a/platform/core-impl/src/com/intellij/psi/impl/source/DummyHolder.java
+++ b/platform/core-impl/src/com/intellij/psi/impl/source/DummyHolder.java
@@ -47,7 +47,15 @@ public class DummyHolder extends PsiFileImpl {
}
public DummyHolder(@NotNull PsiManager manager, TreeElement contentElement, PsiElement context, CharTable table) {
- this(manager, contentElement, context, table, null, context == null ? PlainTextLanguage.INSTANCE : context.getLanguage());
+ this(manager, contentElement, context, table, null, language(context, PlainTextLanguage.INSTANCE));
+ }
+
+ protected static Language language(PsiElement context, Language defaultLanguage) {
+ if (context == null) return defaultLanguage;
+ Language contextLanguage = context.getLanguage();
+ Language language = context.getContainingFile().getLanguage();
+ if (language.isKindOf(contextLanguage)) return language;
+ return contextLanguage;
}
public DummyHolder(@NotNull PsiManager manager, TreeElement contentElement, PsiElement context, CharTable table, Boolean validity, Language language) {
diff --git a/platform/core-impl/src/com/intellij/psi/impl/source/text/BlockSupportImpl.java b/platform/core-impl/src/com/intellij/psi/impl/source/text/BlockSupportImpl.java
index efb9d3bf0aa8..14ce9c6860c1 100644
--- a/platform/core-impl/src/com/intellij/psi/impl/source/text/BlockSupportImpl.java
+++ b/platform/core-impl/src/com/intellij/psi/impl/source/text/BlockSupportImpl.java
@@ -112,14 +112,14 @@ public class BlockSupportImpl extends BlockSupport {
final TextRange textRange = node.getTextRange();
final IReparseableElementType reparseable = (IReparseableElementType)elementType;
- if (reparseable.getLanguage() == baseLanguage) {
+ if (baseLanguage.isKindOf(reparseable.getLanguage())) {
final int start = textRange.getStartOffset();
final int end = start + textRange.getLength() + lengthShift;
assertFileLength(file, newFileText, node, elementType, start, end);
CharSequence newTextStr = newFileText.subSequence(start, end);
- if (reparseable.isParsable(newTextStr, project)) {
+ if (reparseable.isParsable(newTextStr, baseLanguage, project)) {
ASTNode chameleon = reparseable.createNode(newTextStr);
if (chameleon != null) {
DummyHolder holder = DummyHolderFactory.createHolder(fileImpl.getManager(), null, node.getPsi(), charTable);
diff --git a/platform/core-impl/src/com/intellij/psi/tree/IErrorCounterReparseableElementType.java b/platform/core-impl/src/com/intellij/psi/tree/IErrorCounterReparseableElementType.java
index 40524866aaea..dfa9c3647f61 100644
--- a/platform/core-impl/src/com/intellij/psi/tree/IErrorCounterReparseableElementType.java
+++ b/platform/core-impl/src/com/intellij/psi/tree/IErrorCounterReparseableElementType.java
@@ -28,10 +28,10 @@ public abstract class IErrorCounterReparseableElementType extends IReparseableEl
super(debugName, language);
}
- public abstract int getErrorsCount(CharSequence seq, Project project);
+ public abstract int getErrorsCount(CharSequence seq, Language fileLanguage, Project project);
@Override
- public boolean isParsable(CharSequence buffer, final Project project) {
- return getErrorsCount(buffer, project) == NO_ERRORS;
+ public boolean isParsable(CharSequence buffer, Language fileLanguage, final Project project) {
+ return getErrorsCount(buffer, fileLanguage, project) == NO_ERRORS;
}
}
diff --git a/platform/lang-api/src/com/intellij/codeInspection/ui/AddAction.java b/platform/lang-api/src/com/intellij/codeInspection/ui/AddAction.java
deleted file mode 100644
index 7e0fd8359699..000000000000
--- a/platform/lang-api/src/com/intellij/codeInspection/ui/AddAction.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright 2007-2010 Bas Leijdekkers
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.intellij.codeInspection.ui;
-
-import com.intellij.CommonBundle;
-
-import javax.swing.*;
-import javax.swing.table.TableCellEditor;
-import java.awt.*;
-import java.awt.event.ActionEvent;
-
-public class AddAction extends AbstractAction {
-
- final ListTable table;
-
- public AddAction(ListTable table) {
- this.table = table;
- putValue(NAME, CommonBundle.message("button.add.a"));
- }
-
- public void actionPerformed(ActionEvent e) {
- final ListWrappingTableModel tableModel = table.getModel();
- tableModel.addRow();
- EventQueue.invokeLater(new Runnable() {
- public void run() {
- final int lastRowIndex = tableModel.getRowCount() - 1;
- final Rectangle rectangle =
- table.getCellRect(lastRowIndex, 0, true);
- table.scrollRectToVisible(rectangle);
- table.editCellAt(lastRowIndex, 0);
- final ListSelectionModel selectionModel =
- table.getSelectionModel();
- selectionModel.setSelectionInterval(lastRowIndex, lastRowIndex);
- final TableCellEditor editor = table.getCellEditor();
- final Component component =
- editor.getTableCellEditorComponent(table,
- null, true, lastRowIndex, 0);
- component.requestFocus();
- }
- });
- }
-}
\ No newline at end of file
diff --git a/platform/lang-api/src/com/intellij/codeInspection/ui/ListEditForm.form b/platform/lang-api/src/com/intellij/codeInspection/ui/ListEditForm.form
deleted file mode 100644
index 605c7defe87f..000000000000
--- a/platform/lang-api/src/com/intellij/codeInspection/ui/ListEditForm.form
+++ /dev/null
@@ -1,47 +0,0 @@
-
-
diff --git a/platform/lang-api/src/com/intellij/codeInspection/ui/ListEditForm.java b/platform/lang-api/src/com/intellij/codeInspection/ui/ListEditForm.java
index 5e1072ad4dc2..61513a26a583 100644
--- a/platform/lang-api/src/com/intellij/codeInspection/ui/ListEditForm.java
+++ b/platform/lang-api/src/com/intellij/codeInspection/ui/ListEditForm.java
@@ -15,32 +15,77 @@
*/
package com.intellij.codeInspection.ui;
-import com.intellij.codeInspection.ui.AddAction;
-import com.intellij.codeInspection.ui.ListTable;
-import com.intellij.codeInspection.ui.ListWrappingTableModel;
-import com.intellij.codeInspection.ui.RemoveAction;
+import com.intellij.ui.AnActionButton;
+import com.intellij.ui.AnActionButtonRunnable;
+import com.intellij.ui.ToolbarDecorator;
import javax.swing.*;
+import javax.swing.table.TableCellEditor;
+import java.awt.*;
import java.util.List;
public class ListEditForm {
-
JPanel contentPanel;
- JButton addButton;
- JButton removeButton;
ListTable table;
- private List myStringList;
- private String myTitle;
public ListEditForm(String title, List stringList) {
- myStringList = stringList;
- myTitle = title;
- removeButton.setAction(new RemoveAction(table));
- addButton.setAction(new AddAction(table));
- }
+ table = new ListTable(new ListWrappingTableModel(stringList, title));
- private void createUIComponents() {
- table = new ListTable(new ListWrappingTableModel(myStringList, myTitle));
+ contentPanel = ToolbarDecorator.createDecorator(table)
+ .setAddAction(new AnActionButtonRunnable() {
+ @Override
+ public void run(AnActionButton button) {
+ final ListWrappingTableModel tableModel = table.getModel();
+ tableModel.addRow();
+ EventQueue.invokeLater(new Runnable() {
+ public void run() {
+ final int lastRowIndex = tableModel.getRowCount() - 1;
+ final Rectangle rectangle =
+ table.getCellRect(lastRowIndex, 0, true);
+ table.scrollRectToVisible(rectangle);
+ table.editCellAt(lastRowIndex, 0);
+ final ListSelectionModel selectionModel =
+ table.getSelectionModel();
+ selectionModel.setSelectionInterval(lastRowIndex, lastRowIndex);
+ final TableCellEditor editor = table.getCellEditor();
+ final Component component =
+ editor.getTableCellEditorComponent(table,
+ null, true, lastRowIndex, 0);
+ component.requestFocus();
+ }
+ });
+ }
+ }).setRemoveAction(new AnActionButtonRunnable() {
+ @Override
+ public void run(AnActionButton button) {
+ final ListSelectionModel selectionModel = table.getSelectionModel();
+ final int minIndex = selectionModel.getMinSelectionIndex();
+ final int maxIndex = selectionModel.getMaxSelectionIndex();
+ if (minIndex == -1 || maxIndex == -1) {
+ return;
+ }
+ final ListWrappingTableModel tableModel = table.getModel();
+ for (int i = minIndex; i <= maxIndex; i++) {
+ if (selectionModel.isSelectedIndex(i)) {
+ tableModel.removeRow(i);
+ }
+ }
+ final int count = tableModel.getRowCount();
+ if (count <= minIndex) {
+ selectionModel.setSelectionInterval(count - 1,
+ count - 1);
+ }
+ else if (minIndex <= 0) {
+ if (count > 0) {
+ selectionModel.setSelectionInterval(0, 0);
+ }
+ }
+ else {
+ selectionModel.setSelectionInterval(minIndex - 1,
+ minIndex - 1);
+ }
+ }
+ }).disableUpDownActions().createPanel();
}
public JComponent getContentPanel() {
diff --git a/platform/lang-api/src/com/intellij/codeInspection/ui/RemoveAction.java b/platform/lang-api/src/com/intellij/codeInspection/ui/RemoveAction.java
deleted file mode 100644
index e89b6383189e..000000000000
--- a/platform/lang-api/src/com/intellij/codeInspection/ui/RemoveAction.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright 2007 Bas Leijdekkers
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.intellij.codeInspection.ui;
-
-import com.intellij.CommonBundle;
-
-import javax.swing.*;
-import java.awt.event.ActionEvent;
-
-public class RemoveAction extends AbstractAction {
-
- private final ListTable table;
-
- public RemoveAction(ListTable table) {
- this.table = table;
- putValue(NAME, CommonBundle.message("button.remove.r"));
- }
-
- public void actionPerformed(ActionEvent e) {
- final ListSelectionModel selectionModel = table.getSelectionModel();
- final int minIndex = selectionModel.getMinSelectionIndex();
- final int maxIndex = selectionModel.getMaxSelectionIndex();
- if (minIndex == -1 || maxIndex == -1) {
- return;
- }
- final ListWrappingTableModel tableModel = table.getModel();
- for (int i = minIndex; i <= maxIndex; i++) {
- if (selectionModel.isSelectedIndex(i)) {
- tableModel.removeRow(i);
- }
- }
- final int count = tableModel.getRowCount();
- if (count <= minIndex) {
- selectionModel.setSelectionInterval(count - 1,
- count - 1);
- }
- else if (minIndex <= 0) {
- if (count > 0) {
- selectionModel.setSelectionInterval(0, 0);
- }
- }
- else {
- selectionModel.setSelectionInterval(minIndex - 1,
- minIndex - 1);
- }
- }
-}
\ No newline at end of file
diff --git a/platform/lang-api/src/com/intellij/lang/folding/CustomFoldingBuilder.java b/platform/lang-api/src/com/intellij/lang/folding/CustomFoldingBuilder.java
index 1b5822fbe3e2..cc6c34625ef8 100644
--- a/platform/lang-api/src/com/intellij/lang/folding/CustomFoldingBuilder.java
+++ b/platform/lang-api/src/com/intellij/lang/folding/CustomFoldingBuilder.java
@@ -22,6 +22,7 @@ import java.util.List;
public abstract class CustomFoldingBuilder extends FoldingBuilderEx implements DumbAware {
private CustomFoldingProvider myDefaultProvider;
+ private static final int MAX_LOOKUP_DEPTH = 10;
@NotNull
@Override
@@ -29,7 +30,7 @@ public abstract class CustomFoldingBuilder extends FoldingBuilderEx implements D
List descriptors = new ArrayList();
if (CustomFoldingProvider.getAllProviders().length > 0) {
myDefaultProvider = null;
- addCustomFoldingRegionsRecursively(null, root.getNode(), descriptors);
+ addCustomFoldingRegionsRecursively(null, root.getNode(), descriptors, 0);
}
buildLanguageFoldRegions(descriptors, root, document, quick);
return descriptors.toArray(new FoldingDescriptor[descriptors.size()]);
@@ -57,7 +58,8 @@ public abstract class CustomFoldingBuilder extends FoldingBuilderEx implements D
private void addCustomFoldingRegionsRecursively(@Nullable FoldingStack foldingStack,
@NotNull ASTNode node,
- List descriptors) {
+ List descriptors,
+ int currDepth) {
FoldingStack localFoldingStack = isCustomFoldingRoot(node) || foldingStack == null ? new FoldingStack(node) : foldingStack;
for (ASTNode child = node.getFirstChildNode(); child != null; child = child.getTreeNext()) {
if (isCustomRegionStart(child)) {
@@ -72,7 +74,9 @@ public abstract class CustomFoldingBuilder extends FoldingBuilderEx implements D
}
}
else {
- addCustomFoldingRegionsRecursively(localFoldingStack, child, descriptors);
+ if (currDepth < MAX_LOOKUP_DEPTH) {
+ addCustomFoldingRegionsRecursively(localFoldingStack, child, descriptors, currDepth + 1);
+ }
}
}
}
diff --git a/platform/lang-api/src/com/intellij/openapi/project/ModuleNameTracker.java b/platform/lang-api/src/com/intellij/openapi/project/ModuleNameTracker.java
new file mode 100644
index 000000000000..2b6036e1d960
--- /dev/null
+++ b/platform/lang-api/src/com/intellij/openapi/project/ModuleNameTracker.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2000-2012 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.openapi.project;
+
+import com.intellij.openapi.Disposable;
+import com.intellij.openapi.module.Module;
+import com.intellij.openapi.util.Disposer;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * User: ksafonov
+ */
+public abstract class ModuleNameTracker extends ModuleAdapter {
+ private final Map myModulesNames = new HashMap();
+ private final Project myProject;
+
+ public ModuleNameTracker(Project project) {
+ myProject = project;
+ Disposer.register(project, new Disposable() {
+ @Override
+ public void dispose() {
+ myModulesNames.clear();
+ }
+ });
+ }
+
+ @Override
+ public void moduleAdded(final Project project, final Module module) {
+ if (myProject == project) {
+ myModulesNames.put(module, module.getName());
+ }
+ }
+
+ @Override
+ public void moduleRemoved(final Project project, final Module module) {
+ if (myProject == project) {
+ myModulesNames.remove(module);
+ }
+ }
+
+ @Override
+ public void modulesRenamed(final Project project, final List modules) {
+ if (myProject != project) {
+ return;
+ }
+
+ Map old2newNames = new HashMap(modules.size());
+ for (Module module : modules) {
+ String newName = module.getName();
+ String oldName = myModulesNames.put(module, newName);
+ old2newNames.put(oldName, newName);
+ }
+ modulesRenamed(project, old2newNames);
+ }
+
+ protected abstract void modulesRenamed(final Project project, final Map old2newNames);
+}
diff --git a/platform/lang-api/src/com/intellij/openapi/projectRoots/ui/PathEditor.java b/platform/lang-api/src/com/intellij/openapi/projectRoots/ui/PathEditor.java
index 26732a0f1817..374c5adc6c39 100644
--- a/platform/lang-api/src/com/intellij/openapi/projectRoots/ui/PathEditor.java
+++ b/platform/lang-api/src/com/intellij/openapi/projectRoots/ui/PathEditor.java
@@ -113,46 +113,41 @@ public class PathEditor {
myList = new JBList(getListModel());
myList.setCellRenderer(createListCellRenderer(myList));
- ToolbarDecorator toolbarDecorator = ToolbarDecorator.createDecorator(myList).disableUpDownActions();
- toolbarDecorator.setAddAction(new AnActionButtonRunnable() {
- @Override
- public void run(AnActionButton button) {
- final VirtualFile[] added = doAdd();
- if (added.length > 0) {
- setModified(true);
+ ToolbarDecorator toolbarDecorator = ToolbarDecorator.createDecorator(myList).disableUpDownActions()
+ .setAddAction(new AnActionButtonRunnable() {
+ @Override
+ public void run(AnActionButton button) {
+ final VirtualFile[] added = doAdd();
+ if (added.length > 0) {
+ setModified(true);
+ }
+ requestDefaultFocus();
+ setSelectedRoots(added);
}
- requestDefaultFocus();
- setSelectedRoots(added);
- }
- });
-
- toolbarDecorator.setRemoveAction(new AnActionButtonRunnable() {
- @Override
- public void run(AnActionButton button) {
- int[] idxs = myList.getSelectedIndices();
- doRemoveItems(idxs, myList);
- }
- });
+ }).setRemoveAction(new AnActionButtonRunnable() {
+ @Override
+ public void run(AnActionButton button) {
+ int[] idxs = myList.getSelectedIndices();
+ doRemoveItems(idxs, myList);
+ }
+ }).setAddActionUpdater(new AnActionButtonUpdater() {
+ @Override
+ public boolean isEnabled(AnActionEvent e) {
+ return myEnabled;
+ }
+ }).setRemoveActionUpdater(new AnActionButtonUpdater() {
+ @Override
+ public boolean isEnabled(AnActionEvent e) {
+ Object[] values = getSelectedRoots();
+ return values.length > 0 && myEnabled;
+ }
+ });
addToolbarButtons(toolbarDecorator);
myPanel = toolbarDecorator.createPanel();
myPanel.setBorder(null);
- ToolbarDecorator.findAddButton(myPanel).addCustomUpdater(new AnActionButtonUpdater() {
- @Override
- public boolean isEnabled(AnActionEvent e) {
- return myEnabled;
- }
- });
- ToolbarDecorator.findRemoveButton(myPanel).addCustomUpdater(new AnActionButtonUpdater() {
- @Override
- public boolean isEnabled(AnActionEvent e) {
- Object[] values = getSelectedRoots();
- return values.length > 0 && myEnabled;
- }
- });
-
return myPanel;
}
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonCodeAnalyzerImpl.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonCodeAnalyzerImpl.java
index 4cd590aa5898..252b26675a03 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonCodeAnalyzerImpl.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonCodeAnalyzerImpl.java
@@ -61,6 +61,7 @@ import com.intellij.psi.impl.PsiDocumentManagerImpl;
import com.intellij.psi.search.scope.packageSet.NamedScope;
import com.intellij.psi.search.scope.packageSet.NamedScopeManager;
import com.intellij.psi.search.scope.packageSet.NamedScopesHolder;
+import com.intellij.psi.util.PsiUtilCore;
import com.intellij.util.Alarm;
import com.intellij.util.CommonProcessors;
import com.intellij.util.Processor;
@@ -94,7 +95,7 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx
private final Alarm myAlarm = new Alarm();
private boolean myUpdateByTimerEnabled = true;
private final Collection myDisabledHintsFiles = new THashSet();
- private final Collection myDisabledHighlightingFiles = new THashSet();
+ private final Collection myDisabledHighlightingFiles = new THashSet();
private final FileStatusMap myFileStatusMap;
private DaemonCodeAnalyzerSettings myLastSettings;
@@ -122,6 +123,7 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx
myFileStatusMap = new FileStatusMap(myProject);
myPassExecutorService = new PassExecutorService(myProject) {
+ @Override
protected void afterApplyInformationToEditor(final TextEditorHighlightingPass pass,
final FileEditor fileEditor,
final ProgressIndicator updateProgress) {
@@ -132,6 +134,7 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx
}
}
+ @Override
protected boolean isDisposed() {
return myDisposed || super.isDisposed();
}
@@ -283,14 +286,17 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx
myPassExecutorService.cancelAll(true);
}
+ @Override
@NotNull
public String getComponentName() {
return "DaemonCodeAnalyzer";
}
+ @Override
public void initComponent() {
}
+ @Override
public void disposeComponent() {
}
@@ -309,6 +315,7 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx
myFileStatusMap.markAllFilesDirty();
}
+ @Override
public void projectClosed() {
assert myInitialized : "Disposing not initialized component";
assert !myDisposed : "Double dispose";
@@ -354,6 +361,7 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx
return myScopes;
}
+ @Override
public void settingsChanged() {
DaemonCodeAnalyzerSettings settings = DaemonCodeAnalyzerSettings.getInstance();
if (settings.isCodeHighlightingChanged(myLastSettings)) {
@@ -362,11 +370,13 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx
myLastSettings = (DaemonCodeAnalyzerSettings)settings.clone();
}
+ @Override
public void updateVisibleHighlighters(@NotNull Editor editor) {
ApplicationManager.getApplication().assertIsDispatchThread();
// no need, will not work anyway
}
+ @Override
public void setUpdateByTimerEnabled(boolean value) {
myUpdateByTimerEnabled = value;
stopProcess(value);
@@ -376,6 +386,7 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx
return myUpdateByTimerEnabled;
}
+ @Override
public void setImportHintsEnabled(@NotNull PsiFile file, boolean value) {
VirtualFile vFile = file.getVirtualFile();
if (value) {
@@ -388,23 +399,27 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx
}
}
+ @Override
public void resetImportHintsEnabledForProject() {
myDisabledHintsFiles.clear();
}
+ @Override
public void setHighlightingEnabled(@NotNull PsiFile file, boolean value) {
+ VirtualFile virtualFile = PsiUtilCore.getVirtualFile(file);
if (value) {
- myDisabledHighlightingFiles.remove(file);
+ myDisabledHighlightingFiles.remove(virtualFile);
}
else {
- myDisabledHighlightingFiles.add(file);
+ myDisabledHighlightingFiles.add(virtualFile);
}
}
+ @Override
public boolean isHighlightingAvailable(PsiFile file) {
- if (myDisabledHighlightingFiles.contains(file)) return false;
-
if (file == null || !file.isPhysical()) return false;
+ if (myDisabledHighlightingFiles.contains(PsiUtilCore.getVirtualFile(file))) return false;
+
if (file instanceof PsiCompiledElement) return false;
final FileType fileType = file.getFileType();
if (fileType == StdFileTypes.GUI_DESIGNER_FORM){
@@ -414,14 +429,17 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx
return !fileType.isBinary();
}
+ @Override
public boolean isImportHintsEnabled(@NotNull PsiFile file) {
return isAutohintsAvailable(file) && !myDisabledHintsFiles.contains(file.getVirtualFile());
}
+ @Override
public boolean isAutohintsAvailable(PsiFile file) {
return isHighlightingAvailable(file) && !(file instanceof PsiCompiledElement);
}
+ @Override
public void restart() {
myFileStatusMap.markAllFilesDirty();
stopProcess(true);
@@ -507,6 +525,7 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx
final SeverityRegistrar severityRegistrar = SeverityRegistrar.getInstance(project);
MarkupModelEx model = (MarkupModelEx)DocumentMarkupModel.forDocument(document, project, true);
return model.processRangeHighlightersOverlappingWith(startOffset, endOffset, new Processor() {
+ @Override
public boolean process(RangeHighlighterEx marker) {
Object tt = marker.getErrorStripeTooltip();
if (!(tt instanceof HighlightInfo)) return true;
@@ -529,6 +548,7 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx
final SeverityRegistrar severityRegistrar = SeverityRegistrar.getInstance(project);
MarkupModelEx model = (MarkupModelEx)DocumentMarkupModel.forDocument(document, project, true);
return model.processRangeHighlightersOutside(startOffset, endOffset, new Processor() {
+ @Override
public boolean process(RangeHighlighterEx marker) {
Object tt = marker.getErrorStripeTooltip();
if (!(tt instanceof HighlightInfo)) return true;
@@ -548,6 +568,7 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx
final boolean includeFixRange,
@NotNull final Processor processor) {
return processHighlights(document, project, null, 0, document.getTextLength(), new Processor() {
+ @Override
public boolean process(HighlightInfo info) {
if (!isOffsetInsideHighlightInfo(offset, info, includeFixRange)) return true;
@@ -561,6 +582,7 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx
public HighlightInfo findHighlightByOffset(Document document, final int offset, final boolean includeFixRange) {
final List foundInfoList = new SmartList();
processHighlightsNearOffset(document, myProject, HighlightSeverity.INFORMATION, offset, includeFixRange, new Processor() {
+ @Override
public boolean process(HighlightInfo info) {
if (!foundInfoList.isEmpty()) {
HighlightInfo foundInfo = foundInfoList.get(0);
@@ -635,6 +657,7 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx
return myLastIntentionHint;
}
+ @Override
public void writeExternal(Element parentNode) throws WriteExternalException {
Element disableHintsElement = new Element(DISABLE_HINTS_TAG);
parentNode.addContent(disableHintsElement);
@@ -654,6 +677,7 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx
}
}
+ @Override
public void readExternal(Element parentNode) throws InvalidDataException {
myDisabledHintsFiles.clear();
@@ -675,12 +699,14 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx
private Runnable createUpdateRunnable() {
return new Runnable() {
+ @Override
public void run() {
if (myDisposed || !myProject.isInitialized()) return;
if (PowerSaveMode.isEnabled()) return;
Editor activeEditor = FileEditorManager.getInstance(myProject).getSelectedTextEditor();
Runnable runnable = new Runnable() {
+ @Override
public void run() {
PassExecutorService.log(myUpdateProgress, null, "Update Runnable. myUpdateByTimerEnabled:",myUpdateByTimerEnabled," something disposed:",PowerSaveMode.isEnabled() || myDisposed || !myProject.isInitialized()," activeEditors:",myProject.isDisposed() ? null : myDaemonListeners.getSelectedEditors());
if (!myUpdateByTimerEnabled) return;
@@ -745,6 +771,7 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx
return myDaemonListeners.canChangeFileSilently(file);
}
+ @Override
public void autoImportReferenceAtCursor(@NotNull Editor editor, @NotNull PsiFile file) {
for(ReferenceImporter importer: Extensions.getExtensions(ReferenceImporter.EP_NAME)) {
if (importer.autoImportReferenceAtCursor(editor, file)) break;
diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/impl/VirtualDirectoryImpl.java b/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/impl/VirtualDirectoryImpl.java
index 035266c4dd47..c7b2b88a308c 100644
--- a/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/impl/VirtualDirectoryImpl.java
+++ b/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/impl/VirtualDirectoryImpl.java
@@ -73,7 +73,7 @@ public class VirtualDirectoryImpl extends VirtualFileSystemEntry {
private final NewVirtualFileSystem myFS;
// guarded by this
- protected Object myChildren; // Either HashMap or VFile[]
+ private Object myChildren; // Either HashMap or VFile[]
public VirtualDirectoryImpl(@NotNull String name, final VirtualDirectoryImpl parent, @NotNull NewVirtualFileSystem fs, final int id) {
super(name, parent, id);
@@ -379,8 +379,9 @@ public class VirtualDirectoryImpl extends VirtualFileSystemEntry {
@NotNull
private synchronized Collection getInDbChildren() {
- if (myChildren instanceof VirtualFileSystemEntry[]) {
- return Arrays.asList((VirtualFile[])myChildren);
+ VirtualFileSystemEntry[] children = asArray();
+ if (children != null) {
+ return Arrays.asList((VirtualFile[])children);
}
if (!ourPersistence.wereChildrenAccessed(this)) {
@@ -404,13 +405,13 @@ public class VirtualDirectoryImpl extends VirtualFileSystemEntry {
@Override
@NotNull
public synchronized VirtualFile[] getChildren() {
- if (myChildren instanceof VirtualFileSystemEntry[]) {
- return (VirtualFileSystemEntry[])myChildren;
+ VirtualFileSystemEntry[] children = asArray();
+ if (children != null) {
+ return children;
}
Pair pair = PersistentFS.listAll(this);
final int[] childrenIds = pair.second;
- VirtualFileSystemEntry[] children;
if (childrenIds.length == 0) {
children = EMPTY_ARRAY;
}
@@ -454,7 +455,10 @@ public class VirtualDirectoryImpl extends VirtualFileSystemEntry {
@Override
public NewVirtualFile findChildByIdIfCached(int id) {
- final VirtualFile[] a = asArray();
+ final VirtualFile[] a;
+ synchronized (this) {
+ a = asArray();
+ }
if (a != null) {
for (VirtualFile file : a) {
NewVirtualFile withId = (NewVirtualFile)file;
@@ -477,12 +481,15 @@ public class VirtualDirectoryImpl extends VirtualFileSystemEntry {
return null;
}
+ // MUST BE CALLED UNDER this LOCK
@Nullable
private VirtualFileSystemEntry[] asArray() {
- if (myChildren instanceof VirtualFileSystemEntry[]) return (VirtualFileSystemEntry[])myChildren;
+ Object children = myChildren;
+ if (children instanceof VirtualFileSystemEntry[]) return (VirtualFileSystemEntry[])children;
return null;
}
+ // MUST BE CALLED UNDER this LOCK
@Nullable
private Map asMap() {
if (myChildren instanceof Map) {
@@ -530,7 +537,7 @@ public class VirtualDirectoryImpl extends VirtualFileSystemEntry {
}
public synchronized boolean allChildrenLoaded() {
- return myChildren instanceof VirtualFileSystemEntry[];
+ return asArray() != null;
}
@NotNull
diff --git a/platform/util/src/com/intellij/openapi/util/io/FileSystemUtil.java b/platform/util/src/com/intellij/openapi/util/io/FileSystemUtil.java
index 33fb57c01f33..55ddc639be3a 100644
--- a/platform/util/src/com/intellij/openapi/util/io/FileSystemUtil.java
+++ b/platform/util/src/com/intellij/openapi/util/io/FileSystemUtil.java
@@ -88,8 +88,11 @@ public class FileSystemUtil {
}
public static boolean isSymLink(@NotNull final String path) {
- final FileAttributes attributes = getAttributes(path);
- return attributes != null && attributes.isSymlink;
+ if (SystemInfo.areSymLinksSupported) {
+ final FileAttributes attributes = getAttributes(path);
+ return attributes != null && attributes.isSymlink;
+ }
+ return false;
}
public static boolean isSymLink(@NotNull final File file) {
diff --git a/plugins/InspectionGadgets/src/com/siyeh/InspectionGadgetsBundle.properties b/plugins/InspectionGadgets/src/com/siyeh/InspectionGadgetsBundle.properties
index 62555bcfe923..0a8f5c42d78b 100644
--- a/plugins/InspectionGadgets/src/com/siyeh/InspectionGadgetsBundle.properties
+++ b/plugins/InspectionGadgets/src/com/siyeh/InspectionGadgetsBundle.properties
@@ -917,7 +917,8 @@ utility.class.without.private.constructor.problem.descriptor=Class #ref#ref() overrides concrete method #loc
abstract.method.with.missing.implementations.problem.descriptor=Abstract method #ref() is not implemented in every subclass #loc
abstract.method.overrides.abstract.method.problem.descriptor=Abstract method #ref() overrides abstract method #loc
-abstract.method.overrides.abstract.method.ignore.different.javadoc.option=Ignore methods with a different JavaDoc than their super methods
+abstract.method.overrides.abstract.method.ignore.different.javadoc.option=Ignore methods with different JavaDoc than their super methods
+abstract.method.overrides.abstract.method.ignore.different.annotations.option=Ignore methods with different annotations than their super methods
abstract.class.extends.concrete.class.problem.descriptor=Class #ref is declared 'abstract', and extends a concrete class #loc
static.non.final.field.problem.descriptor='static' non-'final' field #ref #loc
constant.declared.in.abstract.class.problem.descriptor=Constant #ref declared in abstract class #loc
@@ -1411,9 +1412,6 @@ assignment.replaceable.with.operator.assignment.problem.descriptor=#ref#ref() is identical to its super method #loc
@@ -1425,7 +1423,6 @@ pointless.indexof.comparison.display.name=Pointless 'indexOf()' comparison
pointless.indexof.comparison.always.true.problem.descriptor=#ref is always true #loc
pointless.indexof.comparison.always.false.problem.descriptor=#ref is always false #loc
reuse.of.local.variable.problem.descriptor=Reuse of local variable #ref #loc
-button.remove=&Remove
single.character.startswith.display.name=Single character 'startsWith()' or 'endsWith()'
single.character.startswith.problem.descriptor=Single character #ref() could be replaced with 'charAt()' expression #loc
indexof.replaceable.by.contains.display.name='indexOf()' expression is replaceable with 'contains()'
@@ -1959,6 +1956,7 @@ unclear.binary.expression.problem.descriptor=Expression could use clarifying par
unclear.binary.expression.quickfix=Add clarifying parentheses
new.exception.without.arguments.display.name=Exception constructor called without arguments
new.exception.without.arguments.problem.descriptor=new #ref() without arguments #loc
+new.exception.without.arguments.ignore.option=Ignore for exceptions that have no constructors with parameters
absolute.alignment.in.user.interface.display.name=Absolute alignment used in AWT/Swing code
absolute.alignment.in.user.interface.problem.descriptor=Absolute alignment constant {0}.#ref used #loc
absolute.alignment.in.user.interface.quickfix=Replace with ''{0}.{1}''
diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/bugs/IgnoreResultOfCallInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/bugs/IgnoreResultOfCallInspection.java
index 39f8b70db984..873a2407a5cc 100644
--- a/plugins/InspectionGadgets/src/com/siyeh/ig/bugs/IgnoreResultOfCallInspection.java
+++ b/plugins/InspectionGadgets/src/com/siyeh/ig/bugs/IgnoreResultOfCallInspection.java
@@ -17,12 +17,10 @@ package com.siyeh.ig.bugs;
import com.intellij.codeInspection.ui.ListTable;
import com.intellij.codeInspection.ui.ListWrappingTableModel;
-import com.intellij.openapi.actionSystem.ActionToolbar;
import com.intellij.openapi.util.InvalidDataException;
import com.intellij.openapi.util.WriteExternalException;
import com.intellij.psi.*;
import com.intellij.psi.util.InheritanceUtil;
-import com.intellij.ui.ScrollPaneFactory;
import com.intellij.util.ui.CheckBox;
import com.siyeh.InspectionGadgetsBundle;
import com.siyeh.ig.BaseInspection;
@@ -107,43 +105,15 @@ public class IgnoreResultOfCallInspection extends BaseInspection {
@Override
public JComponent createOptionsPanel() {
- final JPanel panel = new JPanel(new GridBagLayout());
- final ListTable table =
- new ListTable(new ListWrappingTableModel(
- Arrays.asList(classNames, methodNamePatterns),
- InspectionGadgetsBundle.message(
- "result.of.method.call.ignored.class.column.title"),
- InspectionGadgetsBundle.message(
- "result.of.method.call.ignored.method.column.title")));
- final JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(table);
- UiUtils.setScrollPaneSize(scrollPane, 7, 25);
-
- final ActionToolbar toolbar = UiUtils.createAddRemoveToolbar(table);
-
- final CheckBox checkBox = new CheckBox(InspectionGadgetsBundle.message(
- "result.of.method.call.ignored.non.library.option"), this,
- "m_reportAllNonLibraryCalls");
-
- final GridBagConstraints constraints = new GridBagConstraints();
- constraints.anchor = GridBagConstraints.FIRST_LINE_START;
- constraints.gridx = 0;
- constraints.gridy = 0;
- constraints.insets.left = 4;
- constraints.insets.right = 4;
- constraints.fill = GridBagConstraints.HORIZONTAL;
- panel.add(toolbar.getComponent(), constraints);
-
- constraints.gridy = 1;
- constraints.weightx = 1.0;
- constraints.weighty = 1.0;
- constraints.fill = GridBagConstraints.BOTH;
- panel.add(scrollPane, constraints);
-
- constraints.gridy = 2;
- constraints.weighty = 0.0;
- constraints.fill = GridBagConstraints.HORIZONTAL;
- panel.add(checkBox, constraints);
- panel.add(checkBox, constraints);
+ final JPanel panel = new JPanel(new BorderLayout());
+ final ListTable table = new ListTable(new ListWrappingTableModel(Arrays.asList(classNames, methodNamePatterns), InspectionGadgetsBundle
+ .message("result.of.method.call.ignored.class.column.title"), InspectionGadgetsBundle
+ .message("result.of.method.call.ignored.method.column.title")));
+ final JPanel tablePanel = UiUtils.createAddRemovePanel(table);
+ final CheckBox checkBox =
+ new CheckBox(InspectionGadgetsBundle.message("result.of.method.call.ignored.non.library.option"), this, "m_reportAllNonLibraryCalls");
+ panel.add(tablePanel, BorderLayout.CENTER);
+ panel.add(checkBox, BorderLayout.SOUTH);
return panel;
}
diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/bugs/MismatchedCollectionQueryUpdateInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/bugs/MismatchedCollectionQueryUpdateInspection.java
index 91bb9d973765..b8d2d84576c9 100644
--- a/plugins/InspectionGadgets/src/com/siyeh/ig/bugs/MismatchedCollectionQueryUpdateInspection.java
+++ b/plugins/InspectionGadgets/src/com/siyeh/ig/bugs/MismatchedCollectionQueryUpdateInspection.java
@@ -17,12 +17,11 @@ package com.siyeh.ig.bugs;
import com.intellij.codeInspection.ui.ListTable;
import com.intellij.codeInspection.ui.ListWrappingTableModel;
-import com.intellij.openapi.actionSystem.ActionToolbar;
import com.intellij.psi.*;
import com.intellij.psi.tree.IElementType;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.util.PsiUtil;
-import com.intellij.ui.ScrollPaneFactory;
+import com.intellij.util.ui.UIUtil;
import com.siyeh.InspectionGadgetsBundle;
import com.siyeh.ig.BaseInspection;
import com.siyeh.ig.BaseInspectionVisitor;
@@ -76,37 +75,15 @@ public class MismatchedCollectionQueryUpdateInspection
@Override
public JComponent createOptionsPanel() {
- final JPanel panel = new JPanel(new GridBagLayout());
+ final JPanel panel = new JPanel(new GridLayout(1, 2, UIUtil.DEFAULT_HGAP, UIUtil.DEFAULT_VGAP));
final ListTable table1 = new ListTable(new ListWrappingTableModel(queryNames, InspectionGadgetsBundle.message("query.column.name")));
- final JScrollPane scrollPane1 = ScrollPaneFactory.createScrollPane(table1);
- UiUtils.setScrollPaneSize(scrollPane1, 10, 15);
- final ActionToolbar toolbar1 = UiUtils.createAddRemoveToolbar(table1);
+ final JPanel tablePanel1 = UiUtils.createAddRemovePanel(table1);
final ListTable table2 = new ListTable(new ListWrappingTableModel(updateNames, InspectionGadgetsBundle.message("update.column.name")));
- final JScrollPane scrollPane2 = ScrollPaneFactory.createScrollPane(table2);
- UiUtils.setScrollPaneSize(scrollPane2, 10, 15);
- final ActionToolbar toolbar2 = UiUtils.createAddRemoveToolbar(table2);
+ final JPanel tablePanel2 = UiUtils.createAddRemovePanel(table2);
- final GridBagConstraints constraints = new GridBagConstraints();
- constraints.gridx = 0;
- constraints.gridy = 0;
- constraints.insets.left = 4;
- constraints.insets.right = 4;
- constraints.fill = GridBagConstraints.HORIZONTAL;
- panel.add(toolbar1.getComponent(), constraints);
-
- constraints.gridx = 1;
- panel.add(toolbar2.getComponent(), constraints);
-
- constraints.gridx = 0;
- constraints.gridy = 1;
- constraints.weightx = 0.5;
- constraints.weighty = 1.0;
- constraints.fill = GridBagConstraints.BOTH;
- panel.add(scrollPane1, constraints);
-
- constraints.gridx = 1;
- panel.add(scrollPane2, constraints);
+ panel.add(tablePanel1);
+ panel.add(tablePanel2);
return panel;
}
diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/errorhandling/BadExceptionCaughtInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/errorhandling/BadExceptionCaughtInspection.java
index 71b8faa8fe44..7d266394df4a 100644
--- a/plugins/InspectionGadgets/src/com/siyeh/ig/errorhandling/BadExceptionCaughtInspection.java
+++ b/plugins/InspectionGadgets/src/com/siyeh/ig/errorhandling/BadExceptionCaughtInspection.java
@@ -17,13 +17,11 @@ package com.siyeh.ig.errorhandling;
import com.intellij.codeInspection.ui.ListTable;
import com.intellij.codeInspection.ui.ListWrappingTableModel;
-import com.intellij.openapi.actionSystem.ActionToolbar;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.PsiCatchSection;
import com.intellij.psi.PsiParameter;
import com.intellij.psi.PsiType;
import com.intellij.psi.PsiTypeElement;
-import com.intellij.ui.ScrollPaneFactory;
import com.siyeh.InspectionGadgetsBundle;
import com.siyeh.ig.BaseInspection;
import com.siyeh.ig.BaseInspectionVisitor;
@@ -31,11 +29,7 @@ import com.siyeh.ig.ui.ExternalizableStringSet;
import com.siyeh.ig.ui.UiUtils;
import org.jetbrains.annotations.NotNull;
-import javax.swing.JComponent;
-import javax.swing.JPanel;
-import javax.swing.JScrollPane;
-import java.awt.GridBagConstraints;
-import java.awt.GridBagLayout;
+import javax.swing.*;
import java.util.List;
public class BadExceptionCaughtInspection extends BaseInspection {
@@ -88,36 +82,10 @@ public class BadExceptionCaughtInspection extends BaseInspection {
@Override
public JComponent createOptionsPanel() {
- final JComponent panel = new JPanel(new GridBagLayout());
-
final ListTable table =
- new ListTable(new ListWrappingTableModel(exceptions,
- InspectionGadgetsBundle.message(
- "exception.class.column.name")));
- final JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(table);
- UiUtils.setScrollPaneSize(scrollPane, 7, 25);
- final ActionToolbar toolbar =
- UiUtils.createAddRemoveTreeClassChooserToolbar(table,
- InspectionGadgetsBundle.message(
- "choose.exception.class"),
- "java.lang.Throwable");
-
- final GridBagConstraints constraints = new GridBagConstraints();
- constraints.anchor = GridBagConstraints.FIRST_LINE_START;
- constraints.gridx = 0;
- constraints.gridy = 0;
- constraints.insets.left = 4;
- constraints.insets.right = 4;
- constraints.fill = GridBagConstraints.HORIZONTAL;
- panel.add(toolbar.getComponent(), constraints);
-
- constraints.gridy = 1;
- constraints.weightx = 1.0;
- constraints.weighty = 1.0;
- constraints.fill = GridBagConstraints.BOTH;
- panel.add(scrollPane, constraints);
-
- return panel;
+ new ListTable(new ListWrappingTableModel(exceptions, InspectionGadgetsBundle.message("exception.class.column.name")));
+ return UiUtils
+ .createAddRemoveTreeClassChooserPanel(table, InspectionGadgetsBundle.message("choose.exception.class"), "java.lang.Throwable");
}
@Override
diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/errorhandling/BadExceptionDeclaredInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/errorhandling/BadExceptionDeclaredInspection.java
index 2561e3730ae5..cfa98c4e706c 100644
--- a/plugins/InspectionGadgets/src/com/siyeh/ig/errorhandling/BadExceptionDeclaredInspection.java
+++ b/plugins/InspectionGadgets/src/com/siyeh/ig/errorhandling/BadExceptionDeclaredInspection.java
@@ -18,10 +18,8 @@ package com.siyeh.ig.errorhandling;
import com.intellij.codeInsight.TestFrameworks;
import com.intellij.codeInspection.ui.ListTable;
import com.intellij.codeInspection.ui.ListWrappingTableModel;
-import com.intellij.openapi.actionSystem.ActionToolbar;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.*;
-import com.intellij.ui.ScrollPaneFactory;
import com.intellij.util.ui.CheckBox;
import com.siyeh.InspectionGadgetsBundle;
import com.siyeh.ig.BaseInspection;
@@ -95,28 +93,16 @@ public class BadExceptionDeclaredInspection extends BaseInspection {
@Override
public JComponent createOptionsPanel() {
- final JComponent panel = new JPanel(new BorderLayout());
-
final ListTable table =
- new ListTable(new ListWrappingTableModel(exceptions,
- InspectionGadgetsBundle.message(
- "exception.class.column.name")));
- final JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(table);
- UiUtils.setScrollPaneSize(scrollPane, 7, 25);
- final ActionToolbar toolbar =
- UiUtils.createAddRemoveTreeClassChooserToolbar(table,
- InspectionGadgetsBundle.message(
- "choose.exception.class"),
- "java.lang.Throwable");
-
- final CheckBox checkBox = new CheckBox(InspectionGadgetsBundle.message(
- "bad.exception.declared.ignore.exceptions.declared.in.tests.option"),
- this, "ignoreTestCases");
-
- panel.add(toolbar.getComponent(), BorderLayout.NORTH);
- panel.add(scrollPane, BorderLayout.CENTER);
+ new ListTable(new ListWrappingTableModel(exceptions, InspectionGadgetsBundle.message("exception.class.column.name")));
+ JPanel tablePanel =
+ UiUtils.createAddRemoveTreeClassChooserPanel(table, InspectionGadgetsBundle.message("choose.exception.class"), "java.lang.Throwable");
+ final CheckBox checkBox =
+ new CheckBox(InspectionGadgetsBundle.message("bad.exception.declared.ignore.exceptions.declared.in.tests.option"), this,
+ "ignoreTestCases");
+ final JComponent panel = new JPanel(new BorderLayout());
+ panel.add(tablePanel, BorderLayout.CENTER);
panel.add(checkBox, BorderLayout.SOUTH);
-
return panel;
}
diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/errorhandling/BadExceptionThrownInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/errorhandling/BadExceptionThrownInspection.java
index 059de791a131..aceb1ada64e7 100644
--- a/plugins/InspectionGadgets/src/com/siyeh/ig/errorhandling/BadExceptionThrownInspection.java
+++ b/plugins/InspectionGadgets/src/com/siyeh/ig/errorhandling/BadExceptionThrownInspection.java
@@ -17,12 +17,10 @@ package com.siyeh.ig.errorhandling;
import com.intellij.codeInspection.ui.ListTable;
import com.intellij.codeInspection.ui.ListWrappingTableModel;
-import com.intellij.openapi.actionSystem.ActionToolbar;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.PsiExpression;
import com.intellij.psi.PsiThrowStatement;
import com.intellij.psi.PsiType;
-import com.intellij.ui.ScrollPaneFactory;
import com.siyeh.InspectionGadgetsBundle;
import com.siyeh.ig.BaseInspection;
import com.siyeh.ig.BaseInspectionVisitor;
@@ -30,13 +28,7 @@ import com.siyeh.ig.ui.ExternalizableStringSet;
import com.siyeh.ig.ui.UiUtils;
import org.jetbrains.annotations.NotNull;
-import javax.swing.JComponent;
-import javax.swing.JPanel;
-import javax.swing.JScrollPane;
-import java.awt.Dimension;
-import java.awt.FontMetrics;
-import java.awt.GridBagConstraints;
-import java.awt.GridBagLayout;
+import javax.swing.*;
import java.util.List;
public class BadExceptionThrownInspection extends BaseInspection {
@@ -85,36 +77,8 @@ public class BadExceptionThrownInspection extends BaseInspection {
@Override
public JComponent createOptionsPanel() {
- final JComponent panel = new JPanel(new GridBagLayout());
-
- final ListTable table =
- new ListTable(new ListWrappingTableModel(exceptions,
- InspectionGadgetsBundle.message(
- "exception.class.column.name")));
- final JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(table);
- UiUtils.setScrollPaneSize(scrollPane, 7, 25);
- final ActionToolbar toolbar =
- UiUtils.createAddRemoveTreeClassChooserToolbar(table,
- InspectionGadgetsBundle.message(
- "choose.exception.class"),
- "java.lang.Throwable");
-
- final GridBagConstraints constraints = new GridBagConstraints();
- constraints.anchor = GridBagConstraints.FIRST_LINE_START;
- constraints.gridx = 0;
- constraints.gridy = 0;
- constraints.insets.left = 4;
- constraints.insets.right = 4;
- constraints.fill = GridBagConstraints.HORIZONTAL;
- panel.add(toolbar.getComponent(), constraints);
-
- constraints.gridy = 1;
- constraints.weightx = 1.0;
- constraints.weighty = 1.0;
- constraints.fill = GridBagConstraints.BOTH;
- panel.add(scrollPane, constraints);
-
- return panel;
+ final ListTable table = new ListTable(new ListWrappingTableModel(exceptions, InspectionGadgetsBundle.message( "exception.class.column.name")));
+ return UiUtils.createAddRemoveTreeClassChooserPanel(table, InspectionGadgetsBundle.message("choose.exception.class"), "java.lang.Throwable");
}
@Override
diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/errorhandling/NewExceptionWithoutArgumentsInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/errorhandling/NewExceptionWithoutArgumentsInspection.java
index b6453a340e03..7355df374b26 100644
--- a/plugins/InspectionGadgets/src/com/siyeh/ig/errorhandling/NewExceptionWithoutArgumentsInspection.java
+++ b/plugins/InspectionGadgets/src/com/siyeh/ig/errorhandling/NewExceptionWithoutArgumentsInspection.java
@@ -15,14 +15,22 @@
*/
package com.siyeh.ig.errorhandling;
+import com.intellij.codeInspection.ui.SingleCheckboxOptionsPanel;
import com.intellij.psi.*;
-import com.intellij.psi.search.GlobalSearchScope;
-import com.siyeh.InspectionGadgetsBundle;import com.siyeh.ig.BaseInspection;
+import com.intellij.psi.util.InheritanceUtil;
+import com.siyeh.InspectionGadgetsBundle;
+import com.siyeh.ig.BaseInspection;
import com.siyeh.ig.BaseInspectionVisitor;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NotNull;
+import javax.swing.*;
+
public class NewExceptionWithoutArgumentsInspection extends BaseInspection {
+
+ @SuppressWarnings("PublicField")
+ public boolean ignoreWithoutParameters = false;
+
@Nls
@NotNull
@Override
@@ -36,12 +44,18 @@ public class NewExceptionWithoutArgumentsInspection extends BaseInspection {
return InspectionGadgetsBundle.message("new.exception.without.arguments.problem.descriptor");
}
+ @Override
+ public JComponent createOptionsPanel() {
+ return new SingleCheckboxOptionsPanel(InspectionGadgetsBundle.message("new.exception.without.arguments.ignore.option"), this,
+ "ignoreWithoutParameters");
+ }
+
@Override
public BaseInspectionVisitor buildVisitor() {
return new NewExceptionWithoutArgumentsVisitor();
}
- private static class NewExceptionWithoutArgumentsVisitor extends BaseInspectionVisitor {
+ private class NewExceptionWithoutArgumentsVisitor extends BaseInspectionVisitor {
@Override
public void visitNewExpression(PsiNewExpression expression) {
@@ -63,16 +77,29 @@ public class NewExceptionWithoutArgumentsInspection extends BaseInspection {
return;
}
final PsiClass aClass = (PsiClass)target;
- final GlobalSearchScope resolveScope = expression.getResolveScope();
- final JavaPsiFacade psiFacade = JavaPsiFacade.getInstance(expression.getProject());
- final PsiClass exceptionClass = psiFacade.findClass(CommonClassNames.JAVA_LANG_EXCEPTION, resolveScope);
- if (exceptionClass == null) {
+ if (!InheritanceUtil.isInheritor(aClass, CommonClassNames.JAVA_LANG_EXCEPTION)) {
return;
}
- if (!aClass.isInheritor(exceptionClass, true)) {
- return;
+ if (ignoreWithoutParameters) {
+ if (!hasAccessibleConstructorWithParameters(aClass, expression)) return;
}
registerNewExpressionError(expression);
}
+
+ private boolean hasAccessibleConstructorWithParameters(PsiClass aClass, PsiElement context) {
+ final PsiMethod[] constructors = aClass.getConstructors();
+ for (PsiMethod constructor : constructors) {
+ final PsiParameterList parameterList = constructor.getParameterList();
+ final int count = parameterList.getParametersCount();
+ if (count <= 0) {
+ continue;
+ }
+ final PsiResolveHelper resolveHelper = JavaPsiFacade.getInstance(context.getProject()).getResolveHelper();
+ if (resolveHelper.isAccessible(constructor, context, aClass)) {
+ return true;
+ }
+ }
+ return false;
+ }
}
}
diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/inheritance/AbstractMethodOverridesAbstractMethodInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/inheritance/AbstractMethodOverridesAbstractMethodInspection.java
index cd1de1310380..9ef603908f9c 100644
--- a/plugins/InspectionGadgets/src/com/siyeh/ig/inheritance/AbstractMethodOverridesAbstractMethodInspection.java
+++ b/plugins/InspectionGadgets/src/com/siyeh/ig/inheritance/AbstractMethodOverridesAbstractMethodInspection.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2011 Dave Griffith, Bas Leijdekkers
+ * Copyright 2003-2012 Dave Griffith, Bas Leijdekkers
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,7 +16,7 @@
package com.siyeh.ig.inheritance;
import com.intellij.codeInspection.ProblemDescriptor;
-import com.intellij.codeInspection.ui.SingleCheckboxOptionsPanel;
+import com.intellij.codeInspection.ui.MultipleCheckboxOptionsPanel;
import com.intellij.openapi.project.Project;
import com.intellij.psi.*;
import com.intellij.psi.javadoc.PsiDocComment;
@@ -34,8 +34,12 @@ import java.util.Set;
public class AbstractMethodOverridesAbstractMethodInspection extends BaseInspection {
+ @SuppressWarnings("PublicField")
public boolean ignoreJavaDoc = false;
+ @SuppressWarnings("PublicField")
+ public boolean ignoreAnnotations = false;
+
@Override
@NotNull
public String getDisplayName() {
@@ -55,8 +59,12 @@ public class AbstractMethodOverridesAbstractMethodInspection extends BaseInspect
@Override
public JComponent createOptionsPanel() {
- return new SingleCheckboxOptionsPanel(InspectionGadgetsBundle.message(
- "abstract.method.overrides.abstract.method.ignore.different.javadoc.option"), this, "ignoreJavaDoc");
+ final MultipleCheckboxOptionsPanel panel = new MultipleCheckboxOptionsPanel(this);
+ panel.addCheckbox(InspectionGadgetsBundle.message(
+ "abstract.method.overrides.abstract.method.ignore.different.javadoc.option"), "ignoreJavaDoc");
+ panel.addCheckbox(InspectionGadgetsBundle.message(
+ "abstract.method.overrides.abstract.method.ignore.different.annotations.option"), "ignoreAnnotations");
+ return panel;
}
private static class AbstractMethodOverridesAbstractMethodFix extends InspectionGadgetsFix {
@@ -83,7 +91,6 @@ public class AbstractMethodOverridesAbstractMethodInspection extends BaseInspect
private class AbstractMethodOverridesAbstractMethodVisitor extends BaseInspectionVisitor {
-
@Override
public void visitMethod(@NotNull PsiMethod method) {
//no call to super, so we don't drill into anonymous classes
@@ -105,18 +112,61 @@ public class AbstractMethodOverridesAbstractMethodInspection extends BaseInspect
if (!isAbstract(superMethod)) {
continue;
}
- if (!methodsHaveSameReturnTypes(method, superMethod) ||
- !haveSameExceptionSignatures(method, superMethod)) {
+ if (!methodsHaveSameReturnTypes(method, superMethod) || !haveSameExceptionSignatures(method, superMethod)) {
continue;
}
if (ignoreJavaDoc && !haveSameJavaDoc(method, superMethod)) {
return;
}
+ if (ignoreAnnotations && !methodsHaveSameAnnotations(method, superMethod)) {
+ return;
+ }
registerMethodError(method);
return;
}
}
+ private boolean methodsHaveSameAnnotations(PsiMethod method, PsiMethod superMethod) {
+ if (!haveSameAnnotations(method, superMethod)) {
+ return false;
+ }
+ final PsiParameterList superParameterList = superMethod.getParameterList();
+ final PsiParameter[] superParameters = superParameterList.getParameters();
+ final PsiParameterList parameterList = method.getParameterList();
+ final PsiParameter[] parameters = parameterList.getParameters();
+ for (int i = 0, length = superParameters.length; i < length; i++) {
+ final PsiParameter superParameter = superParameters[i];
+ final PsiParameter parameter = parameters[i];
+ if (!haveSameAnnotations(parameter, superParameter)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ private boolean haveSameAnnotations(PsiModifierListOwner owner1, PsiModifierListOwner owner2) {
+ final PsiModifierList modifierList = owner1.getModifierList();
+ final PsiModifierList superModifierList = owner2.getModifierList();
+ if (superModifierList == null) {
+ return modifierList == null;
+ } else if (modifierList == null) {
+ return false;
+ }
+ final PsiAnnotation[] superAnnotations = superModifierList.getAnnotations();
+ final PsiAnnotation[] annotations = modifierList.getAnnotations();
+ final Set annotationsSet = new HashSet(Arrays.asList(superAnnotations));
+ for (PsiAnnotation annotation : annotations) {
+ final String qualifiedName = annotation.getQualifiedName();
+ if ("java.lang.Override".equals(qualifiedName)) {
+ continue;
+ }
+ if (!annotationsSet.contains(annotation)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
private boolean haveSameJavaDoc(PsiMethod method, PsiMethod superMethod) {
final PsiDocComment superDocComment = superMethod.getDocComment();
final PsiDocComment docComment = method.getDocComment();
diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/junit/TestMethodWithoutAssertionInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/junit/TestMethodWithoutAssertionInspection.java
index 65eb48a313bc..849531914a18 100644
--- a/plugins/InspectionGadgets/src/com/siyeh/ig/junit/TestMethodWithoutAssertionInspection.java
+++ b/plugins/InspectionGadgets/src/com/siyeh/ig/junit/TestMethodWithoutAssertionInspection.java
@@ -17,12 +17,10 @@ package com.siyeh.ig.junit;
import com.intellij.codeInspection.ui.ListTable;
import com.intellij.codeInspection.ui.ListWrappingTableModel;
-import com.intellij.openapi.actionSystem.ActionToolbar;
import com.intellij.openapi.util.InvalidDataException;
import com.intellij.openapi.util.WriteExternalException;
import com.intellij.psi.*;
import com.intellij.psi.util.InheritanceUtil;
-import com.intellij.ui.ScrollPaneFactory;
import com.intellij.util.ui.CheckBox;
import com.siyeh.InspectionGadgetsBundle;
import com.siyeh.ig.BaseInspection;
@@ -84,37 +82,15 @@ public class TestMethodWithoutAssertionInspection extends BaseInspection {
@Override
public JComponent createOptionsPanel() {
- final JPanel panel = new JPanel(new GridBagLayout());
- final ListTable table = new ListTable(new ListWrappingTableModel(
- Arrays.asList(classNames, methodNamePatterns),
- InspectionGadgetsBundle.message("class.name"),
- InspectionGadgetsBundle.message("method.name.pattern")));
- final JScrollPane scrollPane =
- ScrollPaneFactory.createScrollPane(table);
- UiUtils.setScrollPaneSize(scrollPane, 7, 25);
- final ActionToolbar toolbar =
- UiUtils.createAddRemoveToolbar(table);
-
- final CheckBox checkBox = new CheckBox(InspectionGadgetsBundle.message(
- "assert.keyword.is.considered.an.assertion"), this,
- "assertKeywordIsAssertion");
-
- final GridBagConstraints constraints = new GridBagConstraints();
- constraints.gridx = 0;
- constraints.gridy = 0;
- constraints.fill = GridBagConstraints.HORIZONTAL;
- panel.add(toolbar.getComponent(), constraints);
-
- constraints.gridx = 0;
- constraints.gridy = 1;
- constraints.weightx = 1.0;
- constraints.weighty = 1.0;
- constraints.fill = GridBagConstraints.BOTH;
- panel.add(scrollPane, constraints);
-
- constraints.gridy = 2;
- constraints.weighty = 0.0;
- panel.add(checkBox, constraints);
+ final JPanel panel = new JPanel(new BorderLayout());
+ final ListTable table = new ListTable(
+ new ListWrappingTableModel(Arrays.asList(classNames, methodNamePatterns), InspectionGadgetsBundle.message("class.name"),
+ InspectionGadgetsBundle.message("method.name.pattern")));
+ final JPanel tablePanel = UiUtils.createAddRemovePanel(table);
+ final CheckBox checkBox =
+ new CheckBox(InspectionGadgetsBundle.message("assert.keyword.is.considered.an.assertion"), this, "assertKeywordIsAssertion");
+ panel.add(tablePanel, BorderLayout.CENTER);
+ panel.add(checkBox, BorderLayout.SOUTH);
return panel;
}
diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/logging/ClassWithMultipleLoggersInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/logging/ClassWithMultipleLoggersInspection.java
index 0ea7e17054aa..893d77f20b57 100644
--- a/plugins/InspectionGadgets/src/com/siyeh/ig/logging/ClassWithMultipleLoggersInspection.java
+++ b/plugins/InspectionGadgets/src/com/siyeh/ig/logging/ClassWithMultipleLoggersInspection.java
@@ -17,11 +17,9 @@ package com.siyeh.ig.logging;
import com.intellij.codeInspection.ui.ListTable;
import com.intellij.codeInspection.ui.ListWrappingTableModel;
-import com.intellij.openapi.actionSystem.ActionToolbar;
import com.intellij.openapi.util.InvalidDataException;
import com.intellij.openapi.util.WriteExternalException;
import com.intellij.psi.*;
-import com.intellij.ui.ScrollPaneFactory;
import com.siyeh.InspectionGadgetsBundle;
import com.siyeh.ig.BaseInspection;
import com.siyeh.ig.BaseInspectionVisitor;
@@ -31,7 +29,6 @@ import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
-import java.awt.*;
import java.util.ArrayList;
import java.util.List;
@@ -78,32 +75,8 @@ public class ClassWithMultipleLoggersInspection extends BaseInspection {
@Override
public JComponent createOptionsPanel() {
- final JComponent panel = new JPanel(new GridBagLayout());
-
- final ListTable table =
- new ListTable(new ListWrappingTableModel(loggerNames,
- InspectionGadgetsBundle.message("logger.class.names")));
- final JScrollPane scrollPane =
- ScrollPaneFactory.createScrollPane(table);
- UiUtils.setScrollPaneSize(scrollPane, 7, 25);
- final ActionToolbar toolbar =
- UiUtils.createAddRemoveTreeClassChooserToolbar(table,
- InspectionGadgetsBundle.message("choose.logger.class"));
-
- final GridBagConstraints constraints = new GridBagConstraints();
- constraints.gridx = 0;
- constraints.gridy = 0;
- constraints.insets.left = 4;
- constraints.insets.right = 4;
- constraints.fill = GridBagConstraints.HORIZONTAL;
- panel.add(toolbar.getComponent(), constraints);
-
- constraints.gridy = 1;
- constraints.weightx = 1.0;
- constraints.weighty = 1.0;
- constraints.fill = GridBagConstraints.BOTH;
- panel.add(scrollPane, constraints);
- return panel;
+ final ListTable table = new ListTable(new ListWrappingTableModel(loggerNames, InspectionGadgetsBundle.message("logger.class.names")));
+ return UiUtils.createAddRemoveTreeClassChooserPanel(table, InspectionGadgetsBundle.message("choose.logger.class"));
}
@Override
diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/logging/ClassWithoutLoggerInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/logging/ClassWithoutLoggerInspection.java
index d72c0668981c..751dd8ae30d0 100644
--- a/plugins/InspectionGadgets/src/com/siyeh/ig/logging/ClassWithoutLoggerInspection.java
+++ b/plugins/InspectionGadgets/src/com/siyeh/ig/logging/ClassWithoutLoggerInspection.java
@@ -17,12 +17,10 @@ package com.siyeh.ig.logging;
import com.intellij.codeInspection.ui.ListTable;
import com.intellij.codeInspection.ui.ListWrappingTableModel;
-import com.intellij.openapi.actionSystem.ActionToolbar;
import com.intellij.openapi.util.InvalidDataException;
import com.intellij.openapi.util.WriteExternalException;
import com.intellij.psi.*;
import com.intellij.psi.util.PsiUtil;
-import com.intellij.ui.ScrollPaneFactory;
import com.intellij.util.ui.CheckBox;
import com.siyeh.InspectionGadgetsBundle;
import com.siyeh.ig.BaseInspection;
@@ -84,39 +82,12 @@ public class ClassWithoutLoggerInspection extends BaseInspection {
@Override
public JComponent createOptionsPanel() {
- final JComponent panel = new JPanel(new GridBagLayout());
-
- final ListTable table =
- new ListTable(new ListWrappingTableModel(loggerNames,
- InspectionGadgetsBundle.message("logger.class.names")));
- final JScrollPane scrollPane =
- ScrollPaneFactory.createScrollPane(table);
- UiUtils.setScrollPaneSize(scrollPane, 7, 25);
- final ActionToolbar toolbar =
- UiUtils.createAddRemoveTreeClassChooserToolbar(table,
- InspectionGadgetsBundle.message("choose.logger.class"));
-
- final GridBagConstraints constraints = new GridBagConstraints();
- constraints.gridx = 0;
- constraints.gridy = 0;
- constraints.insets.left = 4;
- constraints.insets.right = 4;
- constraints.fill = GridBagConstraints.HORIZONTAL;
- panel.add(toolbar.getComponent(), constraints);
-
- constraints.gridy = 1;
- constraints.weightx = 1.0;
- constraints.weighty = 1.0;
- constraints.fill = GridBagConstraints.BOTH;
- panel.add(scrollPane, constraints);
-
- final CheckBox checkBox = new CheckBox(
- InspectionGadgetsBundle.message("super.class.logger.option"),
- this, "ignoreSuperLoggers");
- constraints.gridy = 2;
- constraints.weighty = 0.0;
- constraints.fill = GridBagConstraints.HORIZONTAL;
- panel.add(checkBox, constraints);
+ final JComponent panel = new JPanel(new BorderLayout());
+ final ListTable table = new ListTable(new ListWrappingTableModel(loggerNames, InspectionGadgetsBundle.message("logger.class.names")));
+ final JPanel tablePanel = UiUtils.createAddRemoveTreeClassChooserPanel(table, InspectionGadgetsBundle.message("choose.logger.class"));
+ final CheckBox checkBox = new CheckBox(InspectionGadgetsBundle.message("super.class.logger.option"), this, "ignoreSuperLoggers");
+ panel.add(tablePanel, BorderLayout.CENTER);
+ panel.add(checkBox, BorderLayout.SOUTH);
return panel;
}
diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/logging/LogStatementGuardedByLogConditionInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/logging/LogStatementGuardedByLogConditionInspection.java
index 38fcd9c0f80f..ddf001bde062 100644
--- a/plugins/InspectionGadgets/src/com/siyeh/ig/logging/LogStatementGuardedByLogConditionInspection.java
+++ b/plugins/InspectionGadgets/src/com/siyeh/ig/logging/LogStatementGuardedByLogConditionInspection.java
@@ -18,7 +18,6 @@ package com.siyeh.ig.logging;
import com.intellij.codeInspection.ProblemDescriptor;
import com.intellij.codeInspection.ui.ListTable;
import com.intellij.codeInspection.ui.ListWrappingTableModel;
-import com.intellij.openapi.actionSystem.ActionToolbar;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.InvalidDataException;
import com.intellij.openapi.util.WriteExternalException;
@@ -26,8 +25,8 @@ import com.intellij.psi.*;
import com.intellij.psi.codeStyle.JavaCodeStyleManager;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.util.PsiUtil;
-import com.intellij.ui.ScrollPaneFactory;
import com.intellij.util.IncorrectOperationException;
+import com.intellij.util.ui.FormBuilder;
import com.siyeh.InspectionGadgetsBundle;
import com.siyeh.ig.BaseInspection;
import com.siyeh.ig.BaseInspectionVisitor;
@@ -80,47 +79,16 @@ public class LogStatementGuardedByLogConditionInspection
@Override
public JComponent createOptionsPanel() {
- final GridBagLayout layout = new GridBagLayout();
- final JPanel panel = new JPanel(layout);
-
- final JLabel classNameLabel = new JLabel(
- InspectionGadgetsBundle.message("logger.name.option"));
+ final JPanel panel = new JPanel(new BorderLayout());
+ final JLabel classNameLabel = new JLabel(InspectionGadgetsBundle.message("logger.name.option"));
classNameLabel.setHorizontalAlignment(SwingConstants.TRAILING);
- final TextField loggerClassNameField =
- new TextField(this, "loggerClassName");
- final ListTable table = new ListTable(new ListWrappingTableModel(
- Arrays.asList(logMethodNameList, logConditionMethodNameList),
- InspectionGadgetsBundle.message("log.method.name"),
- InspectionGadgetsBundle.message("log.condition.text")));
- final JScrollPane scrollPane =
- ScrollPaneFactory.createScrollPane(table);
- UiUtils.setScrollPaneSize(scrollPane, 7, 25);
- final ActionToolbar toolbar = UiUtils.createAddRemoveToolbar(table);
-
- final GridBagConstraints constraints = new GridBagConstraints();
- constraints.gridx = 0;
- constraints.gridy = 2;
- constraints.ipady = 10;
-
- constraints.anchor = GridBagConstraints.NORTHEAST;
- panel.add(classNameLabel, constraints);
-
- constraints.gridx = 1;
- constraints.ipady = 0;
- constraints.weightx = 1.0;
- constraints.fill = GridBagConstraints.HORIZONTAL;
- panel.add(loggerClassNameField, constraints);
-
- constraints.gridwidth = 2;
- constraints.gridx = 0;
- constraints.gridy = 0;
- panel.add(toolbar.getComponent(), constraints);
-
- constraints.weighty = 1.0;
- constraints.gridy = 1;
- constraints.fill = GridBagConstraints.BOTH;
- panel.add(scrollPane, constraints);
-
+ final TextField loggerClassNameField = new TextField(this, "loggerClassName");
+ final ListTable table = new ListTable(new ListWrappingTableModel(Arrays.asList(logMethodNameList, logConditionMethodNameList),
+ InspectionGadgetsBundle.message("log.method.name"),
+ InspectionGadgetsBundle.message("log.condition.text")));
+ final JPanel tablePanel = UiUtils.createAddRemovePanel(table);
+ panel.add(tablePanel, BorderLayout.CENTER);
+ panel.add(FormBuilder.createFormBuilder().addLabeledComponent(classNameLabel, loggerClassNameField).getPanel(), BorderLayout.NORTH);
return panel;
}
diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/naming/BooleanMethodNameMustStartWithQuestionInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/naming/BooleanMethodNameMustStartWithQuestionInspection.java
index f55151b46390..b4d9ac91e14b 100644
--- a/plugins/InspectionGadgets/src/com/siyeh/ig/naming/BooleanMethodNameMustStartWithQuestionInspection.java
+++ b/plugins/InspectionGadgets/src/com/siyeh/ig/naming/BooleanMethodNameMustStartWithQuestionInspection.java
@@ -17,7 +17,6 @@ package com.siyeh.ig.naming;
import com.intellij.codeInspection.ui.ListTable;
import com.intellij.codeInspection.ui.ListWrappingTableModel;
-import com.intellij.openapi.actionSystem.ActionToolbar;
import com.intellij.openapi.util.InvalidDataException;
import com.intellij.openapi.util.WriteExternalException;
import com.intellij.psi.CommonClassNames;
@@ -26,7 +25,6 @@ import com.intellij.psi.PsiMethod;
import com.intellij.psi.PsiType;
import com.intellij.psi.search.searches.SuperMethodsSearch;
import com.intellij.psi.util.MethodSignatureBackedByPsiMethod;
-import com.intellij.ui.ScrollPaneFactory;
import com.intellij.util.Query;
import com.intellij.util.ui.CheckBox;
import com.siyeh.InspectionGadgetsBundle;
@@ -99,48 +97,32 @@ public class BooleanMethodNameMustStartWithQuestionInspection
@Override
public JComponent createOptionsPanel() {
final JPanel panel = new JPanel(new GridBagLayout());
- final ListTable table =
- new ListTable(new ListWrappingTableModel(questionList,
- InspectionGadgetsBundle.message(
- "boolean.method.name.must.start.with.question.table.column.name")));
- final JScrollPane scrollPane =
- ScrollPaneFactory.createScrollPane(table);
- UiUtils.setScrollPaneSize(scrollPane, 7, 25);
- final ActionToolbar toolbar =
- UiUtils.createAddRemoveToolbar(table);
+ final ListTable table = new ListTable(new ListWrappingTableModel(questionList, InspectionGadgetsBundle
+ .message("boolean.method.name.must.start.with.question.table.column.name")));
+ final JPanel tablePanel = UiUtils.createAddRemovePanel(table);
final GridBagConstraints constraints = new GridBagConstraints();
constraints.gridx = 0;
constraints.gridy = 0;
- constraints.fill = GridBagConstraints.HORIZONTAL;
- panel.add(toolbar.getComponent(), constraints);
-
- constraints.gridy = 1;
constraints.weightx = 1.0;
constraints.weighty = 1.0;
constraints.fill = GridBagConstraints.BOTH;
- panel.add(scrollPane, constraints);
+ panel.add(tablePanel, constraints);
final CheckBox checkBox1 =
- new CheckBox(InspectionGadgetsBundle.message(
- "ignore.methods.with.boolean.return.type.option"),
- this, "ignoreBooleanMethods");
- constraints.gridy = 2;
+ new CheckBox(InspectionGadgetsBundle.message("ignore.methods.with.boolean.return.type.option"), this, "ignoreBooleanMethods");
+ constraints.gridy = 1;
constraints.weighty = 0.0;
panel.add(checkBox1, constraints);
final CheckBox checkBox2 =
- new CheckBox(InspectionGadgetsBundle.message(
- "ignore.boolean.methods.in.an.interface.option"),
- this, "ignoreInAnnotationInterface");
- constraints.gridy = 3;
+ new CheckBox(InspectionGadgetsBundle.message("ignore.boolean.methods.in.an.interface.option"), this, "ignoreInAnnotationInterface");
+ constraints.gridy = 2;
panel.add(checkBox2, constraints);
final CheckBox checkBox3 =
- new CheckBox(InspectionGadgetsBundle.message(
- "ignore.methods.overriding.super.method"),
- this, "onlyWarnOnBaseMethods");
- constraints.gridy = 4;
+ new CheckBox(InspectionGadgetsBundle.message("ignore.methods.overriding.super.method"), this, "onlyWarnOnBaseMethods");
+ constraints.gridy = 3;
panel.add(checkBox3, constraints);
return panel;
}
diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/naming/NonBooleanMethodNameMayNotStartWithQuestionInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/naming/NonBooleanMethodNameMayNotStartWithQuestionInspection.java
index 22031e3470a5..7744a4f72d15 100644
--- a/plugins/InspectionGadgets/src/com/siyeh/ig/naming/NonBooleanMethodNameMayNotStartWithQuestionInspection.java
+++ b/plugins/InspectionGadgets/src/com/siyeh/ig/naming/NonBooleanMethodNameMayNotStartWithQuestionInspection.java
@@ -17,7 +17,6 @@ package com.siyeh.ig.naming;
import com.intellij.codeInspection.ui.ListTable;
import com.intellij.codeInspection.ui.ListWrappingTableModel;
-import com.intellij.openapi.actionSystem.ActionToolbar;
import com.intellij.openapi.util.InvalidDataException;
import com.intellij.openapi.util.WriteExternalException;
import com.intellij.psi.CommonClassNames;
@@ -25,9 +24,9 @@ import com.intellij.psi.PsiMethod;
import com.intellij.psi.PsiType;
import com.intellij.psi.search.searches.SuperMethodsSearch;
import com.intellij.psi.util.MethodSignatureBackedByPsiMethod;
-import com.intellij.ui.ScrollPaneFactory;
import com.intellij.util.Query;
import com.intellij.util.ui.CheckBox;
+import com.intellij.util.ui.FormBuilder;
import com.siyeh.InspectionGadgetsBundle;
import com.siyeh.ig.BaseInspection;
import com.siyeh.ig.BaseInspectionVisitor;
@@ -94,42 +93,18 @@ public class NonBooleanMethodNameMayNotStartWithQuestionInspection
@Override
public JComponent createOptionsPanel() {
- final JPanel panel = new JPanel(new GridBagLayout());
- final ListTable table =
- new ListTable(new ListWrappingTableModel(questionList,
- InspectionGadgetsBundle.message(
- "boolean.method.name.must.start.with.question.table.column.name")));
- final JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(table);
- UiUtils.setScrollPaneSize(scrollPane, 7, 25);
-
- final ActionToolbar toolbar =
- UiUtils.createAddRemoveToolbar(table);
- final GridBagConstraints constraints = new GridBagConstraints();
- constraints.gridx = 0;
- constraints.gridy = 0;
- constraints.fill = GridBagConstraints.HORIZONTAL;
- panel.add(toolbar.getComponent(), constraints);
-
- constraints.gridy = 1;
- constraints.weightx = 1.0;
- constraints.weighty = 1.0;
- constraints.fill = GridBagConstraints.BOTH;
- panel.add(scrollPane, constraints);
+ final JPanel panel = new JPanel(new BorderLayout());
+ final ListTable table = new ListTable(new ListWrappingTableModel(questionList, InspectionGadgetsBundle
+ .message("boolean.method.name.must.start.with.question.table.column.name")));
+ final JPanel tablePanel = UiUtils.createAddRemovePanel(table);
final CheckBox checkBox1 =
- new CheckBox(InspectionGadgetsBundle.message(
- "ignore.methods.with.boolean.return.type.option"),
- this, "ignoreBooleanMethods");
- constraints.gridy = 2;
- constraints.weighty = 0.0;
- panel.add(checkBox1, constraints);
-
+ new CheckBox(InspectionGadgetsBundle.message("ignore.methods.with.boolean.return.type.option"), this, "ignoreBooleanMethods");
final CheckBox checkBox2 =
- new CheckBox(InspectionGadgetsBundle.message(
- "ignore.methods.overriding.super.method"),
- this, "onlyWarnOnBaseMethods");
- constraints.gridy = 3;
- panel.add(checkBox2, constraints);
+ new CheckBox(InspectionGadgetsBundle.message("ignore.methods.overriding.super.method"), this, "onlyWarnOnBaseMethods");
+
+ panel.add(tablePanel, BorderLayout.CENTER);
+ panel.add(FormBuilder.createFormBuilder().addComponent(checkBox1).addComponent(checkBox2).getPanel(), BorderLayout.SOUTH);
return panel;
}
diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/naming/QuestionableNameInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/naming/QuestionableNameInspection.java
index 08011bf76880..72e4d4e119bc 100644
--- a/plugins/InspectionGadgets/src/com/siyeh/ig/naming/QuestionableNameInspection.java
+++ b/plugins/InspectionGadgets/src/com/siyeh/ig/naming/QuestionableNameInspection.java
@@ -17,13 +17,11 @@ package com.siyeh.ig.naming;
import com.intellij.codeInspection.ui.ListTable;
import com.intellij.codeInspection.ui.ListWrappingTableModel;
-import com.intellij.openapi.actionSystem.ActionToolbar;
import com.intellij.openapi.util.InvalidDataException;
import com.intellij.openapi.util.WriteExternalException;
import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiMethod;
import com.intellij.psi.PsiVariable;
-import com.intellij.ui.ScrollPaneFactory;
import com.siyeh.InspectionGadgetsBundle;
import com.siyeh.ig.BaseInspection;
import com.siyeh.ig.BaseInspectionVisitor;
@@ -35,7 +33,6 @@ import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
-import java.awt.*;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
@@ -86,29 +83,9 @@ public class QuestionableNameInspection extends BaseInspection {
@Override
public JComponent createOptionsPanel() {
- final JPanel panel = new JPanel(new GridBagLayout());
- final ListTable table = new ListTable(new ListWrappingTableModel(
- nameList, InspectionGadgetsBundle.message(
- "questionable.name.column.title")));
- final JScrollPane scrollPane =
- ScrollPaneFactory.createScrollPane(table);
- UiUtils.setScrollPaneSize(scrollPane, 7, 25);
- final ActionToolbar toolbar =
- UiUtils.createAddRemoveToolbar(table);
-
- final GridBagConstraints constraints = new GridBagConstraints();
- constraints.gridx = 0;
- constraints.gridy = 0;
- constraints.fill = GridBagConstraints.HORIZONTAL;
- panel.add(toolbar.getComponent(), constraints);
-
- constraints.gridy = 1;
- constraints.weightx = 1.0;
- constraints.weighty = 1.0;
- constraints.fill = GridBagConstraints.BOTH;
- panel.add(scrollPane, constraints);
-
- return panel;
+ final ListTable table =
+ new ListTable(new ListWrappingTableModel(nameList, InspectionGadgetsBundle.message("questionable.name.column.title")));
+ return UiUtils.createAddRemovePanel(table);
}
@Override
diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/resources/IOResourceInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/resources/IOResourceInspection.java
index 0374d38a3397..136cb5fdb86d 100644
--- a/plugins/InspectionGadgets/src/com/siyeh/ig/resources/IOResourceInspection.java
+++ b/plugins/InspectionGadgets/src/com/siyeh/ig/resources/IOResourceInspection.java
@@ -17,12 +17,10 @@ package com.siyeh.ig.resources;
import com.intellij.codeInspection.ui.ListTable;
import com.intellij.codeInspection.ui.ListWrappingTableModel;
-import com.intellij.openapi.actionSystem.ActionToolbar;
import com.intellij.openapi.util.InvalidDataException;
import com.intellij.openapi.util.WriteExternalException;
import com.intellij.psi.*;
import com.intellij.psi.util.PsiTreeUtil;
-import com.intellij.ui.ScrollPaneFactory;
import com.intellij.util.ui.CheckBox;
import com.siyeh.InspectionGadgetsBundle;
import com.siyeh.ig.BaseInspectionVisitor;
@@ -88,44 +86,15 @@ public class IOResourceInspection extends ResourceInspection {
@Override
public JComponent createOptionsPanel() {
- final JComponent panel = new JPanel(new GridBagLayout());
-
+ final JComponent panel = new JPanel(new BorderLayout());
final ListTable table =
- new ListTable(new ListWrappingTableModel(ignoredTypes,
- InspectionGadgetsBundle.message(
- "ignored.io.resource.types")));
- final JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(table);
- UiUtils.setScrollPaneSize(scrollPane, 7, 25);
- final ActionToolbar toolbar =
- UiUtils.createAddRemoveTreeClassChooserToolbar(table,
- InspectionGadgetsBundle.message(
- "choose.io.resource.type.to.ignore"), IO_TYPES);
-
- final CheckBox checkBox = new CheckBox(
- InspectionGadgetsBundle.message(
- "allow.resource.to.be.opened.inside.a.try.block"),
- this, "insideTryAllowed");
-
- final GridBagConstraints constraints = new GridBagConstraints();
- constraints.anchor = GridBagConstraints.FIRST_LINE_START;
- constraints.gridx = 0;
- constraints.gridy = 0;
- constraints.insets.left = 4;
- constraints.insets.right = 4;
- constraints.fill = GridBagConstraints.HORIZONTAL;
- panel.add(toolbar.getComponent(), constraints);
-
- constraints.gridy = 1;
- constraints.weightx = 1.0;
- constraints.weighty = 1.0;
- constraints.fill = GridBagConstraints.BOTH;
- panel.add(scrollPane, constraints);
-
- constraints.gridy = 2;
- constraints.weighty = 0.0;
- constraints.fill = GridBagConstraints.HORIZONTAL;
- panel.add(checkBox, constraints);
-
+ new ListTable(new ListWrappingTableModel(ignoredTypes, InspectionGadgetsBundle.message("ignored.io.resource.types")));
+ JPanel tablePanel =
+ UiUtils.createAddRemoveTreeClassChooserPanel(table, InspectionGadgetsBundle.message("choose.io.resource.type.to.ignore"), IO_TYPES);
+ final CheckBox checkBox =
+ new CheckBox(InspectionGadgetsBundle.message("allow.resource.to.be.opened.inside.a.try.block"), this, "insideTryAllowed");
+ panel.add(tablePanel, BorderLayout.CENTER);
+ panel.add(checkBox, BorderLayout.SOUTH);
return panel;
}
@@ -148,7 +117,8 @@ public class IOResourceInspection extends ResourceInspection {
private class IOResourceVisitor extends BaseInspectionVisitor {
- IOResourceVisitor() {}
+ IOResourceVisitor() {
+ }
@Override
public void visitMethodCallExpression(@NotNull PsiMethodCallExpression expression) {
diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/ui/UiUtils.java b/plugins/InspectionGadgets/src/com/siyeh/ig/ui/UiUtils.java
index a1d89f8d2f04..fb7b8dab1738 100644
--- a/plugins/InspectionGadgets/src/com/siyeh/ig/ui/UiUtils.java
+++ b/plugins/InspectionGadgets/src/com/siyeh/ig/ui/UiUtils.java
@@ -21,17 +21,15 @@ import com.intellij.ide.DataManager;
import com.intellij.ide.util.ClassFilter;
import com.intellij.ide.util.TreeClassChooser;
import com.intellij.ide.util.TreeClassChooserFactory;
-import com.intellij.openapi.actionSystem.*;
+import com.intellij.openapi.actionSystem.DataContext;
+import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiClass;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.util.InheritanceUtil;
import com.intellij.ui.*;
import com.intellij.ui.components.JBList;
-import com.intellij.util.PlatformIcons;
-import com.siyeh.InspectionGadgetsBundle;
import org.jetbrains.annotations.NonNls;
-import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import javax.swing.table.TableCellEditor;
@@ -40,7 +38,8 @@ import java.util.Collection;
public class UiUtils {
- private UiUtils() {}
+ private UiUtils() {
+ }
public static void setScrollPaneSize(JScrollPane scrollPane, int rows, int columns) {
final Component view = scrollPane.getViewport().getView();
@@ -55,19 +54,35 @@ public class UiUtils {
component.setPreferredSize(new Dimension(width, fontMetrics.getHeight() * rows));
}
- public static ActionToolbar createAddRemoveToolbar(ListTable table) {
- final AnAction addAction = new AddAction(table);
- final AnAction removeAction = new RemoveAction(table);
- final ActionGroup group =
- new DefaultActionGroup(addAction, removeAction);
- final ActionManager actionManager = ActionManager.getInstance();
- return actionManager.createActionToolbar(ActionPlaces.UNKNOWN,
- group, true);
+ public static JPanel createAddRemovePanel(final ListTable table) {
+ return ToolbarDecorator.createDecorator(table)
+ .setAddAction(new AnActionButtonRunnable() {
+ @Override
+ public void run(AnActionButton button) {
+ final ListWrappingTableModel tableModel = table.getModel();
+ tableModel.addRow();
+ EventQueue.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ final int lastRowIndex = tableModel.getRowCount() - 1;
+ final Rectangle rectangle = table.getCellRect(lastRowIndex, 0, true);
+ table.scrollRectToVisible(rectangle);
+ table.editCellAt(lastRowIndex, 0);
+ final ListSelectionModel selectionModel = table.getSelectionModel();
+ selectionModel.setSelectionInterval(lastRowIndex, lastRowIndex);
+ final TableCellEditor editor = table.getCellEditor();
+ final Component component = editor.getTableCellEditorComponent(table, null, true, lastRowIndex, 0);
+ component.requestFocus();
+ }
+ });
+ }
+ }).setRemoveAction(new RemoveAction(table))
+ .disableUpDownActions().createPanel();
}
- public static ActionToolbar createAddRemoveTreeClassChooserToolbar(
- ListTable table, String chooserTitle,
- @NonNls String... ancestorClasses) {
+ public static JPanel createAddRemoveTreeClassChooserPanel(final ListTable table,
+ final String chooserTitle,
+ @NonNls String... ancestorClasses) {
final ClassFilter filter;
if (ancestorClasses.length == 0) {
filter = ClassFilter.ALL;
@@ -75,19 +90,53 @@ public class UiUtils {
else {
filter = new SubclassFilter(ancestorClasses);
}
- final AnAction addAction = new TreeClassChooserAction(table,
- chooserTitle, filter);
- final AnAction removeAction = new RemoveAction(table);
- final ActionGroup group =
- new DefaultActionGroup(addAction, removeAction);
- final ActionManager actionManager = ActionManager.getInstance();
- return actionManager.createActionToolbar(ActionPlaces.UNKNOWN,
- group, true);
+ return ToolbarDecorator.createDecorator(table)
+ .setAddAction(new AnActionButtonRunnable() {
+ @Override
+ public void run(AnActionButton button) {
+ final DataContext dataContext = DataManager.getInstance().getDataContext(table);
+ final Project project = PlatformDataKeys.PROJECT.getData(dataContext);
+ if (project == null) {
+ return;
+ }
+ final TreeClassChooserFactory chooserFactory = TreeClassChooserFactory.getInstance(project);
+ final TreeClassChooser classChooser =
+ chooserFactory.createWithInnerClassesScopeChooser(chooserTitle, GlobalSearchScope.allScope(project), filter, null);
+ classChooser.showDialog();
+ final PsiClass selectedClass = classChooser.getSelected();
+ if (selectedClass == null) {
+ return;
+ }
+ final String qualifiedName = selectedClass.getQualifiedName();
+ final ListWrappingTableModel tableModel = table.getModel();
+ final int index = tableModel.indexOf(qualifiedName, 0);
+ final int rowIndex;
+ if (index < 0) {
+ tableModel.addRow(qualifiedName);
+ rowIndex = tableModel.getRowCount() - 1;
+ }
+ else {
+ rowIndex = index;
+ }
+ final ListSelectionModel selectionModel =
+ table.getSelectionModel();
+ selectionModel.setSelectionInterval(rowIndex, rowIndex);
+ EventQueue.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ final Rectangle rectangle = table.getCellRect(rowIndex, 0, true);
+ table.scrollRectToVisible(rectangle);
+ }
+ });
+ }
+ }).setRemoveAction(new RemoveAction(table))
+ .disableUpDownActions().createPanel();
}
- public static JPanel createTreeClassChooserList(
- final Collection collection, String borderTitle,
- final String chooserTitle, String... ancestorClasses) {
+ public static JPanel createTreeClassChooserList(final Collection collection,
+ String borderTitle,
+ final String chooserTitle,
+ String... ancestorClasses) {
final ClassFilter filter;
if (ancestorClasses.length == 0) {
filter = ClassFilter.ALL;
@@ -103,26 +152,20 @@ public class UiUtils {
.setAddAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton anActionButton) {
- final DataContext dataContext =
- DataManager.getInstance().getDataContext(list);
- final Project project =
- DataKeys.PROJECT.getData(dataContext);
+ final DataContext dataContext = DataManager.getInstance().getDataContext(list);
+ final Project project = PlatformDataKeys.PROJECT.getData(dataContext);
if (project == null) {
return;
}
- final TreeClassChooser chooser =
- TreeClassChooserFactory.getInstance(project)
- .createNoInnerClassesScopeChooser(chooserTitle,
- GlobalSearchScope.allScope(project),
- filter, null);
+ final TreeClassChooser chooser = TreeClassChooserFactory.getInstance(project)
+ .createNoInnerClassesScopeChooser(chooserTitle, GlobalSearchScope.allScope(project), filter, null);
chooser.showDialog();
final PsiClass selected = chooser.getSelected();
if (selected == null) {
return;
}
final String qualifiedName = selected.getQualifiedName();
- final DefaultListModel model =
- (DefaultListModel)list.getModel();
+ final DefaultListModel model = (DefaultListModel)list.getModel();
final int index = model.indexOf(qualifiedName);
if (index < 0) {
model.addElement(qualifiedName);
@@ -147,112 +190,16 @@ public class UiUtils {
return optionsPanel;
}
- private static class TreeClassChooserAction extends AnAction {
-
- private final ListTable table;
- private final String chooserTitle;
- private final ClassFilter myFilter;
-
- public TreeClassChooserAction(
- @NotNull ListTable table, @NotNull String chooserTitle,
- @NotNull ClassFilter filter) {
- super(InspectionGadgetsBundle.message("button.add"), "",
- PlatformIcons.ADD_ICON);
- this.table = table;
- this.chooserTitle = chooserTitle;
- this.myFilter = filter;
- }
-
- @Override
- public void actionPerformed(AnActionEvent e) {
- final DataContext dataContext = e.getDataContext();
- final Project project = DataKeys.PROJECT.getData(dataContext);
- if (project == null) {
- return;
- }
- final TreeClassChooserFactory chooserFactory =
- TreeClassChooserFactory.getInstance(project);
- final TreeClassChooser classChooser =
- chooserFactory.createWithInnerClassesScopeChooser(chooserTitle,
- GlobalSearchScope.allScope(project), myFilter, null);
- classChooser.showDialog();
- final PsiClass selectedClass = classChooser.getSelected();
- if (selectedClass == null) {
- return;
- }
- final String qualifiedName = selectedClass.getQualifiedName();
- final ListWrappingTableModel tableModel = table.getModel();
- final int index = tableModel.indexOf(qualifiedName, 0);
- final int rowIndex;
- if (index < 0) {
- tableModel.addRow(qualifiedName);
- rowIndex = tableModel.getRowCount() - 1;
- }
- else {
- rowIndex = index;
- }
- final ListSelectionModel selectionModel =
- table.getSelectionModel();
- selectionModel.setSelectionInterval(rowIndex, rowIndex);
- EventQueue.invokeLater(new Runnable() {
- @Override
- public void run() {
- final Rectangle rectangle =
- table.getCellRect(rowIndex, 0, true);
- table.scrollRectToVisible(rectangle);
- }
- });
- }
- }
-
- private static class AddAction extends AnAction {
-
- private final ListTable table;
-
- public AddAction(ListTable table) {
- super(InspectionGadgetsBundle.message("button.add"), "",
- PlatformIcons.ADD_ICON);
- this.table = table;
- }
-
- @Override
- public void actionPerformed(AnActionEvent anActionEvent) {
- final ListWrappingTableModel tableModel = table.getModel();
- tableModel.addRow();
- EventQueue.invokeLater(new Runnable() {
- @Override
- public void run() {
- final int lastRowIndex = tableModel.getRowCount() - 1;
- final Rectangle rectangle =
- table.getCellRect(lastRowIndex, 0, true);
- table.scrollRectToVisible(rectangle);
- table.editCellAt(lastRowIndex, 0);
- final ListSelectionModel selectionModel =
- table.getSelectionModel();
- selectionModel.setSelectionInterval(lastRowIndex,
- lastRowIndex);
- final TableCellEditor editor = table.getCellEditor();
- final Component component =
- editor.getTableCellEditorComponent(table,
- null, true, lastRowIndex, 0);
- component.requestFocus();
- }
- });
- }
- }
-
- private static class RemoveAction extends AnAction {
+ private static class RemoveAction implements AnActionButtonRunnable {
private final ListTable table;
public RemoveAction(ListTable table) {
- super(InspectionGadgetsBundle.message("button.remove"), "",
- PlatformIcons.DELETE_ICON);
this.table = table;
}
@Override
- public void actionPerformed(AnActionEvent anActionEvent) {
+ public void run(AnActionButton button) {
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
@@ -260,8 +207,7 @@ public class UiUtils {
if (editor != null) {
editor.stopCellEditing();
}
- final ListSelectionModel selectionModel =
- table.getSelectionModel();
+ final ListSelectionModel selectionModel = table.getSelectionModel();
final int minIndex = selectionModel.getMinSelectionIndex();
final int maxIndex = selectionModel.getMaxSelectionIndex();
if (minIndex == -1 || maxIndex == -1) {
@@ -275,8 +221,7 @@ public class UiUtils {
}
final int count = tableModel.getRowCount();
if (count <= minIndex) {
- selectionModel.setSelectionInterval(count - 1,
- count - 1);
+ selectionModel.setSelectionInterval(count - 1, count - 1);
}
else if (minIndex <= 0) {
if (count > 0) {
@@ -284,27 +229,7 @@ public class UiUtils {
}
}
else {
- selectionModel.setSelectionInterval(minIndex - 1,
- minIndex - 1);
- }
- }
- });
- }
-
- @Override
- public void update(final AnActionEvent e) {
- EventQueue.invokeLater(new Runnable() {
- @Override
- public void run() {
- final ListSelectionModel selectionModel =
- table.getSelectionModel();
- final int minIndex = selectionModel.getMinSelectionIndex();
- final int maxIndex = selectionModel.getMaxSelectionIndex();
- if (minIndex == -1 || maxIndex == -1) {
- e.getPresentation().setEnabled(false);
- }
- else {
- e.getPresentation().setEnabled(true);
+ selectionModel.setSelectionInterval(minIndex - 1, minIndex - 1);
}
}
});
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/AbstractMethodOverridesAbstractMethod.html b/plugins/InspectionGadgets/src/inspectionDescriptions/AbstractMethodOverridesAbstractMethod.html
index abd9135fc4c2..59e628bae7ef 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/AbstractMethodOverridesAbstractMethod.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/AbstractMethodOverridesAbstractMethod.html
@@ -1,9 +1,13 @@
-This inspection reports abstract methods which override abstract methods. Methods with
+This inspection reports abstract methods which override abstract methods. Methods with
different return types or exception declarations than the method they override are not
reported by this inspection.
+Use the first checkbox to ignore any abstract methods that have a different JavaDoc comment than their super method.
+
+Use the second checkbox to ignore any abstract methods that have one or more annotations that are not present on their super method.
+
Powered by InspectionGadgets
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/BadOddness.html b/plugins/InspectionGadgets/src/inspectionDescriptions/BadOddness.html
index ae1eb20bdc84..6e0616a2ac02 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/BadOddness.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/BadOddness.html
@@ -3,7 +3,7 @@
This inspection reports any checks for oddness of the form:
x % 2 == 1
Such checks will fail for negative odd values, which is probably not the behaviour intended. Consider using:
-x % 2 != 0
or: x & 1 == 1
instead.
+x % 2 != 0
or: (x & 1) == 1
instead.
Powered by InspectionGadgets
-This inspection reports construction of exceptions without arguments. When an exception is constructed without arguments it contains no
-information about the fault that happened, which makes debugging needlessly hard.
+This inspection reports exception instance creation without any arguments specified. When an exception is constructed
+without arguments it contains no information about the fault that happened, which makes debugging needlessly hard.
+
+Use the checkbox below to ignore instance creation of exception classes which have no constructors that take arguments.
New in 11, Powered by InspectionGadgets
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/classlayout/AbstractMethodOverridesAbstractMethodInspection.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/classlayout/AbstractMethodOverridesAbstractMethodInspection.java
deleted file mode 100644
index 2cdf865ca3ec..000000000000
--- a/plugins/InspectionGadgets/test/com/siyeh/igtest/classlayout/AbstractMethodOverridesAbstractMethodInspection.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package com.siyeh.igtest.classlayout;
-
-
-public abstract class AbstractMethodOverridesAbstractMethodInspection {
- public abstract Object foo() throws Exception;
-}
-
- abstract class Child extends AbstractMethodOverridesAbstractMethodInspection
-{
- public abstract Object foo() ;
-}
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/errorhandling/new_exception_without_arguments/NewExceptionWithoutArguments.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/errorhandling/new_exception_without_arguments/NewExceptionWithoutArguments.java
new file mode 100644
index 000000000000..f563cab3b3c1
--- /dev/null
+++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/errorhandling/new_exception_without_arguments/NewExceptionWithoutArguments.java
@@ -0,0 +1,16 @@
+package com.siyeh.igtest.errorhandling.new_exception_without_arguments;
+
+class NewExceptionWithoutArguments {
+
+ void foo() {
+ throw new RuntimeException();
+ }
+
+ void bar() {
+ throw new MyException();
+ }
+
+}
+class MyException extends RuntimeException {
+
+}
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/errorhandling/new_exception_without_arguments/expected.xml b/plugins/InspectionGadgets/test/com/siyeh/igtest/errorhandling/new_exception_without_arguments/expected.xml
new file mode 100644
index 000000000000..3d60c6a05598
--- /dev/null
+++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/errorhandling/new_exception_without_arguments/expected.xml
@@ -0,0 +1,11 @@
+
+
+
+
+ NewExceptionWithoutArguments.java
+ 6
+ Exception constructor called without arguments
+ <code>new RuntimeException()</code> without arguments #loc
+
+
+
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/inheritance/abstract_method_overrides_abstract_method/AbstractMethodOverridesAbstractMethod.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/inheritance/abstract_method_overrides_abstract_method/AbstractMethodOverridesAbstractMethod.java
new file mode 100644
index 000000000000..55c25977c82b
--- /dev/null
+++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/inheritance/abstract_method_overrides_abstract_method/AbstractMethodOverridesAbstractMethod.java
@@ -0,0 +1,31 @@
+package com.siyeh.igtest.inheritance.abstract_method_overrides_abstract_method;
+
+
+import org.jetbrains.annotations.Nullable;
+
+public abstract class AbstractMethodOverridesAbstractMethod {
+ public abstract Object foo() throws Exception;
+
+ abstract void one(String s);
+
+ abstract void two();
+
+ public abstract void three();
+
+
+
+
+}
+abstract class Child extends AbstractMethodOverridesAbstractMethod
+{
+ public abstract String foo() ;
+
+ abstract void one(@Nullable String s);
+
+ /**
+ * some documentation
+ */
+ abstract void two();
+
+ public abstract void three();
+}
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/inheritance/abstract_method_overrides_abstract_method/expected.xml b/plugins/InspectionGadgets/test/com/siyeh/igtest/inheritance/abstract_method_overrides_abstract_method/expected.xml
new file mode 100644
index 000000000000..7682ee3c3a6a
--- /dev/null
+++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/inheritance/abstract_method_overrides_abstract_method/expected.xml
@@ -0,0 +1,11 @@
+
+
+
+
+ AbstractMethodOverridesAbstractMethod.java
+ 30
+ Abstract method overrides abstract method
+ Abstract method <code>three()</code> overrides abstract method #loc
+
+
+
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/errorhandling/NewExceptionWithoutArgumentsInspectionTest.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/errorhandling/NewExceptionWithoutArgumentsInspectionTest.java
new file mode 100644
index 000000000000..fbd585cddfc8
--- /dev/null
+++ b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/errorhandling/NewExceptionWithoutArgumentsInspectionTest.java
@@ -0,0 +1,13 @@
+package com.siyeh.ig.errorhandling;
+
+import com.siyeh.ig.IGInspectionTestCase;
+
+public class NewExceptionWithoutArgumentsInspectionTest extends IGInspectionTestCase {
+
+ public void test() throws Exception {
+ final NewExceptionWithoutArgumentsInspection tool = new NewExceptionWithoutArgumentsInspection();
+ tool.ignoreWithoutParameters = true;
+ doTest("com/siyeh/igtest/errorhandling/new_exception_without_arguments", tool);
+ }
+
+}
diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/inheritance/AbstractMethodOverridesAbstractMethodInspectionTest.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/inheritance/AbstractMethodOverridesAbstractMethodInspectionTest.java
new file mode 100644
index 000000000000..5e6ed0b25c88
--- /dev/null
+++ b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/inheritance/AbstractMethodOverridesAbstractMethodInspectionTest.java
@@ -0,0 +1,13 @@
+package com.siyeh.ig.inheritance;
+
+import com.siyeh.ig.IGInspectionTestCase;
+
+public class AbstractMethodOverridesAbstractMethodInspectionTest extends IGInspectionTestCase {
+
+ public void test() throws Exception {
+ final AbstractMethodOverridesAbstractMethodInspection tool = new AbstractMethodOverridesAbstractMethodInspection();
+ tool.ignoreAnnotations = true;
+ tool.ignoreJavaDoc = true;
+ doTest("com/siyeh/igtest/inheritance/abstract_method_overrides_abstract_method", tool);
+ }
+}
diff --git a/plugins/android-designer/src/com/intellij/android/designer/model/PropertyParser.java b/plugins/android-designer/src/com/intellij/android/designer/model/PropertyParser.java
index 427c33b6dfa7..17b16d4c4892 100644
--- a/plugins/android-designer/src/com/intellij/android/designer/model/PropertyParser.java
+++ b/plugins/android-designer/src/com/intellij/android/designer/model/PropertyParser.java
@@ -17,12 +17,17 @@ package com.intellij.android.designer.model;
import com.android.ide.common.rendering.api.ViewInfo;
import com.android.sdklib.IAndroidTarget;
+import com.intellij.android.designer.propertyTable.AttributeProperty;
+import com.intellij.android.designer.propertyTable.FlagProperty;
import com.intellij.designer.model.MetaManager;
+import com.intellij.designer.model.MetaModel;
import com.intellij.designer.model.RadComponent;
import com.intellij.designer.propertyTable.Property;
+import com.intellij.designer.propertyTable.PropertyTable;
import com.intellij.openapi.module.Module;
import org.jetbrains.android.dom.attrs.AttributeDefinition;
import org.jetbrains.android.dom.attrs.AttributeDefinitions;
+import org.jetbrains.android.dom.attrs.AttributeFormat;
import org.jetbrains.android.dom.attrs.StyleableDefinition;
import org.jetbrains.android.sdk.AndroidPlatform;
import org.jetbrains.android.sdk.AndroidTargetData;
@@ -38,15 +43,16 @@ import java.util.*;
public class PropertyParser {
public static final String KEY = "PROPERTY_PARSER";
+ private MetaManager myMetaManager;
private AttributeDefinitions myDefinitions;
private ProjectClassLoader myClassLoader;
private Map> myCachedProperties;
public PropertyParser(Module module, IAndroidTarget target) throws Exception {
- MetaManager metaManager = ViewsMetaManager.getInstance(module.getProject());
- myCachedProperties = metaManager.getCache(target.hashString());
+ myMetaManager = ViewsMetaManager.getInstance(module.getProject());
+ myCachedProperties = myMetaManager.getCache(target.hashString());
if (myCachedProperties == null) {
- metaManager.setCache(target.hashString(), myCachedProperties = new HashMap>());
+ myMetaManager.setCache(target.hashString(), myCachedProperties = new HashMap>());
}
AndroidPlatform androidPlatform = AndroidPlatform.getInstance(module);
@@ -67,38 +73,87 @@ public class PropertyParser {
public void load(RadViewComponent component) throws Exception {
ViewInfo info = component.getViewInfo();
+ MetaModel model = component.getMetaModel();
if (info == null) {
- String target = component.getMetaModel().getTarget();
+ String target = model.getTarget();
if (target == null) {
component.setProperties(Collections.emptyList());
}
else {
- component.setProperties(load(myClassLoader.loadClass(target)));
+ component.setProperties(load(myClassLoader.loadClass(target), model));
}
}
else {
- component.setProperties(load(myClassLoader.loadClass(info.getClassName())));
+ component.setProperties(load(myClassLoader.loadClass(info.getClassName()), model));
}
}
- private List load(Class> componentClass) {
+ private List load(Class> componentClass, MetaModel model) {
String component = componentClass.getSimpleName();
List properties = myCachedProperties.get(component);
if (properties == null) {
properties = new ArrayList();
+ System.out.println("--- " + componentClass + " -----------------");
+
StyleableDefinition definitions = myDefinitions.getStyleableByName(component);
if (definitions != null) {
for (AttributeDefinition definition : definitions.getAttributes()) {
- properties.add(new AttributeProperty(null, definition));
- // TODO
+ String name = definition.getName();
+ Set formats = definition.getFormats();
+ Property property;
+
+ if (formats.contains(AttributeFormat.Flag)) {
+ property = new FlagProperty(name, definition);
+ }
+ else {
+ property = new AttributeProperty(name, definition);
+ }
+
+ if (model != null) {
+ property.setImportant(model.isImportantProperty(name));
+ property.setExpert(model.isExpertProperty(name));
+ property.setDeprecated(model.isDeprecatedProperty(name));
+ }
+
+ properties.add(property);
+
+ System.out.println(definition + " = " + Arrays.toString(definition.getValues()));
}
}
Class> superComponentClass = componentClass.getSuperclass();
if (superComponentClass != null) {
- properties.addAll(load(superComponentClass));
+ List superProperties = load(superComponentClass, myMetaManager.getModelByTarget(superComponentClass.getName()));
+ for (Property superProperty : superProperties) {
+ if (PropertyTable.findProperty(properties, superProperty) == -1) {
+ if (model == null) {
+ properties.add(superProperty);
+ }
+ else {
+ String name = superProperty.getName();
+ boolean normal = model.isNormalProperty(name);
+ boolean important = model.isImportantProperty(name);
+ boolean expert = model.isExpertProperty(name);
+ boolean deprecated = model.isDeprecatedProperty(name);
+
+ if ((normal && (superProperty.isImportant() || superProperty.isExpert())) ||
+ (important && !superProperty.isImportant()) ||
+ (expert && !superProperty.isExpert()) ||
+ (deprecated && !superProperty.isDeprecated())) {
+ Property property = superProperty.createForNewPresentation();
+ property.setImportant(important);
+ property.setExpert(expert);
+ property.setDeprecated(deprecated);
+ properties.add(property);
+ }
+ else {
+ properties.add(superProperty);
+ }
+ }
+ }
+ }
}
if (!properties.isEmpty()) {
diff --git a/plugins/android-designer/src/com/intellij/android/designer/model/views-meta-model.xml b/plugins/android-designer/src/com/intellij/android/designer/model/views-meta-model.xml
index 94bd4cd07e9f..81cb4c375d41 100644
--- a/plugins/android-designer/src/com/intellij/android/designer/model/views-meta-model.xml
+++ b/plugins/android-designer/src/com/intellij/android/designer/model/views-meta-model.xml
@@ -21,6 +21,19 @@
+
+
+
+
+
+
+
+
@@ -29,6 +42,11 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/plugins/android-designer/src/com/intellij/android/designer/model/AttributeProperty.java b/plugins/android-designer/src/com/intellij/android/designer/propertyTable/AttributeProperty.java
similarity index 70%
rename from plugins/android-designer/src/com/intellij/android/designer/model/AttributeProperty.java
rename to plugins/android-designer/src/com/intellij/android/designer/propertyTable/AttributeProperty.java
index 06a5a512bd3c..23c645a6550d 100644
--- a/plugins/android-designer/src/com/intellij/android/designer/model/AttributeProperty.java
+++ b/plugins/android-designer/src/com/intellij/android/designer/propertyTable/AttributeProperty.java
@@ -13,8 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.intellij.android.designer.model;
+package com.intellij.android.designer.propertyTable;
+import com.intellij.android.designer.model.RadViewComponent;
+import com.intellij.android.designer.propertyTable.editors.BooleanEditor;
+import com.intellij.android.designer.propertyTable.renderers.BooleanRenderer;
import com.intellij.designer.propertyTable.Property;
import com.intellij.designer.propertyTable.PropertyEditor;
import com.intellij.designer.propertyTable.PropertyRenderer;
@@ -24,25 +27,51 @@ import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.xml.XmlAttribute;
import org.jetbrains.android.dom.attrs.AttributeDefinition;
+import org.jetbrains.android.dom.attrs.AttributeFormat;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
+import java.util.Set;
+
/**
* @author Alexander Lobas
*/
public class AttributeProperty extends Property {
- private final LabelPropertyRenderer myRenderer = new LabelPropertyRenderer(null);
private final AttributeDefinition myDefinition;
- private final PropertyEditor myEditor = new AbstractTextFieldEditor() {
- @Override
- public Object getValue() throws Exception {
- return myTextField.getText();
- }
- };
+ private final PropertyRenderer myRenderer;
+ private final PropertyEditor myEditor;
- public AttributeProperty(Property parent, @NotNull AttributeDefinition definition) {
- super(parent, definition.getName());
+ public AttributeProperty(@NotNull String name, @NotNull AttributeDefinition definition) {
+ super(null, name);
myDefinition = definition;
+
+ Set formats = definition.getFormats();
+ if (formats.contains(AttributeFormat.Boolean)) {
+ myRenderer = new BooleanRenderer();
+ myEditor = new BooleanEditor();
+ }
+ else {
+ myRenderer = new LabelPropertyRenderer(null);
+
+ if (formats.contains(AttributeFormat.Enum)) {
+
+ }
+ else {
+
+ }
+
+ myEditor = new AbstractTextFieldEditor() {
+ @Override
+ public Object getValue() throws Exception {
+ return myTextField.getText();
+ }
+ };
+ }
+ }
+
+ @Override
+ public Property createForNewPresentation() {
+ return new AttributeProperty(getName(), myDefinition);
}
@Override
diff --git a/plugins/android-designer/src/com/intellij/android/designer/propertyTable/FlagProperty.java b/plugins/android-designer/src/com/intellij/android/designer/propertyTable/FlagProperty.java
new file mode 100644
index 000000000000..36bc7426b7b1
--- /dev/null
+++ b/plugins/android-designer/src/com/intellij/android/designer/propertyTable/FlagProperty.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2000-2012 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.android.designer.propertyTable;
+
+import com.intellij.android.designer.model.RadViewComponent;
+import com.intellij.designer.propertyTable.Property;
+import com.intellij.designer.propertyTable.PropertyEditor;
+import com.intellij.designer.propertyTable.PropertyRenderer;
+import com.intellij.designer.propertyTable.renderers.LabelPropertyRenderer;
+import org.jetbrains.android.dom.attrs.AttributeDefinition;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.List;
+
+/**
+ * @author Alexander Lobas
+ */
+public class FlagProperty extends Property {
+ private final PropertyRenderer myRenderer = new LabelPropertyRenderer(null);
+ private final AttributeDefinition myDefinition;
+
+ public FlagProperty(@NotNull String name, @NotNull AttributeDefinition definition) {
+ super(null, name);
+ myDefinition = definition;
+ }
+
+ @Override
+ public Property createForNewPresentation() {
+ return new FlagProperty(getName(), myDefinition);
+ }
+
+ @Override
+ public List getChildren(@Nullable RadViewComponent component) {
+ return super.getChildren(component); // TODO: Auto-generated method stub
+ }
+
+ @Override
+ public Object getValue(RadViewComponent component) throws Exception {
+ return "[]";
+ }
+
+ @Override
+ public void setValue(RadViewComponent component, Object value) throws Exception {
+ super.setValue(component, value); // TODO: Auto-generated method stub
+ }
+
+ @Override
+ public boolean isDefaultValue(RadViewComponent component) throws Exception {
+ return super.isDefaultValue(component); // TODO: Auto-generated method stub
+ }
+
+ @Override
+ public void setDefaultValue(RadViewComponent component) throws Exception {
+ super.setDefaultValue(component); // TODO: Auto-generated method stub
+ }
+
+ @NotNull
+ @Override
+ public PropertyRenderer getRenderer() {
+ return myRenderer;
+ }
+
+ @Override
+ public PropertyEditor getEditor() {
+ return null;
+ }
+}
\ No newline at end of file
diff --git a/plugins/android-designer/src/com/intellij/android/designer/propertyTable/editors/BooleanEditor.java b/plugins/android-designer/src/com/intellij/android/designer/propertyTable/editors/BooleanEditor.java
new file mode 100644
index 000000000000..ba21dcd2c6d6
--- /dev/null
+++ b/plugins/android-designer/src/com/intellij/android/designer/propertyTable/editors/BooleanEditor.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2000-2012 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.android.designer.propertyTable.editors;
+
+import com.intellij.openapi.util.text.StringUtil;
+
+/**
+ * @author Alexander Lobas
+ */
+public class BooleanEditor extends com.intellij.designer.propertyTable.editors.BooleanEditor {
+ @Override
+ public Object getValue() throws Exception {
+ return Boolean.toString(myCheckBox.isSelected());
+ }
+
+ @Override
+ protected boolean getValue(Object value) {
+ return Boolean.parseBoolean((String)value);
+ }
+}
\ No newline at end of file
diff --git a/plugins/android-designer/src/com/intellij/android/designer/propertyTable/renderers/BooleanRenderer.java b/plugins/android-designer/src/com/intellij/android/designer/propertyTable/renderers/BooleanRenderer.java
new file mode 100644
index 000000000000..61adcd26ebb1
--- /dev/null
+++ b/plugins/android-designer/src/com/intellij/android/designer/propertyTable/renderers/BooleanRenderer.java
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2000-2012 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.android.designer.propertyTable.renderers;
+
+/**
+ * @author Alexander Lobas
+ */
+public class BooleanRenderer extends com.intellij.designer.propertyTable.renderers.BooleanRenderer {
+ @Override
+ protected boolean getValue(Object value) {
+ return Boolean.parseBoolean((String)value);
+ }
+}
\ No newline at end of file
diff --git a/plugins/android/src/org/jetbrains/android/actions/CreateResourceDirectoryAction.java b/plugins/android/src/org/jetbrains/android/actions/CreateResourceDirectoryAction.java
index 11cda9efb863..5c822b1245bf 100644
--- a/plugins/android/src/org/jetbrains/android/actions/CreateResourceDirectoryAction.java
+++ b/plugins/android/src/org/jetbrains/android/actions/CreateResourceDirectoryAction.java
@@ -1,5 +1,6 @@
package org.jetbrains.android.actions;
+import com.android.resources.ResourceFolderType;
import com.intellij.CommonBundle;
import com.intellij.ide.actions.CreateElementActionBase;
import com.intellij.openapi.actionSystem.DataContext;
@@ -22,15 +23,23 @@ import java.io.File;
* @author Eugene.Kudelevsky
*/
public class CreateResourceDirectoryAction extends CreateElementActionBase {
+ private final ResourceFolderType myResourceFolderType;
+
+ @SuppressWarnings("UnusedDeclaration")
public CreateResourceDirectoryAction() {
+ this(null);
+ }
+
+ public CreateResourceDirectoryAction(@Nullable ResourceFolderType resourceFolderType) {
super(AndroidBundle.message("new.resource.dir.action.title"), AndroidBundle.message("new.resource.action.description"),
PlatformIcons.DIRECTORY_CLOSED_ICON);
+ myResourceFolderType = resourceFolderType;
}
@NotNull
@Override
- protected PsiElement[] invokeDialog(final Project project, final PsiDirectory directory) {
- final CreateResourceDirectoryDialog dialog = new CreateResourceDirectoryDialog(project) {
+ public PsiElement[] invokeDialog(final Project project, final PsiDirectory directory) {
+ final CreateResourceDirectoryDialog dialog = new CreateResourceDirectoryDialog(project, myResourceFolderType) {
@Override
protected InputValidator createValidator() {
return CreateResourceDirectoryAction.this.createValidator(project, directory);
diff --git a/plugins/android/src/org/jetbrains/android/actions/CreateResourceDirectoryDialog.form b/plugins/android/src/org/jetbrains/android/actions/CreateResourceDirectoryDialog.form
index 13ff3aa495d2..6e6d2e12dbb7 100644
--- a/plugins/android/src/org/jetbrains/android/actions/CreateResourceDirectoryDialog.form
+++ b/plugins/android/src/org/jetbrains/android/actions/CreateResourceDirectoryDialog.form
@@ -47,7 +47,7 @@
-
+
diff --git a/plugins/android/src/org/jetbrains/android/actions/CreateResourceDirectoryDialog.java b/plugins/android/src/org/jetbrains/android/actions/CreateResourceDirectoryDialog.java
index 4c284c98cec3..fa10c6a667c5 100644
--- a/plugins/android/src/org/jetbrains/android/actions/CreateResourceDirectoryDialog.java
+++ b/plugins/android/src/org/jetbrains/android/actions/CreateResourceDirectoryDialog.java
@@ -26,6 +26,7 @@ import com.intellij.ui.components.JBLabel;
import org.jetbrains.android.uipreview.DeviceConfiguratorPanel;
import org.jetbrains.android.uipreview.InvalidOptionValueException;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.awt.*;
@@ -45,7 +46,7 @@ public abstract class CreateResourceDirectoryDialog extends DialogWrapper {
private final DeviceConfiguratorPanel myDeviceConfiguratorPanel;
private InputValidator myValidator;
- public CreateResourceDirectoryDialog(@NotNull Project project) {
+ public CreateResourceDirectoryDialog(@NotNull Project project, @Nullable ResourceFolderType resType) {
super(project);
myResourceTypeComboBox.setModel(new EnumComboBoxModel(ResourceFolderType.class));
@@ -84,6 +85,11 @@ public abstract class CreateResourceDirectoryDialog extends DialogWrapper {
}
});
+ if (resType != null) {
+ myResourceTypeComboBox.setSelectedItem(resType);
+ myResourceTypeComboBox.setEnabled(false);
+ }
+
myDeviceConfiguratorPanel.updateAll();
setOKActionEnabled(myDirectoryNameTextField.getText().length() > 0);
init();
diff --git a/plugins/android/src/org/jetbrains/android/actions/CreateXmlResourceDialog.form b/plugins/android/src/org/jetbrains/android/actions/CreateXmlResourceDialog.form
index e259ae3a5dad..2fc86f924add 100644
--- a/plugins/android/src/org/jetbrains/android/actions/CreateXmlResourceDialog.form
+++ b/plugins/android/src/org/jetbrains/android/actions/CreateXmlResourceDialog.form
@@ -1,21 +1,13 @@
diff --git a/plugins/android/src/org/jetbrains/android/actions/CreateXmlResourceDialog.java b/plugins/android/src/org/jetbrains/android/actions/CreateXmlResourceDialog.java
index 2138266bb93c..edcb31fb12c9 100644
--- a/plugins/android/src/org/jetbrains/android/actions/CreateXmlResourceDialog.java
+++ b/plugins/android/src/org/jetbrains/android/actions/CreateXmlResourceDialog.java
@@ -1,57 +1,68 @@
package org.jetbrains.android.actions;
-import com.android.AndroidConstants;
-import com.android.ide.common.resources.configuration.FolderConfiguration;
import com.android.resources.ResourceFolderType;
import com.android.resources.ResourceType;
import com.intellij.CommonBundle;
import com.intellij.ide.ui.ListCellRendererWrapper;
+import com.intellij.openapi.actionSystem.AnActionEvent;
+import com.intellij.openapi.actionSystem.DataContext;
+import com.intellij.openapi.actionSystem.PlatformDataKeys;
+import com.intellij.openapi.fileChooser.actions.VirtualFileDeleteProvider;
import com.intellij.openapi.fileTypes.StdFileTypes;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleType;
+import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.ui.ValidationInfo;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.psi.PsiDirectory;
+import com.intellij.psi.PsiElement;
+import com.intellij.psi.PsiManager;
+import com.intellij.ui.*;
import com.intellij.ui.components.JBLabel;
+import com.intellij.util.ArrayUtil;
+import com.intellij.util.PlatformIcons;
import com.intellij.util.containers.HashSet;
+import com.intellij.util.containers.hash.HashMap;
import org.jetbrains.android.dom.resources.ResourceElement;
import org.jetbrains.android.dom.resources.Resources;
import org.jetbrains.android.facet.AndroidFacet;
import org.jetbrains.android.facet.AndroidRootUtil;
-import org.jetbrains.android.uipreview.DeviceConfiguratorPanel;
-import org.jetbrains.android.uipreview.InvalidOptionValueException;
import org.jetbrains.android.util.AndroidBundle;
-import org.jetbrains.android.util.AndroidCommonUtils;
import org.jetbrains.android.util.AndroidResourceUtil;
import org.jetbrains.android.util.AndroidUtils;
+import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
-import java.awt.*;
-import java.util.Arrays;
-import java.util.Comparator;
-import java.util.Set;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.*;
/**
* @author Eugene.Kudelevsky
*/
public class CreateXmlResourceDialog extends DialogWrapper {
private JPanel myPanel;
- private JPanel myDeviceConfigurationWrapper;
private JTextField myNameField;
private JComboBox myModuleCombo;
private JBLabel myModuleLabel;
- private JTextField myDirectoryNameField;
- private JBLabel myErrorLabel;
private JTextField myFileNameField;
+ private JPanel myDirectoriesPanel;
+ private JBLabel myDirectoriesLabel;
- private final DeviceConfiguratorPanel myDeviceConfiguratorPanel;
private final Module myModule;
private final ResourceType myResourceType;
+ private Map myCheckBoxes = Collections.emptyMap();
+ private String[] myDirNames = ArrayUtil.EMPTY_STRING_ARRAY;
+
+ private final CheckBoxList myDirectoriesList;
+ private VirtualFile myResourceDir;
+
public CreateXmlResourceDialog(@NotNull Module module, @NotNull ResourceType resourceType) {
super(module.getProject());
@@ -94,39 +105,189 @@ public class CreateXmlResourceDialog extends DialogWrapper {
});
}
- myDeviceConfiguratorPanel = new DeviceConfiguratorPanel(null) {
- @Override
- public void applyEditors() {
- try {
- doApplyEditors();
-
- final FolderConfiguration config = myDeviceConfiguratorPanel.getConfiguration();
- myErrorLabel.setText("");
- myDirectoryNameField.setText(config.getFolderName(ResourceFolderType.VALUES));
- }
- catch (InvalidOptionValueException e) {
- myErrorLabel.setText("" + e.getMessage() + "");
- myDirectoryNameField.setText(AndroidConstants.FD_RES_VALUES);
- }
- }
- };
- myDeviceConfigurationWrapper.add(myDeviceConfiguratorPanel, BorderLayout.CENTER);
-
final String defaultResFileName = AndroidResourceUtil.getDefaultResourceFileName(resourceType.getName());
if (defaultResFileName != null) {
myFileNameField.setText(defaultResFileName);
}
- myDirectoryNameField.setText(AndroidConstants.FD_RES_VALUES);
- myDeviceConfiguratorPanel.updateAll();
+
+
+ myDirectoriesList = new CheckBoxList();
+ myDirectoriesLabel.setLabelFor(myDirectoriesList);
+ final ToolbarDecorator decorator = ToolbarDecorator.createDecorator(myDirectoriesList);
+
+ decorator.setEditAction(null);
+ decorator.disableUpDownActions();
+
+ decorator.setAddAction(new AnActionButtonRunnable() {
+ @Override
+ public void run(AnActionButton button) {
+ doAddNewDirectory();
+ }
+ });
+
+ decorator.setRemoveAction(new AnActionButtonRunnable() {
+ @Override
+ public void run(AnActionButton button) {
+ doDeleteDirectory();
+ }
+ });
+
+ final AnActionButton selectAll = new AnActionButton("Select All", null, PlatformIcons.SELECT_ALL_ICON) {
+ @Override
+ public void actionPerformed(AnActionEvent e) {
+ doSelectAllDirs();
+ }
+ };
+ decorator.addExtraAction(selectAll);
+
+ final AnActionButton unselectAll = new AnActionButton("Unselect All", null, PlatformIcons.UNSELECT_ALL_ICON) {
+ @Override
+ public void actionPerformed(AnActionEvent e) {
+ doUnselectAllDirs();
+ }
+ };
+ decorator.addExtraAction(unselectAll);
+
+ myDirectoriesPanel.add(decorator.createPanel());
+
+ updateDirectories();
+
+ myModuleCombo.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ updateDirectories();
+ }
+ });
init();
}
+ private void doDeleteDirectory() {
+ if (myResourceDir == null) {
+ return;
+ }
+
+ final int selectedIndex = myDirectoriesList.getSelectedIndex();
+ if (selectedIndex < 0) {
+ return;
+ }
+
+ final String selectedDirName = myDirNames[selectedIndex];
+ final VirtualFile selectedDir = myResourceDir.findChild(selectedDirName);
+ if (selectedDir == null) {
+ return;
+ }
+
+ final VirtualFileDeleteProvider provider = new VirtualFileDeleteProvider();
+ provider.deleteElement(new DataContext() {
+ @Override
+ public Object getData(@NonNls String dataId) {
+ if (PlatformDataKeys.VIRTUAL_FILE_ARRAY.getName().equals(dataId)) {
+ return new VirtualFile[] {selectedDir};
+ }
+ else {
+ return null;
+ }
+ }
+ });
+ updateDirectories();
+ }
+
+ private void doSelectAllDirs() {
+ for (JCheckBox checkBox : myCheckBoxes.values()) {
+ checkBox.setSelected(true);
+ }
+ myDirectoriesList.repaint();
+ }
+
+ private void doUnselectAllDirs() {
+ for (JCheckBox checkBox : myCheckBoxes.values()) {
+ checkBox.setSelected(false);
+ }
+ myDirectoriesList.repaint();
+ }
+
+ private void doAddNewDirectory() {
+ if (myResourceDir == null) {
+ return;
+ }
+ final Module module = getModule();
+ if (module == null) {
+ return;
+ }
+ final Project project = module.getProject();
+ final PsiDirectory psiResDir = PsiManager.getInstance(project).findDirectory(myResourceDir);
+
+ if (psiResDir != null) {
+ final PsiElement[] createdElements = new CreateResourceDirectoryAction(ResourceFolderType.VALUES).invokeDialog(project, psiResDir);
+
+ if (createdElements.length > 0) {
+ updateDirectories();
+ }
+ }
+ }
+
+ private void updateDirectories() {
+ final Module module = getModule();
+ List valuesDirs = Collections.emptyList();
+
+ if (module != null) {
+ final AndroidFacet facet = AndroidFacet.getInstance(module);
+
+ if (facet != null) {
+ myResourceDir = AndroidRootUtil.getResourceDir(facet);
+
+ if (myResourceDir != null) {
+ valuesDirs = AndroidResourceUtil.getResourceSubdirs(ResourceFolderType.VALUES.getName(), new VirtualFile[]{myResourceDir});
+ }
+ }
+ }
+
+ Collections.sort(valuesDirs, new Comparator() {
+ @Override
+ public int compare(VirtualFile f1, VirtualFile f2) {
+ return f1.getName().compareTo(f2.getName());
+ }
+ });
+
+ final Map oldCheckBoxes = myCheckBoxes;
+ final int selectedIndex = myDirectoriesList.getSelectedIndex();
+ final String selectedDirName = selectedIndex >= 0 ? myDirNames[selectedIndex] : null;
+
+ final List checkBoxList = new ArrayList();
+ myCheckBoxes = new HashMap();
+ myDirNames = new String[valuesDirs.size()];
+
+ int newSelectedIndex = -1;
+
+ int i = 0;
+
+ for (VirtualFile dir : valuesDirs) {
+ final String dirName = dir.getName();
+ final JCheckBox oldCheckBox = oldCheckBoxes.get(dirName);
+ final boolean selected = oldCheckBox != null && oldCheckBox.isSelected();
+ final JCheckBox checkBox = new JCheckBox(dirName, selected);
+ checkBoxList.add(checkBox);
+ myCheckBoxes.put(dirName, checkBox);
+ myDirNames[i] = dirName;
+
+ if (dirName.equals(selectedDirName)) {
+ newSelectedIndex = i;
+ }
+ i++;
+ }
+ myDirectoriesList.setModel(new CollectionListModel(checkBoxList));
+
+ if (newSelectedIndex >= 0) {
+ myDirectoriesList.setSelectedIndex(newSelectedIndex);
+ }
+ }
+
@Override
protected ValidationInfo doValidate() {
final String resourceName = getResourceName();
final Module selectedModule = getModule();
- final String directoryName = getDirectoryName();
+ final List directoryNames = getDirNames();
final String fileName = getFileName();
if (resourceName.length() == 0) {
@@ -141,23 +302,14 @@ public class CreateXmlResourceDialog extends DialogWrapper {
else if (selectedModule == null) {
return new ValidationInfo("specify module", myModuleCombo);
}
- else if (!ResourceFolderType.VALUES.getName().equals(
- AndroidCommonUtils.getResourceTypeByDirName(directoryName))) {
- return new ValidationInfo("directory name is not appropriate for value resources");
+ else if (directoryNames.size() == 0) {
+ return new ValidationInfo("choose directories", myDirectoriesList);
}
- final ValidationInfo info = checkIfResourceAlreadyExists(selectedModule, resourceName, myResourceType, directoryName, fileName);
+ final ValidationInfo info = checkIfResourceAlreadyExists(selectedModule, resourceName, myResourceType, directoryNames, fileName);
if (info != null) {
return info;
}
-
- try {
- myDeviceConfiguratorPanel.doApplyEditors();
- }
- catch (InvalidOptionValueException e) {
- return new ValidationInfo("fix errors in configuration editor");
- }
-
return null;
}
@@ -165,10 +317,10 @@ public class CreateXmlResourceDialog extends DialogWrapper {
private static ValidationInfo checkIfResourceAlreadyExists(@NotNull Module selectedModule,
@NotNull String resourceName,
@NotNull ResourceType resourceType,
- @NotNull String directoryName,
+ @NotNull List dirNames,
@NotNull String fileName) {
if (resourceName.length() == 0 ||
- directoryName.length() == 0 ||
+ dirNames.size() == 0 ||
fileName.length() == 0) {
return null;
}
@@ -179,29 +331,31 @@ public class CreateXmlResourceDialog extends DialogWrapper {
return null;
}
- final VirtualFile resourceSubdir = resourceDir.findChild(directoryName);
- if (resourceSubdir == null) {
- return null;
- }
+ for (String directoryName : dirNames) {
+ final VirtualFile resourceSubdir = resourceDir.findChild(directoryName);
+ if (resourceSubdir == null) {
+ continue;
+ }
- final VirtualFile resFile = resourceSubdir.findChild(fileName);
- if (resFile == null) {
- return null;
- }
+ final VirtualFile resFile = resourceSubdir.findChild(fileName);
+ if (resFile == null) {
+ continue;
+ }
- if (resFile.getFileType() != StdFileTypes.XML) {
- return new ValidationInfo("File " + FileUtil.toSystemDependentName(resFile.getPath()) + " is not XML file");
- }
+ if (resFile.getFileType() != StdFileTypes.XML) {
+ return new ValidationInfo("File " + FileUtil.toSystemDependentName(resFile.getPath()) + " is not XML file");
+ }
- final Resources resources = AndroidUtils.loadDomElement(selectedModule, resFile, Resources.class);
- if (resources == null) {
- return new ValidationInfo(AndroidBundle.message("not.resource.file.error", FileUtil.toSystemDependentName(resFile.getPath())));
- }
+ final Resources resources = AndroidUtils.loadDomElement(selectedModule, resFile, Resources.class);
+ if (resources == null) {
+ return new ValidationInfo(AndroidBundle.message("not.resource.file.error", FileUtil.toSystemDependentName(resFile.getPath())));
+ }
- for (ResourceElement element : AndroidResourceUtil.getValueResourcesFromElement(resourceType.getName(), resources)) {
- if (resourceName.equals(element.getName().getValue())) {
- return new ValidationInfo("resource '" + resourceName + "' already exists in " + FileUtil.toSystemDependentName(
- resFile.getPath()));
+ for (ResourceElement element : AndroidResourceUtil.getValueResourcesFromElement(resourceType.getName(), resources)) {
+ if (resourceName.equals(element.getName().getValue())) {
+ return new ValidationInfo("resource '" + resourceName + "' already exists in " + FileUtil.toSystemDependentName(
+ resFile.getPath()));
+ }
}
}
return null;
@@ -216,7 +370,7 @@ public class CreateXmlResourceDialog extends DialogWrapper {
protected void doOKAction() {
final String resourceName = getResourceName();
final String fileName = getFileName();
- final String dirName = getDirectoryName();
+ final List dirNames = getDirNames();
final Module module = getModule();
if (resourceName.length() == 0) {
@@ -228,8 +382,8 @@ public class CreateXmlResourceDialog extends DialogWrapper {
else if (fileName.length() == 0) {
Messages.showErrorDialog(myPanel, "File name is not specified", CommonBundle.getErrorTitle());
}
- else if (dirName.length() == 0) {
- Messages.showErrorDialog(myPanel, "Directory name is not specified", CommonBundle.getErrorTitle());
+ else if (dirNames.size() == 0) {
+ Messages.showErrorDialog(myPanel, "Directories are not selected", CommonBundle.getErrorTitle());
}
else if (module == null) {
Messages.showErrorDialog(myPanel, "Module is not specified", CommonBundle.getErrorTitle());
@@ -245,8 +399,15 @@ public class CreateXmlResourceDialog extends DialogWrapper {
}
@NotNull
- public String getDirectoryName() {
- return myDirectoryNameField.getText().trim();
+ public List getDirNames() {
+ final List selectedDirs = new ArrayList();
+
+ for (Map.Entry entry : myCheckBoxes.entrySet()) {
+ if (entry.getValue().isSelected()) {
+ selectedDirs.add(entry.getKey());
+ }
+ }
+ return selectedDirs;
}
@NotNull
diff --git a/plugins/android/src/org/jetbrains/android/intentions/AndroidAddStringResourceAction.java b/plugins/android/src/org/jetbrains/android/intentions/AndroidAddStringResourceAction.java
index e6e4e54ba23b..990d166a93de 100644
--- a/plugins/android/src/org/jetbrains/android/intentions/AndroidAddStringResourceAction.java
+++ b/plugins/android/src/org/jetbrains/android/intentions/AndroidAddStringResourceAction.java
@@ -67,7 +67,9 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.io.File;
+import java.util.Collections;
import java.util.LinkedHashSet;
+import java.util.List;
import java.util.Set;
import static org.jetbrains.android.util.AndroidUtils.VIEW_CLASS_NAME;
@@ -204,20 +206,14 @@ public class AndroidAddStringResourceAction extends AbstractIntentionAction impl
return;
}
- final ResourceElement createdElement =
- doCreate(module, dialog.getResourceName(), ResourceType.STRING, dialog.getFileName(), dialog.getDirectoryName(), value);
-
- if (createdElement != null) {
- resName = createdElement.getName().getValue();
+ resName = dialog.getResourceName();
+ if (!doCreate(module, resName, ResourceType.STRING, dialog.getFileName(), dialog.getDirNames(), value)) {
+ return;
}
}
else {
assert ApplicationManager.getApplication().isUnitTestMode();
- doCreate(facet.getModule(), resName, ResourceType.STRING, "strings.xml", "values", value);
- }
-
- if (resName == null) {
- return;
+ doCreate(facet.getModule(), resName, ResourceType.STRING, "strings.xml", Collections.singletonList("values"), value);
}
if (file instanceof PsiJavaFile) {
@@ -358,19 +354,18 @@ public class AndroidAddStringResourceAction extends AbstractIntentionAction impl
return true;
}
- @Nullable
- private static ResourceElement doCreate(@NotNull Module module,
- @NotNull String resourceName,
- @NotNull ResourceType resourceType,
- @NotNull String fileName,
- @NotNull String dirName,
- @NotNull String value) {
+ private static boolean doCreate(@NotNull Module module,
+ @NotNull String resourceName,
+ @NotNull ResourceType resourceType,
+ @NotNull String fileName,
+ @NotNull List dirNames,
+ @NotNull String value) {
final Project project = module.getProject();
final AndroidFacet facet = AndroidFacet.getInstance(module);
assert facet != null;
try {
- return addValueResource(facet, resourceName, resourceType, fileName, dirName, value);
+ return addValueResource(facet, resourceName, resourceType, fileName, dirNames, value);
}
catch (Exception e) {
final String message = CreateElementActionBase.filterMessage(e.getMessage());
@@ -382,36 +377,52 @@ public class AndroidAddStringResourceAction extends AbstractIntentionAction impl
LOG.info(e);
reportError(project, message);
}
- return null;
+ return false;
}
}
- @Nullable
- public static ResourceElement addValueResource(@NotNull AndroidFacet facet,
- @NotNull String resourceName,
- @NotNull ResourceType resourceType,
- @NotNull String fileName,
- @NotNull String dirName,
- @NotNull String value) throws Exception {
- final VirtualFile resFile = findOrCreateResourceFile(facet, fileName, dirName);
- if (resFile == null ||
- !ReadonlyStatusHandler.ensureFilesWritable(facet.getModule().getProject(), resFile)) {
- return null;
+ private static boolean addValueResource(@NotNull AndroidFacet facet,
+ @NotNull String resourceName,
+ @NotNull ResourceType resourceType,
+ @NotNull String fileName,
+ @NotNull List dirNames,
+ @NotNull String value) throws Exception {
+ if (dirNames.size() == 0) {
+ return false;
+ }
+ final VirtualFile[] resFiles = new VirtualFile[dirNames.size()];
+
+ for (int i = 0, n = dirNames.size(); i < n; i++) {
+ final VirtualFile resFile = findOrCreateResourceFile(facet, fileName, dirNames.get(i));
+ if (resFile == null) {
+ return false;
+ }
+ resFiles[i] = resFile;
+ }
+
+ if (!ReadonlyStatusHandler.ensureFilesWritable(facet.getModule().getProject(), resFiles)) {
+ return false;
+ }
+ final Resources[] resourcesElements = new Resources[resFiles.length];
+
+ for (int i = 0; i < resFiles.length; i++) {
+ final Resources resources = AndroidUtils.loadDomElement(facet.getModule(), resFiles[i], Resources.class);
+ if (resources == null) {
+ reportError(facet.getModule().getProject(), AndroidBundle.message("not.resource.file.error", fileName));
+ return false;
+ }
+ resourcesElements[i] = resources;
}
- final Resources resources = AndroidUtils.loadDomElement(facet.getModule(), resFile, Resources.class);
- if (resources == null) {
- reportError(facet.getModule().getProject(), AndroidBundle.message("not.resource.file.error", fileName));
- return null;
- }
+ for (Resources resources : resourcesElements) {
+ final ResourceElement element = AndroidResourceUtil.addValueResource(resourceType.getName(), resources);
+ element.getName().setValue(resourceName);
- final ResourceElement element = AndroidResourceUtil.addValueResource(resourceType.getName(), resources);
- element.getName().setValue(resourceName);
-
- if (value.length() > 0) {
- element.setStringValue(value);
+ if (value.length() > 0) {
+ element.setStringValue(value);
+ }
}
- return element;
+ return true;
}
@Nullable
diff --git a/plugins/ant/src/com/intellij/lang/ant/config/impl/configuration/AntClasspathEditorPanel.form b/plugins/ant/src/com/intellij/lang/ant/config/impl/configuration/AntClasspathEditorPanel.form
index d68af3e02d70..0acb741d97e5 100644
--- a/plugins/ant/src/com/intellij/lang/ant/config/impl/configuration/AntClasspathEditorPanel.form
+++ b/plugins/ant/src/com/intellij/lang/ant/config/impl/configuration/AntClasspathEditorPanel.form
@@ -1,18 +1,16 @@
-
-
-
-
-
-
-
-
-
-
-
+
diff --git a/plugins/ant/src/com/intellij/lang/ant/config/impl/configuration/AntClasspathEditorPanel.java b/plugins/ant/src/com/intellij/lang/ant/config/impl/configuration/AntClasspathEditorPanel.java
index c71c6b5f0e37..53fded553a8a 100644
--- a/plugins/ant/src/com/intellij/lang/ant/config/impl/configuration/AntClasspathEditorPanel.java
+++ b/plugins/ant/src/com/intellij/lang/ant/config/impl/configuration/AntClasspathEditorPanel.java
@@ -18,7 +18,6 @@ package com.intellij.lang.ant.config.impl.configuration;
import com.intellij.lang.ant.config.impl.AllJarsUnderDirEntry;
import com.intellij.lang.ant.config.impl.AntClasspathEntry;
import com.intellij.lang.ant.config.impl.SinglePathEntry;
-import com.intellij.openapi.ui.LabeledComponent;
import com.intellij.ui.ListUtil;
import com.intellij.util.config.AbstractProperty;
import com.intellij.util.config.ListProperty;
@@ -68,19 +67,17 @@ public class AntClasspathEditorPanel extends JPanel {
return myBinding;
}
- private static class Form {
+ public static class Form {
private JButton myAddButton;
private JButton myAddAllInDir;
private JButton myRemoveButton;
private JButton myMoveUpButton;
private JButton myMoveDownButton;
private JPanel myWholePanel;
- private JLabel myClasspathLabel;
private JList myClasspathList;
private final ArrayList myUpdatables = new ArrayList();
public Form() {
- myClasspathLabel.setLabelFor(myClasspathList);
myClasspathList.setCellRenderer(new AntUIUtil.ClasspathRenderer());
myUpdatables.add(ListUtil.addRemoveListener(myRemoveButton, myClasspathList));
@@ -96,14 +93,6 @@ public class AntClasspathEditorPanel extends JPanel {
}
}
- public void setClasspathLabel(String textWithMnemonic) {
- LabeledComponent.TextWithMnemonic.fromTextWithMnemonic(textWithMnemonic).setToLabel(myForm.myClasspathLabel);
- }
-
- public String getClasspathLabel() {
- return LabeledComponent.TextWithMnemonic.fromLabel(myForm.myClasspathLabel).getTextWithMnemonic();
- }
-
public JComponent getPreferedFocusComponent() {
return myForm.myClasspathList;
}
diff --git a/plugins/ant/src/com/intellij/lang/ant/config/impl/configuration/BuildFilePropertiesPanel.java b/plugins/ant/src/com/intellij/lang/ant/config/impl/configuration/BuildFilePropertiesPanel.java
index 9cbb98c13ce2..e2ad3ac39e05 100644
--- a/plugins/ant/src/com/intellij/lang/ant/config/impl/configuration/BuildFilePropertiesPanel.java
+++ b/plugins/ant/src/com/intellij/lang/ant/config/impl/configuration/BuildFilePropertiesPanel.java
@@ -28,16 +28,13 @@ import com.intellij.openapi.projectRoots.ui.ProjectJdksEditor;
import com.intellij.openapi.ui.ComponentWithBrowseButton;
import com.intellij.openapi.ui.DialogBuilder;
import com.intellij.openapi.ui.DialogWrapper;
-import com.intellij.openapi.util.Condition;
import com.intellij.openapi.util.Disposer;
-import com.intellij.ui.ComboboxWithBrowseButton;
-import com.intellij.ui.RawCommandLineEditor;
-import com.intellij.ui.SimpleColoredComponent;
-import com.intellij.ui.TabbedPaneWrapper;
-import com.intellij.util.NewInstanceFactory;
+import com.intellij.ui.*;
+import com.intellij.ui.table.JBTable;
import com.intellij.util.config.AbstractProperty;
import com.intellij.util.containers.Convertor;
import com.intellij.util.ui.ColumnInfo;
+import com.intellij.util.ui.ListTableModel;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -197,8 +194,6 @@ public class BuildFilePropertiesPanel {
}
private static class PropertiesTab extends Tab {
- private JButton myAddButton;
- private JButton myRemoveButton;
private JTable myPropertiesTable;
private JPanel myWholePanel;
@@ -237,11 +232,41 @@ public class BuildFilePropertiesPanel {
private static final ColumnInfo[] PROPERTY_COLUMNS = new ColumnInfo[]{NAME_COLUMN, VALUE_COLUMN};
public PropertiesTab() {
+ myPropertiesTable = new JBTable();
UIPropertyBinding.TableListBinding tableListBinding = getBinding().bindList(myPropertiesTable, PROPERTY_COLUMNS,
- AntBuildFileImpl.ANT_PROPERTIES);
+ AntBuildFileImpl.ANT_PROPERTIES);
tableListBinding.setColumnWidths(GlobalAntConfiguration.PROPERTIES_TABLE_LAYOUT);
- tableListBinding.addAddFacility(myAddButton, NewInstanceFactory.fromClass(BuildFileProperty.class));
- tableListBinding.addRemoveFacility(myRemoveButton, Condition.TRUE);
+
+ myWholePanel = ToolbarDecorator.createDecorator(myPropertiesTable)
+ .setAddAction(new AnActionButtonRunnable() {
+
+
+ @Override
+ public void run(AnActionButton button) {
+ if (myPropertiesTable.isEditing() && !myPropertiesTable.getCellEditor().stopCellEditing()) {
+ return;
+ }
+ BuildFileProperty item = new BuildFileProperty();
+ ListTableModel model = (ListTableModel)myPropertiesTable.getModel();
+ ArrayList items = new ArrayList(model.getItems());
+ items.add(item);
+ model.setItems(items);
+ int newIndex = model.indexOf(item);
+ ListSelectionModel selectionModel = myPropertiesTable.getSelectionModel();
+ selectionModel.clearSelection();
+ selectionModel.setSelectionInterval(newIndex, newIndex);
+ ColumnInfo[] columns = model.getColumnInfos();
+ for (int i = 0; i < columns.length; i++) {
+ ColumnInfo column = columns[i];
+ if (column.isCellEditable(item)) {
+ myPropertiesTable.requestFocusInWindow();
+ myPropertiesTable.editCellAt(newIndex, i);
+ break;
+ }
+ }
+ }
+ }).disableUpDownActions().createPanel();
+ myWholePanel.setBorder(null);
}
public JComponent getComponent() {
@@ -288,9 +313,9 @@ public class BuildFilePropertiesPanel {
private static final Comparator NAME_COMPARATOR = new Comparator() {
public int compare(TargetFilter o1, TargetFilter o2) {
final String name1 = o1.getTargetName();
- if(name1 == null) return -1;
+ if (name1 == null) return -1;
final String name2 = o2.getTargetName();
- if(name2 == null) return 1;
+ if (name2 == null) return 1;
return name1.compareToIgnoreCase(name2);
}
};
@@ -482,5 +507,4 @@ public class BuildFilePropertiesPanel {
private static void setLabelFor(JLabel label, ComponentWithBrowseButton component) {
label.setLabelFor(component.getChildComponent());
}
-
}
diff --git a/plugins/ant/src/com/intellij/lang/ant/config/impl/configuration/FiltersTab.form b/plugins/ant/src/com/intellij/lang/ant/config/impl/configuration/FiltersTab.form
index 33932c1f1244..5083f5d7a604 100644
--- a/plugins/ant/src/com/intellij/lang/ant/config/impl/configuration/FiltersTab.form
+++ b/plugins/ant/src/com/intellij/lang/ant/config/impl/configuration/FiltersTab.form
@@ -1,24 +1,16 @@