1 19 20 package org.netbeans.modules.versioning.system.cvss.ui.actions.tag; 21 22 import org.netbeans.modules.versioning.system.cvss.CvsModuleConfig; 23 import org.netbeans.modules.versioning.system.cvss.ui.selectors.BranchSelector; 24 import org.netbeans.modules.versioning.system.cvss.util.Utils; 25 import org.netbeans.lib.cvsclient.CVSRoot; 26 27 import java.io.File ; 28 import java.io.IOException ; 29 import org.openide.util.*; 30 31 36 class SwitchBranchPanel extends javax.swing.JPanel { 37 38 private final File [] roots; 39 40 41 public SwitchBranchPanel(File [] roots) { 42 this.roots = roots; 43 initComponents(); 44 rbSwitchToTrunk.setSelected(CvsModuleConfig.getDefault().getPreferences().getBoolean("SwitchBranchSettings.switchToTrunk", true)); rbSwitchToBranch.setSelected(CvsModuleConfig.getDefault().getPreferences().getBoolean("SwitchBranchSettings.switchToBranch", false)); tfBranchName.setText(CvsModuleConfig.getDefault().getPreferences().get("SwitchBranchSettings.branchName", NbBundle.getMessage(SwitchBranchPanel.class, "BK2001"))); refreshComponents(); 48 } 49 50 public void saveSettings() { 51 CvsModuleConfig.getDefault().getPreferences().putBoolean("SwitchBranchSettings.switchToTrunk", rbSwitchToTrunk.isSelected()); CvsModuleConfig.getDefault().getPreferences().putBoolean("SwitchBranchSettings.switchToBranch", rbSwitchToBranch.isSelected()); CvsModuleConfig.getDefault().getPreferences().put("SwitchBranchSettings.branchName", tfBranchName.getText()); } 55 56 private void refreshComponents() { 57 if (rbSwitchToTrunk.isSelected()) { 58 tfBranchName.setEnabled(false); 59 bBrowse.setEnabled(false); 60 } else { 61 tfBranchName.setEnabled(true); 62 bBrowse.setEnabled(true); 63 } 64 } 65 66 public String getBranchName() { 67 return tfBranchName.getText(); 68 } 69 70 public boolean isSwitchToTrunk() { 71 return rbSwitchToTrunk.isSelected(); 72 } 73 74 79 private void initComponents() { 81 java.awt.GridBagConstraints gridBagConstraints; 82 83 bgSwitchRadio = new javax.swing.ButtonGroup (); 84 rbSwitchToTrunk = new javax.swing.JRadioButton (); 85 rbSwitchToBranch = new javax.swing.JRadioButton (); 86 tfBranchName = new javax.swing.JTextField (); 87 bBrowse = new javax.swing.JButton (); 88 89 setLayout(new java.awt.GridBagLayout ()); 90 91 setBorder(javax.swing.BorderFactory.createEmptyBorder(12, 12, 0, 11)); 92 bgSwitchRadio.add(rbSwitchToTrunk); 93 org.openide.awt.Mnemonics.setLocalizedText(rbSwitchToTrunk, java.util.ResourceBundle.getBundle("org/netbeans/modules/versioning/system/cvss/ui/actions/tag/Bundle").getString("CTL_SwitchBranchForm_ToTrunk")); 94 rbSwitchToTrunk.setToolTipText(java.util.ResourceBundle.getBundle("org/netbeans/modules/versioning/system/cvss/ui/actions/tag/Bundle").getString("TT_SwitchBranchForm_ToTrunk")); 95 rbSwitchToTrunk.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 2, 0)); 96 rbSwitchToTrunk.setMargin(new java.awt.Insets (0, 0, 0, 0)); 97 rbSwitchToTrunk.addActionListener(new java.awt.event.ActionListener () { 98 public void actionPerformed(java.awt.event.ActionEvent evt) { 99 radioSwitch(evt); 100 } 101 }); 102 103 gridBagConstraints = new java.awt.GridBagConstraints (); 104 gridBagConstraints.gridx = 0; 105 gridBagConstraints.gridy = 0; 106 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 107 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 108 add(rbSwitchToTrunk, gridBagConstraints); 109 110 bgSwitchRadio.add(rbSwitchToBranch); 111 org.openide.awt.Mnemonics.setLocalizedText(rbSwitchToBranch, java.util.ResourceBundle.getBundle("org/netbeans/modules/versioning/system/cvss/ui/actions/tag/Bundle").getString("CTL_SwitchBranchForm_ToBranch")); 112 rbSwitchToBranch.setToolTipText(java.util.ResourceBundle.getBundle("org/netbeans/modules/versioning/system/cvss/ui/actions/tag/Bundle").getString("TT_SwitchBranchForm_ToBranch")); 113 rbSwitchToBranch.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); 114 rbSwitchToBranch.setMargin(new java.awt.Insets (0, 0, 0, 0)); 115 rbSwitchToBranch.addActionListener(new java.awt.event.ActionListener () { 116 public void actionPerformed(java.awt.event.ActionEvent evt) { 117 radioSwitch(evt); 118 } 119 }); 120 121 gridBagConstraints = new java.awt.GridBagConstraints (); 122 gridBagConstraints.gridx = 0; 123 gridBagConstraints.gridy = 1; 124 gridBagConstraints.insets = new java.awt.Insets (0, 0, 0, 6); 125 add(rbSwitchToBranch, gridBagConstraints); 126 127 tfBranchName.setColumns(20); 128 gridBagConstraints = new java.awt.GridBagConstraints (); 129 gridBagConstraints.gridx = 1; 130 gridBagConstraints.gridy = 1; 131 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 132 gridBagConstraints.weightx = 1.0; 133 gridBagConstraints.insets = new java.awt.Insets (0, 0, 0, 6); 134 add(tfBranchName, gridBagConstraints); 135 tfBranchName.getAccessibleContext().setAccessibleName(java.util.ResourceBundle.getBundle("org/netbeans/modules/versioning/system/cvss/ui/actions/tag/Bundle").getString("ACSN_SwitchBranchForm_BranchName")); 136 tfBranchName.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/versioning/system/cvss/ui/actions/tag/Bundle").getString("ACSD_SwitchBranchForm_BranchName")); 137 138 org.openide.awt.Mnemonics.setLocalizedText(bBrowse, java.util.ResourceBundle.getBundle("org/netbeans/modules/versioning/system/cvss/ui/actions/tag/Bundle").getString("CTL_SwitchBranchForm_BrowseBranch")); 139 bBrowse.setToolTipText(java.util.ResourceBundle.getBundle("org/netbeans/modules/versioning/system/cvss/ui/actions/tag/Bundle").getString("TT_SwitchBranchForm_BrowseBranch")); 140 bBrowse.addActionListener(new java.awt.event.ActionListener () { 141 public void actionPerformed(java.awt.event.ActionEvent evt) { 142 browseBranches(evt); 143 } 144 }); 145 146 gridBagConstraints = new java.awt.GridBagConstraints (); 147 gridBagConstraints.gridx = 2; 148 gridBagConstraints.gridy = 1; 149 add(bBrowse, gridBagConstraints); 150 151 } 152 154 private void browseBranches(java.awt.event.ActionEvent evt) { for (int i = 0; i < roots.length; i++) { 156 try { 157 CVSRoot.parse(Utils.getCVSRootFor(roots[i])); BranchSelector selector = new BranchSelector(); 159 String tag = selector.selectTag(roots[i]); 160 if (tag != null) { 161 tfBranchName.setText(tag); 162 } 163 return; 164 } catch (IOException e) { 165 } 167 } 168 } 170 private void radioSwitch(java.awt.event.ActionEvent evt) { refreshComponents(); 172 } 174 175 private javax.swing.JButton bBrowse; 177 private javax.swing.ButtonGroup bgSwitchRadio; 178 private javax.swing.JRadioButton rbSwitchToBranch; 179 private javax.swing.JRadioButton rbSwitchToTrunk; 180 private javax.swing.JTextField tfBranchName; 181 183 } 184 | Popular Tags |