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

(-)a/git/nbproject/project.xml (-1 / +1 lines)
Lines 20-26 Link Here
20
                    <compile-dependency/>
20
                    <compile-dependency/>
21
                    <run-dependency>
21
                    <run-dependency>
22
                        <release-version>1</release-version>
22
                        <release-version>1</release-version>
23
                        <specification-version>1.5</specification-version>
23
                        <specification-version>1.7</specification-version>
24
                    </run-dependency>
24
                    </run-dependency>
25
                </dependency>
25
                </dependency>
26
                <dependency>
26
                <dependency>
(-)a/git/src/org/netbeans/modules/git/GitModuleConfig.java (-1 / +1 lines)
Lines 136-142 Link Here
136
    public void setLastCanceledCommitMessage(String message) {
136
    public void setLastCanceledCommitMessage(String message) {
137
        lastCanceledCommitMessage = message;
137
        lastCanceledCommitMessage = message;
138
    }
138
    }
139
    
139
140
    /**
140
    /**
141
     * @param paths collection of paths, of File.getAbsolutePath()
141
     * @param paths collection of paths, of File.getAbsolutePath()
142
     */
142
     */
(-)a/git/src/org/netbeans/modules/git/client/GitClient.java (-1 / +5 lines)
Lines 290-300 Link Here
290
    }
290
    }
291
    
291
    
292
    public GitRevisionInfo commit (final File[] roots, final String commitMessage, final GitUser author, final GitUser commiter, final ProgressMonitor monitor) throws GitException {
292
    public GitRevisionInfo commit (final File[] roots, final String commitMessage, final GitUser author, final GitUser commiter, final ProgressMonitor monitor) throws GitException {
293
        return commit(roots, commitMessage, author, commiter, false, monitor);
294
    }
295
    
296
    public GitRevisionInfo commit (final File[] roots, final String commitMessage, final GitUser author, final GitUser commiter, final boolean amend, final ProgressMonitor monitor) throws GitException {
293
        return new CommandInvoker().runMethod(new Callable<GitRevisionInfo>() {
297
        return new CommandInvoker().runMethod(new Callable<GitRevisionInfo>() {
294
298
295
            @Override
299
            @Override
296
            public GitRevisionInfo call () throws Exception {
300
            public GitRevisionInfo call () throws Exception {
297
                return delegate.commit(roots, commitMessage, author, commiter, monitor);
301
                return delegate.commit(roots, commitMessage, author, commiter, amend, monitor);
298
            }
302
            }
299
        }, "commit", roots); //NOI18N
303
        }, "commit", roots); //NOI18N
300
    }
304
    }
(-)a/git/src/org/netbeans/modules/git/ui/commit/Bundle.properties (-4 / +6 lines)
Lines 72-82 Link Here
72
CommitOptionsPanel.jLabel2.text=Commiter:
72
CommitOptionsPanel.jLabel2.text=Commiter:
73
CommitOptionsPanel.jLabel1.text_1=Author:
73
CommitOptionsPanel.jLabel1.text_1=Author:
74
CommitOptionsPanel.sighOffCheckBox.text=Add Signed-off-by line by the committer at the end of the commit log message
74
CommitOptionsPanel.sighOffCheckBox.text=Add Signed-off-by line by the committer at the end of the commit log message
75
CommitPanel.jLabel2.text=Author:
75
CommitPanel.jLabel2.text=&Author:
76
CommitPanel.jLabel3.text=Commiter:
76
CommitPanel.jLabel3.text=Commi&ter:
77
CommitPanel.recentLabel.text=
77
CommitPanel.recentLabel.text=
78
CommitPanel.templatesLabel.text=
78
CommitPanel.templatesLabel.text=
79
CommitPanel.messageLabel.text=Commit Message:
79
CommitPanel.messageLabel.text=Commit &Message:
80
MSG_CommitForm_ErrorConflicts=You cannot commit Files with Conflicts. Edit Files and resolve Conflicts first.
80
MSG_CommitForm_ErrorConflicts=You cannot commit Files with Conflicts. Edit Files and resolve Conflicts first.
81
MSG_ERROR_NO_FILES=No files available for commit.
81
MSG_ERROR_NO_FILES=No files available for commit.
82
LBL_CommitAction_CannotCommit = Cannot commit
82
LBL_CommitAction_CannotCommit = Cannot commit
Lines 103-106 Link Here
103
103
104
#includeInCommitAction
104
#includeInCommitAction
105
LBL_IncludeInCommitAction_Name = &Include In Commit
105
LBL_IncludeInCommitAction_Name = &Include In Commit
106
LBL_IncludeInCommitAction_PopupName = Include In Commit
106
LBL_IncludeInCommitAction_PopupName = Include In Commit
107
CommitPanel.amendCheckBox.text=Am&end Last Commit
108
CommitPanel.amendCheckBox.TTtext=Modifies the last commit and updates its commit message and modified files
(-)a/git/src/org/netbeans/modules/git/ui/commit/CommitAction.java (-3 / +5 lines)
Lines 200-205 Link Here
200
                String message = parameters.getCommitMessage();
200
                String message = parameters.getCommitMessage();
201
                GitUser author = parameters.getAuthor();
201
                GitUser author = parameters.getAuthor();
202
                GitUser commiter = parameters.getCommiter();
202
                GitUser commiter = parameters.getCommiter();
203
                boolean amend = parameters.isAmend();
204
                
203
                Collection<GitHook> hooks = panel.getHooks();
205
                Collection<GitHook> hooks = panel.getHooks();
204
                try {
206
                try {
205
207
Lines 219-225 Link Here
219
                    String origMessage = message;
221
                    String origMessage = message;
220
                    message = beforeCommitHook(commitCandidates, hooks, message);
222
                    message = beforeCommitHook(commitCandidates, hooks, message);
221
223
222
                    GitRevisionInfo info = commit(commitCandidates, message, author, commiter);
224
                    GitRevisionInfo info = commit(commitCandidates, message, author, commiter, amend);
223
225
224
                    GitModuleConfig.getDefault().putRecentCommitAuthors(GitCommitParameters.getUserString(author));
226
                    GitModuleConfig.getDefault().putRecentCommitAuthors(GitCommitParameters.getUserString(author));
225
                    GitModuleConfig.getDefault().putRecentCommiter(GitCommitParameters.getUserString(commiter));
227
                    GitModuleConfig.getDefault().putRecentCommiter(GitCommitParameters.getUserString(commiter));
Lines 314-324 Link Here
314
            }
316
            }
315
        }
317
        }
316
318
317
        private GitRevisionInfo commit (List<File> commitCandidates, String message, GitUser author, GitUser commiter) throws GitException {
319
        private GitRevisionInfo commit (List<File> commitCandidates, String message, GitUser author, GitUser commiter, boolean amend) throws GitException {
318
            try {
320
            try {
319
                GitRevisionInfo info = getClient().commit(
321
                GitRevisionInfo info = getClient().commit(
320
                        state == GitRepositoryState.MERGING_RESOLVED ? new File[0] : commitCandidates.toArray(new File[commitCandidates.size()]),
322
                        state == GitRepositoryState.MERGING_RESOLVED ? new File[0] : commitCandidates.toArray(new File[commitCandidates.size()]),
321
                        message, author, commiter, getProgressMonitor());
323
                        message, author, commiter, amend, getProgressMonitor());
322
                printInfo(info);
324
                printInfo(info);
323
                return info;
325
                return info;
324
            } catch (GitException ex) {
326
            } catch (GitException ex) {
(-)a/git/src/org/netbeans/modules/git/ui/commit/CommitPanel.form (-9 / +39 lines)
Lines 5-11 Link Here
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 17-43 Link Here
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" 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="585" max="32767" attributes="0"/>
22
                  <Component id="jScrollPane1" alignment="0" max="32767" attributes="0"/>
23
                  <Group type="102" alignment="0" attributes="0">
23
                  <Group type="102" alignment="0" attributes="0">
24
                      <Component id="messageLabel" min="-2" max="-2" attributes="0"/>
24
                      <Component id="messageLabel" min="-2" max="-2" attributes="0"/>
25
                      <EmptySpace pref="465" max="32767" attributes="0"/>
25
                      <EmptySpace pref="355" max="32767" attributes="0"/>
26
                      <Component id="recentLabel" min="-2" max="-2" attributes="0"/>
26
                      <Component id="recentLabel" min="-2" max="-2" attributes="0"/>
27
                      <EmptySpace max="-2" attributes="0"/>
27
                      <EmptySpace max="-2" attributes="0"/>
28
                      <Component id="templatesLabel" min="-2" max="-2" attributes="0"/>
28
                      <Component id="templatesLabel" min="-2" max="-2" attributes="0"/>
29
                      <EmptySpace min="-2" pref="57" max="-2" attributes="0"/>
29
                  </Group>
30
                  </Group>
30
                  <Group type="102" alignment="0" attributes="0">
31
                  <Group type="102" alignment="0" attributes="0">
31
                      <Component id="jLabel2" min="-2" max="-2" attributes="0"/>
32
                      <Component id="jLabel2" min="-2" max="-2" attributes="0"/>
32
                      <EmptySpace type="unrelated" max="-2" attributes="0"/>
33
                      <EmptySpace type="unrelated" max="-2" attributes="0"/>
33
                      <Component id="authorComboBox" pref="219" max="32767" attributes="0"/>
34
                      <Component id="authorComboBox" max="32767" attributes="0"/>
34
                      <EmptySpace max="-2" attributes="0"/>
35
                      <EmptySpace max="-2" attributes="0"/>
35
                      <Component id="jLabel3" min="-2" max="-2" attributes="0"/>
36
                      <Component id="jLabel3" min="-2" max="-2" attributes="0"/>
36
                      <EmptySpace type="separate" max="-2" attributes="0"/>
37
                      <EmptySpace type="separate" max="-2" attributes="0"/>
37
                      <Component id="commiterComboBox" pref="219" max="32767" attributes="0"/>
38
                      <Component id="commiterComboBox" max="32767" attributes="0"/>
39
                  </Group>
40
                  <Group type="102" alignment="0" attributes="0">
41
                      <Component id="amendCheckBox" min="-2" max="-2" attributes="0"/>
42
                      <EmptySpace min="0" pref="0" max="32767" attributes="0"/>
38
                  </Group>
43
                  </Group>
39
              </Group>
44
              </Group>
40
              <EmptySpace min="-2" max="-2" attributes="0"/>
45
              <EmptySpace max="-2" attributes="0"/>
41
          </Group>
46
          </Group>
42
      </Group>
47
      </Group>
43
    </DimensionLayout>
48
    </DimensionLayout>
Lines 51-57 Link Here
51
                  <Component id="recentLabel" alignment="3" min="-2" max="-2" attributes="0"/>
56
                  <Component id="recentLabel" alignment="3" min="-2" max="-2" attributes="0"/>
52
              </Group>
57
              </Group>
53
              <EmptySpace min="-2" max="-2" attributes="0"/>
58
              <EmptySpace min="-2" max="-2" attributes="0"/>
54
              <Component id="jScrollPane1" pref="113" max="32767" attributes="0"/>
59
              <Component id="jScrollPane1" pref="92" max="32767" attributes="0"/>
55
              <EmptySpace min="-2" max="-2" attributes="0"/>
60
              <EmptySpace min="-2" max="-2" attributes="0"/>
56
              <Group type="103" groupAlignment="3" attributes="0">
61
              <Group type="103" groupAlignment="3" attributes="0">
57
                  <Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/>
62
                  <Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/>
Lines 59-65 Link Here
59
                  <Component id="authorComboBox" alignment="3" min="-2" max="-2" attributes="0"/>
64
                  <Component id="authorComboBox" alignment="3" min="-2" max="-2" attributes="0"/>
60
                  <Component id="commiterComboBox" alignment="3" min="-2" max="-2" attributes="0"/>
65
                  <Component id="commiterComboBox" alignment="3" min="-2" max="-2" attributes="0"/>
61
              </Group>
66
              </Group>
62
              <EmptySpace min="-2" max="-2" attributes="0"/>
67
              <EmptySpace max="-2" attributes="0"/>
68
              <Component id="amendCheckBox" min="-2" max="-2" attributes="0"/>
69
              <EmptySpace max="-2" attributes="0"/>
63
          </Group>
70
          </Group>
64
      </Group>
71
      </Group>
65
    </DimensionLayout>
72
    </DimensionLayout>
Lines 95-100 Link Here
95
    </Container>
102
    </Container>
96
    <Component class="javax.swing.JLabel" name="jLabel2">
103
    <Component class="javax.swing.JLabel" name="jLabel2">
97
      <Properties>
104
      <Properties>
105
        <Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
106
          <ComponentRef name="authorComboBox"/>
107
        </Property>
98
        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
108
        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
99
          <ResourceString bundle="org/netbeans/modules/git/ui/commit/Bundle.properties" key="CommitPanel.jLabel2.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
109
          <ResourceString bundle="org/netbeans/modules/git/ui/commit/Bundle.properties" key="CommitPanel.jLabel2.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
100
        </Property>
110
        </Property>
Lines 124-129 Link Here
124
    </Component>
134
    </Component>
125
    <Component class="javax.swing.JLabel" name="jLabel3">
135
    <Component class="javax.swing.JLabel" name="jLabel3">
126
      <Properties>
136
      <Properties>
137
        <Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
138
          <ComponentRef name="commiterComboBox"/>
139
        </Property>
127
        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
140
        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
128
          <ResourceString bundle="org/netbeans/modules/git/ui/commit/Bundle.properties" key="CommitPanel.jLabel3.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
141
          <ResourceString bundle="org/netbeans/modules/git/ui/commit/Bundle.properties" key="CommitPanel.jLabel3.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
129
        </Property>
142
        </Property>
Lines 149-153 Link Here
149
        <AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="parameters.getRecentMessagesLink(messageTextArea)"/>
162
        <AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="parameters.getRecentMessagesLink(messageTextArea)"/>
150
      </AuxValues>
163
      </AuxValues>
151
    </Component>
164
    </Component>
165
    <Component class="javax.swing.JCheckBox" name="amendCheckBox">
166
      <Properties>
167
        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
168
          <ResourceString bundle="org/netbeans/modules/git/ui/commit/Bundle.properties" key="CommitPanel.amendCheckBox.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
169
        </Property>
170
        <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
171
          <ResourceString bundle="org/netbeans/modules/git/ui/commit/Bundle.properties" key="CommitPanel.amendCheckBox.TTtext" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
172
        </Property>
173
        <Property name="enabled" type="boolean" value="false"/>
174
      </Properties>
175
      <Events>
176
        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="amendCheckBoxActionPerformed"/>
177
      </Events>
178
      <AuxValues>
179
        <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
180
      </AuxValues>
181
    </Component>
152
  </SubComponents>
182
  </SubComponents>
153
</Form>
183
</Form>
(-)a/git/src/org/netbeans/modules/git/ui/commit/CommitPanel.java (-11 / +50 lines)
Lines 72-77 Link Here
72
public class CommitPanel extends javax.swing.JPanel {
72
public class CommitPanel extends javax.swing.JPanel {
73
    private final GitCommitParameters parameters;
73
    private final GitCommitParameters parameters;
74
    private UndoRedoSupport um; 
74
    private UndoRedoSupport um; 
75
    private String headCommitMessage;
76
    private boolean commitMessageAmended;
75
77
76
    /** Creates new form CommitPanel */
78
    /** Creates new form CommitPanel */
77
    public CommitPanel(GitCommitParameters parameters, String commitMessage, String user) {
79
    public CommitPanel(GitCommitParameters parameters, String commitMessage, String user) {
Lines 121-126 Link Here
121
                List<String> messages = parameters.getCommitMessages();
123
                List<String> messages = parameters.getCommitMessages();
122
                if (messages.size() > 0) {
124
                if (messages.size() > 0) {
123
                    lastCommitMessage = messages.get(0);
125
                    lastCommitMessage = messages.get(0);
126
                } else {
127
                    lastCommitMessage = headCommitMessage;
124
                }
128
                }
125
            }
129
            }
126
            if (!lastCommitMessage.isEmpty()) {
130
            if (!lastCommitMessage.isEmpty()) {
Lines 166-190 Link Here
166
        jLabel3 = new javax.swing.JLabel();
170
        jLabel3 = new javax.swing.JLabel();
167
        templatesLabel = parameters.getMessagesTemplateLink(messageTextArea);
171
        templatesLabel = parameters.getMessagesTemplateLink(messageTextArea);
168
        recentLabel = parameters.getRecentMessagesLink(messageTextArea);
172
        recentLabel = parameters.getRecentMessagesLink(messageTextArea);
173
        amendCheckBox = new javax.swing.JCheckBox();
169
174
170
        messageLabel.setLabelFor(messageTextArea);
175
        messageLabel.setLabelFor(messageTextArea);
171
        messageLabel.setText(org.openide.util.NbBundle.getMessage(CommitPanel.class, "CommitPanel.messageLabel.text")); // NOI18N
176
        org.openide.awt.Mnemonics.setLocalizedText(messageLabel, org.openide.util.NbBundle.getMessage(CommitPanel.class, "CommitPanel.messageLabel.text")); // NOI18N
172
177
173
        messageTextArea.setColumns(20);
178
        messageTextArea.setColumns(20);
174
        messageTextArea.setRows(5);
179
        messageTextArea.setRows(5);
175
        jScrollPane1.setViewportView(messageTextArea);
180
        jScrollPane1.setViewportView(messageTextArea);
176
181
177
        jLabel2.setText(org.openide.util.NbBundle.getMessage(CommitPanel.class, "CommitPanel.jLabel2.text")); // NOI18N
182
        jLabel2.setLabelFor(authorComboBox);
183
        org.openide.awt.Mnemonics.setLocalizedText(jLabel2, org.openide.util.NbBundle.getMessage(CommitPanel.class, "CommitPanel.jLabel2.text")); // NOI18N
178
184
179
        authorComboBox.setEditable(true);
185
        authorComboBox.setEditable(true);
180
186
181
        commiterComboBox.setEditable(true);
187
        commiterComboBox.setEditable(true);
182
188
183
        jLabel3.setText(org.openide.util.NbBundle.getMessage(CommitPanel.class, "CommitPanel.jLabel3.text")); // NOI18N
189
        jLabel3.setLabelFor(commiterComboBox);
190
        org.openide.awt.Mnemonics.setLocalizedText(jLabel3, org.openide.util.NbBundle.getMessage(CommitPanel.class, "CommitPanel.jLabel3.text")); // NOI18N
184
191
185
        templatesLabel.setText(org.openide.util.NbBundle.getMessage(CommitPanel.class, "CommitPanel.templatesLabel.text")); // NOI18N
192
        org.openide.awt.Mnemonics.setLocalizedText(templatesLabel, org.openide.util.NbBundle.getMessage(CommitPanel.class, "CommitPanel.templatesLabel.text")); // NOI18N
186
193
187
        recentLabel.setText(org.openide.util.NbBundle.getMessage(CommitPanel.class, "CommitPanel.recentLabel.text")); // NOI18N
194
        org.openide.awt.Mnemonics.setLocalizedText(recentLabel, org.openide.util.NbBundle.getMessage(CommitPanel.class, "CommitPanel.recentLabel.text")); // NOI18N
195
196
        org.openide.awt.Mnemonics.setLocalizedText(amendCheckBox, org.openide.util.NbBundle.getMessage(CommitPanel.class, "CommitPanel.amendCheckBox.text")); // NOI18N
197
        amendCheckBox.setToolTipText(org.openide.util.NbBundle.getMessage(CommitPanel.class, "CommitPanel.amendCheckBox.TTtext")); // NOI18N
198
        amendCheckBox.setEnabled(false);
199
        amendCheckBox.addActionListener(new java.awt.event.ActionListener() {
200
            public void actionPerformed(java.awt.event.ActionEvent evt) {
201
                amendCheckBoxActionPerformed(evt);
202
            }
203
        });
188
204
189
        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
205
        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
190
        this.setLayout(layout);
206
        this.setLayout(layout);
Lines 193-213 Link Here
193
            .addGroup(layout.createSequentialGroup()
209
            .addGroup(layout.createSequentialGroup()
194
                .addContainerGap()
210
                .addContainerGap()
195
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
211
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
196
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 585, Short.MAX_VALUE)
212
                    .addComponent(jScrollPane1)
197
                    .addGroup(layout.createSequentialGroup()
213
                    .addGroup(layout.createSequentialGroup()
198
                        .addComponent(messageLabel)
214
                        .addComponent(messageLabel)
199
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 465, Short.MAX_VALUE)
215
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 355, Short.MAX_VALUE)
200
                        .addComponent(recentLabel)
216
                        .addComponent(recentLabel)
201
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
217
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
202
                        .addComponent(templatesLabel))
218
                        .addComponent(templatesLabel)
219
                        .addGap(57, 57, 57))
203
                    .addGroup(layout.createSequentialGroup()
220
                    .addGroup(layout.createSequentialGroup()
204
                        .addComponent(jLabel2)
221
                        .addComponent(jLabel2)
205
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
222
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
206
                        .addComponent(authorComboBox, 0, 219, Short.MAX_VALUE)
223
                        .addComponent(authorComboBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
207
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
224
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
208
                        .addComponent(jLabel3)
225
                        .addComponent(jLabel3)
209
                        .addGap(18, 18, 18)
226
                        .addGap(18, 18, 18)
210
                        .addComponent(commiterComboBox, 0, 219, Short.MAX_VALUE)))
227
                        .addComponent(commiterComboBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
228
                    .addGroup(layout.createSequentialGroup()
229
                        .addComponent(amendCheckBox)
230
                        .addGap(0, 0, Short.MAX_VALUE)))
211
                .addContainerGap())
231
                .addContainerGap())
212
        );
232
        );
213
        layout.setVerticalGroup(
233
        layout.setVerticalGroup(
Lines 219-237 Link Here
219
                    .addComponent(templatesLabel)
239
                    .addComponent(templatesLabel)
220
                    .addComponent(recentLabel))
240
                    .addComponent(recentLabel))
221
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
241
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
222
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 113, Short.MAX_VALUE)
242
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 92, Short.MAX_VALUE)
223
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
243
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
224
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
244
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
225
                    .addComponent(jLabel2)
245
                    .addComponent(jLabel2)
226
                    .addComponent(jLabel3)
246
                    .addComponent(jLabel3)
227
                    .addComponent(authorComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
247
                    .addComponent(authorComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
228
                    .addComponent(commiterComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
248
                    .addComponent(commiterComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
249
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
250
                .addComponent(amendCheckBox)
229
                .addContainerGap())
251
                .addContainerGap())
230
        );
252
        );
231
    }// </editor-fold>//GEN-END:initComponents
253
    }// </editor-fold>//GEN-END:initComponents
232
254
255
    private void amendCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_amendCheckBoxActionPerformed
256
        if (amendCheckBox.isSelected() && !commitMessageAmended) {
257
            this.messageTextArea.setText(headCommitMessage);
258
            commitMessageAmended = true;
259
        }
260
    }//GEN-LAST:event_amendCheckBoxActionPerformed
261
233
262
234
    // Variables declaration - do not modify//GEN-BEGIN:variables
263
    // Variables declaration - do not modify//GEN-BEGIN:variables
264
    javax.swing.JCheckBox amendCheckBox;
235
    final javax.swing.JComboBox authorComboBox = new javax.swing.JComboBox();
265
    final javax.swing.JComboBox authorComboBox = new javax.swing.JComboBox();
236
    final javax.swing.JComboBox commiterComboBox = new javax.swing.JComboBox();
266
    final javax.swing.JComboBox commiterComboBox = new javax.swing.JComboBox();
237
    private javax.swing.JLabel jLabel2;
267
    private javax.swing.JLabel jLabel2;
Lines 247-252 Link Here
247
        return NbBundle.getMessage(CommitPanel.class, msgKey);
277
        return NbBundle.getMessage(CommitPanel.class, msgKey);
248
    }
278
    }
249
279
280
    public String getHeadCommitMessage() {
281
        return headCommitMessage;
282
    }
283
284
    public void setHeadCommitMessage(String headCommitMessage) {
285
        this.headCommitMessage = headCommitMessage;
286
        this.amendCheckBox.setEnabled(true);
287
    }
288
250
    private ComboBoxModel prepareUserModel (List<String> authors, String user) {
289
    private ComboBoxModel prepareUserModel (List<String> authors, String user) {
251
        DefaultComboBoxModel model;
290
        DefaultComboBoxModel model;
252
        if (authors == null) {
291
        if (authors == null) {
(-)a/git/src/org/netbeans/modules/git/ui/commit/GitCommitPanel.java (-71 / +101 lines)
Lines 43-48 Link Here
43
package org.netbeans.modules.git.ui.commit;
43
package org.netbeans.modules.git.ui.commit;
44
44
45
import java.awt.EventQueue;
45
import java.awt.EventQueue;
46
import java.awt.event.ItemEvent;
47
import java.awt.event.ItemListener;
46
import java.io.File;
48
import java.io.File;
47
import java.util.ArrayList;
49
import java.util.ArrayList;
48
import java.util.Arrays;
50
import java.util.Arrays;
Lines 62-67 Link Here
62
import javax.swing.ImageIcon;
64
import javax.swing.ImageIcon;
63
import javax.swing.JComponent;
65
import javax.swing.JComponent;
64
import org.netbeans.libs.git.GitException;
66
import org.netbeans.libs.git.GitException;
67
import org.netbeans.libs.git.GitRevisionInfo;
65
import org.netbeans.libs.git.GitUser;
68
import org.netbeans.libs.git.GitUser;
66
import org.netbeans.modules.git.FileInformation;
69
import org.netbeans.modules.git.FileInformation;
67
import org.netbeans.modules.git.FileInformation.Mode;
70
import org.netbeans.modules.git.FileInformation.Mode;
Lines 124-141 Link Here
124
    }
127
    }
125
128
126
    public static GitCommitPanel create(final File[] roots, final File repository, GitUser user, boolean fromGitView) {
129
    public static GitCommitPanel create(final File[] roots, final File repository, GitUser user, boolean fromGitView) {
127
        
128
        Preferences preferences = GitModuleConfig.getDefault().getPreferences();
130
        Preferences preferences = GitModuleConfig.getDefault().getPreferences();
129
        String lastCanceledCommitMessage = GitModuleConfig.getDefault().getLastCanceledCommitMessage();
131
        String lastCanceledCommitMessage = GitModuleConfig.getDefault().getLastCanceledCommitMessage();
130
        
132
131
        DefaultCommitParameters parameters = new GitCommitParameters(preferences, lastCanceledCommitMessage, user);
133
        GitCommitParameters parameters = new GitCommitParameters(preferences, lastCanceledCommitMessage, user);
132
        
134
        
133
        Collection<GitHook> hooks = VCSHooks.getInstance().getHooks(GitHook.class);
135
        Collection<GitHook> hooks = VCSHooks.getInstance().getHooks(GitHook.class);
134
        GitHookContext hooksCtx = new GitHookContext(roots, null, new GitHookContext.LogEntry[] {});        
136
        GitHookContext hooksCtx = new GitHookContext(roots, null, new GitHookContext.LogEntry[] {});        
135
        
137
        
136
        DiffProvider diffProvider = new DiffProvider();
138
        DiffProvider diffProvider = new DiffProvider();
137
        
139
        final GitCommitTable gitCommitTable = new GitCommitTable();
138
        return new GitCommitPanel(new GitCommitTable(), roots, repository, parameters, preferences, hooks, hooksCtx, diffProvider, fromGitView, createFilters(fromGitView));
140
        final CommitPanel panel = parameters.getPanel();
141
        panel.amendCheckBox.addItemListener(new ItemListener() {
142
143
            @Override
144
            public void itemStateChanged(ItemEvent e) {
145
                gitCommitTable.setAmend(panel.amendCheckBox.isSelected());
146
            }
147
        });
148
        return new GitCommitPanel(gitCommitTable, roots, repository, parameters, preferences, hooks, hooksCtx, diffProvider, fromGitView, createFilters(fromGitView));
139
    }
149
    }
140
150
141
    private static void disableFilters () {
151
    private static void disableFilters () {
Lines 220-300 Link Here
220
230
221
    // merge-type commit dialog can hook into this method
231
    // merge-type commit dialog can hook into this method
222
    protected GitProgressSupport getProgressSupport (final boolean[] refreshFinished) {
232
    protected GitProgressSupport getProgressSupport (final boolean[] refreshFinished) {
223
        return new GitProgressSupport() {
233
        return new GitCommitDialogProgressSupport(refreshFinished);
224
            @Override
234
    }
225
            public void perform() {
235
226
                try {
236
    private class GitCommitDialogProgressSupport extends GitProgressSupport {
227
                    EventQueue.invokeLater(new Runnable() {
237
228
                        @Override
238
        private final boolean[] refreshFinished;
229
                        public void run() {
239
230
                            getCommitTable().setNodes(new GitFileNode[0]);
240
        public GitCommitDialogProgressSupport(boolean[] refreshFinished) {
231
                        }
241
            this.refreshFinished = refreshFinished;
232
                    });
242
        }
233
                    // Ensure that cache is uptodate
243
234
                    FileStatusCache cache = Git.getInstance().getFileStatusCache();
244
        @Override
235
                    cache.refreshAllRoots(Collections.<File, Collection<File>>singletonMap(repository, Arrays.asList(roots)), getProgressMonitor());
245
        public void perform() {
236
                    // the realy time consuming part is over;
246
            try {
237
                    // no need to show the progress component,
247
                loadFiles();
238
                    // which only makes the dialog flicker
248
                loadHeadLogMessage();
239
                    refreshFinished[0] = true;
249
            } catch (GitException ex) {
240
                    File[][] split = Utils.splitFlatOthers(roots);
250
                GitClientExceptionHandler.notifyException(ex, true);
241
                    List<File> fileList = new ArrayList<File>();
251
            } finally {
242
                    for (int c = 0; c < split.length; c++) {
252
                refreshFinished[0] = true;
243
                        File[] splitRoots = split[c];
253
                EventQueue.invokeLater(new Runnable() {
244
                        boolean recursive = c == 1;
254
                    @Override
245
                        if (recursive) {
255
                    public void run() {
246
                            File[] files = cache.listFiles(splitRoots, getAcceptedStatus());
256
                        stopProgress();
247
                            for (int i = 0; i < files.length; i++) {
257
                    }
248
                                for(int r = 0; r < splitRoots.length; r++) {
258
                });
249
                                    if(Utils.isAncestorOrEqual(splitRoots[r], files[i]))
259
            }
250
                                    {
260
        }
251
                                        if(!fileList.contains(files[i])) {
261
252
                                            fileList.add(files[i]);
262
        private void loadHeadLogMessage() throws IllegalArgumentException, GitException {
253
                                        }
263
            GitRevisionInfo gitRevisionInfo = getClient().log(GitUtils.HEAD, getProgressMonitor());
254
                                    }
264
            String headCommitMessage = gitRevisionInfo.getFullMessage();
255
                                }
265
            getParameters().getPanel().setHeadCommitMessage(headCommitMessage);
256
                            }
266
        }
257
                        } else {
267
258
                            File[] files = GitUtils.flatten(splitRoots, getAcceptedStatus());
268
        private boolean loadFiles() {
259
                            for (int i= 0; i<files.length; i++) {
269
            EventQueue.invokeLater(new Runnable() {
260
                                if(!fileList.contains(files[i])) {
270
                @Override
271
                public void run() {
272
                    getCommitTable().setNodes(new GitFileNode[0]);
273
                }
274
            });
275
            // Ensure that cache is uptodate
276
            FileStatusCache cache = Git.getInstance().getFileStatusCache();
277
            cache.refreshAllRoots(Collections.<File, Collection<File>>singletonMap(repository, Arrays.asList(roots)), getProgressMonitor());
278
            // the realy time consuming part is over;
279
            // no need to show the progress component,
280
            // which only makes the dialog flicker
281
            refreshFinished[0] = true;
282
            File[][] split = Utils.splitFlatOthers(roots);
283
            List<File> fileList = new ArrayList<File>();
284
            for (int c = 0; c < split.length; c++) {
285
                File[] splitRoots = split[c];
286
                boolean recursive = c == 1;
287
                if (recursive) {
288
                    File[] files = cache.listFiles(splitRoots, getAcceptedStatus());
289
                    for (int i = 0; i < files.length; i++) {
290
                        for (int r = 0; r < splitRoots.length; r++) {
291
                            if (Utils.isAncestorOrEqual(splitRoots[r], files[i])) {
292
                                if (!fileList.contains(files[i])) {
261
                                    fileList.add(files[i]);
293
                                    fileList.add(files[i]);
262
                                }
294
                                }
263
                            }
295
                            }
264
                        }
296
                        }
265
                    }
297
                    }
266
                    if(fileList.isEmpty()) {
298
                } else {
267
                        return;
299
                    File[] files = GitUtils.flatten(splitRoots, getAcceptedStatus());
268
                    }
300
                    for (int i = 0; i < files.length; i++) {
269
301
                        if (!fileList.contains(files[i])) {
270
                    ArrayList<GitFileNode> nodesList = new ArrayList<GitFileNode>(fileList.size());
302
                            fileList.add(files[i]);
271
272
                    Git git = Git.getInstance();
273
                    for (Iterator<File> it = fileList.iterator(); it.hasNext();) {
274
                        File file = it.next();
275
                        if (repository.equals(git.getRepositoryRoot(file))) {
276
                            GitFileNode node = new GitFileNode(repository, file);
277
                            nodesList.add(node);
278
                        }
303
                        }
279
                    }
304
                    }
280
                    final GitFileNode[] nodes = nodesList.toArray(new GitFileNode[nodesList.size()]);
281
                    EventQueue.invokeLater(new Runnable() {
282
                        @Override
283
                        public void run() {
284
                            getCommitTable().setNodes(nodes);
285
                        }
286
                    });
287
                } finally {
288
                    refreshFinished[0] = true;
289
                    EventQueue.invokeLater(new Runnable() {
290
                        @Override
291
                        public void run() {
292
                            stopProgress();
293
                        }
294
                    });
295
                }
305
                }
296
            }
306
            }
297
        };
307
            if (fileList.isEmpty()) {
308
                return true;
309
            }
310
            List<GitFileNode> nodesList = new ArrayList<GitFileNode>(fileList.size());
311
            Git git = Git.getInstance();
312
            for (Iterator<File> it = fileList.iterator(); it.hasNext();) {
313
                File file = it.next();
314
                if (repository.equals(git.getRepositoryRoot(file))) {
315
                    GitFileNode node = new GitFileNode(repository, file);
316
                    nodesList.add(node);
317
                }
318
            }
319
            final GitFileNode[] nodes = nodesList.toArray(new GitFileNode[nodesList.size()]);
320
            EventQueue.invokeLater(new Runnable() {
321
                @Override
322
                public void run() {
323
                    getCommitTable().setNodes(nodes);
324
                }
325
            });
326
            return false;
327
        }
298
    }
328
    }
299
    
329
    
300
    private EnumSet<Status> getAcceptedStatus() {
330
    private EnumSet<Status> getAcceptedStatus() {
(-)a/git/src/org/netbeans/modules/git/ui/commit/GitCommitParameters.java (+5 lines)
Lines 82-87 Link Here
82
            
82
            
83
            ((JTextField) panel.authorComboBox.getEditor().getEditorComponent()).getDocument().addDocumentListener(this);
83
            ((JTextField) panel.authorComboBox.getEditor().getEditorComponent()).getDocument().addDocumentListener(this);
84
            ((JTextField) panel.commiterComboBox.getEditor().getEditorComponent()).getDocument().addDocumentListener(this);
84
            ((JTextField) panel.commiterComboBox.getEditor().getEditorComponent()).getDocument().addDocumentListener(this);
85
            panel.amendCheckBox.addItemListener(this);
85
            panel.authorComboBox.addItemListener(this);
86
            panel.authorComboBox.addItemListener(this);
86
            panel.commiterComboBox.addItemListener(this);
87
            panel.commiterComboBox.addItemListener(this);
87
        }
88
        }
Lines 120-125 Link Here
120
    public String getCommitMessage() {
121
    public String getCommitMessage() {
121
        return ((CommitPanel) getPanel()).messageTextArea.getText();
122
        return ((CommitPanel) getPanel()).messageTextArea.getText();
122
    }
123
    }
124
125
    public boolean isAmend() {
126
        return getPanel().amendCheckBox.isSelected();
127
    }
123
    
128
    
124
    public GitUser getAuthor() {
129
    public GitUser getAuthor() {
125
        return getUser(getPanel().authorComboBox);
130
        return getUser(getPanel().authorComboBox);
(-)a/git/src/org/netbeans/modules/git/ui/commit/GitCommitTable.java (+12 lines)
Lines 57-62 Link Here
57
public class GitCommitTable extends VCSCommitTable<GitFileNode> {
57
public class GitCommitTable extends VCSCommitTable<GitFileNode> {
58
58
59
    private String errroMessage;
59
    private String errroMessage;
60
    private boolean amend;
60
    
61
    
61
    public GitCommitTable() {
62
    public GitCommitTable() {
62
        this(true);
63
        this(true);
Lines 74-79 Link Here
74
        boolean ret = false;        
75
        boolean ret = false;        
75
        errroMessage = null;
76
        errroMessage = null;
76
        boolean isEmpty = true;
77
        boolean isEmpty = true;
78
        if (amend) {
79
            return true;
80
        }
77
        for(GitFileNode fileNode : list) {                        
81
        for(GitFileNode fileNode : list) {                        
78
            
82
            
79
            VCSCommitOptions co = fileNode.getCommitOptions();
83
            VCSCommitOptions co = fileNode.getCommitOptions();
Lines 102-106 Link Here
102
    public String getErrorMessage() {
106
    public String getErrorMessage() {
103
        return errroMessage;
107
        return errroMessage;
104
    }    
108
    }    
109
110
    public boolean isAmend() {
111
        return amend;
112
    }
113
114
    public void setAmend(boolean amend) {
115
        this.amend = amend;
116
    }
105
    
117
    
106
}
118
}

Return to bug 215636