|
What this is
Other links
The source code/*
* Sun Public License Notice
*
* The contents of this file are subject to the Sun Public License
* Version 1.0 (the "License"). You may not use this file except in
* compliance with the License. A copy of the License is available at
* http://www.sun.com/
*
* The Original Code is NetBeans. The Initial Developer of the Original
* Code is Sun Microsystems, Inc. Portions Copyright 1997-2003 Sun
* Microsystems, Inc. All Rights Reserved.
*/
package org.netbeans.modules.refactoring.api.ui;
import java.awt.event.ActionEvent;
import javax.swing.Action;
import javax.swing.Icon;
import javax.swing.SwingUtilities;
import javax.swing.text.JTextComponent;
import javax.swing.text.TextAction;
import org.netbeans.jmi.javamodel.Element;
import org.netbeans.modules.javacore.internalapi.JavaMetamodel;
import org.netbeans.modules.refactoring.ui.RefactoringPanel;
import org.netbeans.api.mdr.MDRepository;
import org.netbeans.modules.java.JavaEditor;
import org.netbeans.modules.refactoring.classpath.RefactoringClassPathImplementation;
import org.netbeans.spi.java.classpath.ClassPathFactory;
import org.openide.cookies.EditorCookie;
import org.openide.loaders.DataObject;
import org.openide.loaders.DataShadow;
import org.openide.nodes.Node;
import org.openide.util.HelpCtx;
import org.openide.util.actions.NodeAction;
import org.openide.windows.TopComponent;
/** Generic superclass for refactoring actions.
* Subclasses should implement createRefactoringUI and enabled methods.
*
* @author Martin Matula
*/
public abstract class AbstractRefactoringAction extends NodeAction implements RefactoringAction, Runnable {
private Node[] activatedNodes;
private int caretPosition;
private static DelegateTextAction delegate = new DelegateTextAction();
/** Creates a new instance of AbstractRefactoringAction */
public AbstractRefactoringAction(String name, Icon icon) {
setName(name);
setIcon(icon);
}
public final String getName() {
return (String) getValue(Action.NAME);
}
protected void setName(String name) {
putValue(Action.NAME, name);
}
protected void setMnemonic(char m) {
putValue(Action.MNEMONIC_KEY, new Integer(m));
}
public final void performAction(Node[] n) {
processContext(n, delegate.getTextComponent());
run();
}
protected abstract boolean enabled(Node[] activatedNodes);
/** Should be implemented by subclasses to provide instance of RefactoringUI
* implementation for the implemented refactoring. The method should initialize
* the RefactoringUI implementation with the provided array of nodes and textComponent.
* @param nodes Array of activated nodes that the refactoring should be performed
* on.
* @param selectedElement org.netbeans.jmi.javamodel.Element at cursor position if the action is invoked in editor or
|
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.