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 @@ -86,3 +86,7 @@ TIT_FIRST=First Project Open Only SettingsPanel.cbSkipTests.text=Skip &Tests for any build executions not directly related to testing KW_MavenOptions=Maven Version,Maven Options,Maven Repository Options +SettingsPanel.jLabel2.text=Appearance: +SettingsPanel.jLabel4.text=&Project node name: +SettingsPanel.txtProjectNodeNameCustomPattern.text= +SettingsPanel.txtProjectNodeNameCustomPattern.toolTipText=\nAll resolvable properties within pom.xml are supported as placeholders. Use the pattern ${property}\n

\nCommonly used patterns are\n

\n

diff --git a/maven/src/org/netbeans/modules/maven/options/MavenSettings.java b/maven/src/org/netbeans/modules/maven/options/MavenSettings.java --- a/maven/src/org/netbeans/modules/maven/options/MavenSettings.java +++ b/maven/src/org/netbeans/modules/maven/options/MavenSettings.java @@ -58,6 +58,7 @@ import org.apache.maven.execution.MavenExecutionRequest; import org.codehaus.plexus.util.cli.CommandLineUtils; import org.netbeans.api.annotations.common.CheckForNull; +import org.netbeans.modules.maven.api.Constants; import org.netbeans.modules.maven.embedder.EmbedderFactory; import org.openide.filesystems.FileObject; import org.openide.filesystems.FileUtil; @@ -78,6 +79,7 @@ private static final String PROP_LAST_ARCHETYPE_VERSION = "lastArchetypeVersion"; //NOI18N private static final String PROP_SKIP_TESTS = "skipTests"; //NOI18N private static final String PROP_MAVEN_RUNTIMES = "mavenRuntimes"; //NOI18N + private static final String PROP_PROJECTNODE_NAME_PATTERN = "project.displayName"; //NOI18N //these are from former versions (6.5) and are here only for conversion private static final String PROP_DEBUG = "showDebug"; // NOI18N @@ -260,6 +262,18 @@ putProperty(PROP_LAST_ARCHETYPE_VERSION, version); //NOI18N } + public void setProjectNodeNamePattern(String pattern) { + if (null == pattern) { + getPreferences().remove(PROP_PROJECTNODE_NAME_PATTERN); + } else { + putProperty(PROP_PROJECTNODE_NAME_PATTERN, pattern); + } + } + + public String getProjectNodeNamePattern() { + return getPreferences().get(PROP_PROJECTNODE_NAME_PATTERN, null); //NOI18N + } + public static enum DownloadStrategy { NEVER, FIRST_OPEN, 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 @@ -79,8 +79,22 @@ + + + + + + + + + + + + + + @@ -128,7 +142,16 @@ - + + + + + + + + + + @@ -264,5 +287,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 @@ -186,6 +186,7 @@ listener = new ActionListenerImpl(); comIndex.addActionListener(listener); completer = new TextValueCompleter(getGlobalOptions(), txtOptions, " "); //NOI18N + txtOptions.setVisible(false); } /** XXX update for M3 from {@link org.apache.maven.cli.CLIManager#CLIManager} */ @@ -322,6 +323,10 @@ lblIndex = new javax.swing.JLabel(); comIndex = new javax.swing.JComboBox(); btnIndex = new javax.swing.JButton(); + jLabel2 = new javax.swing.JLabel(); + jLabel4 = new javax.swing.JLabel(); + cbProjectNodeNameMode = new javax.swing.JComboBox(); + txtProjectNodeNameCustomPattern = new javax.swing.JTextField(); org.openide.awt.Mnemonics.setLocalizedText(lblCommandLine, org.openide.util.NbBundle.getMessage(SettingsPanel.class, "SettingsPanel.lblCommandLine.text")); // NOI18N @@ -368,6 +373,25 @@ } }); + org.openide.awt.Mnemonics.setLocalizedText(jLabel2, org.openide.util.NbBundle.getMessage(SettingsPanel.class, "SettingsPanel.jLabel2.text")); // NOI18N + + org.openide.awt.Mnemonics.setLocalizedText(jLabel4, org.openide.util.NbBundle.getMessage(SettingsPanel.class, "SettingsPanel.jLabel4.text")); // NOI18N + + cbProjectNodeNameMode.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Default", "${project.artifactId}", "${project.artifactId}-TRUNK", "${project.artifactId}-${project.version}", "${project.groupId}.${project.artifactId}", "${project.groupId}.${project.artifactId}-${project.version}", "Custom..." })); + cbProjectNodeNameMode.addItemListener(new java.awt.event.ItemListener() { + public void itemStateChanged(java.awt.event.ItemEvent evt) { + cbProjectNodeNameModeItemStateChanged(evt); + } + }); + cbProjectNodeNameMode.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + cbProjectNodeNameModeActionPerformed(evt); + } + }); + + txtProjectNodeNameCustomPattern.setText(org.openide.util.NbBundle.getMessage(SettingsPanel.class, "SettingsPanel.txtProjectNodeNameCustomPattern.text")); // NOI18N + txtProjectNodeNameCustomPattern.setToolTipText(org.openide.util.NbBundle.getMessage(SettingsPanel.class, "SettingsPanel.txtProjectNodeNameCustomPattern.toolTipText")); // NOI18N + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( @@ -419,7 +443,18 @@ .addGroup(layout.createSequentialGroup() .addComponent(cbSkipTests) .addGap(0, 0, Short.MAX_VALUE))) - .addContainerGap()))) + .addContainerGap()) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel2) + .addGap(0, 0, Short.MAX_VALUE)))) + .addGroup(layout.createSequentialGroup() + .addGap(30, 30, 30) + .addComponent(jLabel4) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(txtProjectNodeNameCustomPattern) + .addComponent(cbProjectNodeNameMode, 0, 1, Short.MAX_VALUE)) + .addContainerGap()) ); layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {btnIndex, btnOptions}); @@ -465,7 +500,15 @@ .addComponent(btnIndex) .addComponent(lblIndex) .addComponent(comIndex, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jLabel2) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel4) + .addComponent(cbProjectNodeNameMode, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(txtProjectNodeNameCustomPattern, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(29, Short.MAX_VALUE)) ); }// //GEN-END:initComponents @@ -515,12 +558,20 @@ } }//GEN-LAST:event_btnOptionsActionPerformed + + private void cbProjectNodeNameModeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbProjectNodeNameModeActionPerformed + txtProjectNodeNameCustomPattern.setVisible(cbProjectNodeNameMode.getSelectedIndex()==cbProjectNodeNameMode.getItemCount()-1); + }//GEN-LAST:event_cbProjectNodeNameModeActionPerformed + + private void cbProjectNodeNameModeItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cbProjectNodeNameModeItemStateChanged + }//GEN-LAST:event_cbProjectNodeNameModeItemStateChanged // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton btnGoals; private javax.swing.JButton btnIndex; private javax.swing.JButton btnOptions; + private javax.swing.JComboBox cbProjectNodeNameMode; private javax.swing.JCheckBox cbSkipTests; private javax.swing.JComboBox comBinaries; private javax.swing.JComboBox comIndex; @@ -528,7 +579,9 @@ private javax.swing.JComboBox comMavenHome; private javax.swing.JComboBox comSource; private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; + private javax.swing.JLabel jLabel4; private javax.swing.JLabel lblBinaries; private javax.swing.JLabel lblCommandLine; private javax.swing.JLabel lblExternalVersion; @@ -537,6 +590,7 @@ private javax.swing.JLabel lblOptions; private javax.swing.JLabel lblSource; private javax.swing.JTextField txtOptions; + private javax.swing.JTextField txtProjectNodeNameCustomPattern; // End of variables declaration//GEN-END:variables private void browseAddNewRuntime() { @@ -623,6 +677,33 @@ comSource.setSelectedItem(MavenSettings.getDefault().getSourceDownloadStrategy()); cbSkipTests.setSelected(MavenSettings.getDefault().isSkipTests()); + final String pattern = MavenSettings.getDefault().getProjectNodeNamePattern(); + txtProjectNodeNameCustomPattern.setText(""); + if (null == pattern || pattern.isEmpty()) { + //default + cbProjectNodeNameMode.setSelectedIndex(0); + } else { + //ignore the "default" entry + //ignore the "custom..." entry + final int start = 1; + final int end = cbProjectNodeNameMode.getItemCount() - 1; + + boolean foundPredefinedPattern = false; + for (int i = start; i < end; i++) { + final Object itemAt = cbProjectNodeNameMode.getItemAt(i); + if (pattern.equals(itemAt)) { + cbProjectNodeNameMode.setSelectedIndex(i); + foundPredefinedPattern = true; + break; + } + } + if (!foundPredefinedPattern) { + //set mode to custom + cbProjectNodeNameMode.setSelectedIndex(cbProjectNodeNameMode.getItemCount() - 1); + txtProjectNodeNameCustomPattern.setText(pattern); + } + } + changed = false; //#163955 - do not fire change events on load } @@ -656,6 +737,16 @@ MavenSettings.getDefault().setJavadocDownloadStrategy((MavenSettings.DownloadStrategy) comJavadoc.getSelectedItem()); MavenSettings.getDefault().setSourceDownloadStrategy((MavenSettings.DownloadStrategy) comSource.getSelectedItem()); MavenSettings.getDefault().setSkipTests(cbSkipTests.isSelected()); + if (0 == cbProjectNodeNameMode.getSelectedIndex()) { + //selected "default" entry + MavenSettings.getDefault().setProjectNodeNamePattern(null); + } else if (cbProjectNodeNameMode.getSelectedIndex() == cbProjectNodeNameMode.getItemCount() - 1) { + //selected "custom..." entry + MavenSettings.getDefault().setProjectNodeNamePattern(txtProjectNodeNameCustomPattern.getText()); + } else { + //a predefined pattern entry was selected + MavenSettings.getDefault().setProjectNodeNamePattern(cbProjectNodeNameMode.getSelectedItem().toString()); + } changed = false; }