Merge remote-tracking branch 'origin/master'

This commit is contained in:
Alexander Lobas
2012-03-19 21:48:03 +04:00
129 changed files with 1634 additions and 2207 deletions
@@ -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);
@@ -3,7 +3,7 @@
<grid id="66887" binding="myPanel" layout-manager="GridLayoutManager" row-count="6" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="103" y="66" width="429" height="225"/>
<xy x="103" y="66" width="439" height="254"/>
</constraints>
<properties/>
<clientProperties>
@@ -46,14 +46,20 @@
<grid row="5" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<grid id="62794" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="8" bottom="0" right="0"/>
<grid id="31c1" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="415eb" class="com.intellij.openapi.ui.TextFieldWithBrowseButton" binding="myPathField">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
<component id="327dc" class="javax.swing.JLabel">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
@@ -62,39 +68,10 @@
<text resource-bundle="messages/CompilerBundle" key="jikes.option.path.to.executable"/>
</properties>
</component>
<grid id="aa983" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="0" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="f8e3d" class="javax.swing.JTextField" binding="myPathField">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties/>
</component>
<component id="78d21" class="javax.swing.JButton" binding="myJikesPathFieldBrowseButton">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="21" height="21"/>
</grid>
</constraints>
<properties>
<margin top="0" left="0" bottom="0" right="0"/>
<text value="..."/>
</properties>
</component>
</children>
</grid>
</children>
</grid>
<grid id="8f7f6" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="8" bottom="0" right="0"/>
<grid id="918d2" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
@@ -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;
}
@@ -10,6 +10,7 @@
<orderEntry type="module" module-name="execution-openapi" />
<orderEntry type="module" module-name="jsp-openapi" />
<orderEntry type="module" module-name="java-psi-api" />
<orderEntry type="module" module-name="resources-en" />
</component>
<component name="copyright">
<Base>
@@ -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);
}
}
}
@@ -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;
}
}
}
}
@@ -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<String, List<XmlFile>> myExternalAnnotations = new ConcurrentWeakValueHashMap<String, List<XmlFile>>();
@NotNull private final AtomicReference<ThreeState> myHasAnyAnnotationsRoots = new AtomicReference<ThreeState>(ThreeState.UNSURE);
@NotNull private volatile ThreeState myHasAnyAnnotationsRoots = ThreeState.UNSURE;
@NotNull private static final List<XmlFile> NULL = new ArrayList<XmlFile>();
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<String, PsiAnnotation> result = collectExternalAnnotations(listOwner);
@@ -135,11 +138,11 @@ public class ExternalAnnotationsManagerImpl extends ExternalAnnotationsManager {
@NotNull
private Map<String, PsiAnnotation> collectExternalAnnotations(@NotNull final PsiModifierListOwner listOwner) {
if (hasAnyAnnotationsRoots() == ThreeState.NO) return Collections.emptyMap();
final Map<String, PsiAnnotation> result = new HashMap<String, PsiAnnotation>();
final List<XmlFile> files = findExternalAnnotationsFile(listOwner);
final List<XmlFile> files = findExternalAnnotationsFiles(listOwner);
if (files == null) {
return Collections.emptyMap();
}
final Map<String, PsiAnnotation> result = new HashMap<String, PsiAnnotation>();
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<XmlFile> xmlFiles = findExternalAnnotationsFile(listOwner);
final List<XmlFile> 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<XmlFile> xmlFiles = findExternalAnnotationsFile(listOwner);
List<XmlFile> 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<XmlFile> annotationFiles = new ArrayList<XmlFile>(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<XmlFile> files = findExternalAnnotationsFile(listOwner);
final List<XmlFile> 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 {
"<item name=\'" + externalName + "\'>\n";
text += createAnnotationTag(annotationFQName, values);
text += "</item>";
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 = " <annotation name=\'" + annotationFQName + "\'>\n";
text += StringUtil.join(values, new Function<PsiNameValuePair, String>() {
@NonNls
@NotNull
@Override
public String fun(@NotNull PsiNameValuePair pair) {
if (pair.getName() != null) {
return "<val name=\"" + pair.getName() + "\" val=\"" + StringUtil.escapeXml(pair.getValue().getText()) + "\"/>";
}
return "<val val=\"" + StringUtil.escapeXml(pair.getValue().getText()) + "\"/>";
return "<val" +
(pair.getName() != null ? " name=\"" + pair.getName() + "\"" : "") +
" val=\"" + StringUtil.escapeXml(pair.getValue().getText()) + "\"/>";
}
}, " \n");
text += " </annotation>";
@@ -572,8 +582,8 @@ public class ExternalAnnotationsManagerImpl extends ExternalAnnotationsManager {
}
@Nullable
private List<XmlFile> findExternalAnnotationsFile(@NotNull PsiModifierListOwner listOwner) {
final Project project = listOwner.getProject();
private List<XmlFile> 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;
}
@@ -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);
@@ -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() {
@@ -35,7 +35,7 @@ public class JavaDummyHolder extends DummyHolder implements PsiImportHolder {
private Map<String, PsiClass> 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) {
@@ -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) {
@@ -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);
@@ -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(); }
}
@@ -44,7 +44,7 @@ public abstract class JavaCodeInsightFixtureTestCase extends UsefulTestCase{
protected void setUp() throws Exception {
super.setUp();
final TestFixtureBuilder<IdeaProjectTestFixture> projectBuilder = IdeaTestFixtureFactory.getFixtureFactory().createFixtureBuilder();
final TestFixtureBuilder<IdeaProjectTestFixture> projectBuilder = IdeaTestFixtureFactory.getFixtureFactory().createFixtureBuilder(getName());
myFixture = JavaTestFixtureFactory.getFixtureFactory().createCodeInsightFixture(projectBuilder.getFixture());
final JavaModuleFixtureBuilder moduleFixtureBuilder = projectBuilder.addModule(JavaModuleFixtureBuilder.class);
moduleFixtureBuilder.addSourceContentRoot(myFixture.getTempDirPath());
@@ -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<IdeaProjectTestFixture> createFixtureBuilder() {
return IdeaTestFixtureFactory.getFixtureFactory().createFixtureBuilder();
}
public static TestFixtureBuilder<IdeaProjectTestFixture> createFixtureBuilder(@NotNull String name) {
return IdeaTestFixtureFactory.getFixtureFactory().createFixtureBuilder(name);
}
}
@@ -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;
}
}
@@ -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) {
@@ -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);
@@ -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;
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

@@ -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();
}
});
}
}
@@ -1,47 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.codeInspection.ui.ListEditForm">
<grid id="33211" binding="contentPanel" layout-manager="GridLayoutManager" row-count="3" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="4" vgap="4">
<margin top="4" left="4" bottom="4" right="4"/>
<constraints>
<xy x="96" y="37" width="285" height="154"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<scrollpane class="com.intellij.ui.components.JBScrollPane" id="14807">
<constraints>
<grid row="0" column="0" row-span="3" col-span="1" vsize-policy="3" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="e5752" class="com.intellij.codeInspection.ui.ListTable" binding="table" custom-create="true">
<constraints/>
<properties/>
</component>
</children>
</scrollpane>
<component id="f6174" class="javax.swing.JButton" binding="removeButton">
<constraints>
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<margin top="3" left="8" bottom="3" right="8"/>
</properties>
</component>
<component id="52926" class="javax.swing.JButton" binding="addButton">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<margin top="3" left="8" bottom="3" right="8"/>
</properties>
</component>
<vspacer id="b3fb7">
<constraints>
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
</children>
</grid>
</form>
@@ -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<String> myStringList;
private String myTitle;
public ListEditForm(String title, List<String> 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() {
@@ -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);
}
}
}
@@ -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<FoldingDescriptor> descriptors = new ArrayList<FoldingDescriptor>();
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<FoldingDescriptor> descriptors) {
List<FoldingDescriptor> 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);
}
}
}
}
@@ -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;
}
@@ -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<VirtualFile> myDisabledHintsFiles = new THashSet<VirtualFile>();
private final Collection<PsiFile> myDisabledHighlightingFiles = new THashSet<PsiFile>();
private final Collection<VirtualFile> myDisabledHighlightingFiles = new THashSet<VirtualFile>();
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<RangeHighlighterEx>() {
@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<RangeHighlighterEx>() {
@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<HighlightInfo> processor) {
return processHighlights(document, project, null, 0, document.getTextLength(), new Processor<HighlightInfo>() {
@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<HighlightInfo> foundInfoList = new SmartList<HighlightInfo>();
processHighlightsNearOffset(document, myProject, HighlightSeverity.INFORMATION, offset, includeFixRange, new Processor<HighlightInfo>() {
@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;
@@ -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
@@ -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);
}
}
@@ -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);
}
@@ -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();
}
}
@@ -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);
}
@@ -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";
@@ -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;
}
@@ -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;
@@ -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();
}
@@ -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() {
@@ -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) {
@@ -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();
@@ -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
@@ -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);
@@ -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);
}
});
@@ -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();
}
});
@@ -73,7 +73,7 @@ public class VirtualDirectoryImpl extends VirtualFileSystemEntry {
private final NewVirtualFileSystem myFS;
// guarded by this
protected Object myChildren; // Either HashMap<String, VFile> or VFile[]
private Object myChildren; // Either HashMap<String, VFile> 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<VirtualFile> 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<String[], int[]> 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<String, VirtualFileSystemEntry> 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
@@ -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) {
@@ -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) {
@@ -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;
}
@@ -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) {
@@ -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;
@@ -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;
}
}
}
@@ -135,7 +135,7 @@ public abstract class AbstractRefreshablePanel<T> 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
@@ -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<XExecutionStack, StackFramesListBuilder> myBuilders = new HashMap<XExecutionStack, StackFramesListBuilder>();
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;
}
@@ -917,7 +917,8 @@ utility.class.without.private.constructor.problem.descriptor=Class <code>#ref</c
abstract.method.overrides.concrete.method.problem.descriptor=Abstract method <code>#ref()</code> overrides concrete method #loc
abstract.method.with.missing.implementations.problem.descriptor=Abstract method <code>#ref()</code> is not implemented in every subclass #loc
abstract.method.overrides.abstract.method.problem.descriptor=Abstract method <code>#ref()</code> 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 <code>#ref</code> is declared 'abstract', and extends a concrete class #loc
static.non.final.field.problem.descriptor='static' non-'final' field <code>#ref</code> #loc
constant.declared.in.abstract.class.problem.descriptor=Constant <code>#ref</code> declared in abstract class #loc
@@ -1411,9 +1412,6 @@ assignment.replaceable.with.operator.assignment.problem.descriptor=<code>#ref</c
assignment.replaceable.with.operator.assignment.ignore.conditional.operators.option=Ignore conditional operators
assignment.replaceable.with.operator.assignment.ignore.obscure.operators.option=Ignore the obscure ^ and % operators
assignment.replaceable.with.operator.replace.quickfix=Replace '=' with ''{0}=''
button.add=&Add
button.delete=Delete
button.reset=Reset
object.equality.ignore.between.objects.of.a.type.with.only.private.constructors.option=Ignore '==' between objects of a type with only private constructors
redundant.method.override.display.name=Method is identical to its super method
redundant.method.override.problem.descriptor=Method <code>#ref()</code> 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=<code>#ref</code> is always true #loc
pointless.indexof.comparison.always.false.problem.descriptor=<code>#ref</code> is always false #loc
reuse.of.local.variable.problem.descriptor=Reuse of local variable <code>#ref</code> #loc
button.remove=&Remove
single.character.startswith.display.name=Single character 'startsWith()' or 'endsWith()'
single.character.startswith.problem.descriptor=Single character <code>#ref()</code> 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=<code>new #ref()</code> 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 <code>{0}.#ref</code> used #loc
absolute.alignment.in.user.interface.quickfix=Replace with ''{0}.{1}''
@@ -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);
@@ -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;
}
@@ -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;
}
@@ -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
@@ -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;
}
@@ -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
@@ -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;
}
}
}
@@ -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<PsiAnnotation> annotationsSet = new HashSet<PsiAnnotation>(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();
@@ -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;
}
@@ -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
@@ -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;
}
@@ -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;
}
@@ -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;
}
@@ -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;
}
@@ -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
@@ -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) {
@@ -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<String> collection, String borderTitle,
final String chooserTitle, String... ancestorClasses) {
public static JPanel createTreeClassChooserList(final Collection<String> 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);
}
}
});
@@ -1,9 +1,13 @@
<html>
<body>
This inspection reports abstract methods which override abstract methods. Methods with
This inspection reports <b>abstract</b> methods which override <b>abstract</b> methods. Methods with
different return types or exception declarations than the method they override are not
reported by this inspection.
<p>
Use the first checkbox to ignore any abstract methods that have a different JavaDoc comment than their super method.
<p>
Use the second checkbox to ignore any abstract methods that have one or more annotations that are not present on their super method.
<p>
<small>Powered by InspectionGadgets</small>
</body>
</html>
@@ -3,7 +3,7 @@
This inspection reports any checks for oddness of the form:
<code><pre>x % 2 == 1</pre></code>
Such checks will fail for negative odd values, which is probably not the behaviour intended. Consider using:
<code><pre>x % 2 != 0</pre></code> or: <code><pre>x & 1 == 1</pre></code> instead.
<code><pre>x % 2 != 0</pre></code> or: <code><pre>(x & 1) == 1</pre></code> instead.
<p>
<small>Powered by InspectionGadgets</small>
</body>
@@ -1,7 +1,9 @@
<html>
<body>
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.
<p>
Use the checkbox below to ignore instance creation of exception classes which have no constructors that take arguments.
<p>
<small>New in 11, Powered by InspectionGadgets</small>
</body>
@@ -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() ;
}
@@ -6,4 +6,11 @@
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Empty class</problem_class>
<description>Class &lt;code&gt;ReportMe&lt;/code&gt; is empty #loc</description>
</problem>
<problem>
<file>EmptyFile.java</file>
<line>1</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Empty class</problem_class>
<description>Java file does not declare any class #loc</description>
</problem>
</problems>
@@ -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 {
}
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems>
<problem>
<file>NewExceptionWithoutArguments.java</file>
<line>6</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Exception constructor called without arguments</problem_class>
<description>&lt;code&gt;new RuntimeException()&lt;/code&gt; without arguments #loc</description>
</problem>
</problems>
@@ -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();
}
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems>
<problem>
<file>AbstractMethodOverridesAbstractMethod.java</file>
<line>30</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Abstract method overrides abstract method</problem_class>
<description>Abstract method &lt;code&gt;three()&lt;/code&gt; overrides abstract method #loc</description>
</problem>
</problems>
@@ -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);
}
}
@@ -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);
}
}
@@ -42,74 +42,18 @@
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<grid id="1a993" binding="myPropertiesPanel" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<grid id="1a993" binding="myPropertiesPanel" layout-manager="BorderLayout" hgap="0" vgap="0">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="1" use-parent-layout="false"/>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="1" use-parent-layout="false">
<preferred-size width="-1" height="250"/>
</grid>
</constraints>
<properties/>
<clientProperties>
<BorderFactoryClass class="java.lang.String" value="com.intellij.ui.IdeBorderFactory$PlainSmallWithoutIndent"/>
</clientProperties>
<border type="none" title="Properties"/>
<children>
<grid id="25699" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<scrollpane id="eb376" class="com.intellij.ui.components.JBScrollPane">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="7" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="f2d63" class="com.intellij.ui.table.JBTable" binding="myPropertiesTable">
<constraints/>
<properties>
<preferredScrollableViewportSize width="350" height="200"/>
</properties>
</component>
</children>
</scrollpane>
<grid id="c5a2a" layout-manager="GridLayoutManager" row-count="3" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="3370" class="javax.swing.JButton" binding="myAddButton" default-binding="true">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="&amp;Add"/>
</properties>
</component>
<vspacer id="4ebaf">
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<component id="ada4f" class="javax.swing.JButton" binding="myRemoveButton" default-binding="true">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="&amp;Remove"/>
</properties>
</component>
</children>
</grid>
</children>
</grid>
</children>
<children/>
</grid>
</children>
</grid>
@@ -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<BuildFileProperty> ANT_PROPERTIES = ListProperty.create("ant-properties");
private static final ColumnInfo<BuildFileProperty, String> NAME_COLUMN = new ColumnInfo<BuildFileProperty, String>(AntBundle.message("edit.ant.properties.name.column.name")) {
public String valueOf(BuildFileProperty buildFileProperty) {
return buildFileProperty.getPropertyName();
}
private static final ColumnInfo<BuildFileProperty, String> NAME_COLUMN =
new ColumnInfo<BuildFileProperty, String>(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<BuildFileProperty, String> VALUE_COLUMN = new ColumnInfo<BuildFileProperty, String>(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<BuildFileProperty, String> VALUE_COLUMN =
new ColumnInfo<BuildFileProperty, String>(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<BuildFileProperty> USER_PROPERTY_CONDITION = new Condition<BuildFileProperty>() {
@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<BuildFileProperty> model = (ListTableModel<BuildFileProperty>)myPropertiesTable.getModel();
if (myPropertiesTable.isEditing() && !myPropertiesTable.getCellEditor().stopCellEditing()) {
return;
}
BuildFileProperty item = new BuildFileProperty();
ArrayList<BuildFileProperty> items = new ArrayList<BuildFileProperty>(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<BuildFileProperty> model = (ListTableModel<BuildFileProperty>)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() {
@@ -1,18 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.lang.ant.config.impl.configuration.AntClasspathEditorPanel$Form">
<grid id="e8f1e" binding="myWholePanel" row-count="7" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="e8f1e" binding="myWholePanel" layout-manager="GridLayoutManager" row-count="6" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="76" y="46" width="433" height="265"/>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="3fa57" class="javax.swing.JButton" binding="myAddButton">
<constraints>
<xy x="306" y="25" width="127" height="25"/>
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1"/>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text resource-bundle="messages/AntBundle" key="button.add"/>
@@ -20,8 +18,7 @@
</component>
<component id="f3cd" class="javax.swing.JButton" binding="myRemoveButton">
<constraints>
<xy x="306" y="85" width="127" height="25"/>
<grid row="3" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1"/>
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text resource-bundle="messages/AntBundle" key="button.remove"/>
@@ -29,8 +26,7 @@
</component>
<component id="4c683" class="javax.swing.JButton" binding="myMoveUpButton">
<constraints>
<xy x="306" y="115" width="127" height="25"/>
<grid row="4" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1"/>
<grid row="3" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text resource-bundle="messages/AntBundle" key="button.move.up"/>
@@ -38,8 +34,7 @@
</component>
<component id="57625" class="javax.swing.JButton" binding="myMoveDownButton">
<constraints>
<xy x="306" y="145" width="127" height="25"/>
<grid row="5" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1"/>
<grid row="4" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text resource-bundle="messages/AntBundle" key="button.move.down"/>
@@ -47,14 +42,12 @@
</component>
<vspacer id="585ab">
<constraints>
<xy x="364" y="170" width="11" height="95"/>
<grid row="6" column="1" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2"/>
<grid row="5" column="1" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<scrollpane class="com.intellij.ui.components.JBScrollPane" id="50e51">
<scrollpane id="50e51" class="com.intellij.ui.components.JBScrollPane">
<constraints>
<xy x="0" y="25" width="296" height="240"/>
<grid row="1" column="0" row-span="6" col-span="1" vsize-policy="7" hsize-policy="7" anchor="0" fill="3"/>
<grid row="0" column="0" row-span="6" col-span="1" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
@@ -65,19 +58,9 @@
</component>
</children>
</scrollpane>
<component id="ef36" class="javax.swing.JLabel" binding="myClasspathLabel">
<constraints>
<xy x="0" y="3" width="124" height="14"/>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0"/>
</constraints>
<properties>
<text value="&lt;#############&gt;"/>
</properties>
</component>
<component id="84aa7" class="javax.swing.JButton" binding="myAddAllInDir">
<constraints>
<xy x="306" y="55" width="127" height="25"/>
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1"/>
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text resource-bundle="messages/AntBundle" key="additional.classpath.tab.add.all.in.directory.button"/>
@@ -18,7 +18,6 @@ package com.intellij.lang.ant.config.impl.configuration;
import com.intellij.lang.ant.config.impl.AllJarsUnderDirEntry;
import com.intellij.lang.ant.config.impl.AntClasspathEntry;
import com.intellij.lang.ant.config.impl.SinglePathEntry;
import com.intellij.openapi.ui.LabeledComponent;
import com.intellij.ui.ListUtil;
import com.intellij.util.config.AbstractProperty;
import com.intellij.util.config.ListProperty;
@@ -68,19 +67,17 @@ public class AntClasspathEditorPanel extends JPanel {
return myBinding;
}
private static class Form {
public static class Form {
private JButton myAddButton;
private JButton myAddAllInDir;
private JButton myRemoveButton;
private JButton myMoveUpButton;
private JButton myMoveDownButton;
private JPanel myWholePanel;
private JLabel myClasspathLabel;
private JList myClasspathList;
private final ArrayList<ListUtil.Updatable> myUpdatables = new ArrayList<ListUtil.Updatable>();
public Form() {
myClasspathLabel.setLabelFor(myClasspathList);
myClasspathList.setCellRenderer(new AntUIUtil.ClasspathRenderer());
myUpdatables.add(ListUtil.addRemoveListener(myRemoveButton, myClasspathList));
@@ -96,14 +93,6 @@ public class AntClasspathEditorPanel extends JPanel {
}
}
public void setClasspathLabel(String textWithMnemonic) {
LabeledComponent.TextWithMnemonic.fromTextWithMnemonic(textWithMnemonic).setToLabel(myForm.myClasspathLabel);
}
public String getClasspathLabel() {
return LabeledComponent.TextWithMnemonic.fromLabel(myForm.myClasspathLabel).getTextWithMnemonic();
}
public JComponent getPreferedFocusComponent() {
return myForm.myClasspathList;
}
@@ -28,16 +28,13 @@ import com.intellij.openapi.projectRoots.ui.ProjectJdksEditor;
import com.intellij.openapi.ui.ComponentWithBrowseButton;
import com.intellij.openapi.ui.DialogBuilder;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.util.Condition;
import com.intellij.openapi.util.Disposer;
import com.intellij.ui.ComboboxWithBrowseButton;
import com.intellij.ui.RawCommandLineEditor;
import com.intellij.ui.SimpleColoredComponent;
import com.intellij.ui.TabbedPaneWrapper;
import com.intellij.util.NewInstanceFactory;
import com.intellij.ui.*;
import com.intellij.ui.table.JBTable;
import com.intellij.util.config.AbstractProperty;
import com.intellij.util.containers.Convertor;
import com.intellij.util.ui.ColumnInfo;
import com.intellij.util.ui.ListTableModel;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -197,8 +194,6 @@ public class BuildFilePropertiesPanel {
}
private static class PropertiesTab extends Tab {
private JButton myAddButton;
private JButton myRemoveButton;
private JTable myPropertiesTable;
private JPanel myWholePanel;
@@ -237,11 +232,41 @@ public class BuildFilePropertiesPanel {
private static final ColumnInfo[] PROPERTY_COLUMNS = new ColumnInfo[]{NAME_COLUMN, VALUE_COLUMN};
public PropertiesTab() {
myPropertiesTable = new JBTable();
UIPropertyBinding.TableListBinding<BuildFileProperty> tableListBinding = getBinding().bindList(myPropertiesTable, PROPERTY_COLUMNS,
AntBuildFileImpl.ANT_PROPERTIES);
AntBuildFileImpl.ANT_PROPERTIES);
tableListBinding.setColumnWidths(GlobalAntConfiguration.PROPERTIES_TABLE_LAYOUT);
tableListBinding.addAddFacility(myAddButton, NewInstanceFactory.fromClass(BuildFileProperty.class));
tableListBinding.addRemoveFacility(myRemoveButton, Condition.TRUE);
myWholePanel = ToolbarDecorator.createDecorator(myPropertiesTable)
.setAddAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
if (myPropertiesTable.isEditing() && !myPropertiesTable.getCellEditor().stopCellEditing()) {
return;
}
BuildFileProperty item = new BuildFileProperty();
ListTableModel<BuildFileProperty> model = (ListTableModel<BuildFileProperty>)myPropertiesTable.getModel();
ArrayList<BuildFileProperty> items = new ArrayList<BuildFileProperty>(model.getItems());
items.add(item);
model.setItems(items);
int newIndex = model.indexOf(item);
ListSelectionModel selectionModel = myPropertiesTable.getSelectionModel();
selectionModel.clearSelection();
selectionModel.setSelectionInterval(newIndex, newIndex);
ColumnInfo[] columns = model.getColumnInfos();
for (int i = 0; i < columns.length; i++) {
ColumnInfo column = columns[i];
if (column.isCellEditable(item)) {
myPropertiesTable.requestFocusInWindow();
myPropertiesTable.editCellAt(newIndex, i);
break;
}
}
}
}).disableUpDownActions().createPanel();
myWholePanel.setBorder(null);
}
public JComponent getComponent() {
@@ -288,9 +313,9 @@ public class BuildFilePropertiesPanel {
private static final Comparator<TargetFilter> NAME_COMPARATOR = new Comparator<TargetFilter>() {
public int compare(TargetFilter o1, TargetFilter o2) {
final String name1 = o1.getTargetName();
if(name1 == null) return -1;
if (name1 == null) return -1;
final String name2 = o2.getTargetName();
if(name2 == null) return 1;
if (name2 == null) return 1;
return name1.compareToIgnoreCase(name2);
}
};
@@ -482,5 +507,4 @@ public class BuildFilePropertiesPanel {
private static void setLabelFor(JLabel label, ComponentWithBrowseButton component) {
label.setLabelFor(component.getChildComponent());
}
}
@@ -1,24 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.lang.ant.config.impl.configuration.BuildFilePropertiesPanel.FiltersTab">
<grid id="ecb84" binding="myWholePanel" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="6" left="6" bottom="6" right="6"/>
<grid id="ecb84" binding="myWholePanel" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="154" y="86" width="398" height="336"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="aabbb" class="javax.swing.JLabel">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text resource-bundle="messages/AntBundle" key="run.filters.tab.targets.label"/>
</properties>
</component>
<scrollpane id="8b9bc" class="com.intellij.ui.components.JBScrollPane">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
@@ -1,52 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.lang.ant.config.impl.configuration.BuildFilePropertiesPanel.PropertiesTab">
<grid id="23284" binding="myWholePanel" row-count="3" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="6" left="6" bottom="6" right="6"/>
<constraints>
<xy x="173" y="110" width="248" height="158"/>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<scrollpane class="com.intellij.ui.components.JBScrollPane" id="9e63e">
<constraints>
<xy x="6" y="6" width="151" height="146"/>
<grid row="0" column="0" row-span="3" col-span="1" vsize-policy="7" hsize-policy="7" anchor="0" fill="3"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="2a3e5" class="com.intellij.util.ui.Table" binding="myPropertiesTable">
<constraints/>
<properties/>
</component>
</children>
</scrollpane>
<component id="5fffe" class="javax.swing.JButton" binding="myAddButton">
<constraints>
<xy x="167" y="6" width="75" height="25"/>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1"/>
</constraints>
<properties>
<text resource-bundle="messages/AntBundle" key="button.add"/>
</properties>
</component>
<component id="fad56" class="javax.swing.JButton" binding="myRemoveButton">
<constraints>
<xy x="167" y="36" width="75" height="25"/>
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1"/>
</constraints>
<properties>
<text resource-bundle="messages/AntBundle" key="button.remove"/>
</properties>
</component>
<vspacer id="bcf7d">
<constraints>
<xy x="199" y="61" width="11" height="91"/>
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2"/>
</constraints>
</vspacer>
</children>
</grid>
</form>
@@ -159,7 +159,7 @@ class GitMergeOperation extends GitBranchOperation {
@Override
protected void notifySuccess(@NotNull String message) {
if (!myLocalBranch) {
if (isRemoteBranch() || isMasterBranch()) {
super.notifySuccess(message);
}
else {
@@ -169,6 +169,14 @@ class GitMergeOperation extends GitBranchOperation {
}
}
private boolean isMasterBranch() {
return myBranchToMerge.equals("master");
}
private boolean isRemoteBranch() {
return !myLocalBranch;
}
private boolean resolveConflicts() {
if (!myConflictedRepositories.isEmpty()) {
return new MyMergeConflictResolver().merge();
@@ -15,7 +15,7 @@
*/
package org.jetbrains.git4idea.ssh;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.io.FileUtilLight;
import com.trilead.ssh2.KnownHosts;
import gnu.trove.THashMap;
import org.apache.commons.codec.DecoderException;
@@ -67,7 +67,7 @@ public abstract class GitSSHService {
if (myScriptPath == null || !myScriptPath.exists()) {
ScriptGenerator generator = new ScriptGenerator(GitSSHHandler.GIT_SSH_PREFIX, SSHMain.class, getTempDir());
generator.addClasses(XmlRpcClientLite.class, DecoderException.class);
generator.addClasses(KnownHosts.class, FileUtil.class);
generator.addClasses(KnownHosts.class, FileUtilLight.class);
generator.addResource(SSHMainBundle.class, "/org/jetbrains/git4idea/ssh/SSHMainBundle.properties");
myScriptPath = generator.generate();
}
@@ -15,7 +15,7 @@
*/
package org.jetbrains.git4idea.ssh;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.io.FileUtilLight;
import com.intellij.util.ArrayUtil;
import com.trilead.ssh2.*;
import com.trilead.ssh2.crypto.PEMDecoder;
@@ -302,7 +302,7 @@ public class SSHMain {
if (file.exists()) {
// if encrypted ask user for passphrase
String passphrase = null;
char[] text = FileUtil.loadFileText(file);
char[] text = FileUtilLight.loadFileText(file);
if (isEncryptedKey(text)) {
// need to ask passphrase from user
int i;

Some files were not shown because too many files have changed in this diff Show More