Author: dgolovin
Date: 2008-03-11 01:10:02 -0400 (Tue, 11 Mar 2008)
New Revision: 6827
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamPreferencesMessages.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamPreferencesMessages.properties
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamSettingsPreferencePageNew.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/BaseFieldEditor.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/CompositeEditor.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/IFieldEditorFactory.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/SwtFieldEditorFactory.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/TextFieldEditor.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-1322
layout for Preference page is finished
enablement/disablement for depended GUI controls is finished
basic save for preferences is added
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamPreferencesMessages.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamPreferencesMessages.java 2008-03-10
19:58:43 UTC (rev 6826)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamPreferencesMessages.java 2008-03-11
05:10:02 UTC (rev 6827)
@@ -57,6 +57,12 @@
public static String SEAM_VALIDATOR_PREFERENCE_PAGE_SEAM_VALIDATOR;
+ public static String SEAM_SETTINGS_PREFERENCE_PAGE_CREATE_TEST;
+
+ public static String SEAM_SETTINGS_PREFERENCES_PAGE_TEST;
+
+ public static String SEAM_SETTINGS_PREFERENCE_PAGE_TEST_PROJECT;
+
//Validator Preference page
public static String SeamValidatorConfigurationBlock_common_description;
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamPreferencesMessages.properties
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamPreferencesMessages.properties 2008-03-10
19:58:43 UTC (rev 6826)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamPreferencesMessages.properties 2008-03-11
05:10:02 UTC (rev 6827)
@@ -74,8 +74,11 @@
SEAM_SETTINGS_PREFERENCES_PAGE_MODEL=Model
SEAM_SETTINGS_PREFERENCES_PAGE_SOURCE_FOLDER=Source Folder:
SEAM_SETTINGS_PREFERENCES_PAGE_PACKAGE=Package:
-SEAM_SETTINGS_PREFERENCES_PAGE_ACTION=Action/Form/Conversation
-SEAM_SETTINGS_PREFERENCE_PAGE_SEAM_SUPPORT=Seam support:
+SEAM_SETTINGS_PREFERENCES_PAGE_ACTION=Action / Form / Conversation
+SEAM_SETTINGS_PREFERENCE_PAGE_SEAM_SUPPORT=Seam support\:
+SEAM_SETTINGS_PREFERENCE_PAGE_CREATE_TEST=Create Test\:
+SEAM_SETTINGS_PREFERENCES_PAGE_TEST=Test
+SEAM_SETTINGS_PREFERENCE_PAGE_TEST_PROJECT=Test Project\:
SEAM_SETTINGS_PREFERENCE_PAGE_RUNTIME=Runtime
SEAM_SETTINGS_PREFERENCE_PAGE_SEAM_RUNTIME_IS_NOT_SELECTED=Seam runtime is not selected
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamSettingsPreferencePageNew.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamSettingsPreferencePageNew.java 2008-03-10
19:58:43 UTC (rev 6826)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamSettingsPreferencePageNew.java 2008-03-11
05:10:02 UTC (rev 6827)
@@ -12,19 +12,28 @@
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
+import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ProjectScope;
+import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.core.runtime.preferences.IScopeContext;
import org.eclipse.datatools.connectivity.IConnectionProfile;
import org.eclipse.datatools.connectivity.ProfileManager;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
@@ -37,6 +46,7 @@
import org.jboss.tools.seam.core.SeamCorePlugin;
import org.jboss.tools.seam.core.SeamProjectsSet;
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.SeamVersion;
import org.jboss.tools.seam.internal.core.project.facet.ISeamFacetDataModelProperties;
import org.jboss.tools.seam.ui.SeamGuiPlugin;
@@ -45,6 +55,7 @@
import org.jboss.tools.seam.ui.internal.project.facet.ValidatorFactory;
import org.jboss.tools.seam.ui.widget.editor.IFieldEditor;
import org.jboss.tools.seam.ui.widget.editor.IFieldEditorFactory;
+import org.jboss.tools.seam.ui.widget.editor.SeamRuntimeListFieldEditor;
import org.jboss.tools.seam.ui.wizard.IParameter;
import org.jboss.tools.seam.ui.wizard.SeamWizardFactory;
import org.jboss.tools.seam.ui.wizard.SeamWizardUtils;
@@ -88,6 +99,7 @@
@Override
protected Control createContents(Composite parent) {
Composite root = new Composite(parent, SWT.NONE);
+
GridData gd = new GridData();
gd.horizontalSpan = 1;
@@ -97,6 +109,7 @@
GridLayout gridLayout = new GridLayout(1, false);
root.setLayout(gridLayout);
+
Composite generalGroup = new Composite(root, SWT.NONE);
generalGroup.setLayoutData(gd);
gridLayout = new GridLayout(4, false);
@@ -117,7 +130,10 @@
});
registerEditor(seamSupportCheckBox, generalGroup);
- IFieldEditor seamRuntimeEditor =
SeamWizardFactory.createSeamRuntimeSelectionFieldEditor(getSeamVersions(),
getSeamRuntimeName());
+ IFieldEditor seamRuntimeEditor =
+ SeamWizardFactory.createSeamRuntimeSelectionFieldEditor(
+ getSeamVersions(),
+ getSeamRuntimeName());
seamRuntimeEditor.addPropertyChangeListener(new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
Object value = evt.getNewValue();
@@ -131,7 +147,14 @@
});
registerEditor(seamRuntimeEditor, generalGroup);
- IFieldEditor projectNameEditor =
IFieldEditorFactory.INSTANCE.createUneditableTextEditor(IParameter.SEAM_PROJECT_NAME,
SeamPreferencesMessages.SEAM_SETTINGS_PREFERENCES_PAGE_SEAM_PROJECT,
getSeamProjectName());
+ IFieldEditor projectNameEditor =
+ IFieldEditorFactory.INSTANCE.createUneditableTextEditor(
+ IParameter.SEAM_PROJECT_NAME,
+ SeamPreferencesMessages.SEAM_SETTINGS_PREFERENCES_PAGE_SEAM_PROJECT,
+ getPrefValue(
+ IParameter.SEAM_PROJECT_NAME,
+ getSeamProjectName()));
+
registerEditor(projectNameEditor, generalGroup);
IFieldEditor connProfileEditor =
SeamWizardFactory.createConnectionProfileSelectionFieldEditor(getConnectionProfile(), new
IValidator() {
@@ -142,69 +165,148 @@
});
registerEditor(connProfileEditor, generalGroup);
- gd = new GridData();
- gd.horizontalSpan = 1;
- gd.horizontalAlignment = GridData.FILL;
- gd.grabExcessHorizontalSpace = true;
- gd.grabExcessVerticalSpace = false;
+ Group deploymentGroup = createGroup(
+ root,
+ SeamPreferencesMessages.SEAM_SETTINGS_PREFERENCES_PAGE_DEPLOYMENT,
+ 4);
- Group deploymentGroup = new Group(root, SWT.NONE);
- groups.add(deploymentGroup);
- deploymentGroup.setLayoutData(gd);
- deploymentGroup.setText(SeamPreferencesMessages.SEAM_SETTINGS_PREFERENCES_PAGE_DEPLOYMENT);
- gridLayout = new GridLayout(4, false);
- deploymentGroup.setLayout(gridLayout);
-
IFieldEditor deployTypeEditor = IFieldEditorFactory.INSTANCE.createRadioEditor(
ISeamFacetDataModelProperties.JBOSS_AS_DEPLOY_AS,
SeamUIMessages.SEAM_INSTALL_WIZARD_PAGE_DEPLOY_AS,
Arrays.asList(new String[]
{ISeamFacetDataModelProperties.DEPLOY_AS_WAR.toUpperCase(),
ISeamFacetDataModelProperties.DEPLOY_AS_EAR.toUpperCase()}),
Arrays.asList(new Object[] {ISeamFacetDataModelProperties.DEPLOY_AS_WAR,
ISeamFacetDataModelProperties.DEPLOY_AS_EAR}),
getDeployAsValue());
+
+ deployTypeEditor.addPropertyChangeListener(new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+ setEnabledDeploymentGroup();
+ }
+ });
registerEditor(deployTypeEditor, deploymentGroup);
- IFieldEditor ejbProjectEditor =
SeamWizardFactory.createSeamProjectSelectionFieldEditor(ISeamFacetDataModelProperties.SEAM_EJB_PROJECT,
SeamPreferencesMessages.SEAM_SETTINGS_PREFERENCES_PAGE_EJB_PROJECT, getEjbProjectName(),
true);
+ IFieldEditor ejbProjectEditor =
SeamWizardFactory.createSeamProjectSelectionFieldEditor(
+ ISeamFacetDataModelProperties.SEAM_EJB_PROJECT,
+ SeamPreferencesMessages.SEAM_SETTINGS_PREFERENCES_PAGE_EJB_PROJECT,
+ getEjbProjectName(),
+ true);
registerEditor(ejbProjectEditor, deploymentGroup);
- Group viewGroup = new Group(root, SWT.NONE);
- groups.add(viewGroup);
- gd = new GridData();
- gd.horizontalSpan = 1;
- gd.horizontalAlignment = GridData.FILL;
- gd.grabExcessHorizontalSpace = true;
- gd.grabExcessVerticalSpace = false;
+ Group viewGroup = createGroup(
+ root,
+ SeamPreferencesMessages.SEAM_SETTINGS_PREFERENCES_PAGE_VIEW,
+ 3);
- viewGroup.setLayoutData(gd);
- viewGroup.setText(SeamPreferencesMessages.SEAM_SETTINGS_PREFERENCES_PAGE_VIEW);
- gridLayout = new GridLayout(3, false);
- viewGroup.setLayout(gridLayout);
-
IFieldEditor viewFolderEditor =
SeamWizardFactory.createViewFolderFieldEditor(getViewFolder());
registerEditor(viewFolderEditor, viewGroup);
- Group modelGroup = new Group(root, SWT.NONE);
- groups.add(modelGroup);
- gd = new GridData();
- gd.horizontalSpan = 1;
- gd.horizontalAlignment = GridData.FILL;
- gd.grabExcessHorizontalSpace = true;
- gd.grabExcessVerticalSpace = false;
+ Group modelGroup = createGroup(root,
+ SeamPreferencesMessages.SEAM_SETTINGS_PREFERENCES_PAGE_MODEL,
+ 3);
- modelGroup.setLayoutData(gd);
- modelGroup.setText(SeamPreferencesMessages.SEAM_SETTINGS_PREFERENCES_PAGE_MODEL);
- gridLayout = new GridLayout(3, false);
- modelGroup.setLayout(gridLayout);
-
- IFieldEditor modelSourceFolderEditor =
IFieldEditorFactory.INSTANCE.createBrowseSourceFolderEditor(ISeamFacetDataModelProperties.ENTITY_BEAN_SOURCE_FOLDER,
SeamPreferencesMessages.SEAM_SETTINGS_PREFERENCES_PAGE_SOURCE_FOLDER,
getModelSourceFolder());
+ IFieldEditor modelSourceFolderEditor =
+ IFieldEditorFactory.INSTANCE.createBrowseSourceFolderEditor(
+ ISeamFacetDataModelProperties.ENTITY_BEAN_SOURCE_FOLDER,
+ SeamPreferencesMessages.SEAM_SETTINGS_PREFERENCES_PAGE_SOURCE_FOLDER,
+ getModelSourceFolder());
+
+ IFieldEditor modelPackageEditor =
+ IFieldEditorFactory.INSTANCE.createBrowsePackageEditor(
+ ISeamFacetDataModelProperties.ENTITY_BEAN_PACKAGE_NAME,
+ SeamPreferencesMessages.SEAM_SETTINGS_PREFERENCES_PAGE_PACKAGE,
+ "");
+
registerEditor(modelSourceFolderEditor, modelGroup);
+ registerEditor(modelPackageEditor, modelGroup);
+
+ Group actionGroup = createGroup(root,
+ SeamPreferencesMessages.SEAM_SETTINGS_PREFERENCES_PAGE_ACTION,
+ 3);
+ IFieldEditor actionSourceFolderEditor =
+ IFieldEditorFactory.INSTANCE.createBrowseSourceFolderEditor(
+ ISeamFacetDataModelProperties.SESSION_BEAN_SOURCE_FOLDER,
+ SeamPreferencesMessages.SEAM_SETTINGS_PREFERENCES_PAGE_SOURCE_FOLDER,
+ getModelSourceFolder());
+
+ IFieldEditor actionPackageEditor =
+ IFieldEditorFactory.INSTANCE.createBrowsePackageEditor(
+ ISeamFacetDataModelProperties.SESSION_BEAN_PACKAGE_NAME,
+ SeamPreferencesMessages.SEAM_SETTINGS_PREFERENCES_PAGE_PACKAGE,
+ "");
+ registerEditor(actionSourceFolderEditor, actionGroup);
+ registerEditor(actionPackageEditor, actionGroup);
+
+ Group testGroup = createGroup(root,
+ SeamPreferencesMessages.SEAM_SETTINGS_PREFERENCES_PAGE_TEST,
+ 3);
+
+ IFieldEditor createTestCheckBox = IFieldEditorFactory.INSTANCE.createCheckboxEditor(
+ ISeamFacetDataModelProperties.TEST_CREATING,
SeamPreferencesMessages.SEAM_SETTINGS_PREFERENCE_PAGE_CREATE_TEST, false);
+ createTestCheckBox.addPropertyChangeListener(new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+ Object value = evt.getNewValue();
+ if (value instanceof Boolean) {
+ setEnabledTestGroup();
+ }
+ }
+ });
+
+ registerEditor(createTestCheckBox, testGroup);
+
+ IFieldEditor testProjectEditor =
SeamWizardFactory.createSeamProjectSelectionFieldEditor(ISeamFacetDataModelProperties.SEAM_TEST_PROJECT,
SeamPreferencesMessages.SEAM_SETTINGS_PREFERENCE_PAGE_TEST_PROJECT,
getTestProjectName(),false);
+ registerEditor(testProjectEditor, testGroup);
+
+ IFieldEditor testSourceFolderEditor =
+ IFieldEditorFactory.INSTANCE.createBrowseSourceFolderEditor(
+ ISeamFacetDataModelProperties.TEST_SOURCE_FOLDER,
+ SeamPreferencesMessages.SEAM_SETTINGS_PREFERENCES_PAGE_SOURCE_FOLDER,
+ getModelSourceFolder());
+
+ IFieldEditor testPackageEditor =
+ IFieldEditorFactory.INSTANCE.createBrowsePackageEditor(
+ ISeamFacetDataModelProperties.TEST_CASES_PACKAGE_NAME,
+ SeamPreferencesMessages.SEAM_SETTINGS_PREFERENCES_PAGE_PACKAGE,
+ "");
+
+ registerEditor(testSourceFolderEditor, testGroup);
+ registerEditor(testPackageEditor, testGroup);
+
setEnabledSeamSuport(warSeamProject!=null);
- setRuntimeIsSelected(getSeamRuntimeName().length()>0);
+// setRuntimeIsSelected(getSeamRuntimeName().length()>0);
return root;
}
+ private String getPrefValue(String seamRuntimeName,String defaultValue) {
+ return preferences.get(
+ ISeamFacetDataModelProperties.SEAM_RUNTIME_NAME,
+ defaultValue);
+ }
+
+ private Group createGroup(Composite parent, String title, int rows) {
+ return createGroupWithSpan(parent,title,rows,1);
+ }
+
+ private Group createGroupWithSpan(Composite parent, String title, int rows, int span) {
+ GridData gd;
+ GridLayout gridLayout;
+ gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
+ gd.horizontalSpan = span;
+ gd.horizontalAlignment = GridData.FILL;
+ gd.grabExcessHorizontalSpace = true;
+ gd.grabExcessVerticalSpace = false;
+
+ Group newGroup = new Group(parent, SWT.NONE);
+ newGroup.setLayoutData(gd);
+ newGroup.setText(title);
+
+ gridLayout = new GridLayout(rows, false);
+ newGroup.setLayout(gridLayout);
+ groups.add(newGroup);
+ return newGroup;
+ }
+
private String getModelSourceFolder() {
String folder = null;
if(preferences!=null) {
@@ -288,6 +390,14 @@
private String getSeamProjectName() {
return warProject!=null ? warProject.getName() : project.getName();
}
+
+ private String getTestProjectName() {
+ String projectName = "";
+ if(preferences!=null) {
+ projectName = preferences.get(ISeamFacetDataModelProperties.SEAM_TEST_PROJECT,
getSeamProjectName());
+ }
+ return projectName;
+ }
/* (non-Javadoc)
* @see
java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
@@ -316,35 +426,101 @@
}
private void storeSettigs() {
- //TODO
-// pref.put("test", "blah-blah-blah");
+ IScopeContext projectScope = new ProjectScope(project);
+ IEclipsePreferences prefs = projectScope.getNode(SeamCorePlugin.PLUGIN_ID);
+
+ prefs.put(ISeamFacetDataModelProperties.SEAM_SETTINGS_VERSION,
+ "1.1");
+
+ prefs.put(ISeamFacetDataModelProperties.JBOSS_AS_DEPLOY_AS,
+ getValue(ISeamFacetDataModelProperties.JBOSS_AS_DEPLOY_AS));
+
+ prefs.put(ISeamFacetDataModelProperties.SEAM_RUNTIME_NAME,
+ getValue(ISeamFacetDataModelProperties.SEAM_RUNTIME_NAME));
+ prefs.put(ISeamFacetDataModelProperties.SEAM_CONNECTION_PROFILE,
+ getValue(ISeamFacetDataModelProperties.SEAM_CONNECTION_PROFILE));
+ prefs.put(ISeamFacetDataModelProperties.SESSION_BEAN_PACKAGE_NAME,
+ getValue(ISeamFacetDataModelProperties.SESSION_BEAN_PACKAGE_NAME));
+ prefs.put(ISeamFacetDataModelProperties.ENTITY_BEAN_PACKAGE_NAME,
+ getValue(ISeamFacetDataModelProperties.ENTITY_BEAN_PACKAGE_NAME));
+ prefs.put(ISeamFacetDataModelProperties.TEST_CASES_PACKAGE_NAME,
+ getValue(ISeamFacetDataModelProperties.TEST_CASES_PACKAGE_NAME));
+ prefs.put(ISeamFacetDataModelProperties.TEST_CREATING,
+ "true");
+ prefs.put(ISeamFacetDataModelProperties.TEST_SOURCE_FOLDER,
+ getValue(ISeamFacetDataModelProperties.TEST_CREATING));
+ prefs.put(ISeamFacetDataModelProperties.SEAM_TEST_PROJECT,
+ getValue(ISeamFacetDataModelProperties.SEAM_TEST_PROJECT));
+ prefs.put(ISeamFacetDataModelProperties.SEAM_EJB_PROJECT,
+ getValue(ISeamFacetDataModelProperties.SEAM_EJB_PROJECT));
+ prefs.put(ISeamFacetDataModelProperties.ENTITY_BEAN_SOURCE_FOLDER,
+ getValue(ISeamFacetDataModelProperties.ENTITY_BEAN_SOURCE_FOLDER));
+ prefs.put(ISeamFacetDataModelProperties.SESSION_BEAN_SOURCE_FOLDER,
+ getValue(ISeamFacetDataModelProperties.SESSION_BEAN_SOURCE_FOLDER));
try {
- preferences.flush();
+ prefs.flush();
} catch (BackingStoreException e) {
SeamGuiPlugin.getPluginLog().logError(e);
}
}
+ private String getValue(String editorName) {
+ return editorRegistry.get(editorName).getValue().toString();
+ }
+
private boolean isSeamSupported() {
return suportSeam;
}
private void setEnabledSeamSuport(boolean enabled) {
+ // just for enabling/disabling groups
+ setEnabledGroups(enabled);
suportSeam = enabled;
- for (String key : editorRegistry.keySet()) {
- if(key!=SeamPreferencesMessages.SEAM_SETTINGS_PREFERENCE_PAGE_SEAM_SUPPORT) {
- editorRegistry.get(key).setEnabled(enabled && runtimeIsSelected);
+ if(!enabled) {
+ // disable all below
+ for (String key : editorRegistry.keySet()) {
+ if(key!=SeamPreferencesMessages.SEAM_SETTINGS_PREFERENCE_PAGE_SEAM_SUPPORT) {
+ editorRegistry.get(key).setEnabled(enabled);
+ }
+ }
+ } else {
+ for (String key : editorRegistry.keySet()) {
+ if(key!=SeamPreferencesMessages.SEAM_SETTINGS_PREFERENCE_PAGE_SEAM_SUPPORT
+ && key!=ISeamFacetDataModelProperties.SEAM_TEST_PROJECT
+ && key!=ISeamFacetDataModelProperties.TEST_SOURCE_FOLDER
+ && key!=ISeamFacetDataModelProperties.TEST_CASES_PACKAGE_PATH
+ && key!=ISeamFacetDataModelProperties.SEAM_EJB_PROJECT) {
+ editorRegistry.get(key).setEnabled(enabled);
+ }
}
- if(key==ISeamFacetDataModelProperties.SEAM_RUNTIME_NAME) {
- editorRegistry.get(key).setEnabled(enabled);
- }
+ setEnabledTestGroup();
+ setEnabledDeploymentGroup();
}
- setEnabledGroups(enabled && runtimeIsSelected);
+
}
+ private void setEnabledDeploymentGroup() {
+ IFieldEditor deployment =
+ editorRegistry.get(ISeamFacetDataModelProperties.JBOSS_AS_DEPLOY_AS);
+
+ editorRegistry.get(ISeamFacetDataModelProperties.SEAM_EJB_PROJECT)
+ .setEnabled(
+ ISeamFacetDataModelProperties.DEPLOY_AS_EAR.equals(
+ deployment.getValue()));
+
+ }
+
+ private void setEnabledTestGroup() {
+ IFieldEditor createTestCheckBox =
editorRegistry.get(ISeamFacetDataModelProperties.TEST_CREATING);
+ boolean enabled = ((Boolean)createTestCheckBox.getValue()).booleanValue();
+ editorRegistry.get(ISeamFacetDataModelProperties.SEAM_TEST_PROJECT).setEnabled(enabled);
+ editorRegistry.get(ISeamFacetDataModelProperties.TEST_SOURCE_FOLDER).setEnabled(enabled);
+ editorRegistry.get(ISeamFacetDataModelProperties.TEST_CASES_PACKAGE_NAME).setEnabled(enabled);
+ }
+
private void setEnabledGroups(boolean enabled) {
for (Group group : groups) {
- group.setEnabled(enabled);
+ group.setEnabled(enabled);
}
}
@@ -376,24 +552,24 @@
}
private SeamVersion[] getSeamVersions() {
-// if(warSeamProject != null) {
-// SeamRuntime r = warSeamProject.getRuntime();
-// if(r != null) {
-// return new SeamVersion[]{r.getVersion()};
-// }
-// String jarLocation = getJBossSeamJarLocation();
-// if(jarLocation != null) {
-// String folder = new File(jarLocation).getParent();
-// String vs =
SeamRuntimeListFieldEditor.SeamRuntimeWizardPage.getSeamVersion(folder);
-// SeamVersion v = findMatchingVersion(vs);
-// if(v != null) {
-// return new SeamVersion[]{v};
-// }
-// }
-// }
+ if(warSeamProject != null) {
+ SeamRuntime r = warSeamProject.getRuntime();
+ if(r != null) {
+ return new SeamVersion[]{r.getVersion()};
+ }
+ String jarLocation = getJBossSeamJarLocation();
+ if(jarLocation != null) {
+ String folder = new File(jarLocation).getParent();
+ String vs = SeamRuntimeListFieldEditor.SeamRuntimeWizardPage.getSeamVersion(folder);
+ SeamVersion v = findMatchingVersion(vs);
+ if(v != null) {
+ return new SeamVersion[]{v};
+ }
+ }
+ }
return SeamVersion.ALL_VERSIONS;
}
-/*
+
private SeamVersion findMatchingVersion(String vs) {
if(vs == null) return null;
if(vs.matches(SeamVersion.SEAM_1_2.toString().replace(".", "\\.") +
".*")) {
@@ -425,5 +601,5 @@
}
return null;
}
-*/
+
}
\ No newline at end of file
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/BaseFieldEditor.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/BaseFieldEditor.java 2008-03-10
19:58:43 UTC (rev 6826)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/BaseFieldEditor.java 2008-03-11
05:10:02 UTC (rev 6827)
@@ -42,6 +42,8 @@
protected Map<Object, Object> data = null;
+ private boolean enabled = true;
+
/**
*
* @param name
@@ -155,17 +157,14 @@
*
*/
public boolean isEnabled() {
- if(getSwtControls().length==0)
- return true;
- else {
- return getSwtControls()[0].isEnabled();
- }
+ return this.enabled ;
}
/**
*
*/
public void setEnabled(boolean enabled) {
+ this.enabled = enabled;
Control[] controls = getSwtControls();
for(int i=0;i<controls.length;i++) {
Control control = controls[i];
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/CompositeEditor.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/CompositeEditor.java 2008-03-10
19:58:43 UTC (rev 6826)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/CompositeEditor.java 2008-03-11
05:10:02 UTC (rev 6827)
@@ -58,6 +58,7 @@
}
controls[i].setLayoutData(gd);
+ controls[i].setEnabled(isEnabled());
}
}
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/IFieldEditorFactory.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/IFieldEditorFactory.java 2008-03-10
19:58:43 UTC (rev 6826)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/IFieldEditorFactory.java 2008-03-11
05:10:02 UTC (rev 6827)
@@ -17,7 +17,7 @@
public interface IFieldEditorFactory {
- public static final IFieldEditorFactory INSTANCE = new SwtFieldEditorFactory();
+ final IFieldEditorFactory INSTANCE = new SwtFieldEditorFactory();
/**
*
@@ -62,7 +62,7 @@
* @param defaultValue
* @return
*/
- public ITaggedFieldEditor createRadioEditor(String name, String label,
+ ITaggedFieldEditor createRadioEditor(String name, String label,
List<String> labels, List values, Object defaultValue);
/**
@@ -103,6 +103,12 @@
*/
IFieldEditor createBrowseSourceFolderEditor(String name, String label, String
defaultValue);
+
+ IFieldEditor createBrowsePackageEditor(String name, String label, String defaultValue)
;
+
+
+ IFieldEditor createBrowseSeamProjectEditor(String name, String label, String
defaultValue);
+
/**
*
* @param name
@@ -132,7 +138,7 @@
* @param validator
* @return
*/
- public IFieldEditor createButtonFieldEditor(String name, String label,
+ IFieldEditor createButtonFieldEditor(String name, String label,
String defaultValue, ButtonFieldEditor.ButtonPressedAction action,
IValidator validator);
@@ -148,15 +154,17 @@
* @param validator
* @return
*/
- public IFieldEditor createComboWithTwoButtons(String name, String label,
+ IFieldEditor createComboWithTwoButtons(String name, String label,
List values, Object defaultValue, boolean flat,
ButtonFieldEditor.ButtonPressedAction action1,
ButtonFieldEditor.ButtonPressedAction action2, IValidator validator);
- public ButtonFieldEditor.ButtonPressedAction createNotImplementedYetAction(String
buttonName);
+ ButtonFieldEditor.ButtonPressedAction createNotImplementedYetAction(String buttonName);
- public IFieldEditor createComboWithButton(String name, String label,
+ IFieldEditor createComboWithButton(String name, String label,
List values, Object defaultValue, boolean flat,
ButtonPressedAction action1,
IValidator validator);
+
+
}
\ No newline at end of file
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/SwtFieldEditorFactory.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/SwtFieldEditorFactory.java 2008-03-10
19:58:43 UTC (rev 6826)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/SwtFieldEditorFactory.java 2008-03-11
05:10:02 UTC (rev 6827)
@@ -22,6 +22,7 @@
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.ui.JavaElementLabelProvider;
@@ -146,6 +147,19 @@
return editor;
}
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.seam.ui.widget.editor.IFieldEditorFactory#createBrowseSourceFolderEditor(java.lang.String,
java.lang.String, java.lang.String)
+ */
+ public IFieldEditor createBrowsePackageEditor(String name, String label, String
defaultValue) {
+ ButtonFieldEditor.ButtonPressedAction action =
createSelectPackageAction(SeamUIMessages.SWT_FIELD_EDITOR_FACTORY_BROWS, defaultValue);
+ CompositeEditor editor = new CompositeEditor(name, label, defaultValue);
+ editor.addFieldEditors(new IFieldEditor[]{new LabelFieldEditor(name, label),
+ new TextFieldEditor(name, label, defaultValue),
+ new ButtonFieldEditor(name, action, defaultValue)});
+ action.setFieldEditor(editor);
+ return editor;
+ }
+
/**
* @param buttonName
* @return
@@ -213,6 +227,17 @@
*/
private static class JavaSourceContentProvider extends
StandardJavaElementContentProvider {
+ boolean providePackages = false;
+
+ public JavaSourceContentProvider() {
+ super(false);
+ }
+
+ public JavaSourceContentProvider(boolean providePackages) {
+ this();
+ this.providePackages = providePackages;
+ }
+
/*
* (non-Javadoc)
* @see
org.eclipse.jdt.ui.StandardJavaElementContentProvider#hasChildren(java.lang.Object)
@@ -220,6 +245,8 @@
@Override
public boolean hasChildren(Object element) {
if (element instanceof IPackageFragmentRoot) {
+ return providePackages;
+ } else if(element instanceof IPackageFragment) {
return false;
}
return true;
@@ -268,7 +295,12 @@
}
}
if (element instanceof IPackageFragmentRoot) {
- return NO_CHILDREN;
+ IPackageFragmentRoot pkgRoot = (IPackageFragmentRoot)element;
+ try {
+ return pkgRoot.getChildren();
+ } catch (JavaModelException e) {
+ return NO_CHILDREN;
+ }
}
return super.getChildren(element);
@@ -381,6 +413,29 @@
* @param buttonName
* @return
*/
+ public ButtonFieldEditor.ButtonPressedAction createSelectPackageAction(String
buttonName, String defaultValue) {
+ return new ButtonFieldEditor.ButtonPressedAction(buttonName) {
+ @Override
+ public void run() {
+ final ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(
+ Display.getCurrent().getActiveShell(),
+ new JavaElementLabelProvider(), new JavaSourceContentProvider(true));
+ dialog.setInput(ResourcesPlugin.getWorkspace());
+ if (dialog.open() == Window.OK) {
+ IPackageFragment pack = (IPackageFragment) dialog.getFirstResult();
+ IPath newPath = pack.getResource().getFullPath();
+ String value = newPath.toString();
+ getFieldEditor().setValue(value);
+ }
+ }
+ };
+ }
+
+ /**
+ *
+ * @param buttonName
+ * @return
+ */
public ButtonFieldEditor.ButtonPressedAction createSelectFileAction(String buttonName)
{
return new ButtonFieldEditor.ButtonPressedAction(buttonName) {
@Override
@@ -443,4 +498,10 @@
});
return editor;
}
+
+ public IFieldEditor createBrowseSeamProjectEditor(String name,
+ String label, String defaultValue) {
+ // TODO Auto-generated method stub
+ return null;
+ }
}
\ No newline at end of file
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/TextFieldEditor.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/TextFieldEditor.java 2008-03-10
19:58:43 UTC (rev 6826)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/TextFieldEditor.java 2008-03-11
05:10:02 UTC (rev 6827)
@@ -114,6 +114,7 @@
Object value = getValue();
textField.setText(getValue().toString());
textField.setEditable(isEditable());
+ textField.setEnabled(isEnabled());
fTextField.addPropertyChangeListener(this);
} else if (parent!=null){
Assert.isTrue(parent==fTextField.getTextControl().getParent());