KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > catalog > AddCatalogEntryAction


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * 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-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

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 /**
29  * AddCatalogEntryAction.java
30  *
31  * Created on May 31, 2005
32  * @author mkuchtiak
33  */

34 public class AddCatalogEntryAction extends NodeAction {
35
36     /** Creates a new instance of AddCatalogEntryAction */
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")); //NOI18N
45
//dd.setHelpCtx(new HelpCtx(CatalogMounterPanel.class));
46
panel.setEnclosingDesc(dd);
47         java.awt.Dialog JavaDoc 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()); //NOI18N
53
else
54                 catalog.registerCatalogEntry("SYSTEM:"+panel.getSystemId(), panel.getUri()); //NOI18N
55
}
56     }
57
58     protected boolean enable(org.openide.nodes.Node[] activatedNodes) {
59         if (activatedNodes.length>0) {
60             Object JavaDoc 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 JavaDoc getName() {
75         return NbBundle.getMessage(AddCatalogEntryAction.class,"TXT_AddCatalogEntry");
76     }
77     
78 }
79
Popular Tags