me.dsnet.quickopener.actions.AbstractFileContextAwareAction Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of nb-quickopener Show documentation
Show all versions of nb-quickopener Show documentation
<p>Sometimes while programming in NetBeans you want to explore a particular file that you are editing on the file
system browser, or maybe launch a command in a terminal to do something with it.</p>
<p>This plugins brings to your NetBeans six action, three of them always available and three of them available when
the selected node has a file assiociated with it.<br/>
In particular:<p><p><em>When the selection has a valid file</em></p>
<ul>
<li><strong>Open the default OS shell</strong> on the location of the file (or its folder) selected.</li>
<li><strong>Open the file system browser</strong> on the location of the file (or its folder) selected.</li>
<li><strong>Copy to the clipboard</strong> the path of the file selected.</li>
</ul>
<p><em>Always enabled:</em></p>
<ul>
<li><strong>Launch a shell command</strong> (with parameters, customizable on
preferences)</li>
<li><strong>FileSystem browser on any location</strong> (favorites, customizable on preferences)</li>
<li><strong>Open a shell on any location</strong> (favorites, customizable on preferences)</li>
</ul>
The newest version!
package me.dsnet.quickopener.actions;
import java.io.File;
import me.dsnet.quickopener.PathFinder;
import org.openide.loaders.DataObject;
import org.openide.nodes.Node;
import org.openide.util.HelpCtx;
import org.openide.util.actions.NodeAction;
public abstract class AbstractFileContextAwareAction extends NodeAction {
private File file;
protected File getFile() {
return file;
}
@Override
protected boolean asynchronous() {
return false;
}
@Override
public HelpCtx getHelpCtx() {
return HelpCtx.DEFAULT_HELP;
}
@Override
public abstract String getName();
@Override
protected boolean enable(Node[] activatedNodes) {
file = null;
if (null != activatedNodes && activatedNodes.length == 1) {
file = PathFinder.getActiveFile(activatedNodes[0].getLookup().lookup(DataObject.class), false);
}
return null != file;
}
@Override
protected abstract String iconResource();
@Override
protected abstract void performAction(Node[] activatedNodes);
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy