1 19 20 package org.netbeans.modules.web.project.ui.wizards; 21 22 import java.awt.Dimension ; 23 import javax.swing.JPanel ; 24 import javax.swing.event.DocumentEvent ; 25 import javax.swing.event.DocumentListener ; 26 import org.netbeans.modules.web.project.Utils; 27 28 import org.openide.WizardDescriptor; 29 import org.openide.WizardValidationException; 30 import org.openide.util.HelpCtx; 31 import org.openide.util.NbBundle; 32 33 public class PanelConfigureProjectVisual extends JPanel implements HelpCtx.Provider { 34 35 private PanelConfigureProject panel; 36 37 private PanelProjectLocationVisual projectLocationPanel; 38 private PanelOptionsVisual optionsPanel; 39 40 41 public PanelConfigureProjectVisual(PanelConfigureProject panel) { 42 this.panel = panel; 43 initComponents(); 44 this.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(PanelConfigureProjectVisual.class, "ACS_NWP1_NamePanel_A11YDesc")); 46 projectLocationPanel = new PanelProjectLocationVisual(panel); 47 locationContainer.add(projectLocationPanel, java.awt.BorderLayout.NORTH); 48 49 optionsPanel = new PanelOptionsVisual(panel); 50 java.awt.GridBagConstraints gridBagConstraints = new java.awt.GridBagConstraints (); 51 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 52 gridBagConstraints.weightx = 1.0; 53 gridBagConstraints.weighty = 1.0; 54 optionsContainer.add(optionsPanel, gridBagConstraints); 55 56 DocumentListener dl = new DocumentListener () { 57 public void changedUpdate(DocumentEvent e) { 58 setContextPath(e); 59 } 60 61 public void insertUpdate(DocumentEvent e) { 62 setContextPath(e); 63 } 64 65 public void removeUpdate(DocumentEvent e) { 66 setContextPath(e); 67 } 68 69 private void setContextPath(DocumentEvent e) { 70 if (!optionsPanel.isContextModified()) 71 optionsPanel.jTextFieldContextPath.setText(Utils.createDefaultContext(projectLocationPanel.projectNameTextField.getText())); 72 } 73 }; 74 projectLocationPanel.projectNameTextField.getDocument().addDocumentListener(dl); 75 76 77 setName(NbBundle.getMessage(PanelConfigureProjectVisual.class, "LBL_NWP1_ProjectTitleName")); putClientProperty ("NewProjectWizard_Title", NbBundle.getMessage(PanelConfigureProjectVisual.class, "TXT_NewWebApp")); 81 int height = projectLocationPanel.computeHeight() + optionsPanel.computeHeight() + 30; 83 if (height > 340) { 84 Dimension dim = new Dimension (getWidth(), height); 85 setMinimumSize(dim); 86 setPreferredSize(dim); 87 } 88 } 89 90 boolean valid(WizardDescriptor wizardDescriptor) { 91 return projectLocationPanel.valid(wizardDescriptor) && optionsPanel.valid(wizardDescriptor); 92 } 93 94 void validate (WizardDescriptor d) throws WizardValidationException { 95 projectLocationPanel.validate (d); 96 } 97 98 void read (WizardDescriptor d) { 99 projectLocationPanel.read(d); 100 optionsPanel.read(d); 101 } 102 103 void store(WizardDescriptor d) { 104 projectLocationPanel.store(d); 105 optionsPanel.store(d); 106 } 107 108 113 private void initComponents() { 115 java.awt.GridBagConstraints gridBagConstraints; 116 117 locationContainer = new javax.swing.JPanel (); 118 jSeparator1 = new javax.swing.JSeparator (); 119 optionsContainer = new javax.swing.JPanel (); 120 121 setLayout(new java.awt.GridBagLayout ()); 122 123 setRequestFocusEnabled(false); 124 locationContainer.setLayout(new java.awt.BorderLayout ()); 125 126 gridBagConstraints = new java.awt.GridBagConstraints (); 127 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 128 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 129 gridBagConstraints.weightx = 1.0; 130 add(locationContainer, gridBagConstraints); 131 132 gridBagConstraints = new java.awt.GridBagConstraints (); 133 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 134 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 135 gridBagConstraints.weightx = 1.0; 136 gridBagConstraints.insets = new java.awt.Insets (12, 0, 12, 0); 137 add(jSeparator1, gridBagConstraints); 138 139 optionsContainer.setLayout(new java.awt.GridBagLayout ()); 140 141 gridBagConstraints = new java.awt.GridBagConstraints (); 142 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 143 gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER; 144 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 145 gridBagConstraints.weightx = 1.0; 146 gridBagConstraints.weighty = 1.0; 147 add(optionsContainer, gridBagConstraints); 148 149 } 151 private javax.swing.JSeparator jSeparator1; 153 private javax.swing.JPanel locationContainer; 154 private javax.swing.JPanel optionsContainer; 155 157 160 public HelpCtx getHelpCtx() { 161 return new HelpCtx(PanelConfigureProjectVisual.class); 162 } 163 } 164 | Popular Tags |