Merge branch 'master' of git.labs.intellij.net:idea/community

This commit is contained in:
irengrig
2012-03-19 14:37:23 +04:00
100 changed files with 1929 additions and 1605 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;
}
@@ -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;
}
@@ -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);
@@ -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);
}
}
@@ -2,17 +2,16 @@ package org.jetbrains.jps.incremental;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.Pair;
import org.jetbrains.ether.dependencyView.Mappings;
import org.jetbrains.jps.Module;
import org.jetbrains.jps.ModuleChunk;
import org.jetbrains.jps.ProjectPaths;
import org.jetbrains.jps.incremental.messages.ProgressMessage;
import java.io.File;
import java.io.IOException;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import java.util.*;
/**
* Use {@link BuilderService} to register implementations of this class
@@ -103,6 +102,18 @@ public abstract class ModuleLevelBuilder extends Builder {
context.processMessage(new ProgressMessage("Found " + newlyAffectedFiles.size() + " affected files"));
if (!newlyAffectedFiles.isEmpty()) {
if (LOG.isDebugEnabled()) {
final List<Pair<File, Module>> wrongFiles = checkAffectedFilesInCorrectModules(context, chunk, newlyAffectedFiles);
if (!wrongFiles.isEmpty()) {
LOG.debug("Wrong affected files for module chunk " + chunk.getName() + ": ");
for (Pair<File, Module> pair : wrongFiles) {
LOG.debug("\t[" + pair.second.getName() + "] " + pair.first.getPath());
}
}
}
for (File file : newlyAffectedFiles) {
context.markDirtyIfNotDeleted(file);
}
@@ -135,6 +146,45 @@ public abstract class ModuleLevelBuilder extends Builder {
}
}
private static List<Pair<File, Module>> checkAffectedFilesInCorrectModules(CompileContext context, ModuleChunk currentChunk, Collection<File> affected) {
if (affected.isEmpty()) {
return Collections.emptyList();
}
final Set<Module> chunkModules = currentChunk.getModules();
final Map<Module, Set<Module>> cache = new HashMap<Module, Set<Module>>();
final List<Pair<File, Module>> result = new ArrayList<Pair<File, Module>>();
for (File file : affected) {
final RootDescriptor moduleAndRoot = context.getModuleAndRoot(file);
if (moduleAndRoot == null) {
continue;
}
final Module moduleOfFile = moduleAndRoot.module;
if (chunkModules.contains(moduleOfFile)) {
continue;
}
Set<Module> moduleOfFileWithDependencies = cache.get(moduleOfFile);
if (moduleOfFileWithDependencies == null) {
moduleOfFileWithDependencies = ProjectPaths.getModulesWithDependentsRecursively(moduleOfFile, true);
cache.put(moduleOfFile, moduleOfFileWithDependencies);
}
if (intersects(moduleOfFileWithDependencies, chunkModules)) {
continue;
}
result.add(Pair.create(file, moduleOfFile));
}
return result;
}
private static boolean intersects(Set<Module> set1, Set<Module> set2) {
if (set1.size() < set2.size()) {
return new HashSet<Module>(set1).removeAll(set2);
}
return new HashSet<Module>(set2).removeAll(set1);
}
private static boolean chunkContainsAffectedFiles(CompileContext context, ModuleChunk chunk, final Set<File> affected) throws IOException {
final Set<Module> chunkModules = new HashSet<Module>(chunk.getModules());
if (!chunkModules.isEmpty()) {
@@ -181,6 +181,16 @@ public class ProjectPaths {
return sourcePaths;
}
public static Set<Module> getModulesWithDependentsRecursively(final Module module, final boolean includeTests) {
final Set<Module> result = new HashSet<Module>();
collectPathsRecursively(module, ClasspathKind.compile(includeTests), new HashSet<Module>(), new PathsGetter() {
public void apply(Module module, ClasspathKind kind) {
result.add(module);
}
});
return result;
}
private interface PathsGetter {
void apply(Module module, ClasspathKind kind);
}
@@ -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,15 @@ public class DummyHolder extends PsiFileImpl {
}
public DummyHolder(@NotNull PsiManager manager, TreeElement contentElement, PsiElement context, CharTable table) {
this(manager, contentElement, context, table, null, context == null ? PlainTextLanguage.INSTANCE : context.getLanguage());
this(manager, contentElement, context, table, null, language(context, PlainTextLanguage.INSTANCE));
}
protected static Language language(PsiElement context, Language defaultLanguage) {
if (context == null) return defaultLanguage;
Language contextLanguage = context.getLanguage();
Language language = context.getContainingFile().getLanguage();
if (language.isKindOf(contextLanguage)) return language;
return contextLanguage;
}
public DummyHolder(@NotNull PsiManager manager, TreeElement contentElement, PsiElement context, CharTable table, Boolean validity, Language language) {
@@ -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;
}
}
@@ -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);
}
}
}
}
@@ -0,0 +1,73 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.openapi.project;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.util.Disposer;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* User: ksafonov
*/
public abstract class ModuleNameTracker extends ModuleAdapter {
private final Map<Module, String> myModulesNames = new HashMap<Module, String>();
private final Project myProject;
public ModuleNameTracker(Project project) {
myProject = project;
Disposer.register(project, new Disposable() {
@Override
public void dispose() {
myModulesNames.clear();
}
});
}
@Override
public void moduleAdded(final Project project, final Module module) {
if (myProject == project) {
myModulesNames.put(module, module.getName());
}
}
@Override
public void moduleRemoved(final Project project, final Module module) {
if (myProject == project) {
myModulesNames.remove(module);
}
}
@Override
public void modulesRenamed(final Project project, final List<Module> modules) {
if (myProject != project) {
return;
}
Map<String, String> old2newNames = new HashMap<String, String>(modules.size());
for (Module module : modules) {
String newName = module.getName();
String oldName = myModulesNames.put(module, newName);
old2newNames.put(oldName, newName);
}
modulesRenamed(project, old2newNames);
}
protected abstract void modulesRenamed(final Project project, final Map<String, String> old2newNames);
}
@@ -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;
@@ -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
@@ -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) {
@@ -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}''
@@ -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() ;
}
@@ -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);
}
}
@@ -17,12 +17,17 @@ package com.intellij.android.designer.model;
import com.android.ide.common.rendering.api.ViewInfo;
import com.android.sdklib.IAndroidTarget;
import com.intellij.android.designer.propertyTable.AttributeProperty;
import com.intellij.android.designer.propertyTable.FlagProperty;
import com.intellij.designer.model.MetaManager;
import com.intellij.designer.model.MetaModel;
import com.intellij.designer.model.RadComponent;
import com.intellij.designer.propertyTable.Property;
import com.intellij.designer.propertyTable.PropertyTable;
import com.intellij.openapi.module.Module;
import org.jetbrains.android.dom.attrs.AttributeDefinition;
import org.jetbrains.android.dom.attrs.AttributeDefinitions;
import org.jetbrains.android.dom.attrs.AttributeFormat;
import org.jetbrains.android.dom.attrs.StyleableDefinition;
import org.jetbrains.android.sdk.AndroidPlatform;
import org.jetbrains.android.sdk.AndroidTargetData;
@@ -38,15 +43,16 @@ import java.util.*;
public class PropertyParser {
public static final String KEY = "PROPERTY_PARSER";
private MetaManager myMetaManager;
private AttributeDefinitions myDefinitions;
private ProjectClassLoader myClassLoader;
private Map<String, List<Property>> myCachedProperties;
public PropertyParser(Module module, IAndroidTarget target) throws Exception {
MetaManager metaManager = ViewsMetaManager.getInstance(module.getProject());
myCachedProperties = metaManager.getCache(target.hashString());
myMetaManager = ViewsMetaManager.getInstance(module.getProject());
myCachedProperties = myMetaManager.getCache(target.hashString());
if (myCachedProperties == null) {
metaManager.setCache(target.hashString(), myCachedProperties = new HashMap<String, List<Property>>());
myMetaManager.setCache(target.hashString(), myCachedProperties = new HashMap<String, List<Property>>());
}
AndroidPlatform androidPlatform = AndroidPlatform.getInstance(module);
@@ -67,38 +73,87 @@ public class PropertyParser {
public void load(RadViewComponent component) throws Exception {
ViewInfo info = component.getViewInfo();
MetaModel model = component.getMetaModel();
if (info == null) {
String target = component.getMetaModel().getTarget();
String target = model.getTarget();
if (target == null) {
component.setProperties(Collections.<Property>emptyList());
}
else {
component.setProperties(load(myClassLoader.loadClass(target)));
component.setProperties(load(myClassLoader.loadClass(target), model));
}
}
else {
component.setProperties(load(myClassLoader.loadClass(info.getClassName())));
component.setProperties(load(myClassLoader.loadClass(info.getClassName()), model));
}
}
private List<Property> load(Class<?> componentClass) {
private List<Property> load(Class<?> componentClass, MetaModel model) {
String component = componentClass.getSimpleName();
List<Property> properties = myCachedProperties.get(component);
if (properties == null) {
properties = new ArrayList<Property>();
System.out.println("--- " + componentClass + " -----------------");
StyleableDefinition definitions = myDefinitions.getStyleableByName(component);
if (definitions != null) {
for (AttributeDefinition definition : definitions.getAttributes()) {
properties.add(new AttributeProperty(null, definition));
// TODO
String name = definition.getName();
Set<AttributeFormat> formats = definition.getFormats();
Property property;
if (formats.contains(AttributeFormat.Flag)) {
property = new FlagProperty(name, definition);
}
else {
property = new AttributeProperty(name, definition);
}
if (model != null) {
property.setImportant(model.isImportantProperty(name));
property.setExpert(model.isExpertProperty(name));
property.setDeprecated(model.isDeprecatedProperty(name));
}
properties.add(property);
System.out.println(definition + " = " + Arrays.toString(definition.getValues()));
}
}
Class<?> superComponentClass = componentClass.getSuperclass();
if (superComponentClass != null) {
properties.addAll(load(superComponentClass));
List<Property> superProperties = load(superComponentClass, myMetaManager.getModelByTarget(superComponentClass.getName()));
for (Property superProperty : superProperties) {
if (PropertyTable.findProperty(properties, superProperty) == -1) {
if (model == null) {
properties.add(superProperty);
}
else {
String name = superProperty.getName();
boolean normal = model.isNormalProperty(name);
boolean important = model.isImportantProperty(name);
boolean expert = model.isExpertProperty(name);
boolean deprecated = model.isDeprecatedProperty(name);
if ((normal && (superProperty.isImportant() || superProperty.isExpert())) ||
(important && !superProperty.isImportant()) ||
(expert && !superProperty.isExpert()) ||
(deprecated && !superProperty.isDeprecated())) {
Property property = superProperty.createForNewPresentation();
property.setImportant(important);
property.setExpert(expert);
property.setDeprecated(deprecated);
properties.add(property);
}
else {
properties.add(superProperty);
}
}
}
}
}
if (!properties.isEmpty()) {
@@ -21,6 +21,19 @@
<palette title="Unknown (%tag%)" icon="/com/intellij/android/designer/icons/unknown.png"/>
</meta>
<meta class="android.view.View">
<properties
important="id background"
expert="tag scrollX scrollY fitsSystemWindows scrollbars scrollbarStyle isScrollContainer fadeScrollbars scrollbarFadeDuration scrollbarDefaultDelayBeforeFade scrollbarSize scrollbarThumbHorizontal scrollbarThumbVertical scrollbarTrackHorizontal scrollbarTrackVertical scrollbarAlwaysDrawHorizontalTrack scrollbarAlwaysDrawVerticalTrack fadingEdge requiresFadingEdge fadingEdgeLength nextFocusLeft nextFocusRight nextFocusUp nextFocusDown nextFocusForward saveEnabled filterTouchesWhenObscured drawingCacheQuality keepScreenOn duplicateParentState soundEffectsEnabled hapticFeedbackEnabled contentDescription overScrollMode translationX translationY transformPivotX transformPivotY rotation rotationX rotationY scaleX scaleY verticalScrollbarPosition layerType layoutDirection textDirection"
/>
</meta>
<meta class="class android.view.ViewGroup">
<properties
expert="animateLayoutChanges clipChildren clipToPadding layoutAnimation animationCache persistentDrawingCache alwaysDrawnWithCache addStatesFromChildren descendantFocusability splitMotionEvents"
/>
</meta>
<meta model="com.intellij.android.designer.model.RadViewComponent"
class="android.widget.Button"
tag="Button">
@@ -29,6 +42,11 @@
<palette title="Button" icon="/com/intellij/android/designer/icons/Button.png"
tooltip="Represents a push-button widget."/>
<properties
important="onClick"
expert="editable password autoLink linksClickable numeric digits phoneNumber inputMethod autoText inputType textIsSelectable"
/>
<creation>
<![CDATA[
<Button
@@ -48,6 +66,11 @@
<palette title="TextView" icon="/com/intellij/android/designer/icons/TextView.png"
tooltip="Displays text to the user and optionally allows them to edit it."/>
<properties
important="text hint textColor typeface textStyle gravity editable enabled"
expert="bufferType textScaleX cursorVisible scrollHorizontally includeFontPadding shadowDx shadowDy shadowRadius freezesText drawableTop drawableLeft drawableStart drawablePadding lineSpacingExtra lineSpacingMultiplier imeOptions privateImeOptions imeActionLabel imeActionId editorExtras textSelectHandleLeft textSelectHandleRight textSelectHandle textEditPasteWindowLayout textEditNoPasteWindowLayout textEditSideNoPasteWindowLayout textEditSuggestionItemLayout textCursorDrawable textAllCaps maxEms ems minEms"
/>
<creation>
<![CDATA[
<TextView
@@ -67,6 +90,10 @@
<palette title="LinearLayout" icon="/com/intellij/android/designer/icons/LinearLayout.png"
tooltip="A Layout that arranges its children in a single column or a single row."/>
<properties
important="orientation gravity"
/>
<creation>
<![CDATA[
<LinearLayout
@@ -83,6 +110,9 @@
<item tag="Button"/>
<item tag="TextView"/>
</group>
<group name="Containers">
<item tag="LinearLayout"/>
</group>
</palette>
</meta-model>
@@ -13,8 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.android.designer.model;
package com.intellij.android.designer.propertyTable;
import com.intellij.android.designer.model.RadViewComponent;
import com.intellij.android.designer.propertyTable.editors.BooleanEditor;
import com.intellij.android.designer.propertyTable.renderers.BooleanRenderer;
import com.intellij.designer.propertyTable.Property;
import com.intellij.designer.propertyTable.PropertyEditor;
import com.intellij.designer.propertyTable.PropertyRenderer;
@@ -24,25 +27,51 @@ import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.xml.XmlAttribute;
import org.jetbrains.android.dom.attrs.AttributeDefinition;
import org.jetbrains.android.dom.attrs.AttributeFormat;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Set;
/**
* @author Alexander Lobas
*/
public class AttributeProperty extends Property<RadViewComponent> {
private final LabelPropertyRenderer myRenderer = new LabelPropertyRenderer(null);
private final AttributeDefinition myDefinition;
private final PropertyEditor myEditor = new AbstractTextFieldEditor() {
@Override
public Object getValue() throws Exception {
return myTextField.getText();
}
};
private final PropertyRenderer myRenderer;
private final PropertyEditor myEditor;
public AttributeProperty(Property parent, @NotNull AttributeDefinition definition) {
super(parent, definition.getName());
public AttributeProperty(@NotNull String name, @NotNull AttributeDefinition definition) {
super(null, name);
myDefinition = definition;
Set<AttributeFormat> formats = definition.getFormats();
if (formats.contains(AttributeFormat.Boolean)) {
myRenderer = new BooleanRenderer();
myEditor = new BooleanEditor();
}
else {
myRenderer = new LabelPropertyRenderer(null);
if (formats.contains(AttributeFormat.Enum)) {
}
else {
}
myEditor = new AbstractTextFieldEditor() {
@Override
public Object getValue() throws Exception {
return myTextField.getText();
}
};
}
}
@Override
public Property createForNewPresentation() {
return new AttributeProperty(getName(), myDefinition);
}
@Override
@@ -0,0 +1,81 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.android.designer.propertyTable;
import com.intellij.android.designer.model.RadViewComponent;
import com.intellij.designer.propertyTable.Property;
import com.intellij.designer.propertyTable.PropertyEditor;
import com.intellij.designer.propertyTable.PropertyRenderer;
import com.intellij.designer.propertyTable.renderers.LabelPropertyRenderer;
import org.jetbrains.android.dom.attrs.AttributeDefinition;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
/**
* @author Alexander Lobas
*/
public class FlagProperty extends Property<RadViewComponent> {
private final PropertyRenderer myRenderer = new LabelPropertyRenderer(null);
private final AttributeDefinition myDefinition;
public FlagProperty(@NotNull String name, @NotNull AttributeDefinition definition) {
super(null, name);
myDefinition = definition;
}
@Override
public Property createForNewPresentation() {
return new FlagProperty(getName(), myDefinition);
}
@Override
public List<Property> getChildren(@Nullable RadViewComponent component) {
return super.getChildren(component); // TODO: Auto-generated method stub
}
@Override
public Object getValue(RadViewComponent component) throws Exception {
return "[]";
}
@Override
public void setValue(RadViewComponent component, Object value) throws Exception {
super.setValue(component, value); // TODO: Auto-generated method stub
}
@Override
public boolean isDefaultValue(RadViewComponent component) throws Exception {
return super.isDefaultValue(component); // TODO: Auto-generated method stub
}
@Override
public void setDefaultValue(RadViewComponent component) throws Exception {
super.setDefaultValue(component); // TODO: Auto-generated method stub
}
@NotNull
@Override
public PropertyRenderer getRenderer() {
return myRenderer;
}
@Override
public PropertyEditor getEditor() {
return null;
}
}
@@ -0,0 +1,33 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.android.designer.propertyTable.editors;
import com.intellij.openapi.util.text.StringUtil;
/**
* @author Alexander Lobas
*/
public class BooleanEditor extends com.intellij.designer.propertyTable.editors.BooleanEditor {
@Override
public Object getValue() throws Exception {
return Boolean.toString(myCheckBox.isSelected());
}
@Override
protected boolean getValue(Object value) {
return Boolean.parseBoolean((String)value);
}
}
@@ -0,0 +1,26 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.android.designer.propertyTable.renderers;
/**
* @author Alexander Lobas
*/
public class BooleanRenderer extends com.intellij.designer.propertyTable.renderers.BooleanRenderer {
@Override
protected boolean getValue(Object value) {
return Boolean.parseBoolean((String)value);
}
}
@@ -1,5 +1,6 @@
package org.jetbrains.android.actions;
import com.android.resources.ResourceFolderType;
import com.intellij.CommonBundle;
import com.intellij.ide.actions.CreateElementActionBase;
import com.intellij.openapi.actionSystem.DataContext;
@@ -22,15 +23,23 @@ import java.io.File;
* @author Eugene.Kudelevsky
*/
public class CreateResourceDirectoryAction extends CreateElementActionBase {
private final ResourceFolderType myResourceFolderType;
@SuppressWarnings("UnusedDeclaration")
public CreateResourceDirectoryAction() {
this(null);
}
public CreateResourceDirectoryAction(@Nullable ResourceFolderType resourceFolderType) {
super(AndroidBundle.message("new.resource.dir.action.title"), AndroidBundle.message("new.resource.action.description"),
PlatformIcons.DIRECTORY_CLOSED_ICON);
myResourceFolderType = resourceFolderType;
}
@NotNull
@Override
protected PsiElement[] invokeDialog(final Project project, final PsiDirectory directory) {
final CreateResourceDirectoryDialog dialog = new CreateResourceDirectoryDialog(project) {
public PsiElement[] invokeDialog(final Project project, final PsiDirectory directory) {
final CreateResourceDirectoryDialog dialog = new CreateResourceDirectoryDialog(project, myResourceFolderType) {
@Override
protected InputValidator createValidator() {
return CreateResourceDirectoryAction.this.createValidator(project, directory);
@@ -47,7 +47,7 @@
</grid>
</constraints>
<properties>
<enabled value="false"/>
<enabled value="true"/>
</properties>
</component>
<component id="71b17" class="com.intellij.ui.components.JBLabel" binding="myErrorLabel">
@@ -26,6 +26,7 @@ import com.intellij.ui.components.JBLabel;
import org.jetbrains.android.uipreview.DeviceConfiguratorPanel;
import org.jetbrains.android.uipreview.InvalidOptionValueException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.awt.*;
@@ -45,7 +46,7 @@ public abstract class CreateResourceDirectoryDialog extends DialogWrapper {
private final DeviceConfiguratorPanel myDeviceConfiguratorPanel;
private InputValidator myValidator;
public CreateResourceDirectoryDialog(@NotNull Project project) {
public CreateResourceDirectoryDialog(@NotNull Project project, @Nullable ResourceFolderType resType) {
super(project);
myResourceTypeComboBox.setModel(new EnumComboBoxModel<ResourceFolderType>(ResourceFolderType.class));
@@ -84,6 +85,11 @@ public abstract class CreateResourceDirectoryDialog extends DialogWrapper {
}
});
if (resType != null) {
myResourceTypeComboBox.setSelectedItem(resType);
myResourceTypeComboBox.setEnabled(false);
}
myDeviceConfiguratorPanel.updateAll();
setOKActionEnabled(myDirectoryNameTextField.getText().length() > 0);
init();
@@ -1,21 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="org.jetbrains.android.actions.CreateXmlResourceDialog">
<grid id="27dc6" binding="myPanel" layout-manager="GridLayoutManager" row-count="6" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="27dc6" binding="myPanel" layout-manager="GridLayoutManager" row-count="5" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="5" right="0"/>
<constraints>
<xy x="20" y="20" width="500" height="400"/>
<xy x="20" y="20" width="288" height="400"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<grid id="82472" binding="myDeviceConfigurationWrapper" layout-manager="BorderLayout" hgap="0" vgap="0">
<constraints>
<grid row="4" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children/>
</grid>
<component id="43fab" class="com.intellij.ui.components.JBLabel">
<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"/>
@@ -48,29 +40,6 @@
<text value="&amp;Module:"/>
</properties>
</component>
<component id="d6c07" class="com.intellij.ui.components.JBLabel">
<constraints>
<grid row="3" 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>
<labelFor value="832da"/>
<text value="&amp;Directory name:"/>
</properties>
</component>
<component id="832da" class="javax.swing.JTextField" binding="myDirectoryNameField">
<constraints>
<grid row="3" column="1" 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="da401" class="com.intellij.ui.components.JBLabel" binding="myErrorLabel">
<constraints>
<grid row="5" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="0" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
<component id="21872" class="com.intellij.ui.components.JBLabel">
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
@@ -88,6 +57,22 @@
</constraints>
<properties/>
</component>
<grid id="8a4e8" binding="myDirectoriesPanel" layout-manager="BorderLayout" hgap="0" vgap="0">
<constraints>
<grid row="4" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children/>
</grid>
<component id="d6c07" class="com.intellij.ui.components.JBLabel" binding="myDirectoriesLabel">
<constraints>
<grid row="3" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="&amp;Directories:"/>
</properties>
</component>
</children>
</grid>
</form>
@@ -1,57 +1,68 @@
package org.jetbrains.android.actions;
import com.android.AndroidConstants;
import com.android.ide.common.resources.configuration.FolderConfiguration;
import com.android.resources.ResourceFolderType;
import com.android.resources.ResourceType;
import com.intellij.CommonBundle;
import com.intellij.ide.ui.ListCellRendererWrapper;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.fileChooser.actions.VirtualFileDeleteProvider;
import com.intellij.openapi.fileTypes.StdFileTypes;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleType;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.ui.ValidationInfo;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiDirectory;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiManager;
import com.intellij.ui.*;
import com.intellij.ui.components.JBLabel;
import com.intellij.util.ArrayUtil;
import com.intellij.util.PlatformIcons;
import com.intellij.util.containers.HashSet;
import com.intellij.util.containers.hash.HashMap;
import org.jetbrains.android.dom.resources.ResourceElement;
import org.jetbrains.android.dom.resources.Resources;
import org.jetbrains.android.facet.AndroidFacet;
import org.jetbrains.android.facet.AndroidRootUtil;
import org.jetbrains.android.uipreview.DeviceConfiguratorPanel;
import org.jetbrains.android.uipreview.InvalidOptionValueException;
import org.jetbrains.android.util.AndroidBundle;
import org.jetbrains.android.util.AndroidCommonUtils;
import org.jetbrains.android.util.AndroidResourceUtil;
import org.jetbrains.android.util.AndroidUtils;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.awt.*;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Set;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.*;
/**
* @author Eugene.Kudelevsky
*/
public class CreateXmlResourceDialog extends DialogWrapper {
private JPanel myPanel;
private JPanel myDeviceConfigurationWrapper;
private JTextField myNameField;
private JComboBox myModuleCombo;
private JBLabel myModuleLabel;
private JTextField myDirectoryNameField;
private JBLabel myErrorLabel;
private JTextField myFileNameField;
private JPanel myDirectoriesPanel;
private JBLabel myDirectoriesLabel;
private final DeviceConfiguratorPanel myDeviceConfiguratorPanel;
private final Module myModule;
private final ResourceType myResourceType;
private Map<String, JCheckBox> myCheckBoxes = Collections.emptyMap();
private String[] myDirNames = ArrayUtil.EMPTY_STRING_ARRAY;
private final CheckBoxList myDirectoriesList;
private VirtualFile myResourceDir;
public CreateXmlResourceDialog(@NotNull Module module, @NotNull ResourceType resourceType) {
super(module.getProject());
@@ -94,39 +105,189 @@ public class CreateXmlResourceDialog extends DialogWrapper {
});
}
myDeviceConfiguratorPanel = new DeviceConfiguratorPanel(null) {
@Override
public void applyEditors() {
try {
doApplyEditors();
final FolderConfiguration config = myDeviceConfiguratorPanel.getConfiguration();
myErrorLabel.setText("");
myDirectoryNameField.setText(config.getFolderName(ResourceFolderType.VALUES));
}
catch (InvalidOptionValueException e) {
myErrorLabel.setText("<html><body><font color=\"red\">" + e.getMessage() + "</font></body></html>");
myDirectoryNameField.setText(AndroidConstants.FD_RES_VALUES);
}
}
};
myDeviceConfigurationWrapper.add(myDeviceConfiguratorPanel, BorderLayout.CENTER);
final String defaultResFileName = AndroidResourceUtil.getDefaultResourceFileName(resourceType.getName());
if (defaultResFileName != null) {
myFileNameField.setText(defaultResFileName);
}
myDirectoryNameField.setText(AndroidConstants.FD_RES_VALUES);
myDeviceConfiguratorPanel.updateAll();
myDirectoriesList = new CheckBoxList();
myDirectoriesLabel.setLabelFor(myDirectoriesList);
final ToolbarDecorator decorator = ToolbarDecorator.createDecorator(myDirectoriesList);
decorator.setEditAction(null);
decorator.disableUpDownActions();
decorator.setAddAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
doAddNewDirectory();
}
});
decorator.setRemoveAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
doDeleteDirectory();
}
});
final AnActionButton selectAll = new AnActionButton("Select All", null, PlatformIcons.SELECT_ALL_ICON) {
@Override
public void actionPerformed(AnActionEvent e) {
doSelectAllDirs();
}
};
decorator.addExtraAction(selectAll);
final AnActionButton unselectAll = new AnActionButton("Unselect All", null, PlatformIcons.UNSELECT_ALL_ICON) {
@Override
public void actionPerformed(AnActionEvent e) {
doUnselectAllDirs();
}
};
decorator.addExtraAction(unselectAll);
myDirectoriesPanel.add(decorator.createPanel());
updateDirectories();
myModuleCombo.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
updateDirectories();
}
});
init();
}
private void doDeleteDirectory() {
if (myResourceDir == null) {
return;
}
final int selectedIndex = myDirectoriesList.getSelectedIndex();
if (selectedIndex < 0) {
return;
}
final String selectedDirName = myDirNames[selectedIndex];
final VirtualFile selectedDir = myResourceDir.findChild(selectedDirName);
if (selectedDir == null) {
return;
}
final VirtualFileDeleteProvider provider = new VirtualFileDeleteProvider();
provider.deleteElement(new DataContext() {
@Override
public Object getData(@NonNls String dataId) {
if (PlatformDataKeys.VIRTUAL_FILE_ARRAY.getName().equals(dataId)) {
return new VirtualFile[] {selectedDir};
}
else {
return null;
}
}
});
updateDirectories();
}
private void doSelectAllDirs() {
for (JCheckBox checkBox : myCheckBoxes.values()) {
checkBox.setSelected(true);
}
myDirectoriesList.repaint();
}
private void doUnselectAllDirs() {
for (JCheckBox checkBox : myCheckBoxes.values()) {
checkBox.setSelected(false);
}
myDirectoriesList.repaint();
}
private void doAddNewDirectory() {
if (myResourceDir == null) {
return;
}
final Module module = getModule();
if (module == null) {
return;
}
final Project project = module.getProject();
final PsiDirectory psiResDir = PsiManager.getInstance(project).findDirectory(myResourceDir);
if (psiResDir != null) {
final PsiElement[] createdElements = new CreateResourceDirectoryAction(ResourceFolderType.VALUES).invokeDialog(project, psiResDir);
if (createdElements.length > 0) {
updateDirectories();
}
}
}
private void updateDirectories() {
final Module module = getModule();
List<VirtualFile> valuesDirs = Collections.emptyList();
if (module != null) {
final AndroidFacet facet = AndroidFacet.getInstance(module);
if (facet != null) {
myResourceDir = AndroidRootUtil.getResourceDir(facet);
if (myResourceDir != null) {
valuesDirs = AndroidResourceUtil.getResourceSubdirs(ResourceFolderType.VALUES.getName(), new VirtualFile[]{myResourceDir});
}
}
}
Collections.sort(valuesDirs, new Comparator<VirtualFile>() {
@Override
public int compare(VirtualFile f1, VirtualFile f2) {
return f1.getName().compareTo(f2.getName());
}
});
final Map<String, JCheckBox> oldCheckBoxes = myCheckBoxes;
final int selectedIndex = myDirectoriesList.getSelectedIndex();
final String selectedDirName = selectedIndex >= 0 ? myDirNames[selectedIndex] : null;
final List<JCheckBox> checkBoxList = new ArrayList<JCheckBox>();
myCheckBoxes = new HashMap<String, JCheckBox>();
myDirNames = new String[valuesDirs.size()];
int newSelectedIndex = -1;
int i = 0;
for (VirtualFile dir : valuesDirs) {
final String dirName = dir.getName();
final JCheckBox oldCheckBox = oldCheckBoxes.get(dirName);
final boolean selected = oldCheckBox != null && oldCheckBox.isSelected();
final JCheckBox checkBox = new JCheckBox(dirName, selected);
checkBoxList.add(checkBox);
myCheckBoxes.put(dirName, checkBox);
myDirNames[i] = dirName;
if (dirName.equals(selectedDirName)) {
newSelectedIndex = i;
}
i++;
}
myDirectoriesList.setModel(new CollectionListModel<JCheckBox>(checkBoxList));
if (newSelectedIndex >= 0) {
myDirectoriesList.setSelectedIndex(newSelectedIndex);
}
}
@Override
protected ValidationInfo doValidate() {
final String resourceName = getResourceName();
final Module selectedModule = getModule();
final String directoryName = getDirectoryName();
final List<String> directoryNames = getDirNames();
final String fileName = getFileName();
if (resourceName.length() == 0) {
@@ -141,23 +302,14 @@ public class CreateXmlResourceDialog extends DialogWrapper {
else if (selectedModule == null) {
return new ValidationInfo("specify module", myModuleCombo);
}
else if (!ResourceFolderType.VALUES.getName().equals(
AndroidCommonUtils.getResourceTypeByDirName(directoryName))) {
return new ValidationInfo("directory name is not appropriate for value resources");
else if (directoryNames.size() == 0) {
return new ValidationInfo("choose directories", myDirectoriesList);
}
final ValidationInfo info = checkIfResourceAlreadyExists(selectedModule, resourceName, myResourceType, directoryName, fileName);
final ValidationInfo info = checkIfResourceAlreadyExists(selectedModule, resourceName, myResourceType, directoryNames, fileName);
if (info != null) {
return info;
}
try {
myDeviceConfiguratorPanel.doApplyEditors();
}
catch (InvalidOptionValueException e) {
return new ValidationInfo("fix errors in configuration editor");
}
return null;
}
@@ -165,10 +317,10 @@ public class CreateXmlResourceDialog extends DialogWrapper {
private static ValidationInfo checkIfResourceAlreadyExists(@NotNull Module selectedModule,
@NotNull String resourceName,
@NotNull ResourceType resourceType,
@NotNull String directoryName,
@NotNull List<String> dirNames,
@NotNull String fileName) {
if (resourceName.length() == 0 ||
directoryName.length() == 0 ||
dirNames.size() == 0 ||
fileName.length() == 0) {
return null;
}
@@ -179,29 +331,31 @@ public class CreateXmlResourceDialog extends DialogWrapper {
return null;
}
final VirtualFile resourceSubdir = resourceDir.findChild(directoryName);
if (resourceSubdir == null) {
return null;
}
for (String directoryName : dirNames) {
final VirtualFile resourceSubdir = resourceDir.findChild(directoryName);
if (resourceSubdir == null) {
continue;
}
final VirtualFile resFile = resourceSubdir.findChild(fileName);
if (resFile == null) {
return null;
}
final VirtualFile resFile = resourceSubdir.findChild(fileName);
if (resFile == null) {
continue;
}
if (resFile.getFileType() != StdFileTypes.XML) {
return new ValidationInfo("File " + FileUtil.toSystemDependentName(resFile.getPath()) + " is not XML file");
}
if (resFile.getFileType() != StdFileTypes.XML) {
return new ValidationInfo("File " + FileUtil.toSystemDependentName(resFile.getPath()) + " is not XML file");
}
final Resources resources = AndroidUtils.loadDomElement(selectedModule, resFile, Resources.class);
if (resources == null) {
return new ValidationInfo(AndroidBundle.message("not.resource.file.error", FileUtil.toSystemDependentName(resFile.getPath())));
}
final Resources resources = AndroidUtils.loadDomElement(selectedModule, resFile, Resources.class);
if (resources == null) {
return new ValidationInfo(AndroidBundle.message("not.resource.file.error", FileUtil.toSystemDependentName(resFile.getPath())));
}
for (ResourceElement element : AndroidResourceUtil.getValueResourcesFromElement(resourceType.getName(), resources)) {
if (resourceName.equals(element.getName().getValue())) {
return new ValidationInfo("resource '" + resourceName + "' already exists in " + FileUtil.toSystemDependentName(
resFile.getPath()));
for (ResourceElement element : AndroidResourceUtil.getValueResourcesFromElement(resourceType.getName(), resources)) {
if (resourceName.equals(element.getName().getValue())) {
return new ValidationInfo("resource '" + resourceName + "' already exists in " + FileUtil.toSystemDependentName(
resFile.getPath()));
}
}
}
return null;
@@ -216,7 +370,7 @@ public class CreateXmlResourceDialog extends DialogWrapper {
protected void doOKAction() {
final String resourceName = getResourceName();
final String fileName = getFileName();
final String dirName = getDirectoryName();
final List<String> dirNames = getDirNames();
final Module module = getModule();
if (resourceName.length() == 0) {
@@ -228,8 +382,8 @@ public class CreateXmlResourceDialog extends DialogWrapper {
else if (fileName.length() == 0) {
Messages.showErrorDialog(myPanel, "File name is not specified", CommonBundle.getErrorTitle());
}
else if (dirName.length() == 0) {
Messages.showErrorDialog(myPanel, "Directory name is not specified", CommonBundle.getErrorTitle());
else if (dirNames.size() == 0) {
Messages.showErrorDialog(myPanel, "Directories are not selected", CommonBundle.getErrorTitle());
}
else if (module == null) {
Messages.showErrorDialog(myPanel, "Module is not specified", CommonBundle.getErrorTitle());
@@ -245,8 +399,15 @@ public class CreateXmlResourceDialog extends DialogWrapper {
}
@NotNull
public String getDirectoryName() {
return myDirectoryNameField.getText().trim();
public List<String> getDirNames() {
final List<String> selectedDirs = new ArrayList<String>();
for (Map.Entry<String, JCheckBox> entry : myCheckBoxes.entrySet()) {
if (entry.getValue().isSelected()) {
selectedDirs.add(entry.getKey());
}
}
return selectedDirs;
}
@NotNull
@@ -67,7 +67,9 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.io.File;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import static org.jetbrains.android.util.AndroidUtils.VIEW_CLASS_NAME;
@@ -204,20 +206,14 @@ public class AndroidAddStringResourceAction extends AbstractIntentionAction impl
return;
}
final ResourceElement createdElement =
doCreate(module, dialog.getResourceName(), ResourceType.STRING, dialog.getFileName(), dialog.getDirectoryName(), value);
if (createdElement != null) {
resName = createdElement.getName().getValue();
resName = dialog.getResourceName();
if (!doCreate(module, resName, ResourceType.STRING, dialog.getFileName(), dialog.getDirNames(), value)) {
return;
}
}
else {
assert ApplicationManager.getApplication().isUnitTestMode();
doCreate(facet.getModule(), resName, ResourceType.STRING, "strings.xml", "values", value);
}
if (resName == null) {
return;
doCreate(facet.getModule(), resName, ResourceType.STRING, "strings.xml", Collections.singletonList("values"), value);
}
if (file instanceof PsiJavaFile) {
@@ -358,19 +354,18 @@ public class AndroidAddStringResourceAction extends AbstractIntentionAction impl
return true;
}
@Nullable
private static ResourceElement doCreate(@NotNull Module module,
@NotNull String resourceName,
@NotNull ResourceType resourceType,
@NotNull String fileName,
@NotNull String dirName,
@NotNull String value) {
private static boolean doCreate(@NotNull Module module,
@NotNull String resourceName,
@NotNull ResourceType resourceType,
@NotNull String fileName,
@NotNull List<String> dirNames,
@NotNull String value) {
final Project project = module.getProject();
final AndroidFacet facet = AndroidFacet.getInstance(module);
assert facet != null;
try {
return addValueResource(facet, resourceName, resourceType, fileName, dirName, value);
return addValueResource(facet, resourceName, resourceType, fileName, dirNames, value);
}
catch (Exception e) {
final String message = CreateElementActionBase.filterMessage(e.getMessage());
@@ -382,36 +377,52 @@ public class AndroidAddStringResourceAction extends AbstractIntentionAction impl
LOG.info(e);
reportError(project, message);
}
return null;
return false;
}
}
@Nullable
public static ResourceElement addValueResource(@NotNull AndroidFacet facet,
@NotNull String resourceName,
@NotNull ResourceType resourceType,
@NotNull String fileName,
@NotNull String dirName,
@NotNull String value) throws Exception {
final VirtualFile resFile = findOrCreateResourceFile(facet, fileName, dirName);
if (resFile == null ||
!ReadonlyStatusHandler.ensureFilesWritable(facet.getModule().getProject(), resFile)) {
return null;
private static boolean addValueResource(@NotNull AndroidFacet facet,
@NotNull String resourceName,
@NotNull ResourceType resourceType,
@NotNull String fileName,
@NotNull List<String> dirNames,
@NotNull String value) throws Exception {
if (dirNames.size() == 0) {
return false;
}
final VirtualFile[] resFiles = new VirtualFile[dirNames.size()];
for (int i = 0, n = dirNames.size(); i < n; i++) {
final VirtualFile resFile = findOrCreateResourceFile(facet, fileName, dirNames.get(i));
if (resFile == null) {
return false;
}
resFiles[i] = resFile;
}
if (!ReadonlyStatusHandler.ensureFilesWritable(facet.getModule().getProject(), resFiles)) {
return false;
}
final Resources[] resourcesElements = new Resources[resFiles.length];
for (int i = 0; i < resFiles.length; i++) {
final Resources resources = AndroidUtils.loadDomElement(facet.getModule(), resFiles[i], Resources.class);
if (resources == null) {
reportError(facet.getModule().getProject(), AndroidBundle.message("not.resource.file.error", fileName));
return false;
}
resourcesElements[i] = resources;
}
final Resources resources = AndroidUtils.loadDomElement(facet.getModule(), resFile, Resources.class);
if (resources == null) {
reportError(facet.getModule().getProject(), AndroidBundle.message("not.resource.file.error", fileName));
return null;
}
for (Resources resources : resourcesElements) {
final ResourceElement element = AndroidResourceUtil.addValueResource(resourceType.getName(), resources);
element.getName().setValue(resourceName);
final ResourceElement element = AndroidResourceUtil.addValueResource(resourceType.getName(), resources);
element.getName().setValue(resourceName);
if (value.length() > 0) {
element.setStringValue(value);
if (value.length() > 0) {
element.setStringValue(value);
}
}
return element;
return true;
}
@Nullable
@@ -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>
+1
View File
@@ -224,6 +224,7 @@
<readWriteAccessDetector implementation="org.jetbrains.plugins.groovy.findUsages.GroovyReadWriteAccessDetector" order="before java"/>
<findUsagesHandlerFactory implementation="org.jetbrains.plugins.groovy.findUsages.GroovyFindUsagesHandlerFactory"/>
<highlightUsagesHandlerFactory implementation="org.jetbrains.plugins.groovy.findUsages.GrHighlightOverridingMethodsHandlerFactory"/>
<lang.braceMatcher language="Groovy" implementationClass="org.jetbrains.plugins.groovy.highlighter.GroovyBraceMatcher"/>
<lang.importOptimizer language="Groovy" implementationClass="org.jetbrains.plugins.groovy.lang.editor.GroovyImportOptimizer"/>
<lang.documentationProvider language="Groovy"
@@ -0,0 +1,57 @@
/*
* 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 org.jetbrains.plugins.groovy.findUsages;
import com.intellij.codeInsight.highlighting.ChooseClassAndDoHighlightRunnable;
import com.intellij.codeInsight.highlighting.HighlightOverridingMethodsHandler;
import com.intellij.openapi.editor.Editor;
import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiClassType;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrReferenceList;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition;
import java.util.Collections;
import java.util.List;
/**
* @author Max Medvedev
*/
public class GrHighlightOverridingMethodsHandler extends HighlightOverridingMethodsHandler {
private final PsiElement myTarget;
private final GrTypeDefinition myClass;
public GrHighlightOverridingMethodsHandler(final Editor editor,
final PsiFile file,
final PsiElement target,
final GrTypeDefinition psiClass) {
super(editor, file, target, psiClass);
myTarget = target;
myClass = psiClass;
}
@Override
public List<PsiClass> getTargets() {
GrReferenceList list =
GroovyTokenTypes.kEXTENDS == myTarget.getNode().getElementType() ? myClass.getExtendsClause() : myClass.getImplementsClause();
if (list == null) return Collections.emptyList();
final PsiClassType[] classTypes = list.getReferenceTypes();
return ChooseClassAndDoHighlightRunnable.resolveClasses(classTypes);
}
}
@@ -0,0 +1,53 @@
/*
* 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 org.jetbrains.plugins.groovy.findUsages;
import com.intellij.codeInsight.TargetElementUtilBase;
import com.intellij.codeInsight.highlighting.HighlightUsagesHandlerBase;
import com.intellij.codeInsight.highlighting.HighlightUsagesHandlerFactory;
import com.intellij.lang.ASTNode;
import com.intellij.openapi.editor.Editor;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.tree.IElementType;
import org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrReferenceList;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition;
/**
* @author Max Medvedev
*/
public class GrHighlightOverridingMethodsHandlerFactory implements HighlightUsagesHandlerFactory {
@Override
public HighlightUsagesHandlerBase createHighlightUsagesHandler(Editor editor, PsiFile file) {
int offset = TargetElementUtilBase.adjustOffset(editor.getDocument(), editor.getCaretModel().getOffset());
final PsiElement target = file.findElementAt(offset);
if (target == null) return null;
ASTNode node = target.getNode();
if (node == null) return null;
IElementType type = node.getElementType();
if (type == GroovyTokenTypes.kIMPLEMENTS || type == GroovyTokenTypes.kEXTENDS) {
PsiElement parent = target.getParent();
if (!(parent instanceof GrReferenceList)) return null;
PsiElement grand = parent.getParent();
if (!(grand instanceof GrTypeDefinition)) return null;
return new GrHighlightOverridingMethodsHandler(editor, file, target, (GrTypeDefinition)grand);
}
return null;
}
}
@@ -16,6 +16,7 @@
package org.jetbrains.plugins.groovy.lang.parser;
import com.intellij.lang.ASTNode;
import com.intellij.lang.Language;
import com.intellij.lexer.Lexer;
import com.intellij.openapi.project.Project;
import com.intellij.psi.tree.ICompositeElementType;
@@ -47,7 +48,7 @@ public abstract class GrCodeBlockElementType extends IErrorCounterReparseableEle
public abstract GrBlockImpl createNode(final CharSequence text);
@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 GroovyLexer();
lexer.start(seq);
@@ -1,4 +1,4 @@
class Pair {}
List<Pair> otherPairs = new ArrayList<Pair>();
List<Pair> pairs = otherPairs.findAll({it != null})
List<Date> pairs2 = <warning descr="Cannot assign 'Collection<Pair>' to 'List<Date>'">otherPairs.findAll({it != null})</warning>
List<Date> pairs2 = <warning descr="Cannot assign 'ArrayList<Pair>' to 'List<Date>'">otherPairs.findAll({it != null})</warning>
@@ -15,6 +15,7 @@
*/
package org.jetbrains.idea.svn;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ModalityState;
import com.intellij.openapi.diagnostic.Logger;
@@ -23,6 +24,7 @@ import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.MessageType;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.Getter;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.util.io.FileUtil;
@@ -57,7 +59,7 @@ public class SvnAuthenticationManager extends DefaultSVNAuthenticationManager im
public static final String SVN_SSH = "svn+ssh";
public static final String HTTP = "http";
public static final String HTTPS = "https";
private final Project myProject;
private Project myProject;
private File myConfigDirectory;
private PersistentAuthenticationProviderProxy myPersistentAuthenticationProviderProxy;
private SvnConfiguration myConfig;
@@ -81,6 +83,22 @@ public class SvnAuthenticationManager extends DefaultSVNAuthenticationManager im
myPersistentAuthenticationProviderProxy.setProject(myProject);
}
myInteraction = new MySvnAuthenticationInteraction(myProject);
Disposer.register(project, new Disposable() {
@Override
public void dispose() {
myProject = null;
if (myPersistentAuthenticationProviderProxy != null) {
myPersistentAuthenticationProviderProxy.myProject = null;
myPersistentAuthenticationProviderProxy = null;
}
if (myConfig != null) {
myConfig.clear();
myConfig = null;
}
myInteraction = null;
}
});
}
public void setArtificialSaving(boolean artificialSaving) {
@@ -303,7 +303,7 @@ public class SvnAuthenticationNotifier extends GenericNotifierImpl<SvnAuthentica
public static boolean passiveValidation(final Project project, final SVNURL url) {
final SvnConfiguration configuration = SvnConfiguration.getInstance(project);
final SvnAuthenticationManager passiveManager = configuration.getPassiveAuthenticationManager();
final SvnAuthenticationManager passiveManager = configuration.getPassiveAuthenticationManager(project);
return validationImpl(project, url, configuration, passiveManager, false, null, null, false);
}
@@ -266,6 +266,9 @@
<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/>
<clientProperties>
<BorderFactoryClass class="java.lang.String" value="com.intellij.ui.IdeBorderFactory$BoldSmallWithIndent"/>
</clientProperties>
<border type="etched" title="Subversion 1.7 Acceleration">
<color color="-16777216"/>
</border>
@@ -103,7 +103,7 @@ public class SvnConfigurable implements Configurable {
Messages.getWarningIcon());
if (result == 0) {
SvnConfiguration.RUNTIME_AUTH_CACHE.clear();
SvnConfiguration.getInstance(myProject).clearAuthenticationDirectory();
SvnConfiguration.getInstance(myProject).clearAuthenticationDirectory(myProject);
}
}
@@ -36,6 +36,7 @@ import com.intellij.openapi.vcs.annotate.AnnotationListener;
import org.jdom.Attribute;
import org.jdom.DataConversionException;
import org.jdom.Element;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.idea.svn.dialogs.SvnAuthenticationProvider;
import org.jetbrains.idea.svn.dialogs.SvnInteractiveAuthenticationProvider;
import org.jetbrains.idea.svn.update.MergeRootInfo;
@@ -87,7 +88,6 @@ public class SvnConfiguration implements PersistentStateComponent<Element> {
private boolean myIsKeepLocks;
private boolean myAutoUpdateAfterCommit;
private boolean myRemoteStatus;
private final Project myProject;
private SvnAuthenticationManager myAuthManager;
private SvnAuthenticationManager myPassiveAuthManager;
private SvnAuthenticationManager myInteractiveManager;
@@ -146,7 +146,6 @@ public class SvnConfiguration implements PersistentStateComponent<Element> {
}
public SvnConfiguration(final Project project) {
myProject = project;
myAnnotationListeners = new ArrayList<AnnotationListener>();
}
@@ -210,10 +209,10 @@ public class SvnConfiguration implements PersistentStateComponent<Element> {
}
}
public SvnSupportOptions getSupportOptions() {
public SvnSupportOptions getSupportOptions(Project project) {
if (mySupportOptions == null) {
// used to be kept in SvnBranchConfigurationManager
mySupportOptions = new SvnSupportOptions(SvnBranchConfigurationManager.getInstance(myProject).getSupportValue());
mySupportOptions = new SvnSupportOptions(SvnBranchConfigurationManager.getInstance(project).getSupportValue());
}
return mySupportOptions;
}
@@ -234,6 +233,10 @@ public class SvnConfiguration implements PersistentStateComponent<Element> {
File dir = path == null ? new File(IdeaSubversionConfigurationDirectory.getPath()) : new File(path);
SVNConfigFile.createDefaultConfiguration(dir);
clear();
}
public void clear() {
myOptions = null;
myAuthManager = null;
myPassiveAuthManager = null;
@@ -244,12 +247,7 @@ public class SvnConfiguration implements PersistentStateComponent<Element> {
public void setUseDefaultConfiguation(boolean useDefault) {
myIsUseDefaultConfiguration = useDefault;
myOptions = null;
myAuthManager = null;
myPassiveAuthManager = null;
myInteractiveManager = null;
myInteractiveProvider = null;
RUNTIME_AUTH_CACHE.clear();
clear();
}
public ISVNOptions getOptions(Project project) {
@@ -277,7 +275,7 @@ public class SvnConfiguration implements PersistentStateComponent<Element> {
public SvnAuthenticationManager getAuthenticationManager(final SvnVcs svnVcs) {
if (myAuthManager == null) {
// reloaded when configuration directory changes
myAuthManager = new SvnAuthenticationManager(myProject, new File(getConfigurationDirectory()));
myAuthManager = new SvnAuthenticationManager(svnVcs.getProject(), new File(getConfigurationDirectory()));
getInteractiveManager(svnVcs);
// to init
myAuthManager.setAuthenticationProvider(new SvnAuthenticationProvider(svnVcs, myInteractiveProvider, RUNTIME_AUTH_CACHE));
@@ -286,9 +284,9 @@ public class SvnConfiguration implements PersistentStateComponent<Element> {
return myAuthManager;
}
public SvnAuthenticationManager getPassiveAuthenticationManager() {
public SvnAuthenticationManager getPassiveAuthenticationManager(Project project) {
if (myPassiveAuthManager == null) {
myPassiveAuthManager = new SvnAuthenticationManager(myProject, new File(getConfigurationDirectory()));
myPassiveAuthManager = new SvnAuthenticationManager(project, new File(getConfigurationDirectory()));
myPassiveAuthManager.setAuthenticationProvider(new ISVNAuthenticationProvider() {
@Override
public SVNAuthentication requestClientAuthentication(String kind,
@@ -312,7 +310,7 @@ public class SvnConfiguration implements PersistentStateComponent<Element> {
public SvnAuthenticationManager getInteractiveManager(final SvnVcs svnVcs) {
if (myInteractiveManager == null) {
myInteractiveManager = new SvnAuthenticationManager(myProject, new File(getConfigurationDirectory()));
myInteractiveManager = new SvnAuthenticationManager(svnVcs.getProject(), new File(getConfigurationDirectory()));
myInteractiveManager.setRuntimeStorage(RUNTIME_AUTH_CACHE);
myInteractiveProvider = new SvnInteractiveAuthenticationProvider(svnVcs, myInteractiveManager);
myInteractiveManager.setAuthenticationProvider(myInteractiveProvider);
@@ -517,7 +515,7 @@ public class SvnConfiguration implements PersistentStateComponent<Element> {
private static final List<String> ourAuthKinds = Arrays.asList(ISVNAuthenticationManager.PASSWORD, ISVNAuthenticationManager.SSH,
ISVNAuthenticationManager.SSL, ISVNAuthenticationManager.USERNAME, "svn.ssl.server", "svn.ssh.server");
public void clearAuthenticationDirectory() {
public void clearAuthenticationDirectory(@Nullable Project project) {
final File authDir = new File(getConfigurationDirectory(), "auth");
if (authDir.exists()) {
ProgressManager.getInstance().runProcessWithProgressSynchronously(new Runnable() {
@@ -540,7 +538,7 @@ public class SvnConfiguration implements PersistentStateComponent<Element> {
FileUtil.delete(dir);
}
}
}, "button.text.clear.authentication.cache", false, myProject);
}, "button.text.clear.authentication.cache", false, project);
}
}
@@ -298,7 +298,7 @@ public class SvnVcs extends AbstractVcs<CommittedChangeList> {
try {
ChangeListManager.getInstance(myProject).setReadOnly(SvnChangeProvider.ourDefaultListName, true);
supportOptions = myConfiguration.getSupportOptions();
supportOptions = myConfiguration.getSupportOptions(myProject);
upgradeToRecentVersion(supportOptions);
if (! supportOptions.changeListsSynchronized()) {
@@ -39,7 +39,7 @@ public class BranchesLoader {
final List<SvnBranchItem> result = new LinkedList<SvnBranchItem>();
final SvnConfiguration configuration = SvnConfiguration.getInstance(project);
final ISVNAuthenticationManager passiveManager = passive ? configuration.getPassiveAuthenticationManager() : configuration.getInteractiveManager(
final ISVNAuthenticationManager passiveManager = passive ? configuration.getPassiveAuthenticationManager(project) : configuration.getInteractiveManager(
SvnVcs.getInstance(project));
final SVNLogClient logClient = new SVNLogClient(passiveManager, configuration.getOptions(project));
@@ -730,7 +730,7 @@ public class SvnAuthenticationTest extends PlatformTestCase {
@Override
public void run() {
try {
myConfiguration.clearAuthenticationDirectory();
myConfiguration.clearAuthenticationDirectory(getProject());
}
catch (Exception e) {
throw new RuntimeException(e);
@@ -875,7 +875,7 @@ public class SvnAuthenticationTest extends PlatformTestCase {
@Override
public void run() {
try {
myConfiguration.clearAuthenticationDirectory();
myConfiguration.clearAuthenticationDirectory(getProject());
}
catch (Exception e) {
throw new RuntimeException(e);
@@ -734,7 +734,7 @@ public class SvnAuthenticationTest extends PlatformTestCase {
@Override
public void run() {
try {
myConfiguration.clearAuthenticationDirectory();
myConfiguration.clearAuthenticationDirectory(getProject());
}
catch (Exception e) {
throw new RuntimeException(e);
@@ -879,7 +879,7 @@ public class SvnAuthenticationTest extends PlatformTestCase {
@Override
public void run() {
try {
myConfiguration.clearAuthenticationDirectory();
myConfiguration.clearAuthenticationDirectory(getProject());
}
catch (Exception e) {
throw new RuntimeException(e);
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.uiDesigner.GuiDesignerConfigurable.MyGeneralUI">
<grid id="4a770" binding="myPanel" layout-manager="GridLayoutManager" row-count="7" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="4a770" binding="myPanel" layout-manager="GridLayoutManager" row-count="6" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="62" y="47" width="493" height="278"/>
@@ -10,53 +10,53 @@
<children>
<vspacer id="d5f77">
<constraints>
<grid row="6" column="0" row-span="1" col-span="2" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
<grid row="5" column="0" row-span="1" col-span="2" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<component id="2eed8" class="javax.swing.JLabel">
<grid id="b77c5" layout-manager="GridLayoutManager" row-count="2" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="0">
<margin top="0" left="0" bottom="4" right="0"/>
<constraints>
<grid row="0" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text resource-bundle="messages/UIDesignerBundle" key="label.generate.gui.into"/>
</properties>
</component>
<grid id="b77c5" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="10" bottom="10" right="0"/>
<constraints>
<grid row="1" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<grid row="0" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="e8471" class="javax.swing.JRadioButton" binding="myRbInstrumentClasses">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<margin top="2" left="0" bottom="2" right="2"/>
<text resource-bundle="messages/UIDesignerBundle" key="radio.generate.into.class"/>
</properties>
</component>
<component id="2add1" class="javax.swing.JRadioButton" binding="myRbInstrumentSources">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<margin top="2" left="0" bottom="2" right="2"/>
<text resource-bundle="messages/UIDesignerBundle" key="radio.generate.into.java"/>
</properties>
</component>
<component id="e8471" class="javax.swing.JRadioButton" binding="myRbInstrumentClasses">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<margin top="2" left="0" bottom="2" right="2"/>
<text resource-bundle="messages/UIDesignerBundle" key="radio.generate.into.class"/>
</properties>
</component>
<component id="2eed8" 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/UIDesignerBundle" key="label.generate.gui.into"/>
</properties>
</component>
</children>
</grid>
<hspacer id="cdabe">
<constraints>
<grid row="1" column="2" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
<component id="e8ed8" class="javax.swing.JCheckBox" binding="myChkCopyFormsRuntime">
<constraints>
<grid row="2" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="1" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text resource-bundle="messages/UIDesignerBundle" key="chk.copy.form.runtime"/>
@@ -64,7 +64,7 @@
</component>
<component id="3c31d" class="javax.swing.JLabel">
<constraints>
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="2" 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>
<labelFor value="4c65a"/>
@@ -73,7 +73,7 @@
</component>
<component id="117bd" class="javax.swing.JLabel">
<constraints>
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="3" 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>
<labelFor value="baaa0"/>
@@ -82,13 +82,13 @@
</component>
<component id="4c65a" class="javax.swing.JComboBox" binding="myLayoutManagerCombo">
<constraints>
<grid row="3" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
<component id="baaa0" class="javax.swing.JComboBox" binding="myDefaultFieldAccessibilityCombo" default-binding="true">
<constraints>
<grid row="4" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
<grid row="3" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<model>
@@ -101,7 +101,7 @@
</component>
<component id="b9ad7" class="javax.swing.JCheckBox" binding="myResizeHeaders">
<constraints>
<grid row="5" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="4" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<margin top="10" left="0" bottom="2" right="2"/>
@@ -21,6 +21,8 @@ import com.intellij.ide.palette.PaletteGroup;
import com.intellij.openapi.components.AbstractProjectComponent;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.text.StringUtil;
import org.jdom.Attribute;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.input.SAXBuilder;
@@ -78,7 +80,8 @@ public abstract class MetaManager {
@SuppressWarnings("unchecked")
private void loadModel(ClassLoader classLoader, Element element) throws Exception {
Class<RadComponent> model = (Class<RadComponent>)classLoader.loadClass(element.getAttributeValue("model"));
String modelValue = element.getAttributeValue("model");
Class<RadComponent> model = modelValue == null ? null : (Class<RadComponent>)classLoader.loadClass(modelValue);
String target = element.getAttributeValue("class");
String tag = element.getAttributeValue(TAG);
@@ -95,15 +98,42 @@ public abstract class MetaManager {
}
Element palette = element.getChild("palette");
meta.setPaletteItem(
new Item(palette.getAttributeValue("title"), palette.getAttributeValue("icon"), palette.getAttributeValue("tooltip")));
if (palette != null) {
meta.setPaletteItem(
new Item(palette.getAttributeValue("title"), palette.getAttributeValue("icon"), palette.getAttributeValue("tooltip")));
}
Element creation = element.getChild("creation");
if (creation != null) {
meta.setCreation(creation.getTextTrim());
}
myTag2Model.put(tag, meta);
Element properties = element.getChild("properties");
if (properties != null) {
Attribute normal = properties.getAttribute("normal");
if (normal != null) {
meta.setNormalProperties(StringUtil.split(normal.getValue(), " "));
}
Attribute important = properties.getAttribute("important");
if (important != null) {
meta.setImportantProperties(StringUtil.split(important.getValue(), " "));
}
Attribute expert = properties.getAttribute("expert");
if (expert != null) {
meta.setExpertProperties(StringUtil.split(expert.getValue(), " "));
}
Attribute deprecated = properties.getAttribute("deprecated");
if (deprecated != null) {
meta.setDeprecatedProperties(StringUtil.split(deprecated.getValue(), " "));
}
}
if (tag != null) {
myTag2Model.put(tag, meta);
}
if (target != null) {
myTarget2Model.put(target, meta);
@@ -20,6 +20,8 @@ import com.intellij.openapi.util.IconLoader;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.util.Collections;
import java.util.List;
/**
* @author Alexander Lobas
@@ -34,6 +36,10 @@ public class MetaModel {
private String myIconPath;
private Icon myIcon;
private String myCreation;
private List<String> myNormalProperties = Collections.emptyList();
private List<String> myImportantProperties = Collections.emptyList();
private List<String> myExpertProperties = Collections.emptyList();
private List<String> myDeprecatedProperties = Collections.emptyList();
public MetaModel(Class<RadComponent> model, String target, String tag) {
myModel = model;
@@ -97,4 +103,36 @@ public class MetaModel {
myPaletteItem = paletteItem;
myPaletteItem.setMetaModel(this);
}
public boolean isNormalProperty(String name) {
return myNormalProperties.contains(name);
}
public void setNormalProperties(List<String> normalProperties) {
myNormalProperties = normalProperties;
}
public boolean isImportantProperty(String name) {
return myImportantProperties.contains(name);
}
public void setImportantProperties(List<String> importantProperties) {
myImportantProperties = importantProperties;
}
public boolean isExpertProperty(String name) {
return myExpertProperties.contains(name);
}
public void setExpertProperties(List<String> expertProperties) {
myExpertProperties = expertProperties;
}
public boolean isDeprecatedProperty(String name) {
return myDeprecatedProperties.contains(name);
}
public void setDeprecatedProperties(List<String> deprecatedProperties) {
myDeprecatedProperties = deprecatedProperties;
}
}
@@ -16,7 +16,6 @@
package com.intellij.designer.propertyTable;
import com.intellij.designer.model.RadComponent;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -28,16 +27,17 @@ import java.util.List;
*/
public abstract class Property<T extends RadComponent> {
private final Property myParent;
@NotNull private final String myName;
private final String myName;
private boolean myImportant;
private boolean myExpert;
private boolean myDeprecated;
public Property(Property parent, @NotNull @NonNls String name) {
public Property(@Nullable Property parent, @NotNull String name) {
myParent = parent;
myName = name;
}
public abstract Property createForNewPresentation();
//////////////////////////////////////////////////////////////////////////////////////////
//
// Hierarchy
@@ -333,7 +333,7 @@ public final class PropertyTable extends JBTable implements ComponentSelectionLi
}
}
private static int findProperty(List<Property> properties, Property property) {
public static int findProperty(List<Property> properties, Property property) {
String name = property.getName();
int size = properties.size();
@@ -30,7 +30,7 @@ import java.awt.event.ActionListener;
* @author Vladimir Kondratyev
*/
public class BooleanEditor extends PropertyEditor {
private final JCheckBox myCheckBox;
protected final JCheckBox myCheckBox;
private boolean myInsideChange;
public BooleanEditor() {
@@ -52,12 +52,16 @@ public class BooleanEditor extends PropertyEditor {
return Boolean.valueOf(myCheckBox.isSelected());
}
protected boolean getValue(Object value) {
return value != null && (Boolean)value;
}
@NotNull
public JComponent getComponent(@Nullable RadComponent component, Object value) {
try {
myInsideChange = true;
myCheckBox.setBackground(UIUtil.getTableBackground());
myCheckBox.setSelected(value != null && (Boolean)value);
myCheckBox.setSelected(getValue(value));
return myCheckBox;
}
finally {
@@ -0,0 +1,74 @@
/*
* 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.designer.propertyTable.editors;
import com.intellij.designer.model.RadComponent;
import com.intellij.designer.propertyTable.PropertyEditor;
import com.intellij.openapi.ui.ComboBox;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import javax.swing.event.PopupMenuEvent;
import javax.swing.event.PopupMenuListener;
/**
* @author Alexander Lobas
*/
public class ComboEditor extends PropertyEditor {
protected final ComboBox myCombo;
public ComboEditor() {
myCombo = new ComboBox(-1);
myCombo.setBorder(null);
myCombo.addPopupMenuListener(new PopupMenuListener() {
@Override
public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
// TODO: Auto-generated method stub
}
@Override
public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
// TODO: Auto-generated method stub
}
@Override
public void popupMenuCanceled(PopupMenuEvent e) {
// TODO: Auto-generated method stub
}
});
}
@Override
public void updateUI() {
SwingUtilities.updateComponentTreeUI(myCombo);
ListCellRenderer renderer = myCombo.getRenderer();
if (renderer instanceof JComponent) {
SwingUtilities.updateComponentTreeUI((JComponent)renderer);
}
}
@Override
public Object getValue() throws Exception {
return null; // TODO: Auto-generated method stub
}
@NotNull
@Override
public JComponent getComponent(@Nullable RadComponent component, Object value) {
return null; // TODO: Auto-generated method stub
}
}
@@ -28,6 +28,10 @@ import javax.swing.*;
* @author Vladimir Kondratyev
*/
public class BooleanRenderer extends JCheckBox implements PropertyRenderer {
protected boolean getValue(Object value) {
return value != null && (Boolean)value;
}
@NotNull
public JComponent getComponent(@Nullable RadComponent component, @Nullable Object value, boolean selected, boolean hasFocus) {
if (selected) {
@@ -39,7 +43,7 @@ public class BooleanRenderer extends JCheckBox implements PropertyRenderer {
setBackground(UIUtil.getTableBackground());
}
setSelected(value != null && (Boolean)value);
setSelected(getValue(value));
return this;
}
}
@@ -15,8 +15,6 @@
*/
package org.intellij.lang.xpath.xslt.associations.impl;
import org.intellij.lang.xpath.xslt.associations.FileAssociationsManager;
import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
@@ -24,15 +22,16 @@ import com.intellij.openapi.actionSystem.LangDataKeys;
import com.intellij.openapi.fileChooser.FileChooser;
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.IconLoader;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiFile;
import com.intellij.util.PlatformIcons;
import org.intellij.lang.xpath.xslt.associations.FileAssociationsManager;
class AddAssociationAction extends AnAction {
private final FileAssociationsManager myManager;
public AddAssociationAction(FileAssociationsManager manager) {
super("Add...", "Add File Association", IconLoader.getIcon("/general/add.png"));
super("Add...", "Add File Association", PlatformIcons.TABLE_ADD_ROW);
myManager = manager;
}
@@ -23,6 +23,7 @@ import com.intellij.ui.*;
import com.intellij.ui.components.JBList;
import com.intellij.ui.components.JBScrollPane;
import com.intellij.ui.treeStructure.Tree;
import com.intellij.util.PlatformIcons;
import com.intellij.util.config.StorageAccessors;
import com.intellij.util.ui.UIUtil;
import org.intellij.lang.xpath.xslt.XsltSupport;
@@ -224,7 +225,7 @@ class AssociationsEditor {
class RemoveAssociationAction extends AnAction {
public RemoveAssociationAction() {
super(null, "Remove Association", IconLoader.getIcon("/general/remove.png"));
super(null, "Remove Association", PlatformIcons.TABLE_REMOVE_ROW);
}
public void actionPerformed(AnActionEvent e) {
@@ -16,10 +16,10 @@
package org.intellij.plugins.xpathView.ui;
import com.intellij.codeInsight.intention.IntentionAction;
import com.intellij.ide.DataManager;
import com.intellij.javaee.ExternalResourceManager;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.LangDataKeys;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.fileTypes.LanguageFileType;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.DialogWrapper;
@@ -30,8 +30,10 @@ import com.intellij.openapi.util.Pair;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiReference;
import com.intellij.psi.xml.XmlElement;
import com.intellij.ui.*;
import com.intellij.util.IconUtil;
import com.intellij.ui.AnActionButton;
import com.intellij.ui.AnActionButtonRunnable;
import com.intellij.ui.IdeBorderFactory;
import com.intellij.ui.ToolbarDecorator;
import com.intellij.util.containers.BidirectionalMap;
import com.intellij.util.ui.Table;
import com.intellij.util.ui.UIUtil;
@@ -120,19 +122,36 @@ public class EditContextDialog extends DialogWrapper {
public void run(AnActionButton button) {
myVariableTableModel.removeVariable(myVariableTable.getSelectedRow());
}
}).createPanel();
}).disableUpDownActions().createPanel();
UIUtil.addBorder(p, IdeBorderFactory.createTitledBorder("Variables", false));
final JPanel n = ToolbarDecorator.createDecorator(myNamespaceTable)
.addExtraAction(myContextProvider.getContextElement() != null ? null :
AnActionButton.fromAction(new AddAction(myNamespaceTableModel, myUnresolvedPrefixes)))
.setRemoveAction(
.setAddAction(myContextProvider.getContextElement() != null ? null : new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
final ExternalResourceManager erm = ExternalResourceManager.getInstance();
final List<String> allURIs = new ArrayList<String>(Arrays.asList(erm.getResourceUrls(null, true)));
final Collection<Namespace> namespaces = myNamespaceTableModel.getNamespaces();
for (Namespace namespace : namespaces) {
allURIs.remove(namespace.getUri());
}
Collections.sort(allURIs);
final DataContext dataContext = DataManager.getInstance().getDataContext(myNamespaceTable);
final Project project = PlatformDataKeys.PROJECT.getData(dataContext);
final AddNamespaceDialog dlg = new AddNamespaceDialog(project, myUnresolvedPrefixes, allURIs, AddNamespaceDialog.Mode.EDITABLE);
dlg.show();
if (dlg.isOK()) {
myNamespaceTableModel.addNamespace(new Namespace(dlg.getPrefix(), dlg.getURI()));
}
}
}).setRemoveAction(
myContextProvider.getContextElement() != null ? null : new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
myNamespaceTableModel.removeNamespace(myNamespaceTable.getSelectedRow());
}
}).setButtonComparator("Add", "Remove").createPanel();
}).disableUpDownActions().createPanel();
UIUtil.addBorder(n, IdeBorderFactory.createTitledBorder("Namespaces", false));
int extendedState = myDimensionService.getExtendedState(getDimensionServiceKey());
@@ -490,37 +509,4 @@ public class EditContextDialog extends DialogWrapper {
return myContextProvider.getElements(forValidation);
}
}
private static class AddAction extends AnAction {
private NamespaceTableModel myNamespaceTableModel;
private Set<String> myUnresolvedPrefixes;
public AddAction(NamespaceTableModel model, Set<String> prefixes) {
super("Add", "Add", IconUtil.getAddRowIcon());
myNamespaceTableModel = model;
myUnresolvedPrefixes = prefixes;
setShortcutSet(CommonActionsPanel.getCommonShortcut(CommonActionsPanel.Buttons.ADD));
}
public void update(AnActionEvent e) {
e.getPresentation().setEnabled(true);
}
public void actionPerformed(AnActionEvent e) {
final ExternalResourceManager erm = ExternalResourceManager.getInstance();
final List<String> allURIs = new ArrayList<String>(Arrays.asList(erm.getResourceUrls(null, true)));
final Collection<Namespace> namespaces = myNamespaceTableModel.getNamespaces();
for (Namespace namespace : namespaces) {
allURIs.remove(namespace.getUri());
}
Collections.sort(allURIs);
final Project project = LangDataKeys.PROJECT.getData(e.getDataContext());
final AddNamespaceDialog dlg = new AddNamespaceDialog(project, myUnresolvedPrefixes, allURIs, AddNamespaceDialog.Mode.EDITABLE);
dlg.show();
if (dlg.isOK()) {
myNamespaceTableModel.addNamespace(new Namespace(dlg.getPrefix(), dlg.getURI()));
}
}
}
}
@@ -121,7 +121,7 @@ java.compiler.option.generate.no.warnings=Generate no warnings
java.compiler.option.generate.debugging.info=Generate debugging info
java.compiler.option.report.deprecated=Report use of deprecated features
javac.option.max.heap.size=Maximum heap size (MB):
jikes.option.path.to.executable= Path to Jikes executable:
jikes.option.path.to.executable=Path to Jikes executable:
jikes.options.group.title=Jikes Options
javac.options.group.title=Javac Options
rmic.option.generate.iiop.stubs=Generate IIOP stubs
@@ -15,28 +15,55 @@
*/
package com.intellij.application.options;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.application.ApplicationBundle;
import com.intellij.openapi.roots.ui.configuration.actions.IconWithTextAction;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.ui.Messages;
import com.intellij.ui.ScrollPaneFactory;
import com.intellij.ui.AnActionButton;
import com.intellij.ui.AnActionButtonRunnable;
import com.intellij.ui.ToolbarDecorator;
import com.intellij.ui.components.JBList;
import com.intellij.util.PlatformIcons;
import javax.swing.*;
import java.awt.*;
import java.util.ArrayList;
public class TagListDialog extends DialogWrapper{
private final JPanel myPanel = new JPanel(new BorderLayout());
public class TagListDialog extends DialogWrapper {
private final JPanel myPanel;
private final JList myList = new JBList(new DefaultListModel());
private ArrayList<String> myData;
public TagListDialog(String title) {
super(true);
myPanel.add(createToolbar(), BorderLayout.NORTH);
myPanel.add(createList(), BorderLayout.CENTER);
myPanel = ToolbarDecorator.createDecorator(myList)
.setAddAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
final String tagName = Messages.showInputDialog(ApplicationBundle.message("editbox.enter.tag.name"),
ApplicationBundle.message("title.tag.name"), Messages.getQuestionIcon());
if (tagName != null) {
while (myData.contains(tagName)) {
myData.remove(tagName);
}
myData.add(tagName);
updateData();
myList.setSelectedIndex(myData.size() - 1);
}
}
}).setRemoveAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
int selectedIndex = myList.getSelectedIndex();
if (selectedIndex >= 0) {
myData.remove(selectedIndex);
updateData();
if (selectedIndex >= myData.size()) {
selectedIndex -= 1;
}
if (selectedIndex >= 0) {
myList.setSelectedIndex(selectedIndex);
}
}
}
}).disableUpDownActions().createPanel();
setTitle(title);
init();
}
@@ -57,76 +84,10 @@ public class TagListDialog extends DialogWrapper{
}
}
public ArrayList<String> getData(){
public ArrayList<String> getData() {
return myData;
}
private JComponent createList() {
return ScrollPaneFactory.createScrollPane(myList);
}
private JComponent createToolbar() {
return ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN,
createActionGroup(),
true).getComponent();
}
private ActionGroup createActionGroup() {
final DefaultActionGroup result = new DefaultActionGroup();
final AnAction addAction = createAddAction();
addAction.registerCustomShortcutSet(CommonShortcuts.INSERT, myList);
result.add(addAction);
final AnAction deleteAction = createDeleteAction();
deleteAction.registerCustomShortcutSet(CommonShortcuts.DELETE, myList);
result.add(deleteAction);
return result;
}
private AnAction createDeleteAction() {
return new IconWithTextAction(ApplicationBundle.message("action.remove"), null, PlatformIcons.DELETE_ICON) {
public void update(AnActionEvent e) {
final int selectedIndex = myList.getSelectedIndex();
if (selectedIndex >= 0) {
e.getPresentation().setEnabled(true);
} else {
e.getPresentation().setEnabled(false);
}
}
public void actionPerformed(AnActionEvent e) {
int selectedIndex = myList.getSelectedIndex();
if (selectedIndex >= 0) {
myData.remove(selectedIndex);
updateData();
if (selectedIndex >= myData.size()) {
selectedIndex -= 1;
}
if (selectedIndex >= 0) {
myList.setSelectedIndex(selectedIndex);
}
}
}
};
}
private AnAction createAddAction() {
return new IconWithTextAction(ApplicationBundle.message("action.add"), null, PlatformIcons.ADD_ICON){
public void actionPerformed(AnActionEvent e) {
final String tagName = Messages.showInputDialog(ApplicationBundle.message("editbox.enter.tag.name"),
ApplicationBundle.message("title.tag.name"), Messages.getQuestionIcon());
if (tagName != null) {
while (myData.contains(tagName)) {
myData.remove(tagName);
}
myData.add(tagName);
updateData();
myList.setSelectedIndex(myData.size() - 1);
}
}
};
}
protected JComponent createCenterPanel() {
return myPanel;
}
@@ -16,6 +16,7 @@
package com.intellij.psi.xml;
import com.intellij.lang.ASTNode;
import com.intellij.lang.Language;
import com.intellij.lang.dtd.DTDLanguage;
import com.intellij.lang.html.HTMLLanguage;
import com.intellij.lang.xhtml.XHTMLLanguage;
@@ -75,7 +76,7 @@ public interface XmlElementType extends XmlTokenType {
final XmlParsingContext parsingContext = new XmlParsingContext(table);
return parsingContext.getXmlParsing().parse(new OldXmlLexer(), chars, 0, chars.length(), SharedImplUtil.getManagerByTree(chameleon));
}
public boolean isParsable(CharSequence buffer, final Project project) {return true;}
public boolean isParsable(CharSequence buffer, Language fileLanguage, final Project project) {return true;}
};
IElementType XML_MARKUP = new CustomParsingType("XML_MARKUP_DECL", XMLLanguage.INSTANCE){