KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > autoupdate > catalog > ModuleCatalogAction


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.autoupdate.catalog;
21
22 import java.awt.Dialog JavaDoc;
23 import java.awt.event.ActionEvent JavaDoc;
24 import java.awt.event.ActionListener JavaDoc;
25 import java.lang.ref.Reference JavaDoc;
26 import java.lang.ref.WeakReference JavaDoc;
27 import javax.swing.JButton JavaDoc;
28 import org.netbeans.modules.autoupdate.Wizard;
29 import org.openide.DialogDescriptor;
30 import org.openide.DialogDisplayer;
31 import org.openide.awt.Mnemonics;
32 import org.openide.util.HelpCtx;
33 import org.openide.util.NbBundle;
34 import org.openide.util.actions.CallableSystemAction;
35 /**
36  * PENDING
37  * @author Jiri Rechtacek
38  */

39 public class ModuleCatalogAction extends CallableSystemAction {
40
41     /** Weak reference to the dialog showing singleton Module Catalog. */
42     static private Reference JavaDoc dialogWRef = new WeakReference JavaDoc (null);
43     
44     public ModuleCatalogAction() {
45         putValue("noIconInMenu", Boolean.TRUE); //NOI18N
46
}
47     
48     public void performAction () {
49         
50         Dialog JavaDoc dialog = (Dialog JavaDoc) dialogWRef.get ();
51
52         if (dialog == null || ! dialog.isShowing ()) {
53             
54             JButton JavaDoc closeOption = new JButton JavaDoc ();
55             Mnemonics.setLocalizedText (closeOption, NbBundle.getBundle (ModuleCatalogAction.class).getString ("BTN_ModuleCatalog_CloseOption")); // NOI18N
56

57             DialogDescriptor dd = new DialogDescriptor (ModuleSelectionPanel.getGUI (true),
58                                     NbBundle.getMessage (ModuleCatalogAction.class, "LBL_ModuleCatalogName"), // NOI18N
59
false,
60                                     new Object JavaDoc [] { closeOption },
61                                     closeOption,
62                                     DialogDescriptor.DEFAULT_ALIGN,
63                                     new HelpCtx (ModuleSelectionPanel.class),
64                                     null,
65                                     true);
66             JButton JavaDoc updateOption = new JButton JavaDoc ();
67         Mnemonics.setLocalizedText (updateOption, NbBundle.getBundle (ModuleCatalogAction.class).getString ("BTN_ModuleSelectionPanel_UpdateButton")); // NOI18N
68
updateOption.addActionListener (new ActionListener JavaDoc () {
69         public void actionPerformed (ActionEvent JavaDoc e) {
70             Wizard.go ();
71         }
72         });
73             closeOption.addActionListener (new ActionListener JavaDoc () {
74                 public void actionPerformed (ActionEvent JavaDoc e) {
75                     ModuleSelectionPanel.getGUI (false).setWaitingState (false, false);
76                 }
77             });
78             dd.setAdditionalOptions(new Object JavaDoc [] { updateOption });
79             dialog = DialogDisplayer.getDefault ().createDialog (dd);
80             dialogWRef = new WeakReference JavaDoc (dialog);
81             dialog.setVisible (true);
82             
83         } else {
84             dialog.toFront ();
85         }
86         
87     }
88     
89     protected boolean asynchronous() {
90         return false;
91     }
92
93     public String JavaDoc getName () {
94         return NbBundle.getMessage (ModuleCatalogAction.class, "LBL_ModuleCatalogAction"); // NOI18N
95
}
96
97     public HelpCtx getHelpCtx () {
98         return null;
99     }
100
101     /**
102      * Adding hint.
103      */

104     protected void initialize () {
105     super.initialize ();
106         putProperty (ModuleCatalogAction.SHORT_DESCRIPTION, NbBundle.getMessage (ModuleCatalogAction.class, "HINT_ModuleCatalogAction"));
107     }
108 }
109
Popular Tags