Lines 52-57
Link Here
|
52 |
import java.util.ArrayList; |
52 |
import java.util.ArrayList; |
53 |
import java.util.Iterator; |
53 |
import java.util.Iterator; |
54 |
import java.util.List; |
54 |
import java.util.List; |
|
|
55 |
import java.util.logging.Level; |
55 |
import java.util.logging.Logger; |
56 |
import java.util.logging.Logger; |
56 |
import javax.swing.DefaultComboBoxModel; |
57 |
import javax.swing.DefaultComboBoxModel; |
57 |
import javax.swing.DefaultListCellRenderer; |
58 |
import javax.swing.DefaultListCellRenderer; |
Lines 60-65
Link Here
|
60 |
import javax.swing.JLabel; |
61 |
import javax.swing.JLabel; |
61 |
import javax.swing.JList; |
62 |
import javax.swing.JList; |
62 |
import javax.swing.JTextField; |
63 |
import javax.swing.JTextField; |
|
|
64 |
import javax.swing.SwingUtilities; |
63 |
import javax.swing.event.ChangeEvent; |
65 |
import javax.swing.event.ChangeEvent; |
64 |
import javax.swing.event.ChangeListener; |
66 |
import javax.swing.event.ChangeListener; |
65 |
import javax.swing.event.DocumentEvent; |
67 |
import javax.swing.event.DocumentEvent; |
Lines 68-73
Link Here
|
68 |
import org.netbeans.api.project.ProjectUtils; |
70 |
import org.netbeans.api.project.ProjectUtils; |
69 |
import org.netbeans.api.project.SourceGroup; |
71 |
import org.netbeans.api.project.SourceGroup; |
70 |
import org.netbeans.api.project.Sources; |
72 |
import org.netbeans.api.project.Sources; |
|
|
73 |
import org.netbeans.modules.java.j2seproject.ui.customizer.vmo.OptionsDialog; |
71 |
import org.netbeans.modules.maven.NbMavenProjectImpl; |
74 |
import org.netbeans.modules.maven.NbMavenProjectImpl; |
72 |
import org.netbeans.modules.maven.api.customizer.ModelHandle2; |
75 |
import org.netbeans.modules.maven.api.customizer.ModelHandle2; |
73 |
import org.netbeans.modules.maven.classpath.MavenSourcesImpl; |
76 |
import org.netbeans.modules.maven.classpath.MavenSourcesImpl; |
Lines 90-95
Link Here
|
90 |
* @author Milos Kleint |
93 |
* @author Milos Kleint |
91 |
*/ |
94 |
*/ |
92 |
public class RunJarPanel extends javax.swing.JPanel implements HelpCtx.Provider { |
95 |
public class RunJarPanel extends javax.swing.JPanel implements HelpCtx.Provider { |
|
|
96 |
public static final Logger log = Logger.getLogger(RunJarPanel.class.getName()); |
93 |
|
97 |
|
94 |
private boolean isCurrentRun = true; |
98 |
private boolean isCurrentRun = true; |
95 |
private boolean isCurrentDebug = true; |
99 |
private boolean isCurrentDebug = true; |
Lines 109-116
Link Here
|
109 |
private String oldVMParams; |
113 |
private String oldVMParams; |
110 |
private String oldWorkDir; |
114 |
private String oldWorkDir; |
111 |
private String oldAllParams; |
115 |
private String oldAllParams; |
112 |
private DocumentListener docListener; |
116 |
private final DocumentListener docListener; |
113 |
private ActionListener comboListener; |
117 |
private final ActionListener comboListener; |
114 |
private ProjectCustomizer.Category category; |
118 |
private ProjectCustomizer.Category category; |
115 |
|
119 |
|
116 |
public RunJarPanel(ModelHandle2 handle, NbMavenProjectImpl project, ProjectCustomizer.Category category) { |
120 |
public RunJarPanel(ModelHandle2 handle, NbMavenProjectImpl project, ProjectCustomizer.Category category) { |
Lines 135-141
Link Here
|
135 |
|
139 |
|
136 |
initValues(); |
140 |
initValues(); |
137 |
lblMainClass.setFont(lblMainClass.getFont().deriveFont(Font.BOLD)); |
141 |
lblMainClass.setFont(lblMainClass.getFont().deriveFont(Font.BOLD)); |
138 |
List<FileObject> roots = new ArrayList<FileObject>(); |
142 |
List<FileObject> roots = new ArrayList<>(); |
139 |
Sources srcs = ProjectUtils.getSources(project); |
143 |
Sources srcs = ProjectUtils.getSources(project); |
140 |
SourceGroup[] grps = srcs.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA); |
144 |
SourceGroup[] grps = srcs.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA); |
141 |
for (int i = 0; i < grps.length; i++) { |
145 |
for (int i = 0; i < grps.length; i++) { |
Lines 319-328
Link Here
|
319 |
txtWorkDir = new javax.swing.JTextField(); |
323 |
txtWorkDir = new javax.swing.JTextField(); |
320 |
btnWorkDir = new javax.swing.JButton(); |
324 |
btnWorkDir = new javax.swing.JButton(); |
321 |
lblVMOptions = new javax.swing.JLabel(); |
325 |
lblVMOptions = new javax.swing.JLabel(); |
322 |
txtVMOptions = new javax.swing.JTextField(); |
|
|
323 |
lblHint = new javax.swing.JLabel(); |
326 |
lblHint = new javax.swing.JLabel(); |
324 |
lblConfiguration = new javax.swing.JLabel(); |
327 |
lblConfiguration = new javax.swing.JLabel(); |
325 |
comConfiguration = new javax.swing.JComboBox(); |
328 |
comConfiguration = new javax.swing.JComboBox(); |
|
|
329 |
jScrollPane1 = new javax.swing.JScrollPane(); |
330 |
txtVMOptions = new javax.swing.JTextArea(); |
331 |
customizeOptionsButton = new javax.swing.JButton(); |
326 |
|
332 |
|
327 |
lblMainClass.setLabelFor(txtMainClass); |
333 |
lblMainClass.setLabelFor(txtMainClass); |
328 |
org.openide.awt.Mnemonics.setLocalizedText(lblMainClass, org.openide.util.NbBundle.getMessage(RunJarPanel.class, "LBL_MainClass")); // NOI18N |
334 |
org.openide.awt.Mnemonics.setLocalizedText(lblMainClass, org.openide.util.NbBundle.getMessage(RunJarPanel.class, "LBL_MainClass")); // NOI18N |
Lines 352-362
Link Here
|
352 |
|
358 |
|
353 |
comConfiguration.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" })); |
359 |
comConfiguration.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" })); |
354 |
|
360 |
|
|
|
361 |
txtVMOptions.setColumns(20); |
362 |
txtVMOptions.setLineWrap(true); |
363 |
txtVMOptions.setRows(5); |
364 |
jScrollPane1.setViewportView(txtVMOptions); |
365 |
txtVMOptions.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(RunJarPanel.class, "RunJarPanel.txtVMOptions.AccessibleContext.accessibleDescription")); // NOI18N |
366 |
|
367 |
org.openide.awt.Mnemonics.setLocalizedText(customizeOptionsButton, org.openide.util.NbBundle.getMessage(RunJarPanel.class, "RunJarPanel.customizeOptionsButton.text")); // NOI18N |
368 |
customizeOptionsButton.addActionListener(new java.awt.event.ActionListener() { |
369 |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
370 |
customizeOptionsButtonActionPerformed(evt); |
371 |
} |
372 |
}); |
373 |
|
355 |
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); |
374 |
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); |
356 |
this.setLayout(layout); |
375 |
this.setLayout(layout); |
357 |
layout.setHorizontalGroup( |
376 |
layout.setHorizontalGroup( |
358 |
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) |
377 |
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) |
359 |
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() |
378 |
.addGroup(layout.createSequentialGroup() |
360 |
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) |
379 |
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) |
361 |
.addComponent(lblWorkDir) |
380 |
.addComponent(lblWorkDir) |
362 |
.addComponent(lblVMOptions) |
381 |
.addComponent(lblVMOptions) |
Lines 365-383
Link Here
|
365 |
.addComponent(lblMainClass)) |
384 |
.addComponent(lblMainClass)) |
366 |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) |
385 |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) |
367 |
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) |
386 |
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) |
368 |
.addComponent(txtVMOptions, javax.swing.GroupLayout.DEFAULT_SIZE, 225, Short.MAX_VALUE) |
|
|
369 |
.addComponent(txtWorkDir, javax.swing.GroupLayout.DEFAULT_SIZE, 225, Short.MAX_VALUE) |
370 |
.addComponent(txtArguments, javax.swing.GroupLayout.DEFAULT_SIZE, 225, Short.MAX_VALUE) |
371 |
.addComponent(txtMainClass, javax.swing.GroupLayout.DEFAULT_SIZE, 225, Short.MAX_VALUE) |
372 |
.addComponent(comConfiguration, 0, 225, Short.MAX_VALUE)) |
373 |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) |
374 |
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) |
375 |
.addComponent(btnWorkDir) |
376 |
.addComponent(btnMainClass))) |
377 |
.addGroup(layout.createSequentialGroup() |
387 |
.addGroup(layout.createSequentialGroup() |
378 |
.addGap(128, 128, 128) |
|
|
379 |
.addComponent(lblHint) |
388 |
.addComponent(lblHint) |
380 |
.addContainerGap(246, Short.MAX_VALUE)) |
389 |
.addGap(0, 0, Short.MAX_VALUE)) |
|
|
390 |
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() |
391 |
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) |
392 |
.addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING) |
393 |
.addComponent(txtWorkDir, javax.swing.GroupLayout.Alignment.LEADING) |
394 |
.addComponent(txtArguments, javax.swing.GroupLayout.Alignment.LEADING) |
395 |
.addComponent(txtMainClass, javax.swing.GroupLayout.Alignment.LEADING) |
396 |
.addComponent(comConfiguration, javax.swing.GroupLayout.Alignment.LEADING, 0, 230, Short.MAX_VALUE)) |
397 |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) |
398 |
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) |
399 |
.addComponent(btnWorkDir, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) |
400 |
.addComponent(btnMainClass, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) |
401 |
.addComponent(customizeOptionsButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))) |
381 |
); |
402 |
); |
382 |
layout.setVerticalGroup( |
403 |
layout.setVerticalGroup( |
383 |
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) |
404 |
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) |
Lines 400-411
Link Here
|
400 |
.addComponent(txtWorkDir, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) |
421 |
.addComponent(txtWorkDir, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) |
401 |
.addComponent(btnWorkDir)) |
422 |
.addComponent(btnWorkDir)) |
402 |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) |
423 |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) |
403 |
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) |
424 |
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) |
404 |
.addComponent(lblVMOptions) |
425 |
.addComponent(lblVMOptions) |
405 |
.addComponent(txtVMOptions, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) |
426 |
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE) |
|
|
427 |
.addComponent(customizeOptionsButton)) |
406 |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) |
428 |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) |
407 |
.addComponent(lblHint) |
429 |
.addComponent(lblHint) |
408 |
.addContainerGap(139, Short.MAX_VALUE)) |
430 |
.addContainerGap(91, Short.MAX_VALUE)) |
409 |
); |
431 |
); |
410 |
|
432 |
|
411 |
txtMainClass.getAccessibleContext().setAccessibleDescription("Main class"); |
433 |
txtMainClass.getAccessibleContext().setAccessibleDescription("Main class"); |
Lines 413-419
Link Here
|
413 |
txtArguments.getAccessibleContext().setAccessibleDescription("Arguments"); |
435 |
txtArguments.getAccessibleContext().setAccessibleDescription("Arguments"); |
414 |
txtWorkDir.getAccessibleContext().setAccessibleDescription("Working directory"); |
436 |
txtWorkDir.getAccessibleContext().setAccessibleDescription("Working directory"); |
415 |
btnWorkDir.getAccessibleContext().setAccessibleDescription("Browse working directory"); |
437 |
btnWorkDir.getAccessibleContext().setAccessibleDescription("Browse working directory"); |
416 |
txtVMOptions.getAccessibleContext().setAccessibleDescription("VM options"); |
|
|
417 |
comConfiguration.getAccessibleContext().setAccessibleDescription("Configuration"); |
438 |
comConfiguration.getAccessibleContext().setAccessibleDescription("Configuration"); |
418 |
}// </editor-fold>//GEN-END:initComponents |
439 |
}// </editor-fold>//GEN-END:initComponents |
419 |
|
440 |
|
Lines 435-440
Link Here
|
435 |
} |
456 |
} |
436 |
}//GEN-LAST:event_btnWorkDirActionPerformed |
457 |
}//GEN-LAST:event_btnWorkDirActionPerformed |
437 |
|
458 |
|
|
|
459 |
private void customizeOptionsButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_customizeOptionsButtonActionPerformed |
460 |
String origin = txtVMOptions.getText(); |
461 |
try { |
462 |
String result = OptionsDialog.showCustomizer(SwingUtilities.getWindowAncestor(this), origin); |
463 |
txtVMOptions.setText(result); |
464 |
} catch (Exception e) { |
465 |
log.log(Level.WARNING, "Cannot parse vm options.", e); // NOI18N |
466 |
} |
467 |
}//GEN-LAST:event_customizeOptionsButtonActionPerformed |
468 |
|
438 |
void applyChanges() { |
469 |
void applyChanges() { |
439 |
String newMainClass = txtMainClass.getText().trim(); |
470 |
String newMainClass = txtMainClass.getText().trim(); |
440 |
String newParams = txtArguments.getText().trim(); |
471 |
String newParams = txtArguments.getText().trim(); |
Lines 446-454
Link Here
|
446 |
if (newMainClass.trim().length() > 0) { |
477 |
if (newMainClass.trim().length() > 0) { |
447 |
newAllParams = newAllParams + newMainClass + " "; //NOI18N |
478 |
newAllParams = newAllParams + newMainClass + " "; //NOI18N |
448 |
} else { |
479 |
} else { |
449 |
newAllParams = newAllParams + "${packageClassName} "; //NOI18N |
480 |
newAllParams += "${packageClassName} "; //NOI18N |
450 |
} |
481 |
} |
451 |
newAllParams = newAllParams + newParams; |
482 |
newAllParams += newParams; |
452 |
newAllParams = newAllParams.trim(); |
483 |
newAllParams = newAllParams.trim(); |
453 |
if (isCurrentRun) { |
484 |
if (isCurrentRun) { |
454 |
boolean changed = false; |
485 |
boolean changed = false; |
Lines 506-512
Link Here
|
506 |
while (it.hasNext()) { |
537 |
while (it.hasNext()) { |
507 |
String goal = (String) it.next(); |
538 |
String goal = (String) it.next(); |
508 |
if (goal.matches("org\\.codehaus\\.mojo\\:exec-maven-plugin\\:(.)+\\:exec") //NOI18N |
539 |
if (goal.matches("org\\.codehaus\\.mojo\\:exec-maven-plugin\\:(.)+\\:exec") //NOI18N |
509 |
|| goal.indexOf("exec:exec") > -1) { //NOI18N |
540 |
|| goal.contains("exec:exec")) { //NOI18N |
510 |
if (map.getProperties() != null && map.getProperties().containsKey("exec.args")) { |
541 |
if (map.getProperties() != null && map.getProperties().containsKey("exec.args")) { |
511 |
String execArgs = map.getProperties().get("exec.args"); |
542 |
String execArgs = map.getProperties().get("exec.args"); |
512 |
if (execArgs.contains("-classpath")) { |
543 |
if (execArgs.contains("-classpath")) { |
Lines 567-573
Link Here
|
567 |
} else if (s.equals("${packageClassName}") || s.matches("[\\w]+[\\.]{0,1}[\\w\\.]*")) { //NOI18N |
598 |
} else if (s.equals("${packageClassName}") || s.matches("[\\w]+[\\.]{0,1}[\\w\\.]*")) { //NOI18N |
568 |
return s; |
599 |
return s; |
569 |
} else { |
600 |
} else { |
570 |
Logger.getLogger(RunJarPanel.class.getName()).fine("failed splitting main class from=" + line); //NOI18N |
601 |
log.log(Level.WARNING, "failed splitting main class from={0}", line); //NOI18N |
571 |
} |
602 |
} |
572 |
s = ps.nextPair(); |
603 |
s = ps.nextPair(); |
573 |
} |
604 |
} |
Lines 587-592
Link Here
|
587 |
private javax.swing.JButton btnMainClass; |
618 |
private javax.swing.JButton btnMainClass; |
588 |
private javax.swing.JButton btnWorkDir; |
619 |
private javax.swing.JButton btnWorkDir; |
589 |
private javax.swing.JComboBox comConfiguration; |
620 |
private javax.swing.JComboBox comConfiguration; |
|
|
621 |
private javax.swing.JButton customizeOptionsButton; |
622 |
private javax.swing.JScrollPane jScrollPane1; |
590 |
private javax.swing.JLabel lblArguments; |
623 |
private javax.swing.JLabel lblArguments; |
591 |
private javax.swing.JLabel lblConfiguration; |
624 |
private javax.swing.JLabel lblConfiguration; |
592 |
private javax.swing.JLabel lblHint; |
625 |
private javax.swing.JLabel lblHint; |
Lines 595-601
Link Here
|
595 |
private javax.swing.JLabel lblWorkDir; |
628 |
private javax.swing.JLabel lblWorkDir; |
596 |
private javax.swing.JTextField txtArguments; |
629 |
private javax.swing.JTextField txtArguments; |
597 |
private javax.swing.JTextField txtMainClass; |
630 |
private javax.swing.JTextField txtMainClass; |
598 |
private javax.swing.JTextField txtVMOptions; |
631 |
private javax.swing.JTextArea txtVMOptions; |
599 |
private javax.swing.JTextField txtWorkDir; |
632 |
private javax.swing.JTextField txtWorkDir; |
600 |
// End of variables declaration//GEN-END:variables |
633 |
// End of variables declaration//GEN-END:variables |
601 |
|
634 |
|
Lines 621-628
Link Here
|
621 |
private class MainClassListener implements ActionListener /*, DocumentListener */ { |
654 |
private class MainClassListener implements ActionListener /*, DocumentListener */ { |
622 |
|
655 |
|
623 |
private final JButton okButton; |
656 |
private final JButton okButton; |
624 |
private FileObject[] sourceRoots; |
657 |
private final FileObject[] sourceRoots; |
625 |
private JTextField mainClassTextField; |
658 |
private final JTextField mainClassTextField; |
626 |
|
659 |
|
627 |
MainClassListener( FileObject[] sourceRoots, JTextField mainClassTextField ) { |
660 |
MainClassListener( FileObject[] sourceRoots, JTextField mainClassTextField ) { |
628 |
this.sourceRoots = sourceRoots; |
661 |
this.sourceRoots = sourceRoots; |