1 19 package org.netbeans.modules.ruby.rubyproject.gems; 20 21 import java.awt.Dialog ; 22 import java.io.File ; 23 24 import org.netbeans.modules.ruby.rubyproject.api.RubyInstallation; 25 import org.openide.DialogDescriptor; 26 import org.openide.DialogDisplayer; 27 import org.openide.NotifyDescriptor; 28 import org.openide.util.HelpCtx; 29 import org.openide.util.NbBundle; 30 import org.openide.util.actions.CallableSystemAction; 31 32 33 public final class GemAction extends CallableSystemAction { 34 public void performAction() { 35 if (!RubyInstallation.getInstance().isValidRuby(true)) { 36 return; 37 } 38 39 String gem = RubyInstallation.getInstance().getGem(); 40 41 if (!(new File (gem).exists())) { 42 String msg = NbBundle.getMessage(GemAction.class, "GemMissing", gem); 43 NotifyDescriptor nd = 44 new NotifyDescriptor.Message(msg, NotifyDescriptor.Message.ERROR_MESSAGE); 45 DialogDisplayer.getDefault().notify(nd); 46 47 return; 48 } 49 50 InstalledGemsPanel customizer = new InstalledGemsPanel(); 51 javax.swing.JButton close = 52 new javax.swing.JButton (NbBundle.getMessage(GemAction.class, "CTL_Close")); 53 close.getAccessibleContext() 54 .setAccessibleDescription(NbBundle.getMessage(GemAction.class, "AD_Close")); 55 56 DialogDescriptor descriptor = 57 new DialogDescriptor(customizer, NbBundle.getMessage(GemAction.class, "CTL_GemAction"), 58 true, new Object [] { close }, close, DialogDescriptor.DEFAULT_ALIGN, 59 new HelpCtx(GemAction.class), null); Dialog dlg = null; 61 62 try { 63 dlg = DialogDisplayer.getDefault().createDialog(descriptor); 64 dlg.setVisible(true); 65 } finally { 66 if (dlg != null) { 67 dlg.dispose(); 68 } 69 } 70 71 if (customizer.isModified()) { 72 RubyInstallation.getInstance().recomputeRoots(); 73 } 74 } 75 76 public String getName() { 77 return NbBundle.getMessage(GemAction.class, "CTL_GemAction"); 78 } 79 80 protected void initialize() { 81 super.initialize(); 82 putValue("noIconInMenu", Boolean.TRUE); 84 } 85 86 public HelpCtx getHelpCtx() { 87 return HelpCtx.DEFAULT_HELP; 88 } 89 90 protected boolean asynchronous() { 91 return false; 92 } 93 } 94 | Popular Tags |