Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 63634 Details for
Bug 173314
[relengtool] Update tools to handle multiple versions of plug-ins in map files
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
patch for releng.tools
173314.txt (text/plain), 65.89 KB, created by
DJ Houghton
on 2007-04-12 13:19:25 EDT
(
hide
)
Description:
patch for releng.tools
Filename:
MIME Type:
Creator:
DJ Houghton
Created:
2007-04-12 13:19:25 EDT
Size:
65.89 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.releng.tools >Index: src/org/eclipse/releng/tools/TagMap.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.releng.tools/src/org/eclipse/releng/tools/TagMap.java,v >retrieving revision 1.10 >diff -u -r1.10 TagMap.java >--- src/org/eclipse/releng/tools/TagMap.java 10 Apr 2007 15:54:52 -0000 1.10 >+++ src/org/eclipse/releng/tools/TagMap.java 12 Apr 2007 17:19:38 -0000 >@@ -24,7 +24,7 @@ > * Tags the versions in a map file with another tag > */ > public class TagMap extends TagInRepositoryAction { >- >+ > /* (non-Javadoc) > * @see org.eclipse.team.internal.ccvs.ui.actions.CVSAction#getSelectedCVSResources() > */ >@@ -34,7 +34,7 @@ > for (int i = 0; i < resources.length; i++) { > IResource resource = resources[i]; > try { >- String[] strings = LoadMap.readReferenceStrings((IFile)resource); >+ String[] strings = LoadMap.readReferenceStrings((IFile) resource); > identifiers.addAll(Arrays.asList(strings)); > } catch (CoreException e) { > RelEngPlugin.log(e); >@@ -57,11 +57,12 @@ > try { > String repo = tokenizer.nextToken(); > ICVSRepositoryLocation storedlocation = getLocationFromString(repo); >- ICVSRepositoryLocation location = (ICVSRepositoryLocation)previouslySelectedRepositories.get(storedlocation); >+ ICVSRepositoryLocation location = (ICVSRepositoryLocation) previouslySelectedRepositories.get(storedlocation); > if (location == null) { > location = getWritableRepositoryLocation(storedlocation); > previouslySelectedRepositories.put(storedlocation, location); >- if (location == null) return new ICVSRemoteResource[0]; >+ if (location == null) >+ return new ICVSRemoteResource[0]; > } > String module = tokenizer.nextToken(); > tokenizer.nextToken(); /* project name */ >@@ -72,12 +73,12 @@ > } > result.add(location.getRemoteFolder(module, tag)); > } catch (CVSException e) { >- RelEngPlugin.log(e); >+ RelEngPlugin.log(e); > } > } > return (ICVSRemoteResource[]) result.toArray(new ICVSRemoteResource[result.size()]); > } >- >+ > private ICVSRepositoryLocation getLocationFromString(String repo) throws CVSException { > // create the new location > ICVSRepositoryLocation newLocation = CVSRepositoryLocation.fromString(repo); >@@ -86,16 +87,13 @@ > ICVSRepositoryLocation[] locations = CVSProviderPlugin.getPlugin().getKnownRepositories(); > for (int i = 0; i < locations.length; i++) { > ICVSRepositoryLocation location = locations[i]; >- if (location.getMethod() == newLocation.getMethod() >- && location.getHost().equals(newLocation.getHost()) >- && location.getPort() == newLocation.getPort() >- && location.getRootDirectory().equals(newLocation.getRootDirectory())) >- return location; >+ if (location.getMethod() == newLocation.getMethod() && location.getHost().equals(newLocation.getHost()) && location.getPort() == newLocation.getPort() && location.getRootDirectory().equals(newLocation.getRootDirectory())) >+ return location; > } > } > return newLocation; > } >- >+ > private ICVSRepositoryLocation getWritableRepositoryLocation(ICVSRepositoryLocation storedLocation) { > // Find out which repo locations are appropriate > ICVSRepositoryLocation[] locations = CVSUIPlugin.getPlugin().getRepositoryManager().getKnownRepositoryLocations(); >@@ -103,23 +101,30 @@ > for (int i = 0; i < locations.length; i++) { > ICVSRepositoryLocation location = locations[i]; > // Only locations with the same host and root are eligible >- if (!location.getHost().equals(storedLocation.getHost())) continue; >- if (!location.getRootDirectory().equals(storedLocation.getRootDirectory())) continue; >+ if (!location.getHost().equals(storedLocation.getHost())) >+ continue; >+ if (!location.getRootDirectory().equals(storedLocation.getRootDirectory())) >+ continue; > compatibleLocations.add(location); > } > RepositorySelectionDialog dialog = new RepositorySelectionDialog(getShell()); >- dialog.setLocations((ICVSRepositoryLocation[])compatibleLocations.toArray(new ICVSRepositoryLocation[compatibleLocations.size()])); >+ dialog.setLocations((ICVSRepositoryLocation[]) compatibleLocations.toArray(new ICVSRepositoryLocation[compatibleLocations.size()])); > dialog.open(); > ICVSRepositoryLocation location = dialog.getLocation(); > return location; > } >- >+ > /* (non-Javadoc) > * @see org.eclipse.team.internal.ui.actions.TeamAction#isEnabled() > */ > public boolean isEnabled() { > IResource[] resources = getSelectedResources(); >- return (resources.length >= 0 && MapProject.getDefaultMapProject().mapsAreLoaded()); >+ if (resources.length <= 0) >+ return false; >+ for (int i = 0; i < resources.length; i++) >+ if (MapProject.getDefaultMapProject().getMapEntry(resources[i].getProject()) == null) >+ return false; >+ return true; > } > > } >Index: src/org/eclipse/releng/tools/MapEntry.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.releng.tools/src/org/eclipse/releng/tools/MapEntry.java,v >retrieving revision 1.6 >diff -u -r1.6 MapEntry.java >--- src/org/eclipse/releng/tools/MapEntry.java 10 Apr 2007 15:51:59 -0000 1.6 >+++ src/org/eclipse/releng/tools/MapEntry.java 12 Apr 2007 17:19:38 -0000 >@@ -35,45 +35,46 @@ > private OrderedMap arguments = new OrderedMap(); > private boolean legacy = false; > private String version; >+ private MapFile file; > >- public static void main (String[] args) { >+ public static void main(String[] args) { > // For testing only >- >- String[] strings = { >- "", >- " ", >- "type", >- "type@", >- "type@id", >- "type@id=", >- "type@id=tag,", >- "type@id=tag, connectString", >- "type@id=tag, connectString,", >- "type@id=tag, connectString,password", >- "type@id=tag, connectString,password,", >- "type@id=tag, connectString,password,moduleName", >- "type@id=tag, connectString,,moduleName", >- "!*************** FEATURE CONTRIBUTION ******************************************************", >- "@", >- "=", >- ",,,", >- "@=,,,,", >- "type@id,version=CVS,tag=myTag,cvsRoot=myCvsRoot,password=password,path=myPath", >+ >+ String[] strings = { // >+ "", // >+ " ", // >+ "type", // >+ "type@", // >+ "type@id", // >+ "type@id=", // >+ "type@id=tag,", // >+ "type@id=tag, connectString", // >+ "type@id=tag, connectString,", // >+ "type@id=tag, connectString,password", // >+ "type@id=tag, connectString,password,", // >+ "type@id=tag, connectString,password,moduleName", // >+ "type@id=tag, connectString,,moduleName", // >+ "!*************** FEATURE CONTRIBUTION ******************************************************", // >+ "@", // >+ "=", // >+ ",,,", // >+ "@=,,,,", // >+ "type@id,version=CVS,tag=myTag,cvsRoot=myCvsRoot,password=password,path=myPath", // > }; >- >+ > for (int i = 0; i < strings.length; i++) { > String string = strings[i]; >- MapEntry anEntry = new MapEntry(string); >+ MapEntry anEntry = new MapEntry(string, null); > > System.out.println("-----------------------------------------------"); > System.out.println("input: " + string); > System.out.println("map string: " + anEntry.getMapString()); >-// System.out.println(anEntry.getReferenceString()); >+ // System.out.println(anEntry.getReferenceString()); > anEntry.display(); > } >- >+ > } >- >+ > /** > * > */ >@@ -89,28 +90,45 @@ > System.out.println("Password: " + getPassword()); > System.out.println("CVS Module: " + getCVSModule()); > } >- >- public MapEntry(String entryLine) { >+ >+ /* >+ * Return a new MapEntry object based on the given line from a Map >+ * file. If the line isn't a valid entry (comment, unknown fetch type, etc) >+ * then return null. >+ */ >+ public static MapEntry parse(String line, MapFile file) { >+ MapEntry result = new MapEntry(line, file); >+ return result.isValid() ? result : null; >+ } >+ >+ private MapEntry(String entryLine, MapFile file) { >+ this.file = file; > init(entryLine); > } > >+ public MapFile getFile() { >+ return file; >+ } >+ > /** > * Parse a map file entry line > * @param entryLine >- */ >+ */ > private void init(String entryLine) { > valid = false; >- >+ > // Type > int start = 0; > int end = entryLine.indexOf('@'); >- if (end == -1) return; >+ if (end == -1) >+ return; > type = entryLine.substring(start, end).trim(); >- >+ > // Project Name > start = end + 1; > end = entryLine.indexOf('=', start); >- if (end == -1) return; >+ if (end == -1) >+ return; > id = entryLine.substring(start, end).trim(); > // we have a version that we have to strip off > int comma = id.indexOf(','); >@@ -134,13 +152,17 @@ > */ > private OrderedMap populate(String[] entries) { > OrderedMap result = new OrderedMap(); >- for (int i=0; i<entries.length; i++) { >+ for (int i = 0; i < entries.length; i++) { > String entry = entries[i]; > int index = entry.indexOf('='); > if (index == -1) { >- // we only handle CVS entries >- if (i == 0 && "CVS".equalsIgnoreCase(entry)) >- continue; >+ if (RelEngPlugin.isValidFetchCommand(entry)) { >+ // we only handle CVS entries >+ if (i == 0 && "CVS".equalsIgnoreCase(entry)) >+ continue; >+ // if we have GET or something then just return >+ return result; >+ } > // legacy story... > return legacyPopulate(entries); > } >@@ -151,7 +173,7 @@ > result.toString(); > return result; > } >- >+ > private OrderedMap legacyPopulate(String[] entries) { > legacy = true; > OrderedMap result = new OrderedMap(); >@@ -161,11 +183,11 @@ > result.put(KEY_TAG, entries[0]); > // Repo Connect String > result.put(KEY_CVSROOT, entries[1]); >- >+ > // Optional Password. > if (entries.length >= 3) > result.put(KEY_PASSWORD, entries[2]); >- >+ > // Optional CVS Module Name > if (entries.length >= 4) > result.put(KEY_PATH, entries[3]); >@@ -203,12 +225,13 @@ > String value = (String) arguments.get(KEY_TAG); > return value == null ? EMPTY_STRING : value; > } >- >+ > public CVSTag getTag() { >- if (getTagName().equals("HEAD")) return CVSTag.DEFAULT; >+ if (getTagName().equals("HEAD")) >+ return CVSTag.DEFAULT; > return new CVSTag(getTagName(), CVSTag.VERSION); > } >- >+ > public String getPassword() { > String value = (String) arguments.get(KEY_PASSWORD); > return value == null ? EMPTY_STRING : value; >@@ -218,11 +241,11 @@ > return id; > } > >- private String internalGetCVSModule() { >+ private String internalGetCVSModule() { > String module = (String) arguments.get(KEY_PATH); > return module == null ? id : module; > } >- >+ > public String getCVSModule() { > String value = (String) arguments.get(KEY_PATH); > return value == null ? EMPTY_STRING : value; >@@ -240,9 +263,10 @@ > public boolean isValid() { > return valid; > } >- >- public String getReferenceString() { >- if (!isValid()) return null; >+ >+ public String getReferenceString() { >+ if (!isValid()) >+ return null; > // This is the format used by the CVS IProjectSerializer > String projectName = new Path(internalGetCVSModule()).lastSegment(); > return "1.0," + getRepo() + "," + internalGetCVSModule() + "," + projectName + "," + getTagName(); >@@ -278,7 +302,7 @@ > } > result.append('='); > result.append("CVS"); >- for (Iterator iter = arguments.keys().iterator(); iter.hasNext(); ) { >+ for (Iterator iter = arguments.keys().iterator(); iter.hasNext();) { > String key = (String) iter.next(); > String value = (String) arguments.get(key); > if (value != null && value.length() > 0) >@@ -293,7 +317,7 @@ > public String getVersion() { > return version; > } >- >+ > public void setPassword(String password) { > arguments.put(KEY_PASSWORD, password); > } >@@ -321,7 +345,7 @@ > public void setValid(boolean valid) { > this.valid = valid; > } >- >+ > public String toString() { > return "Entry: " + getMapString(); > } >@@ -331,54 +355,8 @@ > */ > public boolean equals(Object obj) { > if (obj instanceof MapEntry) { >- return ((MapEntry)obj).getMapString().equals(getMapString()); >+ return ((MapEntry) obj).getMapString().equals(getMapString()); > } > return super.equals(obj); > } >- >- /** >- * Return true if this map entry is mapped to the given CVS module >- * @param moduleName >- */ >- public boolean isMappedTo(String moduleName) { >- IPath entryPath = new Path(internalGetCVSModule()); >- IPath modulePath = new Path(moduleName); >- if (entryPath.segmentCount() != modulePath.segmentCount()) return false; >- for (int i = 0; i < entryPath.segmentCount(); i++) { >- if (!entryPath.segment(i).equals(modulePath.segment(i))) { >- return false; >- } >- } >- return true; >- } >- >- /** >- * Return <code>true</code> if the entry is mapped to the given project >- * and <code>false</code> otherwise. >- */ >- public boolean isMappedTo(IProject project) { >- String moduleName; >- try { >- moduleName = getCVSModule(project); >- if (moduleName == null) return false; >- return isMappedTo(moduleName); >- } catch (CVSException e) { >- RelEngPlugin.getDefault().getLog().log(e.getStatus()); >- return false; >- } >- } >- >- /** >- * Get the remote CVS module for the project or <code>null</code> >- * if the project is not a CVS project. >- */ >- private String getCVSModule(IProject project) throws CVSException { >- ICVSFolder folder = CVSWorkspaceRoot.getCVSFolderFor(project); >- FolderSyncInfo info = folder.getFolderSyncInfo(); >- if (info == null) { >- return null; >- } >- return info.getRepository(); >- } >- > } >Index: src/org/eclipse/releng/tools/MapContentDocument.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.releng.tools/src/org/eclipse/releng/tools/MapContentDocument.java,v >retrieving revision 1.3 >diff -u -r1.3 MapContentDocument.java >--- src/org/eclipse/releng/tools/MapContentDocument.java 1 Dec 2005 21:16:42 -0000 1.3 >+++ src/org/eclipse/releng/tools/MapContentDocument.java 12 Apr 2007 17:19:38 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2005 IBM Corporation and others. >+ * Copyright (c) 2000, 2007 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -10,13 +10,7 @@ > *******************************************************************************/ > package org.eclipse.releng.tools; > >-import java.io.BufferedInputStream; >-import java.io.BufferedReader; >-import java.io.ByteArrayInputStream; >-import java.io.IOException; >-import java.io.InputStream; >-import java.io.InputStreamReader; >- >+import java.io.*; > import org.eclipse.compare.IStreamContentAccessor; > import org.eclipse.compare.ITypedElement; > import org.eclipse.core.resources.IProject; >@@ -25,14 +19,18 @@ > import org.eclipse.team.internal.ccvs.core.CVSException; > import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; > >- >-public class MapContentDocument implements ITypedElement, IStreamContentAccessor{ >+/* >+ * TODO Its a shame that we use Strings here and it isn't backed by real MapEntry objects >+ * but in order to do this we need to make changes outside of the MapEntryRegistry and then >+ * commit them once the user commits the map file changes to the file-system. >+ */ >+public class MapContentDocument implements ITypedElement, IStreamContentAccessor { > private MapFile mapFile; > private String oldContents = ""; > private String newContents = ""; > > public MapContentDocument(MapFile aMapFile) { >- mapFile = aMapFile; >+ mapFile = aMapFile; > initialize(); > } > >@@ -40,23 +38,21 @@ > * Update the tag associated with the given project in the new contents. > */ > public void updateTag(IProject project, String tag) throws CVSException { >- InputStream inputStream = new BufferedInputStream( >- new ByteArrayInputStream(newContents.getBytes())); >+ MapEntry realEntry = mapFile.getMapEntry(project); >+ if (realEntry == null) >+ return; >+ String mapString = realEntry.getMapString(); >+ InputStream inputStream = new BufferedInputStream(new ByteArrayInputStream(newContents.getBytes())); > boolean match = false; > StringBuffer buffer = new StringBuffer(); > try { >- BufferedReader aReader = new BufferedReader(new InputStreamReader( >- inputStream)); >+ BufferedReader aReader = new BufferedReader(new InputStreamReader(inputStream)); > String aLine = aReader.readLine(); > while (aLine != null) { > if (aLine.trim().length() != 0 && !aLine.startsWith("!")) { > // Found a possible match >- MapEntry entry = new MapEntry(aLine); >- if (!entry.isValid()) { >- throw new CVSException("Malformed map file line: " >- + aLine); >- } >- if (entry.isMappedTo(project)) { >+ MapEntry entry = MapEntry.parse(aLine, mapFile); >+ if (entry != null && mapString.equals(entry.getMapString())) { > // Now for sure we have a match. Replace the line. > entry.setTagName(tag); > aLine = entry.getMapString(); >@@ -69,8 +65,6 @@ > buffer.append(System.getProperty("line.separator")); //$NON-NLS-1$ > } > } >- } catch (CoreException e) { >- throw CVSException.wrapException(e); > } catch (IOException e) { > throw CVSException.wrapException(e); > } finally { >@@ -78,6 +72,7 @@ > try { > inputStream.close(); > } catch (IOException e) { >+ // ignore > } > } > } >@@ -85,9 +80,11 @@ > newContents = buffer.toString(); > } > } >+ > public boolean isChanged() { > return !(oldContents.equals(newContents)); > } >+ > /* > * (non-Javadoc) > * >@@ -96,6 +93,7 @@ > public String getName() { > return mapFile.getFile().getName(); > } >+ > /* > * (non-Javadoc) > * >@@ -104,6 +102,7 @@ > public Image getImage() { > return null; > } >+ > /* > * (non-Javadoc) > * >@@ -112,6 +111,7 @@ > public String getType() { > return mapFile.getFile().getFileExtension(); > } >+ > /* > * (non-Javadoc) > * >@@ -120,20 +120,21 @@ > public InputStream getContents() throws CoreException { > return new ByteArrayInputStream(getNewContent().getBytes()); > } >+ > public MapFile getMapFile() { > return mapFile; > } >- >+ > private String getNewContent() { > return newContents; > } >+ > private void initialize() { > InputStream inputStream; > StringBuffer buffer = new StringBuffer(); > try { > inputStream = mapFile.getFile().getContents(); >- BufferedReader aReader = new BufferedReader(new InputStreamReader( >- inputStream)); >+ BufferedReader aReader = new BufferedReader(new InputStreamReader(inputStream)); > String aLine = aReader.readLine(); > while (aLine != null) { > buffer.append(aLine); >Index: src/org/eclipse/releng/tools/ReplaceLocalFromMap.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.releng.tools/src/org/eclipse/releng/tools/ReplaceLocalFromMap.java,v >retrieving revision 1.8 >diff -u -r1.8 ReplaceLocalFromMap.java >--- src/org/eclipse/releng/tools/ReplaceLocalFromMap.java 10 Apr 2007 15:54:52 -0000 1.8 >+++ src/org/eclipse/releng/tools/ReplaceLocalFromMap.java 12 Apr 2007 17:19:38 -0000 >@@ -40,11 +40,12 @@ > * @throws CVSException > */ > protected CVSTag getTag(IResource resource) { >- MapEntry entry = MapProject.getDefaultMapProject().getMapEntry((IProject)resource); >- if (entry == null) return CVSTag.DEFAULT; >+ MapEntry entry = MapProject.getDefaultMapProject().getMapEntry((IProject) resource); >+ if (entry == null) >+ return CVSTag.DEFAULT; > return entry.getTag(); > } >- >+ > /** > * @see org.eclipse.team.internal.ccvs.ui.actions.WorkspaceAction#isEnabledForAddedResources() > */ >@@ -58,7 +59,7 @@ > protected boolean isEnabledForNonExistantResources() { > return true; > } >- >+ > /** > * @see org.eclipse.team.internal.ccvs.ui.actions.WorkspaceAction#isEnabledForCVSResource(org.eclipse.team.internal.ccvs.core.ICVSResource) > */ >@@ -70,7 +71,8 @@ > if (info != null && info.getTag() != null) { > String revision = info.getRevision(); > String tag = info.getTag().getName(); >- if (revision.equals(tag)) return false; >+ if (revision.equals(tag)) >+ return false; > } > } > return true; >@@ -78,7 +80,7 @@ > return false; > } > } >- >+ > /** > * Returns true if the super would enable the option *and* > * only projects are selected. There is no concept of "releasing" >@@ -87,21 +89,19 @@ > * @see org.eclipse.team.internal.ui.actions.TeamAction#isEnabled() > */ > public boolean isEnabled() { >- >- boolean result = super.isEnabled(); >- if (!result) { >+ if (!super.isEnabled()) > return false; >- } >- >+ > IResource[] resources = super.getSelectedResources(); > for (int i = 0; i < resources.length; i++) { > IResource resource = resources[i]; >- if (resource.getType() != IResource.PROJECT) { >+ if (resource.getType() != IResource.PROJECT) >+ return false; >+ if (MapProject.getDefaultMapProject().getMapEntry((IProject) resource) == null) > return false; >- } > } >- >- return (getMapProject() != null && getMapProject().mapsAreLoaded()); >+ >+ return true; > } > > /* (non-Javadoc) >@@ -111,24 +111,21 @@ > monitor.beginTask(null, 100 * resources.length); > for (int i = 0; i < resources.length; i++) { > IResource resource = resources[i]; >- new ReplaceOperation(getTargetPart(), new IResource[] { resource }, getTag(resource), true).run(new SubProgressMonitor(monitor, 100)); >+ new ReplaceOperation(getTargetPart(), new IResource[] {resource}, getTag(resource), true).run(new SubProgressMonitor(monitor, 100)); > } > monitor.done(); > } >- private MapProject getMapProject(){ >- return MapProject.getDefaultMapProject(); >- } > > /* (non-Javadoc) > * @see org.eclipse.team.internal.ccvs.ui.actions.CVSAction#execute(org.eclipse.jface.action.IAction) > */ > protected void execute(IAction action) throws InvocationTargetException, InterruptedException { >- >+ > final IResource[][] resources = new IResource[][] {null}; > run(new IRunnableWithProgress() { > public void run(IProgressMonitor monitor) throws InterruptedException, InvocationTargetException { > try { >- monitor.beginTask(null, 100); >+ monitor.beginTask(null, 100); > resources[0] = checkOverwriteOfDirtyResources(getSelectedResources(), new InfiniteSubProgressMonitor(monitor, 100)); > } catch (TeamException e) { > throw new InvocationTargetException(e); >@@ -137,9 +134,10 @@ > } > } > }, false /* cancelable */, PROGRESS_BUSYCURSOR); >- >- if (resources[0] == null || resources[0].length == 0) return; >- >+ >+ if (resources[0] == null || resources[0].length == 0) >+ return; >+ > run(new IRunnableWithProgress() { > public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { > try { >@@ -149,6 +147,6 @@ > } > } > }, true, PROGRESS_DIALOG); >- >+ > } > } >Index: src/org/eclipse/releng/tools/RelEngPlugin.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.releng.tools/src/org/eclipse/releng/tools/RelEngPlugin.java,v >retrieving revision 1.5 >diff -u -r1.5 RelEngPlugin.java >--- src/org/eclipse/releng/tools/RelEngPlugin.java 1 Dec 2005 21:16:42 -0000 1.5 >+++ src/org/eclipse/releng/tools/RelEngPlugin.java 12 Apr 2007 17:19:38 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2005 IBM Corporation and others. >+ * Copyright (c) 2000, 2007 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -8,17 +8,12 @@ > * Contributors: > * IBM Corporation - initial API and implementation > *******************************************************************************/ >- > package org.eclipse.releng.tools; > >-import java.util.MissingResourceException; >-import java.util.ResourceBundle; >- >+import java.util.*; > import org.eclipse.core.resources.IWorkspace; > import org.eclipse.core.resources.ResourcesPlugin; >-import org.eclipse.core.runtime.CoreException; >-import org.eclipse.core.runtime.IStatus; >-import org.eclipse.core.runtime.Status; >+import org.eclipse.core.runtime.*; > import org.eclipse.ui.plugin.AbstractUIPlugin; > > /** >@@ -36,6 +31,7 @@ > private static RelEngPlugin plugin; > //Resource bundle. > private ResourceBundle resourceBundle; >+ private static Set fetchCommands; > > /** > * The constructor. >@@ -121,7 +117,32 @@ > } > return plugin; > } >- >+ >+ /* >+ * Return true if the given string is a valid fetch command >+ * and false otherwise. CVS and GET come with Eclipse by default. >+ */ >+ public static boolean isValidFetchCommand(String command) { >+ if (fetchCommands == null) { >+ IExtensionPoint extpt = Platform.getExtensionRegistry().getExtensionPoint("org.eclipse.pde.build.fetchFactories"); >+ if (extpt == null) >+ return false; >+ fetchCommands = new HashSet(); >+ IExtension[] extensions = extpt.getExtensions(); >+ for (int i=0; i<extensions.length; i++) { >+ IExtension ext = extensions[i]; >+ IConfigurationElement[] configs = ext.getConfigurationElements(); >+ for (int j=0; j<configs.length; j++) { >+ IConfigurationElement config = configs[j]; >+ String id = config.getAttribute("id"); >+ if (id != null) >+ fetchCommands.add(id); >+ } >+ } >+ } >+ return fetchCommands.contains(command); >+ } >+ > /** > * The following code is a sample of how to assign a > * RelEng nature to a project. This only ever needed >Index: src/org/eclipse/releng/tools/MapFile.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.releng.tools/src/org/eclipse/releng/tools/MapFile.java,v >retrieving revision 1.5 >diff -u -r1.5 MapFile.java >--- src/org/eclipse/releng/tools/MapFile.java 10 Apr 2007 15:52:00 -0000 1.5 >+++ src/org/eclipse/releng/tools/MapFile.java 12 Apr 2007 17:19:38 -0000 >@@ -10,49 +10,50 @@ > *******************************************************************************/ > package org.eclipse.releng.tools; > >-import java.io.BufferedReader; >-import java.io.IOException; >-import java.io.InputStream; >-import java.io.InputStreamReader; >+import java.io.*; > import java.util.*; >- >-import org.eclipse.core.resources.IFile; >-import org.eclipse.core.resources.IProject; >-import org.eclipse.core.resources.ResourcesPlugin; >-import org.eclipse.core.runtime.CoreException; >-import org.eclipse.core.runtime.IStatus; >-import org.eclipse.core.runtime.Status; >+import org.eclipse.core.resources.*; >+import org.eclipse.core.runtime.*; >+import org.eclipse.osgi.util.ManifestElement; >+import org.osgi.framework.*; > > public class MapFile { > > public static final String MAP_FILE_EXTENSION = "map"; > > protected IFile file; >- protected MapEntry[] entries; >+ // entries in the files...mixed Strings and MapEntry >+ protected List entries = new ArrayList(); > >+ /* >+ * Constructor for the class. Create a new map file on the given >+ * workspace file with the specified parent project. >+ */ > public MapFile(IFile aFile) throws CoreException { > file = aFile; > loadEntries(); > } > >+ /* >+ * Return the workspace file associated with this map file. >+ */ > public IFile getFile(){ > return file; > } > >+ /* >+ * Load this map file's contents. Populate the entry list. >+ */ > protected void loadEntries() throws CoreException { > InputStream inputStream = null; >- List list = new ArrayList(); >- > try { > inputStream = file.getContents(); >- BufferedReader aReader = new BufferedReader(new InputStreamReader( >- inputStream)); >- String aLine = aReader.readLine(); >- while (aLine != null) { >- if (isMapLine(aLine)) { >- list.add(new MapEntry(aLine)); >- } >- aLine = aReader.readLine(); >+ BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); >+ String lline = reader.readLine(); >+ while (lline != null) { >+ MapEntry entry = MapEntry.parse(lline, this); >+ entries.add(entry == null ? (Object) lline : entry); >+ lline = reader.readLine(); > } > } catch (IOException e) { > throw new CoreException(new Status(IStatus.ERROR, RelEngPlugin.ID, 0, "An I/O Error occurred process map file " + file.getFullPath().toString(), e)); >@@ -65,53 +66,189 @@ > } > } > } >- >- this.entries = (MapEntry[]) list.toArray(new MapEntry[list.size()]); >- } >- >- private boolean isMapLine(String line) { >- if (line.trim().length() == 0) return false; >- if (line.startsWith("!")) return false; >- return true; > } >- >- public boolean contains(IProject project){ >- for(int j = 0;j < entries.length; j++){ >- if (entries[j].isMappedTo(project)){ >- return true; >- } >+ >+ /* >+ * Return a boolean value indicating whether or not this map file >+ * contains a valid map file entry for the given project. >+ */ >+ public boolean contains(IProject project) { >+ return getMapEntry(project) != null; >+ } >+ >+ /* >+ * Return all of the map file entries registered for the given project. >+ */ >+ private List getAll(IProject project) { >+ List result = new ArrayList(); >+ if (entries == null || entries.size() == 0) >+ return result; >+ for (Iterator iter = entries.iterator(); iter.hasNext();) { >+ Object next = iter.next(); >+ if (next instanceof String) >+ continue; >+ MapEntry entry = (MapEntry) next; >+ if (entry.getId().equals(project.getName())) >+ result.add(entry); > } >- return false; >+ return result; > } > >+ /* >+ * Return the map entry for the given project, or null >+ * if there isn't a match. Note that it only returns an entry >+ * if it is a member of this map file. >+ */ > public MapEntry getMapEntry(IProject project) { >- for(int j = 0;j < entries.length; j++){ >- if (entries[j].isMappedTo(project)){ >- return entries[j]; >+ List mapEntries = getAll(project); >+ int count = mapEntries.size(); >+ if (mapEntries == null || count == 0) >+ return null; >+ if (count == 1) >+ return (MapEntry) mapEntries.get(0); >+ >+ // get the version from the project >+ Version projectVersion = getVersion(project); >+ if (projectVersion == null) >+ return null; >+ // check for an exact match, also keep track if we have a null version entry >+ MapEntry nullEntry = null; >+ for (Iterator iter = mapEntries.iterator(); iter.hasNext();) { >+ MapEntry entry = (MapEntry) iter.next(); >+ Version entryVersion = entry.getVersion() == null ? null : new Version(entry.getVersion()); >+ // we have an exact match >+ if (projectVersion.equals(entryVersion)) >+ return entry; >+ if (entryVersion == null) >+ nullEntry = entry; >+ } >+ // we didn't have an exact match but there was an entry in the file >+ // with a null version so return it >+ if (nullEntry != null) >+ return nullEntry; >+ // otherwise try and guess the best version >+ return bestMatch(projectVersion, mapEntries); >+ } >+ >+ /* >+ * Try and determine the version of the given project by looking >+ * in its manifest file. >+ */ >+ private Version getVersion(IProject project) { >+ // sort and pick the best based on version >+ // get the version from the project >+ IFile manifest = project.getFile(new Path("META-INF/MANIFEST.MF")); >+ // we can't find the manifest file so we can't determine the version in the workspace >+ // TODO we could try and parse the plugin.xml if one exists >+ if (!manifest.exists()) >+ return null; >+ String versionString = null; >+ try { >+ Map map = ManifestElement.parseBundleManifest(manifest.getContents(), null); >+ versionString = (String) map.get(Constants.BUNDLE_VERSION); >+ } catch (IOException e) { >+ e.printStackTrace(); >+ return null; >+ } catch (BundleException e) { >+ e.printStackTrace(); >+ return null; >+ } catch (CoreException e) { >+ e.printStackTrace(); >+ return null; >+ } >+ if (versionString == null) >+ return null; >+ Version projectVersion = new Version(versionString); >+ // TODO for now we strip off the qualifier >+ return new Version(projectVersion.getMajor(), projectVersion.getMinor(), projectVersion.getMicro(), null); >+ } >+ >+ /* >+ * Return the best map file entry match for the given version. >+ */ >+ private MapEntry bestMatch(Version version, List mapEntries) { >+ MapEntry result = null; >+ Version resultVersion = null; >+ for (Iterator iter = mapEntries.iterator(); iter.hasNext();) { >+ MapEntry entry = (MapEntry) iter.next(); >+ String versionString = entry.getVersion(); >+ if (versionString == null) >+ return entry; >+ Version entryVersion = new Version(versionString); >+ // we require at least... >+ int comparison = entryVersion.compareTo(version); >+ if (comparison < 0) >+ continue; >+ // we should have already handled the equals case but >+ // in case we didn't... >+ if (comparison == 0) >+ return entry; >+ // grab the latest version >+ if (result == null || entryVersion.compareTo(resultVersion) > 0) { >+ result = entry; >+ resultVersion = entryVersion; >+ continue; > } > } >- return null; >+ return result; > } > >+ /* >+ * Return an array of accessible workspace projects for this map file. >+ */ > public IProject[] getAccessibleProjects() { >+ if (entries == null || entries.size() == 0) >+ return null; > Set list = new HashSet(); > IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects(); >- if(entries == null || entries.length ==0) return null; > for (int i = 0; i < projects.length; i++) { >- IProject project = projects[i]; >- if (project.isAccessible()) { >- for (int j = 0; j < entries.length; j++){ >- if (entries[j].isMappedTo(project)) { >- list.add(project); >- } >- } >+ IProject workspaceProject = projects[i]; >+ if (workspaceProject.isAccessible()) { >+ MapEntry entry = getMapEntry(workspaceProject); >+ if (entry != null) >+ list.add(workspaceProject); > } > } >- return (IProject[])list.toArray(new IProject[list.size()]); >+ return (IProject[]) list.toArray(new IProject[list.size()]); >+ } >+ >+ /* (non-Javadoc) >+ * @see java.lang.Object#equals(java.lang.Object) >+ */ >+ public boolean equals(Object obj) { >+ if (!(obj instanceof MapFile)) >+ return false; >+ return getFile().equals(((MapFile) obj).getFile()); >+ } >+ >+ /* (non-Javadoc) >+ * @see java.lang.Object#hashCode() >+ */ >+ public int hashCode() { >+ return file.hashCode(); > } > >+ /* >+ * Return the simple name of this map file's workspace file. >+ */ > public String getName() { > return file.getName(); > } > >+ /* >+ * Return a string representation of this map file. >+ */ >+ public String getContents() { >+ StringBuffer buffer = new StringBuffer(); >+ for (Iterator iter = entries.iterator(); iter.hasNext();) { >+ Object obj = iter.next(); >+ if (obj instanceof String) >+ buffer.append(obj); >+ else >+ buffer.append(((MapEntry) obj).getMapString()); >+ if (iter.hasNext()) >+ buffer.append(System.getProperty("line.separator")); //$NON-NLS-1$ >+ } >+ return buffer.toString(); >+ } > } >Index: src/org/eclipse/releng/tools/ProjectSelectionPage.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.releng.tools/src/org/eclipse/releng/tools/ProjectSelectionPage.java,v >retrieving revision 1.6 >diff -u -r1.6 ProjectSelectionPage.java >--- src/org/eclipse/releng/tools/ProjectSelectionPage.java 1 Dec 2005 21:16:42 -0000 1.6 >+++ src/org/eclipse/releng/tools/ProjectSelectionPage.java 12 Apr 2007 17:19:38 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2005 IBM Corporation and others. >+ * Copyright (c) 2000, 2007 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -11,7 +11,6 @@ > package org.eclipse.releng.tools; > > import java.util.*; >- > import org.eclipse.core.resources.IProject; > import org.eclipse.core.resources.ResourcesPlugin; > import org.eclipse.jface.dialogs.IDialogSettings; >@@ -30,7 +29,6 @@ > import org.eclipse.ui.model.WorkbenchContentProvider; > import org.eclipse.ui.model.WorkbenchLabelProvider; > >- > /** > * This class extends <code>WizardPage<code> class and use a <code>CheckboxTreeViewer<code> to > * display selectable items. >@@ -39,39 +37,39 @@ > private CheckboxTreeViewer viewer; > private IDialogSettings settings; > private Button compareButton; >- private boolean compareButtonChecked; >+ private boolean compareButtonChecked; > private String SELECTED_ITEMS_KEY = Messages.getString("ProjectSelectionPage.0"); //$NON-NLS-1$ > private String COMPARE_BUTTON_KEY = Messages.getString("ProjectSelectionPage.1"); //$NON-NLS-1$ > private MapProject mapProject; > > private class MapFileLabelProvider extends LabelProvider { > WorkbenchLabelProvider provider = new WorkbenchLabelProvider(); >+ > public String getText(Object element) { > if (element instanceof MapFile) { >- return ((MapFile)element).getName(); >+ return ((MapFile) element).getName(); > } > return provider.getText(element); > } >+ > public Image getImage(Object element) { > if (element instanceof MapFile) { >- return provider.getImage(((MapFile)element).getFile()); >+ return provider.getImage(((MapFile) element).getFile()); > } > return provider.getImage(element); > } >+ > public void dispose() { > provider.dispose(); > super.dispose(); > } > } >- >- public ProjectSelectionPage(String pageName, >- String title, >- IDialogSettings settings, >- ImageDescriptor image) { >+ >+ public ProjectSelectionPage(String pageName, String title, IDialogSettings settings, ImageDescriptor image) { > super(pageName, title, image); > this.settings = settings; > } >- >+ > /* > * (non-Javadoc) > * >@@ -79,32 +77,31 @@ > */ > public void createControl(Composite parent) { > Font font = parent.getFont(); >- >+ > Composite topContainer = new Composite(parent, SWT.NONE); > topContainer.setLayout(new GridLayout()); > topContainer.setLayoutData(new GridData(GridData.FILL_BOTH)); >- >+ > Label label = new Label(topContainer, SWT.HORIZONTAL); > label.setFont(font); > label.setText(Messages.getString("ProjectSelectionPage.2")); //$NON-NLS-1$ >- >- viewer = new ContainerCheckedTreeViewer(topContainer, SWT.SINGLE | SWT.H_SCROLL >- | SWT.V_SCROLL | SWT.BORDER); >- GridData gd= new GridData(GridData.FILL_BOTH); >- gd.heightHint= viewer.getTree().getItemHeight() * 15; >+ >+ viewer = new ContainerCheckedTreeViewer(topContainer, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER); >+ GridData gd = new GridData(GridData.FILL_BOTH); >+ gd.heightHint = viewer.getTree().getItemHeight() * 15; > viewer.getTree().setLayoutData(gd); > viewer.getTree().setFont(font); > viewer.setLabelProvider(new MapFileLabelProvider()); > viewer.setContentProvider(getContentProvider()); > viewer.setInput(mapProject); > viewer.expandAll(); >- viewer.addCheckStateListener(new ICheckStateListener(){ >+ viewer.addCheckStateListener(new ICheckStateListener() { > public void checkStateChanged(CheckStateChangedEvent event) { >- updatePageComplete(); >+ updatePageComplete(); > } > }); >- >- compareButton = new Button(topContainer,SWT.CHECK); >+ >+ compareButton = new Button(topContainer, SWT.CHECK); > compareButton.setText(Messages.getString("ProjectSelectionPage.3")); //$NON-NLS-1$ > compareButton.setFont(font); > compareButton.addSelectionListener(new SelectionAdapter() { >@@ -112,28 +109,51 @@ > compareButtonChecked = compareButton.getSelection(); > } > }); >- >+ > initialize(); > setControl(topContainer); > } >+ > /** > * Returns the content provider for the viewer > */ > private IContentProvider getContentProvider() { > return new WorkbenchContentProvider() { > public Object[] getChildren(Object parentElement) { >+ > if (parentElement instanceof MapProject) { >- return mapProject.getValidMapFiles(); >- } >- if (parentElement instanceof MapFile) { >- return ((MapFile)parentElement).getAccessibleProjects(); >+ MapFile[] files = mapProject.getValidMapFiles(); >+ if (files == null) >+ return null; >+ Set list = new TreeSet(new Comparator() { >+ public int compare(Object o1, Object o2) { >+ String m1 = ((MapFile) o1).getName().toLowerCase(); >+ String m2 = ((MapFile) o2).getName().toLowerCase(); >+ return m1.compareTo(m2); >+ } >+ }); >+ list.addAll(Arrays.asList(files)); >+ return list.toArray(); >+ } else if (parentElement instanceof MapFile) { >+ IProject[] projects = ((MapFile) parentElement).getAccessibleProjects(); >+ if (projects == null) >+ return null; >+ Set list = new TreeSet(new Comparator() { >+ public int compare(Object o1, Object o2) { >+ String p1 = ((IProject) o1).getName().toLowerCase(); >+ String p2 = ((IProject) o2).getName().toLowerCase(); >+ return p1.compareTo(p2); >+ } >+ }); >+ list.addAll(Arrays.asList(projects)); >+ return list.toArray(); > } > return null; > } >- >+ > public boolean hasChildren(Object element) { > if (element instanceof MapFile) { >- return ((MapFile)element).getAccessibleProjects().length > 0; >+ return ((MapFile) element).getAccessibleProjects().length > 0; > } > return false; > } >@@ -143,72 +163,74 @@ > /** > * Returns all the checked items if they are IProject > */ >- public IProject[] getCheckedProjects(){ >+ public IProject[] getCheckedProjects() { > ArrayList projectsToRelease = new ArrayList(); > Object[] obj = viewer.getCheckedElements(); >- if (obj == null)return null; >- for(int i = 0; i < obj.length; i++){ >+ if (obj == null) >+ return null; >+ for (int i = 0; i < obj.length; i++) { > if (obj[i] instanceof IProject) >- projectsToRelease.add(obj[i]); >+ projectsToRelease.add(obj[i]); > } >- return (IProject[])projectsToRelease.toArray(new IProject[projectsToRelease.size()]); >- } >- >- private void readProjectSettings(){ >- if( settings == null) return; >- if(settings.getArray(SELECTED_ITEMS_KEY) != null){ >+ return (IProject[]) projectsToRelease.toArray(new IProject[projectsToRelease.size()]); >+ } >+ >+ private void readProjectSettings() { >+ if (settings == null) >+ return; >+ if (settings.getArray(SELECTED_ITEMS_KEY) != null) { > ArrayList nameList = new ArrayList(Arrays.asList(settings.getArray(SELECTED_ITEMS_KEY))); >- if(nameList != null){ >+ if (nameList != null) { > Iterator iter = nameList.iterator(); >- while(iter.hasNext()){ >- String name = (String)iter.next(); >+ while (iter.hasNext()) { >+ String name = (String) iter.next(); > IProject project = getProjectWithName(name); >- if(project != null){ >- viewer.setChecked(project,true); >- } >+ if (project != null) { >+ viewer.setChecked(project, true); >+ } > } > } > } > } >- >- private void initCompareEnablement(){ >- if( settings == null || settings.get(COMPARE_BUTTON_KEY) == null) { >- compareButton.setSelection( true); >+ >+ private void initCompareEnablement() { >+ if (settings == null || settings.get(COMPARE_BUTTON_KEY) == null) { >+ compareButton.setSelection(true); > compareButtonChecked = true; > return; >- }else{ >+ } else { > boolean b = settings.getBoolean(COMPARE_BUTTON_KEY); > compareButton.setSelection(b); > compareButtonChecked = b; > } > } >- >+ > /** > * Save the checked items and the checkbox options to dialog settings > */ >- public void saveSettings(){ >+ public void saveSettings() { > Object[] obj = viewer.getCheckedElements(); > ArrayList names = new ArrayList(); >- for (int i = 0; i < obj.length; i++){ >- if(obj[i] instanceof IProject){ >- names.add(((IProject)obj[i]).getName()); >+ for (int i = 0; i < obj.length; i++) { >+ if (obj[i] instanceof IProject) { >+ names.add(((IProject) obj[i]).getName()); > } > } >- settings.put(SELECTED_ITEMS_KEY, (String[])names.toArray(new String[names.size()])); >+ settings.put(SELECTED_ITEMS_KEY, (String[]) names.toArray(new String[names.size()])); > settings.put(COMPARE_BUTTON_KEY, compareButtonChecked); > } >- >- private void initialize(){ >+ >+ private void initialize() { > initCheckedProjects(); > initCompareEnablement(); > updatePageComplete(); > } >- >- private void initCheckedProjects(){ >- IProject[] p = ((ReleaseWizard)getWizard()).getPreSelectedProjects( ); >- if(p != null){ >+ >+ private void initCheckedProjects() { >+ IProject[] p = ((ReleaseWizard) getWizard()).getPreSelectedProjects(); >+ if (p != null) { > viewer.setCheckedElements(p); >- }else{ >+ } else { > readProjectSettings(); > } > } >@@ -216,48 +238,48 @@ > /** > * Called by <code>readSettings()<code> to return the project associated with the given name > */ >- private IProject getProjectWithName(String name){ >+ private IProject getProjectWithName(String name) { > IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(name); >- if(project.exists() && project.isAccessible()) >+ if (project.exists() && project.isAccessible()) > return project; > return null; > } > >- public boolean isCompareButtonChecked(){ >+ public boolean isCompareButtonChecked() { > return compareButtonChecked; > } >- >+ > /** > *This page will not complete until at least one project is checked > */ >- private void updatePageComplete(){ >+ private void updatePageComplete() { > Object[] obj = viewer.getCheckedElements(); >- if(obj.length > 0){ >- for(int i = 0; i < obj.length; i++){ >+ if (obj.length > 0) { >+ for (int i = 0; i < obj.length; i++) { > //Exclude the situation that an empty shown map file is selected >- if(obj[i] instanceof IProject){ >+ if (obj[i] instanceof IProject) { > setPageComplete(true); > break; > } > } >- } >- else{ >+ } else { > setPageComplete(false); > } > } >- >- private CheckboxTreeViewer getViewer(){ >+ >+ private CheckboxTreeViewer getViewer() { > return viewer; > } >- >+ > public void setSelection(IProject[] projects) { >- if(projects != null && projects.length > 0){ >- getViewer().setCheckedElements(projects); >+ if (projects != null && projects.length > 0) { >+ getViewer().setCheckedElements(projects); > } > } >- public void updateMapProject(MapProject m){ >+ >+ public void updateMapProject(MapProject m) { > mapProject = m; >- if(viewer != null){ >+ if (viewer != null) { > viewer.setInput(mapProject); > } > } >Index: src/org/eclipse/releng/tools/LoadMap.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.releng.tools/src/org/eclipse/releng/tools/LoadMap.java,v >retrieving revision 1.9 >diff -u -r1.9 LoadMap.java >--- src/org/eclipse/releng/tools/LoadMap.java 10 Apr 2007 15:54:52 -0000 1.9 >+++ src/org/eclipse/releng/tools/LoadMap.java 12 Apr 2007 17:19:38 -0000 >@@ -69,12 +69,12 @@ > List allStrings = new ArrayList(); > for (int i = 0; i < mapFiles.length; i++) { > IResource resource = mapFiles[i]; >- String[] referenceStrings = readReferenceStrings((IFile)resource); >+ String[] referenceStrings = readReferenceStrings((IFile) resource); > allStrings.addAll(Arrays.asList(referenceStrings)); > } > return (String[]) allStrings.toArray(new String[allStrings.size()]); > } >- >+ > /** > * Method readReferenceStrings. > * @param file >@@ -88,10 +88,9 @@ > String line = reader.readLine(); > List references = new ArrayList(); > while (line != null) { >- String referenceString = new MapEntry(line).getReferenceString(); >- if (referenceString != null) { >- references.add(referenceString); >- } >+ MapEntry entry = MapEntry.parse(line, null); >+ if (entry != null && entry.getReferenceString() != null) >+ references.add(entry.getReferenceString()); > line = reader.readLine(); > } > return (String[]) references.toArray(new String[references.size()]); >@@ -103,17 +102,19 @@ > } > } > >- > /** > * @see org.eclipse.team.internal.ui.actions.TeamAction#isEnabled() > */ > public boolean isEnabled() { > IResource[] resources = getSelectedResources(); >- if (resources.length == 0) return false; >+ if (resources.length == 0) >+ return false; > for (int i = 0; i < resources.length; i++) { > IResource resource = resources[i]; >- if (resource.getType() != IResource.FILE) return false; >- if (!resource.getFileExtension().equals("map")) return false; >+ if (resource.getType() != IResource.FILE) >+ return false; >+ if (!resource.getFileExtension().equals("map")) >+ return false; > } > return true; > } >Index: src/org/eclipse/releng/tools/MapProject.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.releng.tools/src/org/eclipse/releng/tools/MapProject.java,v >retrieving revision 1.9 >diff -u -r1.9 MapProject.java >--- src/org/eclipse/releng/tools/MapProject.java 10 Apr 2007 15:54:52 -0000 1.9 >+++ src/org/eclipse/releng/tools/MapProject.java 12 Apr 2007 17:19:38 -0000 >@@ -9,9 +9,9 @@ > * IBM Corporation - initial API and implementation > *******************************************************************************/ > package org.eclipse.releng.tools; >+ > import java.lang.reflect.InvocationTargetException; > import java.util.*; >- > import org.eclipse.core.resources.*; > import org.eclipse.core.runtime.CoreException; > import org.eclipse.core.runtime.IProgressMonitor; >@@ -21,12 +21,15 @@ > import org.eclipse.team.internal.ccvs.ui.operations.CommitOperation; > import org.eclipse.team.internal.ccvs.ui.operations.RepositoryProviderOperation; > >+/* >+ * This class represents a workspace project which contains map files. >+ */ > public class MapProject implements IResourceChangeListener { >- >- private static MapProject mapProject = null; >+ >+ private static MapProject mapProject; > private IProject project; > private MapFile[] mapFiles; >- >+ > /** > * Return the default map project (org.eclipse.releng) or > * <code>null</code> if the project does not exist or there >@@ -34,7 +37,7 @@ > * will be logged. > * @return the default map project > */ >- public static MapProject getDefaultMapProject(){ >+ public static MapProject getDefaultMapProject() { > if (mapProject == null) { > IProject project = getProjectFromWorkspace(); > try { >@@ -43,10 +46,9 @@ > RelEngPlugin.log(e); > } > } >- > return mapProject; > } >- >+ > private static IProject getProjectFromWorkspace() { > IWorkspace workspace = ResourcesPlugin.getWorkspace(); > IWorkspaceRoot root = workspace.getRoot(); >@@ -54,148 +56,167 @@ > return project; > } > >+ /* >+ * Create a new map project based on the given workspace project. >+ */ > public MapProject(IProject p) throws CoreException { > this.project = p; > ResourcesPlugin.getWorkspace().addResourceChangeListener(this, IResourceChangeEvent.POST_CHANGE); > loadMapFiles(); > } > >+ /* >+ * Return the workspace project represented by this map project. >+ */ > public IProject getProject() { > return project; > } >- >- public void setProject(IProject p){ >- this.project = p; >- } >- >- private MapFile getMapFile(IProject p){ >- for (int i = 0; i< mapFiles.length; i++){ >- if (mapFiles[i].contains(p)) { >- return mapFiles[i]; >- } >- } >- return null; >+ >+ /* >+ * Return the map file which contains the entry for this project. >+ */ >+ private MapFile getMapFile(IProject p) { >+ MapEntry entry = getMapEntry(p); >+ return entry == null ? null : entry.getFile(); > } >- >- /** >- * Return the MapEntry for the given project >- * @param string >- * @param string1 >+ >+ /* >+ * Return the MapEntry for the given project. Do a lookup in the registry. > */ > public MapEntry getMapEntry(IProject p) { >- MapFile file = getMapFile(p); >- if (file != null) { >- return file.getMapEntry(p); >+ if (mapFiles == null) >+ return null; >+ for (int i = 0; i < mapFiles.length; i++) { >+ MapEntry result = mapFiles[i].getMapEntry(p); >+ if (result != null) >+ return result; > } > return null; > } > >- public boolean mapsAreLoaded() { >- return project.exists(); >- } >- >- public MapFile[] getValidMapFiles(){ >+ /* >+ * Return an array of the valid map files in this project. >+ */ >+ public MapFile[] getValidMapFiles() { > List list = new ArrayList(); >- for (int i = 0; i <mapFiles.length; i++){ >- IProject[] projects = mapFiles[i].getAccessibleProjects(); >- if( projects!= null && projects.length > 0){ >+ for (int i = 0; i < mapFiles.length; i++) { >+ IProject[] projects = mapFiles[i].getAccessibleProjects(); >+ if (projects != null && projects.length > 0) { > list.add(mapFiles[i]); > } > } >- return (MapFile[])list.toArray(new MapFile[list.size()]); >+ return (MapFile[]) list.toArray(new MapFile[list.size()]); > } >- >+ >+ public MapFile[] getMapFiles() { >+ return mapFiles; >+ } >+ > /** >+ * Update the map file entry for the given workspace project, with the specified tag. >+ * > * @param aProject The map entry of the specified project will be changed to the specified tag > * @param tag The specified tag >- * @return returns if no map file having such a map entry is found > */ > public void updateFile(IProject aProject, String tag) throws CoreException { > MapFile aFile = getMapFile(aProject); >- if (aFile == null)return; >+ if (aFile == null) >+ return; > MapContentDocument changed = new MapContentDocument(aFile); > changed.updateTag(aProject, tag); > if (changed.isChanged()) { >- aFile.getFile().setContents(changed.getContents(), IFile.KEEP_HISTORY, null); >+ aFile.getFile().setContents(changed.getContents(), IResource.KEEP_HISTORY, null); > } > } >- >- public void commitMapProject(String comment, IProgressMonitor monitor) throws CoreException{ >+ >+ /* >+ * Commit our changes to CVS. >+ */ >+ public void commitMapProject(String comment, IProgressMonitor monitor) throws CoreException { > try { >- new CommitOperation(null, RepositoryProviderOperation.asResourceMappers(new IResource[] { project }), new Command.LocalOption[0], comment).run(monitor); >+ new CommitOperation(null, RepositoryProviderOperation.asResourceMappers(new IResource[] {project}), new Command.LocalOption[0], comment).run(monitor); > } catch (InvocationTargetException e) { > throw TeamException.asTeamException(e); > } catch (InterruptedException e) { > // Ignore; > } > } >- >- public MapFile[] getMapFilesFor(IProject[] projects){ >- Set alist = new HashSet(); >- for(int i = 0; i<projects.length; i++){ >+ >+ /* >+ * Return an array with the map files for the given projects. >+ */ >+ public MapFile[] getMapFilesFor(IProject[] projects) { >+ Set alist = new HashSet(); >+ for (int i = 0; i < projects.length; i++) { > MapFile aMapFile = getMapFile(projects[i]); > alist.add(aMapFile); > } >- return (MapFile[])alist.toArray(new MapFile[alist.size()]); >+ return (MapFile[]) alist.toArray(new MapFile[alist.size()]); > } > > /** > * Get the tags for the given projects. If no tag is found > * for whatever reason, HEAD is used. >+ * > * @param projects >- * @return > */ >- public CVSTag[] getTagsFor(IProject[] projects){ >- if(projects == null || projects.length == 0)return null; >+ public CVSTag[] getTagsFor(IProject[] projects) { >+ if (projects == null || projects.length == 0) >+ return null; > CVSTag[] tags = new CVSTag[projects.length]; >- for (int i = 0; i < tags.length; i++){ >+ for (int i = 0; i < tags.length; i++) { > MapEntry entry = getMapEntry(projects[i]); >- if (entry == null) tags[i] = CVSTag.DEFAULT; >- else tags[i] = entry.getTag(); >+ if (entry == null) >+ tags[i] = CVSTag.DEFAULT; >+ else >+ tags[i] = entry.getTag(); > } > return tags; > } >+ > /** >- * Deregister the IResourceChangeListner. It is reserved for use in the future. It is never called >- * for now >+ * Unregister the IResourceChangeListner. It is reserved for use in the future. It is never called >+ * for now. > */ >- public void dispose(){ >+ public void dispose() { > ResourcesPlugin.getWorkspace().removeResourceChangeListener(this); > } >- >+ > /** > * @see IResourceChangeListener#resourceChanged(IResourceChangeEvent) > */ > public void resourceChanged(IResourceChangeEvent event) { > IResourceDelta root = event.getDelta(); >- >+ > //TODO: Need to add code to handle map project deletion, addition and rename > IResourceDelta folderDelta = root.findMember(getMapFolder().getFullPath()); >- if (folderDelta == null) return; >- >+ if (folderDelta == null) >+ return; >+ > //Handle map files deletion, addition and rename > IResourceDelta[] deltas = folderDelta.getAffectedChildren(); >- if(deltas == null || deltas.length == 0) return; >+ if (deltas == null || deltas.length == 0) >+ return; > for (int i = 0; i < deltas.length; i++) { > IResourceDelta delta = deltas[i]; >- if(delta.getResource().getType() == IResource.FILE){ >- try{ >- IFile aFile = (IFile)(delta.getResource()); >+ if (delta.getResource().getType() == IResource.FILE) { >+ try { >+ IFile aFile = (IFile) (delta.getResource()); > MapFile mFile = null; >- if(isMapFile(aFile)){ >+ if (isMapFile(aFile)) { > // Handle content change >- if(delta.getKind() == IResourceDelta.CHANGED){ >+ if (delta.getKind() == IResourceDelta.CHANGED) { > mFile = getMapFileFor(aFile); >- mFile.loadEntries(); >+ mFile.loadEntries(); > } > //Handle deletion. We cannot simply remove the map file directly bacause we have to call > //getMapFileFor(IFile) in order to do so. But the IFile is already deleted. So we have to > //reconstuct the map files. >- if(delta.getKind() == IResourceDelta.REMOVED ){ >+ if (delta.getKind() == IResourceDelta.REMOVED) { > loadMapFiles(); > } > // Handle addition >- if(delta.getKind() == IResourceDelta.ADDED ){ >+ if (delta.getKind() == IResourceDelta.ADDED) { > mFile = getMapFileFor(aFile); > addMapFile(mFile); > } >@@ -207,12 +228,13 @@ > } > } > >- private IFolder getMapFolder(){ >+ private IFolder getMapFolder() { > return getProject().getFolder(RelEngPlugin.MAP_FOLDER); > } >+ > private void loadMapFiles() throws CoreException { > IFolder folder = project.getFolder(RelEngPlugin.MAP_FOLDER); >- if(!folder.exists()) { >+ if (!folder.exists()) { > mapFiles = new MapFile[0]; > return; > } >@@ -221,34 +243,45 @@ > List list = new ArrayList(); > for (int i = 0; i < resource.length; i++) { > //In case there are some sub folders >- if(resource[i].getType() == IResource.FILE){ >+ if (resource[i].getType() == IResource.FILE) { > IFile file = (IFile) resource[i]; >- if(isMapFile(file)){ >+ if (isMapFile(file)) > list.add(new MapFile(file)); >- } > } > } >- mapFiles = (MapFile[])list.toArray(new MapFile[list.size()]); >+ mapFiles = (MapFile[]) list.toArray(new MapFile[list.size()]); > } else { > mapFiles = new MapFile[0]; > } > } >- >- private MapFile getMapFileFor(IFile file) throws CoreException{ >- for(int i = 0; i < mapFiles.length; i++){ >+ >+ private MapFile getMapFileFor(IFile file) throws CoreException { >+ for (int i = 0; i < mapFiles.length; i++) { > if (mapFiles[i].getFile().equals(file)) > return mapFiles[i]; > } > return new MapFile(file); > } >- private void addMapFile(MapFile aFile){ >+ >+ private void addMapFile(MapFile aFile) { > Set set = new HashSet(Arrays.asList(mapFiles)); > set.add(aFile); >- mapFiles = (MapFile[])set.toArray(new MapFile[set.size()]); >+ mapFiles = (MapFile[]) set.toArray(new MapFile[set.size()]); > } >- private boolean isMapFile(IFile aFile){ >- String extension = aFile.getFileExtension(); >- //In case file has no extension name or is not validate map file >- return ( extension != null && extension.equals(MapFile.MAP_FILE_EXTENSION)); >+ >+ /* >+ * Return a boolean value indicating whether or not the given >+ * file is a valid map file. >+ */ >+ private boolean isMapFile(IFile file) { >+ // for now just validate based on file extension >+ return MapFile.MAP_FILE_EXTENSION.equals(file.getFileExtension()); >+ } >+ >+ /* (non-Javadoc) >+ * @see java.lang.Object#toString() >+ */ >+ public String toString() { >+ return "MapProject(" + project.getName() + ")"; > } > } >Index: src/org/eclipse/releng/tools/CompareLocalToMap.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.releng.tools/src/org/eclipse/releng/tools/CompareLocalToMap.java,v >retrieving revision 1.13 >diff -u -r1.13 CompareLocalToMap.java >--- src/org/eclipse/releng/tools/CompareLocalToMap.java 10 Apr 2007 15:54:52 -0000 1.13 >+++ src/org/eclipse/releng/tools/CompareLocalToMap.java 12 Apr 2007 17:19:38 -0000 >@@ -11,12 +11,14 @@ > package org.eclipse.releng.tools; > > import java.lang.reflect.InvocationTargetException; >- >+import org.eclipse.core.resources.IProject; > import org.eclipse.core.resources.IResource; > import org.eclipse.jface.action.IAction; >-import org.eclipse.team.internal.ccvs.core.CVSCompareSubscriber; >-import org.eclipse.team.internal.ccvs.core.CVSException; >-import org.eclipse.team.internal.ccvs.core.CVSTag; >+import org.eclipse.jface.dialogs.*; >+import org.eclipse.jface.dialogs.Dialog; >+import org.eclipse.swt.widgets.*; >+import org.eclipse.team.core.RepositoryProvider; >+import org.eclipse.team.internal.ccvs.core.*; > import org.eclipse.team.internal.ccvs.ui.actions.WorkspaceAction; > import org.eclipse.team.internal.ccvs.ui.subscriber.CompareParticipant; > import org.eclipse.team.ui.TeamUI; >@@ -38,10 +40,11 @@ > */ > protected CVSTag getTag(IResource resource) { > MapEntry entry = getMapProject().getMapEntry(resource.getProject()); >- if (entry == null) return CVSTag.DEFAULT; >+ if (entry == null) >+ return CVSTag.DEFAULT; > return entry.getTag(); > } >- >+ > /** > * Returns true if the super would enable the option *and* > * only projects are selected. There is no concept of "releasing" >@@ -50,21 +53,32 @@ > * @see org.eclipse.team.internal.ui.actions.TeamAction#isEnabled() > */ > public boolean isEnabled() { >- >+ > boolean result = super.isEnabled(); > if (!result) { > return false; >- } >- return (getMapProject() != null && getMapProject().mapsAreLoaded()); >+ } >+ IResource[] resources = getSelectedResources(); >+ if (resources == null || resources.length == 0) >+ return false; >+ for (int i = 0; i < resources.length; i++) { >+ IResource resource = resources[i]; >+ if (resource.getType() != IResource.PROJECT) >+ return false; >+ if (getMapProject().getMapEntry((IProject) resource) == null) >+ return false; >+ } >+ return true; > } > > /** > * @see org.eclipse.team.internal.ccvs.ui.actions.CVSAction#execute(org.eclipse.jface.action.IAction) > */ >- protected void execute(IAction action) throws InvocationTargetException, InterruptedException { >+ protected void execute(IAction action) throws InvocationTargetException, InterruptedException { > IResource[] resources = getSelectedResources(); >- if (resources.length == 0) return; >- CVSTag[] tags = new CVSTag[resources.length]; >+ if (resources.length == 0) >+ return; >+ CVSTag[] tags = new CVSTag[resources.length]; > for (int i = 0; i < resources.length; i++) { > tags[i] = getTag(resources[i]); > } >@@ -78,10 +92,11 @@ > RelEngPlugin.log(e); > } > CompareParticipant participant = new CompareParticipant(s); >- TeamUI.getSynchronizeManager().addSynchronizeParticipants(new ISynchronizeParticipant[]{participant}); >+ TeamUI.getSynchronizeManager().addSynchronizeParticipants(new ISynchronizeParticipant[] {participant}); > participant.refresh(resources, "Refreshing", "Refreshing", getTargetPart().getSite()); > } >- private MapProject getMapProject(){ >+ >+ private MapProject getMapProject() { > return MapProject.getDefaultMapProject(); > } > } >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.releng.tools/META-INF/MANIFEST.MF,v >retrieving revision 1.5 >diff -u -r1.5 MANIFEST.MF >--- META-INF/MANIFEST.MF 10 Apr 2007 18:05:10 -0000 1.5 >+++ META-INF/MANIFEST.MF 12 Apr 2007 17:19:38 -0000 >@@ -3,7 +3,6 @@ > Bundle-Name: %PluginName > Bundle-SymbolicName: org.eclipse.releng.tools; singleton:=true > Bundle-Version: 3.3.0.qualifier >-Bundle-ClassPath: tools.jar > Bundle-Activator: org.eclipse.releng.tools.RelEngPlugin > Bundle-Vendor: %PluginProvider > Bundle-Localization: plugin >Index: build.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.releng.tools/build.properties,v >retrieving revision 1.5 >diff -u -r1.5 build.properties >--- build.properties 1 Dec 2005 21:16:42 -0000 1.5 >+++ build.properties 12 Apr 2007 17:19:38 -0000 >@@ -1,5 +1,5 @@ > ############################################################################### >-# Copyright (c) 2000, 2005 IBM Corporation and others. >+# Copyright (c) 2000, 2007 IBM Corporation and others. > # All rights reserved. This program and the accompanying materials > # are made available under the terms of the Eclipse Public License v1.0 > # which accompanies this distribution, and is available at >@@ -8,10 +8,12 @@ > # Contributors: > # IBM Corporation - initial API and implementation > ############################################################################### >-source.tools.jar = src/ >+source..=src/ > bin.includes = plugin.xml,\ >- *.jar,\ >+ .,\ > about.html,\ > icons/,\ > plugin.properties,\ > META-INF/ >+output.. = bin/ >+src.includes=about.html >\ No newline at end of file
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 173314
:
59426
|
59427
|
60567
|
60569
|
63633
| 63634