(no message)

This commit is contained in:
Eugene Vigdorchik
2005-02-17 13:41:24 +03:00
parent 424eab86d4
commit 685c93f58c
2 changed files with 38 additions and 22 deletions
@@ -30,6 +30,7 @@ import com.intellij.ui.*;
import com.intellij.util.Alarm;
import com.intellij.util.IncorrectOperationException;
import com.intellij.util.ui.Table;
import com.intellij.util.ui.Tree;
import javax.swing.*;
import javax.swing.event.TableModelEvent;
@@ -64,6 +65,9 @@ public class ChangeSignatureDialog extends RefactoringDialog {
private Set<PsiMethod> myMethodsToPropagateParameters = null;
private Set<PsiMethod> myMethodsToPropagateExceptions = null;
private Tree myExceptionPropagationTree;
private Tree myParameterPropagationTree;
public ChangeSignatureDialog(Project project, PsiMethod method, boolean allowDelegation) {
super(project, true);
myProject = project;
@@ -164,9 +168,10 @@ public class ChangeSignatureDialog extends RefactoringDialog {
myPropagateParamChangesButton = new JButton("Propagate Parameters");
myPropagateParamChangesButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
new CallerChooser(myMethod, "Select New Parameters Propagation End Points") {
new CallerChooser(myMethod, "Select Methods To Propagate New Parameters", myParameterPropagationTree) {
protected void callersChosen(Set<PsiMethod> callers) {
myMethodsToPropagateParameters = callers;
myParameterPropagationTree = getTree();
}
}.show();
}
@@ -176,9 +181,10 @@ public class ChangeSignatureDialog extends RefactoringDialog {
myPropagateExnChangesButton = new JButton("Propagate Exceptions");
myPropagateExnChangesButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
new CallerChooser(myMethod, "Select New Thrown Exceptions Propagation End Points") {
new CallerChooser(myMethod, "Select Methods To Propagate New Exceptions", myExceptionPropagationTree) {
protected void callersChosen(Set<PsiMethod> callers) {
myMethodsToPropagateExceptions = callers;
myExceptionPropagationTree = getTree();
}
}.show();
}
@@ -35,11 +35,17 @@ public abstract class CallerChooser extends DialogWrapper {
private Alarm myAlarm = new Alarm();
private MethodNode myRoot;
private Project myProject;
private Tree myTree;
public CallerChooser(final PsiMethod method, String title) {
public Tree getTree() {
return myTree;
}
public CallerChooser(final PsiMethod method, String title, Tree previousTree) {
super(true);
myMethod = method;
myProject = myMethod.getProject();
myTree = previousTree;
setTitle(title);
init();
}
@@ -47,31 +53,19 @@ public abstract class CallerChooser extends DialogWrapper {
protected JComponent createCenterPanel() {
Splitter splitter = new Splitter(false, ((float)0.6));
JPanel result = new JPanel(new BorderLayout());
final Tree tree = createTree();
JScrollPane scrollPane = new JScrollPane(tree);
if (myTree == null) {
myTree = createTree();
} else {
final CheckedTreeNode root = (CheckedTreeNode)myTree.getModel().getRoot();
myRoot = (MethodNode)root.getFirstChild();
}
JScrollPane scrollPane = new JScrollPane(myTree);
splitter.setFirstComponent(scrollPane);
myEditorField = createCallSitesViewer();
myEditorField.setText(getText(myMethod));
myEditorField.setBorder(IdeBorderFactory.createBorder());
splitter.setSecondComponent(myEditorField);
result.add(splitter);
tree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() {
public void valueChanged(TreeSelectionEvent e) {
final TreePath path = e.getPath();
if (path != null) {
MethodNode node = (MethodNode)path.getLastPathComponent();
final PsiMethod method = node.getMethod();
myAlarm.cancelAllRequests();
myAlarm.addRequest(new Runnable() {
public void run() {
myEditorField.setText(getText(method));
}
}, 300);
}
}
});
return result;
}
@@ -128,6 +122,22 @@ public abstract class CallerChooser extends DialogWrapper {
};
tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
tree.getSelectionModel().setSelectionPath(new TreePath(myRoot.getPath()));
tree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() {
public void valueChanged(TreeSelectionEvent e) {
final TreePath path = e.getPath();
if (path != null) {
MethodNode node = (MethodNode)path.getLastPathComponent();
final PsiMethod method = node.getMethod();
myAlarm.cancelAllRequests();
myAlarm.addRequest(new Runnable() {
public void run() {
myEditorField.setText(getText(method));
}
}, 300);
}
}
});
return tree;
}