mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-14 12:35:22 +02:00
Bug 133881 - Make refreshing after building optional
Code cleanup.
This commit is contained in:
parent
37a7387a3f
commit
95bf88c5a0
10 changed files with 985 additions and 939 deletions
|
@ -15,40 +15,105 @@ import org.eclipse.core.resources.IResource;
|
|||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
|
||||
/**
|
||||
* Represents a particular instance of an exclusion. E.g., if an exclusion allowed
|
||||
* for the exclusion of a list individual resources, there would be one exclusion instance
|
||||
* per resource. Each exclusion instance is presented in the user interface as a child of the exclusion.
|
||||
* Represents a particular instance of an exclusion. E.g., if an exclusion allowed for the exclusion of a list
|
||||
* individual resources, there would be one exclusion instance per resource. Each exclusion instance is
|
||||
* presented in the user interface as a child of the exclusion.
|
||||
*
|
||||
* Clients may extend this class to provide custom implementations for their exclusion type.
|
||||
*
|
||||
* <strong>EXPERIMENTAL</strong>. This class or interface has been added as
|
||||
* part of a work in progress. There is no guarantee that this API will work or
|
||||
* that it will remain the same. Please do not use this API without consulting
|
||||
* with the CDT team.
|
||||
* <strong>EXPERIMENTAL</strong>. This class or interface has been added as part of a work in progress. There
|
||||
* is no guarantee that this API will work or that it will remain the same. Please do not use this API without
|
||||
* consulting with the CDT team.
|
||||
*
|
||||
* @author crecoskie
|
||||
* @since 5.3
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class ExclusionInstance {
|
||||
|
||||
|
||||
public static final String CLASS_ATTRIBUTE_NAME = "class"; //$NON-NLS-1$
|
||||
public static final String EXTENSION_DATA_ELEMENT_NAME = "extensionData"; //$NON-NLS-1$
|
||||
public static final String CONTRIBUTOR_ID_ATTRIBUTE_NAME = "contributorId"; //$NON-NLS-1$
|
||||
public static final String INSTANCE_ELEMENT_NAME = "instance"; //$NON-NLS-1$
|
||||
public static final String WORKSPACE_PATH_ATTRIBUTE_NAME = "workspacePath"; //$NON-NLS-1$
|
||||
public static final String EXCLUSION_TYPE_ATTRIBUTE_NAME = "exclusionType"; //$NON-NLS-1$
|
||||
public static final String EXCLUSION_ELEMENT_NAME = "exclusion"; //$NON-NLS-1$
|
||||
public static final String RESOURCE_VALUE = "RESOURCE"; //$NON-NLS-1$
|
||||
public static final String FOLDER_VALUE = "FOLDER"; //$NON-NLS-1$
|
||||
public static final String FILE_VALUE = "FILE"; //$NON-NLS-1$
|
||||
public static final String DISPLAY_STRING_ATTRIBUTE_NAME = "displayString"; //$NON-NLS-1$
|
||||
|
||||
protected ExclusionType fInstanceExclusionType;
|
||||
protected IResource fResource;
|
||||
public static final String EXCLUSION_ELEMENT_NAME = "exclusion"; //$NON-NLS-1$
|
||||
public static final String EXCLUSION_TYPE_ATTRIBUTE_NAME = "exclusionType"; //$NON-NLS-1$
|
||||
public static final String EXTENSION_DATA_ELEMENT_NAME = "extensionData"; //$NON-NLS-1$
|
||||
public static final String FILE_VALUE = "FILE"; //$NON-NLS-1$
|
||||
public static final String FOLDER_VALUE = "FOLDER"; //$NON-NLS-1$
|
||||
public static final String INSTANCE_ELEMENT_NAME = "instance"; //$NON-NLS-1$
|
||||
public static final String RESOURCE_VALUE = "RESOURCE"; //$NON-NLS-1$
|
||||
public static final String WORKSPACE_PATH_ATTRIBUTE_NAME = "workspacePath"; //$NON-NLS-1$
|
||||
|
||||
public synchronized static ExclusionInstance loadInstanceData(ICStorageElement instanceElement,
|
||||
RefreshScopeManager manager) {
|
||||
|
||||
String className = instanceElement.getAttribute(CLASS_ATTRIBUTE_NAME);
|
||||
|
||||
ExclusionInstance newInstance = null;
|
||||
|
||||
// see if there is a custom instance class
|
||||
newInstance = manager.getInstanceForClassName(className);
|
||||
|
||||
if (newInstance == null) {
|
||||
newInstance = new ExclusionInstance();
|
||||
}
|
||||
|
||||
// load the exclusion type
|
||||
String exclusionTypeString = instanceElement.getAttribute(EXCLUSION_TYPE_ATTRIBUTE_NAME);
|
||||
if (exclusionTypeString != null) {
|
||||
if (exclusionTypeString.equals(FILE_VALUE)) {
|
||||
newInstance.fInstanceExclusionType = org.eclipse.cdt.core.resources.ExclusionType.FILE;
|
||||
}
|
||||
|
||||
else if (exclusionTypeString.equals(FOLDER_VALUE)) {
|
||||
newInstance.fInstanceExclusionType = org.eclipse.cdt.core.resources.ExclusionType.FOLDER;
|
||||
}
|
||||
|
||||
else if (exclusionTypeString.equals(RESOURCE_VALUE)) {
|
||||
newInstance.fInstanceExclusionType = org.eclipse.cdt.core.resources.ExclusionType.RESOURCE;
|
||||
}
|
||||
|
||||
else {
|
||||
// error
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// load resource path, use it to get the corresponding resource
|
||||
String resourcePath = instanceElement.getAttribute(WORKSPACE_PATH_ATTRIBUTE_NAME);
|
||||
|
||||
if (resourcePath != null) {
|
||||
newInstance.fResource = ResourcesPlugin.getWorkspace().getRoot()
|
||||
.findMember(resourcePath);
|
||||
}
|
||||
|
||||
// load display string
|
||||
newInstance.fDisplayString = instanceElement.getAttribute(DISPLAY_STRING_ATTRIBUTE_NAME);
|
||||
|
||||
// load any data from extenders
|
||||
newInstance.loadExtendedInstanceData(instanceElement);
|
||||
|
||||
return newInstance;
|
||||
}
|
||||
|
||||
protected String fDisplayString;
|
||||
protected ExclusionType fInstanceExclusionType;
|
||||
protected RefreshExclusion fParent;
|
||||
|
||||
protected IResource fResource;
|
||||
|
||||
/**
|
||||
* @return a String corresponding to the human-readable name for this exclusion instance. Examples of this
|
||||
* would be the resource name for a resource based exclusion, or the file extension excluded by a
|
||||
* file extension exclusion.
|
||||
*/
|
||||
public synchronized String getDisplayString() {
|
||||
return fDisplayString;
|
||||
}
|
||||
|
||||
public synchronized ExclusionType getExclusionType() {
|
||||
return fInstanceExclusionType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the parent exclusion of this exclusion instance.
|
||||
*
|
||||
|
@ -58,21 +123,6 @@ public class ExclusionInstance {
|
|||
return fParent;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param parent the RefreshExclusion to set as the parent.
|
||||
*/
|
||||
public synchronized void setParentExclusion(RefreshExclusion parent) {
|
||||
fParent = parent;
|
||||
}
|
||||
|
||||
public synchronized ExclusionType getExclusionType() {
|
||||
return fInstanceExclusionType;
|
||||
}
|
||||
|
||||
public synchronized void setExclusionType(ExclusionType type) {
|
||||
fInstanceExclusionType = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* If there is a resource directly associated with this exclusion instance, returns the resource.
|
||||
*
|
||||
|
@ -81,122 +131,75 @@ public class ExclusionInstance {
|
|||
public synchronized IResource getResource() {
|
||||
return fResource;
|
||||
}
|
||||
|
||||
public synchronized void setResource(IResource resource) {
|
||||
fResource = resource;
|
||||
|
||||
protected synchronized void loadExtendedInstanceData(ICStorageElement child) {
|
||||
// override to provide extension specific behaviour if desired
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a String corresponding to the human-readable name for this exclusion instance.
|
||||
* Examples of this would be the resource name for a resource based exclusion, or the file extension
|
||||
* excluded by a file extension exclusion.
|
||||
*/
|
||||
public synchronized String getDisplayString() {
|
||||
return fDisplayString;
|
||||
}
|
||||
|
||||
public synchronized void setDisplayString(String displayString) {
|
||||
fDisplayString = displayString;
|
||||
|
||||
protected synchronized void persistExtendedInstanceData(ICStorageElement instanceElement) {
|
||||
// override to provide extension specific behaviour if desired
|
||||
}
|
||||
|
||||
public synchronized void persistInstanceData(ICStorageElement exclusionElement) {
|
||||
|
||||
|
||||
ICStorageElement instanceElement = exclusionElement.createChild(INSTANCE_ELEMENT_NAME);
|
||||
|
||||
|
||||
// persist the type of the object we are
|
||||
instanceElement.setAttribute(CLASS_ATTRIBUTE_NAME, this.getClass().getName());
|
||||
|
||||
|
||||
// persist the exclusion type
|
||||
String exclusionType = null;
|
||||
switch(getExclusionType()) {
|
||||
switch (getExclusionType()) {
|
||||
case FILE:
|
||||
exclusionType = FILE_VALUE;
|
||||
break;
|
||||
|
||||
|
||||
case FOLDER:
|
||||
exclusionType = FOLDER_VALUE;
|
||||
break;
|
||||
|
||||
|
||||
case RESOURCE:
|
||||
exclusionType = RESOURCE_VALUE;
|
||||
break;
|
||||
}
|
||||
|
||||
if(exclusionType != null) {
|
||||
|
||||
if (exclusionType != null) {
|
||||
instanceElement.setAttribute(EXCLUSION_TYPE_ATTRIBUTE_NAME, exclusionType);
|
||||
}
|
||||
|
||||
|
||||
// persist resource path
|
||||
if(fResource != null) {
|
||||
instanceElement.setAttribute(WORKSPACE_PATH_ATTRIBUTE_NAME, fResource.getFullPath().toString());
|
||||
if (fResource != null) {
|
||||
instanceElement.setAttribute(WORKSPACE_PATH_ATTRIBUTE_NAME, fResource.getFullPath()
|
||||
.toString());
|
||||
}
|
||||
|
||||
|
||||
// persist display string
|
||||
if(fDisplayString != null) {
|
||||
if (fDisplayString != null) {
|
||||
instanceElement.setAttribute(DISPLAY_STRING_ATTRIBUTE_NAME, fDisplayString);
|
||||
}
|
||||
|
||||
|
||||
// persist any data from extenders
|
||||
persistExtendedInstanceData(instanceElement);
|
||||
|
||||
}
|
||||
|
||||
protected synchronized void persistExtendedInstanceData(ICStorageElement instanceElement) {
|
||||
// override to provide extension specific behaviour if desired
|
||||
|
||||
}
|
||||
|
||||
public synchronized static ExclusionInstance loadInstanceData(ICStorageElement instanceElement, RefreshScopeManager manager) {
|
||||
|
||||
String className = instanceElement.getAttribute(CLASS_ATTRIBUTE_NAME);
|
||||
|
||||
ExclusionInstance newInstance = null;
|
||||
|
||||
// see if there is a custom instance class
|
||||
newInstance = manager.getInstanceForClassName(className);
|
||||
|
||||
if(newInstance == null) {
|
||||
newInstance = new ExclusionInstance();
|
||||
}
|
||||
|
||||
// load the exclusion type
|
||||
String exclusionTypeString = instanceElement.getAttribute(EXCLUSION_TYPE_ATTRIBUTE_NAME);
|
||||
if(exclusionTypeString != null) {
|
||||
if(exclusionTypeString.equals(FILE_VALUE)) {
|
||||
newInstance.fInstanceExclusionType = org.eclipse.cdt.core.resources.ExclusionType.FILE;
|
||||
}
|
||||
|
||||
else if(exclusionTypeString.equals(FOLDER_VALUE)) {
|
||||
newInstance.fInstanceExclusionType = org.eclipse.cdt.core.resources.ExclusionType.FOLDER;
|
||||
}
|
||||
|
||||
else if(exclusionTypeString.equals(RESOURCE_VALUE)) {
|
||||
newInstance.fInstanceExclusionType = org.eclipse.cdt.core.resources.ExclusionType.RESOURCE;
|
||||
}
|
||||
|
||||
else {
|
||||
// error
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// load resource path, use it to get the corresponding resource
|
||||
String resourcePath = instanceElement.getAttribute(WORKSPACE_PATH_ATTRIBUTE_NAME);
|
||||
|
||||
if(resourcePath != null) {
|
||||
newInstance.fResource = ResourcesPlugin.getWorkspace().getRoot().findMember(resourcePath);
|
||||
}
|
||||
|
||||
// load display string
|
||||
newInstance.fDisplayString = instanceElement.getAttribute(DISPLAY_STRING_ATTRIBUTE_NAME);
|
||||
|
||||
|
||||
// load any data from extenders
|
||||
newInstance.loadExtendedInstanceData(instanceElement);
|
||||
|
||||
return newInstance;
|
||||
public synchronized void setDisplayString(String displayString) {
|
||||
fDisplayString = displayString;
|
||||
}
|
||||
|
||||
protected synchronized void loadExtendedInstanceData(ICStorageElement child) {
|
||||
// override to provide extension specific behaviour if desired
|
||||
|
||||
public synchronized void setExclusionType(ExclusionType type) {
|
||||
fInstanceExclusionType = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param parent
|
||||
* the RefreshExclusion to set as the parent.
|
||||
*/
|
||||
public synchronized void setParentExclusion(RefreshExclusion parent) {
|
||||
fParent = parent;
|
||||
}
|
||||
|
||||
public synchronized void setResource(IResource resource) {
|
||||
fResource = resource;
|
||||
}
|
||||
}
|
|
@ -12,31 +12,28 @@
|
|||
package org.eclipse.cdt.core.resources;
|
||||
|
||||
/**
|
||||
* Indicates the type of resources that this exclusion can exclude. Used to determine which type of icon is displayed in
|
||||
* the exclusion UI when this exclusion is present.
|
||||
* Indicates the type of resources that this exclusion can exclude. Used to determine which type of icon is
|
||||
* displayed in the exclusion UI when this exclusion is present.
|
||||
*
|
||||
* <strong>EXPERIMENTAL</strong>. This class or interface has been added as
|
||||
* part of a work in progress. There is no guarantee that this API will work or
|
||||
* that it will remain the same. Please do not use this API without consulting
|
||||
* with the CDT team.
|
||||
* <strong>EXPERIMENTAL</strong>. This class or interface has been added as part of a work in progress. There
|
||||
* is no guarantee that this API will work or that it will remain the same. Please do not use this API without
|
||||
* consulting with the CDT team.
|
||||
*
|
||||
* @author crecoskie
|
||||
* @since 5.3
|
||||
*
|
||||
*
|
||||
*/
|
||||
public enum ExclusionType {
|
||||
/**
|
||||
* Constant indicating that this exclusion only excludes folders.
|
||||
*/
|
||||
FOLDER,
|
||||
|
||||
|
||||
FILE,
|
||||
|
||||
/**
|
||||
* Constant indicating that this exclusion only excludes folders.
|
||||
*/
|
||||
FILE,
|
||||
|
||||
|
||||
FOLDER,
|
||||
|
||||
/**
|
||||
* Constant indicating that this exclusion can exclude any resource.
|
||||
*/
|
||||
|
|
|
@ -26,243 +26,31 @@ import com.ibm.icu.text.MessageFormat;
|
|||
*
|
||||
* Clients should extend this class to provide support for their own custom exclusions.
|
||||
*
|
||||
* <strong>EXPERIMENTAL</strong>. This class or interface has been added as
|
||||
* part of a work in progress. There is no guarantee that this API will work or
|
||||
* that it will remain the same. Please do not use this API without consulting
|
||||
* with the CDT team.
|
||||
* <strong>EXPERIMENTAL</strong>. This class or interface has been added as part of a work in progress. There
|
||||
* is no guarantee that this API will work or that it will remain the same. Please do not use this API without
|
||||
* consulting with the CDT team.
|
||||
*
|
||||
* @author crecoskie
|
||||
* @since 5.3
|
||||
*
|
||||
*
|
||||
*/
|
||||
public abstract class RefreshExclusion {
|
||||
|
||||
|
||||
public static final String CLASS_ATTRIBUTE_NAME = "class"; //$NON-NLS-1$
|
||||
public static final String EXTENSION_DATA_ELEMENT_NAME = "extensionData"; //$NON-NLS-1$
|
||||
public static final String CONTRIBUTOR_ID_ATTRIBUTE_NAME = "contributorId"; //$NON-NLS-1$
|
||||
public static final String INSTANCE_ELEMENT_NAME = "instance"; //$NON-NLS-1$
|
||||
public static final String WORKSPACE_PATH_ATTRIBUTE_NAME = "workspacePath"; //$NON-NLS-1$
|
||||
public static final String EXCLUSION_TYPE_ATTRIBUTE_NAME = "exclusionType"; //$NON-NLS-1$
|
||||
public static final String EXCLUSION_ELEMENT_NAME = "exclusion"; //$NON-NLS-1$
|
||||
public static final String RESOURCE_VALUE = "RESOURCE"; //$NON-NLS-1$
|
||||
public static final String FOLDER_VALUE = "FOLDER"; //$NON-NLS-1$
|
||||
public static final String FILE_VALUE = "FILE"; //$NON-NLS-1$
|
||||
public static final String DISPLAY_STRING_ATTRIBUTE_NAME = "displayString"; //$NON-NLS-1$
|
||||
|
||||
protected List<ExclusionInstance> fExclusionInstanceList = new LinkedList<ExclusionInstance>();
|
||||
protected List<RefreshExclusion> fNestedExclusions = new LinkedList<RefreshExclusion>();
|
||||
protected ExclusionType fExclusionType = ExclusionType.RESOURCE;
|
||||
protected RefreshExclusion fParentExclusion;
|
||||
protected IResource fParentResource;
|
||||
|
||||
|
||||
protected String fContributorId = ""; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* If this exclusion is a direct descendant of a resource, returns that resource.
|
||||
* Otherwise, returns null;
|
||||
*
|
||||
* @return IResource
|
||||
*/
|
||||
public synchronized IResource getParentResource() {
|
||||
return fParentResource;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the parent resource of this exclusion.
|
||||
*
|
||||
* @param parentResource the parent resource to set
|
||||
*/
|
||||
public synchronized void setParentResource(IResource parentResource) {
|
||||
this.fParentResource = parentResource;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a String corresponding to the ID of the RefreshExclusionContributor that was used to create
|
||||
* this exclusion.
|
||||
*/
|
||||
public synchronized String getContributorId() {
|
||||
return fContributorId;
|
||||
}
|
||||
|
||||
public synchronized void setContributorId(String id) {
|
||||
fContributorId = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* If this is a nested exclusion, returns the exclusion which is the direct parent of this one.
|
||||
*
|
||||
* @return RefreshExclusion
|
||||
*/
|
||||
public synchronized RefreshExclusion getParentExclusion() {
|
||||
return fParentExclusion;
|
||||
}
|
||||
|
||||
public synchronized void setParentExclusion(RefreshExclusion parent) {
|
||||
fParentExclusion = parent;
|
||||
}
|
||||
|
||||
public synchronized ExclusionType getExclusionType() {
|
||||
return fExclusionType;
|
||||
}
|
||||
|
||||
public synchronized void setExclusionType(ExclusionType exclusionType) {
|
||||
fExclusionType = exclusionType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a String corresponding to the human-readable name for this exclusion.
|
||||
*/
|
||||
public abstract String getName();
|
||||
|
||||
/**
|
||||
* Tests a given resource to see if this exclusion applies to it.
|
||||
*
|
||||
* @param resource the resource to be tested.
|
||||
* @return true if the resource triggers the exclusion, false otherwise (including if this
|
||||
* exclusion does not apply).
|
||||
*/
|
||||
public abstract boolean testExclusion(IResource resource);
|
||||
|
||||
/**
|
||||
* Tests this exclusion and recursively test all of its nested exclusions to determine whether this
|
||||
* exclusion should be triggered or not.
|
||||
*
|
||||
* @param resource the resource to be tested
|
||||
* @return true if the exclusion is triggered, false otherwise (including if this exclusion does not apply)
|
||||
*/
|
||||
public synchronized boolean testExclusionChain(IResource resource) {
|
||||
// first check and see if this exclusion would be triggered in the first place
|
||||
boolean currentValue = testExclusion(resource);
|
||||
|
||||
if (currentValue) {
|
||||
List<RefreshExclusion> nestedExclusions = getNestedExclusions();
|
||||
for (RefreshExclusion exclusion : nestedExclusions) {
|
||||
|
||||
boolean nestedValue = exclusion.testExclusionChain(resource);
|
||||
|
||||
if(nestedValue) {
|
||||
// the nested exclusion says to do the opposite of what we originally thought, so negate the current value
|
||||
currentValue = (!currentValue);
|
||||
|
||||
// since the first exclusion chain to trump us wins, then, break out of the loop
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return currentValue;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return an unmodifiable list of all the instance of this exclusion
|
||||
*/
|
||||
public synchronized List<ExclusionInstance> getExclusionInstances() {
|
||||
return Collections.unmodifiableList(fExclusionInstanceList);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an instance to the list of instances of this exclusion.
|
||||
*
|
||||
* @param exclusionInstance
|
||||
*/
|
||||
public synchronized void addExclusionInstance(ExclusionInstance exclusionInstance) {
|
||||
exclusionInstance.setParentExclusion(this);
|
||||
fExclusionInstanceList.add(exclusionInstance);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes an exclusion instance from the list of instances of this exclusion.
|
||||
*
|
||||
* @param exclusionInstance
|
||||
*/
|
||||
public synchronized void removeExclusionInstance(ExclusionInstance exclusionInstance) {
|
||||
fExclusionInstanceList.remove(exclusionInstance);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return an unmodifiable list of exclusions to this exclusion.
|
||||
*/
|
||||
public synchronized List<RefreshExclusion> getNestedExclusions() {
|
||||
return Collections.unmodifiableList(fNestedExclusions);
|
||||
}
|
||||
|
||||
public synchronized void addNestedExclusion(RefreshExclusion exclusion) {
|
||||
fNestedExclusions.add(exclusion);
|
||||
exclusion.setParentExclusion(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the given nested exclusion. The exclusion must be a direct child of this exclusion.
|
||||
*
|
||||
* @param exclusion
|
||||
*/
|
||||
public synchronized void removeNestedExclusion(RefreshExclusion exclusion) {
|
||||
fNestedExclusions.remove(exclusion);
|
||||
}
|
||||
|
||||
public synchronized void persistData(ICStorageElement parentElement) {
|
||||
// persist the common data that all RefreshExclusions have
|
||||
ICStorageElement exclusionElement = parentElement.createChild(EXCLUSION_ELEMENT_NAME);
|
||||
|
||||
// persist the type of the object we are
|
||||
exclusionElement.setAttribute(CLASS_ATTRIBUTE_NAME, this.getClass().getName());
|
||||
|
||||
// persist the exclusion type
|
||||
String exclusionType = null;
|
||||
switch(getExclusionType()) {
|
||||
case FILE:
|
||||
exclusionType = FILE_VALUE;
|
||||
break;
|
||||
|
||||
case FOLDER:
|
||||
exclusionType = FOLDER_VALUE;
|
||||
break;
|
||||
|
||||
case RESOURCE:
|
||||
exclusionType = RESOURCE_VALUE;
|
||||
break;
|
||||
}
|
||||
|
||||
if(exclusionType != null) {
|
||||
exclusionElement.setAttribute(EXCLUSION_TYPE_ATTRIBUTE_NAME, exclusionType);
|
||||
}
|
||||
|
||||
// note: no need to persist parent, the parent relationship will be determined on load by
|
||||
// the structure of the XML tree
|
||||
|
||||
exclusionElement.setAttribute(CONTRIBUTOR_ID_ATTRIBUTE_NAME, getContributorId());
|
||||
|
||||
// persist instances
|
||||
for(ExclusionInstance instance : fExclusionInstanceList) {
|
||||
instance.persistInstanceData(exclusionElement);
|
||||
}
|
||||
|
||||
// provide a place for extenders to store their own data
|
||||
ICStorageElement extensionElement = exclusionElement.createChild(EXTENSION_DATA_ELEMENT_NAME);
|
||||
|
||||
// call extender to store any extender-specific data
|
||||
persistExtendedData(extensionElement);
|
||||
|
||||
// persist nested exclusions
|
||||
for(RefreshExclusion exclusion : fNestedExclusions) {
|
||||
exclusion.persistData(exclusionElement);
|
||||
}
|
||||
}
|
||||
|
||||
protected synchronized void persistExtendedData(ICStorageElement extensionElement) {
|
||||
// override to provide extension specific behaviour if desired
|
||||
}
|
||||
|
||||
protected synchronized void loadExtendedData(ICStorageElement grandchild) {
|
||||
// override to provide extension specific behaviour if desired
|
||||
}
|
||||
public static final String EXCLUSION_ELEMENT_NAME = "exclusion"; //$NON-NLS-1$
|
||||
public static final String EXCLUSION_TYPE_ATTRIBUTE_NAME = "exclusionType"; //$NON-NLS-1$
|
||||
public static final String EXTENSION_DATA_ELEMENT_NAME = "extensionData"; //$NON-NLS-1$
|
||||
public static final String FILE_VALUE = "FILE"; //$NON-NLS-1$
|
||||
public static final String FOLDER_VALUE = "FOLDER"; //$NON-NLS-1$
|
||||
public static final String INSTANCE_ELEMENT_NAME = "instance"; //$NON-NLS-1$
|
||||
public static final String RESOURCE_VALUE = "RESOURCE"; //$NON-NLS-1$
|
||||
public static final String WORKSPACE_PATH_ATTRIBUTE_NAME = "workspacePath"; //$NON-NLS-1$
|
||||
|
||||
public synchronized static List<RefreshExclusion> loadData(ICStorageElement parentElement,
|
||||
RefreshExclusion parentExclusion, IResource parentResource, RefreshScopeManager manager) throws CoreException {
|
||||
RefreshExclusion parentExclusion, IResource parentResource, RefreshScopeManager manager)
|
||||
throws CoreException {
|
||||
|
||||
List<RefreshExclusion> exclusions = new LinkedList<RefreshExclusion>();
|
||||
|
||||
|
@ -324,13 +112,15 @@ public abstract class RefreshExclusion {
|
|||
else if (grandchild.getName().equals(INSTANCE_ELEMENT_NAME)) {
|
||||
|
||||
// load the instance data
|
||||
ExclusionInstance instance = ExclusionInstance.loadInstanceData(grandchild, manager);
|
||||
ExclusionInstance instance = ExclusionInstance.loadInstanceData(grandchild,
|
||||
manager);
|
||||
newExclusion.fExclusionInstanceList.add(instance);
|
||||
}
|
||||
}
|
||||
|
||||
// load nested exclusions
|
||||
List<RefreshExclusion> nestedExclusions = loadData(child, newExclusion, null, manager);
|
||||
List<RefreshExclusion> nestedExclusions = loadData(child, newExclusion, null,
|
||||
manager);
|
||||
|
||||
// add to parent
|
||||
for (RefreshExclusion nestedExclusion : nestedExclusions) {
|
||||
|
@ -345,9 +135,226 @@ public abstract class RefreshExclusion {
|
|||
return exclusions;
|
||||
}
|
||||
|
||||
protected String fContributorId = ""; //$NON-NLS-1$
|
||||
protected List<ExclusionInstance> fExclusionInstanceList = new LinkedList<ExclusionInstance>();
|
||||
protected ExclusionType fExclusionType = ExclusionType.RESOURCE;
|
||||
protected List<RefreshExclusion> fNestedExclusions = new LinkedList<RefreshExclusion>();
|
||||
|
||||
protected RefreshExclusion fParentExclusion;
|
||||
|
||||
protected IResource fParentResource;
|
||||
|
||||
/**
|
||||
* Adds an instance to the list of instances of this exclusion.
|
||||
*
|
||||
* @param exclusionInstance
|
||||
*/
|
||||
public synchronized void addExclusionInstance(ExclusionInstance exclusionInstance) {
|
||||
exclusionInstance.setParentExclusion(this);
|
||||
fExclusionInstanceList.add(exclusionInstance);
|
||||
}
|
||||
|
||||
public synchronized void addNestedExclusion(RefreshExclusion exclusion) {
|
||||
fNestedExclusions.add(exclusion);
|
||||
exclusion.setParentExclusion(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a String corresponding to the ID of the RefreshExclusionContributor that was used to create
|
||||
* this exclusion.
|
||||
*/
|
||||
public synchronized String getContributorId() {
|
||||
return fContributorId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return an unmodifiable list of all the instance of this exclusion
|
||||
*/
|
||||
public synchronized List<ExclusionInstance> getExclusionInstances() {
|
||||
return Collections.unmodifiableList(fExclusionInstanceList);
|
||||
}
|
||||
|
||||
public synchronized ExclusionType getExclusionType() {
|
||||
return fExclusionType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a String corresponding to the human-readable name for this exclusion.
|
||||
*/
|
||||
public abstract String getName();
|
||||
|
||||
/**
|
||||
*
|
||||
* @return an unmodifiable list of exclusions to this exclusion.
|
||||
*/
|
||||
public synchronized List<RefreshExclusion> getNestedExclusions() {
|
||||
return Collections.unmodifiableList(fNestedExclusions);
|
||||
}
|
||||
|
||||
/**
|
||||
* If this is a nested exclusion, returns the exclusion which is the direct parent of this one.
|
||||
*
|
||||
* @return RefreshExclusion
|
||||
*/
|
||||
public synchronized RefreshExclusion getParentExclusion() {
|
||||
return fParentExclusion;
|
||||
}
|
||||
|
||||
/**
|
||||
* If this exclusion is a direct descendant of a resource, returns that resource. Otherwise, returns null;
|
||||
*
|
||||
* @return IResource
|
||||
*/
|
||||
public synchronized IResource getParentResource() {
|
||||
return fParentResource;
|
||||
}
|
||||
|
||||
protected synchronized void loadExtendedData(ICStorageElement grandchild) {
|
||||
// override to provide extension specific behaviour if desired
|
||||
}
|
||||
|
||||
public synchronized void persistData(ICStorageElement parentElement) {
|
||||
// persist the common data that all RefreshExclusions have
|
||||
ICStorageElement exclusionElement = parentElement.createChild(EXCLUSION_ELEMENT_NAME);
|
||||
|
||||
// persist the type of the object we are
|
||||
exclusionElement.setAttribute(CLASS_ATTRIBUTE_NAME, this.getClass().getName());
|
||||
|
||||
// persist the exclusion type
|
||||
String exclusionType = null;
|
||||
switch (getExclusionType()) {
|
||||
case FILE:
|
||||
exclusionType = FILE_VALUE;
|
||||
break;
|
||||
|
||||
case FOLDER:
|
||||
exclusionType = FOLDER_VALUE;
|
||||
break;
|
||||
|
||||
case RESOURCE:
|
||||
exclusionType = RESOURCE_VALUE;
|
||||
break;
|
||||
}
|
||||
|
||||
if (exclusionType != null) {
|
||||
exclusionElement.setAttribute(EXCLUSION_TYPE_ATTRIBUTE_NAME, exclusionType);
|
||||
}
|
||||
|
||||
// note: no need to persist parent, the parent relationship will be determined on load by
|
||||
// the structure of the XML tree
|
||||
|
||||
exclusionElement.setAttribute(CONTRIBUTOR_ID_ATTRIBUTE_NAME, getContributorId());
|
||||
|
||||
// persist instances
|
||||
for (ExclusionInstance instance : fExclusionInstanceList) {
|
||||
instance.persistInstanceData(exclusionElement);
|
||||
}
|
||||
|
||||
// provide a place for extenders to store their own data
|
||||
ICStorageElement extensionElement = exclusionElement
|
||||
.createChild(EXTENSION_DATA_ELEMENT_NAME);
|
||||
|
||||
// call extender to store any extender-specific data
|
||||
persistExtendedData(extensionElement);
|
||||
|
||||
// persist nested exclusions
|
||||
for (RefreshExclusion exclusion : fNestedExclusions) {
|
||||
exclusion.persistData(exclusionElement);
|
||||
}
|
||||
}
|
||||
|
||||
protected synchronized void persistExtendedData(ICStorageElement extensionElement) {
|
||||
// override to provide extension specific behaviour if desired
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes an exclusion instance from the list of instances of this exclusion.
|
||||
*
|
||||
* @param exclusionInstance
|
||||
*/
|
||||
public synchronized void removeExclusionInstance(ExclusionInstance exclusionInstance) {
|
||||
fExclusionInstanceList.remove(exclusionInstance);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the given nested exclusion. The exclusion must be a direct child of this exclusion.
|
||||
*
|
||||
* @param exclusion
|
||||
*/
|
||||
public synchronized void removeNestedExclusion(RefreshExclusion exclusion) {
|
||||
fNestedExclusions.remove(exclusion);
|
||||
}
|
||||
|
||||
public synchronized void setContributorId(String id) {
|
||||
fContributorId = id;
|
||||
}
|
||||
|
||||
public synchronized void setExclusionType(ExclusionType exclusionType) {
|
||||
fExclusionType = exclusionType;
|
||||
}
|
||||
|
||||
public synchronized void setParentExclusion(RefreshExclusion parent) {
|
||||
fParentExclusion = parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the parent resource of this exclusion.
|
||||
*
|
||||
* @param parentResource
|
||||
* the parent resource to set
|
||||
*/
|
||||
public synchronized void setParentResource(IResource parentResource) {
|
||||
this.fParentResource = parentResource;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if this exclusion supports exclusion instances
|
||||
*/
|
||||
public abstract boolean supportsExclusionInstances();
|
||||
|
||||
/**
|
||||
* Tests a given resource to see if this exclusion applies to it.
|
||||
*
|
||||
* @param resource
|
||||
* the resource to be tested.
|
||||
* @return true if the resource triggers the exclusion, false otherwise (including if this exclusion does
|
||||
* not apply).
|
||||
*/
|
||||
public abstract boolean testExclusion(IResource resource);
|
||||
|
||||
/**
|
||||
* Tests this exclusion and recursively test all of its nested exclusions to determine whether this
|
||||
* exclusion should be triggered or not.
|
||||
*
|
||||
* @param resource
|
||||
* the resource to be tested
|
||||
* @return true if the exclusion is triggered, false otherwise (including if this exclusion does not
|
||||
* apply)
|
||||
*/
|
||||
public synchronized boolean testExclusionChain(IResource resource) {
|
||||
// first check and see if this exclusion would be triggered in the first place
|
||||
boolean currentValue = testExclusion(resource);
|
||||
|
||||
if (currentValue) {
|
||||
List<RefreshExclusion> nestedExclusions = getNestedExclusions();
|
||||
for (RefreshExclusion exclusion : nestedExclusions) {
|
||||
|
||||
boolean nestedValue = exclusion.testExclusionChain(resource);
|
||||
|
||||
if (nestedValue) {
|
||||
// the nested exclusion says to do the opposite of what we originally thought, so negate
|
||||
// the current value
|
||||
currentValue = (!currentValue);
|
||||
|
||||
// since the first exclusion chain to trump us wins, then, break out of the loop
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return currentValue;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -11,45 +11,43 @@
|
|||
package org.eclipse.cdt.core.resources;
|
||||
|
||||
/**
|
||||
* Responsible for manufacturing a given type of RefreshExclusion. Called by the
|
||||
* RefreshScopeManager when loading persisted settings to instantiate exclusion objects.
|
||||
* Responsible for manufacturing a given type of RefreshExclusion. Called by the RefreshScopeManager when
|
||||
* loading persisted settings to instantiate exclusion objects.
|
||||
*
|
||||
* @author crecoskie
|
||||
* @since 5.3
|
||||
*
|
||||
*
|
||||
*/
|
||||
public abstract class RefreshExclusionFactory {
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new RefreshExclusion.
|
||||
*
|
||||
* @return RefreshExclusion
|
||||
*/
|
||||
abstract public RefreshExclusion createNewExclusion();
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new ExclusionInstance
|
||||
*
|
||||
* @return ExclusionInstance
|
||||
*/
|
||||
abstract public ExclusionInstance createNewExclusionInstance();
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Returns the fully qualified classname of the type of the object that will
|
||||
* be returned by org.eclipse.cdt.core.resources.RefreshExclusionFactory.createNewExclusion()
|
||||
* Returns the fully qualified classname of the type of the object that will be returned by
|
||||
* org.eclipse.cdt.core.resources.RefreshExclusionFactory.createNewExclusion()
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
abstract public String getExclusionClassname();
|
||||
|
||||
|
||||
/**
|
||||
* Returns the fully qualified classname of the type of the object that will
|
||||
* be returned by org.eclipse.cdt.core.resources.RefreshExclusionFactory.createNewExclusionInstance()
|
||||
* Returns the fully qualified classname of the type of the object that will be returned by
|
||||
* org.eclipse.cdt.core.resources.RefreshExclusionFactory.createNewExclusionInstance()
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
abstract public String getInstanceClassname();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -43,48 +43,55 @@ import org.eclipse.core.runtime.jobs.ISchedulingRule;
|
|||
import org.eclipse.core.runtime.jobs.MultiRule;
|
||||
|
||||
/**
|
||||
* The RefreshScopeManager provides access to settings pertaining to refreshes performed during
|
||||
* a build. Each project may have a set of resources associated with it that are the set of resources
|
||||
* to be refreshed. An exclusion mechanism exists that allows for one to specify arbitrarily complicated,
|
||||
* nested logic that determines whether or not a given resource is refreshed according to previously
|
||||
* specified rules.
|
||||
* The RefreshScopeManager provides access to settings pertaining to refreshes performed during a build. Each
|
||||
* project may have a set of resources associated with it that are the set of resources to be refreshed. An
|
||||
* exclusion mechanism exists that allows for one to specify arbitrarily complicated, nested logic that
|
||||
* determines whether or not a given resource is refreshed according to previously specified rules.
|
||||
*
|
||||
* <strong>EXPERIMENTAL</strong>. This class or interface has been added as
|
||||
* part of a work in progress. There is no guarantee that this API will work or
|
||||
* that it will remain the same. Please do not use this API without consulting
|
||||
* with the CDT team.
|
||||
* <strong>EXPERIMENTAL</strong>. This class or interface has been added as part of a work in progress. There
|
||||
* is no guarantee that this API will work or that it will remain the same. Please do not use this API without
|
||||
* consulting with the CDT team.
|
||||
*
|
||||
* @author crecoskie
|
||||
* @since 5.3
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class RefreshScopeManager {
|
||||
|
||||
public static final String PROJECT_VALUE = "PROJECT"; //$NON-NLS-1$
|
||||
public static final String FOLDER_VALUE = "FOLDER"; //$NON-NLS-1$
|
||||
public static final String FILE_VALUE = "FILE"; //$NON-NLS-1$
|
||||
public static final String RESOURCE_TYPE_ATTRIBUTE_NAME = "resourceType"; //$NON-NLS-1$
|
||||
public static final String WORKSPACE_PATH_ATTRIBUTE_NAME = "workspacePath"; //$NON-NLS-1$
|
||||
public static final String RESOURCE_ELEMENT_NAME = "resource"; //$NON-NLS-1$
|
||||
public static final String VERSION_NUMBER_ATTRIBUTE_NAME = "versionNumber"; //$NON-NLS-1$
|
||||
public static final String VERSION_ELEMENT_NAME = "version"; //$NON-NLS-1$
|
||||
public static final String REFRESH_SCOPE_STORAGE_NAME = "refreshScope"; //$NON-NLS-1$
|
||||
public static final String EXTENSION_ID = "RefreshExclusionFactory"; //$NON-NLS-1$
|
||||
public static final Object EXCLUSION_FACTORY = "exclusionFactory"; //$NON-NLS-1$
|
||||
public static final String EXCLUSION_CLASS = "exclusionClass"; //$NON-NLS-1$
|
||||
public static final Object EXCLUSION_FACTORY = "exclusionFactory"; //$NON-NLS-1$
|
||||
public static final String EXTENSION_ID = "RefreshExclusionFactory"; //$NON-NLS-1$
|
||||
public static final String FACTORY_CLASS = "factoryClass"; //$NON-NLS-1$
|
||||
public static final String FILE_VALUE = "FILE"; //$NON-NLS-1$
|
||||
private static RefreshScopeManager fInstance;
|
||||
public static final String FOLDER_VALUE = "FOLDER"; //$NON-NLS-1$
|
||||
public static final String INSTANCE_CLASS = "instanceClass"; //$NON-NLS-1$
|
||||
public static final String OTHER_VALUE = "OTHER"; //$NON-NLS-1$
|
||||
private int fVersion = 1;
|
||||
|
||||
public static final String PROJECT_VALUE = "PROJECT"; //$NON-NLS-1$
|
||||
public static final String REFRESH_SCOPE_STORAGE_NAME = "refreshScope"; //$NON-NLS-1$
|
||||
public static final String RESOURCE_ELEMENT_NAME = "resource"; //$NON-NLS-1$
|
||||
public static final String RESOURCE_TYPE_ATTRIBUTE_NAME = "resourceType"; //$NON-NLS-1$
|
||||
public static final String VERSION_ELEMENT_NAME = "version"; //$NON-NLS-1$
|
||||
public static final String VERSION_NUMBER_ATTRIBUTE_NAME = "versionNumber"; //$NON-NLS-1$
|
||||
public static final String WORKSPACE_PATH_ATTRIBUTE_NAME = "workspacePath"; //$NON-NLS-1$
|
||||
|
||||
public static synchronized RefreshScopeManager getInstance() {
|
||||
if (fInstance == null) {
|
||||
fInstance = new RefreshScopeManager();
|
||||
}
|
||||
|
||||
return fInstance;
|
||||
}
|
||||
|
||||
private HashMap<String, RefreshExclusionFactory> fClassnameToExclusionFactoryMap;
|
||||
private boolean fIsLoaded = false;
|
||||
|
||||
private boolean fIsLoading = false;
|
||||
private HashMap<IProject, LinkedHashSet<IResource>> fProjectToResourcesMap;
|
||||
private HashMap<IResource, List<RefreshExclusion>> fResourceToExclusionsMap;
|
||||
private HashMap<String, RefreshExclusionFactory> fClassnameToExclusionFactoryMap;
|
||||
|
||||
private static RefreshScopeManager fInstance;
|
||||
private boolean fIsLoading = false;
|
||||
private boolean fIsLoaded = false;
|
||||
|
||||
|
||||
private int fVersion = 1;
|
||||
|
||||
private RefreshScopeManager() {
|
||||
fClassnameToExclusionFactoryMap = new HashMap<String, RefreshExclusionFactory>();
|
||||
loadExtensions();
|
||||
|
@ -128,11 +135,13 @@ public class RefreshScopeManager {
|
|||
IProject project = (IProject) delta.getResource();
|
||||
|
||||
if (delta.getKind() == IResourceDelta.ADDED
|
||||
|| (delta.getKind() == IResourceDelta.CHANGED && ((delta.getFlags() & IResourceDelta.OPEN) != 0) ) ) {
|
||||
|
||||
loadSettings(ResourcesPlugin.getWorkspace().getRoot(), project);
|
||||
|| (delta.getKind() == IResourceDelta.CHANGED && ((delta
|
||||
.getFlags() & IResourceDelta.OPEN) != 0))) {
|
||||
|
||||
loadSettings(ResourcesPlugin.getWorkspace()
|
||||
.getRoot(), project);
|
||||
return false;
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -140,7 +149,7 @@ public class RefreshScopeManager {
|
|||
else if (delta.getResource() instanceof IWorkspaceRoot) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -157,10 +166,220 @@ public class RefreshScopeManager {
|
|||
IResourceChangeEvent.POST_CHANGE | IResourceChangeEvent.PRE_CLOSE
|
||||
| IResourceChangeEvent.PRE_DELETE);
|
||||
}
|
||||
|
||||
|
||||
public synchronized void addExclusion(IResource resource, RefreshExclusion exclusion) {
|
||||
getResourcesToExclusionsMap();
|
||||
|
||||
List<RefreshExclusion> exclusions = fResourceToExclusionsMap.get(resource);
|
||||
if (exclusions == null) {
|
||||
exclusions = new LinkedList<RefreshExclusion>();
|
||||
fResourceToExclusionsMap.put(resource, exclusions);
|
||||
}
|
||||
|
||||
exclusions.add(exclusion);
|
||||
}
|
||||
|
||||
public synchronized void addResourceToRefresh(IProject project, IResource resource) {
|
||||
getProjectToResourcesMap();
|
||||
LinkedHashSet<IResource> resourceSet = fProjectToResourcesMap.get(project);
|
||||
|
||||
if (resourceSet == null) {
|
||||
resourceSet = new LinkedHashSet<IResource>();
|
||||
fProjectToResourcesMap.put(project, resourceSet);
|
||||
}
|
||||
|
||||
resourceSet.add(resource);
|
||||
|
||||
}
|
||||
|
||||
public synchronized void clearAllData() {
|
||||
clearAllResourcesToRefresh();
|
||||
clearAllExclusions();
|
||||
fIsLoaded = false;
|
||||
}
|
||||
|
||||
public synchronized void clearAllExclusions() {
|
||||
if (fResourceToExclusionsMap != null)
|
||||
fResourceToExclusionsMap.clear();
|
||||
}
|
||||
|
||||
public synchronized void clearAllResourcesToRefresh() {
|
||||
getProjectToResourcesMap();
|
||||
fProjectToResourcesMap.clear();
|
||||
}
|
||||
|
||||
private synchronized void clearDataForProject(IProject project) {
|
||||
clearResourcesToRefresh(project);
|
||||
clearExclusionsForProject(project);
|
||||
}
|
||||
|
||||
public synchronized void clearExclusions(IResource resource) {
|
||||
getResourcesToExclusionsMap();
|
||||
List<RefreshExclusion> exclusions = fResourceToExclusionsMap.get(resource);
|
||||
if (exclusions != null) {
|
||||
exclusions.clear();
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void clearExclusionsForProject(IProject project) {
|
||||
getResourcesToExclusionsMap();
|
||||
List<IResource> resourcesToRemove = new LinkedList<IResource>();
|
||||
|
||||
for (IResource resource : fResourceToExclusionsMap.keySet()) {
|
||||
IProject project2 = resource.getProject();
|
||||
if (project2.equals(project)) {
|
||||
resourcesToRemove.add(resource);
|
||||
}
|
||||
}
|
||||
|
||||
for (IResource resource : resourcesToRemove) {
|
||||
fResourceToExclusionsMap.remove(resource);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void clearResourcesToRefresh(IProject project) {
|
||||
getProjectToResourcesMap();
|
||||
LinkedHashSet<IResource> resourceSet = null;
|
||||
|
||||
fProjectToResourcesMap.put(project, resourceSet);
|
||||
}
|
||||
|
||||
public synchronized void deleteResourceToRefresh(IProject project, IResource resource) {
|
||||
getProjectToResourcesMap();
|
||||
LinkedHashSet<IResource> resourceSet = fProjectToResourcesMap.get(project);
|
||||
|
||||
if (resourceSet == null) {
|
||||
resourceSet = new LinkedHashSet<IResource>();
|
||||
return;
|
||||
}
|
||||
|
||||
resourceSet.remove(resource);
|
||||
}
|
||||
|
||||
public synchronized RefreshExclusion getExclusionForClassName(String className) {
|
||||
RefreshExclusionFactory factory = getFactoryForClassName(className);
|
||||
|
||||
if (factory == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return factory.createNewExclusion();
|
||||
}
|
||||
|
||||
public synchronized List<RefreshExclusion> getExclusions(IResource resource) {
|
||||
getResourcesToExclusionsMap();
|
||||
List<RefreshExclusion> exclusions = fResourceToExclusionsMap.get(resource);
|
||||
if (exclusions == null) {
|
||||
exclusions = new LinkedList<RefreshExclusion>();
|
||||
fResourceToExclusionsMap.put(resource, exclusions);
|
||||
}
|
||||
|
||||
return exclusions;
|
||||
}
|
||||
|
||||
public synchronized RefreshExclusionFactory getFactoryForClassName(String className) {
|
||||
RefreshExclusionFactory factory = fClassnameToExclusionFactoryMap.get(className);
|
||||
|
||||
return factory;
|
||||
}
|
||||
|
||||
public synchronized ExclusionInstance getInstanceForClassName(String className) {
|
||||
RefreshExclusionFactory factory = getFactoryForClassName(className);
|
||||
|
||||
if (factory == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return factory.createNewExclusionInstance();
|
||||
}
|
||||
|
||||
private HashMap<IProject, LinkedHashSet<IResource>> getProjectToResourcesMap() {
|
||||
if (fProjectToResourcesMap == null) {
|
||||
fProjectToResourcesMap = new HashMap<IProject, LinkedHashSet<IResource>>();
|
||||
}
|
||||
|
||||
return fProjectToResourcesMap;
|
||||
}
|
||||
|
||||
public IWorkspaceRunnable getRefreshRunnable(final IProject project) {
|
||||
|
||||
IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
|
||||
|
||||
/**
|
||||
* @param q
|
||||
* @param resource
|
||||
* @throws CoreException
|
||||
*/
|
||||
private void refreshResources(IResource resource, List<RefreshExclusion> exclusions,
|
||||
IProgressMonitor monitor) throws CoreException {
|
||||
if (resource instanceof IContainer) {
|
||||
IContainer container = (IContainer) resource;
|
||||
|
||||
if (shouldResourceBeRefreshed(resource)) {
|
||||
resource.refreshLocal(IResource.DEPTH_ONE, monitor);
|
||||
|
||||
}
|
||||
|
||||
for (IResource child : container.members()) {
|
||||
refreshResources(child, exclusions, monitor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void run(IProgressMonitor monitor) throws CoreException {
|
||||
|
||||
List<IResource> resourcesToRefresh = getResourcesToRefresh(project);
|
||||
for (IResource resource : resourcesToRefresh) {
|
||||
List<RefreshExclusion> exclusions = getExclusions(resource);
|
||||
refreshResources(resource, exclusions, monitor);
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
return runnable;
|
||||
}
|
||||
|
||||
public synchronized ISchedulingRule getRefreshSchedulingRule(IProject project) {
|
||||
return new MultiRule(getResourcesToRefresh(project).toArray(new ISchedulingRule[0]));
|
||||
}
|
||||
|
||||
private HashMap<IResource, List<RefreshExclusion>> getResourcesToExclusionsMap() {
|
||||
if (fResourceToExclusionsMap == null) {
|
||||
fResourceToExclusionsMap = new HashMap<IResource, List<RefreshExclusion>>();
|
||||
}
|
||||
|
||||
return fResourceToExclusionsMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the set of resources that should be refreshed for a project. These resources might have
|
||||
* associated exclusions.
|
||||
*
|
||||
* @param project
|
||||
* @return List<IResource>
|
||||
*/
|
||||
public synchronized List<IResource> getResourcesToRefresh(IProject project) {
|
||||
getProjectToResourcesMap();
|
||||
LinkedHashSet<IResource> resources = fProjectToResourcesMap.get(project);
|
||||
|
||||
if (resources == null) {
|
||||
// there are no settings yet for the project, setup the defaults
|
||||
resources = new LinkedHashSet<IResource>();
|
||||
resources.add(project);
|
||||
fProjectToResourcesMap.put(project, resources);
|
||||
}
|
||||
|
||||
return new LinkedList<IResource>(resources);
|
||||
}
|
||||
|
||||
public int getVersion() {
|
||||
return fVersion;
|
||||
}
|
||||
|
||||
public synchronized void loadExtensions() {
|
||||
IExtensionPoint extension = Platform.getExtensionRegistry().getExtensionPoint(CCorePlugin.PLUGIN_ID,
|
||||
EXTENSION_ID);
|
||||
IExtensionPoint extension = Platform.getExtensionRegistry().getExtensionPoint(
|
||||
CCorePlugin.PLUGIN_ID, EXTENSION_ID);
|
||||
if (extension != null) {
|
||||
IExtension[] extensions = extension.getExtensions();
|
||||
for (IExtension extension2 : extensions) {
|
||||
|
@ -174,16 +393,19 @@ public class RefreshScopeManager {
|
|||
|
||||
if (factoryClassName != null) {
|
||||
try {
|
||||
Object execExt = configElement.createExecutableExtension(FACTORY_CLASS);
|
||||
Object execExt = configElement
|
||||
.createExecutableExtension(FACTORY_CLASS);
|
||||
if ((execExt instanceof RefreshExclusionFactory)) {
|
||||
RefreshExclusionFactory exclusionFactory = (RefreshExclusionFactory) execExt;
|
||||
|
||||
if(exclusionClassName != null) {
|
||||
fClassnameToExclusionFactoryMap.put(exclusionClassName, exclusionFactory);
|
||||
|
||||
if (exclusionClassName != null) {
|
||||
fClassnameToExclusionFactoryMap.put(exclusionClassName,
|
||||
exclusionFactory);
|
||||
}
|
||||
|
||||
if(instanceClassName != null) {
|
||||
fClassnameToExclusionFactoryMap.put(instanceClassName, exclusionFactory);
|
||||
|
||||
if (instanceClassName != null) {
|
||||
fClassnameToExclusionFactoryMap.put(instanceClassName,
|
||||
exclusionFactory);
|
||||
}
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
|
@ -195,222 +417,9 @@ public class RefreshScopeManager {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static synchronized RefreshScopeManager getInstance() {
|
||||
if(fInstance == null) {
|
||||
fInstance = new RefreshScopeManager();
|
||||
}
|
||||
|
||||
return fInstance;
|
||||
}
|
||||
|
||||
public int getVersion() {
|
||||
return fVersion;
|
||||
}
|
||||
|
||||
public synchronized RefreshExclusionFactory getFactoryForClassName(String className) {
|
||||
RefreshExclusionFactory factory = fClassnameToExclusionFactoryMap.get(className);
|
||||
|
||||
return factory;
|
||||
}
|
||||
|
||||
public synchronized RefreshExclusion getExclusionForClassName(String className) {
|
||||
RefreshExclusionFactory factory = getFactoryForClassName(className);
|
||||
|
||||
if(factory == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return factory.createNewExclusion();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the set of resources that should be refreshed for a project.
|
||||
* These resources might have associated exclusions.
|
||||
*
|
||||
* @param project
|
||||
* @return List<IResource>
|
||||
*/
|
||||
public synchronized List<IResource> getResourcesToRefresh(IProject project) {
|
||||
getProjectToResourcesMap();
|
||||
LinkedHashSet<IResource> resources = fProjectToResourcesMap.get(project);
|
||||
|
||||
if (resources == null) {
|
||||
// there are no settings yet for the project, setup the defaults
|
||||
resources = new LinkedHashSet<IResource>();
|
||||
resources.add(project);
|
||||
fProjectToResourcesMap.put(project, resources);
|
||||
}
|
||||
|
||||
return new LinkedList<IResource>(resources);
|
||||
}
|
||||
|
||||
public synchronized void setResourcesToRefresh(IProject project, List<IResource> resources) {
|
||||
getProjectToResourcesMap();
|
||||
LinkedHashSet<IResource> resourceSet = new LinkedHashSet<IResource>(resources);
|
||||
|
||||
fProjectToResourcesMap.put(project, resourceSet);
|
||||
}
|
||||
|
||||
public synchronized void addResourceToRefresh(IProject project, IResource resource) {
|
||||
getProjectToResourcesMap();
|
||||
LinkedHashSet<IResource> resourceSet = fProjectToResourcesMap.get(project);
|
||||
|
||||
if(resourceSet == null) {
|
||||
resourceSet = new LinkedHashSet<IResource>();
|
||||
fProjectToResourcesMap.put(project, resourceSet);
|
||||
}
|
||||
|
||||
resourceSet.add(resource);
|
||||
|
||||
}
|
||||
|
||||
public synchronized void deleteResourceToRefresh(IProject project, IResource resource) {
|
||||
getProjectToResourcesMap();
|
||||
LinkedHashSet<IResource> resourceSet = fProjectToResourcesMap.get(project);
|
||||
|
||||
if(resourceSet == null) {
|
||||
resourceSet = new LinkedHashSet<IResource>();
|
||||
return;
|
||||
}
|
||||
|
||||
resourceSet.remove(resource);
|
||||
}
|
||||
|
||||
public synchronized void clearResourcesToRefresh(IProject project) {
|
||||
getProjectToResourcesMap();
|
||||
LinkedHashSet<IResource> resourceSet = null;
|
||||
|
||||
fProjectToResourcesMap.put(project, resourceSet);
|
||||
}
|
||||
|
||||
public synchronized void clearAllResourcesToRefresh() {
|
||||
getProjectToResourcesMap();
|
||||
fProjectToResourcesMap.clear();
|
||||
}
|
||||
|
||||
public synchronized void clearAllData() {
|
||||
clearAllResourcesToRefresh();
|
||||
clearAllExclusions();
|
||||
fIsLoaded = false;
|
||||
}
|
||||
|
||||
private HashMap<IProject, LinkedHashSet<IResource>> getProjectToResourcesMap() {
|
||||
if(fProjectToResourcesMap == null) {
|
||||
fProjectToResourcesMap = new HashMap<IProject, LinkedHashSet<IResource>>();
|
||||
}
|
||||
|
||||
return fProjectToResourcesMap;
|
||||
}
|
||||
|
||||
public synchronized List<RefreshExclusion> getExclusions(IResource resource) {
|
||||
getResourcesToExclusionsMap();
|
||||
List<RefreshExclusion> exclusions = fResourceToExclusionsMap.get(resource);
|
||||
if(exclusions == null) {
|
||||
exclusions = new LinkedList<RefreshExclusion>();
|
||||
fResourceToExclusionsMap.put(resource, exclusions);
|
||||
}
|
||||
|
||||
return exclusions;
|
||||
}
|
||||
|
||||
public synchronized void addExclusion(IResource resource, RefreshExclusion exclusion) {
|
||||
getResourcesToExclusionsMap();
|
||||
|
||||
List<RefreshExclusion> exclusions = fResourceToExclusionsMap.get(resource);
|
||||
if(exclusions == null) {
|
||||
exclusions = new LinkedList<RefreshExclusion>();
|
||||
fResourceToExclusionsMap.put(resource, exclusions);
|
||||
}
|
||||
|
||||
exclusions.add(exclusion);
|
||||
}
|
||||
|
||||
private HashMap<IResource, List<RefreshExclusion>> getResourcesToExclusionsMap() {
|
||||
if(fResourceToExclusionsMap == null) {
|
||||
fResourceToExclusionsMap = new HashMap<IResource, List<RefreshExclusion>>();
|
||||
}
|
||||
|
||||
return fResourceToExclusionsMap;
|
||||
}
|
||||
|
||||
public synchronized void removeExclusion(IResource resource, RefreshExclusion exclusion) {
|
||||
getResourcesToExclusionsMap();
|
||||
List<RefreshExclusion> exclusions = fResourceToExclusionsMap.get(resource);
|
||||
if(exclusions == null) {
|
||||
exclusions = new LinkedList<RefreshExclusion>();
|
||||
fResourceToExclusionsMap.put(resource, exclusions);
|
||||
}
|
||||
|
||||
exclusions.remove(exclusion);
|
||||
}
|
||||
|
||||
public synchronized void persistSettings(ICProjectDescription projectDescription)
|
||||
throws CoreException {
|
||||
getProjectToResourcesMap();
|
||||
getResourcesToExclusionsMap();
|
||||
IProject project = projectDescription.getProject();
|
||||
|
||||
if (!project.exists()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// serialize all settings for the project to the C Project Description
|
||||
if (project.isOpen()) {
|
||||
if (project.hasNature(CProjectNature.C_NATURE_ID)) {
|
||||
|
||||
ICStorageElement storageElement = projectDescription.getStorage(
|
||||
REFRESH_SCOPE_STORAGE_NAME, true);
|
||||
storageElement.clear();
|
||||
|
||||
storageElement.setAttribute(VERSION_NUMBER_ATTRIBUTE_NAME,
|
||||
Integer.toString(fVersion));
|
||||
|
||||
for (IResource resource : fProjectToResourcesMap.get(project)) {
|
||||
|
||||
// create a resource node
|
||||
ICStorageElement resourceElement = storageElement
|
||||
.createChild(RESOURCE_ELEMENT_NAME);
|
||||
resourceElement.setAttribute(WORKSPACE_PATH_ATTRIBUTE_NAME, resource
|
||||
.getFullPath().toString());
|
||||
|
||||
String resourceTypeString = null;
|
||||
|
||||
if(resource instanceof IFile) {
|
||||
resourceTypeString = FILE_VALUE;
|
||||
}
|
||||
|
||||
else if(resource instanceof IFolder) {
|
||||
resourceTypeString = FOLDER_VALUE;
|
||||
}
|
||||
|
||||
else if(resource instanceof IProject) {
|
||||
resourceTypeString = PROJECT_VALUE;
|
||||
}
|
||||
|
||||
else {
|
||||
resourceTypeString = OTHER_VALUE;
|
||||
}
|
||||
resourceElement.setAttribute(RESOURCE_TYPE_ATTRIBUTE_NAME, resourceTypeString);
|
||||
|
||||
// populate the node with any exclusions
|
||||
List<RefreshExclusion> exclusions = fResourceToExclusionsMap.get(resource);
|
||||
if (exclusions != null) {
|
||||
for (RefreshExclusion exclusion : exclusions) {
|
||||
exclusion.persistData(resourceElement);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public synchronized void loadSettings() throws CoreException {
|
||||
if(!fIsLoaded && !fIsLoading) {
|
||||
if (!fIsLoaded && !fIsLoading) {
|
||||
fIsLoading = true;
|
||||
// iterate through all projects in the workspace. If they are C projects, attempt to load settings
|
||||
// from them.
|
||||
|
@ -419,7 +428,7 @@ public class RefreshScopeManager {
|
|||
for (IProject project : workspaceRoot.getProjects()) {
|
||||
loadSettings(workspaceRoot, project);
|
||||
}
|
||||
|
||||
|
||||
fIsLoaded = true;
|
||||
fIsLoading = false;
|
||||
}
|
||||
|
@ -434,16 +443,21 @@ public class RefreshScopeManager {
|
|||
throws CoreException {
|
||||
if (project.isOpen()) {
|
||||
if (project.hasNature(CProjectNature.C_NATURE_ID)) {
|
||||
CProjectDescriptionManager descriptionManager = CProjectDescriptionManager.getInstance();
|
||||
ICProjectDescription projectDescription = descriptionManager.getProjectDescription(project, false);
|
||||
|
||||
CProjectDescriptionManager descriptionManager = CProjectDescriptionManager
|
||||
.getInstance();
|
||||
ICProjectDescription projectDescription = descriptionManager.getProjectDescription(
|
||||
project, false);
|
||||
|
||||
if (projectDescription == null) {
|
||||
// then there's nothing to load... could be an old project that pre-dates the project description's
|
||||
// existence, or the project could have been just created but the project description hasn't been
|
||||
// created yet. Either way, just do nothing, because there's nothing to load.
|
||||
/*
|
||||
* then there's nothing to load... could be an old project that pre-dates the project
|
||||
* description's existence, or the project could have been just created but the project
|
||||
* description hasn't been created yet. Either way, just do nothing, because there's
|
||||
* nothing to load.
|
||||
*/
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
ICStorageElement storageElement = projectDescription.getStorage(
|
||||
REFRESH_SCOPE_STORAGE_NAME, true);
|
||||
|
||||
|
@ -468,18 +482,18 @@ public class RefreshScopeManager {
|
|||
}
|
||||
|
||||
else {
|
||||
String resourceTypeString = child.getAttribute(RESOURCE_TYPE_ATTRIBUTE_NAME);
|
||||
|
||||
if(resourceTypeString == null) {
|
||||
// we'll do our best, but we won't be able to create handles to non-existent resources
|
||||
String resourceTypeString = child
|
||||
.getAttribute(RESOURCE_TYPE_ATTRIBUTE_NAME);
|
||||
|
||||
if (resourceTypeString == null) {
|
||||
// we'll do our best, but we won't be able to create handles to non-existent
|
||||
// resources
|
||||
resourceTypeString = OTHER_VALUE;
|
||||
}
|
||||
|
||||
|
||||
// find the resource
|
||||
IResource resource = null;
|
||||
|
||||
|
||||
|
||||
if (resourceTypeString.equals(PROJECT_VALUE)) {
|
||||
resource = workspaceRoot.getProject(resourcePath);
|
||||
}
|
||||
|
@ -528,128 +542,124 @@ public class RefreshScopeManager {
|
|||
}
|
||||
}
|
||||
|
||||
public synchronized void clearExclusions(IResource resource) {
|
||||
public synchronized void persistSettings(ICProjectDescription projectDescription)
|
||||
throws CoreException {
|
||||
getProjectToResourcesMap();
|
||||
getResourcesToExclusionsMap();
|
||||
IProject project = projectDescription.getProject();
|
||||
|
||||
if (!project.exists()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// serialize all settings for the project to the C Project Description
|
||||
if (project.isOpen()) {
|
||||
if (project.hasNature(CProjectNature.C_NATURE_ID)) {
|
||||
|
||||
ICStorageElement storageElement = projectDescription.getStorage(
|
||||
REFRESH_SCOPE_STORAGE_NAME, true);
|
||||
storageElement.clear();
|
||||
|
||||
storageElement.setAttribute(VERSION_NUMBER_ATTRIBUTE_NAME,
|
||||
Integer.toString(fVersion));
|
||||
|
||||
for (IResource resource : fProjectToResourcesMap.get(project)) {
|
||||
|
||||
// create a resource node
|
||||
ICStorageElement resourceElement = storageElement
|
||||
.createChild(RESOURCE_ELEMENT_NAME);
|
||||
resourceElement.setAttribute(WORKSPACE_PATH_ATTRIBUTE_NAME, resource
|
||||
.getFullPath().toString());
|
||||
|
||||
String resourceTypeString = null;
|
||||
|
||||
if (resource instanceof IFile) {
|
||||
resourceTypeString = FILE_VALUE;
|
||||
}
|
||||
|
||||
else if (resource instanceof IFolder) {
|
||||
resourceTypeString = FOLDER_VALUE;
|
||||
}
|
||||
|
||||
else if (resource instanceof IProject) {
|
||||
resourceTypeString = PROJECT_VALUE;
|
||||
}
|
||||
|
||||
else {
|
||||
resourceTypeString = OTHER_VALUE;
|
||||
}
|
||||
|
||||
resourceElement.setAttribute(RESOURCE_TYPE_ATTRIBUTE_NAME, resourceTypeString);
|
||||
|
||||
// populate the node with any exclusions
|
||||
List<RefreshExclusion> exclusions = fResourceToExclusionsMap.get(resource);
|
||||
if (exclusions != null) {
|
||||
for (RefreshExclusion exclusion : exclusions) {
|
||||
exclusion.persistData(resourceElement);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public synchronized void removeExclusion(IResource resource, RefreshExclusion exclusion) {
|
||||
getResourcesToExclusionsMap();
|
||||
List<RefreshExclusion> exclusions = fResourceToExclusionsMap.get(resource);
|
||||
if(exclusions != null) {
|
||||
exclusions.clear();
|
||||
if (exclusions == null) {
|
||||
exclusions = new LinkedList<RefreshExclusion>();
|
||||
fResourceToExclusionsMap.put(resource, exclusions);
|
||||
}
|
||||
|
||||
exclusions.remove(exclusion);
|
||||
}
|
||||
|
||||
|
||||
public synchronized void setExclusions(IResource resource, List<RefreshExclusion> newExclusions) {
|
||||
getResourcesToExclusionsMap();
|
||||
List<RefreshExclusion> exclusions = new LinkedList<RefreshExclusion>(newExclusions);
|
||||
|
||||
|
||||
fResourceToExclusionsMap.put(resource, exclusions);
|
||||
}
|
||||
|
||||
public synchronized void clearAllExclusions() {
|
||||
if(fResourceToExclusionsMap != null)
|
||||
fResourceToExclusionsMap.clear();
|
||||
}
|
||||
|
||||
public synchronized void clearExclusionsForProject(IProject project) {
|
||||
getResourcesToExclusionsMap();
|
||||
List<IResource> resourcesToRemove = new LinkedList<IResource>();
|
||||
|
||||
for(IResource resource : fResourceToExclusionsMap.keySet()) {
|
||||
IProject project2 = resource.getProject();
|
||||
if(project2.equals(project)) {
|
||||
resourcesToRemove.add(resource);
|
||||
}
|
||||
}
|
||||
|
||||
for(IResource resource : resourcesToRemove) {
|
||||
fResourceToExclusionsMap.remove(resource);
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized void clearDataForProject(IProject project) {
|
||||
clearResourcesToRefresh(project);
|
||||
clearExclusionsForProject(project);
|
||||
|
||||
public synchronized void setResourcesToRefresh(IProject project, List<IResource> resources) {
|
||||
getProjectToResourcesMap();
|
||||
LinkedHashSet<IResource> resourceSet = new LinkedHashSet<IResource>(resources);
|
||||
|
||||
fProjectToResourcesMap.put(project, resourceSet);
|
||||
}
|
||||
|
||||
public synchronized ExclusionInstance getInstanceForClassName(String className) {
|
||||
RefreshExclusionFactory factory = getFactoryForClassName(className);
|
||||
|
||||
if(factory == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return factory.createNewExclusionInstance();
|
||||
}
|
||||
|
||||
public synchronized ISchedulingRule getRefreshSchedulingRule(IProject project) {
|
||||
return new MultiRule(getResourcesToRefresh(project).toArray(new ISchedulingRule[0]));
|
||||
}
|
||||
|
||||
public IWorkspaceRunnable getRefreshRunnable(final IProject project) {
|
||||
|
||||
IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
|
||||
|
||||
public void run(IProgressMonitor monitor) throws CoreException {
|
||||
|
||||
List<IResource> resourcesToRefresh = getResourcesToRefresh(project);
|
||||
for(IResource resource : resourcesToRefresh) {
|
||||
List<RefreshExclusion> exclusions = getExclusions(resource);
|
||||
refreshResources(resource, exclusions, monitor);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param q
|
||||
* @param resource
|
||||
* @throws CoreException
|
||||
*/
|
||||
private void refreshResources(IResource resource, List<RefreshExclusion> exclusions, IProgressMonitor monitor) throws CoreException {
|
||||
if (resource instanceof IContainer) {
|
||||
IContainer container = (IContainer) resource;
|
||||
|
||||
if (shouldResourceBeRefreshed(resource)) {
|
||||
resource.refreshLocal(IResource.DEPTH_ONE, monitor);
|
||||
|
||||
}
|
||||
|
||||
for (IResource child : container.members()) {
|
||||
refreshResources(child, exclusions, monitor);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return runnable;
|
||||
}
|
||||
|
||||
public synchronized boolean shouldResourceBeRefreshed(IResource resource) {
|
||||
IProject project = resource.getProject();
|
||||
List<IResource> resourcesToRefresh = getResourcesToRefresh(project);
|
||||
boolean isInSomeTree = false;
|
||||
IResource topLevelResource = null;
|
||||
|
||||
for(IResource resourceToRefresh : resourcesToRefresh) {
|
||||
if(resourceToRefresh.equals(resource)) {
|
||||
|
||||
for (IResource resourceToRefresh : resourcesToRefresh) {
|
||||
if (resourceToRefresh.equals(resource)) {
|
||||
isInSomeTree = true;
|
||||
topLevelResource = resource;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
// see if the resource is a child of our top level resources
|
||||
if(resourceToRefresh instanceof IContainer) {
|
||||
if (resourceToRefresh instanceof IContainer) {
|
||||
IContainer container = (IContainer) resourceToRefresh;
|
||||
if(container.getFullPath().isPrefixOf(resource.getFullPath())) {
|
||||
if (container.getFullPath().isPrefixOf(resource.getFullPath())) {
|
||||
isInSomeTree = true;
|
||||
topLevelResource = resourceToRefresh;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
if(!isInSomeTree) {
|
||||
|
||||
if (!isInSomeTree) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// get any exclusions
|
||||
boolean isExcluded = false;
|
||||
|
||||
|
@ -659,7 +669,7 @@ public class RefreshScopeManager {
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return !isExcluded;
|
||||
|
||||
}
|
||||
|
|
|
@ -22,18 +22,19 @@ import org.eclipse.core.resources.IResource;
|
|||
|
||||
/**
|
||||
*
|
||||
* <strong>EXPERIMENTAL</strong>. This class or interface has been added as
|
||||
* part of a work in progress. There is no guarantee that this API will work or
|
||||
* that it will remain the same. Please do not use this API without consulting
|
||||
* with the CDT team.
|
||||
* <strong>EXPERIMENTAL</strong>. This class or interface has been added as part of a work in progress. There
|
||||
* is no guarantee that this API will work or that it will remain the same. Please do not use this API without
|
||||
* consulting with the CDT team.
|
||||
*
|
||||
* @author vkong
|
||||
* @since 5.3
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class ResourceExclusion extends RefreshExclusion {
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.cdt.core.resources.RefreshExclusion#getName()
|
||||
*/
|
||||
@Override
|
||||
|
@ -41,26 +42,34 @@ public class ResourceExclusion extends RefreshExclusion {
|
|||
return Messages.ResourceExclusion_name;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.resources.RefreshExclusion#testExclusion(org.eclipse.core.resources.IResource)
|
||||
@Override
|
||||
public boolean supportsExclusionInstances() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.eclipse.cdt.core.resources.RefreshExclusion#testExclusion(org.eclipse.core.resources.IResource)
|
||||
*/
|
||||
@Override
|
||||
public synchronized boolean testExclusion(IResource resource) {
|
||||
|
||||
//Populate the resources to be excluded by this exclusion
|
||||
|
||||
// Populate the resources to be excluded by this exclusion
|
||||
List<IResource> excludedResources = new LinkedList<IResource>();
|
||||
List<ExclusionInstance> exclusionInstances = getExclusionInstances();
|
||||
|
||||
for(ExclusionInstance instance : exclusionInstances) {
|
||||
|
||||
for (ExclusionInstance instance : exclusionInstances) {
|
||||
excludedResources.add(instance.getResource());
|
||||
}
|
||||
|
||||
|
||||
if (excludedResources.contains(resource)) {
|
||||
return true;
|
||||
} else { //check to see if the given resource is part of this exclusion
|
||||
|
||||
for(IResource excludedResource : excludedResources) {
|
||||
//TODO: need to update this for Phase 2 implementation
|
||||
} else { // check to see if the given resource is part of this exclusion
|
||||
|
||||
for (IResource excludedResource : excludedResources) {
|
||||
// TODO: need to update this for Phase 2 implementation
|
||||
if (excludedResource instanceof IContainer) {
|
||||
IContainer container = (IContainer) excludedResource;
|
||||
if (container.getFullPath().isPrefixOf(resource.getFullPath())) {
|
||||
|
@ -72,9 +81,4 @@ public class ResourceExclusion extends RefreshExclusion {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsExclusionInstances() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ import org.eclipse.cdt.core.resources.RefreshExclusionFactory;
|
|||
|
||||
/**
|
||||
* @author crecoskie
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class ResourceExclusionFactory extends RefreshExclusionFactory {
|
||||
|
||||
|
@ -27,7 +27,9 @@ public class ResourceExclusionFactory extends RefreshExclusionFactory {
|
|||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.cdt.core.resources.RefreshExclusionFactory#createNewExclusion()
|
||||
*/
|
||||
@Override
|
||||
|
@ -35,7 +37,9 @@ public class ResourceExclusionFactory extends RefreshExclusionFactory {
|
|||
return new ResourceExclusion();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.cdt.core.resources.RefreshExclusionFactory#createNewExclusionInstance()
|
||||
*/
|
||||
@Override
|
||||
|
@ -44,7 +48,9 @@ public class ResourceExclusionFactory extends RefreshExclusionFactory {
|
|||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.cdt.core.resources.RefreshExclusionFactory#getExclusionClassname()
|
||||
*/
|
||||
@Override
|
||||
|
@ -52,7 +58,9 @@ public class ResourceExclusionFactory extends RefreshExclusionFactory {
|
|||
return ResourceExclusion.class.getName();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.cdt.core.resources.RefreshExclusionFactory#getInstanceClassname()
|
||||
*/
|
||||
@Override
|
||||
|
|
|
@ -47,44 +47,42 @@ import org.eclipse.cdt.ui.resources.RefreshExclusionContributor;
|
|||
import org.eclipse.cdt.internal.core.resources.ResourceExclusion;
|
||||
|
||||
/**
|
||||
* <strong>EXPERIMENTAL</strong>. This class or interface has been added as
|
||||
* part of a work in progress. There is no guarantee that this API will work or
|
||||
* that it will remain the same. Please do not use this API without consulting
|
||||
* with the CDT team.
|
||||
* <strong>EXPERIMENTAL</strong>. This class or interface has been added as part of a work in progress. There
|
||||
* is no guarantee that this API will work or that it will remain the same. Please do not use this API without
|
||||
* consulting with the CDT team.
|
||||
*
|
||||
* @author vkong
|
||||
* @since 5.3
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class ResourceExclusionContributor extends RefreshExclusionContributor {
|
||||
|
||||
/* (non-Javadoc)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.cdt.ui.resources.RefreshExclusionContributor#createExclusion()
|
||||
*/
|
||||
@Override
|
||||
public RefreshExclusion createExclusion() {
|
||||
ResourceExclusion newExclusion = new ResourceExclusion();
|
||||
newExclusion.setContributorId(getID());
|
||||
|
||||
//TODO change this for Phase 2
|
||||
|
||||
// TODO change this for Phase 2
|
||||
newExclusion.setExclusionType(ExclusionType.FOLDER);
|
||||
return newExclusion;
|
||||
}
|
||||
|
||||
private IResource getResourceRoot(RefreshExclusion exclusion) {
|
||||
if (exclusion.getParentExclusion() != null) {
|
||||
return getResourceRoot(exclusion.getParentExclusion());
|
||||
}
|
||||
return exclusion.getParentResource();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.ui.resources.RefreshExclusionContributor#createProperiesUI(org.eclipse.swt.widgets.Composite, org.eclipse.cdt.core.resources.RefreshExclusion)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.eclipse.cdt.ui.resources.RefreshExclusionContributor#createProperiesUI(org.eclipse.swt.widgets.
|
||||
* Composite, org.eclipse.cdt.core.resources.RefreshExclusion)
|
||||
*/
|
||||
@Override
|
||||
public void createProperiesUI(Composite parent, final RefreshExclusion exclusion) {
|
||||
final Shell shell = parent.getShell();
|
||||
|
||||
|
||||
Group g = new Group(parent, SWT.NONE);
|
||||
g.setText(Messages.RefreshPolicyExceptionDialog_exceptionTypeResources);
|
||||
g.setLayout(new GridLayout(1, false));
|
||||
|
@ -93,7 +91,7 @@ public class ResourceExclusionContributor extends RefreshExclusionContributor {
|
|||
gridData.horizontalSpan = 2;
|
||||
gridData.verticalSpan = 2;
|
||||
g.setLayoutData(gridData);
|
||||
|
||||
|
||||
final List exceptionsList = new List(g, SWT.NONE);
|
||||
gridData = new GridData();
|
||||
gridData.verticalAlignment = GridData.FILL;
|
||||
|
@ -103,13 +101,13 @@ public class ResourceExclusionContributor extends RefreshExclusionContributor {
|
|||
gridData.minimumHeight = 250;
|
||||
gridData.minimumWidth = 275;
|
||||
exceptionsList.setLayoutData(gridData);
|
||||
|
||||
|
||||
final HashMap<String, ExclusionInstance> exclusionInstanceStrings = new LinkedHashMap<String, ExclusionInstance>();
|
||||
final HashMap<String, Object> exclusionInstanceResources = new LinkedHashMap<String, Object>();
|
||||
|
||||
|
||||
java.util.List<ExclusionInstance> exclusionInstances = exclusion.getExclusionInstances();
|
||||
|
||||
//populate exclusion instance list
|
||||
// populate exclusion instance list
|
||||
if (exclusionInstances != null) {
|
||||
Iterator<ExclusionInstance> iterator = exclusionInstances.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
|
@ -120,97 +118,106 @@ public class ResourceExclusionContributor extends RefreshExclusionContributor {
|
|||
exclusionInstanceResources.put(name, exclusionInstance.getResource());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Composite buttonComp = new Composite(parent, SWT.NONE);
|
||||
buttonComp.setLayout(new GridLayout(1, false));
|
||||
gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL);
|
||||
gridData.minimumWidth = 100;
|
||||
buttonComp.setLayoutData(gridData);
|
||||
|
||||
|
||||
Button addButton = new Button(buttonComp, SWT.NONE);
|
||||
gridData = new GridData();
|
||||
gridData.horizontalAlignment = GridData.FILL;
|
||||
gridData.grabExcessHorizontalSpace = true;
|
||||
addButton.setLayoutData(gridData);
|
||||
addButton.setText(Messages.RefreshPolicyExceptionDialog_addButtonLabel);
|
||||
|
||||
|
||||
addButton.addSelectionListener(new SelectionAdapter() {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
|
||||
*/
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
CheckedTreeSelectionDialog dialog = new CheckedTreeSelectionDialog(shell, WorkbenchLabelProvider.getDecoratingWorkbenchLabelProvider(),
|
||||
CheckedTreeSelectionDialog dialog = new CheckedTreeSelectionDialog(shell,
|
||||
WorkbenchLabelProvider.getDecoratingWorkbenchLabelProvider(),
|
||||
new ITreeContentProvider() {
|
||||
|
||||
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
|
||||
}
|
||||
|
||||
|
||||
public void dispose() {
|
||||
}
|
||||
|
||||
public boolean hasChildren(Object element) {
|
||||
return getChildren(element).length > 0;
|
||||
|
||||
public Object[] getChildren(Object parentElement) {
|
||||
if (parentElement instanceof IContainer) {
|
||||
IContainer container = (IContainer) parentElement;
|
||||
if (container.isAccessible()) {
|
||||
try {
|
||||
java.util.List<IResource> children = new ArrayList<IResource>();
|
||||
IResource[] members = container.members();
|
||||
for (int i = 0; i < members.length; i++) {
|
||||
if (members[i].getType() == IResource.FOLDER) {
|
||||
children.add(members[i]);
|
||||
}
|
||||
}
|
||||
return children.toArray();
|
||||
} catch (CoreException e) {
|
||||
// this should never happen because we call #isAccessible before
|
||||
// invoking #members
|
||||
}
|
||||
}
|
||||
}
|
||||
return new Object[0];
|
||||
}
|
||||
|
||||
|
||||
public Object[] getElements(Object inputElement) {
|
||||
return getChildren(inputElement);
|
||||
}
|
||||
|
||||
public Object getParent(Object element) {
|
||||
if (element instanceof IResource) {
|
||||
return ((IResource) element).getParent();
|
||||
}
|
||||
return null;
|
||||
return null;
|
||||
}
|
||||
|
||||
public Object[] getElements(Object inputElement) {
|
||||
return getChildren(inputElement);
|
||||
|
||||
public boolean hasChildren(Object element) {
|
||||
return getChildren(element).length > 0;
|
||||
}
|
||||
|
||||
public Object[] getChildren(Object parentElement) {
|
||||
if (parentElement instanceof IContainer) {
|
||||
IContainer container = (IContainer) parentElement;
|
||||
if (container.isAccessible()) {
|
||||
try {
|
||||
java.util.List<IResource> children = new ArrayList<IResource>();
|
||||
IResource[] members = container.members();
|
||||
for (int i = 0; i < members.length; i++) {
|
||||
if (members[i].getType() == IResource.FOLDER) {
|
||||
children.add(members[i]);
|
||||
}
|
||||
}
|
||||
return children.toArray();
|
||||
} catch (CoreException e) {
|
||||
// this should never happen because we call #isAccessible before invoking #members
|
||||
}
|
||||
}
|
||||
}
|
||||
return new Object[0];
|
||||
|
||||
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
|
||||
}
|
||||
} );
|
||||
|
||||
});
|
||||
|
||||
dialog.setInput(getResourceRoot(exclusion));
|
||||
|
||||
|
||||
if (exclusionInstanceResources.values().size() > 0) {
|
||||
dialog.setInitialElementSelections(Arrays.asList(exclusionInstanceResources.values().toArray()));
|
||||
dialog.setInitialElementSelections(Arrays.asList(exclusionInstanceResources.values()
|
||||
.toArray()));
|
||||
}
|
||||
dialog.setMessage(Messages.RefreshPolicyExceptionDialog_SelectResourceDialogMessage);
|
||||
dialog.setTitle(Messages.RefreshPolicyExceptionDialog_SelectResourceDialogTitle);
|
||||
|
||||
|
||||
if (dialog.open() == Window.OK) {
|
||||
Object[] selection = dialog.getResult();
|
||||
exceptionsList.removeAll();
|
||||
exclusionInstanceResources.clear();
|
||||
final HashMap<String, ExclusionInstance> oldExclusionInstanceStrings = new LinkedHashMap<String, ExclusionInstance>(exclusionInstanceStrings);
|
||||
final HashMap<String, ExclusionInstance> oldExclusionInstanceStrings = new LinkedHashMap<String, ExclusionInstance>(
|
||||
exclusionInstanceStrings);
|
||||
exclusionInstanceStrings.clear();
|
||||
|
||||
|
||||
for (int i = 0; i < selection.length; i++) {
|
||||
Object selected = selection[i];
|
||||
if (selected instanceof IFolder) {
|
||||
IPath path = ((IFolder)selected).getFullPath();
|
||||
IPath relativePath = path.makeRelativeTo(getResourceRoot(exclusion).getFullPath());
|
||||
|
||||
IPath path = ((IFolder) selected).getFullPath();
|
||||
IPath relativePath = path
|
||||
.makeRelativeTo(getResourceRoot(exclusion).getFullPath());
|
||||
|
||||
exceptionsList.add(relativePath.toString());
|
||||
ExclusionInstance instance = oldExclusionInstanceStrings.get(relativePath.toString());
|
||||
if (instance == null) {
|
||||
ExclusionInstance instance = oldExclusionInstanceStrings.get(relativePath
|
||||
.toString());
|
||||
if (instance == null) {
|
||||
instance = new ExclusionInstance();
|
||||
instance.setExclusionType(ExclusionType.FOLDER);
|
||||
instance.setParentExclusion(exclusion);
|
||||
|
@ -220,12 +227,12 @@ public class ResourceExclusionContributor extends RefreshExclusionContributor {
|
|||
} else {
|
||||
oldExclusionInstanceStrings.remove(relativePath.toString());
|
||||
}
|
||||
|
||||
|
||||
exclusionInstanceStrings.put(instance.getDisplayString(), instance);
|
||||
exclusionInstanceResources.put(instance.getDisplayString(), selected);
|
||||
exclusionInstanceResources.put(instance.getDisplayString(), selected);
|
||||
}
|
||||
}
|
||||
//remove deprecated exclusion instances
|
||||
// remove deprecated exclusion instances
|
||||
oldExclusionInstanceStrings.keySet();
|
||||
Iterator<String> iterator = oldExclusionInstanceStrings.keySet().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
|
@ -236,48 +243,58 @@ public class ResourceExclusionContributor extends RefreshExclusionContributor {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
Button deleteButton = new Button(buttonComp, SWT.NONE);
|
||||
gridData = new GridData();
|
||||
gridData.horizontalAlignment = GridData.FILL;
|
||||
gridData.grabExcessHorizontalSpace = true;
|
||||
deleteButton.setLayoutData(gridData);
|
||||
deleteButton.setText(Messages.RefreshPolicyExceptionDialog_deleteButtonLabel);
|
||||
|
||||
|
||||
deleteButton.addSelectionListener(new SelectionAdapter() {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
|
||||
*/
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
String[] selected = exceptionsList.getSelection();
|
||||
String[] selected = exceptionsList.getSelection();
|
||||
if (selected.length < 1)
|
||||
return;
|
||||
|
||||
|
||||
for (int i = 0; i < selected.length; i++) {
|
||||
String folderToRemove = selected[i];
|
||||
ExclusionInstance instanceToRemove = exclusionInstanceStrings.get(folderToRemove);
|
||||
|
||||
// Iterator<Object> iterator = selectedFolders.iterator();
|
||||
|
||||
// while (iterator.hasNext()) {
|
||||
// IPath path = ((IFolder)iterator.next()).getFullPath();
|
||||
// IPath relativePath = path.makeRelativeTo(getResourceRoot(exclusionRoot).getFullPath());
|
||||
// if (relativePath.toString().compareTo(folderToRemove) == 0) {
|
||||
// iterator.remove();
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
|
||||
// Iterator<Object> iterator = selectedFolders.iterator();
|
||||
|
||||
// while (iterator.hasNext()) {
|
||||
// IPath path = ((IFolder)iterator.next()).getFullPath();
|
||||
// IPath relativePath = path.makeRelativeTo(getResourceRoot(exclusionRoot).getFullPath());
|
||||
// if (relativePath.toString().compareTo(folderToRemove) == 0) {
|
||||
// iterator.remove();
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
exclusion.removeExclusionInstance(instanceToRemove);
|
||||
exclusionInstanceStrings.remove(folderToRemove);
|
||||
exclusionInstanceResources.remove(folderToRemove);
|
||||
}
|
||||
}
|
||||
exceptionsList.remove(exceptionsList.getSelectionIndices());
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
private IResource getResourceRoot(RefreshExclusion exclusion) {
|
||||
if (exclusion.getParentExclusion() != null) {
|
||||
return getResourceRoot(exclusion.getParentExclusion());
|
||||
}
|
||||
return exclusion.getParentResource();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,33 +23,59 @@ import org.eclipse.core.runtime.Platform;
|
|||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
|
||||
/**
|
||||
* <strong>EXPERIMENTAL</strong>. This class or interface has been added as
|
||||
* part of a work in progress. There is no guarantee that this API will work or
|
||||
* that it will remain the same. Please do not use this API without consulting
|
||||
* with the CDT team.
|
||||
* <strong>EXPERIMENTAL</strong>. This class or interface has been added as part of a work in progress. There
|
||||
* is no guarantee that this API will work or that it will remain the same. Please do not use this API without
|
||||
* consulting with the CDT team.
|
||||
*
|
||||
* @author crecoskie
|
||||
* @since 5.3
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class RefreshExclusionContributionManager {
|
||||
|
||||
|
||||
public static final String EXCLUSION_CONTRIBUTOR = "exclusionContributor"; //$NON-NLS-1$
|
||||
public static final String EXTENSION_ID = "RefreshExclusionContributor"; //$NON-NLS-1$
|
||||
private LinkedHashMap<String, RefreshExclusionContributor> fIDtoContributorsMap;
|
||||
private static RefreshExclusionContributionManager fInstance;
|
||||
|
||||
|
||||
public static synchronized RefreshExclusionContributionManager getInstance() {
|
||||
if (fInstance == null) {
|
||||
fInstance = new RefreshExclusionContributionManager();
|
||||
}
|
||||
|
||||
return fInstance;
|
||||
}
|
||||
|
||||
private LinkedHashMap<String, RefreshExclusionContributor> fIDtoContributorsMap;
|
||||
|
||||
private RefreshExclusionContributionManager() {
|
||||
fIDtoContributorsMap = new LinkedHashMap<String, RefreshExclusionContributor>();
|
||||
loadExtensions();
|
||||
}
|
||||
|
||||
public static synchronized RefreshExclusionContributionManager getInstance() {
|
||||
if(fInstance == null) {
|
||||
fInstance = new RefreshExclusionContributionManager();
|
||||
|
||||
public RefreshExclusionContributor getContributor(String id) {
|
||||
return fIDtoContributorsMap.get(id);
|
||||
}
|
||||
|
||||
public List<RefreshExclusionContributor> getContributors() {
|
||||
return getContributors(false);
|
||||
}
|
||||
|
||||
public List<RefreshExclusionContributor> getContributors(boolean returnTestContributors) {
|
||||
List<RefreshExclusionContributor> retVal = new LinkedList<RefreshExclusionContributor>();
|
||||
|
||||
if (!returnTestContributors) {
|
||||
for (RefreshExclusionContributor contributor : fIDtoContributorsMap.values()) {
|
||||
if (!contributor.isTest()) {
|
||||
retVal.add(contributor);
|
||||
}
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
else {
|
||||
return new LinkedList<RefreshExclusionContributor>(fIDtoContributorsMap.values());
|
||||
}
|
||||
|
||||
return fInstance;
|
||||
}
|
||||
|
||||
public synchronized void loadExtensions() {
|
||||
|
@ -68,7 +94,7 @@ public class RefreshExclusionContributionManager {
|
|||
String contributorClassName = configElement.getAttribute("class"); //$NON-NLS-1$
|
||||
boolean isTest = false;
|
||||
String isTestString = configElement.getAttribute("isTest"); //$NON-NLS-1$
|
||||
if(isTestString != null) {
|
||||
if (isTestString != null) {
|
||||
isTest = Boolean.getBoolean(isTestString);
|
||||
}
|
||||
|
||||
|
@ -81,7 +107,7 @@ public class RefreshExclusionContributionManager {
|
|||
exclusionContributor.setName(name);
|
||||
exclusionContributor.setIsTest(isTest);
|
||||
fIDtoContributorsMap.put(id, exclusionContributor);
|
||||
|
||||
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
CUIPlugin.log(e);
|
||||
|
@ -92,30 +118,4 @@ public class RefreshExclusionContributionManager {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public RefreshExclusionContributor getContributor(String id) {
|
||||
return fIDtoContributorsMap.get(id);
|
||||
}
|
||||
|
||||
public List<RefreshExclusionContributor> getContributors() {
|
||||
return getContributors(false);
|
||||
}
|
||||
|
||||
public List<RefreshExclusionContributor> getContributors(boolean returnTestContributors) {
|
||||
List<RefreshExclusionContributor> retVal = new LinkedList<RefreshExclusionContributor>();
|
||||
|
||||
if(!returnTestContributors) {
|
||||
for(RefreshExclusionContributor contributor : fIDtoContributorsMap.values()) {
|
||||
if(!contributor.isTest()) {
|
||||
retVal.add(contributor);
|
||||
}
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
else {
|
||||
return new LinkedList<RefreshExclusionContributor>(fIDtoContributorsMap.values());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,37 +15,36 @@ import org.eclipse.swt.widgets.Composite;
|
|||
import org.eclipse.cdt.core.resources.RefreshExclusion;
|
||||
|
||||
/**
|
||||
* <strong>EXPERIMENTAL</strong>. This class or interface has been added as
|
||||
* part of a work in progress. There is no guarantee that this API will work or
|
||||
* that it will remain the same. Please do not use this API without consulting
|
||||
* with the CDT team.
|
||||
* <strong>EXPERIMENTAL</strong>. This class or interface has been added as part of a work in progress. There
|
||||
* is no guarantee that this API will work or that it will remain the same. Please do not use this API without
|
||||
* consulting with the CDT team.
|
||||
*
|
||||
* @author crecoskie
|
||||
* @since 5.3
|
||||
*
|
||||
*
|
||||
*/
|
||||
public abstract class RefreshExclusionContributor {
|
||||
|
||||
|
||||
protected String fID;
|
||||
protected String fName;
|
||||
protected boolean fIsTest;
|
||||
|
||||
protected String fName;
|
||||
|
||||
abstract public RefreshExclusion createExclusion();
|
||||
|
||||
/**
|
||||
* Creates the UI that allows user to modify the given RefreshExclusion
|
||||
*
|
||||
* @param parent
|
||||
* - the parent composite to contain the UI
|
||||
* @param exclusion
|
||||
* - the RefreshExclusion to be modified
|
||||
*/
|
||||
abstract public void createProperiesUI(Composite parent, RefreshExclusion exclusion);
|
||||
|
||||
public String getID() {
|
||||
return fID;
|
||||
}
|
||||
|
||||
public void setID(String id) {
|
||||
fID = id;
|
||||
}
|
||||
|
||||
public boolean isTest() {
|
||||
return fIsTest;
|
||||
}
|
||||
|
||||
public void setIsTest(boolean isTest) {
|
||||
fIsTest = isTest;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the human-readable name of this exclusion type.
|
||||
*
|
||||
|
@ -54,18 +53,21 @@ public abstract class RefreshExclusionContributor {
|
|||
public String getName() {
|
||||
return fName;
|
||||
}
|
||||
|
||||
|
||||
public boolean isTest() {
|
||||
return fIsTest;
|
||||
}
|
||||
|
||||
public void setID(String id) {
|
||||
fID = id;
|
||||
}
|
||||
|
||||
public void setIsTest(boolean isTest) {
|
||||
fIsTest = isTest;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
fName = name;
|
||||
}
|
||||
|
||||
abstract public RefreshExclusion createExclusion();
|
||||
|
||||
/**
|
||||
* Creates the UI that allows user to modify the given RefreshExclusion
|
||||
* @param parent - the parent composite to contain the UI
|
||||
* @param exclusion - the RefreshExclusion to be modified
|
||||
*/
|
||||
abstract public void createProperiesUI(Composite parent, RefreshExclusion exclusion);
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue