1 19 20 package org.netbeans.modules.apisupport.project.ui.wizard.winsys; 21 22 import java.io.IOException ; 23 import java.util.ArrayList ; 24 import java.util.Collection ; 25 import javax.swing.DefaultComboBoxModel ; 26 import org.netbeans.modules.apisupport.project.layers.LayerUtils; 27 import org.netbeans.modules.apisupport.project.ui.wizard.BasicWizardIterator; 28 import org.openide.WizardDescriptor; 29 import org.openide.filesystems.FileObject; 30 import org.openide.filesystems.FileSystem; 31 import org.openide.util.HelpCtx; 32 import org.openide.util.NbBundle; 33 34 39 final class BasicSettingsPanel extends BasicWizardIterator.Panel { 40 41 private NewTCIterator.DataModel data; 42 private static final String [] DEFAULT_MODES = 43 new String [] { 44 "editor" }; 46 49 public BasicSettingsPanel(WizardDescriptor setting, NewTCIterator.DataModel data) { 50 super(setting); 51 this.data = data; 52 initComponents(); 53 initAccessibility(); 54 setupCombo(); 55 putClientProperty("NewFileWizard_Title", getMessage("LBL_TCWizardTitle")); 56 } 57 58 private void checkValidity() { 59 markValid(); 61 } 62 63 87 private void setupCombo() { 88 String [] modes = null; 90 try { 91 FileSystem fs = LayerUtils.getEffectiveSystemFilesystem(data.getProject()); 92 FileObject foRoot = fs.getRoot().getFileObject("Windows2/Modes"); if (foRoot != null) { 94 FileObject[] fos = foRoot.getChildren(); 95 Collection col = new ArrayList (); 96 for (int i=0; i < fos.length; i++) { 97 if (fos[i].isData() && "wsmode".equals(fos[i].getExt())) { col.add(fos[i].getName()); 99 } 100 } 101 modes = (String [])col.toArray(new String [col.size()]); 102 } else { 103 modes = DEFAULT_MODES; 104 } 105 } catch (IOException exc) { 106 modes = DEFAULT_MODES; 107 108 } 109 110 comMode.setModel(new DefaultComboBoxModel (modes)); 111 } 112 113 protected void storeToDataModel() { 114 data.setOpened(cbOpenedOnStart.isSelected()); 115 data.setMode((String )comMode.getSelectedItem()); 116 } 117 118 protected void readFromDataModel() { 119 cbOpenedOnStart.setSelected(data.isOpened()); 120 if (data.getMode() != null) { 121 comMode.setSelectedItem(data.getMode()); 122 } else { 123 comMode.setSelectedItem("output"); } 125 checkValidity(); 126 } 127 128 protected String getPanelName() { 129 return getMessage("LBL_BasicSettings_Title"); 130 } 131 132 protected HelpCtx getHelp() { 133 return new HelpCtx(BasicSettingsPanel.class); 134 } 135 136 private static String getMessage(String key) { 137 return NbBundle.getMessage(BasicSettingsPanel.class, key); 138 } 139 140 145 private void initComponents() { 147 java.awt.GridBagConstraints gridBagConstraints; 148 149 lblMode = new javax.swing.JLabel (); 150 comMode = new javax.swing.JComboBox (); 151 cbOpenedOnStart = new javax.swing.JCheckBox (); 152 153 setLayout(new java.awt.GridBagLayout ()); 154 155 lblMode.setLabelFor(comMode); 156 org.openide.awt.Mnemonics.setLocalizedText(lblMode, org.openide.util.NbBundle.getMessage(BasicSettingsPanel.class, "LBL_Mode")); 157 gridBagConstraints = new java.awt.GridBagConstraints (); 158 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 159 gridBagConstraints.insets = new java.awt.Insets (12, 6, 0, 0); 160 add(lblMode, gridBagConstraints); 161 162 gridBagConstraints = new java.awt.GridBagConstraints (); 163 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 164 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 165 gridBagConstraints.weightx = 0.1; 166 gridBagConstraints.insets = new java.awt.Insets (12, 6, 0, 6); 167 add(comMode, gridBagConstraints); 168 169 org.openide.awt.Mnemonics.setLocalizedText(cbOpenedOnStart, org.openide.util.NbBundle.getMessage(BasicSettingsPanel.class, "LBL_OpenOnStart")); 170 cbOpenedOnStart.setBorder(new javax.swing.border.EmptyBorder (new java.awt.Insets (0, 0, 0, 0))); 171 cbOpenedOnStart.setMargin(new java.awt.Insets (0, 0, 0, 0)); 172 gridBagConstraints = new java.awt.GridBagConstraints (); 173 gridBagConstraints.gridx = 0; 174 gridBagConstraints.gridy = 1; 175 gridBagConstraints.gridwidth = 2; 176 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 177 gridBagConstraints.weighty = 0.1; 178 gridBagConstraints.insets = new java.awt.Insets (12, 6, 0, 0); 179 add(cbOpenedOnStart, gridBagConstraints); 180 181 } 182 184 private javax.swing.JCheckBox cbOpenedOnStart; 186 private javax.swing.JComboBox comMode; 187 private javax.swing.JLabel lblMode; 188 190 private void initAccessibility() { 191 this.getAccessibleContext().setAccessibleDescription(getMessage("ACS_BasicSettingsPanel")); 192 cbOpenedOnStart.getAccessibleContext().setAccessibleDescription(getMessage("ACS_CTL_OpenOnStart")); 193 comMode.getAccessibleContext().setAccessibleDescription(getMessage("ACS_CTL_Mode")); 194 } 195 196 } 197 | Popular Tags |