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 229481
Collapse All | Expand All

(-)a/git/src/org/netbeans/modules/git/ui/selectors/Bundle.properties (+2 lines)
Lines 40-42 Link Here
40
40
41
# Portions Copyrighted 2011 Sun Microsystems, Inc.
41
# Portions Copyrighted 2011 Sun Microsystems, Inc.
42
ItemsPanel.titleLabel.text=title
42
ItemsPanel.titleLabel.text=title
43
ItemsPanel.btnSelectAll.text=Select &All
44
ItemsPanel.btnSelectNone.text=Select &None
(-)a/git/src/org/netbeans/modules/git/ui/selectors/ItemSelector.java (+52 lines)
Lines 42-47 Link Here
42
package org.netbeans.modules.git.ui.selectors;
42
package org.netbeans.modules.git.ui.selectors;
43
43
44
import java.awt.Component;
44
import java.awt.Component;
45
import java.awt.event.ActionEvent;
46
import java.awt.event.ActionListener;
45
import java.awt.event.KeyAdapter;
47
import java.awt.event.KeyAdapter;
46
import java.awt.event.KeyEvent;
48
import java.awt.event.KeyEvent;
47
import java.awt.event.MouseAdapter;
49
import java.awt.event.MouseAdapter;
Lines 57-62 Link Here
57
import javax.swing.UIManager;
59
import javax.swing.UIManager;
58
import javax.swing.border.Border;
60
import javax.swing.border.Border;
59
import javax.swing.border.EmptyBorder;
61
import javax.swing.border.EmptyBorder;
62
import javax.swing.event.ChangeEvent;
60
import javax.swing.event.ChangeListener;
63
import javax.swing.event.ChangeListener;
61
import javax.swing.event.ListSelectionEvent;
64
import javax.swing.event.ListSelectionEvent;
62
import javax.swing.event.ListSelectionListener;
65
import javax.swing.event.ListSelectionListener;
Lines 98-103 Link Here
98
            model.addElement(i);
101
            model.addElement(i);
99
        }
102
        }
100
        panel.list.setModel(model);        
103
        panel.list.setModel(model);        
104
        //inform listeners like select all/none buttons
105
        changeSupport.fireChange();
101
    }
106
    }
102
    
107
    
103
    @SuppressWarnings("unchecked")
108
    @SuppressWarnings("unchecked")
Lines 130-135 Link Here
130
        return panel.list.getModel().getSize() == 0;
135
        return panel.list.getModel().getSize() == 0;
131
    }
136
    }
132
    
137
    
138
    /**
139
     * Selects all or deselects all items in the list of items.
140
     *
141
     * @param newState true, if select all, false if select none
142
     */
143
    private void selectAll(boolean newState) {
144
        for (int i = 0; i < panel.list.getModel().getSize(); i++) {
145
            Item item = (Item) panel.list.getModel().getElementAt(i);
146
            item.isSelected = newState;
147
        }
148
        panel.list.repaint();
149
        changeSupport.fireChange();
150
    }
151
    
133
    private void attachListeners () {
152
    private void attachListeners () {
134
        panel.list.addMouseListener(new MouseAdapter() {
153
        panel.list.addMouseListener(new MouseAdapter() {
135
            @Override
154
            @Override
Lines 145-150 Link Here
145
                }
164
                }
146
            }
165
            }
147
        });
166
        });
167
     
168
        panel.btnSelectAll.addActionListener(new ActionListener() {
169
170
            @Override
171
            public void actionPerformed(ActionEvent e) {
172
                selectAll(true);
173
            }
174
        });
175
        panel.btnSelectNone.addActionListener(new ActionListener() {
176
177
            @Override
178
            public void actionPerformed(ActionEvent e) {
179
                selectAll(false);
180
            }
181
        });
182
183
        changeSupport.addChangeListener(new ChangeListener() {
184
185
            @Override
186
            public void stateChanged(ChangeEvent e) {
187
                int selectedItemsCount = 0;
188
                int maxItemsCount = panel.list.getModel().getSize();
189
                for (int i = 0; i < maxItemsCount; i++) {
190
                    Item item = (Item) panel.list.getModel().getElementAt(i);
191
                    if (item.isSelected) {
192
                        selectedItemsCount++;
193
                    }
194
                }
195
                //sync the buttons
196
                panel.btnSelectAll.setEnabled(selectedItemsCount<maxItemsCount);
197
                panel.btnSelectNone.setEnabled(selectedItemsCount>0);
198
            }
199
        });
148
    };   
200
    };   
149
    
201
    
150
    private void switchSelection(int index) {
202
    private void switchSelection(int index) {
(-)a/git/src/org/netbeans/modules/git/ui/selectors/ItemsPanel.form (-9 / +46 lines)
Lines 1-11 Link Here
1
<?xml version="1.1" encoding="UTF-8" ?>
1
<?xml version="1.0" encoding="UTF-8" ?>
2
2
3
<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
3
<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
4
  <AuxValues>
4
  <AuxValues>
5
    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
5
    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
6
    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
6
    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
7
    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
7
    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
8
    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
8
    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="true"/>
9
    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/>
9
    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/>
10
    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
10
    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
11
    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
11
    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
Lines 16-26 Link Here
16
  <Layout>
16
  <Layout>
17
    <DimensionLayout dim="0">
17
    <DimensionLayout dim="0">
18
      <Group type="103" groupAlignment="0" attributes="0">
18
      <Group type="103" groupAlignment="0" attributes="0">
19
          <Group type="102" alignment="0" attributes="0">
19
          <Group type="102" attributes="0">
20
              <EmptySpace min="-2" max="-2" attributes="0"/>
20
              <EmptySpace max="-2" attributes="0"/>
21
              <Group type="103" groupAlignment="0" attributes="0">
21
              <Group type="103" groupAlignment="0" attributes="0">
22
                  <Component id="jScrollPane1" alignment="0" pref="360" max="32767" attributes="0"/>
22
                  <Component id="jScrollPane1" alignment="0" pref="360" max="32767" attributes="0"/>
23
                  <Component id="titleLabel" alignment="0" min="-2" max="-2" attributes="0"/>
23
                  <Group type="102" attributes="0">
24
                      <Group type="103" groupAlignment="0" attributes="0">
25
                          <Component id="titleLabel" min="-2" max="-2" attributes="0"/>
26
                          <Group type="102" alignment="0" attributes="0">
27
                              <Component id="btnSelectAll" min="-2" max="-2" attributes="0"/>
28
                              <EmptySpace max="-2" attributes="0"/>
29
                              <Component id="btnSelectNone" min="-2" max="-2" attributes="0"/>
30
                          </Group>
31
                      </Group>
32
                      <EmptySpace min="0" pref="0" max="32767" attributes="0"/>
33
                  </Group>
24
              </Group>
34
              </Group>
25
              <EmptySpace max="-2" attributes="0"/>
35
              <EmptySpace max="-2" attributes="0"/>
26
          </Group>
36
          </Group>
Lines 29-39 Link Here
29
    <DimensionLayout dim="1">
39
    <DimensionLayout dim="1">
30
      <Group type="103" groupAlignment="0" attributes="0">
40
      <Group type="103" groupAlignment="0" attributes="0">
31
          <Group type="102" alignment="0" attributes="0">
41
          <Group type="102" alignment="0" attributes="0">
32
              <EmptySpace max="-2" attributes="0"/>
42
              <EmptySpace min="-2" max="-2" attributes="0"/>
33
              <Component id="titleLabel" min="-2" max="-2" attributes="0"/>
43
              <Component id="titleLabel" min="-2" max="-2" attributes="0"/>
34
              <EmptySpace max="-2" attributes="0"/>
44
              <EmptySpace min="-2" max="-2" attributes="0"/>
35
              <Component id="jScrollPane1" pref="236" max="32767" attributes="0"/>
45
              <Component id="jScrollPane1" pref="216" max="32767" attributes="0"/>
36
              <EmptySpace max="-2" attributes="0"/>
46
              <EmptySpace min="-2" max="-2" attributes="0"/>
47
              <Group type="103" groupAlignment="3" attributes="0">
48
                  <Component id="btnSelectNone" alignment="0" min="-2" max="-2" attributes="0"/>
49
                  <Component id="btnSelectAll" alignment="3" min="-2" max="-2" attributes="0"/>
50
              </Group>
51
              <EmptySpace min="-2" max="-2" attributes="0"/>
37
          </Group>
52
          </Group>
38
      </Group>
53
      </Group>
39
    </DimensionLayout>
54
    </DimensionLayout>
Lines 72-76 Link Here
72
        </Component>
87
        </Component>
73
      </SubComponents>
88
      </SubComponents>
74
    </Container>
89
    </Container>
90
    <Component class="javax.swing.JButton" name="btnSelectNone">
91
      <Properties>
92
        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
93
          <ResourceString bundle="org/netbeans/modules/git/ui/selectors/Bundle.properties" key="ItemsPanel.btnSelectNone.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
94
        </Property>
95
        <Property name="enabled" type="boolean" value="false"/>
96
      </Properties>
97
      <AuxValues>
98
        <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
99
      </AuxValues>
100
    </Component>
101
    <Component class="javax.swing.JButton" name="btnSelectAll">
102
      <Properties>
103
        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
104
          <ResourceString bundle="org/netbeans/modules/git/ui/selectors/Bundle.properties" key="ItemsPanel.btnSelectAll.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
105
        </Property>
106
        <Property name="enabled" type="boolean" value="false"/>
107
      </Properties>
108
      <AuxValues>
109
        <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
110
      </AuxValues>
111
    </Component>
75
  </SubComponents>
112
  </SubComponents>
76
</Form>
113
</Form>
(-)a/git/src/org/netbeans/modules/git/ui/selectors/ItemsPanel.java (-3 / +24 lines)
Lines 70-83 Link Here
70
    private void initComponents() {
70
    private void initComponents() {
71
71
72
        jScrollPane1 = new javax.swing.JScrollPane();
72
        jScrollPane1 = new javax.swing.JScrollPane();
73
        btnSelectNone = new javax.swing.JButton();
74
        btnSelectAll = new javax.swing.JButton();
73
75
74
        titleLabel.setText(org.openide.util.NbBundle.getMessage(ItemsPanel.class, "ItemsPanel.titleLabel.text")); // NOI18N
76
        org.openide.awt.Mnemonics.setLocalizedText(titleLabel, org.openide.util.NbBundle.getMessage(ItemsPanel.class, "ItemsPanel.titleLabel.text")); // NOI18N
75
        titleLabel.setToolTipText(org.openide.util.NbBundle.getMessage(ItemsPanel.class, "ItemsPanel.titleLabel.toolTipText")); // NOI18N
77
        titleLabel.setToolTipText(org.openide.util.NbBundle.getMessage(ItemsPanel.class, "ItemsPanel.titleLabel.toolTipText")); // NOI18N
76
78
77
        list.setModel(new DefaultListModel());
79
        list.setModel(new DefaultListModel());
78
        list.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
80
        list.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
79
        jScrollPane1.setViewportView(list);
81
        jScrollPane1.setViewportView(list);
80
82
83
        org.openide.awt.Mnemonics.setLocalizedText(btnSelectNone, org.openide.util.NbBundle.getMessage(ItemsPanel.class, "ItemsPanel.btnSelectNone.text")); // NOI18N
84
        btnSelectNone.setEnabled(false);
85
86
        org.openide.awt.Mnemonics.setLocalizedText(btnSelectAll, org.openide.util.NbBundle.getMessage(ItemsPanel.class, "ItemsPanel.btnSelectAll.text")); // NOI18N
87
        btnSelectAll.setEnabled(false);
88
81
        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
89
        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
82
        this.setLayout(layout);
90
        this.setLayout(layout);
83
        layout.setHorizontalGroup(
91
        layout.setHorizontalGroup(
Lines 86-92 Link Here
86
                .addContainerGap()
94
                .addContainerGap()
87
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
95
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
88
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 360, Short.MAX_VALUE)
96
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 360, Short.MAX_VALUE)
89
                    .addComponent(titleLabel))
97
                    .addGroup(layout.createSequentialGroup()
98
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
99
                            .addComponent(titleLabel)
100
                            .addGroup(layout.createSequentialGroup()
101
                                .addComponent(btnSelectAll)
102
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
103
                                .addComponent(btnSelectNone)))
104
                        .addGap(0, 0, Short.MAX_VALUE)))
90
                .addContainerGap())
105
                .addContainerGap())
91
        );
106
        );
92
        layout.setVerticalGroup(
107
        layout.setVerticalGroup(
Lines 95-105 Link Here
95
                .addContainerGap()
110
                .addContainerGap()
96
                .addComponent(titleLabel)
111
                .addComponent(titleLabel)
97
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
112
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
98
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 236, Short.MAX_VALUE)
113
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 216, Short.MAX_VALUE)
114
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
115
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
116
                    .addComponent(btnSelectNone)
117
                    .addComponent(btnSelectAll))
99
                .addContainerGap())
118
                .addContainerGap())
100
        );
119
        );
101
    }// </editor-fold>//GEN-END:initComponents
120
    }// </editor-fold>//GEN-END:initComponents
102
    // Variables declaration - do not modify//GEN-BEGIN:variables
121
    // Variables declaration - do not modify//GEN-BEGIN:variables
122
    javax.swing.JButton btnSelectAll;
123
    javax.swing.JButton btnSelectNone;
103
    private javax.swing.JScrollPane jScrollPane1;
124
    private javax.swing.JScrollPane jScrollPane1;
104
    final javax.swing.JList list = new javax.swing.JList();
125
    final javax.swing.JList list = new javax.swing.JList();
105
    final javax.swing.JLabel titleLabel = new javax.swing.JLabel();
126
    final javax.swing.JLabel titleLabel = new javax.swing.JLabel();

Return to bug 229481