Author: rob.stryker(a)jboss.com
Date: 2010-08-02 08:59:50 -0400 (Mon, 02 Aug 2010)
New Revision: 23866
Modified:
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/PublishUtil.java
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/xpl/PublishCopyUtil.java
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/rse/core/AbstractServerToolsPublisher.java
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/rse/core/RSERemotePublishHandler.java
Log:
JBIDE-6761 - RSE progress monitors
Modified:
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/PublishUtil.java
===================================================================
---
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/PublishUtil.java 2010-08-02
12:55:27 UTC (rev 23865)
+++
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/PublishUtil.java 2010-08-02
12:59:50 UTC (rev 23866)
@@ -17,12 +17,14 @@
import org.eclipse.core.resources.IFile;
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.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.eclipse.jst.server.core.IEnterpriseApplication;
import org.eclipse.wst.common.componentcore.ModuleCoreNature;
+import org.eclipse.wst.common.project.facet.core.util.internal.ProgressMonitorUtil;
import org.eclipse.wst.server.core.IModule;
import org.eclipse.wst.server.core.internal.DeletedModule;
import org.eclipse.wst.server.core.model.IModuleFile;
@@ -213,11 +215,19 @@
return ServerModelUtilities.isBinaryModule(lastMod);
}
+ @Deprecated
public static IModuleResource[] getResources(IModule module) throws CoreException {
- ModuleDelegate md = (ModuleDelegate)module.loadAdapter(ModuleDelegate.class, new
NullProgressMonitor());
+ return getResources(module, new NullProgressMonitor());
+ }
+
+ public static IModuleResource[] getResources(IModule module, IProgressMonitor monitor)
throws CoreException {
+ monitor.beginTask("Fetching Module Resources", 100); //$NON-NLS-1$
+ ModuleDelegate md = (ModuleDelegate)module.loadAdapter(ModuleDelegate.class,
ProgressMonitorUtil.submon(monitor, 100));
IModuleResource[] members = md.members();
+ monitor.done();
return members;
}
+
public static IModuleResource[] getResources(IModule[] tree) throws CoreException {
return getResources(tree[tree.length-1]);
}
Modified:
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/xpl/PublishCopyUtil.java
===================================================================
---
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/xpl/PublishCopyUtil.java 2010-08-02
12:55:27 UTC (rev 23865)
+++
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/xpl/PublishCopyUtil.java 2010-08-02
12:59:50 UTC (rev 23866)
@@ -26,9 +26,11 @@
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.Path;
import org.eclipse.core.runtime.Status;
import org.eclipse.osgi.util.NLS;
+import org.eclipse.wst.common.project.facet.core.util.internal.ProgressMonitorUtil;
import org.eclipse.wst.server.core.IServer;
import org.eclipse.wst.server.core.internal.Messages;
import org.eclipse.wst.server.core.internal.ProgressUtil;
@@ -524,8 +526,11 @@
* @return a possibly-empty array of error and warning status
*/
public IStatus[] publishFull(IModuleResource[] resources, IProgressMonitor monitor)
throws CoreException {
- handler.makeDirectoryIfRequired(new Path("/"), monitor); //$NON-NLS-1$
- return publishFull(resources, new Path("/"), monitor); //$NON-NLS-1$
+ monitor.beginTask("Publishing " + resources.length + " resources",
100 * (resources.length) + 100); //$NON-NLS-1$ //$NON-NLS-2$
+ handler.makeDirectoryIfRequired(new Path("/"),
ProgressMonitorUtil.submon(monitor, 100)); //$NON-NLS-1$
+ IStatus[] results = publishFull(resources, new Path("/"),
ProgressMonitorUtil.submon(monitor, 100*resources.length)); //$NON-NLS-1$
+ monitor.done();
+ return results;
}
public IStatus[] publishFull(IModuleResource[] resources, IPath relative,
IProgressMonitor monitor) throws CoreException {
@@ -533,14 +538,14 @@
return EMPTY_STATUS;
monitor = ProgressUtil.getMonitorFor(monitor);
-
+ monitor.beginTask("Publishing " + resources.length + " resources",
100 * (resources.length)); //$NON-NLS-1$ //$NON-NLS-2$
List status = new ArrayList(2);
int size = resources.length;
for (int i = 0; i < size; i++) {
- IStatus[] stat = copy(resources[i], relative, monitor);
+ IStatus[] stat = copy(resources[i], relative, ProgressMonitorUtil.submon(monitor,
100));
addArrayToList(status, stat);
}
-
+ monitor.done();
IStatus[] stat = new IStatus[status.size()];
status.toArray(stat);
return stat;
@@ -554,7 +559,7 @@
IModuleFolder folder = (IModuleFolder) resource;
IModuleResource[] children = folder.members();
if( children.length == 0 )
- handler.makeDirectoryIfRequired(folder.getModuleRelativePath().append(folder.getName()),
monitor);
+ handler.makeDirectoryIfRequired(folder.getModuleRelativePath().append(folder.getName()),
monitor);
else {
IStatus[] stat = publishFull(children, path, monitor);
addArrayToList(status, stat);
@@ -562,7 +567,7 @@
} else {
IModuleFile mf = (IModuleFile) resource;
path = path.append(mf.getModuleRelativePath()).append(name);
- IStatus[] stats = handler.makeDirectoryIfRequired(path.removeLastSegments(1),
monitor);
+ IStatus[] stats = handler.makeDirectoryIfRequired(path.removeLastSegments(1), new
NullProgressMonitor());
if( stats != null && stats.length > 0 && !stats[0].isOK())
addArrayToList(status, stats);
Modified:
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/rse/core/AbstractServerToolsPublisher.java
===================================================================
---
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/rse/core/AbstractServerToolsPublisher.java 2010-08-02
12:55:27 UTC (rev 23865)
+++
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/rse/core/AbstractServerToolsPublisher.java 2010-08-02
12:59:50 UTC (rev 23866)
@@ -25,6 +25,7 @@
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.eclipse.osgi.util.NLS;
+import org.eclipse.wst.common.project.facet.core.util.internal.ProgressMonitorUtil;
import org.eclipse.wst.server.core.IModule;
import org.eclipse.wst.server.core.IServer;
import org.eclipse.wst.server.core.model.IModuleResource;
@@ -79,17 +80,19 @@
if( module[i].isExternal() )
deleted = true;
}
-
+
+ // Monitor at this point has been begun with 1000 monitor
+ IProgressMonitor subMon = ProgressMonitorUtil.submon(monitor, 1000);
if (publishType == REMOVE_PUBLISH ) {
- status = unpublish(this.server, module, monitor);
+ status = unpublish(this.server, module, subMon);
} else {
if( deleted ) {
publishState = IServer.PUBLISH_STATE_UNKNOWN;
} else {
if (publishType == FULL_PUBLISH ) {
- status = fullPublish(module, module[module.length-1], monitor);
+ status = fullPublish(module, module[module.length-1], subMon);
} else if (publishType == INCREMENTAL_PUBLISH) {
- status = incrementalPublish(module, module[module.length-1], monitor);
+ status = incrementalPublish(module, module[module.length-1], subMon);
}
}
}
@@ -141,24 +144,27 @@
}
protected IStatus fullPublish(IModule[] moduleTree, IModule module, IProgressMonitor
monitor) throws CoreException {
+ monitor.beginTask("Full Publish", 1000); //$NON-NLS-1$
+
IPath deployPath = getDeployPath(moduleTree, server);
IPublishCopyCallbackHandler callback = getCallbackHandler(deployPath);
- IModuleResource[] members = PublishUtil.getResources(module);
+ IModuleResource[] members = PublishUtil.getResources(module,
ProgressMonitorUtil.submon(monitor, 200));
// First delete it
// if the module we're publishing is a project, not a binary, clean it's
folder
if( !(new Path(module.getName()).segmentCount() > 1 ))
- callback.deleteResource(new Path("/"), monitor); //$NON-NLS-1$
+ callback.deleteResource(new Path("/"), ProgressMonitorUtil.submon(monitor,
100)); //$NON-NLS-1$
ArrayList<IStatus> list = new ArrayList<IStatus>();
boolean isBinaryObject = ServerModelUtilities.isBinaryModule(module);
boolean forceZip = forceZipModule(moduleTree);
+
if( !forceZip && !isBinaryObject) {
PublishCopyUtil util = new PublishCopyUtil(callback);
- list.addAll(Arrays.asList(util.publishFull(members, monitor)));
+ list.addAll(Arrays.asList(util.publishFull(members,
ProgressMonitorUtil.submon(monitor, 700))));
} else if( isBinaryObject )
- list.addAll(Arrays.asList(copyBinaryModule(moduleTree, monitor)));
+ list.addAll(Arrays.asList(copyBinaryModule(moduleTree,
ProgressMonitorUtil.submon(monitor, 700))));
else {
// A child that must be zipped, forceZip is true
IPath deployRoot = JBossServerCorePlugin.getServerStateLocation(server.getServer()).
@@ -170,30 +176,32 @@
list.addAll(Arrays.asList(PublishUtil.packModuleIntoJar(moduleTree[moduleTree.length-1],
tempFile)));
IPublishCopyCallbackHandler handler = getCallbackHandler(new Path("/"));
//$NON-NLS-1$
String parentFolder = deployPath.removeLastSegments(1).toString();
- handler.makeDirectoryIfRequired(new Path(parentFolder), new NullProgressMonitor());
+ handler.makeDirectoryIfRequired(new Path(parentFolder),
ProgressMonitorUtil.submon(monitor, 200));
ModuleFile mf = new ModuleFile(tempFile.toFile(), tempFile.lastSegment(), tempFile);
- handler.copyFile(mf, deployPath, new NullProgressMonitor());
+ handler.copyFile(mf, deployPath, ProgressMonitorUtil.submon(monitor, 500));
} catch( IOException ioe) {
list.add(new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID, ioe.getMessage(),
ioe));
}
}
+ monitor.done();
if( list.size() > 0 )
return createMultiStatus(list, module);
return Status.OK_STATUS;
}
protected IStatus incrementalPublish(IModule[] moduleTree, IModule module,
IProgressMonitor monitor) throws CoreException {
+ monitor.beginTask("Incremental Publish", 100); //$NON-NLS-1$
IStatus[] results = new IStatus[] {};
IPath deployPath = getDeployPath(moduleTree, server);
boolean isBinaryObject = ServerModelUtilities.isBinaryModule(module);
boolean forceZip = forceZipModule(moduleTree);
if( !forceZip && !isBinaryObject) {
IPublishCopyCallbackHandler handler = getCallbackHandler(deployPath);
- results = new PublishCopyUtil(handler).publishDelta(delta, monitor);
+ results = new PublishCopyUtil(handler).publishDelta(delta,
ProgressMonitorUtil.submon(monitor, 100));
} else if( delta.length > 0 ) {
if( isBinaryObject)
- results = copyBinaryModule(moduleTree, monitor);
+ results = copyBinaryModule(moduleTree, ProgressMonitorUtil.submon(monitor, 100));
else {
// forceZip a child module
IPath localDeployRoot =
JBossServerCorePlugin.getServerStateLocation(server.getServer()).
@@ -204,9 +212,9 @@
PublishUtil.packModuleIntoJar(moduleTree[moduleTree.length-1], tempFile);
IPublishCopyCallbackHandler handler = getCallbackHandler(new Path("/"));
//$NON-NLS-1$
String parentFolder = deployPath.removeLastSegments(1).toString();
- handler.makeDirectoryIfRequired(new Path(parentFolder), new NullProgressMonitor());
+ handler.makeDirectoryIfRequired(new Path(parentFolder),
ProgressMonitorUtil.submon(monitor, 50));
ModuleFile mf = new ModuleFile(tempFile.toFile(), tempFile.lastSegment(),
tempFile);
- handler.copyFile(mf, deployPath, new NullProgressMonitor());
+ handler.copyFile(mf, deployPath, ProgressMonitorUtil.submon(monitor, 50));
} catch( IOException ioe) {
IStatus s = new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID,
ioe.getMessage(), ioe);
results = new IStatus[] { s };
@@ -214,6 +222,7 @@
}
}
+ monitor.done();
if( results != null && results.length > 0 ) {
MultiStatus ms = new MultiStatus(JBossServerCorePlugin.PLUGIN_ID,
IEventCodes.JST_PUB_INC_FAIL,
NLS.bind(Messages.IncrementalPublishFail, module.getName()), null);
@@ -236,6 +245,7 @@
}
protected IStatus[] copyBinaryModule(IModule[] moduleTree, IProgressMonitor monitor) {
+ monitor.beginTask("Copy Binary Module", 100); //$NON-NLS-1$
try {
IPath destinationPath = getDeployPath(moduleTree, server);
IModuleResource[] members = PublishUtil.getResources(moduleTree);
@@ -255,14 +265,17 @@
} catch( CoreException ce ) {
return new IStatus[] {ce.getStatus()};
}
+ monitor.done();
return new IStatus[]{Status.OK_STATUS};
}
protected IStatus unpublish(IDeployableServer jbServer, IModule[] module,
IProgressMonitor monitor) throws CoreException {
+ monitor.beginTask("Begin Unpublish", 100); //$NON-NLS-1$
IPath remotePath = getDeployPath(module, server);
IPublishCopyCallbackHandler handler = getCallbackHandler(new Path("/"));
//$NON-NLS-1$
- handler.deleteResource(remotePath, monitor);
+ handler.deleteResource(remotePath, ProgressMonitorUtil.submon(monitor, 100));
+ monitor.done();
return Status.OK_STATUS;
}
}
Modified:
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/rse/core/RSERemotePublishHandler.java
===================================================================
---
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/rse/core/RSERemotePublishHandler.java 2010-08-02
12:55:27 UTC (rev 23865)
+++
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/rse/core/RSERemotePublishHandler.java 2010-08-02
12:59:50 UTC (rev 23866)
@@ -21,6 +21,7 @@
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.rse.services.clientserver.messages.SystemMessageException;
+import org.eclipse.wst.common.project.facet.core.util.internal.ProgressMonitorUtil;
import org.eclipse.wst.server.core.model.IModuleFile;
import org.jboss.ide.eclipse.as.core.publishers.PublishUtil;
import
org.jboss.ide.eclipse.as.core.server.xpl.PublishCopyUtil.IPublishCopyCallbackHandler;
@@ -59,17 +60,20 @@
public IStatus[] makeDirectoryIfRequired(IPath dir,
IProgressMonitor monitor) throws CoreException {
+ monitor.beginTask("Make directory " + dir.toString(), 100); //$NON-NLS-1$
if( dir.segmentCount() > 0 )
- makeDirectoryIfRequired(dir.removeLastSegments(1), monitor);
+ makeDirectoryIfRequired(dir.removeLastSegments(1), ProgressMonitorUtil.submon(monitor,
70));
IPath toMake = root.append(dir);
if( createdFolders.contains(toMake))
return new IStatus[]{Status.OK_STATUS};
try {
- method.getFileService().createFolder(toMake.removeLastSegments(1).toString(),
toMake.lastSegment(), monitor);
+ method.getFileService().createFolder(toMake.removeLastSegments(1).toString(),
+ toMake.lastSegment(), ProgressMonitorUtil.submon(monitor, 30));
} catch( SystemMessageException sme ) {
System.err.println("failed to make folder " + toMake.toString());
//$NON-NLS-1$
}
createdFolders.add(toMake);
+ monitor.done();
return null;
}
}