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 163389 Details for
Bug 306508
[Backport] [Sync View] Error message during update operation after synchronization
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]
Fix v01 & tests
306508_20090330.txt (text/plain), 39.11 KB, created by
Szymon Brandys
on 2010-03-30 05:32:44 EDT
(
hide
)
Description:
Fix v01 & tests
Filename:
MIME Type:
Creator:
Szymon Brandys
Created:
2010-03-30 05:32:44 EDT
Size:
39.11 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.team.cvs.ui >Index: src/org/eclipse/team/internal/ccvs/ui/subscriber/SafeUpdateOperation.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/SafeUpdateOperation.java,v >retrieving revision 1.14 >diff -u -r1.14 SafeUpdateOperation.java >--- src/org/eclipse/team/internal/ccvs/ui/subscriber/SafeUpdateOperation.java 29 Mar 2006 17:13:53 -0000 1.14 >+++ src/org/eclipse/team/internal/ccvs/ui/subscriber/SafeUpdateOperation.java 30 Mar 2010 09:31:52 -0000 >@@ -11,33 +11,33 @@ > package org.eclipse.team.internal.ccvs.ui.subscriber; > > import java.lang.reflect.InvocationTargetException; >-import java.util.ArrayList; >-import java.util.HashSet; >-import java.util.List; >-import java.util.Set; >+import java.util.*; > > import org.eclipse.compare.structuremergeviewer.IDiffElement; > import org.eclipse.core.resources.*; >+import org.eclipse.core.resources.mapping.ResourceMapping; >+import org.eclipse.core.resources.mapping.ResourceMappingContext; >+import org.eclipse.core.runtime.CoreException; > import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.jobs.ISchedulingRule; >+import org.eclipse.core.runtime.jobs.MultiRule; > import org.eclipse.jface.dialogs.MessageDialog; > import org.eclipse.osgi.util.NLS; > import org.eclipse.team.core.TeamException; >-import org.eclipse.team.core.synchronize.FastSyncInfoFilter; >-import org.eclipse.team.core.synchronize.SyncInfo; >-import org.eclipse.team.core.synchronize.SyncInfoSet; >-import org.eclipse.team.core.synchronize.FastSyncInfoFilter.AndSyncInfoFilter; >-import org.eclipse.team.core.synchronize.FastSyncInfoFilter.OrSyncInfoFilter; >-import org.eclipse.team.core.synchronize.FastSyncInfoFilter.SyncInfoDirectionFilter; >+import org.eclipse.team.core.mapping.provider.SynchronizationScopeManager; >+import org.eclipse.team.core.synchronize.*; >+import org.eclipse.team.core.synchronize.FastSyncInfoFilter.*; > import org.eclipse.team.core.variants.IResourceVariant; >-import org.eclipse.team.internal.ccvs.core.CVSException; >-import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin; >-import org.eclipse.team.internal.ccvs.core.ICVSFile; >+import org.eclipse.team.internal.ccvs.core.*; > import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption; > import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; >+import org.eclipse.team.internal.ccvs.core.resources.EclipseSynchronizer; > import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo; > import org.eclipse.team.internal.ccvs.ui.*; >-import org.eclipse.team.internal.ccvs.ui.operations.UpdateOnlyMergableOperation; >+import org.eclipse.team.internal.ccvs.ui.Policy; >+import org.eclipse.team.internal.ccvs.ui.operations.*; > import org.eclipse.team.internal.ui.TeamUIPlugin; >+import org.eclipse.team.internal.ui.Utils; > import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration; > > /** >@@ -64,6 +64,69 @@ > public boolean shouldRun() { > return promptIfNeeded(); > } >+ >+ /** >+ * Run the operation for the sync infos from the given project. By default, a lock >+ * is acquired on the project. >+ * @param projectSyncInfos the project syncInfos >+ * @param project the project >+ * @param monitor a progress monitor >+ * @throws InvocationTargetException >+ */ >+ protected void run(final Map projectSyncInfos, final IProject project, >+ IProgressMonitor monitor) throws InvocationTargetException { >+ try { >+ IResource[] resources = getIResourcesFrom(((SyncInfoSet) projectSyncInfos >+ .get(project)).getSyncInfos()); >+ ResourceMapping[] selectedMappings = Utils >+ .getResourceMappings(resources); >+ ResourceMappingContext context = new SingleProjectSubscriberContext( >+ CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber(), >+ false, project); >+ SynchronizationScopeManager manager = new SingleProjectScopeManager( >+ getJobName(), selectedMappings, context, true, project); >+ manager.initialize(null); >+ ISchedulingRule updateRule = getUpdateRule(manager); >+ >+ // Pass the scheduling rule to the synchronizer so that sync change >+ // events >+ // and cache commits to disk are batched >+ EclipseSynchronizer.getInstance().run(updateRule, >+ new ICVSRunnable() { >+ public void run(IProgressMonitor monitor) >+ throws CVSException { >+ try { >+ runWithProjectRule(project, >+ (SyncInfoSet) projectSyncInfos >+ .get(project), monitor); >+ } catch (TeamException e) { >+ throw CVSException.wrapException(e); >+ } >+ } >+ }, Policy.subMonitorFor(monitor, 100)); >+ } catch (TeamException e) { >+ throw new InvocationTargetException(e); >+ } catch (CoreException e) { >+ throw new InvocationTargetException(e); >+ } >+ } >+ >+ private ISchedulingRule getUpdateRule(SynchronizationScopeManager manager) { >+ ISchedulingRule rule = null; >+ ResourceMapping[] mappings = manager.getScope().getMappings(); >+ for (int i = 0; i < mappings.length; i++) { >+ ResourceMapping mapping = mappings[i]; >+ IProject[] mappingProjects = mapping.getProjects(); >+ for (int j = 0; j < mappingProjects.length; j++) { >+ if (rule == null) { >+ rule = mappingProjects[j]; >+ } else { >+ rule = MultiRule.combine(rule, mappingProjects[j]); >+ } >+ } >+ } >+ return rule; >+ } > > /* (non-Javadoc) > * @see org.eclipse.team.internal.ccvs.ui.subscriber.CVSSubscriberOperation#run(org.eclipse.core.runtime.IProgressMonitor) >#P org.eclipse.team.tests.cvs.core >Index: src/org/eclipse/team/tests/ccvs/core/subscriber/TestUpdateOperation.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/TestUpdateOperation.java,v >retrieving revision 1.5 >diff -u -r1.5 TestUpdateOperation.java >--- src/org/eclipse/team/tests/ccvs/core/subscriber/TestUpdateOperation.java 10 May 2006 18:10:44 -0000 1.5 >+++ src/org/eclipse/team/tests/ccvs/core/subscriber/TestUpdateOperation.java 30 Mar 2010 09:31:54 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2006 IBM Corporation and others. >+ * Copyright (c) 2000, 2010 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,10 +10,23 @@ > *******************************************************************************/ > package org.eclipse.team.tests.ccvs.core.subscriber; > >+import java.lang.reflect.InvocationTargetException; >+ > import org.eclipse.compare.structuremergeviewer.IDiffElement; >+import org.eclipse.core.resources.IProject; >+import org.eclipse.core.resources.IResource; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.team.core.TeamException; >+import org.eclipse.team.core.mapping.ISynchronizationScope; > import org.eclipse.team.core.synchronize.SyncInfoSet; >+import org.eclipse.team.internal.ccvs.core.CVSException; >+import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption; >+import org.eclipse.team.internal.ccvs.ui.Policy; >+import org.eclipse.team.internal.ccvs.ui.operations.UpdateOnlyMergableOperation; > import org.eclipse.team.internal.ccvs.ui.subscriber.WorkspaceUpdateOperation; >+import org.eclipse.team.internal.ui.mapping.BuildScopeOperation; > import org.eclipse.team.tests.ccvs.core.EclipseTest; >+import org.eclipse.team.tests.ccvs.ui.ReflectionUtils; > > class TestUpdateOperation extends WorkspaceUpdateOperation { > >@@ -42,4 +55,35 @@ > EclipseTest.fail("Should never prompt on update, simply update nodes that are valid."); > return false; > } >+ >+ protected void safeUpdate(IProject project, IResource[] resources, LocalOption[] localOptions, IProgressMonitor monitor) throws TeamException { >+ try { >+ UpdateOnlyMergableOperation operation = new UpdateOnlyMergableOperation(getPart(), project, resources, localOptions) { >+ public ISynchronizationScope buildScope(IProgressMonitor monitor) throws InterruptedException, CVSException { >+ if (getScopeManager() == null) { >+ // manager = createScopeManager(consultModelsWhenBuildingScope && consultModelsForMappings()); >+ ReflectionUtils.setField(this, "manager", createScopeManager(consultModelsWhenBuildingScope && consultModelsForMappings())); >+ BuildScopeOperation op = new BuildScopeOperation(getPart(), getScopeManager()) { >+ protected boolean promptForInputChange(String requestPreviewMessage, IProgressMonitor monitor) { >+ return false; // do not prompt >+ } >+ }; >+ try { >+ op.run(monitor); >+ } catch (InvocationTargetException e) { >+ throw CVSException.wrapException(e); >+ } >+ } >+ return getScope(); >+ } >+ }; >+ operation.run(monitor); >+ // addSkippedFiles(operation.getSkippedFiles()); >+ ReflectionUtils.callMethod(this, "addSkippedFiles", new Object[] {operation.getSkippedFiles()}); >+ } catch (InvocationTargetException e) { >+ throw CVSException.wrapException(e); >+ } catch (InterruptedException e) { >+ Policy.cancelOperation(); >+ } >+ } > } >Index: src/org/eclipse/team/tests/ccvs/core/subscriber/CVSWorkspaceSubscriberTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/CVSWorkspaceSubscriberTest.java,v >retrieving revision 1.46 >diff -u -r1.46 CVSWorkspaceSubscriberTest.java >--- src/org/eclipse/team/tests/ccvs/core/subscriber/CVSWorkspaceSubscriberTest.java 29 May 2007 17:35:57 -0000 1.46 >+++ src/org/eclipse/team/tests/ccvs/core/subscriber/CVSWorkspaceSubscriberTest.java 30 Mar 2010 09:31:54 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2007 IBM Corporation and others. >+ * Copyright (c) 2000, 2010 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 >@@ -13,24 +13,45 @@ > import java.io.ByteArrayInputStream; > import java.io.IOException; > import java.lang.reflect.InvocationTargetException; >-import java.util.*; >+import java.util.Arrays; >+import java.util.HashSet; >+import java.util.Set; > > import junit.framework.Test; > import junit.framework.TestSuite; > >-import org.eclipse.core.resources.*; >+import org.eclipse.core.resources.IContainer; >+import org.eclipse.core.resources.IFile; >+import org.eclipse.core.resources.IFolder; >+import org.eclipse.core.resources.IProject; >+import org.eclipse.core.resources.IProjectDescription; >+import org.eclipse.core.resources.IResource; >+import org.eclipse.core.resources.IResourceVisitor; >+import org.eclipse.core.resources.ResourcesPlugin; > import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.NullProgressMonitor; > import org.eclipse.core.runtime.Path; > import org.eclipse.team.core.RepositoryProvider; > import org.eclipse.team.core.TeamException; > import org.eclipse.team.core.subscribers.ISubscriberChangeEvent; > import org.eclipse.team.core.synchronize.SyncInfo; >-import org.eclipse.team.internal.ccvs.core.*; >+import org.eclipse.team.internal.ccvs.core.CVSException; >+import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin; >+import org.eclipse.team.internal.ccvs.core.CVSSyncTreeSubscriber; >+import org.eclipse.team.internal.ccvs.core.CVSTag; >+import org.eclipse.team.internal.ccvs.core.CVSTeamProvider; >+import org.eclipse.team.internal.ccvs.core.ICVSFile; >+import org.eclipse.team.internal.ccvs.core.ICVSFolder; >+import org.eclipse.team.internal.ccvs.core.ICVSResource; > import org.eclipse.team.internal.ccvs.core.client.Command; > import org.eclipse.team.internal.ccvs.core.client.Command.KSubstOption; > import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; > import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo; >+import org.eclipse.team.internal.ccvs.ui.operations.RepositoryProviderOperation; > import org.eclipse.team.tests.ccvs.core.CVSTestSetup; >+import org.eclipse.team.tests.ccvs.core.mappings.model.ModelProject; >+import org.eclipse.team.tests.ccvs.core.mappings.model.mapping.ModelResourceMapping; >+import org.eclipse.team.tests.ccvs.ui.ModelParticipantSyncInfoSource; > > /** > * This class tests the CVSWorkspaceSubscriber >@@ -277,6 +298,67 @@ > * Tests > ******************************************************************/ > >+ public void testBug302163WithoutModel() throws CoreException { >+ // Create a test project >+ IProject modelProject = getUniqueTestProject("test1"); >+ buildResources(modelProject, new String[] { "file.mod", "f1.moe" }, true); >+ modelProject.getFile("file.mod").setContents(new ByteArrayInputStream(("\nf1.moe").getBytes()), false, true, null); >+ shareProject(modelProject); >+ assertValidCheckout(modelProject); >+ >+ // Checkout and modify a copy >+ IProject copyModelProject = checkoutCopy(modelProject, "-copy"); >+ copyModelProject.getFile("file.mod").setContents(new ByteArrayInputStream(("\nf1.moe\nf2.moe").getBytes()), false, true, null); >+ commitProject(copyModelProject); >+ >+ refresh(getSubscriber(), modelProject); >+ >+ RepositoryProviderOperation.consultModelsWhenBuildingScope = true; >+ setSyncSource(new SyncInfoSource()); >+ // Update >+ try { >+ update(modelProject, new String[] { "file.mod" }); >+ } catch (CVSException e) { >+ fail("Update without models failed", e); >+ } >+ // Reset settings >+ RepositoryProviderOperation.consultModelsWhenBuildingScope = false; >+ setSyncSource(new ModelParticipantSyncInfoSource()); >+ } >+ >+ public void testBug302163WithModel() throws CoreException { >+ // Create a test project >+ IProject project = createProject("test", new String[] { "file1.txt" }); >+ ModelResourceMapping.projectName = project.getName(); >+ >+ // Create a test model project >+ IProject modelProject = getUniqueTestProject("test1"); >+ buildResources(modelProject, new String[] { "file.mod", "f1.moe" }, true); >+ modelProject.getFile("file.mod").setContents(new ByteArrayInputStream(("\nf1.moe").getBytes()), false, true, null); >+ ModelProject.makeModProject(modelProject, new NullProgressMonitor()); >+ shareProject(modelProject); >+ assertValidCheckout(modelProject); >+ >+ // Checkout and modify a copy of the model project >+ IProject copyModelProject = checkoutCopy(modelProject, "-copy"); >+ copyModelProject.getFile("file.mod").setContents(new ByteArrayInputStream(("\nf1.moe\nf2.moe").getBytes()), false, true, null); >+ commitProject(copyModelProject); >+ >+ refresh(getSubscriber(), modelProject); >+ >+ RepositoryProviderOperation.consultModelsWhenBuildingScope = true; >+ setSyncSource(new SyncInfoSource()); >+ // Update >+ try { >+ update(modelProject, new String[] { "file.mod" }); >+ } catch (CVSException e) { >+ fail("Update without models failed", e); >+ } >+ // Reset settings >+ RepositoryProviderOperation.consultModelsWhenBuildingScope = false; >+ setSyncSource(new ModelParticipantSyncInfoSource()); >+ } >+ > /* > * Perform a simple test that checks for the different types of incoming changes > */ >Index: src/org/eclipse/team/tests/ccvs/ui/ReflectionUtils.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/ReflectionUtils.java,v >retrieving revision 1.1 >diff -u -r1.1 ReflectionUtils.java >--- src/org/eclipse/team/tests/ccvs/ui/ReflectionUtils.java 9 Apr 2009 12:34:53 -0000 1.1 >+++ src/org/eclipse/team/tests/ccvs/ui/ReflectionUtils.java 30 Mar 2010 09:31:54 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2009 IBM Corporation and others. >+ * Copyright (c) 2009, 2010 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 >@@ -14,43 +14,111 @@ > import java.lang.reflect.InvocationTargetException; > import java.lang.reflect.Method; > >+import org.eclipse.team.tests.ccvs.core.EclipseTest; >+ > public class ReflectionUtils { > >- public static Object callMethod(Object object, String name, Object args[]) >- throws IllegalArgumentException, IllegalAccessException, >- InvocationTargetException, NoSuchMethodException { >- Class types[] = new Class[args.length]; >- for (int i = 0; i < args.length; i++) { >- types[i] = args[i].getClass(); >- } >- Method method = null; >- Class clazz = object.getClass(); >- NoSuchMethodException ex = null; >- while (method == null && clazz != null) { >- try { >- method = clazz.getDeclaredMethod(name, types); >- } catch (NoSuchMethodException e) { >- if (ex == null) { >- ex = e; >+ public static Object callMethod(Object object, String name, Object args[]) { >+ try { >+ Class types[] = new Class[args.length]; >+ for (int i = 0; i < args.length; i++) { >+ types[i] = args[i].getClass(); >+ } >+ Method method = null; >+ Class clazz = object.getClass(); >+ NoSuchMethodException ex = null; >+ while (method == null && clazz != null) { >+ try { >+ method = clazz.getDeclaredMethod(name, types); >+ } catch (NoSuchMethodException e) { >+ if (ex == null) { >+ ex = e; >+ } >+ clazz = clazz.getSuperclass(); > } >- clazz = clazz.getSuperclass(); > } >+ if (method == null) { >+ throw ex; >+ } >+ method.setAccessible(true); >+ Object ret = method.invoke(object, args); >+ return ret; >+ } catch (IllegalArgumentException e) { >+ EclipseTest.fail(e.getMessage()); >+ } catch (IllegalAccessException e) { >+ EclipseTest.fail(e.getMessage()); >+ } catch (SecurityException e) { >+ EclipseTest.fail(e.getMessage()); >+ } catch (NoSuchMethodException e) { >+ EclipseTest.fail(e.getMessage()); >+ } catch (InvocationTargetException e) { >+ EclipseTest.fail(e.getMessage()); > } >- if (method == null) { >- throw ex; >+ return null; >+ } >+ >+ public static Object getField(Object object, String name) { >+ try { >+ Field field = null; >+ Class clazz = object.getClass(); >+ NoSuchFieldException ex = null; >+ while (field == null && clazz != null) { >+ try { >+ field = clazz.getDeclaredField(name); >+ } catch (NoSuchFieldException e) { >+ if (ex == null) { >+ ex = e; >+ } >+ clazz = clazz.getSuperclass(); >+ } >+ } >+ if (field == null) { >+ throw ex; >+ } >+ field.setAccessible(true); >+ Object ret = field.get(object); >+ return ret; >+ } catch (IllegalArgumentException e) { >+ EclipseTest.fail(e.getMessage()); >+ } catch (IllegalAccessException e) { >+ EclipseTest.fail(e.getMessage()); >+ } catch (SecurityException e) { >+ EclipseTest.fail(e.getMessage()); >+ } catch (NoSuchFieldException e) { >+ EclipseTest.fail(e.getMessage()); > } >- method.setAccessible(true); >- Object ret = method.invoke(object, args); >- return ret; >+ return null; > } > >- public static Object getField(Object object, String name) >- throws IllegalArgumentException, IllegalAccessException, >- SecurityException, NoSuchFieldException { >- Field field = object.getClass().getDeclaredField(name); >- field.setAccessible(true); >- Object ret = field.get(object); >- return ret; >+ public static void setField(Object object, String name, Object value) { >+ try { >+ Field field = null; >+ Class clazz = object.getClass(); >+ NoSuchFieldException ex = null; >+ while (field == null && clazz != null) { >+ try { >+ field = clazz.getDeclaredField(name); >+ } catch (NoSuchFieldException e) { >+ if (ex == null) { >+ ex = e; >+ } >+ clazz = clazz.getSuperclass(); >+ } >+ } >+ if (field == null) { >+ throw ex; >+ } >+ field.setAccessible(true); >+ field.set(object, value); >+ } catch (IllegalArgumentException e) { >+ EclipseTest.fail(e.getMessage()); >+ } catch (IllegalAccessException e) { >+ EclipseTest.fail(e.getMessage()); >+ } catch (SecurityException e) { >+ EclipseTest.fail(e.getMessage()); >+ } catch (NoSuchFieldException e) { >+ EclipseTest.fail(e.getMessage()); >+ } > } > > } >\ No newline at end of file >Index: src/org/eclipse/team/tests/ccvs/ui/CreatePatchTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/CreatePatchTest.java,v >retrieving revision 1.1 >diff -u -r1.1 CreatePatchTest.java >--- src/org/eclipse/team/tests/ccvs/ui/CreatePatchTest.java 9 Apr 2009 12:34:53 -0000 1.1 >+++ src/org/eclipse/team/tests/ccvs/ui/CreatePatchTest.java 30 Mar 2010 09:31:54 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2009 IBM Corporation and others. >+ * Copyright (c) 2009, 2010 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 >@@ -14,7 +14,6 @@ > import java.io.IOException; > import java.io.InputStream; > import java.io.InputStreamReader; >-import java.lang.reflect.InvocationTargetException; > import java.net.URL; > > import junit.framework.Test; >@@ -241,47 +240,15 @@ > } > > private Text getText(Object object, String name) { >- return (Text) getField(object, name); >+ return (Text) ReflectionUtils.getField(object, name); > } > > private Button getButton(Object object, String name) { >- return (Button) getField(object, name); >- } >- >- private Object getField(Object object, String name) { >- Object ret = null; >- try { >- ret = ReflectionUtils.getField(object, name); >- } catch (IllegalArgumentException e) { >- fail(e.getMessage()); >- } catch (SecurityException e) { >- fail(e.getMessage()); >- } catch (IllegalAccessException e) { >- fail(e.getMessage()); >- } catch (NoSuchFieldException e) { >- fail(e.getMessage()); >- } >- return ret; >+ return (Button) ReflectionUtils.getField(object, name); > } > > private Object callMethod(Object object, String name) { >- return callMethod(object, name, new Object[] {}); >- } >- >- private Object callMethod(Object object, String name, Object args[]) { >- Object ret = null; >- try { >- ret = ReflectionUtils.callMethod(object, name, args); >- } catch (IllegalArgumentException e) { >- fail(e.getMessage()); >- } catch (IllegalAccessException e) { >- fail(e.getMessage()); >- } catch (InvocationTargetException e) { >- fail(e.getMessage()); >- } catch (NoSuchMethodException e) { >- fail(e.getMessage()); >- } >- return ret; >+ return ReflectionUtils.callMethod(object, name, new Object[] {}); > } > > private Shell getShell() { >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.team.tests.cvs.core/plugin.xml,v >retrieving revision 1.34 >diff -u -r1.34 plugin.xml >--- plugin.xml 9 Apr 2009 12:34:53 -0000 1.34 >+++ plugin.xml 30 Mar 2010 09:31:54 -0000 >@@ -49,4 +49,28 @@ > name="CVS Test Editor"> > </editor> > </extension> >+ >+<!-- Other declarations --> >+ >+ <!-- ***** Nature that identifies model projects used in tests for bug 302163 ***** --> >+ <extension >+ id="bug302163_ModelNature" >+ name="Project nature for bug 302163" >+ point="org.eclipse.core.resources.natures"> >+ <runtime> >+ <run class="org.eclipse.team.tests.ccvs.core.mappings.model.ModelNature"/> >+ </runtime> >+ </extension> >+ >+ <!-- ***** Model provider for the model used in tests for bug 302163 ***** --> >+ <extension >+ id="bug302163_ModelProvider" >+ name="Model Provider for bug 302163" >+ point="org.eclipse.core.resources.modelProviders"> >+ <modelProvider class="org.eclipse.team.tests.ccvs.core.mappings.model.mapping.CustomModelProvider"/> >+ <extends-model id="org.eclipse.core.resources.modelProvider"/> >+ <enablement> >+ <test property="org.eclipse.core.resources.projectNature" value="org.eclipse.team.tests.cvs.core.bug302163_ModelNature" /> >+ </enablement> >+ </extension> > </plugin> >Index: src/org/eclipse/team/tests/ccvs/core/mappings/model/mapping/CustomModelProvider.java >=================================================================== >RCS file: src/org/eclipse/team/tests/ccvs/core/mappings/model/mapping/CustomModelProvider.java >diff -N src/org/eclipse/team/tests/ccvs/core/mappings/model/mapping/CustomModelProvider.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/team/tests/ccvs/core/mappings/model/mapping/CustomModelProvider.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,45 @@ >+/******************************************************************************* >+ * Copyright (c) 2010 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 >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.team.tests.ccvs.core.mappings.model.mapping; >+ >+import org.eclipse.core.resources.*; >+import org.eclipse.core.resources.mapping.*; >+import org.eclipse.core.runtime.*; >+import org.eclipse.team.tests.ccvs.core.mappings.model.*; >+ >+/** >+ * The model provider for our example >+ */ >+public class CustomModelProvider extends >+ org.eclipse.core.resources.mapping.ModelProvider { >+ >+ public static final String ID = "org.eclipse.team.tests.cvs.core.bug302163_ModelProvider"; >+ >+ public CustomModelProvider() { >+ super(); >+ } >+ >+ public IStatus validateChange(IResourceDelta delta, IProgressMonitor monitor) { >+ return super.validateChange(delta, monitor); >+ } >+ >+ public ResourceMapping[] getMappings(IResource resource, >+ ResourceMappingContext context, IProgressMonitor monitor) >+ throws CoreException { >+ if (ModelProject.isModProject(resource.getProject())) { >+ ModelObject object = ModelObject.create(resource); >+ if (object != null) >+ return new ResourceMapping[] { ModelResourceMapping >+ .create(object) }; >+ } >+ return super.getMappings(resource, context, monitor); >+ } >+} >Index: src/org/eclipse/team/tests/ccvs/core/mappings/model/ModelFile.java >=================================================================== >RCS file: src/org/eclipse/team/tests/ccvs/core/mappings/model/ModelFile.java >diff -N src/org/eclipse/team/tests/ccvs/core/mappings/model/ModelFile.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/team/tests/ccvs/core/mappings/model/ModelFile.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,54 @@ >+/******************************************************************************* >+ * Copyright (c) 2010 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 >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.team.tests.ccvs.core.mappings.model; >+ >+import java.util.ArrayList; >+import java.util.List; >+ >+import org.eclipse.core.resources.*; >+import org.eclipse.core.runtime.*; >+ >+public class ModelFile extends ModelObject { >+ >+ public static final String MODEL_FILE_EXTENSION = "mod"; >+ >+ public static boolean isModFile(IResource resource) { >+ if (resource instanceof IFile) { >+ String fileExtension = resource.getFileExtension(); >+ if (fileExtension != null) >+ return fileExtension.equals(MODEL_FILE_EXTENSION); >+ } >+ return false; >+ } >+ >+ public static IResource[] getReferencedResources(String projectName, >+ IStorage storage) { >+ if (storage == null) >+ return new IResource[0]; >+ List result = new ArrayList(); >+ return (IResource[]) result.toArray(new IResource[result.size()]); >+ } >+ >+ public ModelFile(IFile file) { >+ super(file); >+ } >+ >+ public ModelObject[] getChildren() throws CoreException { >+ return null; >+ } >+ >+ public String getName() { >+ String name = super.getName(); >+ int index = name.lastIndexOf("."); >+ return name.substring(0, index); >+ } >+ >+} >Index: src/org/eclipse/team/tests/ccvs/core/mappings/model/mapping/ModelResourceMapping.java >=================================================================== >RCS file: src/org/eclipse/team/tests/ccvs/core/mappings/model/mapping/ModelResourceMapping.java >diff -N src/org/eclipse/team/tests/ccvs/core/mappings/model/mapping/ModelResourceMapping.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/team/tests/ccvs/core/mappings/model/mapping/ModelResourceMapping.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,76 @@ >+/******************************************************************************* >+ * Copyright (c) 2010 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 >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.team.tests.ccvs.core.mappings.model.mapping; >+ >+import org.eclipse.core.resources.IProject; >+import org.eclipse.core.resources.IResource; >+import org.eclipse.core.resources.ResourcesPlugin; >+import org.eclipse.core.resources.mapping.ResourceMapping; >+import org.eclipse.core.resources.mapping.ResourceMappingContext; >+import org.eclipse.core.resources.mapping.ResourceTraversal; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.team.tests.ccvs.core.mappings.model.*; >+ >+public class ModelResourceMapping extends ResourceMapping { >+ >+ public static String projectName = ""; >+ private final ModelObject object; >+ >+ public static ResourceMapping create(ModelObject object) { >+ if (object instanceof ModelProject) { >+ return new ModelResourceMapping(object); >+ } >+ if (object instanceof ModelFile) { >+ return new ModelResourceMapping(object); >+ } >+ return null; >+ } >+ >+ public ResourceTraversal[] getTraversals(ResourceMappingContext context, >+ IProgressMonitor monitor) throws CoreException { >+ return new ResourceTraversal[] { new ResourceTraversal( >+ new IResource[] { ResourcesPlugin.getWorkspace().getRoot() >+ .getProject(projectName).getFile("file1.txt") }, >+ IResource.DEPTH_ZERO, IResource.NONE) }; >+ } >+ >+ protected ModelResourceMapping(ModelObject object) { >+ this.object = object; >+ } >+ >+ public Object getModelObject() { >+ return object; >+ } >+ >+ public String getModelProviderId() { >+ return CustomModelProvider.ID; >+ } >+ >+ public IProject[] getProjects() { >+ return new IProject[] { (IProject) object.getProject().getResource() }; >+ } >+ >+ public boolean contains(ResourceMapping mapping) { >+ if (mapping instanceof ModelResourceMapping) { >+ ModelObject object = (ModelObject) mapping.getModelObject(); >+ IResource resource = object.getResource(); >+ return getResource().getFullPath().isPrefixOf( >+ resource.getFullPath()); >+ } >+ return false; >+ } >+ >+ private IResource getResource() { >+ return ((ModelProject) getModelObject()).getResource(); >+ } >+ >+} >Index: src/org/eclipse/team/tests/ccvs/core/mappings/model/ModelNature.java >=================================================================== >RCS file: src/org/eclipse/team/tests/ccvs/core/mappings/model/ModelNature.java >diff -N src/org/eclipse/team/tests/ccvs/core/mappings/model/ModelNature.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/team/tests/ccvs/core/mappings/model/ModelNature.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,41 @@ >+/******************************************************************************* >+ * Copyright (c) 2010 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 >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.team.tests.ccvs.core.mappings.model; >+ >+import org.eclipse.core.resources.IProject; >+import org.eclipse.core.resources.IProjectNature; >+ >+/** >+ * Nature used to identify a model project >+ */ >+public class ModelNature implements IProjectNature { >+ >+ public static final String NATURE_ID = "org.eclipse.team.tests.cvs.core.bug302163_ModelNature"; >+ >+ private IProject project; >+ >+ public void configure() { >+ // Nothing to do >+ } >+ >+ public void deconfigure() { >+ // Nothing to do >+ } >+ >+ public IProject getProject() { >+ return project; >+ } >+ >+ public void setProject(IProject project) { >+ this.project = project; >+ } >+ >+} >Index: src/org/eclipse/team/tests/ccvs/core/mappings/model/ModelObject.java >=================================================================== >RCS file: src/org/eclipse/team/tests/ccvs/core/mappings/model/ModelObject.java >diff -N src/org/eclipse/team/tests/ccvs/core/mappings/model/ModelObject.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/team/tests/ccvs/core/mappings/model/ModelObject.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,74 @@ >+/******************************************************************************* >+ * Copyright (c) 2010 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 >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.team.tests.ccvs.core.mappings.model; >+ >+import org.eclipse.core.resources.*; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.PlatformObject; >+ >+public abstract class ModelObject extends PlatformObject { >+ >+ private final IResource resource; >+ >+ public static ModelObject create(IResource resource) { >+ switch (resource.getType()) { >+ case IResource.PROJECT: >+ return new ModelProject((IProject) resource); >+ case IResource.FILE: >+ if (ModelFile.isModFile(resource)) { >+ return new ModelFile((IFile) resource); >+ } >+ } >+ return null; >+ } >+ >+ protected ModelObject(IResource resource) { >+ this.resource = resource; >+ } >+ >+ public abstract ModelObject[] getChildren() throws CoreException; >+ >+ public IResource getResource() { >+ return resource; >+ } >+ >+ public String getName() { >+ return getResource().getName(); >+ } >+ >+ public String getPath() { >+ return getResource().getFullPath().makeRelative().toString(); >+ } >+ >+ public ModelObject getParent() { >+ return ModelObject.create(getResource().getParent()); >+ } >+ >+ public boolean equals(Object obj) { >+ if (obj instanceof ModelObject) { >+ ModelObject mr = (ModelObject) obj; >+ return getResource().equals(mr.getResource()); >+ } >+ return super.equals(obj); >+ } >+ >+ public int hashCode() { >+ return getResource().hashCode(); >+ } >+ >+ public void delete() throws CoreException { >+ getResource().delete(false, null); >+ } >+ >+ public ModelProject getProject() { >+ return (ModelProject) ModelObject.create(getResource().getProject()); >+ } >+} >Index: src/org/eclipse/team/tests/ccvs/core/mappings/model/ModelProject.java >=================================================================== >RCS file: src/org/eclipse/team/tests/ccvs/core/mappings/model/ModelProject.java >diff -N src/org/eclipse/team/tests/ccvs/core/mappings/model/ModelProject.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/team/tests/ccvs/core/mappings/model/ModelProject.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,70 @@ >+/******************************************************************************* >+ * Copyright (c) 2010 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 >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.team.tests.ccvs.core.mappings.model; >+ >+import java.util.ArrayList; >+import java.util.List; >+ >+import org.eclipse.core.resources.IContainer; >+import org.eclipse.core.resources.IFile; >+import org.eclipse.core.resources.IProject; >+import org.eclipse.core.resources.IProjectDescription; >+import org.eclipse.core.resources.IResource; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IProgressMonitor; >+ >+public class ModelProject extends ModelObject { >+ >+ public static boolean isModProject(IProject project) throws CoreException { >+ if (!project.isOpen()) >+ return false; >+ IProjectDescription description = project.getDescription(); >+ return description.hasNature(ModelNature.NATURE_ID); >+ } >+ >+ public static void makeModProject(IProject project, IProgressMonitor monitor) >+ throws CoreException { >+ IProjectDescription description = project.getDescription(); >+ String[] natureIds = description.getNatureIds(); >+ List result = new ArrayList(); >+ for (int i = 0; i < natureIds.length; i++) { >+ result.add(natureIds[i]); >+ } >+ result.add(ModelNature.NATURE_ID); >+ description.setNatureIds((String[]) result.toArray(new String[result >+ .size()])); >+ project.setDescription(description, monitor); >+ } >+ >+ public ModelProject(IProject project) { >+ super(project); >+ } >+ >+ protected IContainer getContainer() { >+ return (IContainer) getResource(); >+ } >+ >+ public ModelObject[] getChildren() throws CoreException { >+ IResource[] members = getContainer().members(); >+ List result = new ArrayList(); >+ for (int i = 0; i < members.length; i++) { >+ IResource resource = members[i]; >+ if (ModelFile.isModFile(resource)) { >+ result.add(new ModelFile((IFile) resource)); >+ } else if (resource instanceof IProject >+ && ModelProject.isModProject((IProject) resource)) { >+ result.add(new ModelProject((IProject) resource)); >+ } >+ } >+ return (ModelObject[]) result.toArray(new ModelObject[result.size()]); >+ } >+ >+}
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 306508
:
163295
| 163389