Author: rob.stryker(a)jboss.com
Date: 2007-11-02 07:49:02 -0400 (Fri, 02 Nov 2007)
New Revision: 4656
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/events/EventLogModel.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/NullPublisher.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/PackagesPublisher.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/PublisherEventLogger.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/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/util/SimpleTreeItem.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/events/PackagesPublishLabelProvider.java
Log:
Event Log changes regarding publishing. No JIRA associated, sadly.
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/events/EventLogModel.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/events/EventLogModel.java 2007-11-02
11:13:03 UTC (rev 4655)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/events/EventLogModel.java 2007-11-02
11:49:02 UTC (rev 4656)
@@ -203,11 +203,6 @@
if( isLoggingEnabled() )
super.addChild(item);
}
-
- public void addChild(int loc, SimpleTreeItem item) {
- if( isLoggingEnabled() )
- super.addChild(loc, item);
- }
public void addChildren(SimpleTreeItem[] kids) {
if( isLoggingEnabled() )
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 2007-11-02
11:13:03 UTC (rev 4655)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/JstPublisher.java 2007-11-02
11:49:02 UTC (rev 4656)
@@ -31,16 +31,17 @@
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.IServer;
import org.eclipse.wst.server.core.internal.DeletedModule;
+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.eclipse.wst.server.core.model.ModuleDelegate;
-import org.eclipse.wst.server.core.model.ServerBehaviourDelegate;
import org.eclipse.wst.server.core.util.ProjectModule;
import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
import org.jboss.ide.eclipse.as.core.extensions.events.EventLogModel;
@@ -91,11 +92,8 @@
return modulePath;
}
- public IStatus publishModule(int kind, int deltaKind,
- int modulePublishState, IModule[] module, IProgressMonitor monitor)
+ public IStatus publishModule(IModule[] module, int publishType, IProgressMonitor
monitor)
throws CoreException {
- String modulePath = getModulePath(module);
-
IStatus status = null;
boolean deleted = false;
for( int i = 0; i < module.length; i++ ) {
@@ -103,24 +101,25 @@
deleted = true;
}
- if (ServerBehaviourDelegate.REMOVED == deltaKind) {
+ if (publishType == REMOVE_PUBLISH ) {
status = unpublish(server, module, monitor);
- } else if (kind == IServer.PUBLISH_FULL || modulePublishState ==
IServer.PUBLISH_STATE_FULL || kind == IServer.PUBLISH_CLEAN ) {
- if( deleted )
+ } else {
+ if( deleted ) {
publishState = IServer.PUBLISH_STATE_UNKNOWN;
- else
- status = fullPublish(module, module[module.length-1], monitor);
- } else if (kind == IServer.PUBLISH_INCREMENTAL || modulePublishState ==
IServer.PUBLISH_STATE_INCREMENTAL || kind == IServer.PUBLISH_AUTO) {
- if( deleted )
- publishState = IServer.PUBLISH_STATE_UNKNOWN;
- else
- status = incrementalPublish(module, module[module.length-1], monitor);
- }
+ } else {
+ if (publishType == FULL_PUBLISH ) {
+ status = fullPublish(module, module[module.length-1], monitor);
+ } else if (publishType == INCREMENTAL_PUBLISH) {
+ status = incrementalPublish(module, module[module.length-1], monitor);
+ }
+ }
+ }
return status;
}
protected IStatus fullPublish(IModule[] moduleTree, IModule module, IProgressMonitor
monitor) throws CoreException {
+ eventRoot.setProperty(PublisherEventLogger.CHANGED_FILE_COUNT, countMembers(module));
IPath deployPath = getDeployPath(moduleTree);
ModuleDelegate md = (ModuleDelegate)module.loadAdapter(ModuleDelegate.class, monitor);
IModuleResource[] members = md.members();
@@ -135,7 +134,6 @@
for( int i = 0; i < length; i++ ) {
new PublisherEventLogger.PublishUtilStatusWrapper(eventRoot, results[i]);
}
- if( length != 0 ) EventLogModel.markChanged(eventRoot);
// adjust timestamps
FileFilter filter = new FileFilter() {
@@ -150,6 +148,7 @@
}
protected IStatus incrementalPublish(IModule[] moduleTree, IModule module,
IProgressMonitor monitor) throws CoreException {
+ eventRoot.setProperty(PublisherEventLogger.CHANGED_FILE_COUNT, countChanges(delta));
IStatus[] results = new IStatus[] {};
if( !deployPackaged(moduleTree))
results = new PublishUtil(server.getServer()).publishDelta(delta,
getDeployPath(moduleTree), monitor);
@@ -160,13 +159,13 @@
for( int i = 0; i < length; i++ ) {
new PublisherEventLogger.PublishUtilStatusWrapper(eventRoot, results[i]);
}
- if( length != 0 ) EventLogModel.markChanged(eventRoot);
-
+
return null;
}
protected IStatus unpublish(IDeployableServer jbServer, IModule[] module,
IProgressMonitor monitor) throws CoreException {
+ eventRoot.setProperty(PublisherEventLogger.CHANGED_FILE_COUNT,
countMembers(module[module.length-1]));
boolean error = localSafeDelete(getDeployPath(module), eventRoot);
if( error ) {
publishState = IServer.PUBLISH_STATE_FULL;
@@ -287,4 +286,35 @@
}
}
}
+
+ protected int countChanges(IModuleResourceDelta[] deltas) {
+ IModuleResource res;
+ int count = 0;
+ for( int i = 0; i < deltas.length; i++ ) {
+ res = deltas[i].getModuleResource();
+ if( res != null && res instanceof IModuleFile)
+ count++;
+ count += countChanges(deltas[i].getAffectedChildren());
+ }
+ return count;
+ }
+
+ protected int countMembers(IModule module) {
+ try {
+ ModuleDelegate delegate = (ModuleDelegate)module.loadAdapter(ModuleDelegate.class, new
NullProgressMonitor());
+ return delegate == null ? 0 : countMembers(delegate.members());
+ } catch( CoreException ce ) {}
+ return 0;
+ }
+ protected int countMembers(IModuleResource[] resources) {
+ int count = 0;
+ for( int i = 0; i < resources.length; i++ ) {
+ if( resources[i] instanceof IModuleFile ) {
+ count++;
+ } else if( resources[i] instanceof IModuleFolder ) {
+ count += countMembers(((IModuleFolder)resources[i]).members());
+ }
+ }
+ return count;
+ }
}
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 2007-11-02
11:13:03 UTC (rev 4655)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/NullPublisher.java 2007-11-02
11:49:02 UTC (rev 4656)
@@ -39,8 +39,7 @@
return IServer.PUBLISH_STATE_NONE;
}
- public IStatus publishModule(int kind, int deltaKind, int modulePublishState,
- IModule[] module, IProgressMonitor monitor) throws CoreException {
+ public IStatus publishModule(IModule[] module, int publishType, IProgressMonitor
monitor) throws CoreException {
return null;
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/PackagesPublisher.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/PackagesPublisher.java 2007-11-02
11:13:03 UTC (rev 4655)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/PackagesPublisher.java 2007-11-02
11:49:02 UTC (rev 4656)
@@ -29,12 +29,14 @@
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.IServer;
import org.eclipse.wst.server.core.model.IModuleResource;
import org.eclipse.wst.server.core.model.IModuleResourceDelta;
import org.eclipse.wst.server.core.model.ServerBehaviourDelegate;
import org.jboss.ide.eclipse.archives.core.model.IArchive;
+import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
import org.jboss.ide.eclipse.as.core.extensions.events.EventLogModel.EventLogTreeItem;
import org.jboss.ide.eclipse.as.core.modules.PackageModuleFactory.ExtendedModuleFile;
import
org.jboss.ide.eclipse.as.core.modules.PackageModuleFactory.IExtendedModuleResource;
@@ -43,6 +45,7 @@
import
org.jboss.ide.eclipse.as.core.publishers.PublisherEventLogger.PublisherFileUtilListener;
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.JBossServer;
import org.jboss.ide.eclipse.as.core.util.FileUtil;
import org.jboss.ide.eclipse.as.core.util.ServerConverter;
@@ -72,45 +75,39 @@
return IServer.PUBLISH_STATE_NONE;
}
- public IStatus publishModule(int kind, int deltaKind, int modulePublishState,
- IModule[] module, IProgressMonitor monitor) throws CoreException {
+ public IStatus publishModule(IModule[] module, int publishType, IProgressMonitor
monitor) throws CoreException {
try {
IModule module2 = module[0];
// if it's being removed
- if( deltaKind == ServerBehaviourDelegate.REMOVED ) {
- removeModule(module2, kind, deltaKind, modulePublishState, monitor);
- return null;
+ if( publishType == REMOVE_PUBLISH ) {
+ removeModule(module2, monitor);
+ } else if( publishType == FULL_PUBLISH ) {
+ publishModule(module2, true, monitor);
+ } else if( publishType == INCREMENTAL_PUBLISH ) {
+ publishModule(module2, false, monitor);
}
-
- if( deltaKind == ServerBehaviourDelegate.ADDED || deltaKind ==
ServerBehaviourDelegate.CHANGED) {
- publishModule(module2, kind, deltaKind, modulePublishState, monitor);
- return null;
- }
}catch(Exception e) {
- e.printStackTrace();
+ IStatus status = new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID,
"Error during publish", e);
+ JBossServerCorePlugin.getDefault().getLog().log(status);
}
return null;
}
- protected void removeModule(IModule module, int kind, int deltaKind, int publishState,
IProgressMonitor monitor) {
+ protected void removeModule(IModule module, IProgressMonitor monitor) {
IArchive pack = getPackage(module);
// remove all of the deployed items
- PublishEvent event = PublisherEventLogger.createModuleRootEvent(
- eventRoot, new IModule[]{module}, kind, deltaKind, publishState);
if( pack != null ) {
IPath sourcePath = pack.getArchiveFilePath();
IPath destPath = new
Path(server.getDeployDirectory()).append(sourcePath.lastSegment());
// remove the entire file or folder
- PublisherFileUtilListener listener = new PublisherFileUtilListener(event);
+ PublisherFileUtilListener listener = new PublisherFileUtilListener(eventRoot);
FileUtil.safeDelete(destPath.toFile(), listener);
}
}
- protected void publishModule(IModule module, int kind, int deltaKind, int
modulePublishState, IProgressMonitor monitor) {
- PublishEvent event = PublisherEventLogger.createModuleRootEvent(
- eventRoot, new IModule[]{module}, kind, deltaKind, modulePublishState);
+ protected void publishModule(IModule module, boolean incremental, IProgressMonitor
monitor) {
IArchive pack = getPackage(module);
IPath sourcePath = pack.getArchiveFilePath();
IPath destPathRoot = new Path(server.getDeployDirectory());
@@ -121,20 +118,15 @@
return;
}
- PublisherFileUtilListener listener = new PublisherFileUtilListener(event);
-
- if( shouldPublishIncremental(module, kind, deltaKind, modulePublishState) ) {
+ PublisherFileUtilListener listener = new PublisherFileUtilListener(eventRoot);
+ if( incremental ) {
publishFromDelta(module, destPathRoot, sourcePath.removeLastSegments(1), delta,
listener);
} else {
// full publish, copy whole folder or file
FileUtil.fileSafeCopy(sourcePath.toFile(),
destPathRoot.append(sourcePath.lastSegment()).toFile(), listener);
}
}
- protected boolean shouldPublishIncremental(IModule module, int kind, int deltaKind, int
modulePublishState) {
- if(modulePublishState == IServer.PUBLISH_STATE_FULL || kind == IServer.PUBLISH_FULL)
- return false;
- return true;
- }
+
protected void publishFromDelta(IModule module, IPath destPathRoot, IPath sourcePrefix,
IModuleResourceDelta[] delta, PublisherFileUtilListener listener) {
ArrayList changedFiles = new ArrayList();
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/PublisherEventLogger.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/PublisherEventLogger.java 2007-11-02
11:13:03 UTC (rev 4655)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/PublisherEventLogger.java 2007-11-02
11:49:02 UTC (rev 4656)
@@ -23,11 +23,7 @@
setProperty(MODULE_NAME, module.getName());
}
}
-
- public static PublishEvent createTopEvent(EventLogTreeItem parent) {
- return new PublishEvent(parent, ROOT_EVENT);
- }
-
+
// type
public static final String ROOT_EVENT =
"org.jboss.ide.eclipse.as.core.publishers.PublisherEventLogger.ROOT_EVENT";
public static final String MODULE_ROOT_EVENT =
"org.jboss.ide.eclipse.as.core.publishers.PublisherEventLogger.MODULE_ROOT_EVENT";
@@ -35,6 +31,7 @@
public static final String MODULE_KIND =
"org.jboss.ide.eclipse.as.core.publishers.PublisherEventLogger.MODULE_KIND";
public static final String DELTA_KIND =
"org.jboss.ide.eclipse.as.core.publishers.PublisherEventLogger.DELTA_KIND";
public static final String MODULE_PUBLISH_STATE =
"org.jboss.ide.eclipse.as.core.publishers.PublisherEventLogger.MODULE_PUBLISH_STATE";
+
public static PublishEvent createModuleRootEvent(EventLogTreeItem parent, IModule[]
module,
int kind, int deltaKind, int moduleStateKind) {
PublishEvent event = new PublishEvent(parent, MODULE_ROOT_EVENT);
@@ -83,6 +80,10 @@
public static final String SOURCE_PROPERTY =
"org.jboss.ide.eclipse.as.core.publishers.Events.Properties.SOURCE_PROPERTY";
public static final String DEST_PROPERTY =
"org.jboss.ide.eclipse.as.core.publishers.Events.Properties.DEST_PROPERTY";
public static final String EXCEPTION_MESSAGE =
"org.jboss.ide.eclipse.as.core.publishers.Events.Properties.EXCEPTION_PROPERTY";
+ public static final String CHANGED_MODULE_COUNT =
"org.jboss.ide.eclipse.as.core.publishers.Events.Properties.CHANGED_MODULE_COUNT_PROPERTY";
+ public static final String CHANGED_FILE_COUNT =
"org.jboss.ide.eclipse.as.core.publishers.Events.Properties.CHANGED_FILE_COUNT_PROPERTY";
+
+
public static class DeletedEvent extends EventLogTreeItem {
public DeletedEvent(EventLogTreeItem parent, File file, boolean result, Exception e) {
super(parent, FILE_EVENT_MAJOR_TYPE, file.isDirectory() ? FOLDER_DELETED_EVENT :
FILE_DELETED_EVENT);
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 2007-11-02
11:13:03 UTC (rev 4655)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/SingleFilePublisher.java 2007-11-02
11:49:02 UTC (rev 4656)
@@ -13,7 +13,6 @@
import org.eclipse.wst.server.core.IModule;
import org.eclipse.wst.server.core.IServer;
import org.eclipse.wst.server.core.model.IModuleResourceDelta;
-import org.eclipse.wst.server.core.model.ServerBehaviourDelegate;
import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
import org.jboss.ide.eclipse.as.core.extensions.events.EventLogModel;
import org.jboss.ide.eclipse.as.core.extensions.events.EventLogModel.EventLogTreeItem;
@@ -40,27 +39,26 @@
return publishState;
}
- public IStatus publishModule(int kind, int deltaKind,
- int modulePublishState, IModule[] module, IProgressMonitor monitor)
+ public IStatus publishModule(IModule[] module, int publishType, IProgressMonitor
monitor)
throws CoreException {
IModule module2 = module[0];
IStatus status = null;
- if(ServerBehaviourDelegate.REMOVED == deltaKind){
- status = unpublish(server, module2, kind, deltaKind, modulePublishState,
monitor);
- } else if( ServerBehaviourDelegate.NO_CHANGE != deltaKind || kind ==
IServer.PUBLISH_FULL || kind == IServer.PUBLISH_CLEAN ){
+ if(publishType == REMOVE_PUBLISH){
+ status = unpublish(server, module2, monitor);
+ } else if( publishType == FULL_PUBLISH ){
// if there's no change, do nothing. Otherwise, on change or add,
re-publish
- status = publish(server, module2, kind, deltaKind, modulePublishState, true,
monitor);
- } else if( ServerBehaviourDelegate.NO_CHANGE != deltaKind && kind ==
IServer.PUBLISH_INCREMENTAL ){
- status = publish(server, module2, kind, deltaKind, modulePublishState, false,
monitor);
+ status = publish(server, module2, true, monitor);
+ } else if( publishType == INCREMENTAL_PUBLISH ) {
+ status = publish(server, module2, false, monitor);
}
+ root.setProperty(PublisherEventLogger.CHANGED_FILE_COUNT, new Integer(1));
return status;
}
- protected IStatus publish(IDeployableServer server, IModule module, int kind, int
deltaKind,
- int modulePublishState, boolean updateTimestamp, IProgressMonitor monitor) throws
CoreException {
+ protected IStatus publish(IDeployableServer server, IModule module, boolean
updateTimestamp, IProgressMonitor monitor) throws CoreException {
SingleDeployableModuleDelegate delegate =
(SingleDeployableModuleDelegate)module.loadAdapter(SingleDeployableModuleDelegate.class,
new NullProgressMonitor());
if( delegate != null ) {
IPath sourcePath = delegate.getGlobalSourcePath();
@@ -83,7 +81,7 @@
return null;
}
- protected IStatus unpublish(IDeployableServer server, IModule module, int kind, int
deltaKind, int modulePublishState, IProgressMonitor monitor) throws CoreException {
+ protected IStatus unpublish(IDeployableServer server, IModule module, IProgressMonitor
monitor) throws CoreException {
// delete file
SingleDeployableModuleDelegate delegate =
(SingleDeployableModuleDelegate)module.loadAdapter(SingleDeployableModuleDelegate.class,
new NullProgressMonitor());
if( delegate != null ) {
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 2007-11-02
11:13:03 UTC (rev 4655)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IJBossServerPublisher.java 2007-11-02
11:49:02 UTC (rev 4656)
@@ -33,10 +33,13 @@
*
*/
public interface IJBossServerPublisher {
- public IStatus publishModule(int kind, int deltaKind, int modulePublishState,
- IModule[] module, IProgressMonitor monitor)
- throws CoreException;
+ public static final int NO_PUBLISH = 0;
+ public static final int INCREMENTAL_PUBLISH = 1;
+ public static final int FULL_PUBLISH = 2;
+ public static final int REMOVE_PUBLISH = 3;
+
+ public IStatus publishModule(IModule[] module, int publishType,
+ IProgressMonitor monitor) throws CoreException;
public int getPublishState();
public void setDelta(IModuleResourceDelta[] delta);
-
}
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 2007-11-02
11:13:03 UTC (rev 4655)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/DeployableServerBehavior.java 2007-11-02
11:49:02 UTC (rev 4656)
@@ -69,38 +69,12 @@
workingCopy.setAttribute(DeployableLaunchConfiguration.ACTION_KEY,
DeployableLaunchConfiguration.START);
}
- private String print(int kind, int deltaKind, IModule[] module) {
- String ret = "";
- String name = "";
- for( int i = 0; i < module.length; i++ )
- name += module[i].getName();
-
- ret += "publishing module (" + name + "): ";
- switch( kind ) {
- case IServer.PUBLISH_INCREMENTAL: ret += "incremental, "; break;
- case IServer.PUBLISH_FULL: ret += "full, "; break;
- case IServer.PUBLISH_AUTO: ret += "auto, "; break;
- case IServer.PUBLISH_CLEAN: ret += "clean, "; break;
- }
- switch( deltaKind ) {
- case ServerBehaviourDelegate.NO_CHANGE: ret += "no change"; break;
- case ServerBehaviourDelegate.ADDED: ret += "added"; break;
- case ServerBehaviourDelegate.CHANGED: ret += "changed"; break;
- case ServerBehaviourDelegate.REMOVED: ret += "removed"; break;
- }
- ret += " to server " + getServer().getName() + "(" +
getServer().getId() + ")";
- return ret;
- }
-
- protected PublishEvent publishEvent;
+ protected PublishEvent publishRootEvent;
protected void publishStart(IProgressMonitor monitor) throws CoreException {
- EventLogTreeItem root = EventLogModel.getModel(getServer()).getRoot();
- publishEvent = PublisherEventLogger.createTopEvent(root);
+ publishRootEvent = new PublishEvent(null, PublisherEventLogger.ROOT_EVENT);
}
protected void publishFinish(IProgressMonitor monitor) throws CoreException {
- publishEvent = null;
-
IModule[] modules = this.getServer().getModules();
boolean allpublished= true;
for (int i = 0; i < modules.length; i++) {
@@ -109,7 +83,12 @@
}
if(allpublished)
setServerPublishState(IServer.PUBLISH_STATE_NONE);
-
+
+ if( publishRootEvent.getChildren().length != 0 ) {
+ EventLogTreeItem root = EventLogModel.getModel(getServer()).getRoot();
+ root.addChild(publishRootEvent);
+ }
+ publishRootEvent = null;
}
@@ -125,32 +104,58 @@
// kind = [incremental, full, auto, clean] = [1,2,3,4]
// delta = [no_change, added, changed, removed] = [0,1,2,3]
if( module.length == 0 ) return;
+ int modulePublishState = getServer().getModulePublishState(module);
+ int publishType = getPublishType(kind, deltaKind, modulePublishState);
IJBossServerPublisher publisher;
- int modulePublishState = getServer().getModulePublishState(module);
- PublishEvent root = PublisherEventLogger.createModuleRootEvent(publishEvent, module,
kind, deltaKind, modulePublishState);
+
- if( module.length > 0 ) {
+ if( module.length > 0 && publishType != IJBossServerPublisher.NO_PUBLISH) {
+ Integer i,j;
+ i = (Integer)publishRootEvent.getProperty(PublisherEventLogger.CHANGED_MODULE_COUNT);
+ publishRootEvent.setProperty(PublisherEventLogger.CHANGED_MODULE_COUNT, new Integer(i
== null ? 1 : i.intValue()+1));
+ PublishEvent modulePublishEvent =
PublisherEventLogger.createModuleRootEvent(publishRootEvent, module, kind, deltaKind,
modulePublishState);
+
IModule lastMod = module[module.length -1];
if( isJstModule(lastMod) ) {
- publisher = new JstPublisher(getServer(), root);
+ publisher = new JstPublisher(getServer(), modulePublishEvent);
} else if( isPackagesTypeModule(lastMod) ) {
- publisher = new PackagesPublisher(getServer(), root);
+ publisher = new PackagesPublisher(getServer(), modulePublishEvent);
} else if( lastMod.getModuleType().getId().equals("jboss.singlefile")){
- publisher = new SingleFilePublisher(getServer(), root);
+ publisher = new SingleFilePublisher(getServer(), modulePublishEvent);
} else {
publisher = new NullPublisher();
}
publisher.setDelta(getPublishedResourceDelta(module));
try {
- publisher.publishModule(kind, deltaKind, modulePublishState, module, monitor);
+ publisher.publishModule(module, publishType, monitor);
} catch( CoreException ce ) {
throw ce;
} finally {
setModulePublishState(module, publisher.getPublishState());
}
+
+ // add file changed count to top level element
+ i = (Integer)publishRootEvent.getProperty(PublisherEventLogger.CHANGED_FILE_COUNT);
+ j = (Integer)modulePublishEvent.getProperty(PublisherEventLogger.CHANGED_FILE_COUNT);
+ j = j == null ? new Integer(0) : j;
+ int count = (i == null ? 0 : i.intValue()) + j.intValue();
+ publishRootEvent.setProperty(PublisherEventLogger.CHANGED_FILE_COUNT, count);
}
}
+
+ protected int getPublishType(int kind, int deltaKind, int modulePublishState) {
+ if (ServerBehaviourDelegate.REMOVED == deltaKind) {
+ return IJBossServerPublisher.REMOVE_PUBLISH;
+ } else if (kind == IServer.PUBLISH_FULL || modulePublishState ==
IServer.PUBLISH_STATE_FULL || kind == IServer.PUBLISH_CLEAN ) {
+ return IJBossServerPublisher.FULL_PUBLISH;
+ } else if (kind == IServer.PUBLISH_INCREMENTAL || modulePublishState ==
IServer.PUBLISH_STATE_INCREMENTAL || kind == IServer.PUBLISH_AUTO) {
+ if( ServerBehaviourDelegate.CHANGED == deltaKind )
+ return IJBossServerPublisher.INCREMENTAL_PUBLISH;
+ }
+ return IJBossServerPublisher.NO_PUBLISH;
+ }
+
/* Temporary and will need to be fixed */
// TODO: Change to if it is a flex project. Don't know how to do that yet.
protected boolean isJstModule(IModule mod) {
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/SimpleTreeItem.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/SimpleTreeItem.java 2007-11-02
11:13:03 UTC (rev 4655)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/SimpleTreeItem.java 2007-11-02
11:49:02 UTC (rev 4656)
@@ -56,10 +56,6 @@
item.setParent(this);
}
}
-
- public void addChild(int loc, SimpleTreeItem item) {
- children.add(loc, item);
- }
public void addChildren(SimpleTreeItem[] kids) {
for( int i = 0; i < kids.length; i++ ) {
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/events/PackagesPublishLabelProvider.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/events/PackagesPublishLabelProvider.java 2007-11-02
11:13:03 UTC (rev 4655)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/events/PackagesPublishLabelProvider.java 2007-11-02
11:49:02 UTC (rev 4656)
@@ -75,6 +75,8 @@
propertyToMessageMap.put(PublisherEventLogger.DELTA_KIND + DELIMITER +
ServerBehaviourDelegate.REMOVED, "Removed");
propertyToMessageMap.put(PublisherEventLogger.DELTA_KIND + DELIMITER +
ServerBehaviourDelegate.NO_CHANGE, "No Change");
+ propertyToMessageMap.put(PublisherEventLogger.CHANGED_FILE_COUNT, "Changed
Files");
+ propertyToMessageMap.put(PublisherEventLogger.CHANGED_MODULE_COUNT, "Changed
Modules");
// propertyToMessageMap.put(IJBossServerPublisher.MODULE_NAME, "Module
Name");
// propertyToMessageMap.put(PackagesPublisher.PackagesPublisherRemoveEvent.PACKAGE_NAME,
"Package Name");
@@ -155,8 +157,15 @@
}
if( type.equals(PublisherEventLogger.ROOT_EVENT)) {
- return "Publishing to server";
+ Integer tmp;
+ int files, mods;
+ tmp = (Integer)item.getProperty(PublisherEventLogger.CHANGED_FILE_COUNT);
+ files = tmp == null ? 0 : tmp.intValue();
+ tmp = (Integer)item.getProperty(PublisherEventLogger.CHANGED_MODULE_COUNT);
+ mods = tmp == null ? 0 : tmp.intValue();
+ return "Publishing [" + mods + " modules, " + files + " files
changed]";
}
+
if( type.equals(PublisherEventLogger.MODULE_ROOT_EVENT)) {
return getKindDeltaKind(item) + " " +
item.getProperty(PublisherEventLogger.MODULE_NAME);
}