mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
support JList in ToolbarDecorator
This commit is contained in:
+1
-1
@@ -417,7 +417,7 @@ public class ClasspathPanelImpl extends JPanel implements ClasspathPanel {
|
||||
downButton.setShortcut(KeyboardShortcut.fromString("alt DOWN"));
|
||||
myEntryTable.setBorder(new LineBorder(UIUtil.getBorderColor()));
|
||||
|
||||
final TableToolbarDecorator decorator = TableToolbarDecorator.createDecorator(myEntryTable);
|
||||
final ToolbarDecorator decorator = ToolbarDecorator.createDecorator(myEntryTable);
|
||||
decorator
|
||||
.addExtraAction(addButton)
|
||||
.addExtraAction(removeButton)
|
||||
|
||||
+1
-1
@@ -135,7 +135,7 @@ public class ChangeClassSignatureDialog extends RefactoringDialog {
|
||||
|
||||
final JPanel panel = new JPanel(new BorderLayout());
|
||||
panel.add(SeparatorFactory.createSeparator(RefactoringBundle.message("changeClassSignature.parameters.panel.border.title"), myTable), BorderLayout.NORTH);
|
||||
panel.add(TableToolbarDecorator.createDecorator(myTable).createPanel(), BorderLayout.CENTER);
|
||||
panel.add(ToolbarDecorator.createDecorator(myTable).createPanel(), BorderLayout.CENTER);
|
||||
return panel;
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -40,7 +40,7 @@ import com.intellij.refactoring.util.RefactoringUtil;
|
||||
import com.intellij.ui.AnActionButton;
|
||||
import com.intellij.ui.IdeBorderFactory;
|
||||
import com.intellij.ui.TableColumnAnimator;
|
||||
import com.intellij.ui.TableToolbarDecorator;
|
||||
import com.intellij.ui.ToolbarDecorator;
|
||||
import com.intellij.ui.table.JBTable;
|
||||
import com.intellij.ui.table.TableView;
|
||||
import com.intellij.ui.treeStructure.Tree;
|
||||
@@ -160,7 +160,7 @@ public class JavaChangeSignatureDialog extends ChangeSignatureDialogBase<Paramet
|
||||
};
|
||||
myPropExceptionsButton.setShortcut(KeyboardShortcut.fromString("alt X"));
|
||||
|
||||
final JPanel panel = TableToolbarDecorator.createDecorator(table).addExtraAction(myPropExceptionsButton).createPanel();
|
||||
final JPanel panel = ToolbarDecorator.createDecorator(table).addExtraAction(myPropExceptionsButton).createPanel();
|
||||
panel.setBorder(IdeBorderFactory.createEmptyBorder(0));
|
||||
|
||||
myExceptionsModel.addTableModelListener(new TableModelListener() {
|
||||
|
||||
@@ -23,8 +23,8 @@ import com.intellij.refactoring.ui.TypeSelectorManager;
|
||||
import com.intellij.refactoring.ui.TypeSelectorManagerImpl;
|
||||
import com.intellij.ui.BooleanTableCellRenderer;
|
||||
import com.intellij.ui.EditableModel;
|
||||
import com.intellij.ui.TableToolbarDecorator;
|
||||
import com.intellij.ui.TableUtil;
|
||||
import com.intellij.ui.ToolbarDecorator;
|
||||
import com.intellij.ui.components.JBComboBoxLabel;
|
||||
import com.intellij.ui.components.editors.JBComboBoxTableCellEditorComponent;
|
||||
import com.intellij.ui.table.JBTable;
|
||||
@@ -252,7 +252,7 @@ public abstract class ParameterTablePanel extends JPanel {
|
||||
});
|
||||
|
||||
|
||||
JPanel listPanel = TableToolbarDecorator.createDecorator(myTable).disableAddAction().disableRemoveAction().createPanel();
|
||||
JPanel listPanel = ToolbarDecorator.createDecorator(myTable).disableAddAction().disableRemoveAction().createPanel();
|
||||
add(listPanel, BorderLayout.CENTER);
|
||||
|
||||
if (getVariableData().length > 1) {
|
||||
|
||||
+2
-2
@@ -29,7 +29,7 @@ import com.intellij.packageDependencies.DependencyValidationManager;
|
||||
import com.intellij.psi.search.scope.packageSet.NamedScope;
|
||||
import com.intellij.psi.search.scope.packageSet.PackageSet;
|
||||
import com.intellij.ui.EditableModel;
|
||||
import com.intellij.ui.TableToolbarDecorator;
|
||||
import com.intellij.ui.ToolbarDecorator;
|
||||
import com.intellij.ui.table.TableView;
|
||||
import com.intellij.util.ui.AbstractTableCellEditor;
|
||||
import com.intellij.util.ui.CellEditorComponentWithBrowseButton;
|
||||
@@ -100,7 +100,7 @@ public class DependencyConfigurable extends BaseConfigurable {
|
||||
table.setShowGrid(true);
|
||||
table.setRowHeight(new PackageSetChooserCombo(myProject, null).getPreferredSize().height);
|
||||
|
||||
return TableToolbarDecorator.createDecorator(table).createPanel();
|
||||
return ToolbarDecorator.createDecorator(table).createPanel();
|
||||
}
|
||||
|
||||
public JComponent getPreferredFocusedComponent() {
|
||||
|
||||
+1
-1
@@ -379,7 +379,7 @@ public abstract class ChangeSignatureDialogBase<P extends ParameterInfo, M exten
|
||||
myParametersTable.setSurrendersFocusOnKeystroke(true);
|
||||
myPropagateParamChangesButton.setShortcut(KeyboardShortcut.fromString("alt G"));
|
||||
|
||||
final JPanel buttonsPanel = TableToolbarDecorator.createDecorator(myParametersTable)
|
||||
final JPanel buttonsPanel = ToolbarDecorator.createDecorator(myParametersTable)
|
||||
.addExtraAction(myPropagateParamChangesButton)
|
||||
.createPanel();
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2011 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.
|
||||
@@ -23,28 +23,33 @@ import com.intellij.util.ui.StatusText;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Panel with "Add" and "Delete" buttons on the right side.
|
||||
*
|
||||
* @author Konstantin Bulenkov
|
||||
* @author anna
|
||||
* @since 5.1
|
||||
*/
|
||||
public abstract class AddDeleteListPanel<T> extends PanelWithButtons implements ComponentWithEmptyText {
|
||||
private final String myTitle;
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
protected JButton myAddButton = new JButton(CommonBundle.message("button.add"));
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
protected JButton myDeleteButton = new JButton(CommonBundle.message("button.delete"));
|
||||
|
||||
protected DefaultListModel myListModel = new DefaultListModel();
|
||||
protected JBList myList = new JBList(myListModel);
|
||||
|
||||
public AddDeleteListPanel(final String title,
|
||||
final List<T> initialList) {
|
||||
public AddDeleteListPanel(final String title, final List<T> initialList) {
|
||||
myTitle = title;
|
||||
for (Object o : initialList) {
|
||||
if (o != null) {
|
||||
@@ -52,24 +57,31 @@ public abstract class AddDeleteListPanel<T> extends PanelWithButtons implements
|
||||
}
|
||||
}
|
||||
myList.setCellRenderer(getListCellRenderer());
|
||||
myList.addListSelectionListener(new ListSelectionListener() {
|
||||
public void valueChanged(ListSelectionEvent e) {
|
||||
myDeleteButton.setEnabled(ListUtil.canRemoveSelectedItems(myList));
|
||||
}
|
||||
});
|
||||
myAddButton.addActionListener(new ActionListener(){
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
addElement(findItemToAdd());
|
||||
}
|
||||
});
|
||||
myDeleteButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
ListUtil.removeSelectedItems(myList);
|
||||
}
|
||||
});
|
||||
initPanel();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initPanel() {
|
||||
final ToolbarDecorator decorator = ToolbarDecorator.createDecorator(myList)
|
||||
.disableUpAction()
|
||||
.disableDownAction()
|
||||
.setAddAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
addElement(findItemToAdd());
|
||||
}
|
||||
});
|
||||
customizeDecorator(decorator);
|
||||
setLayout(new BorderLayout());
|
||||
add(decorator.createPanel(), BorderLayout.CENTER);
|
||||
if (myTitle != null) {
|
||||
setBorder(IdeBorderFactory.createTitledBorder(myTitle));
|
||||
}
|
||||
}
|
||||
|
||||
protected void customizeDecorator(ToolbarDecorator decorator) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public StatusText getEmptyText() {
|
||||
return myList.getEmptyText();
|
||||
|
||||
@@ -1,28 +1,36 @@
|
||||
/*
|
||||
* Copyright 2000-2011 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.ui;
|
||||
|
||||
import com.intellij.CommonBundle;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.util.IconUtil;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author peter
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
public abstract class AddEditDeleteListPanel<T> extends AddDeleteListPanel<T> {
|
||||
private JButton myEditButton;
|
||||
|
||||
public AddEditDeleteListPanel(final String title, final List<T> initialList) {
|
||||
super(title, initialList);
|
||||
myEditButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
editSelectedItem();
|
||||
}
|
||||
});
|
||||
myList.addMouseListener(new MouseAdapter() {
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
if (e.getClickCount() == 2 && e.getButton() == MouseEvent.BUTTON1) {
|
||||
@@ -32,9 +40,19 @@ public abstract class AddEditDeleteListPanel<T> extends AddDeleteListPanel<T> {
|
||||
});
|
||||
}
|
||||
|
||||
@Override protected JButton[] createButtons() {
|
||||
myEditButton = new JButton(CommonBundle.message("button.edit"));
|
||||
return new JButton[] { myAddButton, myEditButton, myDeleteButton };
|
||||
@Override
|
||||
protected void customizeDecorator(ToolbarDecorator decorator) {
|
||||
decorator.addExtraAction(new AnActionButton(CommonBundle.message("button.edit"), null, IconUtil.getEditIcon()) {
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
editSelectedItem();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(AnActionEvent e) {
|
||||
e.getPresentation().setEnabled(myList.getSelectedIndex() != -1);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
+133
-55
@@ -34,9 +34,10 @@ import java.util.List;
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
@SuppressWarnings("UnusedDeclaration")
|
||||
public class TableToolbarDecorator {
|
||||
public class ToolbarDecorator {
|
||||
private JTable myTable;
|
||||
private TableModel myModel;
|
||||
private TableModel myTableModel;
|
||||
private ListModel myListModel;
|
||||
private Border myToolbarBorder;
|
||||
private boolean myAddActionEnabled;
|
||||
private boolean myRemoveActionEnabled;
|
||||
@@ -50,29 +51,66 @@ public class TableToolbarDecorator {
|
||||
private Runnable myUpAction;
|
||||
private Runnable myDownAction;
|
||||
private AddRemoveUpDownPanel myPanel;
|
||||
private JList myList;
|
||||
|
||||
|
||||
private TableToolbarDecorator(JTable table) {
|
||||
private ToolbarDecorator(JTable table) {
|
||||
myTable = table;
|
||||
myTable.setBorder(IdeBorderFactory.createEmptyBorder(0));
|
||||
myModel = table.getModel();
|
||||
myToolbarPosition = SystemInfo.isMac ? ActionToolbarPosition.BOTTOM : ActionToolbarPosition.RIGHT;
|
||||
myBorder = SystemInfo.isMac ? new CustomLineBorder(0,1,1,1) : new CustomLineBorder(0, 1, 0, 0);
|
||||
myAddActionEnabled = myRemoveActionEnabled = myUpActionEnabled = myDownActionEnabled = myModel instanceof EditableModel;
|
||||
if (myModel instanceof EditableModel) {
|
||||
createDefaultActions();
|
||||
myTableModel = table.getModel();
|
||||
initPositionAndBorder();
|
||||
myAddActionEnabled = myRemoveActionEnabled = myUpActionEnabled = myDownActionEnabled = myTableModel instanceof EditableModel;
|
||||
if (myTableModel instanceof EditableModel) {
|
||||
createDefaultTableActions();
|
||||
}
|
||||
}
|
||||
|
||||
private void createDefaultActions() {
|
||||
private ToolbarDecorator(JList list) {
|
||||
myList = list;
|
||||
myListModel = list.getModel();
|
||||
myAddActionEnabled = myRemoveActionEnabled = myUpActionEnabled = myDownActionEnabled = true;
|
||||
initPositionAndBorder();
|
||||
createDefaultListActions();
|
||||
}
|
||||
|
||||
private void createDefaultListActions() {
|
||||
myRemoveAction = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ListUtil.removeSelectedItems(myList);
|
||||
updateListButtons(myList, myPanel);
|
||||
}
|
||||
};
|
||||
myUpAction = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ListUtil.moveSelectedItemsUp(myList);
|
||||
updateListButtons(myList, myPanel);
|
||||
}
|
||||
};
|
||||
myDownAction = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ListUtil.moveSelectedItemsDown(myList);
|
||||
updateListButtons(myList, myPanel);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private void initPositionAndBorder() {
|
||||
myToolbarPosition = SystemInfo.isMac ? ActionToolbarPosition.BOTTOM : ActionToolbarPosition.RIGHT;
|
||||
myBorder = SystemInfo.isMac ? new CustomLineBorder(0,1,1,1) : new CustomLineBorder(0, 1, 0, 0);
|
||||
}
|
||||
|
||||
private void createDefaultTableActions() {
|
||||
final JTable table = myTable;
|
||||
final EditableModel tableModel = (EditableModel)myModel;
|
||||
final EditableModel tableModel = (EditableModel)myTableModel;
|
||||
|
||||
myAddAction = new Runnable() {
|
||||
public void run() {
|
||||
TableUtil.stopEditing(table);
|
||||
tableModel.addRow();
|
||||
final int index = myModel.getRowCount() - 1;
|
||||
final int index = myTableModel.getRowCount() - 1;
|
||||
table.editCellAt(index, 0);
|
||||
table.setRowSelectionInterval(index, index);
|
||||
table.setColumnSelectionInterval(0, 0);
|
||||
@@ -90,9 +128,9 @@ public class TableToolbarDecorator {
|
||||
public void run() {
|
||||
TableUtil.stopEditing(table);
|
||||
int index = table.getSelectedRow();
|
||||
if (0 <= index && index < myModel.getRowCount()) {
|
||||
if (0 <= index && index < myTableModel.getRowCount()) {
|
||||
tableModel.removeRow(index);
|
||||
if (index < myModel.getRowCount()) {
|
||||
if (index < myTableModel.getRowCount()) {
|
||||
table.setRowSelectionInterval(index, index);
|
||||
}
|
||||
else {
|
||||
@@ -100,7 +138,7 @@ public class TableToolbarDecorator {
|
||||
table.setRowSelectionInterval(index - 1, index - 1);
|
||||
}
|
||||
}
|
||||
updateButtons(table, tableModel, myPanel);
|
||||
updateTableButtons(table, tableModel, myPanel);
|
||||
}
|
||||
|
||||
table.getParent().repaint();
|
||||
@@ -112,7 +150,7 @@ public class TableToolbarDecorator {
|
||||
public void run() {
|
||||
TableUtil.stopEditing(table);
|
||||
int index = table.getSelectedRow();
|
||||
if (0 < index && index < myModel.getRowCount()) {
|
||||
if (0 < index && index < myTableModel.getRowCount()) {
|
||||
tableModel.exchangeRows(index, index - 1);
|
||||
table.setRowSelectionInterval(index - 1, index - 1);
|
||||
}
|
||||
@@ -124,7 +162,7 @@ public class TableToolbarDecorator {
|
||||
public void run() {
|
||||
TableUtil.stopEditing(table);
|
||||
int index = table.getSelectedRow();
|
||||
if (0 <= index && index < myModel.getRowCount() - 1) {
|
||||
if (0 <= index && index < myTableModel.getRowCount() - 1) {
|
||||
tableModel.exchangeRows(index, index + 1);
|
||||
table.setRowSelectionInterval(index + 1, index + 1);
|
||||
}
|
||||
@@ -133,92 +171,112 @@ public class TableToolbarDecorator {
|
||||
};
|
||||
}
|
||||
|
||||
private static void updateButtons(final JTable table,
|
||||
final EditableModel tableModel,
|
||||
final AddRemoveUpDownPanel p) {
|
||||
if (table.isEnabled()) {
|
||||
private static void updateListButtons(final JList list, final AddRemoveUpDownPanel p) {
|
||||
if (list.isEnabled() && p != null) {
|
||||
final int index = list.getSelectedIndex();
|
||||
if (0 <= index && index < list.getModel().getSize()) {
|
||||
final boolean downEnable = list.getMaxSelectionIndex() < list.getModel().getSize() - 1;
|
||||
final boolean upEnable = list.getMinSelectionIndex() > 0;
|
||||
p.setEnabled(AddRemoveUpDownPanel.Buttons.REMOVE, true);
|
||||
p.setEnabled(AddRemoveUpDownPanel.Buttons.UP, upEnable);
|
||||
p.setEnabled(AddRemoveUpDownPanel.Buttons.DOWN, downEnable);
|
||||
} else {
|
||||
p.setEnabled(AddRemoveUpDownPanel.Buttons.REMOVE, false);
|
||||
p.setEnabled(AddRemoveUpDownPanel.Buttons.UP, false);
|
||||
p.setEnabled(AddRemoveUpDownPanel.Buttons.DOWN, false);
|
||||
}
|
||||
p.setEnabled(AddRemoveUpDownPanel.Buttons.ADD, true);
|
||||
}
|
||||
}
|
||||
|
||||
private static void updateTableButtons(final JTable table,
|
||||
final EditableModel tableModel,
|
||||
final AddRemoveUpDownPanel p) {
|
||||
if (table.isEnabled() && p != null) {
|
||||
final int index = table.getSelectedRow();
|
||||
if (0 <= index && index < ((TableModel)tableModel).getRowCount()) {
|
||||
final boolean downEnable = index < ((TableModel)tableModel).getRowCount() - 1;
|
||||
final boolean upEnable = index > 0;
|
||||
if (p != null) {
|
||||
p.setEnabled(AddRemoveUpDownPanel.Buttons.REMOVE, true);
|
||||
p.setEnabled(AddRemoveUpDownPanel.Buttons.UP, upEnable);
|
||||
p.setEnabled(AddRemoveUpDownPanel.Buttons.DOWN, downEnable);
|
||||
}
|
||||
p.setEnabled(AddRemoveUpDownPanel.Buttons.REMOVE, true);
|
||||
p.setEnabled(AddRemoveUpDownPanel.Buttons.UP, upEnable);
|
||||
p.setEnabled(AddRemoveUpDownPanel.Buttons.DOWN, downEnable);
|
||||
} else {
|
||||
if (p != null) {
|
||||
p.setEnabled(AddRemoveUpDownPanel.Buttons.REMOVE, false);
|
||||
p.setEnabled(AddRemoveUpDownPanel.Buttons.UP, false);
|
||||
p.setEnabled(AddRemoveUpDownPanel.Buttons.DOWN, false);
|
||||
}
|
||||
}
|
||||
if (p != null) {
|
||||
p.setEnabled(AddRemoveUpDownPanel.Buttons.ADD, true);
|
||||
p.setEnabled(AddRemoveUpDownPanel.Buttons.REMOVE, false);
|
||||
p.setEnabled(AddRemoveUpDownPanel.Buttons.UP, false);
|
||||
p.setEnabled(AddRemoveUpDownPanel.Buttons.DOWN, false);
|
||||
}
|
||||
p.setEnabled(AddRemoveUpDownPanel.Buttons.ADD, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static TableToolbarDecorator createDecorator(JTable table) {
|
||||
return new TableToolbarDecorator(table);
|
||||
public static ToolbarDecorator createDecorator(JTable table) {
|
||||
return new ToolbarDecorator(table);
|
||||
}
|
||||
|
||||
public TableToolbarDecorator disableAddAction() {
|
||||
public static ToolbarDecorator createDecorator(JList list) {
|
||||
return new ToolbarDecorator(list);
|
||||
}
|
||||
|
||||
public ToolbarDecorator disableAddAction() {
|
||||
myAddActionEnabled = false;
|
||||
return this;
|
||||
}
|
||||
|
||||
public TableToolbarDecorator disableRemoveAction() {
|
||||
public ToolbarDecorator disableRemoveAction() {
|
||||
myRemoveActionEnabled = false;
|
||||
return this;
|
||||
}
|
||||
|
||||
public TableToolbarDecorator disableUpAction() {
|
||||
public ToolbarDecorator disableUpAction() {
|
||||
myUpActionEnabled = false;
|
||||
return this;
|
||||
}
|
||||
|
||||
public TableToolbarDecorator disableDownAction() {
|
||||
public ToolbarDecorator disableDownAction() {
|
||||
myDownActionEnabled = false;
|
||||
return this;
|
||||
}
|
||||
|
||||
public TableToolbarDecorator setToolbarBorder(Border border) {
|
||||
public ToolbarDecorator setToolbarBorder(Border border) {
|
||||
myBorder = border;
|
||||
return this;
|
||||
}
|
||||
|
||||
public TableToolbarDecorator setLineBorder(int top, int left, int bottom, int right) {
|
||||
public ToolbarDecorator setLineBorder(int top, int left, int bottom, int right) {
|
||||
return setToolbarBorder(new CustomLineBorder(top, left, bottom, right));
|
||||
}
|
||||
|
||||
public TableToolbarDecorator addExtraAction(AnActionButton action) {
|
||||
public ToolbarDecorator addExtraAction(AnActionButton action) {
|
||||
myExtraActions.add(action);
|
||||
return this;
|
||||
}
|
||||
|
||||
public TableToolbarDecorator setToolbarPosition(ActionToolbarPosition position) {
|
||||
public ToolbarDecorator setToolbarPosition(ActionToolbarPosition position) {
|
||||
myToolbarPosition = position;
|
||||
return this;
|
||||
}
|
||||
|
||||
public TableToolbarDecorator setAddAction(Runnable action) {
|
||||
public ToolbarDecorator setAddAction(Runnable action) {
|
||||
myAddActionEnabled = action != null;
|
||||
myAddAction = action;
|
||||
return this;
|
||||
}
|
||||
|
||||
public TableToolbarDecorator setRemoveAction(Runnable action) {
|
||||
public ToolbarDecorator setRemoveAction(Runnable action) {
|
||||
myRemoveActionEnabled = action != null;
|
||||
myRemoveAction = action;
|
||||
return this;
|
||||
}
|
||||
|
||||
public TableToolbarDecorator setUpAction(Runnable action) {
|
||||
public ToolbarDecorator setUpAction(Runnable action) {
|
||||
myUpActionEnabled = action != null;
|
||||
myUpAction = action;
|
||||
return this;
|
||||
}
|
||||
|
||||
public TableToolbarDecorator setDownAction(Runnable action) {
|
||||
public ToolbarDecorator setDownAction(Runnable action) {
|
||||
myDownActionEnabled = action != null;
|
||||
myDownAction = action;
|
||||
return this;
|
||||
}
|
||||
@@ -226,26 +284,46 @@ public class TableToolbarDecorator {
|
||||
public JPanel createPanel() {
|
||||
final AddRemoveUpDownPanel.Buttons[] buttons = getButtons();
|
||||
myPanel = new AddRemoveUpDownPanel(createListener(),
|
||||
myTable,
|
||||
myTable == null ? myList : myTable,
|
||||
myToolbarPosition == ActionToolbarPosition.TOP || myToolbarPosition == ActionToolbarPosition.BOTTOM,
|
||||
myExtraActions.toArray(new AnActionButton[myExtraActions.size()]),
|
||||
buttons);
|
||||
myPanel.setBorder(myBorder);
|
||||
final JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myTable);
|
||||
final JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myTable == null ? myList : myTable);
|
||||
scrollPane.setBorder(IdeBorderFactory.createEmptyBorder(0));
|
||||
final JPanel panel = new JPanel(new BorderLayout());
|
||||
final JPanel panel = new JPanel(new BorderLayout()) {
|
||||
@Override
|
||||
public void addNotify() {
|
||||
super.addNotify();
|
||||
if (myList != null) {
|
||||
updateListButtons(myList, myPanel);
|
||||
}
|
||||
if (myTable != null && myTableModel instanceof EditableModel) {
|
||||
updateTableButtons(myTable, (EditableModel)myTableModel, myPanel);
|
||||
}
|
||||
}
|
||||
};
|
||||
panel.add(scrollPane, BorderLayout.CENTER);
|
||||
panel.add(myPanel, getPlacement());
|
||||
if (myModel instanceof EditableModel && buttons.length > 0) {
|
||||
updateButtons(myTable, (EditableModel)myModel, myPanel);
|
||||
if (myTableModel instanceof EditableModel && buttons.length > 0) {
|
||||
updateTableButtons(myTable, (EditableModel)myTableModel, myPanel);
|
||||
|
||||
if (myUpAction != null && myUpActionEnabled && myDownAction != null && myDownActionEnabled) {
|
||||
TableRowsDnDSupport.install(myTable, (EditableModel)myModel);
|
||||
TableRowsDnDSupport.install(myTable, (EditableModel)myTableModel);
|
||||
}
|
||||
myTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
|
||||
@Override
|
||||
public void valueChanged(ListSelectionEvent e) {
|
||||
updateButtons(myTable, (EditableModel)myModel, myPanel);
|
||||
updateTableButtons(myTable, (EditableModel)myTableModel, myPanel);
|
||||
}
|
||||
});
|
||||
}
|
||||
if (myList != null) {
|
||||
updateListButtons(myList, myPanel);
|
||||
myList.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
|
||||
@Override
|
||||
public void valueChanged(ListSelectionEvent e) {
|
||||
updateListButtons(myList, myPanel);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.help.impl;
|
||||
|
||||
import com.intellij.ide.ui.UISettings;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import sun.swing.SwingUtilities2;
|
||||
|
||||
@@ -55,6 +56,7 @@ class IdeaJHelpContentViewer extends JHelpContentViewer{
|
||||
if (editorPane != null) {
|
||||
editorPane.putClientProperty(SwingUtilities2.AA_TEXT_PROPERTY_KEY, SwingUtilities2.AATextInfo.getAATextInfo(true));
|
||||
}
|
||||
UISettings.setupAntialiasing(g);
|
||||
super.paint(g);
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -30,8 +30,8 @@ import com.intellij.refactoring.util.CanonicalTypes;
|
||||
import com.intellij.refactoring.util.CommonRefactoringUtil;
|
||||
import com.intellij.ui.EditableRowTable;
|
||||
import com.intellij.ui.EditorTextField;
|
||||
import com.intellij.ui.TableToolbarDecorator;
|
||||
import com.intellij.ui.TableUtil;
|
||||
import com.intellij.ui.ToolbarDecorator;
|
||||
import com.intellij.ui.table.JBTable;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
@@ -196,7 +196,7 @@ public class GrChangeSignatureDialog extends RefactoringDialog {
|
||||
myExceptionsTable = new JBTable(myExceptionTableModel);
|
||||
myExceptionsTable.setPreferredScrollableViewportSize(new Dimension(200, myExceptionsTable.getRowHeight() * 8));
|
||||
|
||||
myExceptionsButtonPanel = TableToolbarDecorator.createDecorator(myExceptionsTable).createPanel();
|
||||
myExceptionsButtonPanel = ToolbarDecorator.createDecorator(myExceptionsTable).createPanel();
|
||||
|
||||
myExceptionsTable.getColumnModel().getColumn(0).setCellRenderer(new CodeFragmentTableCellRenderer(myProject));
|
||||
myExceptionsTable.getColumnModel().getColumn(0).setCellEditor(new JavaCodeFragmentTableCellEditor(myProject));
|
||||
|
||||
Reference in New Issue
Block a user