Author: rob.stryker(a)jboss.com
Date: 2009-08-17 19:55:17 -0400 (Mon, 17 Aug 2009)
New Revision: 17113
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/DeploymentPreferenceLoader.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/ModuleDeploymentPage.java
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/PackagesPublisher.java
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/WTPZippedPublisher.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/JstPublisher.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/PublishUtil.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/SingleFilePublisher.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/ServerListener.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/xpl/PublishCopyUtil.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/IJBossToolingConstants.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/DeploySection.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml
Log:
JBIDE-4374 - can still use a bit of cleanup though, perhaps in UI
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/PackagesPublisher.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/PackagesPublisher.java 2009-08-17
17:02:20 UTC (rev 17112)
+++
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/PackagesPublisher.java 2009-08-17
23:55:17 UTC (rev 17113)
@@ -35,6 +35,7 @@
import
org.jboss.ide.eclipse.archives.webtools.modules.PackageModuleFactory.ExtendedModuleFile;
import
org.jboss.ide.eclipse.archives.webtools.modules.PackageModuleFactory.IExtendedModuleResource;
import
org.jboss.ide.eclipse.archives.webtools.modules.PackageModuleFactory.PackagedModuleDelegate;
+import org.jboss.ide.eclipse.as.core.publishers.PublishUtil;
import org.jboss.ide.eclipse.as.core.server.IDeployableServer;
import org.jboss.ide.eclipse.as.core.server.IJBossServerPublisher;
import org.jboss.ide.eclipse.as.core.util.FileUtil;
@@ -106,9 +107,11 @@
// remove all of the deployed items
if( pack != null ) {
IPath sourcePath = pack.getArchiveFilePath();
- IPath destPath = new Path(server.getDeployFolder()).append(sourcePath.lastSegment());
+ IModule[] tree = new IModule[] { module };
+ IPath destPath = PublishUtil.getDeployPath(tree, server);
+ IPath destPath2 = destPath.append(sourcePath.lastSegment());
// remove the entire file or folder
- FileUtil.safeDelete(destPath.toFile(), listener);
+ FileUtil.safeDelete(destPath2.toFile(), listener);
}
}
@@ -117,7 +120,8 @@
protected void publishModule(IModule module, boolean incremental, IProgressMonitor
monitor) {
IArchive pack = getPackage(module);
IPath sourcePath = pack.getArchiveFilePath();
- IPath destPathRoot = new Path(server.getDeployFolder());
+ IModule[] tree = new IModule[] { module };
+ IPath destPathRoot = PublishUtil.getDeployPath(tree, server);
// if destination is deploy directory... no need to re-copy!
if( destPathRoot.toOSString().equals(PathUtils.getGlobalLocation(pack).toOSString()))
{
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/WTPZippedPublisher.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/WTPZippedPublisher.java 2009-08-17
17:02:20 UTC (rev 17112)
+++
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/WTPZippedPublisher.java 2009-08-17
23:55:17 UTC (rev 17113)
@@ -30,6 +30,7 @@
import org.jboss.ide.eclipse.as.core.server.IJBossServerPublisher;
import org.jboss.ide.eclipse.as.core.server.internal.DeployableServerBehavior;
import org.jboss.ide.eclipse.as.core.util.FileUtil;
+import org.jboss.ide.eclipse.as.core.util.ServerConverter;
import org.jboss.ide.eclipse.as.core.util.FileUtil.IFileUtilListener;
import de.schlichtherle.io.ArchiveDetector;
@@ -157,8 +158,8 @@
}
protected IStatus[] removeModule(IServer server, IModule[] module) {
- String depFolder = getDeployableServer(server).getDeployFolder();
- IPath deployPath = getDeployPath(module, depFolder);
+ IDeployableServer ds = ServerConverter.getDeployableServer(server);
+ IPath deployPath = getDeployPath(module, ds);
final ArrayList<IStatus> status = new ArrayList<IStatus>();
IFileUtilListener listener = new IFileUtilListener() {
public void fileCopied(File source, File dest, boolean result,Exception e) {}
@@ -181,9 +182,9 @@
protected IStatus[] fullPublish(IServer server, IModule[] module) {
ArrayList<IStatus> results = new ArrayList<IStatus>();
+ IDeployableServer ds = ServerConverter.getDeployableServer(server);
try {
- String depFolder = getDeployableServer(server).getDeployFolder();
- IPath path = getDeployPath(module, depFolder);
+ IPath path = getDeployPath(module, ds);
// Get rid of the old
FileUtil.safeDelete(path.toFile(), null);
@@ -203,8 +204,8 @@
}
protected IStatus[] publishChanges(IServer server, IModule[] module) {
- String depFolder = getDeployableServer(server).getDeployFolder();
- IPath path = getDeployPath(module, depFolder);
+ IDeployableServer ds = ServerConverter.getDeployableServer(server);
+ IPath path = getDeployPath(module, ds);
de.schlichtherle.io.File root = TrueZipUtil.getFile(path,
TrueZipUtil.getJarArchiveDetector());
IModuleResourceDelta[] deltas = ((Server)server).getPublishedResourceDelta(module);
return publishChanges(server, deltas, root);
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/JstPublisher.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/JstPublisher.java 2009-08-17
17:02:20 UTC (rev 17112)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/JstPublisher.java 2009-08-17
23:55:17 UTC (rev 17113)
@@ -109,7 +109,8 @@
protected IStatus fullPublish(IModule[] moduleTree, IModule module, IProgressMonitor
monitor) throws CoreException {
- IPath deployPath = getDeployPath(moduleTree, server.getDeployFolder());
+ IPath deployPath = getDeployPath(moduleTree, server);
+ IPath tempDeployPath = getTempDeployFolder(moduleTree, server);
IModuleResource[] members = getResources(module);
ArrayList<IStatus> list = new ArrayList<IStatus>();
@@ -117,8 +118,10 @@
if( !(new Path(module.getName()).segmentCount() > 1 ))
list.addAll(Arrays.asList(localSafeDelete(deployPath)));
- if( !deployPackaged(moduleTree) && !isBinaryObject(moduleTree))
- list.addAll(Arrays.asList(new PublishCopyUtil(server.getServer()).publishFull(members,
deployPath, monitor)));
+ if( !deployPackaged(moduleTree) && !isBinaryObject(moduleTree)) {
+ PublishCopyUtil util = new PublishCopyUtil(server.getServer(), deployPath,
tempDeployPath);
+ list.addAll(Arrays.asList(util.publishFull(members, deployPath, monitor)));
+ }
else if( isBinaryObject(moduleTree))
list.addAll(Arrays.asList(copyBinaryModule(moduleTree)));
else
@@ -152,9 +155,11 @@
protected IStatus incrementalPublish(IModule[] moduleTree, IModule module,
IProgressMonitor monitor) throws CoreException {
IStatus[] results = new IStatus[] {};
- IPath deployPath = getDeployPath(moduleTree, server.getDeployFolder());
+ IPath deployPath = getDeployPath(moduleTree, server);
+ IPath tempDeployPath = getTempDeployFolder(moduleTree, server);
if( !deployPackaged(moduleTree) && !isBinaryObject(moduleTree))
- results = new PublishCopyUtil(server.getServer()).publishDelta(delta, deployPath,
monitor);
+ results = new PublishCopyUtil(server.getServer(), deployPath, tempDeployPath)
+ .publishDelta(delta, deployPath, monitor);
else if( delta.length > 0 ) {
if( isBinaryObject(moduleTree))
results = copyBinaryModule(moduleTree);
@@ -176,7 +181,7 @@
protected IStatus unpublish(IDeployableServer jbServer, IModule[] module,
IProgressMonitor monitor) throws CoreException {
IModule mod = module[module.length-1];
- IStatus[] errors = localSafeDelete(getDeployPath(module, server.getDeployFolder()));
+ IStatus[] errors = localSafeDelete(getDeployPath(module, server));
if( errors.length > 0 ) {
publishState = IServer.PUBLISH_STATE_FULL;
MultiStatus ms = new MultiStatus(JBossServerCorePlugin.PLUGIN_ID,
IEventCodes.JST_PUB_REMOVE_FAIL,
@@ -195,7 +200,7 @@
protected IStatus[] copyBinaryModule(IModule[] moduleTree) {
try {
- IPath deployPath = getDeployPath(moduleTree, server.getDeployFolder());
+ IPath deployPath = getDeployPath(moduleTree, server);
FileUtilListener listener = new FileUtilListener();
IModuleResource[] members = getResources(moduleTree);
File source = (File)members[0].getAdapter(File.class);
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/PublishUtil.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/PublishUtil.java 2009-08-17
17:02:20 UTC (rev 17112)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/PublishUtil.java 2009-08-17
23:55:17 UTC (rev 17113)
@@ -22,7 +22,13 @@
import org.eclipse.wst.server.core.model.IModuleResource;
import org.eclipse.wst.server.core.model.IModuleResourceDelta;
import org.eclipse.wst.server.core.model.ModuleDelegate;
+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.util.DeploymentPreferenceLoader;
+import org.jboss.ide.eclipse.as.core.util.IJBossToolingConstants;
+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.DeploymentPreferenceLoader.DeploymentTypePrefs;
public class PublishUtil {
public static int countChanges(IModuleResourceDelta[] deltas) {
@@ -59,7 +65,51 @@
return count;
}
- public static IPath getDeployPath(IModule[] moduleTree, String deployFolder) {
+ private static String getDeployRootFolder(IModule[] moduleTree,
+ IDeployableServer server, String defaultFolder, String moduleProperty) {
+ String folder = defaultFolder;
+ DeploymentPreferences prefs =
DeploymentPreferenceLoader.loadPreferences(server.getServer());
+ DeploymentTypePrefs typePrefs = prefs.getOrCreatePreferences("local");
//$NON-NLS-1$
+ DeploymentModulePrefs modPrefs = typePrefs.getModulePrefs(moduleTree[0]);
+ if( modPrefs != null ) {
+ String loc = modPrefs.getProperty(moduleProperty);
+ if( loc != null && !loc.equals("") ) { //$NON-NLS-1$
+ if( !new Path(loc).isAbsolute()) {
+ folder = server.getServer().getRuntime().getLocation().append(loc).toString();
+ } else {
+ folder = loc;
+ }
+ // TODO translate for variables?
+ }
+ }
+ return folder;
+ }
+
+ public static IPath getDeployPath(IModule[] moduleTree, IDeployableServer server) {
+ String folder = getDeployRootFolder(
+ moduleTree, server,
+ server.getDeployFolder(),
+ IJBossToolingConstants.LOCAL_DEPLOYMENT_LOC);
+ return getDeployPath(moduleTree, folder);
+ }
+
+ public static IPath getDeployRootFolder(IModule[] moduleTree, IDeployableServer server)
{
+ String folder = getDeployRootFolder(
+ moduleTree, server,
+ server.getDeployFolder(),
+ IJBossToolingConstants.LOCAL_DEPLOYMENT_LOC);
+ return new Path(folder);
+ }
+
+ public static IPath getTempDeployFolder(IModule[] moduleTree, IDeployableServer server)
{
+ String folder = getDeployRootFolder(
+ moduleTree, server,
+ server.getTempDeployFolder(),
+ IJBossToolingConstants.LOCAL_DEPLOYMENT_TEMP_LOC);
+ return new Path(folder);
+ }
+
+ private static IPath getDeployPath(IModule[] moduleTree, String deployFolder) {
IPath root = new Path( deployFolder );
String type, modName, name, uri, suffixedName;
for( int i = 0; i < moduleTree.length; i++ ) {
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/SingleFilePublisher.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/SingleFilePublisher.java 2009-08-17
17:02:20 UTC (rev 17112)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/SingleFilePublisher.java 2009-08-17
23:55:17 UTC (rev 17113)
@@ -78,10 +78,11 @@
SingleDeployableModuleDelegate delegate =
(SingleDeployableModuleDelegate)module.loadAdapter(SingleDeployableModuleDelegate.class,
new NullProgressMonitor());
if( delegate != null ) {
IPath sourcePath = delegate.getGlobalSourcePath();
- IPath destFolder = new Path(server.getDeployFolder());
- IPath tempDestFolder = new Path(server.getTempDeployFolder());
+
+ IPath destFolder = PublishUtil.getDeployPath(new IModule[]{module},
server).removeLastSegments(1);;
+ IPath tempDestFolder = PublishUtil.getTempDeployFolder(new IModule[]{module},
server).removeLastSegments(1);;
+ File destFile = destFolder.append(sourcePath.lastSegment()).toFile();
File tempDestFile = tempDestFolder.append(sourcePath.lastSegment()).toFile();
- File destFile = destFolder.append(sourcePath.lastSegment()).toFile();
if( destFile.exists())
destFile.delete();
FileUtilListener l = new FileUtilListener();
@@ -115,7 +116,7 @@
SingleDeployableModuleDelegate delegate =
(SingleDeployableModuleDelegate)module.loadAdapter(SingleDeployableModuleDelegate.class,
new NullProgressMonitor());
if( delegate != null ) {
IPath sourcePath = delegate.getGlobalSourcePath();
- IPath destFolder = new Path(server.getDeployFolder());
+ IPath destFolder = PublishUtil.getDeployPath(new IModule[]{module},
server).removeLastSegments(1);
FileUtilListener l = new FileUtilListener();
File destFile = destFolder.append(sourcePath.lastSegment()).toFile();
FileUtil.safeDelete(destFile, l);
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/ServerListener.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/ServerListener.java 2009-08-17
17:02:20 UTC (rev 17112)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/ServerListener.java 2009-08-17
23:55:17 UTC (rev 17113)
@@ -11,16 +11,17 @@
package org.jboss.ide.eclipse.as.core.server.internal;
import java.io.File;
+import java.util.ArrayList;
import javax.management.MBeanServerConnection;
import javax.management.ObjectName;
import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
+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.ServerEvent;
@@ -29,6 +30,7 @@
import org.jboss.ide.eclipse.as.core.extensions.events.IEventCodes;
import org.jboss.ide.eclipse.as.core.extensions.events.ServerLogger;
import org.jboss.ide.eclipse.as.core.extensions.jmx.JBossServerConnectionProvider;
+import org.jboss.ide.eclipse.as.core.publishers.PublishUtil;
import org.jboss.ide.eclipse.as.core.server.IDeployableServer;
import org.jboss.ide.eclipse.as.core.server.IJBossServerConstants;
import org.jboss.ide.eclipse.as.core.server.IJBossServerRuntime;
@@ -121,9 +123,29 @@
protected void ensureDeployLocationAdded(IServer server, MBeanServerConnection
connection) throws Exception {
IDeployableServer ds = ServerConverter.getDeployableServer(server);
- String deployFolder = ds.getDeployFolder();
- String asURL = new File(deployFolder).toURL().toString();
- ObjectName name = new
ObjectName(IJBossRuntimeConstants.DEPLOYMENT_SCANNER_MBEAN_NAME);
- connection.invoke(name, IJBossRuntimeConstants.addURL, new Object[] { asURL }, new
String[] {String.class.getName()});
+
+ ArrayList<String> folders = new ArrayList<String>();
+ folders.add(ds.getDeployFolder());
+
+ IModule[] modules2 =
org.eclipse.wst.server.core.ServerUtil.getModules(server.getServerType().getRuntimeType().getModuleTypes());
+ if (modules2 != null) {
+ int size = modules2.length;
+ for (int i = 0; i < size; i++) {
+ IModule[] module = new IModule[] { modules2[i] };
+ IStatus status = server.canModifyModules(module, null, null);
+ if (status != null && status.getSeverity() != IStatus.ERROR) {
+ String tempFolder = PublishUtil.getDeployRootFolder(module, ds).toString();
+ if( !folders.contains(tempFolder))
+ folders.add(tempFolder);
+ }
+ }
+ }
+
+ String[] folders2 = (String[]) folders.toArray(new String[folders.size()]);
+ for( int i = 0; i < folders2.length; i++ ) {
+ String asURL = new File(folders2[i]).toURL().toString();
+ ObjectName name = new
ObjectName(IJBossRuntimeConstants.DEPLOYMENT_SCANNER_MBEAN_NAME);
+ connection.invoke(name, IJBossRuntimeConstants.addURL, new Object[] { asURL }, new
String[] {String.class.getName()});
+ }
}
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/xpl/PublishCopyUtil.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/xpl/PublishCopyUtil.java 2009-08-17
17:02:20 UTC (rev 17112)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/xpl/PublishCopyUtil.java 2009-08-17
23:55:17 UTC (rev 17113)
@@ -76,8 +76,19 @@
* PublishUtil cannot be created. Use static methods.
*/
private IServer server;
- public PublishCopyUtil(IServer server) {
+ private IPath rootDeploy;
+ private IPath rootTmpDeploy;
+
+ /**
+ *
+ * @param server The server we're publishing to
+ * @param deploy The deploy path where they're intended to go
+ * @param tmpDeploy The temporary location on the same partition
+ */
+ public PublishCopyUtil(IServer server, IPath deploy, IPath tmpDeploy) {
this.server = server;
+ this.rootDeploy = deploy;
+ this.rootTmpDeploy = tmpDeploy;
}
/**
@@ -193,12 +204,24 @@
* Smart copy the given module resources to the given path.
*
* @param resources an array of module resources
+ * @param monitor a progress monitor, or <code>null</code> if progress
+ * reporting and cancellation are not desired
+ * @return a possibly-empty array of error and warning status
+ */
+ public IStatus[] publishSmart(IModuleResource[] resources, IProgressMonitor monitor) {
+ return publishSmart(resources, rootDeploy, monitor);
+ }
+
+ /**
+ * Smart copy the given module resources to the given path.
+ *
+ * @param resources an array of module resources
* @param path an external path to copy to
* @param monitor a progress monitor, or <code>null</code> if progress
* reporting and cancellation are not desired
* @return a possibly-empty array of error and warning status
*/
- public IStatus[] publishSmart(IModuleResource[] resources, IPath path, IProgressMonitor
monitor) {
+ private IStatus[] publishSmart(IModuleResource[] resources, IPath path, IProgressMonitor
monitor) {
if (resources == null)
return EMPTY_STATUS;
@@ -772,11 +795,17 @@
}
protected File getTempFolder() {
- if( server == null ) return tempDir;
- String path = ServerConverter.getDeployableServer(server).getTempDeployFolder();
- File f = new File(path);
+ File f = null;
+ if( rootTmpDeploy != null ) {
+ f = rootTmpDeploy.toFile();
+ } else if( server != null ){
+ String path = ServerConverter.getDeployableServer(server).getTempDeployFolder();
+ f = new File(path);
+ } else {
+ return tempDir;
+ }
if( !f.exists() )
f.mkdirs();
- return new File(path);
+ return f;
}
}
\ No newline at end of file
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/DeploymentPreferenceLoader.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/DeploymentPreferenceLoader.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/DeploymentPreferenceLoader.java 2009-08-17
23:55:17 UTC (rev 17113)
@@ -0,0 +1,142 @@
+package org.jboss.ide.eclipse.as.core.util;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Set;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.wst.server.core.IModule;
+import org.eclipse.wst.server.core.IServer;
+import org.jboss.tools.jmx.core.IMemento;
+import org.jboss.tools.jmx.core.util.XMLMemento;
+
+public class DeploymentPreferenceLoader {
+ public static DeploymentPreferences loadPreferences(IServer server) {
+ File f = getFile(server);
+ return new DeploymentPreferences(f);
+ }
+
+ public static void savePreferences(IServer server, DeploymentPreferences prefs) throws
IOException {
+ File f = getFile(server);
+ prefs.getMemento().saveToFile(f.getAbsolutePath());
+ }
+
+ protected static File getFile(IServer server) {
+ IPath loc = ServerUtil.getServerStateLocation(server);
+ return loc.append("deploymentPreferences.xml").toFile(); //$NON-NLS-1$
+ }
+
+ public static class DeploymentPreferences {
+ private HashMap<String, DeploymentTypePrefs> children;
+ private XMLMemento memento;
+ public DeploymentPreferences(File f) {
+ children = new HashMap<String, DeploymentTypePrefs>();
+ if( f.exists()) {
+ try {
+ FileInputStream is = new FileInputStream(f);
+ memento = XMLMemento.createReadRoot(is);
+ String[] deploymentTypes = memento.getChildNames();
+ for( int i = 0; i < deploymentTypes.length; i++ )
+ children.put(deploymentTypes[i],
+ new DeploymentTypePrefs(deploymentTypes[i],
+ memento.getChild(deploymentTypes[i])));
+ } catch( FileNotFoundException fnfe) {}
+ } else {
+ memento = XMLMemento.createWriteRoot("deployment"); //$NON-NLS-1$
+ }
+ }
+
+ public DeploymentTypePrefs getPreferences(String deploymentType) {
+ return children.get(deploymentType);
+ }
+
+ public DeploymentTypePrefs getOrCreatePreferences(String deploymentType) {
+ if( children.get(deploymentType) == null ) {
+ children.put(deploymentType,
+ new DeploymentTypePrefs(deploymentType,
+ memento.createChild(deploymentType)));
+ }
+ return children.get(deploymentType);
+ }
+
+ public String[] getDeploymentTypes() {
+ Set<String> s = children.keySet();
+ return (String[]) s.toArray(new String[s.size()]);
+ }
+
+ protected XMLMemento getMemento() {
+ return memento;
+ }
+ }
+
+ public static class DeploymentTypePrefs {
+ private String type;
+ private HashMap<String, DeploymentModulePrefs> children;
+ private IMemento memento;
+ public DeploymentTypePrefs(String type, IMemento memento) {
+ this.type = type;
+ this.memento = memento;
+ this.children = new HashMap<String, DeploymentModulePrefs>();
+ IMemento[] mementos = memento.getChildren("module"); //$NON-NLS-1$
+ for( int i = 0; i < mementos.length; i++ ) {
+ 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) {
+ return children.get(module.getId());
+ }
+ public DeploymentModulePrefs getOrCreateModulePrefs(IModule module) {
+ if( children.get(module.getId()) == null ) {
+ IMemento childMemento = memento.createChild("module"); //$NON-NLS-1$
+ childMemento.putString("id", module.getId()); //$NON-NLS-1$
+ children.put(module.getId(),
+ new DeploymentModulePrefs(module.getId(),
+ childMemento));
+ }
+ return children.get(module.getId());
+ }
+ }
+ public static class DeploymentModulePrefs {
+ private String id;
+ private IMemento memento;
+ private HashMap<String, String> properties;
+ public DeploymentModulePrefs(String id, IMemento memento) {
+ this.id = id;
+ this.memento = memento;
+ properties = new HashMap<String, String>();
+ IMemento[] children = memento.getChildren("property"); //$NON-NLS-1$
+ String key, val;
+ for( int i = 0; i < children.length; i++ ) {
+ key = children[i].getString("key"); //$NON-NLS-1$
+ val = children[i].getString("value"); //$NON-NLS-1$
+ properties.put(key,val);
+ }
+ }
+
+ public String getProperty(String key) {
+ return properties.get(key);
+ }
+
+ public void setProperty(String key, String val) {
+ properties.put(key, 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$
+ }
+ }
+}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/IJBossToolingConstants.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/IJBossToolingConstants.java 2009-08-17
17:02:20 UTC (rev 17112)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/IJBossToolingConstants.java 2009-08-17
23:55:17 UTC (rev 17113)
@@ -72,4 +72,9 @@
public static final int JNDI_DEFAULT_PORT = 1099;
public static final int JBOSS_WEB_DEFAULT_PORT = 8080;
+
+ public static final String LOCAL_DEPLOYMENT_NAME = "name"; //$NON-NLS-1$
+ public static final String LOCAL_DEPLOYMENT_LOC = "location"; //$NON-NLS-1$
+ public static final String LOCAL_DEPLOYMENT_TEMP_LOC = "tempLocation";
//$NON-NLS-1$
+
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/DeploySection.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/DeploySection.java 2009-08-17
17:02:20 UTC (rev 17112)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/DeploySection.java 2009-08-17
23:55:17 UTC (rev 17113)
@@ -394,9 +394,11 @@
oldDir = deployText.getText();
oldTemp = tempDeployText.getText();
- String type;
+ 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();
@@ -409,16 +411,18 @@
IRuntime rt = DeploySection.this.server.getRuntime();
if( rt != null ) {
IJBossServerRuntime jbsrt =
(IJBossServerRuntime)rt.loadAdapter(IJBossServerRuntime.class, new
NullProgressMonitor());
- String config = jbsrt.getJBossConfiguration();
- newDir = new Path(IJBossServerConstants.SERVER)
- .append(config)
- .append(IJBossServerConstants.DEPLOY).makeRelative().toString();
- newTemp = new Path(IJBossServerConstants.SERVER).append(config)
- .append(IJBossServerConstants.TMP)
- .append(IJBossServerConstants.JBOSSTOOLS_TMP).makeRelative().toString();
- new File(newTemp).mkdirs();
+ if( jbsrt != null ) {
+ String config = jbsrt.getJBossConfiguration();
+ newDir = new Path(IJBossServerConstants.SERVER)
+ .append(config)
+ .append(IJBossServerConstants.DEPLOY).makeRelative().toString();
+ newTemp = new Path(IJBossServerConstants.SERVER).append(config)
+ .append(IJBossServerConstants.TMP)
+ .append(IJBossServerConstants.JBOSSTOOLS_TMP).makeRelative().toString();
+ new File(newTemp).mkdirs();
+ type = IDeployableServer.DEPLOY_SERVER;
+ }
}
- type = IDeployableServer.DEPLOY_SERVER;
} else {
newDir = lastCustomDeploy;
newTemp = lastCustomTemp;
@@ -436,6 +440,7 @@
newSelection.addSelectionListener(radioListener);
}
+ type = type == null ? oldType : type;
newDir = newDir == null ? oldDir : newDir;
newTemp = newTemp == null ? oldTemp : newTemp;
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/ModuleDeploymentPage.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/ModuleDeploymentPage.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/ModuleDeploymentPage.java 2009-08-17
23:55:17 UTC (rev 17113)
@@ -0,0 +1,298 @@
+package org.jboss.ide.eclipse.as.ui.editor;
+
+import java.io.IOException;
+import java.util.ArrayList;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+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.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.graphics.Image;
+import org.eclipse.swt.layout.FillLayout;
+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.Composite;
+import org.eclipse.swt.widgets.TreeColumn;
+import org.eclipse.swt.widgets.TreeItem;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.ScrolledForm;
+import org.eclipse.wst.server.core.IModule;
+import org.eclipse.wst.server.core.IRuntime;
+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.server.IJBossServerRuntime;
+import org.jboss.ide.eclipse.as.core.util.DeploymentPreferenceLoader;
+import org.jboss.ide.eclipse.as.core.util.IJBossToolingConstants;
+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;
+
+public class ModuleDeploymentPage extends ServerEditorPart {
+ private ServerResourceCommandManager commandManager;
+ private ArrayList<IModule> possibleChildren;
+
+ public void init(IEditorSite site, IEditorInput input) {
+ super.init(site, input);
+ ArrayList<IModule> possibleChildren = new ArrayList<IModule>();
+ IModule[] modules2 =
org.eclipse.wst.server.core.ServerUtil.getModules(server.getServerType().getRuntimeType().getModuleTypes());
+ if (modules2 != null) {
+ int size = modules2.length;
+ for (int i = 0; i < size; i++) {
+ IModule module = modules2[i];
+ IStatus status = server.canModifyModules(new IModule[] { module }, null, null);
+ if (status != null && status.getSeverity() != IStatus.ERROR)
+ possibleChildren.add(module);
+ }
+ }
+ this.possibleChildren = possibleChildren;
+ if (input instanceof IServerEditorPartInput) {
+ IServerEditorPartInput sepi = (IServerEditorPartInput) input;
+ server = sepi.getServer();
+ commandManager = ((ServerEditorPartInput) sepi).getServerCommandManager();
+ readOnly = sepi.isServerReadOnly();
+ }
+
+ }
+
+ public void createPartControl(Composite parent) {
+ createLocalControl(parent);
+ }
+
+ private TreeViewer viewer;
+ private DeploymentPreferences preferences;
+ 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 void createLocalControl(Composite parent) {
+ preferences = DeploymentPreferenceLoader.loadPreferences(server.getOriginal());
+ FormToolkit toolkit = getFormToolkit(parent.getDisplay());
+
+ ScrolledForm form = toolkit.createScrolledForm(parent);
+ toolkit.decorateFormHeading(form.getForm());
+ form.setText("Module Deployment");
+ //form.setImage(null);
+ GridLayout layout = new GridLayout();
+ layout.marginTop = 6;
+ layout.marginLeft = 6;
+ form.getBody().setLayout(layout);
+
+ Composite random = toolkit.createComposite(form.getBody(), SWT.NONE);
+ random.setLayout(new FillLayout());
+ GridData randomData = new GridData(GridData.FILL_BOTH);
+ random.setLayoutData(randomData);
+ Composite root = toolkit.createComposite(random, SWT.NONE);
+ root.setLayout(new FormLayout());
+
+ 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("Module");
+ publishLocColumn.setText("Publish Location");
+ publishTempLocColumn.setText("Publish Temporary Location");
+
+ moduleColumn.setWidth(200);
+ publishLocColumn.setWidth(200);
+ publishTempLocColumn.setWidth(200);
+
+
+ FormData treeData = new FormData();
+ treeData.top = new FormAttachment(0, 100);
+ treeData.bottom = new FormAttachment(100, -100);
+ 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("");
+ CellEditor[] editors = new CellEditor[] {
+ new TextCellEditor(viewer.getTree()),
+ new TextCellEditor(viewer.getTree()),
+ new TextCellEditor(viewer.getTree())
+ };
+ viewer.setCellModifier(new LocalDeploymentCellModifier());
+ viewer.setCellEditors(editors);
+ }
+
+ private class LocalDeploymentCellModifier implements ICellModifier {
+ public boolean canModify(Object element, String property) {
+ 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) {
+ firePropertyChangeCommand(p, LOCAL_COLUMN_LOC, (String)value);
+ } else
+ if( property == LOCAL_COLUMN_TEMP_LOC) {
+ firePropertyChangeCommand(p, LOCAL_COLUMN_TEMP_LOC, (String)value);
+ }
+ }
+ }
+
+ protected void firePropertyChangeCommand(DeploymentModulePrefs p, String key, String
val) {
+ commandManager.execute(new ChangePropertyCommand(p,key,val));
+ }
+
+ private String makeGlobal(String path) {
+ return ServerUtil.makeGlobal(getRuntime(), new Path(path)).toString();
+ }
+
+ private String makeRelative(String path) {
+ if (getRuntime() == null) {
+ return path;
+ }
+ return ServerUtil.makeRelative(getRuntime(), new Path(path)).toString();
+ }
+
+ private IJBossServerRuntime getRuntime() {
+ IRuntime r = server.getRuntime();
+ IJBossServerRuntime ajbsrt = null;
+ if (r != null) {
+ ajbsrt = (IJBossServerRuntime) r
+ .loadAdapter(IJBossServerRuntime.class,
+ new NullProgressMonitor());
+ }
+ return ajbsrt;
+ }
+
+
+ private class ChangePropertyCommand extends ServerCommand {
+ private DeploymentModulePrefs p;
+ private String key;
+ private String oldVal;
+ private String newVal;
+ public ChangePropertyCommand(DeploymentModulePrefs p, String key, String val) {
+ super(ModuleDeploymentPage.this.server, "command text");
+ this.p = p;
+ this.key = key;
+ this.newVal = val;
+ this.oldVal = p.getProperty(key);
+ }
+ public void execute() {
+ p.setProperty(key, newVal);
+ viewer.refresh();
+ }
+ public void undo() {
+ p.setProperty(key, oldVal);
+ 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 (IModule[]) possibleChildren.toArray(new IModule[possibleChildren.size()]);
+ }
+ 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) {
+ 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, defaultLocation());
+ return defaultLocation();
+ }
+ 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, defaultTempLocation());
+ return defaultTempLocation();
+ }
+ }
+ 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) {
+ }
+ }
+
+ protected String defaultLocation() {
+ //return "server/${jboss_config}/deploy";
+ return "";
+ }
+ protected String defaultTempLocation() {
+ //return "server/${jboss_config}/tmp/jbosstoolsTemp";
+ return "";
+ }
+
+ public void setFocus() {
+ }
+
+ public void doSave(IProgressMonitor monitor) {
+ try {
+ DeploymentPreferenceLoader.savePreferences(server.getOriginal(), preferences);
+ } catch( IOException ioe ) {
+ // TODO eh?
+ }
+ }
+}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml 2009-08-17 17:02:20 UTC (rev
17112)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml 2009-08-17 23:55:17 UTC (rev
17113)
@@ -140,6 +140,16 @@
name="Publish Events"
typeId="org.jboss.ide.eclipse.as.core.publishers.Events.MajorType"/>
</extension>
+ <extension
+ point="org.eclipse.wst.server.ui.editorPages">
+ <page
+ class="org.jboss.ide.eclipse.as.ui.editor.ModuleDeploymentPage"
+ id="org.jboss.ide.eclipse.as.ui.editor.deploymentPage"
+ name="Module Deployment"
+ typeIds="org.jboss.ide.eclipse.as.systemCopyServer,
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.eap.43,org.jboss.ide.eclipse.as.eap.50">
+ </page>
+ </extension>
+
<extension
point="org.eclipse.wst.server.ui.editorPageSections">
<section