Skip to content

Commit 46d33ad

Browse files
authored
Merge pull request #8826 from mbien/improve-maven-rerun-prop-handling
Improve maven goal re-run property handling and UI
2 parents 887fb57 + bb5b83e commit 46d33ad

File tree

6 files changed

+121
-44
lines changed

6 files changed

+121
-44
lines changed

java/maven/src/org/netbeans/modules/maven/ActionProviderImpl.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,7 @@ public void actionPerformed(java.awt.event.ActionEvent e) {
570570
Object retValue = DialogDisplayer.getDefault().notify(dd);
571571
if (retValue == DialogDescriptor.OK_OPTION) {
572572
pnl.applyValues(mapping);
573+
maps.getActions().remove(mapping); // deduplicate
573574
if (maps.getActions().size() > 10) {
574575
maps.getActions().remove(0);
575576
}

java/maven/src/org/netbeans/modules/maven/execute/AbstractMavenExecutor.java

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ public static final class TabContext {
9191

9292
protected RunConfig config;
9393
private TabContext tabContext;
94-
private List<String> messages = new ArrayList<String>();
95-
private List<OutputListener> listeners = new ArrayList<OutputListener>();
94+
private final List<String> messages = new ArrayList<>();
95+
private final List<OutputListener> listeners = new ArrayList<>();
9696
protected ExecutorTask task;
9797
protected MavenItem item;
9898
protected final Object SEMAPHORE = new Object();
@@ -210,23 +210,21 @@ protected void reassignAdditionalContext(TabContext tabContext) {
210210
class ReRunAction extends AbstractAction {
211211

212212
private RunConfig config;
213-
private boolean debug;
213+
private final boolean openGoalsPanel;
214214

215215
@Messages({
216216
"TXT_Rerun_extra=Re-run with different parameters",
217217
"TXT_Rerun=Re-run the goals.",
218218
"TIP_Rerun_Extra=Re-run with different parameters",
219219
"TIP_Rerun=Re-run the goals."
220220
})
221-
ReRunAction(boolean debug) {
222-
this.debug = debug;
223-
this.putValue(Action.SMALL_ICON, debug ? ImageUtilities.loadImageIcon("org/netbeans/modules/maven/execute/refreshdebug.png", false) : //NOI18N
224-
ImageUtilities.loadImageIcon("org/netbeans/modules/maven/execute/refresh.png", false));//NOI18N
225-
226-
putValue(Action.NAME, debug ? TXT_Rerun_extra() : TXT_Rerun());
227-
putValue(Action.SHORT_DESCRIPTION, debug ? TIP_Rerun_Extra() : TIP_Rerun());
221+
ReRunAction(boolean openGoalsPanel) {
222+
this.openGoalsPanel = openGoalsPanel;
223+
String img = openGoalsPanel ? "org/netbeans/modules/maven/execute/refreshdebug.png" : "org/netbeans/modules/maven/execute/refresh.png"; //NOI18N
224+
putValue(Action.SMALL_ICON, ImageUtilities.loadImageIcon(img, false));
225+
putValue(Action.NAME, openGoalsPanel ? TXT_Rerun_extra() : TXT_Rerun());
226+
putValue(Action.SHORT_DESCRIPTION, openGoalsPanel ? TIP_Rerun_Extra() : TIP_Rerun());
228227
setEnabled(false);
229-
230228
}
231229

232230
void setConfig(RunConfig config) {
@@ -236,16 +234,17 @@ void setConfig(RunConfig config) {
236234
@Messages("TIT_Run_maven=Run Maven")
237235
@Override public void actionPerformed(ActionEvent e) {
238236
BeanRunConfig newConfig = new BeanRunConfig(config);
239-
if (debug) {
237+
if (openGoalsPanel) {
240238
RunGoalsPanel pnl = new RunGoalsPanel();
239+
pnl.showPersistenceBar(false);
241240
DialogDescriptor dd = new DialogDescriptor(pnl, TIT_Run_maven());
242241
pnl.readConfig(config);
243242
Object retValue = DialogDisplayer.getDefault().notify(dd);
244243
if (retValue == DialogDescriptor.OK_OPTION) {
245244
pnl.applyValues(newConfig);
246-
} else {
245+
} else {
247246
return;
248-
}
247+
}
249248
}
250249
actionStatesAtStart();
251250
InputOutput inputOutput = getInputOutput();
@@ -292,7 +291,7 @@ void setFinder(ResumeFromFinder finder) {
292291
StatusDisplayer.getDefault().setStatusText(ResumeAction_could_not_find_module());
293292
return;
294293
}
295-
final AtomicReference<Thread> t = new AtomicReference<Thread>();
294+
final AtomicReference<Thread> t = new AtomicReference<>();
296295
final ProgressHandle handle = ProgressHandle.createHandle(ResumeAction_scanning(), new Cancellable() {
297296
@Override public boolean cancel() {
298297
Thread _t = t.get();
@@ -325,7 +324,7 @@ void setFinder(ResumeFromFinder finder) {
325324
String rel = root != null && module != null ? FileUtilities.relativizeFile(root, module) : null;
326325
String id = rel != null ? rel : nbmp.getMavenProject().getGroupId() + ':' + nbmp.getMavenProject().getArtifactId();
327326
BeanRunConfig newConfig = new BeanRunConfig(config);
328-
List<String> goals = new ArrayList<String>(config.getGoals());
327+
List<String> goals = new ArrayList<>(config.getGoals());
329328
int rf = goals.indexOf("--resume-from");
330329
if (rf != -1) {
331330
goals.set(rf + 1, id);
@@ -363,11 +362,7 @@ void setExecutor(AbstractMavenExecutor ex) {
363362

364363
@Override public void actionPerformed(ActionEvent e) {
365364
setEnabled(false);
366-
RequestProcessor.getDefault().post(new Runnable() {
367-
@Override public void run() {
368-
exec.cancel();
369-
}
370-
});
365+
RequestProcessor.getDefault().post(exec::cancel);
371366
}
372367
}
373368

java/maven/src/org/netbeans/modules/maven/execute/model/NetbeansActionMapping.java

Lines changed: 78 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,11 @@
2323
//- Imported classes and packages -/
2424
//---------------------------------/
2525

26+
import java.util.ArrayList;
2627
import java.util.LinkedHashMap;
28+
import java.util.List;
2729
import java.util.Map;
30+
import java.util.Objects;
2831

2932
/**
3033
* Class NetbeansActionMapping.
@@ -56,12 +59,12 @@ public class NetbeansActionMapping implements java.io.Serializable {
5659
/**
5760
* Field packagings.
5861
*/
59-
private java.util.List<String> packagings;
62+
private List<String> packagings;
6063

6164
/**
6265
* Field goals.
6366
*/
64-
private java.util.List<String> goals;
67+
private List<String> goals;
6568

6669
/**
6770
* Field properties.
@@ -76,7 +79,7 @@ public class NetbeansActionMapping implements java.io.Serializable {
7679
/**
7780
* Field activatedProfiles.
7881
*/
79-
private java.util.List<String> activatedProfiles;
82+
private List<String> activatedProfiles;
8083

8184
private String basedir;
8285

@@ -184,7 +187,7 @@ public java.util.List<String> getActivatedProfiles()
184187
{
185188
if ( this.activatedProfiles == null )
186189
{
187-
this.activatedProfiles = new java.util.ArrayList<String>();
190+
this.activatedProfiles = new ArrayList<>();
188191
}
189192

190193
return this.activatedProfiles;
@@ -209,7 +212,7 @@ public java.util.List<String> getGoals()
209212
{
210213
if ( this.goals == null )
211214
{
212-
this.goals = new java.util.ArrayList<String>();
215+
this.goals = new ArrayList<>();
213216
}
214217

215218
return this.goals;
@@ -224,7 +227,7 @@ public java.util.List<String> getPackagings()
224227
{
225228
if ( this.packagings == null )
226229
{
227-
this.packagings = new java.util.ArrayList<String>();
230+
this.packagings = new ArrayList<>();
228231
}
229232

230233
return this.packagings;
@@ -234,7 +237,7 @@ public Map<String,String> getProperties()
234237
{
235238
if ( this.properties == null )
236239
{
237-
this.properties = new LinkedHashMap<String,String>();
240+
this.properties = new LinkedHashMap<>();
238241
}
239242

240243
return this.properties;
@@ -244,7 +247,7 @@ public Map<String,String> getOptions()
244247
{
245248
if ( this.options == null )
246249
{
247-
this.options = new LinkedHashMap<String,String>();
250+
this.options = new LinkedHashMap<>();
248251
}
249252

250253
return this.options;
@@ -391,4 +394,71 @@ public String getModelEncoding()
391394
{
392395
return modelEncoding;
393396
}
397+
398+
@Override
399+
public int hashCode() {
400+
return Objects.hash(
401+
actionName,
402+
displayName,
403+
recursive,
404+
packagings,
405+
goals,
406+
properties,
407+
options,
408+
activatedProfiles,
409+
basedir,
410+
preAction,
411+
reactor,
412+
modelEncoding
413+
);
414+
}
415+
416+
@Override
417+
public boolean equals(Object obj) {
418+
if (this == obj) {
419+
return true;
420+
}
421+
if (obj == null) {
422+
return false;
423+
}
424+
if (getClass() != obj.getClass()) {
425+
return false;
426+
}
427+
final NetbeansActionMapping other = (NetbeansActionMapping) obj;
428+
if (this.recursive != other.recursive) {
429+
return false;
430+
}
431+
if (!Objects.equals(this.actionName, other.actionName)) {
432+
return false;
433+
}
434+
if (!Objects.equals(this.displayName, other.displayName)) {
435+
return false;
436+
}
437+
if (!Objects.equals(this.basedir, other.basedir)) {
438+
return false;
439+
}
440+
if (!Objects.equals(this.preAction, other.preAction)) {
441+
return false;
442+
}
443+
if (!Objects.equals(this.reactor, other.reactor)) {
444+
return false;
445+
}
446+
if (!Objects.equals(this.modelEncoding, other.modelEncoding)) {
447+
return false;
448+
}
449+
if (!Objects.equals(this.packagings, other.packagings)) {
450+
return false;
451+
}
452+
if (!Objects.equals(this.goals, other.goals)) {
453+
return false;
454+
}
455+
if (!Objects.equals(this.properties, other.properties)) {
456+
return false;
457+
}
458+
if (!Objects.equals(this.options, other.options)) {
459+
return false;
460+
}
461+
return Objects.equals(this.activatedProfiles, other.activatedProfiles);
462+
}
463+
394464
}

java/maven/src/org/netbeans/modules/maven/execute/ui/Bundle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ TIP_Next=Get next entry
3636

3737
TIP_Prev=Get previous entry
3838

39-
LBL_Remember=Remember &as\:
39+
LBL_Remember=Save &as:
4040
ShowExecutionPanel.btnPhaseToggle.text=Show Phase
4141
ShowExecutionPanel.btnPhaseToggle.toolTipText=Show build Phase in tree
4242
ShowExecutionPanel.btnCollapse.toolTipText=Collapse All

java/maven/src/org/netbeans/modules/maven/execute/ui/RunGoalsPanel.form

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
<Group type="103" groupAlignment="0" attributes="0">
6969
<Component id="txtGoals" alignment="0" max="32767" attributes="0"/>
7070
<Component id="txtProfiles" alignment="0" max="32767" attributes="0"/>
71-
<Component id="jScrollPane2" alignment="0" max="32767" attributes="0"/>
71+
<Component id="jScrollPane2" alignment="0" pref="540" max="32767" attributes="0"/>
7272
</Group>
7373
</Group>
7474
<Group type="102" alignment="0" attributes="0">
@@ -78,7 +78,7 @@
7878
<EmptySpace min="-2" pref="52" max="-2" attributes="0"/>
7979
<Component id="cbRemember" min="-2" max="-2" attributes="0"/>
8080
<EmptySpace max="-2" attributes="0"/>
81-
<Component id="txtRemember" pref="275" max="32767" attributes="0"/>
81+
<Component id="txtRemember" max="32767" attributes="0"/>
8282
</Group>
8383
<Component id="jSeparator1" alignment="0" max="32767" attributes="0"/>
8484
</Group>
@@ -106,7 +106,7 @@
106106
<EmptySpace max="32767" attributes="0"/>
107107
<Component id="btnAddProps" min="-2" max="-2" attributes="0"/>
108108
</Group>
109-
<Component id="jScrollPane2" pref="110" max="32767" attributes="0"/>
109+
<Component id="jScrollPane2" pref="130" max="32767" attributes="0"/>
110110
</Group>
111111
<EmptySpace type="unrelated" min="-2" max="-2" attributes="0"/>
112112
<Group type="103" groupAlignment="3" attributes="0">

0 commit comments

Comments
 (0)