Author: scabanovich
Date: 2008-06-05 06:42:32 -0400 (Thu, 05 Jun 2008)
New Revision: 8568
Added:
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/helpers/SeamPagesDiagramHelper.java
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/helpers/SeamPagesDiagramStructureHelper.java
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/impl/SeamPagesDiagramImpl.java
Removed:
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/helpers/SeamPagesProcessHelper.java
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/helpers/SeamPagesProcessStructureHelper.java
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/impl/SeamPagesProcessImpl.java
Modified:
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/plugin.xml
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/resources/meta/seam-pages.meta
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/FileSeamPagesImpl.java
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/SeamPagesConstants.java
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/SeamPagesFileLoader.java
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/handlers/AddExceptionHandler.java
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/handlers/AddViewSupport.java
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/handlers/DeleteOutputHandler.java
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/handlers/OpenPageHandler.java
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/handlers/PageAdopt.java
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/handlers/ProcessAdopt.java
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/handlers/SelectOnDiagramHandler.java
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/helpers/SeamPagesUpdateHelper.java
Log:
JBIDE-1189
Modified: trunk/seam/plugins/org.jboss.tools.seam.pages.xml/plugin.xml
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.pages.xml/plugin.xml 2008-06-05 10:41:43 UTC
(rev 8567)
+++ trunk/seam/plugins/org.jboss.tools.seam.pages.xml/plugin.xml 2008-06-05 10:42:32 UTC
(rev 8568)
@@ -49,8 +49,8 @@
<xclass id="org.jboss.tools.seam.pages.xml.model.impl.SeamPageTaskImpl"
class="org.jboss.tools.seam.pages.xml.model.impl.SeamPageTaskImpl"/>
- <xclass
id="org.jboss.tools.seam.pages.xml.model.impl.SeamPagesProcessImpl"
- class="org.jboss.tools.seam.pages.xml.model.impl.SeamPagesProcessImpl"/>
+ <xclass
id="org.jboss.tools.seam.pages.xml.model.impl.SeamPagesDiagramImpl"
+ class="org.jboss.tools.seam.pages.xml.model.impl.SeamPagesDiagramImpl"/>
<xclass
id="org.jboss.tools.seam.pages.xml.model.impl.ReferenceObjectImpl"
class="org.jboss.tools.seam.pages.xml.model.impl.ReferenceObjectImpl"/>
@@ -71,6 +71,10 @@
<xclass id="org.jboss.tools.seam.pages.xml.model.handlers.AddViewSupport"
class="org.jboss.tools.seam.pages.xml.model.handlers.AddViewSupport"/>
+
+ <xclass
id="org.jboss.tools.seam.pages.xml.model.helpers.autolayout.SeamPagesItems"
+ class="org.jboss.tools.seam.pages.xml.model.helpers.autolayout.SeamPagesItems"/>
+
</extension>
<extension point="org.eclipse.wst.xml.core.catalogContributions">
Modified:
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/resources/meta/seam-pages.meta
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/resources/meta/seam-pages.meta 2008-06-05
10:41:43 UTC (rev 8567)
+++
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/resources/meta/seam-pages.meta 2008-06-05
10:42:32 UTC (rev 8568)
@@ -332,7 +332,7 @@
<XChildEntity maxCount="1" name="SeamPageFolderConversation"
required="yes"/>
<XChildEntity maxCount="1" name="SeamPageFolderPage12"
required="yes"/>
<XChildEntity maxCount="1" name="SeamPageFolderException12"
required="yes"/>
- <XChildEntity maxCount="1" name="SeamPagesProcess"
required="yes"/>
+ <XChildEntity maxCount="1" name="SeamPagesDiagram"
required="yes"/>
</XChildrenEntities>
<XEntityRenderer>
<ICONS>
@@ -490,7 +490,7 @@
<XChildEntity maxCount="1" name="SeamPageFolderConversation"
required="yes"/>
<XChildEntity maxCount="1" name="SeamPageFolderPage20"
required="yes"/>
<XChildEntity maxCount="1" name="SeamPageFolderException20"
required="yes"/>
- <XChildEntity maxCount="1" name="SeamPagesProcess"
required="yes"/>
+ <XChildEntity maxCount="1" name="SeamPagesDiagram"
required="yes"/>
</XChildrenEntities>
<XEntityRenderer>
<ICONS>
@@ -2781,9 +2781,9 @@
</XModelEntity>
<XModelEntity
AdoptManagerClass="org.jboss.tools.seam.pages.xml.model.handlers.ProcessAdopt"
-
ImplementingClass="org.jboss.tools.seam.pages.xml.model.impl.SeamPagesProcessImpl"
name="SeamPagesProcess">
+
ImplementingClass="org.jboss.tools.seam.pages.xml.model.impl.SeamPagesDiagramImpl"
name="SeamPagesDiagram">
<XChildrenEntities>
- <XChildEntity name="SeamPagesProcessItem"/>
+ <XChildEntity name="SeamPagesDiagramItem"/>
<XChildEntity name="JSFProcessComment"/>
</XChildrenEntities>
<XEntityRenderer>
@@ -2837,7 +2837,7 @@
<XActionItem
HandlerClassName="org.jboss.tools.jst.web.model.handlers.AutolayoutWebProcessHandler"
ICON="action.empty"
-
PROPERTIES="items-class=org.jboss.tools.jsf.model.helpers.autolayout.JSFItems"
+
PROPERTIES="items-class=org.jboss.tools.seam.pages.xml.model.helpers.autolayout.SeamPagesItems"
displayName="Auto Layout" kind="action"
name="AutoLayout"/>
<XActionItem HIDE="disabled"
HandlerClassName="org.jboss.tools.jst.web.model.handlers.FindItemOnDiagramHandler"
@@ -2876,9 +2876,9 @@
<XModelEntity
AdoptManagerClass="org.jboss.tools.seam.pages.xml.model.handlers.PageAdopt"
ImplementingClass="org.jboss.tools.seam.pages.xml.model.impl.ReferenceObjectImpl"
- XMLSUBPATH="PROCESS-ITEM" name="SeamPagesProcessItem">
+ XMLSUBPATH="item" name="SeamPagesDiagramItem">
<XChildrenEntities>
- <XChildEntity name="SeamPagesProcessItemOutput"/>
+ <XChildEntity name="SeamPagesDiagramItemOutput"/>
</XChildrenEntities>
<XEntityRenderer>
<ICONS>
@@ -3005,7 +3005,7 @@
</XModelEntity>
<XModelEntity
ImplementingClass="org.jboss.tools.seam.pages.xml.model.impl.ReferenceObjectImpl"
- XMLSUBPATH="PROCESS-ITEM-OUTPUT"
name="SeamPagesProcessItemOutput">
+ XMLSUBPATH="output" name="SeamPagesDiagramItemOutput">
<XChildrenEntities/>
<XEntityRenderer>
<ICONS>
Modified:
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/FileSeamPagesImpl.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/FileSeamPagesImpl.java 2008-06-05
10:41:43 UTC (rev 8567)
+++
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/FileSeamPagesImpl.java 2008-06-05
10:42:32 UTC (rev 8568)
@@ -18,7 +18,7 @@
import org.jboss.tools.common.model.util.XModelObjectLoaderUtil;
import org.jboss.tools.jst.web.model.AbstractWebFileImpl;
import org.jboss.tools.jst.web.model.WebProcessLoader;
-import org.jboss.tools.seam.pages.xml.model.impl.SeamPagesProcessImpl;
+import org.jboss.tools.seam.pages.xml.model.impl.SeamPagesDiagramImpl;
public class FileSeamPagesImpl extends AbstractWebFileImpl implements SeamPagesConstants
{
private static final long serialVersionUID = 1L;
@@ -38,13 +38,13 @@
}
protected void mergeAll(XModelObject f, boolean update) throws XModelException {
- SeamPagesProcessImpl process = (SeamPagesProcessImpl)provideWebProcess();
+ SeamPagesDiagramImpl process = (SeamPagesDiagramImpl)provideWebProcess();
boolean b = (process != null && process.isPrepared());
if(b) process.getHelper().addUpdateLock(this);
merge(f, !update);
if(b) {
process.getHelper().removeUpdateLock(this);
- process.getHelper().updateProcess();
+ process.getHelper().updateDiagram();
}
if(process != null) {
Modified:
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/SeamPagesConstants.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/SeamPagesConstants.java 2008-06-05
10:41:43 UTC (rev 8567)
+++
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/SeamPagesConstants.java 2008-06-05
10:42:32 UTC (rev 8568)
@@ -52,10 +52,10 @@
public String FOLDER_PAGES = "Pages"; //$NON-NLS-1$
public String FOLDER_EXCEPTIONS = "Exceptions"; //$NON-NLS-1$
- public String ELM_PROCESS = "process"; //$NON-NLS-1$
- public String ENT_PROCESS = "SeamPagesProcess"; //$NON-NLS-1$
- public String ENT_PROCESS_ITEM = "SeamPagesProcessItem"; //$NON-NLS-1$
- public String ENT_PROCESS_ITEM_OUTPUT = "SeamPagesProcessItemOutput";
//$NON-NLS-1$
+ public String ELM_DIAGRAM = "process"; //$NON-NLS-1$
+ public String ENT_DIAGRAM = "SeamPagesDiagram"; //$NON-NLS-1$
+ public String ENT_DIAGRAM_ITEM = "SeamPagesDiagramItem"; //$NON-NLS-1$
+ public String ENT_DIAGRAM_ITEM_OUTPUT = "SeamPagesDiagramItemOutput";
//$NON-NLS-1$
public String TYPE_PAGE = "page"; //$NON-NLS-1$
public String TYPE_EXCEPTION = "exception"; //$NON-NLS-1$
Modified:
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/SeamPagesFileLoader.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/SeamPagesFileLoader.java 2008-06-05
10:41:43 UTC (rev 8567)
+++
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/SeamPagesFileLoader.java 2008-06-05
10:42:32 UTC (rev 8568)
@@ -28,7 +28,7 @@
import org.jboss.tools.common.model.util.XMLUtil;
import org.jboss.tools.common.model.util.XModelObjectLoaderUtil;
import org.jboss.tools.jst.web.model.WebProcessLoader;
-import org.jboss.tools.seam.pages.xml.model.impl.SeamPagesProcessImpl;
+import org.jboss.tools.seam.pages.xml.model.impl.SeamPagesDiagramImpl;
import org.w3c.dom.Document;
import org.w3c.dom.DocumentType;
import org.w3c.dom.Element;
@@ -105,9 +105,9 @@
}
public void reloadProcess(XModelObject object) {
- SeamPagesProcessImpl process =
(SeamPagesProcessImpl)object.getChildByPath(ELM_PROCESS);
- if(process == null) return;
- process.setReference(object);
+ SeamPagesDiagramImpl diagram =
(SeamPagesDiagramImpl)object.getChildByPath(ELM_DIAGRAM);
+ if(diagram == null) return;
+ diagram.setReference(object);
if(!object.isActive()) return;
String bodyAux = (object.getParent() == null ? null : aux.read(object.getParent(),
object));
if (bodyAux != null) {
@@ -115,11 +115,11 @@
if (doc2 == null) {
//JSFModelPlugin.log("Unable to parse aux body of "+object.getPath());
} else {
- util.load(doc2.getDocumentElement(), process);
+ util.load(doc2.getDocumentElement(), diagram);
}
}
- process.setReference(null);
- process.firePrepared();
+ diagram.setReference(null);
+ diagram.firePrepared();
}
public boolean update(XModelObject object) throws XModelException {
@@ -154,16 +154,16 @@
if(object == null || !object.isActive()) return false;
XModelObjectLoaderUtil util = new XModelObjectLoaderUtil();
try {
- XModelObject process = object.getChildByPath(ELM_PROCESS);
- if(process == null) return true;
- process.setModified(true);
- Element element = XMLUtil.createDocumentElement("PROCESS");
- util.saveAttributes(element, process);
- util.saveChildren(element, process);
+ XModelObject diagram = object.getChildByPath(ELM_DIAGRAM);
+ if(diagram == null) return true;
+ diagram.setModified(true);
+ Element element = XMLUtil.createDocumentElement("diagram");
+ util.saveAttributes(element, diagram);
+ util.saveChildren(element, diagram);
StringWriter sw = new StringWriter();
XModelObjectLoaderUtil.serialize(element, sw);
- XModelObjectLoaderUtil.setTempBody(process, sw.toString());
- aux.write(object.getParent(), object, process);
+ XModelObjectLoaderUtil.setTempBody(diagram, sw.toString());
+ aux.write(object.getParent(), object, diagram);
return true;
} catch (IOException exc) {
ModelPlugin.getPluginLog().logError(exc);
Modified:
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/handlers/AddExceptionHandler.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/handlers/AddExceptionHandler.java 2008-06-05
10:41:43 UTC (rev 8567)
+++
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/handlers/AddExceptionHandler.java 2008-06-05
10:42:32 UTC (rev 8568)
@@ -6,7 +6,7 @@
import org.jboss.tools.common.model.XModelException;
import org.jboss.tools.common.model.XModelObject;
import org.jboss.tools.common.model.util.XModelObjectLoaderUtil;
-import org.jboss.tools.seam.pages.xml.model.helpers.SeamPagesProcessStructureHelper;
+import org.jboss.tools.seam.pages.xml.model.helpers.SeamPagesDiagramStructureHelper;
public class AddExceptionHandler extends DefaultCreateHandler {
@@ -18,7 +18,7 @@
XModelObject created = (XModelObject)prop.get("created");
if(created == null) return;
String path = created.getPathPart();
- XModelObject item =
SeamPagesProcessStructureHelper.getInstance().getProcess(object).getChildByPath(path);
+ XModelObject item =
SeamPagesDiagramStructureHelper.getInstance().getProcess(object).getChildByPath(path);
String shape = getShape(prop);
if(item != null && shape != null) {
item.setAttributeValue("shape", shape);
@@ -35,8 +35,8 @@
}
public static String getShape(Properties p) {
- String x = p.getProperty("process.mouse.x");
- String y = p.getProperty("process.mouse.y");
+ String x = p.getProperty("mouse.x");
+ String y = p.getProperty("mouse.y");
return (x == null || y == null) ? null : x + "," + y + ",0,0";
}
Modified:
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/handlers/AddViewSupport.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/handlers/AddViewSupport.java 2008-06-05
10:41:43 UTC (rev 8567)
+++
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/handlers/AddViewSupport.java 2008-06-05
10:42:32 UTC (rev 8568)
@@ -33,7 +33,7 @@
import org.jboss.tools.seam.pages.xml.SeamPagesXMLMessages;
import org.jboss.tools.seam.pages.xml.SeamPagesXMLPlugin;
import org.jboss.tools.seam.pages.xml.model.SeamPagesConstants;
-import org.jboss.tools.seam.pages.xml.model.helpers.SeamPagesProcessHelper;
+import org.jboss.tools.seam.pages.xml.model.helpers.SeamPagesDiagramHelper;
public class AddViewSupport extends SpecialWizardSupport implements SeamPagesConstants {
public static String JSF_ADD_VIEW_PATH = ""; //preference name
@@ -115,8 +115,8 @@
createFile(path);
XModelObject m = getTarget().getParent().getChildByPath(FOLDER_PAGES);
- String pp = SeamPagesProcessHelper.toNavigationRulePathPart(path);
- boolean isPattern = SeamPagesProcessHelper.isPattern(path);
+ String pp = SeamPagesDiagramHelper.toNavigationRulePathPart(path);
+ boolean isPattern = SeamPagesDiagramHelper.isPattern(path);
boolean existsR = m.getChildByPath(path) != null; // m.getRuleCount(path) != 0;
boolean existsV = findView(path) != null;
@@ -146,9 +146,9 @@
m.setModified(true);
created = getTarget().getChildByPath(pp);
} else {
- created =
getTarget().getModel().createModelObject(SeamPagesConstants.ENT_PROCESS_ITEM, null);
+ created =
getTarget().getModel().createModelObject(SeamPagesConstants.ENT_DIAGRAM_ITEM, null);
String ppi = pp;
-// if(exists && SeamPagesProcessHelper.isPattern(path)) {
+// if(exists && SeamPagesDiagramHelper.isPattern(path)) {
// int index = -1;
// while(getTarget().getChildByPath(ppi + ":" + index) != null) index--;
// ppi = ppi + ":" + index;
@@ -177,10 +177,10 @@
}
private XModelObject findView(String path) {
- String pp = SeamPagesProcessHelper.toNavigationRulePathPart(path);
+ String pp = SeamPagesDiagramHelper.toNavigationRulePathPart(path);
XModelObject o = getTarget().getChildByPath(pp);
if(o != null) return o;
- if(!SeamPagesProcessHelper.isPattern(path)) return null;
+ if(!SeamPagesDiagramHelper.isPattern(path)) return null;
XModelObject[] cs = getTarget().getChildren();
for (int i = 0; i < cs.length; i++) {
String p = cs[i].getPathPart();
@@ -312,9 +312,9 @@
if(message != null) return;
boolean doNotCreateEmptyRule = false;
//"yes".equals(JSFPreference.DO_NOT_CREATE_EMPTY_RULE.getValue());
- String pp = SeamPagesProcessHelper.toNavigationRulePathPart(path);
+ String pp = SeamPagesDiagramHelper.toNavigationRulePathPart(path);
boolean exists = getTarget().getChildByPath(pp) != null;
- if(doNotCreateEmptyRule && exists /*&&
!SeamPagesProcessHelper.isPattern(path)*/) {
+ if(doNotCreateEmptyRule && exists /*&&
!SeamPagesDiagramHelper.isPattern(path)*/) {
message = "View exists."; //JSFUIMessages.THE_VIEW_EXISTS;
}
Modified:
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/handlers/DeleteOutputHandler.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/handlers/DeleteOutputHandler.java 2008-06-05
10:41:43 UTC (rev 8567)
+++
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/handlers/DeleteOutputHandler.java 2008-06-05
10:42:32 UTC (rev 8568)
@@ -6,12 +6,12 @@
import org.jboss.tools.common.model.XModelException;
import org.jboss.tools.common.model.XModelObject;
import org.jboss.tools.seam.pages.xml.model.SeamPagesConstants;
-import org.jboss.tools.seam.pages.xml.model.helpers.SeamPagesProcessStructureHelper;
+import org.jboss.tools.seam.pages.xml.model.helpers.SeamPagesDiagramStructureHelper;
public class DeleteOutputHandler extends DefaultRemoveHandler {
public void executeHandler(XModelObject object, Properties p) throws XModelException {
- XModelObject redirect = SeamPagesProcessStructureHelper.instance.getReference(object);
+ XModelObject redirect = SeamPagesDiagramStructureHelper.instance.getReference(object);
if(redirect == null) return;
XModelObject rule = redirect.getParent();
XModelObject g = rule.getParent();
Modified:
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/handlers/OpenPageHandler.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/handlers/OpenPageHandler.java 2008-06-05
10:41:43 UTC (rev 8567)
+++
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/handlers/OpenPageHandler.java 2008-06-05
10:42:32 UTC (rev 8568)
@@ -23,8 +23,8 @@
|| entity.startsWith(ENT_RULE)) {
source = source.getChildByPath("target");
attr = ATTR_VIEW_ID;
- } else if(ENT_PROCESS_ITEM.equals(entity) ||
- ENT_PROCESS_ITEM_OUTPUT.equals(entity)) {
+ } else if(ENT_DIAGRAM_ITEM.equals(entity) ||
+ ENT_DIAGRAM_ITEM_OUTPUT.equals(entity)) {
attr = ATTR_PATH;
}
if(attr == null) return null;
Modified:
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/handlers/PageAdopt.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/handlers/PageAdopt.java 2008-06-05
10:41:43 UTC (rev 8567)
+++
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/handlers/PageAdopt.java 2008-06-05
10:42:32 UTC (rev 8568)
@@ -24,13 +24,13 @@
public boolean isAdoptable(XModelObject target, XModelObject object) {
String entity = object.getModelEntity().getName();
- if(ENT_PROCESS_ITEM_OUTPUT.equals(entity)) {
+ if(ENT_DIAGRAM_ITEM_OUTPUT.equals(entity)) {
if(move_case) {
return canMoveCase(target, object);
}
return canBeOutputTarget(target);
}
- if(ENT_PROCESS_ITEM.equals(entity)) {
+ if(ENT_DIAGRAM_ITEM.equals(entity)) {
return canBeOutputTarget(target);
}
if(entity.startsWith(ENT_SEAM_PAGE)) {
@@ -65,14 +65,14 @@
public void adopt(XModelObject target, XModelObject object, Properties p) throws
XModelException {
String entity = object.getModelEntity().getName();
- if(ENT_PROCESS_ITEM_OUTPUT.equals(entity)) {
+ if(ENT_DIAGRAM_ITEM_OUTPUT.equals(entity)) {
if(move_case) {
moveOutput(object, target, p);
} else {
adoptOutput(object, target, p);
}
}
- else if(ENT_PROCESS_ITEM.equals(entity)) adoptItem(object, target, p);
+ else if(ENT_DIAGRAM_ITEM.equals(entity)) adoptItem(object, target, p);
else if(entity.startsWith(ENT_SEAM_PAGE)) adoptSeamPage(object, target, p);
}
Modified:
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/handlers/ProcessAdopt.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/handlers/ProcessAdopt.java 2008-06-05
10:41:43 UTC (rev 8567)
+++
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/handlers/ProcessAdopt.java 2008-06-05
10:42:32 UTC (rev 8568)
@@ -18,7 +18,7 @@
import org.jboss.tools.common.model.XModelObject;
import org.jboss.tools.common.model.util.XModelObjectLoaderUtil;
import org.jboss.tools.seam.pages.xml.model.SeamPagesConstants;
-import org.jboss.tools.seam.pages.xml.model.helpers.SeamPagesProcessHelper;
+import org.jboss.tools.seam.pages.xml.model.helpers.SeamPagesDiagramHelper;
public class ProcessAdopt implements XAdoptManager, SeamPagesConstants {
@@ -46,16 +46,16 @@
if (ADOPTABLE_JSP.indexOf("." + entity + ".") >= 0) {
String path = XModelObjectLoaderUtil.getResourcePath(object);
if (target.getModelEntity().getName().startsWith(ENT_FILE_SEAM_PAGES)) {
- target = target.getChildByPath(ELM_PROCESS);
+ target = target.getChildByPath(ELM_DIAGRAM);
}
- return SeamPagesProcessHelper.getHelper(target).getPage(path) == null;
+ return SeamPagesDiagramHelper.getHelper(target).getPage(path) == null;
}
return false;
}
private void adoptJSP(XModelObject target, XModelObject object, Properties p) throws
XModelException {
if (target.getModelEntity().getName().startsWith(ENT_FILE_SEAM_PAGES)) {
- target = target.getChildByPath(ELM_PROCESS);
+ target = target.getChildByPath(ELM_DIAGRAM);
}
addRuleByPageAdopt(target, object, p);
/*
@@ -68,10 +68,10 @@
private void addRuleByPageAdopt(XModelObject process, XModelObject page, Properties p)
throws XModelException {
String path = XModelObjectLoaderUtil.getResourcePath(page);
- XModelObject pageItem = SeamPagesProcessHelper.getHelper(process).getPage(path);
+ XModelObject pageItem = SeamPagesDiagramHelper.getHelper(process).getPage(path);
if(pageItem != null) return;
boolean doNotCreateEmptyRule = false; //or read preferences, compare JSF
- pageItem = SeamPagesProcessHelper.getHelper(process).findOrCreateItem(path, null,
TYPE_PAGE);
+ pageItem = SeamPagesDiagramHelper.getHelper(process).findOrCreateItem(path, null,
TYPE_PAGE);
setShape(pageItem, p);
if(doNotCreateEmptyRule) {
pageItem.setAttributeValue("persistent", "true");
@@ -94,15 +94,15 @@
}
public static void setShape(XModelObject group, Properties p) {
- String x = (p == null) ? null : p.getProperty("process.mouse.x");
- String y = (p == null) ? null : p.getProperty("process.mouse.y");
+ String x = (p == null) ? null : p.getProperty("mouse.x");
+ String y = (p == null) ? null : p.getProperty("mouse.y");
if(x != null && y != null) {
group.setAttributeValue("shape", "" + x + "," + y +
",0,0");
}
}
private boolean isAdoptableItem(XModelObject target, XModelObject object) {
- return ENT_PROCESS_ITEM.equals(object.getModelEntity().getName());
+ return ENT_DIAGRAM_ITEM.equals(object.getModelEntity().getName());
}
private void adoptItem(XModelObject target, XModelObject object, Properties p) {
Modified:
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/handlers/SelectOnDiagramHandler.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/handlers/SelectOnDiagramHandler.java 2008-06-05
10:41:43 UTC (rev 8567)
+++
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/handlers/SelectOnDiagramHandler.java 2008-06-05
10:42:32 UTC (rev 8568)
@@ -16,7 +16,7 @@
import org.jboss.tools.common.meta.action.impl.*;
import org.jboss.tools.jst.web.model.ReferenceObject;
import org.jboss.tools.seam.pages.xml.model.SeamPagesConstants;
-import org.jboss.tools.seam.pages.xml.model.helpers.SeamPagesProcessStructureHelper;
+import org.jboss.tools.seam.pages.xml.model.helpers.SeamPagesDiagramStructureHelper;
public class SelectOnDiagramHandler extends AbstractHandler implements SeamPagesConstants
{
@@ -33,28 +33,28 @@
|| entity.startsWith(SeamPagesConstants.ENT_RULE)) {
object = object.getChildByPath("target");
}
- XModelObject item = getItemOnProcess(object);
+ XModelObject item = getItemOnDiagram(object);
if(item == null) return;
FindObjectHelper.findModelObject(item, FindObjectHelper.IN_EDITOR_ONLY,
"Diagram");
FindObjectHelper.findModelObject(object, FindObjectHelper.IN_EDITOR_ONLY);
}
- public static XModelObject getItemOnProcess(XModelObject object) {
+ public static XModelObject getItemOnDiagram(XModelObject object) {
if(object == null) return null;
- XModelObject process =
SeamPagesProcessStructureHelper.instance.getProcess(object);
- return (process == null) ? null : getItemOnProcess(process, object);
+ XModelObject diagram =
SeamPagesDiagramStructureHelper.instance.getProcess(object);
+ return (diagram == null) ? null : getItemOnDiagram(diagram, object);
}
- public static XModelObject getItemOnProcess(XModelObject processObject, XModelObject
object) {
- if(processObject instanceof ReferenceObject) {
- if(((ReferenceObject)processObject).getReference() == object) return
processObject;
+ public static XModelObject getItemOnDiagram(XModelObject diagramObject, XModelObject
object) {
+ if(diagramObject instanceof ReferenceObject) {
+ if(((ReferenceObject)diagramObject).getReference() == object) return
diagramObject;
}
- return getItemOnProcess(processObject.getChildren(), object);
+ return getItemOnDiagram(diagramObject.getChildren(), object);
}
- public static XModelObject getItemOnProcess(XModelObject[] processObjects,
XModelObject object) {
- for (int i = 0; i < processObjects.length; i++) {
- XModelObject cr = getItemOnProcess(processObjects[i], object);
+ public static XModelObject getItemOnDiagram(XModelObject[] diagramObjects,
XModelObject object) {
+ for (int i = 0; i < diagramObjects.length; i++) {
+ XModelObject cr = getItemOnDiagram(diagramObjects[i], object);
if(cr != null) return cr;
}
return null;
Copied:
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/helpers/SeamPagesDiagramHelper.java
(from rev 8457,
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/helpers/SeamPagesProcessHelper.java)
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/helpers/SeamPagesDiagramHelper.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/helpers/SeamPagesDiagramHelper.java 2008-06-05
10:42:32 UTC (rev 8568)
@@ -0,0 +1,381 @@
+package org.jboss.tools.seam.pages.xml.model.helpers;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.jboss.tools.common.model.XModelObject;
+import org.jboss.tools.common.model.util.XModelObjectUtil;
+import org.jboss.tools.jst.web.model.ReferenceObject;
+import org.jboss.tools.jst.web.model.helpers.autolayout.AutoLayout;
+import org.jboss.tools.seam.pages.xml.model.SeamPagesConstants;
+import org.jboss.tools.seam.pages.xml.model.helpers.autolayout.SeamPagesItems;
+import org.jboss.tools.seam.pages.xml.model.impl.ReferenceObjectImpl;
+import org.jboss.tools.seam.pages.xml.model.impl.SeamPagesDiagramImpl;
+
+public class SeamPagesDiagramHelper implements SeamPagesConstants {
+ private XModelObject diagram;
+ private static XModelObject TEMPLATE;
+ private XModelObject config;
+ private Map<String,XModelObject> pageItems = new
HashMap<String,XModelObject>();
+ private Map<String,XModelObject> exceptionItems = new
HashMap<String,XModelObject>();
+ private Map<String,XModelObject> targets = new
HashMap<String,XModelObject>();
+
+ public SeamPagesDiagramHelper(XModelObject diagram) {
+ this.diagram = diagram;
+ }
+
+ public static SeamPagesDiagramHelper getHelper(XModelObject diagram) {
+ return ((SeamPagesDiagramImpl)diagram).getHelper();
+ }
+
+ private synchronized void reset() {
+ pageItems.clear();
+ exceptionItems.clear();
+ targets.clear();
+ this.config = diagram.getParent();
+ }
+
+ public void restoreRefs() {
+ ((SeamPagesDiagramImpl)diagram).setReference(diagram.getParent());
+ }
+
+ Set<Object> updateLocks = new HashSet<Object>();
+
+ public boolean isUpdateLocked() {
+ return updateLocks.size() > 0;
+ }
+
+ public void addUpdateLock(Object lock) {
+ updateLocks.add(lock);
+ }
+
+ public void removeUpdateLock(Object lock) {
+ updateLocks.remove(lock);
+ }
+
+ public void updateDiagram() {
+ if(isUpdateLocked()) return;
+ addUpdateLock(this);
+ try {
+ updateDiagram0();
+ } finally {
+ removeUpdateLock(this);
+ }
+ }
+
+ private void updateDiagram0() {
+ reset();
+ XModelObject[] sourcePages = config.getChildByPath(FOLDER_PAGES).getChildren();
+
+ for (int i = 0; i < sourcePages.length; i++) {
+ String view = sourcePages[i].getAttributeValue(ATTR_VIEW_ID);
+ if(view == null) continue;
+ String pp = toNavigationRulePathPart(view);
+ XModelObject g = findOrCreateItem(view, pp, TYPE_PAGE);
+ ((ReferenceObjectImpl)g).setReference(sourcePages[i]);
+ pageItems.put(pp, g);
+ XModelObject[] ns = sourcePages[i].getChildren();
+ for (int j = 0; j < ns.length; j++) {
+ String entity = ns[j].getModelEntity().getName();
+ if(!entity.startsWith(ENT_NAVIGATION)) continue;
+ if(entity.startsWith(ENT_NAVIGATION_RULE)) {
+ addTarget(ns[j]);
+ } else {
+ XModelObject[] rs = ns[j].getChildren();
+ for (int k = 0; k < rs.length; k++) {
+ addTarget(rs[k]);
+ }
+ }
+ }
+ }
+
+ XModelObject[] sourceExceptions =
config.getChildByPath(FOLDER_EXCEPTIONS).getChildren();
+ for (int i = 0; i < sourceExceptions.length; i++) {
+ String code = sourceExceptions[i].getAttributeValue("class");
+ XModelObject g = findOrCreateItem(code, code, TYPE_EXCEPTION);
+ ((ReferenceObjectImpl)g).setReference(sourceExceptions[i]);
+ exceptionItems.put(code, g);
+ addTarget(sourceExceptions[i]);
+ }
+
+ Iterator<String> it = pageItems.keySet().iterator();
+ while(it.hasNext()) targets.remove(it.next());
+
+ removeObsoletePageItems();
+ removeObsoleteExceptionItems();
+ createPageItems();
+ updatePageItems();
+ updateExceptionItems();
+
+ updatePages();
+ }
+
+ private void addTarget(XModelObject rule) {
+ XModelObject target = rule.getChildByPath("target");
+ if(target == null) return;
+ String tvi = target.getAttributeValue(ATTR_VIEW_ID);
+ if(tvi == null) return;
+ String ppt = toNavigationRulePathPart(tvi);
+ targets.put(ppt, getTemplate());
+ }
+
+ private XModelObject getTemplate() {
+ if(TEMPLATE == null && diagram != null) {
+ TEMPLATE = diagram.getModel().createModelObject(ENT_DIAGRAM_ITEM, null);
+ }
+ return TEMPLATE;
+ }
+
+ public XModelObject findOrCreateItem(String path, String pp, String type) {
+ if(pp == null) pp = toNavigationRulePathPart(path);
+ XModelObject g = diagram.getChildByPath(pp);
+ if(g == null) {
+ g = diagram.getModel().createModelObject(ENT_DIAGRAM_ITEM, null);
+ g.setAttributeValue(ATTR_NAME, pp);
+ g.setAttributeValue(ATTR_PATH, path);
+ g.setAttributeValue(ATTR_TYPE, type);
+ diagram.addChild(g);
+ }
+ return g;
+ }
+
+ private void removeObsoletePageItems() {
+ XModelObject[] ps = diagram.getChildren(ENT_DIAGRAM_ITEM);
+ for (int i = 0; i < ps.length; i++) {
+ String path = ps[i].getPathPart();
+ String type = ps[i].getAttributeValue(ATTR_TYPE);
+ if(!TYPE_PAGE.equals(type)) continue;
+ if(!pageItems.containsKey(path) && !targets.containsKey(path)) {
+ ps[i].removeFromParent();
+ }
+ }
+ }
+
+ private void removeObsoleteExceptionItems() {
+ XModelObject[] ps = diagram.getChildren(ENT_DIAGRAM_ITEM);
+ for (int i = 0; i < ps.length; i++) {
+ String path = ps[i].getPathPart();
+ String type = ps[i].getAttributeValue(ATTR_TYPE);
+ if(!TYPE_EXCEPTION.equals(type)) continue;
+ if(!exceptionItems.containsKey(path)) {
+ ps[i].removeFromParent();
+ }
+ }
+ }
+
+ private void createPageItems() {
+ String[] paths = (String[])targets.keySet().toArray(new String[0]);
+ for (int i = 0; i < paths.length; i++) {
+ String fvi = toFromViewId(paths[i]);
+ XModelObject g = findOrCreateItem(fvi, paths[i], TYPE_PAGE);
+ targets.put(paths[i], g);
+ }
+ }
+
+ private void updatePageItems() {
+ ReferenceObjectImpl[] gs = (ReferenceObjectImpl[])pageItems.values().toArray(new
ReferenceObjectImpl[0]);
+ for (int i = 0; i < gs.length; i++) {
+ updatePageItem(gs[i]);
+ }
+ gs = (ReferenceObjectImpl[])targets.values().toArray(new ReferenceObjectImpl[0]);
+ for (int i = 0; i < gs.length; i++) {
+ gs[i].setReference(null);
+ updatePageItem(gs[i]);
+ }
+ }
+
+ private void updateExceptionItems() {
+ ReferenceObjectImpl[] gs = (ReferenceObjectImpl[])exceptionItems.values().toArray(new
ReferenceObjectImpl[0]);
+ for (int i = 0; i < gs.length; i++) {
+ updateExceptionItem(gs[i]);
+ }
+ }
+
+ private void updatePageItem(ReferenceObjectImpl item) {
+ if(item.isUpToDate()) return;
+ item.notifyUpdate();
+ XModelObject sourcePage = item.getReference();
+ item.setAttributeValue(ATTR_ID, sourcePage.getPathPart());
+ item.setAttributeValue(ATTR_PATH, sourcePage.getAttributeValue(ATTR_VIEW_ID));
+ String[][] params = SeamPagesDiagramStructureHelper.getInstance().getParams(item);
+ StringBuffer sb = new StringBuffer();
+ for (int i = 0; i < params.length; i++) {
+ sb.append(params[i][0]).append('=').append(params[i][1]).append(';');
+ }
+ item.setAttributeValue("params", sb.toString());
+ XModelObject[] cs = getPageTargets(sourcePage);
+ updateOutputs(item, cs);
+ }
+
+ private XModelObject[] getPageTargets(XModelObject o) {
+ XModelObject[] ns = o.getChildren();
+ List<XModelObject> result = null;
+ for (int i = 0; i < ns.length; i++) {
+ String entity = ns[i].getModelEntity().getName();
+ if(!entity.startsWith(ENT_NAVIGATION)) continue;
+ if(entity.startsWith(ENT_NAVIGATION_RULE)) {
+ XModelObject t = getTargetChild(ns[i]);
+ if(t != null) {
+ if(result == null) result = new ArrayList<XModelObject>();
+ result.add(t);
+ }
+ } else {
+ XModelObject[] rs = ns[i].getChildren();
+ for (int k = 0; k < rs.length; k++) {
+ XModelObject t = getTargetChild(rs[k]);
+ if(t != null) {
+ if(result == null) result = new ArrayList<XModelObject>();
+ result.add(t);
+ }
+ }
+ }
+ }
+ return result == null ? new XModelObject[0]
+ : result.toArray(new XModelObject[0]);
+ }
+
+ private void updateExceptionItem(ReferenceObjectImpl item) {
+ if(item.isUpToDate()) return;
+ item.notifyUpdate();
+ XModelObject exc = item.getReference();
+ item.setAttributeValue(ATTR_ID, exc.getPathPart());
+ item.setAttributeValue(ATTR_PATH, exc.getAttributeValue(ATTR_VIEW_ID));
+ XModelObject t = getTargetChild(exc);
+ XModelObject[] cs = t == null ? new XModelObject[0] : new XModelObject[]{t};
+ updateOutputs(item, cs);
+ }
+
+ private XModelObject getTargetChild(XModelObject o) {
+ XModelObject t = o.getChildByPath("target");
+ if(t == null || t.getModelEntity().getAttribute(ATTR_VIEW_ID) == null) return null;
+ return t;
+ }
+
+ private void updateOutputs(ReferenceObjectImpl item, XModelObject[] cases) {
+ XModelObject[] os = item.getChildren();
+ if(isOutputOrderUpToDate(cases, os)) {
+ updateOutputs_1(item, cases, os);
+ } else {
+ updateOutputs_2(item, cases, os);
+ }
+ }
+
+ private void updateOutputs_1(ReferenceObjectImpl item, XModelObject[] cases,
XModelObject[] outputs) {
+ int c = 0;
+ for (int i = 0; i < cases.length; i++) {
+ XModelObject output = null;
+ if(c < outputs.length) {
+ output = outputs[c];
+ } else {
+ output = createOutput(item, cases[i]);
+ }
+ ReferenceObjectImpl r = (ReferenceObjectImpl)output;
+ r.setReference(cases[i]);
+ updateOutput(r);
+ ++c;
+ }
+ for (int i = c; i < outputs.length; i++) outputs[i].removeFromParent();
+ }
+
+ private void updateOutputs_2(ReferenceObjectImpl item, XModelObject[] cases,
XModelObject[] outputs) {
+ Map<String,XModelObject> map = new HashMap<String,XModelObject>();
+ for (int i = 0; i < outputs.length; i++) {
+ XModelObject output = outputs[i];
+ output.removeFromParent();
+ map.put(output.getAttributeValue(ATTR_ID), output);
+ }
+ for (int i = 0; i < cases.length; i++) {
+ XModelObject output = map.get(cases[i].getPathPart());
+ if(output == null) {
+ output = createOutput(item, cases[i]);
+ } else {
+ item.addChild(output);
+ }
+ ReferenceObjectImpl r = (ReferenceObjectImpl)output;
+ r.setReference(cases[i]);
+ updateOutput(r);
+ }
+ }
+
+ private boolean isOutputOrderUpToDate(XModelObject[] cases, XModelObject[] outputs) {
+ for (int i = 0; i < cases.length && i < outputs.length; i++) {
+ ReferenceObject r = (ReferenceObject)outputs[i];
+ if(r.getReference() == cases[i]) continue;
+ String pp = cases[i].getAttributeValue(ATTR_VIEW_ID);
+ String id = outputs[i].getAttributeValue(ATTR_ID);
+ if(!pp.equals(id)) return false;
+ }
+ return true;
+ }
+
+ private XModelObject createOutput(XModelObject item, XModelObject rulecase) {
+ XModelObject output = item.getModel().createModelObject(ENT_DIAGRAM_ITEM_OUTPUT,
null);
+ output.setAttributeValue(ATTR_ID, rulecase.getAttributeValue(ATTR_VIEW_ID));
+ output.setAttributeValue(ATTR_PATH, rulecase.getAttributeValue(ATTR_VIEW_ID));
+ String name = XModelObjectUtil.createNewChildName("output", item);
+ output.setAttributeValue(ATTR_NAME, name);
+
+ ReferenceObjectImpl r = (ReferenceObjectImpl)output;
+ r.setReference(rulecase);
+ updateOutput(r);
+
+ item.addChild(output);
+ return output;
+ }
+
+ private void updateOutput(ReferenceObjectImpl output) {
+ if(output.isUpToDate()) return;
+ output.notifyUpdate();
+ XModelObject rulecase = output.getReference();
+ output.setAttributeValue(ATTR_ID, rulecase.getAttributeValue(ATTR_VIEW_ID));
+ String path = rulecase.getAttributeValue(ATTR_VIEW_ID);
+ output.setAttributeValue(ATTR_PATH, path);
+// String title =
SeamPagesDiagramStructureHelper.createItemOutputPresentation(rulecase);
+// output.setAttributeValue("title", title);
+ XModelObject g = findGroupByPath(path);
+ String target = (g == null) ? "" : g.getPathPart();
+ output.setAttributeValue(ATTR_TARGET, target);
+ }
+
+ private XModelObject findGroupByPath(String path) {
+ return getPage(path);
+ }
+
+ public void autolayout() {
+ AutoLayout auto = new AutoLayout();
+ auto.setItems(new SeamPagesItems());
+ auto.setProcess(diagram);
+ }
+
+ public XModelObject getPage(String path) {
+ path = toNavigationRulePathPart(path);
+ XModelObject g = (XModelObject)pageItems.get(path);
+ if(g == null) g = (XModelObject)targets.get(path);
+ return g;
+ }
+
+ public void updatePages() {
+ //TODO
+ }
+
+ public static String toNavigationRulePathPart(String path) {
+ return "" + path.replace('/', '#');
+ }
+
+ public static String toFromViewId(String pathpart) {
+ if(!pathpart.startsWith("rules:")) return pathpart.replace('#',
'/');
+ pathpart = pathpart.substring(6).replace('#', '/');
+ int i = pathpart.lastIndexOf(':');
+ return (i < 0) ? pathpart : pathpart.substring(0, i);
+ }
+
+ public static boolean isPattern(String path) {
+ return path != null && (path.length() == 0 || path.indexOf('*') >=
0);
+ }
+
+}
Copied:
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/helpers/SeamPagesDiagramStructureHelper.java
(from rev 8457,
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/helpers/SeamPagesProcessStructureHelper.java)
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/helpers/SeamPagesDiagramStructureHelper.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/helpers/SeamPagesDiagramStructureHelper.java 2008-06-05
10:42:32 UTC (rev 8568)
@@ -0,0 +1,80 @@
+package org.jboss.tools.seam.pages.xml.model.helpers;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.tools.common.model.XModelObject;
+import org.jboss.tools.jst.web.model.ReferenceObject;
+import org.jboss.tools.jst.web.model.helpers.WebProcessStructureHelper;
+import org.jboss.tools.seam.pages.xml.model.SeamPagesConstants;
+
+public class SeamPagesDiagramStructureHelper extends WebProcessStructureHelper implements
SeamPagesConstants {
+ public static SeamPagesDiagramStructureHelper instance = new
SeamPagesDiagramStructureHelper();
+
+ public static SeamPagesDiagramStructureHelper getInstance() {
+ return instance;
+ }
+
+ public XModelObject getParentProcess(XModelObject element) {
+ XModelObject p = element;
+ while(p != null && p.getFileType() == XModelObject.NONE &&
+ !ENT_DIAGRAM.equals(p.getModelEntity().getName())) p = p.getParent();
+ return p;
+ }
+
+ public XModelObject[] getItems(XModelObject process) {
+ return process.getChildren(ENT_DIAGRAM_ITEM);
+ }
+
+ public XModelObject[] getOutputs(XModelObject item) {
+ return item.getChildren(ENT_DIAGRAM_ITEM_OUTPUT);
+ }
+
+ public String getPath(XModelObject element) {
+ return element.getAttributeValue(ATTR_PATH);
+ }
+
+ public XModelObject getItemOutputTarget(XModelObject itemOutput) {
+ return
itemOutput.getParent().getParent().getChildByPath(itemOutput.getAttributeValue(ATTR_TARGET));
+ }
+
+ public String getItemOutputPresentation(XModelObject itemOutput) {
+// boolean s = isShortcut(itemOutput);
+ return itemOutput.getPresentationString();
+ }
+
+ public boolean isPattern(XModelObject item) {
+ String path = item.getAttributeValue(ATTR_PATH);
+ return (path != null) && (path.length() == 0 || path.indexOf('*') >=
0);
+ }
+
+ public boolean isUnconfirmedPage(XModelObject item) {
+ String type = item.getAttributeValue(ATTR_TYPE);
+ if(!TYPE_PAGE.equals(type)) return false;
+ if(isPattern(item)) return false;
+ return !"true".equals(item.getAttributeValue("confirmed"));
+ }
+
+ public XModelObject getReference(XModelObject diagramObject) {
+ if(diagramObject instanceof ReferenceObject) {
+ return ((ReferenceObject)diagramObject).getReference();
+ }
+ return null;
+ }
+
+ public String[][] getParams(XModelObject item) {
+ XModelObject o = getReference(item);
+ if(o == null) return new String[0][];
+ XModelObject[] os = o.getChildren();
+ List<String[]> list = new ArrayList<String[]>();
+ for (int i = 0; i < os.length; i++) {
+ if(os[i].getModelEntity().getName().startsWith(ENT_PARAM)) {
+ String n = os[i].getAttributeValue(ATTR_NAME);
+ String v = os[i].getAttributeValue(ATTR_VALUE);
+ list.add(new String[]{n, v});
+ }
+ }
+ return list.toArray(new String[0][]);
+ }
+
+}
Deleted:
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/helpers/SeamPagesProcessHelper.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/helpers/SeamPagesProcessHelper.java 2008-06-05
10:41:43 UTC (rev 8567)
+++
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/helpers/SeamPagesProcessHelper.java 2008-06-05
10:42:32 UTC (rev 8568)
@@ -1,381 +0,0 @@
-package org.jboss.tools.seam.pages.xml.model.helpers;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.jboss.tools.common.model.XModelObject;
-import org.jboss.tools.common.model.util.XModelObjectUtil;
-import org.jboss.tools.jst.web.model.ReferenceObject;
-import org.jboss.tools.jst.web.model.helpers.autolayout.AutoLayout;
-import org.jboss.tools.seam.pages.xml.model.SeamPagesConstants;
-import org.jboss.tools.seam.pages.xml.model.helpers.autolayout.SeamPagesItems;
-import org.jboss.tools.seam.pages.xml.model.impl.ReferenceObjectImpl;
-import org.jboss.tools.seam.pages.xml.model.impl.SeamPagesProcessImpl;
-
-public class SeamPagesProcessHelper implements SeamPagesConstants {
- private XModelObject process;
- private static XModelObject TEMPLATE;
- private XModelObject config;
- private Map<String,XModelObject> pageItems = new
HashMap<String,XModelObject>();
- private Map<String,XModelObject> exceptionItems = new
HashMap<String,XModelObject>();
- private Map<String,XModelObject> targets = new
HashMap<String,XModelObject>();
-
- public SeamPagesProcessHelper(XModelObject process) {
- this.process = process;
- }
-
- public static SeamPagesProcessHelper getHelper(XModelObject process) {
- return ((SeamPagesProcessImpl)process).getHelper();
- }
-
- private synchronized void reset() {
- pageItems.clear();
- exceptionItems.clear();
- targets.clear();
- this.config = process.getParent();
- }
-
- public void restoreRefs() {
- ((SeamPagesProcessImpl)process).setReference(process.getParent());
- }
-
- Set<Object> updateLocks = new HashSet<Object>();
-
- public boolean isUpdateLocked() {
- return updateLocks.size() > 0;
- }
-
- public void addUpdateLock(Object lock) {
- updateLocks.add(lock);
- }
-
- public void removeUpdateLock(Object lock) {
- updateLocks.remove(lock);
- }
-
- public void updateProcess() {
- if(isUpdateLocked()) return;
- addUpdateLock(this);
- try {
- updateProcess0();
- } finally {
- removeUpdateLock(this);
- }
- }
-
- private void updateProcess0() {
- reset();
- XModelObject[] sourcePages = config.getChildByPath(FOLDER_PAGES).getChildren();
-
- for (int i = 0; i < sourcePages.length; i++) {
- String view = sourcePages[i].getAttributeValue(ATTR_VIEW_ID);
- if(view == null) continue;
- String pp = toNavigationRulePathPart(view);
- XModelObject g = findOrCreateItem(view, pp, TYPE_PAGE);
- ((ReferenceObjectImpl)g).setReference(sourcePages[i]);
- pageItems.put(pp, g);
- XModelObject[] ns = sourcePages[i].getChildren();
- for (int j = 0; j < ns.length; j++) {
- String entity = ns[j].getModelEntity().getName();
- if(!entity.startsWith(ENT_NAVIGATION)) continue;
- if(entity.startsWith(ENT_NAVIGATION_RULE)) {
- addTarget(ns[j]);
- } else {
- XModelObject[] rs = ns[j].getChildren();
- for (int k = 0; k < rs.length; k++) {
- addTarget(rs[k]);
- }
- }
- }
- }
-
- XModelObject[] sourceExceptions =
config.getChildByPath(FOLDER_EXCEPTIONS).getChildren();
- for (int i = 0; i < sourceExceptions.length; i++) {
- String code = sourceExceptions[i].getAttributeValue("class");
- XModelObject g = findOrCreateItem(code, code, TYPE_EXCEPTION);
- ((ReferenceObjectImpl)g).setReference(sourceExceptions[i]);
- exceptionItems.put(code, g);
- addTarget(sourceExceptions[i]);
- }
-
- Iterator<String> it = pageItems.keySet().iterator();
- while(it.hasNext()) targets.remove(it.next());
-
- removeObsoletePageItems();
- removeObsoleteExceptionItems();
- createPageItems();
- updatePageItems();
- updateExceptionItems();
-
- updatePages();
- }
-
- private void addTarget(XModelObject rule) {
- XModelObject target = rule.getChildByPath("target");
- if(target == null) return;
- String tvi = target.getAttributeValue(ATTR_VIEW_ID);
- if(tvi == null) return;
- String ppt = toNavigationRulePathPart(tvi);
- targets.put(ppt, getTemplate());
- }
-
- private XModelObject getTemplate() {
- if(TEMPLATE == null && process != null) {
- TEMPLATE = process.getModel().createModelObject(ENT_PROCESS_ITEM, null);
- }
- return TEMPLATE;
- }
-
- public XModelObject findOrCreateItem(String path, String pp, String type) {
- if(pp == null) pp = toNavigationRulePathPart(path);
- XModelObject g = process.getChildByPath(pp);
- if(g == null) {
- g = process.getModel().createModelObject(ENT_PROCESS_ITEM, null);
- g.setAttributeValue(ATTR_NAME, pp);
- g.setAttributeValue(ATTR_PATH, path);
- g.setAttributeValue(ATTR_TYPE, type);
- process.addChild(g);
- }
- return g;
- }
-
- private void removeObsoletePageItems() {
- XModelObject[] ps = process.getChildren(ENT_PROCESS_ITEM);
- for (int i = 0; i < ps.length; i++) {
- String path = ps[i].getPathPart();
- String type = ps[i].getAttributeValue(ATTR_TYPE);
- if(!TYPE_PAGE.equals(type)) continue;
- if(!pageItems.containsKey(path) && !targets.containsKey(path)) {
- ps[i].removeFromParent();
- }
- }
- }
-
- private void removeObsoleteExceptionItems() {
- XModelObject[] ps = process.getChildren(ENT_PROCESS_ITEM);
- for (int i = 0; i < ps.length; i++) {
- String path = ps[i].getPathPart();
- String type = ps[i].getAttributeValue(ATTR_TYPE);
- if(!TYPE_EXCEPTION.equals(type)) continue;
- if(!exceptionItems.containsKey(path)) {
- ps[i].removeFromParent();
- }
- }
- }
-
- private void createPageItems() {
- String[] paths = (String[])targets.keySet().toArray(new String[0]);
- for (int i = 0; i < paths.length; i++) {
- String fvi = toFromViewId(paths[i]);
- XModelObject g = findOrCreateItem(fvi, paths[i], TYPE_PAGE);
- targets.put(paths[i], g);
- }
- }
-
- private void updatePageItems() {
- ReferenceObjectImpl[] gs = (ReferenceObjectImpl[])pageItems.values().toArray(new
ReferenceObjectImpl[0]);
- for (int i = 0; i < gs.length; i++) {
- updatePageItem(gs[i]);
- }
- gs = (ReferenceObjectImpl[])targets.values().toArray(new ReferenceObjectImpl[0]);
- for (int i = 0; i < gs.length; i++) {
- gs[i].setReference(null);
- updatePageItem(gs[i]);
- }
- }
-
- private void updateExceptionItems() {
- ReferenceObjectImpl[] gs = (ReferenceObjectImpl[])exceptionItems.values().toArray(new
ReferenceObjectImpl[0]);
- for (int i = 0; i < gs.length; i++) {
- updateExceptionItem(gs[i]);
- }
- }
-
- private void updatePageItem(ReferenceObjectImpl item) {
- if(item.isUpToDate()) return;
- item.notifyUpdate();
- XModelObject sourcePage = item.getReference();
- item.setAttributeValue(ATTR_ID, sourcePage.getPathPart());
- item.setAttributeValue(ATTR_PATH, sourcePage.getAttributeValue(ATTR_VIEW_ID));
- String[][] params = SeamPagesProcessStructureHelper.getInstance().getParams(item);
- StringBuffer sb = new StringBuffer();
- for (int i = 0; i < params.length; i++) {
- sb.append(params[i][0]).append('=').append(params[i][1]).append(';');
- }
- item.setAttributeValue("params", sb.toString());
- XModelObject[] cs = getPageTargets(sourcePage);
- updateOutputs(item, cs);
- }
-
- private XModelObject[] getPageTargets(XModelObject o) {
- XModelObject[] ns = o.getChildren();
- List<XModelObject> result = null;
- for (int i = 0; i < ns.length; i++) {
- String entity = ns[i].getModelEntity().getName();
- if(!entity.startsWith(ENT_NAVIGATION)) continue;
- if(entity.startsWith(ENT_NAVIGATION_RULE)) {
- XModelObject t = getTargetChild(ns[i]);
- if(t != null) {
- if(result == null) result = new ArrayList<XModelObject>();
- result.add(t);
- }
- } else {
- XModelObject[] rs = ns[i].getChildren();
- for (int k = 0; k < rs.length; k++) {
- XModelObject t = getTargetChild(rs[k]);
- if(t != null) {
- if(result == null) result = new ArrayList<XModelObject>();
- result.add(t);
- }
- }
- }
- }
- return result == null ? new XModelObject[0]
- : result.toArray(new XModelObject[0]);
- }
-
- private void updateExceptionItem(ReferenceObjectImpl item) {
- if(item.isUpToDate()) return;
- item.notifyUpdate();
- XModelObject exc = item.getReference();
- item.setAttributeValue(ATTR_ID, exc.getPathPart());
- item.setAttributeValue(ATTR_PATH, exc.getAttributeValue(ATTR_VIEW_ID));
- XModelObject t = getTargetChild(exc);
- XModelObject[] cs = t == null ? new XModelObject[0] : new XModelObject[]{t};
- updateOutputs(item, cs);
- }
-
- private XModelObject getTargetChild(XModelObject o) {
- XModelObject t = o.getChildByPath("target");
- if(t == null || t.getModelEntity().getAttribute(ATTR_VIEW_ID) == null) return null;
- return t;
- }
-
- private void updateOutputs(ReferenceObjectImpl item, XModelObject[] cases) {
- XModelObject[] os = item.getChildren();
- if(isOutputOrderUpToDate(cases, os)) {
- updateOutputs_1(item, cases, os);
- } else {
- updateOutputs_2(item, cases, os);
- }
- }
-
- private void updateOutputs_1(ReferenceObjectImpl item, XModelObject[] cases,
XModelObject[] outputs) {
- int c = 0;
- for (int i = 0; i < cases.length; i++) {
- XModelObject output = null;
- if(c < outputs.length) {
- output = outputs[c];
- } else {
- output = createOutput(item, cases[i]);
- }
- ReferenceObjectImpl r = (ReferenceObjectImpl)output;
- r.setReference(cases[i]);
- updateOutput(r);
- ++c;
- }
- for (int i = c; i < outputs.length; i++) outputs[i].removeFromParent();
- }
-
- private void updateOutputs_2(ReferenceObjectImpl item, XModelObject[] cases,
XModelObject[] outputs) {
- Map<String,XModelObject> map = new HashMap<String,XModelObject>();
- for (int i = 0; i < outputs.length; i++) {
- XModelObject output = outputs[i];
- output.removeFromParent();
- map.put(output.getAttributeValue(ATTR_ID), output);
- }
- for (int i = 0; i < cases.length; i++) {
- XModelObject output = map.get(cases[i].getPathPart());
- if(output == null) {
- output = createOutput(item, cases[i]);
- } else {
- item.addChild(output);
- }
- ReferenceObjectImpl r = (ReferenceObjectImpl)output;
- r.setReference(cases[i]);
- updateOutput(r);
- }
- }
-
- private boolean isOutputOrderUpToDate(XModelObject[] cases, XModelObject[] outputs) {
- for (int i = 0; i < cases.length && i < outputs.length; i++) {
- ReferenceObject r = (ReferenceObject)outputs[i];
- if(r.getReference() == cases[i]) continue;
- String pp = cases[i].getAttributeValue(ATTR_VIEW_ID);
- String id = outputs[i].getAttributeValue(ATTR_ID);
- if(!pp.equals(id)) return false;
- }
- return true;
- }
-
- private XModelObject createOutput(XModelObject item, XModelObject rulecase) {
- XModelObject output = item.getModel().createModelObject(ENT_PROCESS_ITEM_OUTPUT,
null);
- output.setAttributeValue(ATTR_ID, rulecase.getAttributeValue(ATTR_VIEW_ID));
- output.setAttributeValue(ATTR_PATH, rulecase.getAttributeValue(ATTR_VIEW_ID));
- String name = XModelObjectUtil.createNewChildName("output", item);
- output.setAttributeValue(ATTR_NAME, name);
-
- ReferenceObjectImpl r = (ReferenceObjectImpl)output;
- r.setReference(rulecase);
- updateOutput(r);
-
- item.addChild(output);
- return output;
- }
-
- private void updateOutput(ReferenceObjectImpl output) {
- if(output.isUpToDate()) return;
- output.notifyUpdate();
- XModelObject rulecase = output.getReference();
- output.setAttributeValue(ATTR_ID, rulecase.getAttributeValue(ATTR_VIEW_ID));
- String path = rulecase.getAttributeValue(ATTR_VIEW_ID);
- output.setAttributeValue(ATTR_PATH, path);
-// String title =
SeamPagesProcessStructureHelper.createItemOutputPresentation(rulecase);
-// output.setAttributeValue("title", title);
- XModelObject g = findGroupByPath(path);
- String target = (g == null) ? "" : g.getPathPart();
- output.setAttributeValue(ATTR_TARGET, target);
- }
-
- private XModelObject findGroupByPath(String path) {
- return getPage(path);
- }
-
- public void autolayout() {
- AutoLayout auto = new AutoLayout();
- auto.setItems(new SeamPagesItems());
- auto.setProcess(process);
- }
-
- public XModelObject getPage(String path) {
- path = toNavigationRulePathPart(path);
- XModelObject g = (XModelObject)pageItems.get(path);
- if(g == null) g = (XModelObject)targets.get(path);
- return g;
- }
-
- public void updatePages() {
- //TODO
- }
-
- public static String toNavigationRulePathPart(String path) {
- return "" + path.replace('/', '#');
- }
-
- public static String toFromViewId(String pathpart) {
- if(!pathpart.startsWith("rules:")) return pathpart.replace('#',
'/');
- pathpart = pathpart.substring(6).replace('#', '/');
- int i = pathpart.lastIndexOf(':');
- return (i < 0) ? pathpart : pathpart.substring(0, i);
- }
-
- public static boolean isPattern(String path) {
- return path != null && (path.length() == 0 || path.indexOf('*') >=
0);
- }
-
-}
Deleted:
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/helpers/SeamPagesProcessStructureHelper.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/helpers/SeamPagesProcessStructureHelper.java 2008-06-05
10:41:43 UTC (rev 8567)
+++
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/helpers/SeamPagesProcessStructureHelper.java 2008-06-05
10:42:32 UTC (rev 8568)
@@ -1,80 +0,0 @@
-package org.jboss.tools.seam.pages.xml.model.helpers;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.jboss.tools.common.model.XModelObject;
-import org.jboss.tools.jst.web.model.ReferenceObject;
-import org.jboss.tools.jst.web.model.helpers.WebProcessStructureHelper;
-import org.jboss.tools.seam.pages.xml.model.SeamPagesConstants;
-
-public class SeamPagesProcessStructureHelper extends WebProcessStructureHelper implements
SeamPagesConstants {
- public static SeamPagesProcessStructureHelper instance = new
SeamPagesProcessStructureHelper();
-
- public static SeamPagesProcessStructureHelper getInstance() {
- return instance;
- }
-
- public XModelObject getParentProcess(XModelObject element) {
- XModelObject p = element;
- while(p != null && p.getFileType() == XModelObject.NONE &&
- !ENT_PROCESS.equals(p.getModelEntity().getName())) p = p.getParent();
- return p;
- }
-
- public XModelObject[] getItems(XModelObject process) {
- return process.getChildren(ENT_PROCESS_ITEM);
- }
-
- public XModelObject[] getOutputs(XModelObject item) {
- return item.getChildren(ENT_PROCESS_ITEM_OUTPUT);
- }
-
- public String getPath(XModelObject element) {
- return element.getAttributeValue(ATTR_PATH);
- }
-
- public XModelObject getItemOutputTarget(XModelObject itemOutput) {
- return
itemOutput.getParent().getParent().getChildByPath(itemOutput.getAttributeValue(ATTR_TARGET));
- }
-
- public String getItemOutputPresentation(XModelObject itemOutput) {
-// boolean s = isShortcut(itemOutput);
- return itemOutput.getPresentationString();
- }
-
- public boolean isPattern(XModelObject item) {
- String path = item.getAttributeValue(ATTR_PATH);
- return (path != null) && (path.length() == 0 || path.indexOf('*') >=
0);
- }
-
- public boolean isUnconfirmedPage(XModelObject item) {
- String type = item.getAttributeValue(ATTR_TYPE);
- if(!TYPE_PAGE.equals(type)) return false;
- if(isPattern(item)) return false;
- return !"true".equals(item.getAttributeValue("confirmed"));
- }
-
- public XModelObject getReference(XModelObject diagramObject) {
- if(diagramObject instanceof ReferenceObject) {
- return ((ReferenceObject)diagramObject).getReference();
- }
- return null;
- }
-
- public String[][] getParams(XModelObject item) {
- XModelObject o = getReference(item);
- if(o == null) return new String[0][];
- XModelObject[] os = o.getChildren();
- List<String[]> list = new ArrayList<String[]>();
- for (int i = 0; i < os.length; i++) {
- if(os[i].getModelEntity().getName().startsWith(ENT_PARAM)) {
- String n = os[i].getAttributeValue(ATTR_NAME);
- String v = os[i].getAttributeValue(ATTR_VALUE);
- list.add(new String[]{n, v});
- }
- }
- return list.toArray(new String[0][]);
- }
-
-}
Modified:
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/helpers/SeamPagesUpdateHelper.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/helpers/SeamPagesUpdateHelper.java 2008-06-05
10:41:43 UTC (rev 8567)
+++
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/helpers/SeamPagesUpdateHelper.java 2008-06-05
10:42:32 UTC (rev 8568)
@@ -4,26 +4,26 @@
import org.jboss.tools.common.model.event.XModelTreeEvent;
import org.jboss.tools.jst.web.model.helpers.WebProcessUpdateHelper;
import org.jboss.tools.seam.pages.xml.model.SeamPagesConstants;
-import org.jboss.tools.seam.pages.xml.model.impl.SeamPagesProcessImpl;
+import org.jboss.tools.seam.pages.xml.model.impl.SeamPagesDiagramImpl;
public class SeamPagesUpdateHelper implements WebProcessUpdateHelper {
private XModelObject config;
- private SeamPagesProcessImpl process;
- private SeamPagesProcessHelper helper;
+ private SeamPagesDiagramImpl diagram;
+ private SeamPagesDiagramHelper helper;
- public SeamPagesUpdateHelper(SeamPagesProcessImpl process) {
- this.process = process;
- this.helper = process.getHelper();
- this.config = process.getParent();
- SeamPagesUpdateManager.getInstance(process.getModel()).register(config.getPath(),
this);
+ public SeamPagesUpdateHelper(SeamPagesDiagramImpl diagram) {
+ this.diagram = diagram;
+ this.helper = diagram.getHelper();
+ this.config = diagram.getParent();
+ SeamPagesUpdateManager.getInstance(diagram.getModel()).register(config.getPath(),
this);
}
public void unregister() {
- SeamPagesUpdateManager.getInstance(process.getModel()).unregister(config.getPath(),
this);
+ SeamPagesUpdateManager.getInstance(diagram.getModel()).unregister(config.getPath(),
this);
}
public boolean isActive() {
- return process.isActive();
+ return diagram.isActive();
}
public void nodeChanged(XModelTreeEvent event, String localPath) {
@@ -32,7 +32,7 @@
} else if(localPath.startsWith(SeamPagesConstants.FOLDER_PAGES)
|| localPath.startsWith(SeamPagesConstants.FOLDER_EXCEPTIONS)
) {
- helper.updateProcess();
+ helper.updateDiagram();
}
}
@@ -41,7 +41,7 @@
if(localPath.startsWith(SeamPagesConstants.FOLDER_PAGES)
|| localPath.startsWith(SeamPagesConstants.FOLDER_EXCEPTIONS)
) {
- helper.updateProcess();
+ helper.updateDiagram();
if(!helper.isUpdateLocked()) {
helper.autolayout();
}
Copied:
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/impl/SeamPagesDiagramImpl.java
(from rev 8447,
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/impl/SeamPagesProcessImpl.java)
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/impl/SeamPagesDiagramImpl.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/impl/SeamPagesDiagramImpl.java 2008-06-05
10:42:32 UTC (rev 8568)
@@ -0,0 +1,90 @@
+package org.jboss.tools.seam.pages.xml.model.impl;
+
+import org.jboss.tools.common.model.XModelObject;
+import org.jboss.tools.common.model.impl.OrderedObjectImpl;
+import org.jboss.tools.jst.web.model.ReferenceObject;
+import org.jboss.tools.jst.web.model.WebProcess;
+import org.jboss.tools.seam.pages.xml.model.SeamPagesConstants;
+import org.jboss.tools.seam.pages.xml.model.helpers.SeamPagesDiagramHelper;
+import org.jboss.tools.seam.pages.xml.model.helpers.SeamPagesUpdateHelper;
+
+public class SeamPagesDiagramImpl extends OrderedObjectImpl implements WebProcess,
ReferenceObject, SeamPagesConstants {
+ private static final long serialVersionUID = 1981573715076399163L;
+ protected XModelObject reference;
+ protected SeamPagesDiagramHelper phelper = new SeamPagesDiagramHelper(this);
+ protected SeamPagesUpdateHelper uhelper = null;
+ protected boolean isPrepared = false;
+
+ public XModelObject getReference() {
+ return reference;
+ }
+
+ public void setReference(XModelObject reference) {
+ this.reference = reference;
+ if(reference != null) {
+ String shape = get("SHAPE");
+ if(shape != null && shape.length() > 0) reference.set("_shape",
shape);
+ }
+ }
+
+ public boolean isPrepared() {
+ return isPrepared;
+ }
+
+ public void firePrepared() {
+ isPrepared = true;
+ fireStructureChanged(3, getPath());
+ }
+
+ public void autolayout() {
+ phelper.autolayout();
+ }
+
+ protected void loadChildren() {
+ if (isPrepared && reference == null && isActive()) {
+ restoreRefs();
+ registerListener();
+ updateDiagram();
+ }
+ }
+
+ protected void restoreRefs() {
+ phelper.restoreRefs();
+ }
+
+ protected void updateDiagram() {
+ phelper.updateDiagram();
+ }
+
+ protected void registerListener() {
+ if (uhelper == null) {
+ uhelper = new SeamPagesUpdateHelper(this);
+ }
+ }
+
+ protected void deactivate() {
+ if (uhelper != null) {
+ uhelper.unregister();
+ uhelper = null;
+ }
+ }
+
+ public SeamPagesDiagramHelper getHelper() {
+ return phelper;
+ }
+
+ protected void changeTimeStamp() {
+ boolean actualBody = false;
+ String abts = null;
+ XModelObject parent = (XModelObject)getParent();
+ if(parent != null) {
+ abts = parent.get("actualBodyTimeStamp");
+ actualBody = (abts != null && (abts.equals("0") ||
abts.equals("" + parent.getTimeStamp())));
+ }
+ super.changeTimeStamp();
+ if(actualBody && !abts.equals("0")) {
+ parent.set("actualBodyTimeStamp", "" + parent.getTimeStamp());
+ }
+ }
+
+}
Deleted:
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/impl/SeamPagesProcessImpl.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/impl/SeamPagesProcessImpl.java 2008-06-05
10:41:43 UTC (rev 8567)
+++
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/impl/SeamPagesProcessImpl.java 2008-06-05
10:42:32 UTC (rev 8568)
@@ -1,90 +0,0 @@
-package org.jboss.tools.seam.pages.xml.model.impl;
-
-import org.jboss.tools.common.model.XModelObject;
-import org.jboss.tools.common.model.impl.OrderedObjectImpl;
-import org.jboss.tools.jst.web.model.ReferenceObject;
-import org.jboss.tools.jst.web.model.WebProcess;
-import org.jboss.tools.seam.pages.xml.model.SeamPagesConstants;
-import org.jboss.tools.seam.pages.xml.model.helpers.SeamPagesProcessHelper;
-import org.jboss.tools.seam.pages.xml.model.helpers.SeamPagesUpdateHelper;
-
-public class SeamPagesProcessImpl extends OrderedObjectImpl implements WebProcess,
ReferenceObject, SeamPagesConstants {
- private static final long serialVersionUID = 1981573715076399163L;
- protected XModelObject reference;
- protected SeamPagesProcessHelper phelper = new SeamPagesProcessHelper(this);
- protected SeamPagesUpdateHelper uhelper = null;
- protected boolean isPrepared = false;
-
- public XModelObject getReference() {
- return reference;
- }
-
- public void setReference(XModelObject reference) {
- this.reference = reference;
- if(reference != null) {
- String shape = get("SHAPE");
- if(shape != null && shape.length() > 0) reference.set("_shape",
shape);
- }
- }
-
- public boolean isPrepared() {
- return isPrepared;
- }
-
- public void firePrepared() {
- isPrepared = true;
- fireStructureChanged(3, getPath());
- }
-
- public void autolayout() {
- phelper.autolayout();
- }
-
- protected void loadChildren() {
- if (isPrepared && reference == null && isActive()) {
- restoreRefs();
- registerListener();
- updateProcess();
- }
- }
-
- protected void restoreRefs() {
- phelper.restoreRefs();
- }
-
- protected void updateProcess() {
- phelper.updateProcess();
- }
-
- protected void registerListener() {
- if (uhelper == null) {
- uhelper = new SeamPagesUpdateHelper(this);
- }
- }
-
- protected void deactivate() {
- if (uhelper != null) {
- uhelper.unregister();
- uhelper = null;
- }
- }
-
- public SeamPagesProcessHelper getHelper() {
- return phelper;
- }
-
- protected void changeTimeStamp() {
- boolean actualBody = false;
- String abts = null;
- XModelObject parent = (XModelObject)getParent();
- if(parent != null) {
- abts = parent.get("actualBodyTimeStamp");
- actualBody = (abts != null && (abts.equals("0") ||
abts.equals("" + parent.getTimeStamp())));
- }
- super.changeTimeStamp();
- if(actualBody && !abts.equals("0")) {
- parent.set("actualBodyTimeStamp", "" + parent.getTimeStamp());
- }
- }
-
-}