# HG changeset patch
# User padraigob@netbeans.org
# Date 1201768692 0
# Node ID 74d5f5ff2f687b95af59be2c5075d197f3f3e952
# Parent 0ca1a28c477bd505dd92101e69ce54e2b4281848
125700: Use new dialog for mercurial properties
diff -r 0ca1a28c477b -r 74d5f5ff2f68 mercurial/src/org/netbeans/modules/mercurial/HgModuleConfig.java
--- a/mercurial/src/org/netbeans/modules/mercurial/HgModuleConfig.java Wed Jan 30 14:32:37 2008 +0000
+++ b/mercurial/src/org/netbeans/modules/mercurial/HgModuleConfig.java Thu Jan 31 08:38:12 2008 +0000
@@ -231,12 +231,18 @@ public class HgModuleConfig {
name = getUserName();
if (name.length() > 0)
props.setProperty("username", name); // NOI18N
+ else
+ props.setProperty("username", ""); // NOI18N
name = hgconfig.getDefaultPull(false);
if (name.length() > 0)
props.setProperty("default-pull", name); // NOI18N
+ else
+ props.setProperty("default-pull", ""); // NOI18N
name = hgconfig.getDefaultPush(false);
if (name.length() > 0)
props.setProperty("default-push", name); // NOI18N
+ else
+ props.setProperty("default-push", ""); // NOI18N
return props;
}
diff -r 0ca1a28c477b -r 74d5f5ff2f68 mercurial/src/org/netbeans/modules/mercurial/options/Bundle.properties
--- a/mercurial/src/org/netbeans/modules/mercurial/options/Bundle.properties Wed Jan 30 14:32:37 2008 +0000
+++ b/mercurial/src/org/netbeans/modules/mercurial/options/Bundle.properties Thu Jan 31 08:38:12 2008 +0000
@@ -93,3 +93,16 @@ MercurialPanel.ExportFilename.text=&Defa
MercurialPanel.ExportFilename.text=&Default Export Filename\:
MercurialPanel.browseButton2.text=B&rowse...
+
+
+PropertiesPanel.jLabel2.text=Property &Name:
+PropertiesPanel.jLabel1.text=Property &Value:
+PropertiesPanel.btnAdd.text=&Add
+PropertiesPanel.btnRemove.text=&Remove
+jLabel3.txt=Mercurial &Properties:
+ACSD_PropertiesTable = Lists of mercurial properties.
+LBL_Properties_Progress=Scanning mercurial properties
+
+CTL_PropertiesTable_Column_Name=Name
+CTL_PropertiesTable_Column_Value=Value
+
diff -r 0ca1a28c477b -r 74d5f5ff2f68 mercurial/src/org/netbeans/modules/mercurial/options/HgExtProperties.java
--- a/mercurial/src/org/netbeans/modules/mercurial/options/HgExtProperties.java Wed Jan 30 14:32:37 2008 +0000
+++ b/mercurial/src/org/netbeans/modules/mercurial/options/HgExtProperties.java Thu Jan 31 08:38:12 2008 +0000
@@ -68,8 +68,8 @@ import org.netbeans.modules.mercurial.Me
import org.netbeans.modules.mercurial.Mercurial;
import org.netbeans.modules.mercurial.HgProgressSupport;
import org.netbeans.modules.mercurial.HgModuleConfig;
-import org.netbeans.modules.mercurial.ui.properties.PropertiesPanel;
-import org.netbeans.modules.mercurial.ui.properties.PropertiesTable;
+import org.netbeans.modules.mercurial.options.PropertiesPanel;
+import org.netbeans.modules.mercurial.options.PropertiesTable;
import org.netbeans.modules.mercurial.ui.properties.HgPropertiesNode;
import org.netbeans.modules.versioning.util.AccessibleJFileChooser;
import org.netbeans.modules.versioning.util.Utils;
diff -r 0ca1a28c477b -r 74d5f5ff2f68 mercurial/src/org/netbeans/modules/mercurial/options/MercurialOptionsPanelController.java
--- a/mercurial/src/org/netbeans/modules/mercurial/options/MercurialOptionsPanelController.java Wed Jan 30 14:32:37 2008 +0000
+++ b/mercurial/src/org/netbeans/modules/mercurial/options/MercurialOptionsPanelController.java Thu Jan 31 08:38:12 2008 +0000
@@ -60,9 +60,9 @@ import org.netbeans.modules.mercurial.Me
import org.netbeans.modules.mercurial.Mercurial;
import org.netbeans.modules.mercurial.MercurialAnnotator;
import org.netbeans.modules.mercurial.HgModuleConfig;
-import org.netbeans.modules.mercurial.ui.properties.PropertiesPanel;
-import org.netbeans.modules.mercurial.ui.properties.PropertiesTable;
-import org.netbeans.modules.mercurial.ui.properties.PropertiesTableModel;
+import org.netbeans.modules.mercurial.options.PropertiesPanel;
+import org.netbeans.modules.mercurial.options.PropertiesTable;
+import org.netbeans.modules.mercurial.options.PropertiesTableModel;
import org.netbeans.spi.options.OptionsPanelController;
import org.netbeans.modules.versioning.util.AccessibleJFileChooser;
import org.openide.DialogDescriptor;
diff -r 0ca1a28c477b -r 74d5f5ff2f68 mercurial/src/org/netbeans/modules/mercurial/options/PropertiesPanel.form
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mercurial/src/org/netbeans/modules/mercurial/options/PropertiesPanel.form Thu Jan 31 08:38:12 2008 +0000
@@ -0,0 +1,174 @@
+
+
+
diff -r 0ca1a28c477b -r 74d5f5ff2f68 mercurial/src/org/netbeans/modules/mercurial/options/PropertiesPanel.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mercurial/src/org/netbeans/modules/mercurial/options/PropertiesPanel.java Thu Jan 31 08:38:12 2008 +0000
@@ -0,0 +1,217 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common
+ * Development and Distribution License("CDDL") (collectively, the
+ * "License"). You may not use this file except in compliance with the
+ * License. You can obtain a copy of the License at
+ * http://www.netbeans.org/cddl-gplv2.html
+ * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
+ * specific language governing permissions and limitations under the
+ * License. When distributing the software, include this License Header
+ * Notice in each file and include the License file at
+ * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the GPL Version 2 section of the License file that
+ * accompanied this code. If applicable, add the following below the
+ * License Header, with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * The Original Software is NetBeans. The Initial Developer of the Original
+ * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
+ * Microsystems, Inc. All Rights Reserved.
+ *
+ * If you wish your version of this file to be governed by only the CDDL
+ * or only the GPL Version 2, indicate your decision by adding
+ * "[Contributor] elects to include this software in this distribution
+ * under the [CDDL or GPL Version 2] license." If you do not indicate a
+ * single choice of license, a recipient has the option to distribute
+ * your version of this file under either the CDDL, the GPL Version 2 or
+ * to extend the choice of license to its licensees as provided above.
+ * However, if you add GPL Version 2 code and therefore, elected the GPL
+ * Version 2 license, then the option applies only if the new code is
+ * made subject to such option by the copyright holder.
+ */
+package org.netbeans.modules.mercurial.options;
+
+import java.util.prefs.PreferenceChangeEvent;
+import java.util.prefs.PreferenceChangeListener;
+import javax.swing.event.TableModelEvent;
+import javax.swing.event.TableModelListener;
+import org.netbeans.modules.mercurial.HgModuleConfig;
+import org.netbeans.modules.mercurial.options.PropertiesTable;
+import org.netbeans.modules.versioning.util.ListenersSupport;
+
+/**
+ *
+ * @author Peter Pis
+ */
+public class PropertiesPanel extends javax.swing.JPanel implements PreferenceChangeListener, TableModelListener {
+
+ private static final Object EVENT_SETTINGS_CHANGED = new Object();
+ private PropertiesTable propertiesTable;
+ private ListenersSupport listenerSupport = new ListenersSupport(this);
+
+ /** Creates new form PropertiesPanel */
+ public PropertiesPanel() {
+ initComponents();
+ }
+
+ public javax.swing.JTextArea getTxtAreaValue() {
+ return txtAreaValue;
+ }
+
+ public javax.swing.JComboBox getComboName() {
+ return comboName;
+ }
+
+ public javax.swing.JButton getBtnAdd() {
+ return btnAdd;
+ }
+
+ public javax.swing.JButton getBtnRemove() {
+ return btnRemove;
+ }
+
+ public void setPropertiesTable(PropertiesTable propertiesTable){
+ this.propertiesTable = propertiesTable;
+ }
+
+ public void addNotify() {
+ super.addNotify();
+ HgModuleConfig.getDefault().getPreferences().addPreferenceChangeListener(this);
+ propertiesTable.getTableModel().addTableModelListener(this);
+ listenerSupport.fireVersioningEvent(EVENT_SETTINGS_CHANGED);
+ txtAreaValue.selectAll();
+ }
+
+ public void removeNotify() {
+ propertiesTable.getTableModel().removeTableModelListener(this);
+ HgModuleConfig.getDefault().getPreferences().removePreferenceChangeListener(this);
+ super.removeNotify();
+ }
+
+ public void preferenceChange(PreferenceChangeEvent evt) {
+ if (evt.getKey().startsWith(HgModuleConfig.PROP_COMMIT_EXCLUSIONS)) {
+ propertiesTable.dataChanged();
+ listenerSupport.fireVersioningEvent(EVENT_SETTINGS_CHANGED);
+ }
+ }
+
+ public void tableChanged(TableModelEvent e) {
+ listenerSupport.fireVersioningEvent(EVENT_SETTINGS_CHANGED);
+ }
+
+ /** This method is called from within the constructor to
+ * initialize the form.
+ * WARNING: Do NOT modify this code. The content of this method is
+ * always regenerated by the Form Editor.
+ */
+ // //GEN-BEGIN:initComponents
+ private void initComponents() {
+
+ jLabel2 = new javax.swing.JLabel();
+ jLabel1 = new javax.swing.JLabel();
+ propsPanel = new javax.swing.JPanel();
+ jScrollPane1 = new javax.swing.JScrollPane();
+ jLabel3 = new javax.swing.JLabel();
+
+ jLabel2.setLabelFor(comboName);
+ org.openide.awt.Mnemonics.setLocalizedText(jLabel2, org.openide.util.NbBundle.getMessage(PropertiesPanel.class, "PropertiesPanel.jLabel2.text")); // NOI18N
+
+ jLabel1.setLabelFor(txtAreaValue);
+ org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(PropertiesPanel.class, "PropertiesPanel.jLabel1.text")); // NOI18N
+
+ org.jdesktop.layout.GroupLayout propsPanelLayout = new org.jdesktop.layout.GroupLayout(propsPanel);
+ propsPanel.setLayout(propsPanelLayout);
+ propsPanelLayout.setHorizontalGroup(
+ propsPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(0, 420, Short.MAX_VALUE)
+ );
+ propsPanelLayout.setVerticalGroup(
+ propsPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(0, 99, Short.MAX_VALUE)
+ );
+
+ txtAreaValue.setColumns(20);
+ txtAreaValue.setRows(5);
+ jScrollPane1.setViewportView(txtAreaValue);
+
+ org.openide.awt.Mnemonics.setLocalizedText(btnRemove, org.openide.util.NbBundle.getMessage(PropertiesPanel.class, "PropertiesPanel.btnRemove.text")); // NOI18N
+
+ org.openide.awt.Mnemonics.setLocalizedText(btnAdd, org.openide.util.NbBundle.getMessage(PropertiesPanel.class, "PropertiesPanel.btnAdd.text")); // NOI18N
+ btnAdd.setMaximumSize(new java.awt.Dimension(75, 23));
+ btnAdd.setMinimumSize(new java.awt.Dimension(75, 23));
+
+ org.openide.awt.Mnemonics.setLocalizedText(jLabel3, org.openide.util.NbBundle.getMessage(PropertiesPanel.class, "jLabel3.txt")); // NOI18N
+
+ org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
+ this.setLayout(layout);
+ layout.setHorizontalGroup(
+ layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(layout.createSequentialGroup()
+ .addContainerGap()
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(propsPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .add(layout.createSequentialGroup()
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(jLabel2)
+ .add(btnAdd, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+ .add(jLabel3)
+ .add(jLabel1))
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
+ .add(org.jdesktop.layout.GroupLayout.LEADING, comboName, 0, 307, Short.MAX_VALUE)
+ .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 307, Short.MAX_VALUE))
+ .add(layout.createSequentialGroup()
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(btnRemove)))))
+ .addContainerGap())
+ );
+
+ layout.linkSize(new java.awt.Component[] {btnAdd, btnRemove}, org.jdesktop.layout.GroupLayout.HORIZONTAL);
+
+ layout.setVerticalGroup(
+ layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(layout.createSequentialGroup()
+ .addContainerGap()
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+ .add(jLabel2)
+ .add(comboName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(layout.createSequentialGroup()
+ .add(jLabel1)
+ .add(99, 99, 99)
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+ .add(btnAdd, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+ .add(btnRemove))
+ .add(26, 26, 26)
+ .add(jLabel3)
+ .add(12, 12, 12))
+ .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 13, Short.MAX_VALUE)
+ .add(propsPanel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
+ );
+ }// //GEN-END:initComponents
+
+
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ final javax.swing.JButton btnAdd = new javax.swing.JButton();
+ final javax.swing.JButton btnRemove = new javax.swing.JButton();
+ final javax.swing.JComboBox comboName = new javax.swing.JComboBox();
+ private javax.swing.JLabel jLabel1;
+ private javax.swing.JLabel jLabel2;
+ private javax.swing.JLabel jLabel3;
+ private javax.swing.JScrollPane jScrollPane1;
+ public javax.swing.JPanel propsPanel;
+ final javax.swing.JTextArea txtAreaValue = new javax.swing.JTextArea();
+ // End of variables declaration//GEN-END:variables
+
+}
diff -r 0ca1a28c477b -r 74d5f5ff2f68 mercurial/src/org/netbeans/modules/mercurial/options/PropertiesTable.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mercurial/src/org/netbeans/modules/mercurial/options/PropertiesTable.java Thu Jan 31 08:38:12 2008 +0000
@@ -0,0 +1,211 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common
+ * Development and Distribution License("CDDL") (collectively, the
+ * "License"). You may not use this file except in compliance with the
+ * License. You can obtain a copy of the License at
+ * http://www.netbeans.org/cddl-gplv2.html
+ * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
+ * specific language governing permissions and limitations under the
+ * License. When distributing the software, include this License Header
+ * Notice in each file and include the License file at
+ * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the GPL Version 2 section of the License file that
+ * accompanied this code. If applicable, add the following below the
+ * License Header, with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * The Original Software is NetBeans. The Initial Developer of the Original
+ * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
+ * Microsystems, Inc. All Rights Reserved.
+ *
+ * If you wish your version of this file to be governed by only the CDDL
+ * or only the GPL Version 2, indicate your decision by adding
+ * "[Contributor] elects to include this software in this distribution
+ * under the [CDDL or GPL Version 2] license." If you do not indicate a
+ * single choice of license, a recipient has the option to distribute
+ * your version of this file under either the CDDL, the GPL Version 2 or
+ * to extend the choice of license to its licensees as provided above.
+ * However, if you add GPL Version 2 code and therefore, elected the GPL
+ * Version 2 license, then the option applies only if the new code is
+ * made subject to such option by the copyright holder.
+ */
+package org.netbeans.modules.mercurial.options;
+
+import java.awt.Component;
+import java.awt.Dimension;
+import java.util.Arrays;
+import javax.swing.JComponent;
+import javax.swing.JScrollPane;
+import javax.swing.JTable;
+import javax.swing.event.AncestorEvent;
+import javax.swing.event.AncestorListener;
+import javax.swing.event.TableModelEvent;
+import javax.swing.event.TableModelListener;
+import javax.swing.table.DefaultTableCellRenderer;
+import javax.swing.table.TableColumnModel;
+import javax.swing.table.TableModel;
+import org.netbeans.modules.versioning.util.TableSorter;
+import org.netbeans.modules.mercurial.ui.properties.HgPropertiesNode;
+import org.netbeans.modules.mercurial.options.PropertiesTableModel;
+import org.openide.util.NbBundle;
+
+/**
+ *
+ * @author Peter Pis
+ */
+public class PropertiesTable implements AncestorListener, TableModelListener {
+
+ static public final String[] PROPERTIES_COLUMNS = new String[] {PropertiesTableModel.COLUMN_NAME_NAME, PropertiesTableModel.COLUMN_NAME_VALUE};
+
+ private PropertiesTableModel tableModel;
+ private JTable table;
+ private TableSorter sorter;
+ private JComponent component;
+ private String[] columns;
+ private String[] sortByColumns;
+
+ /** Creates a new instance of PropertiesTable */
+ public PropertiesTable(String[] columns, String[] sortByColumns) {
+ init(columns, null);
+ this.sortByColumns = sortByColumns;
+ setSortingStatus();
+ }
+
+ public PropertiesTable(String[] columns, TableSorter sorter) {
+ init(columns, sorter);
+ }
+
+ private void init(String[] columns, TableSorter sorter) {
+ tableModel = new PropertiesTableModel(columns);
+ tableModel.addTableModelListener(this);
+ if(sorter == null) {
+ sorter = new TableSorter(tableModel);
+ }
+ this.sorter = sorter;
+ table = new JTable(this.sorter);
+ table.getTableHeader().setReorderingAllowed(false);
+ table.setDefaultRenderer(String.class, new PropertiesTableCellRenderer());
+ //table.setDefaultEditor(CommitOptions.class, new CommitOptionsCellEditor());
+ table.getTableHeader().setReorderingAllowed(true);
+ this.sorter.setTableHeader(table.getTableHeader());
+ table.setRowHeight(table.getRowHeight());
+ table.addAncestorListener(this);
+ component = new JScrollPane(table, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
+ component.setPreferredSize(new Dimension(340, 150));
+ table.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(PropertiesTable.class, "ACSD_PropertiesTable")); // NOI18N
+ setColumns(columns);
+ }
+
+ public void setColumns(String[] clmns) {
+ if (Arrays.equals(columns, clmns))
+ return;
+ columns = clmns;
+ tableModel.setColumns(clmns);
+ setDefaultColumnSize();
+ }
+
+ public JTable getTable() {
+ return table;
+ }
+
+ private void setDefaultColumnSize() {
+ int width = table.getWidth();
+ TableColumnModel columnModel = table.getColumnModel();
+ if (columns == null || columnModel == null)
+ return;
+ if (columnModel.getColumnCount() != columns.length)
+ return;
+ for (int i = 0; i < columns.length; i++) {
+ String col = columns[i];
+ sorter.setColumnComparator(i, null);
+ if (col.equals(PropertiesTableModel.COLUMN_NAME_NAME)) {
+ columnModel.getColumn(i).setPreferredWidth(width * 20 / 100);
+ } else if (col.equals(PropertiesTableModel.COLUMN_NAME_VALUE)) {
+ columnModel.getColumn(i).setPreferredWidth(width * 40 / 100);
+ }
+ }
+ }
+
+ private void setSortingStatus() {
+ for (int i = 0; i < sortByColumns.length; i++) {
+ String sortByColumn = sortByColumns[i];
+ for (int j = 0; j < columns.length; j++) {
+ String column = columns[j];
+ if(column.equals(sortByColumn)) {
+ sorter.setSortingStatus(j, column.equals(sortByColumn) ? TableSorter.ASCENDING : TableSorter.NOT_SORTED);
+ break;
+ }
+ }
+ }
+ }
+
+ TableModel getTableModel() {
+ return tableModel;
+ }
+
+ void dataChanged() {
+ int idx = table.getSelectedRow();
+ tableModel.fireTableDataChanged();
+ if (idx != -1) {
+ table.getSelectionModel().addSelectionInterval(idx, idx);
+ }
+ }
+
+ public int getModelIndex(int viewIndex) {
+ return sorter.modelIndex(viewIndex);
+ }
+
+ public int[] getSelectedItems() {
+ return table.getSelectedRows();
+ }
+
+ public HgPropertiesNode[] getNodes() {
+ return tableModel.getNodes();
+ }
+
+ public void setNodes(HgPropertiesNode[] nodes) {
+ tableModel.setNodes(nodes);
+ }
+
+ public JComponent getComponent() {
+ return component;
+ }
+
+ public void ancestorAdded(AncestorEvent arg0) {
+ setDefaultColumnSize();
+ }
+
+ public void ancestorRemoved(AncestorEvent arg0) {
+ }
+
+ public void ancestorMoved(AncestorEvent arg0) {
+ }
+
+ public void tableChanged(TableModelEvent event) {
+ table.repaint();
+ }
+
+ public class PropertiesTableCellRenderer extends DefaultTableCellRenderer {
+
+ public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int rowIndex, int columnIndex) {
+ Component renderer = super.getTableCellRendererComponent(table, value, hasFocus, hasFocus, rowIndex, columnIndex);
+ if (renderer instanceof JComponent) {
+ String strValue = tableModel.getNode(sorter.modelIndex(rowIndex)).getValue();
+ ((JComponent) renderer).setToolTipText(strValue);
+ }
+ setToolTipText(value.toString());
+ return renderer;
+ }
+ }
+
+
+}
diff -r 0ca1a28c477b -r 74d5f5ff2f68 mercurial/src/org/netbeans/modules/mercurial/options/PropertiesTableModel.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mercurial/src/org/netbeans/modules/mercurial/options/PropertiesTableModel.java Thu Jan 31 08:38:12 2008 +0000
@@ -0,0 +1,120 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common
+ * Development and Distribution License("CDDL") (collectively, the
+ * "License"). You may not use this file except in compliance with the
+ * License. You can obtain a copy of the License at
+ * http://www.netbeans.org/cddl-gplv2.html
+ * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
+ * specific language governing permissions and limitations under the
+ * License. When distributing the software, include this License Header
+ * Notice in each file and include the License file at
+ * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the GPL Version 2 section of the License file that
+ * accompanied this code. If applicable, add the following below the
+ * License Header, with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * The Original Software is NetBeans. The Initial Developer of the Original
+ * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
+ * Microsystems, Inc. All Rights Reserved.
+ *
+ * If you wish your version of this file to be governed by only the CDDL
+ * or only the GPL Version 2, indicate your decision by adding
+ * "[Contributor] elects to include this software in this distribution
+ * under the [CDDL or GPL Version 2] license." If you do not indicate a
+ * single choice of license, a recipient has the option to distribute
+ * your version of this file under either the CDDL, the GPL Version 2 or
+ * to extend the choice of license to its licensees as provided above.
+ * However, if you add GPL Version 2 code and therefore, elected the GPL
+ * Version 2 license, then the option applies only if the new code is
+ * made subject to such option by the copyright holder.
+ */
+package org.netbeans.modules.mercurial.options;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.ResourceBundle;
+import javax.swing.table.AbstractTableModel;
+import org.openide.util.NbBundle;
+import org.netbeans.modules.mercurial.ui.properties.HgPropertiesNode;
+
+/**
+ *
+ * @author Peter Pis
+ */
+public class PropertiesTableModel extends AbstractTableModel {
+
+ public static final String COLUMN_NAME_NAME = "name"; // NOI18N
+ public static final String COLUMN_NAME_VALUE = "value"; // NOI18N
+
+ private HgPropertiesNode[] nodes;
+ private String[] columns;
+
+ private static final Map columnLabels = new HashMap(2);
+
+ {
+ ResourceBundle loc = NbBundle.getBundle(PropertiesTableModel.class);
+ columnLabels.put(COLUMN_NAME_NAME, new String[] {loc.getString("CTL_PropertiesTable_Column_Name"), loc.getString("CTL_PropertiesTable_Column_Name")}); // NOI18N
+ columnLabels.put(COLUMN_NAME_VALUE, new String[] {loc.getString("CTL_PropertiesTable_Column_Value"), loc.getString("CTL_PropertiesTable_Column_Value")}); // NOI18N
+ }
+
+ /** Creates a new instance of PropertiesTableModel */
+ public PropertiesTableModel(String[] clms) {
+ if (Arrays.equals(columns, clms))
+ return;
+ setColumns(clms);
+ setNodes(new HgPropertiesNode[0]);
+ }
+
+ public void setColumns(String[] clms) {
+ this.columns = clms;
+ fireTableStructureChanged();
+ }
+
+ public void setNodes(HgPropertiesNode[] nodes) {
+ this.nodes = nodes;
+ fireTableDataChanged();
+ }
+
+ public HgPropertiesNode[] getNodes() {
+ return nodes;
+ }
+
+ public HgPropertiesNode getNode(int row) {
+ return nodes[row];
+ }
+
+ public int getRowCount() {
+ return nodes.length;
+ }
+
+ public String getColumnName(int column) {
+ return columnLabels.get(columns[column])[0];
+ }
+
+ public int getColumnCount() {
+ return columns.length;
+ }
+
+ public Object getValueAt(int rowIndex, int columnIndex) {
+ String clm = columns[columnIndex];
+ if (clm.equals(COLUMN_NAME_NAME)) {
+ return nodes[rowIndex].getName();
+ } else if (clm.equals(COLUMN_NAME_VALUE)) {
+ return nodes[rowIndex].getValue();
+ }
+ throw new IllegalArgumentException("The column index is out of index: " + columnIndex); // NOI18N
+ }
+
+
+}
diff -r 0ca1a28c477b -r 74d5f5ff2f68 mercurial/src/org/netbeans/modules/mercurial/ui/properties/Bundle.properties
--- a/mercurial/src/org/netbeans/modules/mercurial/ui/properties/Bundle.properties Wed Jan 30 14:32:37 2008 +0000
+++ b/mercurial/src/org/netbeans/modules/mercurial/ui/properties/Bundle.properties Thu Jan 31 08:38:12 2008 +0000
@@ -44,18 +44,10 @@ CTL_Properties_Action_OK = &OK
CTL_Properties_Action_OK = &OK
ACSN_Properties_Action_OK = OK
ACSD_Properties_Action_OK = OK
-PropertiesPanel.jLabel2.text=Property &Name:
PropertiesPanel.jLabel1.text=Property &Value:
#
-MSG_PROPERTIES_INVALID_MESSAGE = The specified value, {0}, for the property {1} is invalid
-MSG_PROPERTIES_INVALID_TITLE = Invalid Property Value
CTL_PropertiesTable_Column_Name=Name
CTL_PropertiesTable_Column_Value=Value
ACSD_PropertiesTable = Lists of mercurial properties.
LBL_Properties_Progress=Scanning mercurial properties
-PropertiesPanel.btnAdd.text=&Add
-PropertiesPanel.btnRemove.text=&Remove
jLabel3.txt=Mercurial &Properties:
-CTL_Properties_Action_Modify = &Modify
-ACSN_Properties_Action_Modify = Modify
-ACSD_Properties_Action_Modify = Modify
diff -r 0ca1a28c477b -r 74d5f5ff2f68 mercurial/src/org/netbeans/modules/mercurial/ui/properties/HgProperties.java
--- a/mercurial/src/org/netbeans/modules/mercurial/ui/properties/HgProperties.java Wed Jan 30 14:32:37 2008 +0000
+++ b/mercurial/src/org/netbeans/modules/mercurial/ui/properties/HgProperties.java Thu Jan 31 08:38:12 2008 +0000
@@ -45,8 +45,6 @@ import java.awt.Font;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
-import java.awt.event.MouseAdapter;
-import java.awt.event.MouseEvent;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
@@ -62,8 +60,11 @@ import javax.swing.DefaultComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JFileChooser;
import javax.swing.JTextField;
+import javax.swing.ListSelectionModel;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.ListSelectionListener;
import javax.swing.text.Document;
import org.netbeans.modules.mercurial.Mercurial;
import org.netbeans.modules.mercurial.HgProgressSupport;
@@ -80,9 +81,9 @@ import org.openide.NotifyDescriptor;
/**
*
- * @author Peter Pis
+ * @author Padraig O'Briain
*/
-public class HgProperties implements ActionListener, DocumentListener {
+public class HgProperties implements ListSelectionListener {
private static final String HGPROPNAME_USERNAME = "username"; // NOI18N
private static final String HGPROPNAME_DEFAULT_PULL = "default-pull"; // NOI18N
@@ -100,14 +101,10 @@ public class HgProperties implements Act
this.panel = panel;
this.propTable = propTable;
this.root = root;
- panel.txtAreaValue.getDocument().addDocumentListener(this);
- ((JTextField) panel.comboName.getEditor().getEditorComponent()).getDocument().addDocumentListener(this);
- propTable.getTable().addMouseListener(new TableMouseListener());
- panel.btnAdd.addActionListener(this);
- panel.btnRemove.addActionListener(this);
- initPropertyNameCbx();
+ propTable.getTable().getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+ propTable.getTable().getSelectionModel().addListSelectionListener(this);
+
refreshProperties();
-
}
public PropertiesPanel getPropertiesPanel() {
@@ -126,37 +123,8 @@ public class HgProperties implements Act
this.root = root;
}
- public void actionPerformed(ActionEvent event) {
- Object source = event.getSource();
-
- if (source.equals(panel.btnAdd)) {
- addProperty();
- }
-
- if (source.equals(panel.btnRemove)) {
- removeProperties();
- }
-
- }
-
- protected void initPropertyNameCbx() {
- List lstName = new ArrayList(8);
-
- lstName.add(HGPROPNAME_DEFAULT_PULL);
- lstName.add(HGPROPNAME_DEFAULT_PUSH);
- lstName.add(HGPROPNAME_USERNAME);
-
- ComboBoxModel comboModel = new DefaultComboBoxModel(new Vector(lstName));
- panel.comboName.setModel(comboModel);
- panel.comboName.setSelectedIndex(0);
- }
-
protected String getPropertyValue() {
return panel.txtAreaValue.getText();
- }
-
- protected String getPropertyName() {
- return ((String)panel.comboName.getSelectedItem()).trim();
}
protected void refreshProperties() {
@@ -184,46 +152,6 @@ public class HgProperties implements Act
}
}
- private boolean addProperty(String name, String value) {
- if (name.equals(HGPROPNAME_USERNAME)) {
- if (!HgModuleConfig.getDefault().isUserNameValid(value)) {
- try {
- JOptionPane.showMessageDialog(null,
- NbBundle.getMessage(HgProperties.class, "MSG_PROPERTIES_INVALID_MESSAGE", value, name), // NOI18N
- NbBundle.getMessage(HgProperties.class, "MSG_PROPERTIES_INVALID_TITLE"), JOptionPane.ERROR_MESSAGE); // NOI18N
- } catch (Exception ex) {
- NotifyDescriptor.Exception e = new NotifyDescriptor.Exception(ex);
- DialogDisplayer.getDefault().notifyLater(e);
- }
- return false;
- }
- }
-
- HgPropertiesNode[] hgPropertiesNodes = propTable.getNodes();
- for (int i = 0; i < hgPropertiesNodes.length; i++) {
- String hgPropertyName = hgPropertiesNodes[propTable.getModelIndex(i)].getName();
- if (hgPropertyName.equals(name)) {
- hgPropertiesNodes[propTable.getModelIndex(i)].setValue(value);
- propTable.setNodes(hgPropertiesNodes);
- return true;
- }
- }
- HgPropertiesNode[] hgProps = new HgPropertiesNode[hgPropertiesNodes.length + 1];
- for (int i = 0; i < hgPropertiesNodes.length; i++) {
- hgProps[i] = hgPropertiesNodes[i];
- }
- hgProps[hgPropertiesNodes.length] = new HgPropertiesNode(name, value);
- propTable.setNodes(hgProps);
- return true;
- }
-
- public void addProperty() {
- if (addProperty(getPropertyName(), getPropertyValue())) {
- panel.comboName.getEditor().setItem(""); // NOI18N
- panel.txtAreaValue.setText(""); // NOI18N
- }
- }
-
public void setProperties() {
RequestProcessor rp = Mercurial.getInstance().getRequestProcessor(root.getAbsolutePath());
try {
@@ -233,9 +161,11 @@ public class HgProperties implements Act
HgModuleConfig.getDefault().removeProperty(root, "ui", HGPROPNAME_USERNAME); // NOI18N
HgPropertiesNode[] hgPropertiesNodes = propTable.getNodes();
for (int i = 0; i < hgPropertiesNodes.length; i++) {
- String hgPropertyName = hgPropertiesNodes[propTable.getModelIndex(i)].getName();
- String hgPropertyValue = hgPropertiesNodes[propTable.getModelIndex(i)].getValue();
- HgModuleConfig.getDefault().setProperty(root, hgPropertyName, hgPropertyValue);
+ String hgPropertyName = hgPropertiesNodes[i].getName();
+ String hgPropertyValue = hgPropertiesNodes[i].getValue();
+ if (hgPropertyValue.trim().length() > 0 ) {
+ HgModuleConfig.getDefault().setProperty(root, hgPropertyName, hgPropertyValue);
+ }
}
HgRepositoryContextCache.resetPullDefault();
HgRepositoryContextCache.resetPushDefault();
@@ -247,67 +177,20 @@ public class HgProperties implements Act
}
}
- public void removeProperties() {
- final int[] rows = propTable.getSelectedItems();
- if (rows.length == 0) return;
+ private int lastIndex = -1;
+
+ public void valueChanged (ListSelectionEvent e) {
+ int index = propTable.getTable().getSelectedRow();
+ if (index < 0) {
+ lastIndex = -1;
+ return;
+ }
HgPropertiesNode[] hgPropertiesNodes = propTable.getNodes();
- HgPropertiesNode[] hgProps = new HgPropertiesNode[hgPropertiesNodes.length - rows.length];
- int j = 0;
- int k = 0;
- for (int i = 0; i < hgPropertiesNodes.length; i++) {
- if (i != rows[j]) {
- hgProps[k++] = hgPropertiesNodes[propTable.getModelIndex(i)];
- } else {
- if (j < rows.length - 1) j++;
- }
+ if (lastIndex >= 0) {
+ hgPropertiesNodes[lastIndex].setValue(getPropertyValue());
+ propTable.setNodes(hgPropertiesNodes);
}
- propTable.setNodes(hgProps);
- }
-
- public void insertUpdate(DocumentEvent event) {
- validateUserInput(event);
- }
-
- public void removeUpdate(DocumentEvent event) {
- validateUserInput(event);
- }
-
- public void changedUpdate(DocumentEvent event) {
- validateUserInput(event);
- }
-
- private void validateUserInput(DocumentEvent event) {
-
- Document doc = event.getDocument();
- String name = ((String)panel.comboName.getSelectedItem()).trim();
- String value = panel.txtAreaValue.getText().trim();
-
- if (name.length() == 0 || value.length() == 0 || name.indexOf(" ") > 0) { // NOI18N
- panel.btnAdd.setEnabled(false);
- } else {
- panel.btnAdd.setEnabled(true);
- }
- }
-
- public class TableMouseListener extends MouseAdapter {
-
- @Override
- public void mouseClicked(MouseEvent event) {
- //super.mouseClicked(arg0);
- if (event.getClickCount() == 2) {
- int[] rows = propTable.getSelectedItems();
- HgPropertiesNode[] hgPropertiesNodes = propTable.getNodes();
- if (hgPropertiesNodes == null)
- return;
- final String hgPropertyName = hgPropertiesNodes[propTable.getModelIndex(rows[0])].getName();
- final String hgPropertyValue = hgPropertiesNodes[propTable.getModelIndex(rows[0])].getValue();
- EventQueue.invokeLater(new Runnable() {
- public void run() {
- panel.comboName.setSelectedItem(hgPropertyName);
- panel.txtAreaValue.setText(hgPropertyValue);
- }
- });
- }
- }
+ panel.txtAreaValue.setText(hgPropertiesNodes[index].getValue());
+ lastIndex = index;
}
}
diff -r 0ca1a28c477b -r 74d5f5ff2f68 mercurial/src/org/netbeans/modules/mercurial/ui/properties/PropertiesAction.java
--- a/mercurial/src/org/netbeans/modules/mercurial/ui/properties/PropertiesAction.java Wed Jan 30 14:32:37 2008 +0000
+++ b/mercurial/src/org/netbeans/modules/mercurial/ui/properties/PropertiesAction.java Thu Jan 31 08:38:12 2008 +0000
@@ -78,7 +78,7 @@ public class PropertiesAction extends Ab
final PropertiesTable propTable;
- propTable = new PropertiesTable(PropertiesTable.PROPERTIES_COLUMNS, new String[] { PropertiesTableModel.COLUMN_NAME_VALUE});
+ propTable = new PropertiesTable(PropertiesTable.PROPERTIES_COLUMNS);
panel.setPropertiesTable(propTable);
@@ -105,10 +105,6 @@ public class PropertiesAction extends Ab
panel.putClientProperty("DialogDescriptor", dd); // NOI18N
Dialog dialog = DialogDisplayer.getDefault().createDialog(dd);
dialog.pack();
- panel.btnRemove.setVisible(false);
- org.openide.awt.Mnemonics.setLocalizedText(panel.btnAdd, org.openide.util.NbBundle.getMessage(PropertiesAction.class, "CTL_Properties_Action_Modify"));
- panel.btnAdd.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(PropertiesAction.class, "ACSN_Properties_Action_Modify")); // NOI18N
- panel.btnAdd.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(PropertiesAction.class, "ACSD_Properties_Action_Modify"));
dialog.setVisible(true);
if (dd.getValue() == okButton) {
hgProperties.setProperties();
diff -r 0ca1a28c477b -r 74d5f5ff2f68 mercurial/src/org/netbeans/modules/mercurial/ui/properties/PropertiesPanel.form
--- a/mercurial/src/org/netbeans/modules/mercurial/ui/properties/PropertiesPanel.form Wed Jan 30 14:32:37 2008 +0000
+++ b/mercurial/src/org/netbeans/modules/mercurial/ui/properties/PropertiesPanel.form Thu Jan 31 08:38:12 2008 +0000
@@ -14,28 +14,13 @@
-
+
-
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -43,54 +28,21 @@
-
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -109,12 +61,12 @@
-
+
-
+
@@ -129,7 +81,7 @@
-
+
@@ -137,32 +89,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff -r 0ca1a28c477b -r 74d5f5ff2f68 mercurial/src/org/netbeans/modules/mercurial/ui/properties/PropertiesPanel.java
--- a/mercurial/src/org/netbeans/modules/mercurial/ui/properties/PropertiesPanel.java Wed Jan 30 14:32:37 2008 +0000
+++ b/mercurial/src/org/netbeans/modules/mercurial/ui/properties/PropertiesPanel.java Thu Jan 31 08:38:12 2008 +0000
@@ -66,18 +66,6 @@ public class PropertiesPanel extends jav
return txtAreaValue;
}
- public javax.swing.JComboBox getComboName() {
- return comboName;
- }
-
- public javax.swing.JButton getBtnAdd() {
- return btnAdd;
- }
-
- public javax.swing.JButton getBtnRemove() {
- return btnRemove;
- }
-
public void setPropertiesTable(PropertiesTable propertiesTable){
this.propertiesTable = propertiesTable;
}
@@ -115,14 +103,10 @@ public class PropertiesPanel extends jav
// //GEN-BEGIN:initComponents
private void initComponents() {
- jLabel2 = new javax.swing.JLabel();
jLabel1 = new javax.swing.JLabel();
propsPanel = new javax.swing.JPanel();
jScrollPane1 = new javax.swing.JScrollPane();
jLabel3 = new javax.swing.JLabel();
-
- jLabel2.setLabelFor(comboName);
- org.openide.awt.Mnemonics.setLocalizedText(jLabel2, org.openide.util.NbBundle.getMessage(PropertiesPanel.class, "PropertiesPanel.jLabel2.text")); // NOI18N
jLabel1.setLabelFor(txtAreaValue);
org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(PropertiesPanel.class, "PropertiesPanel.jLabel1.text")); // NOI18N
@@ -131,22 +115,16 @@ public class PropertiesPanel extends jav
propsPanel.setLayout(propsPanelLayout);
propsPanelLayout.setHorizontalGroup(
propsPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
- .add(0, 420, Short.MAX_VALUE)
+ .add(0, 460, Short.MAX_VALUE)
);
propsPanelLayout.setVerticalGroup(
propsPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
- .add(0, 99, Short.MAX_VALUE)
+ .add(0, 111, Short.MAX_VALUE)
);
txtAreaValue.setColumns(20);
- txtAreaValue.setRows(5);
+ txtAreaValue.setRows(1);
jScrollPane1.setViewportView(txtAreaValue);
-
- org.openide.awt.Mnemonics.setLocalizedText(btnRemove, org.openide.util.NbBundle.getMessage(PropertiesPanel.class, "PropertiesPanel.btnRemove.text")); // NOI18N
-
- org.openide.awt.Mnemonics.setLocalizedText(btnAdd, org.openide.util.NbBundle.getMessage(PropertiesPanel.class, "PropertiesPanel.btnAdd.text")); // NOI18N
- btnAdd.setMaximumSize(new java.awt.Dimension(75, 23));
- btnAdd.setMinimumSize(new java.awt.Dimension(75, 23));
org.openide.awt.Mnemonics.setLocalizedText(jLabel3, org.openide.util.NbBundle.getMessage(PropertiesPanel.class, "jLabel3.txt")); // NOI18N
@@ -154,59 +132,33 @@ public class PropertiesPanel extends jav
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
- .add(layout.createSequentialGroup()
+ .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
.addContainerGap()
- .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
- .add(propsPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .add(layout.createSequentialGroup()
- .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
- .add(jLabel2)
- .add(btnAdd, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
- .add(jLabel3)
- .add(jLabel1))
- .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
- .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
- .add(org.jdesktop.layout.GroupLayout.LEADING, comboName, 0, 307, Short.MAX_VALUE)
- .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 307, Short.MAX_VALUE))
- .add(layout.createSequentialGroup()
- .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
- .add(btnRemove)))))
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
+ .add(org.jdesktop.layout.GroupLayout.LEADING, jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 460, Short.MAX_VALUE)
+ .add(org.jdesktop.layout.GroupLayout.LEADING, jLabel3)
+ .add(org.jdesktop.layout.GroupLayout.LEADING, jLabel1)
+ .add(org.jdesktop.layout.GroupLayout.LEADING, propsPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap())
);
-
- layout.linkSize(new java.awt.Component[] {btnAdd, btnRemove}, org.jdesktop.layout.GroupLayout.HORIZONTAL);
-
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
- .add(layout.createSequentialGroup()
+ .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
.addContainerGap()
- .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
- .add(jLabel2)
- .add(comboName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
+ .add(jLabel3)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
- .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
- .add(layout.createSequentialGroup()
- .add(jLabel1)
- .add(99, 99, 99)
- .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
- .add(btnAdd, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
- .add(btnRemove))
- .add(26, 26, 26)
- .add(jLabel3)
- .add(12, 12, 12))
- .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
- .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 13, Short.MAX_VALUE)
- .add(propsPanel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
+ .add(propsPanel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+ .add(22, 22, 22)
+ .add(jLabel1)
+ .add(18, 18, 18)
+ .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 32, Short.MAX_VALUE)
+ .addContainerGap())
);
}// //GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
- final javax.swing.JButton btnAdd = new javax.swing.JButton();
- final javax.swing.JButton btnRemove = new javax.swing.JButton();
- final javax.swing.JComboBox comboName = new javax.swing.JComboBox();
private javax.swing.JLabel jLabel1;
- private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JScrollPane jScrollPane1;
public javax.swing.JPanel propsPanel;
diff -r 0ca1a28c477b -r 74d5f5ff2f68 mercurial/src/org/netbeans/modules/mercurial/ui/properties/PropertiesTable.java
--- a/mercurial/src/org/netbeans/modules/mercurial/ui/properties/PropertiesTable.java Wed Jan 30 14:32:37 2008 +0000
+++ b/mercurial/src/org/netbeans/modules/mercurial/ui/properties/PropertiesTable.java Thu Jan 31 08:38:12 2008 +0000
@@ -58,7 +58,7 @@ import org.openide.util.NbBundle;
/**
*
- * @author Peter Pis
+ * @author Padraig O'Briain
*/
public class PropertiesTable implements AncestorListener, TableModelListener {
@@ -66,35 +66,21 @@ public class PropertiesTable implements
private PropertiesTableModel tableModel;
private JTable table;
- private TableSorter sorter;
private JComponent component;
private String[] columns;
- private String[] sortByColumns;
/** Creates a new instance of PropertiesTable */
- public PropertiesTable(String[] columns, String[] sortByColumns) {
- init(columns, null);
- this.sortByColumns = sortByColumns;
- setSortingStatus();
+ public PropertiesTable(String[] columns) {
+ init(columns);
}
- public PropertiesTable(String[] columns, TableSorter sorter) {
- init(columns, sorter);
- }
-
- private void init(String[] columns, TableSorter sorter) {
+ private void init(String[] columns) {
tableModel = new PropertiesTableModel(columns);
tableModel.addTableModelListener(this);
- if(sorter == null) {
- sorter = new TableSorter(tableModel);
- }
- this.sorter = sorter;
- table = new JTable(this.sorter);
+ table = new JTable(tableModel);
table.getTableHeader().setReorderingAllowed(false);
table.setDefaultRenderer(String.class, new PropertiesTableCellRenderer());
//table.setDefaultEditor(CommitOptions.class, new CommitOptionsCellEditor());
- table.getTableHeader().setReorderingAllowed(true);
- this.sorter.setTableHeader(table.getTableHeader());
table.setRowHeight(table.getRowHeight());
table.addAncestorListener(this);
component = new JScrollPane(table, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
@@ -124,7 +110,6 @@ public class PropertiesTable implements
return;
for (int i = 0; i < columns.length; i++) {
String col = columns[i];
- sorter.setColumnComparator(i, null);
if (col.equals(PropertiesTableModel.COLUMN_NAME_NAME)) {
columnModel.getColumn(i).setPreferredWidth(width * 20 / 100);
} else if (col.equals(PropertiesTableModel.COLUMN_NAME_VALUE)) {
@@ -133,33 +118,16 @@ public class PropertiesTable implements
}
}
- private void setSortingStatus() {
- for (int i = 0; i < sortByColumns.length; i++) {
- String sortByColumn = sortByColumns[i];
- for (int j = 0; j < columns.length; j++) {
- String column = columns[j];
- if(column.equals(sortByColumn)) {
- sorter.setSortingStatus(j, column.equals(sortByColumn) ? TableSorter.ASCENDING : TableSorter.NOT_SORTED);
- break;
- }
- }
- }
- }
-
- TableModel getTableModel() {
+ public TableModel getTableModel() {
return tableModel;
}
- void dataChanged() {
+ public void dataChanged() {
int idx = table.getSelectedRow();
tableModel.fireTableDataChanged();
if (idx != -1) {
table.getSelectionModel().addSelectionInterval(idx, idx);
}
- }
-
- public int getModelIndex(int viewIndex) {
- return sorter.modelIndex(viewIndex);
}
public int[] getSelectedItems() {
@@ -191,13 +159,14 @@ public class PropertiesTable implements
public void tableChanged(TableModelEvent event) {
table.repaint();
}
+
public class PropertiesTableCellRenderer extends DefaultTableCellRenderer {
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int rowIndex, int columnIndex) {
Component renderer = super.getTableCellRendererComponent(table, value, hasFocus, hasFocus, rowIndex, columnIndex);
if (renderer instanceof JComponent) {
- String strValue = tableModel.getNode(sorter.modelIndex(rowIndex)).getValue();
+ String strValue = tableModel.getNode(rowIndex).getValue();
((JComponent) renderer).setToolTipText(strValue);
}
setToolTipText(value.toString());