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/debugger/openapi/debugger-openapi.iml b/java/debugger/openapi/debugger-openapi.iml
index ff0584c35f08..52013f3be018 100644
--- a/java/debugger/openapi/debugger-openapi.iml
+++ b/java/debugger/openapi/debugger-openapi.iml
@@ -10,6 +10,7 @@
+
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/codeInspection/dataFlow/DfaMemoryStateImpl.java b/java/java-impl/src/com/intellij/codeInspection/dataFlow/DfaMemoryStateImpl.java
index b85c5fc4a1b0..2b4005a40ef8 100644
--- a/java/java-impl/src/com/intellij/codeInspection/dataFlow/DfaMemoryStateImpl.java
+++ b/java/java-impl/src/com/intellij/codeInspection/dataFlow/DfaMemoryStateImpl.java
@@ -568,6 +568,7 @@ public class DfaMemoryStateImpl implements DfaMemoryState {
return true;
}
+ /*
if (dfaRight instanceof DfaNotNullValue) {
if (dfaLeft instanceof DfaVariableValue) {
DfaVariableState varState = getVariableState((DfaVariableValue)dfaLeft);
@@ -576,11 +577,12 @@ public class DfaMemoryStateImpl implements DfaMemoryState {
if (isNegated) {
return varState.addNotInstanceofValue(type) || applyCondition(compareToNull(dfaVar, false));
}
- return applyCondition(compareToNull(dfaVar, false)) && varState.setInstanceofValue(type);
+ return applyCondition(compareToNull(dfaVar, true)) && varState.setInstanceofValue(type);
}
return true;
}
+ */
if (dfaRight == myFactory.getConstFactory().getNull() && dfaLeft instanceof DfaVariableValue) {
final DfaVariableState varState = getVariableState((DfaVariableValue)dfaLeft);
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/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionFixtureTest.java b/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionFixtureTest.java
index 160e94d71460..a4b7ec1fe242 100644
--- a/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionFixtureTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionFixtureTest.java
@@ -50,7 +50,7 @@ public class DataFlowInspectionFixtureTest extends JavaCodeInsightFixtureTestCas
public void testFieldInAnonymous() throws Throwable { doTest(); }
public void testNullableField() throws Throwable { doTest(); }
public void testCanBeNullDoesntImplyIsNull() throws Throwable { doTest(); }
- public void testAnnReport() throws Throwable { doTest(); }
+ /*public void testAnnReport() throws Throwable { doTest(); }*/
public void testBigMethodNotComplex() throws Throwable { doTest(); }
}
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/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..c12f291f9431 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,17 @@ 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;
+ PsiFile file = context.getContainingFile();
+ if (file == null) return defaultLanguage;
+ Language contextLanguage = context.getLanguage();
+ Language language = file.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/icons/src/general/collapseAllHover.png b/platform/icons/src/general/collapseAllHover.png
new file mode 100755
index 000000000000..c06145527144
Binary files /dev/null and b/platform/icons/src/general/collapseAllHover.png differ
diff --git a/platform/icons/src/general/gearHover.png b/platform/icons/src/general/gearHover.png
new file mode 100755
index 000000000000..4d4518ab2b76
Binary files /dev/null and b/platform/icons/src/general/gearHover.png differ
diff --git a/platform/icons/src/general/hideDownHover.png b/platform/icons/src/general/hideDownHover.png
new file mode 100755
index 000000000000..66dd0339f008
Binary files /dev/null and b/platform/icons/src/general/hideDownHover.png differ
diff --git a/platform/icons/src/general/hideDownPartHover.png b/platform/icons/src/general/hideDownPartHover.png
new file mode 100755
index 000000000000..97d7fda24393
Binary files /dev/null and b/platform/icons/src/general/hideDownPartHover.png differ
diff --git a/platform/icons/src/general/hideLeftHover.png b/platform/icons/src/general/hideLeftHover.png
new file mode 100755
index 000000000000..37e59950136e
Binary files /dev/null and b/platform/icons/src/general/hideLeftHover.png differ
diff --git a/platform/icons/src/general/hideLeftPartHover.png b/platform/icons/src/general/hideLeftPartHover.png
new file mode 100755
index 000000000000..220e5f025d04
Binary files /dev/null and b/platform/icons/src/general/hideLeftPartHover.png differ
diff --git a/platform/icons/src/general/hideRightHover.png b/platform/icons/src/general/hideRightHover.png
new file mode 100755
index 000000000000..f971f5cdab81
Binary files /dev/null and b/platform/icons/src/general/hideRightHover.png differ
diff --git a/platform/icons/src/general/hideRightPartHover.png b/platform/icons/src/general/hideRightPartHover.png
new file mode 100755
index 000000000000..e4daccb90838
Binary files /dev/null and b/platform/icons/src/general/hideRightPartHover.png differ
diff --git a/platform/icons/src/general/locateHover.png b/platform/icons/src/general/locateHover.png
new file mode 100755
index 000000000000..670999a7e8f8
Binary files /dev/null and b/platform/icons/src/general/locateHover.png differ
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/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/lang-impl/src/com/intellij/ide/projectView/impl/ProjectViewImpl.java b/platform/lang-impl/src/com/intellij/ide/projectView/impl/ProjectViewImpl.java
index c75b4662f6f5..08d9c320118f 100644
--- a/platform/lang-impl/src/com/intellij/ide/projectView/impl/ProjectViewImpl.java
+++ b/platform/lang-impl/src/com/intellij/ide/projectView/impl/ProjectViewImpl.java
@@ -512,6 +512,7 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
if (action instanceof CollapseAllToolbarAction) {
collapseAction = (CollapseAllToolbarAction)action;
collapseAction.getTemplatePresentation().setIcon(IconLoader.getIcon("/general/collapseAll.png"));
+ collapseAction.getTemplatePresentation().setHoveredIcon(IconLoader.getIcon("/general/collapseAllHover.png"));
myActionGroup.remove(collapseAction);
}
}
@@ -1710,6 +1711,7 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
private class ScrollFromSourceAction extends AnAction implements DumbAware {
private ScrollFromSourceAction() {
super("Scroll from Source", "Select the file open in the active editor", IconLoader.getIcon("/general/locate.png"));
+ getTemplatePresentation().setHoveredIcon(IconLoader.getIcon("/general/locateHover.png"));
}
@Override
diff --git a/platform/lang-impl/src/com/intellij/psi/impl/source/ParsingContext.java b/platform/lang-impl/src/com/intellij/psi/impl/source/ParsingContext.java
deleted file mode 100644
index a45ac8c81132..000000000000
--- a/platform/lang-impl/src/com/intellij/psi/impl/source/ParsingContext.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright 2000-2009 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.psi.impl.source;
-
-import com.intellij.lexer.Lexer;
-import com.intellij.lexer.LexerUtil;
-import com.intellij.util.CharTable;
-
-/**
- * @author ven
- */
-public class ParsingContext {
- private final CharTable myTable;
-
- public ParsingContext(final CharTable table) {
- myTable = table;
- }
-
- public CharTable getCharTable() {
- return myTable;
- }
-
- public CharSequence tokenText(Lexer lexer) {
- return LexerUtil.internToken(lexer, myTable);
- }
-}
diff --git a/platform/lang-impl/src/com/intellij/psi/impl/source/parsing/DefaultWhiteSpaceTokenProcessorImpl.java b/platform/lang-impl/src/com/intellij/psi/impl/source/parsing/DefaultWhiteSpaceTokenProcessorImpl.java
deleted file mode 100644
index b495d0e12907..000000000000
--- a/platform/lang-impl/src/com/intellij/psi/impl/source/parsing/DefaultWhiteSpaceTokenProcessorImpl.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright 2000-2009 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.psi.impl.source.parsing;
-
-import com.intellij.lang.ASTFactory;
-import com.intellij.lexer.Lexer;
-import com.intellij.openapi.diagnostic.Logger;
-import com.intellij.psi.impl.source.ParsingContext;
-import com.intellij.psi.impl.source.tree.TreeElement;
-import com.intellij.psi.tree.IElementType;
-
-public abstract class DefaultWhiteSpaceTokenProcessorImpl implements TokenProcessor {
- private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.source.parsing.DefaultWhiteSpaceTokenProcessorImpl");
-
- @Override
- public boolean isTokenValid(IElementType tokenType) {
- return tokenType != null && isInSet(tokenType);
- }
-
- @Override
- public TreeElement process(Lexer lexer, ParsingContext context) {
- TreeElement first = null;
- TreeElement last = null;
- while (isTokenValid(lexer.getTokenType())) {
- TreeElement tokenElement = ASTFactory.leaf(lexer.getTokenType(), context.tokenText(lexer));
- IElementType type = lexer.getTokenType();
-
- if (!isInSet(type)) {
- LOG.error("Missed token should be white space or comment:" + tokenElement + "; type:" + type);
- throw new RuntimeException();
- }
- if (last != null) {
- last.rawInsertAfterMe(tokenElement);
- last = tokenElement;
- }
- else {
- first = last = tokenElement;
- }
- lexer.advance();
- }
- return first;
- }
-
- protected abstract boolean isInSet(final IElementType type);
-}
diff --git a/platform/lang-impl/src/com/intellij/psi/impl/source/parsing/MissingTokenInserter.java b/platform/lang-impl/src/com/intellij/psi/impl/source/parsing/MissingTokenInserter.java
deleted file mode 100644
index 5f69fe29d7d0..000000000000
--- a/platform/lang-impl/src/com/intellij/psi/impl/source/parsing/MissingTokenInserter.java
+++ /dev/null
@@ -1,173 +0,0 @@
-/*
- * Copyright 2000-2009 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.psi.impl.source.parsing;
-
-import com.intellij.lang.ASTNode;
-import com.intellij.lexer.Lexer;
-import com.intellij.psi.impl.source.ParsingContext;
-import com.intellij.psi.impl.source.tree.CompositeElement;
-import com.intellij.psi.impl.source.tree.LeafElement;
-import com.intellij.psi.impl.source.tree.TreeElement;
-import com.intellij.psi.impl.source.tree.TreeUtil;
-import com.intellij.psi.templateLanguages.OuterLanguageElement;
-import com.intellij.psi.tree.IElementType;
-import com.intellij.psi.tree.ILazyParseableElementType;
-
-public class MissingTokenInserter {
- protected final CompositeElement myRoot;
- protected final Lexer myLexer;
- private final int myStartOffset;
- private final int myEndOffset;
- private final int myState;
- private final TokenProcessor myProcessor;
- private final ParsingContext myContext;
-
- public MissingTokenInserter(final CompositeElement root,
- final Lexer lexer,
- final int startOffset,
- final int endOffset,
- final int state,
- final TokenProcessor processor,
- final ParsingContext context) {
- myRoot = root;
- myLexer = lexer;
- myStartOffset = startOffset;
- myEndOffset = endOffset;
- myState = state;
- myProcessor = processor;
- myContext = context;
- }
-
- public void invoke() {
- if (myState < 0) {
- myLexer.start(myLexer.getBufferSequence(), myStartOffset, myEndOffset);
- }
- else {
- myLexer.start(myLexer.getBufferSequence(), myStartOffset, myEndOffset, myState);
- }
-
- TreeElement leaf = TreeUtil.findFirstLeafOrChameleon(myRoot);
- if (leaf == null) {
- final TreeElement firstMissing = myProcessor.process(myLexer, myContext);
- if (firstMissing != null) {
- myRoot.rawAddChildren(firstMissing);
- }
- return;
- }
- else {
- // Missing in the beginning
- final IElementType tokenType = getNextTokenType();
- if (tokenType != leaf.getElementType() && myProcessor.isTokenValid(tokenType)) {
- final TreeElement firstMissing = myProcessor.process(myLexer, myContext);
- if (firstMissing != null) {
- myRoot.getFirstChildNode().rawInsertBeforeMe(firstMissing);
- }
- }
- passTokenOrChameleon(leaf);
- }
- // Missing in tree body
- insertMissingTokensInTreeBody(leaf);
- if (myLexer.getTokenType() != null) {
- // whitespaces at the end of the file
- final TreeElement firstMissing = myProcessor.process(myLexer, myContext);
- if (firstMissing != null) {
- ASTNode current = myRoot;
- while (current instanceof CompositeElement) {
- if (current.getUserData(TreeUtil.UNCLOSED_ELEMENT_PROPERTY) != null) break;
- current = current.getLastChildNode();
- }
- if (current instanceof CompositeElement) {
- ((CompositeElement)current).rawAddChildren(firstMissing);
- }
- else {
- myRoot.getLastChildNode().rawInsertAfterMe(firstMissing);
- }
- }
- }
- }
-
- protected IElementType getNextTokenType() {
- return myLexer.getTokenType();
- }
-
- private void insertMissingTokensInTreeBody(TreeElement leaf) {
- final TreeUtil.CommonParentState commonParents = new TreeUtil.CommonParentState();
- while (leaf != null) {
- commonParents.strongWhiteSpaceHolder = null;
- final IElementType tokenType = getNextTokenType();
- final TreeElement next = TreeUtil.nextLeaf(leaf, commonParents, tokenType instanceof ILazyParseableElementType ? tokenType : null, false);
-
- if (next == null || tokenType == null) break;
- if (tokenType != next.getElementType() && myProcessor.isTokenValid(tokenType)) {
- final TreeElement firstMissing = myProcessor.process(myLexer, myContext);
- final CompositeElement unclosedElement = commonParents.strongWhiteSpaceHolder;
- if (unclosedElement != null) {
- if (commonParents.isStrongElementOnRisingSlope || unclosedElement.getFirstChildNode() == null) {
- unclosedElement.rawAddChildren(firstMissing);
- }
- else {
- unclosedElement.getFirstChildNode().rawInsertBeforeMe(firstMissing);
- }
- }
- else {
- final ASTNode insertBefore = commonParents.nextLeafBranchStart;
- TreeElement insertAfter = commonParents.startLeafBranchStart;
- TreeElement current = commonParents.startLeafBranchStart;
- while (current != insertBefore) {
- final TreeElement treeNext = current.getTreeNext();
- if (treeNext == insertBefore) {
- insertAfter = current;
- break;
- }
- if (isInsertAfterElement(treeNext)) {
- insertAfter = current;
- break;
- }
- if (treeNext.getUserData(TreeUtil.UNCLOSED_ELEMENT_PROPERTY) != null) {
- insertAfter = null;
- ((CompositeElement)treeNext).rawAddChildren(firstMissing);
- break;
- }
- current = treeNext;
- }
- if (insertAfter != null) insertAfter.rawInsertAfterMe(firstMissing);
- }
- }
- passTokenOrChameleon(next);
- leaf = next;
- }
- }
-
- protected boolean isInsertAfterElement(TreeElement treeNext) {
- return false;
- }
-
- private void passTokenOrChameleon(final ASTNode node) {
- if (node instanceof LeafElement && node instanceof OuterLanguageElement
- || TreeUtil.isCollapsedChameleon(node)) {
- final int endOfChameleon = node.getTextLength() + myLexer.getTokenStart();
- while (myLexer.getTokenType() != null && myLexer.getTokenEnd() < endOfChameleon) {
- myLexer.advance();
- }
- }
- advanceLexer(node);
- }
-
- protected void advanceLexer(final ASTNode next) {
- myLexer.advance();
- }
-}
diff --git a/platform/lang-impl/src/com/intellij/psi/impl/source/parsing/TokenProcessor.java b/platform/lang-impl/src/com/intellij/psi/impl/source/parsing/TokenProcessor.java
deleted file mode 100644
index b94573c0ac99..000000000000
--- a/platform/lang-impl/src/com/intellij/psi/impl/source/parsing/TokenProcessor.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright 2000-2009 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.psi.impl.source.parsing;
-
-import org.jetbrains.annotations.Nullable;
-import com.intellij.psi.impl.source.tree.TreeElement;
-import com.intellij.psi.impl.source.ParsingContext;
-import com.intellij.psi.tree.IElementType;
-import com.intellij.lexer.Lexer;
-
-public interface TokenProcessor {
- @Nullable
- TreeElement process(Lexer lexer, ParsingContext context);
-
- boolean isTokenValid(IElementType tokenType);
-}
diff --git a/platform/platform-api/src/com/intellij/openapi/editor/colors/EditorColorsManager.java b/platform/platform-api/src/com/intellij/openapi/editor/colors/EditorColorsManager.java
index 4a5c1f51d692..037df73d11ff 100644
--- a/platform/platform-api/src/com/intellij/openapi/editor/colors/EditorColorsManager.java
+++ b/platform/platform-api/src/com/intellij/openapi/editor/colors/EditorColorsManager.java
@@ -18,6 +18,7 @@ package com.intellij.openapi.editor.colors;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.components.ServiceManager;
import org.jetbrains.annotations.NonNls;
+import org.jetbrains.annotations.NotNull;
public abstract class EditorColorsManager {
@NonNls public static final String DEFAULT_SCHEME_NAME = "Default";
diff --git a/platform/platform-api/src/com/intellij/ui/ToolbarDecorator.java b/platform/platform-api/src/com/intellij/ui/ToolbarDecorator.java
index 6ae7c8641b7a..40bba4bb9849 100644
--- a/platform/platform-api/src/com/intellij/ui/ToolbarDecorator.java
+++ b/platform/platform-api/src/com/intellij/ui/ToolbarDecorator.java
@@ -17,7 +17,6 @@ package com.intellij.ui;
import com.intellij.ide.DataManager;
import com.intellij.openapi.actionSystem.*;
-import com.intellij.openapi.util.SystemInfo;
import com.intellij.ui.border.CustomLineBorder;
import com.intellij.ui.table.TableView;
import com.intellij.util.ui.ElementProducer;
@@ -89,8 +88,11 @@ public abstract class ToolbarDecorator implements DataProvider, CommonActionsPan
}
protected ToolbarDecorator initPositionAndBorder() {
- myToolbarPosition = SystemInfo.isMac ? ActionToolbarPosition.BOTTOM : ActionToolbarPosition.RIGHT;
- myBorder = new CustomLineBorder(0, SystemInfo.isMac ? 0 : 1, 0, 0);
+ myToolbarPosition = UIUtil.isUnderAquaLookAndFeel() ? ActionToolbarPosition.BOTTOM : ActionToolbarPosition.RIGHT;
+ myBorder = new CustomLineBorder(0,
+ myToolbarPosition == ActionToolbarPosition.RIGHT ? 1 : 0,
+ myToolbarPosition == ActionToolbarPosition.TOP ? 1 : 0,
+ myToolbarPosition == ActionToolbarPosition.LEFT ? 1 : 0);
final JComponent c = getComponent();
if (c != null) {
c.setBorder(IdeBorderFactory.createEmptyBorder(0));
@@ -180,6 +182,10 @@ public abstract class ToolbarDecorator implements DataProvider, CommonActionsPan
public ToolbarDecorator setToolbarPosition(ActionToolbarPosition position) {
myToolbarPosition = position;
+ myBorder = new CustomLineBorder(0,
+ myToolbarPosition == ActionToolbarPosition.RIGHT ? 1 : 0,
+ myToolbarPosition == ActionToolbarPosition.TOP ? 1 : 0,
+ myToolbarPosition == ActionToolbarPosition.LEFT ? 1 : 0);
return this;
}
diff --git a/platform/platform-api/src/com/intellij/ui/tabs/impl/DragHelper.java b/platform/platform-api/src/com/intellij/ui/tabs/impl/DragHelper.java
index 0875bffe57e5..6e1186198afb 100644
--- a/platform/platform-api/src/com/intellij/ui/tabs/impl/DragHelper.java
+++ b/platform/platform-api/src/com/intellij/ui/tabs/impl/DragHelper.java
@@ -50,6 +50,7 @@ class DragHelper extends MouseDragHelper {
if (myDragSource == null || !myDragSource.canBeDraggedOut()) return false;
TabLabel label = myTabs.myInfo2Label.get(myDragSource);
+ if (label == null) return false;
int dX = dragToScreenPoint.x - startScreenPoint.x;
int dY = dragToScreenPoint.y - startScreenPoint.y;
diff --git a/platform/platform-api/src/com/intellij/ui/tabs/impl/TabLayout.java b/platform/platform-api/src/com/intellij/ui/tabs/impl/TabLayout.java
index 8a452c998e70..5ced062c8543 100644
--- a/platform/platform-api/src/com/intellij/ui/tabs/impl/TabLayout.java
+++ b/platform/platform-api/src/com/intellij/ui/tabs/impl/TabLayout.java
@@ -16,7 +16,7 @@
package com.intellij.ui.tabs.impl;
import com.intellij.openapi.util.registry.Registry;
-import com.intellij.ui.awt.RelativePoint;
+import org.jetbrains.annotations.NotNull;
import java.awt.*;
@@ -31,7 +31,7 @@ public abstract class TabLayout {
return new ShapeTransform.Top(rectangle);
}
- public boolean isDragOut(TabLabel tabLabel, int deltaX, int deltaY) {
+ public boolean isDragOut(@NotNull TabLabel tabLabel, int deltaX, int deltaY) {
return Math.abs(deltaY) > tabLabel.getSize().height * getDragOutMultiplier();
}
diff --git a/platform/platform-impl/src/com/intellij/idea/StartupUtil.java b/platform/platform-impl/src/com/intellij/idea/StartupUtil.java
index 0127e75b5b8d..5412e6e1f3eb 100644
--- a/platform/platform-impl/src/com/intellij/idea/StartupUtil.java
+++ b/platform/platform-impl/src/com/intellij/idea/StartupUtil.java
@@ -99,6 +99,26 @@ public class StartupUtil {
return true;
}
+ private synchronized static boolean checkSystemFolders() {
+ final String configPath = PathManager.getConfigPath();
+ if (configPath == null || !new File(configPath).isDirectory()) {
+ showError("Invalid config path", "Config path '" + configPath + "' is invalid.\n" +
+ "If you have modified the 'idea.config.path' property please make sure it is correct,\n" +
+ "otherwise please re-install the IDE.");
+ return false;
+ }
+
+ final String systemPath = PathManager.getSystemPath();
+ if (systemPath == null || !new File(systemPath).isDirectory()) {
+ showError("Invalid system path", "System path '" + systemPath + "' is invalid.\n" +
+ "If you have modified the 'idea.system.path' property please make sure it is correct,\n" +
+ "otherwise please re-install the IDE.");
+ return false;
+ }
+
+ return true;
+ }
+
private synchronized static boolean lockSystemFolders(String[] args) {
if (ourLock == null) {
ourLock = new SocketLock();
@@ -122,14 +142,22 @@ public class StartupUtil {
private static boolean checkTmpIsAccessible() {
if (!SystemInfo.isUnix || SystemInfo.isMac) return true;
+ final File tmpDir = new File(System.getProperty("java.io.tmpdir"));
+ if (!tmpDir.isDirectory()) {
+ showError("Inaccessible Temp Directory", "Temp directory '" + tmpDir + "' does not exist.\n" +
+ "Please set 'java.io.tmpdir' system property to point to an existing directory.");
+ return false;
+ }
+
final File tmp;
try {
- tmp = FileUtil.createTempFile("idea_check_", ".tmp");
+ //noinspection SSBasedInspection
+ tmp = File.createTempFile("idea_tmp_check_", ".sh", tmpDir);
FileUtil.writeToFile(tmp, "#!/bin/sh\n" +
"exit 0");
}
catch (IOException e) {
- showError("Inaccessible Temp Directory", e.getMessage() + " (" + FileUtil.getTempDirectory() + ").\n" +
+ showError("Inaccessible Temp Directory", e.getMessage() + " (" + tmpDir + ").\n" +
"Temp directory is not accessible.\n" +
"Please set 'java.io.tmpdir' system property to point to a writable directory.");
return false;
@@ -161,12 +189,14 @@ public class StartupUtil {
return false;
}
-
return true;
}
static boolean checkStartupPossible(String[] args) {
- return checkJdkVersion() && lockSystemFolders(args) && checkTmpIsAccessible();
+ return checkJdkVersion() &&
+ checkTmpIsAccessible() &&
+ checkSystemFolders() &&
+ lockSystemFolders(args);
}
static void runStartupWizard() {
diff --git a/platform/platform-impl/src/com/intellij/notification/impl/NotificationsConfigurationImpl.java b/platform/platform-impl/src/com/intellij/notification/impl/NotificationsConfigurationImpl.java
index f620dba5529c..5b7ca893a0eb 100644
--- a/platform/platform-impl/src/com/intellij/notification/impl/NotificationsConfigurationImpl.java
+++ b/platform/platform-impl/src/com/intellij/notification/impl/NotificationsConfigurationImpl.java
@@ -172,6 +172,7 @@ public class NotificationsConfigurationImpl extends NotificationsConfiguration i
}
public synchronized void loadState(final Element state) {
+ myIdToSettingsMap.clear();
for (@NonNls Element child : (Iterable extends Element>)state.getChildren("notification")) {
final NotificationSettings settings = NotificationSettings.load(child);
if (settings != null) {
diff --git a/platform/platform-impl/src/com/intellij/openapi/diff/ex/DiffStatusBar.java b/platform/platform-impl/src/com/intellij/openapi/diff/ex/DiffStatusBar.java
index a7379192358e..7f3edab64237 100644
--- a/platform/platform-impl/src/com/intellij/openapi/diff/ex/DiffStatusBar.java
+++ b/platform/platform-impl/src/com/intellij/openapi/diff/ex/DiffStatusBar.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * 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.
@@ -17,7 +17,6 @@ package com.intellij.openapi.diff.ex;
import com.intellij.openapi.editor.colors.EditorColorsManager;
import com.intellij.openapi.editor.colors.EditorColorsScheme;
-import com.intellij.ui.IdeBorderFactory;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.Nullable;
@@ -109,8 +108,7 @@ public class DiffStatusBar extends JPanel {
}
};
setLayout(new BorderLayout());
- setBorder(BorderFactory.createCompoundBorder(IdeBorderFactory.createBorder(),
- BorderFactory.createEmptyBorder(3, 20, 3, 20)));
+ setBorder(BorderFactory.createEmptyBorder(3, 20, 3, 20));
add(myTextLabel, BorderLayout.WEST);
Box box = Box.createHorizontalBox();
diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/EditorColorsManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/EditorColorsManagerImpl.java
index fc9c085ad7c9..4a27a07a35a5 100644
--- a/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/EditorColorsManagerImpl.java
+++ b/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/EditorColorsManagerImpl.java
@@ -285,13 +285,21 @@ public class EditorColorsManagerImpl extends EditorColorsManager implements Name
@Override
public void setGlobalScheme(EditorColorsScheme scheme) {
- mySchemesManager.setCurrentSchemeName(scheme == null ? DefaultColorSchemesManager.getInstance().getAllSchemes()[0].getName() : scheme.getName());
+ mySchemesManager.setCurrentSchemeName(scheme == null ? getDefaultScheme().getName() : scheme.getName());
fireChanges(scheme);
}
+ private static DefaultColorsScheme getDefaultScheme() {
+ return DefaultColorSchemesManager.getInstance().getAllSchemes()[0];
+ }
+
@Override
public EditorColorsScheme getGlobalScheme() {
- return mySchemesManager.getCurrentScheme();
+ final EditorColorsScheme scheme = mySchemesManager.getCurrentScheme();
+ if (scheme == null) {
+ return getDefaultScheme();
+ }
+ return scheme;
}
@Override
diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/highlighter/EditorHighlighterFactoryImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/highlighter/EditorHighlighterFactoryImpl.java
index 58c19f686397..e53742e1e2f4 100644
--- a/platform/platform-impl/src/com/intellij/openapi/editor/highlighter/EditorHighlighterFactoryImpl.java
+++ b/platform/platform-impl/src/com/intellij/openapi/editor/highlighter/EditorHighlighterFactoryImpl.java
@@ -54,7 +54,7 @@ public class EditorHighlighterFactoryImpl extends EditorHighlighterFactory {
}
@Override
- public EditorHighlighter createEditorHighlighter(@NotNull final VirtualFile vFile, final EditorColorsScheme settings, final Project project) {
+ public EditorHighlighter createEditorHighlighter(@NotNull final VirtualFile vFile, @NotNull final EditorColorsScheme settings, final Project project) {
final FileType fileType = vFile.getFileType();
if (fileType instanceof LanguageFileType) {
LanguageFileType substFileType = substituteFileType(((LanguageFileType)fileType).getLanguage(), vFile, project);
diff --git a/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/CheckForUpdateAction.java b/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/CheckForUpdateAction.java
index f9cd94fea2d6..719dd5276cd4 100644
--- a/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/CheckForUpdateAction.java
+++ b/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/CheckForUpdateAction.java
@@ -40,14 +40,17 @@ public class CheckForUpdateAction extends AnAction implements DumbAware {
public void actionPerformed(AnActionEvent e) {
Project project = e.getData(PlatformDataKeys.PROJECT);
- actionPerformed(project, true, null);
+ actionPerformed(project, true, null, UpdateSettings.getInstance());
}
- public static void actionPerformed(Project project, final boolean enableLink, final @Nullable PluginHostsConfigurable hostsConfigurable) {
+ public static void actionPerformed(Project project,
+ final boolean enableLink,
+ final @Nullable PluginHostsConfigurable hostsConfigurable,
+ final UpdateSettings instance) {
ProgressManager.getInstance().run(new Task.Modal(project, "Checking for updates", false) {
@Override
public void run(@NotNull ProgressIndicator indicator) {
- final CheckForUpdateResult result = UpdateChecker.checkForUpdates(UpdateSettings.getInstance(), PropertiesComponent.getInstance(),
+ final CheckForUpdateResult result = UpdateChecker.checkForUpdates(instance, PropertiesComponent.getInstance(),
true
);
@@ -60,7 +63,7 @@ public class CheckForUpdateAction extends AnAction implements DumbAware {
return;
}
- UpdateSettings.getInstance().LAST_TIME_CHECKED = System.currentTimeMillis();
+ instance.LAST_TIME_CHECKED = System.currentTimeMillis();
UpdateChecker.showUpdateResult(result, updatedPlugins, true, enableLink, true);
}
});
diff --git a/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdateSettingsConfigurable.java b/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdateSettingsConfigurable.java
index 34c8f76d896f..4b78b9a77f3a 100644
--- a/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdateSettingsConfigurable.java
+++ b/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdateSettingsConfigurable.java
@@ -20,7 +20,6 @@ import com.intellij.ide.IdeBundle;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.application.ApplicationInfo;
import com.intellij.openapi.options.BaseConfigurable;
-import com.intellij.openapi.options.Configurable;
import com.intellij.openapi.options.ConfigurationException;
import com.intellij.openapi.options.SearchableConfigurable;
import com.intellij.openapi.project.Project;
@@ -118,7 +117,10 @@ public class UpdateSettingsConfigurable extends BaseConfigurable implements Sear
myBtnCheckNow.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Project project = PlatformDataKeys.PROJECT.getData(DataManager.getInstance().getDataContext(myBtnCheckNow));
- CheckForUpdateAction.actionPerformed(project, false, null); //todo load configured hosts on the fly
+ UpdateSettings settings = new UpdateSettings();
+ settings.loadState(UpdateSettings.getInstance().getState());
+ settings.UPDATE_CHANNEL_TYPE = getSelectedChannelType().getCode();
+ CheckForUpdateAction.actionPerformed(project, false, null, settings); //todo load configured hosts on the fly
updateLastCheckedLabel();
}
});
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/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowHeader.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowHeader.java
index 5abc327da393..cc38413cf978 100644
--- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowHeader.java
+++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowHeader.java
@@ -65,6 +65,16 @@ public abstract class ToolWindowHeader extends JPanel implements Disposable {
private static final Icon ourSettingsIcon = IconLoader.getIcon("/general/gear.png");
private static final Icon ourSeparatorIcon = IconLoader.getIcon("/general/divider.png");
+ private static final Icon ourHideLeftSideHoveredIcon = IconLoader.getIcon("/general/hideLeftHover.png");
+ private static final Icon ourHideRightSideHoveredIcon = IconLoader.getIcon("/general/hideRightHover.png");
+ private static final Icon ourHideDownSideHoveredIcon = IconLoader.getIcon("/general/hideDownHover.png");
+
+ private static final Icon ourHideLeftHoveredIcon = IconLoader.getIcon("/general/hideLeftPartHover.png");
+ private static final Icon ourHideRightHoveredIcon = IconLoader.getIcon("/general/hideRightPartHover.png");
+ private static final Icon ourHideDownHoveredIcon = IconLoader.getIcon("/general/hideDownPartHover.png");
+
+ private static final Icon ourSettingsHoveredIcon = IconLoader.getIcon("/general/gearHover.png");
+
private ToolWindow myToolWindow;
private WindowInfoImpl myInfo;
private final ToolWindowHeader.ActionButton myHideButton;
@@ -126,7 +136,12 @@ public abstract class ToolWindowHeader extends JPanel implements Disposable {
popupMenu.getComponent().show(inputEvent.getComponent(), x, y);
}
- }, ourSettingsIcon);
+ }, ourSettingsIcon) {
+ @Override
+ protected Icon getActiveHoveredIcon() {
+ return ourSettingsHoveredIcon;
+ }
+ };
myHideButton = new ActionButton(new HideAction() {
@Override
@@ -150,6 +165,16 @@ public abstract class ToolWindowHeader extends JPanel implements Disposable {
protected Icon getAlternativeIcon() {
return getHideIcon(myToolWindow);
}
+
+ @Override
+ protected Icon getActiveHoveredIcon() {
+ return getHideToolWindowHoveredIcon(myToolWindow);
+ }
+
+ @Override
+ protected Icon getAlternativeHoveredIcon() {
+ return getHideHoveredIcon(myToolWindow);
+ }
};
addDefaultActions(eastPanel);
@@ -206,9 +231,15 @@ public abstract class ToolWindowHeader extends JPanel implements Disposable {
public void setAdditionalTitleActions(AnAction[] actions) {
myButtonPanel.removeAll();
boolean actionAdded = false;
- for (AnAction action : actions) {
+ for (final AnAction action : actions) {
if (action == null) continue;
- myButtonPanel.add(new ActionButton(action, action.getTemplatePresentation().getIcon()));
+ myButtonPanel.add(new ActionButton(action, action.getTemplatePresentation().getIcon()) {
+ @Override
+ protected Icon getActiveHoveredIcon() {
+ final Icon icon = action.getTemplatePresentation().getHoveredIcon();
+ return icon != null ? icon : super.getActiveHoveredIcon();
+ }
+ });
myButtonPanel.add(Box.createHorizontalStrut(7));
actionAdded = true;
}
@@ -243,6 +274,30 @@ public abstract class ToolWindowHeader extends JPanel implements Disposable {
return ourHideLeftSideIcon;
}
+ private static Icon getHideToolWindowHoveredIcon(ToolWindow toolWindow) {
+ ToolWindowAnchor anchor = toolWindow.getAnchor();
+ if (anchor == ToolWindowAnchor.BOTTOM) {
+ return ourHideDownHoveredIcon;
+ }
+ else if (anchor == ToolWindowAnchor.RIGHT) {
+ return ourHideRightHoveredIcon;
+ }
+
+ return ourHideLeftHoveredIcon;
+ }
+
+ private static Icon getHideHoveredIcon(ToolWindow toolWindow) {
+ ToolWindowAnchor anchor = toolWindow.getAnchor();
+ if (anchor == ToolWindowAnchor.BOTTOM) {
+ return ourHideDownSideHoveredIcon;
+ }
+ else if (anchor == ToolWindowAnchor.RIGHT) {
+ return ourHideRightSideHoveredIcon;
+ }
+
+ return ourHideLeftSideHoveredIcon;
+ }
+
@Override
protected void paintComponent(Graphics g) {
Rectangle r = getBounds();
@@ -375,11 +430,11 @@ public abstract class ToolWindowHeader extends JPanel implements Disposable {
}
};
- myButton.setHoveringEnabled(false);
+ myButton.setHoveringEnabled(true);
setContent(myButton);
setOpaque(false);
- setIcon(getActiveIcon(), getInactiveIcon() == null ? getActiveIcon() : getInactiveIcon());
+ setIcon(getActiveIcon(), getInactiveIcon() == null ? getActiveIcon() : getInactiveIcon(), getActiveHoveredIcon());
PropertyChangeListener listener = new PropertyChangeListener() {
@Override
@@ -408,6 +463,10 @@ public abstract class ToolWindowHeader extends JPanel implements Disposable {
return myActiveIcon;
}
+ protected Icon getActiveHoveredIcon() {
+ return myActiveIcon;
+ }
+
protected Icon getInactiveIcon() {
return myInactiveIcon;
}
@@ -416,12 +475,17 @@ public abstract class ToolWindowHeader extends JPanel implements Disposable {
return myAlternativeIcon;
}
+ protected Icon getAlternativeHoveredIcon() {
+ return myAlternativeIcon;
+ }
+
private void switchAlternativeAction(boolean b) {
if (b && myCurrentAction == myAlternativeAction) return;
if (!b && myCurrentAction != myAlternativeAction) return;
setIcon(b ? getAlternativeIcon() : getActiveIcon(),
- b ? getAlternativeIcon() : getInactiveIcon() == null ? getActiveIcon() : getInactiveIcon());
+ b ? getAlternativeIcon() : getInactiveIcon() == null ? getActiveIcon() : getInactiveIcon(),
+ b ? getAlternativeHoveredIcon() : getActiveHoveredIcon());
myCurrentAction = b ? myAlternativeAction : myAction;
setToolTipText(getToolTipTextByAction(myCurrentAction));
@@ -460,8 +524,8 @@ public abstract class ToolWindowHeader extends JPanel implements Disposable {
return ToolWindowHeader.this.isActive();
}
- public void setIcon(final Icon active, Icon inactive) {
- myButton.setIcons(active, inactive, active);
+ public void setIcon(final Icon active, Icon inactive, Icon hovered) {
+ myButton.setIcons(active, inactive, hovered);
}
public void setToolTipText(final String text) {
diff --git a/platform/platform-main/src/com/intellij/idea/MainImpl.java b/platform/platform-main/src/com/intellij/idea/MainImpl.java
index bd1dfa8060df..7b204d186375 100644
--- a/platform/platform-main/src/com/intellij/idea/MainImpl.java
+++ b/platform/platform-main/src/com/intellij/idea/MainImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2011 JetBrains s.r.o.
+ * 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.
@@ -35,9 +35,8 @@ public class MainImpl {
private MainImpl() { }
/**
- * Is called from PluginManager via reflection.
+ * Called from PluginManager via reflection.
*/
- @SuppressWarnings("UnusedDeclaration")
protected static void start(final String[] args) {
if (System.getProperty("idea.platform.prefix") == null) {
System.setProperty("idea.platform.prefix", "Idea");
@@ -66,8 +65,7 @@ public class MainImpl {
Runtime.getRuntime().addShutdownHook(new Thread("Shutdown hook - logging") {
public void run() {
- LOG.info(
- "------------------------------------------------------ IDE SHUTDOWN ------------------------------------------------------");
+ LOG.info("------------------------------------------------------ IDE SHUTDOWN ------------------------------------------------------");
}
});
LOG.info("------------------------------------------------------ IDE STARTED ------------------------------------------------------");
@@ -86,7 +84,7 @@ public class MainImpl {
// http://weblogs.java.net/blog/shan_man/archive/2005/06/improved_drag_g.html
System.setProperty("sun.swing.enableImprovedDragGesture", "");
- if (SystemInfo.isWindows && !SystemInfo.isWindows9x) {
+ if (SystemInfo.isWindows && !SystemInfo.isWindows9x && !StartupUtil.isHeadless) {
final Logger LOG = Logger.getInstance(LOG_CATEGORY);
try {
if (SystemInfo.isAMD64) {
diff --git a/platform/util/src/com/intellij/openapi/application/PathManager.java b/platform/util/src/com/intellij/openapi/application/PathManager.java
index c053d8f6b176..d9ef319b731f 100644
--- a/platform/util/src/com/intellij/openapi/application/PathManager.java
+++ b/platform/util/src/com/intellij/openapi/application/PathManager.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * 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.
@@ -156,11 +156,11 @@ public class PathManager {
public static boolean ensureConfigFolderExists(final boolean createIfNotExists) {
getConfigPathWithoutDialog();
- File file = new File(ourConfigPath);
+ final File file = new File(ourConfigPath);
if (createIfNotExists && !file.exists()) {
- file.mkdirs();
- return true;
+ return file.mkdirs(); // shouldn't copy configs if failed to create new directory
}
+
return false;
}
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/platform/util/src/com/intellij/openapi/util/io/FileUtil.java b/platform/util/src/com/intellij/openapi/util/io/FileUtil.java
index 512ccc600349..a8ab9439d248 100644
--- a/platform/util/src/com/intellij/openapi/util/io/FileUtil.java
+++ b/platform/util/src/com/intellij/openapi/util/io/FileUtil.java
@@ -35,7 +35,6 @@ import org.intellij.lang.annotations.RegExp;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-import org.jetbrains.annotations.TestOnly;
import java.io.*;
import java.lang.reflect.Method;
@@ -44,7 +43,7 @@ import java.util.*;
import java.util.regex.Pattern;
@SuppressWarnings({"UtilityClassWithoutPrivateConstructor"})
-public class FileUtil {
+public class FileUtil extends FileUtilLight {
public static final int MEGABYTE = 1024 * 1024;
@NonNls public static final String ASYNC_DELETE_EXTENSION = ".__del__";
@@ -58,7 +57,6 @@ public class FileUtil {
// do not use channels to copy files larger than 5 Mb because of possible MapFailed error
private static final long CHANNELS_COPYING_LIMIT = 5L * MEGABYTE;
- private static String ourCanonicalTempPathCache = null;
private static final int MAX_FILE_DELETE_ATTEMPTS = 10;
public static final Method JAVA_IO_FILESYSTEM_GET_BOOLEAN_ATTRIBUTES_METHOD;
public static final Object/* java.io.FileSystem */ JAVA_IO_FILESYSTEM;
@@ -186,63 +184,6 @@ public class FileUtil {
}
}
- @NotNull
- public static String loadFile(@NotNull File file) throws IOException {
- return loadFile(file, null, false);
- }
-
- @NotNull
- public static String loadFile(@NotNull File file, boolean convertLineSeparators) throws IOException {
- return loadFile(file, null, convertLineSeparators);
- }
-
- @NotNull
- public static String loadFile(@NotNull File file, String encoding) throws IOException {
- return loadFile(file, encoding, false);
- }
-
- @NotNull
- public static String loadFile(@NotNull File file, String encoding, boolean convertLineSeparators) throws IOException {
- final String s = new String(loadFileText(file, encoding));
- return convertLineSeparators ? StringUtil.convertLineSeparators(s) : s;
- }
-
- @NotNull
- public static char[] loadFileText(@NotNull File file) throws IOException {
- return loadFileText(file, null);
- }
-
- @NotNull
- public static char[] loadFileText(@NotNull File file, @NonNls String encoding) throws IOException {
- InputStream stream = new FileInputStream(file);
- Reader reader = encoding == null ? new InputStreamReader(stream) : new InputStreamReader(stream, encoding);
- try {
- return loadText(reader, (int)file.length());
- }
- finally {
- reader.close();
- }
- }
-
- @NotNull
- public static char[] loadText(@NotNull Reader reader, int length) throws IOException {
- char[] chars = new char[length];
- int count = 0;
- while (count < chars.length) {
- int n = reader.read(chars, count, chars.length - count);
- if (n <= 0) break;
- count += n;
- }
- if (count == chars.length) {
- return chars;
- }
- else {
- char[] newChars = new char[count];
- System.arraycopy(chars, 0, newChars, 0, count);
- return newChars;
- }
- }
-
@NotNull
public static byte[] loadFileBytes(@NotNull File file) throws IOException {
byte[] bytes;
@@ -396,120 +337,6 @@ public class FileUtil {
return result;
}
- @NotNull
- public static File createTempDirectory(@NotNull @NonNls String prefix, @Nullable @NonNls String suffix) throws IOException {
- File file = doCreateTempFile(prefix, suffix);
- file.delete();
- file.mkdir();
- file.deleteOnExit();
- return file;
- }
-
- @NotNull
- public static File createTempDirectory(File dir, @NotNull @NonNls String prefix, @Nullable @NonNls String suffix) throws IOException {
- File file = doCreateTempFile(prefix, suffix, dir);
- file.delete();
- file.mkdir();
- file.deleteOnExit();
- return file;
- }
-
- @NotNull
- public static File createTempFile(@NonNls final File dir, @NotNull @NonNls String prefix, @Nullable @NonNls String suffix, final boolean create)
- throws IOException {
- return createTempFile(dir, prefix, suffix, create, true);
- }
-
- public static File createTempFile(@NonNls final File dir,
- @NotNull @NonNls String prefix,
- @Nullable @NonNls String suffix,
- final boolean create,
- boolean deleteOnExit) throws IOException {
- File file = doCreateTempFile(prefix, suffix, dir);
- file.delete();
- if (create) {
- file.createNewFile();
- }
- if (deleteOnExit) {
- file.deleteOnExit();
- }
- return file;
- }
-
- @NotNull
- public static File createTempFile(@NotNull @NonNls String prefix, @Nullable @NonNls String suffix) throws IOException {
- return createTempFile(prefix, suffix, false); //false until TeamCity fixes its plugin
- }
-
- @NotNull
- public static File createTempFile(@NotNull @NonNls String prefix, @Nullable @NonNls String suffix, boolean deleteOnExit) throws IOException {
- File file = doCreateTempFile(prefix, suffix);
- file.delete();
- file.createNewFile();
- if (deleteOnExit) {
- file.deleteOnExit();
- }
- return file;
- }
-
- @NotNull
- private static File doCreateTempFile(String prefix, String suffix) throws IOException {
- return doCreateTempFile(prefix, suffix, new File(getTempDirectory()));
- }
-
- @NotNull
- private static File doCreateTempFile(@NotNull String prefix, String suffix, final File dir) throws IOException {
- dir.mkdirs();
-
- if (prefix.length() < 3) {
- prefix = (prefix + "___").substring(0, 3);
- }
-
- int exceptionsCount = 0;
- while (true) {
- try {
- //noinspection SSBasedInspection
- final File temp = File.createTempFile(prefix, suffix, dir);
- return normalizeFile(temp);
- }
- catch (IOException e) { // Win32 createFileExclusively access denied
- if (++exceptionsCount >= 100) {
- throw e;
- }
- }
- }
- }
-
- private static File normalizeFile(File temp) throws IOException {
- final File canonical = temp.getCanonicalFile();
- return SystemInfo.isWindows && canonical.getAbsolutePath().contains(" ") ? temp.getAbsoluteFile() : canonical;
- }
-
- public static String getTempDirectory() {
- if (ourCanonicalTempPathCache == null) {
- ourCanonicalTempPathCache = calcCanonicalTempPath();
- }
- return ourCanonicalTempPathCache;
- }
-
- @TestOnly
- public static void resetCanonicalTempPathCache(final String tempPath) {
- ourCanonicalTempPathCache = tempPath;
- }
-
- private static String calcCanonicalTempPath() {
- final File file = new File(System.getProperty("java.io.tmpdir"));
- try {
- final String canonical = file.getCanonicalPath();
- if (!SystemInfo.isWindows || !canonical.contains(" ")) {
- return canonical;
- }
- }
- catch (IOException ignore) {
- }
- return file.getAbsolutePath();
- }
-
public static void asyncDelete(@NotNull File file) {
final File tempFile = renameToTempFileOrDelete(file);
if (tempFile == null) {
@@ -1130,20 +957,6 @@ public class FileUtil {
}
}
- /**
- * Set executable attribute, it makes sense only on non-windows platforms.
- *
- * @param path the path to use
- * @param executableFlag new value of executable attribute
- * @throws IOException if there is a problem with setting the flag
- */
- public static void setExecutableAttribute(@NotNull String path, boolean executableFlag) throws IOException {
- final File file = new File(path);
- if (!file.setExecutable(executableFlag) && file.canExecute() != executableFlag) {
- LOG.warn("Can't set executable attribute of '" + path + "' to " + executableFlag);
- }
- }
-
public static void appendToFile(@NotNull File file, @NotNull String text) throws IOException {
writeToFile(file, text.getBytes("UTF-8"), true);
}
@@ -1296,20 +1109,6 @@ public class FileUtil {
return false;
}
- @NotNull
- public static File generateRandomTemporaryPath() throws IOException {
- File file = new File(getTempDirectory(), UUID.randomUUID().toString());
- int i = 0;
- while (file.exists() && i < 5) {
- file = new File(getTempDirectory(), UUID.randomUUID().toString());
- ++i;
- }
- if (file.exists()) {
- throw new IOException("Couldn't generate unique random path.");
- }
- return normalizeFile(file);
- }
-
@Nullable
public static String getLocationRelativeToUserHome(@Nullable final String path) {
if (path == null) return null;
diff --git a/platform/util/src/com/intellij/openapi/util/io/FileUtilLight.java b/platform/util/src/com/intellij/openapi/util/io/FileUtilLight.java
new file mode 100644
index 000000000000..ae174b7901d7
--- /dev/null
+++ b/platform/util/src/com/intellij/openapi/util/io/FileUtilLight.java
@@ -0,0 +1,238 @@
+/*
+ * 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.util.io;
+
+import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.openapi.util.SystemInfo;
+import com.intellij.openapi.util.text.StringUtil;
+import org.jetbrains.annotations.NonNls;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.jetbrains.annotations.TestOnly;
+
+import java.io.*;
+import java.util.UUID;
+
+/**
+ * This is a light version of {@link FileUtil}.
+ * It is used by scripts loaded externally and almost independent of IDEA, so add here as few dependencies as possible.
+ */
+public class FileUtilLight {
+
+ private static String ourCanonicalTempPathCache = null;
+ private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.util.io.FileUtilLight");
+
+
+ @NotNull
+ public static File createTempDirectory(@NotNull @NonNls String prefix, @Nullable @NonNls String suffix) throws IOException {
+ File file = doCreateTempFile(prefix, suffix);
+ file.delete();
+ file.mkdir();
+ file.deleteOnExit();
+ return file;
+ }
+
+ @NotNull
+ public static File createTempDirectory(File dir, @NotNull @NonNls String prefix, @Nullable @NonNls String suffix) throws IOException {
+ File file = doCreateTempFile(prefix, suffix, dir);
+ file.delete();
+ file.mkdir();
+ file.deleteOnExit();
+ return file;
+ }
+
+ @NotNull
+ public static File createTempFile(@NonNls final File dir, @NotNull @NonNls String prefix, @Nullable @NonNls String suffix, final boolean create)
+ throws IOException {
+ return createTempFile(dir, prefix, suffix, create, true);
+ }
+
+ public static File createTempFile(@NonNls final File dir,
+ @NotNull @NonNls String prefix,
+ @Nullable @NonNls String suffix,
+ final boolean create,
+ boolean deleteOnExit) throws IOException {
+ File file = doCreateTempFile(prefix, suffix, dir);
+ file.delete();
+ if (create) {
+ file.createNewFile();
+ }
+ if (deleteOnExit) {
+ file.deleteOnExit();
+ }
+ return file;
+ }
+
+ @NotNull
+ public static File createTempFile(@NotNull @NonNls String prefix, @Nullable @NonNls String suffix) throws IOException {
+ return createTempFile(prefix, suffix, false); //false until TeamCity fixes its plugin
+ }
+
+ @NotNull
+ public static File createTempFile(@NotNull @NonNls String prefix, @Nullable @NonNls String suffix, boolean deleteOnExit) throws IOException {
+ File file = doCreateTempFile(prefix, suffix);
+ file.delete();
+ file.createNewFile();
+ if (deleteOnExit) {
+ file.deleteOnExit();
+ }
+ return file;
+ }
+
+ @NotNull
+ private static File doCreateTempFile(String prefix, String suffix) throws IOException {
+ return doCreateTempFile(prefix, suffix, new File(getTempDirectory()));
+ }
+
+ @NotNull
+ private static File doCreateTempFile(@NotNull String prefix, String suffix, final File dir) throws IOException {
+ dir.mkdirs();
+
+ if (prefix.length() < 3) {
+ prefix = (prefix + "___").substring(0, 3);
+ }
+
+ int exceptionsCount = 0;
+ while (true) {
+ try {
+ //noinspection SSBasedInspection
+ final File temp = File.createTempFile(prefix, suffix, dir);
+ return normalizeFile(temp);
+ }
+ catch (IOException e) { // Win32 createFileExclusively access denied
+ if (++exceptionsCount >= 100) {
+ throw e;
+ }
+ }
+ }
+ }
+
+ private static File normalizeFile(File temp) throws IOException {
+ final File canonical = temp.getCanonicalFile();
+ return SystemInfo.isWindows && canonical.getAbsolutePath().contains(" ") ? temp.getAbsoluteFile() : canonical;
+ }
+
+ public static String getTempDirectory() {
+ if (ourCanonicalTempPathCache == null) {
+ ourCanonicalTempPathCache = calcCanonicalTempPath();
+ }
+ return ourCanonicalTempPathCache;
+ }
+
+ private static String calcCanonicalTempPath() {
+ final File file = new File(System.getProperty("java.io.tmpdir"));
+ try {
+ final String canonical = file.getCanonicalPath();
+ if (!SystemInfo.isWindows || !canonical.contains(" ")) {
+ return canonical;
+ }
+ }
+ catch (IOException ignore) {
+ }
+ return file.getAbsolutePath();
+ }
+
+ @TestOnly
+ public static void resetCanonicalTempPathCache(final String tempPath) {
+ ourCanonicalTempPathCache = tempPath;
+ }
+
+ @NotNull
+ public static File generateRandomTemporaryPath() throws IOException {
+ File file = new File(getTempDirectory(), UUID.randomUUID().toString());
+ int i = 0;
+ while (file.exists() && i < 5) {
+ file = new File(getTempDirectory(), UUID.randomUUID().toString());
+ ++i;
+ }
+ if (file.exists()) {
+ throw new IOException("Couldn't generate unique random path.");
+ }
+ return normalizeFile(file);
+ }
+
+ /**
+ * Set executable attribute, it makes sense only on non-windows platforms.
+ *
+ * @param path the path to use
+ * @param executableFlag new value of executable attribute
+ * @throws IOException if there is a problem with setting the flag
+ */
+ public static void setExecutableAttribute(@NotNull String path, boolean executableFlag) throws IOException {
+ final File file = new File(path);
+ if (!file.setExecutable(executableFlag) && file.canExecute() != executableFlag) {
+ LOG.warn("Can't set executable attribute of '" + path + "' to " + executableFlag);
+ }
+ }
+
+ @NotNull
+ public static String loadFile(@NotNull File file) throws IOException {
+ return loadFile(file, null, false);
+ }
+
+ @NotNull
+ public static String loadFile(@NotNull File file, boolean convertLineSeparators) throws IOException {
+ return loadFile(file, null, convertLineSeparators);
+ }
+
+ @NotNull
+ public static String loadFile(@NotNull File file, String encoding) throws IOException {
+ return loadFile(file, encoding, false);
+ }
+
+ @NotNull
+ public static String loadFile(@NotNull File file, String encoding, boolean convertLineSeparators) throws IOException {
+ final String s = new String(loadFileText(file, encoding));
+ return convertLineSeparators ? StringUtil.convertLineSeparators(s) : s;
+ }
+
+ @NotNull
+ public static char[] loadFileText(@NotNull File file) throws IOException {
+ return loadFileText(file, null);
+ }
+
+ @NotNull
+ public static char[] loadFileText(@NotNull File file, @NonNls String encoding) throws IOException {
+ InputStream stream = new FileInputStream(file);
+ Reader reader = encoding == null ? new InputStreamReader(stream) : new InputStreamReader(stream, encoding);
+ try {
+ return loadText(reader, (int)file.length());
+ }
+ finally {
+ reader.close();
+ }
+ }
+
+ @NotNull
+ public static char[] loadText(@NotNull Reader reader, int length) throws IOException {
+ char[] chars = new char[length];
+ int count = 0;
+ while (count < chars.length) {
+ int n = reader.read(chars, count, chars.length - count);
+ if (n <= 0) break;
+ count += n;
+ }
+ if (count == chars.length) {
+ return chars;
+ }
+ else {
+ char[] newChars = new char[count];
+ System.arraycopy(chars, 0, newChars, 0, count);
+ return newChars;
+ }
+ }
+
+}
diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/AbstractRefreshablePanel.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/AbstractRefreshablePanel.java
index 226e1b3c1bb0..af635d50dbe2 100644
--- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/AbstractRefreshablePanel.java
+++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/AbstractRefreshablePanel.java
@@ -135,7 +135,7 @@ public abstract class AbstractRefreshablePanel implements RefreshablePanel {
cause = e;
}
LOG.info(e);
- VcsBalloonProblemNotifier.showOverChangesView(myProject, cause.getMessage(), MessageType.ERROR);
+ VcsBalloonProblemNotifier.showOverChangesView(myProject, cause.getMessage() == null ? e.getMessage() : cause.getMessage(), MessageType.ERROR);
}
@Override
diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XFramesView.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XFramesView.java
index 8627536e625e..91f31c4a3886 100644
--- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XFramesView.java
+++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XFramesView.java
@@ -20,10 +20,10 @@ import com.intellij.ide.CommonActionsManager;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.actionSystem.ActionManager;
import com.intellij.openapi.actionSystem.ActionPlaces;
-import com.intellij.openapi.actionSystem.ActionToolbar;
import com.intellij.openapi.actionSystem.DefaultActionGroup;
import com.intellij.openapi.actionSystem.impl.ActionToolbarImpl;
import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.util.text.StringUtil;
import com.intellij.ui.CaptionPanel;
import com.intellij.ui.ScrollPaneFactory;
import com.intellij.ui.border.CustomLineBorder;
@@ -58,6 +58,8 @@ public class XFramesView extends XDebugViewBase {
private XExecutionStack mySelectedStack;
private boolean myListenersEnabled;
private final Map myBuilders = new HashMap();
+ private final ActionToolbarImpl myToolbar;
+ private final Wrapper myThreadsPanel;
public XFramesView(final XDebugSession session, final Disposable parentDisposable) {
super(session, parentDisposable);
@@ -85,27 +87,28 @@ public class XFramesView extends XDebugViewBase {
myThreadComboBox = new JComboBox();
myThreadComboBox.setRenderer(new ThreadComboBoxRenderer(myThreadComboBox));
myThreadComboBox.addItemListener(new MyItemListener());
- final ActionToolbar toolbar = createToolbar();
- Wrapper threadsPanel = new Wrapper();
+ myToolbar = createToolbar();
+ myThreadsPanel = new Wrapper();
CustomLineBorder border = new CustomLineBorder(CaptionPanel.CNT_ACTIVE_COLOR, 0, 0, 1, 0);
- threadsPanel.setBorder(border);
- threadsPanel.add(toolbar.getComponent(), BorderLayout.EAST);
- threadsPanel.add(myThreadComboBox, BorderLayout.CENTER);
- myMainPanel.add(threadsPanel, BorderLayout.NORTH);
+ myThreadsPanel.setBorder(border);
+ myThreadsPanel.add(myToolbar.getComponent(), BorderLayout.EAST);
+ myThreadsPanel.add(myThreadComboBox, BorderLayout.CENTER);
+ myMainPanel.add(myThreadsPanel, BorderLayout.NORTH);
rebuildView(SessionEvent.RESUMED);
}
- private ActionToolbar createToolbar() {
+ private ActionToolbarImpl createToolbar() {
final DefaultActionGroup framesGroup = new DefaultActionGroup();
CommonActionsManager actionsManager = CommonActionsManager.getInstance();
framesGroup.add(actionsManager.createPrevOccurenceAction(getFramesList()));
framesGroup.add(actionsManager.createNextOccurenceAction(getFramesList()));
- final ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.DEBUGGER_TOOLBAR, framesGroup, true);
+ final ActionToolbarImpl toolbar =
+ (ActionToolbarImpl)ActionManager.getInstance().createActionToolbar(ActionPlaces.DEBUGGER_TOOLBAR, framesGroup, true);
toolbar.setReservePlaceAutoPopupIcon(false);
- ((ActionToolbarImpl)toolbar).setAddSeparatorFirst(true);
+ toolbar.setAddSeparatorFirst(true);
toolbar.getComponent().setBorder(new EmptyBorder(1, 0, 0, 0));
return toolbar;
}
@@ -152,6 +155,15 @@ public class XFramesView extends XDebugViewBase {
}
XExecutionStack activeExecutionStack = suspendContext.getActiveExecutionStack();
myThreadComboBox.setSelectedItem(activeExecutionStack);
+ final boolean invisible = executionStacks.length == 1 && StringUtil.isEmpty(executionStacks[0].getDisplayName());
+ myThreadsPanel.removeAll();
+ if (invisible) {
+ myThreadsPanel.add(myToolbar.getComponent(), BorderLayout.WEST);
+ } else {
+ myThreadsPanel.add(myToolbar.getComponent(), BorderLayout.EAST);
+ myThreadsPanel.add(myThreadComboBox, BorderLayout.CENTER);
+ }
+ myToolbar.setAddSeparatorFirst(!invisible);
updateFrames(activeExecutionStack);
myListenersEnabled = true;
}
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/BaseInspectionVisitor.java b/plugins/InspectionGadgets/src/com/siyeh/ig/BaseInspectionVisitor.java
index 88626a6de410..aedb7b302c1d 100644
--- a/plugins/InspectionGadgets/src/com/siyeh/ig/BaseInspectionVisitor.java
+++ b/plugins/InspectionGadgets/src/com/siyeh/ig/BaseInspectionVisitor.java
@@ -173,7 +173,7 @@ public abstract class BaseInspectionVisitor extends JavaElementVisitor {
protected final void registerError(@NotNull PsiElement location,
Object... infos) {
- if (location.getTextLength() == 0) {
+ if (location.getTextLength() == 0 && !(location instanceof PsiFile)) {
return;
}
final InspectionGadgetsFix[] fixes = createFixes(infos);
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/classlayout/emptyclass/EmptyFile.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/classlayout/emptyclass/EmptyFile.java
new file mode 100644
index 000000000000..e69de29bb2d1
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/classlayout/emptyclass/expected.xml b/plugins/InspectionGadgets/test/com/siyeh/igtest/classlayout/emptyclass/expected.xml
index 05c0cc1b6d2d..ea5fd37b96a9 100644
--- a/plugins/InspectionGadgets/test/com/siyeh/igtest/classlayout/emptyclass/expected.xml
+++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/classlayout/emptyclass/expected.xml
@@ -6,4 +6,11 @@
Empty class
Class <code>ReportMe</code> is empty #loc
+
+
+ EmptyFile.java
+ 1
+ Empty class
+ Java file does not declare any class #loc
+
\ No newline at end of file
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/ant/src/com/intellij/lang/ant/config/impl/artifacts/AntArtifactPropertiesEditor.form b/plugins/ant/src/com/intellij/lang/ant/config/impl/artifacts/AntArtifactPropertiesEditor.form
index 5e3784cb08d4..c3b2d1907107 100644
--- a/plugins/ant/src/com/intellij/lang/ant/config/impl/artifacts/AntArtifactPropertiesEditor.form
+++ b/plugins/ant/src/com/intellij/lang/ant/config/impl/artifacts/AntArtifactPropertiesEditor.form
@@ -42,74 +42,18 @@
-
-
+
-
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
diff --git a/plugins/ant/src/com/intellij/lang/ant/config/impl/artifacts/AntArtifactPropertiesEditor.java b/plugins/ant/src/com/intellij/lang/ant/config/impl/artifacts/AntArtifactPropertiesEditor.java
index a28cc76295e2..c94215d3b25f 100644
--- a/plugins/ant/src/com/intellij/lang/ant/config/impl/artifacts/AntArtifactPropertiesEditor.java
+++ b/plugins/ant/src/com/intellij/lang/ant/config/impl/artifacts/AntArtifactPropertiesEditor.java
@@ -21,20 +21,23 @@ import com.intellij.lang.ant.config.AntConfiguration;
import com.intellij.lang.ant.config.impl.BuildFileProperty;
import com.intellij.lang.ant.config.impl.TargetChooserDialog;
import com.intellij.lang.ant.config.impl.configuration.UIPropertyBinding;
+import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.ui.FixedSizeButton;
import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.Condition;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.packaging.ui.ArtifactEditorContext;
import com.intellij.packaging.ui.ArtifactPropertiesEditor;
+import com.intellij.ui.*;
import com.intellij.ui.table.JBTable;
-import com.intellij.util.NewInstanceFactory;
import com.intellij.util.config.ListProperty;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.ui.ColumnInfo;
+import com.intellij.util.ui.ListTableModel;
import com.intellij.util.ui.UIUtil;
import javax.swing.*;
+import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
@@ -45,32 +48,34 @@ import java.util.List;
*/
public class AntArtifactPropertiesEditor extends ArtifactPropertiesEditor {
private static final ListProperty ANT_PROPERTIES = ListProperty.create("ant-properties");
- private static final ColumnInfo NAME_COLUMN = new ColumnInfo(AntBundle.message("edit.ant.properties.name.column.name")) {
- public String valueOf(BuildFileProperty buildFileProperty) {
- return buildFileProperty.getPropertyName();
- }
+ private static final ColumnInfo NAME_COLUMN =
+ new ColumnInfo(AntBundle.message("edit.ant.properties.name.column.name")) {
+ public String valueOf(BuildFileProperty buildFileProperty) {
+ return buildFileProperty.getPropertyName();
+ }
- public boolean isCellEditable(BuildFileProperty buildFileProperty) {
- return USER_PROPERTY_CONDITION.value(buildFileProperty);
- }
+ public boolean isCellEditable(BuildFileProperty buildFileProperty) {
+ return USER_PROPERTY_CONDITION.value(buildFileProperty);
+ }
- public void setValue(BuildFileProperty buildFileProperty, String name) {
- buildFileProperty.setPropertyName(name);
- }
- };
- private static final ColumnInfo VALUE_COLUMN = new ColumnInfo(AntBundle.message("edit.ant.properties.value.column.name")) {
- public boolean isCellEditable(BuildFileProperty buildFileProperty) {
- return USER_PROPERTY_CONDITION.value(buildFileProperty);
- }
+ public void setValue(BuildFileProperty buildFileProperty, String name) {
+ buildFileProperty.setPropertyName(name);
+ }
+ };
+ private static final ColumnInfo VALUE_COLUMN =
+ new ColumnInfo(AntBundle.message("edit.ant.properties.value.column.name")) {
+ public boolean isCellEditable(BuildFileProperty buildFileProperty) {
+ return USER_PROPERTY_CONDITION.value(buildFileProperty);
+ }
- public String valueOf(BuildFileProperty buildFileProperty) {
- return buildFileProperty.getPropertyValue();
- }
+ public String valueOf(BuildFileProperty buildFileProperty) {
+ return buildFileProperty.getPropertyValue();
+ }
- public void setValue(BuildFileProperty buildFileProperty, String value) {
- buildFileProperty.setPropertyValue(value);
- }
- };
+ public void setValue(BuildFileProperty buildFileProperty, String value) {
+ buildFileProperty.setPropertyValue(value);
+ }
+ };
private static final ColumnInfo[] PROPERTY_COLUMNS = new ColumnInfo[]{NAME_COLUMN, VALUE_COLUMN};
private static final Condition USER_PROPERTY_CONDITION = new Condition() {
@Override
@@ -84,8 +89,6 @@ public class AntArtifactPropertiesEditor extends ArtifactPropertiesEditor {
private JCheckBox myRunTargetCheckBox;
private FixedSizeButton mySelectTargetButton;
private JBTable myPropertiesTable;
- private JButton myAddButton;
- private JButton myRemoveButton;
private JPanel myPropertiesPanel;
private AntBuildTarget myTarget;
private final boolean myPostProcessing;
@@ -111,10 +114,59 @@ public class AntArtifactPropertiesEditor extends ArtifactPropertiesEditor {
}
});
+ myPropertiesTable = new JBTable();
UIPropertyBinding.Composite binding = new UIPropertyBinding.Composite();
myBinding = binding.bindList(myPropertiesTable, PROPERTY_COLUMNS, ANT_PROPERTIES);
- myBinding.addAddFacility(myAddButton, NewInstanceFactory.fromClass(BuildFileProperty.class));
- myBinding.addRemoveFacility(myRemoveButton, USER_PROPERTY_CONDITION);
+ myPropertiesPanel.add(
+ ToolbarDecorator.createDecorator(myPropertiesTable)
+ .setAddAction(new AnActionButtonRunnable() {
+ @Override
+ public void run(AnActionButton button) {
+ ListTableModel model = (ListTableModel)myPropertiesTable.getModel();
+ if (myPropertiesTable.isEditing() && !myPropertiesTable.getCellEditor().stopCellEditing()) {
+ return;
+ }
+ BuildFileProperty item = new BuildFileProperty();
+ 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;
+ }
+ }
+ }
+ }).setRemoveAction(new AnActionButtonRunnable() {
+ @Override
+ public void run(AnActionButton button) {
+ TableUtil.removeSelectedItems(myPropertiesTable);
+ }
+ }).setRemoveActionUpdater(new AnActionButtonUpdater() {
+ @Override
+ public boolean isEnabled(AnActionEvent e) {
+ final ListSelectionModel selectionModel = myPropertiesTable.getSelectionModel();
+ ListTableModel model = (ListTableModel)myPropertiesTable.getModel();
+ boolean enable = false;
+ if (!selectionModel.isSelectionEmpty()) {
+ enable = true;
+ for (int i : myPropertiesTable.getSelectedRows()) {
+ if (AntArtifactProperties.isPredefinedProperty(model.getItems().get(i).getPropertyName())) {
+ enable = false;
+ break;
+ }
+ }
+ }
+ return enable;
+ }
+ }).disableUpDownActions().createPanel(), BorderLayout.CENTER);
}
private void selectTarget() {
@@ -135,9 +187,6 @@ public class AntArtifactPropertiesEditor extends ArtifactPropertiesEditor {
}
final boolean enabled = myTarget != null && myRunTargetCheckBox.isSelected();
UIUtil.setEnabled(myPropertiesPanel, enabled, true);
- if (enabled) {
- myBinding.updateRemoveButton(myRemoveButton, USER_PROPERTY_CONDITION);
- }
}
public String getTabName() {
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 @@