Author: scabanovich
Date: 2007-07-18 07:42:01 -0400 (Wed, 18 Jul 2007)
New Revision: 2496
Added:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamPreferences.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/preferences/
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/preferences/SeamPreferenceInitializer.java
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/META-INF/MANIFEST.MF
trunk/seam/plugins/org.jboss.tools.seam.core/plugin.xml
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/BijectedAttributeType.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamProject.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/scanner/java/ComponentBuilder.java
Log:
EXIN-327 Preferences for validation
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/META-INF/MANIFEST.MF
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/META-INF/MANIFEST.MF 2007-07-18 11:39:08
UTC (rev 2495)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/META-INF/MANIFEST.MF 2007-07-18 11:42:01
UTC (rev 2496)
@@ -26,7 +26,8 @@
org.eclipse.jst.ws
Provide-Package: org.jboss.tools.seam.core,
org.jboss.tools.seam.internal.core,
- org.jboss.tools.seam.internal.core.scanner
+ org.jboss.tools.seam.internal.core.scanner,
+ org.jboss.tools.seam.internal.core.preferences
Bundle-Version: 2.0.0
Export-Package: org.jboss.tools.seam.core,
org.jboss.tools.seam.core.event,
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/plugin.xml
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/plugin.xml 2007-07-18 11:39:08 UTC (rev
2495)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/plugin.xml 2007-07-18 11:42:01 UTC (rev
2496)
@@ -26,6 +26,11 @@
id="org.jboss.tools.seam.core.seambuilder">
</builder>
</extension>
+
+ <extension point="org.eclipse.core.runtime.preferences">
+ <initializer
class="org.jboss.tools.seam.internal.core.preferences.SeamPreferenceInitializer"/>
+ </extension>
+
<extension
id="seamProblem"
name="Seam Problem"
@@ -163,4 +168,5 @@
type="org.eclipse.wst.validation.problemmarker">
</super>
</extension>
+
</plugin>
\ No newline at end of file
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/BijectedAttributeType.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/BijectedAttributeType.java 2007-07-18
11:39:08 UTC (rev 2495)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/BijectedAttributeType.java 2007-07-18
11:42:01 UTC (rev 2496)
@@ -17,18 +17,30 @@
* @author Alexey Kazakov
*/
public enum BijectedAttributeType implements SeamAnnotations {
- IN(IN_ANNOTATION_TYPE),
- OUT(OUT_ANNOTATION_TYPE),
- DATA_BINDER(DATA_MODEL_ANNOTATION_TYPE),
- DATA_MODEL_SELECTION(DATA_MODEL_SELECTION_ANNOTATION_TYPE),
- DATA_MODEL_SELECTION_INDEX(DATA_MODEL_SELECTION_INDEX_ANNOTATION_TYPE);
+ IN(IN_ANNOTATION_TYPE, true),
+ OUT(OUT_ANNOTATION_TYPE, true),
+ DATA_BINDER(DATA_MODEL_ANNOTATION_TYPE, true),
+ DATA_MODEL_SELECTION(DATA_MODEL_SELECTION_ANNOTATION_TYPE, false),
+ DATA_MODEL_SELECTION_INDEX(DATA_MODEL_SELECTION_INDEX_ANNOTATION_TYPE, false);
- BijectedAttributeType(String annotationType) {
+ boolean isUsingMemberName;
+
+ BijectedAttributeType(String annotationType, boolean isUsingMemberName) {
this.annotationType = annotationType;
+ this.isUsingMemberName = isUsingMemberName;
}
String annotationType;
public String getAnnotationType() {
return annotationType;
}
+
+ /**
+ *
+ * @return
+ */
+ public boolean isUsingMemberName() {
+ return isUsingMemberName;
+ }
+
}
\ No newline at end of file
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamProject.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamProject.java 2007-07-18
11:39:08 UTC (rev 2495)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamProject.java 2007-07-18
11:42:01 UTC (rev 2496)
@@ -12,12 +12,18 @@
import java.util.Set;
+import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IPath;
import org.jboss.tools.seam.core.event.ISeamProjectChangeListener;
public interface ISeamProject extends ISeamElement {
public static String NATURE_ID = "org.jboss.tools.seam.core.seamnature";
+
+ /**
+ * Returns Eclipse project.
+ */
+ public IProject getProject();
/**
* Returns list of scope objects for all scope types.
Added:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamPreferences.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamPreferences.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamPreferences.java 2007-07-18
11:42:01 UTC (rev 2496)
@@ -0,0 +1,80 @@
+package org.jboss.tools.seam.core;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.eclipse.core.resources.ProjectScope;
+import org.eclipse.core.runtime.preferences.DefaultScope;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+
+public class SeamPreferences {
+
+ public static final String ERROR = "error";
+ public static final String WARNING = "warning";
+ public static final String IGNORE = "ignore";
+
+ public static final Set<String> severityOptionNames = new
HashSet<String>();
+
+ //Components
+ public static final String NONUNIQUE_COMPONENT_NAME =
createSeverityOption("nonUniqueComponentName");
+ public static final String STATEFUL_COMPONENT_DOES_NOT_CONTENT_REMOVE =
createSeverityOption("statefulComponentDoesNotContainRemove");
+ public static final String STATEFUL_COMPONENT_DOES_NOT_CONTENT_DESTROY =
createSeverityOption("statefulComponentDoesNotContainDestroy");
+ public static final String STATEFUL_COMPONENT_WRONG_SCOPE =
createSeverityOption("statefulComponentHasWrongScope");
+
+ //Entities
+ public static final String ENTITY_COMPONENT_WRONG_SCOPE =
createSeverityOption("entityComponentHasWrongScope");
+ public static final String DUPLICATE_REMOVE =
createSeverityOption("duplicateRemove");
+
+ //Component life-cycle methods
+ public static final String DUPLICATE_DESTROY =
createSeverityOption("duplicateDestroy");
+ public static final String DUPLICATE_CREATE =
createSeverityOption("duplicateCreate");
+ public static final String DUPLICATE_UNWRAP =
createSeverityOption("duplicateUnwrap");
+ public static final String DESTROY_DOESNT_BELONG_TO_COMPONENT =
createSeverityOption("destroyDoesNotBelongToComponent");
+ public static final String CREATE_DOESNT_BELONG_TO_COMPONENT =
createSeverityOption("createDoesNotBelongToComponent");
+ public static final String UNWRAP_DOESNT_BELONG_TO_COMPONENT =
createSeverityOption("unwrapDoesNotBelongToComponent");
+ public static final String OBSERVER_DOESNT_BELONG_TO_COMPONENT =
createSeverityOption("observerDoesNotBelongToComponent");
+
+ //Factories
+ public static final String UNKNOWN_FACTORY_NAME =
createSeverityOption("unknownFactoryName");
+
+ //Bijections
+ public static final String MULTIPLE_DATA_BINDER =
createSeverityOption("multipleDataBinder");
+ public static final String UNKNOWN_DATA_MODEL =
createSeverityOption("unknownDataModel");
+
+ //Context variables
+ public static final String DUPLICATE_VARIABLE_NAME =
createSeverityOption("duplicateVariableName");
+ public static final String UNKNOWN_INJECTION_NAME =
createSeverityOption("unknownInjectionName");
+
+ private static String createSeverityOption(String shortName) {
+ String name = SeamCorePlugin.PLUGIN_ID + ".validator.problem." + shortName;
+ severityOptionNames.add(name);
+ return name;
+ }
+
+ public static final Set<String> allOptionNames = new HashSet<String>();
+
+ static {
+ allOptionNames.addAll(severityOptionNames);
+ }
+
+ public IEclipsePreferences getProjectPreferences(ISeamProject project) {
+ return new ProjectScope(project.getProject()).getNode(SeamCorePlugin.PLUGIN_ID);
+ }
+
+ public IEclipsePreferences getDefaultPreferences() {
+ return new DefaultScope().getNode(SeamCorePlugin.PLUGIN_ID);
+ }
+
+ public String getProjectPreference(ISeamProject project, String key) {
+ IEclipsePreferences p = getProjectPreferences(project);
+ if(p == null) return null;
+ return p.get(key, null);
+ }
+
+ public String getDefaultPreference(String key) {
+ IEclipsePreferences p = getDefaultPreferences();
+ if(p == null) return null;
+ return p.get(key, null);
+ }
+
+}
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 2007-07-18
11:39:08 UTC (rev 2495)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java 2007-07-18
11:42:01 UTC (rev 2496)
@@ -641,6 +641,16 @@
allVariables.remove(factory);
}
+ /**
+ * Returns map of all java classes that contain seam annotations.
+ * They may be seam components, as well as cases of incomplete annotating
+ * that does not create a seam component.
+ * @return
+ */
+ public Map<String, SeamJavaComponentDeclaration> getAllJavaComponentDeclarations()
{
+ return javaDeclarations;
+ }
+
public SeamComponent getComponent(String name) {
return name == null ? null : allComponents.get(name);
}
Added:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/preferences/SeamPreferenceInitializer.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/preferences/SeamPreferenceInitializer.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/preferences/SeamPreferenceInitializer.java 2007-07-18
11:42:01 UTC (rev 2496)
@@ -0,0 +1,24 @@
+package org.jboss.tools.seam.internal.core.preferences;
+
+import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
+import org.eclipse.core.runtime.preferences.DefaultScope;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.core.runtime.preferences.IScopeContext;
+import org.jboss.tools.seam.core.SeamCorePlugin;
+import org.jboss.tools.seam.core.SeamPreferences;
+
+public class SeamPreferenceInitializer extends AbstractPreferenceInitializer {
+
+ public SeamPreferenceInitializer() {}
+
+ @Override
+ public void initializeDefaultPreferences() {
+
+ IEclipsePreferences defaultPreferences = ((IScopeContext) new
DefaultScope()).getNode(SeamCorePlugin.PLUGIN_ID);
+ for (String name : SeamPreferences.severityOptionNames) {
+ defaultPreferences.put(name, SeamPreferences.ERROR);
+ }
+
+ }
+
+}
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/ComponentBuilder.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/ComponentBuilder.java 2007-07-18
11:39:08 UTC (rev 2495)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/ComponentBuilder.java 2007-07-18
11:42:01 UTC (rev 2496)
@@ -159,7 +159,7 @@
att.setTypes(types.toArray(new BijectedAttributeType[0]));
ValueInfo name = ValueInfo.getValueInfo(main, null);
- if(name == null) {
+ if(name == null && types.size() > 0 &&
types.get(0).isUsingMemberName()) {
name = new ValueInfo();
name.value = m.getName().getIdentifier();
}