1 19 20 package org.openide.actions; 21 22 23 import java.io.IOException ; 24 import java.util.Set ; 25 import org.openide.loaders.DataObject; 26 import org.openide.nodes.Node; 27 import org.openide.util.*; 28 import org.openide.util.actions.NodeAction; 29 30 38 @Deprecated 39 public class InstantiateAction extends NodeAction { 40 41 static final long serialVersionUID = 1482795804240508824L; 42 43 protected boolean enable (Node[] activatedNodes) { 44 if (activatedNodes.length != 1) return false; 45 DataObject obj = (DataObject)activatedNodes[0].getCookie (DataObject.class); 46 return obj != null && obj.isTemplate (); 47 } 48 49 protected void performAction (Node[] activatedNodes) { 50 DataObject obj = (DataObject)activatedNodes[0].getCookie (DataObject.class); 51 if (obj != null && obj.isTemplate ()) { 52 try { 53 instantiateTemplate (obj); 54 } catch (UserCancelException ex) { 55 } catch (IOException ex) { 58 Exceptions.printStackTrace(ex); 59 } 60 } 61 } 62 63 65 public String getName() { 66 return NbBundle.getMessage(org.openide.loaders.DataObject.class, "Instantiate"); 67 } 68 69 public HelpCtx getHelpCtx () { 70 return new HelpCtx (InstantiateAction.class); 71 } 72 73 82 public static Set <DataObject> instantiateTemplate(DataObject obj) 83 throws IOException { 84 return NewTemplateAction.getWizard (null).instantiate (obj); 86 } 87 } 88 | Popular Tags |