01: /*
02: * To change this template, choose Tools | Templates
03: * and open the template in the editor.
04: */
05: package org.netbeans.modules.xml.schema.actions;
06:
07: import java.awt.Dialog;
08: import org.netbeans.modules.xml.schema.SchemaDataObject;
09: import org.netbeans.modules.xml.schema.ui.basic.SchemaModelCookie;
10: import org.netbeans.modules.xml.schema.wizard.SampleXMLGeneratorWizardIterator;
11: import org.openide.DialogDisplayer;
12: import org.openide.filesystems.FileObject;
13: import org.openide.nodes.Node;
14: import org.openide.util.HelpCtx;
15: import org.openide.util.NbBundle;
16: import org.openide.util.actions.CookieAction;
17:
18: public final class GenerateXMLAction extends CookieAction {
19:
20: private static final Class[] COOKIE_ARRAY = new Class[] { SchemaModelCookie.class };
21:
22: protected void performAction(Node[] activatedNodes) {
23: assert activatedNodes.length == 1 : "Length of nodes array should be 1";
24:
25: if (activatedNodes[0] == null)
26: return;
27:
28: SchemaDataObject sdo = activatedNodes[0]
29: .getCookie(SchemaDataObject.class);
30: if (sdo == null)
31: return;
32: SampleXMLGeneratorWizardIterator wizard = new SampleXMLGeneratorWizardIterator(
33: sdo);
34: wizard.show();
35:
36: }
37:
38: protected int mode() {
39: return CookieAction.MODE_EXACTLY_ONE;
40: }
41:
42: public String getName() {
43: return NbBundle.getMessage(GenerateXMLAction.class,
44: "CTL_GenerateXMLAction");
45: }
46:
47: protected Class[] cookieClasses() {
48: return COOKIE_ARRAY;
49: }
50:
51: @Override
52: protected void initialize() {
53: super .initialize();
54: // see org.openide.util.actions.SystemAction.iconResource() Javadoc for more details
55: putValue("noIconInMenu", Boolean.TRUE);
56: }
57:
58: public HelpCtx getHelpCtx() {
59: return HelpCtx.DEFAULT_HELP;
60: }
61:
62: @Override
63: protected boolean asynchronous() {
64: return false;
65: }
66: }
|