This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 125700
Collapse All | Expand All

(-)a/mercurial/src/org/netbeans/modules/mercurial/HgModuleConfig.java (+6 lines)
Lines 231-242 public class HgModuleConfig { Link Here
231
            name = getUserName();
231
            name = getUserName();
232
        if (name.length() > 0) 
232
        if (name.length() > 0) 
233
            props.setProperty("username", name); // NOI18N
233
            props.setProperty("username", name); // NOI18N
234
        else
235
            props.setProperty("username", ""); // NOI18N
234
        name = hgconfig.getDefaultPull(false);
236
        name = hgconfig.getDefaultPull(false);
235
        if (name.length() > 0) 
237
        if (name.length() > 0) 
236
            props.setProperty("default-pull", name); // NOI18N
238
            props.setProperty("default-pull", name); // NOI18N
239
        else
240
            props.setProperty("default-pull", ""); // NOI18N
237
        name = hgconfig.getDefaultPush(false);
241
        name = hgconfig.getDefaultPush(false);
238
        if (name.length() > 0) 
242
        if (name.length() > 0) 
239
            props.setProperty("default-push", name); // NOI18N
243
            props.setProperty("default-push", name); // NOI18N
244
        else
245
            props.setProperty("default-push", ""); // NOI18N
240
        return props;
246
        return props;
241
    }
247
    }
242
248
(-)a/mercurial/src/org/netbeans/modules/mercurial/options/Bundle.properties (+13 lines)
Lines 93-95 MercurialPanel.ExportFilename.text=&Defa Link Here
93
MercurialPanel.ExportFilename.text=&Default Export Filename\:
93
MercurialPanel.ExportFilename.text=&Default Export Filename\:
94
94
95
MercurialPanel.browseButton2.text=B&rowse...
95
MercurialPanel.browseButton2.text=B&rowse...
96
97
98
PropertiesPanel.jLabel2.text=Property &Name:
99
PropertiesPanel.jLabel1.text=Property &Value:
100
PropertiesPanel.btnAdd.text=&Add
101
PropertiesPanel.btnRemove.text=&Remove
102
jLabel3.txt=Mercurial &Properties:
103
ACSD_PropertiesTable = Lists of mercurial properties.
104
LBL_Properties_Progress=Scanning mercurial properties
105
106
CTL_PropertiesTable_Column_Name=Name
107
CTL_PropertiesTable_Column_Value=Value
108
(-)a/mercurial/src/org/netbeans/modules/mercurial/options/HgExtProperties.java (-2 / +2 lines)
Lines 68-75 import org.netbeans.modules.mercurial.Me Link Here
68
import org.netbeans.modules.mercurial.Mercurial;
68
import org.netbeans.modules.mercurial.Mercurial;
69
import org.netbeans.modules.mercurial.HgProgressSupport;
69
import org.netbeans.modules.mercurial.HgProgressSupport;
70
import org.netbeans.modules.mercurial.HgModuleConfig;
70
import org.netbeans.modules.mercurial.HgModuleConfig;
71
import org.netbeans.modules.mercurial.ui.properties.PropertiesPanel;
71
import org.netbeans.modules.mercurial.options.PropertiesPanel;
72
import org.netbeans.modules.mercurial.ui.properties.PropertiesTable;
72
import org.netbeans.modules.mercurial.options.PropertiesTable;
73
import org.netbeans.modules.mercurial.ui.properties.HgPropertiesNode;
73
import org.netbeans.modules.mercurial.ui.properties.HgPropertiesNode;
74
import org.netbeans.modules.versioning.util.AccessibleJFileChooser;
74
import org.netbeans.modules.versioning.util.AccessibleJFileChooser;
75
import org.netbeans.modules.versioning.util.Utils;
75
import org.netbeans.modules.versioning.util.Utils;
(-)a/mercurial/src/org/netbeans/modules/mercurial/options/MercurialOptionsPanelController.java (-3 / +3 lines)
Lines 60-68 import org.netbeans.modules.mercurial.Me Link Here
60
import org.netbeans.modules.mercurial.Mercurial;
60
import org.netbeans.modules.mercurial.Mercurial;
61
import org.netbeans.modules.mercurial.MercurialAnnotator;
61
import org.netbeans.modules.mercurial.MercurialAnnotator;
62
import org.netbeans.modules.mercurial.HgModuleConfig;
62
import org.netbeans.modules.mercurial.HgModuleConfig;
63
import org.netbeans.modules.mercurial.ui.properties.PropertiesPanel;
63
import org.netbeans.modules.mercurial.options.PropertiesPanel;
64
import org.netbeans.modules.mercurial.ui.properties.PropertiesTable;
64
import org.netbeans.modules.mercurial.options.PropertiesTable;
65
import org.netbeans.modules.mercurial.ui.properties.PropertiesTableModel;
65
import org.netbeans.modules.mercurial.options.PropertiesTableModel;
66
import org.netbeans.spi.options.OptionsPanelController;
66
import org.netbeans.spi.options.OptionsPanelController;
67
import org.netbeans.modules.versioning.util.AccessibleJFileChooser;
67
import org.netbeans.modules.versioning.util.AccessibleJFileChooser;
68
import org.openide.DialogDescriptor;
68
import org.openide.DialogDescriptor;
(-)0ca1a28c477b (+174 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8" ?>
2
3
<Form version="1.4" maxVersion="1.4" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
4
  <AuxValues>
5
    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
6
    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="true"/>
7
    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/>
8
    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
9
    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
10
    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
11
    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
12
  </AuxValues>
13
14
  <Layout>
15
    <DimensionLayout dim="0">
16
      <Group type="103" groupAlignment="0" attributes="0">
17
          <Group type="102" alignment="0" attributes="0">
18
              <EmptySpace max="-2" attributes="0"/>
19
              <Group type="103" groupAlignment="0" attributes="0">
20
                  <Component id="propsPanel" alignment="0" max="32767" attributes="1"/>
21
                  <Group type="102" alignment="0" attributes="0">
22
                      <Group type="103" groupAlignment="0" attributes="0">
23
                          <Component id="jLabel2" alignment="0" min="-2" max="-2" attributes="1"/>
24
                          <Component id="btnAdd" linkSize="1" min="-2" max="-2" attributes="1"/>
25
                          <Component id="jLabel3" alignment="0" min="-2" max="-2" attributes="0"/>
26
                          <Component id="jLabel1" alignment="0" min="-2" max="-2" attributes="0"/>
27
                      </Group>
28
                      <Group type="103" groupAlignment="1" attributes="0">
29
                          <Group type="103" groupAlignment="1" attributes="0">
30
                              <Component id="comboName" alignment="0" pref="307" max="32767" attributes="1"/>
31
                              <Component id="jScrollPane1" alignment="1" pref="307" max="32767" attributes="1"/>
32
                          </Group>
33
                          <Group type="102" alignment="1" attributes="0">
34
                              <EmptySpace max="-2" attributes="0"/>
35
                              <Component id="btnRemove" linkSize="1" min="-2" max="-2" attributes="0"/>
36
                          </Group>
37
                      </Group>
38
                  </Group>
39
              </Group>
40
              <EmptySpace max="-2" attributes="0"/>
41
          </Group>
42
      </Group>
43
    </DimensionLayout>
44
    <DimensionLayout dim="1">
45
      <Group type="103" groupAlignment="0" attributes="0">
46
          <Group type="102" attributes="0">
47
              <EmptySpace min="-2" max="-2" attributes="0"/>
48
              <Group type="103" groupAlignment="3" attributes="0">
49
                  <Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/>
50
                  <Component id="comboName" alignment="3" min="-2" max="-2" attributes="0"/>
51
              </Group>
52
              <EmptySpace max="-2" attributes="0"/>
53
              <Group type="103" groupAlignment="0" attributes="0">
54
                  <Group type="102" attributes="0">
55
                      <Component id="jLabel1" min="-2" max="-2" attributes="0"/>
56
                      <EmptySpace min="-2" pref="99" max="-2" attributes="0"/>
57
                      <Group type="103" groupAlignment="3" attributes="0">
58
                          <Component id="btnAdd" alignment="3" min="-2" max="-2" attributes="0"/>
59
                          <Component id="btnRemove" alignment="3" min="-2" max="-2" attributes="0"/>
60
                      </Group>
61
                      <EmptySpace min="-2" pref="26" max="-2" attributes="0"/>
62
                      <Component id="jLabel3" min="-2" max="-2" attributes="0"/>
63
                      <EmptySpace min="-2" pref="12" max="-2" attributes="0"/>
64
                  </Group>
65
                  <Component id="jScrollPane1" alignment="0" min="-2" max="-2" attributes="0"/>
66
              </Group>
67
              <EmptySpace pref="13" max="32767" attributes="0"/>
68
              <Component id="propsPanel" min="-2" max="-2" attributes="0"/>
69
          </Group>
70
      </Group>
71
    </DimensionLayout>
72
  </Layout>
73
  <SubComponents>
74
    <Component class="javax.swing.JLabel" name="jLabel2">
75
      <Properties>
76
        <Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
77
          <ComponentRef name="comboName"/>
78
        </Property>
79
        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
80
          <ResourceString bundle="org/netbeans/modules/mercurial/options/Bundle.properties" key="PropertiesPanel.jLabel2.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
81
        </Property>
82
      </Properties>
83
    </Component>
84
    <Component class="javax.swing.JComboBox" name="comboName">
85
      <Properties>
86
        <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
87
          <StringArray count="0"/>
88
        </Property>
89
      </Properties>
90
      <AuxValues>
91
        <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="16"/>
92
      </AuxValues>
93
    </Component>
94
    <Component class="javax.swing.JLabel" name="jLabel1">
95
      <Properties>
96
        <Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
97
          <ComponentRef name="txtAreaValue"/>
98
        </Property>
99
        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
100
          <ResourceString bundle="org/netbeans/modules/mercurial/options/Bundle.properties" key="PropertiesPanel.jLabel1.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
101
        </Property>
102
      </Properties>
103
    </Component>
104
    <Container class="javax.swing.JPanel" name="propsPanel">
105
      <AuxValues>
106
        <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="1"/>
107
      </AuxValues>
108
109
      <Layout>
110
        <DimensionLayout dim="0">
111
          <Group type="103" groupAlignment="0" attributes="0">
112
              <EmptySpace min="0" pref="420" max="32767" attributes="0"/>
113
          </Group>
114
        </DimensionLayout>
115
        <DimensionLayout dim="1">
116
          <Group type="103" groupAlignment="0" attributes="0">
117
              <EmptySpace min="0" pref="99" max="32767" attributes="0"/>
118
          </Group>
119
        </DimensionLayout>
120
      </Layout>
121
    </Container>
122
    <Container class="javax.swing.JScrollPane" name="jScrollPane1">
123
      <AuxValues>
124
        <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
125
      </AuxValues>
126
127
      <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
128
      <SubComponents>
129
        <Component class="javax.swing.JTextArea" name="txtAreaValue">
130
          <Properties>
131
            <Property name="columns" type="int" value="20"/>
132
            <Property name="rows" type="int" value="5"/>
133
          </Properties>
134
          <AuxValues>
135
            <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="16"/>
136
          </AuxValues>
137
        </Component>
138
      </SubComponents>
139
    </Container>
140
    <Component class="javax.swing.JButton" name="btnRemove">
141
      <Properties>
142
        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
143
          <ResourceString bundle="org/netbeans/modules/mercurial/options/Bundle.properties" key="PropertiesPanel.btnRemove.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
144
        </Property>
145
      </Properties>
146
      <AuxValues>
147
        <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="16"/>
148
      </AuxValues>
149
    </Component>
150
    <Component class="javax.swing.JButton" name="btnAdd">
151
      <Properties>
152
        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
153
          <ResourceString bundle="org/netbeans/modules/mercurial/options/Bundle.properties" key="PropertiesPanel.btnAdd.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
154
        </Property>
155
        <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
156
          <Dimension value="[75, 23]"/>
157
        </Property>
158
        <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
159
          <Dimension value="[75, 23]"/>
160
        </Property>
161
      </Properties>
162
      <AuxValues>
163
        <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="16"/>
164
      </AuxValues>
165
    </Component>
166
    <Component class="javax.swing.JLabel" name="jLabel3">
167
      <Properties>
168
        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
169
          <ResourceString bundle="org/netbeans/modules/mercurial/options/Bundle.properties" key="jLabel3.txt" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
170
        </Property>
171
      </Properties>
172
    </Component>
173
  </SubComponents>
174
</Form>
(-)0ca1a28c477b (+217 lines)
Added Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of either the GNU
7
 * General Public License Version 2 only ("GPL") or the Common
8
 * Development and Distribution License("CDDL") (collectively, the
9
 * "License"). You may not use this file except in compliance with the
10
 * License. You can obtain a copy of the License at
11
 * http://www.netbeans.org/cddl-gplv2.html
12
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
 * specific language governing permissions and limitations under the
14
 * License.  When distributing the software, include this License Header
15
 * Notice in each file and include the License file at
16
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
17
 * particular file as subject to the "Classpath" exception as provided
18
 * by Sun in the GPL Version 2 section of the License file that
19
 * accompanied this code. If applicable, add the following below the
20
 * License Header, with the fields enclosed by brackets [] replaced by
21
 * your own identifying information:
22
 * "Portions Copyrighted [year] [name of copyright owner]"
23
 *
24
 * Contributor(s):
25
 *
26
 * The Original Software is NetBeans. The Initial Developer of the Original
27
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
28
 * Microsystems, Inc. All Rights Reserved.
29
 *
30
 * If you wish your version of this file to be governed by only the CDDL
31
 * or only the GPL Version 2, indicate your decision by adding
32
 * "[Contributor] elects to include this software in this distribution
33
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
34
 * single choice of license, a recipient has the option to distribute
35
 * your version of this file under either the CDDL, the GPL Version 2 or
36
 * to extend the choice of license to its licensees as provided above.
37
 * However, if you add GPL Version 2 code and therefore, elected the GPL
38
 * Version 2 license, then the option applies only if the new code is
39
 * made subject to such option by the copyright holder.
40
 */
41
package org.netbeans.modules.mercurial.options;
42
43
import java.util.prefs.PreferenceChangeEvent;
44
import java.util.prefs.PreferenceChangeListener;
45
import javax.swing.event.TableModelEvent;
46
import javax.swing.event.TableModelListener;
47
import org.netbeans.modules.mercurial.HgModuleConfig;
48
import org.netbeans.modules.mercurial.options.PropertiesTable;
49
import org.netbeans.modules.versioning.util.ListenersSupport;
50
51
/**
52
 *
53
 * @author  Peter Pis
54
 */
55
public class PropertiesPanel extends javax.swing.JPanel implements PreferenceChangeListener, TableModelListener {
56
57
    private static final Object EVENT_SETTINGS_CHANGED = new Object();
58
    private PropertiesTable propertiesTable;
59
    private ListenersSupport listenerSupport = new ListenersSupport(this);
60
    
61
    /** Creates new form PropertiesPanel */
62
    public PropertiesPanel() {
63
        initComponents();
64
    }
65
    
66
    public javax.swing.JTextArea getTxtAreaValue() {
67
        return txtAreaValue;
68
    }
69
70
    public javax.swing.JComboBox getComboName() {
71
        return comboName;
72
    }
73
74
    public javax.swing.JButton getBtnAdd() {
75
        return btnAdd;
76
    }
77
78
    public javax.swing.JButton getBtnRemove() {
79
        return btnRemove;
80
    }
81
82
    public void setPropertiesTable(PropertiesTable propertiesTable){
83
        this.propertiesTable = propertiesTable;
84
    }
85
    
86
    public void addNotify() {
87
        super.addNotify();
88
        HgModuleConfig.getDefault().getPreferences().addPreferenceChangeListener(this);        
89
        propertiesTable.getTableModel().addTableModelListener(this);
90
        listenerSupport.fireVersioningEvent(EVENT_SETTINGS_CHANGED);
91
        txtAreaValue.selectAll();
92
    }
93
94
    public void removeNotify() {
95
        propertiesTable.getTableModel().removeTableModelListener(this);
96
        HgModuleConfig.getDefault().getPreferences().removePreferenceChangeListener(this);
97
        super.removeNotify();
98
    }
99
    
100
    public void preferenceChange(PreferenceChangeEvent evt) {
101
        if (evt.getKey().startsWith(HgModuleConfig.PROP_COMMIT_EXCLUSIONS)) {
102
            propertiesTable.dataChanged();
103
            listenerSupport.fireVersioningEvent(EVENT_SETTINGS_CHANGED);
104
        }
105
    }
106
107
    public void tableChanged(TableModelEvent e) {
108
        listenerSupport.fireVersioningEvent(EVENT_SETTINGS_CHANGED);
109
    }
110
    
111
    /** This method is called from within the constructor to
112
     * initialize the form.
113
     * WARNING: Do NOT modify this code. The content of this method is
114
     * always regenerated by the Form Editor.
115
     */
116
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
117
    private void initComponents() {
118
119
        jLabel2 = new javax.swing.JLabel();
120
        jLabel1 = new javax.swing.JLabel();
121
        propsPanel = new javax.swing.JPanel();
122
        jScrollPane1 = new javax.swing.JScrollPane();
123
        jLabel3 = new javax.swing.JLabel();
124
125
        jLabel2.setLabelFor(comboName);
126
        org.openide.awt.Mnemonics.setLocalizedText(jLabel2, org.openide.util.NbBundle.getMessage(PropertiesPanel.class, "PropertiesPanel.jLabel2.text")); // NOI18N
127
128
        jLabel1.setLabelFor(txtAreaValue);
129
        org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(PropertiesPanel.class, "PropertiesPanel.jLabel1.text")); // NOI18N
130
131
        org.jdesktop.layout.GroupLayout propsPanelLayout = new org.jdesktop.layout.GroupLayout(propsPanel);
132
        propsPanel.setLayout(propsPanelLayout);
133
        propsPanelLayout.setHorizontalGroup(
134
            propsPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
135
            .add(0, 420, Short.MAX_VALUE)
136
        );
137
        propsPanelLayout.setVerticalGroup(
138
            propsPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
139
            .add(0, 99, Short.MAX_VALUE)
140
        );
141
142
        txtAreaValue.setColumns(20);
143
        txtAreaValue.setRows(5);
144
        jScrollPane1.setViewportView(txtAreaValue);
145
146
        org.openide.awt.Mnemonics.setLocalizedText(btnRemove, org.openide.util.NbBundle.getMessage(PropertiesPanel.class, "PropertiesPanel.btnRemove.text")); // NOI18N
147
148
        org.openide.awt.Mnemonics.setLocalizedText(btnAdd, org.openide.util.NbBundle.getMessage(PropertiesPanel.class, "PropertiesPanel.btnAdd.text")); // NOI18N
149
        btnAdd.setMaximumSize(new java.awt.Dimension(75, 23));
150
        btnAdd.setMinimumSize(new java.awt.Dimension(75, 23));
151
152
        org.openide.awt.Mnemonics.setLocalizedText(jLabel3, org.openide.util.NbBundle.getMessage(PropertiesPanel.class, "jLabel3.txt")); // NOI18N
153
154
        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
155
        this.setLayout(layout);
156
        layout.setHorizontalGroup(
157
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
158
            .add(layout.createSequentialGroup()
159
                .addContainerGap()
160
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
161
                    .add(propsPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
162
                    .add(layout.createSequentialGroup()
163
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
164
                            .add(jLabel2)
165
                            .add(btnAdd, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
166
                            .add(jLabel3)
167
                            .add(jLabel1))
168
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
169
                            .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
170
                                .add(org.jdesktop.layout.GroupLayout.LEADING, comboName, 0, 307, Short.MAX_VALUE)
171
                                .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 307, Short.MAX_VALUE))
172
                            .add(layout.createSequentialGroup()
173
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
174
                                .add(btnRemove)))))
175
                .addContainerGap())
176
        );
177
178
        layout.linkSize(new java.awt.Component[] {btnAdd, btnRemove}, org.jdesktop.layout.GroupLayout.HORIZONTAL);
179
180
        layout.setVerticalGroup(
181
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
182
            .add(layout.createSequentialGroup()
183
                .addContainerGap()
184
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
185
                    .add(jLabel2)
186
                    .add(comboName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
187
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
188
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
189
                    .add(layout.createSequentialGroup()
190
                        .add(jLabel1)
191
                        .add(99, 99, 99)
192
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
193
                            .add(btnAdd, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
194
                            .add(btnRemove))
195
                        .add(26, 26, 26)
196
                        .add(jLabel3)
197
                        .add(12, 12, 12))
198
                    .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
199
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 13, Short.MAX_VALUE)
200
                .add(propsPanel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
201
        );
202
    }// </editor-fold>//GEN-END:initComponents
203
    
204
    
205
    // Variables declaration - do not modify//GEN-BEGIN:variables
206
    final javax.swing.JButton btnAdd = new javax.swing.JButton();
207
    final javax.swing.JButton btnRemove = new javax.swing.JButton();
208
    final javax.swing.JComboBox comboName = new javax.swing.JComboBox();
209
    private javax.swing.JLabel jLabel1;
210
    private javax.swing.JLabel jLabel2;
211
    private javax.swing.JLabel jLabel3;
212
    private javax.swing.JScrollPane jScrollPane1;
213
    public javax.swing.JPanel propsPanel;
214
    final javax.swing.JTextArea txtAreaValue = new javax.swing.JTextArea();
215
    // End of variables declaration//GEN-END:variables
216
    
217
}
(-)0ca1a28c477b (+211 lines)
Added Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of either the GNU
7
 * General Public License Version 2 only ("GPL") or the Common
8
 * Development and Distribution License("CDDL") (collectively, the
9
 * "License"). You may not use this file except in compliance with the
10
 * License. You can obtain a copy of the License at
11
 * http://www.netbeans.org/cddl-gplv2.html
12
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
 * specific language governing permissions and limitations under the
14
 * License.  When distributing the software, include this License Header
15
 * Notice in each file and include the License file at
16
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
17
 * particular file as subject to the "Classpath" exception as provided
18
 * by Sun in the GPL Version 2 section of the License file that
19
 * accompanied this code. If applicable, add the following below the
20
 * License Header, with the fields enclosed by brackets [] replaced by
21
 * your own identifying information:
22
 * "Portions Copyrighted [year] [name of copyright owner]"
23
 *
24
 * Contributor(s):
25
 *
26
 * The Original Software is NetBeans. The Initial Developer of the Original
27
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
28
 * Microsystems, Inc. All Rights Reserved.
29
 *
30
 * If you wish your version of this file to be governed by only the CDDL
31
 * or only the GPL Version 2, indicate your decision by adding
32
 * "[Contributor] elects to include this software in this distribution
33
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
34
 * single choice of license, a recipient has the option to distribute
35
 * your version of this file under either the CDDL, the GPL Version 2 or
36
 * to extend the choice of license to its licensees as provided above.
37
 * However, if you add GPL Version 2 code and therefore, elected the GPL
38
 * Version 2 license, then the option applies only if the new code is
39
 * made subject to such option by the copyright holder.
40
 */
41
package org.netbeans.modules.mercurial.options;
42
43
import java.awt.Component;
44
import java.awt.Dimension;
45
import java.util.Arrays;
46
import javax.swing.JComponent;
47
import javax.swing.JScrollPane;
48
import javax.swing.JTable;
49
import javax.swing.event.AncestorEvent;
50
import javax.swing.event.AncestorListener;
51
import javax.swing.event.TableModelEvent;
52
import javax.swing.event.TableModelListener;
53
import javax.swing.table.DefaultTableCellRenderer;
54
import javax.swing.table.TableColumnModel;
55
import javax.swing.table.TableModel;
56
import org.netbeans.modules.versioning.util.TableSorter;
57
import org.netbeans.modules.mercurial.ui.properties.HgPropertiesNode;
58
import org.netbeans.modules.mercurial.options.PropertiesTableModel;
59
import org.openide.util.NbBundle;
60
61
/**
62
 *
63
 * @author Peter Pis
64
 */
65
public class PropertiesTable implements AncestorListener, TableModelListener {
66
    
67
    static public final String[] PROPERTIES_COLUMNS = new String[] {PropertiesTableModel.COLUMN_NAME_NAME, PropertiesTableModel.COLUMN_NAME_VALUE};
68
            
69
    private PropertiesTableModel tableModel;
70
    private JTable table;
71
    private TableSorter sorter;
72
    private JComponent component;
73
    private String[] columns;
74
    private String[] sortByColumns;
75
    
76
    /** Creates a new instance of PropertiesTable */
77
    public PropertiesTable(String[] columns, String[] sortByColumns) {
78
        init(columns, null);
79
        this.sortByColumns = sortByColumns;
80
        setSortingStatus();
81
    }
82
    
83
    public PropertiesTable(String[] columns, TableSorter sorter) {
84
        init(columns, sorter);
85
    } 
86
    
87
    private void init(String[] columns, TableSorter sorter) {
88
        tableModel = new PropertiesTableModel(columns);
89
        tableModel.addTableModelListener(this);
90
        if(sorter == null) {
91
            sorter = new TableSorter(tableModel);
92
        } 
93
        this.sorter = sorter;   
94
        table = new JTable(this.sorter);
95
        table.getTableHeader().setReorderingAllowed(false);
96
        table.setDefaultRenderer(String.class, new PropertiesTableCellRenderer());
97
        //table.setDefaultEditor(CommitOptions.class, new CommitOptionsCellEditor());
98
        table.getTableHeader().setReorderingAllowed(true);
99
        this.sorter.setTableHeader(table.getTableHeader());
100
        table.setRowHeight(table.getRowHeight());
101
        table.addAncestorListener(this);
102
        component = new JScrollPane(table, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
103
        component.setPreferredSize(new Dimension(340, 150));
104
        table.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(PropertiesTable.class, "ACSD_PropertiesTable")); // NOI18N        
105
        setColumns(columns);
106
    }
107
    
108
    public void setColumns(String[] clmns) {
109
        if (Arrays.equals(columns, clmns))
110
            return;
111
        columns = clmns;
112
        tableModel.setColumns(clmns);
113
        setDefaultColumnSize();
114
    }
115
    
116
    public JTable getTable() {
117
        return table;
118
    }
119
    
120
    private void setDefaultColumnSize() {
121
        int width = table.getWidth();
122
        TableColumnModel columnModel = table.getColumnModel();
123
        if (columns == null || columnModel == null)
124
            return;
125
        if (columnModel.getColumnCount() != columns.length)
126
            return;
127
        for (int i = 0; i < columns.length; i++) {
128
            String col = columns[i];                                
129
            sorter.setColumnComparator(i, null);                    
130
            if (col.equals(PropertiesTableModel.COLUMN_NAME_NAME)) {
131
                columnModel.getColumn(i).setPreferredWidth(width * 20 / 100);
132
            } else if (col.equals(PropertiesTableModel.COLUMN_NAME_VALUE)) {
133
                columnModel.getColumn(i).setPreferredWidth(width * 40 / 100);
134
            }
135
        }
136
    }
137
    
138
    private void setSortingStatus() {
139
        for (int i = 0; i < sortByColumns.length; i++) {
140
            String sortByColumn = sortByColumns[i];        
141
            for (int j = 0; j < columns.length; j++) {
142
                String column = columns[j];
143
                if(column.equals(sortByColumn)) {
144
                    sorter.setSortingStatus(j, column.equals(sortByColumn) ? TableSorter.ASCENDING : TableSorter.NOT_SORTED);                       
145
                    break;
146
                }                    
147
            }                        
148
        }        
149
    }
150
    
151
    TableModel getTableModel() {
152
        return tableModel;
153
    }
154
    
155
    void dataChanged() {
156
        int idx = table.getSelectedRow();
157
        tableModel.fireTableDataChanged();
158
        if (idx != -1) {
159
            table.getSelectionModel().addSelectionInterval(idx, idx);
160
        }    
161
    }
162
    
163
    public int getModelIndex(int viewIndex) {
164
        return sorter.modelIndex(viewIndex);
165
    }
166
    
167
    public int[] getSelectedItems() {
168
        return table.getSelectedRows();
169
    }
170
     
171
    public HgPropertiesNode[] getNodes() {
172
        return tableModel.getNodes();
173
    }
174
    
175
    public void setNodes(HgPropertiesNode[] nodes) {
176
        tableModel.setNodes(nodes);
177
    }
178
    
179
    public JComponent getComponent() {
180
        return component;
181
    }
182
    
183
    public void ancestorAdded(AncestorEvent arg0) {
184
        setDefaultColumnSize();
185
    }
186
187
    public void ancestorRemoved(AncestorEvent arg0) {
188
    }
189
190
    public void ancestorMoved(AncestorEvent arg0) {
191
    }
192
193
    public void tableChanged(TableModelEvent event) {
194
        table.repaint();
195
    }
196
197
    public class PropertiesTableCellRenderer extends DefaultTableCellRenderer {
198
           
199
        public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int rowIndex, int columnIndex) {
200
            Component renderer =  super.getTableCellRendererComponent(table, value, hasFocus, hasFocus, rowIndex, columnIndex);
201
            if (renderer instanceof JComponent) {
202
                String strValue = tableModel.getNode(sorter.modelIndex(rowIndex)).getValue(); 
203
                ((JComponent) renderer).setToolTipText(strValue);
204
            }
205
            setToolTipText(value.toString());
206
            return renderer;
207
        }
208
    }
209
    
210
    
211
}
(-)0ca1a28c477b (+120 lines)
Added Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of either the GNU
7
 * General Public License Version 2 only ("GPL") or the Common
8
 * Development and Distribution License("CDDL") (collectively, the
9
 * "License"). You may not use this file except in compliance with the
10
 * License. You can obtain a copy of the License at
11
 * http://www.netbeans.org/cddl-gplv2.html
12
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
 * specific language governing permissions and limitations under the
14
 * License.  When distributing the software, include this License Header
15
 * Notice in each file and include the License file at
16
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
17
 * particular file as subject to the "Classpath" exception as provided
18
 * by Sun in the GPL Version 2 section of the License file that
19
 * accompanied this code. If applicable, add the following below the
20
 * License Header, with the fields enclosed by brackets [] replaced by
21
 * your own identifying information:
22
 * "Portions Copyrighted [year] [name of copyright owner]"
23
 *
24
 * Contributor(s):
25
 *
26
 * The Original Software is NetBeans. The Initial Developer of the Original
27
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
28
 * Microsystems, Inc. All Rights Reserved.
29
 *
30
 * If you wish your version of this file to be governed by only the CDDL
31
 * or only the GPL Version 2, indicate your decision by adding
32
 * "[Contributor] elects to include this software in this distribution
33
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
34
 * single choice of license, a recipient has the option to distribute
35
 * your version of this file under either the CDDL, the GPL Version 2 or
36
 * to extend the choice of license to its licensees as provided above.
37
 * However, if you add GPL Version 2 code and therefore, elected the GPL
38
 * Version 2 license, then the option applies only if the new code is
39
 * made subject to such option by the copyright holder.
40
 */
41
package org.netbeans.modules.mercurial.options;
42
43
import java.util.Arrays;
44
import java.util.HashMap;
45
import java.util.Map;
46
import java.util.ResourceBundle;
47
import javax.swing.table.AbstractTableModel;
48
import org.openide.util.NbBundle;
49
import org.netbeans.modules.mercurial.ui.properties.HgPropertiesNode;
50
51
/**
52
 *
53
 * @author Peter Pis
54
 */
55
public class PropertiesTableModel extends AbstractTableModel {
56
    
57
    public static final String COLUMN_NAME_NAME = "name"; // NOI18N
58
    public static final String COLUMN_NAME_VALUE = "value"; // NOI18N
59
    
60
    private HgPropertiesNode[] nodes;
61
    private String[] columns;
62
    
63
    private static final Map<String, String[]> columnLabels = new HashMap<String, String[]>(2); 
64
    
65
    {
66
        ResourceBundle loc = NbBundle.getBundle(PropertiesTableModel.class);    
67
        columnLabels.put(COLUMN_NAME_NAME, new String[] {loc.getString("CTL_PropertiesTable_Column_Name"), loc.getString("CTL_PropertiesTable_Column_Name")}); // NOI18N
68
        columnLabels.put(COLUMN_NAME_VALUE, new String[] {loc.getString("CTL_PropertiesTable_Column_Value"), loc.getString("CTL_PropertiesTable_Column_Value")}); // NOI18N
69
    }
70
    
71
    /** Creates a new instance of PropertiesTableModel */
72
    public PropertiesTableModel(String[] clms) {
73
        if (Arrays.equals(columns, clms))
74
            return;
75
        setColumns(clms);
76
        setNodes(new HgPropertiesNode[0]);
77
    }
78
    
79
    public void setColumns(String[] clms) {
80
        this.columns = clms;
81
        fireTableStructureChanged();
82
    }
83
    
84
    public void setNodes(HgPropertiesNode[] nodes) {
85
        this.nodes = nodes;
86
        fireTableDataChanged();
87
    }
88
    
89
    public HgPropertiesNode[] getNodes() {
90
        return nodes;
91
    }
92
    
93
    public HgPropertiesNode getNode(int row) {
94
        return nodes[row];
95
    }
96
    
97
    public int getRowCount() {
98
        return nodes.length;
99
    }
100
101
    public String getColumnName(int column) {
102
        return columnLabels.get(columns[column])[0];
103
    }
104
    
105
    public int getColumnCount() {
106
        return columns.length;
107
    }
108
109
    public Object getValueAt(int rowIndex, int columnIndex) {
110
        String clm = columns[columnIndex];
111
        if (clm.equals(COLUMN_NAME_NAME)) {
112
            return nodes[rowIndex].getName();
113
        } else if (clm.equals(COLUMN_NAME_VALUE)) {
114
            return nodes[rowIndex].getValue();
115
        }
116
        throw new IllegalArgumentException("The column index is out of index: " + columnIndex); // NOI18N
117
    }
118
119
    
120
}
(-)a/mercurial/src/org/netbeans/modules/mercurial/ui/properties/Bundle.properties (-8 lines)
Lines 44-61 CTL_Properties_Action_OK = &OK Link Here
44
CTL_Properties_Action_OK = &OK
44
CTL_Properties_Action_OK = &OK
45
ACSN_Properties_Action_OK = OK
45
ACSN_Properties_Action_OK = OK
46
ACSD_Properties_Action_OK = OK
46
ACSD_Properties_Action_OK = OK
47
PropertiesPanel.jLabel2.text=Property &Name:
48
PropertiesPanel.jLabel1.text=Property &Value:
47
PropertiesPanel.jLabel1.text=Property &Value:
49
#
48
#
50
MSG_PROPERTIES_INVALID_MESSAGE = The specified value, {0}, for the property {1} is invalid
51
MSG_PROPERTIES_INVALID_TITLE = Invalid Property Value
52
CTL_PropertiesTable_Column_Name=Name
49
CTL_PropertiesTable_Column_Name=Name
53
CTL_PropertiesTable_Column_Value=Value
50
CTL_PropertiesTable_Column_Value=Value
54
ACSD_PropertiesTable = Lists of mercurial properties.
51
ACSD_PropertiesTable = Lists of mercurial properties.
55
LBL_Properties_Progress=Scanning mercurial properties
52
LBL_Properties_Progress=Scanning mercurial properties
56
PropertiesPanel.btnAdd.text=&Add
57
PropertiesPanel.btnRemove.text=&Remove
58
jLabel3.txt=Mercurial &Properties:
53
jLabel3.txt=Mercurial &Properties:
59
CTL_Properties_Action_Modify = &Modify
60
ACSN_Properties_Action_Modify = Modify
61
ACSD_Properties_Action_Modify = Modify
(-)a/mercurial/src/org/netbeans/modules/mercurial/ui/properties/HgProperties.java (-143 / +26 lines)
Lines 45-52 import java.awt.Font; Link Here
45
import java.awt.Font;
45
import java.awt.Font;
46
import java.awt.event.ActionEvent;
46
import java.awt.event.ActionEvent;
47
import java.awt.event.ActionListener;
47
import java.awt.event.ActionListener;
48
import java.awt.event.MouseAdapter;
49
import java.awt.event.MouseEvent;
50
import java.io.File;
48
import java.io.File;
51
import java.io.FileReader;
49
import java.io.FileReader;
52
import java.io.IOException;
50
import java.io.IOException;
Lines 62-69 import javax.swing.DefaultComboBoxModel; Link Here
62
import javax.swing.DefaultComboBoxModel;
60
import javax.swing.DefaultComboBoxModel;
63
import javax.swing.JFileChooser;
61
import javax.swing.JFileChooser;
64
import javax.swing.JTextField;
62
import javax.swing.JTextField;
63
import javax.swing.ListSelectionModel;
65
import javax.swing.event.DocumentEvent;
64
import javax.swing.event.DocumentEvent;
66
import javax.swing.event.DocumentListener;
65
import javax.swing.event.DocumentListener;
66
import javax.swing.event.ListSelectionEvent;
67
import javax.swing.event.ListSelectionListener;
67
import javax.swing.text.Document;
68
import javax.swing.text.Document;
68
import org.netbeans.modules.mercurial.Mercurial;
69
import org.netbeans.modules.mercurial.Mercurial;
69
import org.netbeans.modules.mercurial.HgProgressSupport;
70
import org.netbeans.modules.mercurial.HgProgressSupport;
Lines 80-88 import org.openide.NotifyDescriptor; Link Here
80
81
81
/**
82
/**
82
 *
83
 *
83
 * @author Peter Pis
84
 * @author Padraig O'Briain
84
 */
85
 */
85
public class HgProperties implements ActionListener, DocumentListener {
86
public class HgProperties implements ListSelectionListener {
86
    
87
    
87
    private static final String HGPROPNAME_USERNAME = "username"; // NOI18N
88
    private static final String HGPROPNAME_USERNAME = "username"; // NOI18N
88
    private static final String HGPROPNAME_DEFAULT_PULL = "default-pull"; // NOI18N
89
    private static final String HGPROPNAME_DEFAULT_PULL = "default-pull"; // NOI18N
Lines 100-113 public class HgProperties implements Act Link Here
100
        this.panel = panel;
101
        this.panel = panel;
101
        this.propTable = propTable;
102
        this.propTable = propTable;
102
        this.root = root;
103
        this.root = root;
103
        panel.txtAreaValue.getDocument().addDocumentListener(this);
104
        propTable.getTable().getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
104
        ((JTextField) panel.comboName.getEditor().getEditorComponent()).getDocument().addDocumentListener(this);
105
        propTable.getTable().getSelectionModel().addListSelectionListener(this);
105
        propTable.getTable().addMouseListener(new TableMouseListener());
106
        
106
        panel.btnAdd.addActionListener(this);
107
        panel.btnRemove.addActionListener(this);
108
        initPropertyNameCbx();
109
        refreshProperties();
107
        refreshProperties();
110
        
111
    }
108
    }
112
    
109
    
113
    public PropertiesPanel getPropertiesPanel() {
110
    public PropertiesPanel getPropertiesPanel() {
Lines 126-162 public class HgProperties implements Act Link Here
126
        this.root = root;
123
        this.root = root;
127
    }
124
    }
128
    
125
    
129
    public void actionPerformed(ActionEvent event) {
130
        Object source = event.getSource();
131
        
132
        if (source.equals(panel.btnAdd)) {
133
            addProperty();
134
        }
135
        
136
        if (source.equals(panel.btnRemove)) {
137
            removeProperties();
138
        }
139
        
140
    }
141
    
142
    protected void initPropertyNameCbx() {
143
        List<String> lstName = new ArrayList<String>(8);
144
145
        lstName.add(HGPROPNAME_DEFAULT_PULL);
146
        lstName.add(HGPROPNAME_DEFAULT_PUSH);
147
        lstName.add(HGPROPNAME_USERNAME);
148
149
        ComboBoxModel comboModel = new DefaultComboBoxModel(new Vector<String>(lstName));
150
        panel.comboName.setModel(comboModel);
151
        panel.comboName.setSelectedIndex(0);
152
    }
153
    
154
    protected String getPropertyValue() {
126
    protected String getPropertyValue() {
155
        return panel.txtAreaValue.getText();
127
        return panel.txtAreaValue.getText();
156
    }
157
    
158
    protected String getPropertyName() {
159
        return ((String)panel.comboName.getSelectedItem()).trim();
160
    }
128
    }
161
    
129
    
162
    protected void refreshProperties() {        
130
    protected void refreshProperties() {        
Lines 184-229 public class HgProperties implements Act Link Here
184
        }
152
        }
185
    }
153
    }
186
    
154
    
187
    private boolean addProperty(String name, String value) {
188
        if (name.equals(HGPROPNAME_USERNAME)) {
189
            if (!HgModuleConfig.getDefault().isUserNameValid(value)) {
190
                try {
191
                    JOptionPane.showMessageDialog(null, 
192
                        NbBundle.getMessage(HgProperties.class, "MSG_PROPERTIES_INVALID_MESSAGE", value, name),  // NOI18N
193
                        NbBundle.getMessage(HgProperties.class, "MSG_PROPERTIES_INVALID_TITLE"), JOptionPane.ERROR_MESSAGE); // NOI18N
194
                } catch (Exception ex) {
195
                    NotifyDescriptor.Exception e = new NotifyDescriptor.Exception(ex);
196
                    DialogDisplayer.getDefault().notifyLater(e);
197
                }
198
                return false;
199
            }
200
        }
201
        
202
        HgPropertiesNode[] hgPropertiesNodes = propTable.getNodes();
203
        for (int i = 0; i < hgPropertiesNodes.length; i++) {
204
            String hgPropertyName = hgPropertiesNodes[propTable.getModelIndex(i)].getName(); 
205
            if (hgPropertyName.equals(name)) {
206
                hgPropertiesNodes[propTable.getModelIndex(i)].setValue(value); 
207
                propTable.setNodes(hgPropertiesNodes);
208
                return true;
209
            } 
210
        }
211
        HgPropertiesNode[] hgProps = new HgPropertiesNode[hgPropertiesNodes.length + 1];
212
        for (int i = 0; i < hgPropertiesNodes.length; i++) {
213
            hgProps[i] = hgPropertiesNodes[i];
214
        }
215
        hgProps[hgPropertiesNodes.length] = new HgPropertiesNode(name, value);
216
        propTable.setNodes(hgProps); 
217
        return true;
218
    }
219
220
    public void addProperty() {
221
        if (addProperty(getPropertyName(), getPropertyValue())) {
222
            panel.comboName.getEditor().setItem(""); // NOI18N
223
            panel.txtAreaValue.setText(""); // NOI18N
224
        }
225
    }
226
    
227
    public void setProperties() {
155
    public void setProperties() {
228
        RequestProcessor rp = Mercurial.getInstance().getRequestProcessor(root.getAbsolutePath());
156
        RequestProcessor rp = Mercurial.getInstance().getRequestProcessor(root.getAbsolutePath());
229
        try {
157
        try {
Lines 233-241 public class HgProperties implements Act Link Here
233
                    HgModuleConfig.getDefault().removeProperty(root, "ui", HGPROPNAME_USERNAME); // NOI18N
161
                    HgModuleConfig.getDefault().removeProperty(root, "ui", HGPROPNAME_USERNAME); // NOI18N
234
                    HgPropertiesNode[] hgPropertiesNodes = propTable.getNodes();
162
                    HgPropertiesNode[] hgPropertiesNodes = propTable.getNodes();
235
                    for (int i = 0; i < hgPropertiesNodes.length; i++) {
163
                    for (int i = 0; i < hgPropertiesNodes.length; i++) {
236
                        String hgPropertyName = hgPropertiesNodes[propTable.getModelIndex(i)].getName();
164
                        String hgPropertyName = hgPropertiesNodes[i].getName();
237
                        String hgPropertyValue = hgPropertiesNodes[propTable.getModelIndex(i)].getValue();
165
                        String hgPropertyValue = hgPropertiesNodes[i].getValue();
238
                        HgModuleConfig.getDefault().setProperty(root, hgPropertyName, hgPropertyValue);
166
                        if (hgPropertyValue.trim().length() > 0 ) {
167
                            HgModuleConfig.getDefault().setProperty(root, hgPropertyName, hgPropertyValue);
168
                        }
239
                    }
169
                    }
240
                    HgRepositoryContextCache.resetPullDefault();
170
                    HgRepositoryContextCache.resetPullDefault();
241
                    HgRepositoryContextCache.resetPushDefault();
171
                    HgRepositoryContextCache.resetPushDefault();
Lines 247-313 public class HgProperties implements Act Link Here
247
        }
177
        }
248
    }
178
    }
249
179
250
    public void removeProperties() {
180
    private int lastIndex = -1;
251
        final int[] rows = propTable.getSelectedItems();
181
252
        if (rows.length == 0) return;
182
    public void valueChanged (ListSelectionEvent e) {
183
        int index = propTable.getTable().getSelectedRow();
184
        if (index < 0) {
185
            lastIndex = -1;
186
            return;
187
        }
253
        HgPropertiesNode[] hgPropertiesNodes = propTable.getNodes();
188
        HgPropertiesNode[] hgPropertiesNodes = propTable.getNodes();
254
        HgPropertiesNode[] hgProps = new HgPropertiesNode[hgPropertiesNodes.length - rows.length];
189
        if (lastIndex >= 0) {
255
        int j = 0;
190
            hgPropertiesNodes[lastIndex].setValue(getPropertyValue());
256
        int k = 0;
191
            propTable.setNodes(hgPropertiesNodes);
257
        for (int i = 0; i < hgPropertiesNodes.length; i++) {
258
            if (i != rows[j]) {
259
                hgProps[k++] = hgPropertiesNodes[propTable.getModelIndex(i)];
260
            } else {
261
                if (j < rows.length - 1) j++;
262
            }
263
        }
192
        }
264
        propTable.setNodes(hgProps);
193
        panel.txtAreaValue.setText(hgPropertiesNodes[index].getValue());
265
    }
194
        lastIndex = index;
266
    
267
    public void insertUpdate(DocumentEvent event) {
268
        validateUserInput(event);
269
    }
270
271
    public void removeUpdate(DocumentEvent event) {
272
        validateUserInput(event);
273
    }
274
275
    public void changedUpdate(DocumentEvent event) {
276
        validateUserInput(event);
277
    }
278
    
279
    private void validateUserInput(DocumentEvent event) {
280
        
281
        Document doc = event.getDocument();
282
        String name = ((String)panel.comboName.getSelectedItem()).trim();
283
        String value = panel.txtAreaValue.getText().trim();
284
        
285
        if (name.length() == 0 || value.length() == 0 || name.indexOf(" ") > 0) { // NOI18N
286
            panel.btnAdd.setEnabled(false);
287
        } else {
288
            panel.btnAdd.setEnabled(true);
289
        }
290
    }    
291
    
292
    public class TableMouseListener extends MouseAdapter {
293
        
294
        @Override
295
        public void mouseClicked(MouseEvent event) {
296
            //super.mouseClicked(arg0);
297
            if (event.getClickCount() == 2) {
298
                int[] rows = propTable.getSelectedItems();
299
                HgPropertiesNode[] hgPropertiesNodes = propTable.getNodes();
300
                if (hgPropertiesNodes == null)
301
                    return;
302
                final String hgPropertyName = hgPropertiesNodes[propTable.getModelIndex(rows[0])].getName(); 
303
                final String hgPropertyValue = hgPropertiesNodes[propTable.getModelIndex(rows[0])].getValue(); 
304
                EventQueue.invokeLater(new Runnable() {
305
                    public void run() {
306
                        panel.comboName.setSelectedItem(hgPropertyName);
307
                        panel.txtAreaValue.setText(hgPropertyValue);
308
                    }
309
                });
310
            }
311
        }
312
    }
195
    }
313
}
196
}
(-)a/mercurial/src/org/netbeans/modules/mercurial/ui/properties/PropertiesAction.java (-5 / +1 lines)
Lines 78-84 public class PropertiesAction extends Ab Link Here
78
78
79
        final PropertiesTable propTable;
79
        final PropertiesTable propTable;
80
80
81
        propTable = new PropertiesTable(PropertiesTable.PROPERTIES_COLUMNS, new String[] { PropertiesTableModel.COLUMN_NAME_VALUE});
81
        propTable = new PropertiesTable(PropertiesTable.PROPERTIES_COLUMNS);
82
82
83
        panel.setPropertiesTable(propTable);
83
        panel.setPropertiesTable(propTable);
84
84
Lines 105-114 public class PropertiesAction extends Ab Link Here
105
        panel.putClientProperty("DialogDescriptor", dd); // NOI18N
105
        panel.putClientProperty("DialogDescriptor", dd); // NOI18N
106
        Dialog dialog = DialogDisplayer.getDefault().createDialog(dd);
106
        Dialog dialog = DialogDisplayer.getDefault().createDialog(dd);
107
        dialog.pack();
107
        dialog.pack();
108
        panel.btnRemove.setVisible(false);
109
        org.openide.awt.Mnemonics.setLocalizedText(panel.btnAdd, org.openide.util.NbBundle.getMessage(PropertiesAction.class, "CTL_Properties_Action_Modify"));
110
        panel.btnAdd.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(PropertiesAction.class, "ACSN_Properties_Action_Modify")); // NOI18N
111
        panel.btnAdd.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(PropertiesAction.class, "ACSD_Properties_Action_Modify")); 
112
        dialog.setVisible(true);
108
        dialog.setVisible(true);
113
        if (dd.getValue() == okButton) {
109
        if (dd.getValue() == okButton) {
114
            hgProperties.setProperties();
110
            hgProperties.setProperties();
(-)a/mercurial/src/org/netbeans/modules/mercurial/ui/properties/PropertiesPanel.form (-91 / +17 lines)
Lines 14-41 Link Here
14
  <Layout>
14
  <Layout>
15
    <DimensionLayout dim="0">
15
    <DimensionLayout dim="0">
16
      <Group type="103" groupAlignment="0" attributes="0">
16
      <Group type="103" groupAlignment="0" attributes="0">
17
          <Group type="102" alignment="0" attributes="0">
17
          <Group type="102" alignment="1" attributes="0">
18
              <EmptySpace max="-2" attributes="0"/>
18
              <EmptySpace max="-2" attributes="0"/>
19
              <Group type="103" groupAlignment="0" attributes="0">
19
              <Group type="103" groupAlignment="1" attributes="0">
20
                  <Component id="jScrollPane1" alignment="0" pref="460" max="32767" attributes="1"/>
21
                  <Component id="jLabel3" alignment="0" min="-2" max="-2" attributes="0"/>
22
                  <Component id="jLabel1" alignment="0" min="-2" max="-2" attributes="0"/>
20
                  <Component id="propsPanel" alignment="0" max="32767" attributes="1"/>
23
                  <Component id="propsPanel" alignment="0" max="32767" attributes="1"/>
21
                  <Group type="102" alignment="0" attributes="0">
22
                      <Group type="103" groupAlignment="0" attributes="0">
23
                          <Component id="jLabel2" alignment="0" min="-2" max="-2" attributes="1"/>
24
                          <Component id="btnAdd" linkSize="1" min="-2" max="-2" attributes="1"/>
25
                          <Component id="jLabel3" alignment="0" min="-2" max="-2" attributes="0"/>
26
                          <Component id="jLabel1" alignment="0" min="-2" max="-2" attributes="0"/>
27
                      </Group>
28
                      <Group type="103" groupAlignment="1" attributes="0">
29
                          <Group type="103" groupAlignment="1" attributes="0">
30
                              <Component id="comboName" alignment="0" pref="307" max="32767" attributes="1"/>
31
                              <Component id="jScrollPane1" alignment="1" pref="307" max="32767" attributes="1"/>
32
                          </Group>
33
                          <Group type="102" alignment="1" attributes="0">
34
                              <EmptySpace max="-2" attributes="0"/>
35
                              <Component id="btnRemove" linkSize="1" min="-2" max="-2" attributes="0"/>
36
                          </Group>
37
                      </Group>
38
                  </Group>
39
              </Group>
24
              </Group>
40
              <EmptySpace max="-2" attributes="0"/>
25
              <EmptySpace max="-2" attributes="0"/>
41
          </Group>
26
          </Group>
Lines 43-96 Link Here
43
    </DimensionLayout>
28
    </DimensionLayout>
44
    <DimensionLayout dim="1">
29
    <DimensionLayout dim="1">
45
      <Group type="103" groupAlignment="0" attributes="0">
30
      <Group type="103" groupAlignment="0" attributes="0">
46
          <Group type="102" attributes="0">
31
          <Group type="102" alignment="1" attributes="0">
32
              <EmptySpace max="-2" attributes="0"/>
33
              <Component id="jLabel3" min="-2" max="-2" attributes="0"/>
34
              <EmptySpace max="-2" attributes="0"/>
35
              <Component id="propsPanel" min="-2" max="-2" attributes="0"/>
36
              <EmptySpace min="-2" pref="22" max="-2" attributes="0"/>
37
              <Component id="jLabel1" min="-2" max="-2" attributes="1"/>
38
              <EmptySpace type="separate" max="-2" attributes="0"/>
39
              <Component id="jScrollPane1" pref="32" max="32767" attributes="1"/>
47
              <EmptySpace min="-2" max="-2" attributes="0"/>
40
              <EmptySpace min="-2" max="-2" attributes="0"/>
48
              <Group type="103" groupAlignment="3" attributes="0">
49
                  <Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/>
50
                  <Component id="comboName" alignment="3" min="-2" max="-2" attributes="0"/>
51
              </Group>
52
              <EmptySpace max="-2" attributes="0"/>
53
              <Group type="103" groupAlignment="0" attributes="0">
54
                  <Group type="102" attributes="0">
55
                      <Component id="jLabel1" min="-2" max="-2" attributes="0"/>
56
                      <EmptySpace min="-2" pref="99" max="-2" attributes="0"/>
57
                      <Group type="103" groupAlignment="3" attributes="0">
58
                          <Component id="btnAdd" alignment="3" min="-2" max="-2" attributes="0"/>
59
                          <Component id="btnRemove" alignment="3" min="-2" max="-2" attributes="0"/>
60
                      </Group>
61
                      <EmptySpace min="-2" pref="26" max="-2" attributes="0"/>
62
                      <Component id="jLabel3" min="-2" max="-2" attributes="0"/>
63
                      <EmptySpace min="-2" pref="12" max="-2" attributes="0"/>
64
                  </Group>
65
                  <Component id="jScrollPane1" alignment="0" min="-2" max="-2" attributes="0"/>
66
              </Group>
67
              <EmptySpace pref="13" max="32767" attributes="0"/>
68
              <Component id="propsPanel" min="-2" max="-2" attributes="0"/>
69
          </Group>
41
          </Group>
70
      </Group>
42
      </Group>
71
    </DimensionLayout>
43
    </DimensionLayout>
72
  </Layout>
44
  </Layout>
73
  <SubComponents>
45
  <SubComponents>
74
    <Component class="javax.swing.JLabel" name="jLabel2">
75
      <Properties>
76
        <Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
77
          <ComponentRef name="comboName"/>
78
        </Property>
79
        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
80
          <ResourceString bundle="org/netbeans/modules/mercurial/ui/properties/Bundle.properties" key="PropertiesPanel.jLabel2.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
81
        </Property>
82
      </Properties>
83
    </Component>
84
    <Component class="javax.swing.JComboBox" name="comboName">
85
      <Properties>
86
        <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
87
          <StringArray count="0"/>
88
        </Property>
89
      </Properties>
90
      <AuxValues>
91
        <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="16"/>
92
      </AuxValues>
93
    </Component>
94
    <Component class="javax.swing.JLabel" name="jLabel1">
46
    <Component class="javax.swing.JLabel" name="jLabel1">
95
      <Properties>
47
      <Properties>
96
        <Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
48
        <Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
Lines 109-120 Link Here
109
      <Layout>
61
      <Layout>
110
        <DimensionLayout dim="0">
62
        <DimensionLayout dim="0">
111
          <Group type="103" groupAlignment="0" attributes="0">
63
          <Group type="103" groupAlignment="0" attributes="0">
112
              <EmptySpace min="0" pref="420" max="32767" attributes="0"/>
64
              <EmptySpace min="0" pref="460" max="32767" attributes="0"/>
113
          </Group>
65
          </Group>
114
        </DimensionLayout>
66
        </DimensionLayout>
115
        <DimensionLayout dim="1">
67
        <DimensionLayout dim="1">
116
          <Group type="103" groupAlignment="0" attributes="0">
68
          <Group type="103" groupAlignment="0" attributes="0">
117
              <EmptySpace min="0" pref="99" max="32767" attributes="0"/>
69
              <EmptySpace min="0" pref="111" max="32767" attributes="0"/>
118
          </Group>
70
          </Group>
119
        </DimensionLayout>
71
        </DimensionLayout>
120
      </Layout>
72
      </Layout>
Lines 129-135 Link Here
129
        <Component class="javax.swing.JTextArea" name="txtAreaValue">
81
        <Component class="javax.swing.JTextArea" name="txtAreaValue">
130
          <Properties>
82
          <Properties>
131
            <Property name="columns" type="int" value="20"/>
83
            <Property name="columns" type="int" value="20"/>
132
            <Property name="rows" type="int" value="5"/>
84
            <Property name="rows" type="int" value="1"/>
133
          </Properties>
85
          </Properties>
134
          <AuxValues>
86
          <AuxValues>
135
            <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="16"/>
87
            <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="16"/>
Lines 137-168 Link Here
137
        </Component>
89
        </Component>
138
      </SubComponents>
90
      </SubComponents>
139
    </Container>
91
    </Container>
140
    <Component class="javax.swing.JButton" name="btnRemove">
141
      <Properties>
142
        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
143
          <ResourceString bundle="org/netbeans/modules/mercurial/ui/properties/Bundle.properties" key="PropertiesPanel.btnRemove.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
144
        </Property>
145
      </Properties>
146
      <AuxValues>
147
        <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="16"/>
148
      </AuxValues>
149
    </Component>
150
    <Component class="javax.swing.JButton" name="btnAdd">
151
      <Properties>
152
        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
153
          <ResourceString bundle="org/netbeans/modules/mercurial/ui/properties/Bundle.properties" key="PropertiesPanel.btnAdd.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
154
        </Property>
155
        <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
156
          <Dimension value="[75, 23]"/>
157
        </Property>
158
        <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
159
          <Dimension value="[75, 23]"/>
160
        </Property>
161
      </Properties>
162
      <AuxValues>
163
        <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="16"/>
164
      </AuxValues>
165
    </Component>
166
    <Component class="javax.swing.JLabel" name="jLabel3">
92
    <Component class="javax.swing.JLabel" name="jLabel3">
167
      <Properties>
93
      <Properties>
168
        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
94
        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
(-)a/mercurial/src/org/netbeans/modules/mercurial/ui/properties/PropertiesPanel.java (-65 / +17 lines)
Lines 66-83 public class PropertiesPanel extends jav Link Here
66
        return txtAreaValue;
66
        return txtAreaValue;
67
    }
67
    }
68
68
69
    public javax.swing.JComboBox getComboName() {
70
        return comboName;
71
    }
72
73
    public javax.swing.JButton getBtnAdd() {
74
        return btnAdd;
75
    }
76
77
    public javax.swing.JButton getBtnRemove() {
78
        return btnRemove;
79
    }
80
81
    public void setPropertiesTable(PropertiesTable propertiesTable){
69
    public void setPropertiesTable(PropertiesTable propertiesTable){
82
        this.propertiesTable = propertiesTable;
70
        this.propertiesTable = propertiesTable;
83
    }
71
    }
Lines 115-128 public class PropertiesPanel extends jav Link Here
115
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
103
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
116
    private void initComponents() {
104
    private void initComponents() {
117
105
118
        jLabel2 = new javax.swing.JLabel();
119
        jLabel1 = new javax.swing.JLabel();
106
        jLabel1 = new javax.swing.JLabel();
120
        propsPanel = new javax.swing.JPanel();
107
        propsPanel = new javax.swing.JPanel();
121
        jScrollPane1 = new javax.swing.JScrollPane();
108
        jScrollPane1 = new javax.swing.JScrollPane();
122
        jLabel3 = new javax.swing.JLabel();
109
        jLabel3 = new javax.swing.JLabel();
123
124
        jLabel2.setLabelFor(comboName);
125
        org.openide.awt.Mnemonics.setLocalizedText(jLabel2, org.openide.util.NbBundle.getMessage(PropertiesPanel.class, "PropertiesPanel.jLabel2.text")); // NOI18N
126
110
127
        jLabel1.setLabelFor(txtAreaValue);
111
        jLabel1.setLabelFor(txtAreaValue);
128
        org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(PropertiesPanel.class, "PropertiesPanel.jLabel1.text")); // NOI18N
112
        org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(PropertiesPanel.class, "PropertiesPanel.jLabel1.text")); // NOI18N
Lines 131-152 public class PropertiesPanel extends jav Link Here
131
        propsPanel.setLayout(propsPanelLayout);
115
        propsPanel.setLayout(propsPanelLayout);
132
        propsPanelLayout.setHorizontalGroup(
116
        propsPanelLayout.setHorizontalGroup(
133
            propsPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
117
            propsPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
134
            .add(0, 420, Short.MAX_VALUE)
118
            .add(0, 460, Short.MAX_VALUE)
135
        );
119
        );
136
        propsPanelLayout.setVerticalGroup(
120
        propsPanelLayout.setVerticalGroup(
137
            propsPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
121
            propsPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
138
            .add(0, 99, Short.MAX_VALUE)
122
            .add(0, 111, Short.MAX_VALUE)
139
        );
123
        );
140
124
141
        txtAreaValue.setColumns(20);
125
        txtAreaValue.setColumns(20);
142
        txtAreaValue.setRows(5);
126
        txtAreaValue.setRows(1);
143
        jScrollPane1.setViewportView(txtAreaValue);
127
        jScrollPane1.setViewportView(txtAreaValue);
144
145
        org.openide.awt.Mnemonics.setLocalizedText(btnRemove, org.openide.util.NbBundle.getMessage(PropertiesPanel.class, "PropertiesPanel.btnRemove.text")); // NOI18N
146
147
        org.openide.awt.Mnemonics.setLocalizedText(btnAdd, org.openide.util.NbBundle.getMessage(PropertiesPanel.class, "PropertiesPanel.btnAdd.text")); // NOI18N
148
        btnAdd.setMaximumSize(new java.awt.Dimension(75, 23));
149
        btnAdd.setMinimumSize(new java.awt.Dimension(75, 23));
150
128
151
        org.openide.awt.Mnemonics.setLocalizedText(jLabel3, org.openide.util.NbBundle.getMessage(PropertiesPanel.class, "jLabel3.txt")); // NOI18N
129
        org.openide.awt.Mnemonics.setLocalizedText(jLabel3, org.openide.util.NbBundle.getMessage(PropertiesPanel.class, "jLabel3.txt")); // NOI18N
152
130
Lines 154-212 public class PropertiesPanel extends jav Link Here
154
        this.setLayout(layout);
132
        this.setLayout(layout);
155
        layout.setHorizontalGroup(
133
        layout.setHorizontalGroup(
156
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
134
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
157
            .add(layout.createSequentialGroup()
135
            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
158
                .addContainerGap()
136
                .addContainerGap()
159
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
137
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
160
                    .add(propsPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
138
                    .add(org.jdesktop.layout.GroupLayout.LEADING, jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 460, Short.MAX_VALUE)
161
                    .add(layout.createSequentialGroup()
139
                    .add(org.jdesktop.layout.GroupLayout.LEADING, jLabel3)
162
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
140
                    .add(org.jdesktop.layout.GroupLayout.LEADING, jLabel1)
163
                            .add(jLabel2)
141
                    .add(org.jdesktop.layout.GroupLayout.LEADING, propsPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
164
                            .add(btnAdd, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
165
                            .add(jLabel3)
166
                            .add(jLabel1))
167
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
168
                            .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
169
                                .add(org.jdesktop.layout.GroupLayout.LEADING, comboName, 0, 307, Short.MAX_VALUE)
170
                                .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 307, Short.MAX_VALUE))
171
                            .add(layout.createSequentialGroup()
172
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
173
                                .add(btnRemove)))))
174
                .addContainerGap())
142
                .addContainerGap())
175
        );
143
        );
176
177
        layout.linkSize(new java.awt.Component[] {btnAdd, btnRemove}, org.jdesktop.layout.GroupLayout.HORIZONTAL);
178
179
        layout.setVerticalGroup(
144
        layout.setVerticalGroup(
180
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
145
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
181
            .add(layout.createSequentialGroup()
146
            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
182
                .addContainerGap()
147
                .addContainerGap()
183
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
148
                .add(jLabel3)
184
                    .add(jLabel2)
185
                    .add(comboName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
186
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
149
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
187
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
150
                .add(propsPanel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
188
                    .add(layout.createSequentialGroup()
151
                .add(22, 22, 22)
189
                        .add(jLabel1)
152
                .add(jLabel1)
190
                        .add(99, 99, 99)
153
                .add(18, 18, 18)
191
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
154
                .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 32, Short.MAX_VALUE)
192
                            .add(btnAdd, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
155
                .addContainerGap())
193
                            .add(btnRemove))
194
                        .add(26, 26, 26)
195
                        .add(jLabel3)
196
                        .add(12, 12, 12))
197
                    .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
198
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 13, Short.MAX_VALUE)
199
                .add(propsPanel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
200
        );
156
        );
201
    }// </editor-fold>//GEN-END:initComponents
157
    }// </editor-fold>//GEN-END:initComponents
202
    
158
    
203
    
159
    
204
    // Variables declaration - do not modify//GEN-BEGIN:variables
160
    // Variables declaration - do not modify//GEN-BEGIN:variables
205
    final javax.swing.JButton btnAdd = new javax.swing.JButton();
206
    final javax.swing.JButton btnRemove = new javax.swing.JButton();
207
    final javax.swing.JComboBox comboName = new javax.swing.JComboBox();
208
    private javax.swing.JLabel jLabel1;
161
    private javax.swing.JLabel jLabel1;
209
    private javax.swing.JLabel jLabel2;
210
    private javax.swing.JLabel jLabel3;
162
    private javax.swing.JLabel jLabel3;
211
    private javax.swing.JScrollPane jScrollPane1;
163
    private javax.swing.JScrollPane jScrollPane1;
212
    public javax.swing.JPanel propsPanel;
164
    public javax.swing.JPanel propsPanel;
(-)a/mercurial/src/org/netbeans/modules/mercurial/ui/properties/PropertiesTable.java (-40 / +9 lines)
Lines 58-64 import org.openide.util.NbBundle; Link Here
58
58
59
/**
59
/**
60
 *
60
 *
61
 * @author Peter Pis
61
 * @author Padraig O'Briain
62
 */
62
 */
63
public class PropertiesTable implements AncestorListener, TableModelListener {
63
public class PropertiesTable implements AncestorListener, TableModelListener {
64
    
64
    
Lines 66-100 public class PropertiesTable implements Link Here
66
            
66
            
67
    private PropertiesTableModel tableModel;
67
    private PropertiesTableModel tableModel;
68
    private JTable table;
68
    private JTable table;
69
    private TableSorter sorter;
70
    private JComponent component;
69
    private JComponent component;
71
    private String[] columns;
70
    private String[] columns;
72
    private String[] sortByColumns;
73
    
71
    
74
    /** Creates a new instance of PropertiesTable */
72
    /** Creates a new instance of PropertiesTable */
75
    public PropertiesTable(String[] columns, String[] sortByColumns) {
73
    public PropertiesTable(String[] columns) {
76
        init(columns, null);
74
        init(columns);
77
        this.sortByColumns = sortByColumns;
78
        setSortingStatus();
79
    }
75
    }
80
    
76
    
81
    public PropertiesTable(String[] columns, TableSorter sorter) {
77
    private void init(String[] columns) {
82
        init(columns, sorter);
83
    } 
84
    
85
    private void init(String[] columns, TableSorter sorter) {
86
        tableModel = new PropertiesTableModel(columns);
78
        tableModel = new PropertiesTableModel(columns);
87
        tableModel.addTableModelListener(this);
79
        tableModel.addTableModelListener(this);
88
        if(sorter == null) {
80
        table = new JTable(tableModel);
89
            sorter = new TableSorter(tableModel);
90
        } 
91
        this.sorter = sorter;   
92
        table = new JTable(this.sorter);
93
        table.getTableHeader().setReorderingAllowed(false);
81
        table.getTableHeader().setReorderingAllowed(false);
94
        table.setDefaultRenderer(String.class, new PropertiesTableCellRenderer());
82
        table.setDefaultRenderer(String.class, new PropertiesTableCellRenderer());
95
        //table.setDefaultEditor(CommitOptions.class, new CommitOptionsCellEditor());
83
        //table.setDefaultEditor(CommitOptions.class, new CommitOptionsCellEditor());
96
        table.getTableHeader().setReorderingAllowed(true);
97
        this.sorter.setTableHeader(table.getTableHeader());
98
        table.setRowHeight(table.getRowHeight());
84
        table.setRowHeight(table.getRowHeight());
99
        table.addAncestorListener(this);
85
        table.addAncestorListener(this);
100
        component = new JScrollPane(table, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
86
        component = new JScrollPane(table, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
Lines 124-130 public class PropertiesTable implements Link Here
124
            return;
110
            return;
125
        for (int i = 0; i < columns.length; i++) {
111
        for (int i = 0; i < columns.length; i++) {
126
            String col = columns[i];                                
112
            String col = columns[i];                                
127
            sorter.setColumnComparator(i, null);                    
128
            if (col.equals(PropertiesTableModel.COLUMN_NAME_NAME)) {
113
            if (col.equals(PropertiesTableModel.COLUMN_NAME_NAME)) {
129
                columnModel.getColumn(i).setPreferredWidth(width * 20 / 100);
114
                columnModel.getColumn(i).setPreferredWidth(width * 20 / 100);
130
            } else if (col.equals(PropertiesTableModel.COLUMN_NAME_VALUE)) {
115
            } else if (col.equals(PropertiesTableModel.COLUMN_NAME_VALUE)) {
Lines 133-165 public class PropertiesTable implements Link Here
133
        }
118
        }
134
    }
119
    }
135
    
120
    
136
    private void setSortingStatus() {
121
    public TableModel getTableModel() {
137
        for (int i = 0; i < sortByColumns.length; i++) {
138
            String sortByColumn = sortByColumns[i];        
139
            for (int j = 0; j < columns.length; j++) {
140
                String column = columns[j];
141
                if(column.equals(sortByColumn)) {
142
                    sorter.setSortingStatus(j, column.equals(sortByColumn) ? TableSorter.ASCENDING : TableSorter.NOT_SORTED);                       
143
                    break;
144
                }                    
145
            }                        
146
        }        
147
    }
148
    
149
    TableModel getTableModel() {
150
        return tableModel;
122
        return tableModel;
151
    }
123
    }
152
    
124
    
153
    void dataChanged() {
125
    public void dataChanged() {
154
        int idx = table.getSelectedRow();
126
        int idx = table.getSelectedRow();
155
        tableModel.fireTableDataChanged();
127
        tableModel.fireTableDataChanged();
156
        if (idx != -1) {
128
        if (idx != -1) {
157
            table.getSelectionModel().addSelectionInterval(idx, idx);
129
            table.getSelectionModel().addSelectionInterval(idx, idx);
158
        }    
130
        }    
159
    }
160
    
161
    public int getModelIndex(int viewIndex) {
162
        return sorter.modelIndex(viewIndex);
163
    }
131
    }
164
    
132
    
165
    public int[] getSelectedItems() {
133
    public int[] getSelectedItems() {
Lines 191-203 public class PropertiesTable implements Link Here
191
    public void tableChanged(TableModelEvent event) {
159
    public void tableChanged(TableModelEvent event) {
192
        table.repaint();
160
        table.repaint();
193
    }
161
    }
162
    
194
163
195
    public class PropertiesTableCellRenderer extends DefaultTableCellRenderer {
164
    public class PropertiesTableCellRenderer extends DefaultTableCellRenderer {
196
           
165
           
197
        public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int rowIndex, int columnIndex) {
166
        public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int rowIndex, int columnIndex) {
198
            Component renderer =  super.getTableCellRendererComponent(table, value, hasFocus, hasFocus, rowIndex, columnIndex);
167
            Component renderer =  super.getTableCellRendererComponent(table, value, hasFocus, hasFocus, rowIndex, columnIndex);
199
            if (renderer instanceof JComponent) {
168
            if (renderer instanceof JComponent) {
200
                String strValue = tableModel.getNode(sorter.modelIndex(rowIndex)).getValue(); 
169
                String strValue = tableModel.getNode(rowIndex).getValue(); 
201
                ((JComponent) renderer).setToolTipText(strValue);
170
                ((JComponent) renderer).setToolTipText(strValue);
202
            }
171
            }
203
            setToolTipText(value.toString());
172
            setToolTipText(value.toString());

Return to bug 125700