mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-06 11:50:54 +07:00
new action buttons
This commit is contained in:
@@ -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.
|
||||
@@ -18,15 +18,17 @@ package com.intellij.refactoring.changeClassSignature;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.help.HelpManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.VerticalFlowLayout;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.refactoring.HelpID;
|
||||
import com.intellij.refactoring.RefactoringBundle;
|
||||
import com.intellij.refactoring.ui.JavaCodeFragmentTableCellEditor;
|
||||
import com.intellij.refactoring.ui.CodeFragmentTableCellRenderer;
|
||||
import com.intellij.refactoring.ui.JavaCodeFragmentTableCellEditor;
|
||||
import com.intellij.refactoring.ui.RefactoringDialog;
|
||||
import com.intellij.refactoring.ui.StringTableCellEditor;
|
||||
import com.intellij.refactoring.util.CommonRefactoringUtil;
|
||||
import com.intellij.ui.*;
|
||||
import com.intellij.ui.border.CustomLineBorder;
|
||||
import com.intellij.usageView.UsageViewUtil;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.ui.Table;
|
||||
@@ -105,13 +107,16 @@ public class ChangeClassSignatureDialog extends RefactoringDialog {
|
||||
myTable.setFocusCycleRoot(true);
|
||||
|
||||
|
||||
JPanel panel = new JPanel(new BorderLayout());
|
||||
panel.setBorder(IdeBorderFactory.createTitledBorder(RefactoringBundle.message("changeClassSignature.parameters.panel.border.title")));
|
||||
JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myTable);
|
||||
|
||||
panel.add(scrollPane, BorderLayout.CENTER);
|
||||
final JPanel buttonsTable = EditableRowTable.createButtonsTable(myTable, myTableModel, true);
|
||||
panel.add(buttonsTable, BorderLayout.EAST);
|
||||
final JPanel panel = new JPanel(new VerticalFlowLayout(VerticalFlowLayout.TOP, 0, 0, true, false));
|
||||
panel.add(SeparatorFactory.createSeparator(RefactoringBundle.message("changeClassSignature.parameters.panel.border.title"), myTable));
|
||||
panel.add(EditableRowTable.wrapToTableWithButtons(myTable, myTableModel, new CustomLineBorder(0, 1, 1, 1)));
|
||||
//JPanel panel = new JPanel(new BorderLayout());
|
||||
//panel.setBorder(IdeBorderFactory.createTitledBorder(RefactoringBundle.message("changeClassSignature.parameters.panel.border.title")));
|
||||
//JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myTable);
|
||||
//
|
||||
//panel.add(scrollPane, BorderLayout.CENTER);
|
||||
//final JPanel buttonsTable = EditableRowTable.createButtonsTable(myTable, myTableModel, true);
|
||||
//panel.add(buttonsTable, BorderLayout.EAST);
|
||||
return panel;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2010 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.
|
||||
@@ -39,7 +39,9 @@ import com.intellij.util.VisibilityUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* User: anna
|
||||
@@ -246,13 +248,14 @@ public class JavaChangeSignatureDetector implements LanguageChangeSignatureDetec
|
||||
createChangeSignatureProcessor(info, method).run();
|
||||
return true;
|
||||
}
|
||||
final JavaMethodDescriptor descriptor = new JavaMethodDescriptor(info.getMethod()) {
|
||||
@Override
|
||||
public String getReturnTypeText() {
|
||||
return info.getNewReturnType().getTypeText();
|
||||
}
|
||||
};
|
||||
final JavaChangeSignatureDialog dialog =
|
||||
new JavaChangeSignatureDialog(method.getProject(), new JavaMethodDescriptor(info.getMethod()) {
|
||||
@Override
|
||||
public String getReturnTypeText() {
|
||||
return info.getNewReturnType().getTypeText();
|
||||
}
|
||||
}, true, method) {
|
||||
new JavaChangeSignatureDialog(method.getProject(), descriptor, true, method) {
|
||||
protected BaseRefactoringProcessor createRefactoringProcessor() {
|
||||
return createChangeSignatureProcessor(info, method);
|
||||
}
|
||||
|
||||
@@ -39,8 +39,7 @@ import com.intellij.refactoring.util.RefactoringMessageUtil;
|
||||
import com.intellij.refactoring.util.RefactoringUtil;
|
||||
import com.intellij.ui.AnActionButton;
|
||||
import com.intellij.ui.EditableRowTable;
|
||||
import com.intellij.ui.IdeBorderFactory;
|
||||
import com.intellij.ui.ScrollPaneFactory;
|
||||
import com.intellij.ui.border.CustomLineBorder;
|
||||
import com.intellij.ui.table.JBTable;
|
||||
import com.intellij.ui.treeStructure.Tree;
|
||||
import com.intellij.util.Consumer;
|
||||
@@ -54,7 +53,6 @@ import org.jetbrains.annotations.Nullable;
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.TableModelEvent;
|
||||
import javax.swing.event.TableModelListener;
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@@ -98,12 +96,19 @@ public class JavaChangeSignatureDialog extends ChangeSignatureDialogBase<Paramet
|
||||
}
|
||||
|
||||
protected boolean mayPropagateExceptions() {
|
||||
final ThrownExceptionInfo[] thrownExceptions = myExceptionsModel.getThrownExceptions();
|
||||
final ThrownExceptionInfo[] exceptions = myExceptionsModel.getThrownExceptions();
|
||||
final PsiClassType[] types = myMethod.getMethod().getThrowsList().getReferencedTypes();
|
||||
if (thrownExceptions.length <= types.length) return false;
|
||||
for (int i = 0; i < types.length; i++) {
|
||||
if (thrownExceptions[i].getOldIndex() != i) return false;
|
||||
|
||||
if (exceptions.length <= types.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < types.length; i++) {
|
||||
if (exceptions[i].getOldIndex() != i) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -127,15 +132,6 @@ public class JavaChangeSignatureDialog extends ChangeSignatureDialogBase<Paramet
|
||||
}
|
||||
});
|
||||
table.getColumnModel().getColumn(0).setCellEditor(cellEditor);
|
||||
final JPanel panel = new JPanel(new BorderLayout());
|
||||
final JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(table);
|
||||
final JPanel tablePanel = new JPanel(new BorderLayout());
|
||||
tablePanel.add(scrollPane, BorderLayout.CENTER);
|
||||
|
||||
tablePanel.setBorder(IdeBorderFactory.createEmptyBorder(4));
|
||||
panel.add(tablePanel, BorderLayout.CENTER);
|
||||
|
||||
table.setPreferredScrollableViewportSize(new Dimension(450, table.getRowHeight() * 8));
|
||||
table.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||
table.getSelectionModel().setSelectionInterval(0, 0);
|
||||
table.setSurrendersFocusOnKeystroke(true);
|
||||
@@ -151,18 +147,21 @@ public class JavaChangeSignatureDialog extends ChangeSignatureDialogBase<Paramet
|
||||
myExceptionPropagationTree = chooser.get().getTree();
|
||||
}
|
||||
};
|
||||
chooser.set(
|
||||
new JavaCallerChooser(myMethod.getMethod(), myProject, RefactoringBundle.message("changeSignature.exception.caller.chooser"),
|
||||
myExceptionPropagationTree, callback));
|
||||
chooser.set(new JavaCallerChooser(myMethod.getMethod(),
|
||||
myProject,
|
||||
RefactoringBundle.message("changeSignature.exception.caller.chooser"),
|
||||
myExceptionPropagationTree,
|
||||
callback));
|
||||
chooser.get().show();
|
||||
}
|
||||
};
|
||||
myPropExceptionsButton.setShortcut(KeyboardShortcut.fromString("alt X"));
|
||||
|
||||
|
||||
final JPanel buttonsPanel = EditableRowTable.createButtonsTable(table, myExceptionsModel, false, true, false, myPropExceptionsButton);
|
||||
|
||||
panel.add(buttonsPanel, BorderLayout.EAST);
|
||||
final JPanel panel = EditableRowTable.wrapToTableWithButtons(table,
|
||||
myExceptionsModel,
|
||||
new CustomLineBorder(1,0,0,0),
|
||||
myPropExceptionsButton);
|
||||
|
||||
myExceptionsModel.addTableModelListener(new TableModelListener() {
|
||||
public void tableChanged(TableModelEvent e) {
|
||||
|
||||
@@ -45,6 +45,7 @@ import com.intellij.refactoring.RefactoringBundle;
|
||||
import com.intellij.refactoring.ui.*;
|
||||
import com.intellij.refactoring.util.CommonRefactoringUtil;
|
||||
import com.intellij.ui.*;
|
||||
import com.intellij.ui.border.CustomLineBorder;
|
||||
import com.intellij.ui.table.TableView;
|
||||
import com.intellij.ui.treeStructure.Tree;
|
||||
import com.intellij.util.Alarm;
|
||||
@@ -380,27 +381,16 @@ public abstract class ChangeSignatureDialogBase<P extends ParameterInfo, M exten
|
||||
};
|
||||
UIUtil.setTableDecorationEnabled(myParametersTable);
|
||||
myParametersTable.setCellSelectionEnabled(true);
|
||||
JPanel panel = new JPanel(new BorderLayout());
|
||||
panel.setBorder(IdeBorderFactory.createTitledBorder(RefactoringBundle.message("parameters.border.title")));
|
||||
|
||||
JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myParametersTable);
|
||||
|
||||
JPanel tablePanel = new JPanel(new BorderLayout());
|
||||
tablePanel.add(scrollPane, BorderLayout.CENTER);
|
||||
|
||||
tablePanel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
|
||||
panel.add(tablePanel, BorderLayout.CENTER);
|
||||
|
||||
myParametersTable.setPreferredScrollableViewportSize(new Dimension(450, myParametersTable.getRowHeight() * 8));
|
||||
myParametersTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||
myParametersTable.getSelectionModel().setSelectionInterval(0, 0);
|
||||
myParametersTable.setSurrendersFocusOnKeystroke(true);
|
||||
myPropagateParamChangesButton.setShortcut(KeyboardShortcut.fromString("alt G"));
|
||||
final JPanel buttonsPanel = EditableRowTable.createButtonsTable(myParametersTable, myParametersTableModel,
|
||||
false, true, false, myPropagateParamChangesButton);
|
||||
final JPanel buttonsPanel = EditableRowTable.wrapToTableWithButtons(myParametersTable,
|
||||
myParametersTableModel,
|
||||
new CustomLineBorder(1, 0, 0, 0),
|
||||
myPropagateParamChangesButton);
|
||||
myPropagateParamChangesButton.setEnabled(false);
|
||||
myPropagateParamChangesButton.setVisible(false);
|
||||
panel.add(buttonsPanel, BorderLayout.EAST);
|
||||
|
||||
myParametersTableModel.addTableModelListener(
|
||||
new TableModelListener() {
|
||||
@@ -411,8 +401,7 @@ public abstract class ChangeSignatureDialogBase<P extends ParameterInfo, M exten
|
||||
);
|
||||
|
||||
customizeParametersTable(myParametersTable);
|
||||
|
||||
return panel;
|
||||
return buttonsPanel;
|
||||
}
|
||||
|
||||
protected void customizeParametersTable(TableView<ParameterTableModelItemBase<P>> table) {
|
||||
@@ -425,7 +414,7 @@ public abstract class ChangeSignatureDialogBase<P extends ParameterInfo, M exten
|
||||
panel.add(SeparatorFactory.createSeparator(RefactoringBundle.message("signature.preview.border.title"), null), BorderLayout.NORTH);
|
||||
panel.add(mySignatureArea, BorderLayout.CENTER);
|
||||
mySignatureArea.setFont(EditorColorsManager.getInstance().getGlobalScheme().getFont(EditorFontType.PLAIN));
|
||||
mySignatureArea.setPreferredSize(new Dimension(-1, 130));
|
||||
//mySignatureArea.setPreferredSize(new Dimension(-1, 130));
|
||||
mySignatureArea.setBackground(EditorColorsManager.getInstance().getGlobalScheme().getColor(EditorColors.CARET_ROW_COLOR));
|
||||
mySignatureArea.addFocusListener(new FocusAdapter() {
|
||||
@Override
|
||||
|
||||
@@ -16,12 +16,12 @@
|
||||
package com.intellij.ui;
|
||||
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.ui.VerticalFlowLayout;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.util.PlatformIcons;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
@@ -38,10 +38,10 @@ public class AddRemoveUpDownPanel extends JPanel {
|
||||
|
||||
Icon getIcon() {
|
||||
switch (this) {
|
||||
case ADD: return PlatformIcons.ADD_ICON;
|
||||
case REMOVE: return PlatformIcons.DELETE_ICON;
|
||||
case UP: return PlatformIcons.MOVE_UP_ICON;
|
||||
case DOWN: return PlatformIcons.MOVE_DOWN_ICON;
|
||||
case ADD: return PlatformIcons.TABLE_ADD_ROW;
|
||||
case REMOVE: return PlatformIcons.TABLE_REMOVE_ROW;
|
||||
case UP: return PlatformIcons.TABLE_MOVE_ROW_UP;
|
||||
case DOWN: return PlatformIcons.TABLE_MOVE_ROW_DOWN;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -83,7 +83,7 @@ public class AddRemoveUpDownPanel extends JPanel {
|
||||
|
||||
public AddRemoveUpDownPanel(Listener listener, @Nullable JComponent contentPane, boolean isHorizontal,
|
||||
@Nullable AnActionButton[] additionalActions, Buttons... buttons) {
|
||||
super(new VerticalFlowLayout(VerticalFlowLayout.TOP, 0, 0, false, false));
|
||||
super(new BorderLayout());
|
||||
AnActionButton[] actions = new AnActionButton[buttons.length];
|
||||
for (int i = 0; i < buttons.length; i++) {
|
||||
Buttons button = buttons[i];
|
||||
@@ -103,12 +103,12 @@ public class AddRemoveUpDownPanel extends JPanel {
|
||||
final ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN,
|
||||
new DefaultActionGroup(myActions),
|
||||
isHorizontal);
|
||||
add(toolbar.getComponent());
|
||||
toolbar.getComponent().setBorder(null);
|
||||
add(toolbar.getComponent(), BorderLayout.CENTER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addNotify() {
|
||||
super.addNotify();
|
||||
final JRootPane pane = getRootPane();
|
||||
for (AnActionButton button : myActions) {
|
||||
final Shortcut shortcut = button.getShortcut();
|
||||
@@ -116,6 +116,7 @@ public class AddRemoveUpDownPanel extends JPanel {
|
||||
button.registerCustomShortcutSet(new CustomShortcutSet(shortcut), pane);
|
||||
}
|
||||
}
|
||||
super.addNotify(); // call after all to construct actions tooltips properly
|
||||
}
|
||||
|
||||
public void setEnabled(Buttons button, boolean enabled) {
|
||||
|
||||
@@ -16,8 +16,10 @@
|
||||
package com.intellij.ui;
|
||||
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.Border;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
import java.awt.*;
|
||||
@@ -113,7 +115,10 @@ public class EditableRowTable {
|
||||
}
|
||||
};
|
||||
|
||||
if (!iconsOnly) {
|
||||
if (iconsOnly) {
|
||||
p.set(new AddRemoveUpDownPanel(listener, table, isHorizontal, actions, AddRemoveUpDownPanel.Buttons.ALL));
|
||||
panel.add(p.get(), BorderLayout.NORTH);
|
||||
} else {
|
||||
addButton.set(new JButton());
|
||||
addButton.get().setText(addMnemonics ? UIBundle.message("row.add") : UIBundle.message("row.add.without.mnemonic"));
|
||||
addButton.get().setDefaultCapable(false);
|
||||
@@ -159,9 +164,6 @@ public class EditableRowTable {
|
||||
});
|
||||
gbConstraints.weighty = 1;
|
||||
panel.add(new JPanel(), gbConstraints);
|
||||
} else {
|
||||
p.set(new AddRemoveUpDownPanel(listener, table, isHorizontal, actions, AddRemoveUpDownPanel.Buttons.ALL));
|
||||
panel.add(p.get(), BorderLayout.NORTH);
|
||||
}
|
||||
|
||||
table.getSelectionModel().addListSelectionListener(
|
||||
@@ -215,4 +217,17 @@ public class EditableRowTable {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static JPanel wrapToTableWithButtons(final JTable table,
|
||||
final RowEditableTableModel tableModel,
|
||||
@Nullable Border buttonsBorder,
|
||||
final AnActionButton... buttons) {
|
||||
final JPanel buttonsPanel = createButtonsTable(table, tableModel, true, true, true, buttons);
|
||||
buttonsPanel.setBorder(buttonsBorder);
|
||||
final JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(table);
|
||||
final JPanel panel = new JPanel(new BorderLayout()/*new VerticalFlowLayout(VerticalFlowLayout.TOP, 0, 0, true, true)*/);
|
||||
panel.add(scrollPane, BorderLayout.CENTER);
|
||||
panel.add(buttonsPanel, BorderLayout.SOUTH);
|
||||
return panel;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user