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 5350 Details for
Bug 38048
IProjectSetSerializer cannot be used in headless environment
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]
new serializer support for CVS core
bug_38048_new_serializer_team_cvs_core.txt (text/plain), 10.72 KB, created by
Dan Rubel
on 2003-07-04 11:29:17 EDT
(
hide
)
Description:
new serializer support for CVS core
Filename:
MIME Type:
Creator:
Dan Rubel
Created:
2003-07-04 11:29:17 EDT
Size:
10.72 KB
patch
obsolete
>Index: org/eclipse/team/internal/ccvs/core/CVSTeamProviderType.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSTeamProviderType.java,v >retrieving revision 1.3 >diff -u -r1.3 CVSTeamProviderType.java >--- org/eclipse/team/internal/ccvs/core/CVSTeamProviderType.java 10 Mar 2003 21:25:29 -0000 1.3 >+++ org/eclipse/team/internal/ccvs/core/CVSTeamProviderType.java 4 Jul 2003 14:21:34 -0000 >@@ -10,6 +10,7 @@ > *******************************************************************************/ > package org.eclipse.team.internal.ccvs.core; > >+import org.eclipse.team.core.ProjectSetSerializer; > import org.eclipse.team.core.RepositoryProviderType; > > >@@ -27,5 +28,19 @@ > return false; > } > >+ >+ /** >+ * Answers an object for serializing and deserializing >+ * of references to CVS based projects. Given a project, it can produce a >+ * UTF-8 encoded String which can be stored in a file. >+ * Given this String, it can load a project into the workspace. >+ * >+ * @return the serializer (not <code>null</code>) >+ * @see org.eclipse.team.core.RepositoryProviderType#getProjectSetSerializer() >+ * @since 3.0 >+ */ >+ public ProjectSetSerializer getProjectSetSerializer() { >+ return new CVSProjectSetSerializer(); >+ } > > } >Index: src/org/eclipse/team/internal/ccvs/core/CVSProjectSetSerializer.java >=================================================================== >RCS file: src/org/eclipse/team/internal/ccvs/core/CVSProjectSetSerializer.java >diff -N src/org/eclipse/team/internal/ccvs/core/CVSProjectSetSerializer.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/team/internal/ccvs/core/CVSProjectSetSerializer.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,264 @@ >+package org.eclipse.team.internal.ccvs.core; >+ >+import java.util.ArrayList; >+import java.util.Collection; >+import java.util.HashMap; >+import java.util.List; >+import java.util.Map; >+import java.util.StringTokenizer; >+ >+import org.eclipse.core.resources.IProject; >+import org.eclipse.core.resources.ResourcesPlugin; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.NullProgressMonitor; >+import org.eclipse.core.runtime.SubProgressMonitor; >+import org.eclipse.team.core.ProjectSetSerializationContext; >+import org.eclipse.team.core.ProjectSetSerializer; >+import org.eclipse.team.core.RepositoryProvider; >+import org.eclipse.team.core.TeamException; >+import org.eclipse.team.internal.ccvs.core.connection.CVSRepositoryLocation; >+import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; >+import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo; >+ >+/** >+ * An object for serializing and deserializing >+ * of references to CVS based projects. Given a project, it can produce a >+ * UTF-8 encoded String which can be stored in a file. >+ * Given this String, it can load a project into the workspace. >+ * >+ * @since 3.0 >+ */ >+public class CVSProjectSetSerializer extends ProjectSetSerializer { >+ >+ /** >+ * Override superclass implementation to return an array of project references. >+ * >+ * @see ProjectSetSerializer#asReference(IProject[], ProjectSetSerializationContext, IProgressMonitor) >+ */ >+ public String[] asReference( >+ IProject[] projects, >+ ProjectSetSerializationContext context, >+ IProgressMonitor monitor) >+ throws TeamException { >+ >+ String[] result = new String[projects.length]; >+ for (int i = 0; i < projects.length; i++) >+ result[i] = asReference(projects[i]); >+ return result; >+ } >+ >+ /** >+ * Answer a string representing the specified project >+ * >+ * @param project the project (not <code>null</code>) >+ * @return the project reference (not <code>null</code>) >+ * @throws CVSException >+ */ >+ private String asReference(IProject project) throws TeamException { >+ StringBuffer buffer = new StringBuffer(); >+ buffer.append("1.0,"); //$NON-NLS-1$ >+ >+ CVSTeamProvider provider = (CVSTeamProvider)RepositoryProvider.getProvider(project); >+ CVSWorkspaceRoot root = provider.getCVSWorkspaceRoot(); >+ CVSRepositoryLocation location = CVSRepositoryLocation.fromString(root.getRemoteLocation().getLocation()); >+ location.setUserMuteable(true); >+ String repoLocation = location.getLocation(); >+ buffer.append(repoLocation); >+ buffer.append(","); //$NON-NLS-1$ >+ >+ ICVSFolder folder = root.getLocalRoot(); >+ FolderSyncInfo syncInfo = folder.getFolderSyncInfo(); >+ String module = syncInfo.getRepository(); >+ buffer.append(module); >+ buffer.append(","); //$NON-NLS-1$ >+ >+ String projectName = folder.getName(); >+ buffer.append(projectName); >+ CVSTag tag = syncInfo.getTag(); >+ if (tag != null) { >+ if (tag.getType() != CVSTag.DATE) { >+ buffer.append(","); //$NON-NLS-1$ >+ String tagName = tag.getName(); >+ buffer.append(tagName); >+ } >+ } >+ return buffer.toString(); >+ } >+ >+ /** >+ * Override superclass implementation to load the referenced projects into the workspace. >+ * >+ * @see org.eclipse.team.core.ProjectSetSerializer#addToWorkspace(java.lang.String[], org.eclipse.team.core.ProjectSetSerializationContext, org.eclipse.core.runtime.IProgressMonitor) >+ */ >+ public IProject[] addToWorkspace( >+ String[] referenceStrings, >+ ProjectSetSerializationContext context, >+ IProgressMonitor originalMonitor) >+ throws TeamException { >+ >+ IProgressMonitor monitor = originalMonitor; >+ if (monitor == null) >+ monitor = new NullProgressMonitor(); >+ else if (monitor.isCanceled()) >+ return new IProject[0]; >+ >+ // Confirm the projects to be loaded >+ Map infoMap = new HashMap(referenceStrings.length); >+ IProject[] projects = asProjects(referenceStrings, infoMap); >+ projects = confirmOverwrite(context, projects); >+ if (projects == null) >+ return new IProject[0]; >+ >+ // Load the projects >+ monitor.beginTask("", 20); //$NON-NLS-1$ >+ try { >+ projects = createProjects(context, projects, new SubProgressMonitor(monitor, 1)); >+ if (projects == null) >+ return new IProject[0]; >+ return checkout(projects, infoMap, new SubProgressMonitor(monitor, 19)); >+ } >+ finally { >+ monitor.done(); >+ } >+ } >+ >+ /** >+ * Translate the reference strings into projects to be loaded >+ * and build a mapping of project to project load information. >+ * >+ * @param referenceStrings project references >+ * @param infoMap a mapping of project to project load information >+ * @return the projects to be loaded >+ */ >+ private IProject[] asProjects(String[] referenceStrings, Map infoMap) throws CVSException { >+ Collection result = new ArrayList(); >+ for (int i = 0; i < referenceStrings.length; i++) { >+ StringTokenizer tokenizer = new StringTokenizer(referenceStrings[i], ","); //$NON-NLS-1$ >+ String version = tokenizer.nextToken(); >+ // If this is a newer version, then ignore it >+ if (!version.equals("1.0")) //$NON-NLS-1$ >+ continue; >+ LoadInfo info = new LoadInfo(tokenizer); >+ IProject proj = info.getProject(); >+ result.add(proj); >+ infoMap.put(proj, info); >+ } >+ return (IProject[]) result.toArray(new IProject[result.size()]); >+ } >+ >+ /** >+ * Checkout projects from the CVS repository >+ * >+ * @param projects the projects to be loaded from the repository >+ * @param infoMap a mapping of project to project load information >+ * @param monitor the progress monitor (not <code>null</code>) >+ */ >+ private IProject[] checkout( >+ IProject[] projects, >+ Map infoMap, >+ IProgressMonitor monitor) >+ throws TeamException { >+ >+ monitor.beginTask("", 1000 * projects.length); //$NON-NLS-1$ >+ List result = new ArrayList(); >+ try { >+ for (int i = 0; i < projects.length; i++) { >+ if (monitor.isCanceled()) >+ break; >+ IProject project = projects[i]; >+ LoadInfo info = (LoadInfo) infoMap.get(project); >+ if (info != null && info.checkout(new SubProgressMonitor(monitor, 1000))) >+ result.add(project); >+ } >+ } >+ finally { >+ monitor.done(); >+ } >+ return (IProject[])result.toArray(new IProject[result.size()]); >+ } >+ >+ /** >+ * Internal class for adding projects to the workspace >+ */ >+ class LoadInfo { >+ private final ICVSRepositoryLocation repositoryLocation; >+ private final String module; >+ private final IProject project; >+ private final CVSTag tag; >+ >+ /** >+ * Construct a new instance wrappering the specified project reference >+ * >+ * @param projRef the project reference >+ */ >+ LoadInfo(StringTokenizer tokenizer) throws CVSException { >+ String repo = tokenizer.nextToken(); >+ repositoryLocation = getRepositoryLocationFromString(repo); >+ module = tokenizer.nextToken(); >+ String projectName = tokenizer.nextToken(); >+ project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); >+ if (tokenizer.hasMoreTokens()) { >+ String tagName = tokenizer.nextToken(); >+ tag = new CVSTag(tagName, CVSTag.BRANCH); >+ } >+ else { >+ tag = null; >+ } >+ } >+ >+ /** >+ * Answer the project referenced by this object. >+ * The project may or may not already exist. >+ * >+ * @return the project (not <code>null</code>) >+ */ >+ private IProject getProject() { >+ return project; >+ } >+ >+ /** >+ * Checkout the project specified by this reference. >+ * >+ * @param monitor project monitor >+ * @return true if loaded, else false >+ * @throws TeamException >+ */ >+ boolean checkout(IProgressMonitor monitor) throws TeamException { >+ if (repositoryLocation == null) >+ return false; >+ CVSWorkspaceRoot.checkout( >+ repositoryLocation, >+ project, >+ module, >+ tag, >+ monitor); >+ return true; >+ } >+ } >+ >+ /** >+ * Extract the CVS repository location information from the specified string >+ * >+ * @param repo the repository location as a string >+ * @return the CVS repository information >+ * @throws CVSException >+ */ >+ private static ICVSRepositoryLocation getRepositoryLocationFromString(String repo) throws CVSException { >+ // create the new location >+ ICVSRepositoryLocation newLocation = CVSRepositoryLocation.fromString(repo); >+ if (newLocation.getUsername() == null || newLocation.getUsername().length() == 0) { >+ // look for an existing location that matched >+ 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; >+ } >+ } >+ return newLocation; >+ } >+ >+}
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 38048
:
5348
|
5349
|
5350
|
5351
|
7396