Author: bbrodt
Date: 2011-02-17 17:22:01 -0500 (Thu, 17 Feb 2011)
New Revision: 29205
Added:
workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui/.classpath
workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui/.project
workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui/META-INF/
workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui/META-INF/MANIFEST.MF
workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui/build.properties
workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui/icons/
workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui/icons/obj16/
workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui/icons/obj16/checked.gif
workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui/icons/obj16/ode.gif
workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui/icons/obj16/unchecked.gif
workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui/plugin.properties
workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui/plugin.xml
workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui/src/
workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui/src/org/
workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/
workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/
workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/
workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/
workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/
workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/
workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/Activator.java
workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/editors/
workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/editors/ODEDeployMultiPageEditor.java
workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/editors/ODEDeployMultiPageEditorContributor.java
workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/pages/
workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/pages/ProcessPage.java
workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/pages/ServiceCellEditor.java
workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/util/
workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/util/DeployResourceSetImpl.java
workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/util/DeployUtils.java
workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/util/InterfaceTableListener.java
workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/wizards/
workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/wizards/NewODEDeployWizard.java
workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/wizards/ODEDeployWizardPage.java
Modified:
workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui/
Log:
Property changes on: workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui
___________________________________________________________________
Added: svn:ignore
+ bin
Added: workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui/.classpath
===================================================================
--- workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui/.classpath
(rev 0)
+++ workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui/.classpath 2011-02-17 22:22:01
UTC (rev 29205)
@@ -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/J2SE-1.5"/>
+ <classpathentry kind="con"
path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Added: workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui/.project
===================================================================
--- workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui/.project
(rev 0)
+++ workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui/.project 2011-02-17 22:22:01
UTC (rev 29205)
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.bpel.apache.ode.deploy.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>
+ <buildCommand>
+ <name>org.eclipse.pde.api.tools.apiAnalysisBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.pde.api.tools.apiAnalysisNature</nature>
+ </natures>
+</projectDescription>
Added: workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui/META-INF/MANIFEST.MF
===================================================================
--- workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui/META-INF/MANIFEST.MF
(rev 0)
+++ workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui/META-INF/MANIFEST.MF 2011-02-17
22:22:01 UTC (rev 29205)
@@ -0,0 +1,27 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %pluginName
+Bundle-SymbolicName: org.eclipse.bpel.apache.ode.deploy.ui; singleton:=true
+Bundle-Version: 0.6.0.qualifier
+Bundle-Activator: org.eclipse.bpel.apache.ode.deploy.ui.Activator
+Require-Bundle: org.eclipse.ui;bundle-version="[3.4.0,4.0.0)",
+ org.eclipse.core.runtime;bundle-version="[3.4.0,4.0.0)",
+ org.eclipse.jface.text;bundle-version="[3.4.0,4.0.0)",
+ org.eclipse.core.resources;bundle-version="[3.4.0,4.0.0)",
+ org.eclipse.ui.editors;bundle-version="[3.4.0,4.0.0)",
+ org.eclipse.ui.ide;bundle-version="[3.4.0,4.0.0)",
+ org.eclipse.ui.forms;bundle-version="[3.3.100,4.0.0)",
+ org.eclipse.bpel.apache.ode.deploy.model;bundle-version="[0.4.0,2.0.0)",
+ org.eclipse.bpel.model;bundle-version="[0.4.0,2.0.0)",
+ org.eclipse.wst.wsdl,
+ org.eclipse.xsd;bundle-version="[2.4.0,3.0.0)",
+ javax.wsdl;bundle-version="[1.5.0,1.6.0)",
+ org.eclipse.core.databinding;bundle-version="[1.1.0,2.0.0)",
+ org.eclipse.jface.databinding,
+ org.eclipse.emf.edit.ui;bundle-version="[2.4.0,3.0.0)",
+ org.eclipse.bpel.ui;bundle-version="[0.4.0,2.0.0)",
+ org.eclipse.jdt.core;bundle-version="[3.5.0,4.0.0)",
+ org.eclipse.wst.common.modulecore
+Bundle-ActivationPolicy: lazy
+Bundle-Vendor: %providerName
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
Added: workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui/build.properties
===================================================================
--- workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui/build.properties
(rev 0)
+++ workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui/build.properties 2011-02-17
22:22:01 UTC (rev 29205)
@@ -0,0 +1,6 @@
+source.. = src/
+output.. = bin/
+bin.includes = plugin.xml,\
+ META-INF/,\
+ .,\
+ icons/
Added: workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui/icons/obj16/checked.gif
===================================================================
(Binary files differ)
Property changes on:
workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui/icons/obj16/checked.gif
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui/icons/obj16/ode.gif
===================================================================
(Binary files differ)
Property changes on:
workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui/icons/obj16/ode.gif
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui/icons/obj16/unchecked.gif
===================================================================
(Binary files differ)
Property changes on:
workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui/icons/obj16/unchecked.gif
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui/plugin.properties
===================================================================
--- workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui/plugin.properties
(rev 0)
+++ workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui/plugin.properties 2011-02-17
22:22:01 UTC (rev 29205)
@@ -0,0 +1,30 @@
+###############################################################################
+# Copyright (c) 2010 JBoss by Red Hat and others.
+# All rights reserved. This program and the accompanying materials
+# are 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:
+# IBM Corporation - initial API and implementation
+# JBoss by Red Hat - subsequent contributions and maintenance
+###############################################################################
+# <copyright>
+# </copyright>
+#
+# $Id: plugin.properties,v 1.1 2008/08/12 17:27:58 smoser Exp $
+
+# ====================================================================
+# To code developer:
+# Do NOT change the properties between this line and the
+# "%%% END OF TRANSLATED PROPERTIES %%%" line.
+# Make a new property name, append to the end of the file and change
+# the code to use the new property.
+# ====================================================================
+
+# ====================================================================
+# %%% END OF TRANSLATED PROPERTIES %%%
+# ====================================================================
+
+pluginName = ODE Deploy Descriptor UI Plug-in
+providerName = JBoss by Red Hat
Added: workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui/plugin.xml
===================================================================
--- workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui/plugin.xml
(rev 0)
+++ workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui/plugin.xml 2011-02-17 22:22:01
UTC (rev 29205)
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.2"?>
+<plugin>
+
+ <extension
+ point="org.eclipse.ui.editors">
+ <editor
+
class="org.eclipse.bpel.apache.ode.deploy.ui.editors.ODEDeployMultiPageEditor"
+
contributorClass="org.eclipse.bpel.apache.ode.deploy.ui.editors.ODEDeployMultiPageEditorContributor"
+ filenames="bpel-deploy.xml,deploy.xml"
+ icon="icons/obj16/ode.gif"
+
id="org.eclipse.bpel.apache.ode.deploy.ui.editors.ODEDeployMultiPageEditor"
+ name="ODE Deployment Descriptor Editor">
+ <contentTypeBinding
+
contentTypeId="org.eclipse.bpel.apache.ode.deploy.ui.content-type">
+ </contentTypeBinding>
+ </editor>
+ </extension>
+
+ <extension
+ point="org.eclipse.ui.newWizards">
+ <wizard
+ name="Apache ODE Deployment Descriptor"
+ icon="icons/obj16/ode.gif"
+ category="org.eclipse.bpel.wizards"
+
class="org.eclipse.bpel.apache.ode.deploy.ui.wizards.NewODEDeployWizard"
+
id="org.eclipse.bpel.apache.ode.deploy.ui.wizards.NewODEDeployWizard">
+ </wizard>
+ </extension>
+ <extension
+ point="org.eclipse.core.runtime.contentTypes">
+ <content-type
+ base-type="org.eclipse.core.runtime.xml"
+ default-charset="UTF-8"
+ file-names="deploy.xml,bpel-deploy.xml"
+ id="org.eclipse.bpel.apache.ode.deploy.ui.content-type"
+ name="ODE BPEL Deployment Descriptor"
+ priority="normal">
+ </content-type>
+ </extension>
+ <extension
+ point="org.eclipse.ui.decorators">
+ <decorator
+ adaptable="true"
+ icon="icons/obj16/ode.gif"
+ id="org.eclipse.bpel.apache.ode.deploy.ui.icondecorator"
+ label="ODE DD Resource Decorator"
+ lightweight="true"
+ location="TOP_LEFT"
+ state="true">
+ <enablement>
+ <and>
+ <objectClass
+ name="org.eclipse.core.resources.IFile">
+ </objectClass>
+ <objectState
+ name="contentTypeId"
+
value="org.eclipse.bpel.apache.ode.deploy.ui.content-type">
+ </objectState>
+ </and>
+ </enablement>
+ </decorator>
+ </extension>
+
+</plugin>
Added:
workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/Activator.java
===================================================================
---
workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/Activator.java
(rev 0)
+++
workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/Activator.java 2011-02-17
22:22:01 UTC (rev 29205)
@@ -0,0 +1,94 @@
+/*******************************************************************************
+ * Copyright (c) 2008 IBM Corporation, University of Stuttgart (IAAS) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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:
+ * IBM Corporation, University of Stuttgart (IAAS) - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.bpel.apache.ode.deploy.ui;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.resource.ImageRegistry;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ *
+ * @author Tammo van Lessen (IAAS)
+ * @author Simon Moser (IBM)
+ */
+public class Activator extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID =
"org.eclipse.bpel.apache.ode.deploy.ui"; //$NON-NLS-1$
+
+ // The editor ID
+ public static final String EDITOR_ID =
"org.eclipse.bpel.apache.ode.deploy.ui.editors.ODEDeployMultiPageEditor";
//$NON-NLS-1$
+
+ // The shared instance
+ private static Activator plugin;
+
+ // shared images
+ public static final String IMG_ODE = "ode16"; //$NON-NLS-1$
+ public static final String IMG_CHECKED = "checked"; //$NON-NLS-1$
+ public static final String IMG_UNCHECKED = "unchecked"; //$NON-NLS-1$
+
+ /**
+ * The constructor
+ */
+ public Activator() {
+ }
+
+ /*
+ * (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 Activator getDefault() {
+ return plugin;
+ }
+
+ /**
+ * Returns an image descriptor for the image file at the given
+ * plug-in relative path
+ *
+ * @param path the path
+ * @return the image descriptor
+ */
+ public static ImageDescriptor getImageDescriptor(String path) {
+ return imageDescriptorFromPlugin(PLUGIN_ID, path);
+ }
+
+ @Override
+ protected void initializeImageRegistry(ImageRegistry reg) {
+ super.initializeImageRegistry(reg);
+ reg.put(IMG_ODE, getImageDescriptor("icons/obj16/ode.gif")); //$NON-NLS-1$
+ reg.put(IMG_CHECKED, getImageDescriptor("icons/obj16/checked.gif"));
//$NON-NLS-1$
+ reg.put(IMG_UNCHECKED, getImageDescriptor("icons/obj16/unchecked.gif"));
//$NON-NLS-1$
+ }
+
+
+}
Added:
workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/editors/ODEDeployMultiPageEditor.java
===================================================================
---
workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/editors/ODEDeployMultiPageEditor.java
(rev 0)
+++
workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/editors/ODEDeployMultiPageEditor.java 2011-02-17
22:22:01 UTC (rev 29205)
@@ -0,0 +1,282 @@
+/*******************************************************************************
+ * Copyright (c) 2008 IBM Corporation, University of Stuttgart (IAAS) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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:
+ * IBM Corporation, University of Stuttgart (IAAS) - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.bpel.apache.ode.deploy.ui.editors;
+
+import java.io.IOException;
+import java.util.Collections;
+import java.util.EventObject;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Vector;
+
+import org.eclipse.bpel.apache.ode.deploy.model.dd.DocumentRoot;
+import org.eclipse.bpel.apache.ode.deploy.model.dd.ProcessType;
+import org.eclipse.bpel.apache.ode.deploy.model.dd.TDeployment;
+import org.eclipse.bpel.apache.ode.deploy.model.dd.util.ddResourceFactoryImpl;
+import org.eclipse.bpel.apache.ode.deploy.ui.pages.ProcessPage;
+import org.eclipse.bpel.apache.ode.deploy.ui.util.DeployUtils;
+import org.eclipse.bpel.model.BPELFactory;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceVisitor;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.emf.common.command.BasicCommandStack;
+import org.eclipse.emf.common.command.CommandStackListener;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.edit.domain.IEditingDomainProvider;
+import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
+import org.eclipse.emf.edit.ui.util.EditUIUtil;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.IFileEditorInput;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.forms.editor.FormEditor;
+
+/**
+ * A multipage editor for Apache ODE deployment descriptors.
+ *
+ * @author Tammo van Lessen (IAAS)
+ * @author Simon Moser (IBM)
+ */
+public class ODEDeployMultiPageEditor extends FormEditor implements
+ IEditingDomainProvider {
+
+ // Display this in title if no BPEL process files are found in current directory
+ private final static String NO_PROCESSES_FOUND = " *** No Processes Found ***
";
+ private boolean readOnly = false;
+ //
https://jira.jboss.org/jira/browse/JBIDE-6230
+ // if BPEL processes were added or deleted, DD model is not in sync and needs to be
saved
+ private boolean modelInSync = true;
+ protected TDeployment deployDescriptor = null;
+
+ protected AdapterFactoryEditingDomain editingDomain;
+ protected ComposedAdapterFactory adapterFactory;
+
+ /**
+ * Creates a multi-page editor example.
+ */
+ public ODEDeployMultiPageEditor() {
+ super();
+ initializeEditingDomain();
+ }
+
+ /**
+ * Saves the deployment descriptor
+ */
+ public void doSave(IProgressMonitor monitor) {
+ commitPages(true);
+ saveDeploymentDescriptor();
+ ((BasicCommandStack) editingDomain.getCommandStack()).saveIsDone();
+ modelInSync = true;
+ firePropertyChange(IEditorPart.PROP_DIRTY);
+ }
+
+ /**
+ * SaveAs is not supported.
+ */
+ public void doSaveAs() {
+ throw new UnsupportedOperationException("SaveAs is not allowed.");
//$NON-NLS-1$
+ }
+
+ /**
+ * The implementation of this method checks that the input is an instance of
+ * <code>IFileEditorInput</code> and creates the data model.
+ */
+ public void init(IEditorSite site, IEditorInput editorInput)
+ throws PartInitException {
+ super.init(site, editorInput);
+ setPartName(editorInput.getName());
+
+ if (!(editorInput instanceof IFileEditorInput)) {
+ throw new PartInitException(
+ "Invalid Input: Must be IFileEditorInput"); //$NON-NLS-1$
+ }
+
+ createModel();
+ }
+
+ public boolean isSaveAsAllowed() {
+ return false;
+ }
+
+ public void saveDeploymentDescriptor() {
+ try {
+ //
https://jira.jboss.org/jira/browse/JBIDE-6006
+ // editor will be "read only" if there are no BPEL resources to process
+ if (!readOnly)
+ deployDescriptor.eResource().save(null);
+ } catch (IOException e1) {
+ e1.printStackTrace();
+ }
+ }
+
+ protected org.eclipse.bpel.model.Process loadBPEL(IFile bpelFile) {
+ IPath fullProcessPath = bpelFile.getFullPath();
+ URI uri = URI.createPlatformResourceURI(fullProcessPath.toString(), false);
+ Resource bpelResource = editingDomain.getResourceSet().getResource(uri, true);
+
+ try {
+ bpelResource.load(Collections.EMPTY_MAP);
+ EList<EObject> contents = bpelResource.getContents();
+ if (!contents.isEmpty()) {
+ return (org.eclipse.bpel.model.Process) contents.get(0);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ return null;
+
+ }
+
+ @Override
+ protected void addPages() {
+ try {
+ for (ProcessType pt : deployDescriptor.getProcess()) {
+ addPage(new ProcessPage(this, pt));
+ }
+ } catch (PartInitException e) {
+ // ~
+ }
+ }
+
+ public TDeployment getDeploymentModel() {
+ return deployDescriptor;
+ }
+
+ protected void initializeEditingDomain() {
+ adapterFactory = new ComposedAdapterFactory(
+ ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
+
+ // Create the command stack that will notify this editor as commands are
+ // executed.
+ BasicCommandStack commandStack = new BasicCommandStack();
+
+ // Add a listener to set the most recent command's affected objects to
+ // be the selection of the viewer with focus.
+ commandStack.addCommandStackListener(new CommandStackListener() {
+ public void commandStackChanged(final EventObject event) {
+ getContainer().getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ editorDirtyStateChanged();
+ }
+ });
+ }
+ });
+
+ // Create the editing domain with a special command stack.
+ editingDomain = new AdapterFactoryEditingDomain(adapterFactory,
+ commandStack, new HashMap<Resource, Boolean>());
+ }
+
+ public EditingDomain getEditingDomain() {
+ return editingDomain;
+ }
+
+ @Override
+ public boolean isDirty() {
+ return !readOnly &&
+ (
+ ((BasicCommandStack) editingDomain.getCommandStack()).isSaveNeeded() ||
+ !modelInSync
+ );
+ }
+
+ @Override
+ public void setFocus() {
+ if (getActivePage() != -1 && getControl(getActivePage()) != null) {
+ getControl(getActivePage()).setFocus();
+ }
+ }
+
+ protected void createModel() throws PartInitException {
+ URI resourceURI = EditUIUtil.getURI(getEditorInput());
+ Resource resource = null;
+
+ ddResourceFactoryImpl fac = new ddResourceFactoryImpl();
+ resource = fac.createResource(resourceURI);
+ editingDomain.getResourceSet().getResources().add(resource);
+ try {
+ resource.load(Collections.EMPTY_MAP);
+
+ EList<EObject> contents = resource.getContents();
+ if (!contents.isEmpty() && contents.get(0) instanceof DocumentRoot) {
+ deployDescriptor = ((DocumentRoot) contents.get(0)).getDeploy();
+
+ populateModel();
+ }
+ } catch (CoreException e) {
+ throw new PartInitException(e.getStatus());
+ } catch (IOException e) {
+ throw new PartInitException(e.getMessage(), e);
+ }
+ if (deployDescriptor.getProcess().isEmpty()) {
+ //
https://jira.jboss.org/jira/browse/JBIDE-6006
+ // add a process stub to DD so the editor doesn't crash
+ org.eclipse.bpel.model.Process p = BPELFactory.eINSTANCE.createProcess();
+ p.setName(NO_PROCESSES_FOUND);
+ ProcessType pt = DeployUtils.createProcessStub(p);
+ deployDescriptor.getProcess().add(pt);
+ // set model
+ pt.setModel(p);
+ readOnly = true; // can't save editor anyway
+ modelInSync = true; // so it might as well be in sync
+ }
+ }
+
+ public void populateModel() throws CoreException {
+ final Vector<ProcessType> processesFound = new Vector<ProcessType>();
+ ((IFileEditorInput) getEditorInput()).getFile().getProject().accept(new
IResourceVisitor() {
+ public boolean visit(IResource bpelfile) throws CoreException {
+ //
https://jira.jboss.org/jira/browse/JBIDE-6006
+ if (DeployUtils.isBPELFile(bpelfile)) {
+ org.eclipse.bpel.model.Process p = DeployUtils.loadBPEL((IFile) bpelfile,
editingDomain.getResourceSet());
+ if (p != null) {
+ // add process to DD unless it is not already there.
+ ProcessType pt = DeployUtils.findProcessTypeInDD(p, deployDescriptor);
+ if (pt == null) {
+ pt = DeployUtils.createProcessStub(p);
+ deployDescriptor.getProcess().add(pt);
+ modelInSync = false; // need to do a save
+ }
+ // set model
+ pt.setModel(p);
+ processesFound.add(pt);
+ }
+ }
+ return true;
+ }
+ });
+ //
https://jira.jboss.org/jira/browse/JBIDE-6230
+ // figure out which BPEL processes are missing from the workspace
+ // and remove them from the DD model
+ Vector<ProcessType> processesToDelete = new Vector<ProcessType>();
+ for(ProcessType pt : deployDescriptor.getProcess())
+ {
+ if (!processesFound.contains(pt))
+ processesToDelete.add(pt);
+ }
+ if ( processesToDelete.size()>0)
+ {
+ deployDescriptor.getProcess().removeAll(processesToDelete);
+ modelInSync = false; // need to do a save
+ }
+ }
+}
Added:
workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/editors/ODEDeployMultiPageEditorContributor.java
===================================================================
---
workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/editors/ODEDeployMultiPageEditorContributor.java
(rev 0)
+++
workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/editors/ODEDeployMultiPageEditorContributor.java 2011-02-17
22:22:01 UTC (rev 29205)
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2008 IBM Corporation, University of Stuttgart (IAAS) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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:
+ * IBM Corporation, University of Stuttgart (IAAS) - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.bpel.apache.ode.deploy.ui.editors;
+
+import org.eclipse.emf.edit.ui.action.EditingDomainActionBarContributor;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.IToolBarManager;
+
+/**
+ * No-op editor contributor
+ * @author Tammo van Lessen (IAAS)
+ * @author Simon Moser (IBM)
+ */
+public class ODEDeployMultiPageEditorContributor extends
EditingDomainActionBarContributor {
+
+ public ODEDeployMultiPageEditorContributor() {
+ super();
+ createActions();
+ }
+
+ private void createActions() {
+ // new actions go here
+ }
+
+ public void contributeToMenu(IMenuManager manager) {
+ // contribute here
+ }
+
+ public void contributeToToolBar(IToolBarManager manager) {
+ // contribute here
+ }
+}
Added:
workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/pages/ProcessPage.java
===================================================================
---
workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/pages/ProcessPage.java
(rev 0)
+++
workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/pages/ProcessPage.java 2011-02-17
22:22:01 UTC (rev 29205)
@@ -0,0 +1,1007 @@
+/*******************************************************************************
+ * Copyright (c) 2008 IBM Corporation, University of Stuttgart (IAAS) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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:
+ * IBM Corporation, University of Stuttgart (IAAS) - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.bpel.apache.ode.deploy.ui.pages;
+
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.wsdl.Binding;
+import javax.xml.namespace.QName;
+
+import org.eclipse.bpel.apache.ode.deploy.model.dd.GenerateType;
+import org.eclipse.bpel.apache.ode.deploy.model.dd.ProcessType;
+import org.eclipse.bpel.apache.ode.deploy.model.dd.TInvoke;
+import org.eclipse.bpel.apache.ode.deploy.model.dd.TProcessEvents;
+import org.eclipse.bpel.apache.ode.deploy.model.dd.TProvide;
+import org.eclipse.bpel.apache.ode.deploy.model.dd.TScopeEvents;
+import org.eclipse.bpel.apache.ode.deploy.model.dd.TService;
+import org.eclipse.bpel.apache.ode.deploy.model.dd.ddFactory;
+import org.eclipse.bpel.apache.ode.deploy.model.dd.ddPackage;
+import org.eclipse.bpel.apache.ode.deploy.ui.Activator;
+import org.eclipse.bpel.apache.ode.deploy.ui.editors.ODEDeployMultiPageEditor;
+import org.eclipse.bpel.apache.ode.deploy.ui.util.DeployResourceSetImpl;
+import org.eclipse.bpel.apache.ode.deploy.ui.util.DeployUtils;
+import org.eclipse.bpel.model.BPELFactory;
+import org.eclipse.bpel.model.PartnerLink;
+import org.eclipse.bpel.model.PartnerLinks;
+import org.eclipse.bpel.model.Process;
+import org.eclipse.bpel.model.Scope;
+import org.eclipse.bpel.ui.BPELMultipageEditorPart;
+import org.eclipse.bpel.ui.BPELUIPlugin;
+import org.eclipse.bpel.ui.IBPELUIConstants;
+import org.eclipse.bpel.ui.util.BPELUtil;
+import org.eclipse.bpel.ui.util.IModelVisitor;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceChangeEvent;
+import org.eclipse.core.resources.IResourceChangeListener;
+import org.eclipse.core.resources.IResourceDelta;
+import org.eclipse.core.resources.IResourceDeltaVisitor;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.command.CompoundCommand;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.emf.edit.command.AddCommand;
+import org.eclipse.emf.edit.command.RemoveCommand;
+import org.eclipse.emf.edit.command.SetCommand;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IMessageProvider;
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.jface.viewers.CheckboxCellEditor;
+import org.eclipse.jface.viewers.CheckboxTableViewer;
+import org.eclipse.jface.viewers.ColumnLabelProvider;
+import org.eclipse.jface.viewers.EditingSupport;
+import org.eclipse.jface.viewers.ICellModifier;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.OwnerDrawLabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TableViewerColumn;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.layout.RowLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Item;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.ui.IFileEditorInput;
+import org.eclipse.ui.forms.IManagedForm;
+import org.eclipse.ui.forms.SectionPart;
+import org.eclipse.ui.forms.editor.FormEditor;
+import org.eclipse.ui.forms.editor.FormPage;
+import org.eclipse.ui.forms.events.HyperlinkAdapter;
+import org.eclipse.ui.forms.events.HyperlinkEvent;
+import org.eclipse.ui.forms.widgets.Form;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.ScrolledForm;
+import org.eclipse.ui.forms.widgets.Section;
+import org.eclipse.wst.wsdl.Port;
+import org.eclipse.wst.wsdl.Service;
+
+/**
+ * Main process page, renders UI for all relevant deployment settings.
+ *
+ * @author Simon Moser (IBM)
+ * @author Tammo van Lessen (IAAS)
+ */
+public class ProcessPage extends FormPage implements IResourceChangeListener {
+ public static final int PARTNER_LINK_COLUMN = 0;
+ public static final int PORT_COLUMN = 1;
+ public static final int SERVICE_COLUMN = 2;
+ public static final int BINDING_COLUMN = 3;
+
+ public static final String INSTANCE_LIFECYCLE_NAME = "instanceLifecycle";
//$NON-NLS-1$
+ public static final String ACTIVITY_LIFECYCLE_NAME = "activityLifecycle";
//$NON-NLS-1$
+ public static final String DATA_HANDLING_NAME = "dataHandling"; //$NON-NLS-1$
+ public static final String SCOPE_HANDLING_NAME = "scopeHandling";
//$NON-NLS-1$
+ public static final String CORRELATION_NAME = "correlation"; //$NON-NLS-1$
+
+ public static final String[] PROCESS_STATUS = new String[] {"activated",
"deactivated", "retired"};
+ public static final int STATUS_ACTIVATED = 0;
+ public static final int STATUS_DEACTIVATED = 1;
+ public static final int STATUS_RETIRED = 2;
+
+ public static final Map<String, String> eventNameById = new HashMap<String,
String>();
+ static {
+ eventNameById.put(INSTANCE_LIFECYCLE_NAME, "Instance life cycle");
+ eventNameById.put(ACTIVITY_LIFECYCLE_NAME, "Activity life cycle");
+ eventNameById.put(DATA_HANDLING_NAME, "Data handling");
+ eventNameById.put(SCOPE_HANDLING_NAME, "Scope handling");
+ eventNameById.put(CORRELATION_NAME, "Correlation");
+ }
+
+ protected ODEDeployMultiPageEditor editor;
+ protected ProcessType processType;
+ protected FormToolkit toolkit;
+ private EditingDomain domain;
+ private TableViewer scopeTableViewer;
+ private Form mainform;
+ //
https://jira.jboss.org/browse/JBIDE-6786
+ // we will manage this for ServiceCellEditor and PortTypeLabelProvider
+ private ResourceSetImpl resourceSet = null;
+
+ public ProcessPage(FormEditor editor, ProcessType pt) {
+ super(editor, "ODED" + pt.getName().toString(), pt.getName().getLocalPart());
//$NON-NLS-1$
+ this.processType = pt;
+ this.editor = (ODEDeployMultiPageEditor)editor;
+
+ ResourcesPlugin.getWorkspace().addResourceChangeListener(this,
IResourceChangeEvent.POST_CHANGE);
+
+ this.domain = this.editor.getEditingDomain();
+ //
https://jira.jboss.org/browse/JBIDE-6786
+ resourceSet = new DeployResourceSetImpl();
+ }
+
+ @Override
+ protected void createFormContent(IManagedForm managedForm) {
+ toolkit = managedForm.getToolkit();
+ ScrolledForm form = managedForm.getForm();
+ form.setText(MessageFormat.format("Process {0} - {1}",
processType.getName().getLocalPart(), processType.getName().getNamespaceURI()));
+ toolkit.decorateFormHeading(form.getForm());
+ mainform = form.getForm();
+ mainform.addMessageHyperlinkListener(new HyperlinkAdapter() {
+ @Override
+ public void linkActivated(HyperlinkEvent e) {
+ refreshModel();
+ }
+
+ });
+
+ form.setImage(BPELUIPlugin.INSTANCE.getImage(IBPELUIConstants.ICON_PROCESS_32));
+
+ RowLayout layout = new RowLayout();
+ layout.wrap = false;
+ layout.pack = true;
+ layout.justify = false;
+ layout.fill = true;
+ layout.type = SWT.VERTICAL;
+ layout.marginLeft = 5;
+ layout.marginTop = 5;
+ layout.marginRight = 5;
+ layout.marginBottom = 5;
+ layout.spacing = 5;
+
+ form.getBody().setLayout(layout);
+ Dialog.applyDialogFont(form.getBody());
+
+ Composite client = createSection(form.getBody(), "General", null, 1);
+
+ final Composite statusArea = new Composite(client, SWT.NONE);
+ statusArea.setLayout(new GridLayout(2, false));
+ toolkit.createLabel(statusArea, "This process is ");
+ final Combo comboStatus = new Combo(statusArea, SWT.READ_ONLY);
+ toolkit.adapt(comboStatus);
+ comboStatus.setItems(PROCESS_STATUS);
+ if (processType.isActive()) {
+ comboStatus.select(STATUS_ACTIVATED);
+ } else {
+ if (processType.isRetired()) {
+ comboStatus.select(STATUS_RETIRED);
+ } else {
+ comboStatus.select(STATUS_DEACTIVATED);
+ }
+ }
+ comboStatus.addSelectionListener(new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ Command setActiveCommand = SetCommand.create(domain, processType,
ddPackage.eINSTANCE.getProcessType_Active(), comboStatus.getSelectionIndex() ==
STATUS_ACTIVATED);
+ Command setRetiredCommand = SetCommand.create(domain, processType,
ddPackage.eINSTANCE.getProcessType_Retired(), comboStatus.getSelectionIndex() ==
STATUS_RETIRED);
+ CompoundCommand compoundCommand = new CompoundCommand();
+ compoundCommand.append(setActiveCommand);
+ compoundCommand.append(setRetiredCommand);
+ domain.getCommandStack().execute(compoundCommand);
+ }
+ });
+
+ final Button btnRunInMemory = toolkit.createButton(client, "Run this process in
memory", SWT.CHECK);
+ btnRunInMemory.setToolTipText("Define a process as being executed only in-memory.
This gives better performance, but the processes cannot be queried by using the ODE
Management API.");
+ btnRunInMemory.setSelection(processType.isInMemory());
+ btnRunInMemory.addSelectionListener(new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ Command setInMemoryCommand = SetCommand.create(domain, processType,
ddPackage.eINSTANCE.getProcessType_InMemory(), btnRunInMemory.getSelection());
+ domain.getCommandStack().execute(setInMemoryCommand);
+ }
+
+ });
+
+ String serviceDescription = "The table contains interfaces the process provides.
Specify the service, port and binding you want to use for each PartnerLink listed";
+ createInterfaceWidget(form.getBody(), processType, managedForm, "Inbound
Interfaces (Services)", serviceDescription, true);
+ String invokeDescription = "The table contains interfaces the process invokes.
Specify the service, port and binding you want to use for each PartnerLink listed";
+ createInterfaceWidget(form.getBody(), processType, managedForm, "Outbound
Interfaces (Invokes)", invokeDescription, false);
+
+ createProcessMonitoringSection(form.getBody());
+ createScopeMonitoringSection(form.getBody());
+
+ form.reflow(true);
+ }
+
+ private void createInterfaceWidget(Composite fClient, ProcessType current, final
IManagedForm managedForm, String title, String description, boolean isInbound) {
+
+ // Set column names
+ String[] columnNames = new String[] {
+ //"Partner Link (click on entry to open definition)",
+ "Partner Link",
+ "Associated Port",
+ "Related Service",
+ "Binding Used"
+ };
+
+ Section section = toolkit.createSection(fClient, Section.TWISTIE | Section.EXPANDED |
Section.DESCRIPTION | Section.TITLE_BAR);
+ section.setText(title);
+ section.setDescription(description);
+ section.marginHeight = 5;
+
+ Composite client = toolkit.createComposite(section, SWT.WRAP);
+ GridLayout layout = new GridLayout();
+ layout.marginWidth = 2;
+ layout.marginHeight = 2;
+ client.setLayout(layout);
+ final Table t = toolkit.createTable(client, SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL |
SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.HIDE_SELECTION);
+
+ TableColumn tc1 = new TableColumn(t, SWT.CENTER);
+ tc1.setText(columnNames[0]);
+
+ TableColumn tc2 = new TableColumn(t, SWT.CENTER);
+ tc2.setText(columnNames[1]);
+
+ TableColumn tc3 = new TableColumn(t, SWT.CENTER);
+ tc3.setText(columnNames[2]);
+
+ TableColumn tc4 = new TableColumn(t, SWT.CENTER);
+ tc4.setText(columnNames[3]);
+
+ t.setHeaderVisible(true);
+ t.setLinesVisible(true);
+
+ GridData gd = new GridData(GridData.FILL_BOTH);
+ t.setLayoutData(gd);
+ toolkit.paintBordersFor(client);
+
+ section.setClient(client);
+ final SectionPart spart = new SectionPart(section);
+ managedForm.addPart(spart);
+
+
+ URI deployDescriptorURI = current.eResource().getURI();
+ IFile ddFile = DeployUtils.getIFileForURI(deployDescriptorURI);
+
+ TableViewer viewer = new TableViewer(t);
+ viewer.setUseHashlookup(true);
+ viewer.setColumnProperties(columnNames);
+ viewer.setContentProvider(new PortTypeContentProvider(isInbound));
+ //
https://jira.jboss.org/browse/JBIDE-6786
+ viewer.setLabelProvider(new PortTypeLabelProvider(ddFile.getProject(), resourceSet));
+ viewer.setInput(current);
+
+ for (int i = 0, n = t.getColumnCount(); i < n; i++) {
+ t.getColumn(i).pack();
+ }
+
+ // Create the cell editors
+ CellEditor[] editors = new CellEditor[columnNames.length];
+
+ // TODO: Column 1 : HyperLink Listener
+// final TableEditor editor = new TableEditor(t);
+// editor.horizontalAlignment = SWT.LEFT;
+// editor.grabHorizontal = true;
+// IWorkbenchPage wbPage= getEditor().getSite().getPage();
+// InterfaceTableListener tableListener = new InterfaceTableListener(current, t, editor,
toolkit, wbPage, isInbound);
+// t.addListener(SWT.MouseDown, tableListener);
+
+ // Column 2 : Associate Service (ComboBox)
+ //
https://jira.jboss.org/browse/JBIDE-6786
+ ServiceCellEditor sCellEditor = new ServiceCellEditor(t, ddFile.getProject(),
resourceSet);
+ editors[1] = sCellEditor;
+
+ // Assign the cell editors to the viewer
+ viewer.setCellEditors(editors);
+
+ // Set the cell modifier for the viewer
+ viewer.setCellModifier(new InterfaceWidgetCellModifier(viewer, columnNames));
+
+ }
+
+
+ class InterfaceWidgetCellModifier implements ICellModifier {
+ private Viewer viewer;
+ private String[] columnNames;
+
+ public InterfaceWidgetCellModifier(Viewer viewer, String[] columnNames) {
+ this.viewer = viewer;
+ this.columnNames = columnNames;
+ }
+
+ public boolean canModify(Object element, String property) {
+ if (property.equals(columnNames[1])) {
+ return true;
+ }
+ return false;
+ }
+
+ public Object getValue(Object element, String property) {
+ if (!property.equals(columnNames[1])) {
+ return null;
+ }
+ if (element instanceof TProvide) {
+ TProvide provide = (TProvide) element;
+ return provide.getService();
+ }
+ else if (element instanceof TInvoke) {
+ TInvoke invoke = (TInvoke) element;
+ return invoke.getService();
+ }
+ else {
+ return null;
+ }
+
+ }
+
+ public void modify(Object element, String property, Object value) {
+ assert element instanceof Item;
+ if (!property.equals(columnNames[1])) {
+ return;
+ }
+
+ Item item = (Item) element;
+ Object o = item.getData();
+ if (o instanceof TProvide) {
+ TProvide provide = (TProvide) o;
+
+ TService service = provide.getService();
+ if (service == null) {
+ service = ddFactory.eINSTANCE.createTService();
+ provide.setService(service);
+ }
+
+ if (value == null) {
+ Command unsetServiceCommand = SetCommand.create(domain, service,
ddPackage.eINSTANCE.getTService_Name(), SetCommand.UNSET_VALUE);
+ Command unsetPortCommand = SetCommand.create(domain, service,
ddPackage.eINSTANCE.getTService_Port(), SetCommand.UNSET_VALUE);
+ CompoundCommand compoundCommand = new CompoundCommand();
+ compoundCommand.append(unsetServiceCommand);
+ compoundCommand.append(unsetPortCommand);
+ domain.getCommandStack().execute(compoundCommand);
+ }
+ else {
+ Port port = (Port) value;
+ String portName = port.getName();
+
+ Command setPortCommand = SetCommand.create(domain, service,
ddPackage.eINSTANCE.getTService_Port(), portName);
+
+ Service wsdlService = (Service) port.eContainer();
+ QName qname = wsdlService.getQName();
+ Command setServiceCommand = SetCommand.create(domain, service,
ddPackage.eINSTANCE.getTService_Name(), qname);
+
+
+ CompoundCommand compoundCommand = new CompoundCommand();
+ compoundCommand.append(setServiceCommand);
+ compoundCommand.append(setPortCommand);
+
+ domain.getCommandStack().execute(compoundCommand);
+ }
+ }
+ else if (o instanceof TInvoke) {
+ TInvoke invoke = (TInvoke) o;
+
+ TService service = invoke.getService();
+ if (service == null) {
+ service = ddFactory.eINSTANCE.createTService();
+ invoke.setService(service);
+ }
+
+ if (value == null) {
+ Command unsetServiceCommand = SetCommand.create(domain, service,
ddPackage.eINSTANCE.getTService_Name(), SetCommand.UNSET_VALUE);
+ Command unsetPortCommand = SetCommand.create(domain, service,
ddPackage.eINSTANCE.getTService_Port(), SetCommand.UNSET_VALUE);
+ CompoundCommand compoundCommand = new CompoundCommand();
+ compoundCommand.append(unsetServiceCommand);
+ compoundCommand.append(unsetPortCommand);
+ domain.getCommandStack().execute(compoundCommand);
+ }
+ else {
+ Port port = (Port) value;
+ String portName = port.getName();
+
+ Command setPortCommand = SetCommand.create(domain, service,
ddPackage.eINSTANCE.getTService_Port(), portName);
+
+ Service wsdlService = (Service) port.eContainer();
+ QName qname = wsdlService.getQName();
+ Command setServiceCommand = SetCommand.create(domain, service,
ddPackage.eINSTANCE.getTService_Name(), qname);
+
+
+ CompoundCommand compoundCommand = new CompoundCommand();
+ compoundCommand.append(setServiceCommand);
+ compoundCommand.append(setPortCommand);
+
+ domain.getCommandStack().execute(compoundCommand);
+ }
+ }
+
+ viewer.refresh();
+ }
+
+ }
+
+ private Composite createSection(Composite parent, String title, String desc, int
numColumns) {
+
+ Section section = null;
+ if (desc != null) {
+ section = toolkit.createSection(parent, Section.TWISTIE | Section.TITLE_BAR |
Section.DESCRIPTION | Section.EXPANDED);
+ section.setDescription(desc);
+ } else {
+ section = toolkit.createSection(parent, Section.TWISTIE | Section.TITLE_BAR |
Section.EXPANDED);
+ }
+ section.setText(title);
+
+ Composite client = toolkit.createComposite(section);
+ GridLayout layout = new GridLayout();
+ layout.marginWidth = layout.marginHeight = 0;
+ layout.numColumns = numColumns;
+ client.setLayout(layout);
+ section.setClient(client);
+
+ return client;
+ }
+
+ private void createProcessMonitoringSection(Composite parent) {
+ final Composite client = createSection(parent, "Process-level Monitoring
Events", null, 2);
+ final Composite group = toolkit.createComposite(client);
+ group.setLayout(new RowLayout(SWT.VERTICAL));
+ GridData gd = new GridData();
+ gd.verticalAlignment = SWT.BEGINNING;
+ gd.horizontalIndent = 5;
+ group.setLayoutData(gd);
+
+ final Button btnNone = toolkit.createButton(group, "None", SWT.RADIO);
+ final Button btnAll = toolkit.createButton(group, "All", SWT.RADIO);
+ final Button btnSelected = toolkit.createButton(group, "Selected",
SWT.RADIO);
+
+ Composite wrapper = toolkit.createComposite(client);
+ wrapper.setLayout(new RowLayout());
+ final CheckboxTableViewer ctv = CheckboxTableViewer.newCheckList(wrapper, SWT.NONE);
+ wrapper.setLayoutData(gd);
+ toolkit.paintBordersFor(wrapper);
+
+ ctv.setContentProvider(new ArrayContentProvider());
+ ctv.setLabelProvider(new LabelProvider() {
+
+ @Override
+ public String getText(Object element) {
+ return eventNameById.get(element);
+ }
+
+ });
+ ctv.setInput(new String[] {INSTANCE_LIFECYCLE_NAME, ACTIVITY_LIFECYCLE_NAME,
+ DATA_HANDLING_NAME, SCOPE_HANDLING_NAME, CORRELATION_NAME});
+
+ //create defaulting process event settings
+ if (processType.getProcessEvents() == null) {
+ TProcessEvents pe = ddFactory.eINSTANCE.createTProcessEvents();
+ pe.setGenerate(GenerateType.ALL);
+ processType.setProcessEvents(pe);
+ }
+
+ if (processType.getProcessEvents().isSetGenerate()) {
+ switch (processType.getProcessEvents().getGenerate()) {
+ case ALL:
+ btnAll.setSelection(true);
+ ctv.getControl().setEnabled(false);
+ break;
+ case NONE:
+ btnNone.setSelection(true);
+ ctv.getControl().setEnabled(false);
+ break;
+ }
+ } else {
+ btnSelected.setSelection(true);
+ ctv.getControl().setEnabled(true);
+ }
+
+ final SelectionAdapter sa = new SelectionAdapter(){
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ if (btnAll == e.getSource()) {
+ ctv.getControl().setEnabled(false);
+ Command command = SetCommand.create(domain, processType.getProcessEvents(),
ddPackage.eINSTANCE.getTProcessEvents_Generate(), GenerateType.ALL);
+ domain.getCommandStack().execute(command);
+ } else if (btnNone == e.getSource()) {
+ ctv.getControl().setEnabled(false);
+ Command command = SetCommand.create(domain, processType.getProcessEvents(),
ddPackage.eINSTANCE.getTProcessEvents_Generate(), GenerateType.NONE);
+ domain.getCommandStack().execute(command);
+ } else {
+ ctv.getControl().setEnabled(true);
+ Command command = SetCommand.create(domain, processType.getProcessEvents(),
ddPackage.eINSTANCE.getTProcessEvents_Generate(), SetCommand.UNSET_VALUE);
+ domain.getCommandStack().execute(command);
+ }
+ }
+ };
+
+ btnAll.addSelectionListener(sa);
+ btnNone.addSelectionListener(sa);
+ btnSelected.addSelectionListener(sa);
+
+ ctv.setCheckedElements(processType.getProcessEvents().getEnableEvent().toArray());
+ final ISelectionChangedListener scl = new ISelectionChangedListener() {
+
+ public void selectionChanged(SelectionChangedEvent event) {
+ Command command = SetCommand.create(domain, processType.getProcessEvents(),
ddPackage.eINSTANCE.getTEnableEventList_EnableEvent(),
Arrays.asList(ctv.getCheckedElements()));
+ domain.getCommandStack().execute(command);
+ }
+
+ };
+
+ ctv.addSelectionChangedListener(scl);
+ }
+
+ private void createScopeMonitoringSection(Composite parent) {
+ Composite client = createSection(parent, "Scope-level Monitoring Events",
null, 1);
+
+ scopeTableViewer = new TableViewer(toolkit.createTable(client, SWT.SINGLE | SWT.BORDER
| SWT.H_SCROLL | SWT.V_SCROLL |
+ SWT.FULL_SELECTION | SWT.HIDE_SELECTION));
+ Table table = scopeTableViewer.getTable();
+ scopeTableViewer.setContentProvider(new ScopeMonitoringEventContentProvider());
+ scopeTableViewer.setUseHashlookup(true);
+ TableViewerColumn column = new TableViewerColumn(scopeTableViewer, SWT.NONE);
+ column.getColumn().setText("Scope");
+ column.setLabelProvider(new ColumnLabelProvider() {
+
+ @Override
+ public String getText(Object element) {
+ return ((Scope)element).getName();
+ }
+
+ @Override
+ public Image getImage(Object element) {
+ return BPELUIPlugin.INSTANCE.getImage(IBPELUIConstants.ICON_SCOPE_16);
+ }
+ });
+
+ String[] columns = new String[] {INSTANCE_LIFECYCLE_NAME, ACTIVITY_LIFECYCLE_NAME,
DATA_HANDLING_NAME, SCOPE_HANDLING_NAME, CORRELATION_NAME};
+ for (String columnId : columns) {
+ column = new TableViewerColumn(scopeTableViewer, SWT.NONE);
+ column.getColumn().setText(eventNameById.get(columnId));
+ column.setLabelProvider(new ScopeEventCheckboxColumnLabelProvider(columnId));
+ column.setEditingSupport(new ScopeEventEditingSupport(scopeTableViewer, columnId));
+ }
+
+ OwnerDrawLabelProvider.setUpOwnerDraw(scopeTableViewer);
+
+ table.setHeaderVisible(true);
+ table.setLinesVisible(true);
+
+ scopeTableViewer.setInput(processType);
+
+ for (int i = 0, n = table.getColumnCount(); i < n; i++) {
+ table.getColumn(i).pack();
+ }
+ }
+
+ class PortTypeLabelProvider extends LabelProvider implements ITableLabelProvider {
+
+ protected IProject bpelProject = null;
+ protected ResourceSetImpl resourceSet = null;
+
+ public PortTypeLabelProvider(IProject bpelProject, ResourceSetImpl resourceSet){
+ this.bpelProject = bpelProject;
+ //
https://jira.jboss.org/browse/JBIDE-6786
+ // ProcessPage allocates the resourceSet - this should never be null!
+ if (resourceSet != null) {
+ this.resourceSet = resourceSet;
+ }
+ else {
+ this.resourceSet = new ResourceSetImpl();
+ }
+ }
+
+ public String getColumnText(Object obj, int index) {
+
+ if (obj instanceof TProvide && index == PARTNER_LINK_COLUMN){
+ TProvide current = (TProvide) obj;
+ return current.getPartnerLink();
+ }
+ else if (obj instanceof TProvide && index == SERVICE_COLUMN){
+ TProvide current = (TProvide) obj;
+ TService service = current.getService();
+ if (service != null) {
+ QName serviceQName = service.getName();
+ if (serviceQName != null) {
+ return serviceQName.toString();
+ }
+ }
+ }
+ else if (obj instanceof TProvide && index == PORT_COLUMN){
+ TProvide current = (TProvide) obj;
+ TService service = current.getService();
+ if (service != null) {
+ String portName = service.getPort();
+ if (portName != null) {
+ return portName;
+ }
+ }
+ }
+ else if (obj instanceof TProvide && index == BINDING_COLUMN){
+ TProvide current = (TProvide) obj;
+ TService service = current.getService();
+ if (service != null) {
+ String portName = service.getPort();
+ if (portName != null) {
+ Port port = DeployUtils.findPortByName(portName, this.bpelProject,
this.resourceSet);
+ if (port != null) {
+ Binding binding = port.getBinding();
+ QName bindingQName = binding.getQName();
+ if (bindingQName != null) {
+ return bindingQName.getLocalPart();
+ }
+ }
+ }
+ }
+ }
+
+ if (obj instanceof TInvoke && index == PARTNER_LINK_COLUMN){
+ TInvoke current = (TInvoke) obj;
+ return current.getPartnerLink();
+ }
+ else if (obj instanceof TInvoke && index == SERVICE_COLUMN){
+ TInvoke current = (TInvoke) obj;
+ TService service = current.getService();
+ if (service != null) {
+ QName serviceQName = service.getName();
+ if (serviceQName != null) {
+ return serviceQName.toString();
+ }
+ }
+ }
+ else if (obj instanceof TInvoke && index == PORT_COLUMN){
+ TInvoke current = (TInvoke) obj;
+ TService service = current.getService();
+ if (service != null) {
+ String portName = service.getPort();
+ if (portName != null) {
+ return portName;
+ }
+ }
+ }
+ else if (obj instanceof TInvoke && index == BINDING_COLUMN){
+ TInvoke current = (TInvoke) obj;
+ TService service = current.getService();
+ if (service != null) {
+ String portName = service.getPort();
+ if (portName != null) {
+ Port port = DeployUtils.findPortByName(portName, this.bpelProject,
this.resourceSet);
+ if (port != null) {
+ Binding binding = port.getBinding();
+ QName bindingQName = binding.getQName();
+ if (bindingQName != null) {
+ return bindingQName.getLocalPart();
+ }
+ }
+ }
+ }
+ }
+
+ return DeployUtils.NONE_STRING;
+ }
+
+ public Image getColumnImage(Object obj, int index) {
+ return null;
+ }
+ }
+
+ class PortTypeContentProvider implements IStructuredContentProvider {
+
+ protected boolean forInbound = false;
+
+ public PortTypeContentProvider(boolean bForInbound){
+ forInbound = bForInbound;
+ }
+
+ public Object[] getElements(Object inputElement) {
+
+ try
+ {
+ if (inputElement instanceof ProcessType){
+ ProcessType type = (ProcessType) inputElement;
+ if (forInbound){
+ EList<TProvide> provide = type.getProvide();
+
+ if (provide.isEmpty()){
+ Process process = type.getModel();
+ PartnerLinks pls = process.getPartnerLinks();
+ EList<PartnerLink> plList = pls.getChildren();
+ for (Iterator<PartnerLink> iterator = plList.iterator();
iterator.hasNext();) {
+ PartnerLink current = (PartnerLink) iterator.next();
+ if (current.getMyRole() != null){
+ TProvide currentProvide = ddFactory.eINSTANCE.createTProvide();
+ currentProvide.setPartnerLink(current.getName());
+ provide.add(currentProvide);
+ }
+ }
+ }
+
+ return provide.toArray();
+ }
+ else {
+ EList<TInvoke> invoke = type.getInvoke();
+
+ if (invoke.isEmpty()){
+ Process process = type.getModel();
+ PartnerLinks pls = process.getPartnerLinks();
+ if (pls != null) {
+ EList<PartnerLink> plList = pls.getChildren();
+ for (Iterator<PartnerLink> iterator = plList.iterator(); iterator
+ .hasNext();) {
+ PartnerLink current = (PartnerLink) iterator
+ .next();
+ if (current.getPartnerRole() != null) {
+ TInvoke currentInvoke = ddFactory.eINSTANCE
+ .createTInvoke();
+ currentInvoke.setPartnerLink(current
+ .getName());
+ invoke.add(currentInvoke);
+ }
+ }
+ }
+ }
+
+ return invoke.toArray();
+ }
+ }
+ }
+ catch(NullPointerException ex)
+ {
+ }
+ //
https://jira.jboss.org/jira/browse/JBIDE-6006
+ // create a stub invoke so the editor doesn't crash
+ return new TInvoke[] { ddFactory.eINSTANCE.createTInvoke() };
+ }
+
+ public void dispose() {
+ }
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
+ }
+
+ class ScopeMonitoringEventContentProvider implements IStructuredContentProvider {
+
+ public Object[] getElements(Object inputElement) {
+ final List<Object> scopes = new ArrayList<Object>();
+
+ BPELUtil.visitModelDepthFirst(processType.getModel(), new IModelVisitor() {
+ public boolean visit(Object modelObject) {
+ if ((modelObject instanceof Scope) &&
+ (((Scope)modelObject).getName() != null)) {
+ scopes.add(modelObject);
+ }
+ return true;
+ }
+ });
+
+ return scopes.toArray();
+ }
+
+ public void dispose() {}
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
+
+ }
+
+ protected void refreshModel() {
+
+ try {
+ editor.populateModel();
+ scopeTableViewer.refresh();
+ mainform.setMessage(null);
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public void resourceChanged(IResourceChangeEvent event) {
+
+ IResourceDeltaVisitor rdv = new IResourceDeltaVisitor() {
+ public boolean visit(IResourceDelta delta) {
+ IResource res = delta.getResource();
+ //
https://jira.jboss.org/jira/browse/JBIDE-6006
+ if (DeployUtils.isBPELFile(res)) {
+ Display.getDefault().syncExec(new Runnable() {
+ public void run() {
+ mainform.setMessage("Associated BPEL and/or WSDL has been changed, click to
update!", IMessageProvider.WARNING);
+ }
+ });
+ }
+ //
https://jira.jboss.org/browse/JBIDE-7477
+ // close editor when file is deleted
+ else {
+ IFile editorFile = ((IFileEditorInput)getEditorInput()).getFile();
+ IResource target = delta.getResource();
+ if (delta.getKind() == IResourceDelta.REMOVED &&
+ target instanceof IFile &&
+ editorFile.equals(target))
+ {
+ // Close the editor if its input file has been moved or deleted.
+ Display display = getSite().getShell().getDisplay();
+ display.asyncExec(new Runnable() {
+ public void run() {
+ getSite().getPage().closeEditor(ProcessPage.this.editor, false);
+ }
+ });
+ }
+ }
+
+ return true; // visit the children
+ }
+ };
+ try {
+ event.getDelta().accept(rdv);
+ } catch (CoreException e) {
+ //ignore
+ }
+ }
+
+ @Override
+ public void dispose() {
+ ResourcesPlugin.getWorkspace().removeResourceChangeListener(this);
+ super.dispose();
+ }
+
+ class ScopeEventEditingSupport extends EditingSupport {
+
+ private String eventType;
+ private CheckboxCellEditor checkboxCellEditor;
+ public ScopeEventEditingSupport(TableViewer viewer, String eventType) {
+ super(viewer);
+ this.eventType = eventType;
+ this.checkboxCellEditor = new CheckboxCellEditor(viewer.getTable());
+ }
+
+ @Override
+ protected boolean canEdit(Object element) {
+ String scName = ((Scope)element).getName();
+ return scName != null && !"".equals(scName); //$NON-NLS-1$
+ }
+
+ @Override
+ protected CellEditor getCellEditor(Object element) {
+ return checkboxCellEditor;
+ }
+
+ @Override
+ protected Object getValue(Object element) {
+ String scName = ((Scope)element).getName();
+ for (TScopeEvents se : processType.getProcessEvents().getScopeEvents()) {
+ if (scName.equals(se.getName()) &&
+ se.getEnableEvent().contains(eventType)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ protected void setValue(Object element, Object value) {
+ String scName = ((Scope)element).getName();
+ TScopeEvents match = null;
+ for (TScopeEvents se : processType.getProcessEvents().getScopeEvents()) {
+ if (scName.equals(se.getName())) {
+ match = se;
+ break;
+ }
+ }
+
+ if (match == null) {
+ match = ddFactory.eINSTANCE.createTScopeEvents();
+ match.setName(scName);
+ processType.getProcessEvents().getScopeEvents().add(match);
+ }
+
+ if (((Boolean)value).booleanValue()) {
+ if (!match.getEnableEvent().contains(eventType)) {
+ Command command = AddCommand.create(domain, match,
ddPackage.eINSTANCE.getTEnableEventList_EnableEvent(), eventType);
+ domain.getCommandStack().execute(command);
+ }
+ } else {
+ Command command = RemoveCommand.create(domain, match,
ddPackage.eINSTANCE.getTEnableEventList_EnableEvent(), eventType);
+ domain.getCommandStack().execute(command);
+ }
+
+ getViewer().refresh();
+ }
+ }
+
+ class ScopeEventCheckboxColumnLabelProvider extends OwnerDrawLabelProvider {
+
+ private String eventType;
+
+ public ScopeEventCheckboxColumnLabelProvider(String eventType) {
+ this.eventType = eventType;
+ }
+
+ protected void measure(Event event, Object element) {
+ Image img = getImage(element);
+ event.setBounds(new Rectangle(event.x, event.y, img.getBounds().width,
+ img.getBounds().height));
+
+ }
+
+ protected void paint(Event event, Object element) {
+
+ Image img = getImage(element);
+
+ if (img != null) {
+ Rectangle bounds = ((TableItem) event.item)
+ .getBounds(event.index);
+ Rectangle imgBounds = img.getBounds();
+ bounds.width /= 2;
+ bounds.width -= imgBounds.width / 2;
+ bounds.height /= 2;
+ bounds.height -= imgBounds.height / 2;
+
+ int x = bounds.width > 0 ? bounds.x + bounds.width : bounds.x;
+ int y = bounds.height > 0 ? bounds.y + bounds.height : bounds.y;
+
+ event.gc.drawImage(img, x, y);
+ }
+ }
+
+
+ public Image getImage(Object element) {
+ if (isChecked(element)) {
+ return Activator.getDefault().getImageRegistry().get(Activator.IMG_CHECKED);
+ } else {
+ return Activator.getDefault().getImageRegistry().get(Activator.IMG_UNCHECKED);
+ }
+ }
+
+ public boolean isChecked(Object element) {
+ String scName = ((Scope)element).getName();
+ for (TScopeEvents se : processType.getProcessEvents().getScopeEvents()) {
+ if (se.getName().equals(scName) &&
+ se.getEnableEvent().contains(eventType)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ }
+
+
+}
\ No newline at end of file
Added:
workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/pages/ServiceCellEditor.java
===================================================================
---
workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/pages/ServiceCellEditor.java
(rev 0)
+++
workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/pages/ServiceCellEditor.java 2011-02-17
22:22:01 UTC (rev 29205)
@@ -0,0 +1,134 @@
+package org.eclipse.bpel.apache.ode.deploy.ui.pages;
+
+/*******************************************************************************
+ * Copyright (c) 2008 IBM Corporation, University of Stuttgart (IAAS) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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:
+ * IBM Corporation, University of Stuttgart (IAAS) - initial API and implementation
+ *******************************************************************************/
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.bpel.apache.ode.deploy.model.dd.TService;
+import org.eclipse.bpel.apache.ode.deploy.ui.util.DeployUtils;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.jface.viewers.ComboBoxCellEditor;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.CCombo;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.wst.wsdl.Definition;
+import org.eclipse.wst.wsdl.Port;
+import org.eclipse.wst.wsdl.Service;
+
+/**
+ * In-place editor for WSDL services in tables.
+ *
+ * @author Simon Moser (IBM)
+ */
+public class ServiceCellEditor extends ComboBoxCellEditor {
+
+ IProject bpelProject = null;
+ ResourceSet resourceSet = null;
+ List<Port> portList = null;
+
+ public ServiceCellEditor(Table parent, IProject bpelProject, ResourceSet resourceSet)
+ {
+ super(parent, new String[]{}, SWT.READ_ONLY);
+ this.bpelProject = bpelProject;
+ if (resourceSet != null) {
+ this.resourceSet = resourceSet;
+ }
+ else {
+ this.resourceSet = new ResourceSetImpl();
+ }
+ }
+
+ @Override
+ protected Object doGetValue() {
+
+ Integer integer = (Integer) super.doGetValue();
+
+ CCombo combo = (CCombo) getControl();
+ String string = combo.getItem(integer.intValue());
+
+ Port port = findPortByName(string);
+
+ return port;
+ }
+
+ private Port findPortByName(String string) {
+
+ for (Iterator<Port> iterator = portList.iterator(); iterator.hasNext();) {
+ Port currentPort = iterator.next();
+ if (currentPort.getName().equals(string)){
+ return currentPort;
+ }
+ }
+
+ return null;
+ }
+
+ @SuppressWarnings("unchecked") //$NON-NLS-1$
+ @Override
+ protected void doSetValue(Object value) {
+
+ List<Service> serviceList = new ArrayList();
+ portList = new ArrayList<Port>();
+
+ //load WSDL's
+ List<Definition> wsdlDefs = DeployUtils.loadAllWSDLFromProject(this.bpelProject,
this.resourceSet);
+ //Assemble All Services from WSDL's
+ for (Iterator<Definition> iterator = wsdlDefs.iterator(); iterator.hasNext();) {
+ Definition current = (Definition) iterator.next();
+ Map services = current.getServices();
+ if (!services.isEmpty()){
+ Collection values = services.values();
+ for (Iterator<Service> iterator2 = values.iterator(); iterator2.hasNext();) {
+ Service name = iterator2.next();
+ serviceList.add(name);
+ }
+ }
+ }
+
+ //now we have all services in a List .. get All Ports from these services
+ for (Iterator<Service> iterator = serviceList.iterator(); iterator.hasNext();) {
+ Service currentService = iterator.next();
+ Map portMap = currentService.getPorts();
+ Collection<Port> ports = portMap.values();
+ portList.addAll(ports);
+ }
+
+ String[] items = new String[portList.size() + 1];
+ items[0] = DeployUtils.NONE_STRING;
+
+ for (int i=1; i<portList.size()+1; i++){
+ Port currentPort = (Port) portList.get(i-1);
+ items[i] = currentPort.getName();
+ }
+
+ setItems(items);
+
+ if (value != null){
+ TService service = (TService) value;
+ for (int i = 0; i < portList.size(); i++) {
+ Port p = portList.get(i);
+ if (p.getName().equals(service.getPort()) &&
+ ((Service)p.getContainer()).getQName().equals(service.getName())) {
+ super.doSetValue(i+1);
+ return;
+ }
+ }
+ }
+ super.doSetValue(0);
+ }
+}
Added:
workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/util/DeployResourceSetImpl.java
===================================================================
---
workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/util/DeployResourceSetImpl.java
(rev 0)
+++
workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/util/DeployResourceSetImpl.java 2011-02-17
22:22:01 UTC (rev 29205)
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Oracle Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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:
+ * Oracle Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.bpel.apache.ode.deploy.ui.util;
+
+import org.eclipse.bpel.model.resource.BPELResourceSetImpl;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.resource.Resource;
+
+/**
+ * @author Bob Brodt (bbrodt(a)redhat.com)
+ * @date Aug 10, 2010
+ */
+
+@SuppressWarnings("nls")
+public class DeployResourceSetImpl extends BPELResourceSetImpl {
+
+ public DeployResourceSetImpl() {
+ super();
+ }
+
+ @Override
+ public Resource getResource(URI uri, boolean loadOnDemand) {
+ String name = uri.toString().toLowerCase();
+ // revert
https://jira.jboss.org/browse/JBIDE-6825
+ if (name.endsWith("wsdl"))
+ return getResource(uri,true,"wsdl");
+ if (name.endsWith("wsil"))
+ return getResource(uri,true,"wsil");
+ if (name.endsWith(".xsd"))
+ return getResource(uri,true,"xsd");
+ if (name.endsWith(".bpel"))
+ return getResource(uri,true,"bpel");
+ return super.getResource(uri,loadOnDemand);
+ }
+}
Added:
workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/util/DeployUtils.java
===================================================================
---
workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/util/DeployUtils.java
(rev 0)
+++
workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/util/DeployUtils.java 2011-02-17
22:22:01 UTC (rev 29205)
@@ -0,0 +1,390 @@
+/*******************************************************************************
+ * Copyright (c) 2008 IBM Corporation, University of Stuttgart (IAAS) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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:
+ * IBM Corporation, University of Stuttgart (IAAS) - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.bpel.apache.ode.deploy.ui.util;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.eclipse.bpel.apache.ode.deploy.model.dd.ProcessType;
+import org.eclipse.bpel.apache.ode.deploy.model.dd.TDeployment;
+import org.eclipse.bpel.apache.ode.deploy.model.dd.ddFactory;
+import org.eclipse.bpel.model.Process;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceVisitor;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.content.IContentDescription;
+import org.eclipse.core.runtime.content.IContentType;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EcorePackage;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IPackageFragmentRoot;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.wst.common.componentcore.ComponentCore;
+import org.eclipse.wst.common.componentcore.ModuleCoreNature;
+import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
+import org.eclipse.wst.wsdl.Definition;
+import org.eclipse.wst.wsdl.Port;
+import org.eclipse.wst.wsdl.Service;
+
+/**
+ * @author Simon Moser (IBM)
+ * @author Tammo van Lessen (IAAS)
+ */
+public class DeployUtils {
+
+ public static final String URL_PREFIX_FILE = "file"; //$NON-NLS-1$
+ public static final String URL_PREFIX_PLATFORM = "platform"; //$NON-NLS-1$
+ public static final String URL_PREFIX_RESOURCE = "resource"; //$NON-NLS-1$
+ public static final String NONE_STRING = "-- none -- "; //$NON-NLS-1$
+ public static final String BPEL_CONTENT_TYPE = "org.eclipse.bpel.contenttype";
//$NON-NLS-1$
+
+ public static ProcessType findProcessTypeInDD(
+ org.eclipse.bpel.model.Process process, TDeployment dd) {
+ for (ProcessType pt : dd.getProcess()) {
+ if (pt.getName().getLocalPart().equals(process.getName())
+ && pt.getName().getNamespaceURI().equals(
+ process.getTargetNamespace())) {
+ return pt;
+ }
+ }
+ return null;
+ }
+
+ public static ProcessType createProcessStub(
+ org.eclipse.bpel.model.Process process) {
+ ProcessType pt = ddFactory.eINSTANCE.createProcessType();
+ QName processQName = new QName(process.getTargetNamespace(), process
+ .getName());
+ pt.setName(processQName);
+ return pt;
+ }
+
+ public static QName getQNameFromSerialzedForm(String qNameAsString) {
+
+ int pos = qNameAsString.lastIndexOf("}"); //$NON-NLS-1$
+
+ String ns = qNameAsString.substring(1, pos);
+ String name = qNameAsString.substring(pos + 1, qNameAsString.length());
+
+ QName qName = new QName(ns, name);
+
+ return qName;
+ }
+
+ @SuppressWarnings("unchecked")//$NON-NLS-1$
+ public static Port findPortByName(String name, IProject bpelProject,
+ ResourceSet resourceSet) {
+
+ List serviceList = new ArrayList();
+ List portList = new ArrayList();
+
+ List<Definition> wsdlDefs = DeployUtils.loadAllWSDLFromProject(
+ bpelProject, resourceSet);
+ // Assemble All Services from WSDL's
+ for (Iterator<Definition> iterator = wsdlDefs.iterator(); iterator
+ .hasNext();) {
+ Definition current = (Definition) iterator.next();
+ Map services = current.getServices();
+ if (!services.isEmpty()) {
+ Collection values = services.values();
+ for (Iterator iterator2 = values.iterator(); iterator2
+ .hasNext();) {
+ Service name2 = (Service) iterator2.next();
+ serviceList.add(name2);
+ }
+ }
+ }
+
+ // now we have all services in a List .. get All Ports from these
+ // services
+ for (Iterator iterator = serviceList.iterator(); iterator.hasNext();) {
+ Service currentService = (Service) iterator.next();
+ Map portMap = currentService.getPorts();
+ Collection ports = portMap.values();
+ portList.addAll(ports);
+ }
+
+ for (Iterator iterator = portList.iterator(); iterator.hasNext();) {
+ Port currentPort = (Port) iterator.next();
+ if (currentPort.getName().equals(name)) {
+ return currentPort;
+ }
+ }
+
+ return null;
+
+ }
+
+ public static Process loadBPEL(IFile bpelFile, ResourceSet resourceSet) {
+
+ IPath fullProcessPath = bpelFile.getFullPath();
+ URI uri = URI.createPlatformResourceURI(fullProcessPath.toString(),
+ false);
+ Resource bpelResource = resourceSet.getResource(uri, true);
+
+ EcorePackage instance = EcorePackage.eINSTANCE;
+ instance.eAdapters();
+
+ try {
+ if (bpelResource.isLoaded()) {
+ bpelResource.unload();
+ }
+ bpelResource.load(Collections.EMPTY_MAP);
+ EList<EObject> contents = bpelResource.getContents();
+ if (!contents.isEmpty()) {
+ return (Process) contents.get(0);
+ }
+ } catch (Exception e) {
+ // swallow exception
+ }
+
+ return null;
+ }
+
+ public static Definition loadWSDL(IFile wsdlFile, ResourceSet resourceSet) {
+
+ IPath fullProcessPath = wsdlFile.getFullPath();
+ URI uri = URI.createPlatformResourceURI(fullProcessPath.toString(),
+ false);
+ Resource wsdlResource = resourceSet.getResource(uri, true);
+
+ EcorePackage instance = EcorePackage.eINSTANCE;
+ instance.eAdapters();
+
+ try {
+ wsdlResource.load(Collections.EMPTY_MAP);
+ EList<EObject> contents = wsdlResource.getContents();
+ if (!contents.isEmpty()) {
+ return (Definition) contents.get(0);
+ }
+ } catch (Exception e) {
+ // swallow exception
+ }
+
+ return null;
+ }
+
+ public static List<Definition> loadAllWSDLFromProject(IProject project,
+ ResourceSet resourceSet) {
+ List<Definition> wsdlFiles = new ArrayList<Definition>();
+
+ List<IFile> allFiles = DeployUtils.getAllFilesInProject(project);
+
+ for (IFile file : allFiles) {
+
+ if ("wsdl".equalsIgnoreCase(file.getFileExtension())) { //$NON-NLS-1$
+ // load it
+ Definition currentDef = loadWSDL(file, resourceSet);
+ // stuff it in wsdlFiles
+ wsdlFiles.add(currentDef);
+ }
+ }
+
+ //
https://jira.jboss.org/browse/JBIDE-6786
+ // Add WSDLs that were resolved as imports, to the list
+ for (Resource res : resourceSet.getResources())
+ {
+ //
https://jira.jboss.org/browse/JBIDE-6613
+ // fix a dumb mistake: XSDs don't have Definitions
+ // and will cause this to throw a class cast exception
+ Object obj = res.getContents().get(0);
+ if ( obj instanceof Definition )
+ {
+ Definition def = (Definition)obj;
+ if (!wsdlFiles.contains(def))
+ wsdlFiles.add(def);
+ }
+ }
+
+ return wsdlFiles;
+ }
+
+ public static List<Process> loadAllBPELFromProject(IProject project,
+ ResourceSet resourceSet) {
+ List<Process> bpelFiles = new ArrayList<Process>();
+
+ List<IFile> allFiles = DeployUtils.getAllFilesInProject(project);
+
+ for (IFile file : allFiles) {
+
+ //
https://jira.jboss.org/jira/browse/JBIDE-6006
+ if (DeployUtils.isBPELFile(file)) {
+ // load it
+ Process currentProcess = loadBPEL(file, resourceSet);
+ //
https://jira.jboss.org/browse/JBIDE-6613
+ // make sure the BPEL is valid.
+ if (currentProcess!=null)
+ // stuff it in bpelFiles
+ bpelFiles.add(currentProcess);
+ }
+ }
+
+ return bpelFiles;
+ }
+
+ public static List<IFile> getAllFilesInProject(IProject project) {
+
+ final List<IFile> files = new ArrayList<IFile>();
+ IResourceVisitor visitor = new IResourceVisitor() {
+ public boolean visit(org.eclipse.core.resources.IResource resource)
+ throws org.eclipse.core.runtime.CoreException {
+ if (resource.getType() == IResource.FILE) {
+ files.add((IFile) resource);
+ }
+ return true;
+ }
+ };
+ try {
+ IResource[] reses = project.getFolder(getWebContentRootPath(project)).members();
+ for (IResource res : reses) {
+ res.accept(visitor);
+
+ }
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ return files;
+ }
+
+ public static IResource[] getSourceContainers(IProject project) {
+ IJavaProject jProject = JavaCore.create(project);
+ if (jProject == null)
+ return new IResource[0];
+ List<IResource> list = new ArrayList<IResource>();
+
+ IPackageFragmentRoot[] roots;
+ try {
+ roots = jProject.getPackageFragmentRoots();
+ for (int i = 0; i < roots.length; i++) {
+ if (roots[i].getKind() != IPackageFragmentRoot.K_SOURCE)
+ continue;
+ IResource resource = roots[i].getResource();
+ list.add(resource);
+ // if (null != resource) {
+ // IVirtualResource[] vResources =
+ // ComponentCore.createResources(resource);
+ // boolean found = false;
+ // for (int j = 0; !found && j < vResources.length; j++) {
+ // if (vResources[j].getComponent().equals(vc)) {
+ // if (!list.contains(roots[i]))
+ // list.add(roots[i]);
+ // found = true;
+ // }
+ // }
+ // }
+ }
+ } catch (JavaModelException e) {
+ // Logger.getLogger().logError(e);
+ }
+ return (IResource[]) list.toArray(new IResource[list.size()]);
+ }
+
+ public static IFile getIFileForURI(URI uri) {
+
+ if (uri == null)
+ return null;
+
+ String filePath = null;
+ String scheme = uri.scheme();
+
+ if (URL_PREFIX_FILE.equals(scheme)) {
+ filePath = uri.toFileString();
+ } else if (URL_PREFIX_PLATFORM.equals(scheme) && uri.segmentCount() > 1
+ && URL_PREFIX_RESOURCE.equals(uri.segment(0))) {
+ StringBuffer platformResourcePath = new StringBuffer();
+ for (int i = 1, size = uri.segmentCount(); i < size; ++i) {
+ platformResourcePath.append('/');
+ platformResourcePath.append(uri.segment(i));
+ }
+ filePath = URI.decode(platformResourcePath.toString());
+ }
+
+ if (filePath == null)
+ return null;
+
+ IFile file = null;
+
+ if (URL_PREFIX_FILE.equals(scheme)) { // 44110
+ if (uri.device() != null) {
+ filePath = filePath.substring(filePath.indexOf(uri.device()));
+ }
+ file = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(
+ new Path(filePath));
+ } else
+ file = ResourcesPlugin.getWorkspace().getRoot().getFile(
+ new Path(filePath));
+
+ return file;
+ }
+
+ //
https://jira.jboss.org/jira/browse/JBIDE-6006
+ public static boolean isBPELFile(IResource res)
+ {
+ try
+ {
+ if (res.getType() == IResource.FILE) {
+ // check if file was recognized by eclipse BPEL editor
+ IContentDescription desc = ((IFile) res).getContentDescription();
+ if (desc != null) {
+ IContentType type = desc.getContentType();
+ if (type.getId().equals(BPEL_CONTENT_TYPE))
+ return true;
+ }
+
+ //
https://jira.jboss.org/browse/JBIDE-6006
+ // this causes all kinds of nasty stack traces - see
https://jira.jboss.org/browse/JBIDE-6093
+ // since this version of the ODE deployment editor is part of the same feature as the
BPEL editor
+ // plugin, we'll go on the assumption that they will always be installed
together. You'd have to
+ // something pretty dangerous to install one without the other.
+ // maybe the eclipse BPEL editor is not installed?
+ // fall back to using '.bpel' file extension
+ //if ("bpel".equals(((IFile)res).getFileExtension()))
+ // return true;
+ }
+ }
+ catch(Exception ex)
+ {
+ }
+ return false;
+ }
+
+ public static IPath getWebContentRootPath(IProject project) {
+ if (project == null)
+ return null;
+
+ if (!ModuleCoreNature.isFlexibleProject(project))
+ return null;
+
+ IPath path = null;
+ IVirtualComponent component = ComponentCore.createComponent(project);
+ if (component != null && component.exists()) {
+ path = component.getRootFolder().getProjectRelativePath();
+ }
+ return path;
+ }
+}
Added:
workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/util/InterfaceTableListener.java
===================================================================
---
workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/util/InterfaceTableListener.java
(rev 0)
+++
workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/util/InterfaceTableListener.java 2011-02-17
22:22:01 UTC (rev 29205)
@@ -0,0 +1,168 @@
+/*******************************************************************************
+ * Copyright (c) 2008 IBM Corporation, University of Stuttgart (IAAS) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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:
+ * IBM Corporation, University of Stuttgart (IAAS) - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.bpel.apache.ode.deploy.ui.util;
+
+import java.util.Iterator;
+
+import org.eclipse.bpel.apache.ode.deploy.model.dd.ProcessType;
+import org.eclipse.bpel.apache.ode.deploy.ui.pages.ProcessPage;
+import org.eclipse.bpel.model.PartnerLink;
+import org.eclipse.bpel.model.PartnerLinks;
+import org.eclipse.bpel.model.partnerlinktype.Role;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.TableEditor;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.forms.events.HyperlinkAdapter;
+import org.eclipse.ui.forms.events.HyperlinkEvent;
+import org.eclipse.ui.forms.events.IHyperlinkListener;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.Hyperlink;
+import org.eclipse.ui.ide.IDE;
+import org.eclipse.wst.wsdl.PortType;
+
+public class InterfaceTableListener implements Listener {
+
+ protected ProcessType processType = null;
+ protected Table table = null;
+ protected TableEditor editor = null;
+ protected FormToolkit toolkit = null;
+ protected IWorkbenchPage page = null;
+ protected boolean isInbound = false;
+
+ public InterfaceTableListener(ProcessType fProcessType, Table fTable, TableEditor
fEditor, FormToolkit fToolkit, IWorkbenchPage fPage, boolean bIsInbound){
+ processType = fProcessType;
+ table = fTable;
+ editor = fEditor;
+ toolkit = fToolkit;
+ page = fPage;
+ isInbound = bIsInbound;
+ }
+
+ public void handleEvent(Event event) {
+ Rectangle clientArea = table.getClientArea();
+ Point pt = new Point(event.x, event.y);
+ int index = table.getTopIndex();
+ while (index < table.getItemCount()) {
+ boolean visible = false;
+ final TableItem item = table.getItem(index);
+ for (int i = 0; i < table.getColumnCount(); i++) {
+ Rectangle rect = item.getBounds(i);
+ if (rect.contains(pt)) {
+
+ final int column = i;
+
+ System.out.println("A cell in column " + (i+1) + " has been
pressed");
+
+ if (i == ProcessPage.PARTNER_LINK_COLUMN) {
+ System.out.println("PORT_TYPE_COLUMN has been pressed");
+ final Hyperlink link = toolkit.createHyperlink(table, "",
SWT.NONE); //$NON-NLS-1$
+ IHyperlinkListener listener = new HyperlinkAdapter(){
+ public void linkActivated(HyperlinkEvent e) {
+
+ System.out.println("Hyper clicked!");
+
+ String partnerLinkName = e.getLabel();
+ PartnerLink theOne = null;
+
+ PartnerLinks partnerLinksElm = processType.getModel().getPartnerLinks();
+ EList<PartnerLink> partnerLinks = partnerLinksElm.getChildren();
+ for (Iterator<PartnerLink> iterator = partnerLinks.iterator();
iterator.hasNext();) {
+ PartnerLink currentPL = iterator.next();
+ if (currentPL.getName().equals(partnerLinkName)){
+ theOne = currentPL;
+ break;
+ }
+ }
+
+ if (theOne != null) {
+
+ Role role = null;
+
+ if (isInbound) {
+ role = theOne.getMyRole();
+ }
+ else {
+ role = theOne.getPartnerRole();
+ }
+
+ if (role != null) {
+ PortType portType = (PortType) role.getPortType();
+ Resource resource = portType.eResource();
+ IFile file = DeployUtils.getIFileForURI(resource.getURI());;
+ try {
+ IDE.openEditor(page, file);
+ }
+ catch (PartInitException e1) {
+ e1.printStackTrace();
+ }
+ }
+ }
+ }
+ };
+ link.addHyperlinkListener(listener);
+ editor.setEditor(link, item, i);
+ link.setText(item.getText(i));
+ link.setFocus();
+ }
+ else {
+ final Text text = new Text(table, SWT.NONE);
+ Listener textListener = new Listener() {
+ public void handleEvent(final Event e) {
+ switch (e.type) {
+ case SWT.FocusOut:
+ item.setText(column, text.getText());
+ text.dispose();
+ break;
+ case SWT.Traverse:
+ switch (e.detail) {
+ case SWT.TRAVERSE_RETURN:
+ item.setText(column, text.getText());
+ // FALL THROUGH
+ case SWT.TRAVERSE_ESCAPE:
+ text.dispose();
+ e.doit = false;
+ }
+ break;
+ }
+ }
+ };
+ text.addListener(SWT.FocusOut, textListener);
+ text.addListener(SWT.Traverse, textListener);
+ editor.setEditor(text, item, i);
+ text.setText(item.getText(i));
+ text.selectAll();
+ text.setFocus();
+ }
+
+ return;
+ }
+ if (!visible && rect.intersects(clientArea)) {
+ visible = true;
+ }
+ }
+ if (!visible)
+ return;
+ index++;
+ }
+ }
+}
Added:
workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/wizards/NewODEDeployWizard.java
===================================================================
---
workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/wizards/NewODEDeployWizard.java
(rev 0)
+++
workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/wizards/NewODEDeployWizard.java 2011-02-17
22:22:01 UTC (rev 29205)
@@ -0,0 +1,199 @@
+package org.eclipse.bpel.apache.ode.deploy.ui.wizards;
+
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.bpel.apache.ode.deploy.model.dd.DocumentRoot;
+import org.eclipse.bpel.apache.ode.deploy.model.dd.ProcessType;
+import org.eclipse.bpel.apache.ode.deploy.model.dd.TDeployment;
+import org.eclipse.bpel.apache.ode.deploy.model.dd.ddFactory;
+import org.eclipse.bpel.apache.ode.deploy.model.dd.util.ddResourceFactoryImpl;
+import org.eclipse.bpel.apache.ode.deploy.model.dd.util.ddResourceImpl;
+import org.eclipse.bpel.apache.ode.deploy.ui.Activator;
+import org.eclipse.bpel.apache.ode.deploy.ui.util.DeployUtils;
+import org.eclipse.bpel.model.Process;
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWizard;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.ide.IDE;
+
+/**
+ * Wizard that enables creating new deployment descriptors for Apache ODE.
+ *
+ * @author Simon Moser (IBM)
+ * @author Tammo van Lessen (IAAS)
+ */
+public class NewODEDeployWizard extends Wizard implements INewWizard {
+ private ODEDeployWizardPage page;
+ private ISelection selection;
+
+ /**
+ * Constructor for NewODEDeployWizard.
+ */
+ public NewODEDeployWizard() {
+ super();
+ setNeedsProgressMonitor(true);
+ }
+
+ /**
+ * Adding the page to the wizard.
+ */
+
+ public void addPages() {
+ page = new ODEDeployWizardPage(selection);
+ addPage(page);
+ }
+
+ /**
+ * This method is called when 'Finish' button is pressed in
+ * the wizard. We will create an operation and run it
+ * using wizard as execution context.
+ */
+ public boolean performFinish() {
+ final String containerName = page.getContainerName();
+ final String fileName = page.getFileName();
+ IRunnableWithProgress op = new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor) throws InvocationTargetException {
+ try {
+ doFinish(containerName, fileName, monitor);
+ } catch (CoreException e) {
+ throw new InvocationTargetException(e);
+ } finally {
+ monitor.done();
+ }
+ }
+ };
+ try {
+ getContainer().run(true, false, op);
+ } catch (InterruptedException e) {
+ return false;
+ } catch (InvocationTargetException e) {
+ Throwable realException = e.getTargetException();
+ MessageDialog.openError(getShell(), "Error", realException.getMessage());
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * The worker method. It will find the container, create the
+ * file if missing or just replace its contents, and open
+ * the editor on the newly created file.
+ */
+
+ private void doFinish(
+ String containerName,
+ String fileName,
+ IProgressMonitor monitor)
+ throws CoreException {
+
+ // create a sample file
+ monitor.beginTask("Creating " + fileName, 2);
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ IResource resource = root.findMember(new Path(containerName));
+ if (!resource.exists() || !(resource instanceof IContainer)) {
+ throwCoreException("Container \"" + containerName + "\" does
not exist.");
+ }
+ IContainer container = (IContainer) resource;
+ final IFile file = container.getFile(new Path(fileName));
+
+ try {
+ Resource emfResource = createBaseDeploymentDescriptor(file);
+ emfResource.save(null);
+ }
+ catch (IOException e) {
+ throwCoreException(e.getMessage());
+ }
+
+ monitor.worked(1);
+ monitor.setTaskName("Opening file for editing...");
+ getShell().getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ IWorkbenchPage page =
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ try {
+ IDE.openEditor(page, file, Activator.EDITOR_ID, true);
+ } catch (PartInitException e) {
+ }
+ }
+ });
+ monitor.worked(1);
+ }
+
+
+ /**
+ * Purpose of this method is to create a new empty deployment descriptor
+ * in the targetDir
+ */
+ public Resource createBaseDeploymentDescriptor(IFile file)
+ {
+ URI fileURI = URI.createURI(file.getFullPath().toString());
+
+ //generate Resource Factory
+ ddResourceFactoryImpl fac = new ddResourceFactoryImpl();
+ //URI ddFileLocation = URI.createFileURI(this.deployDirectory +
System.getProperty("file.separator") + DD_FILENAME );
+
+ ddResourceImpl ddResource = (ddResourceImpl) fac.createResource(fileURI);
+ ddResource.setEncoding("UTF-8");
+ DocumentRoot rootElm = ddFactory.eINSTANCE.createDocumentRoot();
+ TDeployment deployElement = ddFactory.eINSTANCE.createTDeployment();
+ rootElm.setDeploy(deployElement);
+ ddResource.getContents().add(rootElm);
+
+ //bugzilla 250057: parse the project, and if we find a BPEL file, create
+ //a base "process" tag that has
+ // <active>true</active>
+ // <retired>false</retired>
+ IProject project = file.getProject();
+ List<Process> processes = DeployUtils.loadAllBPELFromProject(project, new
ResourceSetImpl());
+ for (Iterator iterator = processes.iterator(); iterator.hasNext();) {
+ Process process = (Process) iterator.next();
+ ProcessType pt = DeployUtils.createProcessStub(process);
+ pt.setActive(true);
+ pt.setRetired(false);
+ pt.setModel(process);
+ deployElement.getProcess().add(pt);
+ }
+
+ return ddResource;
+ }
+
+ private void throwCoreException(String message) throws CoreException {
+ IStatus status =
+ new Status(IStatus.ERROR, "org.eclipse.bpel.apache.ode.deploy.ui",
IStatus.OK, message, null);
+ throw new CoreException(status);
+ }
+
+ /**
+ * We will accept the selection in the workbench to see if
+ * we can initialize from it.
+ * @see IWorkbenchWizard#init(IWorkbench, IStructuredSelection)
+ */
+ public void init(IWorkbench workbench, IStructuredSelection selection) {
+ this.selection = selection;
+ }
+}
\ No newline at end of file
Added:
workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/wizards/ODEDeployWizardPage.java
===================================================================
---
workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/wizards/ODEDeployWizardPage.java
(rev 0)
+++
workspace/bbrodt/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/wizards/ODEDeployWizardPage.java 2011-02-17
22:22:01 UTC (rev 29205)
@@ -0,0 +1,187 @@
+package org.eclipse.bpel.apache.ode.deploy.ui.wizards;
+
+import org.eclipse.bpel.apache.ode.deploy.ui.util.DeployUtils;
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.dialogs.IDialogPage;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+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.dialogs.ContainerSelectionDialog;
+
+/**
+ * ODE deployment descriptor wizard page.
+ *
+ * @author Simon Moser (IBM)
+ * @author Tammo van Lessen (IAAS)
+ */
+public class ODEDeployWizardPage extends WizardPage {
+ private Text containerText;
+
+ private Text fileText;
+
+ private ISelection selection;
+
+ /**
+ * Constructor for SampleNewWizardPage.
+ *
+ * @param pageName
+ */
+ public ODEDeployWizardPage(ISelection selection) {
+ super("ODEDeployDescriptorWizardPage");
+ setTitle("Apache ODE Deployment Descriptor");
+ setDescription("This wizard creates a new Apache ODE descriptor file (deploy.xml).
Note that the file name cannot be changed.");
+ this.selection = selection;
+ }
+
+ /**
+ * @see IDialogPage#createControl(Composite)
+ */
+ public void createControl(Composite parent) {
+ Composite container = new Composite(parent, SWT.NULL);
+ GridLayout layout = new GridLayout();
+ container.setLayout(layout);
+ layout.numColumns = 3;
+ layout.verticalSpacing = 9;
+ Label label = new Label(container, SWT.NULL);
+ label.setText("BPEL &Project:");
+
+ containerText = new Text(container, SWT.BORDER | SWT.SINGLE);
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ containerText.setLayoutData(gd);
+ containerText.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ dialogChanged();
+ }
+ });
+
+ Button button = new Button(container, SWT.PUSH);
+ button.setText("Browse...");
+ button.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ handleBrowse();
+ }
+ });
+ label = new Label(container, SWT.NULL);
+ label.setText("&File name:");
+
+ fileText = new Text(container, SWT.BORDER | SWT.SINGLE);
+ fileText.setText("deploy.xml");
+ fileText.setEditable(false);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ fileText.setLayoutData(gd);
+ initialize();
+ dialogChanged();
+ setControl(container);
+ }
+
+ /**
+ * Tests if the current workbench selection is a suitable container to use.
+ */
+
+ private void initialize() {
+ if (selection != null && selection.isEmpty() == false
+ && selection instanceof IStructuredSelection) {
+ IStructuredSelection ssel = (IStructuredSelection) selection;
+ if (ssel.size() > 1)
+ return;
+ Object obj = ssel.getFirstElement();
+
+ if (obj instanceof IResource) {
+ IProject project;
+ project = ((IResource) obj).getProject();
+ IContainer bpelContent =
project.getFolder(DeployUtils.getWebContentRootPath(project));
+ if (bpelContent != null) {
+ containerText.setText(bpelContent.getFullPath().toString());
+ } else {
+ containerText.setText(project.getFullPath().toString());
+ }
+ }
+ }
+ }
+
+ /**
+ * Uses the standard container selection dialog to choose the new value for
+ * the container field.
+ */
+
+ private void handleBrowse() {
+ ContainerSelectionDialog dialog = new ContainerSelectionDialog(
+ getShell(), ResourcesPlugin.getWorkspace().getRoot(), false,
+ "Select a BPEL Project that hosts the deployment descriptor");
+ if (dialog.open() == ContainerSelectionDialog.OK) {
+ Object[] result = dialog.getResult();
+ if (result.length == 1) {
+ containerText.setText(((Path) result[0]).toString());
+ }
+ }
+ }
+
+ /**
+ * Ensures that both text fields are set.
+ */
+
+ private void dialogChanged() {
+ IResource container = ResourcesPlugin.getWorkspace().getRoot()
+ .findMember(new Path(getContainerName()));
+ String fileName = getFileName();
+
+ if (getContainerName().length() == 0) {
+ updateStatus("BPEL Project must be specified");
+ return;
+ }
+ if (container == null
+ || (container.getType() & (IResource.PROJECT | IResource.FOLDER)) == 0) {
+ updateStatus("BPEL Project must exist");
+ return;
+ }
+ if (!container.isAccessible()) {
+ updateStatus("BPEL Project must be writable");
+ return;
+ }
+ if (fileName.length() == 0) {
+ updateStatus("File name must be specified");
+ return;
+ }
+ if (fileName.replace('\\', '/').indexOf('/', 1) > 0) {
+ updateStatus("File name must be valid");
+ return;
+ }
+ int dotLoc = fileName.lastIndexOf('.');
+ if (dotLoc != -1) {
+ String ext = fileName.substring(dotLoc + 1);
+ if (ext.equalsIgnoreCase("xml") == false) {
+ updateStatus("File extension must be \"xml\"");
+ return;
+ }
+ }
+ updateStatus(null);
+ }
+
+ private void updateStatus(String message) {
+ setErrorMessage(message);
+ setPageComplete(message == null);
+ }
+
+ public String getContainerName() {
+ return containerText.getText();
+ }
+
+ public String getFileName() {
+ return fileText.getText();
+ }
+}
\ No newline at end of file