1 19 20 package org.netbeans.modules.autoupdate.catalog; 21 22 import java.awt.Dialog ; 23 import java.awt.event.ActionEvent ; 24 import java.awt.event.ActionListener ; 25 import java.lang.ref.Reference ; 26 import java.lang.ref.WeakReference ; 27 import javax.swing.JButton ; 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 39 public class ModuleCatalogAction extends CallableSystemAction { 40 41 42 static private Reference dialogWRef = new WeakReference (null); 43 44 public ModuleCatalogAction() { 45 putValue("noIconInMenu", Boolean.TRUE); } 47 48 public void performAction () { 49 50 Dialog dialog = (Dialog ) dialogWRef.get (); 51 52 if (dialog == null || ! dialog.isShowing ()) { 53 54 JButton closeOption = new JButton (); 55 Mnemonics.setLocalizedText (closeOption, NbBundle.getBundle (ModuleCatalogAction.class).getString ("BTN_ModuleCatalog_CloseOption")); 57 DialogDescriptor dd = new DialogDescriptor (ModuleSelectionPanel.getGUI (true), 58 NbBundle.getMessage (ModuleCatalogAction.class, "LBL_ModuleCatalogName"), false, 60 new Object [] { closeOption }, 61 closeOption, 62 DialogDescriptor.DEFAULT_ALIGN, 63 new HelpCtx (ModuleSelectionPanel.class), 64 null, 65 true); 66 JButton updateOption = new JButton (); 67 Mnemonics.setLocalizedText (updateOption, NbBundle.getBundle (ModuleCatalogAction.class).getString ("BTN_ModuleSelectionPanel_UpdateButton")); updateOption.addActionListener (new ActionListener () { 69 public void actionPerformed (ActionEvent e) { 70 Wizard.go (); 71 } 72 }); 73 closeOption.addActionListener (new ActionListener () { 74 public void actionPerformed (ActionEvent e) { 75 ModuleSelectionPanel.getGUI (false).setWaitingState (false, false); 76 } 77 }); 78 dd.setAdditionalOptions(new Object [] { updateOption }); 79 dialog = DialogDisplayer.getDefault ().createDialog (dd); 80 dialogWRef = new WeakReference (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 getName () { 94 return NbBundle.getMessage (ModuleCatalogAction.class, "LBL_ModuleCatalogAction"); } 96 97 public HelpCtx getHelpCtx () { 98 return null; 99 } 100 101 104 protected void initialize () { 105 super.initialize (); 106 putProperty (ModuleCatalogAction.SHORT_DESCRIPTION, NbBundle.getMessage (ModuleCatalogAction.class, "HINT_ModuleCatalogAction")); 107 } 108 } 109 | Popular Tags |