/*
(comment
*******************************************************************************
* Copyright (c) ThorTech, L.L.C.. All rights reserved.
* The use and distribution terms for this software are covered by the
* GNU General Public License, version 2
* (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) with classpath
* exception (http://www.gnu.org/software/classpath/license.html)
* which can be found in the file GPL-2.0+ClasspathException.txt at the root
* of this distribution.
* By using this software in any fashion, you are agreeing to be bound by
* the terms of this license.
* You must not remove this notice, or any other, from this software.
*******************************************************************************
* Author: Narayan Singhal
*******************************************************************************
)
*/
package org.enclojure.ide.nb.actions;
import clojure.lang.RT;
import clojure.lang.Var;
import javax.swing.JEditorPane;
import org.openide.cookies.EditorCookie;
import org.openide.nodes.Node;
import org.openide.util.Exceptions;
import org.openide.util.HelpCtx;
import org.openide.util.NbBundle;
import org.openide.util.actions.CookieAction;
public final class SelectOuterExpr extends CookieAction {
static final Var selectCurrentFormFn =
RT.var("org.enclojure.ide.navigator.token-nav", "select-current-form");
protected void performAction(Node[] activatedNodes) {
EditorCookie editorCookie = activatedNodes[0].getLookup().lookup(EditorCookie.class);
if(editorCookie != null)
{
JEditorPane pane = editorCookie.getOpenedPanes()[0];
try {
selectCurrentFormFn.invoke(pane);
} catch (Exception ex) {
Exceptions.printStackTrace(ex);
}
}
}
protected int mode() {
return CookieAction.MODE_EXACTLY_ONE;
}
public String getName() {
return NbBundle.getMessage(SelectOuterExpr.class, "CTL_SelectOuterExpr");
}
protected Class[] cookieClasses() {
return new Class[]{EditorCookie.class};
}
@Override
protected void initialize() {
super.initialize();
putValue("noIconInMenu", Boolean.TRUE);
}
public HelpCtx getHelpCtx() {
return HelpCtx.DEFAULT_HELP;
}
@Override
protected boolean asynchronous() {
return false;
}
}