Author: bfitzpat
Date: 2012-02-03 14:41:38 -0500 (Fri, 03 Feb 2012)
New Revision: 38422
Modified:
trunk/esb/plugins/org.jboss.tools.esb.project.ui/META-INF/MANIFEST.MF
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/messages/JBossESBUI.properties
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/messages/JBossESBUIMessages.java
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/visualizer/ESBDomParser.java
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/visualizer/ESBVisualizerView.java
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/visualizer/WorkbenchFileSelectionDialog.java
Log:
[JBIDE-10783] Adding ability to double-click on a node to open in the ESB editor
Modified: trunk/esb/plugins/org.jboss.tools.esb.project.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.project.ui/META-INF/MANIFEST.MF 2012-02-03
18:44:27 UTC (rev 38421)
+++ trunk/esb/plugins/org.jboss.tools.esb.project.ui/META-INF/MANIFEST.MF 2012-02-03
19:41:38 UTC (rev 38422)
@@ -38,7 +38,8 @@
org.jboss.ide.eclipse.as.core;bundle-version="1.0.0",
org.jboss.tools.common.ui;bundle-version="3.1.0",
org.eclipse.zest.core,
- org.eclipse.zest.layouts
+ org.eclipse.zest.layouts,
+ org.jboss.tools.common.model
Bundle-ActivationPolicy: lazy
Bundle-Vendor: %Bundle-Vendor.0
Eclipse-RegisterBuddy: org.eclipse.jst.ws.annotations.core
Modified:
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/messages/JBossESBUI.properties
===================================================================
---
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/messages/JBossESBUI.properties 2012-02-03
18:44:27 UTC (rev 38421)
+++
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/messages/JBossESBUI.properties 2012-02-03
19:41:38 UTC (rev 38422)
@@ -51,6 +51,8 @@
JBossRuntimeListFieldEditor_ErrorMessageAtLeastOneJar=The library must contain at least
one jar.
+ESBDomParser_Actions_Node_Label=Actions
+ESBDomParser_Listeners_Node_Label=Listeners
ESBDomParser_Providers_Label=Providers
ESBDomParser_Services_Label=Services
ESBFacetInstallationPage_Button_Text_New=New
@@ -82,12 +84,15 @@
ESBExportWizard_Description=Export an ESB project to the local file system.
ESBExportWizard_ESBProject=ESB Project\:
ESBVisualizerView_Change_Layout_Action_Label=Change Layout
+ESBVisualizerView_DoubleClick_Toggle_Action_label=Freeze Node on Double-click
ESBVisualizerView_EmptyNodeLabel=Select an ESB Configuration file in the navigator\n or
use the 'Open JBoss ESB Configuration' view menu\n to show a configuration
graphically.
ESBVisualizerView_Open_ESB_Config_Action_Label=Open ESB Configuration
ESBVisualizerView_Open_ESB_Config_Dialog_Field_Text=Select ESB file:
ESBVisualizerView_Open_ESB_Config_Dialog_Title=Open ESB Configuration
+ESBVisualizerView_Open_ESB_Editor_Action_Label=Open ESB Editor
ESBVisualizerView_Refresh_Layout_Action_Label=Refresh Layout
ESBVisualizerView_Select_ESB_File_Warning=Please select an ESB configuration file.
ESBVisualizerView_Use_Horizontal_Tree_Layout_Action_Label=Use Horizontal Tree Layout
ESBVisualizerView_Use_Radial_Layout_Action_Label=Use Radial Layout
ESBVisualizerView_Use_Vertical_Tree_Layout_Action_Label=Use Vertical Tree Layout
+WorkbenchFileSelectionDialog_Title=Select a File
Modified:
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/messages/JBossESBUIMessages.java
===================================================================
---
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/messages/JBossESBUIMessages.java 2012-02-03
18:44:27 UTC (rev 38421)
+++
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/messages/JBossESBUIMessages.java 2012-02-03
19:41:38 UTC (rev 38422)
@@ -55,6 +55,10 @@
public static String JBoss_ESBRuntime_Classpath_Container_5;
public static String JBoss_Runtime_List_Field_Editor_Configuration;
+ public static String ESBDomParser_Actions_Node_Label;
+
+ public static String ESBDomParser_Listeners_Node_Label;
+
public static String ESBDomParser_Providers_Label;
public static String ESBDomParser_Services_Label;
@@ -143,6 +147,8 @@
public static String ESBVisualizerView_Change_Layout_Action_Label;
+ public static String ESBVisualizerView_DoubleClick_Toggle_Action_label;
+
public static String ESBVisualizerView_EmptyNodeLabel;
public static String ESBVisualizerView_Open_ESB_Config_Action_Label;
@@ -151,6 +157,8 @@
public static String ESBVisualizerView_Open_ESB_Config_Dialog_Title;
+ public static String ESBVisualizerView_Open_ESB_Editor_Action_Label;
+
public static String ESBVisualizerView_Refresh_Layout_Action_Label;
public static String ESBVisualizerView_Select_ESB_File_Warning;
@@ -161,7 +169,9 @@
public static String ESBVisualizerView_Use_Vertical_Tree_Layout_Action_Label;
+ public static String WorkbenchFileSelectionDialog_Title;
+
static {
NLS.initializeMessages(BUNDLE_NAME, JBossESBUIMessages.class);
}
Modified:
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/visualizer/ESBDomParser.java
===================================================================
---
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/visualizer/ESBDomParser.java 2012-02-03
18:44:27 UTC (rev 38421)
+++
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/visualizer/ESBDomParser.java 2012-02-03
19:41:38 UTC (rev 38422)
@@ -65,11 +65,11 @@
return true;
}
}catch(ParserConfigurationException pce) {
- pce.printStackTrace();
+ // ignore
}catch(SAXException se) {
- se.printStackTrace();
+ // ignore
}catch(IOException ioe) {
- ioe.printStackTrace();
+ // ignore
}
return false;
@@ -109,8 +109,12 @@
//parse using builder to get DOM representation of the XML file
dom = db.parse(filepath);
dom.getDocumentElement().normalize();
- root.setName(dom.getDocumentElement().getTagName());
+ java.io.File tempFile = new java.io.File(filepath);
+ String filename = tempFile.getName();
+ root.setName(filename);
root.setEsbObjectType(ESBType.ESB);
+ File setupFile = new File(filepath);
+ root.setData(setupFile);
parseDocument();
@@ -188,7 +192,7 @@
parent.setEsbObjectType(ESBType.SERVICE);
} else if (tag.equalsIgnoreCase("listeners")) { //$NON-NLS-1$
parent.setEsbObjectType(ESBType.LISTENER);
- } else if (tag.equalsIgnoreCase("actions")) { //$NON-NLS-1$
+ } else if (tag.equalsIgnoreCase("Actions")) { //$NON-NLS-1$
parent.setEsbObjectType(ESBType.ACTION);
} else if (tag.equalsIgnoreCase("action")) { //$NON-NLS-1$
parent.setEsbObjectType(ESBType.ACTION);
@@ -211,6 +215,11 @@
if (name == null || name.trim().length() == 0) {
name = child.getTagName();
}
+ if (name.equalsIgnoreCase("actions")) { //$NON-NLS-1$
+ name = JBossESBUIMessages.ESBDomParser_Actions_Node_Label;
+ } else if (name.equalsIgnoreCase("listeners")) { //$NON-NLS-1$
+ name = JBossESBUIMessages.ESBDomParser_Listeners_Node_Label;
+ }
ESBNodeWithChildren childNode = new ESBNodeWithChildren(name);
String ref = child.getAttribute("busidref"); //$NON-NLS-1$
Modified:
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/visualizer/ESBVisualizerView.java
===================================================================
---
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/visualizer/ESBVisualizerView.java 2012-02-03
18:44:27 UTC (rev 38421)
+++
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/visualizer/ESBVisualizerView.java 2012-02-03
19:41:38 UTC (rev 38422)
@@ -35,8 +35,11 @@
import org.eclipse.swt.widgets.Menu;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.ISelectionListener;
+import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.PartInitException;
import org.eclipse.ui.dialogs.ISelectionValidator;
+import org.eclipse.ui.ide.IDE;
import org.eclipse.ui.part.IShowInTarget;
import org.eclipse.ui.part.ShowInContext;
import org.eclipse.ui.part.ViewPart;
@@ -56,6 +59,9 @@
import org.eclipse.zest.layouts.algorithms.TreeLayoutAlgorithm;
import org.eclipse.zest.layouts.constraints.BasicEntityConstraint;
import org.eclipse.zest.layouts.constraints.LayoutConstraint;
+import org.jboss.tools.common.model.XModelObject;
+import org.jboss.tools.common.model.util.EclipseResourceUtil;
+import org.jboss.tools.common.model.util.FindObjectHelper;
import org.jboss.tools.esb.project.ui.ESBProjectPlugin;
import org.jboss.tools.esb.project.ui.messages.JBossESBUIMessages;
import org.jboss.tools.esb.project.ui.visualizer.ESBNode.ESBType;
@@ -88,12 +94,18 @@
private GraphViewer gv;
+ private IFile currentFile;
+
// Some stashed colors
private Color defaultBorder;
// menu items
private Action openESBFileAction;
+ private Action openESBFileInEditorAction;
+ private Action doubleClickAction;
+ private boolean doubleClickFreezesNode = false;
+
// toolbar buttons for different layouts
private IAction horizontalLayoutAction;
private IAction verticalLayoutAction;
@@ -112,6 +124,7 @@
String path = selectedFile.getLocation().toOSString();
ESBDomParser parser = new ESBDomParser();
if (parser.isFileESBConfig(path)) {
+ currentFile = selectedFile;
if (!gv.getGraphControl().isDisposed()) {
visualizeESB(path);
refreshLayoutAction.run();
@@ -169,7 +182,6 @@
clearGraph();
new GraphNode (gv.getGraphControl(), ZestStyles.NODES_CACHE_LABEL,
JBossESBUIMessages.ESBVisualizerView_EmptyNodeLabel);
-// refreshLayoutAction.run();
}
/**
@@ -337,7 +349,7 @@
* @param manager
*/
private void fillContextMenu(IMenuManager manager) {
- manager.add(openESBFileAction);
+ manager.add(doubleClickAction);
}
/*
@@ -345,6 +357,10 @@
*/
private void makeActions() {
+ openESBFileInEditorAction = new OpenESBEditorAction();
+
+ doubleClickAction = new DoubleClickToggleAction();
+
refreshLayoutAction = new Action() {
@Override
public void run() {
@@ -391,6 +407,10 @@
if (rtn_code == WorkbenchFileSelectionDialog.OK) {
IPath resultPath = dialog.getFullPath();
IPath totalPath =
ResourcesPlugin.getWorkspace().getRoot().getLocation().append(resultPath);
+ IFile[] files =
ResourcesPlugin.getWorkspace().getRoot().findFilesForLocationURI(dialog.getFullPath().toFile().toURI());
+ if (files != null && files.length > 0) {
+ currentFile = files[0];
+ }
String path = totalPath.toOSString();
visualizeESB(path);
}
@@ -410,6 +430,8 @@
this);
IActionBars bars = getViewSite().getActionBars();
bars.getMenuManager().add(openESBFileAction);
+ bars.getMenuManager().add(openESBFileInEditorAction);
+ bars.getMenuManager().add(doubleClickAction);
IToolBarManager toolbar = bars.getToolBarManager();
@@ -502,12 +524,114 @@
}
}
}
+
+ /*
+ * Opens the currently displayed file in the ESB editor with the path pre-selected
+ */
+ private void openESBAction ( ) {
+ if (currentFile != null) {
+ Graph graph = gv.getGraphControl();
+ String modelpath = ""; //$NON-NLS-1$
+ if (!graph.getSelection().isEmpty()) {
+ GraphNode node = (GraphNode) graph.getSelection().get(0);
+ if (node.getData() != null && node.getData() instanceof ESBNode) {
+ ESBNode esbnode = (ESBNode) node.getData();
+ while (esbnode != null && esbnode.getParent() != null) {
+ if (modelpath.trim().length() > 0)
+ modelpath = "/" + modelpath; //$NON-NLS-1$
+ modelpath = esbnode.getName() + modelpath;
+ esbnode = esbnode.getParent();
+ }
+// boolean useIdeMethod = false;
+// if (useIdeMethod) {
+// modelpath = "FileSystems/project/" +
currentFile.getProjectRelativePath().toString() + "/" + modelpath;
+// // modelpath =
"FileSystems/project/esbcontent/META-INF/jboss-esb.xml/Services/SimpleListener";
+//
+// IWorkbenchPage page = getSite().getPage();
+// HashMap<String, String> map = new HashMap<String, String>();
+// map.put("xpath", modelpath);// "action/path/whatever");
+// map.put(IDE.EDITOR_ID_ATTR,
+// "org.jboss.tools.common.model.ui.editor.EditorPartWrapper");
+// try {
+// IMarker marker = currentFile.createMarker(IMarker.TEXT);
+// marker.setAttributes(map);
+// IDE.openEditor(page, marker); //3.0 API
+// marker.delete();
+// } catch (CoreException e) {
+// e.printStackTrace();
+// }
+// } else {
+ // if we have an empty path, the user double-clicked on the root
+ // so just open the file
+ if (modelpath.trim().length() == 0) {
+ IWorkbenchPage page = getSite().getPage();
+ try {
+ IDE.openEditor(page, currentFile);
+ } catch (PartInitException e) {
+ e.printStackTrace();
+ }
+ } else {
+ // otherwise use the FindObjectHelper to find the actual node
+ // in the ESB editor
+ XModelObject fileObject =
+ EclipseResourceUtil.createObjectForResource(currentFile);
+ XModelObject actionObject =
+ fileObject.getChildByPath(modelpath);
//"Services/SimpleListener/Actions/displayAction");
+ FindObjectHelper.findModelObject(actionObject, FindObjectHelper.IN_EDITOR_ONLY);
+ }
+ // }
+ }
+ }
+ }
+ }
+
/*
+ * Action to open the ESB editor
* @author bfitzpat
- * If the user double-clicks on a node, "fix" it in place. If they double-
- * click again, un-"fix" it.
+ *
*/
+ private class OpenESBEditorAction extends Action {
+
+ public OpenESBEditorAction() {
+ super(JBossESBUIMessages.ESBVisualizerView_Open_ESB_Editor_Action_Label);
+ }
+
+ public void run() {
+ openESBAction();
+ }
+
+ }
+
+ /*
+ * Action to toggle the double-click behavior from freezing a node to opening
+ * the ESB editor to the selected object.
+ * By default it opens the ESB editor.
+ * @author bfitzpat
+ *
+ */
+ private class DoubleClickToggleAction extends Action {
+
+ public DoubleClickToggleAction() {
+ super(JBossESBUIMessages.ESBVisualizerView_DoubleClick_Toggle_Action_label);
+ this.setChecked(doubleClickFreezesNode);
+ }
+
+ public void run() {
+ doubleClickFreezesNode = !doubleClickFreezesNode;
+ this.setChecked(doubleClickFreezesNode);
+ }
+
+ }
+
+ /*
+ * @author bfitzpat
+ * If the user double-clicks on a node, it does one of two things:
+ * * if the double-click toggle is set to freeze the node, it will "freeze" it
in place.
+ * If they double-click again, un-"freeze" it. Frozen nodes don't move
when the layout
+ * changes or is refreshed.
+ * * if not, the ESB editor is opened and the object double-clicked on is selected
+ */
private class FixNodeDoubleClickListener implements IDoubleClickListener {
public void doubleClick(DoubleClickEvent e) {
if (e.getSource() instanceof GraphViewer) {
@@ -515,15 +639,19 @@
if (!graph.getSelection().isEmpty()) {
GraphNode node = (GraphNode) graph.getSelection().get(0);
if (node.getData() != null && node.getData() instanceof ESBNode) {
- ESBNode to = (ESBNode)node.getData();
- to.setIsMovementLocked(!to.isMovementLocked());
- if (to.isMovementLocked()) {
- node.setBorderWidth(3);
- node.setBorderColor(gv.getGraphControl().getDisplay().getSystemColor(
- SWT.COLOR_BLUE));
+ if (doubleClickFreezesNode) {
+ ESBNode to = (ESBNode)node.getData();
+ to.setIsMovementLocked(!to.isMovementLocked());
+ if (to.isMovementLocked()) {
+ node.setBorderWidth(3);
+ node.setBorderColor(gv.getGraphControl().getDisplay().getSystemColor(
+ SWT.COLOR_BLUE));
+ } else {
+ node.setBorderWidth(1);
+ node.setBorderColor(defaultBorder);
+ }
} else {
- node.setBorderWidth(1);
- node.setBorderColor(defaultBorder);
+ openESBAction();
}
}
}
@@ -576,6 +704,7 @@
String path = ((IFile)first).getLocation().toOSString();
ESBDomParser parser = new ESBDomParser();
if (parser.isFileESBConfig(path)) {
+ this.currentFile = (IFile) first;
visualizeESB(path);
return true;
} else {
Modified:
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/visualizer/WorkbenchFileSelectionDialog.java
===================================================================
---
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/visualizer/WorkbenchFileSelectionDialog.java 2012-02-03
18:44:27 UTC (rev 38421)
+++
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/visualizer/WorkbenchFileSelectionDialog.java 2012-02-03
19:41:38 UTC (rev 38422)
@@ -28,6 +28,7 @@
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
+import org.jboss.tools.esb.project.ui.messages.JBossESBUIMessages;
public class WorkbenchFileSelectionDialog
@@ -106,7 +107,7 @@
e.printStackTrace();
}
- this.title = "Some fun title";
+ this.title = JBossESBUIMessages.WorkbenchFileSelectionDialog_Title;
this.message = message;
setShellStyle(getShellStyle() | SWT.RESIZE);
this.filterPatterns = filterPatterns;