01: /*
02: * The contents of this file are subject to the terms of the Common Development
03: * and Distribution License (the License). You may not use this file except in
04: * compliance with the License.
05: *
06: * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
07: * or http://www.netbeans.org/cddl.txt.
08: *
09: * When distributing Covered Code, include this CDDL Header Notice in each file
10: * and include the License file at http://www.netbeans.org/cddl.txt.
11: * If applicable, add the following below the CDDL Header, with the fields
12: * enclosed by brackets [] replaced by your own identifying information:
13: * "Portions Copyrighted [year] [name of copyright owner]"
14: *
15: * The Original Software is NetBeans. The Initial Developer of the Original
16: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
17: * Microsystems, Inc. All Rights Reserved.
18: */
19: package org.netbeans.modules.xslt.core.multiview;
20:
21: import org.netbeans.modules.xslt.core.XSLTDataEditorSupport;
22: import org.netbeans.modules.xslt.core.XSLTDataObject;
23: import org.openide.cookies.EditCookie;
24: import org.openide.cookies.OpenCookie;
25: import org.openide.nodes.Node;
26: import org.openide.util.HelpCtx;
27: import org.openide.util.NbBundle;
28: import org.openide.util.actions.NodeAction;
29:
30: /**
31: *
32: * @author Vitaly Bychkov
33: */
34: public class XsltDesignViewOpenAction extends NodeAction {
35:
36: private static final long serialVersionUID = 1L;
37:
38: protected void performAction(Node[] activatedNodes) {
39: if (activatedNodes == null || activatedNodes[0] == null) {
40: return;
41: }
42: XSLTDataObject dObj = activatedNodes[0].getLookup().lookup(
43: XSLTDataObject.class);
44: if (dObj != null) {
45: XSLTDataEditorSupport editorSupport = dObj
46: .getEditorSupport();
47: if (editorSupport.getOpenedPanes() == null
48: || editorSupport.getOpenedPanes().length == 0) {
49: editorSupport.open();
50: XsltMultiViewSupport support = XsltMultiViewSupport
51: .getInstance();
52: support.requestViewOpen(editorSupport);
53: } else {
54: editorSupport.open();
55: }
56: return;
57: }
58: // default to edit cookie
59: // EditCookie ec = activatedNodes[0].getCookie(EditCookie.class);
60: // if (ec != null) {
61: // ec.edit();
62: // }
63: }
64:
65: protected boolean enable(Node[] activatedNodes) {
66: if (activatedNodes == null || activatedNodes.length < 1
67: || activatedNodes[0] == null) {
68: return false;
69: }
70: XSLTDataObject dObj = activatedNodes[0].getLookup().lookup(
71: XSLTDataObject.class);
72: return dObj != null;
73: }
74:
75: public String getName() {
76: return NbBundle.getMessage(XsltDesignViewOpenAction.class,
77: "XsltDesignViewOpenAction_Name");
78: }
79:
80: public HelpCtx getHelpCtx() {
81: return HelpCtx.DEFAULT_HELP;
82: }
83:
84: @Override
85: protected boolean asynchronous() {
86: return false;
87: }
88: }
|