Author: bfitzpat
Date: 2012-01-26 18:38:47 -0500 (Thu, 26 Jan 2012)
New Revision: 38233
Modified:
workspace/bfitzpat/org.jboss.tools.esb.visualizer/plugin.xml
workspace/bfitzpat/org.jboss.tools.esb.visualizer/src/org/jboss/tools/esb/visualizer/Activator.java
workspace/bfitzpat/org.jboss.tools.esb.visualizer/src/org/jboss/tools/esb/visualizer/views/ESBVisualizerView.java
Log:
[JBIDE-10726] Some additional cleanup work
Modified: workspace/bfitzpat/org.jboss.tools.esb.visualizer/plugin.xml
===================================================================
--- workspace/bfitzpat/org.jboss.tools.esb.visualizer/plugin.xml 2012-01-26 23:30:15 UTC
(rev 38232)
+++ workspace/bfitzpat/org.jboss.tools.esb.visualizer/plugin.xml 2012-01-26 23:38:47 UTC
(rev 38233)
@@ -5,16 +5,29 @@
<extension
point="org.eclipse.ui.views">
<category
- name="ESB"
+ name="JBoss ESB"
id="org.jboss.tools.esb.visualizer">
</category>
<view
- name="ESB Configuration Visualizer"
- icon="icons/esb/esb_file.gif"
+ allowMultiple="false"
category="org.jboss.tools.esb.visualizer"
class="org.jboss.tools.esb.visualizer.views.ESBVisualizerView"
- id="org.jboss.tools.esb.visualizer.views.ESBVisualizerView">
+ icon="icons/esb/esb_file.gif"
+ id="org.jboss.tools.esb.visualizer.views.ESBVisualizerView"
+ name="JBoss ESB Configuration Visualizer">
</view>
</extension>
-
+ <extension
+ point="org.eclipse.ui.perspectiveExtensions">
+ <perspectiveExtension targetID =
+ "org.eclipse.ui.resourcePerspective">
+ <showInPart id =
"org.jboss.tools.esb.visualizer.views.ESBVisualizerView"/>
+ </perspectiveExtension>
+ <perspectiveExtension
+ targetID="org.eclipse.jst.j2ee.J2EEPerspective">
+ <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/Activator.java
===================================================================
---
workspace/bfitzpat/org.jboss.tools.esb.visualizer/src/org/jboss/tools/esb/visualizer/Activator.java 2012-01-26
23:30:15 UTC (rev 38232)
+++
workspace/bfitzpat/org.jboss.tools.esb.visualizer/src/org/jboss/tools/esb/visualizer/Activator.java 2012-01-26
23:38:47 UTC (rev 38233)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.esb.visualizer;
+import org.eclipse.core.runtime.Status;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
@@ -68,4 +69,12 @@
public static ImageDescriptor getImageDescriptor(String path) {
return imageDescriptorFromPlugin(PLUGIN_ID, path);
}
+
+ /**
+ * Log a message
+ * @param ex
+ */
+ public static void log(Throwable ex) {
+ plugin.getLog().log(new Status(Status.ERROR, PLUGIN_ID, Status.OK, "No
message", ex));
+ }
}
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-26
23:30:15 UTC (rev 38232)
+++
workspace/bfitzpat/org.jboss.tools.esb.visualizer/src/org/jboss/tools/esb/visualizer/views/ESBVisualizerView.java 2012-01-26
23:38:47 UTC (rev 38233)
@@ -37,6 +37,8 @@
import org.eclipse.ui.ISelectionListener;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.dialogs.ISelectionValidator;
+import org.eclipse.ui.part.IShowInTarget;
+import org.eclipse.ui.part.ShowInContext;
import org.eclipse.ui.part.ViewPart;
import org.eclipse.zest.core.viewers.AbstractZoomableViewer;
import org.eclipse.zest.core.viewers.GraphViewer;
@@ -64,12 +66,24 @@
* @author bfitzpat
*
*/
-public class ESBVisualizerView extends ViewPart implements IZoomableWorkbenchPart{
+public class ESBVisualizerView extends ViewPart implements IZoomableWorkbenchPart,
IShowInTarget {
/**
* The ID of the view as specified by the extension.
*/
- public static final String ID =
"org.jboss.tools.esb.visualizer.views.ESBVisualizerView";
+ public static final String ID =
"org.jboss.tools.esb.visualizer.views.ESBVisualizerView";//$NON-NLS-1$
+
+ private static final String ACTION_ICON_TAG =
"/icons/esb/action.gif";//$NON-NLS-1$
+ private static final String SERVICE_ICON_TAG =
"/icons/esb/service.gif";//$NON-NLS-1$
+ private static final String PROVIDER_ICON_TAG =
"/icons/esb/provider.gif";//$NON-NLS-1$
+ private static final String BUS_ICON_TAG = "/icons/esb/bus.gif";//$NON-NLS-1$
+ private static final String PROPERTY_ICON_TAG =
"/icons/esb/property.gif";//$NON-NLS-1$
+ private static final String LISTENER_ICON_TAG =
"/icons/esb/listener.gif";//$NON-NLS-1$
+ private static final String ESB_FILE_ICON_TAG =
"/icons/esb/esb_file.gif";//$NON-NLS-1$
+ private static final String REFRESH_ICON_TAG =
"/icons/refresh.gif";//$NON-NLS-1$
+ private static final String HORIZONTAL_TREE_LAYOUT_ICON_TAG =
"/icons/horizontalTreeLayout.gif";//$NON-NLS-1$
+ private static final String VERTICAL_TREE_LAYOUT_ICON_TAG =
"/icons/verticalTreeLayout.gif";//$NON-NLS-1$
+ private static final String RADIAL_LAYOUT_ICON_TAG =
"/icons/radialLayout.gif";//$NON-NLS-1$
private GraphViewer gv;
@@ -97,7 +111,10 @@
String path = selectedFile.getLocation().toOSString();
ESBDomParser parser = new ESBDomParser();
if (parser.isFileESBConfig(path)) {
- visualizeESB(path);
+ if (!gv.getGraphControl().isDisposed()) {
+ visualizeESB(path);
+ refreshLayoutAction.run();
+ }
}
}
}
@@ -123,7 +140,8 @@
makeActions();
hookContextMenu();
fillToolBar();
- visualizeESB(null);
+// visualizeESB(null);
+ setEmptyGraph();
horizontalLayoutAction.setChecked(true);
horizontalLayoutAction.run();
getSite().getWorkbenchWindow().getSelectionService().addSelectionListener(listener);
@@ -143,17 +161,28 @@
}
}
- /*
+ private void setEmptyGraph() {
+ clearGraph();
+ new GraphNode (gv.getGraphControl(), ZestStyles.NODES_CACHE_LABEL,
+ "Select an ESB Configuration file in the navigator\n" +
+ "or use the 'Open JBoss ESB Configuration' view menu\n" +
+ "to show a configuration graphically.");
+ refreshLayoutAction.run();
+ }
+
+ /**
* Import the esb XML file and render nodes and connections
* @param filepath
*/
- private void visualizeESB ( String filepath ) {
+ public void visualizeESB ( String filepath ) {
ESBDomParser parser = new ESBDomParser();
parser.parseXmlFile(filepath);
clearGraph();
TreeParent root = parser.getRoot();
root.setEsbObjectType(ESBType.ESB);
- GraphNode rootnode = new GraphNode(gv.getGraphControl(), ZestStyles.NODES_CACHE_LABEL,
root.getName());
+ GraphNode rootnode = new GraphNode(gv.getGraphControl(),
+ ZestStyles.NODES_CACHE_LABEL,
+ root.getName());
rootnode.setImage(getImageFromPlugin("/icons/esb/esb_file.gif"));
this.defaultBorder = rootnode.getBorderColor();
rootnode.setData(root);
@@ -197,25 +226,25 @@
if (tp.getEsbObjectType() != null) {
switch (tp.getEsbObjectType()) {
case ACTION:
- p.setImage(getImageFromPlugin("/icons/esb/action.gif"));
+ p.setImage(getImageFromPlugin(ACTION_ICON_TAG));
break;
case SERVICE:
- p.setImage(getImageFromPlugin("/icons/esb/service.gif"));
+ p.setImage(getImageFromPlugin(SERVICE_ICON_TAG));
break;
case PROVIDER:
- p.setImage(getImageFromPlugin("/icons/esb/provider.gif"));
+ p.setImage(getImageFromPlugin(PROVIDER_ICON_TAG));
break;
case BUS:
- p.setImage(getImageFromPlugin("/icons/esb/bus.gif"));
+ p.setImage(getImageFromPlugin(BUS_ICON_TAG));
break;
case PROPERTY:
- p.setImage(getImageFromPlugin("/icons/esb/property.gif"));
+ p.setImage(getImageFromPlugin(PROPERTY_ICON_TAG));
break;
case LISTENER:
- p.setImage(getImageFromPlugin("/icons/esb/listener.gif"));
+ p.setImage(getImageFromPlugin(LISTENER_ICON_TAG));
break;
case ESB:
- p.setImage(getImageFromPlugin("/icons/esb/esb_file.gif"));
+ p.setImage(getImageFromPlugin(ESB_FILE_ICON_TAG));
break;
default:
break;
@@ -287,7 +316,7 @@
* Fill the view menu
*/
private void hookContextMenu() {
- MenuManager menuMgr = new MenuManager("#PopupMenu");
+ MenuManager menuMgr = new MenuManager("#PopupMenu");//$NON-NLS-1$
menuMgr.setRemoveAllWhenShown(true);
menuMgr.addMenuListener(new IMenuListener() {
public void menuAboutToShow(IMenuManager manager) {
@@ -325,7 +354,7 @@
refreshLayoutAction.setText("Refresh Layout");
refreshLayoutAction.setToolTipText("Refresh Layout");
- refreshLayoutAction.setImageDescriptor(Activator.getImageDescriptor("/icons/refresh.gif"));
+ refreshLayoutAction.setImageDescriptor(Activator.getImageDescriptor(REFRESH_ICON_TAG));
openESBFileAction = new Action() {
public void run() {
@@ -334,9 +363,9 @@
ESBVisualizerView.this.getSite().getShell().getShell(),
null,
"Select ESB file:",
- ".xml");
+ ".xml");//$NON-NLS-1$
dialog.setTitle("Open ESB Configuration");
- dialog.setImage(getImageFromPlugin("/icons/esb/esb_file.gif"));
+ dialog.setImage(getImageFromPlugin(ESB_FILE_ICON_TAG));
dialog.setValidator(new ISelectionValidator() {
@Override
@@ -368,7 +397,7 @@
};
openESBFileAction.setText("Open ESB Configuration");
openESBFileAction.setToolTipText("Open ESB Configuration");
- openESBFileAction.setImageDescriptor(Activator.getImageDescriptor("/icons/esb/new_esb_file.gif"));
+ openESBFileAction.setImageDescriptor(Activator.getImageDescriptor(ESB_FILE_ICON_TAG));
}
@@ -386,12 +415,12 @@
toolbar.add(refreshLayoutAction);
horizontalLayoutAction = new LayoutAction(gv, new
HorizontalTreeLayoutAlgorithm(LayoutStyles.NO_LAYOUT_NODE_RESIZING));
- horizontalLayoutAction.setImageDescriptor(Activator.getImageDescriptor("/icons/horizontalTreeLayout.gif"));
+ horizontalLayoutAction.setImageDescriptor(Activator.getImageDescriptor(HORIZONTAL_TREE_LAYOUT_ICON_TAG));
horizontalLayoutAction.setToolTipText("Use Horizontal Tree Layout");
horizontalLayoutAction.addPropertyChangeListener(new IPropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent event) {
- if (event.getProperty().equalsIgnoreCase("checked")) {
+ if (event.getProperty().equalsIgnoreCase("checked")) {//$NON-NLS-1$
Boolean state = (Boolean)event.getNewValue();
if (state.equals(Boolean.TRUE)) {
verticalLayoutAction.setChecked(false);
@@ -407,12 +436,12 @@
toolbar.add(horizontalLayoutAction);
verticalLayoutAction = new LayoutAction(gv, new
TreeLayoutAlgorithm(LayoutStyles.NO_LAYOUT_NODE_RESIZING));
- verticalLayoutAction.setImageDescriptor(Activator.getImageDescriptor("/icons/verticalTreeLayout.gif"));
+ verticalLayoutAction.setImageDescriptor(Activator.getImageDescriptor(VERTICAL_TREE_LAYOUT_ICON_TAG));
verticalLayoutAction.setToolTipText("Use Vertical Tree Layout");
verticalLayoutAction.addPropertyChangeListener(new IPropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent event) {
- if (event.getProperty().equalsIgnoreCase("checked")) {
+ if (event.getProperty().equalsIgnoreCase("checked")) {//$NON-NLS-1$
Boolean state = (Boolean)event.getNewValue();
if (state.equals(Boolean.TRUE)) {
horizontalLayoutAction.setChecked(false);
@@ -428,12 +457,12 @@
toolbar.add(verticalLayoutAction);
radialLayoutAction = new LayoutAction(gv, new
RadialLayoutAlgorithm(LayoutStyles.NO_LAYOUT_NODE_RESIZING));
- radialLayoutAction.setImageDescriptor(Activator.getImageDescriptor("/icons/radialLayout.gif"));
+ radialLayoutAction.setImageDescriptor(Activator.getImageDescriptor(RADIAL_LAYOUT_ICON_TAG));
radialLayoutAction.setToolTipText("Use Radial Layout");
radialLayoutAction.addPropertyChangeListener(new IPropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent event) {
- if (event.getProperty().equalsIgnoreCase("checked")) {
+ if (event.getProperty().equalsIgnoreCase("checked")) {//$NON-NLS-1$
Boolean state = (Boolean)event.getNewValue();
if (state.equals(Boolean.TRUE)) {
horizontalLayoutAction.setChecked(false);
@@ -538,5 +567,25 @@
}
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.part.IShowInTarget#show(org.eclipse.ui.part.ShowInContext)
+ */
+ @Override
+ public boolean show(ShowInContext context) {
+ if (gv == null || context == null)
+ return false;
+ ISelection sel = context.getSelection();
+ if (sel instanceof IStructuredSelection) {
+ IStructuredSelection ss = (IStructuredSelection)sel;
+ Object first = ss.getFirstElement();
+ if (first instanceof IFile) {
+ String path = ((IFile)first).getLocation().toOSString();
+ visualizeESB(path);
+ return true;
+ }
+ }
+ return false;
+ }
+
}