Author: rob.stryker(a)jboss.com
Date: 2009-10-19 17:52:18 -0400 (Mon, 19 Oct 2009)
New Revision: 18171
Added:
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/LocalZippedPublisherUtil.java
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/plugin.xml
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/ExtensionManager.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/LocalPublishMethod.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/NullPublisher.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/IJBossServerPublishMethod.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IJBossServerPublisher.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/DeployableServerBehavior.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.ui/META-INF/MANIFEST.MF
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/LocalDeploymentModuleTab.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/ModuleDeploymentPage.java
Log:
JBIDE-5048 - preparation for step 1, getting some APIs in order
Modified: trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/plugin.xml
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/plugin.xml 2009-10-19
17:21:45 UTC (rev 18170)
+++ trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/plugin.xml 2009-10-19
21:52:18 UTC (rev 18171)
@@ -92,7 +92,7 @@
</publisher>
<publisher
class="org.jboss.ide.eclipse.archives.webtools.modules.WTPZippedPublisher"
- priority="0"
+ priority="2"
zipDelegate="true">
</publisher>
</extension>
Added:
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/LocalZippedPublisherUtil.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/LocalZippedPublisherUtil.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/LocalZippedPublisherUtil.java 2009-10-19
21:52:18 UTC (rev 18171)
@@ -0,0 +1,287 @@
+package org.jboss.ide.eclipse.archives.webtools.modules;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.MultiStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.wst.server.core.IModule;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.internal.Server;
+import org.eclipse.wst.server.core.model.IModuleFile;
+import org.eclipse.wst.server.core.model.IModuleFolder;
+import org.eclipse.wst.server.core.model.IModuleResource;
+import org.eclipse.wst.server.core.model.IModuleResourceDelta;
+import org.jboss.ide.eclipse.archives.core.util.internal.TrueZipUtil;
+import org.jboss.ide.eclipse.archives.webtools.IntegrationPlugin;
+import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
+import org.jboss.ide.eclipse.as.core.extensions.events.IEventCodes;
+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.server.internal.DeployableServerBehavior;
+import org.jboss.ide.eclipse.as.core.util.FileUtil;
+import org.jboss.ide.eclipse.as.core.util.FileUtil.IFileUtilListener;
+
+import de.schlichtherle.io.ArchiveDetector;
+
+public class LocalZippedPublisherUtil extends PublishUtil {
+
+ private IServer server;
+ private String deployRoot;
+ private IModule[] module;
+ private int publishType;
+ private IModuleResourceDelta[] delta;
+
+ public IStatus publishModule(IServer server, String deployRoot, IModule[] module,
+ int publishType, IModuleResourceDelta[] delta,
+ IProgressMonitor monitor) throws CoreException {
+ this.server = server;
+ this.deployRoot = deployRoot;
+ this.module = module;
+ this.publishType = publishType;
+ this.delta = delta;
+
+ IStatus[] returnStatus;
+
+
+ // Am I a removal? If yes, remove me, and return
+ if( publishType == IJBossServerPublisher.REMOVE_PUBLISH)
+ returnStatus = removeModule(server, deployRoot, module);
+
+ // Am I a full publish? If yes, full publish me, and return
+ else if( publishType == IJBossServerPublisher.FULL_PUBLISH)
+ returnStatus = fullPublish(server, deployRoot, module);
+
+ else {
+ // Am I changed? If yes, handle my changes
+ ArrayList<IStatus> results = new ArrayList<IStatus>();
+ if( countChanges(delta) > 0) {
+ results.addAll(Arrays.asList(publishChanges(server, deployRoot, module)));
+ }
+
+ IModule[] children = server.getChildModules(module, new NullProgressMonitor());
+ results.addAll(Arrays.asList(handleChildrenDeltas(server, deployRoot, module,
children)));
+
+ // Handle the removed children that are not returned by getChildModules
+ List<IModule[]> removed = getBehaviour(server).getRemovedModules();
+ Iterator<IModule[]> i = removed.iterator();
+ while(i.hasNext()) {
+ IModule[] removedArray = i.next();
+ if( removedArray[0].getId().equals(module[0].getId())) {
+ results.addAll(Arrays.asList(removeModule(server, deployRoot, removedArray)));
+ }
+ }
+ returnStatus = (IStatus[]) results.toArray(new IStatus[results.size()]);
+ }
+ TrueZipUtil.umount();
+
+ IStatus finalStatus;
+ if( returnStatus.length > 0 ) {
+ MultiStatus ms = new MultiStatus(JBossServerCorePlugin.PLUGIN_ID,
IEventCodes.JST_PUB_INC_FAIL,
+ "Publish Failed for module " + module[0].getName(), null); //$NON-NLS-1$
+ for( int i = 0; i < returnStatus.length; i++ )
+ ms.add(returnStatus[i]);
+ finalStatus = ms;
+ } else
+ finalStatus = Status.OK_STATUS;
+
+ return finalStatus;
+ }
+
+
+ protected IDeployableServer getDeployableServer(IServer server) {
+ return (IDeployableServer)server.loadAdapter(IDeployableServer.class, new
NullProgressMonitor());
+ }
+ protected DeployableServerBehavior getBehaviour(IServer server) {
+ return (DeployableServerBehavior)server.loadAdapter(DeployableServerBehavior.class, new
NullProgressMonitor());
+ }
+
+ protected List<IModule[]> getRemovedModules(IServer s) {
+ return getBehaviour(s).getRemovedModules();
+ }
+
+ protected IStatus[] handleChildrenDeltas(IServer server, String deployRoot, IModule[]
module, IModule[] children) {
+ // For each child:
+ ArrayList<IStatus> results = new ArrayList<IStatus>();
+ for( int i = 0; i < children.length; i++ ) {
+ IModule[] combinedChild = combine(module, children[i]);
+ // if it's new, full publish it
+ if( !getBehaviour(server).hasBeenPublished(combinedChild)) {
+ results.addAll(Arrays.asList(fullPublish(server, deployRoot, combinedChild)));
+ }
+ // else if it's removed, full remove it
+ else if( isRemoved(server, combinedChild)) {
+ results.addAll(Arrays.asList(removeModule(server, deployRoot, combinedChild)));
+ }
+ // else
+ else {
+ // handle changed resources
+ results.addAll(Arrays.asList(publishChanges(server, deployRoot, combinedChild)));
+
+ // recurse
+ IModule[] children2 = server.getChildModules(combinedChild, new
NullProgressMonitor());
+ results.addAll(Arrays.asList(handleChildrenDeltas(server, deployRoot, children,
children2)));
+ }
+ }
+ return (IStatus[]) results.toArray(new IStatus[results.size()]);
+ }
+
+ protected boolean isRemoved(IServer server, IModule[] child) {
+ List<IModule[]> removed = getBehaviour(server).getRemovedModules();
+ Iterator<IModule[]> i = removed.iterator();
+ while(i.hasNext()) {
+ IModule[] next = i.next();
+ if( next.length == child.length) {
+ for( int j = 0; j < next.length; j++ ) {
+ if( !next[j].getId().equals(child[j].getId())) {
+ continue;
+ }
+ }
+ return true;
+ }
+ }
+ return false;
+ }
+
+ protected IStatus[] removeModule(IServer server, String deployRoot, IModule[] module) {
+ IPath deployPath = getOutputFilePath();
+ final ArrayList<IStatus> status = new ArrayList<IStatus>();
+ IFileUtilListener listener = new IFileUtilListener() {
+ public void fileCopied(File source, File dest, boolean result,Exception e) {}
+ public void fileDeleted(File file, boolean result, Exception e) {
+ if( result == false || e != null ) {
+ status.add(new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID,
IEventCodes.JST_PUB_FILE_DELETE_FAIL,
+ "Attempt to delete " + file.getAbsolutePath() + " failed",e));
//$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+ public void folderDeleted(File file, boolean result, Exception e) {
+ if( result == false || e != null ) {
+ status.add(new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID,
IEventCodes.JST_PUB_FILE_DELETE_FAIL,
+ "Attempt to delete " + file.getAbsolutePath() + " failed",e));
//$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+ };
+ FileUtil.safeDelete(deployPath.toFile(), listener);
+ return (IStatus[]) status.toArray(new IStatus[status.size()]);
+ }
+
+ protected IStatus[] fullPublish(IServer server, String deployRoot, IModule[] module) {
+ ArrayList<IStatus> results = new ArrayList<IStatus>();
+ try {
+ IPath path = getOutputFilePath();
+ // Get rid of the old
+ FileUtil.safeDelete(path.toFile(), null);
+
+ TrueZipUtil.createArchive(path);
+ de.schlichtherle.io.File root = TrueZipUtil.getFile(path,
TrueZipUtil.getJarArchiveDetector());
+ IModuleResource[] resources = getResources(module);
+ results.addAll(Arrays.asList(copy(root, resources)));
+
+ IModule[] children = server.getChildModules(module, new NullProgressMonitor());
+ for( int i = 0; i < children.length; i++ )
+ results.addAll(Arrays.asList(fullPublish(server, deployRoot, combine(module,
children[i]))));
+ return (IStatus[]) results.toArray(new IStatus[results.size()]);
+ } catch( CoreException ce) {
+ results.add(generateCoreExceptionStatus(ce));
+ return (IStatus[]) results.toArray(new IStatus[results.size()]);
+ }
+ }
+
+ protected IStatus[] publishChanges(IServer server, String deployRoot, IModule[] module)
{
+ IPath path = getOutputFilePath();
+ de.schlichtherle.io.File root = TrueZipUtil.getFile(path,
TrueZipUtil.getJarArchiveDetector());
+ IModuleResourceDelta[] deltas = ((Server)server).getPublishedResourceDelta(module);
+ return publishChanges(server, deltas, root);
+ }
+
+ protected IStatus[] publishChanges(IServer server, IModuleResourceDelta[] deltas,
de.schlichtherle.io.File root) {
+ ArrayList<IStatus> results = new ArrayList<IStatus>();
+ if( deltas == null || deltas.length == 0 )
+ return new IStatus[]{};
+ int dKind;
+ IModuleResource resource;
+ for( int i = 0; i < deltas.length; i++ ) {
+ dKind = deltas[i].getKind();
+ resource = deltas[i].getModuleResource();
+ if( dKind == IModuleResourceDelta.ADDED ) {
+ results.addAll(Arrays.asList(copy(root, new IModuleResource[]{resource})));
+ } else if( dKind == IModuleResourceDelta.CHANGED ) {
+ if( resource instanceof IModuleFile )
+ results.addAll(Arrays.asList(copy(root, new IModuleResource[]{resource})));
+ results.addAll(Arrays.asList(publishChanges(server, deltas[i].getAffectedChildren(),
root)));
+ } else if( dKind == IModuleResourceDelta.REMOVED) {
+ de.schlichtherle.io.File f = getFileInArchive(root,
+ resource.getModuleRelativePath().append(
+ resource.getName()));
+ boolean b = f.deleteAll();
+ if( !b )
+ results.add(generateDeleteFailedStatus(f));
+ } else if( dKind == IModuleResourceDelta.NO_CHANGE ) {
+ results.addAll(Arrays.asList(publishChanges(server, deltas[i].getAffectedChildren(),
root)));
+ }
+ }
+
+ return (IStatus[]) results.toArray(new IStatus[results.size()]);
+ }
+
+
+ protected IStatus[] copy(de.schlichtherle.io.File root, IModuleResource[] children) {
+ ArrayList<IStatus> results = new ArrayList<IStatus>();
+ for( int i = 0; i < children.length; i++ ) {
+ if( children[i] instanceof IModuleFile ) {
+ IModuleFile mf = (IModuleFile)children[i];
+ java.io.File source = getFile(mf);
+ de.schlichtherle.io.File destination = getFileInArchive(root,
mf.getModuleRelativePath().append(mf.getName()));
+ boolean b = new de.schlichtherle.io.File(source).copyAllTo(destination);
+ if( !b )
+ results.add(generateCopyFailStatus(source, destination));
+ } else if( children[i] instanceof IModuleFolder ) {
+ de.schlichtherle.io.File destination = getFileInArchive(root,
children[i].getModuleRelativePath().append(children[i].getName()));
+ destination.mkdirs();
+ IModuleFolder mf = (IModuleFolder)children[i];
+ results.addAll(Arrays.asList(copy(root, mf.members())));
+ }
+ }
+ return (IStatus[]) results.toArray(new IStatus[results.size()]);
+ }
+
+ protected IStatus generateDeleteFailedStatus(java.io.File file) {
+ return new Status(IStatus.ERROR, IntegrationPlugin.PLUGIN_ID, "Could not delete
file " + file); //$NON-NLS-1$
+ }
+ protected IStatus generateCoreExceptionStatus(CoreException ce) {
+ return new Status(IStatus.ERROR, IntegrationPlugin.PLUGIN_ID, ce.getMessage(), ce);
+ }
+ protected IStatus generateCopyFailStatus(java.io.File source, java.io.File destination)
{
+ return new Status(IStatus.ERROR, IntegrationPlugin.PLUGIN_ID, "Copy of " +
source + " to " + destination + " has
failed");//$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
+ }
+
+ protected de.schlichtherle.io.File getFileInArchive(de.schlichtherle.io.File root, IPath
relative) {
+ while(relative.segmentCount() > 0 ) {
+ root = new de.schlichtherle.io.File(root,
+ relative.segment(0), ArchiveDetector.DEFAULT);
+ relative = relative.removeFirstSegments(1);
+ }
+ return root;
+ }
+
+ private IModule[] combine(IModule[] module, IModule newMod) {
+ IModule[] retval = new IModule[module.length + 1];
+ for( int i = 0; i < module.length; i++ )
+ retval[i]=module[i];
+ retval[retval.length-1] = newMod;
+ return retval;
+ }
+
+ public IPath getOutputFilePath() {
+ return getDeployPath(module, deployRoot);
+ }
+}
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-10-19
17:21:45 UTC (rev 18170)
+++
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/PackagesPublisher.java 2009-10-19
21:52:18 UTC (rev 18171)
@@ -18,7 +18,6 @@
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.eclipse.osgi.util.NLS;
import org.eclipse.wst.server.core.IModule;
@@ -27,7 +26,6 @@
import org.eclipse.wst.server.core.model.IModuleFolder;
import org.eclipse.wst.server.core.model.IModuleResource;
import org.eclipse.wst.server.core.model.IModuleResourceDelta;
-import org.jboss.ide.eclipse.archives.core.build.ArchiveBuildDelegate;
import org.jboss.ide.eclipse.archives.core.model.IArchive;
import org.jboss.ide.eclipse.archives.core.util.PathUtils;
import org.jboss.ide.eclipse.archives.webtools.IntegrationPlugin;
@@ -35,8 +33,10 @@
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.LocalPublishMethod;
import org.jboss.ide.eclipse.as.core.publishers.PublishUtil;
import org.jboss.ide.eclipse.as.core.server.IDeployableServer;
+import org.jboss.ide.eclipse.as.core.server.IJBossServerPublishMethod;
import org.jboss.ide.eclipse.as.core.server.IJBossServerPublisher;
import org.jboss.ide.eclipse.as.core.util.FileUtil;
import org.jboss.ide.eclipse.as.core.util.ServerConverter;
@@ -59,12 +59,14 @@
}
public boolean accepts(String method, IServer server, IModule[] module) {
- if( "local".equals(method) && module != null && module.length
> 0 //$NON-NLS-1$
+ if( LocalPublishMethod.LOCAL_PUBLISH_METHOD.equals(method) && module != null
&& module.length > 0
&&
PackageModuleFactory.MODULE_TYPE.equals(module[0].getModuleType().getId()))
return true;
return false;
}
- public IStatus publishModule(IServer server, IModule[] module,
+ public IStatus publishModule(
+ IJBossServerPublishMethod method,
+ IServer server, IModule[] module,
int publishType, IModuleResourceDelta[] delta,
IProgressMonitor monitor)
throws CoreException {
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-10-19
17:21:45 UTC (rev 18170)
+++
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/WTPZippedPublisher.java 2009-10-19
21:52:18 UTC (rev 18171)
@@ -1,292 +1,52 @@
package org.jboss.ide.eclipse.archives.webtools.modules;
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.List;
-
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.MultiStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Status;
import org.eclipse.wst.common.componentcore.ModuleCoreNature;
import org.eclipse.wst.server.core.IModule;
import org.eclipse.wst.server.core.IServer;
-import org.eclipse.wst.server.core.internal.Server;
-import org.eclipse.wst.server.core.model.IModuleFile;
-import org.eclipse.wst.server.core.model.IModuleFolder;
-import org.eclipse.wst.server.core.model.IModuleResource;
import org.eclipse.wst.server.core.model.IModuleResourceDelta;
-import org.jboss.ide.eclipse.archives.core.util.internal.TrueZipUtil;
-import org.jboss.ide.eclipse.archives.webtools.IntegrationPlugin;
-import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
-import org.jboss.ide.eclipse.as.core.extensions.events.IEventCodes;
+import org.jboss.ide.eclipse.as.core.publishers.LocalPublishMethod;
import org.jboss.ide.eclipse.as.core.publishers.PublishUtil;
import org.jboss.ide.eclipse.as.core.server.IDeployableServer;
+import org.jboss.ide.eclipse.as.core.server.IJBossServerPublishMethod;
import org.jboss.ide.eclipse.as.core.server.IJBossServerPublisher;
-import org.jboss.ide.eclipse.as.core.server.internal.DeployableServerBehavior;
-import org.jboss.ide.eclipse.as.core.util.FileUtil;
+import org.jboss.ide.eclipse.as.core.util.IJBossToolingConstants;
import org.jboss.ide.eclipse.as.core.util.ServerConverter;
-import org.jboss.ide.eclipse.as.core.util.FileUtil.IFileUtilListener;
-import de.schlichtherle.io.ArchiveDetector;
-
public class WTPZippedPublisher extends PublishUtil implements IJBossServerPublisher {
private int moduleState = IServer.PUBLISH_STATE_NONE;
public boolean accepts(String method, IServer server, IModule[] module) {
- // TODO check for zip preference
- return "local".equals(method) && //$NON-NLS-1$
- ModuleCoreNature.isFlexibleProject(module[0].getProject());
+ IDeployableServer ds = ServerConverter.getDeployableServer(server);
+ IModule lastMod = (module == null || module.length == 0 ) ? null : module[module.length
-1];
+ if( LocalPublishMethod.LOCAL_PUBLISH_METHOD.equals(method) && lastMod == null)
+ return true;
+ return LocalPublishMethod.LOCAL_PUBLISH_METHOD.equals(method)
+ && ModuleCoreNature.isFlexibleProject(lastMod.getProject())
+ && ds != null && ds.zipsWTPDeployments();
}
public int getPublishState() {
return moduleState;
}
-
- protected IDeployableServer getDeployableServer(IServer server) {
- return (IDeployableServer)server.loadAdapter(IDeployableServer.class, new
NullProgressMonitor());
- }
- protected DeployableServerBehavior getBehaviour(IServer server) {
- return (DeployableServerBehavior)server.loadAdapter(DeployableServerBehavior.class, new
NullProgressMonitor());
- }
- protected List<IModule[]> getRemovedModules(IServer s) {
- return getBehaviour(s).getRemovedModules();
- }
-
- public boolean isNew(IModule[] module, IServer s) {
- return !getBehaviour(s).hasBeenPublished(module);
- }
-
-
- public IStatus publishModule(IServer server, IModule[] module,
+ public IStatus publishModule(
+ IJBossServerPublishMethod method,
+ IServer server, IModule[] module,
int publishType, IModuleResourceDelta[] delta,
IProgressMonitor monitor) throws CoreException {
if( module.length > 1 ) {
return Status.OK_STATUS;
}
- IStatus[] returnStatus;
- // Am I a removal? If yes, remove me, and return
- if( publishType == IJBossServerPublisher.REMOVE_PUBLISH)
- returnStatus = removeModule(server, module);
-
- // Am I a full publish? If yes, full publish me, and return
- else if( publishType == IJBossServerPublisher.FULL_PUBLISH)
- returnStatus = fullPublish(server, module);
-
- else {
- // Am I changed? If yes, handle my changes
- ArrayList<IStatus> results = new ArrayList<IStatus>();
- if( countChanges(delta) > 0) {
- results.addAll(Arrays.asList(publishChanges(server, module)));
- }
-
- IModule[] children = server.getChildModules(module, new NullProgressMonitor());
- results.addAll(Arrays.asList(handleChildrenDeltas(server, module, children)));
-
- // Handle the removed children that are not returned by getChildModules
- List<IModule[]> removed = getBehaviour(server).getRemovedModules();
- Iterator<IModule[]> i = removed.iterator();
- while(i.hasNext()) {
- IModule[] removedArray = i.next();
- if( removedArray[0].getId().equals(module[0].getId())) {
- results.addAll(Arrays.asList(removeModule(server, removedArray)));
- }
- }
- returnStatus = (IStatus[]) results.toArray(new IStatus[results.size()]);
- }
- TrueZipUtil.umount();
-
- IStatus finalStatus;
- if( returnStatus.length > 0 ) {
- MultiStatus ms = new MultiStatus(JBossServerCorePlugin.PLUGIN_ID,
IEventCodes.JST_PUB_INC_FAIL,
- "Publish Failed for module " + module[0].getName(), null); //$NON-NLS-1$
- for( int i = 0; i < returnStatus.length; i++ )
- ms.add(returnStatus[i]);
- finalStatus = ms;
- } else
- finalStatus = Status.OK_STATUS;
-
- return finalStatus;
- }
-
- protected IStatus[] handleChildrenDeltas(IServer server, IModule[] module, IModule[]
children) {
- // For each child:
- ArrayList<IStatus> results = new ArrayList<IStatus>();
- for( int i = 0; i < children.length; i++ ) {
- IModule[] combinedChild = combine(module, children[i]);
- // if it's new, full publish it
- if( !getBehaviour(server).hasBeenPublished(combinedChild)) {
- results.addAll(Arrays.asList(fullPublish(server, combinedChild)));
- }
- // else if it's removed, full remove it
- else if( isRemoved(server, combinedChild)) {
- results.addAll(Arrays.asList(removeModule(server, combinedChild)));
- }
- // else
- else {
- // handle changed resources
- results.addAll(Arrays.asList(publishChanges(server, combinedChild)));
-
- // recurse
- IModule[] children2 = server.getChildModules(combinedChild, new
NullProgressMonitor());
- results.addAll(Arrays.asList(handleChildrenDeltas(server, children, children2)));
- }
- }
- return (IStatus[]) results.toArray(new IStatus[results.size()]);
- }
-
- protected boolean isRemoved(IServer server, IModule[] child) {
- List<IModule[]> removed = getBehaviour(server).getRemovedModules();
- Iterator<IModule[]> i = removed.iterator();
- while(i.hasNext()) {
- IModule[] next = i.next();
- if( next.length == child.length) {
- for( int j = 0; j < next.length; j++ ) {
- if( !next[j].getId().equals(child[j].getId())) {
- continue;
- }
- }
- return true;
- }
- }
- return false;
- }
-
- protected IStatus[] removeModule(IServer server, IModule[] module) {
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) {}
- public void fileDeleted(File file, boolean result, Exception e) {
- if( result == false || e != null ) {
- status.add(new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID,
IEventCodes.JST_PUB_FILE_DELETE_FAIL,
- "Attempt to delete " + file.getAbsolutePath() + " failed",e));
//$NON-NLS-1$ //$NON-NLS-2$
- }
- }
- public void folderDeleted(File file, boolean result, Exception e) {
- if( result == false || e != null ) {
- status.add(new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID,
IEventCodes.JST_PUB_FILE_DELETE_FAIL,
- "Attempt to delete " + file.getAbsolutePath() + " failed",e));
//$NON-NLS-1$ //$NON-NLS-2$
- }
- }
- };
- FileUtil.safeDelete(deployPath.toFile(), listener);
- return (IStatus[]) status.toArray(new IStatus[status.size()]);
- }
-
- protected IStatus[] fullPublish(IServer server, IModule[] module) {
- ArrayList<IStatus> results = new ArrayList<IStatus>();
- IDeployableServer ds = ServerConverter.getDeployableServer(server);
- try {
- IPath path = getDeployPath(module, ds);
- // Get rid of the old
- FileUtil.safeDelete(path.toFile(), null);
-
- TrueZipUtil.createArchive(path);
- de.schlichtherle.io.File root = TrueZipUtil.getFile(path,
TrueZipUtil.getJarArchiveDetector());
- IModuleResource[] resources = getResources(module);
- results.addAll(Arrays.asList(copy(root, resources)));
-
- IModule[] children = server.getChildModules(module, new NullProgressMonitor());
- for( int i = 0; i < children.length; i++ )
- results.addAll(Arrays.asList(fullPublish(server, combine(module, children[i]))));
- return (IStatus[]) results.toArray(new IStatus[results.size()]);
- } catch( CoreException ce) {
- results.add(generateCoreExceptionStatus(ce));
- return (IStatus[]) results.toArray(new IStatus[results.size()]);
- }
- }
-
- protected IStatus[] publishChanges(IServer server, IModule[] module) {
- 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);
- }
-
- protected IStatus[] publishChanges(IServer server, IModuleResourceDelta[] deltas,
de.schlichtherle.io.File root) {
- ArrayList<IStatus> results = new ArrayList<IStatus>();
- if( deltas == null || deltas.length == 0 )
- return new IStatus[]{};
- int dKind;
- IModuleResource resource;
- for( int i = 0; i < deltas.length; i++ ) {
- dKind = deltas[i].getKind();
- resource = deltas[i].getModuleResource();
- if( dKind == IModuleResourceDelta.ADDED ) {
- results.addAll(Arrays.asList(copy(root, new IModuleResource[]{resource})));
- } else if( dKind == IModuleResourceDelta.CHANGED ) {
- if( resource instanceof IModuleFile )
- results.addAll(Arrays.asList(copy(root, new IModuleResource[]{resource})));
- results.addAll(Arrays.asList(publishChanges(server, deltas[i].getAffectedChildren(),
root)));
- } else if( dKind == IModuleResourceDelta.REMOVED) {
- de.schlichtherle.io.File f = getFileInArchive(root,
- resource.getModuleRelativePath().append(
- resource.getName()));
- boolean b = f.deleteAll();
- if( !b )
- results.add(generateDeleteFailedStatus(f));
- } else if( dKind == IModuleResourceDelta.NO_CHANGE ) {
- results.addAll(Arrays.asList(publishChanges(server, deltas[i].getAffectedChildren(),
root)));
- }
- }
+ String deployRoot = PublishUtil.getDeployRootFolder(
+ module, ds, ds.getDeployFolder(),
+ IJBossToolingConstants.LOCAL_DEPLOYMENT_LOC);
- return (IStatus[]) results.toArray(new IStatus[results.size()]);
+ LocalZippedPublisherUtil util = new LocalZippedPublisherUtil();
+ return util.publishModule(server, deployRoot, module, publishType, delta, monitor);
}
-
-
- protected IStatus[] copy(de.schlichtherle.io.File root, IModuleResource[] children) {
- ArrayList<IStatus> results = new ArrayList<IStatus>();
- for( int i = 0; i < children.length; i++ ) {
- if( children[i] instanceof IModuleFile ) {
- IModuleFile mf = (IModuleFile)children[i];
- java.io.File source = getFile(mf);
- de.schlichtherle.io.File destination = getFileInArchive(root,
mf.getModuleRelativePath().append(mf.getName()));
- boolean b = new de.schlichtherle.io.File(source).copyAllTo(destination);
- if( !b )
- results.add(generateCopyFailStatus(source, destination));
- } else if( children[i] instanceof IModuleFolder ) {
- de.schlichtherle.io.File destination = getFileInArchive(root,
children[i].getModuleRelativePath().append(children[i].getName()));
- destination.mkdirs();
- IModuleFolder mf = (IModuleFolder)children[i];
- results.addAll(Arrays.asList(copy(root, mf.members())));
- }
- }
- return (IStatus[]) results.toArray(new IStatus[results.size()]);
- }
-
- protected IStatus generateDeleteFailedStatus(java.io.File file) {
- return new Status(IStatus.ERROR, IntegrationPlugin.PLUGIN_ID, "Could not delete
file " + file); //$NON-NLS-1$
- }
- protected IStatus generateCoreExceptionStatus(CoreException ce) {
- return new Status(IStatus.ERROR, IntegrationPlugin.PLUGIN_ID, ce.getMessage(), ce);
- }
- protected IStatus generateCopyFailStatus(java.io.File source, java.io.File destination)
{
- return new Status(IStatus.ERROR, IntegrationPlugin.PLUGIN_ID, "Copy of " +
source + " to " + destination + " has
failed");//$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
- }
-
- protected de.schlichtherle.io.File getFileInArchive(de.schlichtherle.io.File root, IPath
relative) {
- while(relative.segmentCount() > 0 ) {
- root = new de.schlichtherle.io.File(root,
- relative.segment(0), ArchiveDetector.DEFAULT);
- relative = relative.removeFirstSegments(1);
- }
- return root;
- }
-
- private IModule[] combine(IModule[] module, IModule newMod) {
- IModule[] retval = new IModule[module.length + 1];
- for( int i = 0; i < module.length; i++ )
- retval[i]=module[i];
- retval[retval.length-1] = newMod;
- return retval;
- }
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/ExtensionManager.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/ExtensionManager.java 2009-10-19
17:21:45 UTC (rev 18170)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/ExtensionManager.java 2009-10-19
21:52:18 UTC (rev 18171)
@@ -153,17 +153,18 @@
return null;
}
- public IJBossServerPublisher getZippedPublisher() {
+ public IJBossServerPublisher[] getZippedPublishers() {
if( publishers == null )
loadPublishers();
+ ArrayList<IJBossServerPublisher> list = new
ArrayList<IJBossServerPublisher>();
Iterator<PublisherWrapper> i = publishers.iterator();
PublisherWrapper wrapper;
while(i.hasNext()) {
wrapper = i.next();
if( wrapper.isZipDelegate )
- return wrapper.getNewInstance();
+ list.add( wrapper.getNewInstance() );
}
- return null;
+ return list.toArray(new IJBossServerPublisher[list.size()]);
}
private void loadPublishers() {
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-10-19
17:21:45 UTC (rev 18170)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/JstPublisher.java 2009-10-19
21:52:18 UTC (rev 18171)
@@ -33,11 +33,11 @@
import org.eclipse.wst.server.core.model.IModuleResource;
import org.eclipse.wst.server.core.model.IModuleResourceDelta;
import org.eclipse.wst.server.core.util.ProjectModule;
-import org.jboss.ide.eclipse.as.core.ExtensionManager;
import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
import org.jboss.ide.eclipse.as.core.Messages;
import org.jboss.ide.eclipse.as.core.extensions.events.IEventCodes;
import org.jboss.ide.eclipse.as.core.server.IDeployableServer;
+import org.jboss.ide.eclipse.as.core.server.IJBossServerPublishMethod;
import org.jboss.ide.eclipse.as.core.server.IJBossServerPublisher;
import org.jboss.ide.eclipse.as.core.server.xpl.ModulePackager;
import org.jboss.ide.eclipse.as.core.server.xpl.PublishCopyUtil;
@@ -65,26 +65,23 @@
public JstPublisher() {
}
- private boolean serverRequiresZips() {
- return server.zipsWTPDeployments();
+ public boolean accepts(String type, IServer server, IModule[] module) {
+ IDeployableServer ds = ServerConverter.getDeployableServer(server);
+ boolean shouldAccept = ds != null &&
LocalPublishMethod.LOCAL_PUBLISH_METHOD.equals(type)
+ && ModuleCoreNature.isFlexibleProject(module[0].getProject())
+ && ds.zipsWTPDeployments();
+ return shouldAccept;
}
- public IStatus publishModule(IServer server, IModule[] module,
- int publishType, IModuleResourceDelta[] delta, IProgressMonitor monitor) throws
CoreException {
+ public IStatus publishModule(
+ IJBossServerPublishMethod method,
+ IServer server, IModule[] module,
+ int publishType, IModuleResourceDelta[] delta,
+ IProgressMonitor monitor) throws CoreException {
IStatus status = null;
this.server = ServerConverter.getDeployableServer(server);
this.delta = delta;
- if( serverRequiresZips() ) {
- IJBossServerPublisher delegate =
- ExtensionManager.getDefault().getZippedPublisher();
- if( delegate != null ) {
- return delegate.publishModule(server, module, publishType, delta, monitor);
- } else {
- // TODO log, use unzipped instead
- }
- }
-
boolean deleted = false;
for( int i = 0; i < module.length; i++ ) {
if( module[i].isExternal() )
@@ -319,8 +316,4 @@
}
}
}
- public boolean accepts(String type, IServer server, IModule[] module) {
- return "local".equals(type) && //$NON-NLS-1$
- ModuleCoreNature.isFlexibleProject(module[0].getProject());
- }
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/LocalPublishMethod.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/LocalPublishMethod.java 2009-10-19
17:21:45 UTC (rev 18170)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/LocalPublishMethod.java 2009-10-19
21:52:18 UTC (rev 18171)
@@ -14,9 +14,14 @@
import org.jboss.ide.eclipse.as.core.server.internal.DeployableServerBehavior;
public class LocalPublishMethod implements IJBossServerPublishMethod {
-
+ public static final String LOCAL_PUBLISH_METHOD = "local"; //$NON-NLS-1$
+
+ public String getPublishMethodId() {
+ return LOCAL_PUBLISH_METHOD;
+ }
+
public boolean accepts(String methodType) {
- return "local".equals(methodType); //$NON-NLS-1$
+ return getPublishMethodId().equals(methodType);
}
public void publishStart(DeployableServerBehavior behaviour,
@@ -58,12 +63,14 @@
// Let the publisher decide what to do
if( module.length > 0 ) {
- publisher = ExtensionManager.getDefault().getPublisher(behaviour.getServer(), module,
"local"); //$NON-NLS-1$
+ publisher = ExtensionManager.getDefault().getPublisher(behaviour.getServer(), module,
getPublishMethodId());
IModuleResourceDelta[] deltas = new IModuleResourceDelta[]{};
if( deltaKind != ServerBehaviourDelegate.REMOVED)
deltas = behaviour.getPublishedResourceDelta(module);
if( publisher != null ) {
- IStatus result = publisher.publishModule(behaviour.getServer(), module,
+ IStatus result = publisher.publishModule(
+ this,
+ behaviour.getServer(), module,
publishType, deltas, monitor);
if( result != null )
ServerLogger.getDefault().log(behaviour.getServer(), result);
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/NullPublisher.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/NullPublisher.java 2009-10-19
17:21:45 UTC (rev 18170)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/NullPublisher.java 2009-10-19
21:52:18 UTC (rev 18171)
@@ -21,6 +21,7 @@
import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
import org.jboss.ide.eclipse.as.core.Messages;
import org.jboss.ide.eclipse.as.core.extensions.events.IEventCodes;
+import org.jboss.ide.eclipse.as.core.server.IJBossServerPublishMethod;
import org.jboss.ide.eclipse.as.core.server.IJBossServerPublisher;
/**
@@ -36,8 +37,11 @@
return true;
}
- public IStatus publishModule(IServer server, IModule[] module,
- int publishType, IModuleResourceDelta[] delta, IProgressMonitor monitor) throws
CoreException {
+ public IStatus publishModule(
+ IJBossServerPublishMethod method,
+ IServer server, IModule[] module,
+ int publishType, IModuleResourceDelta[] delta,
+ IProgressMonitor monitor) throws CoreException {
return new Status(IStatus.WARNING, JBossServerCorePlugin.PLUGIN_ID,
IEventCodes.NO_PUBLISHER_ROOT_CODE,
NLS.bind(Messages.NoPublisherFound, module[module.length-1]), null);
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-10-19
17:21:45 UTC (rev 18170)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/PublishUtil.java 2009-10-19
21:52:18 UTC (rev 18171)
@@ -65,7 +65,7 @@
return count;
}
- private static String getDeployRootFolder(IModule[] moduleTree,
+ public static String getDeployRootFolder(IModule[] moduleTree,
IDeployableServer server, String defaultFolder, String moduleProperty) {
String folder = defaultFolder;
// TODO bug 286699
@@ -110,7 +110,7 @@
return new Path(folder);
}
- private static IPath getDeployPath(IModule[] moduleTree, String deployFolder) {
+ public 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-10-19
17:21:45 UTC (rev 18170)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/SingleFilePublisher.java 2009-10-19
21:52:18 UTC (rev 18171)
@@ -18,7 +18,6 @@
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.osgi.util.NLS;
import org.eclipse.wst.server.core.IModule;
@@ -30,6 +29,7 @@
import org.jboss.ide.eclipse.as.core.modules.SingleDeployableFactory;
import
org.jboss.ide.eclipse.as.core.modules.SingleDeployableFactory.SingleDeployableModuleDelegate;
import org.jboss.ide.eclipse.as.core.server.IDeployableServer;
+import org.jboss.ide.eclipse.as.core.server.IJBossServerPublishMethod;
import org.jboss.ide.eclipse.as.core.server.IJBossServerPublisher;
import org.jboss.ide.eclipse.as.core.util.FileUtil;
import org.jboss.ide.eclipse.as.core.util.ServerConverter;
@@ -47,15 +47,19 @@
}
public boolean accepts(String method, IServer server, IModule[] module) {
- if( "local".equals(method) && module != null && module.length
> 0 //$NON-NLS-1$
+ if( LocalPublishMethod.LOCAL_PUBLISH_METHOD.equals(method)
+ && module != null && module.length > 0
&& module[module.length-1] != null
&&
module[module.length-1].getModuleType().getId().equals(SingleDeployableFactory.MODULE_TYPE))
return true;
return false;
}
- public IStatus publishModule(IServer server, IModule[] module,
- int publishType, IModuleResourceDelta[] delta, IProgressMonitor monitor) throws
CoreException {
+ public IStatus publishModule(
+ IJBossServerPublishMethod method,
+ IServer server, IModule[] module,
+ int publishType, IModuleResourceDelta[] delta,
+ IProgressMonitor monitor) throws CoreException {
this.server = ServerConverter.getDeployableServer(server);
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IJBossServerPublishMethod.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IJBossServerPublishMethod.java 2009-10-19
17:21:45 UTC (rev 18170)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IJBossServerPublishMethod.java 2009-10-19
21:52:18 UTC (rev 18171)
@@ -6,6 +6,7 @@
import org.jboss.ide.eclipse.as.core.server.internal.DeployableServerBehavior;
public interface IJBossServerPublishMethod {
+ public String getPublishMethodId();
public boolean accepts(String methodType);
public void publishStart(DeployableServerBehavior behaviour, IProgressMonitor monitor)
throws CoreException;
public int publishFinish(DeployableServerBehavior behaviour, IProgressMonitor monitor)
throws CoreException;
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IJBossServerPublisher.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IJBossServerPublisher.java 2009-10-19
17:21:45 UTC (rev 18170)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IJBossServerPublisher.java 2009-10-19
21:52:18 UTC (rev 18171)
@@ -33,6 +33,9 @@
public boolean accepts(String method, IServer server, IModule[] module);
// post publish
public int getPublishState();
- public IStatus publishModule(IServer server, IModule[] module,
- int publishType, IModuleResourceDelta[] delta, IProgressMonitor monitor) throws
CoreException;
+ public IStatus publishModule(
+ IJBossServerPublishMethod method,
+ IServer server, IModule[] module,
+ int publishType, IModuleResourceDelta[] delta,
+ IProgressMonitor monitor) throws CoreException;
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/DeployableServerBehavior.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/DeployableServerBehavior.java 2009-10-19
17:21:45 UTC (rev 18170)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/DeployableServerBehavior.java 2009-10-19
21:52:18 UTC (rev 18171)
@@ -14,6 +14,8 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.wst.server.core.IModule;
import org.eclipse.wst.server.core.IServer;
@@ -21,6 +23,7 @@
import org.eclipse.wst.server.core.ServerEvent;
import org.eclipse.wst.server.core.model.IModuleResourceDelta;
import org.eclipse.wst.server.core.model.ServerBehaviourDelegate;
+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.IJBossServerPublisher;
@@ -39,24 +42,31 @@
workingCopy.setAttribute(DeployableLaunchConfiguration.ACTION_KEY,
DeployableLaunchConfiguration.START);
}
+
+ protected IJBossServerPublishMethod method;
protected void publishStart(IProgressMonitor monitor) throws CoreException {
- IJBossServerPublishMethod method = getPublishMethod();
+ if( method != null )
+ throw new CoreException(new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID,
"Already publishing")); //$NON-NLS-1$
+ method = createPublishMethod();
method.publishStart(this, monitor);
}
protected void publishFinish(IProgressMonitor monitor) throws CoreException {
- IJBossServerPublishMethod method = getPublishMethod();
+ if( method == null )
+ throw new CoreException(new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID,
"Not publishing")); //$NON-NLS-1$
int result = method.publishFinish(this, monitor);
setServerPublishState(result);
+ method = null;
}
protected void publishModule(int kind, int deltaKind, IModule[] module, IProgressMonitor
monitor) throws CoreException {
- IJBossServerPublishMethod method = getPublishMethod();
+ if( method == null )
+ throw new CoreException(new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID,
"Not publishing")); //$NON-NLS-1$
int result = method.publishModule(this, kind, deltaKind, module, monitor);
setModulePublishState(module, result);
}
- protected IJBossServerPublishMethod getPublishMethod() {
+ protected IJBossServerPublishMethod createPublishMethod() {
return new LocalPublishMethod(); // TODO FIX THIS
}
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-10-19
17:21:45 UTC (rev 18170)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/xpl/PublishCopyUtil.java 2009-10-19
21:52:18 UTC (rev 18171)
@@ -156,7 +156,7 @@
* reporting and cancellation are not desired
* @return a possibly-empty array of error and warning status
*/
- public IStatus[] deleteDirectory(File dir, IProgressMonitor monitor) {
+ private IStatus[] deleteDirectory(File dir, IProgressMonitor monitor) {
if (!dir.exists() || !dir.isDirectory())
return new IStatus[] { new Status(IStatus.ERROR, ServerPlugin.PLUGIN_ID, 0,
NLS.bind(Messages.errorNotADirectory, dir.getAbsolutePath()), null) };
@@ -203,17 +203,7 @@
/**
* 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.
+ * Not yet used
*
* @param resources an array of module resources
* @param path an external path to copy to
@@ -221,149 +211,149 @@
* reporting and cancellation are not desired
* @return a possibly-empty array of error and warning status
*/
- private IStatus[] publishSmart(IModuleResource[] resources, IPath path, IProgressMonitor
monitor) {
- if (resources == null)
- return EMPTY_STATUS;
-
- monitor = ProgressUtil.getMonitorFor(monitor);
-
- List status = new ArrayList(2);
- File toDir = path.toFile();
- int fromSize = resources.length;
- String[] fromFileNames = new String[fromSize];
- for (int i = 0; i < fromSize; i++)
- fromFileNames[i] = resources[i].getName();
-
- // cache files and file names for performance
- File[] toFiles = null;
- String[] toFileNames = null;
-
- boolean foundExistingDir = false;
- if (toDir.exists()) {
- if (toDir.isDirectory()) {
- foundExistingDir = true;
- toFiles = toDir.listFiles();
- int toSize = toFiles.length;
- toFileNames = new String[toSize];
-
- // check if this exact file exists in the new directory
- for (int i = 0; i < toSize; i++) {
- toFileNames[i] = toFiles[i].getName();
- boolean isDir = toFiles[i].isDirectory();
- boolean found = false;
- for (int j = 0; j < fromSize; j++) {
- if (toFileNames[i].equals(fromFileNames[j]) && isDir == resources[j]
instanceof IModuleFolder)
- found = true;
- }
-
- // delete file if it can't be found or isn't the correct type
- if (!found) {
- if (isDir) {
- IStatus[] stat = deleteDirectory(toFiles[i], null);
- addArrayToList(status, stat);
- } else {
- if (!toFiles[i].delete())
- status.add(new Status(IStatus.ERROR, ServerPlugin.PLUGIN_ID, 0,
NLS.bind(Messages.errorDeleting, toFiles[i].getAbsolutePath()), null));
- }
- toFiles[i] = null;
- toFileNames[i] = null;
- }
- }
- } else { //if (toDir.isFile())
- if (!toDir.delete()) {
- status.add(new Status(IStatus.ERROR, ServerPlugin.PLUGIN_ID, 0,
NLS.bind(Messages.errorDeleting, toDir.getAbsolutePath()), null));
- IStatus[] stat = new IStatus[status.size()];
- status.toArray(stat);
- return stat;
- }
- }
- }
- if (!foundExistingDir && !toDir.mkdirs()) {
- status.add(new Status(IStatus.ERROR, ServerPlugin.PLUGIN_ID, 0,
NLS.bind(Messages.errorMkdir, toDir.getAbsolutePath()), null));
- IStatus[] stat = new IStatus[status.size()];
- status.toArray(stat);
- return stat;
- }
-
- if (monitor.isCanceled())
- return new IStatus[] { Status.CANCEL_STATUS };
-
- monitor.worked(50);
-
- // cycle through files and only copy when it doesn't exist
- // or is newer
- if (toFiles == null)
- toFiles = toDir.listFiles();
- int toSize = 0;
- if (toFiles != null)
- toSize = toFiles.length;
-
- int dw = 0;
- if (toSize > 0)
- dw = 500 / toSize;
-
- // cache file names and last modified dates for performance
- if (toFileNames == null)
- toFileNames = new String[toSize];
- long[] toFileMod = new long[toSize];
- for (int i = 0; i < toSize; i++) {
- if (toFiles[i] != null) {
- if (toFileNames[i] != null)
- toFileNames[i] = toFiles[i].getName();
- toFileMod[i] = toFiles[i].lastModified();
- }
- }
-
- for (int i = 0; i < fromSize; i++) {
- IModuleResource current = resources[i];
- String name = fromFileNames[i];
- boolean currentIsDir = current instanceof IModuleFolder;
-
- if (!currentIsDir) {
- // check if this is a new or newer file
- boolean copy = true;
- IModuleFile mf = (IModuleFile) current;
-
- long mod = -1;
- IFile file = (IFile) mf.getAdapter(IFile.class);
- if (file != null) {
- mod = file.getLocalTimeStamp();
- } else {
- File file2 = (File) mf.getAdapter(File.class);
- mod = file2.lastModified();
- }
-
- for (int j = 0; j < toSize; j++) {
- if (name.equals(toFileNames[j]) && mod == toFileMod[j])
- copy = false;
- }
-
- if (copy) {
- try {
- copyFile(mf, path.append(name));
- } catch (CoreException ce) {
- status.add(ce.getStatus());
- }
- }
- monitor.worked(dw);
- } else { //if (currentIsDir) {
- IModuleFolder folder = (IModuleFolder) current;
- IModuleResource[] children = folder.members();
- monitor.subTask(NLS.bind(Messages.copyingTask, new String[] {name, name}));
- IStatus[] stat = publishSmart(children, path.append(name),
ProgressUtil.getSubMonitorFor(monitor, dw));
- addArrayToList(status, stat);
- }
- }
- if (monitor.isCanceled())
- return new IStatus[] { Status.CANCEL_STATUS };
-
- monitor.worked(500 - dw * toSize);
- monitor.done();
-
- IStatus[] stat = new IStatus[status.size()];
- status.toArray(stat);
- return stat;
- }
+// private IStatus[] publishSmart(IModuleResource[] resources, IPath path,
IProgressMonitor monitor) {
+// if (resources == null)
+// return EMPTY_STATUS;
+//
+// monitor = ProgressUtil.getMonitorFor(monitor);
+//
+// List status = new ArrayList(2);
+// File toDir = path.toFile();
+// int fromSize = resources.length;
+// String[] fromFileNames = new String[fromSize];
+// for (int i = 0; i < fromSize; i++)
+// fromFileNames[i] = resources[i].getName();
+//
+// // cache files and file names for performance
+// File[] toFiles = null;
+// String[] toFileNames = null;
+//
+// boolean foundExistingDir = false;
+// if (toDir.exists()) {
+// if (toDir.isDirectory()) {
+// foundExistingDir = true;
+// toFiles = toDir.listFiles();
+// int toSize = toFiles.length;
+// toFileNames = new String[toSize];
+//
+// // check if this exact file exists in the new directory
+// for (int i = 0; i < toSize; i++) {
+// toFileNames[i] = toFiles[i].getName();
+// boolean isDir = toFiles[i].isDirectory();
+// boolean found = false;
+// for (int j = 0; j < fromSize; j++) {
+// if (toFileNames[i].equals(fromFileNames[j]) && isDir == resources[j]
instanceof IModuleFolder)
+// found = true;
+// }
+//
+// // delete file if it can't be found or isn't the correct type
+// if (!found) {
+// if (isDir) {
+// IStatus[] stat = deleteDirectory(toFiles[i], null);
+// addArrayToList(status, stat);
+// } else {
+// if (!toFiles[i].delete())
+// status.add(new Status(IStatus.ERROR, ServerPlugin.PLUGIN_ID, 0,
NLS.bind(Messages.errorDeleting, toFiles[i].getAbsolutePath()), null));
+// }
+// toFiles[i] = null;
+// toFileNames[i] = null;
+// }
+// }
+// } else { //if (toDir.isFile())
+// if (!toDir.delete()) {
+// status.add(new Status(IStatus.ERROR, ServerPlugin.PLUGIN_ID, 0,
NLS.bind(Messages.errorDeleting, toDir.getAbsolutePath()), null));
+// IStatus[] stat = new IStatus[status.size()];
+// status.toArray(stat);
+// return stat;
+// }
+// }
+// }
+// if (!foundExistingDir && !toDir.mkdirs()) {
+// status.add(new Status(IStatus.ERROR, ServerPlugin.PLUGIN_ID, 0,
NLS.bind(Messages.errorMkdir, toDir.getAbsolutePath()), null));
+// IStatus[] stat = new IStatus[status.size()];
+// status.toArray(stat);
+// return stat;
+// }
+//
+// if (monitor.isCanceled())
+// return new IStatus[] { Status.CANCEL_STATUS };
+//
+// monitor.worked(50);
+//
+// // cycle through files and only copy when it doesn't exist
+// // or is newer
+// if (toFiles == null)
+// toFiles = toDir.listFiles();
+// int toSize = 0;
+// if (toFiles != null)
+// toSize = toFiles.length;
+//
+// int dw = 0;
+// if (toSize > 0)
+// dw = 500 / toSize;
+//
+// // cache file names and last modified dates for performance
+// if (toFileNames == null)
+// toFileNames = new String[toSize];
+// long[] toFileMod = new long[toSize];
+// for (int i = 0; i < toSize; i++) {
+// if (toFiles[i] != null) {
+// if (toFileNames[i] != null)
+// toFileNames[i] = toFiles[i].getName();
+// toFileMod[i] = toFiles[i].lastModified();
+// }
+// }
+//
+// for (int i = 0; i < fromSize; i++) {
+// IModuleResource current = resources[i];
+// String name = fromFileNames[i];
+// boolean currentIsDir = current instanceof IModuleFolder;
+//
+// if (!currentIsDir) {
+// // check if this is a new or newer file
+// boolean copy = true;
+// IModuleFile mf = (IModuleFile) current;
+//
+// long mod = -1;
+// IFile file = (IFile) mf.getAdapter(IFile.class);
+// if (file != null) {
+// mod = file.getLocalTimeStamp();
+// } else {
+// File file2 = (File) mf.getAdapter(File.class);
+// mod = file2.lastModified();
+// }
+//
+// for (int j = 0; j < toSize; j++) {
+// if (name.equals(toFileNames[j]) && mod == toFileMod[j])
+// copy = false;
+// }
+//
+// if (copy) {
+// try {
+// copyFile(mf, path.append(name));
+// } catch (CoreException ce) {
+// status.add(ce.getStatus());
+// }
+// }
+// monitor.worked(dw);
+// } else { //if (currentIsDir) {
+// IModuleFolder folder = (IModuleFolder) current;
+// IModuleResource[] children = folder.members();
+// monitor.subTask(NLS.bind(Messages.copyingTask, new String[] {name, name}));
+// IStatus[] stat = publishSmart(children, path.append(name),
ProgressUtil.getSubMonitorFor(monitor, dw));
+// addArrayToList(status, stat);
+// }
+// }
+// if (monitor.isCanceled())
+// return new IStatus[] { Status.CANCEL_STATUS };
+//
+// monitor.worked(500 - dw * toSize);
+// monitor.done();
+//
+// IStatus[] stat = new IStatus[status.size()];
+// status.toArray(stat);
+// return stat;
+// }
/**
* Handle a delta publish.
@@ -539,118 +529,6 @@
}
/**
- * Creates a new zip file containing the given module resources. Deletes the existing
file
- * (and doesn't create a new one) if resources is null or empty.
- *
- * @param resources an array of module resources
- * @param path the path where the zip file should be created
- * @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[] publishZip(IModuleResource[] resources, IPath path, IProgressMonitor
monitor) {
- if (resources == null || resources.length == 0) {
- // should also check if resources consists of all empty directories
- File file = path.toFile();
- if (file.exists())
- file.delete();
- return EMPTY_STATUS;
- }
-
- monitor = ProgressUtil.getMonitorFor(monitor);
-
- File tempFile = null;
- try {
- File file = path.toFile();
- tempFile = File.createTempFile(TEMPFILE_PREFIX, "." +
path.getFileExtension(), getTempFolder()); //$NON-NLS-1$
- BufferedOutputStream bout = new BufferedOutputStream(new FileOutputStream(tempFile));
- ZipOutputStream zout = new ZipOutputStream(bout);
- addZipEntries(zout, resources);
- zout.close();
-
- moveTempFile(tempFile, file);
- } catch (CoreException e) {
- return new IStatus[] { e.getStatus() };
- } catch (Exception e) {
- //Trace.trace(Trace.SEVERE, "Error zipping", e);
- return new Status[] { new Status(IStatus.ERROR, ServerPlugin.PLUGIN_ID, 0,
NLS.bind(Messages.errorCreatingZipFile, path.lastSegment(), e.getLocalizedMessage()), e)
};
- } finally {
- if (tempFile != null && tempFile.exists())
- tempFile.deleteOnExit();
- }
- return EMPTY_STATUS;
- }
-
- private void addZipEntries(ZipOutputStream zout, IModuleResource[] resources) throws
Exception {
- if (resources == null)
- return;
-
- int size = resources.length;
- for (int i = 0; i < size; i++) {
- if (resources[i] instanceof IModuleFolder) {
- IModuleFolder mf = (IModuleFolder) resources[i];
- IModuleResource[] res = mf.members();
-
- IPath path = mf.getModuleRelativePath().append(mf.getName());
- String entryPath = path.toPortableString();
- if (!entryPath.endsWith("/")) //$NON-NLS-1$
- entryPath += '/';
-
- ZipEntry ze = new ZipEntry(entryPath);
-
- long ts = 0;
- IContainer folder = (IContainer) mf.getAdapter(IContainer.class);
- if (folder != null)
- ts = folder.getLocalTimeStamp();
-
- if (ts != IResource.NULL_STAMP && ts != 0)
- ze.setTime(ts);
-
- zout.putNextEntry(ze);
- zout.closeEntry();
-
- addZipEntries(zout, res);
- continue;
- }
-
- IModuleFile mf = (IModuleFile) resources[i];
- IPath path = mf.getModuleRelativePath().append(mf.getName());
-
- ZipEntry ze = new ZipEntry(path.toPortableString());
-
- InputStream in = null;
- long ts = 0;
- IFile file = (IFile) mf.getAdapter(IFile.class);
- if (file != null) {
- ts = file.getLocalTimeStamp();
- in = file.getContents();
- } else {
- File file2 = (File) mf.getAdapter(File.class);
- ts = file2.lastModified();
- in = new FileInputStream(file2);
- }
-
- if (ts != IResource.NULL_STAMP && ts != 0)
- ze.setTime(ts);
-
- zout.putNextEntry(ze);
-
- try {
- int n = 0;
- while (n > -1) {
- n = in.read(buf);
- if (n > 0)
- zout.write(buf, 0, n);
- }
- } finally {
- in.close();
- }
-
- zout.closeEntry();
- }
- }
-
- /**
* Utility method to move a temp file into position by deleting the original and
* swapping in a new copy.
*
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/META-INF/MANIFEST.MF 2009-10-19 17:21:45
UTC (rev 18170)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/META-INF/MANIFEST.MF 2009-10-19 21:52:18
UTC (rev 18171)
@@ -51,6 +51,7 @@
Export-Package: org.jboss.ide.eclipse.as.ui,
org.jboss.ide.eclipse.as.ui.dialogs,
org.jboss.ide.eclipse.as.ui.views.server.extensions,
+ org.jboss.ide.eclipse.as.ui.editor,
org.jboss.ide.eclipse.as.ui.wizards,
org.jboss.tools.as.wst.server.ui.xpl
Bundle-Activator: org.jboss.ide.eclipse.as.ui.JBossServerUIPlugin
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/LocalDeploymentModuleTab.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/LocalDeploymentModuleTab.java 2009-10-19
17:21:45 UTC (rev 18170)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/LocalDeploymentModuleTab.java 2009-10-19
21:52:18 UTC (rev 18171)
@@ -43,8 +43,10 @@
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.IJBossToolingConstants;
@@ -290,11 +292,10 @@
zipDeployWTPProjects = toolkit.createButton(composite,
Messages.EditorZipDeployments, SWT.CHECK);
- boolean publisherAvailable = ExtensionManager.getDefault()
- .getZippedPublisher() != null;
+ boolean zippedPublisherAvailable = isLocalZippedPublisherAvailable();
boolean value = getServer().zipsWTPDeployments();
- zipDeployWTPProjects.setEnabled(publisherAvailable);
- zipDeployWTPProjects.setSelection(publisherAvailable && value);
+ zipDeployWTPProjects.setEnabled(zippedPublisherAvailable);
+ zipDeployWTPProjects.setSelection(zippedPublisherAvailable && value);
FormData zipButtonData = new FormData();
zipButtonData.right = new FormAttachment(100, -5);
@@ -319,6 +320,16 @@
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;
Modified:
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 2009-10-19
17:21:45 UTC (rev 18170)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/ModuleDeploymentPage.java 2009-10-19
21:52:18 UTC (rev 18171)
@@ -34,11 +34,11 @@
import
org.jboss.ide.eclipse.as.core.util.DeploymentPreferenceLoader.DeploymentPreferences;
public class ModuleDeploymentPage extends ServerEditorPart {
- private ServerResourceCommandManager commandManager;
- private ArrayList<IModule> possibleModules;
- private DeploymentPreferences preferences;
- private ArrayList<IDeploymentEditorTab> tabs;
- private ServerAttributeHelper helper;
+ protected ServerResourceCommandManager commandManager;
+ protected ArrayList<IModule> possibleModules;
+ protected DeploymentPreferences preferences;
+ protected ArrayList<IDeploymentEditorTab> tabs;
+ protected ServerAttributeHelper helper;
public IModule[] getPossibleModules() {
return (IModule[]) possibleModules.toArray(new IModule[possibleModules.size()]);
@@ -92,18 +92,24 @@
toolkit.adapt(tabFolder);
toolkit.adapt(form);
toolkit.adapt(form.getBody());
- // for loop {
- TabItem tabItem = new TabItem(tabFolder, SWT.NULL);
- IDeploymentEditorTab tab = new LocalDeploymentModuleTab();
- tabItem.setText(tab.getTabName());
- tab.setDeploymentPage(this);
- tab.setDeploymentPrefs(preferences);
- tabItem.setControl(tab.createControl(tabFolder));
- toolkit.adapt((Composite)tabItem.getControl());
- tabs.add(tab);
- // }
+ IDeploymentEditorTab[] newItems = createTabs(toolkit, tabFolder);
+ for( int i = 0; i < newItems.length; i++ ) {
+ tabs.add(newItems[i]);
+ }
}
+ protected IDeploymentEditorTab[] createTabs(FormToolkit toolkit, TabFolder tabFolder) {
+ TabItem tabItem = new TabItem(tabFolder, SWT.NULL);
+ IDeploymentEditorTab tab = new LocalDeploymentModuleTab();
+ tabItem.setText(tab.getTabName());
+ tab.setDeploymentPage(this);
+ tab.setDeploymentPrefs(preferences);
+ tabItem.setControl(tab.createControl(tabFolder));
+ toolkit.adapt((Composite)tabItem.getControl());
+
+ return new IDeploymentEditorTab[] { tab };
+ }
+
public void execute(ServerCommand command) {
commandManager.execute(command);
}