1 19 20 package org.netbeans.modules.apisupport.project.ui.platform; 21 22 import java.io.File ; 23 import java.io.IOException ; 24 import javax.swing.event.DocumentEvent ; 25 import org.netbeans.modules.apisupport.project.ui.UIUtil; 26 import org.netbeans.modules.apisupport.project.ui.wizard.BasicVisualPanel; 27 import org.netbeans.modules.apisupport.project.universe.NbPlatform; 28 import org.openide.WizardDescriptor; 29 import org.openide.util.NbBundle; 30 31 37 public class PlatformInfoVisualPanel extends BasicVisualPanel { 38 39 private boolean attached; 40 41 42 public PlatformInfoVisualPanel(WizardDescriptor setting) { 43 super(setting); 44 initComponents(); 45 initAccessibility(); 46 setName(NbPlatformCustomizer.INFO_STEP); 47 } 48 49 void refreshData() { 50 String destDir = (String ) getSettings().getProperty(NbPlatformCustomizer.PLAF_DIR_PROPERTY); 51 try { 52 plafNameValue.setText(NbPlatform.computeDisplayName(new File (destDir))); 53 } catch (IOException e) { 54 plafNameValue.setText(destDir); 55 } 56 checkForm(); 57 } 58 59 private void checkForm() { 60 String plafName = plafNameValue.getText().trim(); 61 if (plafName.equals("")) { 62 setError(getMessage("MSG_BlankPlatformName")); 63 } else if (!NbPlatform.isLabelValid(plafName)) { 64 setError(getMessage("MSG_NameIsAlreadyUsed")); 65 } else { 66 markValid(); 67 } 68 } 69 70 void storeData() { 71 getSettings().putProperty(NbPlatformCustomizer.PLAF_LABEL_PROPERTY, 72 plafNameValue.getText().trim()); 73 } 74 75 public void addNotify() { 76 super.addNotify(); 77 if (!attached) { 78 plafNameValue.getDocument().addDocumentListener(new UIUtil.DocumentAdapter() { 79 public void insertUpdate(DocumentEvent e) { 80 checkForm(); 81 } 82 }); 83 attached = true; 84 } 85 } 86 87 private static String getMessage(String key) { 88 return NbBundle.getMessage(PlatformInfoVisualPanel.class, key); 89 } 90 91 96 private void initComponents() { 98 java.awt.GridBagConstraints gridBagConstraints; 99 100 plafName = new javax.swing.JLabel (); 101 plafNameValue = new javax.swing.JTextField (); 102 filler = new javax.swing.JLabel (); 103 104 setLayout(new java.awt.GridBagLayout ()); 105 106 org.openide.awt.Mnemonics.setLocalizedText(plafName, org.openide.util.NbBundle.getMessage(PlatformInfoVisualPanel.class, "LBL_PlatformName_P")); 107 gridBagConstraints = new java.awt.GridBagConstraints (); 108 gridBagConstraints.gridx = 0; 109 gridBagConstraints.gridy = 0; 110 gridBagConstraints.insets = new java.awt.Insets (0, 0, 0, 12); 111 add(plafName, gridBagConstraints); 112 113 gridBagConstraints = new java.awt.GridBagConstraints (); 114 gridBagConstraints.gridx = 1; 115 gridBagConstraints.gridy = 0; 116 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 117 gridBagConstraints.weightx = 1.0; 118 add(plafNameValue, gridBagConstraints); 119 120 gridBagConstraints = new java.awt.GridBagConstraints (); 121 gridBagConstraints.gridx = 0; 122 gridBagConstraints.gridy = 1; 123 gridBagConstraints.weighty = 1.0; 124 add(filler, gridBagConstraints); 125 126 } 127 129 private javax.swing.JLabel filler; 131 private javax.swing.JLabel plafName; 132 private javax.swing.JTextField plafNameValue; 133 135 private void initAccessibility() { 136 this.getAccessibleContext().setAccessibleDescription(getMessage("ACS_PlatformInfoVisualPanel")); 137 plafNameValue.getAccessibleContext().setAccessibleDescription(getMessage("ACS_CTL_plafNameValue")); 138 } 139 } 140 | Popular Tags |