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

(-)a/maven/src/org/netbeans/modules/maven/options/Bundle.properties (-1 / +3 lines)
Lines 90-93 Link Here
90
TIT_EVERY=Every Project Open
90
TIT_EVERY=Every Project Open
91
TIT_FIRST=First Project Open Only
91
TIT_FIRST=First Project Open Only
92
SettingsPanel.cbSkipTests.text=Skip &Tests for any build executions not directly related to testing
92
SettingsPanel.cbSkipTests.text=Skip &Tests for any build executions not directly related to testing
93
SettingsPanel.btnDefault.text=Default
93
MAVEN_RUNTIME_Bundled=Bundled
94
MAVEN_RUNTIME_External={0}
95
MAVEN_RUNTIME_Browse=Browse...
(-)a/maven/src/org/netbeans/modules/maven/options/MavenSettings.java (-1 / +94 lines)
Lines 49-54 Link Here
49
import java.io.IOException;
49
import java.io.IOException;
50
import java.io.InputStream;
50
import java.io.InputStream;
51
import java.net.URL;
51
import java.net.URL;
52
import java.util.ArrayList;
53
import java.util.Collections;
54
import java.util.List;
52
import java.util.Properties;
55
import java.util.Properties;
53
import java.util.logging.Logger;
56
import java.util.logging.Logger;
54
import java.util.prefs.BackingStoreException;
57
import java.util.prefs.BackingStoreException;
Lines 59-64 Link Here
59
import org.openide.filesystems.FileUtil;
62
import org.openide.filesystems.FileUtil;
60
import org.openide.filesystems.URLMapper;
63
import org.openide.filesystems.URLMapper;
61
import org.openide.modules.InstalledFileLocator;
64
import org.openide.modules.InstalledFileLocator;
65
import org.openide.util.NbBundle;
62
import org.openide.util.NbPreferences;
66
import org.openide.util.NbPreferences;
63
67
64
/**
68
/**
Lines 76-81 Link Here
76
    public static final String PROP_LAST_ARCHETYPE_GROUPID = "lastArchetypeGroupId"; //NOI18N
80
    public static final String PROP_LAST_ARCHETYPE_GROUPID = "lastArchetypeGroupId"; //NOI18N
77
    public static final String PROP_CUSTOM_LOCAL_REPOSITORY = "localRepository"; //NOI18N
81
    public static final String PROP_CUSTOM_LOCAL_REPOSITORY = "localRepository"; //NOI18N
78
    public static final String PROP_SKIP_TESTS = "skipTests"; //NOI18N
82
    public static final String PROP_SKIP_TESTS = "skipTests"; //NOI18N
83
    public static final String PROP_MAVEN_RUNTIMES = "mavenRuntimes"; //NOI18N
79
84
80
    //these are from former versions (6.5) and are here only for conversion
85
    //these are from former versions (6.5) and are here only for conversion
81
    private static final String PROP_DEBUG = "showDebug"; // NOI18N
86
    private static final String PROP_DEBUG = "showDebug"; // NOI18N
Lines 84-90 Link Here
84
    private static final String PROP_PLUGIN_POLICY = "pluginUpdatePolicy"; //NOI18N
89
    private static final String PROP_PLUGIN_POLICY = "pluginUpdatePolicy"; //NOI18N
85
    private static final String PROP_FAILURE_BEHAVIOUR = "failureBehaviour"; //NOI18N
90
    private static final String PROP_FAILURE_BEHAVIOUR = "failureBehaviour"; //NOI18N
86
    private static final String PROP_USE_REGISTRY = "usePluginRegistry"; //NOI18N
91
    private static final String PROP_USE_REGISTRY = "usePluginRegistry"; //NOI18N
87
88
    
92
    
89
    private static final MavenSettings INSTANCE = new MavenSettings();
93
    private static final MavenSettings INSTANCE = new MavenSettings();
90
    
94
    
Lines 288-293 Link Here
288
    public boolean isShowRunDialog(){
292
    public boolean isShowRunDialog(){
289
     return getPreferences().getBoolean(PROP_SHOW_RUN_DIALOG, false);
293
     return getPreferences().getBoolean(PROP_SHOW_RUN_DIALOG, false);
290
    }
294
    }
295
    
291
    public void setShowRunDialog(boolean  b){
296
    public void setShowRunDialog(boolean  b){
292
      getPreferences().putBoolean(PROP_SHOW_RUN_DIALOG, b);
297
      getPreferences().putBoolean(PROP_SHOW_RUN_DIALOG, b);
293
    }
298
    }
Lines 390-394 Link Here
390
        }
395
        }
391
        return null;
396
        return null;
392
    }
397
    }
398
399
    private static List<String> searchMavenRuntimes(String[] paths, boolean stopOnFirstValid) {
400
        List<String> runtimes = new ArrayList<String>();
401
        for (String path : paths) {
402
            File file = new File(path);
403
            path = FileUtil.normalizeFile(file).getAbsolutePath();
404
            String version = getCommandLineMavenVersion(new File(path));
405
            if (version != null) {
406
                runtimes.add(path);
407
                if (stopOnFirstValid) {
408
                    break;
409
                }
410
            }
411
        }
412
413
        return runtimes;
414
    }
415
416
	/**
417
	 * Searches for Maven Runtimes by the environment settings and returns the first valid one.
418
	 *
419
	 * <p>It searches in this order:
420
	 * <ul>
421
	 * <li>MAVEN_HOME</li>
422
	 * <li>M2_HOME</li>
423
	 * <li>PATH</li></ul>
424
	 * </p>
425
	 * <p>Only the first appereance will be appended.</p>
426
	 *
427
	 * @returns the default external Maven runtime on the path.
428
	 */
429
    public static String getDefaultExternalMavenRuntime() {
430
        String paths = System.getenv("PATH"); // NOI18N
431
        String mavenHome = System.getenv("MAVEN_HOME"); // NOI18N
432
        String m2Home = System.getenv("M2_HOME"); // NOI18N
433
434
        List<String> mavenEnvDirs = new ArrayList<String>();
435
        if (mavenHome != null) {
436
            mavenEnvDirs.add(mavenHome);
437
        }
438
        if (m2Home != null) {
439
            mavenEnvDirs.add(m2Home);
440
        }
441
        if (paths != null) {
442
            for (String path : paths.split(File.pathSeparator)) {
443
                if (!path.endsWith("bin")) { // NOI18N
444
                    continue;
445
                }
446
447
                mavenEnvDirs.add(path.substring(0,
448
                        path.length() - "bin".length() - File.pathSeparator.length()));
449
            }
450
        }
451
452
        List<String> runtimes = searchMavenRuntimes(mavenEnvDirs.toArray(new String[0]), true);
453
        return !runtimes.isEmpty() ? runtimes.get(0) : null;
454
    }
455
    
456
    public List<String> getUserDefinedMavenRuntimes() {
457
        List<String> runtimes = new ArrayList<String>();
458
459
        String defaultRuntimePath = getDefaultExternalMavenRuntime();
460
        String runtimesPref = getPreferences().get(PROP_MAVEN_RUNTIMES, null);
461
        if (runtimesPref != null) {
462
            for (String runtimePath : runtimesPref.split(File.pathSeparator)) {
463
                if (!"".equals(runtimePath) && !runtimePath.equals(defaultRuntimePath)) {
464
                    runtimes.add(runtimePath);
465
                }
466
            }
467
        }
468
469
        return Collections.unmodifiableList(runtimes);
470
    }
471
472
    public void setMavenRuntimes(List<String> runtimes) {
473
        if (runtimes == null) {
474
            getPreferences().remove(PROP_MAVEN_RUNTIMES);
475
        } else {
476
            String runtimesPref = "";
477
            for (String path : runtimes) {
478
                runtimesPref += path + File.pathSeparator;
479
            }
480
            if (runtimesPref.endsWith(File.pathSeparator)) {
481
                runtimesPref = runtimesPref.substring(0, runtimesPref.length() - 1);
482
            }
483
            putProperty(PROP_MAVEN_RUNTIMES, runtimesPref);
484
        }
485
    }
393
    
486
    
394
}
487
}
(-)a/maven/src/org/netbeans/modules/maven/options/SettingsPanel.form (-43 / +26 lines)
Lines 25-31 Link Here
25
    <DimensionLayout dim="0">
25
    <DimensionLayout dim="0">
26
      <Group type="103" groupAlignment="0" attributes="0">
26
      <Group type="103" groupAlignment="0" attributes="0">
27
          <Group type="102" attributes="0">
27
          <Group type="102" attributes="0">
28
              <EmptySpace max="-2" attributes="0"/>
28
              <EmptySpace min="-2" max="-2" attributes="0"/>
29
              <Group type="103" groupAlignment="0" attributes="0">
29
              <Group type="103" groupAlignment="0" attributes="0">
30
                  <Group type="102" alignment="0" attributes="0">
30
                  <Group type="102" alignment="0" attributes="0">
31
                      <Group type="103" groupAlignment="0" attributes="0">
31
                      <Group type="103" groupAlignment="0" attributes="0">
Lines 33-55 Link Here
33
                          <Component id="lblOptions" alignment="0" min="-2" max="-2" attributes="0"/>
33
                          <Component id="lblOptions" alignment="0" min="-2" max="-2" attributes="0"/>
34
                          <Component id="lblLocalRepository" alignment="0" min="-2" max="-2" attributes="0"/>
34
                          <Component id="lblLocalRepository" alignment="0" min="-2" max="-2" attributes="0"/>
35
                      </Group>
35
                      </Group>
36
                      <EmptySpace max="-2" attributes="0"/>
36
                      <EmptySpace min="-2" max="-2" attributes="0"/>
37
                      <Group type="103" groupAlignment="0" attributes="0">
37
                      <Group type="103" groupAlignment="0" attributes="0">
38
                          <Group type="102" alignment="1" attributes="0">
38
                          <Component id="lblExternalVersion" alignment="0" pref="524" max="32767" attributes="0"/>
39
                              <Component id="txtCommandLine" pref="295" max="32767" attributes="0"/>
40
                              <EmptySpace max="-2" attributes="0"/>
41
                              <Component id="btnCommandLine" linkSize="1" min="-2" max="-2" attributes="0"/>
42
                              <EmptySpace max="-2" attributes="0"/>
43
                              <Component id="btnDefault" min="-2" max="-2" attributes="0"/>
44
                          </Group>
45
                          <Component id="lblExternalVersion" alignment="0" pref="500" max="32767" attributes="0"/>
46
                          <Group type="102" alignment="1" attributes="0">
39
                          <Group type="102" alignment="1" attributes="0">
47
                              <Group type="103" groupAlignment="0" attributes="0">
40
                              <Group type="103" groupAlignment="0" attributes="0">
48
                                  <Component id="comSource" alignment="0" pref="387" max="32767" attributes="1"/>
41
                                  <Component id="comSource" alignment="0" pref="404" max="32767" attributes="1"/>
49
                                  <Component id="comJavadoc" alignment="0" pref="387" max="32767" attributes="1"/>
42
                                  <Component id="comJavadoc" alignment="0" pref="404" max="32767" attributes="1"/>
50
                                  <Component id="comBinaries" alignment="0" pref="387" max="32767" attributes="1"/>
43
                                  <Component id="comBinaries" alignment="0" pref="404" max="32767" attributes="1"/>
51
                                  <Component id="txtLocalRepository" alignment="0" pref="387" max="32767" attributes="1"/>
44
                                  <Component id="txtLocalRepository" alignment="0" pref="404" max="32767" attributes="1"/>
52
                                  <Component id="txtOptions" pref="387" max="32767" attributes="0"/>
45
                                  <Component id="txtOptions" pref="404" max="32767" attributes="0"/>
53
                              </Group>
46
                              </Group>
54
                              <EmptySpace max="-2" attributes="0"/>
47
                              <EmptySpace max="-2" attributes="0"/>
55
                              <Group type="103" groupAlignment="0" attributes="0">
48
                              <Group type="103" groupAlignment="0" attributes="0">
Lines 58-63 Link Here
58
                              </Group>
51
                              </Group>
59
                          </Group>
52
                          </Group>
60
                          <Component id="cbSkipTests" alignment="0" min="-2" max="-2" attributes="0"/>
53
                          <Component id="cbSkipTests" alignment="0" min="-2" max="-2" attributes="0"/>
54
                          <Group type="102" alignment="1" attributes="0">
55
                              <Component id="comMavenHome" pref="402" max="32767" attributes="0"/>
56
                              <EmptySpace min="-2" pref="122" max="-2" attributes="0"/>
57
                          </Group>
61
                      </Group>
58
                      </Group>
62
                  </Group>
59
                  </Group>
63
                  <Component id="jLabel1" alignment="0" min="-2" max="-2" attributes="0"/>
60
                  <Component id="jLabel1" alignment="0" min="-2" max="-2" attributes="0"/>
Lines 77-89 Link Here
77
                      <EmptySpace max="-2" attributes="0"/>
74
                      <EmptySpace max="-2" attributes="0"/>
78
                      <Group type="103" groupAlignment="0" attributes="0">
75
                      <Group type="103" groupAlignment="0" attributes="0">
79
                          <Component id="cbSnapshots" min="-2" max="-2" attributes="0"/>
76
                          <Component id="cbSnapshots" min="-2" max="-2" attributes="0"/>
80
                          <Component id="comIndex" pref="396" max="32767" attributes="0"/>
77
                          <Component id="comIndex" pref="421" max="32767" attributes="0"/>
81
                      </Group>
78
                      </Group>
82
                      <EmptySpace max="-2" attributes="0"/>
79
                      <EmptySpace max="-2" attributes="0"/>
83
                      <Component id="btnIndex" linkSize="1" min="-2" max="-2" attributes="0"/>
80
                      <Component id="btnIndex" linkSize="1" min="-2" max="-2" attributes="0"/>
84
                  </Group>
81
                  </Group>
85
              </Group>
82
              </Group>
86
              <EmptySpace max="-2" attributes="0"/>
83
              <EmptySpace min="-2" max="-2" attributes="0"/>
87
          </Group>
84
          </Group>
88
      </Group>
85
      </Group>
89
    </DimensionLayout>
86
    </DimensionLayout>
Lines 93-101 Link Here
93
              <EmptySpace min="-2" pref="6" max="-2" attributes="0"/>
90
              <EmptySpace min="-2" pref="6" max="-2" attributes="0"/>
94
              <Group type="103" groupAlignment="3" attributes="0">
91
              <Group type="103" groupAlignment="3" attributes="0">
95
                  <Component id="lblCommandLine" alignment="3" min="-2" max="-2" attributes="0"/>
92
                  <Component id="lblCommandLine" alignment="3" min="-2" max="-2" attributes="0"/>
96
                  <Component id="txtCommandLine" alignment="3" min="-2" max="-2" attributes="0"/>
93
                  <Component id="comMavenHome" alignment="3" min="-2" max="-2" attributes="0"/>
97
                  <Component id="btnDefault" alignment="3" min="-2" max="-2" attributes="0"/>
98
                  <Component id="btnCommandLine" alignment="3" min="-2" max="-2" attributes="0"/>
99
              </Group>
94
              </Group>
100
              <EmptySpace max="-2" attributes="0"/>
95
              <EmptySpace max="-2" attributes="0"/>
101
              <Component id="lblExternalVersion" min="-2" pref="14" max="-2" attributes="0"/>
96
              <Component id="lblExternalVersion" min="-2" pref="14" max="-2" attributes="0"/>
Lines 142-148 Link Here
142
              </Group>
137
              </Group>
143
              <EmptySpace max="-2" attributes="0"/>
138
              <EmptySpace max="-2" attributes="0"/>
144
              <Component id="cbSnapshots" min="-2" max="-2" attributes="0"/>
139
              <Component id="cbSnapshots" min="-2" max="-2" attributes="0"/>
145
              <EmptySpace max="32767" attributes="0"/>
140
              <EmptySpace pref="23" max="32767" attributes="0"/>
146
          </Group>
141
          </Group>
147
      </Group>
142
      </Group>
148
    </DimensionLayout>
143
    </DimensionLayout>
Lines 155-182 Link Here
155
        </Property>
150
        </Property>
156
      </Properties>
151
      </Properties>
157
    </Component>
152
    </Component>
158
    <Component class="javax.swing.JTextField" name="txtCommandLine">
159
    </Component>
160
    <Component class="javax.swing.JButton" name="btnCommandLine">
161
      <Properties>
162
        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
163
          <ResourceString bundle="org/netbeans/modules/maven/options/Bundle.properties" key="SettingsPanel.btnCommandLine.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
164
        </Property>
165
      </Properties>
166
      <Events>
167
        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnCommandLineActionPerformed"/>
168
      </Events>
169
    </Component>
170
    <Component class="javax.swing.JButton" name="btnDefault">
171
      <Properties>
172
        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
173
          <ResourceString bundle="org/netbeans/modules/maven/options/Bundle.properties" key="SettingsPanel.btnDefault.text" replaceFormat="NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
174
        </Property>
175
      </Properties>
176
      <Events>
177
        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnDefaultActionPerformed"/>
178
      </Events>
179
    </Component>
180
    <Component class="javax.swing.JLabel" name="lblExternalVersion">
153
    <Component class="javax.swing.JLabel" name="lblExternalVersion">
181
    </Component>
154
    </Component>
182
    <Component class="javax.swing.JLabel" name="lblOptions">
155
    <Component class="javax.swing.JLabel" name="lblOptions">
Lines 187-192 Link Here
187
      </Properties>
160
      </Properties>
188
    </Component>
161
    </Component>
189
    <Component class="javax.swing.JTextField" name="txtOptions">
162
    <Component class="javax.swing.JTextField" name="txtOptions">
163
      <AuxValues>
164
        <AuxValue name="JavaCodeGenerator_SerializeTo" type="java.lang.String" value="SettingsPanel_txtOptions"/>
165
      </AuxValues>
190
    </Component>
166
    </Component>
191
    <Component class="javax.swing.JButton" name="btnOptions">
167
    <Component class="javax.swing.JButton" name="btnOptions">
192
      <Properties>
168
      <Properties>
Lines 319-323 Link Here
319
        </Property>
295
        </Property>
320
      </Properties>
296
      </Properties>
321
    </Component>
297
    </Component>
298
    <Component class="javax.swing.JComboBox" name="comMavenHome">
299
      <Properties>
300
        <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
301
          <StringArray count="0"/>
302
        </Property>
303
      </Properties>
304
    </Component>
322
  </SubComponents>
305
  </SubComponents>
323
</Form>
306
</Form>
(-)a/maven/src/org/netbeans/modules/maven/options/SettingsPanel.java (-103 / +210 lines)
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 {

Return to bug 183455