# HG changeset patch
# Parent c190a715f91e847a7e19a18b237f1652ace0f18c
Multiple Maven Runtimes support.
diff --git a/maven/src/org/netbeans/modules/maven/options/Bundle.properties b/maven/src/org/netbeans/modules/maven/options/Bundle.properties
--- a/maven/src/org/netbeans/modules/maven/options/Bundle.properties
+++ b/maven/src/org/netbeans/modules/maven/options/Bundle.properties
@@ -40,25 +40,19 @@
TIP_Maven_Category=Setting up of default Maven execution options.
SettingsPanel.btnIndex.text=Index &Now
-SettingsPanel.lblLocalRepository.text=&Local Repository \:
+SettingsPanel.lblLocalRepository.text=&Local Repository:
SettingsPanel.btnLocalRepository.text=&Browse...
SettingsPanel.lblIndex.text=&Index Update Frequency\:
SettingsPanel.cbSnapshots.text=Include &Snapshots In Local Index
TIT_Select=Select Local Repository Location
-SettingsPanel.lblCommandLine.text=External &Maven Home :
TIT_Select2=Select Maven2 Installation Location
-
-SettingsPanel.txtCommandLine.text=
-SettingsPanel.btnCommandLine.text=&Browse...
-SettingsPanel.btnGoals.text=Edit &Global Custom Goal Definitions...
+SettingsPanel.btnGoals.text=Edit
TIT_Global=Global Maven Goal definitions
ACSD_Global=Global Maven Goal definitions
-SettingsPanel.lblEmbeddedVersion.text=
LBL_MavenVersion1=(Embedded Maven version: {0} built on {1})
LBL_MavenVersion2=(Embedded Maven version: {0})
LBL_MavenVersion3=Cannot figure version of embedded Maven
-SettingsPanel.lblExternalVersion.text=
LBL_ExMavenVersion1=(Version: {0} built on {1})
LBL_ExMavenVersion2=(Version: {0})
LBL_ExMavenVersion3=Using Default Maven Version: {0} (as found on PATH)
@@ -68,14 +62,13 @@
FREQ_Always=On every startup
FREQ_Never=Never
ERR_Wrong_Settings_file=Cannot parse the ~/.m2/settings.xml file, any options related to that file will be disabled.
-SettingsPanel.lblOptions.text=Global Execution &Options :
-SettingsPanel.btnOptions.text=&Add
+SettingsPanel.lblOptions.text=Global Execution &Options:
GlobalOptionsPanel.lblOptions.text=&Global Execution Options :
-SettingsPanel.lblBinaries.text=&Download Binaries :
+SettingsPanel.lblBinaries.text=&Download Binaries:
SettingsPanel.jLabel3.text=Please note that setting any of these to values other than "Never" can make opening projects significantly slower.
On_Project_Open=On Project Open
-SettingsPanel.lblSource.text=Check &Sources :
-SettingsPanel.lblJavadoc.text=Check &Javadoc :
+SettingsPanel.lblSource.text=Check &Sources:
+SettingsPanel.lblJavadoc.text=Check &Javadoc:
txt_default_repository=
+ * Only the first appereance will be appended.
+ *
+ * @param mavenRuntimes a list to store all Maven Runtime configurations.
+ */
+ private void initDefaultExternalVersion(List mavenRuntimes) {
+ String paths = System.getenv("PATH"); // NOI18N
+ String mavenHome = System.getenv("MAVEN_HOME"); // NOI18N
+ String m2Home = System.getenv("M2_HOME"); // NOI18N
+
+ List mavenEnvDirs = new ArrayList();
+ if (mavenHome != null) {
+ mavenEnvDirs.add(mavenHome);
+ }
+ if (m2Home != null) {
+ mavenEnvDirs.add(m2Home);
+ }
+ if (paths != null) {
+ for (String path : paths.split(File.pathSeparator)) {
+ if (!path.endsWith("bin")) { // NOI18N
+ continue;
+ }
+
+ mavenEnvDirs.add(path.substring(0,
+ path.length() - "bin".length() - File.pathSeparator.length()));
+ }
+ }
+
+ initExternalVersion(mavenRuntimes, mavenEnvDirs.toArray(new String[0]), true);
+ }
+
+ public MavenRuntime[] getMavenRuntimes() {
+ List runtimes = new ArrayList();
+
+ // Embedded
+ runtimes.add(new MavenRuntime("",
+ NbBundle.getMessage(SettingsPanel.class, "LBL_MavenVersion2", "3.0-SNAPSHOT")));
+
+ String runtimesPref = getPreferences().get(PROP_MAVEN_RUNTIMES, null);
+ if (runtimesPref != null) {
+ for (String runtimePath : runtimesPref.split(File.pathSeparator)) {
+ if (!"".equals(runtimePath)) {
+ String version = MavenUtil.getExternalVersion(runtimePath);
+ if (version != null) {
+ runtimes.add(new MavenRuntime(runtimePath, version));
+ }
+ }
+ }
+
+ } else {
+ // Try to find
+ initDefaultExternalVersion(runtimes);
+ }
+
+ return runtimes.toArray(new MavenRuntime[0]);
+ }
+
+ public void setMavenRuntimes(MavenRuntime[] runtimes) {
+ if (runtimes == null) {
+ getPreferences().remove(PROP_MAVEN_RUNTIMES);
+ } else {
+ String runtimesPref = "";
+ for (MavenRuntime runtime : runtimes) {
+ runtimesPref += runtime.getPath() + File.pathSeparator;
+ }
+ putProperty(PROP_MAVEN_RUNTIMES, runtimesPref);
+ }
+ }
}
diff --git a/maven/src/org/netbeans/modules/maven/options/SettingsPanel.form b/maven/src/org/netbeans/modules/maven/options/SettingsPanel.form
--- a/maven/src/org/netbeans/modules/maven/options/SettingsPanel.form
+++ b/maven/src/org/netbeans/modules/maven/options/SettingsPanel.form
@@ -24,160 +24,181 @@
-
-
+
+
-
+
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
-
+
+
-
-
-
-
-
+
-
+
-
+
-
+
-
+
-
+
-
-
-
-
-
-
-
+
-
+
-
-
-
-
-
-
-
@@ -185,18 +206,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
@@ -213,7 +222,7 @@
-
+
@@ -226,13 +235,6 @@
-
-
-
-
-
-
-
@@ -325,5 +327,88 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/maven/src/org/netbeans/modules/maven/options/SettingsPanel.java b/maven/src/org/netbeans/modules/maven/options/SettingsPanel.java
--- a/maven/src/org/netbeans/modules/maven/options/SettingsPanel.java
+++ b/maven/src/org/netbeans/modules/maven/options/SettingsPanel.java
@@ -43,25 +43,24 @@
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
-import java.io.FilenameFilter;
-import java.io.IOException;
-import java.io.InputStream;
import java.io.StringReader;
+import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Enumeration;
import java.util.List;
-import java.util.Properties;
-import java.util.jar.JarFile;
-import java.util.zip.ZipEntry;
import javax.swing.BorderFactory;
import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.DefaultListCellRenderer;
+import javax.swing.DefaultListModel;
import javax.swing.JFileChooser;
import javax.swing.JList;
+import javax.swing.JOptionPane;
import javax.swing.ListCellRenderer;
import javax.swing.SwingUtilities;
-import javax.swing.event.DocumentEvent;
-import javax.swing.event.DocumentListener;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.ListSelectionListener;
+import javax.swing.table.AbstractTableModel;
import org.netbeans.modules.maven.TextValueCompleter;
import org.netbeans.modules.maven.indexer.api.RepositoryIndexer;
import org.netbeans.modules.maven.indexer.api.RepositoryInfo;
@@ -92,10 +91,101 @@
private boolean changed;
private boolean valid;
private ActionListener listener;
- private DocumentListener docList;
private MavenOptionController controller;
private TextValueCompleter completer;
+ private File commandLinePath;
+ private List mavenRuntimes;
+ private AbstractTableModel tableModel = new AbstractTableModel() {
+ @Override
+ public int getRowCount() {
+ return mavenRuntimes.size();
+ }
+
+ @Override
+ public int getColumnCount() {
+ return 2;
+ }
+
+ @Override
+ public Class> getColumnClass(int columnIndex) {
+ if (columnIndex == 0) {
+ return Boolean.class;
+ } else {
+ return String.class;
+ }
+ }
+
+ @Override
+ public boolean isCellEditable(int rowIndex, int columnIndex) {
+ if (columnIndex == 0) {
+ MavenRuntime runtime = mavenRuntimes.get(rowIndex);
+ if (!runtime.isExternal() && commandLinePath == null) {
+ return false;
+ }
+
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
+ if (columnIndex == 0) {
+ MavenRuntime runtime = mavenRuntimes.get(rowIndex);
+ boolean newValue = (Boolean) aValue;
+ if (!runtime.isExternal()) {
+ if (commandLinePath != null) {
+ if (newValue) {
+ commandLinePath = null;
+ fireTableDataChanged();
+ }
+ }
+ if (newValue == false && commandLinePath != null) {
+ return;
+ }
+
+ commandLinePath = null;
+
+ } else {
+ commandLinePath = newValue ? new File(runtime.getPath()) : null;
+ fireTableDataChanged();
+ }
+
+ } else {
+ super.setValueAt(aValue, rowIndex, columnIndex);
+ }
+ }
+
+ @Override
+ public Object getValueAt(int rowIndex, int columnIndex) {
+ switch (columnIndex) {
+ case 0: {
+ MavenRuntime runtime = mavenRuntimes.get(rowIndex);
+ if (commandLinePath != null && commandLinePath.getAbsolutePath().equals(runtime.getPath())) {
+ return true;
+
+ } else if (commandLinePath == null && !runtime.isExternal()) {
+ return true;
+ }
+
+ return false;
+ }
+
+ case 1: {
+ MavenRuntime runtime = mavenRuntimes.get(rowIndex);
+ String key = runtime.isExternal() ? "MAVEN_RUNTIME_External" : "MAVEN_RUNTIME_Embedded";
+ return NbBundle.getMessage(SettingsPanel.class, key,
+ new Object[]{runtime.getPath(), runtime.getVersion()});
+ }
+ }
+
+ return null;
+ }
+ };
+
+ private DefaultListModel optionsModel = new DefaultListModel();
+
/** Creates new form SettingsPanel */
SettingsPanel(MavenOptionController controller) {
initComponents();
@@ -105,6 +195,44 @@
comJavadoc.setModel(new DefaultComboBoxModel(downloads));
comSource.setModel(new DefaultComboBoxModel(downloads));
+ mavenRuntimes = new ArrayList();
+ tblMavenRuntimes.setModel(tableModel);
+ tblMavenRuntimes.setTableHeader(null);
+ tblMavenRuntimes.getColumnModel().getColumn(0).setMaxWidth(20);
+ tblMavenRuntimes.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
+
+ @Override
+ public void valueChanged(ListSelectionEvent e) {
+ if (!e.getValueIsAdjusting()) {
+ int selected = tblMavenRuntimes.getSelectedRow();
+ if (selected != -1 && mavenRuntimes.get(selected).isExternal()) {
+ btnEditRuntime.setEnabled(true);
+ btnRemoveRuntime.setEnabled(true);
+ } else {
+ btnEditRuntime.setEnabled(false);
+ btnRemoveRuntime.setEnabled(false);
+ }
+ }
+ }
+
+ });
+
+ lstOptions.setModel(optionsModel);
+ lstOptions.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
+
+ @Override
+ public void valueChanged(ListSelectionEvent e) {
+ if (!e.getValueIsAdjusting()) {
+ if (optionsModel.getSize() > 0) {
+ btnRemoveOption.setEnabled(true);
+ } else {
+ btnRemoveOption.setEnabled(false);
+ }
+ }
+ }
+
+ });
+
ListCellRenderer rend = new DefaultListCellRenderer() {
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
@@ -124,24 +252,11 @@
comJavadoc.setRenderer(rend);
this.controller = controller;
- docList = new DocumentListener() {
- public void insertUpdate(DocumentEvent e) {
- documentChanged(e);
- }
- public void removeUpdate(DocumentEvent e) {
- documentChanged(e);
- }
- public void changedUpdate(DocumentEvent e) {
- documentChanged(e);
- }
- };
initValues();
- ((MyJTextField)txtLocalRepository).setHintText(org.openide.util.NbBundle.getMessage(SettingsPanel.class, "txt_default_repository"));
+ ((JHintTextField)txtLocalRepository).setHintText(org.openide.util.NbBundle.getMessage(SettingsPanel.class, "txt_default_repository"));
listener = new ActionListenerImpl();
cbSnapshots.addActionListener(listener);
comIndex.addActionListener(listener);
- completer = new TextValueCompleter(getGlobalOptions(), txtOptions, " "); //NOI18N
- initEmbeddedVersion();
}
static String[] AVAILABLE_OPTIONS = new String[] {
@@ -183,12 +298,10 @@
return Arrays.asList(AVAILABLE_OPTIONS);
}
- private void initEmbeddedVersion()
- {
+// private void initEmbeddedVersion() {
//there was a renumbering scheme for maven. current trunk is not 2.1 but 3.0
//http://blogs.sonatype.com/brian/2008/09/05/1220649145080.html
//XXX: just hardwire here to not confuse people with old style versions.
- lblEmbeddedVersion.setText(NbBundle.getMessage(SettingsPanel.class, "LBL_MavenVersion2", "3.0-SNAPSHOT")); //NOI18N
// InputStream resourceAsStream;
// try {
@@ -206,86 +319,13 @@
// catch ( IOException e ) {
// lblEmbeddedVersion.setText(NbBundle.getMessage(SettingsPanel.class, "LBL_MavenVersion3"));
// }
- }
+// }
- private void initExternalVersion()
- {
- String path = txtCommandLine.getText().trim();
- if (path.length() == 0) {
- String ver = MavenSettings.getDefaultMavenInstanceVersion();
- if (ver != null) {
- lblExternalVersion.setText(NbBundle.getMessage(SettingsPanel.class, "LBL_ExMavenVersion3", ver));//NOI18N
- } else {
- lblExternalVersion.setText(ver != null ? ver : ""); //NOI18N
- }
- return;
- }
- File root = new File(path);
- File lib = new File(root, "lib"); //NOI18N
- if (lib.exists()) {
- File[] jars = lib.listFiles(new FilenameFilter() {
- public boolean accept(File dir, String name) {
- return name.endsWith(".jar"); //NOI18N
- }
- });
- for (File jar : jars) {
- JarFile jf = null;
- try
- {
- jf = new JarFile(jar);
- ZipEntry entry = jf.getEntry("META-INF/maven/org.apache.maven/maven-core/pom.properties");//NOI18N
- if (entry != null) {
- InputStream resourceAsStream = jf.getInputStream(entry);
- Properties properties = new Properties();
- properties.load( resourceAsStream );
- if ( properties.getProperty( "builtOn" ) != null ) { //NOI18N
- lblExternalVersion.setText(NbBundle.getMessage(SettingsPanel.class, "LBL_ExMavenVersion1",
- properties.getProperty( "version", "unknown" ), properties.getProperty( "builtOn" )));//NOI18N
- } else {
- lblExternalVersion.setText(NbBundle.getMessage(SettingsPanel.class, "LBL_ExMavenVersion2", properties.getProperty( "version", "unknown" )));//NOI18N
- }
- return;
- }
- } catch ( IOException ex )
- {
- //ignore..
- } finally {
- if (jf != null) {
- try {
- jf.close();
- } catch (IOException x) {}
- }
- }
- }
- }
- //add red color..
- lblExternalVersion.setText(NbBundle.getMessage(SettingsPanel.class, "ERR_NoValidInstallation"));
- }
-
private void initValues() {
comIndex.setSelectedIndex(0);
cbSnapshots.setSelected(true);
}
- private void documentChanged(DocumentEvent e) {
- changed = true;
- boolean oldvalid = valid;
- if (txtCommandLine.getText().trim().length() > 0) {
- File fil = new File(txtCommandLine.getText());
- if (fil.exists() && new File(fil, "bin" + File.separator + "mvn").exists()) { //NOI18N
- valid = true;
- } else {
- valid = false;
- }
- } else {
- valid = true;
- }
- if (oldvalid != valid) {
- controller.firePropChange(MavenOptionController.PROP_VALID, Boolean.valueOf(oldvalid), Boolean.valueOf(valid));
- }
- initExternalVersion();
- }
-
private ComboBoxModel createComboModel() {
return new DefaultComboBoxModel(
new String[] {
@@ -307,18 +347,13 @@
bgChecksums = new javax.swing.ButtonGroup();
bgPlugins = new javax.swing.ButtonGroup();
bgFailure = new javax.swing.ButtonGroup();
- lblCommandLine = new javax.swing.JLabel();
- txtCommandLine = new javax.swing.JTextField();
- btnCommandLine = new javax.swing.JButton();
- lblExternalVersion = new javax.swing.JLabel();
+ lblMavenRuntimes = new javax.swing.JLabel();
+ btnRemoveRuntime = new javax.swing.JButton();
lblOptions = new javax.swing.JLabel();
- txtOptions = new javax.swing.JTextField();
- btnOptions = new javax.swing.JButton();
cbSkipTests = new javax.swing.JCheckBox();
lblLocalRepository = new javax.swing.JLabel();
- txtLocalRepository = new MyJTextField();
+ txtLocalRepository = new org.netbeans.modules.maven.options.JHintTextField();
btnLocalRepository = new javax.swing.JButton();
- lblEmbeddedVersion = new javax.swing.JLabel();
lblBinaries = new javax.swing.JLabel();
comBinaries = new javax.swing.JComboBox();
lblJavadoc = new javax.swing.JLabel();
@@ -332,29 +367,28 @@
comIndex = new javax.swing.JComboBox();
btnIndex = new javax.swing.JButton();
cbSnapshots = new javax.swing.JCheckBox();
+ btnAddRuntime = new javax.swing.JButton();
+ btnEditRuntime = new javax.swing.JButton();
+ jScrollPane1 = new javax.swing.JScrollPane();
+ tblMavenRuntimes = new javax.swing.JTable();
+ jScrollPane2 = new javax.swing.JScrollPane();
+ lstOptions = new javax.swing.JList();
+ jLabel2 = new javax.swing.JLabel();
+ btnAddOption = new javax.swing.JButton();
+ btnRemoveOption = new javax.swing.JButton();
- org.openide.awt.Mnemonics.setLocalizedText(lblCommandLine, org.openide.util.NbBundle.getMessage(SettingsPanel.class, "SettingsPanel.lblCommandLine.text")); // NOI18N
+ org.openide.awt.Mnemonics.setLocalizedText(lblMavenRuntimes, org.openide.util.NbBundle.getMessage(SettingsPanel.class, "SettingsPanel.lblMavenRuntimes.text")); // NOI18N
- txtCommandLine.setText(org.openide.util.NbBundle.getMessage(SettingsPanel.class, "SettingsPanel.txtCommandLine.text")); // NOI18N
-
- org.openide.awt.Mnemonics.setLocalizedText(btnCommandLine, org.openide.util.NbBundle.getMessage(SettingsPanel.class, "SettingsPanel.btnCommandLine.text")); // NOI18N
- btnCommandLine.addActionListener(new java.awt.event.ActionListener() {
+ org.openide.awt.Mnemonics.setLocalizedText(btnRemoveRuntime, org.openide.util.NbBundle.getMessage(SettingsPanel.class, "SettingsPanel.btnRemoveRuntime.text")); // NOI18N
+ btnRemoveRuntime.setEnabled(false);
+ btnRemoveRuntime.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
- btnCommandLineActionPerformed(evt);
+ btnRemoveRuntimeActionPerformed(evt);
}
});
- org.openide.awt.Mnemonics.setLocalizedText(lblExternalVersion, org.openide.util.NbBundle.getMessage(SettingsPanel.class, "SettingsPanel.lblExternalVersion.text", new Object[] {})); // NOI18N
-
org.openide.awt.Mnemonics.setLocalizedText(lblOptions, org.openide.util.NbBundle.getMessage(SettingsPanel.class, "SettingsPanel.lblOptions.text")); // NOI18N
- org.openide.awt.Mnemonics.setLocalizedText(btnOptions, org.openide.util.NbBundle.getMessage(SettingsPanel.class, "SettingsPanel.btnOptions.text")); // NOI18N
- btnOptions.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- btnOptionsActionPerformed(evt);
- }
- });
-
org.openide.awt.Mnemonics.setLocalizedText(cbSkipTests, org.openide.util.NbBundle.getMessage(SettingsPanel.class, "SettingsPanel.cbSkipTests.text")); // NOI18N
org.openide.awt.Mnemonics.setLocalizedText(lblLocalRepository, org.openide.util.NbBundle.getMessage(SettingsPanel.class, "SettingsPanel.lblLocalRepository.text")); // NOI18N
@@ -366,8 +400,6 @@
}
});
- org.openide.awt.Mnemonics.setLocalizedText(lblEmbeddedVersion, org.openide.util.NbBundle.getMessage(SettingsPanel.class, "SettingsPanel.lblEmbeddedVersion.text")); // NOI18N
-
lblBinaries.setLabelFor(comBinaries);
org.openide.awt.Mnemonics.setLocalizedText(lblBinaries, org.openide.util.NbBundle.getMessage(SettingsPanel.class, "SettingsPanel.lblBinaries.text")); // NOI18N
@@ -402,110 +434,177 @@
org.openide.awt.Mnemonics.setLocalizedText(cbSnapshots, org.openide.util.NbBundle.getMessage(SettingsPanel.class, "SettingsPanel.cbSnapshots.text")); // NOI18N
+ org.openide.awt.Mnemonics.setLocalizedText(btnAddRuntime, org.openide.util.NbBundle.getMessage(SettingsPanel.class, "SettingsPanel.btnAddRuntime.text")); // NOI18N
+ btnAddRuntime.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ btnAddRuntimeActionPerformed(evt);
+ }
+ });
+
+ org.openide.awt.Mnemonics.setLocalizedText(btnEditRuntime, org.openide.util.NbBundle.getMessage(SettingsPanel.class, "SettingsPanel.btnEditRuntime.text")); // NOI18N
+ btnEditRuntime.setEnabled(false);
+ btnEditRuntime.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ btnEditRuntimeActionPerformed(evt);
+ }
+ });
+
+ tblMavenRuntimes.setModel(new javax.swing.table.DefaultTableModel(
+ new Object [][] {
+ {},
+ {},
+ {},
+ {}
+ },
+ new String [] {
+
+ }
+ ));
+ tblMavenRuntimes.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_LAST_COLUMN);
+ tblMavenRuntimes.setShowVerticalLines(false);
+ jScrollPane1.setViewportView(tblMavenRuntimes);
+
+ jScrollPane2.setViewportView(lstOptions);
+
+ org.openide.awt.Mnemonics.setLocalizedText(jLabel2, org.openide.util.NbBundle.getMessage(SettingsPanel.class, "SettingsPanel.jLabel2.text")); // NOI18N
+
+ org.openide.awt.Mnemonics.setLocalizedText(btnAddOption, org.openide.util.NbBundle.getMessage(SettingsPanel.class, "SettingsPanel.btnAddOption.text")); // NOI18N
+ btnAddOption.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ btnAddOptionActionPerformed(evt);
+ }
+ });
+
+ org.openide.awt.Mnemonics.setLocalizedText(btnRemoveOption, org.openide.util.NbBundle.getMessage(SettingsPanel.class, "SettingsPanel.btnRemoveOption.text")); // NOI18N
+ btnRemoveOption.setEnabled(false);
+ btnRemoveOption.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ btnRemoveOptionActionPerformed(evt);
+ }
+ });
+
org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
- .add(layout.createSequentialGroup()
+ .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
.addContainerGap()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(jLabel1)
.add(layout.createSequentialGroup()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
- .add(lblCommandLine)
- .add(lblOptions)
- .add(lblLocalRepository))
+ .add(jLabel2)
+ .add(lblIndex))
+ .add(10, 10, 10)
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(layout.createSequentialGroup()
+ .add(2, 2, 2)
+ .add(comIndex, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 425, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(btnIndex, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 87, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
+ .add(cbSnapshots)
+ .add(btnGoals, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 57, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
+ .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
+ .add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()
+ .add(9, 9, 9)
+ .add(jLabel3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 578, Short.MAX_VALUE))
+ .add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()
+ .add(10, 10, 10)
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(lblBinaries)
+ .add(lblJavadoc)
+ .add(lblSource))
+ .add(36, 36, 36)
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
+ .add(org.jdesktop.layout.GroupLayout.TRAILING, comSource, 0, 427, Short.MAX_VALUE)
+ .add(org.jdesktop.layout.GroupLayout.TRAILING, comJavadoc, 0, 427, Short.MAX_VALUE)
+ .add(comBinaries, 0, 427, Short.MAX_VALUE)))
+ .add(layout.createSequentialGroup()
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(lblMavenRuntimes)
+ .add(lblOptions)
+ .add(lblLocalRepository))
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
+ .add(org.jdesktop.layout.GroupLayout.LEADING, jScrollPane2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 433, Short.MAX_VALUE)
+ .add(org.jdesktop.layout.GroupLayout.LEADING, cbSkipTests, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 433, Short.MAX_VALUE)
+ .add(org.jdesktop.layout.GroupLayout.LEADING, jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 433, Short.MAX_VALUE)
+ .add(txtLocalRepository, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 433, Short.MAX_VALUE))))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
- .add(lblEmbeddedVersion, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 470, Short.MAX_VALUE)
- .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
- .add(txtCommandLine, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 387, Short.MAX_VALUE)
- .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
- .add(btnCommandLine))
- .add(lblExternalVersion, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 470, Short.MAX_VALUE)
- .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
- .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
- .add(comSource, 0, 387, Short.MAX_VALUE)
- .add(comJavadoc, 0, 387, Short.MAX_VALUE)
- .add(comBinaries, 0, 387, Short.MAX_VALUE)
- .add(txtLocalRepository, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 387, Short.MAX_VALUE)
- .add(txtOptions, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 387, Short.MAX_VALUE))
- .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
- .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
- .add(btnLocalRepository)
- .add(btnOptions)))
- .add(cbSkipTests)))
- .add(jLabel1)
- .add(layout.createSequentialGroup()
- .add(12, 12, 12)
- .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
- .add(lblJavadoc)
- .add(lblBinaries)
- .add(lblSource)
- .add(jLabel3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 531, Short.MAX_VALUE))
- .add(106, 106, 106))
- .add(btnGoals)
- .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
- .add(lblIndex)
- .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
- .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
- .add(cbSnapshots)
- .add(comIndex, 0, 391, Short.MAX_VALUE))
- .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
- .add(btnIndex)))
+ .add(btnLocalRepository)
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
+ .add(org.jdesktop.layout.GroupLayout.LEADING, btnRemoveOption, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .add(org.jdesktop.layout.GroupLayout.LEADING, btnAddOption, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .add(org.jdesktop.layout.GroupLayout.LEADING, btnRemoveRuntime, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .add(org.jdesktop.layout.GroupLayout.LEADING, btnEditRuntime, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .add(org.jdesktop.layout.GroupLayout.LEADING, btnAddRuntime, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 85, Short.MAX_VALUE)))))
.addContainerGap())
);
-
- layout.linkSize(new java.awt.Component[] {btnCommandLine, btnIndex, btnLocalRepository, btnOptions}, org.jdesktop.layout.GroupLayout.HORIZONTAL);
-
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
- .add(lblEmbeddedVersion)
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(layout.createSequentialGroup()
+ .addContainerGap()
+ .add(lblMavenRuntimes))
+ .add(layout.createSequentialGroup()
+ .add(6, 6, 6)
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(layout.createSequentialGroup()
+ .add(btnAddRuntime)
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(btnEditRuntime)
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(btnRemoveRuntime))
+ .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 141, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
- .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
- .add(lblCommandLine)
- .add(txtCommandLine, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
- .add(btnCommandLine))
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(lblOptions)
+ .add(layout.createSequentialGroup()
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(layout.createSequentialGroup()
+ .add(jScrollPane2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 100, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(cbSkipTests))
+ .add(layout.createSequentialGroup()
+ .add(btnAddOption)
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(btnRemoveOption)))
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+ .add(txtLocalRepository, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+ .add(lblLocalRepository)
+ .add(btnLocalRepository))))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
- .add(lblExternalVersion, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 14, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
- .add(18, 18, 18)
- .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
- .add(lblOptions)
- .add(txtOptions, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
- .add(btnOptions))
- .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
- .add(cbSkipTests)
- .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
- .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
- .add(txtLocalRepository, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
- .add(btnLocalRepository)
- .add(lblLocalRepository))
- .add(16, 16, 16)
.add(jLabel1)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(lblBinaries)
.add(comBinaries, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
- .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(lblJavadoc)
.add(comJavadoc, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+ .add(comSource, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+ .add(lblSource))
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(jLabel3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 46, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
- .add(lblSource)
- .add(comSource, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
+ .add(btnGoals)
+ .add(jLabel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 19, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
- .add(jLabel3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 44, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
- .add(btnGoals)
- .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
- .add(btnIndex)
.add(lblIndex)
- .add(comIndex, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
+ .add(comIndex, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+ .add(btnIndex))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(cbSnapshots)
- .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+ .addContainerGap())
);
}// //GEN-END:initComponents
@@ -533,7 +632,7 @@
chooser.setDialogTitle(NbBundle.getMessage(SettingsPanel.class, "TIT_Select"));
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
chooser.setFileHidingEnabled(false);
- String path = ((MyJTextField)txtLocalRepository).getRealText();
+ String path = ((JHintTextField)txtLocalRepository).getRealText();
if (path.trim().length() == 0) {
path = new File(System.getProperty("user.home"), ".m2").getAbsolutePath(); //NOI18N
}
@@ -545,32 +644,17 @@
}
if (JFileChooser.APPROVE_OPTION == chooser.showOpenDialog(this)) {
File projectDir = chooser.getSelectedFile();
- ((MyJTextField)txtLocalRepository).setRealText(FileUtil.normalizeFile(projectDir).getAbsolutePath());
+ ((JHintTextField)txtLocalRepository).setRealText(FileUtil.normalizeFile(projectDir).getAbsolutePath());
}
}//GEN-LAST:event_btnLocalRepositoryActionPerformed
- private void btnCommandLineActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCommandLineActionPerformed
- JFileChooser chooser = new JFileChooser();
- FileUtil.preventFileChooserSymlinkTraversal(chooser, null);
- chooser.setDialogTitle(org.openide.util.NbBundle.getMessage(SettingsPanel.class, "TIT_Select2"));
- chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
- chooser.setFileHidingEnabled(false);
- String path = txtCommandLine.getText();
- if (path.trim().length() == 0) {
- path = new File(System.getProperty("user.home")).getAbsolutePath(); //NOI18N
- }
- if (path.length() > 0) {
- File f = new File(path);
- if (f.exists()) {
- chooser.setSelectedFile(f);
- }
- }
- if (JFileChooser.APPROVE_OPTION == chooser.showOpenDialog(this)) {
- File projectDir = chooser.getSelectedFile();
- txtCommandLine.setText(FileUtil.normalizeFile(projectDir).getAbsolutePath());
- }
-
- }//GEN-LAST:event_btnCommandLineActionPerformed
+ private void btnRemoveRuntimeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRemoveRuntimeActionPerformed
+ int selected = tblMavenRuntimes.getSelectedRow();
+ if (selected != -1 && selected < mavenRuntimes.size()) {
+ mavenRuntimes.remove(selected);
+ tableModel.fireTableDataChanged();
+ }
+ }//GEN-LAST:event_btnRemoveRuntimeActionPerformed
private void btnGoalsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGoalsActionPerformed
NbGlobalActionGoalProvider provider = null;
@@ -597,26 +681,121 @@
}
}//GEN-LAST:event_btnGoalsActionPerformed
- private void btnOptionsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOptionsActionPerformed
+ private boolean tryEditMavenRuntime(String path, MavenRuntime mavenRuntime) {
+ if (path == null || path.length() == 0) {
+ path = new File(System.getProperty("user.home")).getAbsolutePath(); //NOI18N
+ }
+ JFileChooser chooser = new JFileChooser();
+ FileUtil.preventFileChooserSymlinkTraversal(chooser, null);
+ chooser.setDialogTitle(NbBundle.getMessage(SettingsPanel.class, "TIT_Select2"));
+ chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
+ chooser.setFileHidingEnabled(false);
+ if (path.length() > 0) {
+ File f = new File(path);
+ if (f.exists()) {
+ chooser.setSelectedFile(f);
+ }
+ }
+ if (JFileChooser.APPROVE_OPTION == chooser.showOpenDialog(this)) {
+ File projectDir = chooser.getSelectedFile();
+ path = FileUtil.normalizeFile(projectDir).getAbsolutePath();
+ String version = MavenUtil.getExternalVersion(path);
+ if (version == null) {
+ JOptionPane.showMessageDialog(this,
+ NbBundle.getMessage(SettingsPanel.class, "MAVEN_RUNTIME_Error_DuplicatedRuntime_Message", new Object[]{path}),
+ NbBundle.getMessage(SettingsPanel.class, "MAVEN_RUNTIME_ErrorCaption"),
+ JOptionPane.ERROR_MESSAGE);
+ return false;
+ }
+
+ for (MavenRuntime runtime : mavenRuntimes) {
+ if (runtime.isExternal() && runtime.getPath().equals(path)) {
+ JOptionPane.showMessageDialog(this,
+ NbBundle.getMessage(SettingsPanel.class, "MAVEN_RUNTIME_Error_AlreadyRegistered_Message", new Object[]{path}),
+ NbBundle.getMessage(SettingsPanel.class, "MAVEN_RUNTIME_ErrorCaption"),
+ JOptionPane.ERROR_MESSAGE);
+ return false;
+ }
+ }
+
+ mavenRuntime.setPath(path);
+ mavenRuntime.setVersion(version);
+ return true;
+ }
+
+ return false;
+ }
+
+ private void btnAddRuntimeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAddRuntimeActionPerformed
+ int selected = tblMavenRuntimes.getSelectedRow();
+ String path = null;
+ if (selected != -1) {
+ path = mavenRuntimes.get(selected).getPath();
+ }
+
+ MavenRuntime newRuntime = new MavenRuntime("", "");
+ if (tryEditMavenRuntime(path, newRuntime)) {
+ mavenRuntimes.add(newRuntime);
+ tableModel.fireTableDataChanged();
+ }
+ }//GEN-LAST:event_btnAddRuntimeActionPerformed
+
+ private void btnEditRuntimeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEditRuntimeActionPerformed
+ int selected = tblMavenRuntimes.getSelectedRow();
+ if (selected == -1) {
+ return;
+ }
+
+ MavenRuntime runtime = mavenRuntimes.get(selected);
+ if (tryEditMavenRuntime(runtime.getPath(), runtime)) {
+ tableModel.fireTableDataChanged();
+ }
+
+ }//GEN-LAST:event_btnEditRuntimeActionPerformed
+
+ private void btnAddOptionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAddOptionActionPerformed
GlobalOptionsPanel pnl = new GlobalOptionsPanel();
DialogDescriptor dd = new DialogDescriptor(pnl, org.openide.util.NbBundle.getMessage(SettingsPanel.class, "TIT_Add_Globals"));
Object ret = DialogDisplayer.getDefault().notify(dd);
if (ret == DialogDescriptor.OK_OPTION) {
- txtOptions.setText(txtOptions.getText() + pnl.getSelectedOnes());
+ String[] newOptions = pnl.getSelectedOnes();
+ int size = optionsModel.getSize();
+ for (String option : newOptions) {
+ if (optionsModel.contains(option)) {
+ continue;
+ }
+
+ optionsModel.addElement(option);
+ }
+ if (lstOptions.getSelectedIndex() == -1 && size != optionsModel.getSize()) {
+ lstOptions.setSelectedIndex(optionsModel.getSize() - 1);
+ }
}
+ }//GEN-LAST:event_btnAddOptionActionPerformed
- }//GEN-LAST:event_btnOptionsActionPerformed
+ private void btnRemoveOptionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRemoveOptionActionPerformed
+ int[] selectedIndices = lstOptions.getSelectedIndices();
+ for (int i = selectedIndices.length - 1; i >= 0; --i) {
+ optionsModel.remove(selectedIndices[i]);
+ }
+ int newSelected = selectedIndices.length > 0 && selectedIndices[0] < optionsModel.getSize() ?
+ selectedIndices[0] : optionsModel.getSize() - 1;
+ lstOptions.setSelectedIndex(newSelected);
+ }//GEN-LAST:event_btnRemoveOptionActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.ButtonGroup bgChecksums;
private javax.swing.ButtonGroup bgFailure;
private javax.swing.ButtonGroup bgPlugins;
- private javax.swing.JButton btnCommandLine;
+ private javax.swing.JButton btnAddOption;
+ private javax.swing.JButton btnAddRuntime;
+ private javax.swing.JButton btnEditRuntime;
private javax.swing.JButton btnGoals;
private javax.swing.JButton btnIndex;
private javax.swing.JButton btnLocalRepository;
- private javax.swing.JButton btnOptions;
+ private javax.swing.JButton btnRemoveOption;
+ private javax.swing.JButton btnRemoveRuntime;
private javax.swing.JCheckBox cbSkipTests;
private javax.swing.JCheckBox cbSnapshots;
private javax.swing.JComboBox comBinaries;
@@ -624,33 +803,43 @@
private javax.swing.JComboBox comJavadoc;
private javax.swing.JComboBox comSource;
private javax.swing.JLabel jLabel1;
+ private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
+ private javax.swing.JScrollPane jScrollPane1;
+ private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JLabel lblBinaries;
- private javax.swing.JLabel lblCommandLine;
- private javax.swing.JLabel lblEmbeddedVersion;
- private javax.swing.JLabel lblExternalVersion;
private javax.swing.JLabel lblIndex;
private javax.swing.JLabel lblJavadoc;
private javax.swing.JLabel lblLocalRepository;
+ private javax.swing.JLabel lblMavenRuntimes;
private javax.swing.JLabel lblOptions;
private javax.swing.JLabel lblSource;
- private javax.swing.JTextField txtCommandLine;
+ private javax.swing.JList lstOptions;
+ private javax.swing.JTable tblMavenRuntimes;
private javax.swing.JTextField txtLocalRepository;
- private javax.swing.JTextField txtOptions;
// End of variables declaration//GEN-END:variables
public void setValues() {
- txtOptions.setText(MavenSettings.getDefault().getDefaultOptions());
- txtCommandLine.getDocument().removeDocumentListener(docList);
- File command = MavenSettings.getDefault().getCommandLinePath();
- txtCommandLine.setText(command != null ? command.getAbsolutePath() : ""); //NOI18N
- initExternalVersion();
- txtCommandLine.getDocument().addDocumentListener(docList);
-
+ String defaultOptions = MavenSettings.getDefault().getDefaultOptions();
+ optionsModel.clear();
+ if (!"".equals(defaultOptions.trim())) { // NOI18N
+ String[] optionArr = MavenSettings.getDefault().getDefaultOptions().split(" "); // NOI18N
+ for (String option : optionArr) {
+ optionsModel.addElement(option);
+ }
+ }
+ lstOptions.setSelectedIndex(-1);
+
+ mavenRuntimes.clear();
+ MavenRuntime[] runtimes = MavenSettings.getDefault().getMavenRuntimes();
+ mavenRuntimes.addAll(Arrays.asList(runtimes));
+ tableModel.fireTableDataChanged();
+
+ commandLinePath = MavenSettings.getDefault().getCommandLinePath();
cbSnapshots.setSelected(RepositoryPreferences.getInstance().isIncludeSnapshots());
comIndex.setSelectedIndex(RepositoryPreferences.getInstance().getIndexUpdateFrequency());
String repo = MavenSettings.getDefault().getCustomLocalRepository();
- ((MyJTextField)txtLocalRepository).setRealText(repo != null ? repo : "");
+ ((JHintTextField)txtLocalRepository).setRealText(repo != null ? repo : "");
comBinaries.setSelectedItem(MavenSettings.getDefault().getBinaryDownloadStrategy());
comJavadoc.setSelectedItem(MavenSettings.getDefault().getJavadocDownloadStrategy());
comSource.setSelectedItem(MavenSettings.getDefault().getSourceDownloadStrategy());
@@ -660,16 +849,18 @@
}
public void applyValues() {
- MavenSettings.getDefault().setDefaultOptions(txtOptions.getText().trim());
- MavenSettings.getDefault().setCustomLocalRepository(((MyJTextField)txtLocalRepository).getRealText());
- String cl = txtCommandLine.getText().trim();
- if (cl.length() == 0) {
- cl = null;
- }
+ String options = "";
+ Enumeration optEnum = optionsModel.elements();
+ while(optEnum.hasMoreElements()) {
+ options += optEnum.nextElement() + " ";
+ }
+
+ MavenSettings.getDefault().setDefaultOptions(options.trim());
+ MavenSettings.getDefault().setCustomLocalRepository(((JHintTextField)txtLocalRepository).getRealText());
+ MavenSettings.getDefault().setMavenRuntimes(mavenRuntimes.toArray(new MavenRuntime[0]));
//MEVENIDE-553
- File command = cl != null ? new File(cl) : null;
- if (command != null && command.exists()) {
- MavenSettings.getDefault().setCommandLinePath(command);
+ if (commandLinePath != null && commandLinePath.exists()) {
+ MavenSettings.getDefault().setCommandLinePath(commandLinePath);
} else {
MavenSettings.getDefault().setCommandLinePath(null);
}