mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
ToolbarDecorators added for some new icons
This commit is contained in:
@@ -20,6 +20,9 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.ui.classFilter.ClassFilter;
|
||||
import com.intellij.ui.classFilter.ClassFilterEditor;
|
||||
import com.intellij.util.IconUtil;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* User: lex
|
||||
@@ -29,7 +32,6 @@ import com.intellij.ui.classFilter.ClassFilterEditor;
|
||||
public class InstanceFilterEditor extends ClassFilterEditor {
|
||||
public InstanceFilterEditor(Project project) {
|
||||
super(project);
|
||||
myAddPatternButton.setVisible(false);
|
||||
}
|
||||
|
||||
protected void addClassFilter() {
|
||||
@@ -51,6 +53,16 @@ public class InstanceFilterEditor extends ClassFilterEditor {
|
||||
return DebuggerBundle.message("button.add");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Icon getAddButtonIcon() {
|
||||
return IconUtil.getAddIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean addPatternButtonVisible() {
|
||||
return false;
|
||||
}
|
||||
|
||||
protected ClassFilter createFilter(String pattern) {
|
||||
try {
|
||||
Long.parseLong(pattern);
|
||||
|
||||
@@ -47,7 +47,6 @@ 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;
|
||||
protected final Project myProject;
|
||||
@@ -68,20 +67,21 @@ public class ClassFilterEditor extends JPanel implements ComponentWithEmptyText
|
||||
myPatternsHelpId = patternsHelpId;
|
||||
myTable = new JBTable();
|
||||
|
||||
add(
|
||||
ToolbarDecorator.createDecorator(myTable)
|
||||
.addExtraAction(new AnActionButton(getAddButtonText(), IconUtil.getAddClassIcon()) {
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
addClassFilter();
|
||||
}
|
||||
final ToolbarDecorator decorator = ToolbarDecorator.createDecorator(myTable)
|
||||
.addExtraAction(new AnActionButton(getAddButtonText(), getAddButtonIcon()) {
|
||||
@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 updateButton(AnActionEvent e) {
|
||||
super.updateButton(e);
|
||||
setEnabled(!myProject.isDefault());
|
||||
}
|
||||
});
|
||||
if (addPatternButtonVisible()) {
|
||||
decorator.addExtraAction(new AnActionButton(getAddPatternButtonText(), getAddPatternButtonIcon()) {
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
addPatternFilter();
|
||||
@@ -92,14 +92,15 @@ public class ClassFilterEditor extends JPanel implements ComponentWithEmptyText
|
||||
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
|
||||
);
|
||||
});
|
||||
}
|
||||
add(decorator.setRemoveAction(new AnActionButtonRunnable() {
|
||||
@Override
|
||||
public void run(AnActionButton button) {
|
||||
TableUtil.removeSelectedItems(myTable);
|
||||
}
|
||||
}).setButtonComparator(getAddButtonText(), getAddPatternButtonText(), "Remove")
|
||||
.disableUpDownActions().createPanel(), BorderLayout.CENTER);
|
||||
|
||||
myChooserFilter = classFilter;
|
||||
myProject = project;
|
||||
@@ -137,6 +138,18 @@ public class ClassFilterEditor extends JPanel implements ComponentWithEmptyText
|
||||
return UIBundle.message("button.add.pattern");
|
||||
}
|
||||
|
||||
protected Icon getAddButtonIcon() {
|
||||
return IconUtil.getAddClassIcon();
|
||||
}
|
||||
|
||||
protected Icon getAddPatternButtonIcon() {
|
||||
return IconUtil.getAddPatternIcon();
|
||||
}
|
||||
|
||||
protected boolean addPatternButtonVisible() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void setFilters(com.intellij.ui.classFilter.ClassFilter[] filters) {
|
||||
myTableModel.setFilters(filters);
|
||||
}
|
||||
|
||||
@@ -116,4 +116,6 @@ public interface PlatformIcons {
|
||||
|
||||
Icon EXPORT_ICON = IconLoader.getIcon("/toolbarDecorator/export.png");
|
||||
Icon IMPORT_ICON = IconLoader.getIcon("/toolbarDecorator/import.png");
|
||||
|
||||
Icon SEPARATOR_HORIZONTAL_ICON = IconLoader.getIcon("/general/separatorH.png");
|
||||
}
|
||||
|
||||
@@ -50,83 +50,13 @@
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
<grid id="b50b5" 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"/>
|
||||
<grid id="b50b5" binding="myListPanel" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<scrollpane id="79c0e" class="com.intellij.ui.components.JBScrollPane">
|
||||
<constraints>
|
||||
<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"/>
|
||||
<children>
|
||||
<component id="4fd59" class="com.intellij.ui.components.JBList" binding="myActionsList">
|
||||
<constraints/>
|
||||
<properties/>
|
||||
</component>
|
||||
</children>
|
||||
</scrollpane>
|
||||
<grid id="aa68d" 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>
|
||||
<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="e1afd" class="javax.swing.JButton" binding="myMoveActionUpButton">
|
||||
<constraints>
|
||||
<grid row="2" column="0" 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/KeyMapBundle" key="quick.list.panel.move.up.button"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="b3797" class="javax.swing.JButton" binding="myMoveActionDownButton">
|
||||
<constraints>
|
||||
<grid row="3" column="0" 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/KeyMapBundle" key="quick.list.panel.move.down.button"/>
|
||||
</properties>
|
||||
</component>
|
||||
<vspacer id="9f8e8">
|
||||
<constraints>
|
||||
<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>
|
||||
<component id="4cb47" class="javax.swing.JButton" binding="myRemoveActionButton">
|
||||
<constraints>
|
||||
<grid row="4" column="0" 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 value="&Remove"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="8e0f1" class="javax.swing.JButton" binding="myIncludeActionButton">
|
||||
<constraints>
|
||||
<grid row="0" column="0" 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 value="&Add"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="c7c3a" class="javax.swing.JButton" binding="myAddSeparatorButton">
|
||||
<constraints>
|
||||
<grid row="1" column="0" 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/KeyMapBundle" key="quick.list.panel.add.separator.button"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
<children/>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
|
||||
+24
-97
@@ -17,6 +17,7 @@ package com.intellij.openapi.keymap.impl.ui;
|
||||
|
||||
import com.intellij.openapi.actionSystem.ActionManager;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.Separator;
|
||||
import com.intellij.openapi.actionSystem.ex.QuickList;
|
||||
import com.intellij.openapi.actionSystem.ex.QuickListsManager;
|
||||
@@ -24,43 +25,37 @@ import com.intellij.openapi.keymap.KeyMapBundle;
|
||||
import com.intellij.openapi.keymap.KeymapManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import com.intellij.ui.DocumentAdapter;
|
||||
import com.intellij.ui.JBDefaultTreeCellRenderer;
|
||||
import com.intellij.ui.*;
|
||||
import com.intellij.ui.components.JBList;
|
||||
import com.intellij.util.PlatformIcons;
|
||||
import com.intellij.util.ui.EmptyIcon;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
import javax.swing.tree.DefaultMutableTreeNode;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
public class QuickListPanel {
|
||||
private static final Icon EMPTY_ICON = EmptyIcon.ICON_18;
|
||||
|
||||
private static final Icon QUICK_LIST_ICON = IconLoader.getIcon("/actions/quickList.png");
|
||||
private JButton myRemoveActionButton;
|
||||
private JButton myIncludeActionButton;
|
||||
private JButton myMoveActionDownButton;
|
||||
private JButton myMoveActionUpButton;
|
||||
private JPanel myPanel;
|
||||
private JBList myActionsList;
|
||||
private JTextField myDisplayName;
|
||||
private JTextField myDescription;
|
||||
private JButton myAddSeparatorButton;
|
||||
private final boolean myEditable;
|
||||
private JPanel myListPanel;
|
||||
private final QuickList[] myAllQuickLists;
|
||||
|
||||
public QuickListPanel(QuickList origin, final QuickList[] allQuickLists, Project project) {
|
||||
myAllQuickLists = allQuickLists;
|
||||
myEditable = !QuickListsManager.getInstance().getSchemesManager().isShared(origin);
|
||||
|
||||
myActionsList.setModel(new DefaultListModel());
|
||||
myActionsList = new JBList(new DefaultListModel());
|
||||
myActionsList.setCellRenderer(new MyListCellRenderer());
|
||||
myActionsList.getEmptyText().setText(KeyMapBundle.message("no.actions"));
|
||||
myActionsList.setEnabled(!QuickListsManager.getInstance().getSchemesManager().isShared(origin));
|
||||
|
||||
myActionsList.addMouseListener(new MouseAdapter() {
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
@@ -70,61 +65,19 @@ public class QuickListPanel {
|
||||
}
|
||||
});
|
||||
|
||||
myActionsList.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
|
||||
public void valueChanged(ListSelectionEvent e) {
|
||||
update();
|
||||
}
|
||||
});
|
||||
|
||||
myIncludeActionButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
includeSelectedAction();
|
||||
}
|
||||
});
|
||||
|
||||
myAddSeparatorButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
addSeparator();
|
||||
}
|
||||
});
|
||||
|
||||
myActionsList.registerKeyboardAction(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
excludeSelectionAction();
|
||||
}
|
||||
}, KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
|
||||
|
||||
myRemoveActionButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
excludeSelectionAction();
|
||||
}
|
||||
});
|
||||
|
||||
myMoveActionUpButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
int idx = myActionsList.getSelectedIndex();
|
||||
if (idx > 0) {
|
||||
DefaultListModel listModel = (DefaultListModel)myActionsList.getModel();
|
||||
Object oldValue = listModel.get(idx);
|
||||
listModel.removeElementAt(idx);
|
||||
listModel.add(--idx, oldValue);
|
||||
myActionsList.getSelectionModel().setSelectionInterval(idx, idx);
|
||||
myListPanel.add(
|
||||
ToolbarDecorator.createDecorator(myActionsList)
|
||||
.setAddAction(new AnActionButtonRunnable() {
|
||||
@Override
|
||||
public void run(AnActionButton button) {
|
||||
includeSelectedAction();
|
||||
}
|
||||
}).addExtraAction(new AnActionButton("Add Separator", PlatformIcons.SEPARATOR_HORIZONTAL_ICON) {
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
addSeparator();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
myMoveActionDownButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
int idx = myActionsList.getSelectedIndex();
|
||||
DefaultListModel listModel = (DefaultListModel)myActionsList.getModel();
|
||||
if (idx < listModel.getSize() - 1) {
|
||||
Object oldValue = listModel.get(idx);
|
||||
listModel.removeElementAt(idx);
|
||||
listModel.add(++idx, oldValue);
|
||||
myActionsList.getSelectionModel().setSelectionInterval(idx, idx);
|
||||
}
|
||||
}
|
||||
});
|
||||
}).setButtonComparator("Add", "Add Separator", "Remove", "Up", "Down").createPanel(), BorderLayout.CENTER);
|
||||
|
||||
myDisplayName.setText(origin.getDisplayName());
|
||||
myDescription.setText(origin.getDescription());
|
||||
@@ -133,11 +86,9 @@ public class QuickListPanel {
|
||||
for (String id : ids) {
|
||||
includeActionId(id);
|
||||
}
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
public void addNameListener(DocumentAdapter adapter){
|
||||
public void addNameListener(DocumentAdapter adapter) {
|
||||
myDisplayName.getDocument().addDocumentListener(adapter);
|
||||
}
|
||||
|
||||
@@ -147,10 +98,9 @@ public class QuickListPanel {
|
||||
|
||||
private void excludeSelectionAction() {
|
||||
int[] ids = myActionsList.getSelectedIndices();
|
||||
for (int i = ids.length - 1; i >=0; i--) {
|
||||
for (int i = ids.length - 1; i >= 0; i--) {
|
||||
((DefaultListModel)myActionsList.getModel()).remove(ids[i]);
|
||||
}
|
||||
update();
|
||||
}
|
||||
|
||||
private void includeSelectedAction() {
|
||||
@@ -174,14 +124,12 @@ public class QuickListPanel {
|
||||
selectionModel.addSelectionInterval(idx, idx);
|
||||
}
|
||||
}
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
private void addSeparator() {
|
||||
DefaultListModel model = (DefaultListModel)myActionsList.getModel();
|
||||
model.addElement(QuickList.SEPARATOR_ID);
|
||||
update();
|
||||
}
|
||||
|
||||
public JList getActionsList() {
|
||||
@@ -196,24 +144,6 @@ public class QuickListPanel {
|
||||
return myDisplayName.getText();
|
||||
}
|
||||
|
||||
private void update() {
|
||||
if (myEditable) {
|
||||
myIncludeActionButton.setEnabled(true);
|
||||
myRemoveActionButton.setEnabled(myActionsList.getSelectedValues().length > 0);
|
||||
boolean enableMove = myActionsList.getSelectedValues().length == 1;
|
||||
myMoveActionUpButton.setEnabled(enableMove && myActionsList.getSelectedIndex() > 0);
|
||||
myMoveActionDownButton.setEnabled(enableMove && myActionsList.getSelectedIndex() < myActionsList.getModel().getSize() - 1);
|
||||
}
|
||||
else {
|
||||
myIncludeActionButton.setEnabled(false);
|
||||
myRemoveActionButton.setEnabled(false);
|
||||
myMoveActionUpButton.setEnabled(false);
|
||||
myMoveActionDownButton.setEnabled(false);
|
||||
myAddSeparatorButton.setEnabled(false);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void includeActionId(String id) {
|
||||
DefaultListModel model = (DefaultListModel)myActionsList.getModel();
|
||||
if (!QuickList.SEPARATOR_ID.equals(id) && model.contains(id)) return;
|
||||
@@ -251,8 +181,6 @@ public class QuickListPanel {
|
||||
if (icon == null) {
|
||||
icon = expanded ? getOpenIcon() : getClosedIcon();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else if (userObject instanceof String) {
|
||||
String actionId = (String)userObject;
|
||||
@@ -277,7 +205,6 @@ public class QuickListPanel {
|
||||
else if (userObject instanceof Separator) {
|
||||
// TODO[vova,anton]: beautify
|
||||
setText("-------------");
|
||||
|
||||
}
|
||||
else {
|
||||
throw new IllegalArgumentException("unknown userObject: " + userObject);
|
||||
@@ -289,7 +216,7 @@ public class QuickListPanel {
|
||||
setForeground(getSelectionForeground(tree));
|
||||
}
|
||||
else {
|
||||
Color foreground = used ? UIUtil.getInactiveTextColor() :UIUtil.getTreeForeground();
|
||||
Color foreground = used ? UIUtil.getInactiveTextColor() : UIUtil.getTreeForeground();
|
||||
setForeground(foreground);
|
||||
}
|
||||
}
|
||||
@@ -319,7 +246,7 @@ public class QuickListPanel {
|
||||
icon = actionIcon;
|
||||
}
|
||||
}
|
||||
if (actionId.startsWith(QuickList.QUICK_LIST_PREFIX)){
|
||||
if (actionId.startsWith(QuickList.QUICK_LIST_PREFIX)) {
|
||||
icon = QUICK_LIST_ICON;
|
||||
}
|
||||
setIcon(ActionsTree.getEvenIcon(icon));
|
||||
|
||||
@@ -396,7 +396,7 @@ i18nize.error.title=Cannot I18nize Selection
|
||||
i18nize.error.message=You can only i18nize Java string literal or substring thereof.\nPlease point the caret inside Java string literal or select part of it.
|
||||
display.coverage.prompt=Do you want to display coverage data for ''{0}''?
|
||||
code.coverage=Code Coverage
|
||||
coverage.button.add.package=Add &Package
|
||||
coverage.button.add.package=Add Package
|
||||
coverage.pattern.filter.editor.choose.package.title=Choose Package
|
||||
no.coverage=No coverage
|
||||
code.coverage.is.not.supported=Code coverage is supported for jre 5.0 or higher
|
||||
|
||||
@@ -198,7 +198,7 @@ label.compound.renderer.configurable.when.expanding=When expanding the node
|
||||
label.compound.renderer.configurable.test.can.expand=Test if the node can be expanded (optional):
|
||||
title.compound.renderer.configurable.choose.renderer.reference.type=Renderer Reference Type
|
||||
text.base.renderer.configurable.no.class.patterns=No class patterns configured
|
||||
button.add=&Add
|
||||
button.add=Add
|
||||
button.remove=&Remove
|
||||
button.move.up=Move &Up
|
||||
button.move.down=Move &Down
|
||||
|
||||
Reference in New Issue
Block a user