Author: bfitzpat
Date: 2012-01-27 10:52:45 -0500 (Fri, 27 Jan 2012)
New Revision: 38244
Added:
workspace/bfitzpat/org.jboss.tools.esb.visualizer/src/org/jboss/tools/esb/visualizer/views/ESBNode.java
workspace/bfitzpat/org.jboss.tools.esb.visualizer/src/org/jboss/tools/esb/visualizer/views/ESBNodeWithChildren.java
Removed:
workspace/bfitzpat/org.jboss.tools.esb.visualizer/src/org/jboss/tools/esb/visualizer/views/TreeObject.java
workspace/bfitzpat/org.jboss.tools.esb.visualizer/src/org/jboss/tools/esb/visualizer/views/TreeParent.java
Modified:
workspace/bfitzpat/org.jboss.tools.esb.visualizer/plugin.xml
workspace/bfitzpat/org.jboss.tools.esb.visualizer/src/org/jboss/tools/esb/visualizer/views/ESBDomParser.java
workspace/bfitzpat/org.jboss.tools.esb.visualizer/src/org/jboss/tools/esb/visualizer/views/ESBVisualizerView.java
Log:
[JBIDE-10726] A bit of refactoring, adding Show In support to JBoss perspective
Modified: workspace/bfitzpat/org.jboss.tools.esb.visualizer/plugin.xml
===================================================================
--- workspace/bfitzpat/org.jboss.tools.esb.visualizer/plugin.xml 2012-01-27 11:34:16 UTC
(rev 38243)
+++ workspace/bfitzpat/org.jboss.tools.esb.visualizer/plugin.xml 2012-01-27 15:52:45 UTC
(rev 38244)
@@ -29,5 +29,11 @@
id="org.jboss.tools.esb.visualizer.views.ESBVisualizerView">
</showInPart>
</perspectiveExtension>
+ <perspectiveExtension
+ targetID="org.jboss.tools.common.ui.JBossPerspective">
+ <showInPart
+ id="org.jboss.tools.esb.visualizer.views.ESBVisualizerView">
+ </showInPart>
+ </perspectiveExtension>
</extension>
</plugin>
Modified:
workspace/bfitzpat/org.jboss.tools.esb.visualizer/src/org/jboss/tools/esb/visualizer/views/ESBDomParser.java
===================================================================
---
workspace/bfitzpat/org.jboss.tools.esb.visualizer/src/org/jboss/tools/esb/visualizer/views/ESBDomParser.java 2012-01-27
11:34:16 UTC (rev 38243)
+++
workspace/bfitzpat/org.jboss.tools.esb.visualizer/src/org/jboss/tools/esb/visualizer/views/ESBDomParser.java 2012-01-27
15:52:45 UTC (rev 38244)
@@ -24,7 +24,7 @@
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.jboss.tools.esb.visualizer.Activator;
-import org.jboss.tools.esb.visualizer.views.TreeObject.ESBType;
+import org.jboss.tools.esb.visualizer.views.ESBNode.ESBType;
import org.osgi.framework.Bundle;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -34,7 +34,7 @@
public class ESBDomParser {
Document dom;
- TreeParent root;
+ ESBNodeWithChildren root;
public boolean isFileESBConfig ( String filepath ) {
//get the factory
@@ -66,7 +66,7 @@
public void parseXmlFile(String filepath){
- root = new TreeParent("Invisible Root");
+ root = new ESBNodeWithChildren("Invisible Root");
//get the factory
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
@@ -120,8 +120,8 @@
}
}
if(providersElement != null) {
- TreeParent providersRoot = new TreeParent("Providers");
- providersRoot.setEsbObjectType(TreeObject.ESBType.PROVIDER);
+ ESBNodeWithChildren providersRoot = new ESBNodeWithChildren("Providers");
+ providersRoot.setEsbObjectType(ESBNode.ESBType.PROVIDER);
processChildren(providersRoot, providersElement);
root.addChild(providersRoot);
}
@@ -138,15 +138,15 @@
}
}
if(servicesElement != null) {
- TreeParent servicesRoot = new TreeParent("Services");
- servicesRoot.setEsbObjectType(TreeObject.ESBType.SERVICE);
+ ESBNodeWithChildren servicesRoot = new ESBNodeWithChildren("Services");
+ servicesRoot.setEsbObjectType(ESBNode.ESBType.SERVICE);
processChildren(servicesRoot, servicesElement);
root.addChild(servicesRoot);
}
}
}
- private void processChildren ( TreeParent parent, Element el ) {
+ private void processChildren ( ESBNodeWithChildren parent, Element el ) {
el.normalize();
parent.setData(el);
@@ -186,7 +186,7 @@
name = child.getTagName();
}
- TreeParent childNode = new TreeParent(name);
+ ESBNodeWithChildren childNode = new ESBNodeWithChildren(name);
String ref = child.getAttribute("busidref");
if (ref != null && ref.trim().length() > 0) {
childNode.setRef(ref);
@@ -200,7 +200,7 @@
}
}
- public TreeParent getRoot() {
+ public ESBNodeWithChildren getRoot() {
return this.root;
}
Copied:
workspace/bfitzpat/org.jboss.tools.esb.visualizer/src/org/jboss/tools/esb/visualizer/views/ESBNode.java
(from rev 38219,
workspace/bfitzpat/org.jboss.tools.esb.visualizer/src/org/jboss/tools/esb/visualizer/views/TreeObject.java)
===================================================================
---
workspace/bfitzpat/org.jboss.tools.esb.visualizer/src/org/jboss/tools/esb/visualizer/views/ESBNode.java
(rev 0)
+++
workspace/bfitzpat/org.jboss.tools.esb.visualizer/src/org/jboss/tools/esb/visualizer/views/ESBNode.java 2012-01-27
15:52:45 UTC (rev 38244)
@@ -0,0 +1,74 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.esb.visualizer.views;
+
+import org.eclipse.core.runtime.IAdaptable;
+
+public class ESBNode implements IAdaptable {
+ private String name;
+ private ESBNodeWithChildren parent;
+ private String ref;
+ private boolean wasMovedFlag = false;
+ private ESBType esbObjectType;
+ private Object data;
+
+ public enum ESBType {
+ ACTION, BUS, LISTENER, PROVIDER,
+ ESB, PROPERTY, SERVICE
+ }
+
+ public ESBNode(String name) {
+ this.name = name;
+ }
+ public String getName() {
+ return name;
+ }
+ public void setName(String newName) {
+ this.name = newName;
+ }
+ public void setParent(ESBNodeWithChildren parent) {
+ this.parent = parent;
+ }
+ public ESBNodeWithChildren getParent() {
+ return parent;
+ }
+ public String toString() {
+ return getName();
+ }
+ @SuppressWarnings("rawtypes")
+ public Object getAdapter(Class key) {
+ return null;
+ }
+ public String getRef() {
+ return ref;
+ }
+ public void setRef(String ref) {
+ this.ref = ref;
+ }
+ protected boolean wasMoved() {
+ return wasMovedFlag;
+ }
+ protected void setWasMoved(boolean wasMoved) {
+ this.wasMovedFlag = wasMoved;
+ }
+ protected ESBType getEsbObjectType() {
+ return esbObjectType;
+ }
+ protected void setEsbObjectType(ESBType esbObjectType) {
+ this.esbObjectType = esbObjectType;
+ }
+ protected Object getData() {
+ return data;
+ }
+ protected void setData(Object data) {
+ this.data = data;
+ }
+}
\ No newline at end of file
Property changes on:
workspace/bfitzpat/org.jboss.tools.esb.visualizer/src/org/jboss/tools/esb/visualizer/views/ESBNode.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Copied:
workspace/bfitzpat/org.jboss.tools.esb.visualizer/src/org/jboss/tools/esb/visualizer/views/ESBNodeWithChildren.java
(from rev 38219,
workspace/bfitzpat/org.jboss.tools.esb.visualizer/src/org/jboss/tools/esb/visualizer/views/TreeParent.java)
===================================================================
---
workspace/bfitzpat/org.jboss.tools.esb.visualizer/src/org/jboss/tools/esb/visualizer/views/ESBNodeWithChildren.java
(rev 0)
+++
workspace/bfitzpat/org.jboss.tools.esb.visualizer/src/org/jboss/tools/esb/visualizer/views/ESBNodeWithChildren.java 2012-01-27
15:52:45 UTC (rev 38244)
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.esb.visualizer.views;
+
+import java.util.ArrayList;
+
+public class ESBNodeWithChildren extends ESBNode {
+
+ private ArrayList<ESBNode> children;
+ public ESBNodeWithChildren(String name) {
+ super(name);
+ children = new ArrayList<ESBNode>();
+ }
+ public void addChild(ESBNode child) {
+ children.add(child);
+ child.setParent(this);
+ }
+ public void removeChild(ESBNode child) {
+ children.remove(child);
+ child.setParent(null);
+ }
+ public ESBNode [] getChildren() {
+ return (ESBNode [])children.toArray(new ESBNode[children.size()]);
+ }
+ public boolean hasChildren() {
+ return children.size()>0;
+ }
+}
Property changes on:
workspace/bfitzpat/org.jboss.tools.esb.visualizer/src/org/jboss/tools/esb/visualizer/views/ESBNodeWithChildren.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified:
workspace/bfitzpat/org.jboss.tools.esb.visualizer/src/org/jboss/tools/esb/visualizer/views/ESBVisualizerView.java
===================================================================
---
workspace/bfitzpat/org.jboss.tools.esb.visualizer/src/org/jboss/tools/esb/visualizer/views/ESBVisualizerView.java 2012-01-27
11:34:16 UTC (rev 38243)
+++
workspace/bfitzpat/org.jboss.tools.esb.visualizer/src/org/jboss/tools/esb/visualizer/views/ESBVisualizerView.java 2012-01-27
15:52:45 UTC (rev 38244)
@@ -57,7 +57,7 @@
import org.eclipse.zest.layouts.constraints.BasicEntityConstraint;
import org.eclipse.zest.layouts.constraints.LayoutConstraint;
import org.jboss.tools.esb.visualizer.Activator;
-import org.jboss.tools.esb.visualizer.views.TreeObject.ESBType;
+import org.jboss.tools.esb.visualizer.views.ESBNode.ESBType;
/**
* This class serves as a simple read-only way to visualize an ESB configuration
@@ -178,7 +178,7 @@
ESBDomParser parser = new ESBDomParser();
parser.parseXmlFile(filepath);
clearGraph();
- TreeParent root = parser.getRoot();
+ ESBNodeWithChildren root = parser.getRoot();
root.setEsbObjectType(ESBType.ESB);
GraphNode rootnode = new GraphNode(gv.getGraphControl(),
ZestStyles.NODES_CACHE_LABEL,
@@ -218,10 +218,10 @@
* @param root
* @param parent
*/
- private void drawNodes ( GraphNode root, TreeParent parent ) {
+ private void drawNodes ( GraphNode root, ESBNodeWithChildren parent ) {
if (parent.hasChildren()) {
for (int i = 0; i < parent.getChildren().length; i++) {
- TreeParent tp = (TreeParent) parent.getChildren()[i];
+ ESBNodeWithChildren tp = (ESBNodeWithChildren) parent.getChildren()[i];
GraphNode p = new GraphNode(gv.getGraphControl(), SWT.NONE, tp.getName());
if (tp.getEsbObjectType() != null) {
switch (tp.getEsbObjectType()) {
@@ -267,8 +267,8 @@
Iterator<GraphNode> nodeIter =
gv.getGraphControl().getGraphModel().getNodes().iterator();
while (nodeIter.hasNext()) {
GraphNode node = nodeIter.next();
- if (node.getData() != null && node.getData() instanceof TreeParent) {
- TreeParent tp = (TreeParent) node.getData();
+ if (node.getData() != null && node.getData() instanceof ESBNodeWithChildren)
{
+ ESBNodeWithChildren tp = (ESBNodeWithChildren) node.getData();
if (tp.getRef() != null && tp.getRef().trim().length() > 0) {
GraphNode refNode = findNode(tp.getRef(), root);
if (refNode != null) {
@@ -499,8 +499,8 @@
GraphNode graphnode = (GraphNode) object;
Object data = graphnode.getData();
- if (data != null && data instanceof TreeObject) {
- boolean wasMoved = ((TreeObject)data).wasMoved();
+ if (data != null && data instanceof ESBNode) {
+ boolean wasMoved = ((ESBNode)data).wasMoved();
basicEntityConstraint.hasPreferredLocation = wasMoved;
}
}
@@ -519,8 +519,8 @@
Graph graph = ((GraphViewer) e.getSource()).getGraphControl();
if (!graph.getSelection().isEmpty()) {
GraphNode node = (GraphNode) graph.getSelection().get(0);
- if (node.getData() != null && node.getData() instanceof TreeObject) {
- TreeObject to = (TreeObject)node.getData();
+ if (node.getData() != null && node.getData() instanceof ESBNode) {
+ ESBNode to = (ESBNode)node.getData();
to.setWasMoved(!to.wasMoved());
if (to.wasMoved()) {
node.setBorderWidth(3);
@@ -580,8 +580,13 @@
Object first = ss.getFirstElement();
if (first instanceof IFile) {
String path = ((IFile)first).getLocation().toOSString();
- visualizeESB(path);
- return true;
+ ESBDomParser parser = new ESBDomParser();
+ if (parser.isFileESBConfig(path)) {
+ visualizeESB(path);
+ return true;
+ } else {
+ return false;
+ }
}
}
return false;
Deleted:
workspace/bfitzpat/org.jboss.tools.esb.visualizer/src/org/jboss/tools/esb/visualizer/views/TreeObject.java
===================================================================
---
workspace/bfitzpat/org.jboss.tools.esb.visualizer/src/org/jboss/tools/esb/visualizer/views/TreeObject.java 2012-01-27
11:34:16 UTC (rev 38243)
+++
workspace/bfitzpat/org.jboss.tools.esb.visualizer/src/org/jboss/tools/esb/visualizer/views/TreeObject.java 2012-01-27
15:52:45 UTC (rev 38244)
@@ -1,74 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 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:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.esb.visualizer.views;
-
-import org.eclipse.core.runtime.IAdaptable;
-
-public class TreeObject implements IAdaptable {
- private String name;
- private TreeParent parent;
- private String ref;
- private boolean wasMovedFlag = false;
- private ESBType esbObjectType;
- private Object data;
-
- public enum ESBType {
- ACTION, BUS, LISTENER, PROVIDER,
- ESB, PROPERTY, SERVICE
- }
-
- public TreeObject(String name) {
- this.name = name;
- }
- public String getName() {
- return name;
- }
- public void setName(String newName) {
- this.name = newName;
- }
- public void setParent(TreeParent parent) {
- this.parent = parent;
- }
- public TreeParent getParent() {
- return parent;
- }
- public String toString() {
- return getName();
- }
- @SuppressWarnings("rawtypes")
- public Object getAdapter(Class key) {
- return null;
- }
- public String getRef() {
- return ref;
- }
- public void setRef(String ref) {
- this.ref = ref;
- }
- protected boolean wasMoved() {
- return wasMovedFlag;
- }
- protected void setWasMoved(boolean wasMoved) {
- this.wasMovedFlag = wasMoved;
- }
- protected ESBType getEsbObjectType() {
- return esbObjectType;
- }
- protected void setEsbObjectType(ESBType esbObjectType) {
- this.esbObjectType = esbObjectType;
- }
- protected Object getData() {
- return data;
- }
- protected void setData(Object data) {
- this.data = data;
- }
-}
\ No newline at end of file
Deleted:
workspace/bfitzpat/org.jboss.tools.esb.visualizer/src/org/jboss/tools/esb/visualizer/views/TreeParent.java
===================================================================
---
workspace/bfitzpat/org.jboss.tools.esb.visualizer/src/org/jboss/tools/esb/visualizer/views/TreeParent.java 2012-01-27
11:34:16 UTC (rev 38243)
+++
workspace/bfitzpat/org.jboss.tools.esb.visualizer/src/org/jboss/tools/esb/visualizer/views/TreeParent.java 2012-01-27
15:52:45 UTC (rev 38244)
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 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:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.esb.visualizer.views;
-
-import java.util.ArrayList;
-
-public class TreeParent extends TreeObject {
-
- private ArrayList<TreeObject> children;
- public TreeParent(String name) {
- super(name);
- children = new ArrayList<TreeObject>();
- }
- public void addChild(TreeObject child) {
- children.add(child);
- child.setParent(this);
- }
- public void removeChild(TreeObject child) {
- children.remove(child);
- child.setParent(null);
- }
- public TreeObject [] getChildren() {
- return (TreeObject [])children.toArray(new TreeObject[children.size()]);
- }
- public boolean hasChildren() {
- return children.size()>0;
- }
-}