Author: dgolovin
Date: 2008-10-29 16:57:39 -0400 (Wed, 29 Oct 2008)
New Revision: 11310
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamActionWizard.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamBaseOperation.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamBaseWizard.java
Log:
Fix for JUnit tests errors in sem.ui related to opening javaEditor with asyncExec.
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamActionWizard.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamActionWizard.java 2008-10-29
20:13:10 UTC (rev 11309)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamActionWizard.java 2008-10-29
20:57:39 UTC (rev 11310)
@@ -15,13 +15,19 @@
import java.util.Map;
import org.eclipse.core.commands.operations.IUndoableOperation;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.ide.IDE;
import org.jboss.tools.seam.internal.core.project.facet.ISeamFacetDataModelProperties;
import org.jboss.tools.seam.ui.ISeamHelpContextIds;
+import org.jboss.tools.seam.ui.SeamGuiPlugin;
import org.jboss.tools.seam.ui.SeamUIMessages;
import org.jboss.tools.seam.ui.widget.editor.INamedElement;
@@ -32,6 +38,11 @@
*/
public class SeamActionWizard extends SeamBaseWizard implements INewWizard {
+ @Override
+ public boolean performFinish() {
+ return super.performFinish();
+ }
+
public void createPageControls(Composite pageContainer) {
super.createPageControls(pageContainer);
PlatformUI.getWorkbench().getHelpSystem().setHelp(pageContainer,
ISeamHelpContextIds.NEW_SEAM_ACTION);
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamBaseOperation.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamBaseOperation.java 2008-10-29
20:13:10 UTC (rev 11309)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamBaseOperation.java 2008-10-29
20:57:39 UTC (rev 11310)
@@ -94,47 +94,14 @@
public IStatus execute(IProgressMonitor monitor, IAdaptable info)
throws ExecutionException {
IStatus result = Status.OK_STATUS;
- Map<String, INamedElement> params = (Map)info.getAdapter(Map.class);
- final IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(
- params.get(IParameter.SEAM_PROJECT_NAME).getValueAsString());
+
+
+ final SeamProjectsSet seamPrjSet = new SeamProjectsSet(getProject(info));
- Map<String, Object> vars = new HashMap<String, Object>();
- IEclipsePreferences seamFacetPrefs = SeamCorePlugin.getSeamPreferences(project);
- SeamProjectsSet seamPrjSet = new SeamProjectsSet(project);
-
try {
- for (String key : seamFacetPrefs.keys()) {
- vars.put(key, seamFacetPrefs.get(key, "")); //$NON-NLS-1$
- }
+
+ Map<String, Object> vars = loadParameters(info, seamPrjSet);
- for (Object valueHolder : params.values()) {
- INamedElement elem = (INamedElement)valueHolder;
- vars.put(elem.getName(),elem.getValue().toString());
- }
-
- loadCustomVariables(vars);
-
- String actionFolder = getSessionBeanPackageName(seamFacetPrefs, params);
- String entityFolder = getEntityBeanPackageName(seamFacetPrefs, params);
- String testFolder = getTestCasesPackageName(seamFacetPrefs, params);
-
- vars.put(IParameter.SEAM_PROJECT_INSTANCE, project);
- vars.put(IParameter.JBOSS_SEAM_HOME,
SeamRuntimeManager.getInstance().getRuntimeForProject(project).getHomeDir());
-
- putResourceLocationProperty(vars, IParameter.SEAM_PROJECT_LOCATION_PATH, project);
- putResourceLocationProperty(vars, IParameter.SEAM_PROJECT_WEBCONTENT_PATH,
seamPrjSet.getViewsFolder());
- putResourceLocationProperty(vars, IParameter.SEAM_PROJECT_SRC_ACTION,
seamPrjSet.getActionFolder());
- putResourceLocationProperty(vars, IParameter.SEAM_PROJECT_SRC_MODEL,
seamPrjSet.getModelFolder());
- putResourceLocationProperty(vars, IParameter.SEAM_EJB_PROJECT_LOCATION_PATH,
seamPrjSet.getEjbProject());
- putResourceLocationProperty(vars, IParameter.SEAM_TEST_PROJECT_LOCATION_PATH,
seamPrjSet.getTestProject());
- putResourceLocationProperty(vars, IParameter.TEST_SOURCE_FOLDER,
seamPrjSet.getTestsFolder());
- putPackageLocationProperty(vars, IParameter.SESSION_BEAN_PACKAGE_PATH, actionFolder);
- putResourceLocationProperty(vars, IParameter.SESSION_BEAN_PACKAGE_NAME,
actionFolder);
- putPackageLocationProperty(vars, IParameter.TEST_CASES_PACKAGE_PATH, testFolder);
- putResourceLocationProperty(vars, IParameter.TEST_CASES_PACKAGE_NAME, testFolder);
- putPackageLocationProperty(vars, IParameter.ENTITY_BEAN_PACKAGE_PATH, entityFolder);
- putResourceLocationProperty(vars, IParameter.ENTITY_BEAN_PACKAGE_NAME, entityFolder);
-
List<FileMapping> fileMapping = getFileMappings(vars);
List<String[]> fileMappingCopy = applyVariables(fileMapping,vars);
FilterSetCollection filters = getFilterSetCollection(vars);
@@ -146,23 +113,23 @@
index++;
}
- Display.getCurrent().asyncExec(new Runnable() {
- /* (non-Javadoc)
- * @see java.lang.Runnable#run()
- */
- public void run() {
- if(file.length > 0){
- IFile iFile = project.getWorkspace().getRoot().getFileForLocation(new
Path(file[0].getAbsolutePath()));
- try {
- IDE.openEditor(SeamGuiPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage(),
iFile);
- } catch (PartInitException e) {
- SeamGuiPlugin.getPluginLog().logError(e);
- }
- }
- }
- });
+// Display.getCurrent().asyncExec(new Runnable() {
+// /* (non-Javadoc)
+// * @see java.lang.Runnable#run()
+// */
+// public void run() {
+// if(file.length > 0){
+// IFile iFile =
seamPrjSet.getWarProject().getWorkspace().getRoot().getFileForLocation(new
Path(file[0].getAbsolutePath()));
+// try {
+// IDE.openEditor(SeamGuiPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage(),
iFile);
+// } catch (PartInitException e) {
+// SeamGuiPlugin.getPluginLog().logError(e);
+// }
+// }
+// }
+// });
if(shouldTouchServer(seamPrjSet)) {
- WebUtils.changeTimeStamp(project);
+ WebUtils.changeTimeStamp(seamPrjSet.getWarProject());
}
} catch (BackingStoreException e) {
result = new Status(IStatus.ERROR,SeamGuiPlugin.PLUGIN_ID,e.getMessage(),e);
@@ -201,6 +168,63 @@
return result;
}
+ private Map<String, Object> loadParameters(IAdaptable info, SeamProjectsSet
seamPrjSet) throws BackingStoreException {
+ Map<String, INamedElement> params = (Map)info.getAdapter(Map.class);
+ IEclipsePreferences seamFacetPrefs =
SeamCorePlugin.getSeamPreferences(seamPrjSet.getWarProject());
+
+ Map<String, Object> vars = new HashMap<String, Object>();
+
+ for (String key : seamFacetPrefs.keys()) {
+ vars.put(key, seamFacetPrefs.get(key, "")); //$NON-NLS-1$
+ }
+
+ for (Object valueHolder : params.values()) {
+ INamedElement elem = (INamedElement)valueHolder;
+ vars.put(elem.getName(),elem.getValue().toString());
+ }
+
+ loadCustomVariables(vars);
+
+ String actionFolder = getSessionBeanPackageName(seamFacetPrefs, params);
+ String entityFolder = getEntityBeanPackageName(seamFacetPrefs, params);
+ String testFolder = getTestCasesPackageName(seamFacetPrefs, params);
+
+ vars.put(IParameter.SEAM_PROJECT_INSTANCE, seamPrjSet.getWarProject());
+ vars.put(IParameter.JBOSS_SEAM_HOME,
SeamRuntimeManager.getInstance().getRuntimeForProject(seamPrjSet.getWarProject()).getHomeDir());
+
+ putResourceLocationProperty(vars, IParameter.SEAM_PROJECT_LOCATION_PATH,
seamPrjSet.getWarProject());
+ putResourceLocationProperty(vars, IParameter.SEAM_PROJECT_WEBCONTENT_PATH,
seamPrjSet.getViewsFolder());
+ putResourceLocationProperty(vars, IParameter.SEAM_PROJECT_SRC_ACTION,
seamPrjSet.getActionFolder());
+ putResourceLocationProperty(vars, IParameter.SEAM_PROJECT_SRC_MODEL,
seamPrjSet.getModelFolder());
+ putResourceLocationProperty(vars, IParameter.SEAM_EJB_PROJECT_LOCATION_PATH,
seamPrjSet.getEjbProject());
+ putResourceLocationProperty(vars, IParameter.SEAM_TEST_PROJECT_LOCATION_PATH,
seamPrjSet.getTestProject());
+ putResourceLocationProperty(vars, IParameter.TEST_SOURCE_FOLDER,
seamPrjSet.getTestsFolder());
+ putPackageLocationProperty(vars, IParameter.SESSION_BEAN_PACKAGE_PATH, actionFolder);
+ putResourceLocationProperty(vars, IParameter.SESSION_BEAN_PACKAGE_NAME, actionFolder);
+ putPackageLocationProperty(vars, IParameter.TEST_CASES_PACKAGE_PATH, testFolder);
+ putResourceLocationProperty(vars, IParameter.TEST_CASES_PACKAGE_NAME, testFolder);
+ putPackageLocationProperty(vars, IParameter.ENTITY_BEAN_PACKAGE_PATH, entityFolder);
+ putResourceLocationProperty(vars, IParameter.ENTITY_BEAN_PACKAGE_NAME, entityFolder);
+ return vars;
+ }
+
+ public void openResultInEditor(IAdaptable info) {
+ final SeamProjectsSet seamPrjSet = new SeamProjectsSet(getProject(info));
+ try {
+ Map<String, Object> vars = loadParameters(info, seamPrjSet);
+ List<FileMapping> fileMapping = getFileMappings(vars);
+ List<String[]> fileMappingCopy = applyVariables(fileMapping,vars);
+ IFile iFile =
seamPrjSet.getWarProject().getWorkspace().getRoot().getFileForLocation(new
Path(fileMappingCopy.get(0)[1]));
+ IDE.openEditor(SeamGuiPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage(),
iFile);
+ } catch (CoreException e) {
+
+ } catch (BackingStoreException e) {
+
+ }
+
+
+ }
+
protected boolean shouldTouchServer(SeamProjectsSet seamPrjSet) {
return !seamPrjSet.isWarConfiguration();
}
@@ -217,6 +241,13 @@
return seamFacetPrefs.get(IParameter.TEST_CASES_PACKAGE_NAME, "");
}
+ protected IProject getProject(IAdaptable info) {
+ Map<String, INamedElement> params = (Map)info.getAdapter(Map.class);
+
+ return ResourcesPlugin.getWorkspace().getRoot().getProject(
+ params.get(IParameter.SEAM_PROJECT_NAME).getValueAsString());
+ }
+
/**
* @param fileMapping
* @param vars
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamBaseWizard.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamBaseWizard.java 2008-10-29
20:13:10 UTC (rev 11309)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamBaseWizard.java 2008-10-29
20:57:39 UTC (rev 11310)
@@ -75,6 +75,10 @@
operation.addContext(undoContext);
try {
result = operationHistory.execute(operation, monitor, (IAdaptable)getPages()[0]);
+ if(operation instanceof SeamBaseOperation) {
+ SeamBaseOperation seamOperation = (SeamBaseOperation)operation;
+ seamOperation.openResultInEditor((IAdaptable)getPages()[0]);
+ }
} catch (ExecutionException e) {
result = new Status(IStatus.ERROR,SeamGuiPlugin.PLUGIN_ID,e.getMessage(),e);
SeamCorePlugin.getPluginLog().logError(e);