Author: scabanovich
Date: 2008-09-22 07:33:22 -0400 (Mon, 22 Sep 2008)
New Revision: 10391
Added:
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/handlers/ModifyLinkHandler.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/helpers/SeamPagesDiagramHelper.java
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/helpers/autolayout/SeamPagesItems.java
Log:
JBIDE-2611 Autolayout for links that have identical source and target nodes.
Modified: trunk/seam/plugins/org.jboss.tools.seam.pages.xml/plugin.xml
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.pages.xml/plugin.xml 2008-09-22 11:32:33 UTC
(rev 10390)
+++ trunk/seam/plugins/org.jboss.tools.seam.pages.xml/plugin.xml 2008-09-22 11:33:22 UTC
(rev 10391)
@@ -87,6 +87,9 @@
<xclass
id="org.jboss.tools.seam.pages.xml.model.handlers.RenameViewSupport"
class="org.jboss.tools.seam.pages.xml.model.handlers.RenameViewSupport"/>
+ <xclass
id="org.jboss.tools.seam.pages.xml.model.handlers.ModifyLinkHandler"
+ class="org.jboss.tools.seam.pages.xml.model.handlers.ModifyLinkHandler"/>
+
<xclass
id="org.jboss.tools.seam.pages.xml.model.helpers.autolayout.SeamPagesItems"
class="org.jboss.tools.seam.pages.xml.model.helpers.autolayout.SeamPagesItems"/>
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-09-22
11:32:33 UTC (rev 10390)
+++
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/resources/meta/seam-pages.meta 2008-09-22
11:33:22 UTC (rev 10391)
@@ -3089,15 +3089,15 @@
ICON="action.empty" displayName="Select in Tree Views"
kind="action" name="Select"/>
<XActionItem kind="list" name="LinkActions">
<XActionItem HIDE="disabled"
- HandlerClassName="org.jboss.tools.jsf.model.handlers.ModifyLinkHandler"
+
HandlerClassName="org.jboss.tools.seam.pages.xml.model.handlers.ModifyLinkHandler"
ICON="action.empty" PROPERTIES="value=no;property=shortcut"
displayName="Show as Transition" kind="action"
name="AsTransition"/>
<XActionItem HIDE="disabled"
- HandlerClassName="org.jboss.tools.jsf.model.handlers.ModifyLinkHandler"
+
HandlerClassName="org.jboss.tools.seam.pages.xml.model.handlers.ModifyLinkHandler"
ICON="action.empty" PROPERTIES="value=yes;property=shortcut"
displayName="Show as Shortcut" kind="action"
name="AsSrortcut"/>
<XActionItem HIDE="always"
- HandlerClassName="org.jboss.tools.jsf.model.handlers.ModifyLinkHandler"
+
HandlerClassName="org.jboss.tools.seam.pages.xml.model.handlers.ModifyLinkHandler"
ICON="action.empty" PROPERTIES="value=yes;property=hidden"
displayName="Hide" kind="action" name="Hide"/>
</XActionItem>
@@ -3156,15 +3156,15 @@
ICON="action.empty" displayName="Auto Layout"
kind="action" name="Autolayout"/>
<XActionItem kind="list" name="LinkActions">
<XActionItem HIDE="disabled"
- HandlerClassName="org.jboss.tools.jsf.model.handlers.ModifyLinkHandler"
+
HandlerClassName="org.jboss.tools.seam.pages.xml.model.handlers.ModifyLinkHandler"
ICON="action.empty" PROPERTIES="value=no;property=shortcut"
displayName="Show as Transition" kind="action"
name="AsTransition"/>
<XActionItem HIDE="disabled"
- HandlerClassName="org.jboss.tools.jsf.model.handlers.ModifyLinkHandler"
+
HandlerClassName="org.jboss.tools.seam.pages.xml.model.handlers.ModifyLinkHandler"
ICON="action.empty" PROPERTIES="value=yes;property=shortcut"
displayName="Show as Shortcut" kind="action"
name="AsSrortcut"/>
<XActionItem HIDE="always"
- HandlerClassName="org.jboss.tools.jsf.model.handlers.ModifyLinkHandler"
+
HandlerClassName="org.jboss.tools.seam.pages.xml.model.handlers.ModifyLinkHandler"
ICON="action.empty" PROPERTIES="value=yes;property=hidden"
displayName="Hide" kind="action" name="Hide"/>
</XActionItem>
Added:
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/handlers/ModifyLinkHandler.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/handlers/ModifyLinkHandler.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/handlers/ModifyLinkHandler.java 2008-09-22
11:33:22 UTC (rev 10391)
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.seam.pages.xml.model.handlers;
+
+import java.util.*;
+import org.jboss.tools.common.model.*;
+import org.jboss.tools.common.meta.action.impl.*;
+import org.jboss.tools.seam.pages.xml.model.SeamPagesConstants;
+
+public class ModifyLinkHandler extends AbstractHandler implements SeamPagesConstants {
+
+ public ModifyLinkHandler() {}
+
+ public boolean isEnabled(XModelObject object) {
+ if(object == null || !object.isObjectEditable()) return false;
+ if(!ENT_DIAGRAM_ITEM_OUTPUT.equals(object.getModelEntity().getName())) return
false;
+ String pn = action.getProperty("property");
+ String pv = action.getProperty("value");
+ return !pv.equals(object.getAttributeValue(pn));
+ }
+
+ public void executeHandler(XModelObject object, Properties p) throws XModelException
{
+ if(!isEnabled(object)) return;
+ String pn = action.getProperty("property");
+ String pv = action.getProperty("value");
+ object.setAttributeValue(pn, pv);
+ }
+
+}
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-09-22
11:32:33 UTC (rev 10390)
+++
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/helpers/SeamPagesDiagramHelper.java 2008-09-22
11:33:22 UTC (rev 10391)
@@ -8,6 +8,7 @@
import java.util.Map;
import java.util.Set;
+import org.jboss.tools.common.model.XModelException;
import org.jboss.tools.common.model.XModelObject;
import org.jboss.tools.common.model.util.XModelObjectUtil;
import org.jboss.tools.jst.web.model.ReferenceObject;
@@ -203,7 +204,6 @@
}
updatePageItem(gs[i]);
if(hadReference && ts == gs[i].getTimeStamp()) {
- System.out.println("fire " + gs[i].getPath());
gs[i].fireReferenceChanged();
}
}
Modified:
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/helpers/autolayout/SeamPagesItems.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/helpers/autolayout/SeamPagesItems.java 2008-09-22
11:32:33 UTC (rev 10390)
+++
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/helpers/autolayout/SeamPagesItems.java 2008-09-22
11:33:22 UTC (rev 10391)
@@ -1,7 +1,15 @@
package org.jboss.tools.seam.pages.xml.model.helpers.autolayout;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.jboss.tools.common.model.XModelException;
+import org.jboss.tools.common.model.XModelObject;
import org.jboss.tools.jst.web.model.helpers.autolayout.Items;
import org.jboss.tools.jst.web.model.helpers.autolayout.LayuotConstants;
+import org.jboss.tools.jst.web.model.helpers.autolayout.TransitionArranger;
+import org.jboss.tools.seam.pages.xml.model.SeamPagesConstants;
+import org.jboss.tools.seam.pages.xml.model.helpers.SeamPagesDiagramStructureHelper;
public class SeamPagesItems extends Items {
@@ -13,6 +21,9 @@
return new SeamLayoutConstants();
}
+ protected TransitionArranger createTransitionArranger() {
+ return new SeamPagesTransitionArranger();
+ }
}
class SeamLayoutConstants extends LayuotConstants {
@@ -22,3 +33,31 @@
}
}
+
+class SeamPagesTransitionArranger extends TransitionArranger {
+ public void execute() {
+ super.execute();
+
+ for (int i = 0; i < items.length; i++) {
+ XModelObject[] links = items[i].getObject().getChildren();
+ if(links.length < 2) continue;
+ Set<String> paths = new HashSet<String>();
+ for (int j = 0; j < links.length; j++) {
+ String path = links[j].getAttributeValue(SeamPagesConstants.ATTR_PATH);
+ if(paths.contains(path)) {
+ if(!SeamPagesDiagramStructureHelper.getInstance().isShortcut(links[j])) {
+ try {
+ links[j].getModel().changeObjectAttribute(links[j], "shortcut",
"yes");
+ } catch (XModelException e) {
+ e.printStackTrace();
+ }
+ System.out.println("Set shortcut " + path);
+ }
+ } else {
+ paths.add(path);
+ }
+ }
+ }
+ }
+
+}