Lines 47-52
Link Here
|
47 |
import java.awt.event.ActionListener; |
47 |
import java.awt.event.ActionListener; |
48 |
import java.io.File; |
48 |
import java.io.File; |
49 |
import java.io.StringReader; |
49 |
import java.io.StringReader; |
|
|
50 |
import java.util.ArrayList; |
50 |
import java.util.Arrays; |
51 |
import java.util.Arrays; |
51 |
import java.util.List; |
52 |
import java.util.List; |
52 |
import javax.swing.BorderFactory; |
53 |
import javax.swing.BorderFactory; |
Lines 55-63
Link Here
|
55 |
import javax.swing.DefaultListCellRenderer; |
56 |
import javax.swing.DefaultListCellRenderer; |
56 |
import javax.swing.JFileChooser; |
57 |
import javax.swing.JFileChooser; |
57 |
import javax.swing.JList; |
58 |
import javax.swing.JList; |
|
|
59 |
import javax.swing.JSeparator; |
58 |
import javax.swing.ListCellRenderer; |
60 |
import javax.swing.ListCellRenderer; |
59 |
import javax.swing.SwingUtilities; |
61 |
import javax.swing.SwingUtilities; |
60 |
import javax.swing.event.DocumentEvent; |
|
|
61 |
import javax.swing.event.DocumentListener; |
62 |
import javax.swing.event.DocumentListener; |
62 |
import org.netbeans.modules.maven.TextValueCompleter; |
63 |
import org.netbeans.modules.maven.TextValueCompleter; |
63 |
import org.netbeans.modules.maven.indexer.api.RepositoryIndexer; |
64 |
import org.netbeans.modules.maven.indexer.api.RepositoryIndexer; |
Lines 86-97
Link Here
|
86 |
*/ |
87 |
*/ |
87 |
public class SettingsPanel extends javax.swing.JPanel { |
88 |
public class SettingsPanel extends javax.swing.JPanel { |
88 |
private static final String CP_SELECTED = "wasSelected"; //NOI18N |
89 |
private static final String CP_SELECTED = "wasSelected"; //NOI18N |
|
|
90 |
private static final String SEPARATOR = "SEPARATOR"; |
91 |
private static final String BUNDLED_RUNTIME_VERSION = |
92 |
MavenSettings.getCommandLineMavenVersion(MavenSettings.getDefaultMavenHome()); |
93 |
private static final int RUNTIME_COUNT_LIMIT = 5; |
89 |
private boolean changed; |
94 |
private boolean changed; |
90 |
private boolean valid; |
95 |
private boolean valid; |
91 |
private ActionListener listener; |
96 |
private ActionListener listener; |
92 |
private DocumentListener docList; |
97 |
private DocumentListener docList; |
93 |
private MavenOptionController controller; |
98 |
private MavenOptionController controller; |
94 |
private TextValueCompleter completer; |
99 |
private TextValueCompleter completer; |
|
|
100 |
private ActionListener listItemChangedListener; |
101 |
private List<String> userDefinedMavenRuntimes = new ArrayList<String>(); |
102 |
private List<String> predefinedRuntimes = new ArrayList<String>(); |
103 |
private DefaultComboBoxModel mavenHomeDataModel = new DefaultComboBoxModel(); |
104 |
private String mavenRuntimeHome = null; |
105 |
private int lastSelected = -1; |
106 |
|
107 |
private static class ComboBoxRenderer extends DefaultListCellRenderer { |
108 |
|
109 |
private JSeparator separator; |
110 |
|
111 |
public ComboBoxRenderer() { |
112 |
super(); |
113 |
separator = new JSeparator(JSeparator.HORIZONTAL); |
114 |
} |
115 |
|
116 |
@Override |
117 |
public Component getListCellRendererComponent(JList list, Object value, |
118 |
int index, boolean isSelected, boolean cellHasFocus) { |
119 |
if (SEPARATOR.equals(value)) { |
120 |
return separator; |
121 |
} |
122 |
return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); |
123 |
} |
124 |
}; |
95 |
|
125 |
|
96 |
/** Creates new form SettingsPanel */ |
126 |
/** Creates new form SettingsPanel */ |
97 |
SettingsPanel(MavenOptionController controller) { |
127 |
SettingsPanel(MavenOptionController controller) { |
Lines 101-106
Link Here
|
101 |
comBinaries.setModel(new DefaultComboBoxModel(downloads)); |
131 |
comBinaries.setModel(new DefaultComboBoxModel(downloads)); |
102 |
comJavadoc.setModel(new DefaultComboBoxModel(downloads)); |
132 |
comJavadoc.setModel(new DefaultComboBoxModel(downloads)); |
103 |
comSource.setModel(new DefaultComboBoxModel(downloads)); |
133 |
comSource.setModel(new DefaultComboBoxModel(downloads)); |
|
|
134 |
comMavenHome.setModel(mavenHomeDataModel); |
104 |
|
135 |
|
105 |
ListCellRenderer rend = new DefaultListCellRenderer() { |
136 |
ListCellRenderer rend = new DefaultListCellRenderer() { |
106 |
@Override |
137 |
@Override |
Lines 119-135
Link Here
|
119 |
comBinaries.setRenderer(rend); |
150 |
comBinaries.setRenderer(rend); |
120 |
comSource.setRenderer(rend); |
151 |
comSource.setRenderer(rend); |
121 |
comJavadoc.setRenderer(rend); |
152 |
comJavadoc.setRenderer(rend); |
|
|
153 |
comMavenHome.setRenderer(new ComboBoxRenderer()); |
122 |
|
154 |
|
123 |
this.controller = controller; |
155 |
this.controller = controller; |
124 |
docList = new DocumentListener() { |
156 |
listItemChangedListener = new ActionListener() { |
125 |
public void insertUpdate(DocumentEvent e) { |
157 |
|
126 |
documentChanged(e); |
158 |
@Override |
127 |
} |
159 |
public void actionPerformed(ActionEvent e) { |
128 |
public void removeUpdate(DocumentEvent e) { |
160 |
if (SEPARATOR.equals(comMavenHome.getSelectedItem())) { |
129 |
documentChanged(e); |
161 |
comMavenHome.setSelectedIndex(lastSelected); |
130 |
} |
162 |
return; |
131 |
public void changedUpdate(DocumentEvent e) { |
163 |
} |
132 |
documentChanged(e); |
164 |
|
|
|
165 |
int selected = comMavenHome.getSelectedIndex(); |
166 |
if (selected == mavenHomeDataModel.getSize() - 1) { |
167 |
// browse |
168 |
comMavenHome.setSelectedIndex(lastSelected); |
169 |
SwingUtilities.invokeLater(new Runnable() { |
170 |
|
171 |
@Override |
172 |
public void run() { |
173 |
browseAddNewRuntime(); |
174 |
} |
175 |
|
176 |
}); |
177 |
return; |
178 |
} |
179 |
|
180 |
listDataChanged(); |
181 |
lastSelected = selected; |
133 |
} |
182 |
} |
134 |
}; |
183 |
}; |
135 |
initValues(); |
184 |
initValues(); |
Lines 179-221
Link Here
|
179 |
return Arrays.asList(AVAILABLE_OPTIONS); |
228 |
return Arrays.asList(AVAILABLE_OPTIONS); |
180 |
} |
229 |
} |
181 |
|
230 |
|
182 |
private void initExternalVersion() |
|
|
183 |
{ |
184 |
String path = txtCommandLine.getText().trim(); |
185 |
File root = new File(path); |
186 |
String version = MavenSettings.getCommandLineMavenVersion(root); |
187 |
if (version != null) { |
188 |
lblExternalVersion.setText(NbBundle.getMessage(SettingsPanel.class, "LBL_ExMavenVersion2", version)); |
189 |
} else { |
190 |
//add red color.. |
191 |
lblExternalVersion.setText(NbBundle.getMessage(SettingsPanel.class, "ERR_NoValidInstallation")); |
192 |
} |
193 |
} |
194 |
|
195 |
private void initValues() { |
231 |
private void initValues() { |
196 |
comIndex.setSelectedIndex(0); |
232 |
comIndex.setSelectedIndex(0); |
197 |
cbSnapshots.setSelected(true); |
233 |
cbSnapshots.setSelected(true); |
198 |
} |
234 |
} |
199 |
|
235 |
|
200 |
private void documentChanged(DocumentEvent e) { |
236 |
private String getSelectedRuntime(int selected) { |
|
|
237 |
if (selected < 0) { |
238 |
return null; |
239 |
} |
240 |
|
241 |
if (selected < predefinedRuntimes.size()) { |
242 |
return predefinedRuntimes.get(selected); |
243 |
|
244 |
} else if (!userDefinedMavenRuntimes.isEmpty() && |
245 |
selected - predefinedRuntimes.size() <= userDefinedMavenRuntimes.size()) { |
246 |
return userDefinedMavenRuntimes.get(selected - 1 - predefinedRuntimes.size()); |
247 |
} |
248 |
|
249 |
return null; |
250 |
} |
251 |
|
252 |
private void listDataChanged() { |
201 |
changed = true; |
253 |
changed = true; |
202 |
boolean oldvalid = valid; |
254 |
boolean oldvalid = valid; |
203 |
if (txtCommandLine.getText().trim().length() > 0) { |
255 |
int selected = comMavenHome.getSelectedIndex(); |
204 |
File fil = new File(txtCommandLine.getText()); |
256 |
String path = getSelectedRuntime(selected); |
|
|
257 |
if (path != null) { |
258 |
path = path.trim(); |
259 |
if ("".equals(path)) { |
260 |
path = null; |
261 |
valid = true; |
262 |
lblExternalVersion.setText(NbBundle.getMessage(SettingsPanel.class, "LBL_ExMavenVersion2", BUNDLED_RUNTIME_VERSION)); |
263 |
} |
264 |
} |
265 |
|
266 |
if (path != null) { |
267 |
path = path.trim(); |
268 |
File fil = new File(path); |
269 |
String ver = null; |
205 |
if (fil.exists() && new File(fil, "bin" + File.separator + "mvn").exists()) { //NOI18N |
270 |
if (fil.exists() && new File(fil, "bin" + File.separator + "mvn").exists()) { //NOI18N |
|
|
271 |
ver = MavenSettings.getCommandLineMavenVersion(new File(path)); |
272 |
} |
273 |
|
274 |
if (ver != null) { |
275 |
lblExternalVersion.setText(NbBundle.getMessage(SettingsPanel.class, "LBL_ExMavenVersion2", ver)); |
206 |
valid = true; |
276 |
valid = true; |
|
|
277 |
|
207 |
} else { |
278 |
} else { |
208 |
valid = false; |
279 |
lblExternalVersion.setText(NbBundle.getMessage(SettingsPanel.class, "ERR_NoValidInstallation")); |
209 |
} |
280 |
} |
210 |
} else { |
|
|
211 |
valid = true; |
212 |
} |
281 |
} |
|
|
282 |
|
283 |
mavenRuntimeHome = path; |
213 |
if (oldvalid != valid) { |
284 |
if (oldvalid != valid) { |
214 |
controller.firePropChange(MavenOptionController.PROP_VALID, Boolean.valueOf(oldvalid), Boolean.valueOf(valid)); |
285 |
controller.firePropChange(MavenOptionController.PROP_VALID, Boolean.valueOf(oldvalid), Boolean.valueOf(valid)); |
215 |
} |
286 |
} |
216 |
initExternalVersion(); |
|
|
217 |
} |
287 |
} |
218 |
|
288 |
|
219 |
private ComboBoxModel createComboModel() { |
289 |
private ComboBoxModel createComboModel() { |
220 |
return new DefaultComboBoxModel( |
290 |
return new DefaultComboBoxModel( |
221 |
new String[] { |
291 |
new String[] { |
Lines 238-246
Link Here
|
238 |
bgPlugins = new javax.swing.ButtonGroup(); |
308 |
bgPlugins = new javax.swing.ButtonGroup(); |
239 |
bgFailure = new javax.swing.ButtonGroup(); |
309 |
bgFailure = new javax.swing.ButtonGroup(); |
240 |
lblCommandLine = new javax.swing.JLabel(); |
310 |
lblCommandLine = new javax.swing.JLabel(); |
241 |
txtCommandLine = new javax.swing.JTextField(); |
|
|
242 |
btnCommandLine = new javax.swing.JButton(); |
243 |
btnDefault = new javax.swing.JButton(); |
244 |
lblExternalVersion = new javax.swing.JLabel(); |
311 |
lblExternalVersion = new javax.swing.JLabel(); |
245 |
lblOptions = new javax.swing.JLabel(); |
312 |
lblOptions = new javax.swing.JLabel(); |
246 |
txtOptions = new javax.swing.JTextField(); |
313 |
txtOptions = new javax.swing.JTextField(); |
Lines 262-284
Link Here
|
262 |
comIndex = new javax.swing.JComboBox(); |
329 |
comIndex = new javax.swing.JComboBox(); |
263 |
btnIndex = new javax.swing.JButton(); |
330 |
btnIndex = new javax.swing.JButton(); |
264 |
cbSnapshots = new javax.swing.JCheckBox(); |
331 |
cbSnapshots = new javax.swing.JCheckBox(); |
|
|
332 |
comMavenHome = new javax.swing.JComboBox(); |
265 |
|
333 |
|
266 |
org.openide.awt.Mnemonics.setLocalizedText(lblCommandLine, org.openide.util.NbBundle.getMessage(SettingsPanel.class, "SettingsPanel.lblCommandLine.text")); // NOI18N |
334 |
org.openide.awt.Mnemonics.setLocalizedText(lblCommandLine, org.openide.util.NbBundle.getMessage(SettingsPanel.class, "SettingsPanel.lblCommandLine.text")); // NOI18N |
267 |
|
335 |
|
268 |
org.openide.awt.Mnemonics.setLocalizedText(btnCommandLine, org.openide.util.NbBundle.getMessage(SettingsPanel.class, "SettingsPanel.btnCommandLine.text")); // NOI18N |
|
|
269 |
btnCommandLine.addActionListener(new java.awt.event.ActionListener() { |
270 |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
271 |
btnCommandLineActionPerformed(evt); |
272 |
} |
273 |
}); |
274 |
|
275 |
org.openide.awt.Mnemonics.setLocalizedText(btnDefault, NbBundle.getMessage(SettingsPanel.class, "SettingsPanel.btnDefault.text")); // NOI18N |
276 |
btnDefault.addActionListener(new java.awt.event.ActionListener() { |
277 |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
278 |
btnDefaultActionPerformed(evt); |
279 |
} |
280 |
}); |
281 |
|
282 |
org.openide.awt.Mnemonics.setLocalizedText(lblOptions, org.openide.util.NbBundle.getMessage(SettingsPanel.class, "SettingsPanel.lblOptions.text")); // NOI18N |
336 |
org.openide.awt.Mnemonics.setLocalizedText(lblOptions, org.openide.util.NbBundle.getMessage(SettingsPanel.class, "SettingsPanel.lblOptions.text")); // NOI18N |
283 |
|
337 |
|
284 |
org.openide.awt.Mnemonics.setLocalizedText(btnOptions, org.openide.util.NbBundle.getMessage(SettingsPanel.class, "SettingsPanel.btnOptions.text")); // NOI18N |
338 |
org.openide.awt.Mnemonics.setLocalizedText(btnOptions, org.openide.util.NbBundle.getMessage(SettingsPanel.class, "SettingsPanel.btnOptions.text")); // NOI18N |
Lines 347-371
Link Here
|
347 |
.add(lblLocalRepository)) |
401 |
.add(lblLocalRepository)) |
348 |
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) |
402 |
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) |
349 |
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) |
403 |
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) |
350 |
.add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup() |
404 |
.add(lblExternalVersion, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 524, Short.MAX_VALUE) |
351 |
.add(txtCommandLine, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 295, Short.MAX_VALUE) |
|
|
352 |
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) |
353 |
.add(btnCommandLine) |
354 |
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) |
355 |
.add(btnDefault)) |
356 |
.add(lblExternalVersion, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 500, Short.MAX_VALUE) |
357 |
.add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup() |
405 |
.add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup() |
358 |
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) |
406 |
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) |
359 |
.add(comSource, 0, 387, Short.MAX_VALUE) |
407 |
.add(comSource, 0, 404, Short.MAX_VALUE) |
360 |
.add(comJavadoc, 0, 387, Short.MAX_VALUE) |
408 |
.add(comJavadoc, 0, 404, Short.MAX_VALUE) |
361 |
.add(comBinaries, 0, 387, Short.MAX_VALUE) |
409 |
.add(comBinaries, 0, 404, Short.MAX_VALUE) |
362 |
.add(txtLocalRepository, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 387, Short.MAX_VALUE) |
410 |
.add(txtLocalRepository, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 404, Short.MAX_VALUE) |
363 |
.add(txtOptions, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 387, Short.MAX_VALUE)) |
411 |
.add(txtOptions, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 404, Short.MAX_VALUE)) |
364 |
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) |
412 |
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) |
365 |
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) |
413 |
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) |
366 |
.add(btnLocalRepository) |
414 |
.add(btnLocalRepository) |
367 |
.add(btnOptions))) |
415 |
.add(btnOptions))) |
368 |
.add(cbSkipTests))) |
416 |
.add(cbSkipTests) |
|
|
417 |
.add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup() |
418 |
.add(comMavenHome, 0, 402, Short.MAX_VALUE) |
419 |
.add(122, 122, 122)))) |
369 |
.add(jLabel1) |
420 |
.add(jLabel1) |
370 |
.add(layout.createSequentialGroup() |
421 |
.add(layout.createSequentialGroup() |
371 |
.add(12, 12, 12) |
422 |
.add(12, 12, 12) |
Lines 381-393
Link Here
|
381 |
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) |
432 |
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) |
382 |
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) |
433 |
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) |
383 |
.add(cbSnapshots) |
434 |
.add(cbSnapshots) |
384 |
.add(comIndex, 0, 396, Short.MAX_VALUE)) |
435 |
.add(comIndex, 0, 421, Short.MAX_VALUE)) |
385 |
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) |
436 |
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) |
386 |
.add(btnIndex))) |
437 |
.add(btnIndex))) |
387 |
.addContainerGap()) |
438 |
.addContainerGap()) |
388 |
); |
439 |
); |
389 |
|
440 |
|
390 |
layout.linkSize(new java.awt.Component[] {btnCommandLine, btnIndex, btnLocalRepository, btnOptions}, org.jdesktop.layout.GroupLayout.HORIZONTAL); |
441 |
layout.linkSize(new java.awt.Component[] {btnIndex, btnLocalRepository, btnOptions}, org.jdesktop.layout.GroupLayout.HORIZONTAL); |
391 |
|
442 |
|
392 |
layout.setVerticalGroup( |
443 |
layout.setVerticalGroup( |
393 |
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) |
444 |
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) |
Lines 395-403
Link Here
|
395 |
.add(6, 6, 6) |
446 |
.add(6, 6, 6) |
396 |
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) |
447 |
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) |
397 |
.add(lblCommandLine) |
448 |
.add(lblCommandLine) |
398 |
.add(txtCommandLine, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) |
449 |
.add(comMavenHome, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) |
399 |
.add(btnDefault) |
|
|
400 |
.add(btnCommandLine)) |
401 |
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) |
450 |
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) |
402 |
.add(lblExternalVersion, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 14, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) |
451 |
.add(lblExternalVersion, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 14, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) |
403 |
.add(18, 18, 18) |
452 |
.add(18, 18, 18) |
Lines 437-443
Link Here
|
437 |
.add(comIndex, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) |
486 |
.add(comIndex, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) |
438 |
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) |
487 |
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) |
439 |
.add(cbSnapshots) |
488 |
.add(cbSnapshots) |
440 |
.addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) |
489 |
.addContainerGap(23, Short.MAX_VALUE)) |
441 |
); |
490 |
); |
442 |
}// </editor-fold>//GEN-END:initComponents |
491 |
}// </editor-fold>//GEN-END:initComponents |
443 |
|
492 |
|
Lines 481-509
Link Here
|
481 |
} |
530 |
} |
482 |
}//GEN-LAST:event_btnLocalRepositoryActionPerformed |
531 |
}//GEN-LAST:event_btnLocalRepositoryActionPerformed |
483 |
|
532 |
|
484 |
private void btnCommandLineActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCommandLineActionPerformed |
|
|
485 |
JFileChooser chooser = new JFileChooser(); |
486 |
FileUtil.preventFileChooserSymlinkTraversal(chooser, null); |
487 |
chooser.setDialogTitle(org.openide.util.NbBundle.getMessage(SettingsPanel.class, "TIT_Select2")); |
488 |
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); |
489 |
chooser.setFileHidingEnabled(false); |
490 |
String path = txtCommandLine.getText(); |
491 |
if (path.trim().length() == 0) { |
492 |
path = new File(System.getProperty("user.home")).getAbsolutePath(); //NOI18N |
493 |
} |
494 |
if (path.length() > 0) { |
495 |
File f = new File(path); |
496 |
if (f.exists()) { |
497 |
chooser.setSelectedFile(f); |
498 |
} |
499 |
} |
500 |
if (JFileChooser.APPROVE_OPTION == chooser.showOpenDialog(this)) { |
501 |
File projectDir = chooser.getSelectedFile(); |
502 |
txtCommandLine.setText(FileUtil.normalizeFile(projectDir).getAbsolutePath()); |
503 |
} |
504 |
|
505 |
}//GEN-LAST:event_btnCommandLineActionPerformed |
506 |
|
507 |
private void btnGoalsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGoalsActionPerformed |
533 |
private void btnGoalsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGoalsActionPerformed |
508 |
NbGlobalActionGoalProvider provider = null; |
534 |
NbGlobalActionGoalProvider provider = null; |
509 |
for (MavenActionsProvider prov : Lookup.getDefault().lookupAll(MavenActionsProvider.class)) { |
535 |
for (MavenActionsProvider prov : Lookup.getDefault().lookupAll(MavenActionsProvider.class)) { |
Lines 538-555
Link Here
|
538 |
} |
564 |
} |
539 |
|
565 |
|
540 |
}//GEN-LAST:event_btnOptionsActionPerformed |
566 |
}//GEN-LAST:event_btnOptionsActionPerformed |
541 |
|
|
|
542 |
private void btnDefaultActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDefaultActionPerformed |
543 |
txtCommandLine.setText(MavenSettings.getDefaultMavenHome().getAbsolutePath()); |
544 |
}//GEN-LAST:event_btnDefaultActionPerformed |
545 |
|
567 |
|
546 |
|
568 |
|
547 |
// Variables declaration - do not modify//GEN-BEGIN:variables |
569 |
// Variables declaration - do not modify//GEN-BEGIN:variables |
548 |
private javax.swing.ButtonGroup bgChecksums; |
570 |
private javax.swing.ButtonGroup bgChecksums; |
549 |
private javax.swing.ButtonGroup bgFailure; |
571 |
private javax.swing.ButtonGroup bgFailure; |
550 |
private javax.swing.ButtonGroup bgPlugins; |
572 |
private javax.swing.ButtonGroup bgPlugins; |
551 |
private javax.swing.JButton btnCommandLine; |
|
|
552 |
private javax.swing.JButton btnDefault; |
553 |
private javax.swing.JButton btnGoals; |
573 |
private javax.swing.JButton btnGoals; |
554 |
private javax.swing.JButton btnIndex; |
574 |
private javax.swing.JButton btnIndex; |
555 |
private javax.swing.JButton btnLocalRepository; |
575 |
private javax.swing.JButton btnLocalRepository; |
Lines 559-564
Link Here
|
559 |
private javax.swing.JComboBox comBinaries; |
579 |
private javax.swing.JComboBox comBinaries; |
560 |
private javax.swing.JComboBox comIndex; |
580 |
private javax.swing.JComboBox comIndex; |
561 |
private javax.swing.JComboBox comJavadoc; |
581 |
private javax.swing.JComboBox comJavadoc; |
|
|
582 |
private javax.swing.JComboBox comMavenHome; |
562 |
private javax.swing.JComboBox comSource; |
583 |
private javax.swing.JComboBox comSource; |
563 |
private javax.swing.JLabel jLabel1; |
584 |
private javax.swing.JLabel jLabel1; |
564 |
private javax.swing.JLabel jLabel3; |
585 |
private javax.swing.JLabel jLabel3; |
Lines 570-587
Link Here
|
570 |
private javax.swing.JLabel lblLocalRepository; |
591 |
private javax.swing.JLabel lblLocalRepository; |
571 |
private javax.swing.JLabel lblOptions; |
592 |
private javax.swing.JLabel lblOptions; |
572 |
private javax.swing.JLabel lblSource; |
593 |
private javax.swing.JLabel lblSource; |
573 |
private javax.swing.JTextField txtCommandLine; |
|
|
574 |
private javax.swing.JTextField txtLocalRepository; |
594 |
private javax.swing.JTextField txtLocalRepository; |
575 |
private javax.swing.JTextField txtOptions; |
595 |
private javax.swing.JTextField txtOptions; |
576 |
// End of variables declaration//GEN-END:variables |
596 |
// End of variables declaration//GEN-END:variables |
577 |
|
597 |
|
|
|
598 |
private void browseAddNewRuntime() { |
599 |
JFileChooser chooser = new JFileChooser(); |
600 |
FileUtil.preventFileChooserSymlinkTraversal(chooser, null); |
601 |
chooser.setDialogTitle(org.openide.util.NbBundle.getMessage(SettingsPanel.class, "TIT_Select2")); |
602 |
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); |
603 |
chooser.setFileHidingEnabled(false); |
604 |
int selected = comMavenHome.getSelectedIndex(); |
605 |
String path = getSelectedRuntime(selected); |
606 |
if (path == null || path.trim().length() == 0) { |
607 |
path = new File(System.getProperty("user.home")).getAbsolutePath(); //NOI18N |
608 |
} |
609 |
if (path.length() > 0) { |
610 |
File f = new File(path); |
611 |
if (f.exists()) { |
612 |
chooser.setSelectedFile(f); |
613 |
} |
614 |
} |
615 |
if (JFileChooser.APPROVE_OPTION == chooser.showOpenDialog(this)) { |
616 |
File projectDir = chooser.getSelectedFile(); |
617 |
String newRuntimePath = FileUtil.normalizeFile(projectDir).getAbsolutePath(); |
618 |
boolean existed = false; |
619 |
List<String> runtimes = new ArrayList<String>(); |
620 |
runtimes.addAll(predefinedRuntimes); |
621 |
runtimes.addAll(userDefinedMavenRuntimes); |
622 |
for (String runtime : runtimes) { |
623 |
if (runtime.equals(newRuntimePath)) { |
624 |
existed = true; |
625 |
} |
626 |
} |
627 |
if (!existed) { |
628 |
// do not add duplicated directory |
629 |
if (userDefinedMavenRuntimes.isEmpty()) { |
630 |
mavenHomeDataModel.insertElementAt(SEPARATOR, predefinedRuntimes.size()); |
631 |
} |
632 |
userDefinedMavenRuntimes.add(newRuntimePath); |
633 |
mavenHomeDataModel.insertElementAt(newRuntimePath, runtimes.size() + 1); |
634 |
} |
635 |
comMavenHome.setSelectedItem(newRuntimePath); |
636 |
} |
637 |
} |
638 |
|
578 |
public void setValues() { |
639 |
public void setValues() { |
579 |
txtOptions.setText(MavenSettings.getDefault().getDefaultOptions()); |
640 |
txtOptions.setText(MavenSettings.getDefault().getDefaultOptions()); |
580 |
txtCommandLine.getDocument().removeDocumentListener(docList); |
641 |
|
|
|
642 |
predefinedRuntimes.clear(); |
643 |
predefinedRuntimes.add(""); |
644 |
predefinedRuntimes.add(MavenSettings.getDefaultExternalMavenRuntime()); |
645 |
userDefinedMavenRuntimes.clear(); |
646 |
userDefinedMavenRuntimes.addAll(MavenSettings.getDefault().getUserDefinedMavenRuntimes()); |
647 |
comMavenHome.removeActionListener(listItemChangedListener); |
648 |
mavenHomeDataModel.removeAllElements(); |
581 |
File command = MavenSettings.getDefault().getMavenHome(); |
649 |
File command = MavenSettings.getDefault().getMavenHome(); |
582 |
txtCommandLine.setText(command != null ? command.getAbsolutePath() : ""); //NOI18N |
650 |
String bundled = null; |
583 |
initExternalVersion(); |
651 |
for (String runtime : predefinedRuntimes) { |
584 |
txtCommandLine.getDocument().addDocumentListener(docList); |
652 |
boolean bundledRuntime = "".equals(runtime); |
|
|
653 |
String desc = org.openide.util.NbBundle.getMessage(SettingsPanel.class, |
654 |
bundledRuntime ? "MAVEN_RUNTIME_Bundled" : "MAVEN_RUNTIME_External", |
655 |
new Object[]{runtime, |
656 |
bundledRuntime ? BUNDLED_RUNTIME_VERSION : MavenSettings.getCommandLineMavenVersion(new File(runtime))}); // NOI18N |
657 |
mavenHomeDataModel.addElement(desc); |
658 |
} |
659 |
|
660 |
if (!userDefinedMavenRuntimes.isEmpty()) { |
661 |
mavenHomeDataModel.addElement(SEPARATOR); |
662 |
for (String runtime : userDefinedMavenRuntimes) { |
663 |
String desc = org.openide.util.NbBundle.getMessage(SettingsPanel.class, |
664 |
"MAVEN_RUNTIME_External", |
665 |
new Object[]{runtime, MavenSettings.getCommandLineMavenVersion(new File(runtime))}); // NOI18N |
666 |
mavenHomeDataModel.addElement(desc); |
667 |
} |
668 |
} |
669 |
|
670 |
mavenHomeDataModel.addElement(SEPARATOR); |
671 |
mavenHomeDataModel.addElement(org.openide.util.NbBundle.getMessage(SettingsPanel.class, |
672 |
"MAVEN_RUNTIME_Browse")); |
673 |
comMavenHome.setSelectedItem(command != null ? command.getAbsolutePath() : bundled); //NOI18N |
674 |
listDataChanged(); |
675 |
lastSelected = comMavenHome.getSelectedIndex(); |
676 |
comMavenHome.addActionListener(listItemChangedListener); |
585 |
|
677 |
|
586 |
cbSnapshots.setSelected(RepositoryPreferences.getInstance().isIncludeSnapshots()); |
678 |
cbSnapshots.setSelected(RepositoryPreferences.getInstance().isIncludeSnapshots()); |
587 |
comIndex.setSelectedIndex(RepositoryPreferences.getInstance().getIndexUpdateFrequency()); |
679 |
comIndex.setSelectedIndex(RepositoryPreferences.getInstance().getIndexUpdateFrequency()); |
Lines 598-606
Link Here
|
598 |
public void applyValues() { |
690 |
public void applyValues() { |
599 |
MavenSettings.getDefault().setDefaultOptions(txtOptions.getText().trim()); |
691 |
MavenSettings.getDefault().setDefaultOptions(txtOptions.getText().trim()); |
600 |
MavenSettings.getDefault().setCustomLocalRepository(((MyJTextField)txtLocalRepository).getRealText()); |
692 |
MavenSettings.getDefault().setCustomLocalRepository(((MyJTextField)txtLocalRepository).getRealText()); |
601 |
String cl = txtCommandLine.getText().trim(); |
693 |
|
|
|
694 |
// remember only user-defined runtimes of RUNTIME_COUNT_LIMIT count at the most |
695 |
List<String> runtimes = new ArrayList<String>(); |
696 |
for (int i = 0; i < userDefinedMavenRuntimes.size() && i < RUNTIME_COUNT_LIMIT; ++i) { |
697 |
runtimes.add(0, userDefinedMavenRuntimes.get(userDefinedMavenRuntimes.size() - 1 - i)); |
698 |
} |
699 |
int selected = comMavenHome.getSelectedIndex() - predefinedRuntimes.size() - 1; |
700 |
if (selected >= 0 && runtimes.size() == RUNTIME_COUNT_LIMIT && |
701 |
userDefinedMavenRuntimes.size() - RUNTIME_COUNT_LIMIT > selected) { |
702 |
runtimes.set(0, userDefinedMavenRuntimes.get(selected)); |
703 |
} |
704 |
if (predefinedRuntimes.size() > 1) { |
705 |
runtimes.add(0, predefinedRuntimes.get(1)); |
706 |
} |
707 |
MavenSettings.getDefault().setMavenRuntimes(runtimes); |
708 |
String cl = mavenRuntimeHome; |
602 |
//MEVENIDE-553 |
709 |
//MEVENIDE-553 |
603 |
File command = cl.isEmpty() ? null : new File(cl); |
710 |
File command = (cl == null || cl.isEmpty()) ? null : new File(cl); |
604 |
if (command != null && command.isDirectory()) { |
711 |
if (command != null && command.isDirectory()) { |
605 |
MavenSettings.getDefault().setMavenHome(command); |
712 |
MavenSettings.getDefault().setMavenHome(command); |
606 |
} else { |
713 |
} else { |