PageRenderTime 45ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/projects/netbeans-7.3/mercurial/src/org/netbeans/modules/mercurial/options/PropertiesPanel.java

https://gitlab.com/essere.lab.public/qualitas.class-corpus
Java | 223 lines | 138 code | 29 blank | 56 comment | 1 complexity | b9a4f1a39ff9d5cebb14255968d458f9 MD5 | raw file
  1. /*
  2. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
  3. *
  4. * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved.
  5. *
  6. * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
  7. * Other names may be trademarks of their respective owners.
  8. *
  9. * The contents of this file are subject to the terms of either the GNU
  10. * General Public License Version 2 only ("GPL") or the Common
  11. * Development and Distribution License("CDDL") (collectively, the
  12. * "License"). You may not use this file except in compliance with the
  13. * License. You can obtain a copy of the License at
  14. * http://www.netbeans.org/cddl-gplv2.html
  15. * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
  16. * specific language governing permissions and limitations under the
  17. * License. When distributing the software, include this License Header
  18. * Notice in each file and include the License file at
  19. * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
  20. * particular file as subject to the "Classpath" exception as provided
  21. * by Oracle in the GPL Version 2 section of the License file that
  22. * accompanied this code. If applicable, add the following below the
  23. * License Header, with the fields enclosed by brackets [] replaced by
  24. * your own identifying information:
  25. * "Portions Copyrighted [year] [name of copyright owner]"
  26. *
  27. * Contributor(s):
  28. *
  29. * The Original Software is NetBeans. The Initial Developer of the Original
  30. * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
  31. * Microsystems, Inc. All Rights Reserved.
  32. *
  33. * If you wish your version of this file to be governed by only the CDDL
  34. * or only the GPL Version 2, indicate your decision by adding
  35. * "[Contributor] elects to include this software in this distribution
  36. * under the [CDDL or GPL Version 2] license." If you do not indicate a
  37. * single choice of license, a recipient has the option to distribute
  38. * your version of this file under either the CDDL, the GPL Version 2 or
  39. * to extend the choice of license to its licensees as provided above.
  40. * However, if you add GPL Version 2 code and therefore, elected the GPL
  41. * Version 2 license, then the option applies only if the new code is
  42. * made subject to such option by the copyright holder.
  43. */
  44. package org.netbeans.modules.mercurial.options;
  45. import java.util.prefs.PreferenceChangeEvent;
  46. import java.util.prefs.PreferenceChangeListener;
  47. import javax.swing.event.TableModelEvent;
  48. import javax.swing.event.TableModelListener;
  49. import org.netbeans.modules.mercurial.HgModuleConfig;
  50. import org.netbeans.modules.mercurial.options.PropertiesTable;
  51. import org.netbeans.modules.versioning.util.ListenersSupport;
  52. /**
  53. *
  54. * @author Peter Pis
  55. */
  56. public class PropertiesPanel extends javax.swing.JPanel implements PreferenceChangeListener, TableModelListener {
  57. private static final Object EVENT_SETTINGS_CHANGED = new Object();
  58. private PropertiesTable propertiesTable;
  59. private ListenersSupport listenerSupport = new ListenersSupport(this);
  60. /** Creates new form PropertiesPanel */
  61. public PropertiesPanel() {
  62. initComponents();
  63. }
  64. public javax.swing.JTextArea getTxtAreaValue() {
  65. return txtAreaValue;
  66. }
  67. public javax.swing.JComboBox getComboName() {
  68. return comboName;
  69. }
  70. public javax.swing.JButton getBtnAdd() {
  71. return btnAdd;
  72. }
  73. public javax.swing.JButton getBtnRemove() {
  74. return btnRemove;
  75. }
  76. public void setPropertiesTable(PropertiesTable propertiesTable){
  77. this.propertiesTable = propertiesTable;
  78. }
  79. public void addNotify() {
  80. super.addNotify();
  81. HgModuleConfig.getDefault().getPreferences().addPreferenceChangeListener(this);
  82. propertiesTable.getTableModel().addTableModelListener(this);
  83. listenerSupport.fireVersioningEvent(EVENT_SETTINGS_CHANGED);
  84. txtAreaValue.selectAll();
  85. }
  86. public void removeNotify() {
  87. propertiesTable.getTableModel().removeTableModelListener(this);
  88. HgModuleConfig.getDefault().getPreferences().removePreferenceChangeListener(this);
  89. super.removeNotify();
  90. }
  91. public void preferenceChange(PreferenceChangeEvent evt) {
  92. if (evt.getKey().startsWith(HgModuleConfig.PROP_COMMIT_EXCLUSIONS)) {
  93. propertiesTable.dataChanged();
  94. listenerSupport.fireVersioningEvent(EVENT_SETTINGS_CHANGED);
  95. }
  96. }
  97. public void tableChanged(TableModelEvent e) {
  98. listenerSupport.fireVersioningEvent(EVENT_SETTINGS_CHANGED);
  99. }
  100. /** This method is called from within the constructor to
  101. * initialize the form.
  102. * WARNING: Do NOT modify this code. The content of this method is
  103. * always regenerated by the Form Editor.
  104. */
  105. // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  106. private void initComponents() {
  107. jLabel2 = new javax.swing.JLabel();
  108. jLabel1 = new javax.swing.JLabel();
  109. propsPanel = new javax.swing.JPanel();
  110. jScrollPane1 = new javax.swing.JScrollPane();
  111. labelForTable = new javax.swing.JLabel();
  112. jLabel2.setLabelFor(comboName);
  113. org.openide.awt.Mnemonics.setLocalizedText(jLabel2, org.openide.util.NbBundle.getMessage(PropertiesPanel.class, "PropertiesPanel.jLabel2.text")); // NOI18N
  114. jLabel1.setLabelFor(txtAreaValue);
  115. org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(PropertiesPanel.class, "PropertiesPanel.jLabel1.text")); // NOI18N
  116. javax.swing.GroupLayout propsPanelLayout = new javax.swing.GroupLayout(propsPanel);
  117. propsPanel.setLayout(propsPanelLayout);
  118. propsPanelLayout.setHorizontalGroup(
  119. propsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  120. .addGap(0, 462, Short.MAX_VALUE)
  121. );
  122. propsPanelLayout.setVerticalGroup(
  123. propsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  124. .addGap(0, 99, Short.MAX_VALUE)
  125. );
  126. txtAreaValue.setColumns(20);
  127. txtAreaValue.setRows(5);
  128. jScrollPane1.setViewportView(txtAreaValue);
  129. txtAreaValue.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(PropertiesPanel.class, "ACSD_txtAreaValue")); // NOI18N
  130. org.openide.awt.Mnemonics.setLocalizedText(btnRemove, org.openide.util.NbBundle.getMessage(PropertiesPanel.class, "PropertiesPanel.btnRemove.text")); // NOI18N
  131. org.openide.awt.Mnemonics.setLocalizedText(btnAdd, org.openide.util.NbBundle.getMessage(PropertiesPanel.class, "PropertiesPanel.btnAdd.text")); // NOI18N
  132. btnAdd.setMaximumSize(new java.awt.Dimension(75, 23));
  133. btnAdd.setMinimumSize(new java.awt.Dimension(75, 23));
  134. org.openide.awt.Mnemonics.setLocalizedText(labelForTable, org.openide.util.NbBundle.getMessage(PropertiesPanel.class, "jLabel3.txt")); // NOI18N
  135. javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
  136. this.setLayout(layout);
  137. layout.setHorizontalGroup(
  138. layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  139. .addGroup(layout.createSequentialGroup()
  140. .addContainerGap()
  141. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  142. .addComponent(propsPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  143. .addGroup(layout.createSequentialGroup()
  144. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  145. .addComponent(jLabel2)
  146. .addComponent(btnAdd, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  147. .addComponent(labelForTable)
  148. .addComponent(jLabel1))
  149. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
  150. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
  151. .addComponent(comboName, javax.swing.GroupLayout.Alignment.LEADING, 0, 307, Short.MAX_VALUE)
  152. .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 307, Short.MAX_VALUE))
  153. .addGroup(layout.createSequentialGroup()
  154. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  155. .addComponent(btnRemove)))))
  156. .addContainerGap())
  157. );
  158. layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {btnAdd, btnRemove});
  159. layout.setVerticalGroup(
  160. layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  161. .addGroup(layout.createSequentialGroup()
  162. .addContainerGap()
  163. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  164. .addComponent(jLabel2)
  165. .addComponent(comboName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
  166. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  167. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  168. .addGroup(layout.createSequentialGroup()
  169. .addComponent(jLabel1)
  170. .addGap(99, 99, 99)
  171. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  172. .addComponent(btnAdd, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  173. .addComponent(btnRemove))
  174. .addGap(26, 26, 26)
  175. .addComponent(labelForTable))
  176. .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
  177. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 25, Short.MAX_VALUE)
  178. .addComponent(propsPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
  179. );
  180. btnRemove.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(PropertiesPanel.class, "ACSD_btnRemove")); // NOI18N
  181. btnAdd.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(PropertiesPanel.class, "ACSD_btnAdd")); // NOI18N
  182. }// </editor-fold>//GEN-END:initComponents
  183. // Variables declaration - do not modify//GEN-BEGIN:variables
  184. final javax.swing.JButton btnAdd = new javax.swing.JButton();
  185. final javax.swing.JButton btnRemove = new javax.swing.JButton();
  186. final javax.swing.JComboBox comboName = new javax.swing.JComboBox();
  187. private javax.swing.JLabel jLabel1;
  188. private javax.swing.JLabel jLabel2;
  189. private javax.swing.JScrollPane jScrollPane1;
  190. public javax.swing.JLabel labelForTable;
  191. public javax.swing.JPanel propsPanel;
  192. final javax.swing.JTextArea txtAreaValue = new javax.swing.JTextArea();
  193. // End of variables declaration//GEN-END:variables
  194. }