1. ToolbarDecorators added for some new icons

2. Duplicate icons removed
3. ToolbarDecorator: Disabling extra actions if context component disabled
4. ToolbarDecorator: Setter for add action.
This commit is contained in:
Evgeny Zakrevsky
2012-05-19 02:24:39 +04:00
parent 0556eb708c
commit 734a8b6db4
108 changed files with 556 additions and 761 deletions
@@ -259,12 +259,12 @@ public class CompoundRendererConfigurable implements UnnamedConfigurable {
getTableModel().removeRow(selectedRow);
}
}
}).setUpAction(new AnActionButtonRunnable() {
}).setMoveUpAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
TableUtil.moveSelectedItemsUp(myTable);
}
}).setDownAction(new AnActionButtonRunnable() {
}).setMoveDownAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
TableUtil.moveSelectedItemsDown(myTable);
@@ -25,8 +25,9 @@ import com.intellij.openapi.options.Configurable;
import com.intellij.openapi.options.ConfigurationException;
import com.intellij.openapi.options.SearchableConfigurable;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.IconLoader;
import com.intellij.ui.DocumentAdapter;
import com.intellij.util.IconUtil;
import com.intellij.util.PlatformIcons;
import com.intellij.util.containers.InternalIterator;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -44,11 +45,11 @@ import java.util.ArrayList;
*/
public class UserRenderersConfigurable implements SearchableConfigurable, Configurable.NoScroll {
private static final Logger LOG = Logger.getInstance("#com.intellij.debugger.settings.UserRenderersConfigurable");
private static final Icon ADD_ICON = IconLoader.getIcon("/general/add.png");
private static final Icon REMOVE_ICON = IconLoader.getIcon("/general/remove.png");
private static final Icon COPY_ICON = IconLoader.getIcon("/general/copy.png");
private static final Icon UP_ICON = IconLoader.getIcon("/actions/previousOccurence.png");
private static final Icon DOWN_ICON = IconLoader.getIcon("/actions/nextOccurence.png");
private static final Icon ADD_ICON = IconUtil.getAddIcon();
private static final Icon REMOVE_ICON = IconUtil.getRemoveIcon();
private static final Icon COPY_ICON = PlatformIcons.COPY_ICON;
private static final Icon UP_ICON = IconUtil.getMoveUpIcon();
private static final Icon DOWN_ICON = IconUtil.getMoveDownIcon();
private JTextField myNameField;
private ElementsChooser<NodeRenderer> myRendererChooser;
@@ -49,7 +49,7 @@ public class ConfigurationArgumentsHelpArea extends JPanel {
);
FixedSizeButton copyButton = new FixedSizeButton(22);
copyButton.setIcon(PlatformIcons.DUPLICATE_ICON);
copyButton.setIcon(PlatformIcons.COPY_ICON);
copyButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
@@ -29,6 +29,7 @@ import com.intellij.ui.DocumentAdapter;
import com.intellij.ui.IdeBorderFactory;
import com.intellij.ui.ScrollPaneFactory;
import com.intellij.ui.components.JBList;
import com.intellij.util.IconUtil;
import com.intellij.util.PlatformIcons;
import com.intellij.util.StringBuilderSpinAllocator;
import com.intellij.util.containers.ContainerUtil;
@@ -52,7 +53,7 @@ import java.util.List;
*/
abstract class ProjectLayoutPanel<T> extends JPanel {
private static final Icon ICON_MODULE = IconLoader.getIcon("/nodes/ModuleClosed.png");
private static final Icon RENAME_ICON = IconLoader.getIcon("/modules/edit.png");
private static final Icon RENAME_ICON = IconUtil.getEditIcon();
private static final Icon MERGE_ICON = IconLoader.getIcon("/modules/merge.png");
private static final Icon SPLIT_ICON = IconLoader.getIcon("/modules/split.png");
@@ -28,7 +28,7 @@ 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.IconUtil;
import com.intellij.util.ui.ItemRemovable;
import com.intellij.util.ui.UIUtil;
@@ -108,7 +108,7 @@ public class JavadocEditor extends ModuleElementsEditor {
TableUtil.selectRows(myTable, new int[]{tableModel.getRowCount() - 1});
}
}
}).addExtraAction(new AnActionButton(ProjectBundle.message("module.javadoc.add.url.button"), PlatformIcons.TABLE_URL) {
}).addExtraAction(new AnActionButton(ProjectBundle.message("module.javadoc.add.url.button"), IconUtil.getAddLinkIcon()) {
@Override
public void actionPerformed(AnActionEvent e) {
VirtualFile[] files = new VirtualFile[]{Util.showSpecifyJavadocUrlDialog(myTable)};
@@ -133,7 +133,7 @@ public class JavadocEditor extends ModuleElementsEditor {
saveData();
}
}
}).createPanel();
}).setButtonComparator("Add", ProjectBundle.message("module.javadoc.add.url.button"), "Remove").createPanel();
final JPanel mainPanel = new JPanel(new BorderLayout());
mainPanel.add(tablePanel, BorderLayout.CENTER);
@@ -39,7 +39,7 @@ import com.intellij.openapi.ui.Splitter;
import com.intellij.openapi.util.Conditions;
import com.intellij.ui.TreeSpeedSearch;
import com.intellij.util.Consumer;
import com.intellij.util.PlatformIcons;
import com.intellij.util.IconUtil;
import com.intellij.util.containers.Convertor;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.Nullable;
@@ -160,7 +160,7 @@ public class ProjectJdksConfigurable extends MasterDetailsComponent {
protected ArrayList<AnAction> createActions(final boolean fromPopup) {
final ArrayList<AnAction> actions = new ArrayList<AnAction>();
DefaultActionGroup group = new DefaultActionGroup(ProjectBundle.message("add.new.jdk.text"), true);
group.getTemplatePresentation().setIcon(PlatformIcons.ADD_ICON);
group.getTemplatePresentation().setIcon(IconUtil.getAddIcon());
myProjectJdksModel.createAddActions(group, myTree, new Consumer<Sdk>() {
public void consume(final Sdk projectJdk) {
addNode(new MyNode(new JdkConfigurable(((ProjectJdkImpl)projectJdk), myProjectJdksModel, TREE_UPDATER, myHistory, myProject), false), myRoot);
@@ -55,7 +55,7 @@ import com.intellij.ui.ScrollPaneFactory;
import com.intellij.ui.TabbedPaneWrapper;
import com.intellij.ui.awt.RelativePoint;
import com.intellij.util.EventDispatcher;
import com.intellij.util.PlatformIcons;
import com.intellij.util.IconUtil;
import com.intellij.util.ui.ThreeStateCheckBox;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -294,8 +294,8 @@ public class ArtifactEditorImpl implements ArtifactEditorEx {
toolbarActionGroup.add(new RemovePackagingElementAction(this));
toolbarActionGroup.add(Separator.getInstance());
toolbarActionGroup.add(new SortElementsToggleAction(this.getLayoutTreeComponent()));
toolbarActionGroup.add(new MovePackagingElementAction(myLayoutTreeComponent, "Move Up", "", IconLoader.getIcon("/actions/moveUp.png"), -1));
toolbarActionGroup.add(new MovePackagingElementAction(myLayoutTreeComponent, "Move Down", "", IconLoader.getIcon("/actions/moveDown.png"), 1));
toolbarActionGroup.add(new MovePackagingElementAction(myLayoutTreeComponent, "Move Up", "", IconUtil.getMoveUpIcon(), -1));
toolbarActionGroup.add(new MovePackagingElementAction(myLayoutTreeComponent, "Move Down", "", IconUtil.getMoveDownIcon(), 1));
return toolbarActionGroup;
}
@@ -342,7 +342,7 @@ public class ArtifactEditorImpl implements ArtifactEditorEx {
private ActionGroup createAddNonCompositeElementGroup() {
DefaultActionGroup group = new DefaultActionGroup(ProjectBundle.message("artifacts.add.copy.action"), true);
group.getTemplatePresentation().setIcon(PlatformIcons.ADD_ICON);
group.getTemplatePresentation().setIcon(IconUtil.getAddIcon());
for (PackagingElementType<?> type : PackagingElementFactory.getInstance().getNonCompositeElementTypes()) {
group.add(new AddNewPackagingElementAction(type, this));
}
@@ -51,7 +51,6 @@ import com.intellij.openapi.ui.popup.JBPopup;
import com.intellij.openapi.ui.popup.JBPopupFactory;
import com.intellij.openapi.ui.popup.PopupStep;
import com.intellij.openapi.ui.popup.util.BaseListPopupStep;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.wm.IdeFocusManager;
import com.intellij.openapi.wm.ToolWindowId;
import com.intellij.packageDependencies.DependenciesBuilder;
@@ -63,7 +62,6 @@ import com.intellij.ui.awt.RelativePoint;
import com.intellij.ui.table.JBTable;
import com.intellij.util.EventDispatcher;
import com.intellij.util.IconUtil;
import com.intellij.util.PlatformIcons;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -286,7 +284,7 @@ public class ClasspathPanelImpl extends JPanel implements ClasspathPanel {
}
};
final AnActionButton analyzeButton = new AnActionButton(ProjectBundle.message("classpath.panel.analyze"), null, SystemInfo.isMac ? PlatformIcons.TABLE_ANALYZE : PlatformIcons.ANALYZE) {
final AnActionButton analyzeButton = new AnActionButton(ProjectBundle.message("classpath.panel.analyze"), null, IconUtil.getAnalyzeIcon()) {
@Override
public void actionPerformed(AnActionEvent e) {
AnalyzeDependenciesDialog.show(getRootModel().getModule());
@@ -355,13 +353,13 @@ public class ClasspathPanelImpl extends JPanel implements ClasspathPanel {
removeAction.actionPerformed(null);
}
})
.setUpAction(new AnActionButtonRunnable() {
.setMoveUpAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
moveSelectedRows(-1);
}
})
.setDownAction(new AnActionButtonRunnable() {
.setMoveDownAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
moveSelectedRows(+1);
@@ -36,7 +36,7 @@ import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.ui.AnActionButton;
import com.intellij.ui.AnActionButtonUpdater;
import com.intellij.ui.ToolbarDecorator;
import com.intellij.util.PlatformIcons;
import com.intellij.util.IconUtil;
import javax.swing.*;
@@ -69,7 +69,7 @@ public class JavadocOrderRootTypeUIFactory implements OrderRootTypeUIFactory {
@Override
protected void addToolbarButtons(ToolbarDecorator toolbarDecorator) {
AnActionButton specifyUrlButton = new AnActionButton(ProjectBundle.message("sdk.paths.specify.url.button"), PlatformIcons.TABLE_URL) {
AnActionButton specifyUrlButton = new AnActionButton(ProjectBundle.message("sdk.paths.specify.url.button"), IconUtil.getAddLinkIcon()) {
@Override
public void actionPerformed(AnActionEvent e) {
onSpecifyUrlButtonClicked();
@@ -29,7 +29,8 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.openapi.roots.libraries.Library;
import com.intellij.openapi.roots.libraries.LibraryTable;
import com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.*;
import com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ProjectStructureDaemonAnalyzerListener;
import com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ProjectStructureElement;
import com.intellij.openapi.ui.MasterDetailsComponent;
import com.intellij.openapi.ui.MasterDetailsState;
import com.intellij.openapi.ui.MasterDetailsStateService;
@@ -42,7 +43,7 @@ import com.intellij.ui.TreeSpeedSearch;
import com.intellij.ui.awt.RelativePoint;
import com.intellij.ui.navigation.Place;
import com.intellij.util.Function;
import com.intellij.util.PlatformIcons;
import com.intellij.util.IconUtil;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.Convertor;
import com.intellij.util.ui.tree.TreeUtil;
@@ -433,7 +434,7 @@ public abstract class BaseStructureConfigurable extends MasterDetailsComponent i
}
public AbstractAddGroup(String text) {
this(text, PlatformIcons.ADD_ICON);
this(text, IconUtil.getAddIcon());
}
public ActionGroup getActionGroup() {
@@ -15,6 +15,7 @@
*/
package com.intellij.application.options;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.application.ApplicationBundle;
import com.intellij.openapi.editor.SyntaxHighlighterColors;
import com.intellij.openapi.editor.markup.TextAttributes;
@@ -24,13 +25,12 @@ import com.intellij.psi.codeStyle.PackageEntry;
import com.intellij.psi.codeStyle.PackageEntryTable;
import com.intellij.ui.*;
import com.intellij.ui.table.JBTable;
import com.intellij.util.IconUtil;
import com.intellij.util.ui.UIUtil;
import javax.swing.*;
import javax.swing.event.CellEditorListener;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.TableCellEditor;
import javax.swing.table.TableColumn;
@@ -67,7 +67,7 @@ public class CodeStyleImportsPanel extends JPanel {
private JPanel myWholePanel;
private JCheckBox myCbLayoutStaticImportsSeparately;
public CodeStyleImportsPanel(CodeStyleSettings settings){
public CodeStyleImportsPanel(CodeStyleSettings settings) {
mySettings = settings;
setLayout(new BorderLayout());
setBorder(IdeBorderFactory.createEmptyBorder(2, 2, 2, 2));
@@ -96,8 +96,9 @@ public class CodeStyleImportsPanel extends JPanel {
final MultiLineLabel oneImportPerDirectiveLabel = new MultiLineLabel("<% page import=\"com.company.Boo\"%>\n" +
"<% page import=\"com.company.Far\"%>");
final JPanel labelPanel = new JPanel(new BorderLayout());
labelPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(20, 10, 0, 0), IdeBorderFactory.createTitledBorder(
ApplicationBundle.message("title.preview"), false)));
labelPanel.setBorder(
BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(20, 10, 0, 0), IdeBorderFactory.createTitledBorder(
ApplicationBundle.message("title.preview"), false)));
JPanel resultPanel = new JPanel(new BorderLayout());
resultPanel.add(btnPanel, BorderLayout.NORTH);
@@ -136,12 +137,18 @@ public class CodeStyleImportsPanel extends JPanel {
myClassCountField = new JTextField(3);
myNamesCountField = new JTextField(3);
final JPanel panel = new JPanel(new GridBagLayout());
panel.add(new JLabel(ApplicationBundle.message("editbox.class.count.to.use.import.with.star")), new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 3, 0, 0), 0, 0));
panel.add(new JLabel(ApplicationBundle.message("editbox.class.count.to.use.import.with.star")),
new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE,
new Insets(0, 3, 0, 0), 0, 0));
panel.add(myClassCountField,
new GridBagConstraints(1, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
new Insets(0, 1, 0, 0), 0, 0));
panel.add(new JLabel(ApplicationBundle.message("editbox.names.count.to.use.static.import.with.star")), new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 0.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 3, 0, 0), 0, 0));
panel.add(myNamesCountField, new GridBagConstraints(1, GridBagConstraints.RELATIVE, 1, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 1, 0, 0), 0, 0));
panel.add(new JLabel(ApplicationBundle.message("editbox.names.count.to.use.static.import.with.star")),
new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 0.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.NONE,
new Insets(0, 3, 0, 0), 0, 0));
panel.add(myNamesCountField,
new GridBagConstraints(1, GridBagConstraints.RELATIVE, 1, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
new Insets(0, 1, 0, 0), 0, 0));
group.add(panel);
return group.createPanel();
@@ -159,8 +166,7 @@ public class CodeStyleImportsPanel extends JPanel {
public void run(AnActionButton button) {
removeEntryFromPackages();
}
}).disableUpDownActions().createPanel();
panel.setPreferredSize(new Dimension(-1, 150));
}).disableUpDownActions().setPreferredSize(new Dimension(-1, 150)).createPanel();
UIUtil.addBorder(panel, IdeBorderFactory.createTitledBorder(ApplicationBundle.message("title.packages.to.use.import.with"), false));
@@ -172,11 +178,11 @@ public class CodeStyleImportsPanel extends JPanel {
panel.setBorder(IdeBorderFactory.createTitledBorder(ApplicationBundle.message("title.import.layout"), false));
myCbLayoutStaticImportsSeparately = new JCheckBox("Layout static imports separately");
myCbLayoutStaticImportsSeparately.addItemListener(new ItemListener(){
myCbLayoutStaticImportsSeparately.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
if (areStaticImportsEnabled()) {
boolean found = false;
for (int i=myImportLayoutList.getEntryCount()-1; i>=0; i--) {
for (int i = myImportLayoutList.getEntryCount() - 1; i >= 0; i--) {
PackageEntry entry = myImportLayoutList.getEntryAt(i);
if (entry == PackageEntry.ALL_OTHER_STATIC_IMPORTS_ENTRY) {
found = true;
@@ -185,14 +191,14 @@ public class CodeStyleImportsPanel extends JPanel {
}
if (!found) {
int index = myImportLayoutList.getEntryCount();
if (index != 0 && myImportLayoutList.getEntryAt(index-1) != PackageEntry.BLANK_LINE_ENTRY) {
if (index != 0 && myImportLayoutList.getEntryAt(index - 1) != PackageEntry.BLANK_LINE_ENTRY) {
myImportLayoutList.addEntry(PackageEntry.BLANK_LINE_ENTRY);
}
myImportLayoutList.addEntry(PackageEntry.ALL_OTHER_STATIC_IMPORTS_ENTRY);
}
}
else {
for (int i=myImportLayoutList.getEntryCount()-1; i>=0; i--) {
for (int i = myImportLayoutList.getEntryCount() - 1; i >= 0; i--) {
PackageEntry entry = myImportLayoutList.getEntryAt(i);
if (entry.isStatic()) {
myImportLayoutList.removeEntryAt(i);
@@ -204,8 +210,44 @@ public class CodeStyleImportsPanel extends JPanel {
}
});
panel.add(myCbLayoutStaticImportsSeparately, BorderLayout.NORTH);
panel.add(createImportLayoutTable(), BorderLayout.CENTER);
panel.add(createImportLayoutButtonsPanel(), BorderLayout.EAST);
panel.add(
ToolbarDecorator.createDecorator(myImportLayoutTable = createTableForPackageEntries(myImportLayoutList))
.addExtraAction(new AnActionButton(ApplicationBundle.message("button.add.package"), IconUtil.getAddPackageIcon()) {
@Override
public void actionPerformed(AnActionEvent e) {
addPackageToImportLayouts();
}
}).addExtraAction(new AnActionButton(ApplicationBundle.message("button.add.blank"), IconUtil.getAddBlankLineIcon()) {
@Override
public void actionPerformed(AnActionEvent e) {
addBlankLine();
}
}).setRemoveAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
removeEntryFromImportLayouts();
}
}).setMoveUpAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
moveRowUp();
}
}).setMoveDownAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
moveRowDown();
}
}).setRemoveActionUpdater(new AnActionButtonUpdater() {
@Override
public boolean isEnabled(AnActionEvent e) {
int selectedImport = myImportLayoutTable.getSelectedRow();
PackageEntry entry = selectedImport < 0 ? null : myImportLayoutList.getEntryAt(selectedImport);
return entry != null && entry != PackageEntry.ALL_OTHER_STATIC_IMPORTS_ENTRY && entry != PackageEntry.ALL_OTHER_IMPORTS_ENTRY;
}
}).setButtonComparator(ApplicationBundle.message("button.add.package"), ApplicationBundle.message("button.add.blank"),
"Remove", "Up", "Down")
.setPreferredSize(new Dimension(-1, 200)).createPanel(), BorderLayout.CENTER);
return panel;
}
@@ -220,82 +262,14 @@ public class CodeStyleImportsPanel extends JPanel {
return myCbLayoutStaticImportsSeparately.isSelected();
}
private JPanel createImportLayoutButtonsPanel() {
JPanel tableButtonsPanel = new JPanel();
tableButtonsPanel.setLayout(new BoxLayout(tableButtonsPanel, BoxLayout.Y_AXIS));
JButton addPackageToImportLayoutButton = new JButton(ApplicationBundle.message("button.add.package"));
tableButtonsPanel.add(addPackageToImportLayoutButton);
addPackageToImportLayoutButton.setMaximumSize(new Dimension(Integer.MAX_VALUE, addPackageToImportLayoutButton.getMaximumSize().height));
JButton addBlankLineButton = new JButton(ApplicationBundle.message("button.add.blank"));
tableButtonsPanel.add(addBlankLineButton);
addBlankLineButton.setMaximumSize(new Dimension(Integer.MAX_VALUE, addBlankLineButton.getMaximumSize().height));
myMoveUpButton = new JButton(ApplicationBundle.message("button.move.up"));
tableButtonsPanel.add(myMoveUpButton);
myMoveUpButton.setMaximumSize(new Dimension(Integer.MAX_VALUE, myMoveUpButton.getMaximumSize().height));
myMoveDownButton = new JButton(ApplicationBundle.message("button.move.down"));
tableButtonsPanel.add(myMoveDownButton);
myMoveDownButton.setMaximumSize(new Dimension(Integer.MAX_VALUE, myMoveDownButton.getMaximumSize().height));
myRemovePackageFromImportLayoutButton = new JButton(ApplicationBundle.message("button.remove"));
tableButtonsPanel.add(myRemovePackageFromImportLayoutButton);
myRemovePackageFromImportLayoutButton.setMaximumSize(new Dimension(Integer.MAX_VALUE, myRemovePackageFromImportLayoutButton.getMaximumSize().height));
addPackageToImportLayoutButton.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent e){
addPackageToImportLayouts();
}
}
);
addBlankLineButton.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent e){
addBlankLine();
}
}
);
myRemovePackageFromImportLayoutButton.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent e){
removeEntryFromImportLayouts();
}
}
);
myMoveUpButton.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent e){
moveRowUp();
}
}
);
myMoveDownButton.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent e){
moveRowDown();
}
}
);
return tableButtonsPanel;
}
private void addPackageToImportLayouts() {
int selected = myImportLayoutTable.getSelectedRow() + 1;
if(selected < 0) {
if (selected < 0) {
selected = myImportLayoutList.getEntryCount();
}
PackageEntry entry = new PackageEntry(false,"", true);
PackageEntry entry = new PackageEntry(false, "", true);
myImportLayoutList.insertEntryAt(entry, selected);
refreshTableModel(selected, myImportLayoutTable);
updateButtons();
}
private static void refreshTableModel(int selectedRow, JBTable table) {
@@ -304,102 +278,98 @@ public class CodeStyleImportsPanel extends JPanel {
table.setRowSelectionInterval(selectedRow, selectedRow);
TableUtil.editCellAt(table, selectedRow, 0);
Component editorComp = table.getEditorComponent();
if(editorComp != null) {
if (editorComp != null) {
editorComp.requestFocus();
}
}
private void addPackageToPackages() {
int selected = myPackageTable.getSelectedRow() + 1;
if(selected < 0) {
if (selected < 0) {
selected = myPackageList.getEntryCount();
}
PackageEntry entry = new PackageEntry(false,"", true);
PackageEntry entry = new PackageEntry(false, "", true);
myPackageList.insertEntryAt(entry, selected);
refreshTableModel(selected, myPackageTable);
}
private void addBlankLine() {
int selected = myImportLayoutTable.getSelectedRow() + 1;
if(selected < 0) {
if (selected < 0) {
selected = myImportLayoutList.getEntryCount();
}
myImportLayoutList.insertEntryAt(PackageEntry.BLANK_LINE_ENTRY, selected);
AbstractTableModel model = (AbstractTableModel)myImportLayoutTable.getModel();
model.fireTableRowsInserted(selected, selected);
myImportLayoutTable.setRowSelectionInterval(selected, selected);
updateButtons();
}
private void removeEntryFromImportLayouts() {
int selected = myImportLayoutTable.getSelectedRow();
if(selected < 0)
if (selected < 0) {
return;
}
PackageEntry entry = myImportLayoutList.getEntryAt(selected);
if(entry == PackageEntry.ALL_OTHER_STATIC_IMPORTS_ENTRY || entry == PackageEntry.ALL_OTHER_IMPORTS_ENTRY) {
if (entry == PackageEntry.ALL_OTHER_STATIC_IMPORTS_ENTRY || entry == PackageEntry.ALL_OTHER_IMPORTS_ENTRY) {
return;
}
TableUtil.stopEditing(myImportLayoutTable);
myImportLayoutList.removeEntryAt(selected);
AbstractTableModel model = (AbstractTableModel)myImportLayoutTable.getModel();
model.fireTableRowsDeleted(selected, selected);
if(selected >= myImportLayoutList.getEntryCount()) {
selected --;
if (selected >= myImportLayoutList.getEntryCount()) {
selected--;
}
if(selected >= 0) {
if (selected >= 0) {
myImportLayoutTable.setRowSelectionInterval(selected, selected);
}
updateButtons();
}
private void removeEntryFromPackages() {
int selected = myPackageTable.getSelectedRow();
if(selected < 0) return;
if (selected < 0) return;
TableUtil.stopEditing(myPackageTable);
myPackageList.removeEntryAt(selected);
AbstractTableModel model = (AbstractTableModel)myPackageTable.getModel();
model.fireTableRowsDeleted(selected, selected);
if(selected >= myPackageList.getEntryCount()) {
selected --;
if (selected >= myPackageList.getEntryCount()) {
selected--;
}
if(selected >= 0) {
if (selected >= 0) {
myPackageTable.setRowSelectionInterval(selected, selected);
}
updateButtons();
}
private void moveRowUp() {
int selected = myImportLayoutTable.getSelectedRow();
if(selected < 1) {
if (selected < 1) {
return;
}
TableUtil.stopEditing(myImportLayoutTable);
PackageEntry entry = myImportLayoutList.getEntryAt(selected);
PackageEntry previousEntry = myImportLayoutList.getEntryAt(selected-1);
PackageEntry previousEntry = myImportLayoutList.getEntryAt(selected - 1);
myImportLayoutList.setEntryAt(previousEntry, selected);
myImportLayoutList.setEntryAt(entry, selected-1);
myImportLayoutList.setEntryAt(entry, selected - 1);
AbstractTableModel model = (AbstractTableModel)myImportLayoutTable.getModel();
model.fireTableRowsUpdated(selected-1, selected);
myImportLayoutTable.setRowSelectionInterval(selected-1, selected-1);
updateButtons();
model.fireTableRowsUpdated(selected - 1, selected);
myImportLayoutTable.setRowSelectionInterval(selected - 1, selected - 1);
}
private void moveRowDown() {
int selected = myImportLayoutTable.getSelectedRow();
if(selected >= myImportLayoutList.getEntryCount()-1) {
if (selected >= myImportLayoutList.getEntryCount() - 1) {
return;
}
TableUtil.stopEditing(myImportLayoutTable);
PackageEntry entry = myImportLayoutList.getEntryAt(selected);
PackageEntry nextEntry = myImportLayoutList.getEntryAt(selected+1);
PackageEntry nextEntry = myImportLayoutList.getEntryAt(selected + 1);
myImportLayoutList.setEntryAt(nextEntry, selected);
myImportLayoutList.setEntryAt(entry, selected+1);
myImportLayoutList.setEntryAt(entry, selected + 1);
AbstractTableModel model = (AbstractTableModel)myImportLayoutTable.getModel();
model.fireTableRowsUpdated(selected, selected+1);
myImportLayoutTable.setRowSelectionInterval(selected+1, selected+1);
updateButtons();
model.fireTableRowsUpdated(selected, selected + 1);
myImportLayoutTable.setRowSelectionInterval(selected + 1, selected + 1);
}
private JBTable createTableForPackageEntries(final PackageEntryTable packageTable) {
@@ -410,7 +380,7 @@ public class CodeStyleImportsPanel extends JPanel {
// Create a model of the data.
TableModel dataModel = new AbstractTableModel() {
public int getColumnCount() {
return names.length + (areStaticImportsEnabled()?1:0);
return names.length + (areStaticImportsEnabled() ? 1 : 0);
}
public int getRowCount() {
@@ -421,13 +391,13 @@ public class CodeStyleImportsPanel extends JPanel {
PackageEntry entry = packageTable.getEntryAt(row);
if (entry == null || !isCellEditable(row, col)) return null;
col += areStaticImportsEnabled() ? 0 : 1;
if(col == 0) {
if (col == 0) {
return entry.isStatic();
}
if(col == 1) {
if (col == 1) {
return entry.getPackageName();
}
if(col == 2) {
if (col == 2) {
return entry.isWithSubpackages() ? Boolean.TRUE : Boolean.FALSE;
}
throw new IllegalArgumentException(String.valueOf(col));
@@ -441,13 +411,13 @@ public class CodeStyleImportsPanel extends JPanel {
public Class getColumnClass(int col) {
col += areStaticImportsEnabled() ? 0 : 1;
if(col == 0) {
if (col == 0) {
return Boolean.class;
}
if(col == 1) {
if (col == 1) {
return String.class;
}
if(col == 2) {
if (col == 2) {
return Boolean.class;
}
throw new IllegalArgumentException(String.valueOf(col));
@@ -461,16 +431,18 @@ public class CodeStyleImportsPanel extends JPanel {
public void setValueAt(Object aValue, int row, int col) {
PackageEntry packageEntry = packageTable.getEntryAt(row);
col += areStaticImportsEnabled() ? 0 : 1;
if(col == 0) {
if (col == 0) {
PackageEntry newPackageEntry = new PackageEntry((Boolean)aValue, packageEntry.getPackageName(), packageEntry.isWithSubpackages());
packageTable.setEntryAt(newPackageEntry, row);
}
else if(col == 1) {
PackageEntry newPackageEntry = new PackageEntry(packageEntry.isStatic(), ((String)aValue).trim(), packageEntry.isWithSubpackages());
else if (col == 1) {
PackageEntry newPackageEntry =
new PackageEntry(packageEntry.isStatic(), ((String)aValue).trim(), packageEntry.isWithSubpackages());
packageTable.setEntryAt(newPackageEntry, row);
}
else if(col == 2) {
PackageEntry newPackageEntry = new PackageEntry(packageEntry.isStatic(), packageEntry.getPackageName(), ((Boolean)aValue).booleanValue());
else if (col == 2) {
PackageEntry newPackageEntry =
new PackageEntry(packageEntry.isStatic(), packageEntry.getPackageName(), ((Boolean)aValue).booleanValue());
packageTable.setEntryAt(newPackageEntry, row);
}
else {
@@ -483,12 +455,6 @@ public class CodeStyleImportsPanel extends JPanel {
final JBTable result = new JBTable(dataModel);
result.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
resizeColumns(packageTable, result);
result.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent e) {
updateButtons();
}
});
TableCellEditor editor = result.getDefaultEditor(String.class);
if (editor instanceof DefaultCellEditor) {
@@ -553,27 +519,12 @@ public class CodeStyleImportsPanel extends JPanel {
private static void fixColumnWidthToHeader(JBTable result, int columnIdx) {
final TableColumn column = result.getColumnModel().getColumn(columnIdx);
final int width = 15 + result.getTableHeader().getFontMetrics(result.getTableHeader().getFont()).stringWidth(result.getColumnName(columnIdx));
final int width =
15 + result.getTableHeader().getFontMetrics(result.getTableHeader().getFont()).stringWidth(result.getColumnName(columnIdx));
column.setMinWidth(width);
column.setMaxWidth(width);
}
private void updateButtons(){
int selectedImport = myImportLayoutTable.getSelectedRow();
myMoveUpButton.setEnabled(selectedImport >= 1);
myMoveDownButton.setEnabled(selectedImport < myImportLayoutTable.getRowCount() - 1);
PackageEntry entry = selectedImport < 0 ? null : myImportLayoutList.getEntryAt(selectedImport);
boolean canRemove = entry != null && entry != PackageEntry.ALL_OTHER_STATIC_IMPORTS_ENTRY && entry != PackageEntry.ALL_OTHER_IMPORTS_ENTRY;
myRemovePackageFromImportLayoutButton.setEnabled(canRemove);
}
private JComponent createImportLayoutTable() {
myImportLayoutTable = createTableForPackageEntries(myImportLayoutList);
JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myImportLayoutTable);
scrollPane.setPreferredSize(new Dimension(-1, 200));
return scrollPane;
}
public void reset(CodeStyleSettings settings) {
myCbUseFQClassNames.setSelected(settings.USE_FQ_CLASS_NAMES);
myCbUseFQClassNamesInJavaDoc.setSelected(settings.USE_FQ_CLASS_NAMES_IN_JAVADOC);
@@ -593,10 +544,10 @@ public class CodeStyleImportsPanel extends JPanel {
model = (AbstractTableModel)myPackageTable.getModel();
model.fireTableDataChanged();
if(myImportLayoutTable.getRowCount() > 0) {
if (myImportLayoutTable.getRowCount() > 0) {
myImportLayoutTable.getSelectionModel().setSelectionInterval(0, 0);
}
if(myPackageTable.getRowCount() > 0) {
if (myPackageTable.getRowCount() > 0) {
myPackageTable.getSelectionModel().setSelectionInterval(0, 0);
}
@@ -606,7 +557,6 @@ public class CodeStyleImportsPanel extends JPanel {
else {
myJspOneImportPerDirective.doClick();
}
updateButtons();
}
public void reset() {
@@ -621,16 +571,16 @@ public class CodeStyleImportsPanel extends JPanel {
settings.USE_FQ_CLASS_NAMES_IN_JAVADOC = myCbUseFQClassNamesInJavaDoc.isSelected();
settings.USE_SINGLE_CLASS_IMPORTS = myCbUseSingleClassImports.isSelected();
settings.INSERT_INNER_CLASS_IMPORTS = myCbInsertInnerClassImports.isSelected();
try{
try {
settings.CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND = Integer.parseInt(myClassCountField.getText());
}
catch(NumberFormatException e){
catch (NumberFormatException e) {
//just a bad number
}
try{
try {
settings.NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND = Integer.parseInt(myNamesCountField.getText());
}
catch(NumberFormatException e){
catch (NumberFormatException e) {
//just a bad number
}
@@ -654,8 +604,7 @@ public class CodeStyleImportsPanel extends JPanel {
}
public boolean isModified(CodeStyleSettings settings) {
boolean
isModified = isModified(myCbLayoutStaticImportsSeparately, settings.LAYOUT_STATIC_IMPORTS_SEPARATELY);
boolean isModified = isModified(myCbLayoutStaticImportsSeparately, settings.LAYOUT_STATIC_IMPORTS_SEPARATELY);
isModified |= isModified(myCbUseFQClassNames, settings.USE_FQ_CLASS_NAMES);
isModified |= isModified(myCbUseFQClassNamesInJavaDoc, settings.USE_FQ_CLASS_NAMES_IN_JAVADOC);
isModified |= isModified(myCbUseSingleClassImports, settings.USE_SINGLE_CLASS_IMPORTS);
@@ -679,7 +628,7 @@ public class CodeStyleImportsPanel extends JPanel {
int fieldValue = Integer.parseInt(textField.getText().trim());
return fieldValue != value;
}
catch(NumberFormatException e) {
catch (NumberFormatException e) {
return false;
}
}
@@ -689,14 +638,14 @@ public class CodeStyleImportsPanel extends JPanel {
}
private static boolean isModified(PackageEntryTable list, PackageEntryTable table) {
if(list.getEntryCount() != table.getEntryCount()) {
if (list.getEntryCount() != table.getEntryCount()) {
return true;
}
for(int i=0; i<list.getEntryCount(); i++) {
for (int i = 0; i < list.getEntryCount(); i++) {
PackageEntry entry1 = list.getEntryAt(i);
PackageEntry entry2 = table.getEntryAt(i);
if(!entry1.equals(entry2)) {
if (!entry1.equals(entry2)) {
return true;
}
}
@@ -23,11 +23,16 @@ import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.ui.VerticalFlowLayout;
import com.intellij.psi.PsiClass;
import com.intellij.ui.ScrollPaneFactory;
import com.intellij.ui.components.JBLabel;
import com.intellij.ui.components.JBList;
import com.intellij.util.ui.UIUtil;
import javax.swing.*;
import java.awt.*;
import static com.intellij.util.ui.UIUtil.ComponentStyle.SMALL;
import static com.intellij.util.ui.UIUtil.FontColor.BRIGHTER;
class RestoreReferencesDialog extends DialogWrapper {
private final Object[] myNamedElements;
private JList myList;
@@ -64,19 +69,14 @@ class RestoreReferencesDialog extends DialogWrapper {
@Override
protected JComponent createCenterPanel() {
final JPanel panel = new JPanel(new BorderLayout());
final JPanel panel = new JPanel(new BorderLayout(UIUtil.DEFAULT_HGAP, UIUtil.DEFAULT_VGAP));
myList = new JBList(myNamedElements);
myList.setCellRenderer(new FQNameCellRenderer());
myList.setBorder(BorderFactory.createEtchedBorder());
panel.add(ScrollPaneFactory.createScrollPane(myList), BorderLayout.CENTER);
JTextArea area = new JTextArea(myContainsClassesOnly ?
CodeInsightBundle.message("dialog.paste.on.import.text") :
CodeInsightBundle.message("dialog.paste.on.import.text2"));
area.setEditable(false);
area.setBackground(this.getContentPane().getBackground());
area.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
panel.add(area, BorderLayout.NORTH);
panel.add(new JBLabel(myContainsClassesOnly ?
CodeInsightBundle.message("dialog.paste.on.import.text") :
CodeInsightBundle.message("dialog.paste.on.import.text2"), SMALL, BRIGHTER), BorderLayout.NORTH);
final JPanel buttonPanel = new JPanel(new VerticalFlowLayout());
final JButton okButton = new JButton(CommonBundle.getOkButtonText());
@@ -25,22 +25,19 @@ 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.AnActionEvent;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectManager;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.Factory;
import com.intellij.openapi.util.IconLoader;
import com.intellij.profile.codeInspection.InspectionProfileManager;
import com.intellij.profile.codeInspection.InspectionProjectProfileManager;
import com.intellij.psi.*;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.ui.ReorderableListController;
import com.intellij.ui.ScrollPaneFactory;
import com.intellij.ui.SeparatorFactory;
import com.intellij.ui.SortedListModel;
import com.intellij.ui.*;
import com.intellij.ui.components.JBList;
import com.intellij.util.IconUtil;
import com.intellij.util.IncorrectOperationException;
import com.intellij.util.Processor;
import org.jetbrains.annotations.NonNls;
@@ -62,7 +59,9 @@ public class SpecialAnnotationsUtil {
return createSpecialAnnotationsListControl(list, borderTitle, false);
}
public static JPanel createSpecialAnnotationsListControl(final List<String> list, final String borderTitle, final boolean acceptPatterns) {
public static JPanel createSpecialAnnotationsListControl(final List<String> list,
final String borderTitle,
final boolean acceptPatterns) {
final SortedListModel<String> listModel = new SortedListModel<String>(new Comparator<String>() {
public int compare(final String o1, final String o2) {
return o1.compareTo(o2);
@@ -73,41 +72,6 @@ public class SpecialAnnotationsUtil {
listModel.add(s);
}
injectionList.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
final DefaultActionGroup actionGroup = new DefaultActionGroup();
final ReorderableListController<String> controller = ReorderableListController.create(injectionList, actionGroup);
controller.addAddAction(InspectionsBundle.message("special.annotations.list.add.annotation.class"), new Factory<String>() {
public String create() {
Project project = PlatformDataKeys.PROJECT.getData(DataManager.getInstance().getDataContext(injectionList));
if (project == null) project = ProjectManager.getInstance().getDefaultProject();
TreeClassChooser chooser = TreeClassChooserFactory.getInstance(project)
.createWithInnerClassesScopeChooser(InspectionsBundle.message("special.annotations.list.annotation.class"),
GlobalSearchScope.allScope(project), new ClassFilter() {
@Override
public boolean isAccepted(PsiClass aClass) {
return aClass.isAnnotationType();
}
}, null);
chooser.showDialog();
final PsiClass selected = chooser.getSelected();
return selected != null ? selected.getQualifiedName() : null;
}
}, true);
if (acceptPatterns) {
controller.addAction(new AnAction(InspectionsBundle.message("special.annotations.list.annotation.pattern"),
InspectionsBundle.message("special.annotations.list.annotation.pattern"),
IconLoader.getIcon("/general/add.png")) {
@Override
public void actionPerformed(AnActionEvent e) {
String selectedPattern = Messages.showInputDialog(InspectionsBundle.message("special.annotations.list.annotation.pattern"),
InspectionsBundle.message("special.annotations.list.annotation.pattern"),
Messages.getQuestionIcon());
if (selectedPattern != null) {
listModel.add(selectedPattern);
}
}
});
}
controller.addRemoveAction(InspectionsBundle.message("special.annotations.list.remove.annotation.class"));
injectionList.getModel().addListDataListener(new ListDataListener() {
public void intervalAdded(ListDataEvent e) {
listChanged();
@@ -129,32 +93,55 @@ public class SpecialAnnotationsUtil {
}
});
final JScrollPane listScrollPane = ScrollPaneFactory.createScrollPane(injectionList);
// listScrollPane.setBorder(BorderFactory.createEtchedBorder());
listScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
listScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
final FontMetrics fontMetrics = injectionList.getFontMetrics(injectionList.getFont());
listScrollPane.setPreferredSize(new Dimension(0, fontMetrics.getHeight() * 5));
listScrollPane.setMinimumSize(new Dimension(0, fontMetrics.getHeight() * 3));
//int height = injectionList.getCellRenderer().getListCellRendererComponent(injectionList, "foo", 0, false, false).getSize().height;
//injectionList.setFixedCellHeight(height);
//injectionList.setPreferredSize(new Dimension(0, height * 3));
//injectionList.setMinimumSize(new Dimension(0, height * 3));
// injectionList.setVisibleRowCount(3);
ToolbarDecorator toolbarDecorator = ToolbarDecorator.createDecorator(injectionList)
.setAddAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
Project project = PlatformDataKeys.PROJECT.getData(DataManager.getInstance().getDataContext(injectionList));
if (project == null) project = ProjectManager.getInstance().getDefaultProject();
TreeClassChooser chooser = TreeClassChooserFactory.getInstance(project)
.createWithInnerClassesScopeChooser(InspectionsBundle.message("special.annotations.list.annotation.class"),
GlobalSearchScope.allScope(project), new ClassFilter() {
@Override
public boolean isAccepted(PsiClass aClass) {
return aClass.isAnnotationType();
}
}, null);
chooser.showDialog();
final PsiClass selected = chooser.getSelected();
if (selected != null) {
listModel.add(selected.getQualifiedName());
}
}
}).setAddActionName(InspectionsBundle.message("special.annotations.list.add.annotation.class")).disableUpDownActions();
final JPanel listPanel = new JPanel(new BorderLayout());
ActionToolbar actionToolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, actionGroup, true);
listPanel.add(actionToolbar.getComponent(), BorderLayout.NORTH);
listPanel.add(listScrollPane, BorderLayout.CENTER);
if (acceptPatterns) {
toolbarDecorator
.setAddIcon(IconUtil.getAddClassIcon())
.addExtraAction(
new AnActionButton(InspectionsBundle.message("special.annotations.list.annotation.pattern"), IconUtil.getAddPatternIcon()) {
@Override
public void actionPerformed(AnActionEvent e) {
String selectedPattern = Messages.showInputDialog(InspectionsBundle.message("special.annotations.list.annotation.pattern"),
InspectionsBundle.message("special.annotations.list.annotation.pattern"),
Messages.getQuestionIcon());
if (selectedPattern != null) {
listModel.add(selectedPattern);
}
}
}).setButtonComparator(InspectionsBundle.message("special.annotations.list.add.annotation.class"),
InspectionsBundle.message("special.annotations.list.annotation.pattern"), "Remove");
}
JPanel panel = new JPanel(new BorderLayout());
panel.add(SeparatorFactory.createSeparator(borderTitle, null), BorderLayout.NORTH);
panel.add(listPanel, BorderLayout.CENTER);
panel.add(toolbarDecorator.createPanel(), BorderLayout.CENTER);
return panel;
}
public static IntentionAction createAddToSpecialAnnotationsListIntentionAction(final String text, final String family, final List<String> targetList,
public static IntentionAction createAddToSpecialAnnotationsListIntentionAction(final String text,
final String family,
final List<String> targetList,
final String qualifiedName) {
return new IntentionAction() {
@NotNull
@@ -181,9 +168,11 @@ public class SpecialAnnotationsUtil {
};
}
public static LocalQuickFix createAddToSpecialAnnotationsListQuickFix(final String text, final String family, final List<String> targetList,
final String qualifiedName,
final PsiElement context) {
public static LocalQuickFix createAddToSpecialAnnotationsListQuickFix(final String text,
final String family,
final List<String> targetList,
final String qualifiedName,
final PsiElement context) {
return new LocalQuickFix() {
@NotNull
public String getName() {
@@ -232,5 +221,4 @@ public class SpecialAnnotationsUtil {
}
}
}
}
@@ -115,12 +115,12 @@ public class EditMigrationDialog extends DialogWrapper{
public void run(AnActionButton button) {
edit();
}
}).setUpAction(new AnActionButtonRunnable() {
}).setMoveUpAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
moveUp();
}
}).setDownAction(new AnActionButtonRunnable() {
}).setMoveDownAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
moveDown();
@@ -30,6 +30,7 @@ import com.intellij.openapi.util.IconLoader;
import com.intellij.openapi.wm.ToolWindowId;
import com.intellij.ui.*;
import com.intellij.ui.components.JBList;
import com.intellij.util.PlatformIcons;
import com.intellij.util.ui.UIUtil;
import javax.swing.*;
@@ -246,7 +247,7 @@ public class ThreadDumpPanel extends JPanel {
private final Project myProject;
public CopyToClipboardAction(List<ThreadState> threadDump, Project project) {
super("Copy to Clipboard", "Copy whole thread dump to clipboard", IconLoader.getIcon("/general/copy.png"));
super("Copy to Clipboard", "Copy whole thread dump to clipboard", PlatformIcons.COPY_ICON);
myThreadDump = threadDump;
myProject = project;
}
@@ -23,14 +23,14 @@ package com.intellij.ui.classFilter;
import com.intellij.ide.util.ClassFilter;
import com.intellij.ide.util.TreeClassChooser;
import com.intellij.ide.util.TreeClassChooserFactory;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiClass;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.ui.ScrollPaneFactory;
import com.intellij.ui.TableUtil;
import com.intellij.ui.UIBundle;
import com.intellij.ui.*;
import com.intellij.ui.table.JBTable;
import com.intellij.util.IconUtil;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.ui.ComponentWithEmptyText;
import com.intellij.util.ui.ItemRemovable;
@@ -40,55 +40,69 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.table.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
public class ClassFilterEditor extends JPanel implements ComponentWithEmptyText {
protected AnActionButton myAddPatternButton;
protected JBTable myTable = null;
protected FilterTableModel myTableModel = null;
private final JButton myAddClassButton;
protected final JButton myAddPatternButton;
private final JButton myRemoveButton;
protected final Project myProject;
private final ClassFilter myChooserFilter;
@Nullable
private final String myPatternsHelpId;
public ClassFilterEditor(Project project) {
this (project, null);
this(project, null);
}
public ClassFilterEditor(Project project, ClassFilter classFilter) {
this (project, classFilter, null);
this(project, classFilter, null);
}
public ClassFilterEditor(Project project, ClassFilter classFilter, @Nullable String patternsHelpId) {
super(new GridBagLayout());
super(new BorderLayout());
myPatternsHelpId = patternsHelpId;
myAddClassButton = new JButton(getAddButtonText());
myAddPatternButton = new JButton(getAddPatternButtonText());
myRemoveButton = new JButton(UIBundle.message("button.remove"));
myTable = new JBTable();
JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myTable);
add(scrollPane, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 3, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(4, 0, 4, 6), 0, 0));
add(myAddClassButton, new GridBagConstraints(1, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(4, 0, 0, 0), 0, 0));
add(myAddPatternButton, new GridBagConstraints(1, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(4, 0, 0, 0), 0, 0));
add(myRemoveButton, new GridBagConstraints(1, GridBagConstraints.RELATIVE, 1, 1, 0.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(4, 0, 0, 0), 0, 0));
add(
ToolbarDecorator.createDecorator(myTable)
.addExtraAction(new AnActionButton(getAddButtonText(), IconUtil.getAddClassIcon()) {
@Override
public void actionPerformed(AnActionEvent e) {
addClassFilter();
}
@Override
public void updateButton(AnActionEvent e) {
super.updateButton(e);
setEnabled(!myProject.isDefault());
}
}).addExtraAction(myAddPatternButton = new AnActionButton(getAddPatternButtonText(), IconUtil.getAddPatternIcon()) {
@Override
public void actionPerformed(AnActionEvent e) {
addPatternFilter();
}
@Override
public void updateButton(AnActionEvent e) {
super.updateButton(e);
setEnabled(!myProject.isDefault());
}
}).setRemoveAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
TableUtil.removeSelectedItems(myTable);
}
}).setButtonComparator(getAddButtonText(), getAddPatternButtonText(), "Remove")
.disableUpDownActions().createPanel(), BorderLayout.CENTER
);
myChooserFilter = classFilter;
myProject = project;
myAddClassButton.setDefaultCapable(false);
myAddPatternButton.setDefaultCapable(false);
myRemoveButton.setDefaultCapable(false);
myTableModel = new FilterTableModel();
myTable.setModel(myTableModel);
@@ -107,46 +121,6 @@ public class ClassFilterEditor extends JPanel implements ComponentWithEmptyText
column.setCellRenderer(new EnabledCellRenderer(myTable.getDefaultRenderer(Boolean.class)));
columnModel.getColumn(FilterTableModel.FILTER).setCellRenderer(new FilterCellRenderer());
myTable.registerKeyboardAction(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
myAddClassButton.doClick();
}
},
KeyStroke.getKeyStroke(KeyEvent.VK_INSERT, 0),
JComponent.WHEN_FOCUSED
);
myTable.registerKeyboardAction(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
myRemoveButton.doClick();
}
},
KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0),
JComponent.WHEN_FOCUSED
);
myTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent e) {
myRemoveButton.setEnabled(myTable.getSelectedRow() > -1);
}
});
myAddPatternButton.setEnabled(!myProject.isDefault());
myAddPatternButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
addPatternFilter();
}
});
myAddClassButton.setEnabled(!myProject.isDefault());
myAddClassButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
addClassFilter();
}
});
myRemoveButton.addActionListener(new RemoveAction());
myRemoveButton.setEnabled(false);
getEmptyText().setText(UIBundle.message("no.patterns"));
}
@@ -173,10 +147,7 @@ public class ClassFilterEditor extends JPanel implements ComponentWithEmptyText
public void setEnabled(boolean enabled) {
super.setEnabled(enabled);
myAddPatternButton.setEnabled(enabled);
myAddClassButton.setEnabled(enabled);
myRemoveButton.setEnabled((myTable.getSelectedRow() > -1) && enabled);
myTable.setEnabled(enabled);
myTable.setRowSelectionAllowed(enabled);
myTableModel.fireTableDataChanged();
}
@@ -188,7 +159,7 @@ public class ClassFilterEditor extends JPanel implements ComponentWithEmptyText
}
}
protected final class FilterTableModel extends AbstractTableModel implements ItemRemovable{
protected final class FilterTableModel extends AbstractTableModel implements ItemRemovable {
private final List<com.intellij.ui.classFilter.ClassFilter> myFilters = new LinkedList<com.intellij.ui.classFilter.ClassFilter>();
public static final int CHECK_MARK = 0;
public static final int FILTER = 1;
@@ -202,7 +173,7 @@ public class ClassFilterEditor extends JPanel implements ComponentWithEmptyText
}
public com.intellij.ui.classFilter.ClassFilter[] getFilters() {
for (Iterator<com.intellij.ui.classFilter.ClassFilter> it = myFilters.iterator(); it.hasNext();) {
for (Iterator<com.intellij.ui.classFilter.ClassFilter> it = myFilters.iterator(); it.hasNext(); ) {
com.intellij.ui.classFilter.ClassFilter filter = it.next();
String pattern = filter.getPattern();
if (pattern == null || "".equals(pattern)) {
@@ -240,7 +211,7 @@ public class ClassFilterEditor extends JPanel implements ComponentWithEmptyText
return filter;
}
if (columnIndex == CHECK_MARK) {
return filter.isEnabled()? Boolean.TRUE : Boolean.FALSE;
return filter.isEnabled() ? Boolean.TRUE : Boolean.FALSE;
}
return null;
}
@@ -248,7 +219,7 @@ public class ClassFilterEditor extends JPanel implements ComponentWithEmptyText
public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
com.intellij.ui.classFilter.ClassFilter filter = myFilters.get(rowIndex);
if (columnIndex == FILTER) {
filter.setPattern(aValue != null? aValue.toString() : "");
filter.setPattern(aValue != null ? aValue.toString() : "");
}
else if (columnIndex == CHECK_MARK) {
filter.setEnabled(aValue == null || ((Boolean)aValue).booleanValue());
@@ -284,7 +255,8 @@ public class ClassFilterEditor extends JPanel implements ComponentWithEmptyText
((JLabel)component).setBorder(noFocusBorder);
}
UIManager.put(UIUtil.TABLE_FOCUS_CELL_BACKGROUND_PROPERTY, color);
com.intellij.ui.classFilter.ClassFilter filter = (com.intellij.ui.classFilter.ClassFilter)table.getValueAt(row, FilterTableModel.FILTER);
com.intellij.ui.classFilter.ClassFilter filter =
(com.intellij.ui.classFilter.ClassFilter)table.getValueAt(row, FilterTableModel.FILTER);
component.setEnabled(ClassFilterEditor.this.isEnabled() && filter.isEnabled());
return component;
}
@@ -306,7 +278,7 @@ public class ClassFilterEditor extends JPanel implements ComponentWithEmptyText
}
@NotNull
protected com.intellij.ui.classFilter.ClassFilter createFilter(String pattern){
protected com.intellij.ui.classFilter.ClassFilter createFilter(String pattern) {
return new com.intellij.ui.classFilter.ClassFilter(pattern);
}
@@ -346,7 +318,7 @@ public class ClassFilterEditor extends JPanel implements ComponentWithEmptyText
@Nullable
private static String getJvmClassName(PsiClass aClass) {
PsiClass parentClass = PsiTreeUtil.getParentOfType(aClass, PsiClass.class, true);
if(parentClass != null) {
if (parentClass != null) {
final String parentName = getJvmClassName(parentClass);
if (parentName == null) {
return null;
@@ -360,14 +332,4 @@ public class ClassFilterEditor extends JPanel implements ComponentWithEmptyText
com.intellij.ui.classFilter.ClassFilter filter = createFilter(pattern);
myTableModel.addRow(filter);
}
private final class RemoveAction implements ActionListener {
public void actionPerformed(ActionEvent e) {
TableUtil.removeSelectedItems(myTable);
}
}
public void setAddPatternButtonVisible(boolean visible) {
myAddPatternButton.setVisible(visible);
}
}