Author: rob.stryker(a)jboss.com
Date: 2008-09-11 19:46:04 -0400 (Thu, 11 Sep 2008)
New Revision: 10208
Modified:
trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/ArchivesBuildListener.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/ArchivesModelModuleContributor.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/PackageModuleFactory.java
Log:
JBIDE-2743 - fixed the module id for archives in a fashion that automatically converts the
old into the new with no conflicts. This was only possible thanks to a well-designed wtp
api.
Modified:
trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/ArchivesBuildListener.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/ArchivesBuildListener.java 2008-09-11
19:45:22 UTC (rev 10207)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/ArchivesBuildListener.java 2008-09-11
23:46:04 UTC (rev 10208)
@@ -115,7 +115,7 @@
}
protected static IModule[] getModule(IArchive node) {
ModuleFactory factory =
ServerPlugin.findModuleFactory("org.jboss.ide.eclipse.as.core.PackageModuleFactory");
- IModule mod = factory.findModule(PackageModuleFactory.getID(node), new
NullProgressMonitor());
+ IModule mod = factory.findModule(PackageModuleFactory.getId(node), new
NullProgressMonitor());
return new IModule[] { mod };
}
protected static PackagedModuleDelegate getModuleDelegate(IArchive node) {
Modified:
trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/ArchivesModelModuleContributor.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/ArchivesModelModuleContributor.java 2008-09-11
19:45:22 UTC (rev 10207)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/ArchivesModelModuleContributor.java 2008-09-11
23:46:04 UTC (rev 10208)
@@ -170,16 +170,18 @@
/**
* Set a property so that each module that's here in the factory
* has a unique ID other than it's name (which is not unique)
+ *
+ * This must set ONLY the timestamp as the property in the file.
* @param archives
* @return returns whether a save has occurred
*/
protected boolean ensureArchivesHaveIDs(IProject project, IArchive[] archives) {
boolean requiresSave = false;
for( int i = 0; i < archives.length; i++ ) {
- if( PackageModuleFactory.getID(archives[i]) == null ) {
+ if( PackageModuleFactory.getStamp(archives[i]) == null ) {
requiresSave = true;
archives[i].setProperty(PackageModuleFactory.MODULE_ID_PROPERTY_KEY,
- PackageModuleFactory.getID(archives[i], true));
+ PackageModuleFactory.getStamp(archives[i], true));
}
}
return requiresSave;
Modified:
trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/PackageModuleFactory.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/PackageModuleFactory.java 2008-09-11
19:45:22 UTC (rev 10207)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/PackageModuleFactory.java 2008-09-11
23:46:04 UTC (rev 10208)
@@ -96,8 +96,8 @@
* @param pack
* @return
*/
- public static String getID(IArchive pack) {
- return getID(pack, false);
+ protected static String getStamp(IArchive pack) {
+ return getStamp(pack, false);
}
/**
@@ -107,14 +107,30 @@
* @param create
* @return
*/
- protected static String getID(IArchive pack, boolean create) {
+ protected static String getStamp(IArchive pack, boolean create) {
String propVal = pack.getProperty(MODULE_ID_PROPERTY_KEY);
if( propVal == null && create ) {
- return "" + new Date().getTime();
+ propVal = "" + new Date().getTime();
}
return propVal;
}
+ protected static String getId(IArchive pack) {
+ IPath p = pack.getModelRootNode().getDescriptor().append(getStamp(pack));
+ return p.toString();
+ }
+
+ public IModule findModule(String id) {
+ IModule m = super.findModule(id);
+ IModule[] allModules = getModules();
+ for( int i = 0; i < allModules.length; i++ ) {
+ Path p = new Path( allModules[i].getId() );
+ if( p.lastSegment().equals(id))
+ return allModules[i];
+ }
+ return m;
+ }
+
/**
* Return the name of the project in the workspace
* @param node
@@ -151,7 +167,7 @@
}
protected IModule createModule2(IArchive pack, IProject project) {
- return createModule(getID(pack), getName(pack), MODULE_TYPE, VERSION, project);
+ return createModule(getId(pack), getName(pack), MODULE_TYPE, VERSION, project);
}
public IModule[] getModules(IProject project) {
Show replies by date