Author: rob.stryker(a)jboss.com
Date: 2010-07-20 05:55:16 -0400 (Tue, 20 Jul 2010)
New Revision: 23582
Added:
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/DeploymentModuleOptionCompositeAssistant.java
Removed:
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/LocalDeploymentModuleTab.java
Modified:
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.archives.webtools/META-INF/MANIFEST.MF
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/META-INF/MANIFEST.MF
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/ExtensionManager.java
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/LocalPublishMethod.java
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/PublishUtil.java
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IJBossServerPublishMethod.java
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/DeployableServerBehavior.java
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/xpl/PublishCopyUtil.java
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/DeploymentPreferenceLoader.java
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/IJBossToolingConstants.java
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/plugin.properties
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/plugin.xml
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/schema/publishMethod.exsd
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.ssh/plugin.xml
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.ssh/src/org/jboss/ide/eclipse/as/ssh/server/SSHServerBehaviourDelegate.java
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.ui/META-INF/MANIFEST.MF
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/IDeploymentEditorTab.java
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/ModuleDeploymentPage.java
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml
Log:
trying to update rse branch
Modified:
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.archives.webtools/META-INF/MANIFEST.MF
===================================================================
---
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.archives.webtools/META-INF/MANIFEST.MF 2010-07-20
09:27:46 UTC (rev 23581)
+++
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.archives.webtools/META-INF/MANIFEST.MF 2010-07-20
09:55:16 UTC (rev 23582)
@@ -27,7 +27,10 @@
org.jboss.ide.eclipse.as.wtp.core,
org.jboss.ide.eclipse.as.wtp.ui,
org.eclipse.emf.common;bundle-version="2.5.0",
- org.eclipse.emf.ecore;bundle-version="2.5.0"
+ org.eclipse.emf.ecore;bundle-version="2.5.0",
+ org.eclipse.rse.core;bundle-version="3.1.100";resolution:=optional,
+
org.eclipse.rse.subsystems.files.core;bundle-version="3.2.0";resolution:=optional,
+ org.eclipse.rse.services;bundle-version="3.2.0";resolution:=optional
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Export-Package: org.jboss.ide.eclipse.archives.webtools,
Modified:
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/META-INF/MANIFEST.MF
===================================================================
---
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/META-INF/MANIFEST.MF 2010-07-20
09:27:46 UTC (rev 23581)
+++
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/META-INF/MANIFEST.MF 2010-07-20
09:55:16 UTC (rev 23582)
@@ -22,7 +22,13 @@
org.eclipse.wst.common.project.facet.core,
org.eclipse.wst.common.frameworks,
org.eclipse.jst.jee,
- org.eclipse.core.commands
+ org.eclipse.core.commands,
+ org.eclipse.rse.core;bundle-version="3.1.100",
+ org.eclipse.rse.subsystems.files.core;bundle-version="3.2.0",
+ org.eclipse.rse.services;bundle-version="3.2.0",
+ org.eclipse.rse.services.files.ftp;bundle-version="3.0.200",
+ org.eclipse.rse.services.local;bundle-version="2.1.200",
+ org.eclipse.rse.services.ssh;bundle-version="3.0.1"
Bundle-ActivationPolicy: lazy
Export-Package: org.jboss.ide.eclipse.as.core,
org.jboss.ide.eclipse.as.core.extensions.descriptors,
@@ -35,7 +41,8 @@
org.jboss.ide.eclipse.as.core.server.internal,
org.jboss.ide.eclipse.as.core.server.internal.launch,
org.jboss.ide.eclipse.as.core.server.xpl,
- org.jboss.ide.eclipse.as.core.util
+ org.jboss.ide.eclipse.as.core.util,
+ org.jboss.ide.eclipse.as.rse.core
Bundle-ClassPath: dom4j-1.6.1.jar,
jaxen-1.1-beta-6.jar,
getopt.jar,
Modified:
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/ExtensionManager.java
===================================================================
---
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/ExtensionManager.java 2010-07-20
09:27:46 UTC (rev 23581)
+++
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/ExtensionManager.java 2010-07-20
09:55:16 UTC (rev 23582)
@@ -11,6 +11,7 @@
package org.jboss.ide.eclipse.as.core;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
@@ -24,9 +25,11 @@
import org.eclipse.core.runtime.Platform;
import org.eclipse.wst.server.core.IModule;
import org.eclipse.wst.server.core.IServer;
+import org.jboss.ide.eclipse.as.core.server.IJBossServerPublishMethodType;
import org.jboss.ide.eclipse.as.core.server.IJBossServerPublisher;
import org.jboss.ide.eclipse.as.core.server.IPollerFailureHandler;
import org.jboss.ide.eclipse.as.core.server.IServerStatePoller;
+import org.jboss.ide.eclipse.as.core.server.internal.ServerPublishMethodType;
import org.jboss.ide.eclipse.as.core.server.internal.ServerStatePollerType;
/**
@@ -214,4 +217,40 @@
return publisher;
}
}
+
+ private ServerPublishMethodType[] publishMethodTypes;
+ public ServerPublishMethodType[] getPublishMethodTypes() {
+ if(publishMethodTypes == null )
+ publishMethodTypes = loadPublishMethodTypes();
+ return publishMethodTypes;
+ }
+
+ public ServerPublishMethodType[] loadPublishMethodTypes() {
+ ArrayList<ServerPublishMethodType> types = new
ArrayList<ServerPublishMethodType>();
+ IExtensionRegistry registry = Platform.getExtensionRegistry();
+ IConfigurationElement[] cf =
registry.getConfigurationElementsFor(JBossServerCorePlugin.PLUGIN_ID,
"publishMethod"); //$NON-NLS-1$
+ for( int i = 0; i < cf.length; i++ ) {
+ types.add(new ServerPublishMethodType(cf[i]));
+ }
+ return types.toArray(new ServerPublishMethodType[types.size()]);
+ }
+
+ public IJBossServerPublishMethodType getPublishMethod(String id) {
+ ServerPublishMethodType[] publishMethods = getPublishMethodTypes();
+ for( int i = 0; i < publishMethods.length; i++ )
+ if( publishMethods[i].getId().equals(id))
+ return publishMethods[i];
+ return null;
+ }
+
+ public IJBossServerPublishMethodType[] findPossiblePublishMethods(IServer server) {
+ ArrayList<IJBossServerPublishMethodType> list = new
ArrayList<IJBossServerPublishMethodType>();
+ list.addAll(Arrays.asList(getPublishMethodTypes()));
+ Iterator<IJBossServerPublishMethodType> i = list.iterator();
+ while(i.hasNext()) {
+ if( !i.next().accepts(server.getServerType().getId()))
+ i.remove();
+ }
+ return list.toArray(new IJBossServerPublishMethodType[list.size()]);
+ }
}
Modified:
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/LocalPublishMethod.java
===================================================================
---
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/LocalPublishMethod.java 2010-07-20
09:27:46 UTC (rev 23581)
+++
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/LocalPublishMethod.java 2010-07-20
09:55:16 UTC (rev 23582)
@@ -1,90 +1,21 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.ide.eclipse.as.core.publishers;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.wst.server.core.IModule;
-import org.eclipse.wst.server.core.IServer;
-import org.eclipse.wst.server.core.model.IModuleResourceDelta;
-import org.eclipse.wst.server.core.model.ServerBehaviourDelegate;
-import org.jboss.ide.eclipse.as.core.ExtensionManager;
-import org.jboss.ide.eclipse.as.core.extensions.events.ServerLogger;
-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.internal.DeployableServerBehavior;
-public class LocalPublishMethod implements IJBossServerPublishMethod {
+public class LocalPublishMethod extends AbstractPublishMethod {
public static final String LOCAL_PUBLISH_METHOD = "local"; //$NON-NLS-1$
-
+
+ @Override
public String getPublishMethodId() {
return LOCAL_PUBLISH_METHOD;
}
-
- public boolean accepts(String methodType) {
- return getPublishMethodId().equals(methodType);
- }
-
- public void publishStart(DeployableServerBehavior behaviour,
- IProgressMonitor monitor) throws CoreException {
- }
-
- public int publishFinish(DeployableServerBehavior behaviour,
- IProgressMonitor monitor) throws CoreException {
- IModule[] modules = behaviour.getServer().getModules();
- boolean allpublished= true;
- for (int i = 0; i < modules.length; i++) {
- if(behaviour.getServer().getModulePublishState(new
IModule[]{modules[i]})!=IServer.PUBLISH_STATE_NONE)
- allpublished=false;
- }
- return allpublished ? IServer.PUBLISH_STATE_NONE :
IServer.PUBLISH_STATE_INCREMENTAL;
- }
-
- public int getServerPublishState(DeployableServerBehavior behaviour) {
- IModule[] modules = behaviour.getServer().getModules();
- boolean allpublished= true;
- for (int i = 0; i < modules.length; i++) {
- if(behaviour.getServer().getModulePublishState(new
IModule[]{modules[i]})!=IServer.PUBLISH_STATE_NONE)
- allpublished=false;
- }
- if(allpublished)
- return IServer.PUBLISH_STATE_NONE;
- return IServer.PUBLISH_STATE_INCREMENTAL;
- }
-
- public int publishModule(DeployableServerBehavior behaviour, int kind,
- int deltaKind, IModule[] module, IProgressMonitor monitor)
- throws CoreException {
- // kind = [incremental, full, auto, clean] = [1,2,3,4]
- // delta = [no_change, added, changed, removed] = [0,1,2,3]
- if( module.length == 0 ) return IServer.PUBLISH_STATE_NONE;
- int modulePublishState = behaviour.getServer().getModulePublishState(module);
- int publishType = behaviour.getPublishType(kind, deltaKind, modulePublishState);
- IJBossServerPublisher publisher;
-
- // Let the publisher decide what to do
- if( module.length > 0 ) {
- publisher = ExtensionManager.getDefault().getPublisher(behaviour.getServer(), module,
getPublishMethodId());
- IModuleResourceDelta[] deltas = new IModuleResourceDelta[]{};
- if( deltaKind != ServerBehaviourDelegate.REMOVED)
- deltas = behaviour.getPublishedResourceDelta(module);
- if( publisher != null ) {
- try {
- IStatus result = publisher.publishModule(
- this,
- behaviour.getServer(), module,
- publishType, deltas, monitor);
- if( result != null )
- ServerLogger.getDefault().log(behaviour.getServer(), result);
- } catch( CoreException ce) {
- // Let the user know
- ServerLogger.getDefault().log(behaviour.getServer(), ce.getStatus());
- throw ce;
- }
- return publisher.getPublishState();
- }
- return IServer.PUBLISH_STATE_INCREMENTAL;
- }
- return IServer.PUBLISH_STATE_NONE;
- }
-
}
Modified:
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/PublishUtil.java
===================================================================
---
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/PublishUtil.java 2010-07-20
09:27:46 UTC (rev 23581)
+++
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/PublishUtil.java 2010-07-20
09:55:16 UTC (rev 23582)
@@ -80,12 +80,18 @@
return count;
}
+
public static String getDeployRootFolder(IModule[] moduleTree,
IDeployableServer server, String defaultFolder, String moduleProperty) {
+ return getDeployRootFolder(moduleTree, LocalPublishMethod.LOCAL_PUBLISH_METHOD, server,
defaultFolder, moduleProperty);
+ }
+
+ public static String getDeployRootFolder(IModule[] moduleTree, String publishMethod,
+ IDeployableServer server, String defaultFolder, String moduleProperty) {
String folder = defaultFolder;
// TODO bug 286699
DeploymentPreferences prefs =
DeploymentPreferenceLoader.loadPreferencesFromServer(server.getServer());
- DeploymentTypePrefs typePrefs = prefs.getOrCreatePreferences("local");
//$NON-NLS-1$
+ DeploymentTypePrefs typePrefs = prefs.getOrCreatePreferences(publishMethod);
DeploymentModulePrefs modPrefs = typePrefs.getModulePrefs(moduleTree[0]);
if( modPrefs != null ) {
String loc = modPrefs.getProperty(moduleProperty);
@@ -234,18 +240,23 @@
* Just package into a jar raw. Don't think about it, just do it
*/
public static IStatus[] packModuleIntoJar(IModule module, IPath destination)throws
CoreException {
+ ProjectModule pm = (ProjectModule) module.loadAdapter(ProjectModule.class, null);
+ IModuleResource[] resources = pm.members();
+ return packModuleIntoJar(module.getName(), resources, destination);
+ }
+
+ public static IStatus[] packModuleIntoJar(String moduleName, IModuleResource[]
resources, IPath destination)throws CoreException {
+
String dest = destination.toString();
ModulePackager packager = null;
try {
packager = new ModulePackager(dest, false);
- ProjectModule pm = (ProjectModule) module.loadAdapter(ProjectModule.class, null);
- IModuleResource[] resources = pm.members();
for (int i = 0; i < resources.length; i++) {
doPackModule(resources[i], packager);
}
} catch (IOException e) {
IStatus status = new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID,
IEventCodes.JST_PUB_ASSEMBLE_FAIL,
- "unable to assemble module " + module.getName(), e); //$NON-NLS-1$
+ "unable to assemble module " + moduleName, e); //$NON-NLS-1$
return new IStatus[]{status};
}
finally{
@@ -255,7 +266,7 @@
}
catch(IOException e){
IStatus status = new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID,
IEventCodes.JST_PUB_ASSEMBLE_FAIL,
- "unable to assemble module "+ module.getName(), e); //$NON-NLS-1$
+ "unable to assemble module "+ moduleName, e); //$NON-NLS-1$
return new IStatus[]{status};
}
}
Modified:
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IJBossServerPublishMethod.java
===================================================================
---
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IJBossServerPublishMethod.java 2010-07-20
09:27:46 UTC (rev 23581)
+++
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IJBossServerPublishMethod.java 2010-07-20
09:55:16 UTC (rev 23582)
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.ide.eclipse.as.core.server;
import org.eclipse.core.runtime.CoreException;
@@ -3,9 +13,9 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.wst.server.core.IModule;
+import org.eclipse.wst.server.core.IServer;
import org.jboss.ide.eclipse.as.core.server.internal.DeployableServerBehavior;
public interface IJBossServerPublishMethod {
- public String getPublishMethodId();
- public boolean accepts(String methodType);
+ public IJBossServerPublishMethodType getPublishMethodType();
public void publishStart(DeployableServerBehavior behaviour, IProgressMonitor monitor)
throws CoreException;
public int publishFinish(DeployableServerBehavior behaviour, IProgressMonitor monitor)
throws CoreException;
Modified:
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/DeployableServerBehavior.java
===================================================================
---
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/DeployableServerBehavior.java 2010-07-20
09:27:46 UTC (rev 23581)
+++
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/DeployableServerBehavior.java 2010-07-20
09:55:16 UTC (rev 23582)
@@ -26,8 +26,10 @@
import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
import org.jboss.ide.eclipse.as.core.publishers.LocalPublishMethod;
import org.jboss.ide.eclipse.as.core.server.IJBossServerPublishMethod;
+import org.jboss.ide.eclipse.as.core.server.IJBossServerPublishMethodType;
import org.jboss.ide.eclipse.as.core.server.IJBossServerPublisher;
import
org.jboss.ide.eclipse.as.core.server.internal.launch.DeployableLaunchConfiguration;
+import org.jboss.ide.eclipse.as.core.util.DeploymentPreferenceLoader;
public class DeployableServerBehavior extends ServerBehaviourDelegate {
@@ -73,8 +75,11 @@
*
* @return
*/
- protected IJBossServerPublishMethod createPublishMethod() {
- return new LocalPublishMethod(); // TODO FIX THIS
+ public IJBossServerPublishMethod createPublishMethod() {
+ IJBossServerPublishMethodType type =
DeploymentPreferenceLoader.getCurrentDeploymentMethodType(getServer());
+ if( type != null )
+ return type.createPublishMethod();
+ return new LocalPublishMethod(); // sensible default
}
public IModuleResourceDelta[] getPublishedResourceDelta(IModule[] module) {
Modified:
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/xpl/PublishCopyUtil.java
===================================================================
---
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/xpl/PublishCopyUtil.java 2010-07-20
09:27:46 UTC (rev 23581)
+++
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/xpl/PublishCopyUtil.java 2010-07-20
09:55:16 UTC (rev 23582)
@@ -563,7 +563,7 @@
IModuleFile mf = (IModuleFile) resource;
path = path.append(mf.getModuleRelativePath()).append(name);
IStatus[] stats = handler.makeDirectoryIfRequired(path.removeLastSegments(1),
monitor);
- if( stats.length > 0 && !stats[0].isOK())
+ if( stats != null && stats.length > 0 && !stats[0].isOK())
addArrayToList(status, stats);
addArrayToList(status, handler.copyFile(mf, path, monitor));
Modified:
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/DeploymentPreferenceLoader.java
===================================================================
---
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/DeploymentPreferenceLoader.java 2010-07-20
09:27:46 UTC (rev 23581)
+++
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/DeploymentPreferenceLoader.java 2010-07-20
09:55:16 UTC (rev 23582)
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.ide.eclipse.as.core.util;
import java.io.ByteArrayInputStream;
@@ -13,12 +23,24 @@
import org.eclipse.wst.server.core.IModule;
import org.eclipse.wst.server.core.IServer;
import org.eclipse.wst.server.core.internal.Server;
+import org.jboss.ide.eclipse.as.core.ExtensionManager;
+import org.jboss.ide.eclipse.as.core.server.IJBossServerPublishMethodType;
import org.jboss.tools.jmx.core.IMemento;
import org.jboss.tools.jmx.core.util.XMLMemento;
public class DeploymentPreferenceLoader {
public static final String DEPLOYMENT_PREFERENCES_KEY =
"org.jboss.ide.eclipse.as.core.util.deploymentPreferenceKey"; //$NON-NLS-1$
+ public static final String CURRENT_METHOD_PROPERTY = "publishMethod";
//$NON-NLS-1$
+ public static IJBossServerPublishMethodType getCurrentDeploymentMethodType(IServer
server) {
+ DeploymentPreferences prefs =
DeploymentPreferenceLoader.loadPreferencesFromServer(server);
+ String type = prefs.getProperty(DeploymentPreferenceLoader.CURRENT_METHOD_PROPERTY);
+ if( type != null ) {
+ return ExtensionManager.getDefault().getPublishMethod(type);
+ }
+ return null;
+ }
+
public static DeploymentPreferences loadPreferencesFromFile(IServer server) {
File f = getFile(server);
InputStream is = null;
@@ -92,6 +114,30 @@
protected XMLMemento getMemento() {
return memento;
}
+ public String getProperty(String key) {
+ IMemento[] children = memento.getChildren("property"); //$NON-NLS-1$
+ for( int i = 0; i < children.length; i++ ) {
+ if( key.equals(children[i].getString("key"))) { //$NON-NLS-1$
+ return children[i].getString("value"); //$NON-NLS-1$
+ }
+ }
+ return null;
+ }
+
+ public void setProperty(String key, String val) {
+ IMemento[] children = memento.getChildren("property"); //$NON-NLS-1$
+ for( int i = 0; i < children.length; i++ ) {
+ if( key.equals(children[i].getString("key"))) { //$NON-NLS-1$
+ children[i].putString("key", key); //$NON-NLS-1$
+ children[i].putString("value", val);//$NON-NLS-1$
+ return;
+ }
+ }
+ // not found
+ IMemento child = memento.createChild("property"); //$NON-NLS-1$
+ child.putString("key", key);//$NON-NLS-1$
+ child.putString("value", val);//$NON-NLS-1$
+ }
}
public static class DeploymentTypePrefs {
@@ -107,7 +153,6 @@
String id = mementos[i].getString("id"); //$NON-NLS-1$
this.children.put(id, new DeploymentModulePrefs(id, mementos[i]));
}
- // TODO properties?
}
public DeploymentModulePrefs getModulePrefs(IModule module) {
@@ -123,6 +168,31 @@
}
return children.get(module.getId());
}
+
+ public String getProperty(String key) {
+ IMemento[] children = memento.getChildren("property"); //$NON-NLS-1$
+ for( int i = 0; i < children.length; i++ ) {
+ if( key.equals(children[i].getString("key"))) { //$NON-NLS-1$
+ return children[i].getString("value"); //$NON-NLS-1$
+ }
+ }
+ return null;
+ }
+
+ public void setProperty(String key, String val) {
+ IMemento[] children = memento.getChildren("property"); //$NON-NLS-1$
+ for( int i = 0; i < children.length; i++ ) {
+ if( key.equals(children[i].getString("key"))) { //$NON-NLS-1$
+ children[i].putString("key", key); //$NON-NLS-1$
+ children[i].putString("value", val);//$NON-NLS-1$
+ return;
+ }
+ }
+ // not found
+ IMemento child = memento.createChild("property"); //$NON-NLS-1$
+ child.putString("key", key);//$NON-NLS-1$
+ child.putString("value", val);//$NON-NLS-1$
+ }
}
public static class DeploymentModulePrefs {
private String id;
Modified:
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/IJBossToolingConstants.java
===================================================================
---
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/IJBossToolingConstants.java 2010-07-20
09:27:46 UTC (rev 23581)
+++
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/IJBossToolingConstants.java 2010-07-20
09:55:16 UTC (rev 23582)
@@ -48,6 +48,7 @@
/* Files or folders inside the TOOLING */
public static final String LOG = "log"; //$NON-NLS-1$
public static final String TEMP_DEPLOY = "tempDeploy"; //$NON-NLS-1$
+ public static final String TEMP_REMOTE_DEPLOY = "tempRemoteDeploy";
//$NON-NLS-1$
public static final String JBOSSTOOLS_TMP = "jbosstoolsTemp"; //$NON-NLS-1$
public static final String TMP = "tmp"; //$NON-NLS-1$
public static final String CONFIG_IN_METADATA = "jbossConfig"; //$NON-NLS-1$
@@ -72,7 +73,6 @@
/*
* Property keys stored in the server object
*/
- public static final String DEPLOYMENT_METHOD =
"org.jboss.ide.eclipse.as.core.server.attributes.deploymentMethod";
//$NON-NLS-1$
public static final String STARTUP_POLLER_KEY =
"org.jboss.ide.eclipse.as.core.server.attributes.startupPollerKey";
//$NON-NLS-1$
public static final String SHUTDOWN_POLLER_KEY =
"org.jboss.ide.eclipse.as.core.server.attributes.shutdownPollerKey";
//$NON-NLS-1$
public static final String SERVER_USERNAME =
"org.jboss.ide.eclipse.as.core.server.userName"; //$NON-NLS-1$
Modified:
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/plugin.properties
===================================================================
---
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/plugin.properties 2010-07-20
09:27:46 UTC (rev 23581)
+++
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/plugin.properties 2010-07-20
09:55:16 UTC (rev 23582)
@@ -43,4 +43,9 @@
deploy.server.description=A server which only provides a deploy folder for publishing.
Bundle-Vendor.0 = JBoss by Red Hat
-Bundle-Name.0 = JBoss AS Core Plug-in
\ No newline at end of file
+Bundle-Name.0 = JBoss AS Core Plug-in
+
+AllJBossRuntimeTypes=org.jboss.ide.eclipse.as.runtime.32,org.jboss.ide.eclipse.as.runtime.40,org.jboss.ide.eclipse.as.runtime.42,org.jboss.ide.eclipse.as.runtime.50,org.jboss.ide.eclipse.as.runtime.51,org.jboss.ide.eclipse.as.runtime.60,org.jboss.ide.eclipse.as.runtime.eap.43,org.jboss.ide.eclipse.as.runtime.eap.50
+AllJBossServerTypes=org.jboss.ide.eclipse.as.32,org.jboss.ide.eclipse.as.40,org.jboss.ide.eclipse.as.42,org.jboss.ide.eclipse.as.50,org.jboss.ide.eclipse.as.51,org.jboss.ide.eclipse.as.60,org.jboss.ide.eclipse.as.eap.43,org.jboss.ide.eclipse.as.eap.50
+AllJBTServerTypes=org.jboss.ide.eclipse.as.32,org.jboss.ide.eclipse.as.40,org.jboss.ide.eclipse.as.42,org.jboss.ide.eclipse.as.50,org.jboss.ide.eclipse.as.51,org.jboss.ide.eclipse.as.60,org.jboss.ide.eclipse.as.eap.43,org.jboss.ide.eclipse.as.eap.50,org.jboss.ide.eclipse.as.systemCopyServer
+ServerTypesJBoss6OrHigher=org.jboss.ide.eclipse.as.60
Modified: workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/plugin.xml
===================================================================
--- workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/plugin.xml 2010-07-20
09:27:46 UTC (rev 23581)
+++ workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/plugin.xml 2010-07-20
09:55:16 UTC (rev 23582)
@@ -1038,4 +1038,36 @@
supportsArgument="true">
</variable>
</extension>
+ <extension
+ point="org.jboss.ide.eclipse.as.core.publishMethod">
+ <publishMethod
+ id="local"
+ name="Local"
+
class="org.jboss.ide.eclipse.as.core.publishers.LocalPublishMethod"
+ serverTypes="%AllJBTServerTypes">
+ </publishMethod>
+ </extension>
+
+
+ <!-- Below here is RSE stuff which can / should be moved if a new plugin is created
-->
+ <extension
+ point="org.jboss.ide.eclipse.as.core.publishMethod">
+ <publishMethod
+ class="org.jboss.ide.eclipse.as.rse.core.RSEPublishMethod"
+ id="rse"
+ name="Remote System Deployment"
+ serverTypes="%AllJBTServerTypes">
+ </publishMethod>
+ </extension>
+ <extension
+ point="org.jboss.ide.eclipse.as.core.publishers">
+ <publisher
+ class="org.jboss.ide.eclipse.as.rse.core.SingleFileRSEPublisher"
+ priority="7">
+ </publisher>
+ <publisher
+ class="org.jboss.ide.eclipse.as.rse.core.RSEJSTPublisher"
+ priority="5">
+ </publisher>
+ </extension>
</plugin>
Modified:
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/schema/publishMethod.exsd
===================================================================
---
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/schema/publishMethod.exsd 2010-07-20
09:27:46 UTC (rev 23581)
+++
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/schema/publishMethod.exsd 2010-07-20
09:55:16 UTC (rev 23582)
@@ -49,6 +49,20 @@
<element name="publishMethod">
<complexType>
+ <attribute name="id" type="string"
use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string"
use="required">
+ <annotation>
+ <documentation>
+ String representation of this publish method
+ </documentation>
+ </annotation>
+ </attribute>
<attribute name="class" type="string"
use="required">
<annotation>
<documentation>
@@ -59,6 +73,13 @@
</appInfo>
</annotation>
</attribute>
+ <attribute name="serverTypes" type="string"
use="required">
+ <annotation>
+ <documentation>
+ A list of comma-separated server types this publish method is available
to.
+ </documentation>
+ </annotation>
+ </attribute>
</complexType>
</element>
Modified: workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.ssh/plugin.xml
===================================================================
--- workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.ssh/plugin.xml 2010-07-20
09:27:46 UTC (rev 23581)
+++ workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.ssh/plugin.xml 2010-07-20
09:55:16 UTC (rev 23582)
@@ -112,5 +112,14 @@
typeIds="org.jboss.ide.eclipse.as.ssh.server.remoteServerType">
</fragment>
</extension>
+ <extension
+ point="org.jboss.ide.eclipse.as.core.publishMethod">
+ <publishMethod
+
class="org.jboss.ide.eclipse.as.ssh.server.SSHServerBehaviourDelegate$SSHPublishMethod"
+ id="ssh"
+ name="SSH Remote Deployment"
+
serverTypes="org.jboss.ide.eclipse.as.ssh.server.remoteServerType">
+ </publishMethod>
+ </extension>
</plugin>
Modified:
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.ssh/src/org/jboss/ide/eclipse/as/ssh/server/SSHServerBehaviourDelegate.java
===================================================================
---
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.ssh/src/org/jboss/ide/eclipse/as/ssh/server/SSHServerBehaviourDelegate.java 2010-07-20
09:27:46 UTC (rev 23581)
+++
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.ssh/src/org/jboss/ide/eclipse/as/ssh/server/SSHServerBehaviourDelegate.java 2010-07-20
09:55:16 UTC (rev 23582)
@@ -16,8 +16,10 @@
import org.eclipse.core.runtime.Status;
import org.eclipse.wst.server.core.IServer;
import org.eclipse.wst.server.core.ServerCore;
+import org.jboss.ide.eclipse.as.core.ExtensionManager;
import org.jboss.ide.eclipse.as.core.publishers.LocalPublishMethod;
import org.jboss.ide.eclipse.as.core.server.IJBossServerPublishMethod;
+import org.jboss.ide.eclipse.as.core.server.IJBossServerPublishMethodType;
import org.jboss.ide.eclipse.as.core.server.internal.DeployableServerBehavior;
import org.jboss.ide.eclipse.as.ssh.SSHDeploymentPlugin;
@@ -37,24 +39,22 @@
setServerState(IServer.STATE_STOPPED);
}
- protected IJBossServerPublishMethod createPublishMethod() {
+ @Override
+ public IJBossServerPublishMethod createPublishMethod() {
return new SSHPublishMethod(); // TODO FIX THIS in superclass
}
public class SSHPublishMethod extends LocalPublishMethod {
public static final String SSH_PUBLISH_METHOD = "ssh"; //$NON-NLS-1$
-
- @Override
- public String getPublishMethodId() {
- return SSH_PUBLISH_METHOD;
- }
-
private Session session;
public Session getSession() {
return session;
}
-
@Override
+ public IJBossServerPublishMethodType getPublishMethodType() {
+ return ExtensionManager.getDefault().getPublishMethod(SSH_PUBLISH_METHOD);
+ }
+ @Override
public void publishStart(DeployableServerBehavior behaviour,
IProgressMonitor monitor) throws CoreException {
Modified:
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.ui/META-INF/MANIFEST.MF
===================================================================
---
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.ui/META-INF/MANIFEST.MF 2010-07-20
09:27:46 UTC (rev 23581)
+++
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.ui/META-INF/MANIFEST.MF 2010-07-20
09:55:16 UTC (rev 23582)
@@ -52,7 +52,8 @@
org.eclipse.ui.views.log,
org.jboss.tools.jmx.ui,
org.jboss.tools.jmx.core,
- org.eclipse.jst.j2ee.core
+ org.eclipse.jst.j2ee.core,
+ org.eclipse.rse.ui;bundle-version="3.1.100"
Bundle-ActivationPolicy: lazy
Export-Package: org.jboss.ide.eclipse.as.ui,
org.jboss.ide.eclipse.as.ui.dialogs,
Copied:
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/DeploymentModuleOptionCompositeAssistant.java
(from rev 23242,
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/LocalDeploymentModuleTab.java)
===================================================================
---
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/DeploymentModuleOptionCompositeAssistant.java
(rev 0)
+++
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/DeploymentModuleOptionCompositeAssistant.java 2010-07-20
09:55:16 UTC (rev 23582)
@@ -0,0 +1,705 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.ide.eclipse.as.ui.editor;
+
+import java.io.File;
+
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.jface.viewers.ICellModifier;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.TextCellEditor;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormLayout;
+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.Control;
+import org.eclipse.swt.widgets.DirectoryDialog;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.swt.widgets.TreeColumn;
+import org.eclipse.swt.widgets.TreeItem;
+import org.eclipse.ui.forms.IFormColors;
+import org.eclipse.ui.forms.widgets.ExpandableComposite;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.Section;
+import org.eclipse.wst.server.core.IModule;
+import org.eclipse.wst.server.core.IRuntime;
+import org.eclipse.wst.server.ui.ServerUICore;
+import org.eclipse.wst.server.ui.internal.command.ServerCommand;
+import org.jboss.ide.eclipse.as.core.ExtensionManager;
+import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
+import org.jboss.ide.eclipse.as.core.publishers.LocalPublishMethod;
+import org.jboss.ide.eclipse.as.core.server.IDeployableServer;
+import org.jboss.ide.eclipse.as.core.server.IJBossServerConstants;
+import org.jboss.ide.eclipse.as.core.server.IJBossServerPublisher;
+import org.jboss.ide.eclipse.as.core.server.IJBossServerRuntime;
+import org.jboss.ide.eclipse.as.core.server.internal.ServerAttributeHelper;
+import
org.jboss.ide.eclipse.as.core.util.DeploymentPreferenceLoader.DeploymentModulePrefs;
+import
org.jboss.ide.eclipse.as.core.util.DeploymentPreferenceLoader.DeploymentPreferences;
+import org.jboss.ide.eclipse.as.core.util.IJBossToolingConstants;
+import org.jboss.ide.eclipse.as.ui.Messages;
+
+public class DeploymentModuleOptionCompositeAssistant {
+ private ModuleDeploymentPage page;
+ private DeploymentPreferences preferences;
+ private TreeViewer viewer;
+ protected String COLUMN_NAME;
+ protected String COLUMN_LOC;
+ protected String COLUMN_TEMP_LOC;
+ protected String currentDeployType;
+
+ public DeploymentModuleOptionCompositeAssistant() {
+ COLUMN_NAME = IJBossToolingConstants.LOCAL_DEPLOYMENT_NAME;
+ COLUMN_LOC = IJBossToolingConstants.LOCAL_DEPLOYMENT_LOC;
+ COLUMN_TEMP_LOC = IJBossToolingConstants.LOCAL_DEPLOYMENT_TEMP_LOC;
+ currentDeployType = LocalPublishMethod.LOCAL_PUBLISH_METHOD;
+ }
+
+ public String getCurrentDeployType() {
+ return currentDeployType;
+ }
+
+ public void setCurrentDeployType(String type) {
+ this.currentDeployType = type;
+ }
+
+ public void setDeploymentPage(ModuleDeploymentPage page) {
+ this.page = page;
+ }
+
+ public void setDeploymentPrefs(DeploymentPreferences prefs) {
+ this.preferences = prefs;
+ }
+
+ protected ServerAttributeHelper getHelper() {
+ return page.getHelper();
+ }
+
+ private Text deployText, tempDeployText;
+ private Button metadataRadio, serverRadio, customRadio, currentSelection;
+ private Button deployButton, tempDeployButton;
+ private ModifyListener deployListener, tempDeployListener;
+ private SelectionListener radioListener, zipListener;
+ private Button zipDeployWTPProjects;
+ private String lastCustomDeploy, lastCustomTemp;
+
+ protected Composite createDefaultComposite(Composite parent) {
+
+ FormToolkit toolkit = new FormToolkit(parent.getDisplay());
+
+ Section section = toolkit.createSection(parent,
+ ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED
+ | ExpandableComposite.TITLE_BAR);
+ section.setText(Messages.swf_DeployEditorHeading);
+ section.setLayoutData(new GridData(GridData.FILL_HORIZONTAL
+ | GridData.VERTICAL_ALIGN_FILL));
+
+ Composite composite = toolkit.createComposite(section);
+
+ composite.setLayout(new FormLayout());
+
+ Label descriptionLabel = toolkit.createLabel(composite,
+ Messages.swf_DeploymentDescription);
+ Control top = descriptionLabel;
+ Composite inner = toolkit.createComposite(composite);
+ inner.setLayout(new GridLayout(1, false));
+
+ IRuntime rt = getServer().getServer().getRuntime();
+ boolean showRadios = true;
+ if( rt == null )
+ showRadios = false;
+ else {
+ IJBossServerRuntime jbsrt =
(IJBossServerRuntime)rt.loadAdapter(IJBossServerRuntime.class, new
NullProgressMonitor());
+ if( jbsrt == null )
+ showRadios = false;
+ }
+
+ if( showRadios ) {
+ metadataRadio = toolkit.createButton(inner,
+ Messages.EditorUseWorkspaceMetadata, SWT.RADIO);
+ serverRadio = toolkit.createButton(inner,
+ Messages.EditorUseServersDeployFolder, SWT.RADIO);
+ customRadio = toolkit.createButton(inner,
+ Messages.EditorUseCustomDeployFolder, SWT.RADIO);
+
+ metadataRadio.setSelection(getDeployType().equals(
+ IDeployableServer.DEPLOY_METADATA));
+ serverRadio.setSelection(getDeployType().equals(
+ IDeployableServer.DEPLOY_SERVER));
+ customRadio.setSelection(getDeployType().equals(
+ IDeployableServer.DEPLOY_CUSTOM));
+ currentSelection = metadataRadio.getSelection() ? metadataRadio
+ : serverRadio.getSelection() ? serverRadio : customRadio;
+
+ radioListener = new SelectionListener() {
+ public void widgetDefaultSelected(SelectionEvent e) {
+ widgetSelected(e);
+ }
+
+ public void widgetSelected(SelectionEvent e) {
+ if (e.getSource() == currentSelection)
+ return; // do nothing
+ page.execute(new RadioClickedCommand((Button) e.getSource(),
+ currentSelection));
+ currentSelection = (Button) e.getSource();
+ }
+ };
+ metadataRadio.addSelectionListener(radioListener);
+ serverRadio.addSelectionListener(radioListener);
+ customRadio.addSelectionListener(radioListener);
+ }
+
+ FormData radios = new FormData();
+ radios.top = new FormAttachment(descriptionLabel, 5);
+ radios.left = new FormAttachment(0, 5);
+ radios.right = new FormAttachment(100, -5);
+ inner.setLayoutData(radios);
+ top = inner;
+
+ Label label = toolkit.createLabel(composite,
+ Messages.swf_DeployDirectory);
+ label.setForeground(toolkit.getColors().getColor(IFormColors.TITLE));
+ deployText = toolkit.createText(composite, getDeployDir(), SWT.BORDER);
+ deployListener = new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ page.execute(new SetDeployDirCommand());
+ }
+ };
+ deployText.addModifyListener(deployListener);
+
+ deployButton = toolkit.createButton(composite, Messages.browse,
+ SWT.PUSH);
+ deployButton.addSelectionListener(new SelectionListener() {
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+
+ public void widgetSelected(SelectionEvent e) {
+ DirectoryDialog d = new DirectoryDialog(new Shell());
+ d.setFilterPath(page.makeGlobal(deployText.getText()));
+ String x = d.open();
+ if (x != null) {
+ deployText.setText(page.makeRelative(x));
+ }
+ }
+ });
+
+ Label tempDeployLabel = toolkit.createLabel(composite,
+ Messages.swf_TempDeployDirectory);
+ tempDeployLabel.setForeground(toolkit.getColors().getColor(
+ IFormColors.TITLE));
+
+ tempDeployText = toolkit.createText(composite, getTempDeployDir(),
+ SWT.BORDER);
+ tempDeployListener = new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ page.execute(new SetTempDeployDirCommand());
+ }
+ };
+ tempDeployText.addModifyListener(tempDeployListener);
+
+ tempDeployButton = toolkit.createButton(composite, Messages.browse,
+ SWT.PUSH);
+ tempDeployButton.addSelectionListener(new SelectionListener() {
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+
+ public void widgetSelected(SelectionEvent e) {
+ DirectoryDialog d = new DirectoryDialog(new Shell());
+ d.setFilterPath(page.makeGlobal(tempDeployText.getText()));
+ String x = d.open();
+ if (x != null)
+ tempDeployText.setText(page.makeRelative(x));
+ }
+ });
+
+ deployText
+ .setEnabled(customRadio == null || customRadio.getSelection());
+ tempDeployText.setEnabled(customRadio == null
+ || customRadio.getSelection());
+
+ FormData descriptionLabelData = new FormData();
+ descriptionLabelData.left = new FormAttachment(0, 5);
+ descriptionLabelData.top = new FormAttachment(0, 5);
+ descriptionLabel.setLayoutData(descriptionLabelData);
+
+ // first row
+ FormData labelData = new FormData();
+ labelData.left = new FormAttachment(0, 5);
+ labelData.right = new FormAttachment(deployText, -5);
+ labelData.top = new FormAttachment(top, 5);
+ label.setLayoutData(labelData);
+
+ FormData textData = new FormData();
+ textData.left = new FormAttachment(deployButton, -305);
+ textData.top = new FormAttachment(top, 5);
+ textData.right = new FormAttachment(deployButton, -5);
+ deployText.setLayoutData(textData);
+
+ FormData buttonData = new FormData();
+ buttonData.right = new FormAttachment(100, -5);
+ buttonData.left = new FormAttachment(100, -100);
+ buttonData.top = new FormAttachment(top, 2);
+ deployButton.setLayoutData(buttonData);
+
+ // second row
+ FormData tempLabelData = new FormData();
+ tempLabelData.left = new FormAttachment(0, 5);
+ tempLabelData.right = new FormAttachment(deployText, -5);
+ tempLabelData.top = new FormAttachment(deployText, 5);
+ tempDeployLabel.setLayoutData(tempLabelData);
+
+ FormData tempTextData = new FormData();
+ tempTextData.left = new FormAttachment(tempDeployButton, -305);
+ tempTextData.top = new FormAttachment(deployText, 5);
+ tempTextData.right = new FormAttachment(tempDeployButton, -5);
+ tempDeployText.setLayoutData(tempTextData);
+
+ FormData tempButtonData = new FormData();
+ tempButtonData.right = new FormAttachment(100, -5);
+ tempButtonData.left = new FormAttachment(100, -100);
+ tempButtonData.top = new FormAttachment(deployText, 5);
+ tempDeployButton.setLayoutData(tempButtonData);
+
+ zipDeployWTPProjects = toolkit.createButton(composite,
+ Messages.EditorZipDeployments, SWT.CHECK);
+ boolean zippedPublisherAvailable = isLocalZippedPublisherAvailable();
+ boolean value = getServer().zipsWTPDeployments();
+ zipDeployWTPProjects.setEnabled(zippedPublisherAvailable);
+ zipDeployWTPProjects.setSelection(zippedPublisherAvailable && value);
+
+ FormData zipButtonData = new FormData();
+ zipButtonData.right = new FormAttachment(100, -5);
+ zipButtonData.left = new FormAttachment(0, 5);
+ zipButtonData.top = new FormAttachment(tempDeployText, 5);
+ zipDeployWTPProjects.setLayoutData(zipButtonData);
+
+ zipListener = new SelectionListener() {
+ public void widgetSelected(SelectionEvent e) {
+ page.execute(new SetZipCommand());
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ widgetSelected(e);
+ }
+ };
+ zipDeployWTPProjects.addSelectionListener(zipListener);
+
+ toolkit.paintBordersFor(composite);
+ section.setClient(composite);
+ page.getSaveStatus();
+ return section;
+ }
+
+ protected boolean isLocalZippedPublisherAvailable() {
+ IJBossServerPublisher[] publishers =
+ ExtensionManager.getDefault().getZippedPublishers();
+ for( int i = 0; i < publishers.length; i++ ) {
+ if( publishers[i].accepts(LocalPublishMethod.LOCAL_PUBLISH_METHOD,
getServer().getServer(), null))
+ return true;
+ }
+ return false;
+ }
+
+ public class SetDeployDirCommand extends ServerCommand {
+ private String oldDir;
+ private String newDir;
+ private Text text;
+ private ModifyListener listener;
+ public SetDeployDirCommand() {
+ super(page.getServer(), Messages.EditorSetDeployLabel);
+ this.text = deployText;
+ this.newDir = deployText.getText();
+ this.listener = deployListener;
+ this.oldDir = getHelper().getAttribute(IDeployableServer.DEPLOY_DIRECTORY,
""); //$NON-NLS-1$
+ }
+ public void execute() {
+ getHelper().setAttribute(IDeployableServer.DEPLOY_DIRECTORY, newDir);
+ lastCustomDeploy = newDir;
+ page.getSaveStatus();
+ }
+ public void undo() {
+ text.removeModifyListener(listener);
+ getHelper().setAttribute(IDeployableServer.DEPLOY_DIRECTORY, oldDir);
+ text.setText(oldDir);
+ text.addModifyListener(listener);
+ page.getSaveStatus();
+ }
+ }
+
+ public class SetZipCommand extends ServerCommand {
+ boolean oldVal;
+ boolean newVal;
+ public SetZipCommand() {
+ super(page.getServer(), Messages.EditorZipDeployments);
+ oldVal = getHelper().getAttribute(IDeployableServer.ZIP_DEPLOYMENTS_PREF, false);
+ newVal = zipDeployWTPProjects.getSelection();
+ }
+ public void execute() {
+ getHelper().setAttribute(IDeployableServer.ZIP_DEPLOYMENTS_PREF, newVal);
+ page.getSaveStatus();
+ }
+ public void undo() {
+ zipDeployWTPProjects.removeSelectionListener(zipListener);
+ zipDeployWTPProjects.setSelection(oldVal);
+ getHelper().setAttribute(IDeployableServer.ZIP_DEPLOYMENTS_PREF, oldVal);
+ zipDeployWTPProjects.addSelectionListener(zipListener);
+ page.getSaveStatus();
+ }
+ }
+
+ public class SetTempDeployDirCommand extends ServerCommand {
+ private String oldDir;
+ private String newDir;
+ private Text text;
+ private ModifyListener listener;
+ public SetTempDeployDirCommand() {
+ super(page.getServer(), Messages.EditorSetTempDeployLabel);
+ text = tempDeployText;
+ newDir = tempDeployText.getText();
+ listener = tempDeployListener;
+ oldDir = getHelper().getAttribute(IDeployableServer.TEMP_DEPLOY_DIRECTORY,
""); //$NON-NLS-1$
+ }
+ public void execute() {
+ getHelper().setAttribute(IDeployableServer.TEMP_DEPLOY_DIRECTORY, newDir);
+ lastCustomTemp = newDir;
+ page.getSaveStatus();
+ }
+ public void undo() {
+ text.removeModifyListener(listener);
+ getHelper().setAttribute(IDeployableServer.TEMP_DEPLOY_DIRECTORY, oldDir);
+ text.setText(oldDir);
+ text.addModifyListener(listener);
+ page.getSaveStatus();
+ }
+ }
+
+ public class RadioClickedCommand extends ServerCommand {
+ private Button newSelection, oldSelection;
+ private String oldDir, newDir;
+ private String oldTemp, newTemp;
+ private String id;
+ public RadioClickedCommand(Button clicked, Button previous) {
+ super(page.getServer(), Messages.EditorSetRadioClicked);
+ newSelection = clicked;
+ oldSelection = previous;
+ id = server.getId();
+ }
+ public void execute() {
+ boolean custom = newSelection == customRadio;
+ deployText.setEnabled(custom);
+ tempDeployText.setEnabled(custom);
+ deployButton.setEnabled(custom);
+ tempDeployButton.setEnabled(custom);
+ oldDir = deployText.getText();
+ oldTemp = tempDeployText.getText();
+
+ String type = null;
+ String oldType = oldSelection == customRadio ? IDeployableServer.DEPLOY_CUSTOM :
+ oldSelection == serverRadio ? IDeployableServer.DEPLOY_SERVER :
+ IDeployableServer.DEPLOY_METADATA;
+
+ if( newSelection == metadataRadio ) {
+ newDir = JBossServerCorePlugin.getServerStateLocation(id)
+ .append(IJBossServerConstants.DEPLOY).makeAbsolute().toString();
+ newTemp = JBossServerCorePlugin.getServerStateLocation(id)
+ .append(IJBossServerConstants.TEMP_DEPLOY).makeAbsolute().toString();
+ type = IDeployableServer.DEPLOY_METADATA;
+ new File(newDir).mkdirs();
+ new File(newTemp).mkdirs();
+ } else if( newSelection == serverRadio ) {
+ IRuntime rt = server.getRuntime();
+ if( rt != null ) {
+ IJBossServerRuntime jbsrt =
(IJBossServerRuntime)rt.loadAdapter(IJBossServerRuntime.class, new
NullProgressMonitor());
+ if( jbsrt != null ) {
+ String loc = jbsrt.getConfigLocation();
+ String config = jbsrt.getJBossConfiguration();
+ newDir = new Path(loc)
+ .append(config)
+ .append(IJBossServerConstants.DEPLOY).toString();
+ newTemp = new Path(loc).append(config)
+ .append(IJBossServerConstants.TMP)
+ .append(IJBossServerConstants.JBOSSTOOLS_TMP).toString();
+ new File(newTemp).mkdirs();
+ type = IDeployableServer.DEPLOY_SERVER;
+ }
+ }
+ } else {
+ newDir = lastCustomDeploy;
+ newTemp = lastCustomTemp;
+ type = IDeployableServer.DEPLOY_CUSTOM;
+ }
+
+ if( !newSelection.getSelection() ) {
+ // REDO, so no one actually clicked the radio. UGH!
+ oldSelection.removeSelectionListener(radioListener);
+ oldSelection.setSelection(false);
+ oldSelection.addSelectionListener(radioListener);
+
+ newSelection.removeSelectionListener(radioListener);
+ newSelection.setSelection(true);
+ newSelection.addSelectionListener(radioListener);
+ }
+
+ type = type == null ? oldType : type;
+ newDir = newDir == null ? oldDir : newDir;
+ newTemp = newTemp == null ? oldTemp : newTemp;
+
+ deployText.removeModifyListener(deployListener);
+ getHelper().setAttribute(IDeployableServer.DEPLOY_DIRECTORY, newDir);
+ deployText.setText(newDir);
+ deployText.addModifyListener(deployListener);
+
+ tempDeployText.removeModifyListener(tempDeployListener);
+ getHelper().setAttribute(IDeployableServer.TEMP_DEPLOY_DIRECTORY, newTemp);
+ tempDeployText.setText(newTemp);
+ tempDeployText.addModifyListener(tempDeployListener);
+
+ getHelper().setAttribute(IDeployableServer.DEPLOY_DIRECTORY_TYPE, type);
+ page.getSaveStatus();
+ }
+ public void undo() {
+ deployText.removeModifyListener(deployListener);
+ getHelper().setAttribute(IDeployableServer.DEPLOY_DIRECTORY, oldDir);
+ deployText.setText(oldDir);
+ deployText.addModifyListener(deployListener);
+
+ tempDeployText.removeModifyListener(tempDeployListener);
+ getHelper().setAttribute(IDeployableServer.TEMP_DEPLOY_DIRECTORY, oldTemp);
+ tempDeployText.setText(oldTemp);
+ tempDeployText.addModifyListener(tempDeployListener);
+
+ oldSelection.removeSelectionListener(radioListener);
+ oldSelection.setSelection(true);
+ oldSelection.addSelectionListener(radioListener);
+
+ newSelection.removeSelectionListener(radioListener);
+ newSelection.setSelection(false);
+ newSelection.addSelectionListener(radioListener);
+
+ deployText.setEnabled(customRadio.getSelection());
+ tempDeployText.setEnabled(customRadio.getSelection());
+
+ String oldType = oldSelection == customRadio ? IDeployableServer.DEPLOY_CUSTOM :
+ oldSelection == serverRadio ? IDeployableServer.DEPLOY_SERVER :
+ IDeployableServer.DEPLOY_METADATA;
+ getHelper().setAttribute(IDeployableServer.DEPLOY_DIRECTORY_TYPE, oldType);
+ page.getSaveStatus();
+ }
+ }
+
+
+ private String getDeployType() {
+ return getServer().getDeployLocationType();
+ }
+
+ private String getDeployDir() {
+ return page.getServer().getRuntime() == null ? "" : //$NON-NLS-1$
+ ModuleDeploymentPage.makeRelative(getServer().getDeployFolder(),
+ page.getServer().getRuntime());
+ }
+
+ private String getTempDeployDir() {
+ return page.getServer().getRuntime() == null ? "" : //$NON-NLS-1$
+ ModuleDeploymentPage.makeRelative(getServer().getTempDeployFolder(),
+ page.getServer().getRuntime());
+ }
+
+ private IDeployableServer getServer() {
+ return (IDeployableServer) page.getServer().loadAdapter(
+ IDeployableServer.class, new NullProgressMonitor());
+ }
+/*
+ *
+ *
+ *
+ * This is where the second half goes
+ *
+ *
+ *
+ */
+ protected Composite createViewerPortion(Composite random) {
+ Composite root = new Composite(random, SWT.NONE);
+ root.setLayout(new FormLayout());
+
+ page.getFormToolkit(random).adapt(root);
+
+ viewer = new TreeViewer(root, SWT.BORDER);
+ viewer.getTree().setHeaderVisible(true);
+ viewer.getTree().setLinesVisible(true);
+ TreeColumn moduleColumn = new TreeColumn(viewer.getTree(), SWT.NONE);
+ TreeColumn publishLocColumn = new TreeColumn(viewer.getTree(), SWT.NONE);
+ TreeColumn publishTempLocColumn = new TreeColumn(viewer.getTree(),
+ SWT.NONE);
+ moduleColumn.setText(Messages.EditorModule);
+ publishLocColumn.setText(Messages.EditorSetDeployLabel);
+ publishTempLocColumn.setText(Messages.EditorSetTempDeployLabel);
+
+ moduleColumn.setWidth(200);
+ publishLocColumn.setWidth(200);
+ publishTempLocColumn.setWidth(200);
+
+ FormData treeData = new FormData();
+ treeData.top = new FormAttachment(0, 5);
+ treeData.bottom = new FormAttachment(100, -5);
+ treeData.left = new FormAttachment(0, 5);
+ treeData.right = new FormAttachment(100, -5);
+ viewer.getTree().setLayoutData(treeData);
+ viewer.setContentProvider(new ModulePageContentProvider());
+
+ viewer.setLabelProvider(new ModulePageLabelProvider());
+ viewer.setColumnProperties(new String[] { COLUMN_NAME,
+ COLUMN_LOC, COLUMN_TEMP_LOC });
+ viewer.setInput(""); // irrelevent
+ CellEditor[] editors = new CellEditor[] {
+ new TextCellEditor(viewer.getTree()),
+ new TextCellEditor(viewer.getTree()),
+ new TextCellEditor(viewer.getTree()) };
+ viewer.setCellModifier(new LocalDeploymentCellModifier());
+ viewer.setCellEditors(editors);
+
+ return root;
+ }
+
+ private class LocalDeploymentCellModifier implements ICellModifier {
+ public boolean canModify(Object element, String property) {
+ if( property == COLUMN_NAME)
+ return false;
+ return true;
+ }
+
+ public Object getValue(Object element, String property) {
+ DeploymentModulePrefs p = preferences.getOrCreatePreferences(currentDeployType)
+ .getOrCreateModulePrefs((IModule) element);
+ if (property == COLUMN_LOC) {
+ String ret = p.getProperty(COLUMN_LOC);
+ return ret == null ? "" : ret;
+ }
+ if (property == COLUMN_TEMP_LOC) {
+ String ret = p.getProperty(COLUMN_TEMP_LOC);
+ return ret == null ? "" : ret;
+ }
+
+ return "";
+ }
+
+ public void modify(Object element, String property, Object value) {
+
+ IModule module = (IModule) ((TreeItem) element).getData();
+ DeploymentModulePrefs p = preferences.getOrCreatePreferences(currentDeployType)
+ .getOrCreateModulePrefs(module);
+ if (property == COLUMN_LOC) {
+ page.firePropertyChangeCommand(p, COLUMN_LOC,
+ (String) value, Messages.EditorEditDeployLocCommand);
+ viewer.refresh();
+ } else if (property == COLUMN_TEMP_LOC) {
+ page.firePropertyChangeCommand(p, COLUMN_TEMP_LOC,
+ (String) value, Messages.EditorEditDeployLocCommand);
+ viewer.refresh();
+ }
+ }
+ }
+
+ private class ModulePageContentProvider implements ITreeContentProvider {
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
+
+ public void dispose() {
+ }
+
+ public Object[] getElements(Object inputElement) {
+ return page.getPossibleModules();
+ }
+
+ public boolean hasChildren(Object element) {
+ return false;
+ }
+
+ public Object getParent(Object element) {
+ return null;
+ }
+
+ public Object[] getChildren(Object parentElement) {
+ return null;
+ }
+ }
+
+ private class ModulePageLabelProvider implements ITableLabelProvider {
+ public Image getColumnImage(Object element, int columnIndex) {
+ if (element instanceof IModule && columnIndex == 0) {
+ ILabelProvider labelProvider = ServerUICore.getLabelProvider();
+ Image image = labelProvider.getImage((IModule) element);
+ labelProvider.dispose();
+ return image;
+ }
+ return null;
+ }
+
+ public String getColumnText(Object element, int columnIndex) {
+ if (element instanceof IModule) {
+ IModule m = (IModule) element;
+ if (columnIndex == 0)
+ return m.getName();
+ if (columnIndex == 1) {
+ DeploymentModulePrefs modPref = preferences
+ .getOrCreatePreferences(currentDeployType)
+ .getOrCreateModulePrefs(m);
+ String result = modPref.getProperty(COLUMN_LOC);
+ if (result != null)
+ return result;
+ modPref.setProperty(COLUMN_LOC, "");
+ return "";
+ }
+ if (columnIndex == 2) {
+ DeploymentModulePrefs modPref = preferences
+ .getOrCreatePreferences(currentDeployType)
+ .getOrCreateModulePrefs(m);
+ String result = modPref.getProperty(COLUMN_TEMP_LOC);
+ if (result != null)
+ return result;
+ modPref.setProperty(COLUMN_TEMP_LOC, "");
+ return "";
+ }
+ }
+ return element.toString();
+ }
+
+ public void addListener(ILabelProviderListener listener) {
+ }
+
+ public void dispose() {
+ }
+
+ public boolean isLabelProperty(Object element, String property) {
+ return false;
+ }
+
+ public void removeListener(ILabelProviderListener listener) {
+ }
+ }
+
+}
Modified:
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/IDeploymentEditorTab.java
===================================================================
---
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/IDeploymentEditorTab.java 2010-07-20
09:27:46 UTC (rev 23581)
+++
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/IDeploymentEditorTab.java 2010-07-20
09:55:16 UTC (rev 23582)
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.ide.eclipse.as.ui.editor;
import org.eclipse.swt.widgets.Composite;
@@ -4,6 +14,7 @@
import org.eclipse.swt.widgets.Control;
import
org.jboss.ide.eclipse.as.core.util.DeploymentPreferenceLoader.DeploymentPreferences;
+@Deprecated
public interface IDeploymentEditorTab {
public void setDeploymentPage(ModuleDeploymentPage page);
public void setDeploymentPrefs(DeploymentPreferences prefs);
Deleted:
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/LocalDeploymentModuleTab.java
===================================================================
---
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/LocalDeploymentModuleTab.java 2010-07-20
09:27:46 UTC (rev 23581)
+++
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/LocalDeploymentModuleTab.java 2010-07-20
09:55:16 UTC (rev 23582)
@@ -1,723 +0,0 @@
-package org.jboss.ide.eclipse.as.ui.editor;
-
-import java.io.File;
-
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jface.viewers.CellEditor;
-import org.eclipse.jface.viewers.ICellModifier;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ILabelProviderListener;
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.TextCellEditor;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.FormAttachment;
-import org.eclipse.swt.layout.FormData;
-import org.eclipse.swt.layout.FormLayout;
-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.Control;
-import org.eclipse.swt.widgets.DirectoryDialog;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.swt.widgets.TreeColumn;
-import org.eclipse.swt.widgets.TreeItem;
-import org.eclipse.ui.forms.IFormColors;
-import org.eclipse.ui.forms.widgets.ExpandableComposite;
-import org.eclipse.ui.forms.widgets.FormToolkit;
-import org.eclipse.ui.forms.widgets.Section;
-import org.eclipse.wst.server.core.IModule;
-import org.eclipse.wst.server.core.IRuntime;
-import org.eclipse.wst.server.ui.ServerUICore;
-import org.eclipse.wst.server.ui.internal.command.ServerCommand;
-import org.jboss.ide.eclipse.as.core.ExtensionManager;
-import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
-import org.jboss.ide.eclipse.as.core.publishers.LocalPublishMethod;
-import org.jboss.ide.eclipse.as.core.server.IDeployableServer;
-import org.jboss.ide.eclipse.as.core.server.IJBossServerConstants;
-import org.jboss.ide.eclipse.as.core.server.IJBossServerPublisher;
-import org.jboss.ide.eclipse.as.core.server.IJBossServerRuntime;
-import org.jboss.ide.eclipse.as.core.server.internal.ServerAttributeHelper;
-import
org.jboss.ide.eclipse.as.core.util.DeploymentPreferenceLoader.DeploymentModulePrefs;
-import
org.jboss.ide.eclipse.as.core.util.DeploymentPreferenceLoader.DeploymentPreferences;
-import org.jboss.ide.eclipse.as.core.util.IJBossToolingConstants;
-import org.jboss.ide.eclipse.as.ui.Messages;
-
-public class LocalDeploymentModuleTab implements IDeploymentEditorTab {
- private ModuleDeploymentPage page;
- private DeploymentPreferences preferences;
-
- public LocalDeploymentModuleTab() {
- }
-
- public String getTabName() {
- return Messages.EditorLocalDeployment;
- }
-
- public void setDeploymentPage(ModuleDeploymentPage page) {
- this.page = page;
- }
-
- public void setDeploymentPrefs(DeploymentPreferences prefs) {
- this.preferences = prefs;
- }
-
- private TreeViewer viewer;
- private static final String LOCAL_COLUMN_NAME =
IJBossToolingConstants.LOCAL_DEPLOYMENT_NAME;
- private static final String LOCAL_COLUMN_LOC =
IJBossToolingConstants.LOCAL_DEPLOYMENT_LOC;
- private static final String LOCAL_COLUMN_TEMP_LOC =
IJBossToolingConstants.LOCAL_DEPLOYMENT_TEMP_LOC;
-
- protected ServerAttributeHelper getHelper() {
- if( helper == null ) {
- helper = new ServerAttributeHelper(page.getServer().getOriginal(), page.getServer());
- } else {
- String helperTS = helper.getWorkingCopy().getAttribute("timestamp",
(String)null);
- String officialTS = page.getServer().getAttribute("timestamp",
(String)null);
- if( !helperTS.equals(officialTS)) {
- helper = new ServerAttributeHelper(page.getServer().getOriginal(),
page.getServer());
- }
- }
- return helper;
- }
-
- public Control createControl(Composite parent) {
- getHelper();
-
- Composite random = new Composite(parent, SWT.NONE);
- GridData randomData = new GridData(GridData.FILL_BOTH);
- random.setLayoutData(randomData);
- random.setLayout(new FormLayout());
-
- Composite defaultComposite = createDefaultComposite(random);
- FormData fd = new FormData();
- fd.left = new FormAttachment(0, 5);
- fd.top = new FormAttachment(0, 5);
- fd.right = new FormAttachment(100, -5);
- defaultComposite.setLayoutData(fd);
-
- Composite viewComposite = createViewerPortion(random);
- fd = new FormData();
- fd.left = new FormAttachment(0, 5);
- fd.top = new FormAttachment(defaultComposite, 5);
- fd.right = new FormAttachment(100, -5);
- fd.bottom = new FormAttachment(100, -5);
- viewComposite.setLayoutData(fd);
-
- return random;
- }
-
- private Text deployText, tempDeployText;
- private Button metadataRadio, serverRadio, customRadio, currentSelection;
- private Button deployButton, tempDeployButton;
- private ModifyListener deployListener, tempDeployListener;
- private SelectionListener radioListener, zipListener;
- private ServerAttributeHelper helper;
- private Button zipDeployWTPProjects;
- private String lastCustomDeploy, lastCustomTemp;
-
- protected Composite createDefaultComposite(Composite parent) {
-
- FormToolkit toolkit = new FormToolkit(parent.getDisplay());
-
- Section section = toolkit.createSection(parent,
- ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED
- | ExpandableComposite.TITLE_BAR);
- section.setText(Messages.swf_DeployEditorHeading);
- section.setLayoutData(new GridData(GridData.FILL_HORIZONTAL
- | GridData.VERTICAL_ALIGN_FILL));
-
- Composite composite = toolkit.createComposite(section);
-
- composite.setLayout(new FormLayout());
-
- Label descriptionLabel = toolkit.createLabel(composite,
- Messages.swf_DeploymentDescription);
- Control top = descriptionLabel;
- Composite inner = toolkit.createComposite(composite);
- inner.setLayout(new GridLayout(1, false));
-
- IRuntime rt = getServer().getServer().getRuntime();
- boolean showRadios = true;
- if( rt == null )
- showRadios = false;
- else {
- IJBossServerRuntime jbsrt =
(IJBossServerRuntime)rt.loadAdapter(IJBossServerRuntime.class, new
NullProgressMonitor());
- if( jbsrt == null )
- showRadios = false;
- }
-
- if( showRadios ) {
- metadataRadio = toolkit.createButton(inner,
- Messages.EditorUseWorkspaceMetadata, SWT.RADIO);
- serverRadio = toolkit.createButton(inner,
- Messages.EditorUseServersDeployFolder, SWT.RADIO);
- customRadio = toolkit.createButton(inner,
- Messages.EditorUseCustomDeployFolder, SWT.RADIO);
-
- metadataRadio.setSelection(getDeployType().equals(
- IDeployableServer.DEPLOY_METADATA));
- serverRadio.setSelection(getDeployType().equals(
- IDeployableServer.DEPLOY_SERVER));
- customRadio.setSelection(getDeployType().equals(
- IDeployableServer.DEPLOY_CUSTOM));
- currentSelection = metadataRadio.getSelection() ? metadataRadio
- : serverRadio.getSelection() ? serverRadio : customRadio;
-
- radioListener = new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {
- widgetSelected(e);
- }
-
- public void widgetSelected(SelectionEvent e) {
- if (e.getSource() == currentSelection)
- return; // do nothing
- page.execute(new RadioClickedCommand((Button) e.getSource(),
- currentSelection));
- currentSelection = (Button) e.getSource();
- }
- };
- metadataRadio.addSelectionListener(radioListener);
- serverRadio.addSelectionListener(radioListener);
- customRadio.addSelectionListener(radioListener);
- }
-
- FormData radios = new FormData();
- radios.top = new FormAttachment(descriptionLabel, 5);
- radios.left = new FormAttachment(0, 5);
- radios.right = new FormAttachment(100, -5);
- inner.setLayoutData(radios);
- top = inner;
-
- Label label = toolkit.createLabel(composite,
- Messages.swf_DeployDirectory);
- label.setForeground(toolkit.getColors().getColor(IFormColors.TITLE));
- deployText = toolkit.createText(composite, getDeployDir(), SWT.BORDER);
- deployListener = new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- page.execute(new SetDeployDirCommand());
- }
- };
- deployText.addModifyListener(deployListener);
-
- deployButton = toolkit.createButton(composite, Messages.browse,
- SWT.PUSH);
- deployButton.addSelectionListener(new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {
- }
-
- public void widgetSelected(SelectionEvent e) {
- DirectoryDialog d = new DirectoryDialog(new Shell());
- d.setFilterPath(page.makeGlobal(deployText.getText()));
- String x = d.open();
- if (x != null) {
- deployText.setText(page.makeRelative(x));
- }
- }
- });
-
- Label tempDeployLabel = toolkit.createLabel(composite,
- Messages.swf_TempDeployDirectory);
- tempDeployLabel.setForeground(toolkit.getColors().getColor(
- IFormColors.TITLE));
-
- tempDeployText = toolkit.createText(composite, getTempDeployDir(),
- SWT.BORDER);
- tempDeployListener = new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- page.execute(new SetTempDeployDirCommand());
- }
- };
- tempDeployText.addModifyListener(tempDeployListener);
-
- tempDeployButton = toolkit.createButton(composite, Messages.browse,
- SWT.PUSH);
- tempDeployButton.addSelectionListener(new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {
- }
-
- public void widgetSelected(SelectionEvent e) {
- DirectoryDialog d = new DirectoryDialog(new Shell());
- d.setFilterPath(page.makeGlobal(tempDeployText.getText()));
- String x = d.open();
- if (x != null)
- tempDeployText.setText(page.makeRelative(x));
- }
- });
-
- deployText
- .setEnabled(customRadio == null || customRadio.getSelection());
- tempDeployText.setEnabled(customRadio == null
- || customRadio.getSelection());
-
- FormData descriptionLabelData = new FormData();
- descriptionLabelData.left = new FormAttachment(0, 5);
- descriptionLabelData.top = new FormAttachment(0, 5);
- descriptionLabel.setLayoutData(descriptionLabelData);
-
- // first row
- FormData labelData = new FormData();
- labelData.left = new FormAttachment(0, 5);
- labelData.right = new FormAttachment(deployText, -5);
- labelData.top = new FormAttachment(top, 5);
- label.setLayoutData(labelData);
-
- FormData textData = new FormData();
- textData.left = new FormAttachment(deployButton, -305);
- textData.top = new FormAttachment(top, 5);
- textData.right = new FormAttachment(deployButton, -5);
- deployText.setLayoutData(textData);
-
- FormData buttonData = new FormData();
- buttonData.right = new FormAttachment(100, -5);
- buttonData.left = new FormAttachment(100, -100);
- buttonData.top = new FormAttachment(top, 2);
- deployButton.setLayoutData(buttonData);
-
- // second row
- FormData tempLabelData = new FormData();
- tempLabelData.left = new FormAttachment(0, 5);
- tempLabelData.right = new FormAttachment(deployText, -5);
- tempLabelData.top = new FormAttachment(deployText, 5);
- tempDeployLabel.setLayoutData(tempLabelData);
-
- FormData tempTextData = new FormData();
- tempTextData.left = new FormAttachment(tempDeployButton, -305);
- tempTextData.top = new FormAttachment(deployText, 5);
- tempTextData.right = new FormAttachment(tempDeployButton, -5);
- tempDeployText.setLayoutData(tempTextData);
-
- FormData tempButtonData = new FormData();
- tempButtonData.right = new FormAttachment(100, -5);
- tempButtonData.left = new FormAttachment(100, -100);
- tempButtonData.top = new FormAttachment(deployText, 5);
- tempDeployButton.setLayoutData(tempButtonData);
-
- zipDeployWTPProjects = toolkit.createButton(composite,
- Messages.EditorZipDeployments, SWT.CHECK);
- boolean zippedPublisherAvailable = isLocalZippedPublisherAvailable();
- boolean value = getServer().zipsWTPDeployments();
- zipDeployWTPProjects.setEnabled(zippedPublisherAvailable);
- zipDeployWTPProjects.setSelection(zippedPublisherAvailable && value);
-
- FormData zipButtonData = new FormData();
- zipButtonData.right = new FormAttachment(100, -5);
- zipButtonData.left = new FormAttachment(0, 5);
- zipButtonData.top = new FormAttachment(tempDeployText, 5);
- zipDeployWTPProjects.setLayoutData(zipButtonData);
-
- zipListener = new SelectionListener() {
- public void widgetSelected(SelectionEvent e) {
- page.execute(new SetZipCommand());
- }
-
- public void widgetDefaultSelected(SelectionEvent e) {
- widgetSelected(e);
- }
- };
- zipDeployWTPProjects.addSelectionListener(zipListener);
-
- toolkit.paintBordersFor(composite);
- section.setClient(composite);
- page.getSaveStatus();
- return section;
- }
-
- protected boolean isLocalZippedPublisherAvailable() {
- IJBossServerPublisher[] publishers =
- ExtensionManager.getDefault().getZippedPublishers();
- for( int i = 0; i < publishers.length; i++ ) {
- if( publishers[i].accepts(LocalPublishMethod.LOCAL_PUBLISH_METHOD,
getServer().getServer(), null))
- return true;
- }
- return false;
- }
-
- public class SetDeployDirCommand extends ServerCommand {
- private String oldDir;
- private String newDir;
- private Text text;
- private ModifyListener listener;
- public SetDeployDirCommand() {
- super(page.getServer(), Messages.EditorSetDeployLabel);
- this.text = deployText;
- this.newDir = deployText.getText();
- this.listener = deployListener;
- this.oldDir = getHelper().getAttribute(IDeployableServer.DEPLOY_DIRECTORY,
""); //$NON-NLS-1$
- }
- public void execute() {
- getHelper().setAttribute(IDeployableServer.DEPLOY_DIRECTORY, newDir);
- lastCustomDeploy = newDir;
- page.getSaveStatus();
- }
- public void undo() {
- text.removeModifyListener(listener);
- getHelper().setAttribute(IDeployableServer.DEPLOY_DIRECTORY, oldDir);
- text.setText(oldDir);
- text.addModifyListener(listener);
- page.getSaveStatus();
- }
- }
-
- public class SetZipCommand extends ServerCommand {
- boolean oldVal;
- boolean newVal;
- public SetZipCommand() {
- super(page.getServer(), Messages.EditorZipDeployments);
- oldVal = getHelper().getAttribute(IDeployableServer.ZIP_DEPLOYMENTS_PREF, false);
- newVal = zipDeployWTPProjects.getSelection();
- }
- public void execute() {
- getHelper().setAttribute(IDeployableServer.ZIP_DEPLOYMENTS_PREF, newVal);
- page.getSaveStatus();
- }
- public void undo() {
- zipDeployWTPProjects.removeSelectionListener(zipListener);
- zipDeployWTPProjects.setSelection(oldVal);
- getHelper().setAttribute(IDeployableServer.ZIP_DEPLOYMENTS_PREF, oldVal);
- zipDeployWTPProjects.addSelectionListener(zipListener);
- page.getSaveStatus();
- }
- }
-
- public class SetTempDeployDirCommand extends ServerCommand {
- private String oldDir;
- private String newDir;
- private Text text;
- private ModifyListener listener;
- public SetTempDeployDirCommand() {
- super(page.getServer(), Messages.EditorSetTempDeployLabel);
- text = tempDeployText;
- newDir = tempDeployText.getText();
- listener = tempDeployListener;
- oldDir = getHelper().getAttribute(IDeployableServer.TEMP_DEPLOY_DIRECTORY,
""); //$NON-NLS-1$
- }
- public void execute() {
- getHelper().setAttribute(IDeployableServer.TEMP_DEPLOY_DIRECTORY, newDir);
- lastCustomTemp = newDir;
- page.getSaveStatus();
- }
- public void undo() {
- text.removeModifyListener(listener);
- getHelper().setAttribute(IDeployableServer.TEMP_DEPLOY_DIRECTORY, oldDir);
- text.setText(oldDir);
- text.addModifyListener(listener);
- page.getSaveStatus();
- }
- }
-
- public class RadioClickedCommand extends ServerCommand {
- private Button newSelection, oldSelection;
- private String oldDir, newDir;
- private String oldTemp, newTemp;
- private String id;
- public RadioClickedCommand(Button clicked, Button previous) {
- super(page.getServer(), Messages.EditorSetRadioClicked);
- newSelection = clicked;
- oldSelection = previous;
- id = server.getId();
- }
- public void execute() {
- boolean custom = newSelection == customRadio;
- deployText.setEnabled(custom);
- tempDeployText.setEnabled(custom);
- deployButton.setEnabled(custom);
- tempDeployButton.setEnabled(custom);
- oldDir = deployText.getText();
- oldTemp = tempDeployText.getText();
-
- String type = null;
- String oldType = oldSelection == customRadio ? IDeployableServer.DEPLOY_CUSTOM :
- oldSelection == serverRadio ? IDeployableServer.DEPLOY_SERVER :
- IDeployableServer.DEPLOY_METADATA;
-
- if( newSelection == metadataRadio ) {
- newDir = JBossServerCorePlugin.getServerStateLocation(id)
- .append(IJBossServerConstants.DEPLOY).makeAbsolute().toString();
- newTemp = JBossServerCorePlugin.getServerStateLocation(id)
- .append(IJBossServerConstants.TEMP_DEPLOY).makeAbsolute().toString();
- type = IDeployableServer.DEPLOY_METADATA;
- new File(newDir).mkdirs();
- new File(newTemp).mkdirs();
- } else if( newSelection == serverRadio ) {
- IRuntime rt = server.getRuntime();
- if( rt != null ) {
- IJBossServerRuntime jbsrt =
(IJBossServerRuntime)rt.loadAdapter(IJBossServerRuntime.class, new
NullProgressMonitor());
- if( jbsrt != null ) {
- String loc = jbsrt.getConfigLocation();
- String config = jbsrt.getJBossConfiguration();
- newDir = new Path(loc)
- .append(config)
- .append(IJBossServerConstants.DEPLOY).toString();
- newTemp = new Path(loc).append(config)
- .append(IJBossServerConstants.TMP)
- .append(IJBossServerConstants.JBOSSTOOLS_TMP).toString();
- new File(newTemp).mkdirs();
- type = IDeployableServer.DEPLOY_SERVER;
- }
- }
- } else {
- newDir = lastCustomDeploy;
- newTemp = lastCustomTemp;
- type = IDeployableServer.DEPLOY_CUSTOM;
- }
-
- if( !newSelection.getSelection() ) {
- // REDO, so no one actually clicked the radio. UGH!
- oldSelection.removeSelectionListener(radioListener);
- oldSelection.setSelection(false);
- oldSelection.addSelectionListener(radioListener);
-
- newSelection.removeSelectionListener(radioListener);
- newSelection.setSelection(true);
- newSelection.addSelectionListener(radioListener);
- }
-
- type = type == null ? oldType : type;
- newDir = newDir == null ? oldDir : newDir;
- newTemp = newTemp == null ? oldTemp : newTemp;
-
- deployText.removeModifyListener(deployListener);
- getHelper().setAttribute(IDeployableServer.DEPLOY_DIRECTORY, newDir);
- deployText.setText(newDir);
- deployText.addModifyListener(deployListener);
-
- tempDeployText.removeModifyListener(tempDeployListener);
- getHelper().setAttribute(IDeployableServer.TEMP_DEPLOY_DIRECTORY, newTemp);
- tempDeployText.setText(newTemp);
- tempDeployText.addModifyListener(tempDeployListener);
-
- getHelper().setAttribute(IDeployableServer.DEPLOY_DIRECTORY_TYPE, type);
- page.getSaveStatus();
- }
- public void undo() {
- deployText.removeModifyListener(deployListener);
- getHelper().setAttribute(IDeployableServer.DEPLOY_DIRECTORY, oldDir);
- deployText.setText(oldDir);
- deployText.addModifyListener(deployListener);
-
- tempDeployText.removeModifyListener(tempDeployListener);
- getHelper().setAttribute(IDeployableServer.TEMP_DEPLOY_DIRECTORY, oldTemp);
- tempDeployText.setText(oldTemp);
- tempDeployText.addModifyListener(tempDeployListener);
-
- oldSelection.removeSelectionListener(radioListener);
- oldSelection.setSelection(true);
- oldSelection.addSelectionListener(radioListener);
-
- newSelection.removeSelectionListener(radioListener);
- newSelection.setSelection(false);
- newSelection.addSelectionListener(radioListener);
-
- deployText.setEnabled(customRadio.getSelection());
- tempDeployText.setEnabled(customRadio.getSelection());
-
- String oldType = oldSelection == customRadio ? IDeployableServer.DEPLOY_CUSTOM :
- oldSelection == serverRadio ? IDeployableServer.DEPLOY_SERVER :
- IDeployableServer.DEPLOY_METADATA;
- getHelper().setAttribute(IDeployableServer.DEPLOY_DIRECTORY_TYPE, oldType);
- page.getSaveStatus();
- }
- }
-
-
- private String getDeployType() {
- return getServer().getDeployLocationType();
- }
-
- private String getDeployDir() {
- return page.getServer().getRuntime() == null ? "" : //$NON-NLS-1$
- ModuleDeploymentPage.makeRelative(getServer().getDeployFolder(),
- page.getServer().getRuntime());
- }
-
- private String getTempDeployDir() {
- return page.getServer().getRuntime() == null ? "" : //$NON-NLS-1$
- ModuleDeploymentPage.makeRelative(getServer().getTempDeployFolder(),
- page.getServer().getRuntime());
- }
-
- private IDeployableServer getServer() {
- return (IDeployableServer) page.getServer().loadAdapter(
- IDeployableServer.class, new NullProgressMonitor());
- }
-/*
- *
- *
- *
- * This is where the second half goes
- *
- *
- *
- */
- protected Composite createViewerPortion(Composite random) {
- Composite root = new Composite(random, SWT.NONE);
- root.setLayout(new FormLayout());
-
- page.getFormToolkit(random).adapt(root);
-
- viewer = new TreeViewer(root, SWT.BORDER);
- viewer.getTree().setHeaderVisible(true);
- viewer.getTree().setLinesVisible(true);
- TreeColumn moduleColumn = new TreeColumn(viewer.getTree(), SWT.NONE);
- TreeColumn publishLocColumn = new TreeColumn(viewer.getTree(), SWT.NONE);
- TreeColumn publishTempLocColumn = new TreeColumn(viewer.getTree(),
- SWT.NONE);
- moduleColumn.setText(Messages.EditorModule);
- publishLocColumn.setText(Messages.EditorSetDeployLabel);
- publishTempLocColumn.setText(Messages.EditorSetTempDeployLabel);
-
- moduleColumn.setWidth(200);
- publishLocColumn.setWidth(200);
- publishTempLocColumn.setWidth(200);
-
- FormData treeData = new FormData();
- treeData.top = new FormAttachment(0, 5);
- treeData.bottom = new FormAttachment(100, -5);
- treeData.left = new FormAttachment(0, 5);
- treeData.right = new FormAttachment(100, -5);
- viewer.getTree().setLayoutData(treeData);
- viewer.setContentProvider(new ModulePageContentProvider());
-
- viewer.setLabelProvider(new ModulePageLabelProvider());
- viewer.setColumnProperties(new String[] { LOCAL_COLUMN_NAME,
- LOCAL_COLUMN_LOC, LOCAL_COLUMN_TEMP_LOC });
- viewer.setInput(""); // irrelevent
- CellEditor[] editors = new CellEditor[] {
- new TextCellEditor(viewer.getTree()),
- new TextCellEditor(viewer.getTree()),
- new TextCellEditor(viewer.getTree()) };
- viewer.setCellModifier(new LocalDeploymentCellModifier());
- viewer.setCellEditors(editors);
-
- return root;
- }
-
- private class LocalDeploymentCellModifier implements ICellModifier {
- public boolean canModify(Object element, String property) {
- if( property == LOCAL_COLUMN_NAME)
- return false;
- return true;
- }
-
- public Object getValue(Object element, String property) {
- DeploymentModulePrefs p = preferences.getPreferences("local")
- .getModulePrefs((IModule) element);
- if (property == LOCAL_COLUMN_LOC) {
- String ret = p.getProperty(LOCAL_COLUMN_LOC);
- return ret == null ? "" : ret;
- }
- if (property == LOCAL_COLUMN_TEMP_LOC) {
- String ret = p.getProperty(LOCAL_COLUMN_TEMP_LOC);
- return ret == null ? "" : ret;
- }
-
- return "";
- }
-
- public void modify(Object element, String property, Object value) {
-
- IModule module = (IModule) ((TreeItem) element).getData();
- DeploymentModulePrefs p = preferences.getPreferences("local")
- .getModulePrefs(module);
- if (property == LOCAL_COLUMN_LOC) {
- page.firePropertyChangeCommand(p, LOCAL_COLUMN_LOC,
- (String) value, Messages.EditorEditDeployLocCommand);
- viewer.refresh();
- } else if (property == LOCAL_COLUMN_TEMP_LOC) {
- page.firePropertyChangeCommand(p, LOCAL_COLUMN_TEMP_LOC,
- (String) value, Messages.EditorEditDeployLocCommand);
- viewer.refresh();
- }
- }
- }
-
- private class ModulePageContentProvider implements ITreeContentProvider {
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- }
-
- public void dispose() {
- }
-
- public Object[] getElements(Object inputElement) {
- return page.getPossibleModules();
- }
-
- public boolean hasChildren(Object element) {
- return false;
- }
-
- public Object getParent(Object element) {
- return null;
- }
-
- public Object[] getChildren(Object parentElement) {
- return null;
- }
- }
-
- private class ModulePageLabelProvider implements ITableLabelProvider {
- public Image getColumnImage(Object element, int columnIndex) {
- if (element instanceof IModule && columnIndex == 0) {
- ILabelProvider labelProvider = ServerUICore.getLabelProvider();
- Image image = labelProvider.getImage((IModule) element);
- labelProvider.dispose();
- return image;
- }
- return null;
- }
-
- public String getColumnText(Object element, int columnIndex) {
- if (element instanceof IModule) {
- IModule m = (IModule) element;
- if (columnIndex == 0)
- return m.getName();
- if (columnIndex == 1) {
- DeploymentModulePrefs modPref = preferences
- .getOrCreatePreferences("local")
- .getOrCreateModulePrefs(m);
- String result = modPref.getProperty(LOCAL_COLUMN_LOC);
- if (result != null)
- return result;
- modPref.setProperty(LOCAL_COLUMN_LOC, "");
- return "";
- }
- if (columnIndex == 2) {
- DeploymentModulePrefs modPref = preferences
- .getOrCreatePreferences("local")
- .getOrCreateModulePrefs(m);
- String result = modPref.getProperty(LOCAL_COLUMN_TEMP_LOC);
- if (result != null)
- return result;
- modPref.setProperty(LOCAL_COLUMN_TEMP_LOC, "");
- return "";
- }
- }
- return element.toString();
- }
-
- public void addListener(ILabelProviderListener listener) {
- }
-
- public void dispose() {
- }
-
- public boolean isLabelProperty(Object element, String property) {
- return false;
- }
-
- public void removeListener(ILabelProviderListener listener) {
- }
- }
-
-}
Modified:
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/ModuleDeploymentPage.java
===================================================================
---
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/ModuleDeploymentPage.java 2010-07-20
09:27:46 UTC (rev 23581)
+++
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/ModuleDeploymentPage.java 2010-07-20
09:55:16 UTC (rev 23582)
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.ide.eclipse.as.ui.editor;
import java.io.ByteArrayOutputStream;
@@ -9,38 +19,65 @@
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.TabFolder;
-import org.eclipse.swt.widgets.TabItem;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.forms.widgets.ExpandableComposite;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.ScrolledForm;
+import org.eclipse.ui.forms.widgets.ScrolledPageBook;
+import org.eclipse.ui.forms.widgets.Section;
import org.eclipse.wst.server.core.IModule;
import org.eclipse.wst.server.core.IRuntime;
-import org.eclipse.wst.server.core.IServer;
import org.eclipse.wst.server.core.IServerWorkingCopy;
import org.eclipse.wst.server.ui.editor.IServerEditorPartInput;
import org.eclipse.wst.server.ui.editor.ServerEditorPart;
import org.eclipse.wst.server.ui.internal.command.ServerCommand;
import org.eclipse.wst.server.ui.internal.editor.ServerEditorPartInput;
import org.eclipse.wst.server.ui.internal.editor.ServerResourceCommandManager;
+import org.jboss.ide.eclipse.as.core.ExtensionManager;
+import org.jboss.ide.eclipse.as.core.server.IJBossServerPublishMethodType;
import org.jboss.ide.eclipse.as.core.server.IJBossServerRuntime;
+import org.jboss.ide.eclipse.as.core.server.internal.DeployableServerBehavior;
import org.jboss.ide.eclipse.as.core.server.internal.ServerAttributeHelper;
import org.jboss.ide.eclipse.as.core.util.DeploymentPreferenceLoader;
-import org.jboss.ide.eclipse.as.core.util.ServerUtil;
import
org.jboss.ide.eclipse.as.core.util.DeploymentPreferenceLoader.DeploymentModulePrefs;
import
org.jboss.ide.eclipse.as.core.util.DeploymentPreferenceLoader.DeploymentPreferences;
+import org.jboss.ide.eclipse.as.core.util.ServerConverter;
+import org.jboss.ide.eclipse.as.core.util.ServerUtil;
+import org.jboss.ide.eclipse.as.ui.UIUtil;
public class ModuleDeploymentPage extends ServerEditorPart {
protected ServerResourceCommandManager commandManager;
protected ArrayList<IModule> possibleModules;
protected DeploymentPreferences preferences;
- protected ArrayList<IDeploymentEditorTab> tabs;
protected ServerAttributeHelper helper;
+ public ServerAttributeHelper getHelper() {
+ if( helper == null ) {
+ helper = new ServerAttributeHelper(getServer().getOriginal(), getServer());
+ } else {
+ String helperTS = helper.getWorkingCopy().getAttribute("timestamp",
(String)null);
+ String officialTS = getServer().getAttribute("timestamp", (String)null);
+ if( !helperTS.equals(officialTS)) {
+ helper = new ServerAttributeHelper(getServer().getOriginal(), getServer());
+ }
+ }
+ return helper;
+ }
+
public IModule[] getPossibleModules() {
return (IModule[]) possibleModules.toArray(new IModule[possibleModules.size()]);
}
@@ -77,40 +114,151 @@
}
+ private ArrayList<DeployUIAdditions> deployAdditions;
+ private ScrolledPageBook preferencePageBook;
+ private Combo deployTypeCombo;
+ private Composite absolutePageRoot;
+ private Section publishTypeSection;
public void createPartControl(Composite parent) {
+ absolutePageRoot = parent;
preferences =
DeploymentPreferenceLoader.loadPreferencesFromServer(server.getOriginal());
- tabs = new ArrayList<IDeploymentEditorTab>();
-
+ Composite innerContent = createPageStructure(parent);
+ Control top = createPublishMethodSection(innerContent);
+ addDeploymentLocationControls(innerContent, top);
+ }
+
+ private Composite createPageStructure(Composite parent) {
FormToolkit toolkit = getFormToolkit(parent);
-
- ScrolledForm form = toolkit.createScrolledForm(parent);
- toolkit.decorateFormHeading(form.getForm());
- form.setText("Deployment");
- form.getBody().setLayout(new GridLayout());
-
- final TabFolder tabFolder = new TabFolder(form.getBody(), SWT.NONE);
- tabFolder.setLayoutData(new GridData(GridData.FILL_BOTH));
- toolkit.adapt(tabFolder);
- toolkit.adapt(form);
- toolkit.adapt(form.getBody());
- IDeploymentEditorTab[] newItems = createTabs(toolkit, tabFolder);
- for( int i = 0; i < newItems.length; i++ ) {
- tabs.add(newItems[i]);
- }
+ ScrolledForm allContent = toolkit.createScrolledForm(parent);
+ toolkit.decorateFormHeading(allContent.getForm());
+ allContent.setText("Deployment");
+ allContent.getBody().setLayout(new GridLayout());
+ Composite random = new Composite(allContent.getBody(), SWT.NONE);
+ GridData randomData = new GridData(GridData.FILL_BOTH);
+ random.setLayoutData(randomData);
+ random.setLayout(new FormLayout());
+ return random;
}
- protected IDeploymentEditorTab[] createTabs(FormToolkit toolkit, TabFolder tabFolder) {
- TabItem tabItem = new TabItem(tabFolder, SWT.NULL);
- IDeploymentEditorTab tab = new LocalDeploymentModuleTab();
- tabItem.setText(tab.getTabName());
+ private void addDeploymentLocationControls(Composite parent, Control top) {
+ DeploymentModuleOptionCompositeAssistant tab = new
DeploymentModuleOptionCompositeAssistant();
tab.setDeploymentPage(this);
tab.setDeploymentPrefs(preferences);
- tabItem.setControl(tab.createControl(tabFolder));
- toolkit.adapt((Composite)tabItem.getControl());
+ Composite defaultComposite = tab.createDefaultComposite(parent);
+ FormData fd = new FormData();
+ fd.left = new FormAttachment(0, 5);
+ fd.top = new FormAttachment(top, 5);
+ fd.right = new FormAttachment(100, -5);
+ defaultComposite.setLayoutData(fd);
+
+ Composite viewComposite = tab.createViewerPortion(parent);
+ fd = new FormData();
+ fd.left = new FormAttachment(0, 5);
+ fd.top = new FormAttachment(defaultComposite, 5);
+ fd.right = new FormAttachment(100, -5);
+ fd.bottom = new FormAttachment(100, -5);
+ viewComposite.setLayoutData(fd);
+ }
+
+
+ private class DeployUIAdditions {
+ private IJBossServerPublishMethodType publishType;
+ private IDeploymentTypeUI ui;
+ private boolean registered = false;
+ public DeployUIAdditions(IJBossServerPublishMethodType type,IDeploymentTypeUI ui) {
+ this.publishType = type;
+ this.ui = ui;
+ }
+ public boolean isRegistered() {
+ return registered;
+ }
+ public IJBossServerPublishMethodType getPublishType() {
+ return publishType;
+ }
+ public void createComposite(Composite parent) {
+ // UI can be null
+ if( ui != null ) {
+ ui.fillComposite(parent, ModuleDeploymentPage.this);
+ registered = true;
+ }
+ }
+ }
+
+ private void loadDeployTypeData() {
+ deployAdditions = new ArrayList<DeployUIAdditions>();
+ IJBossServerPublishMethodType[] publishMethodTypes =
ExtensionManager.getDefault().findPossiblePublishMethods(getServer().getOriginal());
+ for( int i = 0; i < publishMethodTypes.length; i++) {
+ IDeploymentTypeUI ui =
EditorExtensionManager.getDefault().getPublishPreferenceUI(publishMethodTypes[i].getId());
+ deployAdditions.add(new DeployUIAdditions(publishMethodTypes[i], ui));
+ }
+ }
+
+ private Control createPublishMethodSection(Composite parent) {
+ loadDeployTypeData();
- return new IDeploymentEditorTab[] { tab };
+ FormToolkit toolkit2 = new FormToolkit(parent.getDisplay());
+ publishTypeSection = toolkit2.createSection(parent,
+ ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED
+ | ExpandableComposite.TITLE_BAR);
+ publishTypeSection.setText("Publish Method");
+ Composite c = toolkit2.createComposite(publishTypeSection);
+ publishTypeSection.setClient(c);
+ FormData fd = UIUtil.createFormData2(0, 5, null, 0, 0, 5, 100, -5);
+ publishTypeSection.setLayoutData(fd);
+ c.setLayout(new FormLayout());
+ deployTypeCombo = new Combo(c, SWT.DEFAULT);
+ fd = UIUtil.createFormData2(0, 5, null, 0, 0, 5, 50, -5);
+ deployTypeCombo.setLayoutData(fd);
+
+
+ preferencePageBook = toolkit2.createPageBook(c, SWT.FLAT|SWT.TOP);
+ preferencePageBook.setLayoutData(UIUtil.createFormData2(
+ deployTypeCombo, 5, 0, 150, 0, 5, 100, -5));
+// deployTypeCombo, 5, null, 0, 0, 5, 100, -5));
+
+ // fill widgets
+ String[] nameList = new String[deployAdditions.size()];
+ for( int i = 0; i < nameList.length; i++ ) {
+ nameList[i] = deployAdditions.get(i).getPublishType().getName();
+ }
+ deployTypeCombo.setItems(nameList);
+ DeployableServerBehavior ds =
ServerConverter.getDeployableServerBehavior(getServer().getOriginal());
+ if( ds != null ) {
+ String current = ds.createPublishMethod().getPublishMethodType().getName();
+ int index = deployTypeCombo.indexOf(current);
+ if( index != -1 )
+ deployTypeCombo.select(index);
+ }
+ deployTypeCombo.addModifyListener(new ModifyListener(){
+ @Override
+ public void modifyText(ModifyEvent e) {
+ deployTypeChanged(true);
+ }});
+ return publishTypeSection;
}
+ private void deployTypeChanged(boolean fireEvent) {
+ int index = deployTypeCombo.getSelectionIndex();
+ if( index != -1 ) {
+ DeployUIAdditions ui = deployAdditions.get(index);
+ if( !ui.isRegistered()) {
+ Composite newRoot = preferencePageBook.createPage(ui);
+ ui.createComposite(newRoot);
+ }
+ preferencePageBook.showPage(ui);
+ //((Composite)publishTypeSection.getClient()).layout(true, true);
+ absolutePageRoot.layout(true, true);
+ if( fireEvent ) {
+ commandManager.execute(new ChangeRootDeployPreference(preferences,
+ DeploymentPreferenceLoader.CURRENT_METHOD_PROPERTY,
+ ui.getPublishType().getId(), "Change Publish Method"));
+ }
+ } else {
+ // null selection
+ }
+ }
+
+
public void execute(ServerCommand command) {
commandManager.execute(command);
}
@@ -120,8 +268,28 @@
}
+ private class ChangeRootDeployPreference extends ServerCommand {
+ private DeploymentPreferences p;
+ private String key;
+ private String oldVal;
+ private String newVal;
+ public ChangeRootDeployPreference(DeploymentPreferences p, String key, String val,
String command) {
+ super(ModuleDeploymentPage.this.server, command);
+ this.p = p;
+ this.key = key;
+ this.newVal = val;
+ this.oldVal = p.getProperty(key);
+ }
+ public void execute() {
+ p.setProperty(key, newVal);
+ savePreferencesToWorkingCopy();
+ }
+ public void undo() {
+ p.setProperty(key, oldVal);
+ savePreferencesToWorkingCopy();
+ }
+ }
-
private class ChangePropertyCommand extends ServerCommand {
private DeploymentModulePrefs p;
private String key;
@@ -136,23 +304,21 @@
}
public void execute() {
p.setProperty(key, newVal);
- saveToWC();
+ savePreferencesToWorkingCopy();
}
public void undo() {
p.setProperty(key, oldVal);
- saveToWC();
+ savePreferencesToWorkingCopy();
}
-
- protected void saveToWC() {
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
- DeploymentPreferenceLoader.savePreferences(bos, preferences);
- String asXML = new String(bos.toByteArray());
- helper.setAttribute(DeploymentPreferenceLoader.DEPLOYMENT_PREFERENCES_KEY, asXML);
- }
}
+ public void savePreferencesToWorkingCopy() {
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ DeploymentPreferenceLoader.savePreferences(bos, preferences);
+ String asXML = new String(bos.toByteArray());
+ getHelper().setAttribute(DeploymentPreferenceLoader.DEPLOYMENT_PREFERENCES_KEY,
asXML);
+ }
-
public String makeGlobal(String path) {
return makeGlobal(path, server.getRuntime());
}
Modified: workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml
===================================================================
--- workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml 2010-07-20
09:27:46 UTC (rev 23581)
+++ workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml 2010-07-20
09:55:16 UTC (rev 23582)
@@ -4,6 +4,7 @@
<extension-point id="EventLogLabelProvider"
name="org.jboss.ide.as.ui.eventLogLabelProvider"
schema="schema/EventLogLabelProvider.exsd"/>
<extension-point id="EventLogMajorType"
name="org.jboss.ide.eclipse.as.ui.eventLogMajorType"
schema="schema/EventLogMajorType.exsd"/>
<extension-point id="ServerEditorPortSection"
name="org.jboss.ide.as.ui.editor.portSection"
schema="schema/ServerEditorPortSection.exsd"/>
+ <extension-point id="DeployMethodUI"
name="org.jboss.ide.as.ui.deployMethodUI"
schema="schema/DeployMethodUI.exsd"/>
<extension
point="org.eclipse.wst.server.ui.serverImages">
@@ -578,5 +579,12 @@
typeIds="%AllJBossServerTypes">
</runtimeLocator>
</extension>
+ <extension
+ point="org.jboss.ide.eclipse.as.ui.DeployMethodUI">
+ <ui
+ class="org.jboss.tools.as.rse.ui.RSEDeploymentPreferenceUI"
+ deployMethodId="rse">
+ </ui>
+ </extension>
</plugin>