mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-46477 (Need ability to feed custom properties into maven archetype when creating a new project)
This commit is contained in:
+2
-3
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
package org.jetbrains.idea.maven.execution;
|
||||
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
@@ -34,8 +33,8 @@ public class EditMavenPropertyDialog extends DialogWrapper {
|
||||
private JTextField myValueField;
|
||||
private final Map<String, String> myAvailableProperties;
|
||||
|
||||
public EditMavenPropertyDialog(Project p, Pair<String, String> value, Map<String, String> availableProperties) {
|
||||
super(p, false);
|
||||
public EditMavenPropertyDialog(Pair<String, String> value, Map<String, String> availableProperties) {
|
||||
super(false);
|
||||
setTitle("Edit Maven Property");
|
||||
|
||||
myAvailableProperties = availableProperties;
|
||||
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jetbrains.idea.maven.execution;
|
||||
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.ui.AddEditRemovePanel;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Sergey Evdokimov
|
||||
*/
|
||||
public class MavenPropertiesPanel extends AddEditRemovePanel<Pair<String, String>> {
|
||||
private Map<String, String> myAvailableProperties;
|
||||
|
||||
public MavenPropertiesPanel(Map<String, String> availableProperties) {
|
||||
super(new MyPropertiesTableModel(), new ArrayList<Pair<String, String>>(), null);
|
||||
setPreferredSize(new Dimension(100, 100));
|
||||
myAvailableProperties = availableProperties;
|
||||
}
|
||||
|
||||
protected Pair<String, String> addItem() {
|
||||
return doAddOrEdit(new Pair<String, String>("", ""));
|
||||
}
|
||||
|
||||
protected boolean removeItem(Pair<String, String> o) {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected Pair<String, String> editItem(Pair<String, String> o) {
|
||||
return doAddOrEdit(o);
|
||||
}
|
||||
|
||||
private Pair<String, String> doAddOrEdit(Pair<String, String> o) {
|
||||
EditMavenPropertyDialog d = new EditMavenPropertyDialog(o, myAvailableProperties);
|
||||
d.show();
|
||||
if (!d.isOK()) return null;
|
||||
return d.getValue();
|
||||
}
|
||||
|
||||
public Map<String, String> getDataAsMap() {
|
||||
Map<String, String> result = new LinkedHashMap<String, String>();
|
||||
for (Pair<String, String> p : getData()) {
|
||||
result.put(p.getFirst(), p.getSecond());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setDataFromMap(Map<String, String> map) {
|
||||
List<Pair<String, String>> result = new ArrayList<Pair<String, String>>();
|
||||
for (Map.Entry<String, String> e : map.entrySet()) {
|
||||
result.add(new Pair<String, String>(e.getKey(), e.getValue()));
|
||||
}
|
||||
setData(result);
|
||||
}
|
||||
|
||||
private static class MyPropertiesTableModel extends AddEditRemovePanel.TableModel<Pair<String, String>> {
|
||||
public int getColumnCount() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
public String getColumnName(int c) {
|
||||
return c == 0 ? "Name" : "Value";
|
||||
}
|
||||
|
||||
public Object getField(Pair<String, String> o, int c) {
|
||||
return c == 0 ? o.getFirst() : o.getSecond();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+8
-67
@@ -21,8 +21,6 @@ import com.intellij.openapi.options.Configurable;
|
||||
import com.intellij.openapi.options.ConfigurationException;
|
||||
import com.intellij.openapi.options.SearchableConfigurable;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.ui.AddEditRemovePanel;
|
||||
import com.intellij.ui.IdeBorderFactory;
|
||||
import com.intellij.ui.RawCommandLineEditor;
|
||||
import org.jetbrains.annotations.Nls;
|
||||
@@ -35,8 +33,9 @@ import org.jetbrains.idea.maven.utils.ComboBoxUtil;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
public abstract class MavenRunnerConfigurable implements SearchableConfigurable, Configurable.NoScroll {
|
||||
private final Project myProject;
|
||||
@@ -47,7 +46,7 @@ public abstract class MavenRunnerConfigurable implements SearchableConfigurable,
|
||||
private JComboBox myJdkCombo;
|
||||
private final DefaultComboBoxModel myJdkComboModel = new DefaultComboBoxModel();
|
||||
private JCheckBox mySkipTestsCheckBox;
|
||||
private MyPropertiesPanel myPropertiesPanel;
|
||||
private MavenPropertiesPanel myPropertiesPanel;
|
||||
|
||||
private Map<String, String> myProperties;
|
||||
|
||||
@@ -114,7 +113,9 @@ public abstract class MavenRunnerConfigurable implements SearchableConfigurable,
|
||||
|
||||
propertiesPanel.add(mySkipTestsCheckBox = new JCheckBox("Skip tests"), BorderLayout.NORTH);
|
||||
mySkipTestsCheckBox.setMnemonic('t');
|
||||
propertiesPanel.add(myPropertiesPanel = new MyPropertiesPanel(), BorderLayout.CENTER);
|
||||
|
||||
collectProperties();
|
||||
propertiesPanel.add(myPropertiesPanel = new MavenPropertiesPanel(myProperties), BorderLayout.CENTER);
|
||||
myPropertiesPanel.getEmptyText().setText("No properties defined");
|
||||
|
||||
c.gridx = 0;
|
||||
@@ -124,8 +125,6 @@ public abstract class MavenRunnerConfigurable implements SearchableConfigurable,
|
||||
c.fill = GridBagConstraints.BOTH;
|
||||
panel.add(propertiesPanel, c);
|
||||
|
||||
collectProperties();
|
||||
|
||||
return panel;
|
||||
}
|
||||
|
||||
@@ -135,9 +134,7 @@ public abstract class MavenRunnerConfigurable implements SearchableConfigurable,
|
||||
|
||||
for (MavenProject each : s.getProjects()) {
|
||||
Properties properties = each.getProperties();
|
||||
for (Map.Entry p : properties.entrySet()) {
|
||||
result.put((String)p.getKey(), (String)p.getValue());
|
||||
}
|
||||
result.putAll((Map)properties);
|
||||
}
|
||||
|
||||
myProperties = result;
|
||||
@@ -215,60 +212,4 @@ public abstract class MavenRunnerConfigurable implements SearchableConfigurable,
|
||||
|
||||
data.setMavenProperties(myPropertiesPanel.getDataAsMap());
|
||||
}
|
||||
|
||||
private class MyPropertiesPanel extends AddEditRemovePanel<Pair<String, String>> {
|
||||
public MyPropertiesPanel() {
|
||||
super(new MyPropertiesTableModel(), new ArrayList<Pair<String, String>>(), null);
|
||||
setPreferredSize(new Dimension(100, 100));
|
||||
}
|
||||
|
||||
protected Pair<String, String> addItem() {
|
||||
return doAddOrEdit(new Pair<String, String>("", ""));
|
||||
}
|
||||
|
||||
protected boolean removeItem(Pair<String, String> o) {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected Pair<String, String> editItem(Pair<String, String> o) {
|
||||
return doAddOrEdit(o);
|
||||
}
|
||||
|
||||
private Pair<String, String> doAddOrEdit(Pair<String, String> o) {
|
||||
EditMavenPropertyDialog d = new EditMavenPropertyDialog(myProject, o, myProperties);
|
||||
d.show();
|
||||
if (!d.isOK()) return null;
|
||||
return d.getValue();
|
||||
}
|
||||
|
||||
public Map<String, String> getDataAsMap() {
|
||||
Map<String, String> result = new LinkedHashMap<String, String>();
|
||||
for (Pair<String, String> p : getData()) {
|
||||
result.put(p.getFirst(), p.getSecond());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setDataFromMap(Map<String, String> map) {
|
||||
List<Pair<String, String>> result = new ArrayList<Pair<String, String>>();
|
||||
for (Map.Entry<String, String> e : map.entrySet()) {
|
||||
result.add(new Pair<String, String>(e.getKey(), e.getValue()));
|
||||
}
|
||||
setData(result);
|
||||
}
|
||||
}
|
||||
|
||||
private static class MyPropertiesTableModel extends AddEditRemovePanel.TableModel<Pair<String, String>> {
|
||||
public int getColumnCount() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
public String getColumnName(int c) {
|
||||
return c == 0 ? "Name" : "Value";
|
||||
}
|
||||
|
||||
public Object getField(Pair<String, String> o, int c) {
|
||||
return c == 0 ? o.getFirst() : o.getSecond();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -67,7 +67,7 @@ public class MavenFrameworkSupportProvider extends FrameworkSupportProvider {
|
||||
}
|
||||
else {
|
||||
new MavenModuleBuilderHelper(new MavenId("groupId", module.getName(), "1.0-SNAPSHOT"), null, null, false, false, null,
|
||||
"Add Maven Support").configure(model.getProject(), root, true);
|
||||
null, "Add Maven Support").configure(model.getProject(), root, true);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
+29
-2
@@ -33,6 +33,7 @@ import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.idea.maven.model.MavenArchetype;
|
||||
import org.jetbrains.idea.maven.model.MavenId;
|
||||
import org.jetbrains.idea.maven.project.MavenEnvironmentForm;
|
||||
import org.jetbrains.idea.maven.project.MavenProject;
|
||||
import org.jetbrains.idea.maven.project.MavenProjectsManager;
|
||||
import org.jetbrains.idea.maven.utils.MavenUtil;
|
||||
@@ -41,6 +42,7 @@ import javax.swing.*;
|
||||
import java.io.File;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class MavenModuleBuilder extends ModuleBuilder implements SourcePathsBuilder {
|
||||
private static final Icon BIG_ICON = IconLoader.getIcon("/modules/javaModule.png");
|
||||
@@ -54,6 +56,10 @@ public class MavenModuleBuilder extends ModuleBuilder implements SourcePathsBuil
|
||||
private MavenId myProjectId;
|
||||
private MavenArchetype myArchetype;
|
||||
|
||||
private MavenEnvironmentForm myEnvironmentForm;
|
||||
|
||||
private Map<String, String> myPropertiesToCreateByArtifact;
|
||||
|
||||
public void setupRootModel(ModifiableRootModel rootModel) throws ConfigurationException {
|
||||
final Project project = rootModel.getProject();
|
||||
|
||||
@@ -64,8 +70,12 @@ public class MavenModuleBuilder extends ModuleBuilder implements SourcePathsBuil
|
||||
|
||||
MavenUtil.runWhenInitialized(project, new DumbAwareRunnable() {
|
||||
public void run() {
|
||||
if (myEnvironmentForm != null) {
|
||||
myEnvironmentForm.setData(MavenProjectsManager.getInstance(project).getGeneralSettings());
|
||||
}
|
||||
|
||||
new MavenModuleBuilderHelper(myProjectId, myAggregatorProject, myParentProject, myInheritGroupId,
|
||||
myInheritVersion, myArchetype, "Create new Maven module").configure(project, root, false);
|
||||
myInheritVersion, myArchetype, myPropertiesToCreateByArtifact, "Create new Maven module").configure(project, root, false);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -96,7 +106,8 @@ public class MavenModuleBuilder extends ModuleBuilder implements SourcePathsBuil
|
||||
|
||||
@Override
|
||||
public ModuleWizardStep[] createWizardSteps(WizardContext wizardContext, ModulesProvider modulesProvider) {
|
||||
return new ModuleWizardStep[]{new MavenModuleWizardStep(wizardContext.getProject(), this)};
|
||||
return new ModuleWizardStep[]{new MavenModuleWizardStep(wizardContext.getProject(), this),
|
||||
new SelectPropertiesStep(wizardContext.getProject(), this)};
|
||||
}
|
||||
|
||||
public MavenProject findPotentialParentProject(Project project) {
|
||||
@@ -170,4 +181,20 @@ public class MavenModuleBuilder extends ModuleBuilder implements SourcePathsBuil
|
||||
public MavenArchetype getArchetype() {
|
||||
return myArchetype;
|
||||
}
|
||||
|
||||
public MavenEnvironmentForm getEnvironmentForm() {
|
||||
return myEnvironmentForm;
|
||||
}
|
||||
|
||||
public void setEnvironmentForm(MavenEnvironmentForm environmentForm) {
|
||||
myEnvironmentForm = environmentForm;
|
||||
}
|
||||
|
||||
public Map<String, String> getPropertiesToCreateByArtifact() {
|
||||
return myPropertiesToCreateByArtifact;
|
||||
}
|
||||
|
||||
public void setPropertiesToCreateByArtifact(Map<String, String> propertiesToCreateByArtifact) {
|
||||
myPropertiesToCreateByArtifact = propertiesToCreateByArtifact;
|
||||
}
|
||||
}
|
||||
|
||||
+13
-7
@@ -61,6 +61,7 @@ public class MavenModuleBuilderHelper {
|
||||
private final boolean myInheritVersion;
|
||||
|
||||
private final MavenArchetype myArchetype;
|
||||
private final Map<String, String> myPropertiesToCreateByArtifact;
|
||||
|
||||
private final String myCommandName;
|
||||
|
||||
@@ -70,6 +71,7 @@ public class MavenModuleBuilderHelper {
|
||||
boolean inheritGroupId,
|
||||
boolean inheritVersion,
|
||||
MavenArchetype archetype,
|
||||
Map<String, String> propertiesToCreateByArtifact,
|
||||
String commaneName) {
|
||||
myProjectId = projectId;
|
||||
myAggregatorProject = aggregatorProject;
|
||||
@@ -77,6 +79,8 @@ public class MavenModuleBuilderHelper {
|
||||
myInheritGroupId = inheritGroupId;
|
||||
myInheritVersion = inheritVersion;
|
||||
myArchetype = archetype;
|
||||
myPropertiesToCreateByArtifact = propertiesToCreateByArtifact;
|
||||
assert (archetype == null) == (propertiesToCreateByArtifact == null);
|
||||
myCommandName = commaneName;
|
||||
}
|
||||
|
||||
@@ -194,14 +198,16 @@ public class MavenModuleBuilderHelper {
|
||||
Map<String, String> props = settings.getMavenProperties();
|
||||
|
||||
props.put("interactiveMode", "false");
|
||||
props.put("archetypeGroupId", myArchetype.groupId);
|
||||
props.put("archetypeArtifactId", myArchetype.artifactId);
|
||||
props.put("archetypeVersion", myArchetype.version);
|
||||
if (myArchetype.repository != null) props.put("archetypeRepository", myArchetype.repository);
|
||||
//props.put("archetypeGroupId", myArchetype.groupId);
|
||||
//props.put("archetypeArtifactId", myArchetype.artifactId);
|
||||
//props.put("archetypeVersion", myArchetype.version);
|
||||
//if (myArchetype.repository != null) props.put("archetypeRepository", myArchetype.repository);
|
||||
|
||||
props.put("groupId", myProjectId.getGroupId());
|
||||
props.put("artifactId", myProjectId.getArtifactId());
|
||||
props.put("version", myProjectId.getVersion());
|
||||
//props.put("groupId", myProjectId.getGroupId());
|
||||
//props.put("artifactId", myProjectId.getArtifactId());
|
||||
//props.put("version", myProjectId.getVersion());
|
||||
|
||||
props.putAll(myPropertiesToCreateByArtifact);
|
||||
|
||||
runner.run(params, settings, new Runnable() {
|
||||
public void run() {
|
||||
|
||||
+28
-4
@@ -24,7 +24,6 @@ import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.ui.*;
|
||||
import com.intellij.ui.treeStructure.Tree;
|
||||
import com.intellij.util.containers.Convertor;
|
||||
import com.intellij.util.ui.AbstractLayoutManager;
|
||||
import com.intellij.util.ui.AsyncProcessIcon;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import com.intellij.util.ui.tree.TreeUtil;
|
||||
@@ -45,7 +44,6 @@ import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
public class MavenModuleWizardStep extends ModuleWizardStep {
|
||||
private static final Icon WIZARD_ICON = IconLoader.getIcon("/addmodulewizard.png");
|
||||
@@ -91,6 +89,8 @@ public class MavenModuleWizardStep extends ModuleWizardStep {
|
||||
private Object myCurrentUpdaterMarker;
|
||||
private final AsyncProcessIcon myLoadingIcon = new AsyncProcessIcon.Big(getClass() + ".loading");
|
||||
|
||||
private boolean skipUpdateUI;
|
||||
|
||||
public MavenModuleWizardStep(@Nullable Project project, MavenModuleBuilder builder) {
|
||||
myProjectOrNull = project;
|
||||
myBuilder = builder;
|
||||
@@ -140,6 +140,12 @@ public class MavenModuleWizardStep extends ModuleWizardStep {
|
||||
myInheritVersionCheckBox.addActionListener(updatingListener);
|
||||
|
||||
myUseArchetypeCheckBox.addActionListener(updatingListener);
|
||||
myUseArchetypeCheckBox.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
archetypeMayBeChanged();
|
||||
}
|
||||
});
|
||||
|
||||
myAddArchetypeButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
@@ -155,6 +161,7 @@ public class MavenModuleWizardStep extends ModuleWizardStep {
|
||||
myArchetypesTree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() {
|
||||
public void valueChanged(TreeSelectionEvent e) {
|
||||
updateArchetypeDescription();
|
||||
archetypeMayBeChanged();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -169,6 +176,20 @@ public class MavenModuleWizardStep extends ModuleWizardStep {
|
||||
myArchetypeDescriptionField.setBackground(UIUtil.getPanelBackground());
|
||||
}
|
||||
|
||||
private void archetypeMayBeChanged() {
|
||||
MavenArchetype selectedArchetype = getSelectedArchetype();
|
||||
if (((myBuilder.getArchetype() == null) != (selectedArchetype == null))) {
|
||||
myBuilder.setArchetype(selectedArchetype);
|
||||
skipUpdateUI = true;
|
||||
try {
|
||||
fireStateChanged();
|
||||
}
|
||||
finally {
|
||||
skipUpdateUI = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public JComponent getPreferredFocusedComponent() {
|
||||
return myGroupIdField;
|
||||
@@ -253,6 +274,8 @@ public class MavenModuleWizardStep extends ModuleWizardStep {
|
||||
|
||||
@Override
|
||||
public void updateStep() {
|
||||
if (skipUpdateUI) return;
|
||||
|
||||
if (isMavenizedProject()) {
|
||||
MavenProject parent = myBuilder.findPotentialParentProject(myProjectOrNull);
|
||||
myAggregator = parent;
|
||||
@@ -429,7 +452,7 @@ public class MavenModuleWizardStep extends ModuleWizardStep {
|
||||
myArchetypesTree.setBackground(archetypesEnabled ? UIUtil.getListBackground() : UIUtil.getPanelBackground());
|
||||
}
|
||||
|
||||
private String formatProjectString(MavenProject project) {
|
||||
private static String formatProjectString(MavenProject project) {
|
||||
if (project == null) return "<none>";
|
||||
return project.getMavenId().getDisplayString();
|
||||
}
|
||||
@@ -448,12 +471,13 @@ public class MavenModuleWizardStep extends ModuleWizardStep {
|
||||
myBuilder.setArchetype(getSelectedArchetype());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private MavenArchetype getSelectedArchetype() {
|
||||
if (!myUseArchetypeCheckBox.isSelected() || myArchetypesTree.isSelectionEmpty()) return null;
|
||||
return getArchetypeInfoFromPathComponent(myArchetypesTree.getLastSelectedPathComponent());
|
||||
}
|
||||
|
||||
private MavenArchetype getArchetypeInfoFromPathComponent(Object sel) {
|
||||
private static MavenArchetype getArchetypeInfoFromPathComponent(Object sel) {
|
||||
return (MavenArchetype)((DefaultMutableTreeNode)sel).getUserObject();
|
||||
}
|
||||
|
||||
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="org.jetbrains.idea.maven.wizards.SelectPropertiesStep">
|
||||
<grid id="27dc6" binding="myMainPanel" layout-manager="GridLayoutManager" row-count="3" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<xy x="20" y="20" width="500" height="400"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="bbb30" binding="myEnvironmentPanel" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children/>
|
||||
</grid>
|
||||
<grid id="41b57" binding="myPropertiesPanel" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="-1" height="300"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="etched" title="Properties"/>
|
||||
<children/>
|
||||
</grid>
|
||||
<vspacer id="c877e">
|
||||
<constraints>
|
||||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</vspacer>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
||||
+108
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jetbrains.idea.maven.wizards;
|
||||
|
||||
import com.intellij.ide.util.projectWizard.ModuleWizardStep;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectManager;
|
||||
import com.intellij.util.containers.hash.HashMap;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.idea.maven.execution.MavenPropertiesPanel;
|
||||
import org.jetbrains.idea.maven.indices.MavenIndex;
|
||||
import org.jetbrains.idea.maven.model.MavenArchetype;
|
||||
import org.jetbrains.idea.maven.model.MavenId;
|
||||
import org.jetbrains.idea.maven.project.MavenEnvironmentForm;
|
||||
import org.jetbrains.idea.maven.project.MavenGeneralSettings;
|
||||
import org.jetbrains.idea.maven.project.MavenProjectsManager;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Sergey Evdokimov
|
||||
*/
|
||||
public class SelectPropertiesStep extends ModuleWizardStep {
|
||||
|
||||
private final Project myProjectOrNull;
|
||||
private final MavenModuleBuilder myBuilder;
|
||||
|
||||
private JPanel myMainPanel;
|
||||
private JPanel myEnvironmentPanel;
|
||||
private JPanel myPropertiesPanel;
|
||||
|
||||
private MavenEnvironmentForm myEnvironmentForm;
|
||||
private MavenPropertiesPanel myMavenPropertiesPanel;
|
||||
|
||||
private Map<String, String> myAvailableProperties = new HashMap<String, String>();
|
||||
|
||||
public SelectPropertiesStep(@Nullable Project project, MavenModuleBuilder builder) {
|
||||
myProjectOrNull = project;
|
||||
myBuilder = builder;
|
||||
|
||||
initComponents();
|
||||
}
|
||||
|
||||
private void initComponents() {
|
||||
myEnvironmentForm = new MavenEnvironmentForm();
|
||||
|
||||
Project project = myProjectOrNull == null ? ProjectManager.getInstance().getDefaultProject() : myProjectOrNull;
|
||||
myEnvironmentForm.getData(MavenProjectsManager.getInstance(project).getGeneralSettings().clone());
|
||||
|
||||
myEnvironmentPanel.add(myEnvironmentForm.createComponent(), BorderLayout.CENTER);
|
||||
|
||||
myMavenPropertiesPanel = new MavenPropertiesPanel(myAvailableProperties);
|
||||
myPropertiesPanel.add(myMavenPropertiesPanel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateStep() {
|
||||
MavenArchetype archetype = myBuilder.getArchetype();
|
||||
|
||||
Map<String, String> props = new LinkedHashMap<String, String>();
|
||||
|
||||
MavenId projectId = myBuilder.getProjectId();
|
||||
|
||||
props.put("groupId", projectId.getGroupId());
|
||||
props.put("artifactId", projectId.getArtifactId());
|
||||
props.put("version", projectId.getVersion());
|
||||
|
||||
props.put("archetypeGroupId", archetype.groupId);
|
||||
props.put("archetypeArtifactId", archetype.artifactId);
|
||||
props.put("archetypeVersion", archetype.version);
|
||||
if (archetype.repository != null) props.put("archetypeRepository", archetype.repository);
|
||||
|
||||
myMavenPropertiesPanel.setDataFromMap(props);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JComponent getComponent() {
|
||||
return myMainPanel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStepVisible() {
|
||||
return myBuilder.getArchetype() != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDataModel() {
|
||||
myBuilder.setEnvironmentForm(myEnvironmentForm);
|
||||
myBuilder.setPropertiesToCreateByArtifact(myMavenPropertiesPanel.getDataAsMap());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user