1 19 20 package org.netbeans.modules.ruby.rubyproject.gems; 21 22 import javax.swing.DefaultComboBoxModel ; 23 import org.netbeans.modules.ruby.rubyproject.gems.GemManager.Gem; 24 import org.openide.util.NbBundle; 25 26 30 public class InstallationSettingsPanel extends javax.swing.JPanel { 31 private final String LATEST = NbBundle.getMessage(InstallationSettingsPanel.class, "Latest"); 32 33 34 public InstallationSettingsPanel(Gem gem) { 35 initComponents(); 36 nameField.setText(gem.getName()); 37 DefaultComboBoxModel model = new DefaultComboBoxModel (); 38 model.addElement(LATEST); 39 String versions = gem.getVersions(); 40 if (versions != null) { 41 String [] v = versions.split(", "); 42 for (String version : v) { 43 if (version.length() != 0) { 44 model.addElement(version); 45 } 46 } 47 } 48 versionCombo.setModel(model); 49 } 50 51 public void setMessage(String message) { 52 messageLabel.setText(message); 53 } 54 55 public boolean getIncludeDepencies() { 56 return includeToggle.isSelected(); 57 } 58 59 public String getVersion() { 60 String s = versionCombo.getSelectedItem().toString().trim(); 61 if (s == LATEST) { 62 return null; 63 } else { 64 return s; 65 } 66 } 67 68 public String getName() { 69 return nameField.getText().trim(); 70 } 71 72 77 private void initComponents() { 79 80 dependencyGroup = new javax.swing.ButtonGroup (); 81 jLabel1 = new javax.swing.JLabel (); 82 nameField = new javax.swing.JTextField (); 83 jLabel2 = new javax.swing.JLabel (); 84 versionCombo = new javax.swing.JComboBox (); 85 jLabel3 = new javax.swing.JLabel (); 86 includeToggle = new javax.swing.JRadioButton (); 87 excludeToggle = new javax.swing.JRadioButton (); 88 messageLabel = new javax.swing.JLabel (); 89 90 jLabel1.setText(org.openide.util.NbBundle.getMessage(InstallationSettingsPanel.class, "InstallationSettingsPanel.jLabel1.text")); 92 nameField.setText(org.openide.util.NbBundle.getMessage(InstallationSettingsPanel.class, "InstallationSettingsPanel.nameField.text")); 94 jLabel2.setText(org.openide.util.NbBundle.getMessage(InstallationSettingsPanel.class, "InstallationSettingsPanel.jLabel2.text")); 96 versionCombo.setModel(new javax.swing.DefaultComboBoxModel (new String [] { "Item 1", "Item 2", "Item 3", "Item 4" })); 97 98 jLabel3.setText(org.openide.util.NbBundle.getMessage(InstallationSettingsPanel.class, "InstallationSettingsPanel.jLabel3.text")); 100 dependencyGroup.add(includeToggle); 101 includeToggle.setSelected(true); 102 includeToggle.setText(org.openide.util.NbBundle.getMessage(InstallationSettingsPanel.class, "InstallationSettingsPanel.includeToggle.text")); includeToggle.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); 104 includeToggle.setMargin(new java.awt.Insets (0, 0, 0, 0)); 105 106 dependencyGroup.add(excludeToggle); 107 excludeToggle.setText(org.openide.util.NbBundle.getMessage(InstallationSettingsPanel.class, "InstallationSettingsPanel.excludeToggle.text")); excludeToggle.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); 109 excludeToggle.setMargin(new java.awt.Insets (0, 0, 0, 0)); 110 111 messageLabel.setText(org.openide.util.NbBundle.getMessage(InstallationSettingsPanel.class, "InstallationSettingsPanel.messageLabel.text")); 113 org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this); 114 this.setLayout(layout); 115 layout.setHorizontalGroup( 116 layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 117 .add(layout.createSequentialGroup() 118 .addContainerGap() 119 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 120 .add(layout.createSequentialGroup() 121 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 122 .add(jLabel1) 123 .add(jLabel2) 124 .add(jLabel3)) 125 .add(10, 10, 10) 126 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 127 .add(layout.createSequentialGroup() 128 .add(includeToggle) 129 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 130 .add(excludeToggle)) 131 .add(versionCombo, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) 132 .add(nameField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 258, Short.MAX_VALUE))) 133 .add(messageLabel)) 134 .addContainerGap()) 135 ); 136 layout.setVerticalGroup( 137 layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 138 .add(layout.createSequentialGroup() 139 .addContainerGap() 140 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) 141 .add(jLabel1) 142 .add(nameField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) 143 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 144 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) 145 .add(jLabel2) 146 .add(versionCombo, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) 147 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 148 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) 149 .add(jLabel3) 150 .add(includeToggle) 151 .add(excludeToggle)) 152 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 153 .add(messageLabel) 154 .addContainerGap(84, Short.MAX_VALUE)) 155 ); 156 } 158 159 private javax.swing.ButtonGroup dependencyGroup; 161 private javax.swing.JRadioButton excludeToggle; 162 private javax.swing.JRadioButton includeToggle; 163 private javax.swing.JLabel jLabel1; 164 private javax.swing.JLabel jLabel2; 165 private javax.swing.JLabel jLabel3; 166 private javax.swing.JLabel messageLabel; 167 private javax.swing.JTextField nameField; 168 private javax.swing.JComboBox versionCombo; 169 171 } 172 | Popular Tags |