Author: akazakov
Date: 2008-04-04 05:32:08 -0400 (Fri, 04 Apr 2008)
New Revision: 7313
Added:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamContextValidationHelper.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamProjectPropertyValidator.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamValidationHelper.java
Removed:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamValidationHelper.java
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/plugin.xml
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamProjectsSet.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.core/src/org/jboss/tools/seam/internal/core/project/facet/ISeamFacetDataModelProperties.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamCoreValidator.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamELValidator.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamValidator.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamValidatorManager.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/widget/editor/SwtFieldEditorFactory.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-1003
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/plugin.xml
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/plugin.xml 2008-04-04 08:46:10 UTC (rev
7312)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/plugin.xml 2008-04-04 09:32:08 UTC (rev
7313)
@@ -260,7 +260,7 @@
markerIdValue="seamProblem">
</markerId>
<helper
- class="org.jboss.tools.seam.internal.core.validation.SeamValidationHelper">
+ class="org.jboss.tools.seam.internal.core.validation.SeamContextValidationHelper">
</helper>
<run
class="org.jboss.tools.seam.internal.core.validation.SeamValidatorManager"
@@ -272,7 +272,24 @@
</dependentValidator>
</validator>
</extension>
-
+
+ <extension
+ point="org.eclipse.wst.validation.validator"
+ id="SeamProjectPropertyValidator"
+ name="Seam Project Property Validator">
+ <validator>
+ <filter objectClass="org.eclipse.core.resources.IFolder"
nameFilter="*"/>
+ <filter objectClass="org.eclipse.core.resources.IProject"
nameFilter="*"/>
+ <helper class="org.jboss.tools.seam.internal.core.validation.SeamValidationHelper"/>
+ <markerId markerIdValue="seamProblem"/>
+ <run
+
class="org.jboss.tools.seam.internal.core.validation.SeamProjectPropertyValidator"
+ incremental="true"
+ fullBuild="true"
+ />
+ </validator>
+ </extension>
+
<extension
id="seamProblem"
name="Seam Problem"
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamProjectsSet.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamProjectsSet.java 2008-04-04
08:46:10 UTC (rev 7312)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamProjectsSet.java 2008-04-04
09:32:08 UTC (rev 7313)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.seam.core;
+import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
@@ -118,40 +119,43 @@
*
* @return the action folder (this folder is not guaranteed to exist!)
*/
- public IFolder getActionFolder() {
+ public IContainer getActionFolder() {
String folderPath = null;
if(prefs!=null) {
folderPath = prefs.get(ISeamFacetDataModelProperties.SESSION_BEAN_SOURCE_FOLDER,
null);
}
- if(folderPath==null) {
+ if(folderPath==null || folderPath.length()==0) {
return getSourceFolder();
}
- return (IFolder)ResourcesPlugin.getWorkspace().getRoot().findMember(folderPath);
+ return (IContainer)ResourcesPlugin.getWorkspace().getRoot().findMember(folderPath);
}
/**
*
* @return the model folder if exists (this folder is not guaranteed to exist!)
*/
- public IFolder getModelFolder() {
+ public IContainer getModelFolder() {
String folderPath = null;
if(prefs!=null) {
folderPath = prefs.get(ISeamFacetDataModelProperties.ENTITY_BEAN_SOURCE_FOLDER,
null);
}
- if(folderPath==null) {
+ if(folderPath==null || folderPath.length()==0) {
return getSourceFolder();
}
- return (IFolder)ResourcesPlugin.getWorkspace().getRoot().findMember(folderPath);
+ return (IContainer)ResourcesPlugin.getWorkspace().getRoot().findMember(folderPath);
}
- private IFolder getSourceFolder() {
+ private IContainer getSourceFolder() {
IFolder webSrcFolder = findWebSrcFolder();
if(webSrcFolder!=null) {
return webSrcFolder;
}
IJavaProject javaProject = EclipseResourceUtil.getJavaProject(war);
+ if(javaProject==null) {
+ return war;
+ }
try {
IPackageFragmentRoot[] roots = javaProject.getPackageFragmentRoots();
for (int i = 0; i < roots.length; i++) {
@@ -169,12 +173,12 @@
* Returns web contents folder.
* @return
*/
- public IFolder getViewsFolder() {
+ public IContainer getViewsFolder() {
String folderPath = null;
if(prefs!=null) {
folderPath = prefs.get(ISeamFacetDataModelProperties.WEB_CONTENTS_FOLDER, null);
}
- if(folderPath==null) {
+ if(folderPath==null || folderPath.length()==0) {
IVirtualComponent com = ComponentCore.createComponent(war);
if(com!=null) {
IVirtualFolder webRootFolder = com.getRootFolder().getFolder(new
Path("/")); //$NON-NLS-1$
@@ -182,26 +186,26 @@
return (IFolder)webRootFolder.getUnderlyingFolder();
}
}
- return null;
+ return getWarProject();
}
- return (IFolder)ResourcesPlugin.getWorkspace().getRoot().findMember(folderPath);
+ return (IContainer)ResourcesPlugin.getWorkspace().getRoot().findMember(folderPath);
}
/**
* Returns source folder for test cases.
* @return
*/
- public IFolder getTestsFolder() {
+ public IContainer getTestsFolder() {
String folderPath = null;
if(prefs!=null) {
folderPath = prefs.get(ISeamFacetDataModelProperties.TEST_SOURCE_FOLDER, null);
}
- if(folderPath==null) {
+ if(folderPath==null || folderPath.length()==0) {
return getSourceFolder();
}
- return (IFolder)ResourcesPlugin.getWorkspace().getRoot().findMember(folderPath);
+ return (IContainer)ResourcesPlugin.getWorkspace().getRoot().findMember(folderPath);
}
public String getEntityPackage(){
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-04-04
08:46:10 UTC (rev 7312)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java 2008-04-04
09:32:08 UTC (rev 7313)
@@ -55,6 +55,7 @@
import org.jboss.tools.seam.core.project.facet.SeamRuntime;
import org.jboss.tools.seam.core.project.facet.SeamRuntimeManager;
import org.jboss.tools.seam.internal.core.el.VariableResolver;
+import org.jboss.tools.seam.internal.core.project.facet.ISeamFacetDataModelProperties;
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;
@@ -72,8 +73,6 @@
// boolean useDefaultRuntime = false;
- String runtimeName = null;
-
Set<IPath> sourcePaths = new HashSet<IPath>();
Map<IPath, LoadedDeclarations> sourcePaths2 = new HashMap<IPath,
LoadedDeclarations>();
@@ -136,11 +135,8 @@
*
*/
public String getRuntimeName() {
- SeamRuntime runtime = getRuntime();
- if(runtime!=null) {
- return runtime.getName();
- }
- return runtimeName;
+ IEclipsePreferences p = getSeamPreferences();
+ return p.get(ISeamFacetDataModelProperties.SEAM_RUNTIME_NAME, null);
}
/**
@@ -154,6 +150,7 @@
ISeamProject sp = SeamCorePlugin.getSeamProject(p, false);
return sp == null ? null : sp.getRuntime();
}
+ String runtimeName = getRuntimeName();
return runtimeName == null ? null :
SeamRuntimeManager.getInstance().findRuntimeByName(runtimeName);
}
@@ -170,17 +167,21 @@
}
public void setRuntimeName(String runtimeName) {
- if(this.runtimeName == runtimeName) return;
- if(this.runtimeName != null && this.runtimeName.equals(runtimeName)) return;
- SeamRuntime d = SeamRuntimeManager.getInstance().getRuntimeForProject(project);
+ IEclipsePreferences prefs = getSeamPreferences();
+ String storedRuntimeName = getRuntimeName();
+ boolean changed = (storedRuntimeName == null) ? runtimeName != null :
!storedRuntimeName.equals(runtimeName);
+ if(!changed) return;
- boolean useDefaultRuntime = d != null && d.getName().equals(runtimeName);
- if(useDefaultRuntime) {
- this.runtimeName = null;
+ if(runtimeName == null) {
+ prefs.remove(RUNTIME_NAME);
} else {
- this.runtimeName = runtimeName;
+ prefs.put(RUNTIME_NAME, runtimeName);
+ }
+ try {
+ prefs.flush();
+ } catch (BackingStoreException e) {
+ SeamCorePlugin.getPluginLog().logError(e);
}
- storeRuntime();
}
/**
@@ -247,34 +248,9 @@
setSourcePath(project.getFullPath());
resource = project;
classPath.init();
- loadRuntime();
// load();
}
- /**
- *
- */
- void loadRuntime() {
- IEclipsePreferences prefs = getSeamPreferences();
- if(prefs == null) return;
- runtimeName = prefs.get(RUNTIME_NAME, null);
- if(runtimeName != null) {
- } 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)) {
-// runtimeName = null;
-// storeRuntime();
-// }
-// }
-// }
-// });
- }
-
IEclipsePreferences preferences = null;
/**
@@ -481,28 +457,7 @@
XMLUtilities.serialize(root, file.getAbsolutePath());
}
-
- /**
- *
- */
- void storeRuntime() {
- IEclipsePreferences prefs = getSeamPreferences();
- String runtimeName = prefs.get(RUNTIME_NAME, null);
- boolean changed = (this.runtimeName == null) ? runtimeName != null :
!this.runtimeName.equals(runtimeName);
- if(!changed) return;
-
- if(this.runtimeName == null) {
- prefs.remove(RUNTIME_NAME);
- } else {
- prefs.put(RUNTIME_NAME, this.runtimeName);
- }
- try {
- prefs.flush();
- } catch (BackingStoreException e) {
- SeamCorePlugin.getPluginLog().logError(e);
- }
- }
-
+
/*
*
*/
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/ISeamFacetDataModelProperties.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/ISeamFacetDataModelProperties.java 2008-04-04
08:46:10 UTC (rev 7312)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/ISeamFacetDataModelProperties.java 2008-04-04
09:32:08 UTC (rev 7313)
@@ -86,6 +86,11 @@
String SEAM_SETTINGS_VERSION = "seam.project.settings.version";
/**
+ * Seam settings version 1.0.
+ */
+ String SEAM_SETTINGS_VERSION_1_0 = "1.0";
+
+ /**
* Seam settings version 1.1.
*/
String SEAM_SETTINGS_VERSION_1_1 = "1.1";
Copied:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamContextValidationHelper.java
(from rev 7241,
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamValidationHelper.java)
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamContextValidationHelper.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamContextValidationHelper.java 2008-04-04
09:32:08 UTC (rev 7313)
@@ -0,0 +1,74 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.seam.internal.core.validation;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.ui.editors.text.TextFileDocumentProvider;
+import org.jboss.tools.seam.internal.core.SeamProject;
+
+/**
+ * Helper for Seam Validators that use Seam Validator Context.
+ * @author Alexey Kazakov
+ */
+public class SeamContextValidationHelper extends SeamValidationHelper {
+
+ protected SeamValidationContext validationContext;
+ protected TextFileDocumentProvider documentProvider = new TextFileDocumentProvider();
+
+ /*
+ * (non-Javadoc)
+ * @see
org.eclipse.wst.validation.internal.operations.WorkbenchContext#registerResource(org.eclipse.core.resources.IResource)
+ */
+ @Override
+ public void registerResource(IResource resource) {
+ if(resource instanceof IFile) {
+ IFile file = (IFile)resource;
+ if(!file.exists()) {
+ getValidationContext().addRemovedFile(file);
+ } else {
+ getValidationContext().registerFile(file);
+ }
+ }
+ }
+
+ /**
+ * @return Set of changed resources
+ */
+ public Set<IFile> getChangedFiles() {
+ Set<IFile> result = new HashSet<IFile>();
+ String[] uris = getURIs();
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ for (int i = 0; i < uris.length; i++) {
+ IFile currentFile = root.getFile(new Path(uris[i]));
+ result.add(currentFile);
+ }
+ result.addAll(getValidationContext().getRemovedFiles());
+ return result;
+ }
+
+ public SeamValidationContext getValidationContext() {
+ if(validationContext==null) {
+ validationContext = ((SeamProject)getSeamProject()).getValidationContext();
+ }
+ return validationContext;
+ }
+
+ public TextFileDocumentProvider getDocumentProvider(){
+ return documentProvider;
+ }
+}
\ No newline at end of file
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamCoreValidator.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamCoreValidator.java 2008-04-04
08:46:10 UTC (rev 7312)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamCoreValidator.java 2008-04-04
09:32:08 UTC (rev 7313)
@@ -94,7 +94,7 @@
protected static final String VALIDATING_CLASS_MESSAGE_ID =
"VALIDATING_CLASS";
public SeamCoreValidator(SeamValidatorManager validatorManager,
- SeamValidationHelper coreHelper, IReporter reporter,
+ SeamContextValidationHelper coreHelper, IReporter reporter,
SeamValidationContext validationContext, ISeamProject project) {
super(validatorManager, coreHelper, reporter, validationContext, project);
}
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamELValidator.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamELValidator.java 2008-04-04
08:46:10 UTC (rev 7312)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamELValidator.java 2008-04-04
09:32:08 UTC (rev 7313)
@@ -76,7 +76,7 @@
private ElVarSearcher elVarSearcher;
public SeamELValidator(SeamValidatorManager validatorManager,
- SeamValidationHelper coreHelper, IReporter reporter,
+ SeamContextValidationHelper coreHelper, IReporter reporter,
SeamValidationContext validationContext, ISeamProject project) {
super(validatorManager, coreHelper, reporter, validationContext, project);
elVarSearcher = new ElVarSearcher(project, engine);
Added:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamProjectPropertyValidator.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamProjectPropertyValidator.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamProjectPropertyValidator.java 2008-04-04
09:32:08 UTC (rev 7313)
@@ -0,0 +1,185 @@
+ /*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.seam.internal.core.validation;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.jobs.ISchedulingRule;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.jdt.core.JavaConventions;
+import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
+import org.eclipse.wst.validation.internal.core.ValidationException;
+import org.eclipse.wst.validation.internal.provisional.core.IReporter;
+import org.eclipse.wst.validation.internal.provisional.core.IValidationContext;
+import org.eclipse.wst.validation.internal.provisional.core.IValidatorJob;
+import org.jboss.tools.seam.core.ISeamProject;
+import org.jboss.tools.seam.core.SeamCorePlugin;
+import org.jboss.tools.seam.core.project.facet.SeamRuntimeManager;
+import org.jboss.tools.seam.internal.core.project.facet.ISeamFacetDataModelProperties;
+import org.jboss.tools.seam.internal.core.refactoring.SeamProjectChange;
+
+/**
+ * Validates seam project properties.
+ * @author Alexey Kazakov
+ */
+public class SeamProjectPropertyValidator implements IValidatorJob {
+
+ /* (non-Javadoc)
+ * @see
org.eclipse.wst.validation.internal.provisional.core.IValidatorJob#getSchedulingRule(org.eclipse.wst.validation.internal.provisional.core.IValidationContext)
+ */
+ public ISchedulingRule getSchedulingRule(IValidationContext helper) {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see
org.eclipse.wst.validation.internal.provisional.core.IValidatorJob#validateInJob(org.eclipse.wst.validation.internal.provisional.core.IValidationContext,
org.eclipse.wst.validation.internal.provisional.core.IReporter)
+ */
+ public IStatus validateInJob(IValidationContext helper, IReporter reporter) throws
ValidationException {
+ SeamValidationHelper seamHelper = (SeamValidationHelper)helper;
+ IProject project = seamHelper.getProject();
+ ISeamProject seamProject = SeamCorePlugin.getSeamProject(project, false);
+ if(seamProject!=null) {
+ validateSeamProject(project);
+ }
+
+ IProject[] ps = ResourcesPlugin.getWorkspace().getRoot().getProjects();
+ String projectName = project.getName();
+ for (int i = 0; i < ps.length; i++) {
+ if(ps[i]!=project) {
+ validateProject(projectName, ps[i]);
+ }
+ }
+
+ return OK_STATUS;
+ }
+
+ private void validateProject(String nameOfChangedProject, IProject checkingProject) {
+ ISeamProject seamProject = SeamCorePlugin.getSeamProject(checkingProject, false);
+ if(seamProject==null) {
+ return;
+ }
+ IEclipsePreferences pref = SeamCorePlugin.getSeamPreferences(checkingProject);
+ for (int i = 0; i < SeamProjectChange.PROJECT_NAME_PROPERTIES.length; i++) {
+ if(nameOfChangedProject.equals(pref.get(SeamProjectChange.PROJECT_NAME_PROPERTIES[i],
null))) {
+ validateSeamProject(checkingProject);
+ return;
+ }
+ }
+ for (int i = 0; i < SeamProjectChange.FOLDER_PROPERTIES.length; i++) {
+ if(pref.get(SeamProjectChange.FOLDER_PROPERTIES[i],
"").startsWith("/" + nameOfChangedProject + "/")) {
+ validateSeamProject(checkingProject);
+ return;
+ }
+ }
+ }
+
+ private void validateProjectName(String projectName, boolean canBeEmpty) {
+ if((canBeEmpty || (projectName!=null && projectName.length()==0)) &&
new Path("/").isValidSegment(projectName)) {
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
+ if(project.exists()) {
+ return;
+ }
+ }
+ // Mark invalid project name
+ // TODO
+ }
+
+ private boolean isFolderPathValid(String folderPath, boolean canBeEmpty) {
+ if((canBeEmpty || (folderPath!=null && folderPath.length()==0)) && new
Path("/").isValidSegment(folderPath)) {
+ IResource folder = ResourcesPlugin.getWorkspace().getRoot().findMember(folderPath);
+ if(folder!=null && (folder instanceof IContainer) && folder.exists())
{
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private void validateSorceFolder(String folderPath, String packageName) {
+ if(isFolderPathValid(folderPath, true)) {
+ if(!isPackageNameValid(packageName)) {
+ // Mark invalid source folder path
+ // TODO
+ }
+ return;
+ }
+ // Mark invalid source folder path
+ // TODO
+ }
+
+ private boolean isPackageNameValid(String packageName) {
+ if(packageName==null || packageName.length()==0) {
+ return false;
+ }
+ IStatus status = JavaConventions.validatePackageName(packageName,
CompilerOptions.VERSION_1_5, CompilerOptions.VERSION_1_5);
+ if(status.getSeverity()==IStatus.ERROR) {
+ return false;
+ }
+ return true;
+ }
+
+ private boolean validateSeamProject(IProject project) {
+ IEclipsePreferences pref = SeamCorePlugin.getSeamPreferences(project);
+ String parentProject = pref.get(ISeamFacetDataModelProperties.SEAM_PARENT_PROJECT,
null);
+ if(parentProject!=null) {
+ // EJB or Test project
+ validateProjectName(parentProject, false);
+ } else {
+ // War project
+ String settingVersion = pref.get(ISeamFacetDataModelProperties.SEAM_SETTINGS_VERSION,
ISeamFacetDataModelProperties.SEAM_SETTINGS_VERSION_1_0);
+ String seamRuntimeName = pref.get(ISeamFacetDataModelProperties.SEAM_RUNTIME_NAME,
null);
+ if(seamRuntimeName==null || seamRuntimeName.length()==0 ||
(SeamRuntimeManager.getInstance().findRuntimeByName(seamRuntimeName) == null)) {
+ // Mark unknown runtime
+ // TODO
+ }
+
+ if(ISeamFacetDataModelProperties.DEPLOY_AS_EAR.equals(pref.get(ISeamFacetDataModelProperties.JBOSS_AS_DEPLOY_AS,
null))) {
+ validateProjectName(pref.get(ISeamFacetDataModelProperties.SEAM_EJB_PROJECT, null),
true);
+ }
+ String viewFolder = pref.get(ISeamFacetDataModelProperties.WEB_CONTENTS_FOLDER,
null);
+ if(isFolderPathValid(viewFolder, true)) {
+ // Mark unknown View folder
+ // TODO
+ }
+ validateSorceFolder(pref.get(ISeamFacetDataModelProperties.ENTITY_BEAN_SOURCE_FOLDER,
null),
+ pref.get(ISeamFacetDataModelProperties.ENTITY_BEAN_PACKAGE_NAME, null));
+
+ validateSorceFolder(pref.get(ISeamFacetDataModelProperties.SESSION_BEAN_SOURCE_FOLDER,
null),
+ pref.get(ISeamFacetDataModelProperties.SESSION_BEAN_PACKAGE_NAME, null));
+
+ String createTestString = pref.get(ISeamFacetDataModelProperties.TEST_CREATING,
null);
+ if(settingVersion.equals(ISeamFacetDataModelProperties.SEAM_SETTINGS_VERSION_1_0) ||
+ "true".equals(createTestString)) {
+ validateProjectName(pref.get(ISeamFacetDataModelProperties.SEAM_TEST_PROJECT, null),
true);
+ validateSorceFolder(pref.get(ISeamFacetDataModelProperties.TEST_SOURCE_FOLDER,
null),
+ pref.get(ISeamFacetDataModelProperties.TEST_CASES_PACKAGE_NAME, null));
+ }
+ }
+
+ return true;
+ }
+
+ /* (non-Javadoc)
+ * @see
org.eclipse.wst.validation.internal.provisional.core.IValidator#cleanup(org.eclipse.wst.validation.internal.provisional.core.IReporter)
+ */
+ public void cleanup(IReporter reporter) {
+ }
+
+ /* (non-Javadoc)
+ * @see
org.eclipse.wst.validation.internal.provisional.core.IValidator#validate(org.eclipse.wst.validation.internal.provisional.core.IValidationContext,
org.eclipse.wst.validation.internal.provisional.core.IReporter)
+ */
+ public void validate(IValidationContext helper, IReporter reporter) throws
ValidationException {
+ validateInJob(helper, reporter);
+ }
+}
\ No newline at end of file
Deleted:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamValidationHelper.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamValidationHelper.java 2008-04-04
08:46:10 UTC (rev 7312)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamValidationHelper.java 2008-04-04
09:32:08 UTC (rev 7313)
@@ -1,286 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at
http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.seam.internal.core.validation;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.IMethod;
-import org.eclipse.jdt.core.IPackageFragment;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.ui.editors.text.TextFileDocumentProvider;
-import org.eclipse.wst.validation.internal.operations.WorkbenchContext;
-import org.jboss.tools.common.model.util.EclipseResourceUtil;
-import org.jboss.tools.seam.core.ISeamComponent;
-import org.jboss.tools.seam.core.ISeamElement;
-import org.jboss.tools.seam.core.ISeamProject;
-import org.jboss.tools.seam.core.ISeamTextSourceReference;
-import org.jboss.tools.seam.core.SeamCoreMessages;
-import org.jboss.tools.seam.core.SeamCorePlugin;
-import org.jboss.tools.seam.internal.core.AbstractContextVariable;
-import org.jboss.tools.seam.internal.core.SeamComponentDeclaration;
-import org.jboss.tools.seam.internal.core.SeamProject;
-
-/**
- * Base Helper for Seam Validators.
- * @author Alexey Kazakov
- */
-public class SeamValidationHelper extends WorkbenchContext {
-
- protected SeamValidationContext validationContext;
- protected TextFileDocumentProvider documentProvider = new TextFileDocumentProvider();
-
- /**
- * @return Seam project
- */
- public ISeamProject getSeamProject() {
- ISeamProject project = null;
- try {
- project = SeamCorePlugin.getSeamProject(getProject(), true);
- } catch (Exception e) {
- SeamCorePlugin.getDefault().logError(SeamCoreMessages.SEAM_VALIDATION_HELPER_CANNOT_GET_SEAM_PROJECT,
e);
- }
- return project;
- }
-
- /**
- * @return Java project
- */
- public IJavaProject getJavaProject() {
- return EclipseResourceUtil.getJavaProject(getProject());
- }
-
- /**
- * @param element
- * @return Resource of seam model element
- */
- public IResource getComponentResourceWithName(ISeamElement element) {
- if(element instanceof ISeamComponent) {
- Set declarations = ((ISeamComponent)element).getAllDeclarations();
- for (Object o : declarations) {
- SeamComponentDeclaration d = (SeamComponentDeclaration)o;
- if(d.getLocationFor(SeamComponentDeclaration.PATH_OF_NAME)!=null) {
- return d.getResource();
- }
- }
- }
- return element.getResource();
- }
-
- /**
- * @param seam model element
- * @return location of name attribute
- */
- public ISeamTextSourceReference getLocationOfName(ISeamElement element) {
- return getLocationOfAttribute(element, SeamComponentDeclaration.PATH_OF_NAME);
- }
-
- /**
- * @param seam model element
- * @return location of attribute
- */
- public ISeamTextSourceReference getLocationOfAttribute(ISeamElement element, String
attributeName) {
- ISeamTextSourceReference location = null;
- if(element instanceof AbstractContextVariable) {
- location = ((AbstractContextVariable)element).getLocationFor(attributeName);
- } else if(element instanceof ISeamComponent) {
- Set declarations = ((ISeamComponent)element).getAllDeclarations();
- for (Object d : declarations) {
- location = ((SeamComponentDeclaration)d).getLocationFor(attributeName);
- if(location!=null) {
- break;
- }
- }
- } else if(element instanceof SeamComponentDeclaration) {
- location = ((SeamComponentDeclaration)element).getLocationFor(attributeName);
- }
- if(location==null && element instanceof ISeamTextSourceReference) {
- location = (ISeamTextSourceReference)element;
- }
- return location;
- }
-
- /**
- * @param resource
- * @return true if resource is Jar file
- */
- public boolean isJar(IPath path) {
- if(path == null) {
- throw new
IllegalArgumentException(SeamCoreMessages.SEAM_VALIDATION_HELPER_RESOURCE_MUST_NOT_BE_NULL);
- }
- String ext = path.getFileExtension();
- return ext != null && ext.equalsIgnoreCase("jar"); //$NON-NLS-1$
- }
-
- /**
- * @param element
- * @return true if seam element packed in Jar file
- */
- public boolean isJar(ISeamElement element) {
- return isJar(element.getSourcePath());
- }
-
- /**
- * @param componentXmlFile
- * @return IType of component for <ComponentName>.component.xml
- */
- public IType getClassTypeForComponentXml(IFile componentXmlFile) {
- String className = getClassNameForComponentXml(componentXmlFile);
- if(className==null) {
- return null;
- }
- return findType(className);
- }
-
- /**
- * @param type name
- * @return IType
- */
- public IType findType(String fullyQualifiedName) {
- IProject p = getProject().getProject();
- try {
- IJavaProject jp = EclipseResourceUtil.getJavaProject(p);
- return jp.findType(fullyQualifiedName);
- } catch (JavaModelException e) {
- SeamCorePlugin.getDefault().logError(e);
- return null;
- }
- }
-
- /**
- * @param componentXmlFile
- * @return name of component class for <ComponentName>.component.xml
- */
- public String getClassNameForComponentXml(IFile componentXmlFile) {
- String fileName = componentXmlFile.getName();
- int firstDot = fileName.indexOf('.');
- if(firstDot==-1) {
- return null;
- }
- String className = fileName.substring(0, firstDot);
- IProject p = getProject().getProject();
- try {
- IJavaProject jp = EclipseResourceUtil.getJavaProject(p);
- IPackageFragment packageFragment =
jp.findPackageFragment(componentXmlFile.getFullPath().removeLastSegments(1));
- if(packageFragment==null) {
- return null;
- }
- return packageFragment.getElementName() + "." + className; //$NON-NLS-1$
- } catch (JavaModelException e) {
- SeamCorePlugin.getDefault().logError(e);
- return null;
- }
- }
-
- /**
- * Find setter for property
- * @param type
- * @param propertyName
- * @return
- */
- public IMethod findSetter(IType type, String propertyName) {
- if(propertyName == null || propertyName.length()==0) {
- return null;
- }
- String firstLetter = propertyName.substring(0, 1).toUpperCase();
- String nameWithoutFirstLetter = propertyName.substring(1);
- String setterName = "set" + firstLetter + nameWithoutFirstLetter;
//$NON-NLS-1$
- try {
- return findSetterInHierarchy(type, setterName);
- } catch (JavaModelException e) {
- SeamCorePlugin.getDefault().logError(e);
- }
- return null;
- }
-
- private IMethod findSetterInHierarchy(IType type, String setterName) throws
JavaModelException {
- IMethod[] methods = type.getMethods();
- for (int i = 0; i < methods.length; i++) {
- if(methods[i].getElementName().equals(setterName) &&
methods[i].getParameterNames().length==1) {
- return methods[i];
- }
- }
- String superclassName = type.getSuperclassName();
- if(superclassName!=null) {
- String[][] packages = type.resolveType(superclassName);
- if(packages!=null) {
- for (int i = 0; i < packages.length; i++) {
- String packageName = packages[i][0];
- if(packageName!=null && packageName.length()>0) {
- packageName = packageName + "."; //$NON-NLS-1$
- } else {
- packageName = ""; //$NON-NLS-1$
- }
- String qName = packageName + packages[i][1];
- IType superclass = type.getJavaProject().findType(qName);
- if(superclass!=null) {
- IMethod method = findSetterInHierarchy(superclass, setterName);
- if(method!=null) {
- return method;
- }
- }
- }
- }
- }
- return null;
- }
-
- /*
- * (non-Javadoc)
- * @see
org.eclipse.wst.validation.internal.operations.WorkbenchContext#registerResource(org.eclipse.core.resources.IResource)
- */
- @Override
- public void registerResource(IResource resource) {
- if(resource instanceof IFile) {
- IFile file = (IFile)resource;
- if(!file.exists()) {
- getValidationContext().addRemovedFile(file);
- } else {
- getValidationContext().registerFile(file);
- }
- }
- }
-
- /**
- * @return Set of changed resources
- */
- public Set<IFile> getChangedFiles() {
- Set<IFile> result = new HashSet<IFile>();
- String[] uris = getURIs();
- IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
- for (int i = 0; i < uris.length; i++) {
- IFile currentFile = root.getFile(new Path(uris[i]));
- result.add(currentFile);
- }
- result.addAll(getValidationContext().getRemovedFiles());
- return result;
- }
-
- public SeamValidationContext getValidationContext() {
- if(validationContext==null) {
- validationContext = ((SeamProject)getSeamProject()).getValidationContext();
- }
- return validationContext;
- }
-
- public TextFileDocumentProvider getDocumentProvider(){
- return documentProvider;
- }
-}
\ No newline at end of file
Added:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamValidationHelper.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamValidationHelper.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamValidationHelper.java 2008-04-04
09:32:08 UTC (rev 7313)
@@ -0,0 +1,236 @@
+ /*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.seam.internal.core.validation;
+
+import java.util.Set;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IMethod;
+import org.eclipse.jdt.core.IPackageFragment;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.wst.validation.internal.operations.WorkbenchContext;
+import org.jboss.tools.common.model.util.EclipseResourceUtil;
+import org.jboss.tools.seam.core.ISeamComponent;
+import org.jboss.tools.seam.core.ISeamComponentDeclaration;
+import org.jboss.tools.seam.core.ISeamElement;
+import org.jboss.tools.seam.core.ISeamProject;
+import org.jboss.tools.seam.core.ISeamTextSourceReference;
+import org.jboss.tools.seam.core.SeamCoreMessages;
+import org.jboss.tools.seam.core.SeamCorePlugin;
+import org.jboss.tools.seam.internal.core.AbstractContextVariable;
+import org.jboss.tools.seam.internal.core.SeamComponentDeclaration;
+
+/**
+ * Base Helper for Seam Validators.
+ * @author Alexey Kazakov
+ */
+public class SeamValidationHelper extends WorkbenchContext {
+
+ /**
+ * @return Seam project
+ */
+ public ISeamProject getSeamProject() {
+ ISeamProject project = null;
+ try {
+ project = SeamCorePlugin.getSeamProject(getProject(), true);
+ } catch (Exception e) {
+ SeamCorePlugin.getDefault().logError(SeamCoreMessages.SEAM_VALIDATION_HELPER_CANNOT_GET_SEAM_PROJECT,
e);
+ }
+ return project;
+ }
+
+ /**
+ * @return Java project
+ */
+ public IJavaProject getJavaProject() {
+ return EclipseResourceUtil.getJavaProject(getProject());
+ }
+
+ /**
+ * @param element
+ * @return Resource of seam model element
+ */
+ public IResource getComponentResourceWithName(ISeamElement element) {
+ if(element instanceof ISeamComponent) {
+ Set<ISeamComponentDeclaration> declarations =
((ISeamComponent)element).getAllDeclarations();
+ for (Object o : declarations) {
+ SeamComponentDeclaration d = (SeamComponentDeclaration)o;
+ if(d.getLocationFor(SeamComponentDeclaration.PATH_OF_NAME)!=null) {
+ return d.getResource();
+ }
+ }
+ }
+ return element.getResource();
+ }
+
+ /**
+ * @param seam model element
+ * @return location of name attribute
+ */
+ public ISeamTextSourceReference getLocationOfName(ISeamElement element) {
+ return getLocationOfAttribute(element, SeamComponentDeclaration.PATH_OF_NAME);
+ }
+
+ /**
+ * @param seam model element
+ * @return location of attribute
+ */
+ public ISeamTextSourceReference getLocationOfAttribute(ISeamElement element, String
attributeName) {
+ ISeamTextSourceReference location = null;
+ if(element instanceof AbstractContextVariable) {
+ location = ((AbstractContextVariable)element).getLocationFor(attributeName);
+ } else if(element instanceof ISeamComponent) {
+ Set<ISeamComponentDeclaration> declarations =
((ISeamComponent)element).getAllDeclarations();
+ for (ISeamComponentDeclaration d : declarations) {
+ location = ((SeamComponentDeclaration)d).getLocationFor(attributeName);
+ if(location!=null) {
+ break;
+ }
+ }
+ } else if(element instanceof SeamComponentDeclaration) {
+ location = ((SeamComponentDeclaration)element).getLocationFor(attributeName);
+ }
+ if(location==null && element instanceof ISeamTextSourceReference) {
+ location = (ISeamTextSourceReference)element;
+ }
+ return location;
+ }
+
+ /**
+ * @param resource
+ * @return true if resource is Jar file
+ */
+ public boolean isJar(IPath path) {
+ if(path == null) {
+ throw new
IllegalArgumentException(SeamCoreMessages.SEAM_VALIDATION_HELPER_RESOURCE_MUST_NOT_BE_NULL);
+ }
+ String ext = path.getFileExtension();
+ return ext != null && ext.equalsIgnoreCase("jar"); //$NON-NLS-1$
+ }
+
+ /**
+ * @param element
+ * @return true if seam element packed in Jar file
+ */
+ public boolean isJar(ISeamElement element) {
+ return isJar(element.getSourcePath());
+ }
+
+ /**
+ * @param componentXmlFile
+ * @return IType of component for <ComponentName>.component.xml
+ */
+ public IType getClassTypeForComponentXml(IFile componentXmlFile) {
+ String className = getClassNameForComponentXml(componentXmlFile);
+ if(className==null) {
+ return null;
+ }
+ return findType(className);
+ }
+
+ /**
+ * @param type name
+ * @return IType
+ */
+ public IType findType(String fullyQualifiedName) {
+ IProject p = getProject().getProject();
+ try {
+ IJavaProject jp = EclipseResourceUtil.getJavaProject(p);
+ return jp.findType(fullyQualifiedName);
+ } catch (JavaModelException e) {
+ SeamCorePlugin.getDefault().logError(e);
+ return null;
+ }
+ }
+
+ /**
+ * @param componentXmlFile
+ * @return name of component class for <ComponentName>.component.xml
+ */
+ public String getClassNameForComponentXml(IFile componentXmlFile) {
+ String fileName = componentXmlFile.getName();
+ int firstDot = fileName.indexOf('.');
+ if(firstDot==-1) {
+ return null;
+ }
+ String className = fileName.substring(0, firstDot);
+ IProject p = getProject().getProject();
+ try {
+ IJavaProject jp = EclipseResourceUtil.getJavaProject(p);
+ IPackageFragment packageFragment =
jp.findPackageFragment(componentXmlFile.getFullPath().removeLastSegments(1));
+ if(packageFragment==null) {
+ return null;
+ }
+ return packageFragment.getElementName() + "." + className; //$NON-NLS-1$
+ } catch (JavaModelException e) {
+ SeamCorePlugin.getDefault().logError(e);
+ return null;
+ }
+ }
+
+ /**
+ * Find setter for property
+ * @param type
+ * @param propertyName
+ * @return
+ */
+ public IMethod findSetter(IType type, String propertyName) {
+ if(propertyName == null || propertyName.length()==0) {
+ return null;
+ }
+ String firstLetter = propertyName.substring(0, 1).toUpperCase();
+ String nameWithoutFirstLetter = propertyName.substring(1);
+ String setterName = "set" + firstLetter + nameWithoutFirstLetter;
//$NON-NLS-1$
+ try {
+ return findSetterInHierarchy(type, setterName);
+ } catch (JavaModelException e) {
+ SeamCorePlugin.getDefault().logError(e);
+ }
+ return null;
+ }
+
+ private IMethod findSetterInHierarchy(IType type, String setterName) throws
JavaModelException {
+ IMethod[] methods = type.getMethods();
+ for (int i = 0; i < methods.length; i++) {
+ if(methods[i].getElementName().equals(setterName) &&
methods[i].getParameterNames().length==1) {
+ return methods[i];
+ }
+ }
+ String superclassName = type.getSuperclassName();
+ if(superclassName!=null) {
+ String[][] packages = type.resolveType(superclassName);
+ if(packages!=null) {
+ for (int i = 0; i < packages.length; i++) {
+ String packageName = packages[i][0];
+ if(packageName!=null && packageName.length()>0) {
+ packageName = packageName + "."; //$NON-NLS-1$
+ } else {
+ packageName = ""; //$NON-NLS-1$
+ }
+ String qName = packageName + packages[i][1];
+ IType superclass = type.getJavaProject().findType(qName);
+ if(superclass!=null) {
+ IMethod method = findSetterInHierarchy(superclass, setterName);
+ if(method!=null) {
+ return method;
+ }
+ }
+ }
+ }
+ }
+ return null;
+ }
+}
\ No newline at end of file
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamValidator.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamValidator.java 2008-04-04
08:46:10 UTC (rev 7312)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamValidator.java 2008-04-04
09:32:08 UTC (rev 7313)
@@ -39,14 +39,14 @@
"org.eclipse.wst.validation", 0, "OK", null); //$NON-NLS-1$
//$NON-NLS-2$
protected SeamValidatorManager validationManager;
- protected SeamValidationHelper coreHelper;
+ protected SeamContextValidationHelper coreHelper;
protected IReporter reporter;
protected SeamValidationContext validationContext;
protected ISeamProject project;
protected String projectName;
public SeamValidator(SeamValidatorManager validatorManager,
- SeamValidationHelper coreHelper, IReporter reporter,
+ SeamContextValidationHelper coreHelper, IReporter reporter,
SeamValidationContext validationContext, ISeamProject project) {
this.validationManager = validatorManager;
this.coreHelper = coreHelper;
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamValidatorManager.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamValidatorManager.java 2008-04-04
08:46:10 UTC (rev 7312)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamValidatorManager.java 2008-04-04
09:32:08 UTC (rev 7313)
@@ -47,7 +47,7 @@
* @see
org.eclipse.wst.validation.internal.provisional.core.IValidatorJob#validateInJob(org.eclipse.wst.validation.internal.provisional.core.IValidationContext,
org.eclipse.wst.validation.internal.provisional.core.IReporter)
*/
public IStatus validateInJob(IValidationContext helper, IReporter reporter) throws
ValidationException {
- SeamValidationHelper coreHelper = (SeamValidationHelper)helper;
+ SeamContextValidationHelper coreHelper = (SeamContextValidationHelper)helper;
ISeamProject project = coreHelper.getSeamProject();
if(project==null) {
return OK_STATUS;
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-04-04
08:46:10 UTC (rev 7312)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamSettingsPreferencePage.java 2008-04-04
09:32:08 UTC (rev 7313)
@@ -421,10 +421,12 @@
}
private boolean warning;
+ private boolean error;
private void validate() {
warning = false;
+ error = false;
if(!isSeamSupported()) {
setValid(true);
@@ -449,57 +451,64 @@
boolean deployAsEar =
ISeamFacetDataModelProperties.DEPLOY_AS_EAR.equals(getValue(ISeamFacetDataModelProperties.JBOSS_AS_DEPLOY_AS));
if(deployAsEar &&
!validateProjectName(SeamPreferencesMessages.SEAM_SETTINGS_PREFERENCE_PAGE_EJB_PROJECT_DOES_NOT_EXIST,
ISeamFacetDataModelProperties.SEAM_EJB_PROJECT)) {
- return;
+// return;
}
String viewFolder =
getValue(ISeamFacetDataModelProperties.WEB_CONTENTS_FOLDER).trim();
if(viewFolder.length()>0) {
IResource folder = ResourcesPlugin.getWorkspace().getRoot().findMember(viewFolder);
if(folder==null || !folder.exists()) {
- setErrorMessage(NLS.bind(SeamPreferencesMessages.SEAM_SETTINGS_PREFERENCE_PAGE_VIEW_FOLDER_DOES_NOT_EXIST,
new String[]{viewFolder}));
+ if(!error) {
+ setErrorMessage(NLS.bind(SeamPreferencesMessages.SEAM_SETTINGS_PREFERENCE_PAGE_VIEW_FOLDER_DOES_NOT_EXIST,
new String[]{viewFolder}));
+ }
+ error = true;
setValid(false);
- return;
+// return;
}
}
if(!validateSourceFolder(SeamPreferencesMessages.SEAM_SETTINGS_PREFERENCE_PAGE_MODEL_SOURCE_FOLDER_DOES_NOT_EXIST,
ISeamFacetDataModelProperties.ENTITY_BEAN_SOURCE_FOLDER,
ISeamFacetDataModelProperties.ENTITY_BEAN_PACKAGE_NAME)) {
- return;
+// return;
}
if(!validateJavaPackageName(SeamPreferencesMessages.SEAM_SETTINGS_PREFERENCE_PAGE_MODEL_PACKAGE_IS_NOT_VALID,
SeamPreferencesMessages.SEAM_SETTINGS_PREFERENCE_PAGE_MODEL_PACKAGE_HAS_WARNING,
ISeamFacetDataModelProperties.ENTITY_BEAN_PACKAGE_NAME)) {
- return;
+// return;
}
if(!validateSourceFolder(SeamPreferencesMessages.SEAM_SETTINGS_PREFERENCE_PAGE_ACTION_SOURCE_FOLDER_DOES_NOT_EXIST,
ISeamFacetDataModelProperties.SESSION_BEAN_SOURCE_FOLDER,
ISeamFacetDataModelProperties.SESSION_BEAN_PACKAGE_NAME)) {
- return;
+// return;
}
if(!validateJavaPackageName(SeamPreferencesMessages.SEAM_SETTINGS_PREFERENCE_PAGE_ACTION_PACKAGE_IS_NOT_VALID,
SeamPreferencesMessages.SEAM_SETTINGS_PREFERENCE_PAGE_ACTION_PACKAGE_HAS_WARNING,
ISeamFacetDataModelProperties.SESSION_BEAN_PACKAGE_NAME)) {
- return;
+// return;
}
if(isTestEnabled()) {
if(!validateSourceFolder(SeamPreferencesMessages.SEAM_SETTINGS_PREFERENCE_PAGE_TEST_SOURCE_FOLDER_DOES_NOT_EXIST,
ISeamFacetDataModelProperties.TEST_SOURCE_FOLDER,
ISeamFacetDataModelProperties.TEST_CASES_PACKAGE_NAME)){
- return;
+// return;
}
if(!validateProjectName(SeamPreferencesMessages.SEAM_SETTINGS_PREFERENCE_PAGE_TEST_PROJECT_DOES_NOT_EXIST,
ISeamFacetDataModelProperties.SEAM_TEST_PROJECT)) {
- return;
+// return;
}
if(!validateJavaPackageName(SeamPreferencesMessages.SEAM_SETTINGS_PREFERENCE_PAGE_TEST_PACKAGE_IS_NOT_VALID,
SeamPreferencesMessages.SEAM_SETTINGS_PREFERENCE_PAGE_TEST_PACKAGE_HAS_WARNING,
ISeamFacetDataModelProperties.TEST_CASES_PACKAGE_NAME)) {
- return;
+// return;
}
}
+ if(error) {
+ return;
+ }
+
setValid(true);
setErrorMessage(null);
if(!warning) {
@@ -512,12 +521,17 @@
String packageName = getValue(editorName).trim();
IStatus status = JavaConventions.validatePackageName(packageName,
CompilerOptions.VERSION_1_5, CompilerOptions.VERSION_1_5);
if(status.getSeverity()==IStatus.ERROR) {
- setErrorMessage(NLS.bind(errorMessageKey, new String[]{status.getMessage()}));
+ if(!error) {
+ setErrorMessage(NLS.bind(errorMessageKey, new String[]{status.getMessage()}));
+ }
+ error = true;
setValid(false);
return false;
}
if(status.getSeverity()==IStatus.WARNING) {
- setMessage(NLS.bind(warningMessageKey, new String[]{status.getMessage()}),
IMessageProvider.WARNING);
+ if(!error) {
+ setMessage(NLS.bind(warningMessageKey, new String[]{status.getMessage()}),
IMessageProvider.WARNING);
+ }
warning = true;
return true;
}
@@ -529,7 +543,10 @@
String projectName = getValue(editorName).trim();
if(projectName.length()>0) {
if(!ResourcesPlugin.getWorkspace().getRoot().getProject(projectName).exists()) {
- setErrorMessage(NLS.bind(errorMessageKey, new String[]{projectName}));
+ if(!error) {
+ setErrorMessage(NLS.bind(errorMessageKey, new String[]{projectName}));
+ }
+ error = true;
setValid(false);
return false;
}
@@ -543,7 +560,10 @@
IResource folder = ResourcesPlugin.getWorkspace().getRoot().findMember(sourceFolder);
if(folder==null || !(folder instanceof IFolder) || !folder.exists()) {
editorRegistry.get(packageEditorName).setEnabled(false);
- setErrorMessage(NLS.bind(errorMessageKey, new String[]{sourceFolder}));
+ if(!error) {
+ setErrorMessage(NLS.bind(errorMessageKey, new String[]{sourceFolder}));
+ }
+ error = true;
setValid(false);
return false;
} else {
@@ -565,7 +585,7 @@
private String getSeamProjectName() {
return warProject!=null ? warProject.getName() : project.getName();
}
-
+
private String getTestProjectName() {
String projectName = "";
if(preferences!=null) {
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-04-04
08:46:10 UTC (rev 7312)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/SwtFieldEditorFactory.java 2008-04-04
09:32:08 UTC (rev 7313)
@@ -186,7 +186,7 @@
IResource resource = ResourcesPlugin.getWorkspace().getRoot().findMember(path);
if (resource!=null) {
IProject project = resource.getProject();
- if (project.getProject().isOpen()) {
+ if (project!=null && project.isOpen()) {
IJavaProject javaProject = EclipseResourceUtil.getJavaProject(project);
try {
IPackageFragmentRoot[] roots = javaProject.getPackageFragmentRoots();