Author: dennyxu
Date: 2009-01-14 21:35:55 -0500 (Wed, 14 Jan 2009)
New Revision: 13054
Added:
workspace/Denny/ESBTestUI/org.jboss.tools.esb.test.ui/.classpath
workspace/Denny/ESBTestUI/org.jboss.tools.esb.test.ui/.project
workspace/Denny/ESBTestUI/org.jboss.tools.esb.test.ui/.settings/
workspace/Denny/ESBTestUI/org.jboss.tools.esb.test.ui/.settings/org.eclipse.jdt.core.prefs
workspace/Denny/ESBTestUI/org.jboss.tools.esb.test.ui/META-INF/
workspace/Denny/ESBTestUI/org.jboss.tools.esb.test.ui/META-INF/MANIFEST.MF
workspace/Denny/ESBTestUI/org.jboss.tools.esb.test.ui/build.properties
workspace/Denny/ESBTestUI/org.jboss.tools.esb.test.ui/icons/
workspace/Denny/ESBTestUI/org.jboss.tools.esb.test.ui/icons/sample.gif
workspace/Denny/ESBTestUI/org.jboss.tools.esb.test.ui/plugin.xml
workspace/Denny/ESBTestUI/org.jboss.tools.esb.test.ui/src/
workspace/Denny/ESBTestUI/org.jboss.tools.esb.test.ui/src/org/
workspace/Denny/ESBTestUI/org.jboss.tools.esb.test.ui/src/org/jboss/
workspace/Denny/ESBTestUI/org.jboss.tools.esb.test.ui/src/org/jboss/tools/
workspace/Denny/ESBTestUI/org.jboss.tools.esb.test.ui/src/org/jboss/tools/esb/
workspace/Denny/ESBTestUI/org.jboss.tools.esb.test.ui/src/org/jboss/tools/esb/test/
workspace/Denny/ESBTestUI/org.jboss.tools.esb.test.ui/src/org/jboss/tools/esb/test/ui/
workspace/Denny/ESBTestUI/org.jboss.tools.esb.test.ui/src/org/jboss/tools/esb/test/ui/ESBTestUIPlugin.java
workspace/Denny/ESBTestUI/org.jboss.tools.esb.test.ui/src/org/jboss/tools/esb/test/ui/invokers/
workspace/Denny/ESBTestUI/org.jboss.tools.esb.test.ui/src/org/jboss/tools/esb/test/ui/invokers/ESBJMSSender.java
workspace/Denny/ESBTestUI/org.jboss.tools.esb.test.ui/src/org/jboss/tools/esb/test/ui/util/
workspace/Denny/ESBTestUI/org.jboss.tools.esb.test.ui/src/org/jboss/tools/esb/test/ui/util/ESBConfigReader.java
workspace/Denny/ESBTestUI/org.jboss.tools.esb.test.ui/src/org/jboss/tools/esb/test/ui/util/ESBUIHelper.java
workspace/Denny/ESBTestUI/org.jboss.tools.esb.test.ui/src/org/jboss/tools/esb/test/ui/views/
workspace/Denny/ESBTestUI/org.jboss.tools.esb.test.ui/src/org/jboss/tools/esb/test/ui/views/ESBServiceTestView.java
workspace/Denny/ESBTestUI/org.jboss.tools.esb.test.ui/src/org/jboss/tools/esb/test/ui/views/TestComposite.java
workspace/Denny/ESBTestUI/org.jboss.tools.esb.test.ui/src/org/jboss/tools/esb/test/ui/views/TestUIComposite.java
Log:
Initial import.
Added: workspace/Denny/ESBTestUI/org.jboss.tools.esb.test.ui/.classpath
===================================================================
--- workspace/Denny/ESBTestUI/org.jboss.tools.esb.test.ui/.classpath
(rev 0)
+++ workspace/Denny/ESBTestUI/org.jboss.tools.esb.test.ui/.classpath 2009-01-15 02:35:55
UTC (rev 13054)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con"
path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Added: workspace/Denny/ESBTestUI/org.jboss.tools.esb.test.ui/.project
===================================================================
--- workspace/Denny/ESBTestUI/org.jboss.tools.esb.test.ui/.project
(rev 0)
+++ workspace/Denny/ESBTestUI/org.jboss.tools.esb.test.ui/.project 2009-01-15 02:35:55 UTC
(rev 13054)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.jboss.tools.esb.test.ui</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Added:
workspace/Denny/ESBTestUI/org.jboss.tools.esb.test.ui/.settings/org.eclipse.jdt.core.prefs
===================================================================
---
workspace/Denny/ESBTestUI/org.jboss.tools.esb.test.ui/.settings/org.eclipse.jdt.core.prefs
(rev 0)
+++
workspace/Denny/ESBTestUI/org.jboss.tools.esb.test.ui/.settings/org.eclipse.jdt.core.prefs 2009-01-15
02:35:55 UTC (rev 13054)
@@ -0,0 +1,7 @@
+#Fri Jan 09 14:12:30 CST 2009
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
Added: workspace/Denny/ESBTestUI/org.jboss.tools.esb.test.ui/META-INF/MANIFEST.MF
===================================================================
--- workspace/Denny/ESBTestUI/org.jboss.tools.esb.test.ui/META-INF/MANIFEST.MF
(rev 0)
+++ workspace/Denny/ESBTestUI/org.jboss.tools.esb.test.ui/META-INF/MANIFEST.MF 2009-01-15
02:35:55 UTC (rev 13054)
@@ -0,0 +1,17 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Ui Plug-in
+Bundle-SymbolicName: org.jboss.tools.esb.test.ui;singleton:=true
+Bundle-Version: 1.0.0
+Bundle-Activator: org.jboss.tools.esb.test.ui.ESBTestUIPlugin
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.jboss.tools.esb.model;bundle-version="1.0.0",
+ org.eclipse.core.resources;bundle-version="3.4.1",
+ org.eclipse.wst.common.modulecore;bundle-version="1.1.204",
+ org.jboss.tools.esb.project.core;bundle-version="1.0.0",
+ org.jboss.tools.esb.project.ui;bundle-version="1.0.0",
+ org.eclipse.wst.common.project.facet.core;bundle-version="1.3.4",
+ org.eclipse.ui.forms;bundle-version="3.3.101"
+Bundle-ActivationPolicy: lazy
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Added: workspace/Denny/ESBTestUI/org.jboss.tools.esb.test.ui/build.properties
===================================================================
--- workspace/Denny/ESBTestUI/org.jboss.tools.esb.test.ui/build.properties
(rev 0)
+++ workspace/Denny/ESBTestUI/org.jboss.tools.esb.test.ui/build.properties 2009-01-15
02:35:55 UTC (rev 13054)
@@ -0,0 +1,5 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml
Added: workspace/Denny/ESBTestUI/org.jboss.tools.esb.test.ui/icons/sample.gif
===================================================================
(Binary files differ)
Property changes on:
workspace/Denny/ESBTestUI/org.jboss.tools.esb.test.ui/icons/sample.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: workspace/Denny/ESBTestUI/org.jboss.tools.esb.test.ui/plugin.xml
===================================================================
--- workspace/Denny/ESBTestUI/org.jboss.tools.esb.test.ui/plugin.xml
(rev 0)
+++ workspace/Denny/ESBTestUI/org.jboss.tools.esb.test.ui/plugin.xml 2009-01-15 02:35:55
UTC (rev 13054)
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.2"?>
+<plugin>
+ <extension
+ point="org.eclipse.ui.views">
+ <category
+ id="org.jboss.tools.esb.test.ui"
+ name="Sample Category">
+ </category>
+ <view
+ category="org.jboss.tools.esb.test.ui"
+ class="org.jboss.tools.esb.test.ui.views.ESBServiceTestView"
+ icon="icons/sample.gif"
+ id="org.jboss.tools.esb.test.ui.views.ESBServiceTestView"
+ name="ESB Test View">
+ </view>
+ </extension>
+ <extension
+ point="org.eclipse.ui.perspectiveExtensions">
+ <perspectiveExtension
+ targetID="org.eclipse.jdt.ui.JavaPerspective">
+ <view
+ id="org.jboss.tools.esb.test.ui.views.ESBServiceTestView"
+ ratio="0.5"
+ relationship="right"
+ relative="org.eclipse.ui.views.TaskList">
+ </view>
+ </perspectiveExtension>
+ </extension>
+
+</plugin>
Added:
workspace/Denny/ESBTestUI/org.jboss.tools.esb.test.ui/src/org/jboss/tools/esb/test/ui/ESBTestUIPlugin.java
===================================================================
---
workspace/Denny/ESBTestUI/org.jboss.tools.esb.test.ui/src/org/jboss/tools/esb/test/ui/ESBTestUIPlugin.java
(rev 0)
+++
workspace/Denny/ESBTestUI/org.jboss.tools.esb.test.ui/src/org/jboss/tools/esb/test/ui/ESBTestUIPlugin.java 2009-01-15
02:35:55 UTC (rev 13054)
@@ -0,0 +1,50 @@
+package org.jboss.tools.esb.test.ui;
+
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class ESBTestUIPlugin extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.jboss.tools.esb.test.ui";
+
+ // The shared instance
+ private static ESBTestUIPlugin plugin;
+
+ /**
+ * The constructor
+ */
+ public ESBTestUIPlugin() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static ESBTestUIPlugin getDefault() {
+ return plugin;
+ }
+
+}
Added:
workspace/Denny/ESBTestUI/org.jboss.tools.esb.test.ui/src/org/jboss/tools/esb/test/ui/invokers/ESBJMSSender.java
===================================================================
---
workspace/Denny/ESBTestUI/org.jboss.tools.esb.test.ui/src/org/jboss/tools/esb/test/ui/invokers/ESBJMSSender.java
(rev 0)
+++
workspace/Denny/ESBTestUI/org.jboss.tools.esb.test.ui/src/org/jboss/tools/esb/test/ui/invokers/ESBJMSSender.java 2009-01-15
02:35:55 UTC (rev 13054)
@@ -0,0 +1,5 @@
+package org.jboss.tools.esb.test.ui.invokers;
+
+public class ESBJMSSender {
+
+}
Added:
workspace/Denny/ESBTestUI/org.jboss.tools.esb.test.ui/src/org/jboss/tools/esb/test/ui/util/ESBConfigReader.java
===================================================================
---
workspace/Denny/ESBTestUI/org.jboss.tools.esb.test.ui/src/org/jboss/tools/esb/test/ui/util/ESBConfigReader.java
(rev 0)
+++
workspace/Denny/ESBTestUI/org.jboss.tools.esb.test.ui/src/org/jboss/tools/esb/test/ui/util/ESBConfigReader.java 2009-01-15
02:35:55 UTC (rev 13054)
@@ -0,0 +1,140 @@
+package org.jboss.tools.esb.test.ui.util;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.wst.common.componentcore.ComponentCore;
+import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
+import org.eclipse.wst.common.project.facet.core.IFacetedProject;
+import org.eclipse.wst.common.project.facet.core.IProjectFacet;
+import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
+import org.jboss.tools.esb.Bus;
+import org.jboss.tools.esb.BusProvider;
+import org.jboss.tools.esb.DocumentRoot;
+import org.jboss.tools.esb.JmsBusType;
+import org.jboss.tools.esb.Listener;
+import org.jboss.tools.esb.Provider;
+import org.jboss.tools.esb.ServiceType;
+import org.jboss.tools.esb.core.ESBProjectConstant;
+import org.jboss.tools.esb.util.ESBXMLProcessor;
+
+public class ESBConfigReader {
+
+ private DocumentRoot esbRoot;
+ public ESBConfigReader(File file){
+ init(file);
+ }
+
+ public ESBConfigReader(IFile file){
+ this(file.getLocation().toFile());
+ }
+
+ /*
+ * the project should contains ESB facet
+ */
+ public ESBConfigReader(IProject project){
+ this(getConfigFile(project));
+ }
+
+ private static IFile getConfigFile(IProject project){
+
+ try {
+ IFacetedProject fp = ProjectFacetsManager.create(project);
+ IProjectFacet esbfacet =
ProjectFacetsManager.getProjectFacet(ESBProjectConstant.ESB_PROJECT_FACET);
+ Assert.isTrue(fp.hasProjectFacet(esbfacet), "The project should contains
'jst.jboss.esb' Facet");
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+
+ IVirtualComponent c = ComponentCore.createComponent(project);
+ IContainer[] rootFolders = c.getRootFolder().getUnderlyingFolders();
+ IContainer contentFolder = rootFolders[0];
+ if (rootFolders.length > 1) {
+ contentFolder = rootFolders[1];
+ }
+ IFolder metainf = contentFolder.getFolder(new Path(
+ ESBProjectConstant.META_INF));
+ IFile esbConfig = metainf
+ .getFile(ESBProjectConstant.ESB_CONFIG_JBOSSESB);
+
+ return esbConfig;
+ }
+
+ private void init(File file){
+ Assert.isNotNull(file);
+ Assert.isTrue(file.exists());
+
+ ESBXMLProcessor processor = new ESBXMLProcessor();
+ try {
+ Resource resource = processor.load(new FileInputStream(file), null);
+ Object obj = resource.getContents().get(0);
+ if(obj instanceof DocumentRoot){
+ esbRoot = (DocumentRoot)obj;
+ }
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public DocumentRoot getESBRoot(){
+ return esbRoot;
+ }
+
+ public List<Provider> getProviders(){
+ if(esbRoot != null){
+ return esbRoot.getJbossesb().getProviders().getProvider();
+ }
+
+ return new ArrayList<Provider>();
+ }
+
+ public List<ServiceType> getServices(){
+ if(esbRoot != null){
+ return esbRoot.getJbossesb().getServices().getService();
+ }
+ return null;
+ }
+
+ public List<Listener> getListeners(ServiceType service){
+ if(service != null && service.getListeners() != null){
+ return service.getListeners().getListener();
+ }
+
+ return new ArrayList<Listener>();
+ }
+
+ public Bus getBusByListener(Listener listener){
+ String busid = listener.getBusidref();
+ return getBusByBusidRef(busid);
+ }
+
+ public Bus getBusByBusidRef(String busidref){
+ List<Provider> providers = getProviders();
+ for(Provider provider : providers){
+ if(provider instanceof BusProvider){
+ List<Bus> buses = ((BusProvider)provider).getBus();
+ for(Bus bus : buses){
+ if(busidref.equals(bus.getBusid())){
+ return bus;
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+}
Added:
workspace/Denny/ESBTestUI/org.jboss.tools.esb.test.ui/src/org/jboss/tools/esb/test/ui/util/ESBUIHelper.java
===================================================================
---
workspace/Denny/ESBTestUI/org.jboss.tools.esb.test.ui/src/org/jboss/tools/esb/test/ui/util/ESBUIHelper.java
(rev 0)
+++
workspace/Denny/ESBTestUI/org.jboss.tools.esb.test.ui/src/org/jboss/tools/esb/test/ui/util/ESBUIHelper.java 2009-01-15
02:35:55 UTC (rev 13054)
@@ -0,0 +1,14 @@
+package org.jboss.tools.esb.test.ui.util;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+
+public class ESBUIHelper {
+
+ public static Group createGroup(Composite parent, int style){
+ Group group = new Group(parent, style);
+ group.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WHITE));
+ return group;
+ }
+}
Added:
workspace/Denny/ESBTestUI/org.jboss.tools.esb.test.ui/src/org/jboss/tools/esb/test/ui/views/ESBServiceTestView.java
===================================================================
---
workspace/Denny/ESBTestUI/org.jboss.tools.esb.test.ui/src/org/jboss/tools/esb/test/ui/views/ESBServiceTestView.java
(rev 0)
+++
workspace/Denny/ESBTestUI/org.jboss.tools.esb.test.ui/src/org/jboss/tools/esb/test/ui/views/ESBServiceTestView.java 2009-01-15
02:35:55 UTC (rev 13054)
@@ -0,0 +1,280 @@
+package org.jboss.tools.esb.test.ui.views;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IMenuListener;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.SashForm;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.IWorkbenchActionConstants;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.Section;
+import org.eclipse.ui.part.DrillDownAdapter;
+import org.eclipse.ui.part.ViewPart;
+import org.eclipse.wst.common.project.facet.core.IFacetedProject;
+import org.eclipse.wst.common.project.facet.core.IProjectFacet;
+import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
+import org.jboss.tools.esb.ServiceType;
+import org.jboss.tools.esb.core.ESBProjectConstant;
+import org.jboss.tools.esb.project.ui.ESBProjectPlugin;
+import org.jboss.tools.esb.test.ui.util.ESBConfigReader;
+
+
+public class ESBServiceTestView extends ViewPart {
+ private TreeViewer viewer;
+ private DrillDownAdapter drillDownAdapter;
+ private Action action1;
+ private Action action2;
+ private Action doubleClickAction;
+ private FormToolkit toolkit;
+
+ /*
+ * The content provider class is responsible for
+ * providing objects to the view. It can wrap
+ * existing objects in adapters or simply return
+ * objects as-is. These objects may be sensitive
+ * to the current input of the view, or ignore
+ * it and always show the same content
+ * (like Task List, for example).
+ */
+
+ class ESBProjectVeiwerFilter extends ViewerFilter{
+
+ @Override
+ public boolean select(Viewer viewer, Object parentElement,
+ Object element) {
+ if(element instanceof IProject){
+ IProject project = (IProject)element;
+ try {
+ IFacetedProject fp = ProjectFacetsManager.create(project);
+ IProjectFacet esbfacet =
ProjectFacetsManager.getProjectFacet(ESBProjectConstant.ESB_PROJECT_FACET);
+ return fp != null && fp.hasProjectFacet(esbfacet);
+ } catch (CoreException e) {
+ return false;
+ }
+
+ }
+ return true;
+ }
+
+ }
+
+ class ViewContentProvider implements IStructuredContentProvider,
+ ITreeContentProvider {
+
+ public void inputChanged(Viewer v, Object oldInput, Object newInput) {
+ }
+ public void dispose() {
+ }
+ public Object[] getElements(Object parent) {
+ if(parent instanceof IWorkspaceRoot){
+ return ((IWorkspaceRoot)parent).getProjects();
+ }
+ return getChildren(parent);
+ }
+ public Object getParent(Object child) {
+ return null;
+ }
+ public Object [] getChildren(Object parent) {
+ if(parent instanceof IProject){
+ ESBConfigReader reader = new ESBConfigReader((IProject)parent);
+ return reader.getServices().toArray();
+ }
+ return new Object[0];
+ }
+ public boolean hasChildren(Object parent) {
+
+ return getChildren(parent).length > 0;
+ }
+ }
+ class ViewLabelProvider extends LabelProvider {
+
+ public String getText(Object obj) {
+ if(obj instanceof IProject){
+ return ((IProject)obj).getName();
+ }
+ else if(obj instanceof ServiceType){
+ return ((ServiceType)obj).getCategory() + " : " +
((ServiceType)obj).getName();
+ }
+ return obj.toString();
+ }
+ public Image getImage(Object obj) {
+ if(obj instanceof IProject){
+ return
ESBProjectPlugin.getDefault().getImageRegistry().get("esb_runtime");
+ }
+ else if(obj instanceof ServiceType){
+ return
PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_ELEMENT);
+ }
+ return null;
+ }
+ }
+
+
+ /**
+ * The constructor.
+ */
+ public ESBServiceTestView() {
+ toolkit = new FormToolkit(PlatformUI.getWorkbench().getDisplay());
+ }
+
+ /**
+ * This is a callback that will allow us
+ * to create the viewer and initialize it.
+ */
+ public void createPartControl(Composite parent) {
+ SashForm sf = new SashForm(parent, SWT.NONE);
+ sf.setLayout(new FillLayout());
+
+
+
+ createTreeViewer(sf);
+ createEditArea(sf);
+ sf.setWeights(new int[]{20, 70});
+ }
+
+ private void createTreeViewer(Composite parent){
+ Composite uicom = toolkit.createComposite(parent, SWT.NONE);
+ uicom.setLayout(new FillLayout());
+ viewer = new TreeViewer(uicom, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
+ drillDownAdapter = new DrillDownAdapter(viewer);
+ viewer.setContentProvider(new ViewContentProvider());
+ viewer.setLabelProvider(new ViewLabelProvider());
+ viewer.addFilter(new ESBProjectVeiwerFilter());
+
+ viewer.setInput(ResourcesPlugin.getWorkspace().getRoot());
+
+ makeActions();
+ hookContextMenu();
+ hookDoubleClickAction();
+ contributeToActionBars();
+ }
+
+ private void createEditArea(Composite parent){
+ Section section = toolkit.createSection(parent, Section.TITLE_BAR | Section.EXPANDED
);
+ section.setText("Service Test Page");
+ Composite editcom = toolkit.createComposite(section);
+ editcom.setLayout(new GridLayout());
+ editcom.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+ new TestUIComposite(editcom, toolkit);
+
+ section.setClient(editcom);
+ }
+
+ private void hookContextMenu() {
+ MenuManager menuMgr = new MenuManager("#PopupMenu");
+ menuMgr.setRemoveAllWhenShown(true);
+ menuMgr.addMenuListener(new IMenuListener() {
+ public void menuAboutToShow(IMenuManager manager) {
+ ESBServiceTestView.this.fillContextMenu(manager);
+ }
+ });
+ Menu menu = menuMgr.createContextMenu(viewer.getControl());
+ viewer.getControl().setMenu(menu);
+ getSite().registerContextMenu(menuMgr, viewer);
+ }
+
+ private void contributeToActionBars() {
+ IActionBars bars = getViewSite().getActionBars();
+ fillLocalPullDown(bars.getMenuManager());
+ fillLocalToolBar(bars.getToolBarManager());
+ }
+
+ private void fillLocalPullDown(IMenuManager manager) {
+ manager.add(action1);
+ manager.add(new Separator());
+ manager.add(action2);
+ }
+
+ private void fillContextMenu(IMenuManager manager) {
+ manager.add(action1);
+ manager.add(action2);
+ manager.add(new Separator());
+ drillDownAdapter.addNavigationActions(manager);
+ // Other plug-ins can contribute there actions here
+ manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
+ }
+
+ private void fillLocalToolBar(IToolBarManager manager) {
+ manager.add(action1);
+ manager.add(action2);
+ manager.add(new Separator());
+ drillDownAdapter.addNavigationActions(manager);
+ }
+
+ private void makeActions() {
+ action1 = new Action() {
+ public void run() {
+ showMessage("Action 1 executed");
+ }
+ };
+ action1.setText("Action 1");
+ action1.setToolTipText("Action 1 tooltip");
+ action1.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().
+ getImageDescriptor(ISharedImages.IMG_OBJS_INFO_TSK));
+
+ action2 = new Action() {
+ public void run() {
+ showMessage("Action 2 executed");
+ }
+ };
+ action2.setText("Action 2");
+ action2.setToolTipText("Action 2 tooltip");
+ action2.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().
+ getImageDescriptor(ISharedImages.IMG_OBJS_INFO_TSK));
+ doubleClickAction = new Action() {
+ public void run() {
+ ISelection selection = viewer.getSelection();
+ Object obj = ((IStructuredSelection)selection).getFirstElement();
+ showMessage("Double-click detected on "+obj.toString());
+ }
+ };
+ }
+
+ private void hookDoubleClickAction() {
+ viewer.addDoubleClickListener(new IDoubleClickListener() {
+ public void doubleClick(DoubleClickEvent event) {
+ doubleClickAction.run();
+ }
+ });
+ }
+ private void showMessage(String message) {
+ MessageDialog.openInformation(
+ viewer.getControl().getShell(),
+ "ESB Test View",
+ message);
+ }
+
+ /**
+ * Passing the focus request to the viewer's control.
+ */
+ public void setFocus() {
+ viewer.getControl().setFocus();
+ }
+}
\ No newline at end of file
Added:
workspace/Denny/ESBTestUI/org.jboss.tools.esb.test.ui/src/org/jboss/tools/esb/test/ui/views/TestComposite.java
===================================================================
---
workspace/Denny/ESBTestUI/org.jboss.tools.esb.test.ui/src/org/jboss/tools/esb/test/ui/views/TestComposite.java
(rev 0)
+++
workspace/Denny/ESBTestUI/org.jboss.tools.esb.test.ui/src/org/jboss/tools/esb/test/ui/views/TestComposite.java 2009-01-15
02:35:55 UTC (rev 13054)
@@ -0,0 +1,56 @@
+package org.jboss.tools.esb.test.ui.views;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.Section;
+
+abstract class TestComposite extends Composite {
+
+ protected FormToolkit toolkit;
+
+ public TestComposite(Composite parent, FormToolkit toolkit) {
+ super(parent, SWT.COLOR_WHITE);
+ GridLayout layout = new GridLayout();
+ this.setLayout(layout);
+ this.setLayoutData(new GridData(GridData.FILL_BOTH));
+ this.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WHITE));
+
+ this.toolkit = toolkit;
+ createControl(this);
+ }
+
+ protected abstract void createControl(Composite parent);
+
+ public Composite createCompositeWithSection(Composite parent , String text, int cols,
int style){
+ Section inputSec = toolkit.createSection(parent, style);
+ inputSec.setText(text);
+ inputSec.setLayout(new GridLayout());
+ inputSec.setLayoutData(new GridData(GridData.FILL_BOTH));
+ Composite inputCom = createComposite(inputSec, cols);
+
+ inputSec.setClient(inputCom);
+ toolkit.paintBordersFor(inputCom);
+
+ return inputCom;
+ }
+
+ public Composite createComposite(Composite parent, int cols){
+ Composite inputCom = toolkit.createComposite(parent);
+ inputCom.setLayout(new GridLayout(cols, false));
+ inputCom.setLayoutData(new GridData(GridData.FILL_BOTH));
+ return inputCom;
+ }
+
+ public Text createTextWithLabel(Composite parent, String textForLabel, int style){
+ toolkit.createLabel(parent, textForLabel);
+ Text txtQtype = toolkit.createText(parent, "", style);
+ txtQtype.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ return txtQtype;
+ }
+
+}
Added:
workspace/Denny/ESBTestUI/org.jboss.tools.esb.test.ui/src/org/jboss/tools/esb/test/ui/views/TestUIComposite.java
===================================================================
---
workspace/Denny/ESBTestUI/org.jboss.tools.esb.test.ui/src/org/jboss/tools/esb/test/ui/views/TestUIComposite.java
(rev 0)
+++
workspace/Denny/ESBTestUI/org.jboss.tools.esb.test.ui/src/org/jboss/tools/esb/test/ui/views/TestUIComposite.java 2009-01-15
02:35:55 UTC (rev 13054)
@@ -0,0 +1,123 @@
+package org.jboss.tools.esb.test.ui.views;
+
+import java.util.Properties;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.Section;
+
+public class TestUIComposite extends TestComposite {
+
+ private Composite jmsCom;
+ private Text txtQtype;
+ private Text txtDesName;
+ private Text txtMessage;
+
+ public TestUIComposite(Composite parent, FormToolkit toolkit) {
+ super(parent, toolkit);
+ }
+
+ public void createControl(Composite parent){
+ Composite com = toolkit.createComposite(parent);
+ com.setLayout( new GridLayout());
+ com.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+ Composite btncom = toolkit.createComposite(com);
+ btncom.setLayout(new GridLayout(3, false));
+
+ Button btnInVM = toolkit.createButton(btncom, "Send ESB Message" ,
SWT.RADIO);
+ Button btnJMS = toolkit.createButton(btncom, "Send JMS Message", SWT.RADIO);
+ Button btnPerform = toolkit.createButton(btncom, "Test the Service",
SWT.PUSH);
+
+
+ Label sep = toolkit.createSeparator(com, SWT.HORIZONTAL);
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 3;
+ sep.setLayoutData(gd);
+
+ jmsCom = toolkit.createComposite(com);
+ jmsCom.setLayout(new GridLayout());
+ jmsCom.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+ createJMSMessageInputUI(jmsCom);
+ }
+
+ private void createJMSMessageInputUI(Composite parent){
+ Composite subcom = toolkit.createComposite(parent);
+ subcom.setLayout( new GridLayout(2, true));
+ subcom.setLayoutData(new GridData(GridData.FILL_BOTH));
+ Section ctxSection = toolkit.createSection(subcom, Section.TITLE_BAR | Section.EXPANDED
| Section.TWISTIE);
+ ctxSection.setLayout(new GridLayout(2, false));
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 3;
+ ctxSection.setLayoutData(gd);
+ ctxSection.setText("Initial Context");
+
+ Composite grpCtx = createComposite(ctxSection, 2);
+ Text txtNcf = createTextWithLabel(grpCtx, "Initial Context Factory:",
SWT.NONE);
+ txtNcf.setText("org.jnp.interfaces.NamingContextFactory");
+
+ Text txtUrl = createTextWithLabel(grpCtx, "Provider URL:", SWT.NONE);
+ txtUrl.setText("jnp://localhost:1099");
+
+ Text txtUrlPkg = createTextWithLabel(grpCtx, "URL PKG Prefixes:", SWT.NONE);
+ txtUrlPkg.setText("org.jboss.naming:org.jnp.interfaces");
+
+ toolkit.paintBordersFor(grpCtx);
+ ctxSection.setClient(grpCtx);
+
+ //create test data input form
+ Composite inputCom = createCompositeWithSection(subcom, "Input Test Data", 2,
Section.TITLE_BAR | Section.EXPANDED);
+ txtQtype = createTextWithLabel(inputCom, "Destination Type:",
SWT.READ_ONLY);
+ txtDesName = createTextWithLabel(inputCom, "Destination Name:",
SWT.READ_ONLY);
+
+ toolkit.createLabel(inputCom, "Message File:");
+ Composite fileCom = toolkit.createComposite(inputCom);
+ GridLayout layout = new GridLayout(2, false);
+ layout.marginLeft = 0;
+ layout.marginRight = 0;
+ layout.marginWidth = 1;
+ fileCom.setLayout( layout);
+ fileCom.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ Text txtFile = toolkit.createText(fileCom, "");
+ txtFile.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ Button btnBrowser = toolkit.createButton(fileCom, "Browse...", SWT.NONE);
+ btnBrowser.addSelectionListener(new SelectionAdapter(){
+ public void widgetSelected(SelectionEvent e) {
+
+ }
+ });
+ //toolkit.createLabel(inputCom, "Message Body:");
+ txtMessage = toolkit.createText(inputCom, "", SWT.MULTI | SWT.V_SCROLL |
SWT.H_SCROLL);
+ gd = new GridData(GridData.FILL_BOTH);
+ gd.horizontalSpan = 2;
+ txtMessage.setLayoutData(gd);
+
+
+ toolkit.paintBordersFor(fileCom);
+
+ //create test result section
+ Composite resultCom = createCompositeWithSection(subcom, "Test Result", 1,
Section.TITLE_BAR | Section.EXPANDED);
+
+ }
+
+ public Properties getInitialContext(){
+ Properties properties = new Properties();
+
+ return properties;
+ }
+
+ public String getMessageBody(){
+ return txtMessage.getText();
+ }
+
+
+}