Author: akazakov
Date: 2008-01-22 12:58:05 -0500 (Tue, 22 Jan 2008)
New Revision: 5884
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamProjectPreferences.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamRuntimeManager.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/SeamInstallWizardPage.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamSettingsPreferencePage.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamGenerateEnitiesWizard.java
trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/project/facet/SeamRuntimeManagerTest.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-1490 Resolved
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamProjectPreferences.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamProjectPreferences.java 2008-01-22
17:52:40 UTC (rev 5883)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamProjectPreferences.java 2008-01-22
17:58:05 UTC (rev 5884)
@@ -20,12 +20,6 @@
*/
public class SeamProjectPreferences {
/**
- * Last selected SeamRuntime name
- */
- public static final String SEAM_DEFAULT_RUNTIME_NAME = SeamCorePlugin.PLUGIN_ID
- + ".project.facet.default.runtime.name"; //$NON-NLS-1$
-
- /**
* Last selected connection profile
*/
public static final String SEAM_DEFAULT_CONNECTION_PROFILE = SeamCorePlugin.PLUGIN_ID
@@ -44,12 +38,6 @@
+ ".runtime.list"; //$NON-NLS-1$
/**
- * TODO
- */
- public static final String RUNTIME_DEFAULT = SeamCorePlugin.PLUGIN_ID
- + ".runtime.default"; //$NON-NLS-1$
-
- /**
* Last selected deployment type
*/
public static final String JBOSS_AS_DEFAULT_DEPLOY_AS = SeamCorePlugin.PLUGIN_ID
@@ -77,4 +65,4 @@
public static String getStringPreference(final String name) {
return SeamCorePlugin.getDefault().getPreferenceStore().getString(name);
}
-}
+}
\ No newline at end of file
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamRuntimeManager.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamRuntimeManager.java 2008-01-22
17:52:40 UTC (rev 5883)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamRuntimeManager.java 2008-01-22
17:58:05 UTC (rev 5884)
@@ -22,8 +22,13 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.preference.IPersistentPreferenceStore;
import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.wst.common.project.facet.core.IFacetedProject;
+import org.eclipse.wst.common.project.facet.core.IProjectFacet;
+import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
+import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
import org.jboss.tools.seam.core.ISeamProject;
import org.jboss.tools.seam.core.SeamCorePlugin;
+import org.jboss.tools.seam.internal.core.project.facet.ISeamCoreConstants;
import org.jboss.tools.seam.internal.core.project.facet.SeamFacetPreferenceInitializer;
import org.jboss.tools.seam.internal.core.validation.SeamRuntimeValidation;
@@ -207,6 +212,18 @@
}
/**
+ * Marks this runtime as default. Marks other runtimes with the same version as not
default.
+ * @param runtime
+ */
+ public void setDefaultRuntime(SeamRuntime runtime) {
+ SeamRuntime[] runtimes = getRuntimes(runtime.getVersion());
+ for (int i = 0; i < runtimes.length; i++) {
+ runtimes[i].setDefault(false);
+ }
+ runtime.setDefault(true);
+ }
+
+ /**
* Return first default SeamRuntime
*
* @return
@@ -222,6 +239,32 @@
}
/**
+ * If project has seam facet then this method returns default seam runtime for proper
version of facet.
+ * Otherwise return first default runtime.
+ * @param project
+ * @return
+ */
+ public static SeamRuntime getDefaultRuntimeForProject(IProject project) {
+ if(project==null) {
+ throw new IllegalArgumentException("Project must not be null.");
+ }
+ try {
+ IProjectFacet facet =
ProjectFacetsManager.getProjectFacet(ISeamCoreConstants.SEAM_CORE_FACET_ID);
+ IFacetedProject facetedProject = ProjectFacetsManager.create(project);
+ if(facetedProject!=null) {
+ IProjectFacetVersion facetVersion = facetedProject.getInstalledVersion(facet);
+ SeamVersion seamVersion =
SeamVersion.parseFromString(facetVersion.getVersionString());
+ return getInstance().getDefaultRuntime(seamVersion);
+ }
+ } catch (CoreException e) {
+ SeamCorePlugin.getPluginLog().logError(e);
+ } catch (IllegalArgumentException e) {
+ SeamCorePlugin.getPluginLog().logError(e);
+ }
+ return getInstance().getDefaultRuntime();
+ }
+
+ /**
* Return default runtime for given SeamVersion
*
* @param version
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java 2008-01-22
17:52:40 UTC (rev 5883)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java 2008-01-22
17:58:05 UTC (rev 5884)
@@ -35,6 +35,10 @@
import org.eclipse.core.runtime.Preferences;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.core.runtime.preferences.IScopeContext;
+import org.eclipse.wst.common.project.facet.core.IFacetedProject;
+import org.eclipse.wst.common.project.facet.core.IProjectFacet;
+import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
+import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
import org.jboss.tools.common.xml.XMLUtilities;
import org.jboss.tools.seam.core.ISeamComponent;
import org.jboss.tools.seam.core.ISeamComponentDeclaration;
@@ -55,6 +59,8 @@
import org.jboss.tools.seam.core.project.facet.SeamProjectPreferences;
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.ISeamCoreConstants;
import org.jboss.tools.seam.internal.core.scanner.LoadedDeclarations;
import org.jboss.tools.seam.internal.core.scanner.lib.ClassPath;
import org.jboss.tools.seam.internal.core.validation.SeamValidationContext;
@@ -138,24 +144,18 @@
public IProject getProject() {
return project;
}
-
+
/**
*
*/
public String getRuntimeName() {
- String parent = getParentProjectName();
- if(parent != null) {
- IProject p = ResourcesPlugin.getWorkspace().getRoot().getProject(parent);
- if(p == null || !p.isAccessible()) return null;
- ISeamProject sp = SeamCorePlugin.getSeamProject(p, false);
- return sp == null ? null : sp.getRuntimeName();
+ SeamRuntime runtime = getRuntime();
+ if(runtime!=null) {
+ return runtime.getName();
}
- if(runtimeName == null) {
- SeamRuntime runtime = SeamRuntimeManager.getInstance().getDefaultRuntime();
- return runtime != null ? runtime.getName() : null;
- }
return runtimeName;
}
+
/**
*
*/
@@ -168,21 +168,21 @@
return sp == null ? null : sp.getRuntime();
}
if(runtimeName == null) {
- return SeamRuntimeManager.getInstance().getDefaultRuntime();
+ return SeamRuntimeManager.getDefaultRuntimeForProject(project);
}
return runtimeName == null ? null :
SeamRuntimeManager.getInstance().findRuntimeByName(runtimeName);
}
-
+
public String getParentProjectName() {
IEclipsePreferences p = getSeamPreferences();
return p == null ? null : p.get("seam.parent.project", null);
}
-
+
public void setRuntimeName(String runtimeName) {
if(this.runtimeName == runtimeName) return;
if(this.runtimeName != null && this.runtimeName.equals(runtimeName)) return;
- SeamRuntime d = SeamRuntimeManager.getInstance().getDefaultRuntime();
-
+ SeamRuntime d = SeamRuntimeManager.getDefaultRuntimeForProject(project);
+
boolean useDefaultRuntime = d != null && d.getName().equals(runtimeName);
if(useDefaultRuntime) {
this.runtimeName = null;
@@ -191,7 +191,7 @@
}
storeRuntime();
}
-
+
/**
* Returns list of scope objects for all scope types.
* @return
@@ -199,7 +199,7 @@
public ISeamScope[] getScopes() {
return scopes;
}
-
+
/**
* Returns scope object for specified scope type.
* @param scopeType
@@ -251,7 +251,7 @@
loadRuntime();
// load();
}
-
+
/**
*
*/
@@ -263,19 +263,19 @@
} else {
storeRuntime();
}
- SeamCorePlugin.getDefault().getPluginPreferences().addPropertyChangeListener(new
Preferences.IPropertyChangeListener() {
- public void propertyChange(Preferences.PropertyChangeEvent event) {
- if(SeamProjectPreferences.RUNTIME_LIST.equals(event.getProperty())) {
- SeamRuntime d = SeamRuntimeManager.getInstance().getDefaultRuntime();
- if(d != null && d.getName().equals(runtimeName)) {
+// SeamCorePlugin.getDefault().getPluginPreferences().addPropertyChangeListener(new
Preferences.IPropertyChangeListener() {
+// public void propertyChange(Preferences.PropertyChangeEvent event) {
+// if(SeamProjectPreferences.RUNTIME_LIST.equals(event.getProperty())) {
+// SeamRuntime d = SeamRuntimeManager.getInstance().getDefaultRuntime();
+// if(d != null && d.getName().equals(runtimeName)) {
// runtimeName = null;
// storeRuntime();
- }
- }
- }
- });
+// }
+// }
+// }
+// });
}
-
+
/**
*
* @return
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/SeamInstallWizardPage.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/SeamInstallWizardPage.java 2008-01-22
17:52:40 UTC (rev 5883)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/SeamInstallWizardPage.java 2008-01-22
17:58:05 UTC (rev 5884)
@@ -88,11 +88,7 @@
private DataModelValidatorDelegate validatorDelegate;
- private IFieldEditor jBossSeamHomeEditor = IFieldEditorFactory.INSTANCE
- .createComboWithButton(ISeamFacetDataModelProperties.SEAM_RUNTIME_NAME,
- SeamUIMessages.SEAM_INSTALL_WIZARD_PAGE_SEAM_RUNTIME, getRuntimeNames(),
- getSeamRuntimeDefaultValue(),
- true, new NewSeamRuntimeAction(), (IValidator)null);
+ private IFieldEditor jBossSeamHomeEditor;
private IFieldEditor jBossAsDeployAsEditor = IFieldEditorFactory.INSTANCE
.createRadioEditor(
@@ -209,17 +205,11 @@
String seamFacetVersion =
model.getProperty(IFacetDataModelProperties.FACET_VERSION_STR).toString();
SeamVersion seamVersion = SeamVersion.parseFromString(seamFacetVersion);
- String seamDefaultRuntimeName =
SeamProjectPreferences.getStringPreference(SeamProjectPreferences.SEAM_DEFAULT_RUNTIME_NAME);
- if("".equals(seamDefaultRuntimeName)) {
- SeamRuntime defaultRuntime =
SeamRuntimeManager.getInstance().getDefaultRuntime(seamVersion);
- if(defaultRuntime==null) {
- return "";
- } else {
- return defaultRuntime.getName();
- }
- } else {
- return seamDefaultRuntimeName;
+ SeamRuntime defaultRuntime =
SeamRuntimeManager.getInstance().getDefaultRuntime(seamVersion);
+ if(defaultRuntime==null) {
+ return "";
}
+ return defaultRuntime.getName();
}
private DataModelSynchronizer sync;
@@ -248,9 +238,11 @@
* Finish has been pressed.
*/
public void transferStateToConfig() {
- SeamCorePlugin.getDefault().getPluginPreferences().setValue(
- SeamProjectPreferences.SEAM_DEFAULT_RUNTIME_NAME,
- jBossSeamHomeEditor.getValueAsString());
+ String seamRuntimeName = jBossSeamHomeEditor.getValueAsString();
+ SeamRuntime seamRuntime =
SeamRuntimeManager.getInstance().findRuntimeByName(seamRuntimeName);
+ if(seamRuntime!=null) {
+ SeamRuntimeManager.getInstance().setDefaultRuntime(seamRuntime);
+ }
SeamCorePlugin.getDefault().getPluginPreferences().setValue(
SeamProjectPreferences.SEAM_DEFAULT_CONNECTION_PROFILE,
@@ -301,6 +293,12 @@
* Creates Seam Facet Wizard Page contents
*/
public void createControl(Composite parent) {
+ jBossSeamHomeEditor = IFieldEditorFactory.INSTANCE
+ .createComboWithButton(ISeamFacetDataModelProperties.SEAM_RUNTIME_NAME,
+ SeamUIMessages.SEAM_INSTALL_WIZARD_PAGE_SEAM_RUNTIME, getRuntimeNames(),
+ getSeamRuntimeDefaultValue(),
+ true, new NewSeamRuntimeAction(), (IValidator)null);
+
initializeDialogUnits(parent);
Composite root = new Composite(parent, SWT.NONE);
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamSettingsPreferencePage.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamSettingsPreferencePage.java 2008-01-22
17:52:40 UTC (rev 5883)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamSettingsPreferencePage.java 2008-01-22
17:58:05 UTC (rev 5884)
@@ -106,7 +106,7 @@
SeamPreferencesMessages.SEAM_SETTINGS_PREFERENCE_PAGE_SEAM_SUPPORT,
SeamPreferencesMessages.SEAM_SETTINGS_PREFERENCE_PAGE_SEAM_SUPPORT, false);
seamEnablement.setValue(hasSeamSupport());
- SeamRuntime rs = SeamRuntimeManager.getInstance().getDefaultRuntime();
+ SeamRuntime rs = SeamRuntimeManager.getDefaultRuntimeForProject(project);
List<String> namesAsList = getNameList();
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamGenerateEnitiesWizard.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamGenerateEnitiesWizard.java 2008-01-22
17:52:40 UTC (rev 5883)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamGenerateEnitiesWizard.java 2008-01-22
17:58:05 UTC (rev 5884)
@@ -310,7 +310,7 @@
if(project==null) {
return null;
}
- SeamRuntime seamRt = SeamRuntimeManager.getInstance().getDefaultRuntime();
+ SeamRuntime seamRt = SeamRuntimeManager.getDefaultRuntimeForProject(project);
String runtimeName = SeamCorePlugin.getSeamPreferences(project)
.get(ISeamFacetDataModelProperties.SEAM_RUNTIME_NAME,""); //$NON-NLS-1$
Modified:
trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/project/facet/SeamRuntimeManagerTest.java
===================================================================
---
trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/project/facet/SeamRuntimeManagerTest.java 2008-01-22
17:52:40 UTC (rev 5883)
+++
trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/project/facet/SeamRuntimeManagerTest.java 2008-01-22
17:58:05 UTC (rev 5884)
@@ -101,7 +101,7 @@
* Test method for {@link
org.jboss.tools.seam.core.project.facet.SeamRuntimeManager#getDefaultRuntime()}.
*/
public void testGetDefaultRuntime() {
- assertNotNull("Cannot obtain default runtime 'Seam
1.2.0'",manager.getDefaultRuntime());
- assertNotNull("Cannot obtain default runtime 'Seam
1.2.0'",manager.getDefaultRuntime().getName().equals("Seam 1.2.0"));
+ assertNotNull("Cannot obtain default runtime 'Seam
1.2.0'",manager.getDefaultRuntime(SeamVersion.SEAM_1_2));
+ assertNotNull("Cannot obtain default runtime 'Seam
1.2.0'",manager.getDefaultRuntime(SeamVersion.SEAM_1_2).getName().equals("Seam
1.2.0"));
}
-}
+}
\ No newline at end of file