1 19 20 package org.netbeans.modules.xml.catalog; 21 22 import org.openide.util.NbBundle; 23 import org.openide.util.actions.NodeAction; 24 import org.netbeans.modules.xml.catalog.spi.CatalogWriter; 25 import org.openide.DialogDisplayer; 26 import org.openide.DialogDescriptor; 27 28 34 public class AddCatalogEntryAction extends NodeAction { 35 36 37 public AddCatalogEntryAction() {} 38 39 protected void performAction(org.openide.nodes.Node[] activatedNodes) { 40 CatalogNode node = (CatalogNode) activatedNodes[0].getCookie(CatalogNode.class); 41 CatalogWriter catalog = (CatalogWriter)node.getCatalogReader(); 42 CatalogEntryPanel panel = new CatalogEntryPanel(); 43 DialogDescriptor dd = new DialogDescriptor(panel, 44 Util.THIS.getString ("TITLE_addCatalogEntry")); panel.setEnclosingDesc(dd); 47 java.awt.Dialog dialog = DialogDisplayer.getDefault().createDialog(dd); 48 dd.setValid(false); 49 dialog.setVisible(true); 50 if (dd.getValue().equals(DialogDescriptor.OK_OPTION)) { 51 if (panel.isPublic()) 52 catalog.registerCatalogEntry("PUBLIC:"+panel.getPublicId(), panel.getUri()); else 54 catalog.registerCatalogEntry("SYSTEM:"+panel.getSystemId(), panel.getUri()); } 56 } 57 58 protected boolean enable(org.openide.nodes.Node[] activatedNodes) { 59 if (activatedNodes.length>0) { 60 Object node = activatedNodes[0].getCookie(CatalogNode.class); 61 if (node instanceof CatalogNode && ((CatalogNode)node).getCatalogReader() instanceof CatalogWriter) return true; 62 } 63 return false; 64 } 65 66 protected boolean asynchronous() { 67 return false; 68 } 69 70 public org.openide.util.HelpCtx getHelpCtx() { 71 return null; 72 } 73 74 public String getName() { 75 return NbBundle.getMessage(AddCatalogEntryAction.class,"TXT_AddCatalogEntry"); 76 } 77 78 } 79 | Popular Tags |