Author: akazakov
Date: 2011-03-29 21:11:01 -0400 (Tue, 29 Mar 2011)
New Revision: 30136
Modified:
branches/3.2.helios/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/SeamRuntimeListFieldEditor.java
Log:
https://issues.jboss.org/browse/JBIDE-8626
Modified:
branches/3.2.helios/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/SeamRuntimeListFieldEditor.java
===================================================================
---
branches/3.2.helios/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/SeamRuntimeListFieldEditor.java 2011-03-30
01:09:22 UTC (rev 30135)
+++
branches/3.2.helios/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/SeamRuntimeListFieldEditor.java 2011-03-30
01:11:01 UTC (rev 30136)
@@ -66,6 +66,7 @@
import org.jboss.tools.seam.core.SeamCorePlugin;
import org.jboss.tools.seam.core.SeamUtil;
import org.jboss.tools.seam.core.project.facet.SeamRuntime;
+import org.jboss.tools.seam.core.project.facet.SeamRuntimeManager;
import org.jboss.tools.seam.core.project.facet.SeamVersion;
import org.jboss.tools.seam.internal.core.project.facet.ISeamFacetDataModelProperties;
import org.jboss.tools.seam.ui.SeamUIMessages;
@@ -108,6 +109,8 @@
private List<SeamRuntime> added = new ArrayList<SeamRuntime>();
private List<SeamRuntime> removed = new ArrayList<SeamRuntime>();
+
+ private AddAction addAction;
// ------------------------------------------------------------------------
// Constructors
@@ -127,6 +130,12 @@
Object defaultValue) {
super(name, label, defaultValue);
}
+
+ public AddAction getAddAction(){
+ if(addAction == null)
+ addAction = new AddAction();
+ return addAction;
+ }
/**
* TBD
@@ -164,6 +173,31 @@
return removed;
}
+ public void performApply() {
+ for (SeamRuntime rt : getAddedSeamRuntimes()) {
+ SeamRuntimeManager.getInstance().addRuntime(rt);
+ }
+ getAddedSeamRuntimes().clear();
+ for (SeamRuntime rt : getRemoved()) {
+ SeamRuntimeManager.getInstance().removeRuntime(rt);
+ }
+ getRemoved().clear();
+ Map<SeamRuntime, SeamRuntime> changed = getChangedSeamRuntimes();
+ for (SeamRuntime c : changed.keySet()) {
+ SeamRuntime o = changed.get(c);
+ o.setHomeDir(c.getHomeDir());
+ o.setVersion(c.getVersion());
+ String oldName = o.getName();
+ String newName = c.getName();
+ if (!oldName.equals(newName)) {
+ SeamRuntimeManager.getInstance().changeRuntimeName(oldName, newName);
+ }
+ }
+ getChangedSeamRuntimes().clear();
+
+ SeamRuntimeManager.getInstance().save();
+ }
+
/**
* TBD
*
@@ -334,7 +368,7 @@
protected void createActionBar() {
actionPanel = new ActionPanel(root, new BaseAction[] {
- new AddAction(), new EditAction(), new RemoveAction()});
+ getAddAction(), new EditAction(), new RemoveAction()});
tableView.addSelectionChangedListener(actionPanel);
}
@@ -549,18 +583,18 @@
if ("homeDir".equals(evt.getPropertyName())) { //$NON-NLS-1$
if (name.getValueAsString() == null
|| "".equals(name.getValueAsString().trim())) { //$NON-NLS-1$
- String homeDirName = homeDir.getValueAsString();
- if (homeDirName != null && !"".equals(homeDirName.trim())) {
//$NON-NLS-1$
- File folder = new File(homeDirName);
- homeDirName = folder.getName();
- }
- name.setValue(homeDirName);
-
String seamVersion =
SeamUtil.getSeamVersionFromManifest(homeDir.getValueAsString());
if (seamVersion == null) {
setErrorMessage(SeamUIMessages.SEAM_RUNTIME_LIST_FIELD_EDITOR_CANNOT_FIND_JBOSS_SEAM_JAR);
setPageComplete(false);
return;
+ } else {
+ String homeDirName = homeDir.getValueAsString();
+ if (homeDirName != null && !"".equals(homeDirName.trim())) {
//$NON-NLS-1$
+ File folder = new File(homeDirName);
+ homeDirName = folder.getName();
+ }
+ name.setValue(homeDirName);
}
if (validSeamVersions != null) {
for (SeamVersion ver : validSeamVersions) {
@@ -798,7 +832,7 @@
}
if (added.contains(source) || changed.containsKey(source)) {
source.setName(rt.getName());
- source.setHomeDir(rt.getName());
+ source.setHomeDir(rt.getHomeDir());
source.setVersion(rt.getVersion());
} else {
changed.put(rt, source);
@@ -1023,7 +1057,24 @@
dialog.open();
tableView.refresh();
setDefaultRuntimes();
+ performApply();
}
+
+ public void run(String name, String version) {
+ SeamRuntimeNewWizard wiz = new SeamRuntimeNewWizard(
+ (List<SeamRuntime>) getValue(), added);
+
+ wiz.page1.name.setValue(name);
+
+ wiz.page1.version.setValue(version);
+
+ WizardDialog dialog = new WizardDialog(Display.getCurrent()
+ .getActiveShell(), wiz);
+ dialog.open();
+ tableView.refresh();
+ setDefaultRuntimes();
+ performApply();
+ }
}
/**
@@ -1073,6 +1124,7 @@
tableView.setSelection(new StructuredSelection(c));
}
}
+ performApply();
}
private SeamRuntime findChangedRuntime(SeamRuntime source) {
@@ -1117,6 +1169,7 @@
}
tableView.refresh();
setDefaultRuntimes();
+ performApply();
}
private void removeRuntime(SeamRuntime r) {