diff options
Diffstat (limited to 'bundles/org.eclipse.team.core/src/org/eclipse')
45 files changed, 2421 insertions, 2421 deletions
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/IFileContentManager.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/IFileContentManager.java index e8c63f69c..bbc9a275c 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/IFileContentManager.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/IFileContentManager.java @@ -46,145 +46,145 @@ import org.eclipse.core.resources.IStorage; */ public interface IFileContentManager { - /** - * Get the content type for a given instance of <code>IStorage</code>. User-defined mappings - * take precedence over plugin-contributed mappings; further, mappings for the entire file name - * take precedence over mappings for the file extension only. - * - * @param storage the instance of <code>IStorage</code>. - * @return one of <code>Team.UNKNOWN</code>, <code>Team.TEXT</code> or <code>Team.BINARY</code>. - * - * @since 3.1 - */ - int getType(IStorage storage); - - /** - * Check whether the given file name is assigned to a specific type in the content type registry. - * @param filename the file name to check for - * @return True if the file name is registered in the system and assigned to a content type, false - * if the file name is unknown. - * - * @since 3.1 - */ - boolean isKnownFilename(String filename); - - /** - * Check whether the given file extension is assigned to a specific type in the content type registry. - * @param extension the extension to check for - * @return True if the extension is registered in the system and assigned to a content type, false - * if the extension is unknown. - * - * @since 3.1 - */ - boolean isKnownExtension(String extension); - - /** - * Get the content type for a given file name. - * @param filename The file name - * @return one of <code>Team.UNKNOWN</code>, <code>Team.TEXT</code> or <code>Team.BINARY</code>. - * - * @since 3.1 - */ - int getTypeForName(String filename); - - /** - * Get the content type for a given file extension. - * @param extension The extension - * @return one of <code>Team.UNKNOWN</code>, <code>Team.TEXT</code> or <code>Team.BINARY</code>. - * - * @since 3.1 - */ - int getTypeForExtension(String extension); - - /** - * Map a set of file names to a set of content types and save the mappings in - * the preferences. Already existing mappings for these file names are updated - * with the new ones, other mappings will be preserved. - * - * @param names The file names - * @param types The corresponding types, each one being one of - * <code>Team.UNKNOWN</code>,<code>Team.TEXT</code> or - * <code>Team.BINARY</code>. - * - * @since 3.1 - */ - void addNameMappings(String[] names, int[] types); - - /** - * Map a set of file extensions to a set of content types and save the mapping in - * the preferences. Already existing mappings for these extensions are updated - * with the new ones, other mappings will be preserved. - * - * @param extensions The extensions - * @param types The corresponding types, each one being one of - * <code>Team.UNKNOWN</code>,<code>Team.TEXT</code> or - * <code>Team.BINARY</code>. - * - * @since 3.1 - */ - void addExtensionMappings(String[] extensions, int[] types); - - /** - * Map a set of file names to a set of content types and save the mappings in - * the preferences. All existing user-defined mappings for <b>any - * </b> file names are deleted and replaced by the new ones. - * - * @param names The file names - * @param types The corresponding types, each one being one of - * <code>Team.UNKNOWN</code>,<code>Team.TEXT</code> or - * <code>Team.BINARY</code>. - * - * @since 3.1 - */ - void setNameMappings(String[] names, int[] types); - - /** - * Map a set of file extensions to a set of content types and save the - * mapping in the preferences. All existing user-defined mappings for <b>any - * </b> file extensions are deleted and replaced by the new ones. - * - * @param extensions The extensions - * @param types The corresponding types, each one being one of - * <code>Team.UNKNOWN</code>,<code>Team.TEXT</code> or - * <code>Team.BINARY</code>. - * - * @since 3.1 - */ - void setExtensionMappings(String[] extensions, int[] types); - - /** - * Get all the currently defined mappings from file names to content types. - * - * @return the mappings - * - * @since 3.1 - */ - IStringMapping [] getNameMappings(); - - /** - * Get all the currently defined mappings from file names to content types. - * - * @return the mappings - * - * @since 3.1 - */ - IStringMapping [] getExtensionMappings(); - - /** - * Get all the plugin-contributed mappings from file names to content types. - * - * @return the mappings - * - * @since 3.1 - */ - IStringMapping [] getDefaultNameMappings(); - - /** - * Get all the plugin-contributed mappings from file extensions to content types. - * - * @return the mappings - - * @since 3.1 - */ - IStringMapping [] getDefaultExtensionMappings(); + /** + * Get the content type for a given instance of <code>IStorage</code>. User-defined mappings + * take precedence over plugin-contributed mappings; further, mappings for the entire file name + * take precedence over mappings for the file extension only. + * + * @param storage the instance of <code>IStorage</code>. + * @return one of <code>Team.UNKNOWN</code>, <code>Team.TEXT</code> or <code>Team.BINARY</code>. + * + * @since 3.1 + */ + int getType(IStorage storage); + + /** + * Check whether the given file name is assigned to a specific type in the content type registry. + * @param filename the file name to check for + * @return True if the file name is registered in the system and assigned to a content type, false + * if the file name is unknown. + * + * @since 3.1 + */ + boolean isKnownFilename(String filename); + + /** + * Check whether the given file extension is assigned to a specific type in the content type registry. + * @param extension the extension to check for + * @return True if the extension is registered in the system and assigned to a content type, false + * if the extension is unknown. + * + * @since 3.1 + */ + boolean isKnownExtension(String extension); + + /** + * Get the content type for a given file name. + * @param filename The file name + * @return one of <code>Team.UNKNOWN</code>, <code>Team.TEXT</code> or <code>Team.BINARY</code>. + * + * @since 3.1 + */ + int getTypeForName(String filename); + + /** + * Get the content type for a given file extension. + * @param extension The extension + * @return one of <code>Team.UNKNOWN</code>, <code>Team.TEXT</code> or <code>Team.BINARY</code>. + * + * @since 3.1 + */ + int getTypeForExtension(String extension); + + /** + * Map a set of file names to a set of content types and save the mappings in + * the preferences. Already existing mappings for these file names are updated + * with the new ones, other mappings will be preserved. + * + * @param names The file names + * @param types The corresponding types, each one being one of + * <code>Team.UNKNOWN</code>,<code>Team.TEXT</code> or + * <code>Team.BINARY</code>. + * + * @since 3.1 + */ + void addNameMappings(String[] names, int[] types); + + /** + * Map a set of file extensions to a set of content types and save the mapping in + * the preferences. Already existing mappings for these extensions are updated + * with the new ones, other mappings will be preserved. + * + * @param extensions The extensions + * @param types The corresponding types, each one being one of + * <code>Team.UNKNOWN</code>,<code>Team.TEXT</code> or + * <code>Team.BINARY</code>. + * + * @since 3.1 + */ + void addExtensionMappings(String[] extensions, int[] types); + + /** + * Map a set of file names to a set of content types and save the mappings in + * the preferences. All existing user-defined mappings for <b>any + * </b> file names are deleted and replaced by the new ones. + * + * @param names The file names + * @param types The corresponding types, each one being one of + * <code>Team.UNKNOWN</code>,<code>Team.TEXT</code> or + * <code>Team.BINARY</code>. + * + * @since 3.1 + */ + void setNameMappings(String[] names, int[] types); + + /** + * Map a set of file extensions to a set of content types and save the + * mapping in the preferences. All existing user-defined mappings for <b>any + * </b> file extensions are deleted and replaced by the new ones. + * + * @param extensions The extensions + * @param types The corresponding types, each one being one of + * <code>Team.UNKNOWN</code>,<code>Team.TEXT</code> or + * <code>Team.BINARY</code>. + * + * @since 3.1 + */ + void setExtensionMappings(String[] extensions, int[] types); + + /** + * Get all the currently defined mappings from file names to content types. + * + * @return the mappings + * + * @since 3.1 + */ + IStringMapping [] getNameMappings(); + + /** + * Get all the currently defined mappings from file names to content types. + * + * @return the mappings + * + * @since 3.1 + */ + IStringMapping [] getExtensionMappings(); + + /** + * Get all the plugin-contributed mappings from file names to content types. + * + * @return the mappings + * + * @since 3.1 + */ + IStringMapping [] getDefaultNameMappings(); + + /** + * Get all the plugin-contributed mappings from file extensions to content types. + * + * @return the mappings + + * @since 3.1 + */ + IStringMapping [] getDefaultExtensionMappings(); } diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/IStringMapping.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/IStringMapping.java index f62bbe399..ac54d1ddd 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/IStringMapping.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/IStringMapping.java @@ -24,21 +24,21 @@ package org.eclipse.team.core; */ public interface IStringMapping { - /** - * The string part of the mapping - * - * @return the string - * - * @since 3.1 - */ - String getString(); + /** + * The string part of the mapping + * + * @return the string + * + * @since 3.1 + */ + String getString(); - /** - * The content type associated with the string - * - * @return the content type - * - * @since 3.1 - */ - int getType(); + /** + * The content type associated with the string + * + * @return the content type + * + * @since 3.1 + */ + int getType(); } diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/ProjectSetCapability.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/ProjectSetCapability.java index e2a5c5e19..b6473385a 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/ProjectSetCapability.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/ProjectSetCapability.java @@ -244,9 +244,9 @@ public abstract class ProjectSetCapability { IProject eachProj = projects[i]; if (eachProj.exists()) { existingProjects.add(eachProj); - } else if (new File(eachProj.getParent().getLocation().toFile(), eachProj.getName()).exists()) { - existingProjects.add(eachProj); - } + } else if (new File(eachProj.getParent().getLocation().toFile(), eachProj.getName()).exists()) { + existingProjects.add(eachProj); + } } if (existingProjects.size() == 0) return projects; diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/RepositoryProvider.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/RepositoryProvider.java index d2f4c70f9..8e4ba1259 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/RepositoryProvider.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/RepositoryProvider.java @@ -100,8 +100,8 @@ public abstract class RepositoryProvider implements IProjectNature, IAdaptable { // lock to ensure that map/unmap and getProvider support concurrency private static final ILock mappingLock = Job.getJobManager().newLock(); - // Session property used to identify projects that are not mapped - private static final Object NOT_MAPPED = new Object(); + // Session property used to identify projects that are not mapped + private static final Object NOT_MAPPED = new Object(); /** * Instantiate a new RepositoryProvider with concrete class by given providerID @@ -330,10 +330,10 @@ public abstract class RepositoryProvider implements IProjectNature, IAdaptable { */ private static RepositoryProvider lookupProviderProp(IProject project) throws CoreException { Object provider = project.getSessionProperty(TeamPlugin.PROVIDER_PROP_KEY); - if (provider instanceof RepositoryProvider) { - return (RepositoryProvider) provider; - } - return null; + if (provider instanceof RepositoryProvider) { + return (RepositoryProvider) provider; + } + return null; } @@ -394,12 +394,12 @@ public abstract class RepositoryProvider implements IProjectNature, IAdaptable { /** * Returns an <code>IFileModificationValidator</code> for pre-checking operations - * that modify the contents of files. - * Returns <code>null</code> if the provider does not wish to participate in - * file modification validation. + * that modify the contents of files. + * Returns <code>null</code> if the provider does not wish to participate in + * file modification validation. * @return an <code>IFileModificationValidator</code> for pre-checking operations - * that modify the contents of files - * + * that modify the contents of files + * * @see org.eclipse.core.resources.IFileModificationValidator * @deprecated use {@link #getFileModificationValidator2()} */ @@ -460,7 +460,7 @@ public abstract class RepositoryProvider implements IProjectNature, IAdaptable { * @since 3.2 */ public IFileHistoryProvider getFileHistoryProvider(){ - return null; + return null; } /** @@ -532,10 +532,10 @@ public abstract class RepositoryProvider implements IProjectNature, IAdaptable { RepositoryProvider provider = lookupProviderProp(project); if(provider != null) return provider; - // Do a quick check to see it the project is known to be unshared. - // This is done to avoid accessing the persistent property store - if (isMarkedAsUnshared(project)) - return null; + // Do a quick check to see it the project is known to be unshared. + // This is done to avoid accessing the persistent property store + if (isMarkedAsUnshared(project)) + return null; // ----------------------------- //Next, check if it has the ID as a persistent property, if yes then instantiate provider @@ -603,10 +603,10 @@ public abstract class RepositoryProvider implements IProjectNature, IAdaptable { return null; } } - // Do a quick check to see it the project is known to be unshared. - // This is done to avoid accessing the persistent property store - if (isMarkedAsUnshared(project)) - return null; + // Do a quick check to see it the project is known to be unshared. + // This is done to avoid accessing the persistent property store + if (isMarkedAsUnshared(project)) + return null; // There isn't one so check the persistent property String existingID = project.getPersistentProperty(TeamPlugin.PROVIDER_PROP_KEY); @@ -666,14 +666,14 @@ public abstract class RepositoryProvider implements IProjectNature, IAdaptable { if (!project.isAccessible()) return false; try { if (lookupProviderProp(project) != null) return true; - // Do a quick check to see it the project is known to be unshared. - // This is done to avoid accessing the persistent property store - if (isMarkedAsUnshared(project)) - return false; + // Do a quick check to see it the project is known to be unshared. + // This is done to avoid accessing the persistent property store + if (isMarkedAsUnshared(project)) + return false; boolean shared = project.getPersistentProperty(TeamPlugin.PROVIDER_PROP_KEY) != null; - if (!shared) - markAsUnshared(project); - return shared; + if (!shared) + markAsUnshared(project); + return shared; } catch (CoreException e) { TeamPlugin.log(e); return false; @@ -681,20 +681,20 @@ public abstract class RepositoryProvider implements IProjectNature, IAdaptable { } private static boolean isMarkedAsUnshared(IProject project) { - try { - return project.getSessionProperty(TeamPlugin.PROVIDER_PROP_KEY) == NOT_MAPPED; - } catch (CoreException e) { - return false; - } - } - - private static void markAsUnshared(IProject project) { - try { - project.setSessionProperty(TeamPlugin.PROVIDER_PROP_KEY, NOT_MAPPED); - } catch (CoreException e) { - // Just ignore the error as this is just an optimization - } - } + try { + return project.getSessionProperty(TeamPlugin.PROVIDER_PROP_KEY) == NOT_MAPPED; + } catch (CoreException e) { + return false; + } + } + + private static void markAsUnshared(IProject project) { + try { + project.setSessionProperty(TeamPlugin.PROVIDER_PROP_KEY, NOT_MAPPED); + } catch (CoreException e) { + // Just ignore the error as this is just an optimization + } + } @Override public IProject getProject() { diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/RepositoryProviderType.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/RepositoryProviderType.java index 219100a99..62ca83791 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/RepositoryProviderType.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/RepositoryProviderType.java @@ -233,9 +233,9 @@ public abstract class RepositoryProviderType extends PlatformObject { * or in any way modify workspace resources (including auto-sharing the project). However, * auto-sharing (or other modification) could be performed by a background job scheduled from * this callback. - * - * @since 3.1 - * + * + * @since 3.1 + * * @param project the project that contains the detected meta-files. * @param containers the folders (possibly including the project folder) in which meta-files were found */ diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/Team.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/Team.java index 480c90177..d65e49f24 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/Team.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/Team.java @@ -65,25 +65,25 @@ import org.eclipse.team.internal.core.importing.BundleImporterExtension; */ public final class Team { - private static class StringMappingWrapper implements IFileTypeInfo { + private static class StringMappingWrapper implements IFileTypeInfo { - private final IStringMapping fMapping; + private final IStringMapping fMapping; - public StringMappingWrapper(IStringMapping mapping) { - fMapping= mapping; - } + public StringMappingWrapper(IStringMapping mapping) { + fMapping= mapping; + } - @Override + @Override public String getExtension() { - return fMapping.getString(); - } + return fMapping.getString(); + } - @Override + @Override public int getType() { - return fMapping.getType(); - } + return fMapping.getType(); + } - } + } private static final String PREF_TEAM_IGNORES = "ignore_files"; //$NON-NLS-1$ private static final String PREF_TEAM_SEPARATOR = "\n"; //$NON-NLS-1$ @@ -99,19 +99,19 @@ public final class Team { protected static SortedMap<String, Boolean> globalIgnore, pluginIgnore; private static StringMatcher[] ignoreMatchers; - private final static FileContentManager fFileContentManager; + private final static FileContentManager fFileContentManager; private static List<IBundleImporter> fBundleImporters; - static { - fFileContentManager= new FileContentManager(); - } + static { + fFileContentManager= new FileContentManager(); + } /** - * Return the type of the given IStorage. First, we check whether a mapping has - * been defined for the name of the IStorage. If this is not the case, we check for - * a mapping with the extension. If no mapping is defined, UNKNOWN is returned. + * Return the type of the given IStorage. First, we check whether a mapping has + * been defined for the name of the IStorage. If this is not the case, we check for + * a mapping with the extension. If no mapping is defined, UNKNOWN is returned. * * Valid return values are: * Team.TEXT @@ -120,12 +120,12 @@ public final class Team { * * @param storage the IStorage * @return whether the given IStorage is TEXT, BINARY, or UNKNOWN - * - * @deprecated Use <code>getFileContentManager().getType(IStorage storage)</code> instead. + * + * @deprecated Use <code>getFileContentManager().getType(IStorage storage)</code> instead. */ @Deprecated public static int getType(IStorage storage) { - return fFileContentManager.getType(storage); + return fFileContentManager.getType(storage); } /** @@ -179,19 +179,19 @@ public final class Team { /** - * Return all known file types. + * Return all known file types. * * @return all known file types - * @deprecated Use <code>getFileContentManager().getExtensionMappings()</code> instead. + * @deprecated Use <code>getFileContentManager().getExtensionMappings()</code> instead. */ @Deprecated public static IFileTypeInfo[] getAllTypes() { - final IStringMapping [] mappings= fFileContentManager.getExtensionMappings(); - final IFileTypeInfo [] infos= new IFileTypeInfo[mappings.length]; - for (int i = 0; i < infos.length; i++) { - infos[i]= new StringMappingWrapper(mappings[i]); - } - return infos; + final IStringMapping [] mappings= fFileContentManager.getExtensionMappings(); + final IFileTypeInfo [] infos= new IFileTypeInfo[mappings.length]; + for (int i = 0; i < infos.length; i++) { + infos[i]= new StringMappingWrapper(mappings[i]); + } + return infos; } /** @@ -262,8 +262,8 @@ public final class Team { /** - * Set the file type for the give extensions. This - * will replace the existing file types with this new list. + * Set the file type for the give extensions. This + * will replace the existing file types with this new list. * * Valid types are: * Team.TEXT @@ -272,12 +272,12 @@ public final class Team { * * @param extensions the file extensions * @param types the file types - * - * @deprecated Use <code>getFileContentManager().setExtensionMappings()</code> instead. + * + * @deprecated Use <code>getFileContentManager().setExtensionMappings()</code> instead. */ @Deprecated public static void setAllTypes(String[] extensions, int[] types) { - fFileContentManager.addExtensionMappings(extensions, types); + fFileContentManager.addExtensionMappings(extensions, types); } /** @@ -529,40 +529,40 @@ public final class Team { } /** - * TODO: change to file content manager + * TODO: change to file content manager * Return the default file type bindings * (i.e. those that are specified in * plugin manifests). * @return the default file type bindings * @since 3.0 - * @deprecated Use Team.getFileContentManager().getDefaultExtensionMappings() instead. + * @deprecated Use Team.getFileContentManager().getDefaultExtensionMappings() instead. */ @Deprecated public static IFileTypeInfo[] getDefaultTypes() { - return asFileTypeInfo(getFileContentManager().getDefaultExtensionMappings()); + return asFileTypeInfo(getFileContentManager().getDefaultExtensionMappings()); } - private static IFileTypeInfo [] asFileTypeInfo(IStringMapping [] mappings) { - final IFileTypeInfo [] infos= new IFileTypeInfo[mappings.length]; - for (int i = 0; i < infos.length; i++) { - infos[i]= new StringMappingWrapper(mappings[i]); - } - return infos; - } - - /** - * Get the file content manager which implements the API for manipulating the mappings between - * file names, file extensions and content types. - * - * @return an instance of IFileContentManager - * - * @see IFileContentManager - * - * @since 3.1 - */ - public static IFileContentManager getFileContentManager() { - return fFileContentManager; - } + private static IFileTypeInfo [] asFileTypeInfo(IStringMapping [] mappings) { + final IFileTypeInfo [] infos= new IFileTypeInfo[mappings.length]; + for (int i = 0; i < infos.length; i++) { + infos[i]= new StringMappingWrapper(mappings[i]); + } + return infos; + } + + /** + * Get the file content manager which implements the API for manipulating the mappings between + * file names, file extensions and content types. + * + * @return an instance of IFileContentManager + * + * @see IFileContentManager + * + * @since 3.1 + */ + public static IFileContentManager getFileContentManager() { + return fFileContentManager; + } /** * Creates a storage merger for the given content type. @@ -574,9 +574,9 @@ public final class Team { * * @since 3.4 */ - public static IStorageMerger createMerger(IContentType type) { - return StorageMergerRegistry.getInstance().createStreamMerger(type); - } + public static IStorageMerger createMerger(IContentType type) { + return StorageMergerRegistry.getInstance().createStreamMerger(type); + } /** * Creates a storage merger for the given file extension. @@ -588,9 +588,9 @@ public final class Team { * * @since 3.4 */ - public static IStorageMerger createMerger(String extension) { - return StorageMergerRegistry.getInstance().createStreamMerger(extension); - } + public static IStorageMerger createMerger(String extension) { + return StorageMergerRegistry.getInstance().createStreamMerger(extension); + } /** * Creates a storage merger for the given content type. @@ -602,10 +602,10 @@ public final class Team { * @deprecated Use {@link #createMerger(IContentType)} instead. * @since 3.2 */ - @Deprecated + @Deprecated public IStorageMerger createStorageMerger(IContentType type) { - return createMerger(type); - } + return createMerger(type); + } /** * Creates a storage merger for the given file extension. @@ -617,10 +617,10 @@ public final class Team { * @deprecated Use {@link #createMerger(String)} instead. * @since 3.2 */ - @Deprecated + @Deprecated public IStorageMerger createStorageMerger(String extension) { - return createMerger(extension); - } + return createMerger(extension); + } /** * Returns the available bundle importers. diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/TeamException.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/TeamException.java index 1a9cb6870..d97a47cb6 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/TeamException.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/TeamException.java @@ -32,10 +32,10 @@ import org.eclipse.team.internal.core.TeamPlugin; */ public class TeamException extends CoreException { - // Field required to avoid compiler warning + // Field required to avoid compiler warning private static final long serialVersionUID = 1L; - // The operation completed successfully. + // The operation completed successfully. public static final int OK = 0; // The operation failed because the resource is not checked-in. diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/history/IFileRevision.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/history/IFileRevision.java index a4bdf84c3..80fcc52ea 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/history/IFileRevision.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/history/IFileRevision.java @@ -102,8 +102,8 @@ public interface IFileRevision { * Returns the branches names of file revision. * * @return an array of ITag's if branch names exist for this revision - * or an empty ITag array if no names exist - * @since 3.6 + * or an empty ITag array if no names exist + * @since 3.6 */ public ITag[] getBranches(); diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/mapping/IResourceMappingMerger.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/mapping/IResourceMappingMerger.java index 36a95954f..1180d7bdf 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/mapping/IResourceMappingMerger.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/mapping/IResourceMappingMerger.java @@ -49,7 +49,7 @@ import org.eclipse.core.runtime.jobs.ISchedulingRule; */ public interface IResourceMappingMerger { - /** + /** * Attempt to automatically merge the mappings of the merge context(<code>MergeContext#getMappings()</code>). * The merge context provides access to the out-of-sync resources (<code>MergeContext#getSyncInfoTree()</code>) * associated with the mappings to be merged. The set of provided mappings @@ -86,48 +86,48 @@ public interface IResourceMappingMerger { * <code>MergeStatus#getConflictingMappings()</code> * @throws CoreException if errors occurred */ - public IStatus merge(IMergeContext mergeContext, - IProgressMonitor monitor) throws CoreException; + public IStatus merge(IMergeContext mergeContext, + IProgressMonitor monitor) throws CoreException; - /** - * Return the scheduling rule that is required to merge - * all the changes that apply to this merger in the given - * context. When calling {@link #merge(IMergeContext, IProgressMonitor)}, - * clients must ensure that they either have obtained - * a rule that covers the rule returned by this method or - * they must not hold any rule. - * @param context the context that contains the changes to be merged - * @return the scheduling rule required by this merger to merge all - * the changes in the given context belonging to the merger's - * model provider. - */ - public ISchedulingRule getMergeRule(IMergeContext context); + /** + * Return the scheduling rule that is required to merge + * all the changes that apply to this merger in the given + * context. When calling {@link #merge(IMergeContext, IProgressMonitor)}, + * clients must ensure that they either have obtained + * a rule that covers the rule returned by this method or + * they must not hold any rule. + * @param context the context that contains the changes to be merged + * @return the scheduling rule required by this merger to merge all + * the changes in the given context belonging to the merger's + * model provider. + */ + public ISchedulingRule getMergeRule(IMergeContext context); - /** - * Validate an auto-merge for the given context. This - * method must be invoked for all mergers involved - * in the merge before the auto-merge is attempted. - * The purpose of the validation is to indicate whether there - * are conditions in the merge context that make an auto-merge - * undesirable. The purpose is not to indicate that conflicts - * exist (this is done by the <code>merge</code> method) but instead - * to indicate that the nature of one of more incoming changes - * is such that performing an auto-merge may be undesirable. - * <p> - * Clients should validate before performing the merge and, if - * any of the returned status are not OK, should prompt the - * user to make them aware of the potential side effects. - * The user may still decide to attempt an auto-merge, in which case - * the client may still invoke the <code>merge</code> method. - * + /** + * Validate an auto-merge for the given context. This + * method must be invoked for all mergers involved + * in the merge before the auto-merge is attempted. + * The purpose of the validation is to indicate whether there + * are conditions in the merge context that make an auto-merge + * undesirable. The purpose is not to indicate that conflicts + * exist (this is done by the <code>merge</code> method) but instead + * to indicate that the nature of one of more incoming changes + * is such that performing an auto-merge may be undesirable. + * <p> + * Clients should validate before performing the merge and, if + * any of the returned status are not OK, should prompt the + * user to make them aware of the potential side effects. + * The user may still decide to attempt an auto-merge, in which case + * the client may still invoke the <code>merge</code> method. + * * @param mergeContext a context that provides access to the resources * involved in the merge. The context must not be * <code>null</code>. * @param monitor a progress monitor - * @return a status indicating any potential side effects of - * performing an auto-merge. - */ - public IStatus validateMerge(IMergeContext mergeContext, - IProgressMonitor monitor); + * @return a status indicating any potential side effects of + * performing an auto-merge. + */ + public IStatus validateMerge(IMergeContext mergeContext, + IProgressMonitor monitor); } diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/mapping/IStorageMerger.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/mapping/IStorageMerger.java index 5fcbdd1c0..53d3327ab 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/mapping/IStorageMerger.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/mapping/IStorageMerger.java @@ -33,46 +33,46 @@ import org.eclipse.core.runtime.IStatus; */ public interface IStorageMerger { - /** - * Indicates the successful completion of the merge operation (value <code>IStatus.OK</code>) - */ - public static final int OK= IStatus.OK; + /** + * Indicates the successful completion of the merge operation (value <code>IStatus.OK</code>) + */ + public static final int OK= IStatus.OK; - /** - * Indicates that a change conflict prevented the merge from successful completion (value <code>1</code>) - */ - public static final int CONFLICT= 1; + /** + * Indicates that a change conflict prevented the merge from successful completion (value <code>1</code>) + */ + public static final int CONFLICT= 1; - /** - * Status code describing an internal error (value <code>2</code>) - */ - public static final int INTERNAL_ERROR= 2; + /** + * Status code describing an internal error (value <code>2</code>) + */ + public static final int INTERNAL_ERROR= 2; - /** - * Indicates that at least one of the encodings associated with the input was unsupported (value <code>3</code>) - */ - public static final int UNSUPPORTED_ENCODING= 3; + /** + * Indicates that at least one of the encodings associated with the input was unsupported (value <code>3</code>) + */ + public static final int UNSUPPORTED_ENCODING= 3; - /** - * Performs a merge operation on the given storage instances and writes the merge result to the output stream. - * On success a status <code>IStatus.OK</code> is returned, on error a status <code>IStatus.ERROR</code>. - * If the merge operation cannot deal with conflicts, the code of the error status has the value <code>IStreamMerger.CONFLICT</code>. - * For text oriented mergers the encoding for the input and output is honored if they implement - * {@link IEncodedStorage}. - * It is the responsibility of callers to close the output stream. - * <p> - * The provided ancestor may be <code>null</code> if this merger - * returns <code>true</code> from {@link #canMergeWithoutAncestor()}. - * - * @param output the byte stream to which the merge result is written; the merger will not close the stream - * @param outputEncoding the encoding to use when writing to the output stream - * @param ancestor the storage from which the common ancestor is read - * @param target the storage containing the target of the merge - * @param other the storage containing the target of the merge - * @param monitor reports progress of the merge operation - * @return returns the completion status of the operation - * @throws CoreException if an error occurs - */ + /** + * Performs a merge operation on the given storage instances and writes the merge result to the output stream. + * On success a status <code>IStatus.OK</code> is returned, on error a status <code>IStatus.ERROR</code>. + * If the merge operation cannot deal with conflicts, the code of the error status has the value <code>IStreamMerger.CONFLICT</code>. + * For text oriented mergers the encoding for the input and output is honored if they implement + * {@link IEncodedStorage}. + * It is the responsibility of callers to close the output stream. + * <p> + * The provided ancestor may be <code>null</code> if this merger + * returns <code>true</code> from {@link #canMergeWithoutAncestor()}. + * + * @param output the byte stream to which the merge result is written; the merger will not close the stream + * @param outputEncoding the encoding to use when writing to the output stream + * @param ancestor the storage from which the common ancestor is read + * @param target the storage containing the target of the merge + * @param other the storage containing the target of the merge + * @param monitor reports progress of the merge operation + * @return returns the completion status of the operation + * @throws CoreException if an error occurs + */ IStatus merge(OutputStream output, String outputEncoding, IStorage ancestor, IStorage target, IStorage other, IProgressMonitor monitor) throws CoreException; diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/mapping/ResourceMappingMerger.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/mapping/ResourceMappingMerger.java index 37ef3cbcd..b3c994661 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/mapping/ResourceMappingMerger.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/mapping/ResourceMappingMerger.java @@ -61,10 +61,10 @@ public abstract class ResourceMappingMerger implements IResourceMappingMerger { * changes in the context for the model provider of this merger. * By default, return a rule that covers all the projects for the mappings * that belong to the model provider of this merger. - * @param context the context that contains the changes to be merged - * @return the scheduling rule required by this merger to merge all - * the changes in the given context belonging to the merger's - * model provider. + * @param context the context that contains the changes to be merged + * @return the scheduling rule required by this merger to merge all + * the changes in the given context belonging to the merger's + * model provider. * @see org.eclipse.team.core.mapping.IResourceMappingMerger#getMergeRule(org.eclipse.team.core.mapping.IMergeContext) */ @Override diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/mapping/provider/MergeContext.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/mapping/provider/MergeContext.java index f30286846..5a29fe4ea 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/mapping/provider/MergeContext.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/mapping/provider/MergeContext.java @@ -79,11 +79,11 @@ public abstract class MergeContext extends SynchronizationContext implements IMe * @param type the type of synchronization (ONE_WAY or TWO_WAY) * @param deltaTree the sync info tree that contains all out-of-sync resources */ - protected MergeContext(ISynchronizationScopeManager manager, int type, IResourceDiffTree deltaTree) { - super(manager, type, deltaTree); - } + protected MergeContext(ISynchronizationScopeManager manager, int type, IResourceDiffTree deltaTree) { + super(manager, type, deltaTree); + } - @Override + @Override public void reject(final IDiff[] diffs, IProgressMonitor monitor) throws CoreException { run(monitor1 -> { for (int i = 0; i < diffs.length; i++) { @@ -91,9 +91,9 @@ public abstract class MergeContext extends SynchronizationContext implements IMe reject(node, monitor1); } }, getMergeRule(diffs), IResource.NONE, monitor); - } + } - @Override + @Override public void markAsMerged(final IDiff[] nodes, final boolean inSyncHint, IProgressMonitor monitor) throws CoreException { run(monitor1 -> { for (int i = 0; i < nodes.length; i++) { @@ -101,9 +101,9 @@ public abstract class MergeContext extends SynchronizationContext implements IMe markAsMerged(node, inSyncHint, monitor1); } }, getMergeRule(nodes), IResource.NONE, monitor); - } + } - @Override + @Override public IStatus merge(final IDiff[] deltas, final boolean force, IProgressMonitor monitor) throws CoreException { final List<IFile> failedFiles = new ArrayList<>(); run(monitor1 -> { @@ -129,7 +129,7 @@ public abstract class MergeContext extends SynchronizationContext implements IMe } else { return new MergeStatus(TeamPlugin.ID, Messages.MergeContext_0, failedFiles.toArray(new IFile[failedFiles.size()])); } - } + } @Override public IStatus merge(IDiff diff, boolean ignoreLocalChanges, IProgressMonitor monitor) throws CoreException { @@ -156,30 +156,30 @@ public abstract class MergeContext extends SynchronizationContext implements IMe } return Status.OK_STATUS; } - if (diff instanceof IThreeWayDiff && !ignoreLocalChanges && getMergeType() == THREE_WAY) { + if (diff instanceof IThreeWayDiff && !ignoreLocalChanges && getMergeType() == THREE_WAY) { IThreeWayDiff twDelta = (IThreeWayDiff) diff; - int direction = twDelta.getDirection(); - if (direction == IThreeWayDiff.OUTGOING) { - // There's nothing to do so return OK - return Status.OK_STATUS; - } - if (direction == IThreeWayDiff.INCOMING) { - // Just copy the stream since there are no conflicts - performReplace(diff, monitor); - return Status.OK_STATUS; - } + int direction = twDelta.getDirection(); + if (direction == IThreeWayDiff.OUTGOING) { + // There's nothing to do so return OK + return Status.OK_STATUS; + } + if (direction == IThreeWayDiff.INCOMING) { + // Just copy the stream since there are no conflicts + performReplace(diff, monitor); + return Status.OK_STATUS; + } // direction == SyncInfo.CONFLICTING - int type = twDelta.getKind(); - if (type == IDiff.REMOVE) { - makeInSync(diff, monitor); - return Status.OK_STATUS; - } + int type = twDelta.getKind(); + if (type == IDiff.REMOVE) { + makeInSync(diff, monitor); + return Status.OK_STATUS; + } // type == SyncInfo.CHANGE IResourceDiff remoteChange = (IResourceDiff)twDelta.getRemoteChange(); IFileRevision remote = null; - if (remoteChange != null) { - remote = remoteChange.getAfterState(); - } + if (remoteChange != null) { + remote = remoteChange.getAfterState(); + } if (remote == null || !getLocalFile(diff).exists()) { // Nothing we can do so return a conflict status // TODO: Should we handle the case where the local and remote have the same contents for a conflicting addition? @@ -187,11 +187,11 @@ public abstract class MergeContext extends SynchronizationContext implements IMe } // We have a conflict, a local, base and remote so we can do // a three-way merge - return performThreeWayMerge(twDelta, monitor); - } else { - performReplace(diff, monitor); - return Status.OK_STATUS; - } + return performThreeWayMerge(twDelta, monitor); + } else { + performReplace(diff, monitor); + return Status.OK_STATUS; + } } @@ -236,70 +236,70 @@ public abstract class MergeContext extends SynchronizationContext implements IMe status = new MergeStatus(status.getPlugin(), status.getMessage(), new IFile[]{file}); } result[0] = status; - } finally { - disposeTempOutputStream(file, os); - } - monitor1.done(); + } finally { + disposeTempOutputStream(file, os); + } + monitor1.done(); }, getMergeRule(diff), IWorkspace.AVOID_UPDATE, monitor); return result[0]; } - private void disposeTempOutputStream(IFile file, OutputStream output) { - if (output instanceof ByteArrayOutputStream) - return; - // We created a temporary file so we need to clean it up - try { - // First make sure the output stream is closed - // so that file deletion will not fail because of that. - if (output != null) - output.close(); - } catch (IOException e) { - // Ignore - } - File tmpFile = getTempFile(file); - if (tmpFile.exists()) - tmpFile.delete(); - } + private void disposeTempOutputStream(IFile file, OutputStream output) { + if (output instanceof ByteArrayOutputStream) + return; + // We created a temporary file so we need to clean it up + try { + // First make sure the output stream is closed + // so that file deletion will not fail because of that. + if (output != null) + output.close(); + } catch (IOException e) { + // Ignore + } + File tmpFile = getTempFile(file); + if (tmpFile.exists()) + tmpFile.delete(); + } - private OutputStream getTempOutputStream(IFile file) throws CoreException { - File tmpFile = getTempFile(file); - if (tmpFile.exists()) - tmpFile.delete(); - File parent = tmpFile.getParentFile(); - if (!parent.exists()) - parent.mkdirs(); - try { - return new BufferedOutputStream(new FileOutputStream(tmpFile)); - } catch (FileNotFoundException e) { - TeamPlugin.log(IStatus.ERROR, NLS.bind("Could not open temporary file {0} for writing: {1}", new String[] { tmpFile.getAbsolutePath(), e.getMessage() }), e); //$NON-NLS-1$ - return new ByteArrayOutputStream(); - } - } + private OutputStream getTempOutputStream(IFile file) throws CoreException { + File tmpFile = getTempFile(file); + if (tmpFile.exists()) + tmpFile.delete(); + File parent = tmpFile.getParentFile(); + if (!parent.exists()) + parent.mkdirs(); + try { + return new BufferedOutputStream(new FileOutputStream(tmpFile)); + } catch (FileNotFoundException e) { + TeamPlugin.log(IStatus.ERROR, NLS.bind("Could not open temporary file {0} for writing: {1}", new String[] { tmpFile.getAbsolutePath(), e.getMessage() }), e); //$NON-NLS-1$ + return new ByteArrayOutputStream(); + } + } - private InputStream getTempInputStream(IFile file, OutputStream output) throws CoreException { - if (output instanceof ByteArrayOutputStream) { - ByteArrayOutputStream baos = (ByteArrayOutputStream) output; - return new ByteArrayInputStream(baos.toByteArray()); - } - // We created a temporary file so we need to open an input stream on it - try { - // First make sure the output stream is closed - if (output != null) - output.close(); - } catch (IOException e) { - // Ignore - } - File tmpFile = getTempFile(file); - try { - return new BufferedInputStream(new FileInputStream(tmpFile)); - } catch (FileNotFoundException e) { - throw new CoreException(new Status(IStatus.ERROR, TeamPlugin.ID, IMergeStatus.INTERNAL_ERROR, NLS.bind(Messages.MergeContext_4, new String[] { tmpFile.getAbsolutePath(), e.getMessage() }), e)); - } - } + private InputStream getTempInputStream(IFile file, OutputStream output) throws CoreException { + if (output instanceof ByteArrayOutputStream) { + ByteArrayOutputStream baos = (ByteArrayOutputStream) output; + return new ByteArrayInputStream(baos.toByteArray()); + } + // We created a temporary file so we need to open an input stream on it + try { + // First make sure the output stream is closed + if (output != null) + output.close(); + } catch (IOException e) { + // Ignore + } + File tmpFile = getTempFile(file); + try { + return new BufferedInputStream(new FileInputStream(tmpFile)); + } catch (FileNotFoundException e) { + throw new CoreException(new Status(IStatus.ERROR, TeamPlugin.ID, IMergeStatus.INTERNAL_ERROR, NLS.bind(Messages.MergeContext_4, new String[] { tmpFile.getAbsolutePath(), e.getMessage() }), e)); + } + } - private File getTempFile(IFile file) { - return TeamPlugin.getPlugin().getStateLocation().append(".tmp").append(file.getName() + ".tmp").toFile(); //$NON-NLS-1$ //$NON-NLS-2$ - } + private File getTempFile(IFile file) { + return TeamPlugin.getPlugin().getStateLocation().append(".tmp").append(file.getName() + ".tmp").toFile(); //$NON-NLS-1$ //$NON-NLS-2$ + } private IFile getLocalFile(IDiff delta) { return ResourcesPlugin.getWorkspace().getRoot().getFile(delta.getPath()); @@ -321,31 +321,31 @@ public abstract class MergeContext extends SynchronizationContext implements IMe * a progress monitor * @throws CoreException */ - protected void performReplace(final IDiff diff, IProgressMonitor monitor) throws CoreException { - IResourceDiff d; - IFile file = getLocalFile(diff); - IFileRevision remote = null; - if (diff instanceof IResourceDiff) { - d = (IResourceDiff) diff; - remote = d.getAfterState(); - } else { - d = (IResourceDiff)((IThreeWayDiff)diff).getRemoteChange(); - if (d != null) - remote = d.getAfterState(); - } - if (d == null) { - d = (IResourceDiff)((IThreeWayDiff)diff).getLocalChange(); - if (d != null) - remote = d.getBeforeState(); - } + protected void performReplace(final IDiff diff, IProgressMonitor monitor) throws CoreException { + IResourceDiff d; + IFile file = getLocalFile(diff); + IFileRevision remote = null; + if (diff instanceof IResourceDiff) { + d = (IResourceDiff) diff; + remote = d.getAfterState(); + } else { + d = (IResourceDiff)((IThreeWayDiff)diff).getRemoteChange(); + if (d != null) + remote = d.getAfterState(); + } + if (d == null) { + d = (IResourceDiff)((IThreeWayDiff)diff).getLocalChange(); + if (d != null) + remote = d.getBeforeState(); + } - // Only perform the replace if a local or remote change was found - if (d != null) { - performReplace(diff, file, remote, monitor); - } + // Only perform the replace if a local or remote change was found + if (d != null) { + performReplace(diff, file, remote, monitor); + } } - /** + /** * Method that is invoked from * {@link #performReplace(IDiff, IProgressMonitor)} after the local has been * changed to match the remote. Subclasses may override @@ -361,7 +361,7 @@ public abstract class MergeContext extends SynchronizationContext implements IMe * a progress monitor * @throws CoreException */ - protected abstract void makeInSync(IDiff diff, IProgressMonitor monitor) throws CoreException; + protected abstract void makeInSync(IDiff diff, IProgressMonitor monitor) throws CoreException; private void performReplace(final IDiff diff, final IFile file, final IFileRevision remote, IProgressMonitor monitor) throws CoreException { run(monitor1 -> { diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/mapping/provider/MergeStatus.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/mapping/provider/MergeStatus.java index cf272544a..675fbd21c 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/mapping/provider/MergeStatus.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/mapping/provider/MergeStatus.java @@ -34,40 +34,40 @@ import org.eclipse.team.core.mapping.IMergeStatus; */ public class MergeStatus extends Status implements IMergeStatus { - private ResourceMapping[] conflictingMappings; + private ResourceMapping[] conflictingMappings; private IFile[] conflictingFiles; - /** - * Create a merge status for reporting that some of the resource mappings - * for which a merge was attempted were not auto-mergable. - * @param pluginId the plugin id - * @param message the message for the status - * @param conflictingMappings the mappings which were not auto-mergable - */ - public MergeStatus(String pluginId, String message, ResourceMapping[] conflictingMappings) { - super(IStatus.ERROR, pluginId, CONFLICTS, message, null); - this.conflictingMappings = conflictingMappings; - } + /** + * Create a merge status for reporting that some of the resource mappings + * for which a merge was attempted were not auto-mergable. + * @param pluginId the plugin id + * @param message the message for the status + * @param conflictingMappings the mappings which were not auto-mergable + */ + public MergeStatus(String pluginId, String message, ResourceMapping[] conflictingMappings) { + super(IStatus.ERROR, pluginId, CONFLICTS, message, null); + this.conflictingMappings = conflictingMappings; + } - /** - * Create a merge status for reporting that some of the files - * for which a merge was attempted were not auto-mergable. - * @param pluginId the plugin id - * @param message the message for the status - * @param files the files which were not auto-mergable - */ - public MergeStatus(String pluginId, String message, IFile[] files) { - super(IStatus.ERROR, pluginId, CONFLICTS, message, null); - this.conflictingFiles = files; + /** + * Create a merge status for reporting that some of the files + * for which a merge was attempted were not auto-mergable. + * @param pluginId the plugin id + * @param message the message for the status + * @param files the files which were not auto-mergable + */ + public MergeStatus(String pluginId, String message, IFile[] files) { + super(IStatus.ERROR, pluginId, CONFLICTS, message, null); + this.conflictingFiles = files; } - @Override + @Override public ResourceMapping[] getConflictingMappings() { - return conflictingMappings; - } + return conflictingMappings; + } - @Override + @Override public IFile[] getConflictingFiles() { - return conflictingFiles; - } + return conflictingFiles; + } } diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/mapping/provider/SynchronizationContext.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/mapping/provider/SynchronizationContext.java index 75708813d..89349c548 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/mapping/provider/SynchronizationContext.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/mapping/provider/SynchronizationContext.java @@ -36,22 +36,22 @@ import org.eclipse.team.internal.core.Policy; */ public abstract class SynchronizationContext extends PlatformObject implements ISynchronizationContext { - private final int type; - private final IResourceDiffTree diffTree; - private Cache cache; + private final int type; + private final IResourceDiffTree diffTree; + private Cache cache; private final ISynchronizationScopeManager manager; - /** - * Create a synchronization context. - * @param manager the manager that defines the scope of the synchronization - * @param type the type of synchronization (ONE_WAY or TWO_WAY) - * @param diffTree the sync info tree that contains all out-of-sync resources - */ - protected SynchronizationContext(ISynchronizationScopeManager manager, int type, IResourceDiffTree diffTree) { - this.manager = manager; + /** + * Create a synchronization context. + * @param manager the manager that defines the scope of the synchronization + * @param type the type of synchronization (ONE_WAY or TWO_WAY) + * @param diffTree the sync info tree that contains all out-of-sync resources + */ + protected SynchronizationContext(ISynchronizationScopeManager manager, int type, IResourceDiffTree diffTree) { + this.manager = manager; this.type = type; this.diffTree = diffTree; - } + } @Override public ISynchronizationScope getScope() { diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/SubscriberResourceMappingContext.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/SubscriberResourceMappingContext.java index 3df0805ad..b1f3d8817 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/SubscriberResourceMappingContext.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/SubscriberResourceMappingContext.java @@ -45,126 +45,126 @@ import org.eclipse.team.internal.core.TeamPlugin; */ public class SubscriberResourceMappingContext extends RemoteResourceMappingContext { - private final Subscriber subscriber; + private final Subscriber subscriber; - // Lists used to keep track of resources that have been refreshed - private Set<IResource> shallowRefresh = new HashSet<>(); - private Set<IResource> deepRefresh = new HashSet<>(); - private boolean autoRefresh; + // Lists used to keep track of resources that have been refreshed + private Set<IResource> shallowRefresh = new HashSet<>(); + private Set<IResource> deepRefresh = new HashSet<>(); + private boolean autoRefresh; - /** - * Return a resource mapping context suitable for comparison operations. - * Comparisons require that any out-of-sync resources have contents - * that differ. - * @param subscriber the subscriber - * @return a resource mapping context suitable for compare operations - */ - public static RemoteResourceMappingContext createContext(Subscriber subscriber) { - return new SubscriberResourceMappingContext(subscriber, true); - } + /** + * Return a resource mapping context suitable for comparison operations. + * Comparisons require that any out-of-sync resources have contents + * that differ. + * @param subscriber the subscriber + * @return a resource mapping context suitable for compare operations + */ + public static RemoteResourceMappingContext createContext(Subscriber subscriber) { + return new SubscriberResourceMappingContext(subscriber, true); + } - /** - * Create a resource mapping context for the given subscriber - * @param subscriber the subscriber - * from the local contents - * @param autoRefresh whether the context should auto-refresh when queried - */ - public SubscriberResourceMappingContext(Subscriber subscriber, boolean autoRefresh) { - this.subscriber = subscriber; - this.autoRefresh = autoRefresh; - } + /** + * Create a resource mapping context for the given subscriber + * @param subscriber the subscriber + * from the local contents + * @param autoRefresh whether the context should auto-refresh when queried + */ + public SubscriberResourceMappingContext(Subscriber subscriber, boolean autoRefresh) { + this.subscriber = subscriber; + this.autoRefresh = autoRefresh; + } - @Override + @Override public final boolean hasRemoteChange(IResource resource, IProgressMonitor monitor) throws CoreException { - try { + try { monitor.beginTask(null, 100); ensureRefreshed(resource, IResource.DEPTH_ONE, NONE, monitor); SyncInfo syncInfo = subscriber.getSyncInfo(resource); validateRemote(resource, syncInfo); - if (syncInfo == null) return false; - int direction = SyncInfo.getDirection(syncInfo.getKind()); + if (syncInfo == null) return false; + int direction = SyncInfo.getDirection(syncInfo.getKind()); return direction == SyncInfo.INCOMING || direction == SyncInfo.CONFLICTING; } finally { monitor.done(); } - } + } - @Override + @Override public boolean hasLocalChange(IResource resource, IProgressMonitor monitor) throws CoreException { - SyncInfo syncInfo = subscriber.getSyncInfo(resource); - if (syncInfo == null) return false; - int direction = SyncInfo.getDirection(syncInfo.getKind()); + SyncInfo syncInfo = subscriber.getSyncInfo(resource); + if (syncInfo == null) return false; + int direction = SyncInfo.getDirection(syncInfo.getKind()); return direction == SyncInfo.OUTGOING || direction == SyncInfo.CONFLICTING; - } + } - @Override + @Override public final IStorage fetchRemoteContents(IFile file, IProgressMonitor monitor) throws CoreException { - try { + try { monitor.beginTask(null, 100); - ensureRefreshed(file, IResource.DEPTH_ZERO, FILE_CONTENTS_REQUIRED, Policy.subMonitorFor(monitor, 10)); - SyncInfo syncInfo = subscriber.getSyncInfo(file); - IResourceVariant remote = validateRemote(file, syncInfo); - if (remote == null) { - return null; - } - return remote.getStorage(Policy.subMonitorFor(monitor, 90)); + ensureRefreshed(file, IResource.DEPTH_ZERO, FILE_CONTENTS_REQUIRED, Policy.subMonitorFor(monitor, 10)); + SyncInfo syncInfo = subscriber.getSyncInfo(file); + IResourceVariant remote = validateRemote(file, syncInfo); + if (remote == null) { + return null; + } + return remote.getStorage(Policy.subMonitorFor(monitor, 90)); } finally { monitor.done(); } - } + } - @Override + @Override public final IStorage fetchBaseContents(IFile file, IProgressMonitor monitor) throws CoreException { - try { + try { monitor.beginTask(null, 100); - ensureRefreshed(file, IResource.DEPTH_ZERO, FILE_CONTENTS_REQUIRED, Policy.subMonitorFor(monitor, 10)); - SyncInfo syncInfo = subscriber.getSyncInfo(file); - IResourceVariant base = validateBase(file, syncInfo); - if (base == null) { - return null; - } - return base.getStorage(Policy.subMonitorFor(monitor, 90)); + ensureRefreshed(file, IResource.DEPTH_ZERO, FILE_CONTENTS_REQUIRED, Policy.subMonitorFor(monitor, 10)); + SyncInfo syncInfo = subscriber.getSyncInfo(file); + IResourceVariant base = validateBase(file, syncInfo); + if (base == null) { + return null; + } + return base.getStorage(Policy.subMonitorFor(monitor, 90)); } finally { monitor.done(); } - } + } - @Override + @Override public final IResource[] fetchMembers(IContainer container, IProgressMonitor monitor) throws CoreException { - try { + try { monitor.beginTask(null, 100); - ensureRefreshed(container, IResource.DEPTH_ONE, NONE, Policy.subMonitorFor(monitor, 100)); - SyncInfo syncInfo = subscriber.getSyncInfo(container); - if (validateRemote(container, syncInfo) == null) { - // There is no remote so return an empty array - return new IResource[0]; - } - return subscriber.members(container); + ensureRefreshed(container, IResource.DEPTH_ONE, NONE, Policy.subMonitorFor(monitor, 100)); + SyncInfo syncInfo = subscriber.getSyncInfo(container); + if (validateRemote(container, syncInfo) == null) { + // There is no remote so return an empty array + return new IResource[0]; + } + return subscriber.members(container); } finally { monitor.done(); } - } + } - @Override + @Override public final void refresh(ResourceTraversal[] traversals, int flags, IProgressMonitor monitor) throws CoreException { - subscriber.refresh(traversals, monitor); - for (int i = 0; i < traversals.length; i++) { + subscriber.refresh(traversals, monitor); + for (int i = 0; i < traversals.length; i++) { ResourceTraversal traversal = traversals[i]; refreshed(traversal.getResources(), traversal.getDepth()); } - } + } - /** - * Refresh the subscriber and cache the fact that the resources were refreshed by - * calling the <code>refreshed</code> method. The default implementation only refreshes - * the state and does not fetch contents in the <code>FILE_CONTENTS_REQUIRED</code> - * flag is passed. It is up to subclass to handle this. - * @param resources the resources to be refreshed - * @param depth the depth of the refresh - * @param flags the flags that indicate extra state that should be fetched - * @param monitor a progress monitor - * @throws TeamException - */ + /** + * Refresh the subscriber and cache the fact that the resources were refreshed by + * calling the <code>refreshed</code> method. The default implementation only refreshes + * the state and does not fetch contents in the <code>FILE_CONTENTS_REQUIRED</code> + * flag is passed. It is up to subclass to handle this. + * @param resources the resources to be refreshed + * @param depth the depth of the refresh + * @param flags the flags that indicate extra state that should be fetched + * @param monitor a progress monitor + * @throws TeamException + */ protected void refresh(IResource[] resources, int depth, int flags, IProgressMonitor monitor) throws TeamException { subscriber.refresh(resources, depth, monitor); refreshed(resources, depth); @@ -189,32 +189,32 @@ public class SubscriberResourceMappingContext extends RemoteResourceMappingConte } } - /* - * Ensure that the given resource has been refreshed to the specified depth - * since the context has been created. - */ - private void ensureRefreshed(IResource resource, int depth, int flags, IProgressMonitor monitor) throws TeamException { - if (autoRefresh) { - if (depth == IResource.DEPTH_INFINITE) { - // If the resource or a parent was refreshed deeply, no need to do it again - if (wasRefreshedDeeply(resource)) - return; - // if the resource is a file, a shallow refresh is enough - if (resource.getType() == IResource.FILE && wasRefreshedShallow(resource)) - return; - } else { - if (wasRefreshedShallow(resource)) - return; - } - refresh(new IResource[] { resource }, depth, flags, monitor); - } + /* + * Ensure that the given resource has been refreshed to the specified depth + * since the context has been created. + */ + private void ensureRefreshed(IResource resource, int depth, int flags, IProgressMonitor monitor) throws TeamException { + if (autoRefresh) { + if (depth == IResource.DEPTH_INFINITE) { + // If the resource or a parent was refreshed deeply, no need to do it again + if (wasRefreshedDeeply(resource)) + return; + // if the resource is a file, a shallow refresh is enough + if (resource.getType() == IResource.FILE && wasRefreshedShallow(resource)) + return; + } else { + if (wasRefreshedShallow(resource)) + return; + } + refresh(new IResource[] { resource }, depth, flags, monitor); + } } - /* - * Look for a shallow refresh of the resource. If not there, - * look fir a deep refresh of a parent or a shallow refresh of the - * direct parent if the resource is a file. - */ + /* + * Look for a shallow refresh of the resource. If not there, + * look fir a deep refresh of a parent or a shallow refresh of the + * direct parent if the resource is a file. + */ private boolean wasRefreshedShallow(IResource resource) { if (shallowRefresh.contains(resource)) return true; @@ -240,45 +240,45 @@ public class SubscriberResourceMappingContext extends RemoteResourceMappingConte * Validate that the remote resource is of the proper type and return the * remote resource if it is OK. A return of null indicates that there is no remote. */ - private IResourceVariant validateRemote(IResource resource, SyncInfo syncInfo) throws CoreException { - if (syncInfo == null) return null; - IResourceVariant remote = syncInfo.getRemote(); - if (remote == null) return null; - return validateRemote(resource, remote); - } + private IResourceVariant validateRemote(IResource resource, SyncInfo syncInfo) throws CoreException { + if (syncInfo == null) return null; + IResourceVariant remote = syncInfo.getRemote(); + if (remote == null) return null; + return validateRemote(resource, remote); + } private IResourceVariant validateRemote(IResource resource, IResourceVariant remote) throws CoreException { boolean containerExpected = resource.getType() != IResource.FILE; - if (remote.isContainer() && !containerExpected) { - throw new CoreException(new Status(IStatus.ERROR, TeamPlugin.ID, IResourceStatus.RESOURCE_WRONG_TYPE, Messages.SubscriberResourceMappingContext_0 + resource.getFullPath().toString(), null)); - } else if (!remote.isContainer() && containerExpected) { - throw new CoreException(new Status(IStatus.ERROR, TeamPlugin.ID, IResourceStatus.RESOURCE_WRONG_TYPE, Messages.SubscriberResourceMappingContext_1 + resource.getFullPath().toString(), null)); - } - return remote; + if (remote.isContainer() && !containerExpected) { + throw new CoreException(new Status(IStatus.ERROR, TeamPlugin.ID, IResourceStatus.RESOURCE_WRONG_TYPE, Messages.SubscriberResourceMappingContext_0 + resource.getFullPath().toString(), null)); + } else if (!remote.isContainer() && containerExpected) { + throw new CoreException(new Status(IStatus.ERROR, TeamPlugin.ID, IResourceStatus.RESOURCE_WRONG_TYPE, Messages.SubscriberResourceMappingContext_1 + resource.getFullPath().toString(), null)); + } + return remote; } /* * Validate that the base resource is of the proper type and return the * base resource if it is OK. A return of null indicates that there is no base. */ - private IResourceVariant validateBase(IResource resource, SyncInfo syncInfo) throws CoreException { - if (syncInfo == null) return null; - IResourceVariant base = syncInfo.getBase(); - if (base == null) return null; - return validateRemote(resource, base); - } + private IResourceVariant validateBase(IResource resource, SyncInfo syncInfo) throws CoreException { + if (syncInfo == null) return null; + IResourceVariant base = syncInfo.getBase(); + if (base == null) return null; + return validateRemote(resource, base); + } - /** - * Set whether the context should refresh the state of resources - * when their state is requested. The context keeps track of what - * resources were refreshed and only auto-refreshes a resource - * once. - * @param autoRefresh whether the context should refresh the state of resources - * when their state is requested - */ - public void setAutoRefresh(boolean autoRefresh) { - this.autoRefresh = autoRefresh; - } + /** + * Set whether the context should refresh the state of resources + * when their state is requested. The context keeps track of what + * resources were refreshed and only auto-refreshes a resource + * once. + * @param autoRefresh whether the context should refresh the state of resources + * when their state is requested + */ + public void setAutoRefresh(boolean autoRefresh) { + this.autoRefresh = autoRefresh; + } @Override public boolean isThreeWay() { diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/synchronize/SyncInfo.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/synchronize/SyncInfo.java index 91103b8c6..5e5ae3c40 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/synchronize/SyncInfo.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/synchronize/SyncInfo.java @@ -148,20 +148,20 @@ public class SyncInfo implements IAdaptable { /*==================================================================== * Members: *====================================================================*/ - private IResource local; - private IResourceVariant base; - private IResourceVariant remote; - private IResourceVariantComparator comparator; - - private int syncKind; - - /** - * Construct a sync info object. - * @param local the local resource. Must be non-null but may not exist. - * @param base the base resource variant or <code>null</code> - * @param remote the remote resource variant or <code>null</code> - * @param comparator the comparator used to determine if resources differ - */ + private IResource local; + private IResourceVariant base; + private IResourceVariant remote; + private IResourceVariantComparator comparator; + + private int syncKind; + + /** + * Construct a sync info object. + * @param local the local resource. Must be non-null but may not exist. + * @param base the base resource variant or <code>null</code> + * @param remote the remote resource variant or <code>null</code> + * @param comparator the comparator used to determine if resources differ + */ public SyncInfo(IResource local, IResourceVariant base, IResourceVariant remote, IResourceVariantComparator comparator) { Assert.isNotNull(local); Assert.isNotNull(comparator); diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/synchronize/SyncInfoSet.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/synchronize/SyncInfoSet.java index cd6b35f63..beb723704 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/synchronize/SyncInfoSet.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/synchronize/SyncInfoSet.java @@ -667,14 +667,14 @@ public class SyncInfoSet { return errors.values().toArray(new ITeamStatus[errors.size()]); } - /** - * Return an iterator over all <code>SyncInfo</code> - * contained in this set. - * @return an iterator over all <code>SyncInfo</code> - * contained in this set. - * @since 3.1 - */ - public Iterator iterator() { - return resources.values().iterator(); - } + /** + * Return an iterator over all <code>SyncInfo</code> + * contained in this set. + * @return an iterator over all <code>SyncInfo</code> + * contained in this set. + * @since 3.1 + */ + public Iterator iterator() { + return resources.values().iterator(); + } } diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/BackgroundEventHandler.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/BackgroundEventHandler.java index f1f2fbc29..0b6b9a1c8 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/BackgroundEventHandler.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/BackgroundEventHandler.java @@ -101,7 +101,7 @@ public abstract class BackgroundEventHandler { * General event class. The type is specific to subclasses. */ public static class Event { - private int type; + private int type; public Event(int type) { this.type = type; } @@ -116,7 +116,7 @@ public abstract class BackgroundEventHandler { return buffer.toString(); } public IResource getResource() { - return null; + return null; } protected String getTypeString() { return String.valueOf(type); @@ -130,7 +130,7 @@ public abstract class BackgroundEventHandler { private IResource resource; private int depth; public ResourceEvent(IResource resource, int type, int depth) { - super(type); + super(type); this.resource = resource; this.depth = depth; } @@ -249,14 +249,14 @@ public abstract class BackgroundEventHandler { /** * Return the family that the background job for this * event handler belongs to. - * @return the family that the background job for this + * @return the family that the background job for this * event handler belongs to - */ - protected Object getJobFamiliy() { - return null; - } + */ + protected Object getJobFamiliy() { + return null; + } - /** + /** * This method is invoked when the processing job completes. The * default behavior of the handler is to restart the job if the queue * is no longer empty and to clear the queue if the handler was shut down. @@ -467,28 +467,28 @@ public abstract class BackgroundEventHandler { return WAIT_DELAY; } - /** + /** * Return the value that is used to determine how often * the events are dispatched (i.e. how often the UI is * updated) for the first 3 cycles. The default value is 1.5 seconds. * After the first 3 cycles, a longer delay is used - * @return the dispatch delay used for the first 3 cycles. - */ - protected long getShortDispatchDelay() { - return DISPATCH_DELAY; - } + * @return the dispatch delay used for the first 3 cycles. + */ + protected long getShortDispatchDelay() { + return DISPATCH_DELAY; + } /** * Return the value that is used to determine how often * the events are dispatched (i.e. how often the UI is * updated) after the first 3 cycles. The default value is 10 seconds. - * @return the dispatch delay used after the first 3 cycles. - */ - protected long getLongDispatchDelay() { - return LONG_DISPATCH_DELAY; - } + * @return the dispatch delay used after the first 3 cycles. + */ + protected long getLongDispatchDelay() { + return LONG_DISPATCH_DELAY; + } - /** + /** * Handle the exception by recording it in the errors list. * @param e */ diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/DefaultFileModificationValidator.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/DefaultFileModificationValidator.java index 37f0f525b..a01b75680 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/DefaultFileModificationValidator.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/DefaultFileModificationValidator.java @@ -49,22 +49,22 @@ public class DefaultFileModificationValidator extends FileModificationValidator @Override public IStatus validateEdit(IFile[] files, FileModificationValidationContext context) { - IFile[] readOnlyFiles = getReadOnly(files); - if (readOnlyFiles.length == 0) - return Status.OK_STATUS; - synchronized (this) { - if (uiValidator == null) - uiValidator = loadUIValidator(); - } - if (uiValidator != null) { - return uiValidator.validateEdit(files, context); - } - // There was no plugged in validator so fail gracefully + IFile[] readOnlyFiles = getReadOnly(files); + if (readOnlyFiles.length == 0) + return Status.OK_STATUS; + synchronized (this) { + if (uiValidator == null) + uiValidator = loadUIValidator(); + } + if (uiValidator != null) { + return uiValidator.validateEdit(files, context); + } + // There was no plugged in validator so fail gracefully return getStatus(files); } - protected IStatus getStatus(IFile[] files) { - if (files.length == 1) { + protected IStatus getStatus(IFile[] files) { + if (files.length == 1) { return getDefaultStatus(files[0]); } @@ -83,51 +83,51 @@ public class DefaultFileModificationValidator extends FileModificationValidator ? Messages.ok : Messages.FileModificationValidator_someReadOnly, null); - } + } - private IFile[] getReadOnly(IFile[] files) { - List<IFile> result = new ArrayList<>(files.length); - for (int i = 0; i < files.length; i++) { - IFile file = files[i]; - if (file.isReadOnly()) { - result.add(file); - } - } - return result.toArray(new IFile[result.size()]); - } + private IFile[] getReadOnly(IFile[] files) { + List<IFile> result = new ArrayList<>(files.length); + for (int i = 0; i < files.length; i++) { + IFile file = files[i]; + if (file.isReadOnly()) { + result.add(file); + } + } + return result.toArray(new IFile[result.size()]); + } @Override public IStatus validateSave(IFile file) { - if (!file.isReadOnly()) - return Status.OK_STATUS; - synchronized (this) { - if (uiValidator == null) - uiValidator = loadUIValidator(); - } - if (uiValidator != null) { - return uiValidator.validateSave(file); - } + if (!file.isReadOnly()) + return Status.OK_STATUS; + synchronized (this) { + if (uiValidator == null) + uiValidator = loadUIValidator(); + } + if (uiValidator != null) { + return uiValidator.validateSave(file); + } return getDefaultStatus(file); } - private FileModificationValidator loadUIValidator() { - IExtensionPoint extension = Platform.getExtensionRegistry().getExtensionPoint(TeamPlugin.ID, TeamPlugin.DEFAULT_FILE_MODIFICATION_VALIDATOR_EXTENSION); + private FileModificationValidator loadUIValidator() { + IExtensionPoint extension = Platform.getExtensionRegistry().getExtensionPoint(TeamPlugin.ID, TeamPlugin.DEFAULT_FILE_MODIFICATION_VALIDATOR_EXTENSION); if (extension != null) { IExtension[] extensions = extension.getExtensions(); if (extensions.length > 0) { IConfigurationElement[] configElements = extensions[0].getConfigurationElements(); if (configElements.length > 0) { try { - Object o = configElements[0].createExecutableExtension("class"); //$NON-NLS-1$ - if (o instanceof FileModificationValidator) { - return (FileModificationValidator)o; - } - } catch (CoreException e) { - TeamPlugin.log(e); - } + Object o = configElements[0].createExecutableExtension("class"); //$NON-NLS-1$ + if (o instanceof FileModificationValidator) { + return (FileModificationValidator)o; + } + } catch (CoreException e) { + TeamPlugin.log(e); + } } } } return null; - } + } } diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/ExceptionCollector.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/ExceptionCollector.java index d2e177404..8c956d1a9 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/ExceptionCollector.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/ExceptionCollector.java @@ -94,19 +94,19 @@ public class ExceptionCollector { * @param exception the exception to collect */ public void handleException(CoreException exception) { - // log the exception if we have a log - if(log != null) { - log.log(new Status(severity, pluginId, 0, message, exception)); - } - // Record each status individually to flatten the resulting multi-status - IStatus exceptionStatus = exception.getStatus(); - // Wrap the exception so the stack trace is not lost. - IStatus status = new Status(exceptionStatus.getSeverity(), exceptionStatus.getPlugin(), exceptionStatus.getCode(), exceptionStatus.getMessage(), exception); - recordStatus(status); + // log the exception if we have a log + if(log != null) { + log.log(new Status(severity, pluginId, 0, message, exception)); + } + // Record each status individually to flatten the resulting multi-status + IStatus exceptionStatus = exception.getStatus(); + // Wrap the exception so the stack trace is not lost. + IStatus status = new Status(exceptionStatus.getSeverity(), exceptionStatus.getPlugin(), exceptionStatus.getCode(), exceptionStatus.getMessage(), exception); + recordStatus(status); IStatus[] children = status.getChildren(); for (int i = 0; i < children.length; i++) { IStatus status2 = children[i]; - recordStatus(status2); + recordStatus(status2); } } diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/FileContentManager.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/FileContentManager.java index 2ef473292..4c7dd374f 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/FileContentManager.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/FileContentManager.java @@ -40,236 +40,236 @@ import org.eclipse.team.core.Team; */ public class FileContentManager implements IFileContentManager { - private static final String PREF_TEAM_EXTENSION_TYPES= "file_types"; //$NON-NLS-1$ - private static final String PREF_TEAM_FILENAME_TYPES= "cvs_mode_for_file_without_extensions"; //$NON-NLS-1$ + private static final String PREF_TEAM_EXTENSION_TYPES= "file_types"; //$NON-NLS-1$ + private static final String PREF_TEAM_FILENAME_TYPES= "cvs_mode_for_file_without_extensions"; //$NON-NLS-1$ - private static class StringMapping implements IStringMapping { + private static class StringMapping implements IStringMapping { - private final String fString; - private final int fType; + private final String fString; + private final int fType; - public StringMapping(String string, int type) { - fString= string; - fType= type; - } + public StringMapping(String string, int type) { + fString= string; + fType= type; + } - @Override + @Override public String getString() { - return fString; - } + return fString; + } - @Override + @Override public int getType() { - return fType; - } - } + return fType; + } + } - private static class UserExtensionMappings extends UserStringMappings { + private static class UserExtensionMappings extends UserStringMappings { - public UserExtensionMappings(String key) { - super(key); - } + public UserExtensionMappings(String key) { + super(key); + } - @Override + @Override protected Map<String, Integer> loadMappingsFromPreferences() { - final Map<String, Integer> result= super.loadMappingsFromPreferences(); - if (loadMappingsFromOldWorkspace(result)) { - TeamPlugin.getPlugin().savePluginPreferences(); - } - return result; - } - - /** - * If the workspace is an old 2.0 one, read the old file and delete it. - * - * @param A map where the new mappings should be added. - * - * @return true if the workspace was a 2.0 one and the old mappings have - * been added to the map, false otherwise. - * - */ - private boolean loadMappingsFromOldWorkspace(Map<String, Integer> map) { - // File name of the persisted file type information - String STATE_FILE = ".fileTypes"; //$NON-NLS-1$ - IPath pluginStateLocation = TeamPlugin.getPlugin().getStateLocation().append(STATE_FILE); - File f = pluginStateLocation.toFile(); - - if (!f.exists()) - return false; - - try { - DataInputStream input = new DataInputStream(new FileInputStream(f)); - try { - map.putAll(readOldFormatExtensionMappings(input)); - } finally { - input.close(); - f.delete(); - } - } catch (IOException ex) { - TeamPlugin.log(IStatus.ERROR, ex.getMessage(), ex); - return false; - } - return true; - } - - /** - * Read the saved file type state from the given input stream. - * - * @param input the input stream to read the saved state from - * @throws IOException if an I/O problem occurs - */ - private Map<String, Integer> readOldFormatExtensionMappings(DataInputStream input) throws IOException { - final Map<String, Integer> result= new TreeMap<>(); - int numberOfMappings = 0; - try { - numberOfMappings = input.readInt(); - } catch (EOFException e) { - // Ignore the exception, it will occur if there are no - // patterns stored in the state file. - return Collections.emptyMap(); - } - for (int i = 0; i < numberOfMappings; i++) { - final String extension = input.readUTF(); - final int type = input.readInt(); - result.put(extension, Integer.valueOf(type)); - } - return result; - } - } - - private final UserStringMappings fUserExtensionMappings, fUserNameMappings; - private PluginStringMappings fPluginExtensionMappings;//, fPluginNameMappings; - private IContentType textContentType; - - public FileContentManager() { - fUserExtensionMappings= new UserExtensionMappings(PREF_TEAM_EXTENSION_TYPES); - fUserNameMappings= new UserStringMappings(PREF_TEAM_FILENAME_TYPES); - fPluginExtensionMappings= new PluginStringMappings(TeamPlugin.FILE_TYPES_EXTENSION, "extension"); //$NON-NLS-1$ - } - - @Override + final Map<String, Integer> result= super.loadMappingsFromPreferences(); + if (loadMappingsFromOldWorkspace(result)) { + TeamPlugin.getPlugin().savePluginPreferences(); + } + return result; + } + + /** + * If the workspace is an old 2.0 one, read the old file and delete it. + * + * @param A map where the new mappings should be added. + * + * @return true if the workspace was a 2.0 one and the old mappings have + * been added to the map, false otherwise. + * + */ + private boolean loadMappingsFromOldWorkspace(Map<String, Integer> map) { + // File name of the persisted file type information + String STATE_FILE = ".fileTypes"; //$NON-NLS-1$ + IPath pluginStateLocation = TeamPlugin.getPlugin().getStateLocation().append(STATE_FILE); + File f = pluginStateLocation.toFile(); + + if (!f.exists()) + return false; + + try { + DataInputStream input = new DataInputStream(new FileInputStream(f)); + try { + map.putAll(readOldFormatExtensionMappings(input)); + } finally { + input.close(); + f.delete(); + } + } catch (IOException ex) { + TeamPlugin.log(IStatus.ERROR, ex.getMessage(), ex); + return false; + } + return true; + } + + /** + * Read the saved file type state from the given input stream. + * + * @param input the input stream to read the saved state from + * @throws IOException if an I/O problem occurs + */ + private Map<String, Integer> readOldFormatExtensionMappings(DataInputStream input) throws IOException { + final Map<String, Integer> result= new TreeMap<>(); + int numberOfMappings = 0; + try { + numberOfMappings = input.readInt(); + } catch (EOFException e) { + // Ignore the exception, it will occur if there are no + // patterns stored in the state file. + return Collections.emptyMap(); + } + for (int i = 0; i < numberOfMappings; i++) { + final String extension = input.readUTF(); + final int type = input.readInt(); + result.put(extension, Integer.valueOf(type)); + } + return result; + } + } + + private final UserStringMappings fUserExtensionMappings, fUserNameMappings; + private PluginStringMappings fPluginExtensionMappings;//, fPluginNameMappings; + private IContentType textContentType; + + public FileContentManager() { + fUserExtensionMappings= new UserExtensionMappings(PREF_TEAM_EXTENSION_TYPES); + fUserNameMappings= new UserStringMappings(PREF_TEAM_FILENAME_TYPES); + fPluginExtensionMappings= new PluginStringMappings(TeamPlugin.FILE_TYPES_EXTENSION, "extension"); //$NON-NLS-1$ + } + + @Override public int getTypeForName(String filename) { - final int userType= fUserNameMappings.getType(filename); + final int userType= fUserNameMappings.getType(filename); // final int pluginType= fPluginNameMappings.getType(filename); // return userType != Team.UNKNOWN ? userType : pluginType; - return userType; - } + return userType; + } - @Override + @Override public int getTypeForExtension(String extension) { - final int userType= fUserExtensionMappings.getType(extension); - final int pluginType= fPluginExtensionMappings.getType(extension); - return userType != Team.UNKNOWN ? userType : pluginType; - } + final int userType= fUserExtensionMappings.getType(extension); + final int pluginType= fPluginExtensionMappings.getType(extension); + return userType != Team.UNKNOWN ? userType : pluginType; + } - @Override + @Override public void addNameMappings(String[] names, int [] types) { - fUserNameMappings.addStringMappings(names, types); - } + fUserNameMappings.addStringMappings(names, types); + } - @Override + @Override public void addExtensionMappings(String[] extensions, int [] types) { - fUserExtensionMappings.addStringMappings(extensions, types); - } + fUserExtensionMappings.addStringMappings(extensions, types); + } - @Override + @Override public void setNameMappings(String[] names, int [] types) { - fUserNameMappings.setStringMappings(names, types); - } + fUserNameMappings.setStringMappings(names, types); + } - @Override + @Override public void setExtensionMappings(String[] extensions, int [] types) { - fUserExtensionMappings.setStringMappings(extensions, types); - } + fUserExtensionMappings.setStringMappings(extensions, types); + } - @Override + @Override public IStringMapping[] getNameMappings() { - return getMappings(fUserNameMappings, null);//fPluginNameMappings); - } + return getMappings(fUserNameMappings, null);//fPluginNameMappings); + } - @Override + @Override public IStringMapping[] getExtensionMappings() { - return getMappings(fUserExtensionMappings, fPluginExtensionMappings); - } + return getMappings(fUserExtensionMappings, fPluginExtensionMappings); + } - @Override + @Override public int getType(IStorage storage) { - int type; - - final String name= storage.getName(); - if (name != null && (type= getTypeForName(name)) != Team.UNKNOWN) - return type; - - final String extension= getFileExtension(name); - if (extension != null && (type= getTypeForExtension(extension)) != Team.UNKNOWN) - return type; - - IContentType contentType = Platform.getContentTypeManager().findContentTypeFor(name); - if (contentType != null) { - IContentType textType = getTextContentType(); - if (contentType.isKindOf(textType)) { - return Team.TEXT; - } - } - - return Team.UNKNOWN; - } - - private IContentType getTextContentType() { - if (textContentType == null) - textContentType = Platform.getContentTypeManager().getContentType(IContentTypeManager.CT_TEXT); - return textContentType; - } - - @Override + int type; + + final String name= storage.getName(); + if (name != null && (type= getTypeForName(name)) != Team.UNKNOWN) + return type; + + final String extension= getFileExtension(name); + if (extension != null && (type= getTypeForExtension(extension)) != Team.UNKNOWN) + return type; + + IContentType contentType = Platform.getContentTypeManager().findContentTypeFor(name); + if (contentType != null) { + IContentType textType = getTextContentType(); + if (contentType.isKindOf(textType)) { + return Team.TEXT; + } + } + + return Team.UNKNOWN; + } + + private IContentType getTextContentType() { + if (textContentType == null) + textContentType = Platform.getContentTypeManager().getContentType(IContentTypeManager.CT_TEXT); + return textContentType; + } + + @Override public IStringMapping[] getDefaultNameMappings() { - // TODO: There is currently no extension point for this - return new IStringMapping[0];//getStringMappings(fPluginNameMappings.referenceMap()); - } + // TODO: There is currently no extension point for this + return new IStringMapping[0];//getStringMappings(fPluginNameMappings.referenceMap()); + } - @Override + @Override public IStringMapping[] getDefaultExtensionMappings() { - return getStringMappings(fPluginExtensionMappings.referenceMap()); - } + return getStringMappings(fPluginExtensionMappings.referenceMap()); + } - @Override + @Override public boolean isKnownExtension(String extension) { - return fUserExtensionMappings.referenceMap().containsKey(extension) - || fPluginExtensionMappings.referenceMap().containsKey(extension); - } + return fUserExtensionMappings.referenceMap().containsKey(extension) + || fPluginExtensionMappings.referenceMap().containsKey(extension); + } - @Override + @Override public boolean isKnownFilename(String filename) { - return fUserNameMappings.referenceMap().containsKey(filename); + return fUserNameMappings.referenceMap().containsKey(filename); // || fPluginNameMappings.referenceMap().containsKey(filename); - } - - private static String getFileExtension(String name) { - if (name == null) - return null; - int index = name.lastIndexOf('.'); - if (index == -1) - return null; - if (index == (name.length() - 1)) - return ""; //$NON-NLS-1$ - return name.substring(index + 1); - } - - private static IStringMapping [] getStringMappings(Map map) { - final IStringMapping [] result= new IStringMapping [map.size()]; - int index= 0; - for (final Iterator iter = map.entrySet().iterator(); iter.hasNext();) { - final Map.Entry entry= (Map.Entry)iter.next(); - result[index++]= new StringMapping((String)entry.getKey(), ((Integer)entry.getValue()).intValue()); - } - return result; - } - - private IStringMapping [] getMappings(UserStringMappings userMappings, PluginStringMappings pluginMappings) { - final Map<String, Integer> mappings= new HashMap<>(); - if (pluginMappings != null) - mappings.putAll(pluginMappings.referenceMap()); - mappings.putAll(userMappings.referenceMap()); - return getStringMappings(mappings); - } + } + + private static String getFileExtension(String name) { + if (name == null) + return null; + int index = name.lastIndexOf('.'); + if (index == -1) + return null; + if (index == (name.length() - 1)) + return ""; //$NON-NLS-1$ + return name.substring(index + 1); + } + + private static IStringMapping [] getStringMappings(Map map) { + final IStringMapping [] result= new IStringMapping [map.size()]; + int index= 0; + for (final Iterator iter = map.entrySet().iterator(); iter.hasNext();) { + final Map.Entry entry= (Map.Entry)iter.next(); + result[index++]= new StringMapping((String)entry.getKey(), ((Integer)entry.getValue()).intValue()); + } + return result; + } + + private IStringMapping [] getMappings(UserStringMappings userMappings, PluginStringMappings pluginMappings) { + final Map<String, Integer> mappings= new HashMap<>(); + if (pluginMappings != null) + mappings.putAll(pluginMappings.referenceMap()); + mappings.putAll(userMappings.referenceMap()); + return getStringMappings(mappings); + } } diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/FileModificationValidatorManager.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/FileModificationValidatorManager.java index e00379ea3..c8dc7055e 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/FileModificationValidatorManager.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/FileModificationValidatorManager.java @@ -102,9 +102,9 @@ public class FileModificationValidatorManager extends FileModificationValidator } private synchronized FileModificationValidator getDefaultValidator() { - if (defaultValidator == null) { - defaultValidator = new DefaultFileModificationValidator(); - } - return defaultValidator; + if (defaultValidator == null) { + defaultValidator = new DefaultFileModificationValidator(); + } + return defaultValidator; } } diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/Messages.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/Messages.java index fc01b4197..66017dc2a 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/Messages.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/Messages.java @@ -27,7 +27,7 @@ public class Messages extends NLS { public static String ok; public static String concatStrings; - public static String AbstractResourceVariantTree_0; + public static String AbstractResourceVariantTree_0; public static String Assert_assertionFailed; @@ -44,7 +44,7 @@ public class Messages extends NLS { public static String RepositoryProvider_linkedURIsNotSupported; public static String RepositoryProvider_couldNotClearAfterError; public static String RepositoryProvider_invalidClass; - public static String RepositoryProvider_toString; + public static String RepositoryProvider_toString; public static String SubscriberDiffTreeEventHandler_0; @@ -99,15 +99,15 @@ public class Messages extends NLS { public static String ProjectSetCapability_0; public static String ProjectSetCapability_1; - public static String SubscriberResourceMappingContext_0; - public static String SubscriberResourceMappingContext_1; + public static String SubscriberResourceMappingContext_0; + public static String SubscriberResourceMappingContext_1; public static String MergeContext_0; public static String MergeContext_1; public static String MergeContext_2; public static String MergeContext_3; public static String MergeContext_4; - public static String LocalFileRevision_currentVersion; + public static String LocalFileRevision_currentVersion; public static String LocalFileRevision_currentVersionTag; public static String LocalFileRevision_localRevisionTag; static { diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/PluginStringMappings.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/PluginStringMappings.java index 3197bdc6e..8193e6ae4 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/PluginStringMappings.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/PluginStringMappings.java @@ -29,63 +29,63 @@ import org.eclipse.team.core.Team; */ public class PluginStringMappings { - private final String fExtensionID; - private final String fAttributeName; - - private SortedMap<String, Integer> fMappings; - - public PluginStringMappings(String extensionID, String stringAttributeName) { - fExtensionID= extensionID; - fAttributeName= stringAttributeName; - } - - /** - * Load all the extension patterns contributed by plugins. - * @return a map with the patterns - */ - private SortedMap<String, Integer> loadPluginPatterns() { - - final SortedMap<String, Integer> result= new TreeMap<>(); - - final TeamPlugin plugin = TeamPlugin.getPlugin(); - if (plugin == null) - return result; - - final IExtensionPoint extension = Platform.getExtensionRegistry().getExtensionPoint(TeamPlugin.ID, fExtensionID);//TeamPlugin.FILE_TYPES_EXTENSION); - if (extension == null) - return result; - - final IExtension[] extensions = extension.getExtensions(); - - for (int i = 0; i < extensions.length; i++) { - IConfigurationElement[] configElements = extensions[i].getConfigurationElements(); - - for (int j = 0; j < configElements.length; j++) { - - final String ext = configElements[j].getAttribute(fAttributeName);//"extension"); - final String type = configElements[j].getAttribute("type"); //$NON-NLS-1$ - if (ext == null || type == null) - continue; - - if (type.equals("text")) { //$NON-NLS-1$ - result.put(ext, Integer.valueOf(Team.TEXT)); - } else if (type.equals("binary")) { //$NON-NLS-1$ - result.put(ext, Integer.valueOf(Team.BINARY)); - } - } - } - return result; - } - - public Map<String, Integer> referenceMap() { - if (fMappings == null) { - fMappings= loadPluginPatterns(); - } - return fMappings; - } - - public int getType(String filename) { - final Map<String, Integer> mappings= referenceMap(); - return mappings.containsKey(filename) ? mappings.get(filename).intValue() : Team.UNKNOWN; - } + private final String fExtensionID; + private final String fAttributeName; + + private SortedMap<String, Integer> fMappings; + + public PluginStringMappings(String extensionID, String stringAttributeName) { + fExtensionID= extensionID; + fAttributeName= stringAttributeName; + } + + /** + * Load all the extension patterns contributed by plugins. + * @return a map with the patterns + */ + private SortedMap<String, Integer> loadPluginPatterns() { + + final SortedMap<String, Integer> result= new TreeMap<>(); + + final TeamPlugin plugin = TeamPlugin.getPlugin(); + if (plugin == null) + return result; + + final IExtensionPoint extension = Platform.getExtensionRegistry().getExtensionPoint(TeamPlugin.ID, fExtensionID);//TeamPlugin.FILE_TYPES_EXTENSION); + if (extension == null) + return result; + + final IExtension[] extensions = extension.getExtensions(); + + for (int i = 0; i < extensions.length; i++) { + IConfigurationElement[] configElements = extensions[i].getConfigurationElements(); + + for (int j = 0; j < configElements.length; j++) { + + final String ext = configElements[j].getAttribute(fAttributeName);//"extension"); + final String type = configElements[j].getAttribute("type"); //$NON-NLS-1$ + if (ext == null || type == null) + continue; + + if (type.equals("text")) { //$NON-NLS-1$ + result.put(ext, Integer.valueOf(Team.TEXT)); + } else if (type.equals("binary")) { //$NON-NLS-1$ + result.put(ext, Integer.valueOf(Team.BINARY)); + } + } + } + return result; + } + + public Map<String, Integer> referenceMap() { + if (fMappings == null) { + fMappings= loadPluginPatterns(); + } + return fMappings; + } + + public int getType(String filename) { + final Map<String, Integer> mappings= referenceMap(); + return mappings.containsKey(filename) ? mappings.get(filename).intValue() : Team.UNKNOWN; + } } diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/ResourceVariantCache.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/ResourceVariantCache.java index c1702941c..ba1bf5be1 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/ResourceVariantCache.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/ResourceVariantCache.java @@ -100,8 +100,8 @@ public class ResourceVariantCache { public static synchronized void shutdown() { String[] keys = caches.keySet().toArray(new String[caches.size()]); - for (int i = 0; i < keys.length; i++) { - String id = keys[i]; + for (int i = 0; i < keys.length; i++) { + String id = keys[i]; disableCache(id); } } diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/StorageMergerRegistry.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/StorageMergerRegistry.java index 27f3f40f1..4c6095879 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/StorageMergerRegistry.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/StorageMergerRegistry.java @@ -97,11 +97,11 @@ public class StorageMergerRegistry { // collect all IStreamMergers IConfigurationElement[] elements= registry.getConfigurationElementsFor(TeamPlugin.ID, STORAGE_MERGER_EXTENSION_POINT); for (int i= 0; i < elements.length; i++) { - IConfigurationElement element= elements[i]; - if (STORAGE_MERGER.equals(element.getName())) - register(element, new StorageMergerDescriptor(element)); - else if (CONTENT_TYPE_BINDING.equals(element.getName())) - createBinding(element, STORAGE_MERGER_ID_ATTRIBUTE); + IConfigurationElement element= elements[i]; + if (STORAGE_MERGER.equals(element.getName())) + register(element, new StorageMergerDescriptor(element)); + else if (CONTENT_TYPE_BINDING.equals(element.getName())) + createBinding(element, STORAGE_MERGER_ID_ATTRIBUTE); } } diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/TeamPlugin.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/TeamPlugin.java index 82f2e7d8c..b2b22a7e7 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/TeamPlugin.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/TeamPlugin.java @@ -77,9 +77,9 @@ final public class TeamPlugin extends Plugin { // The id of the default file modification validator extension point public static final String DEFAULT_FILE_MODIFICATION_VALIDATOR_EXTENSION = "defaultFileModificationValidator"; //$NON-NLS-1$ - // The id used to associate a provider with a project - public final static QualifiedName PROVIDER_PROP_KEY = - new QualifiedName("org.eclipse.team.core", "repository"); //$NON-NLS-1$ //$NON-NLS-2$ + // The id used to associate a provider with a project + public final static QualifiedName PROVIDER_PROP_KEY = + new QualifiedName("org.eclipse.team.core", "repository"); //$NON-NLS-1$ //$NON-NLS-2$ // The id for the Bundle Import extension point public static final String EXTENSION_POINT_BUNDLE_IMPORTERS = ID + ".bundleImporters"; //$NON-NLS-1$ @@ -187,13 +187,13 @@ final public class TeamPlugin extends Plugin { for (int i = 0; i < extensions.length; i++) { IConfigurationElement [] configElements = extensions[i].getConfigurationElements(); for (int j = 0; j < configElements.length; j++) { - String aliasId = configElements[j].getAttribute("canImportId"); //$NON-NLS-1$ - if (aliasId != null && aliasId.equals(id)) { + String aliasId = configElements[j].getAttribute("canImportId"); //$NON-NLS-1$ + if (aliasId != null && aliasId.equals(id)) { String extensionId = configElements[j].getAttribute("id"); //$NON-NLS-1$ if (extensionId != null) { return RepositoryProviderType.getProviderType(extensionId); } - } + } } } } @@ -208,11 +208,11 @@ final public class TeamPlugin extends Plugin { IConfigurationElement [] configElements = extensions[i].getConfigurationElements(); for (int j = 0; j < configElements.length; j++) { String extensionId = configElements[j].getAttribute("id"); //$NON-NLS-1$ - String metaFilePaths = configElements[j].getAttribute("metaFilePaths"); //$NON-NLS-1$ - if (extensionId != null && extensionId.equals(id) && metaFilePaths != null) { + String metaFilePaths = configElements[j].getAttribute("metaFilePaths"); //$NON-NLS-1$ + if (extensionId != null && extensionId.equals(id) && metaFilePaths != null) { return getPaths(metaFilePaths); - } + } } } } diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/UserStringMappings.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/UserStringMappings.java index acac94a70..cfe1bc0cd 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/UserStringMappings.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/UserStringMappings.java @@ -28,96 +28,96 @@ import org.eclipse.team.core.Team; public class UserStringMappings implements Preferences.IPropertyChangeListener { - public static final Integer BINARY= Integer.valueOf(Team.BINARY); - public static final Integer TEXT= Integer.valueOf(Team.TEXT); - public static final Integer UNKNOWN= Integer.valueOf(Team.UNKNOWN); - - - private static final String PREF_TEAM_SEPARATOR = "\n"; //$NON-NLS-1$ - - private final Preferences fPreferences; - private final String fKey; - - private Map<String, Integer> fMap; - - public UserStringMappings(String key) { - fKey= key; - fPreferences= TeamPlugin.getPlugin().getPluginPreferences(); - fPreferences.addPropertyChangeListener(this); - } - - public Map<String, Integer> referenceMap() { - if (fMap == null) { - fMap= loadMappingsFromPreferences(); - } - return fMap; - } - - public void addStringMappings(String[] names, int[] types) { - Assert.isTrue(names.length == types.length); - final Map<String, Integer> map= referenceMap(); - - for (int i = 0; i < names.length; i++) { - switch (types[i]) { - case Team.BINARY: map.put(names[i], BINARY); break; - case Team.TEXT: map.put(names[i], TEXT); break; - case Team.UNKNOWN: map.put(names[i], UNKNOWN); break; - } - } - save(); - } - - public void setStringMappings(String [] names, int [] types) { - Assert.isTrue(names.length == types.length); - referenceMap().clear(); - addStringMappings(names, types); - } - - public int getType(String string) { - if (string == null) - return Team.UNKNOWN; - final Integer type= referenceMap().get(string); - return type != null ? type.intValue() : Team.UNKNOWN; - } - - @Override + public static final Integer BINARY= Integer.valueOf(Team.BINARY); + public static final Integer TEXT= Integer.valueOf(Team.TEXT); + public static final Integer UNKNOWN= Integer.valueOf(Team.UNKNOWN); + + + private static final String PREF_TEAM_SEPARATOR = "\n"; //$NON-NLS-1$ + + private final Preferences fPreferences; + private final String fKey; + + private Map<String, Integer> fMap; + + public UserStringMappings(String key) { + fKey= key; + fPreferences= TeamPlugin.getPlugin().getPluginPreferences(); + fPreferences.addPropertyChangeListener(this); + } + + public Map<String, Integer> referenceMap() { + if (fMap == null) { + fMap= loadMappingsFromPreferences(); + } + return fMap; + } + + public void addStringMappings(String[] names, int[] types) { + Assert.isTrue(names.length == types.length); + final Map<String, Integer> map= referenceMap(); + + for (int i = 0; i < names.length; i++) { + switch (types[i]) { + case Team.BINARY: map.put(names[i], BINARY); break; + case Team.TEXT: map.put(names[i], TEXT); break; + case Team.UNKNOWN: map.put(names[i], UNKNOWN); break; + } + } + save(); + } + + public void setStringMappings(String [] names, int [] types) { + Assert.isTrue(names.length == types.length); + referenceMap().clear(); + addStringMappings(names, types); + } + + public int getType(String string) { + if (string == null) + return Team.UNKNOWN; + final Integer type= referenceMap().get(string); + return type != null ? type.intValue() : Team.UNKNOWN; + } + + @Override public void propertyChange(PropertyChangeEvent event) { - if(event.getProperty().equals(fKey)) - fMap= null; - } - - public void save() { - // Now set into preferences - final StringBuilder buffer = new StringBuilder(); - final Iterator e = fMap.keySet().iterator(); - - while (e.hasNext()) { - final String filename = (String)e.next(); - buffer.append(filename); - buffer.append(PREF_TEAM_SEPARATOR); - final Integer type = fMap.get(filename); - buffer.append(type); - buffer.append(PREF_TEAM_SEPARATOR); - } - TeamPlugin.getPlugin().getPluginPreferences().setValue(fKey, buffer.toString()); - } - - protected Map<String, Integer> loadMappingsFromPreferences() { - final Map<String, Integer> result= new HashMap<>(); - - if (!fPreferences.contains(fKey)) - return result; - - final String prefTypes = fPreferences.getString(fKey); - final StringTokenizer tok = new StringTokenizer(prefTypes, PREF_TEAM_SEPARATOR); - try { - while (tok.hasMoreElements()) { - final String name = tok.nextToken(); - final String mode= tok.nextToken(); - result.put(name, Integer.valueOf(mode)); - } - } catch (NoSuchElementException e) { - } - return result; - } + if(event.getProperty().equals(fKey)) + fMap= null; + } + + public void save() { + // Now set into preferences + final StringBuilder buffer = new StringBuilder(); + final Iterator e = fMap.keySet().iterator(); + + while (e.hasNext()) { + final String filename = (String)e.next(); + buffer.append(filename); + buffer.append(PREF_TEAM_SEPARATOR); + final Integer type = fMap.get(filename); + buffer.append(type); + buffer.append(PREF_TEAM_SEPARATOR); + } + TeamPlugin.getPlugin().getPluginPreferences().setValue(fKey, buffer.toString()); + } + + protected Map<String, Integer> loadMappingsFromPreferences() { + final Map<String, Integer> result= new HashMap<>(); + + if (!fPreferences.contains(fKey)) + return result; + + final String prefTypes = fPreferences.getString(fKey); + final StringTokenizer tok = new StringTokenizer(prefTypes, PREF_TEAM_SEPARATOR); + try { + while (tok.hasMoreElements()) { + final String name = tok.nextToken(); + final String mode= tok.nextToken(); + result.put(name, Integer.valueOf(mode)); + } + } catch (NoSuchElementException e) { + } + return result; + } } diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/streams/LFtoCRLFInputStream.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/streams/LFtoCRLFInputStream.java index b6b521cb2..92f4ab3b6 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/streams/LFtoCRLFInputStream.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/streams/LFtoCRLFInputStream.java @@ -107,11 +107,11 @@ public class LFtoCRLFInputStream extends FilterInputStream { count++; } buffer[off++] = b; - } - if (iioe != null) { - iioe.bytesTransferred = count; - throw iioe; - } + } + if (iioe != null) { + iioe.bytesTransferred = count; + throw iioe; + } return count; } diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/streams/PollingOutputStream.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/streams/PollingOutputStream.java index f8aaefa67..f98e1331c 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/streams/PollingOutputStream.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/streams/PollingOutputStream.java @@ -151,11 +151,11 @@ public class PollingOutputStream extends FilterOutputStream { @Override public void close() throws IOException { int attempts = numAttempts - 1; // fail fast if flush() does times out - try { - out.flush(); + try { + out.flush(); attempts = 0; - } finally { - boolean stop = false; + } finally { + boolean stop = false; while (!stop) { try { out.close(); @@ -167,7 +167,7 @@ public class PollingOutputStream extends FilterOutputStream { if (Policy.DEBUG_STREAMS) System.out.println("close retry=" + attempts); //$NON-NLS-1$ } } - } + } } /** diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/ActiveChangeSet.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/ActiveChangeSet.java index 0b6cfb1fb..59608f687 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/ActiveChangeSet.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/ActiveChangeSet.java @@ -35,194 +35,194 @@ import org.osgi.service.prefs.Preferences; */ public class ActiveChangeSet extends DiffChangeSet { - private static final String CTX_TITLE = "title"; //$NON-NLS-1$ - private static final String CTX_COMMENT = "comment"; //$NON-NLS-1$ - private static final String CTX_RESOURCES = "resources"; //$NON-NLS-1$ - private static final String CTX_USER_CREATED = "userCreated"; //$NON-NLS-1$ + private static final String CTX_TITLE = "title"; //$NON-NLS-1$ + private static final String CTX_COMMENT = "comment"; //$NON-NLS-1$ + private static final String CTX_RESOURCES = "resources"; //$NON-NLS-1$ + private static final String CTX_USER_CREATED = "userCreated"; //$NON-NLS-1$ - private final ActiveChangeSetManager manager; - private String comment; + private final ActiveChangeSetManager manager; + private String comment; private boolean userCreated = true; /** * Create a change set with the given title * @param manager the manager that owns this set - * @param title the title of the set - */ - public ActiveChangeSet(ActiveChangeSetManager manager, String title) { - super(title); - this.manager = manager; - } - - /** - * Get the title of the change set. The title is used - * as the comment when the set is checking in if no comment - * has been explicitly set using <code>setComment</code>. - * @return the title of the set - */ - public String getTitle() { - return getName(); - } - - /** - * Set the title of the set. The title is used - * as the comment when the set is committed if no comment - * has been explicitly set using <code>setComment</code>. - * @param title the title of the set - */ - public void setTitle(String title) { - setName(title); - getManager().fireNameChangedEvent(this); - } - - /** - * Get the comment of this change set. If the comment - * as never been set, the title is returned as the comment - * @return the comment to be used when the set is committed - */ - @Override + * @param title the title of the set + */ + public ActiveChangeSet(ActiveChangeSetManager manager, String title) { + super(title); + this.manager = manager; + } + + /** + * Get the title of the change set. The title is used + * as the comment when the set is checking in if no comment + * has been explicitly set using <code>setComment</code>. + * @return the title of the set + */ + public String getTitle() { + return getName(); + } + + /** + * Set the title of the set. The title is used + * as the comment when the set is committed if no comment + * has been explicitly set using <code>setComment</code>. + * @param title the title of the set + */ + public void setTitle(String title) { + setName(title); + getManager().fireNameChangedEvent(this); + } + + /** + * Get the comment of this change set. If the comment + * as never been set, the title is returned as the comment + * @return the comment to be used when the set is committed + */ + @Override public String getComment() { - if (comment == null) { - return getTitle(); - } - return comment; - } - - /** - * Set the comment to be used when the change set is committed. - * If <code>null</code> is passed, the title of the set - * will be used as the comment. - * @param comment the comment for the set or <code>null</code> - * if the title should be the comment - */ - public void setComment(String comment) { - if (comment != null && comment.equals(getTitle())) { - this.comment = null; - } else { - this.comment = comment; - } - } - - /* - * Override inherited method to only include outgoing changes - */ - @Override + if (comment == null) { + return getTitle(); + } + return comment; + } + + /** + * Set the comment to be used when the change set is committed. + * If <code>null</code> is passed, the title of the set + * will be used as the comment. + * @param comment the comment for the set or <code>null</code> + * if the title should be the comment + */ + public void setComment(String comment) { + if (comment != null && comment.equals(getTitle())) { + this.comment = null; + } else { + this.comment = comment; + } + } + + /* + * Override inherited method to only include outgoing changes + */ + @Override protected boolean isValidChange(IDiff diff) { - return getManager().isModified(diff); - } - - private void addResource(IResource resource) throws CoreException { - IDiff diff = getManager().getDiff(resource); - if (diff != null) { - add(diff); - } - } - - private ActiveChangeSetManager getManager() { - return manager; - } - - /** - * Return whether the set has a comment that differs from the title. - * @return whether the set has a comment that differs from the title - */ - public boolean hasComment() { - return comment != null; - } - - public void save(Preferences prefs) { - prefs.put(CTX_TITLE, getTitle()); - if (comment != null) { - prefs.put(CTX_COMMENT, comment); - } - if (!isEmpty()) { - StringBuilder buffer = new StringBuilder(); - IResource[] resources = getResources(); - for (int i = 0; i < resources.length; i++) { - IResource resource = resources[i]; - buffer.append(resource.getFullPath().toString()); - buffer.append('\n'); - } - prefs.put(CTX_RESOURCES, buffer.toString()); - } - prefs.putBoolean(CTX_USER_CREATED, isUserCreated()); - } - - public void init(Preferences prefs) { - setName(prefs.get(CTX_TITLE, "")); //$NON-NLS-1$ - comment = prefs.get(CTX_COMMENT, null); - String resourcePaths = prefs.get(CTX_RESOURCES, null); - if (resourcePaths != null) { - ResourceDiffTree tree = internalGetDiffTree(); - try { - tree.beginInput(); - IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); - StringTokenizer tokenizer = new StringTokenizer(resourcePaths, "\n"); //$NON-NLS-1$ - while (tokenizer.hasMoreTokens()) { - String next = tokenizer.nextToken(); - if (next.trim().length() > 0) { - IResource resource = getResource(root, next); - // Only include the resource if it is out-of-sync - try { + return getManager().isModified(diff); + } + + private void addResource(IResource resource) throws CoreException { + IDiff diff = getManager().getDiff(resource); + if (diff != null) { + add(diff); + } + } + + private ActiveChangeSetManager getManager() { + return manager; + } + + /** + * Return whether the set has a comment that differs from the title. + * @return whether the set has a comment that differs from the title + */ + public boolean hasComment() { + return comment != null; + } + + public void save(Preferences prefs) { + prefs.put(CTX_TITLE, getTitle()); + if (comment != null) { + prefs.put(CTX_COMMENT, comment); + } + if (!isEmpty()) { + StringBuilder buffer = new StringBuilder(); + IResource[] resources = getResources(); + for (int i = 0; i < resources.length; i++) { + IResource resource = resources[i]; + buffer.append(resource.getFullPath().toString()); + buffer.append('\n'); + } + prefs.put(CTX_RESOURCES, buffer.toString()); + } + prefs.putBoolean(CTX_USER_CREATED, isUserCreated()); + } + + public void init(Preferences prefs) { + setName(prefs.get(CTX_TITLE, "")); //$NON-NLS-1$ + comment = prefs.get(CTX_COMMENT, null); + String resourcePaths = prefs.get(CTX_RESOURCES, null); + if (resourcePaths != null) { + ResourceDiffTree tree = internalGetDiffTree(); + try { + tree.beginInput(); + IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); + StringTokenizer tokenizer = new StringTokenizer(resourcePaths, "\n"); //$NON-NLS-1$ + while (tokenizer.hasMoreTokens()) { + String next = tokenizer.nextToken(); + if (next.trim().length() > 0) { + IResource resource = getResource(root, next); + // Only include the resource if it is out-of-sync + try { if (resource != null && getManager().getDiff(resource) != null) { addResource(resource); } } catch (CoreException e) { TeamPlugin.log(e); } - } - } - } finally { - tree.endInput(null); - } - } - userCreated = prefs.getBoolean(CTX_USER_CREATED, true); - } - - private IResource getResource(IWorkspaceRoot root, String next) { - IResource resource = root.findMember(next); - if (resource == null) { - // May be an outgoing deletion - Path path = new Path(null, next); - if (next.charAt(next.length()-1) == IPath.SEPARATOR) { - if (path.segmentCount() == 1) { - // resource is a project - resource = root.getProject(path.lastSegment()); - } else { - // resource is a folder - resource = root.getFolder(path); - } - } else { - // resource is a file - resource = root.getFile(path); - } - } - return resource; - } - - /** - * Add the resources to the change set if they are outgoing changes. - * @param resources the resources to add. - * @throws CoreException - */ - public void add(IResource[] resources) throws CoreException { - List<IDiff> toAdd = new ArrayList<>(); - for (int i = 0; i < resources.length; i++) { - IResource resource = resources[i]; - IDiff diff = getManager().getDiff(resource); - if (diff != null) { - toAdd.add(diff); - } - } - if (!toAdd.isEmpty()) { - add(toAdd.toArray(new IDiff[toAdd.size()])); - } - } - - /** - * Set whether this set was created by the user. - * @param userCreated whether this set was created by the user - */ + } + } + } finally { + tree.endInput(null); + } + } + userCreated = prefs.getBoolean(CTX_USER_CREATED, true); + } + + private IResource getResource(IWorkspaceRoot root, String next) { + IResource resource = root.findMember(next); + if (resource == null) { + // May be an outgoing deletion + Path path = new Path(null, next); + if (next.charAt(next.length()-1) == IPath.SEPARATOR) { + if (path.segmentCount() == 1) { + // resource is a project + resource = root.getProject(path.lastSegment()); + } else { + // resource is a folder + resource = root.getFolder(path); + } + } else { + // resource is a file + resource = root.getFile(path); + } + } + return resource; + } + + /** + * Add the resources to the change set if they are outgoing changes. + * @param resources the resources to add. + * @throws CoreException + */ + public void add(IResource[] resources) throws CoreException { + List<IDiff> toAdd = new ArrayList<>(); + for (int i = 0; i < resources.length; i++) { + IResource resource = resources[i]; + IDiff diff = getManager().getDiff(resource); + if (diff != null) { + toAdd.add(diff); + } + } + if (!toAdd.isEmpty()) { + add(toAdd.toArray(new IDiff[toAdd.size()])); + } + } + + /** + * Set whether this set was created by the user. + * @param userCreated whether this set was created by the user + */ public void setUserCreated(boolean userCreated) { this.userCreated = userCreated; } diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/ActiveChangeSetManager.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/ActiveChangeSetManager.java index 0c57ee161..a5b35c1ef 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/ActiveChangeSetManager.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/ActiveChangeSetManager.java @@ -48,61 +48,61 @@ import org.osgi.service.prefs.Preferences; */ public abstract class ActiveChangeSetManager extends ChangeSetManager implements IDiffChangeListener, IChangeGroupingRequestor { - private static final String CTX_DEFAULT_SET = "defaultSet"; //$NON-NLS-1$ + private static final String CTX_DEFAULT_SET = "defaultSet"; //$NON-NLS-1$ - private ActiveChangeSet defaultSet; + private ActiveChangeSet defaultSet; /** - * Return the Change Set whose sync info set is the - * one given. - * @param tree a diff tree - * @return the change set for the given diff tree - */ - protected ChangeSet getChangeSet(IResourceDiffTree tree) { - ChangeSet[] sets = getSets(); - for (int i = 0; i < sets.length; i++) { + * Return the Change Set whose sync info set is the + * one given. + * @param tree a diff tree + * @return the change set for the given diff tree + */ + protected ChangeSet getChangeSet(IResourceDiffTree tree) { + ChangeSet[] sets = getSets(); + for (int i = 0; i < sets.length; i++) { ChangeSet changeSet = sets[i]; - if (((DiffChangeSet)changeSet).getDiffTree() == tree) { - return changeSet; - } - } - return null; - } - - @Override + if (((DiffChangeSet)changeSet).getDiffTree() == tree) { + return changeSet; + } + } + return null; + } + + @Override public void add(ChangeSet set) { - Assert.isTrue(set instanceof ActiveChangeSet); - super.add(set); - } + Assert.isTrue(set instanceof ActiveChangeSet); + super.add(set); + } - @Override + @Override protected void handleSetAdded(ChangeSet set) { - Assert.isTrue(set instanceof ActiveChangeSet); - ((DiffChangeSet)set).getDiffTree().addDiffChangeListener(getDiffTreeListener()); - super.handleSetAdded(set); - handleAddedResources(set, ((ActiveChangeSet)set).internalGetDiffTree().getDiffs()); - } + Assert.isTrue(set instanceof ActiveChangeSet); + ((DiffChangeSet)set).getDiffTree().addDiffChangeListener(getDiffTreeListener()); + super.handleSetAdded(set); + handleAddedResources(set, ((ActiveChangeSet)set).internalGetDiffTree().getDiffs()); + } - @Override + @Override protected void handleSetRemoved(ChangeSet set) { - ((DiffChangeSet)set).getDiffTree().removeDiffChangeListener(getDiffTreeListener()); - super.handleSetRemoved(set); - } - - /** - * Return the listener that is registered with the diff trees associated with - * the sets for this manager. - * @return the listener that is registered with the diff trees associated with - * the sets for this manager - */ - protected IDiffChangeListener getDiffTreeListener() { - return this; - } + ((DiffChangeSet)set).getDiffTree().removeDiffChangeListener(getDiffTreeListener()); + super.handleSetRemoved(set); + } + + /** + * Return the listener that is registered with the diff trees associated with + * the sets for this manager. + * @return the listener that is registered with the diff trees associated with + * the sets for this manager + */ + protected IDiffChangeListener getDiffTreeListener() { + return this; + } @Override public void diffsChanged(IDiffChangeEvent event, IProgressMonitor monitor) { - IResourceDiffTree tree = (IResourceDiffTree)event.getTree(); - handleSyncSetChange(tree, event.getAdditions(), getAllResources(event)); + IResourceDiffTree tree = (IResourceDiffTree)event.getTree(); + handleSyncSetChange(tree, event.getAdditions(), getAllResources(event)); } @Override @@ -123,18 +123,18 @@ public abstract class ActiveChangeSetManager extends ChangeSetManager implements * @param diff the diff * @return whether the given diff represents a local change */ - public boolean isModified(IDiff diff) { - if (diff != null) { - if (diff instanceof IThreeWayDiff) { + public boolean isModified(IDiff diff) { + if (diff != null) { + if (diff instanceof IThreeWayDiff) { IThreeWayDiff twd = (IThreeWayDiff) diff; int dir = twd.getDirection(); return dir == IThreeWayDiff.OUTGOING || dir == IThreeWayDiff.CONFLICTING; } else { return diff.getKind() != IDiff.NO_CHANGE; } - } - return false; - } + } + return false; + } /** * Return the set with the given name. @@ -152,48 +152,48 @@ public abstract class ActiveChangeSetManager extends ChangeSetManager implements return null; } - /** - * Create a change set containing the given files if - * they have been modified locally. - * @param title the title of the commit set - * @param files the files contained in the set - * @return the created set - * @throws CoreException - */ - public ActiveChangeSet createSet(String title, IFile[] files) throws CoreException { - List<IDiff> infos = new ArrayList<>(); - for (int i = 0; i < files.length; i++) { - IFile file = files[i]; - IDiff diff = getDiff(file); - if (diff != null) { - infos.add(diff); - } - } - return createSet(title, infos.toArray(new IDiff[infos.size()])); - } - - /** - * Create a commit set with the given title and files. The created - * set is not added to the control of the commit set manager - * so no events are fired. The set can be added using the - * <code>add</code> method. - * @param title the title of the commit set - * @param diffs the files contained in the set - * @return the created set - */ - public ActiveChangeSet createSet(String title, IDiff[] diffs) { - ActiveChangeSet commitSet = doCreateSet(title); - if (diffs != null && diffs.length > 0) { - commitSet.add(diffs); - } - return commitSet; - } - - /** - * Create a change set with the given name. - * @param name the name of the change set - * @return the created change set - */ + /** + * Create a change set containing the given files if + * they have been modified locally. + * @param title the title of the commit set + * @param files the files contained in the set + * @return the created set + * @throws CoreException + */ + public ActiveChangeSet createSet(String title, IFile[] files) throws CoreException { + List<IDiff> infos = new ArrayList<>(); + for (int i = 0; i < files.length; i++) { + IFile file = files[i]; + IDiff diff = getDiff(file); + if (diff != null) { + infos.add(diff); + } + } + return createSet(title, infos.toArray(new IDiff[infos.size()])); + } + + /** + * Create a commit set with the given title and files. The created + * set is not added to the control of the commit set manager + * so no events are fired. The set can be added using the + * <code>add</code> method. + * @param title the title of the commit set + * @param diffs the files contained in the set + * @return the created set + */ + public ActiveChangeSet createSet(String title, IDiff[] diffs) { + ActiveChangeSet commitSet = doCreateSet(title); + if (diffs != null && diffs.length > 0) { + commitSet.add(diffs); + } + return commitSet; + } + + /** + * Create a change set with the given name. + * @param name the name of the change set + * @return the created change set + */ protected ActiveChangeSet doCreateSet(String name) { return new ActiveChangeSet(this, name); } @@ -208,7 +208,7 @@ public abstract class ActiveChangeSetManager extends ChangeSetManager implements * be in multiple sets. */ protected boolean isSingleSetPerResource() { - return true; + return true; } private IPath[] getAllResources(IDiffChangeEvent event) { @@ -228,7 +228,7 @@ public abstract class ActiveChangeSetManager extends ChangeSetManager implements IPath path = removals[i]; allResources.add(path); } - return allResources.toArray(new IPath[allResources.size()]); + return allResources.toArray(new IPath[allResources.size()]); } /** @@ -237,29 +237,29 @@ public abstract class ActiveChangeSetManager extends ChangeSetManager implements * @param diffs the diffs */ protected void handleAddedResources(ChangeSet set, IDiff[] diffs) { - if (isSingleSetPerResource() && ((ActiveChangeSet)set).isUserCreated()) { - IResource[] resources = new IResource[diffs.length]; - for (int i = 0; i < resources.length; i++) { + if (isSingleSetPerResource() && ((ActiveChangeSet)set).isUserCreated()) { + IResource[] resources = new IResource[diffs.length]; + for (int i = 0; i < resources.length; i++) { resources[i] = ((DiffChangeSet)set).getDiffTree().getResource(diffs[i]); } - // Remove the added files from any other set that contains them - ChangeSet[] sets = getSets(); - for (int i = 0; i < sets.length; i++) { - ChangeSet otherSet = sets[i]; + // Remove the added files from any other set that contains them + ChangeSet[] sets = getSets(); + for (int i = 0; i < sets.length; i++) { + ChangeSet otherSet = sets[i]; if (otherSet != set && ((ActiveChangeSet)otherSet).isUserCreated()) { - otherSet.remove(resources); - } - } - } + otherSet.remove(resources); + } + } + } } private void handleSyncSetChange(IResourceDiffTree tree, IDiff[] addedDiffs, IPath[] allAffectedResources) { - ChangeSet changeSet = getChangeSet(tree); - if (tree.isEmpty() && changeSet != null) { - remove(changeSet); - } - fireResourcesChangedEvent(changeSet, allAffectedResources); - handleAddedResources(changeSet, addedDiffs); + ChangeSet changeSet = getChangeSet(tree); + if (tree.isEmpty() && changeSet != null) { + remove(changeSet); + } + fireResourcesChangedEvent(changeSet, allAffectedResources); + handleAddedResources(changeSet, addedDiffs); } /** @@ -271,13 +271,13 @@ public abstract class ActiveChangeSetManager extends ChangeSetManager implements * <code>null</code> to unset the default set */ public void makeDefault(ActiveChangeSet set) { - // The default set must be an active set + // The default set must be an active set if (set != null && !contains(set)) { add(set); } - ActiveChangeSet oldSet = defaultSet; - defaultSet = set; - fireDefaultChangedEvent(oldSet, defaultSet); + ActiveChangeSet oldSet = defaultSet; + defaultSet = set; + fireDefaultChangedEvent(oldSet, defaultSet); } /** @@ -287,17 +287,17 @@ public abstract class ActiveChangeSetManager extends ChangeSetManager implements * @return whether the set is the default set */ public boolean isDefault(ActiveChangeSet set) { - return set == defaultSet; + return set == defaultSet; } - /** - * Return the set which is currently the default or - * <code>null</code> if there is no default set. - * @return the default change set - */ - public ActiveChangeSet getDefaultSet() { - return defaultSet; - } + /** + * Return the set which is currently the default or + * <code>null</code> if there is no default set. + * @return the default change set + */ + public ActiveChangeSet getDefaultSet() { + return defaultSet; + } /** * If the given traversals contain any resources in the active change sets, ensure @@ -336,42 +336,42 @@ public abstract class ActiveChangeSetManager extends ChangeSetManager implements // No need to save the sets if the manager has never been initialized if (!isInitialized()) return; - // Clear the persisted state before saving the new state - try { - String[] oldSetNames = prefs.childrenNames(); - for (int i = 0; i < oldSetNames.length; i++) { - String string = oldSetNames[i]; - prefs.node(string).removeNode(); - } - } catch (BackingStoreException e) { - TeamPlugin.log(IStatus.ERROR, NLS.bind(Messages.SubscriberChangeSetCollector_5, new String[] { getName() }), e); - } - ChangeSet[] sets = getSets(); - for (int i = 0; i < sets.length; i++) { - ChangeSet set = sets[i]; + // Clear the persisted state before saving the new state + try { + String[] oldSetNames = prefs.childrenNames(); + for (int i = 0; i < oldSetNames.length; i++) { + String string = oldSetNames[i]; + prefs.node(string).removeNode(); + } + } catch (BackingStoreException e) { + TeamPlugin.log(IStatus.ERROR, NLS.bind(Messages.SubscriberChangeSetCollector_5, new String[] { getName() }), e); + } + ChangeSet[] sets = getSets(); + for (int i = 0; i < sets.length; i++) { + ChangeSet set = sets[i]; if (set instanceof ActiveChangeSet && !set.isEmpty()) { - // Since the change set title is stored explicitly, the name of - // the child preference node doesn't matter as long as it - // doesn't contain / and no two change sets get the same name. - String childPrefName = escapePrefName(((ActiveChangeSet)set).getTitle()); - Preferences child = prefs.node(childPrefName); - ((ActiveChangeSet)set).save(child); + // Since the change set title is stored explicitly, the name of + // the child preference node doesn't matter as long as it + // doesn't contain / and no two change sets get the same name. + String childPrefName = escapePrefName(((ActiveChangeSet)set).getTitle()); + Preferences child = prefs.node(childPrefName); + ((ActiveChangeSet)set).save(child); } } if (getDefaultSet() != null) { - prefs.put(CTX_DEFAULT_SET, getDefaultSet().getTitle()); + prefs.put(CTX_DEFAULT_SET, getDefaultSet().getTitle()); } else { // unset default changeset prefs.remove(CTX_DEFAULT_SET); } try { - prefs.flush(); - } catch (BackingStoreException e) { - TeamPlugin.log(IStatus.ERROR, NLS.bind(Messages.SubscriberChangeSetCollector_3, new String[] { getName() }), e); - } - } + prefs.flush(); + } catch (BackingStoreException e) { + TeamPlugin.log(IStatus.ERROR, NLS.bind(Messages.SubscriberChangeSetCollector_3, new String[] { getName() }), e); + } + } - /** + /** * Escape the given string for safe use as a preference node name by * translating / to \s (so it's a single path component) and \ to \\ (to * preserve uniqueness). @@ -406,23 +406,23 @@ public abstract class ActiveChangeSetManager extends ChangeSetManager implements */ protected void load(Preferences prefs) { String defaultSetTitle = prefs.get(CTX_DEFAULT_SET, null); - try { + try { String[] childNames = prefs.childrenNames(); for (int i = 0; i < childNames.length; i++) { - String string = childNames[i]; - Preferences childPrefs = prefs.node(string); - ActiveChangeSet set = createSet(childPrefs); - if (!set.isEmpty()) { - if (getDefaultSet() == null && defaultSetTitle != null && set.getTitle().equals(defaultSetTitle)) { - makeDefault(set); - } - add(set); - } + String string = childNames[i]; + Preferences childPrefs = prefs.node(string); + ActiveChangeSet set = createSet(childPrefs); + if (!set.isEmpty()) { + if (getDefaultSet() == null && defaultSetTitle != null && set.getTitle().equals(defaultSetTitle)) { + makeDefault(set); + } + add(set); + } } } catch (BackingStoreException e) { TeamPlugin.log(IStatus.ERROR, NLS.bind(Messages.SubscriberChangeSetCollector_4, new String[] { getName() }), e); } - } + } /** * Return the name of this change set manager. @@ -430,23 +430,23 @@ public abstract class ActiveChangeSetManager extends ChangeSetManager implements */ protected abstract String getName(); - /** - * Create a change set from the given preferences that were - * previously saved. - * @param childPrefs the previously saved preferences - * @return the created change set - */ - protected ActiveChangeSet createSet(Preferences childPrefs) { - // Don't specify a title when creating the change set; instead, let the - // change set read its title from the preferences. - ActiveChangeSet changeSet = doCreateSet(null); - changeSet.init(childPrefs); - return changeSet; - } - - @Override + /** + * Create a change set from the given preferences that were + * previously saved. + * @param childPrefs the previously saved preferences + * @return the created change set + */ + protected ActiveChangeSet createSet(Preferences childPrefs) { + // Don't specify a title when creating the change set; instead, let the + // change set read its title from the preferences. + ActiveChangeSet changeSet = doCreateSet(null); + changeSet.init(childPrefs); + return changeSet; + } + + @Override public void ensureChangesGrouped(IProject project, IFile[] files, - String name) throws CoreException { + String name) throws CoreException { ActiveChangeSet set = getSet(name); if (set == null) { set = createSet(name, files); @@ -456,5 +456,5 @@ public abstract class ActiveChangeSetManager extends ChangeSetManager implements set.setUserCreated(false); set.add(files); } - } + } } diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/BatchingChangeSetManager.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/BatchingChangeSetManager.java index ea8c4f540..f94fd8972 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/BatchingChangeSetManager.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/BatchingChangeSetManager.java @@ -123,16 +123,16 @@ public class BatchingChangeSetManager extends ChangeSetManager { } } - private void fireChanges(final IProgressMonitor monitor) { - if (changes.isEmpty()) { - return; - } - final CollectorChangeEvent event = changes; - changes = new CollectorChangeEvent(this); - Object[] listeners = getListeners(); - for (int i = 0; i < listeners.length; i++) { - final IChangeSetChangeListener listener = (IChangeSetChangeListener)listeners[i]; - if (listener instanceof IChangeSetCollectorChangeListener) { + private void fireChanges(final IProgressMonitor monitor) { + if (changes.isEmpty()) { + return; + } + final CollectorChangeEvent event = changes; + changes = new CollectorChangeEvent(this); + Object[] listeners = getListeners(); + for (int i = 0; i < listeners.length; i++) { + final IChangeSetChangeListener listener = (IChangeSetChangeListener)listeners[i]; + if (listener instanceof IChangeSetCollectorChangeListener) { final IChangeSetCollectorChangeListener csccl = (IChangeSetCollectorChangeListener) listener; SafeRunner.run(new ISafeRunnable() { @Override @@ -145,44 +145,44 @@ public class BatchingChangeSetManager extends ChangeSetManager { } }); } - } + } } - @Override + @Override public void add(ChangeSet set) { - try { - beginInput(); - super.add(set); - changes.setAdded(set); - } finally { - endInput(null); - } - } - - @Override + try { + beginInput(); + super.add(set); + changes.setAdded(set); + } finally { + endInput(null); + } + } + + @Override public void remove(ChangeSet set) { - try { - beginInput(); - super.remove(set); - changes.setRemoved(set); - } finally { - endInput(null); - } - } - - @Override + try { + beginInput(); + super.remove(set); + changes.setRemoved(set); + } finally { + endInput(null); + } + } + + @Override protected void fireResourcesChangedEvent(ChangeSet changeSet, IPath[] allAffectedResources) { - super.fireResourcesChangedEvent(changeSet, allAffectedResources); - try { - beginInput(); - changes.changed(changeSet, allAffectedResources); - } finally { - endInput(null); - } - } - - @Override + super.fireResourcesChangedEvent(changeSet, allAffectedResources); + try { + beginInput(); + changes.changed(changeSet, allAffectedResources); + } finally { + endInput(null); + } + } + + @Override protected void initializeSets() { - // Nothing to do - } + // Nothing to do + } } diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/BatchingLock.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/BatchingLock.java index eea5814a4..7c551b763 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/BatchingLock.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/BatchingLock.java @@ -86,7 +86,7 @@ public class BatchingLock { } finally { if (!success) { try { - // The begin was canceled (or some other problem occurred). + // The begin was canceled (or some other problem occurred). // Free the scheduling rule // so the clients of ReentrantLock don't need to // do an endRule when the operation is canceled. @@ -195,9 +195,9 @@ public class BatchingLock { handleAbortedFlush(e); throw e; } finally { - // We have to clear the resources no matter what since the next attempt + // We have to clear the resources no matter what since the next attempt // to flush may not have an appropriate scheduling rule - changedResources.clear(); + changedResources.clear(); } } private boolean isFlushRequired() { @@ -295,21 +295,21 @@ public class BatchingLock { * Create the ThreadInfo instance used to cache the lock state for the * current thread. Subclass can override to provide a subclass of * ThreadInfo. - * @param operation the flush operation - * @return a ThreadInfo instance - */ - protected ThreadInfo createThreadInfo(IFlushOperation operation) { - return new ThreadInfo(operation); - } + * @param operation the flush operation + * @return a ThreadInfo instance + */ + protected ThreadInfo createThreadInfo(IFlushOperation operation) { + return new ThreadInfo(operation); + } - /** + /** * Release the lock held on any resources by this thread. The provided rule must * be identical to the rule returned by the corresponding acquire(). If the rule * for the release is non-null and all remaining rules held by the lock are null, * the the flush operation provided in the acquire method will be executed. - * @param rule the scheduling rule - * @param monitor a progress monitor - * @throws TeamException + * @param rule the scheduling rule + * @param monitor a progress monitor + * @throws TeamException */ public void release(ISchedulingRule rule, IProgressMonitor monitor) throws TeamException { ThreadInfo info = getThreadInfo(); diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/ChangeSet.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/ChangeSet.java index 45b16a1f8..03c9e2e3e 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/ChangeSet.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/ChangeSet.java @@ -20,101 +20,101 @@ import org.eclipse.core.resources.IResource; */ public abstract class ChangeSet { - private String name; + private String name; - /** - * Create a change set with no name. Subclasses - * that create a change set in this manner should - * provide a name before the set is used by other clients. - */ - protected ChangeSet() { - super(); - } + /** + * Create a change set with no name. Subclasses + * that create a change set in this manner should + * provide a name before the set is used by other clients. + */ + protected ChangeSet() { + super(); + } - /** - * Create a change set with the given name. - * @param name the name of the change set - */ - public ChangeSet(String name) { - this.name = name; - } + /** + * Create a change set with the given name. + * @param name the name of the change set + */ + public ChangeSet(String name) { + this.name = name; + } - /** - * Return the resources that are contained in this set. - * @return the resources that are contained in this set - */ - public abstract IResource[] getResources(); + /** + * Return the resources that are contained in this set. + * @return the resources that are contained in this set + */ + public abstract IResource[] getResources(); - /** - * Return whether the set contains any files. - * @return whether the set contains any files - */ - public abstract boolean isEmpty(); + /** + * Return whether the set contains any files. + * @return whether the set contains any files + */ + public abstract boolean isEmpty(); - /** - * Return true if the given file is included in this set. - * @param local a local file - * @return true if the given file is included in this set - */ - public abstract boolean contains(IResource local); + /** + * Return true if the given file is included in this set. + * @param local a local file + * @return true if the given file is included in this set + */ + public abstract boolean contains(IResource local); - /** - * Remove the resource from the set. - * @param resource the resource to be removed - */ - public abstract void remove(IResource resource); + /** + * Remove the resource from the set. + * @param resource the resource to be removed + */ + public abstract void remove(IResource resource); - /** - * Remove the resources from the set. - * @param resources the resources to be removed - */ - public void remove(IResource[] resources) { - for (int i = 0; i < resources.length; i++) { - IResource resource = resources[i]; - remove(resource); - } - } + /** + * Remove the resources from the set. + * @param resources the resources to be removed + */ + public void remove(IResource[] resources) { + for (int i = 0; i < resources.length; i++) { + IResource resource = resources[i]; + remove(resource); + } + } - /** - * Remove the resource and it's descendants to the given depth. - * @param resource the resource to be removed - * @param depth the depth of the removal (one of - * <code>IResource.DEPTH_ZERO, IResource.DEPTH_ONE, IResource.DEPTH_INFINITE)</code> - */ - public abstract void rootRemoved(IResource resource, int depth); + /** + * Remove the resource and it's descendants to the given depth. + * @param resource the resource to be removed + * @param depth the depth of the removal (one of + * <code>IResource.DEPTH_ZERO, IResource.DEPTH_ONE, IResource.DEPTH_INFINITE)</code> + */ + public abstract void rootRemoved(IResource resource, int depth); - /** - * Return a comment describing the change. - * @return a comment describing the change - */ - public abstract String getComment(); + /** + * Return a comment describing the change. + * @return a comment describing the change + */ + public abstract String getComment(); - /** - * Return the name assigned to this set. The name should be - * unique. - * @return the name assigned to this set - */ - public String getName() { - return name; - } + /** + * Return the name assigned to this set. The name should be + * unique. + * @return the name assigned to this set + */ + public String getName() { + return name; + } - /** - * Set the name of the change set. The name of a change - * set can be changed but it is up to subclass to notify - * any interested partied of the name change. - * @param name the new name for the set - */ - protected void setName(String name) { - this.name = name; - } + /** + * Set the name of the change set. The name of a change + * set can be changed but it is up to subclass to notify + * any interested partied of the name change. + * @param name the new name for the set + */ + protected void setName(String name) { + this.name = name; + } - /** - * Return whether the set contains descendants of the given resource - * to the given depth. - * @param resource the resource - * @param depth the depth - * @return whether the set contains descendants of the given resource - * to the given depth - */ + /** + * Return whether the set contains descendants of the given resource + * to the given depth. + * @param resource the resource + * @param depth the depth + * @return whether the set contains descendants of the given resource + * to the given depth + */ public abstract boolean containsChildren(IResource resource, int depth); } diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/ChangeSetManager.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/ChangeSetManager.java index 61ff6d178..ca446b0a3 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/ChangeSetManager.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/ChangeSetManager.java @@ -27,219 +27,219 @@ import org.eclipse.core.runtime.SafeRunner; */ public abstract class ChangeSetManager { - private ListenerList<IChangeSetChangeListener> listeners = new ListenerList<IChangeSetChangeListener>(ListenerList.IDENTITY); - private Set<ChangeSet> sets; + private ListenerList<IChangeSetChangeListener> listeners = new ListenerList<IChangeSetChangeListener>(ListenerList.IDENTITY); + private Set<ChangeSet> sets; private boolean initializing; - /** - * Return the list of listeners registered with this change set manager. - * @return the list of listeners registered with this change set manager - */ - protected Object[] getListeners() { - return listeners.getListeners(); - } - - /** - * Method that can be invoked by subclasses when the name of - * a managed change set changes. - * @param set the set whose title has changed - */ - protected void fireNameChangedEvent(final ChangeSet set) { - if (initializing) - return; - if (contains(set)) { - Object[] listeners = getListeners(); - for (int i = 0; i < listeners.length; i++) { - final IChangeSetChangeListener listener = (IChangeSetChangeListener)listeners[i]; - SafeRunner.run(new ISafeRunnable() { - @Override + /** + * Return the list of listeners registered with this change set manager. + * @return the list of listeners registered with this change set manager + */ + protected Object[] getListeners() { + return listeners.getListeners(); + } + + /** + * Method that can be invoked by subclasses when the name of + * a managed change set changes. + * @param set the set whose title has changed + */ + protected void fireNameChangedEvent(final ChangeSet set) { + if (initializing) + return; + if (contains(set)) { + Object[] listeners = getListeners(); + for (int i = 0; i < listeners.length; i++) { + final IChangeSetChangeListener listener = (IChangeSetChangeListener)listeners[i]; + SafeRunner.run(new ISafeRunnable() { + @Override public void handleException(Throwable exception) { - // Exceptions are logged by the platform - } - @Override + // Exceptions are logged by the platform + } + @Override public void run() throws Exception { - listener.nameChanged(set); - } - }); - } - } - } - - /** - * Method which allows subclasses to notify listeners that the default - * set has changed. - * @param oldSet the previous default - * @param defaultSet the new default - */ - protected void fireDefaultChangedEvent(final ChangeSet oldSet, final ChangeSet defaultSet) { - if (initializing) - return; - Object[] listeners = getListeners(); - for (int i = 0; i < listeners.length; i++) { - final IChangeSetChangeListener listener = (IChangeSetChangeListener)listeners[i]; - SafeRunner.run(new ISafeRunnable() { - @Override + listener.nameChanged(set); + } + }); + } + } + } + + /** + * Method which allows subclasses to notify listeners that the default + * set has changed. + * @param oldSet the previous default + * @param defaultSet the new default + */ + protected void fireDefaultChangedEvent(final ChangeSet oldSet, final ChangeSet defaultSet) { + if (initializing) + return; + Object[] listeners = getListeners(); + for (int i = 0; i < listeners.length; i++) { + final IChangeSetChangeListener listener = (IChangeSetChangeListener)listeners[i]; + SafeRunner.run(new ISafeRunnable() { + @Override public void handleException(Throwable exception) { - // Exceptions are logged by the platform - } - @Override + // Exceptions are logged by the platform + } + @Override public void run() throws Exception { - listener.defaultSetChanged(oldSet, defaultSet); - } - }); - } - } - - /** - * Add the set to the list of active sets. - * @param set the set to be added - */ - public void add(final ChangeSet set) { - if (!contains(set)) { - internalGetSets().add(set); - handleSetAdded(set); - } - } - - /** - * Handle the set addition by notifying listeners. - * @param set the added set - */ + listener.defaultSetChanged(oldSet, defaultSet); + } + }); + } + } + + /** + * Add the set to the list of active sets. + * @param set the set to be added + */ + public void add(final ChangeSet set) { + if (!contains(set)) { + internalGetSets().add(set); + handleSetAdded(set); + } + } + + /** + * Handle the set addition by notifying listeners. + * @param set the added set + */ protected void handleSetAdded(final ChangeSet set) { - if (initializing) - return; + if (initializing) + return; Object[] listeners = getListeners(); for (int i = 0; i < listeners.length; i++) { - final IChangeSetChangeListener listener = (IChangeSetChangeListener)listeners[i]; - SafeRunner.run(new ISafeRunnable() { - @Override + final IChangeSetChangeListener listener = (IChangeSetChangeListener)listeners[i]; + SafeRunner.run(new ISafeRunnable() { + @Override public void handleException(Throwable exception) { - // Exceptions are logged by the platform - } - @Override + // Exceptions are logged by the platform + } + @Override public void run() throws Exception { - listener.setAdded(set); - } - }); + listener.setAdded(set); + } + }); } } - /** - * Remove the set from the list of active sets. - * @param set the set to be removed - */ - public void remove(final ChangeSet set) { - if (contains(set)) { - internalGetSets().remove(set); - handleSetRemoved(set); - } - } - - /** - * Handle the set removal by notifying listeners. - * @param set the removed set - */ + /** + * Remove the set from the list of active sets. + * @param set the set to be removed + */ + public void remove(final ChangeSet set) { + if (contains(set)) { + internalGetSets().remove(set); + handleSetRemoved(set); + } + } + + /** + * Handle the set removal by notifying listeners. + * @param set the removed set + */ protected void handleSetRemoved(final ChangeSet set) { - if (initializing) - return; + if (initializing) + return; Object[] listeners = getListeners(); for (int i = 0; i < listeners.length; i++) { - final IChangeSetChangeListener listener = (IChangeSetChangeListener)listeners[i]; - SafeRunner.run(new ISafeRunnable() { - @Override + final IChangeSetChangeListener listener = (IChangeSetChangeListener)listeners[i]; + SafeRunner.run(new ISafeRunnable() { + @Override public void handleException(Throwable exception) { - // Exceptions are logged by the platform - } - @Override + // Exceptions are logged by the platform + } + @Override public void run() throws Exception { - listener.setRemoved(set); - } - }); + listener.setRemoved(set); + } + }); } } - /** - * Return whether the manager contains the given commit set - * @param set the commit set being tested - * @return whether the set is contained in the manager's list of active sets - */ - public boolean contains(ChangeSet set) { - return internalGetSets().contains(set); - } - - /** - * Add the listener to the set of registered listeners. - * @param listener the listener to be added - */ - public void addListener(IChangeSetChangeListener listener) { - listeners.add(listener); - } - - /** - * Remove the listener from the set of registered listeners. - * @param listener the listener to remove - */ - public void removeListener(IChangeSetChangeListener listener) { - listeners.remove(listener); - } - - /** - * Return the list of active commit sets. - * @return the list of active commit sets - */ - public ChangeSet[] getSets() { - Set<ChangeSet> sets = internalGetSets(); + /** + * Return whether the manager contains the given commit set + * @param set the commit set being tested + * @return whether the set is contained in the manager's list of active sets + */ + public boolean contains(ChangeSet set) { + return internalGetSets().contains(set); + } + + /** + * Add the listener to the set of registered listeners. + * @param listener the listener to be added + */ + public void addListener(IChangeSetChangeListener listener) { + listeners.add(listener); + } + + /** + * Remove the listener from the set of registered listeners. + * @param listener the listener to remove + */ + public void removeListener(IChangeSetChangeListener listener) { + listeners.remove(listener); + } + + /** + * Return the list of active commit sets. + * @return the list of active commit sets + */ + public ChangeSet[] getSets() { + Set<ChangeSet> sets = internalGetSets(); return sets.toArray(new ChangeSet[sets.size()]); - } - - /** - * Dispose of any resources maintained by the manager - */ - public void dispose() { - // Nothing to do - } - - /** - * Fire resource change notifications to the listeners. - * @param changeSet - * @param allAffectedResources - */ - protected void fireResourcesChangedEvent(final ChangeSet changeSet, final IPath[] allAffectedResources) { - if (initializing) - return; - Object[] listeners = getListeners(); - for (int i = 0; i < listeners.length; i++) { - final IChangeSetChangeListener listener = (IChangeSetChangeListener)listeners[i]; - SafeRunner.run(new ISafeRunnable() { - @Override + } + + /** + * Dispose of any resources maintained by the manager + */ + public void dispose() { + // Nothing to do + } + + /** + * Fire resource change notifications to the listeners. + * @param changeSet + * @param allAffectedResources + */ + protected void fireResourcesChangedEvent(final ChangeSet changeSet, final IPath[] allAffectedResources) { + if (initializing) + return; + Object[] listeners = getListeners(); + for (int i = 0; i < listeners.length; i++) { + final IChangeSetChangeListener listener = (IChangeSetChangeListener)listeners[i]; + SafeRunner.run(new ISafeRunnable() { + @Override public void handleException(Throwable exception) { - // Exceptions are logged by the platform - } - @Override + // Exceptions are logged by the platform + } + @Override public void run() throws Exception { - listener.resourcesChanged(changeSet, allAffectedResources); - } - }); - } - } - - private Set<ChangeSet> internalGetSets() { - if (sets == null) { - sets = Collections.synchronizedSet(new HashSet<>()); - try { - initializing = true; - initializeSets(); - } finally { - initializing = false; - } - } - return sets; - } - - /** - * Initialize the sets contained in this manager. - * This method is called the first time the sets are accessed. - */ + listener.resourcesChanged(changeSet, allAffectedResources); + } + }); + } + } + + private Set<ChangeSet> internalGetSets() { + if (sets == null) { + sets = Collections.synchronizedSet(new HashSet<>()); + try { + initializing = true; + initializeSets(); + } finally { + initializing = false; + } + } + return sets; + } + + /** + * Initialize the sets contained in this manager. + * This method is called the first time the sets are accessed. + */ protected abstract void initializeSets(); public boolean isInitialized() { diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/CheckedInChangeSet.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/CheckedInChangeSet.java index 9cada75b6..92a65d4a2 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/CheckedInChangeSet.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/CheckedInChangeSet.java @@ -35,128 +35,128 @@ public abstract class CheckedInChangeSet extends ChangeSet { private final SyncInfoTree set = new SyncInfoTree(); - public abstract String getAuthor(); - - public abstract Date getDate(); - - /** - * Return the SyncInfoSet that contains the resources that belong to this change set. - * @return the SyncInfoSet that contains the resources that belong to this change set - */ - public SyncInfoTree getSyncInfoSet() { - return set; - } - - /** - * Return the resources that are contained in this set. - * @return the resources that are contained in this set - */ - @Override + public abstract String getAuthor(); + + public abstract Date getDate(); + + /** + * Return the SyncInfoSet that contains the resources that belong to this change set. + * @return the SyncInfoSet that contains the resources that belong to this change set + */ + public SyncInfoTree getSyncInfoSet() { + return set; + } + + /** + * Return the resources that are contained in this set. + * @return the resources that are contained in this set + */ + @Override public IResource[] getResources() { - return set.getResources(); - } - - /** - * Return whether the set contains any files. - * @return whether the set contains any files - */ - @Override + return set.getResources(); + } + + /** + * Return whether the set contains any files. + * @return whether the set contains any files + */ + @Override public boolean isEmpty() { - return set.isEmpty(); - } - - /** - * Return true if the given file is included in this set. - * @param local a local file - * @return true if the given file is included in this set - */ - @Override + return set.isEmpty(); + } + + /** + * Return true if the given file is included in this set. + * @param local a local file + * @return true if the given file is included in this set + */ + @Override public boolean contains(IResource local) { - return set.getSyncInfo(local) != null; - } - - /** - * Add the resource to this set if it is modified - * w.r.t. the subscriber. - * @param info - */ - public void add(SyncInfo info) { - if (isValidChange(info)) { - set.add(info); - } - } - - /** - * Return whether the given sync info is a valid change - * and can be included in this set. This method is used - * by the <code>add</code> method to filter set additions. - * @param info a sync info - * @return whether the sync info is a valid member of this set - */ - protected boolean isValidChange(SyncInfo info) { - return (info != null); - } - - /** - * Add the resources to this set if they are modified - * w.r.t. the subscriber. - * @param infos the resources to be added. - */ - public void add(SyncInfo[] infos) { - try { - set.beginInput(); - for (int i = 0; i < infos.length; i++) { - SyncInfo info = infos[i]; - add(info); - } - } finally { - set.endInput(null); - } - } - - /** - * Remove the resource from the set. - * @param resource the resource to be removed - */ - @Override + return set.getSyncInfo(local) != null; + } + + /** + * Add the resource to this set if it is modified + * w.r.t. the subscriber. + * @param info + */ + public void add(SyncInfo info) { + if (isValidChange(info)) { + set.add(info); + } + } + + /** + * Return whether the given sync info is a valid change + * and can be included in this set. This method is used + * by the <code>add</code> method to filter set additions. + * @param info a sync info + * @return whether the sync info is a valid member of this set + */ + protected boolean isValidChange(SyncInfo info) { + return (info != null); + } + + /** + * Add the resources to this set if they are modified + * w.r.t. the subscriber. + * @param infos the resources to be added. + */ + public void add(SyncInfo[] infos) { + try { + set.beginInput(); + for (int i = 0; i < infos.length; i++) { + SyncInfo info = infos[i]; + add(info); + } + } finally { + set.endInput(null); + } + } + + /** + * Remove the resource from the set. + * @param resource the resource to be removed + */ + @Override public void remove(IResource resource) { - if (contains(resource)) { - set.remove(resource); - } - } - - /** - * Remove the resources from the set. - * @param resources the resources to be removed - */ - @Override + if (contains(resource)) { + set.remove(resource); + } + } + + /** + * Remove the resources from the set. + * @param resources the resources to be removed + */ + @Override public void remove(IResource[] resources) { - for (int i = 0; i < resources.length; i++) { - IResource resource = resources[i]; - remove(resource); - } - } - - /** - * Remove the resource and it's descendants to the given depth. - * @param resource the resource to be removed - * @param depth the depth of the removal (one of - * <code>IResource.DEPTH_ZERO, IResource.DEPTH_ONE, IResource.DEPTH_INFINITE)</code> - */ - @Override + for (int i = 0; i < resources.length; i++) { + IResource resource = resources[i]; + remove(resource); + } + } + + /** + * Remove the resource and it's descendants to the given depth. + * @param resource the resource to be removed + * @param depth the depth of the removal (one of + * <code>IResource.DEPTH_ZERO, IResource.DEPTH_ONE, IResource.DEPTH_INFINITE)</code> + */ + @Override public void rootRemoved(IResource resource, int depth) { - SyncInfo[] infos = set.getSyncInfos(resource, depth); - if (infos.length > 0) { - IResource[] resources = new IResource[infos.length]; - for (int i = 0; i < resources.length; i++) { - resources[i] = infos[i].getLocal(); - } - set.removeAll(resources); - } - } - - @Override + SyncInfo[] infos = set.getSyncInfos(resource, depth); + if (infos.length > 0) { + IResource[] resources = new IResource[infos.length]; + for (int i = 0; i < resources.length; i++) { + resources[i] = infos[i].getLocal(); + } + set.removeAll(resources); + } + } + + @Override public boolean containsChildren(IResource resource, int depth) { - return set.getSyncInfos(resource, depth).length > 0; - } + return set.getSyncInfos(resource, depth).length > 0; + } } diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/DiffChangeSet.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/DiffChangeSet.java index 0a0798d78..cfb3a92e1 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/DiffChangeSet.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/DiffChangeSet.java @@ -23,127 +23,127 @@ public class DiffChangeSet extends ChangeSet { private final ResourceDiffTree tree = new ResourceDiffTree(); - public DiffChangeSet() { + public DiffChangeSet() { super(); } - public DiffChangeSet(String name) { - super(name); - } + public DiffChangeSet(String name) { + super(name); + } - /** - * Return the diff tree that contains the resources that belong to this change set. - * @return the diff tree that contains the resources that belong to this change set - */ - public IResourceDiffTree getDiffTree() { - return tree; - } + /** + * Return the diff tree that contains the resources that belong to this change set. + * @return the diff tree that contains the resources that belong to this change set + */ + public IResourceDiffTree getDiffTree() { + return tree; + } - protected ResourceDiffTree internalGetDiffTree() { - return tree; - } + protected ResourceDiffTree internalGetDiffTree() { + return tree; + } - /** - * Return the resources that are contained in this set. - * @return the resources that are contained in this set - */ - @Override + /** + * Return the resources that are contained in this set. + * @return the resources that are contained in this set + */ + @Override public IResource[] getResources() { - return tree.getAffectedResources(); - } - - /** - * Return whether the set contains any files. - * @return whether the set contains any files - */ - @Override + return tree.getAffectedResources(); + } + + /** + * Return whether the set contains any files. + * @return whether the set contains any files + */ + @Override public boolean isEmpty() { - return tree.isEmpty(); - } - - /** - * Return true if the given file is included in this set. - * @param local a local file - * @return true if the given file is included in this set - */ - @Override + return tree.isEmpty(); + } + + /** + * Return true if the given file is included in this set. + * @param local a local file + * @return true if the given file is included in this set + */ + @Override public boolean contains(IResource local) { - return tree.getDiff(local) != null; - } - - /** - * Add the resource to this set if it is modified - * w.r.t. the subscriber. - * @param diff the diff to be added - */ - public void add(IDiff diff) { - if (isValidChange(diff)) { - tree.add(diff); - } - } - - /** - * Return whether the given sync info is a valid change - * and can be included in this set. This method is used - * by the <code>add</code> method to filter set additions. - * @param diff a diff - * @return whether the sync info is a valid member of this set - */ - protected boolean isValidChange(IDiff diff) { - return (diff != null); - } - - /** - * Add the resources to this set if they are modified - * w.r.t. the subscriber. - * @param diffs the resources to be added. - */ - public void add(IDiff[] diffs) { - try { - tree.beginInput(); - for (int i = 0; i < diffs.length; i++) { - IDiff diff = diffs[i]; - add(diff); - } - } finally { - tree.endInput(null); - } - } - - /** - * Remove the resource from the set. - * @param resource the resource to be removed - */ - @Override + return tree.getDiff(local) != null; + } + + /** + * Add the resource to this set if it is modified + * w.r.t. the subscriber. + * @param diff the diff to be added + */ + public void add(IDiff diff) { + if (isValidChange(diff)) { + tree.add(diff); + } + } + + /** + * Return whether the given sync info is a valid change + * and can be included in this set. This method is used + * by the <code>add</code> method to filter set additions. + * @param diff a diff + * @return whether the sync info is a valid member of this set + */ + protected boolean isValidChange(IDiff diff) { + return (diff != null); + } + + /** + * Add the resources to this set if they are modified + * w.r.t. the subscriber. + * @param diffs the resources to be added. + */ + public void add(IDiff[] diffs) { + try { + tree.beginInput(); + for (int i = 0; i < diffs.length; i++) { + IDiff diff = diffs[i]; + add(diff); + } + } finally { + tree.endInput(null); + } + } + + /** + * Remove the resource from the set. + * @param resource the resource to be removed + */ + @Override public void remove(IResource resource) { - if (contains(resource)) { - tree.remove(resource); - } - } - - /** - * Remove the resource and it's descendants to the given depth. - * @param resource the resource to be removed - * @param depth the depth of the removal (one of - * <code>IResource.DEPTH_ZERO, IResource.DEPTH_ONE, IResource.DEPTH_INFINITE)</code> - */ - @Override + if (contains(resource)) { + tree.remove(resource); + } + } + + /** + * Remove the resource and it's descendants to the given depth. + * @param resource the resource to be removed + * @param depth the depth of the removal (one of + * <code>IResource.DEPTH_ZERO, IResource.DEPTH_ONE, IResource.DEPTH_INFINITE)</code> + */ + @Override public void rootRemoved(IResource resource, int depth) { - IDiff[] diffs = tree.getDiffs(resource, depth); - if (diffs.length > 0) { - try { - tree.beginInput(); - for (int i = 0; i < diffs.length; i++) { + IDiff[] diffs = tree.getDiffs(resource, depth); + if (diffs.length > 0) { + try { + tree.beginInput(); + for (int i = 0; i < diffs.length; i++) { IDiff diff = diffs[i]; IResource r = tree.getResource(diff); if (r != null) tree.remove(r); } - } finally { - tree.endInput(null); - } - } - } + } finally { + tree.endInput(null); + } + } + } public boolean contains(IPath path) { return getDiffTree().getDiff(path) != null; diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/IChangeSetChangeListener.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/IChangeSetChangeListener.java index ec42f7711..78f125f8a 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/IChangeSetChangeListener.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/IChangeSetChangeListener.java @@ -22,41 +22,41 @@ import org.eclipse.core.runtime.IPath; */ public interface IChangeSetChangeListener { - /** - * The given set has been added to the set manager. - * @param set the added set - */ - void setAdded(ChangeSet set); - - /** - * The default change set has change to be the given set. - * All new modifications will be placed in the default - * set. - * @param previousDefault - * @param set the default set - */ - void defaultSetChanged(ChangeSet previousDefault, ChangeSet set); - - /** - * The given set has been removed from the set manager. - * @param set the removed set - */ - void setRemoved(ChangeSet set); - - /** - * The title of the given set has changed. - * @param set the set whose title changed - */ - void nameChanged(ChangeSet set); - - /** - * The state of the given resources have change with respect to the - * given set. This means that the resource have either been added - * or removed from the set. Callers can use the resources contained - * in the set to determine if each resource is an addition or removal. - * @param set the set that has changed - * @param paths the paths of the resources whose containment state has changed w.r.t the set - */ - void resourcesChanged(ChangeSet set, IPath[] paths); + /** + * The given set has been added to the set manager. + * @param set the added set + */ + void setAdded(ChangeSet set); + + /** + * The default change set has change to be the given set. + * All new modifications will be placed in the default + * set. + * @param previousDefault + * @param set the default set + */ + void defaultSetChanged(ChangeSet previousDefault, ChangeSet set); + + /** + * The given set has been removed from the set manager. + * @param set the removed set + */ + void setRemoved(ChangeSet set); + + /** + * The title of the given set has changed. + * @param set the set whose title changed + */ + void nameChanged(ChangeSet set); + + /** + * The state of the given resources have change with respect to the + * given set. This means that the resource have either been added + * or removed from the set. Callers can use the resources contained + * in the set to determine if each resource is an addition or removal. + * @param set the set that has changed + * @param paths the paths of the resources whose containment state has changed w.r.t the set + */ + void resourcesChanged(ChangeSet set, IPath[] paths); } diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SubscriberChangeSetManager.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SubscriberChangeSetManager.java index 462860ca5..c34010237 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SubscriberChangeSetManager.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SubscriberChangeSetManager.java @@ -42,288 +42,288 @@ import org.osgi.service.prefs.Preferences; */ public class SubscriberChangeSetManager extends ActiveChangeSetManager { - private static final String PREF_CHANGE_SETS = "changeSets"; //$NON-NLS-1$ + private static final String PREF_CHANGE_SETS = "changeSets"; //$NON-NLS-1$ - private static final int RESOURCE_REMOVAL = 1; - private static final int RESOURCE_CHANGE = 2; + private static final int RESOURCE_REMOVAL = 1; + private static final int RESOURCE_CHANGE = 2; - private EventHandler handler; - private ResourceCollector collector; + private EventHandler handler; + private ResourceCollector collector; - /* - * Background event handler for serializing and batching change set changes - */ - private class EventHandler extends BackgroundEventHandler { + /* + * Background event handler for serializing and batching change set changes + */ + private class EventHandler extends BackgroundEventHandler { - private List<Event> dispatchEvents = new ArrayList<>(); + private List<Event> dispatchEvents = new ArrayList<>(); - protected EventHandler(String jobName, String errorTitle) { - super(jobName, errorTitle); - } + protected EventHandler(String jobName, String errorTitle) { + super(jobName, errorTitle); + } - @Override + @Override protected void processEvent(Event event, IProgressMonitor monitor) throws CoreException { - // Handle everything in the dispatch - if (isShutdown()) - throw new OperationCanceledException(); - dispatchEvents.add(event); - } + // Handle everything in the dispatch + if (isShutdown()) + throw new OperationCanceledException(); + dispatchEvents.add(event); + } - @Override + @Override protected boolean doDispatchEvents(IProgressMonitor monitor) throws TeamException { - if (dispatchEvents.isEmpty()) { - return false; - } - if (isShutdown()) - throw new OperationCanceledException(); - ResourceDiffTree[] locked = null; - try { - locked = beginDispath(); - for (Iterator iter = dispatchEvents.iterator(); iter.hasNext();) { - Event event = (Event) iter.next(); - switch (event.getType()) { - case RESOURCE_REMOVAL: - handleRemove(event.getResource()); - break; - case RESOURCE_CHANGE: - handleChange(event.getResource(), ((ResourceEvent)event).getDepth()); - break; - default: - break; - } - if (isShutdown()) - throw new OperationCanceledException(); - } - } catch (CoreException e) { + if (dispatchEvents.isEmpty()) { + return false; + } + if (isShutdown()) + throw new OperationCanceledException(); + ResourceDiffTree[] locked = null; + try { + locked = beginDispath(); + for (Iterator iter = dispatchEvents.iterator(); iter.hasNext();) { + Event event = (Event) iter.next(); + switch (event.getType()) { + case RESOURCE_REMOVAL: + handleRemove(event.getResource()); + break; + case RESOURCE_CHANGE: + handleChange(event.getResource(), ((ResourceEvent)event).getDepth()); + break; + default: + break; + } + if (isShutdown()) + throw new OperationCanceledException(); + } + } catch (CoreException e) { throw TeamException.asTeamException(e); } finally { - try { - endDispatch(locked, monitor); - } finally { - dispatchEvents.clear(); - } - } - return true; - } - - /* - * Begin input on all the sets and return the sync sets that were - * locked. If this method throws an exception then the client - * can assume that no sets were locked - */ - private ResourceDiffTree[] beginDispath() { - ChangeSet[] sets = getSets(); - List<ResourceDiffTree> lockedSets = new ArrayList<>(); - try { - for (int i = 0; i < sets.length; i++) { - ActiveChangeSet set = (ActiveChangeSet)sets[i]; - ResourceDiffTree tree = set.internalGetDiffTree(); - lockedSets.add(tree); - tree.beginInput(); - } - return lockedSets.toArray(new ResourceDiffTree[lockedSets.size()]); - } catch (RuntimeException e) { - try { - for (Iterator iter = lockedSets.iterator(); iter.hasNext();) { - ResourceDiffTree tree = (ResourceDiffTree) iter.next(); - try { - tree.endInput(null); - } catch (Throwable e1) { - // Ignore so that original exception is not masked - } - } - } catch (Throwable e1) { - // Ignore so that original exception is not masked - } - throw e; - } - } - - private void endDispatch(ResourceDiffTree[] locked, IProgressMonitor monitor) { - if (locked == null) { - // The begin failed so there's nothing to unlock - return; - } - monitor.beginTask(null, 100 * locked.length); - for (int i = 0; i < locked.length; i++) { - ResourceDiffTree tree = locked[i]; - try { - tree.endInput(Policy.subMonitorFor(monitor, 100)); - } catch (RuntimeException e) { - // Don't worry about ending every set if an error occurs. - // Instead, log the error and suggest a restart. - TeamPlugin.log(IStatus.ERROR, Messages.SubscriberChangeSetCollector_0, e); - throw e; - } - } - monitor.done(); - } - - @Override + try { + endDispatch(locked, monitor); + } finally { + dispatchEvents.clear(); + } + } + return true; + } + + /* + * Begin input on all the sets and return the sync sets that were + * locked. If this method throws an exception then the client + * can assume that no sets were locked + */ + private ResourceDiffTree[] beginDispath() { + ChangeSet[] sets = getSets(); + List<ResourceDiffTree> lockedSets = new ArrayList<>(); + try { + for (int i = 0; i < sets.length; i++) { + ActiveChangeSet set = (ActiveChangeSet)sets[i]; + ResourceDiffTree tree = set.internalGetDiffTree(); + lockedSets.add(tree); + tree.beginInput(); + } + return lockedSets.toArray(new ResourceDiffTree[lockedSets.size()]); + } catch (RuntimeException e) { + try { + for (Iterator iter = lockedSets.iterator(); iter.hasNext();) { + ResourceDiffTree tree = (ResourceDiffTree) iter.next(); + try { + tree.endInput(null); + } catch (Throwable e1) { + // Ignore so that original exception is not masked + } + } + } catch (Throwable e1) { + // Ignore so that original exception is not masked + } + throw e; + } + } + + private void endDispatch(ResourceDiffTree[] locked, IProgressMonitor monitor) { + if (locked == null) { + // The begin failed so there's nothing to unlock + return; + } + monitor.beginTask(null, 100 * locked.length); + for (int i = 0; i < locked.length; i++) { + ResourceDiffTree tree = locked[i]; + try { + tree.endInput(Policy.subMonitorFor(monitor, 100)); + } catch (RuntimeException e) { + // Don't worry about ending every set if an error occurs. + // Instead, log the error and suggest a restart. + TeamPlugin.log(IStatus.ERROR, Messages.SubscriberChangeSetCollector_0, e); + throw e; + } + } + monitor.done(); + } + + @Override protected synchronized void queueEvent(Event event, boolean front) { - // Override to allow access from enclosing class - super.queueEvent(event, front); - } - - /* - * Handle the removal - */ - private void handleRemove(IResource resource) { - ChangeSet[] sets = getSets(); - for (int i = 0; i < sets.length; i++) { - ChangeSet set = sets[i]; - // This will remove any descendants from the set and callback to - // resourcesChanged which will batch changes - if (!set.isEmpty()) { - set.rootRemoved(resource, IResource.DEPTH_INFINITE); - if (set.isEmpty()) { - remove(set); - } - } - } - } - - /* - * Handle the change - */ - private void handleChange(IResource resource, int depth) throws CoreException { - IDiff diff = getDiff(resource); - if (isModified(diff)) { - ActiveChangeSet[] containingSets = getContainingSets(resource); - if (containingSets.length == 0) { - // Consider for inclusion in the default set - // if the resource is not already a member of another set - if (getDefaultSet() != null) { - getDefaultSet().add(diff); - } - } else { - for (int i = 0; i < containingSets.length; i++) { - ActiveChangeSet set = containingSets[i]; - // Update the sync info in the set - set.add(diff); - } - } - } else { - removeFromAllSets(resource); - } - if (depth != IResource.DEPTH_ZERO) { - IResource[] members = getSubscriber().members(resource); - for (int i = 0; i < members.length; i++) { - IResource member = members[i]; - handleChange(member, depth == IResource.DEPTH_ONE ? IResource.DEPTH_ZERO : IResource.DEPTH_INFINITE); - } - } - } - - private void removeFromAllSets(IResource resource) { - List<ChangeSet> toRemove = new ArrayList<>(); - ChangeSet[] sets = getSets(); - for (int i = 0; i < sets.length; i++) { - ChangeSet set = sets[i]; - if (set.contains(resource)) { - set.remove(resource); - if (set.isEmpty()) { - toRemove.add(set); - } - } - } - for (Object element : toRemove) { - ActiveChangeSet set = (ActiveChangeSet) element; - remove(set); - } - } - - private ActiveChangeSet[] getContainingSets(IResource resource) { - Set<ActiveChangeSet> result = new HashSet<>(); - ChangeSet[] sets = getSets(); - for (int i = 0; i < sets.length; i++) { - ChangeSet set = sets[i]; - if (set.contains(resource)) { - result.add((ActiveChangeSet) set); - } - } - return result.toArray(new ActiveChangeSet[result.size()]); - } - } - - private class ResourceCollector extends SubscriberResourceCollector { - - public ResourceCollector(Subscriber subscriber) { - super(subscriber); - } - - @Override + // Override to allow access from enclosing class + super.queueEvent(event, front); + } + + /* + * Handle the removal + */ + private void handleRemove(IResource resource) { + ChangeSet[] sets = getSets(); + for (int i = 0; i < sets.length; i++) { + ChangeSet set = sets[i]; + // This will remove any descendants from the set and callback to + // resourcesChanged which will batch changes + if (!set.isEmpty()) { + set.rootRemoved(resource, IResource.DEPTH_INFINITE); + if (set.isEmpty()) { + remove(set); + } + } + } + } + + /* + * Handle the change + */ + private void handleChange(IResource resource, int depth) throws CoreException { + IDiff diff = getDiff(resource); + if (isModified(diff)) { + ActiveChangeSet[] containingSets = getContainingSets(resource); + if (containingSets.length == 0) { + // Consider for inclusion in the default set + // if the resource is not already a member of another set + if (getDefaultSet() != null) { + getDefaultSet().add(diff); + } + } else { + for (int i = 0; i < containingSets.length; i++) { + ActiveChangeSet set = containingSets[i]; + // Update the sync info in the set + set.add(diff); + } + } + } else { + removeFromAllSets(resource); + } + if (depth != IResource.DEPTH_ZERO) { + IResource[] members = getSubscriber().members(resource); + for (int i = 0; i < members.length; i++) { + IResource member = members[i]; + handleChange(member, depth == IResource.DEPTH_ONE ? IResource.DEPTH_ZERO : IResource.DEPTH_INFINITE); + } + } + } + + private void removeFromAllSets(IResource resource) { + List<ChangeSet> toRemove = new ArrayList<>(); + ChangeSet[] sets = getSets(); + for (int i = 0; i < sets.length; i++) { + ChangeSet set = sets[i]; + if (set.contains(resource)) { + set.remove(resource); + if (set.isEmpty()) { + toRemove.add(set); + } + } + } + for (Object element : toRemove) { + ActiveChangeSet set = (ActiveChangeSet) element; + remove(set); + } + } + + private ActiveChangeSet[] getContainingSets(IResource resource) { + Set<ActiveChangeSet> result = new HashSet<>(); + ChangeSet[] sets = getSets(); + for (int i = 0; i < sets.length; i++) { + ChangeSet set = sets[i]; + if (set.contains(resource)) { + result.add((ActiveChangeSet) set); + } + } + return result.toArray(new ActiveChangeSet[result.size()]); + } + } + + private class ResourceCollector extends SubscriberResourceCollector { + + public ResourceCollector(Subscriber subscriber) { + super(subscriber); + } + + @Override protected void remove(IResource resource) { - if (handler != null) - handler.queueEvent(new BackgroundEventHandler.ResourceEvent(resource, RESOURCE_REMOVAL, IResource.DEPTH_INFINITE), false); - } + if (handler != null) + handler.queueEvent(new BackgroundEventHandler.ResourceEvent(resource, RESOURCE_REMOVAL, IResource.DEPTH_INFINITE), false); + } - @Override + @Override protected void change(IResource resource, int depth) { - if (handler != null) - handler.queueEvent(new BackgroundEventHandler.ResourceEvent(resource, RESOURCE_CHANGE, depth), false); - } + if (handler != null) + handler.queueEvent(new BackgroundEventHandler.ResourceEvent(resource, RESOURCE_CHANGE, depth), false); + } - @Override + @Override protected boolean hasMembers(IResource resource) { - return SubscriberChangeSetManager.this.hasMembers(resource); - } - } + return SubscriberChangeSetManager.this.hasMembers(resource); + } + } - public SubscriberChangeSetManager(Subscriber subscriber) { - collector = new ResourceCollector(subscriber); - handler = new EventHandler(NLS.bind(Messages.SubscriberChangeSetCollector_1, new String[] { subscriber.getName() }), NLS.bind(Messages.SubscriberChangeSetCollector_2, new String[] { subscriber.getName() })); // - } + public SubscriberChangeSetManager(Subscriber subscriber) { + collector = new ResourceCollector(subscriber); + handler = new EventHandler(NLS.bind(Messages.SubscriberChangeSetCollector_1, new String[] { subscriber.getName() }), NLS.bind(Messages.SubscriberChangeSetCollector_2, new String[] { subscriber.getName() })); // + } - @Override + @Override protected void initializeSets() { - load(getPreferences()); - } - - public boolean hasMembers(IResource resource) { - ChangeSet[] sets = getSets(); - for (int i = 0; i < sets.length; i++) { - ActiveChangeSet set = (ActiveChangeSet)sets[i]; - if (set.getDiffTree().getChildren(resource.getFullPath()).length > 0) - return true; - } - if (getDefaultSet() != null) - return (getDefaultSet().getDiffTree().getChildren(resource.getFullPath()).length > 0); - return false; - } - - /** - * Return the sync info for the given resource obtained - * from the subscriber. - * @param resource the resource - * @return the sync info for the resource - * @throws CoreException - */ - @Override + load(getPreferences()); + } + + public boolean hasMembers(IResource resource) { + ChangeSet[] sets = getSets(); + for (int i = 0; i < sets.length; i++) { + ActiveChangeSet set = (ActiveChangeSet)sets[i]; + if (set.getDiffTree().getChildren(resource.getFullPath()).length > 0) + return true; + } + if (getDefaultSet() != null) + return (getDefaultSet().getDiffTree().getChildren(resource.getFullPath()).length > 0); + return false; + } + + /** + * Return the sync info for the given resource obtained + * from the subscriber. + * @param resource the resource + * @return the sync info for the resource + * @throws CoreException + */ + @Override public IDiff getDiff(IResource resource) throws CoreException { - Subscriber subscriber = getSubscriber(); - return subscriber.getDiff(resource); - } - - /** - * Return the subscriber associated with this collector. - * @return the subscriber associated with this collector - */ - public Subscriber getSubscriber() { - return collector.getSubscriber(); - } - - @Override + Subscriber subscriber = getSubscriber(); + return subscriber.getDiff(resource); + } + + /** + * Return the subscriber associated with this collector. + * @return the subscriber associated with this collector + */ + public Subscriber getSubscriber() { + return collector.getSubscriber(); + } + + @Override public void dispose() { - handler.shutdown(); - collector.dispose(); - super.dispose(); - save(getPreferences()); - } + handler.shutdown(); + collector.dispose(); + super.dispose(); + save(getPreferences()); + } - private Preferences getPreferences() { - return getParentPreferences().node(getSubscriberIdentifier()); - } + private Preferences getPreferences() { + return getParentPreferences().node(getSubscriberIdentifier()); + } private static Preferences getParentPreferences() { return getTeamPreferences().node(PREF_CHANGE_SETS); @@ -333,21 +333,21 @@ public class SubscriberChangeSetManager extends ActiveChangeSetManager { return InstanceScope.INSTANCE.getNode(TeamPlugin.getPlugin().getBundle().getSymbolicName()); } - /** - * Return the id that will uniquely identify the subscriber across - * restarts. - * @return the id that will uniquely identify the subscriber across - */ - protected String getSubscriberIdentifier() { - return getSubscriber().getName(); - } - - /** - * Wait until the collector is done processing any events. - * This method is for testing purposes only. - * @param monitor - */ - public void waitUntilDone(IProgressMonitor monitor) { + /** + * Return the id that will uniquely identify the subscriber across + * restarts. + * @return the id that will uniquely identify the subscriber across + */ + protected String getSubscriberIdentifier() { + return getSubscriber().getName(); + } + + /** + * Wait until the collector is done processing any events. + * This method is for testing purposes only. + * @param monitor + */ + public void waitUntilDone(IProgressMonitor monitor) { monitor.worked(1); // wait for the event handler to process changes. while(handler.getEventHandlerJob().getState() != Job.NONE) { @@ -359,7 +359,7 @@ public class SubscriberChangeSetManager extends ActiveChangeSetManager { Policy.checkCanceled(monitor); } monitor.worked(1); - } + } @Override protected String getName() { diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SubscriberDiffTreeEventHandler.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SubscriberDiffTreeEventHandler.java index c6454da7c..4fbe86525 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SubscriberDiffTreeEventHandler.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SubscriberDiffTreeEventHandler.java @@ -205,7 +205,7 @@ public class SubscriberDiffTreeEventHandler extends SubscriberEventHandler { protected void dispatchEvents(SubscriberEvent[] events, IProgressMonitor monitor) { try { - tree.beginInput(); + tree.beginInput(); for (int i = 0; i < events.length; i++) { SubscriberEvent event = events[i]; switch (event.getType()) { diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SubscriberEventHandler.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SubscriberEventHandler.java index 79355152b..94e2495a4 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SubscriberEventHandler.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SubscriberEventHandler.java @@ -310,15 +310,15 @@ public abstract class SubscriberEventHandler extends BackgroundEventHandler { break; case SubscriberEvent.CHANGE : collect( - event.getResource(), - ((ResourceEvent)event).getDepth(), + event.getResource(), + ((ResourceEvent)event).getDepth(), monitor); break; case SubscriberEvent.INITIALIZE : monitor.subTask(NLS.bind(Messages.SubscriberEventHandler_2, new String[] { event.getResource().getFullPath().toString() })); collectAll( - event.getResource(), - ((ResourceEvent)event).getDepth(), + event.getResource(), + ((ResourceEvent)event).getDepth(), Policy.subMonitorFor(monitor, 64)); break; } diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SubscriberResourceCollector.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SubscriberResourceCollector.java index f202ca6e3..04b85e69f 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SubscriberResourceCollector.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SubscriberResourceCollector.java @@ -32,19 +32,19 @@ import org.eclipse.team.core.subscribers.Subscriber; */ public abstract class SubscriberResourceCollector implements IResourceChangeListener, ISubscriberChangeListener { - Subscriber subscriber; - - /** - * Create the collector and register it as a listener with the workspace - * and the subscriber. - * @param subscriber the subscriber to be associated with this collector - */ - public SubscriberResourceCollector(Subscriber subscriber) { - Assert.isNotNull(subscriber); - this.subscriber = subscriber; + Subscriber subscriber; + + /** + * Create the collector and register it as a listener with the workspace + * and the subscriber. + * @param subscriber the subscriber to be associated with this collector + */ + public SubscriberResourceCollector(Subscriber subscriber) { + Assert.isNotNull(subscriber); + this.subscriber = subscriber; ResourcesPlugin.getWorkspace().addResourceChangeListener(this, IResourceChangeEvent.POST_CHANGE); subscriber.addListener(this); - } + } /** * Returns the <code>Subscriber</code> associated with this collector. @@ -55,9 +55,9 @@ public abstract class SubscriberResourceCollector implements IResourceChangeList return subscriber; } - /** - * De-register the listeners for this collector. - */ + /** + * De-register the listeners for this collector. + */ public void dispose() { getSubscriber().removeListener(this); ResourcesPlugin.getWorkspace().removeResourceChangeListener(this); @@ -65,14 +65,14 @@ public abstract class SubscriberResourceCollector implements IResourceChangeList @Override public void subscriberResourceChanged(ISubscriberChangeEvent[] deltas) { - try { - beginInput(); + try { + beginInput(); IResource[] roots = getRoots(); for (int i = 0; i < deltas.length; i++) { switch (deltas[i].getFlags()) { case ISubscriberChangeEvent.SYNC_CHANGED : if (isAllRootsIncluded() || isDescendantOfRoot(deltas[i].getResource(), roots)) { - change(deltas[i].getResource(), IResource.DEPTH_ZERO); + change(deltas[i].getResource(), IResource.DEPTH_ZERO); } break; case ISubscriberChangeEvent.ROOT_REMOVED : @@ -85,42 +85,42 @@ public abstract class SubscriberResourceCollector implements IResourceChangeList break; } } - } finally { - endInput(); - } + } finally { + endInput(); + } } - /** - * This method is invoked at the beginning of a subscriber change event - * or resource delta event. The endInput method will be invoked at some point - * following this. There may be several invocations of remove or change - * in between. - */ - protected void beginInput() { - // Do nothing by default - } - - /** - * The processing of the resource or subscriber delta has finished. - * Subclasses can accumulate removals and changes and handle them - * at this point to allow batched change events. - */ - protected void endInput() { - // Do nothing by default - } + /** + * This method is invoked at the beginning of a subscriber change event + * or resource delta event. The endInput method will be invoked at some point + * following this. There may be several invocations of remove or change + * in between. + */ + protected void beginInput() { + // Do nothing by default + } + + /** + * The processing of the resource or subscriber delta has finished. + * Subclasses can accumulate removals and changes and handle them + * at this point to allow batched change events. + */ + protected void endInput() { + // Do nothing by default + } @Override public void resourceChanged(IResourceChangeEvent event) { - try { - beginInput(); + try { + beginInput(); processDelta(event.getDelta(), getRoots()); - } finally { - endInput(); - } + } finally { + endInput(); + } } - /** + /** * Process the resource delta and posts all necessary events to the background * event handler. * @@ -133,8 +133,8 @@ public abstract class SubscriberResourceCollector implements IResourceChangeList if (resource.getType() == IResource.PROJECT) { // Handle projects that should be removed from the collector if (((kind & IResourceDelta.REMOVED) != 0) /* deleted project */ - || (delta.getFlags() & IResourceDelta.OPEN) != 0 && !((IProject) resource).isOpen() /* closed project */ - || !isAncestorOfRoot(resource, roots)) /* not within subscriber roots */ { + || (delta.getFlags() & IResourceDelta.OPEN) != 0 && !((IProject) resource).isOpen() /* closed project */ + || !isAncestorOfRoot(resource, roots)) /* not within subscriber roots */ { // If the project has any entries in the sync set, remove them if (hasMembers(resource)) { remove(resource); @@ -178,8 +178,8 @@ public abstract class SubscriberResourceCollector implements IResourceChangeList * Return the root resources that are to be considered by this handler. * These may be either the subscriber roots or a set of resources that are * contained by the subscriber's roots. - * @return the root resources that are to be considered by this handler - */ + * @return the root resources that are to be considered by this handler + */ protected IResource[] getRoots() { return getSubscriber().roots(); } @@ -188,38 +188,38 @@ public abstract class SubscriberResourceCollector implements IResourceChangeList * Return whether the given resource, which is not * within the roots of this handler, has children * that are. - * @param resource the resource - * @return whether the resource has children that are being considered - * by this handler. - */ - protected abstract boolean hasMembers(IResource resource); - - /** - * The resource is no longer of concern to the subscriber. - * Remove the resource and any of it's descendants - * from the set of resources being collected. - * @param resource the resource to be removed along with its - * descendants. - */ - protected abstract void remove(IResource resource); - - /** - * The resource sync state has changed to the depth specified. - * @param resource the resource - * @param depth the depth - */ - protected abstract void change(IResource resource, int depth); + * @param resource the resource + * @return whether the resource has children that are being considered + * by this handler. + */ + protected abstract boolean hasMembers(IResource resource); + + /** + * The resource is no longer of concern to the subscriber. + * Remove the resource and any of it's descendants + * from the set of resources being collected. + * @param resource the resource to be removed along with its + * descendants. + */ + protected abstract void remove(IResource resource); + + /** + * The resource sync state has changed to the depth specified. + * @param resource the resource + * @param depth the depth + */ + protected abstract void change(IResource resource, int depth); /** * Return whether all roots of a subscriber are included or * if the collector is only consider a subset of the resources. - * @return whether all roots of a subscriber are included - */ + * @return whether all roots of a subscriber are included + */ protected boolean isAllRootsIncluded() { return true; } - private boolean isAncestorOfRoot(IResource parent, IResource[] roots) { + private boolean isAncestorOfRoot(IResource parent, IResource[] roots) { // Always traverse into projects in case a root was removed if (parent.getType() == IResource.ROOT) return true; for (int i = 0; i < roots.length; i++) { diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SubscriberSyncInfoCollector.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SubscriberSyncInfoCollector.java index 9ac9c4554..e14f38c7d 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SubscriberSyncInfoCollector.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SubscriberSyncInfoCollector.java @@ -51,7 +51,7 @@ public final class SubscriberSyncInfoCollector extends SubscriberResourceCollect * @param roots the roots of the out-of-sync resources to be collected */ public SubscriberSyncInfoCollector(Subscriber subscriber, IResource[] roots) { - super(subscriber); + super(subscriber); this.roots = roots; this.eventHandler = new SubscriberSyncInfoEventHandler(subscriber, roots); this.subscriberInput = eventHandler.getSyncSetInput(); @@ -196,18 +196,18 @@ public final class SubscriberSyncInfoCollector extends SubscriberResourceCollect reset(); } - @Override + @Override protected boolean hasMembers(IResource resource) { - return getSubscriberSyncInfoSet().hasMembers(resource); - } + return getSubscriberSyncInfoSet().hasMembers(resource); + } - @Override + @Override protected void remove(IResource resource) { - eventHandler.remove(resource); - } + eventHandler.remove(resource); + } - @Override + @Override protected void change(IResource resource, int depth) { - eventHandler.change(resource, depth); - } + eventHandler.change(resource, depth); + } } diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SubscriberSyncInfoEventHandler.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SubscriberSyncInfoEventHandler.java index a6128cd21..72379bb7c 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SubscriberSyncInfoEventHandler.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SubscriberSyncInfoEventHandler.java @@ -179,7 +179,7 @@ public class SubscriberSyncInfoEventHandler extends SubscriberEventHandler { protected void dispatchEvents(SubscriberEvent[] events, IProgressMonitor monitor) { // this will batch the following set changes until endInput is called. SubscriberSyncInfoSet syncSet = syncSetInput.getSyncSet(); - try { + try { syncSet.beginInput(); for (int i = 0; i < events.length; i++) { SubscriberEvent event = events[i]; |