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/api/customizer/support/CheckBoxUpdater.java (-2 / +2 lines)
Lines 74-80 Link Here
74
            inherited = false;
74
            inherited = false;
75
            component.setFont(component.getFont().deriveFont(Font.BOLD));
75
            component.setFont(component.getFont().deriveFont(Font.BOLD));
76
76
77
            component.setToolTipText(""); //NOI18N
77
            component.setToolTipText(null);
78
        } else {
78
        } else {
79
            component.setToolTipText(NbBundle.getMessage(CheckBoxUpdater.class, "MSG_Value_Inherited")); //NOI18N
79
            component.setToolTipText(NbBundle.getMessage(CheckBoxUpdater.class, "MSG_Value_Inherited")); //NOI18N
80
            inherited = true;
80
            inherited = true;
Lines 103-109 Link Here
103
    private void setCheckBoxValue(Boolean value, boolean defValue, JCheckBox component) {
103
    private void setCheckBoxValue(Boolean value, boolean defValue, JCheckBox component) {
104
        if (value != null) {
104
        if (value != null) {
105
            component.setSelected(value.booleanValue());
105
            component.setSelected(value.booleanValue());
106
            component.setToolTipText(""); //NOI18N
106
            component.setToolTipText(null);
107
            inherited = false;
107
            inherited = false;
108
            component.setFont(component.getFont().deriveFont(Font.BOLD));
108
            component.setFont(component.getFont().deriveFont(Font.BOLD));
109
        } else {
109
        } else {
(-)a/maven/src/org/netbeans/modules/maven/api/customizer/support/ComboBoxUpdater.java (-3 / +3 lines)
Lines 79-85 Link Here
79
//            component.setBackground(DEFAULT);
79
//            component.setBackground(DEFAULT);
80
            label.setFont(label.getFont().deriveFont(Font.BOLD));
80
            label.setFont(label.getFont().deriveFont(Font.BOLD));
81
            
81
            
82
            component.setToolTipText(""); //NOI18N
82
            component.setToolTipText(null);
83
        }
83
        }
84
        @SuppressWarnings("unchecked")
84
        @SuppressWarnings("unchecked")
85
        T val = (T)component.getSelectedItem();
85
        T val = (T)component.getSelectedItem();
Lines 114-120 Link Here
114
    private void setComboValue(T value, T projectValue, JComboBox field) {
114
    private void setComboValue(T value, T projectValue, JComboBox field) {
115
        if (value != null) {
115
        if (value != null) {
116
            field.setSelectedItem(value);
116
            field.setSelectedItem(value);
117
            component.setToolTipText(""); //NOI18N
117
            component.setToolTipText(null);
118
            inherited = false;
118
            inherited = false;
119
            label.setFont(label.getFont().deriveFont(Font.BOLD));
119
            label.setFont(label.getFont().deriveFont(Font.BOLD));
120
        } else if (projectValue != null) {
120
        } else if (projectValue != null) {
Lines 125-131 Link Here
125
            inherited = true;
125
            inherited = true;
126
        } else {
126
        } else {
127
            field.setSelectedItem(field.getModel().getElementAt(0));
127
            field.setSelectedItem(field.getModel().getElementAt(0));
128
            component.setToolTipText(""); //NOI18N
128
            component.setToolTipText(null);
129
            inherited = false;
129
            inherited = false;
130
            label.setFont(label.getFont().deriveFont(Font.BOLD));
130
            label.setFont(label.getFont().deriveFont(Font.BOLD));
131
      }
131
      }
(-)a/maven/src/org/netbeans/modules/maven/execute/MavenCommandLineExecutor.java (+10 lines)
Lines 56-62 Link Here
56
import java.net.URL;
56
import java.net.URL;
57
import java.util.Collection;
57
import java.util.Collection;
58
import java.util.HashMap;
58
import java.util.HashMap;
59
import java.util.Iterator;
59
import java.util.Map;
60
import java.util.Map;
61
import java.util.Map.Entry;
60
import java.util.UUID;
62
import java.util.UUID;
61
import org.netbeans.api.progress.ProgressHandle;
63
import org.netbeans.api.progress.ProgressHandle;
62
import org.netbeans.api.progress.ProgressHandleFactory;
64
import org.netbeans.api.progress.ProgressHandleFactory;
Lines 419-424 Link Here
419
            builder.environment().put(env, val);
421
            builder.environment().put(env, val);
420
            display.append(Utilities.escapeParameters(new String[] {env + "=" + val})).append(' '); // NOI18N
422
            display.append(Utilities.escapeParameters(new String[] {env + "=" + val})).append(' '); // NOI18N
421
        }
423
        }
424
        for (Iterator<Map.Entry<String, String>> it = builder.environment().entrySet().iterator(); it.hasNext(); ) {
425
            Entry<String, String> entry = it.next();
426
            if ("M2_HOME".equals(entry.getKey())) {
427
                // M2_HOME must be filtered when 2.x being used and 3.x on the PATH
428
                it.remove();
429
                continue;
430
            }
431
        }
422
        List<String> command = builder.command();
432
        List<String> command = builder.command();
423
        display.append(Utilities.escapeParameters(command.toArray(new String[command.size()])));
433
        display.append(Utilities.escapeParameters(command.toArray(new String[command.size()])));
424
        printGray(ioput, display.toString());
434
        printGray(ioput, display.toString());
(-)a/maven/src/org/netbeans/modules/maven/options/Bundle.properties (-9 / +11 lines)
Lines 43-57 Link Here
43
43
44
TIP_Maven_Category=Set default Maven execution options.
44
TIP_Maven_Category=Set default Maven execution options.
45
SettingsPanel.btnIndex.text=Index &Now
45
SettingsPanel.btnIndex.text=Index &Now
46
SettingsPanel.lblLocalRepository.text=&Local Repository \:
46
SettingsPanel.lblLocalRepository.text=&Local Repository:
47
SettingsPanel.btnLocalRepository.text=&Browse...
47
SettingsPanel.btnLocalRepository.text=&Browse...
48
SettingsPanel.lblIndex.text=&Index Update Frequency\:
48
SettingsPanel.lblIndex.text=&Index Update Frequency\:
49
SettingsPanel.cbSnapshots.text=Include &Snapshots In Local Index
49
SettingsPanel.cbSnapshots.text=Include &Snapshots In Local Index
50
50
51
TIT_Select=Select Local Repository Location
51
TIT_Select=Select Local Repository Location
52
SettingsPanel.lblCommandLine.text=&Maven Home :
52
SettingsPanel.lblCommandLine.text=&Maven Home:
53
TIT_Select2=Select Maven Installation Location
53
TIT_Select2=Select Maven Installation Location
54
SettingsPanel.btnCommandLine.text=&Browse...
55
SettingsPanel.btnGoals.text=Edit &Global Custom Goal Definitions...
54
SettingsPanel.btnGoals.text=Edit &Global Custom Goal Definitions...
56
TIT_Global=Global Maven Goal definitions
55
TIT_Global=Global Maven Goal definitions
57
ACSD_Global=Global Maven Goal definitions
56
ACSD_Global=Global Maven Goal definitions
Lines 62-75 Link Here
62
FREQ_Always=On every startup
61
FREQ_Always=On every startup
63
FREQ_Never=Never
62
FREQ_Never=Never
64
ERR_Wrong_Settings_file=Cannot parse the ~/.m2/settings.xml file, any options related to that file will be disabled.
63
ERR_Wrong_Settings_file=Cannot parse the ~/.m2/settings.xml file, any options related to that file will be disabled.
65
SettingsPanel.lblOptions.text=Global Execution &Options :
64
SettingsPanel.lblOptions.text=Global Execution &Options:
66
SettingsPanel.btnOptions.text=&Add
65
SettingsPanel.btnOptions.text=&Add
67
GlobalOptionsPanel.lblOptions.text=&Global Execution Options :
66
GlobalOptionsPanel.lblOptions.text=&Global Execution Options :
68
SettingsPanel.lblBinaries.text=&Download Binaries :
67
SettingsPanel.lblBinaries.text=&Download Binaries:
69
SettingsPanel.jLabel3.text=<html><b>Please note</b> that setting any of these to values other than <b>"Never"</b> can make opening projects significantly slower.
68
SettingsPanel.jLabel3.text=<html><b>Please note</b> that setting any of these to values other than <b>"Never"</b> can make opening projects significantly slower.
70
On_Project_Open=Dependency Download Strategy
69
On_Project_Open=Dependency Download Strategy
71
SettingsPanel.lblSource.text=Check &Sources :
70
SettingsPanel.lblSource.text=Check &Sources:
72
SettingsPanel.lblJavadoc.text=Check &Javadoc :
71
SettingsPanel.lblJavadoc.text=Check &Javadoc:
73
txt_default_repository=<Use default local repository as defined by Maven>
72
txt_default_repository=<Use default local repository as defined by Maven>
74
WORK_OFFLINE=Work offline.
73
WORK_OFFLINE=Work offline.
75
PRODUCE_EXECUTION_DEBUG_OUTPUT=Produce execution debug output.
74
PRODUCE_EXECUTION_DEBUG_OUTPUT=Produce execution debug output.
Lines 85-93 Link Here
85
FORCES_A_CHECK=Forces a check for updated releases and snapshots on remote repositories.
84
FORCES_A_CHECK=Forces a check for updated releases and snapshots on remote repositories.
86
DON'T_USE_PLUGIN-REGISTRY=Don't use ~/.m2/plugin-registry.xml for plugin versions
85
DON'T_USE_PLUGIN-REGISTRY=Don't use ~/.m2/plugin-registry.xml for plugin versions
87
TIT_Add_Globals=Add Global Option(s)
86
TIT_Add_Globals=Add Global Option(s)
88
SettingsPanel.jLabel1.text=Dependency Download Strategy :
87
SettingsPanel.jLabel1.text=Dependency Download Strategy:
89
TIT_NEVER=Never
88
TIT_NEVER=Never
90
TIT_EVERY=Every Project Open
89
TIT_EVERY=Every Project Open
91
TIT_FIRST=First Project Open Only
90
TIT_FIRST=First Project Open Only
92
SettingsPanel.cbSkipTests.text=Skip &Tests for any build executions not directly related to testing
91
SettingsPanel.cbSkipTests.text=Skip &Tests for any build executions not directly related to testing
93
SettingsPanel.btnDefault.text=Default
92
MAVEN_RUNTIME_Embedded=Embedded
93
MAVEN_RUNTIME_External={0}
94
MAVEN_RUNTIME_Browse=Browse...
95
MAVEN_RUNTIME_ClearUserDefines=Clear User-Defined Maven Runtimes
(-)a/maven/src/org/netbeans/modules/maven/options/MyJTextField.java (-2 / +2 lines)
Lines 50-56 Link Here
50
 *
50
 *
51
 * @author mkleint
51
 * @author mkleint
52
 */
52
 */
53
public class MyJTextField extends JTextField {
53
public class JHintedTextField extends JTextField {
54
54
55
    Color origForeground;
55
    Color origForeground;
56
    String origText = "";
56
    String origText = "";
Lines 75-81 Link Here
75
        }
75
        }
76
    };
76
    };
77
77
78
    public MyJTextField() {
78
    public JHintedTextField() {
79
        addFocusListener(listener);
79
        addFocusListener(listener);
80
    }
80
    }
81
81
(-)a/maven/src/org/netbeans/modules/maven/options/MavenSettings.java (-1 / +95 lines)
Lines 42-47 Link Here
42
42
43
package org.netbeans.modules.maven.options;
43
package org.netbeans.modules.maven.options;
44
44
45
import com.sun.tools.javac.resources.version;
45
import org.codehaus.plexus.util.StringUtils;
46
import org.codehaus.plexus.util.StringUtils;
46
import org.codehaus.plexus.util.cli.CommandLineUtils;
47
import org.codehaus.plexus.util.cli.CommandLineUtils;
47
import java.io.File;
48
import java.io.File;
Lines 49-54 Link Here
49
import java.io.IOException;
50
import java.io.IOException;
50
import java.io.InputStream;
51
import java.io.InputStream;
51
import java.net.URL;
52
import java.net.URL;
53
import java.util.ArrayList;
54
import java.util.Collections;
55
import java.util.List;
52
import java.util.Properties;
56
import java.util.Properties;
53
import java.util.logging.Logger;
57
import java.util.logging.Logger;
54
import java.util.prefs.BackingStoreException;
58
import java.util.prefs.BackingStoreException;
Lines 59-64 Link Here
59
import org.openide.filesystems.FileUtil;
63
import org.openide.filesystems.FileUtil;
60
import org.openide.filesystems.URLMapper;
64
import org.openide.filesystems.URLMapper;
61
import org.openide.modules.InstalledFileLocator;
65
import org.openide.modules.InstalledFileLocator;
66
import org.openide.util.NbBundle;
62
import org.openide.util.NbPreferences;
67
import org.openide.util.NbPreferences;
63
68
64
/**
69
/**
Lines 76-81 Link Here
76
    public static final String PROP_LAST_ARCHETYPE_GROUPID = "lastArchetypeGroupId"; //NOI18N
81
    public static final String PROP_LAST_ARCHETYPE_GROUPID = "lastArchetypeGroupId"; //NOI18N
77
    public static final String PROP_CUSTOM_LOCAL_REPOSITORY = "localRepository"; //NOI18N
82
    public static final String PROP_CUSTOM_LOCAL_REPOSITORY = "localRepository"; //NOI18N
78
    public static final String PROP_SKIP_TESTS = "skipTests"; //NOI18N
83
    public static final String PROP_SKIP_TESTS = "skipTests"; //NOI18N
84
    public static final String PROP_MAVEN_RUNTIMES = "mavenRuntimes"; //NOI18N
79
85
80
    //these are from former versions (6.5) and are here only for conversion
86
    //these are from former versions (6.5) and are here only for conversion
81
    private static final String PROP_DEBUG = "showDebug"; // NOI18N
87
    private static final String PROP_DEBUG = "showDebug"; // NOI18N
Lines 84-90 Link Here
84
    private static final String PROP_PLUGIN_POLICY = "pluginUpdatePolicy"; //NOI18N
90
    private static final String PROP_PLUGIN_POLICY = "pluginUpdatePolicy"; //NOI18N
85
    private static final String PROP_FAILURE_BEHAVIOUR = "failureBehaviour"; //NOI18N
91
    private static final String PROP_FAILURE_BEHAVIOUR = "failureBehaviour"; //NOI18N
86
    private static final String PROP_USE_REGISTRY = "usePluginRegistry"; //NOI18N
92
    private static final String PROP_USE_REGISTRY = "usePluginRegistry"; //NOI18N
87
88
    
93
    
89
    private static final MavenSettings INSTANCE = new MavenSettings();
94
    private static final MavenSettings INSTANCE = new MavenSettings();
90
    
95
    
Lines 288-293 Link Here
288
    public boolean isShowRunDialog(){
293
    public boolean isShowRunDialog(){
289
     return getPreferences().getBoolean(PROP_SHOW_RUN_DIALOG, false);
294
     return getPreferences().getBoolean(PROP_SHOW_RUN_DIALOG, false);
290
    }
295
    }
296
    
291
    public void setShowRunDialog(boolean  b){
297
    public void setShowRunDialog(boolean  b){
292
      getPreferences().putBoolean(PROP_SHOW_RUN_DIALOG, b);
298
      getPreferences().putBoolean(PROP_SHOW_RUN_DIALOG, b);
293
    }
299
    }
Lines 390-394 Link Here
390
        }
396
        }
391
        return null;
397
        return null;
392
    }
398
    }
399
400
    private static List<String> searchMavenRuntimes(String[] paths, boolean stopOnFirstValid) {
401
        List<String> runtimes = new ArrayList<String>();
402
        for (String path : paths) {
403
            File file = new File(path);
404
            path = FileUtil.normalizeFile(file).getAbsolutePath();
405
            String version = getCommandLineMavenVersion(new File(path));
406
            if (version != null) {
407
                runtimes.add(path);
408
                if (stopOnFirstValid) {
409
                    break;
410
                }
411
            }
412
        }
413
414
        return runtimes;
415
    }
416
417
	/**
418
	 * Searches for Maven Runtimes by the environment settings and returns the first valid one.
419
	 *
420
	 * <p>It searches in this order:
421
	 * <ul>
422
	 * <li>MAVEN_HOME</li>
423
	 * <li>M2_HOME</li>
424
	 * <li>PATH</li></ul>
425
	 * </p>
426
	 * <p>Only the first appereance will be appended.</p>
427
	 *
428
	 * @returns the default external Maven runtime on the path.
429
	 */
430
    public static String getDefaultExternalMavenRuntime() {
431
        String paths = System.getenv("PATH"); // NOI18N
432
        String mavenHome = System.getenv("MAVEN_HOME"); // NOI18N
433
        String m2Home = System.getenv("M2_HOME"); // NOI18N
434
435
        List<String> mavenEnvDirs = new ArrayList<String>();
436
        if (mavenHome != null) {
437
            mavenEnvDirs.add(mavenHome);
438
        }
439
        if (m2Home != null) {
440
            mavenEnvDirs.add(m2Home);
441
        }
442
        if (paths != null) {
443
            for (String path : paths.split(File.pathSeparator)) {
444
                if (!path.endsWith("bin")) { // NOI18N
445
                    continue;
446
                }
447
448
                mavenEnvDirs.add(path.substring(0,
449
                        path.length() - "bin".length() - File.pathSeparator.length()));
450
            }
451
        }
452
453
        List<String> runtimes = searchMavenRuntimes(mavenEnvDirs.toArray(new String[0]), true);
454
        return !runtimes.isEmpty() ? runtimes.get(0) : null;
455
    }
456
    
457
    public List<String> getUserDefinedMavenRuntimes() {
458
        List<String> runtimes = new ArrayList<String>();
459
460
        String defaultRuntimePath = getDefaultExternalMavenRuntime();
461
        String runtimesPref = getPreferences().get(PROP_MAVEN_RUNTIMES, null);
462
        if (runtimesPref != null) {
463
            for (String runtimePath : runtimesPref.split(File.pathSeparator)) {
464
                if (!"".equals(runtimePath) && !runtimePath.equals(defaultRuntimePath)) {
465
                    runtimes.add(runtimePath);
466
                }
467
            }
468
        }
469
470
        return Collections.unmodifiableList(runtimes);
471
    }
472
473
    public void setMavenRuntimes(List<String> runtimes) {
474
        if (runtimes == null) {
475
            getPreferences().remove(PROP_MAVEN_RUNTIMES);
476
        } else {
477
            String runtimesPref = "";
478
            for (String path : runtimes) {
479
                runtimesPref += path + File.pathSeparator;
480
            }
481
            if (runtimesPref.endsWith(File.pathSeparator)) {
482
                runtimesPref = runtimesPref.substring(0, runtimesPref.length() - 1);
483
            }
484
            putProperty(PROP_MAVEN_RUNTIMES, runtimesPref);
485
        }
486
    }
393
    
487
    
394
}
488
}
(-)a/maven/src/org/netbeans/modules/maven/options/SettingsPanel.form (-44 / +24 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 214-220 Link Here
214
    </Component>
187
    </Component>
215
    <Component class="javax.swing.JTextField" name="txtLocalRepository">
188
    <Component class="javax.swing.JTextField" name="txtLocalRepository">
216
      <AuxValues>
189
      <AuxValues>
217
        <AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="new MyJTextField();"/>
190
        <AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="new org.netbeans.modules.maven.options.JHintedTextField();"/>
218
      </AuxValues>
191
      </AuxValues>
219
    </Component>
192
    </Component>
220
    <Component class="javax.swing.JButton" name="btnLocalRepository">
193
    <Component class="javax.swing.JButton" name="btnLocalRepository">
Lines 319-323 Link Here
319
        </Property>
292
        </Property>
320
      </Properties>
293
      </Properties>
321
    </Component>
294
    </Component>
295
    <Component class="javax.swing.JComboBox" name="comMavenHome">
296
      <Properties>
297
        <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
298
          <StringArray count="0"/>
299
        </Property>
300
      </Properties>
301
    </Component>
322
  </SubComponents>
302
  </SubComponents>
323
</Form>
303
</Form>
(-)a/maven/src/org/netbeans/modules/maven/options/SettingsPanel.java (-110 / +250 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 54-63 Link Here
54
import javax.swing.DefaultComboBoxModel;
55
import javax.swing.DefaultComboBoxModel;
55
import javax.swing.DefaultListCellRenderer;
56
import javax.swing.DefaultListCellRenderer;
56
import javax.swing.JFileChooser;
57
import javax.swing.JFileChooser;
58
import javax.swing.JLabel;
57
import javax.swing.JList;
59
import javax.swing.JList;
60
import javax.swing.JSeparator;
58
import javax.swing.ListCellRenderer;
61
import javax.swing.ListCellRenderer;
59
import javax.swing.SwingUtilities;
62
import javax.swing.SwingUtilities;
60
import javax.swing.event.DocumentEvent;
63
import javax.swing.border.EmptyBorder;
61
import javax.swing.event.DocumentListener;
64
import javax.swing.event.DocumentListener;
62
import org.netbeans.modules.maven.TextValueCompleter;
65
import org.netbeans.modules.maven.TextValueCompleter;
63
import org.netbeans.modules.maven.indexer.api.RepositoryIndexer;
66
import org.netbeans.modules.maven.indexer.api.RepositoryIndexer;
Lines 86-97 Link Here
86
 */
89
 */
87
public class SettingsPanel extends javax.swing.JPanel {
90
public class SettingsPanel extends javax.swing.JPanel {
88
    private static final String CP_SELECTED = "wasSelected"; //NOI18N
91
    private static final String CP_SELECTED = "wasSelected"; //NOI18N
92
    private static final String SEPARATOR = "SEPARATOR";
93
    private static final String EMBEDDED_RUNTIME_VERSION =
94
            MavenSettings.getCommandLineMavenVersion(MavenSettings.getDefaultMavenHome());
95
    private static final int RUNTIME_COUNT_LIMIT = 5;
89
    private boolean changed;
96
    private boolean changed;
90
    private boolean valid;
97
    private boolean valid;
91
    private ActionListener listener;
98
    private ActionListener listener;
92
    private DocumentListener docList;
99
    private DocumentListener docList;
93
    private MavenOptionController controller;
100
    private MavenOptionController controller;
94
    private TextValueCompleter completer;
101
    private TextValueCompleter completer;
102
    private ActionListener   listItemChangedListener;
103
    private List<String>       userDefinedMavenRuntimes = new ArrayList<String>();
104
    private List<String>       predefinedRuntimes = new ArrayList<String>();
105
    private DefaultComboBoxModel mavenHomeDataModel = new DefaultComboBoxModel();
106
    private String             mavenRuntimeHome = null;
107
    private int                lastSelected = -1;
108
109
    private class ComboBoxRenderer extends JLabel implements ListCellRenderer {
110
111
        private JSeparator separator;
112
113
        public ComboBoxRenderer() {
114
            setOpaque(true);
115
            setBorder(new EmptyBorder(1, 1, 1, 1));
116
            separator = new JSeparator(JSeparator.HORIZONTAL);
117
        }
118
119
        @Override
120
        public Component getListCellRendererComponent(JList list, Object value,
121
                int index, boolean isSelected, boolean cellHasFocus) {
122
            if (SEPARATOR.equals(value)) {
123
                return separator;
124
            }
125
            if (isSelected) {
126
                setBackground(list.getSelectionBackground());
127
                setForeground(list.getSelectionForeground());
128
            } else {
129
                setBackground(list.getBackground());
130
                setForeground(list.getForeground());
131
            }
132
            
133
            setFont(list.getFont());
134
            setText(value.toString());
135
            return this;
136
        }
137
    };
95
138
96
    /** Creates new form SettingsPanel */
139
    /** Creates new form SettingsPanel */
97
    SettingsPanel(MavenOptionController controller) {
140
    SettingsPanel(MavenOptionController controller) {
Lines 101-106 Link Here
101
        comBinaries.setModel(new DefaultComboBoxModel(downloads));
144
        comBinaries.setModel(new DefaultComboBoxModel(downloads));
102
        comJavadoc.setModel(new DefaultComboBoxModel(downloads));
145
        comJavadoc.setModel(new DefaultComboBoxModel(downloads));
103
        comSource.setModel(new DefaultComboBoxModel(downloads));
146
        comSource.setModel(new DefaultComboBoxModel(downloads));
147
        comMavenHome.setModel(mavenHomeDataModel);
104
148
105
        ListCellRenderer rend = new DefaultListCellRenderer() {
149
        ListCellRenderer rend = new DefaultListCellRenderer() {
106
            @Override
150
            @Override
Lines 119-139 Link Here
119
        comBinaries.setRenderer(rend);
163
        comBinaries.setRenderer(rend);
120
        comSource.setRenderer(rend);
164
        comSource.setRenderer(rend);
121
        comJavadoc.setRenderer(rend);
165
        comJavadoc.setRenderer(rend);
166
        comMavenHome.setRenderer(new ComboBoxRenderer());
122
167
123
        this.controller = controller;
168
        this.controller = controller;
124
        docList = new DocumentListener() {
169
        listItemChangedListener = new ActionListener() {
125
            public void insertUpdate(DocumentEvent e) {
170
            
126
                documentChanged(e);
171
            @Override
127
            }
172
            public void actionPerformed(ActionEvent e) {
128
            public void removeUpdate(DocumentEvent e) {
173
                if (SEPARATOR.equals(comMavenHome.getSelectedItem())) {
129
                documentChanged(e);
174
                    comMavenHome.setSelectedIndex(lastSelected);
130
            }
175
                    return;
131
            public void changedUpdate(DocumentEvent e) {
176
                }
132
                documentChanged(e);
177
                
178
                int selected = comMavenHome.getSelectedIndex();
179
                if (selected == mavenHomeDataModel.getSize() - 1) {
180
                    // clear all user defined runtimes
181
                    if (userDefinedMavenRuntimes.isEmpty()) {
182
                        comMavenHome.setSelectedIndex(lastSelected);
183
                        return;
184
                    }
185
                    
186
                    int count = userDefinedMavenRuntimes.size() + 1;
187
                    userDefinedMavenRuntimes.clear();
188
                    for (int i = 0; i < count; ++i) {
189
                        mavenHomeDataModel.removeElementAt(predefinedRuntimes.size());
190
                    }
191
                    
192
                    lastSelected = 0;
193
                    comMavenHome.setSelectedIndex(lastSelected);
194
                    return;
195
                }
196
                
197
                if (selected == mavenHomeDataModel.getSize() - 2) {
198
                    // browse
199
                    comMavenHome.setSelectedIndex(lastSelected);
200
                    SwingUtilities.invokeLater(new Runnable() {
201
202
                        @Override
203
                        public void run() {
204
                            browseAddNewRuntime();
205
                        }
206
                        
207
                    });
208
                    return;
209
                }
210
                
211
                listDataChanged();
212
                lastSelected = selected;
133
            }
213
            }
134
        };
214
        };
135
        initValues();
215
        initValues();
136
        ((MyJTextField)txtLocalRepository).setHintText(org.openide.util.NbBundle.getMessage(SettingsPanel.class, "txt_default_repository"));
216
        ((JHintedTextField)txtLocalRepository).setHintText(org.openide.util.NbBundle.getMessage(SettingsPanel.class, "txt_default_repository"));
137
        listener = new ActionListenerImpl();
217
        listener = new ActionListenerImpl();
138
        cbSnapshots.addActionListener(listener);
218
        cbSnapshots.addActionListener(listener);
139
        comIndex.addActionListener(listener);
219
        comIndex.addActionListener(listener);
Lines 179-221 Link Here
179
        return Arrays.asList(AVAILABLE_OPTIONS);
259
        return Arrays.asList(AVAILABLE_OPTIONS);
180
    }
260
    }
181
261
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() {
262
    private void initValues() {
196
        comIndex.setSelectedIndex(0);
263
        comIndex.setSelectedIndex(0);
197
        cbSnapshots.setSelected(true);
264
        cbSnapshots.setSelected(true);
198
    }
265
    }
199
    
266
    
200
    private void documentChanged(DocumentEvent e) {
267
    private String getSelectedRuntime(int selected) {
268
        if (selected < 0) {
269
            return null;
270
        }
271
        
272
        if (selected < predefinedRuntimes.size()) {
273
            return predefinedRuntimes.get(selected);
274
275
        } else if (!userDefinedMavenRuntimes.isEmpty() &&
276
                selected - predefinedRuntimes.size() <= userDefinedMavenRuntimes.size()) {
277
            return userDefinedMavenRuntimes.get(selected - 1 - predefinedRuntimes.size());
278
        }
279
        
280
        return null;
281
    }
282
    
283
    private void listDataChanged() {
201
        changed = true;
284
        changed = true;
202
        boolean oldvalid = valid;
285
        boolean oldvalid = valid;
203
        if (txtCommandLine.getText().trim().length() > 0) {
286
        int selected = comMavenHome.getSelectedIndex();
204
            File fil = new File(txtCommandLine.getText());
287
        String path = getSelectedRuntime(selected);
288
        if (path != null) {
289
            path = path.trim();
290
            if ("".equals(path)) {
291
                path = null;
292
                valid = true;
293
                lblExternalVersion.setText(NbBundle.getMessage(SettingsPanel.class, "LBL_ExMavenVersion2", EMBEDDED_RUNTIME_VERSION));
294
            }
295
        }
296
297
        if (path != null) {
298
            path = path.trim();
299
            File fil = new File(path);
300
            String ver = null;
205
            if (fil.exists() && new File(fil, "bin" + File.separator + "mvn").exists()) { //NOI18N
301
            if (fil.exists() && new File(fil, "bin" + File.separator + "mvn").exists()) { //NOI18N
302
                ver = MavenSettings.getCommandLineMavenVersion(new File(path));
303
            }
304
305
            if (ver != null) {
306
                lblExternalVersion.setText(NbBundle.getMessage(SettingsPanel.class, "LBL_ExMavenVersion2", ver));
206
                valid = true;
307
                valid = true;
308
207
            } else {
309
            } else {
208
                valid = false;
310
                lblExternalVersion.setText(NbBundle.getMessage(SettingsPanel.class, "ERR_NoValidInstallation"));
209
            }
311
            }
210
        } else {
211
            valid = true;
212
        }
312
        }
313
314
        mavenRuntimeHome = path;
213
        if (oldvalid != valid) {
315
        if (oldvalid != valid) {
214
            controller.firePropChange(MavenOptionController.PROP_VALID, Boolean.valueOf(oldvalid), Boolean.valueOf(valid));
316
            controller.firePropChange(MavenOptionController.PROP_VALID, Boolean.valueOf(oldvalid), Boolean.valueOf(valid));
215
        }
317
        }
216
        initExternalVersion();
217
    }
318
    }
218
    
319
219
    private ComboBoxModel createComboModel() {
320
    private ComboBoxModel createComboModel() {
220
        return new DefaultComboBoxModel(
321
        return new DefaultComboBoxModel(
221
                new String[] { 
322
                new String[] { 
Lines 238-253 Link Here
238
        bgPlugins = new javax.swing.ButtonGroup();
339
        bgPlugins = new javax.swing.ButtonGroup();
239
        bgFailure = new javax.swing.ButtonGroup();
340
        bgFailure = new javax.swing.ButtonGroup();
240
        lblCommandLine = new javax.swing.JLabel();
341
        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();
342
        lblExternalVersion = new javax.swing.JLabel();
245
        lblOptions = new javax.swing.JLabel();
343
        lblOptions = new javax.swing.JLabel();
246
        txtOptions = new javax.swing.JTextField();
344
        txtOptions = new javax.swing.JTextField();
247
        btnOptions = new javax.swing.JButton();
345
        btnOptions = new javax.swing.JButton();
248
        cbSkipTests = new javax.swing.JCheckBox();
346
        cbSkipTests = new javax.swing.JCheckBox();
249
        lblLocalRepository = new javax.swing.JLabel();
347
        lblLocalRepository = new javax.swing.JLabel();
250
        txtLocalRepository = new MyJTextField();
348
        txtLocalRepository = new org.netbeans.modules.maven.options.JHintedTextField();
251
        btnLocalRepository = new javax.swing.JButton();
349
        btnLocalRepository = new javax.swing.JButton();
252
        lblBinaries = new javax.swing.JLabel();
350
        lblBinaries = new javax.swing.JLabel();
253
        comBinaries = new javax.swing.JComboBox();
351
        comBinaries = new javax.swing.JComboBox();
Lines 262-284 Link Here
262
        comIndex = new javax.swing.JComboBox();
360
        comIndex = new javax.swing.JComboBox();
263
        btnIndex = new javax.swing.JButton();
361
        btnIndex = new javax.swing.JButton();
264
        cbSnapshots = new javax.swing.JCheckBox();
362
        cbSnapshots = new javax.swing.JCheckBox();
363
        comMavenHome = new javax.swing.JComboBox();
265
364
266
        org.openide.awt.Mnemonics.setLocalizedText(lblCommandLine, org.openide.util.NbBundle.getMessage(SettingsPanel.class, "SettingsPanel.lblCommandLine.text")); // NOI18N
365
        org.openide.awt.Mnemonics.setLocalizedText(lblCommandLine, org.openide.util.NbBundle.getMessage(SettingsPanel.class, "SettingsPanel.lblCommandLine.text")); // NOI18N
267
366
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
367
        org.openide.awt.Mnemonics.setLocalizedText(lblOptions, org.openide.util.NbBundle.getMessage(SettingsPanel.class, "SettingsPanel.lblOptions.text")); // NOI18N
283
368
284
        org.openide.awt.Mnemonics.setLocalizedText(btnOptions, org.openide.util.NbBundle.getMessage(SettingsPanel.class, "SettingsPanel.btnOptions.text")); // NOI18N
369
        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))
432
                            .add(lblLocalRepository))
348
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
433
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
349
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
434
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
350
                            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
435
                            .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()
436
                            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
358
                                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
437
                                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
359
                                    .add(comSource, 0, 387, Short.MAX_VALUE)
438
                                    .add(comSource, 0, 404, Short.MAX_VALUE)
360
                                    .add(comJavadoc, 0, 387, Short.MAX_VALUE)
439
                                    .add(comJavadoc, 0, 404, Short.MAX_VALUE)
361
                                    .add(comBinaries, 0, 387, Short.MAX_VALUE)
440
                                    .add(comBinaries, 0, 404, Short.MAX_VALUE)
362
                                    .add(txtLocalRepository, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 387, Short.MAX_VALUE)
441
                                    .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))
442
                                    .add(txtOptions, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 404, Short.MAX_VALUE))
364
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
443
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
365
                                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
444
                                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
366
                                    .add(btnLocalRepository)
445
                                    .add(btnLocalRepository)
367
                                    .add(btnOptions)))
446
                                    .add(btnOptions)))
368
                            .add(cbSkipTests)))
447
                            .add(cbSkipTests)
448
                            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
449
                                .add(comMavenHome, 0, 402, Short.MAX_VALUE)
450
                                .add(122, 122, 122))))
369
                    .add(jLabel1)
451
                    .add(jLabel1)
370
                    .add(layout.createSequentialGroup()
452
                    .add(layout.createSequentialGroup()
371
                        .add(12, 12, 12)
453
                        .add(12, 12, 12)
Lines 381-393 Link Here
381
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
463
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
382
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
464
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
383
                            .add(cbSnapshots)
465
                            .add(cbSnapshots)
384
                            .add(comIndex, 0, 396, Short.MAX_VALUE))
466
                            .add(comIndex, 0, 421, Short.MAX_VALUE))
385
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
467
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
386
                        .add(btnIndex)))
468
                        .add(btnIndex)))
387
                .addContainerGap())
469
                .addContainerGap())
388
        );
470
        );
389
471
390
        layout.linkSize(new java.awt.Component[] {btnCommandLine, btnIndex, btnLocalRepository, btnOptions}, org.jdesktop.layout.GroupLayout.HORIZONTAL);
472
        layout.linkSize(new java.awt.Component[] {btnIndex, btnLocalRepository, btnOptions}, org.jdesktop.layout.GroupLayout.HORIZONTAL);
391
473
392
        layout.setVerticalGroup(
474
        layout.setVerticalGroup(
393
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
475
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
Lines 395-403 Link Here
395
                .add(6, 6, 6)
477
                .add(6, 6, 6)
396
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
478
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
397
                    .add(lblCommandLine)
479
                    .add(lblCommandLine)
398
                    .add(txtCommandLine, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
480
                    .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)
481
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
402
                .add(lblExternalVersion, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 14, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
482
                .add(lblExternalVersion, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 14, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
403
                .add(18, 18, 18)
483
                .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))
517
                    .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)
518
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
439
                .add(cbSnapshots)
519
                .add(cbSnapshots)
440
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
520
                .addContainerGap(23, Short.MAX_VALUE))
441
        );
521
        );
442
    }// </editor-fold>//GEN-END:initComponents
522
    }// </editor-fold>//GEN-END:initComponents
443
523
Lines 465-471 Link Here
465
        chooser.setDialogTitle(NbBundle.getMessage(SettingsPanel.class, "TIT_Select"));
545
        chooser.setDialogTitle(NbBundle.getMessage(SettingsPanel.class, "TIT_Select"));
466
        chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
546
        chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
467
        chooser.setFileHidingEnabled(false);
547
        chooser.setFileHidingEnabled(false);
468
        String path = ((MyJTextField)txtLocalRepository).getRealText();
548
        String path = ((JHintedTextField)txtLocalRepository).getRealText();
469
        if (path.trim().length() == 0) {
549
        if (path.trim().length() == 0) {
470
            path = new File(System.getProperty("user.home"), ".m2").getAbsolutePath(); //NOI18N
550
            path = new File(System.getProperty("user.home"), ".m2").getAbsolutePath(); //NOI18N
471
        }
551
        }
Lines 477-509 Link Here
477
        }
557
        }
478
        if (JFileChooser.APPROVE_OPTION == chooser.showOpenDialog(this)) {
558
        if (JFileChooser.APPROVE_OPTION == chooser.showOpenDialog(this)) {
479
            File projectDir = chooser.getSelectedFile();
559
            File projectDir = chooser.getSelectedFile();
480
            ((MyJTextField)txtLocalRepository).setRealText(FileUtil.normalizeFile(projectDir).getAbsolutePath());
560
            ((JHintedTextField)txtLocalRepository).setRealText(FileUtil.normalizeFile(projectDir).getAbsolutePath());
481
        }
561
        }
482
    }//GEN-LAST:event_btnLocalRepositoryActionPerformed
562
    }//GEN-LAST:event_btnLocalRepositoryActionPerformed
483
563
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
564
    private void btnGoalsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGoalsActionPerformed
508
        NbGlobalActionGoalProvider provider = null;
565
        NbGlobalActionGoalProvider provider = null;
509
        for (MavenActionsProvider prov : Lookup.getDefault().lookupAll(MavenActionsProvider.class)) {
566
        for (MavenActionsProvider prov : Lookup.getDefault().lookupAll(MavenActionsProvider.class)) {
Lines 538-555 Link Here
538
        }
595
        }
539
596
540
    }//GEN-LAST:event_btnOptionsActionPerformed
597
    }//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
    
598
    
546
    
599
    
547
    // Variables declaration - do not modify//GEN-BEGIN:variables
600
    // Variables declaration - do not modify//GEN-BEGIN:variables
548
    private javax.swing.ButtonGroup bgChecksums;
601
    private javax.swing.ButtonGroup bgChecksums;
549
    private javax.swing.ButtonGroup bgFailure;
602
    private javax.swing.ButtonGroup bgFailure;
550
    private javax.swing.ButtonGroup bgPlugins;
603
    private javax.swing.ButtonGroup bgPlugins;
551
    private javax.swing.JButton btnCommandLine;
552
    private javax.swing.JButton btnDefault;
553
    private javax.swing.JButton btnGoals;
604
    private javax.swing.JButton btnGoals;
554
    private javax.swing.JButton btnIndex;
605
    private javax.swing.JButton btnIndex;
555
    private javax.swing.JButton btnLocalRepository;
606
    private javax.swing.JButton btnLocalRepository;
Lines 559-564 Link Here
559
    private javax.swing.JComboBox comBinaries;
610
    private javax.swing.JComboBox comBinaries;
560
    private javax.swing.JComboBox comIndex;
611
    private javax.swing.JComboBox comIndex;
561
    private javax.swing.JComboBox comJavadoc;
612
    private javax.swing.JComboBox comJavadoc;
613
    private javax.swing.JComboBox comMavenHome;
562
    private javax.swing.JComboBox comSource;
614
    private javax.swing.JComboBox comSource;
563
    private javax.swing.JLabel jLabel1;
615
    private javax.swing.JLabel jLabel1;
564
    private javax.swing.JLabel jLabel3;
616
    private javax.swing.JLabel jLabel3;
Lines 570-592 Link Here
570
    private javax.swing.JLabel lblLocalRepository;
622
    private javax.swing.JLabel lblLocalRepository;
571
    private javax.swing.JLabel lblOptions;
623
    private javax.swing.JLabel lblOptions;
572
    private javax.swing.JLabel lblSource;
624
    private javax.swing.JLabel lblSource;
573
    private javax.swing.JTextField txtCommandLine;
574
    private javax.swing.JTextField txtLocalRepository;
625
    private javax.swing.JTextField txtLocalRepository;
575
    private javax.swing.JTextField txtOptions;
626
    private javax.swing.JTextField txtOptions;
576
    // End of variables declaration//GEN-END:variables
627
    // End of variables declaration//GEN-END:variables
577
    
628
    
629
    private void browseAddNewRuntime() {
630
        JFileChooser chooser = new JFileChooser();
631
        FileUtil.preventFileChooserSymlinkTraversal(chooser, null);
632
        chooser.setDialogTitle(org.openide.util.NbBundle.getMessage(SettingsPanel.class, "TIT_Select2"));
633
        chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
634
        chooser.setFileHidingEnabled(false);
635
        int selected = comMavenHome.getSelectedIndex();
636
        String path = getSelectedRuntime(selected);
637
        if (path == null || path.trim().length() == 0) {
638
            path = new File(System.getProperty("user.home")).getAbsolutePath(); //NOI18N
639
        }
640
        if (path.length() > 0) {
641
            File f = new File(path);
642
            if (f.exists()) {
643
                chooser.setSelectedFile(f);
644
            }
645
        }
646
        if (JFileChooser.APPROVE_OPTION == chooser.showOpenDialog(this)) {
647
            File projectDir = chooser.getSelectedFile();
648
            String newRuntimePath = FileUtil.normalizeFile(projectDir).getAbsolutePath();
649
            boolean existed = false;
650
            List<String> runtimes = new ArrayList<String>();
651
            runtimes.addAll(predefinedRuntimes);
652
            runtimes.addAll(userDefinedMavenRuntimes);
653
            for (String runtime : runtimes) {
654
                if (runtime.equals(newRuntimePath)) {
655
                    existed = true;
656
                }
657
            }
658
            if (!existed) {
659
                // do not add duplicated directory
660
                if (userDefinedMavenRuntimes.isEmpty()) {
661
                    mavenHomeDataModel.insertElementAt(SEPARATOR, predefinedRuntimes.size());
662
                }
663
                userDefinedMavenRuntimes.add(newRuntimePath);
664
                mavenHomeDataModel.insertElementAt(newRuntimePath, runtimes.size() + 1);
665
            }
666
            comMavenHome.setSelectedItem(newRuntimePath);
667
        }
668
    }
669
    
578
    public void setValues() {
670
    public void setValues() {
579
        txtOptions.setText(MavenSettings.getDefault().getDefaultOptions());
671
        txtOptions.setText(MavenSettings.getDefault().getDefaultOptions());
580
        txtCommandLine.getDocument().removeDocumentListener(docList);
672
673
        predefinedRuntimes.clear();
674
        predefinedRuntimes.add("");
675
        predefinedRuntimes.add(MavenSettings.getDefaultExternalMavenRuntime());
676
        userDefinedMavenRuntimes.clear();
677
        userDefinedMavenRuntimes.addAll(MavenSettings.getDefault().getUserDefinedMavenRuntimes());
678
        comMavenHome.removeActionListener(listItemChangedListener);
679
        mavenHomeDataModel.removeAllElements();
581
        File command = MavenSettings.getDefault().getMavenHome();
680
        File command = MavenSettings.getDefault().getMavenHome();
582
        txtCommandLine.setText(command != null ? command.getAbsolutePath() : ""); //NOI18N
681
        String embedded = null;
583
        initExternalVersion();
682
        for (String runtime : predefinedRuntimes) {
584
        txtCommandLine.getDocument().addDocumentListener(docList);
683
            boolean embeddedRuntime = "".equals(runtime);
684
            String desc = org.openide.util.NbBundle.getMessage(SettingsPanel.class,
685
                    embeddedRuntime ? "MAVEN_RUNTIME_Embedded" : "MAVEN_RUNTIME_External",
686
                    new Object[]{runtime,
687
                    embeddedRuntime ? EMBEDDED_RUNTIME_VERSION : MavenSettings.getCommandLineMavenVersion(new File(runtime))}); // NOI18N
688
            mavenHomeDataModel.addElement(desc);
689
        }
690
        
691
        if (!userDefinedMavenRuntimes.isEmpty()) {
692
            mavenHomeDataModel.addElement(SEPARATOR);
693
            for (String runtime : userDefinedMavenRuntimes) {
694
                String desc = org.openide.util.NbBundle.getMessage(SettingsPanel.class,
695
                        "MAVEN_RUNTIME_External",
696
                        new Object[]{runtime, MavenSettings.getCommandLineMavenVersion(new File(runtime))}); // NOI18N
697
                mavenHomeDataModel.addElement(desc);
698
            }
699
        }
700
        
701
        mavenHomeDataModel.addElement(SEPARATOR);
702
        mavenHomeDataModel.addElement(org.openide.util.NbBundle.getMessage(SettingsPanel.class,
703
                    "MAVEN_RUNTIME_Browse"));
704
        mavenHomeDataModel.addElement(org.openide.util.NbBundle.getMessage(SettingsPanel.class,
705
                    "MAVEN_RUNTIME_ClearUserDefines"));
706
        comMavenHome.setSelectedItem(command != null ? command.getAbsolutePath() : embedded); //NOI18N
707
        listDataChanged();
708
        lastSelected = comMavenHome.getSelectedIndex();
709
        comMavenHome.addActionListener(listItemChangedListener);
585
        
710
        
586
        cbSnapshots.setSelected(RepositoryPreferences.getInstance().isIncludeSnapshots());
711
        cbSnapshots.setSelected(RepositoryPreferences.getInstance().isIncludeSnapshots());
587
        comIndex.setSelectedIndex(RepositoryPreferences.getInstance().getIndexUpdateFrequency());
712
        comIndex.setSelectedIndex(RepositoryPreferences.getInstance().getIndexUpdateFrequency());
588
        String repo = MavenSettings.getDefault().getCustomLocalRepository();
713
        String repo = MavenSettings.getDefault().getCustomLocalRepository();
589
        ((MyJTextField)txtLocalRepository).setRealText(repo != null ? repo : "");
714
        ((JHintedTextField)txtLocalRepository).setRealText(repo != null ? repo : "");
590
        comBinaries.setSelectedItem(MavenSettings.getDefault().getBinaryDownloadStrategy());
715
        comBinaries.setSelectedItem(MavenSettings.getDefault().getBinaryDownloadStrategy());
591
        comJavadoc.setSelectedItem(MavenSettings.getDefault().getJavadocDownloadStrategy());
716
        comJavadoc.setSelectedItem(MavenSettings.getDefault().getJavadocDownloadStrategy());
592
        comSource.setSelectedItem(MavenSettings.getDefault().getSourceDownloadStrategy());
717
        comSource.setSelectedItem(MavenSettings.getDefault().getSourceDownloadStrategy());
Lines 596-606 Link Here
596
    }
721
    }
597
    
722
    
598
    public void applyValues() {
723
    public void applyValues() {
599
        MavenSettings.getDefault().setDefaultOptions(txtOptions.getText().trim());
724
        MavenSettings.getDefault().setCustomLocalRepository(((JHintedTextField)txtLocalRepository).getRealText());
600
        MavenSettings.getDefault().setCustomLocalRepository(((MyJTextField)txtLocalRepository).getRealText());
725
        // remember only user-defined runtimes of RUNTIME_COUNT_LIMIT count at the most
601
        String cl = txtCommandLine.getText().trim();
726
        List<String> runtimes = new ArrayList<String>();
727
        for (int i = 0; i < userDefinedMavenRuntimes.size() && i < RUNTIME_COUNT_LIMIT; ++i) {
728
            runtimes.add(0, userDefinedMavenRuntimes.get(userDefinedMavenRuntimes.size() - 1 - i));
729
        }
730
        int selected = comMavenHome.getSelectedIndex() - predefinedRuntimes.size() - 1;
731
        if (runtimes.size() == RUNTIME_COUNT_LIMIT && userDefinedMavenRuntimes.size() - RUNTIME_COUNT_LIMIT > selected) {
732
            runtimes.set(0, userDefinedMavenRuntimes.get(selected));
733
        }
734
        if (predefinedRuntimes.size() > 1) {
735
            runtimes.add(0, predefinedRuntimes.get(1));
736
        }
737
        MavenSettings.getDefault().setMavenRuntimes(runtimes);
738
        String cl = mavenRuntimeHome;
739
        if (cl != null && cl.length() == 0) {
740
            cl = null;
741
        }
602
        //MEVENIDE-553
742
        //MEVENIDE-553
603
        File command = cl.isEmpty() ? null : new File(cl);
743
        File command = (cl == null || cl.isEmpty()) ? null : new File(cl);
604
        if (command != null && command.isDirectory()) {
744
        if (command != null && command.isDirectory()) {
605
            MavenSettings.getDefault().setMavenHome(command);
745
            MavenSettings.getDefault().setMavenHome(command);
606
        } else {
746
        } else {

Return to bug 183455