Author: scabanovich
Date: 2007-07-06 10:37:50 -0400 (Fri, 06 Jul 2007)
New Revision: 2344
Added:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/AbstractContextVariable.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/Role.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamComponentMethod.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamJavaContextVariable.java
Log:
EXIN-217 Implementations of model interfaces added
Added:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/AbstractContextVariable.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/AbstractContextVariable.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/AbstractContextVariable.java 2007-07-06
14:37:50 UTC (rev 2344)
@@ -0,0 +1,119 @@
+package org.jboss.tools.seam.internal.core;
+
+import java.util.List;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
+import org.jboss.tools.seam.core.ISeamContextVariable;
+import org.jboss.tools.seam.core.ISeamTextSourceReference;
+import org.jboss.tools.seam.core.ISeamXmlComponentDeclaration;
+import org.jboss.tools.seam.core.ScopeType;
+import org.jboss.tools.seam.core.event.Change;
+
+public class AbstractContextVariable implements ISeamContextVariable,
ISeamTextSourceReference {
+ /**
+ * Path of resource where this factory is declared.
+ */
+ protected IPath source;
+
+ protected IResource resource = null;
+
+ /**
+ * Object that allows to identify this declaration.
+ */
+ protected Object id;
+
+ protected String name;
+ protected ScopeType scopeType;
+ protected String scope;
+
+ public Object getId() {
+ return id;
+ }
+
+ public void setId(Object id) {
+ this.id = id;
+ }
+
+ public void setSourcePath(IPath path) {
+ source = path;
+ }
+
+ public IPath getSourcePath() {
+ return source;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public ScopeType getScope() {
+ return scopeType;
+ }
+
+ public void setScope(ScopeType type) {
+ scopeType = type;
+ scope = scopeType == null ? null : scopeType.toString();
+ }
+
+ public void setScopeAsString(String scope) {
+ try {
+ this.scopeType = scope == null || scope.length() == 0 ? ScopeType.UNSPECIFIED :
ScopeType.valueOf(scope.toUpperCase());
+ } catch (Exception e) {
+ //ignore
+ }
+ }
+
+ public int getLength() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public IResource getResource() {
+ if(resource != null) return resource;
+ if(source != null) {
+ resource = ResourcesPlugin.getWorkspace().getRoot().getFile(source);
+ }
+ return resource;
+ }
+
+ public int getStartPosition() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ /**
+ * Merges loaded data into currently used declaration.
+ * If changes were done returns a list of changes.
+ * @param f
+ * @return list of changes
+ */
+ public List<Change> merge(AbstractContextVariable f) {
+ List<Change> changes = null;
+
+ source = f.source;
+ id = f.id;
+
+ if(!stringsEqual(name, f.name)) {
+ changes = Change.addChange(changes, new Change(this,
ISeamXmlComponentDeclaration.NAME, name, f.name));
+ name = f.name;
+ }
+ if(!stringsEqual(scope, f.scope)) {
+ changes = Change.addChange(changes, new Change(this,
ISeamXmlComponentDeclaration.SCOPE, scope, f.scope));
+ scope = f.scope;
+ scopeType = f.scopeType;
+ }
+
+ return changes;
+ }
+
+ boolean stringsEqual(String s1, String s2) {
+ return s1 == null ? s2 == null : s1.equals(s2);
+ }
+
+}
Added:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/Role.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/Role.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/Role.java 2007-07-06
14:37:50 UTC (rev 2344)
@@ -0,0 +1,7 @@
+package org.jboss.tools.seam.internal.core;
+
+import org.jboss.tools.seam.core.IRole;
+
+public class Role extends SeamJavaContextVariable implements IRole {
+
+}
Added:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamComponentMethod.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamComponentMethod.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamComponentMethod.java 2007-07-06
14:37:50 UTC (rev 2344)
@@ -0,0 +1,56 @@
+package org.jboss.tools.seam.internal.core;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jdt.core.IMember;
+import org.jboss.tools.seam.core.ISeamComponentMethod;
+import org.jboss.tools.seam.core.SeamComponentMethodType;
+
+public class SeamComponentMethod implements ISeamComponentMethod {
+ boolean create = false;
+ boolean destroy = false;
+
+ IMember javaSource = null;
+ IResource resource = null;
+
+ public boolean isCreate() {
+ return create;
+ }
+
+ public void setCreate(boolean b) {
+ create = b;
+ }
+
+ public boolean isOfType(SeamComponentMethodType type) {
+ if(type == SeamComponentMethodType.CREATE) return isCreate();
+ if(type == SeamComponentMethodType.DESTROY) return isDestroy();
+ return false;
+ }
+
+ public boolean isDestroy() {
+ return destroy;
+ }
+
+ public void setDestroy(boolean b) {
+ destroy = b;
+ }
+
+ public IMember getSourceMember() {
+ return javaSource;
+ }
+
+ public int getLength() {
+ return 0;
+ }
+
+ public IResource getResource() {
+ if(resource == null && javaSource != null) {
+ resource = javaSource.getResource();
+ }
+ return resource;
+ }
+
+ public int getStartPosition() {
+ return 0;
+ }
+
+}
Added:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamJavaContextVariable.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamJavaContextVariable.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamJavaContextVariable.java 2007-07-06
14:37:50 UTC (rev 2344)
@@ -0,0 +1,56 @@
+package org.jboss.tools.seam.internal.core;
+
+import java.util.List;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jdt.core.IMember;
+import org.eclipse.jdt.core.JavaModelException;
+import org.jboss.tools.seam.core.ISeamJavaSourceReference;
+import org.jboss.tools.seam.core.event.Change;
+
+public class SeamJavaContextVariable extends AbstractContextVariable implements
ISeamJavaSourceReference {
+ protected IMember javaSource = null;
+
+ public IMember getSourceMember() {
+ return javaSource;
+ }
+
+ public int getLength() {
+ if(javaSource == null) return 0;
+ try {
+ if(javaSource.getSourceRange() == null) return 0;
+ return javaSource.getSourceRange().getLength();
+ } catch (JavaModelException e) {
+ //ignore
+ return 0;
+ }
+ }
+
+ public IResource getResource() {
+ return javaSource == null ? null : javaSource.getTypeRoot().getResource();
+ }
+
+ public int getStartPosition() {
+ if(javaSource == null) return 0;
+ try {
+ if(javaSource.getSourceRange() == null) return 0;
+ return javaSource.getSourceRange().getOffset();
+ } catch (JavaModelException e) {
+ //ignore
+ return 0;
+ }
+ }
+
+ public List<Change> merge(AbstractContextVariable f) {
+ List<Change> changes = super.merge(f);
+
+ if(f instanceof SeamJavaContextVariable) {
+ SeamJavaContextVariable sf = (SeamJavaContextVariable)f;
+ javaSource = sf.javaSource;
+ resource = sf.resource;
+ }
+
+ return changes;
+ }
+
+}
Show replies by date