1 19 20 21 package org.netbeans.modules.i18n.wizard; 22 23 import java.awt.Dialog ; 24 import java.lang.ref.WeakReference ; 25 import java.text.MessageFormat ; 26 import java.util.ArrayList ; 27 28 import org.netbeans.modules.i18n.I18nUtil; 29 30 import org.openide.nodes.Node; 31 import org.openide.util.actions.NodeAction; 32 import org.openide.util.HelpCtx; 33 import org.openide.util.NbBundle; 34 import org.openide.WizardDescriptor; 35 import org.openide.DialogDisplayer; 36 import org.netbeans.api.project.Project; 37 38 44 public class I18nTestWizardAction extends NodeAction { 45 46 public I18nTestWizardAction() { 47 putValue("noIconInMenu", Boolean.TRUE); 48 } 49 50 51 static final long serialVersionUID = -3265587506739081248L; 52 53 54 private static WeakReference dialogWRef = new WeakReference (null); 55 56 57 61 protected boolean enable(Node[] activatedNodes) { 62 63 if (Util.wizardEnabled(activatedNodes) == false) { 64 return false; 65 } 66 67 Dialog previous = (Dialog ) dialogWRef.get(); 68 if (previous == null) return true; 69 return previous.isVisible() == false; 70 } 71 72 75 protected void performAction(Node[] activatedNodes) { 76 Dialog dialog = (Dialog )dialogWRef.get(); 77 78 if(dialog != null) { 79 dialog.setVisible(false); 80 dialog.dispose(); 81 } 82 83 Project project = org.netbeans.modules.i18n.Util.getProjectFor(activatedNodes); 84 if (project == null) return; 85 86 WizardDescriptor wizardDescriptor = I18nWizardDescriptor.createI18nWizardDescriptor( 87 getWizardIterator(), 88 new I18nWizardDescriptor. 89 Settings(Util.createWizardSourceMap(activatedNodes), 90 project) 91 92 ); 93 94 initWizard(wizardDescriptor); 95 96 dialog = DialogDisplayer.getDefault().createDialog(wizardDescriptor); 97 dialogWRef = new WeakReference (dialog); 98 dialog.setVisible(true); 99 } 100 101 103 private WizardDescriptor.Iterator getWizardIterator() { 104 WizardDescriptor.Panel[] panels = new WizardDescriptor.Panel[3]; 105 106 panels[0] = new SourceWizardPanel.Panel(true); 107 panels[1] = new ResourceWizardPanel.Panel(true); 108 panels[2] = new TestStringWizardPanel.Panel(); 109 110 return new WizardDescriptor.ArrayIterator(panels); 111 112 } 113 114 115 private void initWizard(WizardDescriptor wizardDesc) { 116 wizardDesc.putProperty("WizardPanel_autoWizardStyle", Boolean.TRUE); wizardDesc.putProperty("WizardPanel_contentDisplayed", Boolean.TRUE); wizardDesc.putProperty("WizardPanel_contentNumbered", Boolean.TRUE); 121 ArrayList contents = new ArrayList (3); 122 contents.add(Util.getString("TXT_SelectTestSources")); 123 contents.add(Util.getString("TXT_SelectTestResources")); 124 contents.add(Util.getString("TXT_FoundMissingResources")); 125 126 wizardDesc.putProperty("WizardPanel_contentData", (String [])contents.toArray(new String [contents.size()])); 128 wizardDesc.setTitle(Util.getString("LBL_TestWizardTitle")); 129 wizardDesc.setTitleFormat(new MessageFormat ("{0} ({1})")); 131 wizardDesc.setModal(false); 132 } 133 134 135 public String getName() { 136 return Util.getString("LBL_TestWizardActionName"); 137 } 138 139 140 public HelpCtx getHelpCtx() { 141 return new HelpCtx(I18nUtil.HELP_ID_TESTING); 142 } 143 144 protected boolean asynchronous() { 145 return false; 146 } 147 148 149 } 150 | Popular Tags |