Author: scabanovich
Date: 2008-08-27 09:01:16 -0400 (Wed, 27 Aug 2008)
New Revision: 9921
Added:
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/handlers/DeleteVirtualOutputHandler.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/SeamPagesConstants.java
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/handlers/CreateVirtualHandler.java
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/handlers/GoToNodeNandler.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/helpers/SeamPagesDiagramHelper.java
Log:
JBIDE-2612
Modified: trunk/seam/plugins/org.jboss.tools.seam.pages.xml/plugin.xml
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.pages.xml/plugin.xml 2008-08-27 12:54:44 UTC
(rev 9920)
+++ trunk/seam/plugins/org.jboss.tools.seam.pages.xml/plugin.xml 2008-08-27 13:01:16 UTC
(rev 9921)
@@ -69,6 +69,8 @@
class="org.jboss.tools.seam.pages.xml.model.handlers.PageAdopt"/>
<xclass
id="org.jboss.tools.seam.pages.xml.model.handlers.DeleteOutputHandler"
class="org.jboss.tools.seam.pages.xml.model.handlers.DeleteOutputHandler"/>
+ <xclass
id="org.jboss.tools.seam.pages.xml.model.handlers.DeleteVirtualOutputHandler"
+ class="org.jboss.tools.seam.pages.xml.model.handlers.DeleteVirtualOutputHandler"/>
<xclass
id="org.jboss.tools.seam.pages.xml.model.handlers.OpenPageHandler"
class="org.jboss.tools.seam.pages.xml.model.handlers.OpenPageHandler"/>
<xclass
id="org.jboss.tools.seam.pages.xml.model.handlers.SelectOnDiagramHandler"
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-08-27
12:54:44 UTC (rev 9920)
+++
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/resources/meta/seam-pages.meta 2008-08-27
13:01:16 UTC (rev 9921)
@@ -3170,6 +3170,11 @@
ICON="action.empty" PROPERTIES="value=yes;property=hidden"
displayName="Hide" kind="action" name="Hide"/>
</XActionItem>
+ <XActionItem ICON="action.delete" displayName="Delete"
kind="list" name="DeleteActions">
+ <XActionItem BaseActionName="Delete"
+
HandlerClassName="org.jboss.tools.seam.pages.xml.model.handlers.DeleteVirtualOutputHandler"
+ ICON="action.delete" displayName="Delete"
kind="action" name="Delete"/>
+ </XActionItem>
<XActionItem displayName="move" kind="list"
name="MoveActions">
<XActionItem HIDE="always"
HandlerClassName="org.jboss.tools.jsf.model.handlers.OutputMoveHandler"
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-08-27
12:54:44 UTC (rev 9920)
+++
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/SeamPagesConstants.java 2008-08-27
13:01:16 UTC (rev 9921)
@@ -47,7 +47,10 @@
public String ATTR_TYPE = "type"; //$NON-NLS-1$
public String ATTR_TARGET = "target"; //$NON-NLS-1$
public String ATTR_ID = "id"; //$NON-NLS-1$
+ public String ATTR_SUBTYPE = "subtype"; //$NON-NLS-1$
+ public String SUBTYPE_CUSTOM = "custom"; //$NON-NLS-1$
+
public String ATTR_VIEW_ID = "view id"; //$NON-NLS-1$
public String FOLDER_CONVERSATIONS = "Conversations"; //$NON-NLS-1$
Modified:
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/handlers/CreateVirtualHandler.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/handlers/CreateVirtualHandler.java 2008-08-27
12:54:44 UTC (rev 9920)
+++
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/handlers/CreateVirtualHandler.java 2008-08-27
13:01:16 UTC (rev 9921)
@@ -13,7 +13,14 @@
public CreateVirtualHandler() {}
public boolean isEnabled(XModelObject object) {
- return object != null && object.isActive();
+ if(object == null || !object.isActive()) {
+ return false;
+ }
+ String path = object.getAttributeValue(SeamPagesConstants.ATTR_PATH);
+ if(path == null || PageAdopt.isEL(path)) {
+ return false;
+ }
+ return true;
}
public void executeHandler(XModelObject object, Properties prop) throws XModelException
{
@@ -22,10 +29,14 @@
XModelObject pages = f.getChildByPath(SeamPagesConstants.FOLDER_PAGES);
if(pages == null) return;
String path = object.getAttributeValue(SeamPagesConstants.ATTR_PATH);
- //TODO handle EL case
- XModelObject page = AddViewSupport.addPage(pages, path);
- if(page != null) {
- page.setModified(true);
+ if(PageAdopt.isEL(path)) {
+ //TODO handle EL case
+
+ } else {
+ XModelObject page = AddViewSupport.addPage(pages, path);
+ if (page != null) {
+ page.setModified(true);
+ }
}
}
Added:
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/handlers/DeleteVirtualOutputHandler.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/handlers/DeleteVirtualOutputHandler.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/handlers/DeleteVirtualOutputHandler.java 2008-08-27
13:01:16 UTC (rev 9921)
@@ -0,0 +1,17 @@
+package org.jboss.tools.seam.pages.xml.model.handlers;
+
+import org.jboss.tools.common.meta.action.impl.handlers.DefaultRemoveHandler;
+import org.jboss.tools.common.model.XModelObject;
+import org.jboss.tools.seam.pages.xml.model.SeamPagesConstants;
+
+public class DeleteVirtualOutputHandler extends DefaultRemoveHandler {
+
+ public boolean isEnabled(XModelObject object) {
+ if(!super.isEnabled(object)) {
+ return false;
+ }
+ String subtype = object.getAttributeValue(SeamPagesConstants.ATTR_SUBTYPE);
+ return SeamPagesConstants.SUBTYPE_CUSTOM.equals(subtype);
+ }
+
+}
Modified:
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/handlers/GoToNodeNandler.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/handlers/GoToNodeNandler.java 2008-08-27
12:54:44 UTC (rev 9920)
+++
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/handlers/GoToNodeNandler.java 2008-08-27
13:01:16 UTC (rev 9921)
@@ -6,6 +6,7 @@
import org.jboss.tools.common.model.XModelObject;
import org.jboss.tools.jst.web.model.ReferenceObject;
import org.jboss.tools.jst.web.model.handlers.FindItemOnDiagramHandler;
+import org.jboss.tools.seam.pages.xml.model.SeamPagesConstants;
import org.jboss.tools.seam.pages.xml.model.helpers.SeamPagesDiagramStructureHelper;
public class GoToNodeNandler extends FindItemOnDiagramHandler {
@@ -24,13 +25,34 @@
super.fillProperties(object, p);
p.put("object", object.getParent());
- //TODO find all matching nodes taking into account EL.
+ //Find all matching nodes taking into account EL.
XModelObject[] outputs = object.getChildren();
ArrayList<XModelObject> targets = new ArrayList<XModelObject>();
for (int i = 0; i < outputs.length; i++) {
XModelObject o =
SeamPagesDiagramStructureHelper.getInstance().getItemOutputTarget(outputs[i]);
if(o != null) targets.add(o);
}
+
+ String path = object.getAttributeValue(SeamPagesConstants.ATTR_PATH);
+ if(PageAdopt.isEL(path)) {
+ XModelObject[] items = object.getParent().getChildren();
+ for (int i = 0; i < items.length; i++) {
+ if(targets.contains(items[i])) {
+ continue;
+ }
+ String path_i = items[i].getAttributeValue(SeamPagesConstants.ATTR_PATH);
+ if(path_i == null || PageAdopt.isEL(path_i)) {
+ continue;
+ }
+ String type = items[i].getAttributeValue(SeamPagesConstants.ATTR_TYPE);
+ if(SeamPagesConstants.TYPE_EXCEPTION.equals(type)) {
+ continue;
+ }
+ //TODO improve if EL is only part of path
+ targets.add(items[i]);
+ }
+ }
+
p.put("items", targets.toArray(new XModelObject[0]));
}
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-08-27
12:54:44 UTC (rev 9920)
+++
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/handlers/PageAdopt.java 2008-08-27
13:01:16 UTC (rev 9921)
@@ -16,6 +16,7 @@
import org.jboss.tools.common.meta.action.impl.handlers.DefaultRemoveHandler;
import org.jboss.tools.common.model.*;
import org.jboss.tools.common.model.util.FindObjectHelper;
+import org.jboss.tools.common.model.util.XModelObjectUtil;
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.SeamPagesDiagramStructureHelper;
@@ -33,7 +34,7 @@
return canBeOutputTarget(target);
}
if(ENT_DIAGRAM_ITEM.equals(entity)) {
- return canBeOutputTarget(target);
+ return canDrawCustomLink(target, object) || canBeOutputTarget(target);
}
if(entity.startsWith(ENT_SEAM_PAGE)) {
return canBeOutputTarget(target);
@@ -53,6 +54,48 @@
if(path.length() == 0 || path.indexOf("*") >= 0) return false;
return true;
}
+
+ private boolean canDrawCustomLink(XModelObject target, XModelObject source) {
+ if(!(source instanceof ReferenceObject)) {
+ return false;
+ }
+ ReferenceObject i = (ReferenceObject)source;
+ if(i.getReference() != null) {
+ //only virtual items can be sources of custom links.
+ return false;
+ }
+ String sourcePath = source.getAttributeValue(ATTR_PATH);
+ if(!isEL(sourcePath)) {
+ return false;
+ }
+
+ if(!(target instanceof ReferenceObject)) {
+ return false;
+ }
+ ReferenceObject j = (ReferenceObject)target;
+ if(j.getReference() == null) {
+ //only real items can be targets of custom links
+ return false;
+ }
+
+ String type = target.getAttributeValue(ATTR_TYPE);
+ if(TYPE_EXCEPTION.equals(type)) {
+ //Exception cannot be the target
+ return false;
+ }
+ String path = target.getAttributeValue(ATTR_PATH);
+ if(path == null) path = target.getAttributeValue(ATTR_VIEW_ID);
+ if(path == null) return false;
+
+ return true;
+ }
+
+ public static boolean isEL(String path) {
+ if(path.indexOf('{') < 0) {
+ return false;
+ }
+ return true;
+ }
private boolean canMoveCase(XModelObject target, XModelObject object) {
XModelObject case_ = null;
@@ -82,7 +125,11 @@
adoptOutput(object, target, p);
}
} else if(ENT_DIAGRAM_ITEM.equals(entity)) {
- adoptItem(object, target, p);
+ if(canDrawCustomLink(target, object)) {
+ drawCustomLink(target, object);
+ } else {
+ adoptItem(object, target, p);
+ }
} else if(entity.startsWith(ENT_SEAM_PAGE)) {
adoptSeamPage(object, target, p);
}
@@ -101,7 +148,12 @@
protected void adoptItem(XModelObject source, XModelObject target, Properties p) throws
XModelException {
ReferenceObject i = (ReferenceObject)source;
if(i.getReference() == null) {
- XModelObject rule = createRule(target, i.getAttributeValue(ATTR_PATH));
+ String path = i.getAttributeValue(ATTR_PATH);
+ if(isEL(path)) {
+ //do not create rule for EL.
+ return;
+ }
+ XModelObject rule = createRule(target, path);
adoptSeamPage(rule, target, p);
} else {
adoptSeamPage(i.getReference(), target, p);
@@ -168,4 +220,18 @@
DefaultCreateHandler.addCreatedObject(pages, rule, FindObjectHelper.IN_EDITOR_ONLY);
return rule;
}
+
+ void drawCustomLink(XModelObject target, XModelObject source) throws XModelException {
+ ReferenceObject j = (ReferenceObject)target;
+ String viewId = j.getReference().getAttributeValue(ATTR_VIEW_ID);
+ XModelObject output = target.getModel().createModelObject(ENT_DIAGRAM_ITEM_OUTPUT,
null);
+ output.setAttributeValue(ATTR_ID, viewId);
+ output.setAttributeValue(ATTR_PATH, viewId);
+ String name = XModelObjectUtil.createNewChildName("output", source);
+ output.setAttributeValue(ATTR_NAME, name);
+ output.setAttributeValue(ATTR_SUBTYPE, SUBTYPE_CUSTOM);
+ output.setAttributeValue(ATTR_TARGET, target.getPathPart());
+ DefaultCreateHandler.addCreatedObject(source, output,
FindObjectHelper.IN_EDITOR_ONLY);
+ }
+
}
Modified:
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/SeamPagesDiagramHelper.java 2008-08-27
12:54:44 UTC (rev 9920)
+++
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/helpers/SeamPagesDiagramHelper.java 2008-08-27
13:01:16 UTC (rev 9921)
@@ -191,6 +191,9 @@
gs[i].setReference(null);
XModelObject[] os = gs[i].getChildren(ENT_DIAGRAM_ITEM_OUTPUT);
for (int j = 0; j < os.length; j++) {
+ if(SUBTYPE_CUSTOM.equals(os[j].getAttributeValue(ATTR_SUBTYPE))) {
+ continue;
+ }
gs[i].removeChild(os[j]);
}
updatePageItem(gs[i]);