Author: dennyxu
Date: 2009-11-18 23:58:20 -0500 (Wed, 18 Nov 2009)
New Revision: 18740
Added:
trunk/bpel/plugins/org.jboss.tools.bpel.runtimes/src/org/jboss/tools/bpel/runtimes/module/JBTBPELPublisher.java
trunk/bpel/plugins/org.jboss.tools.bpel.runtimes/src/org/jboss/tools/bpel/runtimes/ui/view/
trunk/bpel/plugins/org.jboss.tools.bpel.runtimes/src/org/jboss/tools/bpel/runtimes/ui/view/server/
trunk/bpel/plugins/org.jboss.tools.bpel.runtimes/src/org/jboss/tools/bpel/runtimes/ui/view/server/BPELModuleActionProvider.java
trunk/bpel/plugins/org.jboss.tools.bpel.runtimes/src/org/jboss/tools/bpel/runtimes/ui/view/server/BPELModuleContentProvider.java
trunk/bpel/plugins/org.jboss.tools.bpel.runtimes/src/org/jboss/tools/bpel/runtimes/ui/view/server/BPELModuleLabelProvider.java
Modified:
trunk/bpel/plugins/org.jboss.tools.bpel.runtimes/.settings/org.eclipse.jdt.core.prefs
trunk/bpel/plugins/org.jboss.tools.bpel.runtimes/META-INF/MANIFEST.MF
trunk/bpel/plugins/org.jboss.tools.bpel.runtimes/plugin.xml
Log:
JBIDE-4864:BPEL Process Versioning
Modified:
trunk/bpel/plugins/org.jboss.tools.bpel.runtimes/.settings/org.eclipse.jdt.core.prefs
===================================================================
---
trunk/bpel/plugins/org.jboss.tools.bpel.runtimes/.settings/org.eclipse.jdt.core.prefs 2009-11-18
22:57:30 UTC (rev 18739)
+++
trunk/bpel/plugins/org.jboss.tools.bpel.runtimes/.settings/org.eclipse.jdt.core.prefs 2009-11-19
04:58:20 UTC (rev 18740)
@@ -1,7 +1,8 @@
-#Mon Oct 23 11:56:22 PDT 2006
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
-org.eclipse.jdt.core.compiler.compliance=1.5
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.5
+#Tue Oct 20 16:01:25 CST 2009
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
Modified: trunk/bpel/plugins/org.jboss.tools.bpel.runtimes/META-INF/MANIFEST.MF
===================================================================
--- trunk/bpel/plugins/org.jboss.tools.bpel.runtimes/META-INF/MANIFEST.MF 2009-11-18
22:57:30 UTC (rev 18739)
+++ trunk/bpel/plugins/org.jboss.tools.bpel.runtimes/META-INF/MANIFEST.MF 2009-11-19
04:58:20 UTC (rev 18740)
@@ -5,26 +5,31 @@
Bundle-Version: 0.4.0.qualifier
Bundle-Activator: org.jboss.tools.bpel.runtimes.RuntimesPlugin
Bundle-Localization: plugin
-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.core.resources;bundle-version="[3.4.0,4.0.0)",
- org.eclipse.wst.server.core;bundle-version="[1.1.0,2.0.0)",
- org.eclipse.wst.web.ui;bundle-version="[1.1.200,2.0.0)",
- org.eclipse.wst.common.project.facet.ui;bundle-version="[1.3.0,2.0.0)",
- org.eclipse.wst.common.modulecore;bundle-version="[1.1.200,2.0.0)",
- org.eclipse.wst.common.frameworks;bundle-version="[1.1.200,2.0.0)",
- org.eclipse.wst.common.project.facet.core;bundle-version="[1.3.0,2.0.0)",
- org.eclipse.wst.common.frameworks.ui;bundle-version="[1.1.200,2.0.0)",
- org.eclipse.jst.server.generic.core;bundle-version="[1.0.305,2.0.0)",
- org.eclipse.jem.util;bundle-version="[2.0.100,3.0.0)",
- org.eclipse.debug.ui;bundle-version="[3.4.0,4.0.0)",
- org.eclipse.bpel.model;bundle-version="0.4.0",
- org.eclipse.emf.ecore;bundle-version="[2.4.0,3.0.0)",
- org.eclipse.wst.wsdl;bundle-version="[1.1.200,2.0.0)",
- javax.wsdl;bundle-version="[1.5.0,1.6.0)",
- org.eclipse.jst.common.frameworks;bundle-version="1.1.300",
- org.jboss.ide.eclipse.as.wtp.core;bundle-version="1.0.0",
- org.eclipse.wst.web;bundle-version="1.1.300"
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.core.resources,
+ org.eclipse.wst.server.core,
+ org.eclipse.wst.web.ui,
+ org.eclipse.wst.common.project.facet.ui,
+ org.eclipse.wst.common.modulecore,
+ org.eclipse.wst.common.frameworks,
+ org.eclipse.wst.common.project.facet.core,
+ org.eclipse.wst.common.frameworks.ui,
+ org.eclipse.jst.server.generic.core,
+ org.eclipse.jem.util,
+ org.eclipse.debug.ui,
+ org.eclipse.bpel.model,
+ org.eclipse.emf.ecore,
+ org.eclipse.wst.wsdl,
+ javax.wsdl,
+ org.eclipse.jst.common.frameworks,
+ org.jboss.ide.eclipse.as.wtp.core,
+ org.eclipse.wst.web,
+ org.jboss.ide.eclipse.as.core;resolution:=optional,
+ org.jboss.ide.eclipse.archives.webtools;resolution:=optional,
+ org.jboss.tools.jmx.core;resolution:=optional,
+ org.eclipse.wst.server.ui;resolution:=optional,
+ org.eclipse.ui.navigator
Eclipse-LazyStart: true
Export-Package: org.jboss.tools.bpel.runtimes,
org.jboss.tools.bpel.runtimes.facets,
Modified: trunk/bpel/plugins/org.jboss.tools.bpel.runtimes/plugin.xml
===================================================================
--- trunk/bpel/plugins/org.jboss.tools.bpel.runtimes/plugin.xml 2009-11-18 22:57:30 UTC
(rev 18739)
+++ trunk/bpel/plugins/org.jboss.tools.bpel.runtimes/plugin.xml 2009-11-19 04:58:20 UTC
(rev 18740)
@@ -167,7 +167,15 @@
adaptableType="org.eclipse.core.resources.IFile">
<adapter type="org.eclipse.debug.ui.actions.ILaunchable"/>
</factory>
- </extension>
+ </extension>
+ <extension
+ point="org.jboss.ide.eclipse.as.core.publishers">
+ <publisher
+ class="org.jboss.tools.bpel.runtimes.module.JBTBPELPublisher"
+ priority="10"
+ zipDelegate="false">
+ </publisher>
+ </extension>
<!--=========================================================================-->
<!-- TO MAKE PROCESSES ACTUALLY LAUNCHABLE VIA RUN ON SERVER -->
@@ -187,5 +195,62 @@
<!-- -->
<!--=========================================================================-->
-
+ <extension
+ point="org.eclipse.ui.navigator.navigatorContent">
+ <navigatorContent
+ id="org.jboss.tools.bpel.runtimes.ui.view.server.content"
+ activeByDefault="true"
+
contentProvider="org.jboss.tools.bpel.runtimes.ui.view.server.BPELModuleContentProvider"
+ icon="icons/obj16/bpelfacet.gif"
+
labelProvider="org.jboss.tools.bpel.runtimes.ui.view.server.BPELModuleLabelProvider"
+ name="BPEL Modules"
+ priority="highest">
+ <triggerPoints>
+ <instanceof
+ value="java.lang.Object">
+ </instanceof>
+ </triggerPoints>
+ <possibleChildren>
+ <instanceof
+ value="java.lang.Object">
+ </instanceof>
+ </possibleChildren>
+ <actionProvider
+
class="org.jboss.tools.bpel.runtimes.ui.view.server.BPELModuleActionProvider"
+
id="org.jboss.tools.bpel.runtimes.ui.view.server.BPELModuleActionProvider"
+ priority="highest">
+ <enablement>
+ <or>
+ <instanceof
+ value="org.eclipse.wst.server.core.IServer">
+ </instanceof>
+ <instanceof
+
value="org.eclipse.wst.server.ui.internal.view.servers.ModuleServer">
+ </instanceof>
+ <instanceof
+ value="org.eclipse.core.resources.IWorkspaceRoot">
+ </instanceof>
+ <adapt type="java.util.Collection">
+ <count value="0"/>
+ </adapt>
+ <instanceof
+
value="org.jboss.tools.bpel.runtimes.ui.view.server.BPELModuleContentProvider$BPELVersionDeployment">
+ </instanceof>
+ </or>
+ </enablement>
+ </actionProvider>
+ </navigatorContent>
+ </extension>
+ <extension
+ point="org.eclipse.ui.navigator.viewer">
+ <viewerContentBinding
+ viewerId="org.eclipse.wst.server.ui.ServersView">
+ <includes>
+ <contentExtension
+ isRoot="true"
+
pattern="org.jboss.tools.bpel.runtimes.ui.view.server.content">
+ </contentExtension>
+ </includes>
+ </viewerContentBinding>
+ </extension>
</plugin>
Added:
trunk/bpel/plugins/org.jboss.tools.bpel.runtimes/src/org/jboss/tools/bpel/runtimes/module/JBTBPELPublisher.java
===================================================================
---
trunk/bpel/plugins/org.jboss.tools.bpel.runtimes/src/org/jboss/tools/bpel/runtimes/module/JBTBPELPublisher.java
(rev 0)
+++
trunk/bpel/plugins/org.jboss.tools.bpel.runtimes/src/org/jboss/tools/bpel/runtimes/module/JBTBPELPublisher.java 2009-11-19
04:58:20 UTC (rev 18740)
@@ -0,0 +1,289 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.bpel.runtimes.module;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.Iterator;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.MultiStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.wst.server.core.IModule;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.model.IModuleResource;
+import org.eclipse.wst.server.core.model.IModuleResourceDelta;
+import org.jboss.ide.eclipse.archives.webtools.modules.LocalZippedPublisherUtil;
+import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
+import org.jboss.ide.eclipse.as.core.Messages;
+import org.jboss.ide.eclipse.as.core.extensions.events.IEventCodes;
+import org.jboss.ide.eclipse.as.core.publishers.LocalPublishMethod;
+import org.jboss.ide.eclipse.as.core.publishers.PublishUtil;
+import org.jboss.ide.eclipse.as.core.server.IDeployableServer;
+import org.jboss.ide.eclipse.as.core.server.IJBossServerPublishMethod;
+import org.jboss.ide.eclipse.as.core.server.IJBossServerPublisher;
+import org.jboss.ide.eclipse.as.core.server.xpl.PublishCopyUtil;
+import org.jboss.ide.eclipse.as.core.server.xpl.PublishCopyUtil.LocalCopyCallback;
+import org.jboss.ide.eclipse.as.core.util.FileUtil;
+import org.jboss.ide.eclipse.as.core.util.IJBossToolingConstants;
+import org.jboss.ide.eclipse.as.core.util.IWTPConstants;
+import org.jboss.ide.eclipse.as.core.util.ServerConverter;
+import org.jboss.tools.bpel.runtimes.IBPELModuleFacetConstants;
+import org.jboss.tools.jmx.core.IMemento;
+import org.jboss.tools.jmx.core.util.XMLMemento;
+
+/**
+ * This class allows you to publish a BPEL module specifically
+ * to a JBossTools server entity.
+ * @author rob.stryker(a)jboss.com
+ *
+ */
+public class JBTBPELPublisher implements IJBossServerPublisher {
+ private IServer server;
+ private int publishState = IServer.PUBLISH_STATE_INCREMENTAL;
+ public JBTBPELPublisher() {
+ }
+
+ public int getPublishState() {
+ return publishState;
+ }
+
+ public boolean accepts(String method, IServer server, IModule[] module) {
+ if( LocalPublishMethod.LOCAL_PUBLISH_METHOD.equals(method)
+ && module != null && module.length > 0
+ && module[module.length-1] != null
+ &&
module[module.length-1].getModuleType().getId().equals(IBPELModuleFacetConstants.BPEL_MODULE_TYPE))
+ return true;
+ return false;
+ }
+
+ public IStatus publishModule(
+ IJBossServerPublishMethod method,
+ IServer server, IModule[] module,
+ int publishType, IModuleResourceDelta[] delta,
+ IProgressMonitor monitor) throws CoreException {
+
+ this.server = server;
+ IModule last = module[module.length-1];
+ IStatus status = null;
+ if(publishType == REMOVE_PUBLISH){
+ removeAll(server, last.getProject());
+ } else if( publishType == FULL_PUBLISH ){
+ // Publish a new version forced
+ status = publish(module, delta, publishType, monitor);
+ publishState = IServer.PUBLISH_STATE_NONE;
+ } else if( publishType == INCREMENTAL_PUBLISH ) {
+ // Do nothing. This is intentional
+ publishState = IServer.PUBLISH_STATE_INCREMENTAL;
+ }
+ return status == null ? Status.OK_STATUS : status;
+ }
+
+
+ protected IStatus publish(IModule[] moduleTree,
+ IModuleResourceDelta[] delta, int publishType, IProgressMonitor monitor) throws
CoreException {
+ ArrayList<IStatus> resultList = new ArrayList<IStatus>();
+ IDeployableServer ds = ServerConverter.getDeployableServer(server);
+ IModule last = moduleTree[moduleTree.length -1];
+ IPath deployPath = getDeployPath(moduleTree, ds);
+ IPath tempDeployPath = PublishUtil.getTempDeployFolder(moduleTree, ds);
+ IModuleResource[] members = PublishUtil.getResources(last);
+ if( shouldZip() ) {
+ String deployRoot = PublishUtil.getDeployRootFolder(
+ moduleTree, ds, ds.getDeployFolder(),
+ IJBossToolingConstants.LOCAL_DEPLOYMENT_LOC);
+ BPELZippedPublisherUtil util = new BPELZippedPublisherUtil(deployPath);
+ IStatus ret = util.publishModule(server, deployRoot, moduleTree, publishType, delta,
monitor);
+ resultList.add(ret);
+ } else {
+ LocalCopyCallback handler = new LocalCopyCallback(server, deployPath,
tempDeployPath);
+ PublishCopyUtil util = new PublishCopyUtil(handler);
+ resultList.addAll(Arrays.asList(util.publishFull(members, monitor)));
+ }
+ addDeployedPathToDescriptor(server, last.getProject(), deployPath); // persist it
+ pruneList(resultList);
+ if( resultList.size() > 0 ) {
+ MultiStatus ms = new MultiStatus(JBossServerCorePlugin.PLUGIN_ID,
IEventCodes.JST_PUB_FULL_FAIL,
+ NLS.bind(Messages.FullPublishFail, last.getName()), null);
+ for( int i = 0; i < resultList.size(); i++ )
+ ms.add(resultList.get(i));
+ return ms;
+ }
+ return Status.OK_STATUS;
+ }
+
+ // Prune out ok status
+ protected void pruneList(ArrayList<IStatus> list) {
+ Iterator<IStatus> i = list.iterator();
+ while(i.hasNext()) {
+ if( i.next().isOK())
+ i.remove();
+ }
+ }
+
+ protected boolean shouldZip() {
+ IDeployableServer ds = ServerConverter.getDeployableServer(server);
+ return ds == null || ds.zipsWTPDeployments();
+ }
+
+ public static IPath getDeployPath(IModule[] moduleTree, IDeployableServer server) {
+ IPath path = PublishUtil.getDeployPath(moduleTree, server);
+ path = path.removeLastSegments(1).append(getNewLastSegment(moduleTree));
+ return path;
+ }
+
+ public static String getNewLastSegment(IModule[] moduleTree) {
+ IModule last = moduleTree[moduleTree.length-1];
+ long stamp = new Date().getTime();
+ return last.getName() + "-" + stamp + IWTPConstants.EXT_JAR;
+ }
+
+ private static final String DEPLOYMENTS = "deployments";
+ private static final String PROJECT = "project";
+ private static final String NAME = "name";
+ private static final String VERSION = "version";
+
+ protected static void save(IServer server, XMLMemento memento) {
+ try {
+ memento.save(new FileOutputStream(getDeployDetailsFile(server)));
+ } catch( IOException ioe) {
+ // TODO LOG
+ }
+ }
+
+ public static void removeAll(IServer server, IProject project) {
+ String[] paths = getDeployedPathsFromDescriptor(server, project);
+ for( int i = 0; i < paths.length; i++ ) {
+ // remove them all, with full force!!! >=[
+ FileUtil.safeDelete(new File(paths[i]));
+ }
+ removeProjectFromDescriptor(server, project);
+ }
+
+ public static void removeVersion(IServer server, IProject project, String path) {
+ // delete file
+ FileUtil.safeDelete(new File(path));
+ // remove from descriptor
+ removeVersionFromDescriptor(server, project, path);
+ }
+
+ public static void removeVersionFromDescriptor(IServer server, IProject project, String
path) {
+ File f = getDeployDetailsFile(server);
+ XMLMemento memento = null;
+ try {
+ memento = XMLMemento.createReadRoot(new FileInputStream(f));
+ IMemento[] projects = memento.getChildren(PROJECT);//$NON-NLS-1$
+ for( int i = 0; i < projects.length; i++ ) {
+ if( project.getName().equals(projects[i].getString(NAME)) ) {
+ IMemento[] versions = projects[i].getChildren(VERSION);
+ for( int j = 0; j < versions.length; j++ ) {
+ if( ((XMLMemento)versions[j]).getTextData().equals(path)) {
+ ((XMLMemento)projects[i]).removeChild((XMLMemento)versions[j]);
+ }
+ }
+ }
+ }
+ save(server, memento);
+ } catch( FileNotFoundException fnfe) {}
+ }
+
+ public static void removeProjectFromDescriptor(IServer server, IProject project) {
+ File f = getDeployDetailsFile(server);
+ XMLMemento memento = null;
+ try {
+ memento = XMLMemento.createReadRoot(new FileInputStream(f));
+ IMemento[] projects = memento.getChildren(PROJECT);//$NON-NLS-1$
+ for( int i = 0; i < projects.length; i++ ) {
+ if( project.getName().equals(projects[i].getString(NAME)) ) {
+ memento.removeChild((XMLMemento)projects[i]);
+ }
+ }
+ save(server, memento);
+ } catch( FileNotFoundException fnfe) {}
+ }
+
+ public static void addDeployedPathToDescriptor(IServer server, IProject project, IPath
path) {
+ File f = getDeployDetailsFile(server);
+ XMLMemento memento = null;
+ try {
+ memento = XMLMemento.createReadRoot(new FileInputStream(f));
+ } catch( FileNotFoundException fnfe) {}
+
+ if( memento == null )
+ memento = XMLMemento.createWriteRoot(DEPLOYMENTS);
+
+ IMemento[] projects = memento.getChildren(PROJECT);//$NON-NLS-1$
+ boolean projectFound = false;
+ for( int i = 0; i < projects.length; i++ ) {
+ if( project.getName().equals(projects[i].getString(NAME))) {
+ projectFound = true;
+ XMLMemento child = (XMLMemento)projects[i].createChild(VERSION);
+ child.putTextData(path.toOSString());
+ }
+ }
+ if( !projectFound ) {
+ XMLMemento proj = (XMLMemento)memento.createChild(PROJECT);
+ proj.putString(NAME, project.getName());
+ XMLMemento child = (XMLMemento)proj.createChild(VERSION);
+ child.putTextData(path.toOSString());
+ }
+ save(server, memento);
+ }
+
+ public static String[] getDeployedPathsFromDescriptor(IServer server, IProject project)
{
+ File f = getDeployDetailsFile(server);
+ ArrayList<String> list = new ArrayList<String>();
+ if( f.exists() ) {
+ try {
+ XMLMemento memento = XMLMemento.createReadRoot(new FileInputStream(f));
+ IMemento[] projects = memento.getChildren(PROJECT);//$NON-NLS-1$
+ for( int i = 0; i < projects.length; i++ ) {
+ if( project.getName().equals(projects[i].getString(NAME))) {
+ IMemento[] deployments = projects[i].getChildren(VERSION);
+ for( int j = 0; j < deployments.length; j++ ) {
+ String s = ((XMLMemento)deployments[j]).getTextData();
+ if( s != null && !s.equals(""))
+ list.add(s);
+ }
+ break;
+ }
+ }
+ } catch( FileNotFoundException fnfe) {}
+ }
+ return (String[]) list.toArray(new String[list.size()]);
+ }
+
+ public static File getDeployDetailsFile(IServer server) {
+ return JBossServerCorePlugin.getServerStateLocation(server)
+ .append("bpel.deployment.versions").toFile();
+ }
+
+ public static class BPELZippedPublisherUtil extends LocalZippedPublisherUtil {
+ private IPath deployPath;
+ public BPELZippedPublisherUtil(IPath deployPath) {
+ this.deployPath = deployPath;
+ }
+ public IPath getOutputFilePath() {
+ return deployPath;
+ }
+ }
+}
Added:
trunk/bpel/plugins/org.jboss.tools.bpel.runtimes/src/org/jboss/tools/bpel/runtimes/ui/view/server/BPELModuleActionProvider.java
===================================================================
---
trunk/bpel/plugins/org.jboss.tools.bpel.runtimes/src/org/jboss/tools/bpel/runtimes/ui/view/server/BPELModuleActionProvider.java
(rev 0)
+++
trunk/bpel/plugins/org.jboss.tools.bpel.runtimes/src/org/jboss/tools/bpel/runtimes/ui/view/server/BPELModuleActionProvider.java 2009-11-19
04:58:20 UTC (rev 18740)
@@ -0,0 +1,103 @@
+package org.jboss.tools.bpel.runtimes.ui.view.server;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.StructuredViewer;
+import org.eclipse.ui.navigator.CommonActionProvider;
+import org.eclipse.ui.navigator.CommonViewer;
+import org.eclipse.ui.navigator.ICommonActionExtensionSite;
+import org.eclipse.ui.navigator.ICommonViewerSite;
+import org.eclipse.ui.navigator.ICommonViewerWorkbenchSite;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.ui.internal.view.servers.ModuleServer;
+import org.jboss.tools.bpel.runtimes.module.JBTBPELPublisher;
+import
org.jboss.tools.bpel.runtimes.ui.view.server.BPELModuleContentProvider.BPELVersionDeployment;
+
+public class BPELModuleActionProvider extends CommonActionProvider {
+
+ private ICommonActionExtensionSite actionSite;
+ private Action undeployVersionAction;
+ private IStructuredSelection lastSelection;
+ public BPELModuleActionProvider() {
+ super();
+ }
+
+ public void dispose() {
+ super.dispose();
+ }
+
+ public void init(ICommonActionExtensionSite aSite) {
+ super.init(aSite);
+ this.actionSite = aSite;
+ createActions(aSite);
+ }
+
+ protected void createActions(ICommonActionExtensionSite aSite) {
+ ICommonViewerSite site = aSite.getViewSite();
+ if( site instanceof ICommonViewerWorkbenchSite ) {
+ StructuredViewer v = aSite.getStructuredViewer();
+ if( v instanceof CommonViewer ) {
+ CommonViewer cv = (CommonViewer)v;
+ ICommonViewerWorkbenchSite wsSite = (ICommonViewerWorkbenchSite)site;
+ undeployVersionAction = new Action() {
+ public void run() {
+ runUndeployVersion();
+ refreshViewer(getLastServer());
+ }
+ };
+ undeployVersionAction.setText("Undeploy Version");
+ undeployVersionAction.setDescription("Undeploy this version of the
module");
+ //undeployVersionAction.setImageDescriptor(JBossServerUISharedImages.getImageDescriptor(JBossServerUISharedImages.PUBLISH_IMAGE));
+ }
+ }
+ }
+
+ protected void runUndeployVersion() {
+ Object firstSel = lastSelection.getFirstElement();
+ if( firstSel instanceof BPELVersionDeployment ) {
+ BPELVersionDeployment deployment = (BPELVersionDeployment)firstSel;
+ JBTBPELPublisher.removeVersion(deployment.getModuleServer().server,
+ deployment.getProject(), deployment.getPath());
+ }
+ }
+
+ protected IServer getLastServer() {
+ Object firstSel = lastSelection.getFirstElement();
+ if( firstSel instanceof IServer )
+ return (IServer)firstSel;
+ if( firstSel instanceof ModuleServer )
+ return ((ModuleServer)firstSel).getServer();
+ if( firstSel instanceof BPELVersionDeployment )
+ return ((BPELVersionDeployment)firstSel).getModuleServer().getServer();
+ return null;
+ }
+
+ protected void refreshViewer(Object o) {
+ actionSite.getStructuredViewer().refresh(o);
+ }
+
+
+ public void fillContextMenu(IMenuManager menu) {
+ lastSelection = getSelection();
+ if( lastSelection.size() == 1 ) {
+ Object sel = lastSelection.getFirstElement();
+ if( sel instanceof BPELVersionDeployment )
+ menu.add(undeployVersionAction);
+ }
+ }
+
+ public IStructuredSelection getSelection() {
+ ICommonViewerSite site = actionSite.getViewSite();
+ IStructuredSelection selection = null;
+ if (site instanceof ICommonViewerWorkbenchSite) {
+ ICommonViewerWorkbenchSite wsSite = (ICommonViewerWorkbenchSite) site;
+ selection = (IStructuredSelection) wsSite.getSelectionProvider()
+ .getSelection();
+ return selection;
+ }
+ return new StructuredSelection();
+ }
+
+}
Added:
trunk/bpel/plugins/org.jboss.tools.bpel.runtimes/src/org/jboss/tools/bpel/runtimes/ui/view/server/BPELModuleContentProvider.java
===================================================================
---
trunk/bpel/plugins/org.jboss.tools.bpel.runtimes/src/org/jboss/tools/bpel/runtimes/ui/view/server/BPELModuleContentProvider.java
(rev 0)
+++
trunk/bpel/plugins/org.jboss.tools.bpel.runtimes/src/org/jboss/tools/bpel/runtimes/ui/view/server/BPELModuleContentProvider.java 2009-11-19
04:58:20 UTC (rev 18740)
@@ -0,0 +1,75 @@
+package org.jboss.tools.bpel.runtimes.ui.view.server;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.wst.server.core.IModule;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.ui.internal.view.servers.ModuleServer;
+import org.jboss.tools.bpel.runtimes.IBPELModuleFacetConstants;
+import org.jboss.tools.bpel.runtimes.module.JBTBPELPublisher;
+
+public class BPELModuleContentProvider implements ITreeContentProvider {
+ public BPELModuleContentProvider() {
+ }
+ public Object[] getChildren(Object parentElement) {
+ if( parentElement instanceof ModuleServer ) {
+ IServer s = ((ModuleServer)parentElement).server;
+ IModule[] module = ((ModuleServer)parentElement).module;
+ IModule mod = module.length > 0 ? module[module.length-1] : null;
+ String typeId = mod.getModuleType().getId();
+ if( mod != null && typeId.equals(IBPELModuleFacetConstants.BPEL_MODULE_TYPE))
{
+ // we have a bpel module deployed to a server. List the children
+ String[] versions = JBTBPELPublisher.getDeployedPathsFromDescriptor(s,
mod.getProject());
+ return wrap((ModuleServer)parentElement, versions);
+ }
+ }
+ return new Object[]{};
+ }
+
+ protected BPELVersionDeployment[] wrap(ModuleServer ms, String[] vals) {
+ BPELVersionDeployment[] versions = new BPELVersionDeployment[vals.length];
+ for( int i = 0; i < vals.length; i++ ) {
+ versions[i] = new BPELVersionDeployment(ms, vals[i]);
+ }
+ return versions;
+ }
+
+ public static class BPELVersionDeployment {
+ private String path;
+ private ModuleServer ms;
+ public BPELVersionDeployment(ModuleServer ms, String path) {
+ this.path = path;
+ this.ms = ms;
+ }
+ public String getPath() { return path; }
+ public ModuleServer getModuleServer() { return ms; }
+ public IProject getProject() {
+ if( ms.module != null && ms.module.length > 0 )
+ return ms.module[ms.module.length-1].getProject();
+ return null;
+ }
+ }
+
+ public Object getParent(Object element) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public boolean hasChildren(Object element) {
+ return getChildren(element).length > 0;
+ }
+
+ public Object[] getElements(Object inputElement) {
+ return getChildren(inputElement);
+ }
+
+ public void dispose() {
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ // TODO Auto-generated method stub
+
+ }
+
+}
Added:
trunk/bpel/plugins/org.jboss.tools.bpel.runtimes/src/org/jboss/tools/bpel/runtimes/ui/view/server/BPELModuleLabelProvider.java
===================================================================
---
trunk/bpel/plugins/org.jboss.tools.bpel.runtimes/src/org/jboss/tools/bpel/runtimes/ui/view/server/BPELModuleLabelProvider.java
(rev 0)
+++
trunk/bpel/plugins/org.jboss.tools.bpel.runtimes/src/org/jboss/tools/bpel/runtimes/ui/view/server/BPELModuleLabelProvider.java 2009-11-19
04:58:20 UTC (rev 18740)
@@ -0,0 +1,20 @@
+package org.jboss.tools.bpel.runtimes.ui.view.server;
+
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.graphics.Image;
+import
org.jboss.tools.bpel.runtimes.ui.view.server.BPELModuleContentProvider.BPELVersionDeployment;
+
+public class BPELModuleLabelProvider extends LabelProvider {
+ public Image getImage(Object element) {
+ // TODO Add an icon
+ return null;
+ }
+
+ public String getText(Object element) {
+ if( element instanceof BPELVersionDeployment ) {
+ return new Path(((BPELVersionDeployment)element).getPath()).lastSegment();
+ }
+ return element == null ? "" : element.toString();//$NON-NLS-1$
+ }
+}