mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-15 04:55: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,16 +15,15 @@ import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.resources.ResourcesPlugin;
|
import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a particular instance of an exclusion. E.g., if an exclusion allowed
|
* Represents a particular instance of an exclusion. E.g., if an exclusion allowed for the exclusion of a list
|
||||||
* for the exclusion of a list individual resources, there would be one exclusion instance
|
* individual resources, there would be one exclusion instance per resource. Each exclusion instance is
|
||||||
* per resource. Each exclusion instance is presented in the user interface as a child of the exclusion.
|
* presented in the user interface as a child of the exclusion.
|
||||||
*
|
*
|
||||||
* Clients may extend this class to provide custom implementations for their exclusion type.
|
* Clients may extend this class to provide custom implementations for their exclusion type.
|
||||||
*
|
*
|
||||||
* <strong>EXPERIMENTAL</strong>. This class or interface has been added as
|
* <strong>EXPERIMENTAL</strong>. This class or interface has been added as part of a work in progress. There
|
||||||
* part of a work in progress. There is no guarantee that this API will work or
|
* is no guarantee that this API will work or that it will remain the same. Please do not use this API without
|
||||||
* that it will remain the same. Please do not use this API without consulting
|
* consulting with the CDT team.
|
||||||
* with the CDT team.
|
|
||||||
*
|
*
|
||||||
* @author crecoskie
|
* @author crecoskie
|
||||||
* @since 5.3
|
* @since 5.3
|
||||||
|
@ -33,22 +32,88 @@ import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
public class ExclusionInstance {
|
public class ExclusionInstance {
|
||||||
|
|
||||||
public static final String CLASS_ATTRIBUTE_NAME = "class"; //$NON-NLS-1$
|
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 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$
|
public static final String DISPLAY_STRING_ATTRIBUTE_NAME = "displayString"; //$NON-NLS-1$
|
||||||
|
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 ExclusionType fInstanceExclusionType;
|
|
||||||
protected IResource fResource;
|
|
||||||
protected String fDisplayString;
|
protected String fDisplayString;
|
||||||
|
protected ExclusionType fInstanceExclusionType;
|
||||||
protected RefreshExclusion fParent;
|
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.
|
* Returns the parent exclusion of this exclusion instance.
|
||||||
*
|
*
|
||||||
|
@ -58,21 +123,6 @@ public class ExclusionInstance {
|
||||||
return fParent;
|
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.
|
* If there is a resource directly associated with this exclusion instance, returns the resource.
|
||||||
*
|
*
|
||||||
|
@ -82,21 +132,12 @@ public class ExclusionInstance {
|
||||||
return fResource;
|
return fResource;
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void setResource(IResource resource) {
|
protected synchronized void loadExtendedInstanceData(ICStorageElement child) {
|
||||||
fResource = resource;
|
// override to provide extension specific behaviour if desired
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
protected synchronized void persistExtendedInstanceData(ICStorageElement instanceElement) {
|
||||||
* @return a String corresponding to the human-readable name for this exclusion instance.
|
// override to provide extension specific behaviour if desired
|
||||||
* 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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void persistInstanceData(ICStorageElement exclusionElement) {
|
public synchronized void persistInstanceData(ICStorageElement exclusionElement) {
|
||||||
|
@ -108,7 +149,7 @@ public class ExclusionInstance {
|
||||||
|
|
||||||
// persist the exclusion type
|
// persist the exclusion type
|
||||||
String exclusionType = null;
|
String exclusionType = null;
|
||||||
switch(getExclusionType()) {
|
switch (getExclusionType()) {
|
||||||
case FILE:
|
case FILE:
|
||||||
exclusionType = FILE_VALUE;
|
exclusionType = FILE_VALUE;
|
||||||
break;
|
break;
|
||||||
|
@ -122,17 +163,18 @@ public class ExclusionInstance {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(exclusionType != null) {
|
if (exclusionType != null) {
|
||||||
instanceElement.setAttribute(EXCLUSION_TYPE_ATTRIBUTE_NAME, exclusionType);
|
instanceElement.setAttribute(EXCLUSION_TYPE_ATTRIBUTE_NAME, exclusionType);
|
||||||
}
|
}
|
||||||
|
|
||||||
// persist resource path
|
// persist resource path
|
||||||
if(fResource != null) {
|
if (fResource != null) {
|
||||||
instanceElement.setAttribute(WORKSPACE_PATH_ATTRIBUTE_NAME, fResource.getFullPath().toString());
|
instanceElement.setAttribute(WORKSPACE_PATH_ATTRIBUTE_NAME, fResource.getFullPath()
|
||||||
|
.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
// persist display string
|
// persist display string
|
||||||
if(fDisplayString != null) {
|
if (fDisplayString != null) {
|
||||||
instanceElement.setAttribute(DISPLAY_STRING_ATTRIBUTE_NAME, fDisplayString);
|
instanceElement.setAttribute(DISPLAY_STRING_ATTRIBUTE_NAME, fDisplayString);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,62 +183,23 @@ public class ExclusionInstance {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected synchronized void persistExtendedInstanceData(ICStorageElement instanceElement) {
|
public synchronized void setDisplayString(String displayString) {
|
||||||
// override to provide extension specific behaviour if desired
|
fDisplayString = displayString;
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized static ExclusionInstance loadInstanceData(ICStorageElement instanceElement, RefreshScopeManager manager) {
|
public synchronized void setExclusionType(ExclusionType type) {
|
||||||
|
fInstanceExclusionType = type;
|
||||||
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 synchronized void loadExtendedInstanceData(ICStorageElement child) {
|
/**
|
||||||
// override to provide extension specific behaviour if desired
|
* @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,13 +12,12 @@
|
||||||
package org.eclipse.cdt.core.resources;
|
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
|
* Indicates the type of resources that this exclusion can exclude. Used to determine which type of icon is
|
||||||
* the exclusion UI when this exclusion is present.
|
* displayed in the exclusion UI when this exclusion is present.
|
||||||
*
|
*
|
||||||
* <strong>EXPERIMENTAL</strong>. This class or interface has been added as
|
* <strong>EXPERIMENTAL</strong>. This class or interface has been added as part of a work in progress. There
|
||||||
* part of a work in progress. There is no guarantee that this API will work or
|
* is no guarantee that this API will work or that it will remain the same. Please do not use this API without
|
||||||
* that it will remain the same. Please do not use this API without consulting
|
* consulting with the CDT team.
|
||||||
* with the CDT team.
|
|
||||||
*
|
*
|
||||||
* @author crecoskie
|
* @author crecoskie
|
||||||
* @since 5.3
|
* @since 5.3
|
||||||
|
@ -28,14 +27,12 @@ public enum ExclusionType {
|
||||||
/**
|
/**
|
||||||
* Constant indicating that this exclusion only excludes folders.
|
* Constant indicating that this exclusion only excludes folders.
|
||||||
*/
|
*/
|
||||||
FOLDER,
|
FILE,
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constant indicating that this exclusion only excludes folders.
|
* Constant indicating that this exclusion only excludes folders.
|
||||||
*/
|
*/
|
||||||
FILE,
|
FOLDER,
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constant indicating that this exclusion can exclude any resource.
|
* Constant indicating that this exclusion can exclude any resource.
|
||||||
|
|
|
@ -26,10 +26,9 @@ import com.ibm.icu.text.MessageFormat;
|
||||||
*
|
*
|
||||||
* Clients should extend this class to provide support for their own custom exclusions.
|
* Clients should extend this class to provide support for their own custom exclusions.
|
||||||
*
|
*
|
||||||
* <strong>EXPERIMENTAL</strong>. This class or interface has been added as
|
* <strong>EXPERIMENTAL</strong>. This class or interface has been added as part of a work in progress. There
|
||||||
* part of a work in progress. There is no guarantee that this API will work or
|
* is no guarantee that this API will work or that it will remain the same. Please do not use this API without
|
||||||
* that it will remain the same. Please do not use this API without consulting
|
* consulting with the CDT team.
|
||||||
* with the CDT team.
|
|
||||||
*
|
*
|
||||||
* @author crecoskie
|
* @author crecoskie
|
||||||
* @since 5.3
|
* @since 5.3
|
||||||
|
@ -38,231 +37,20 @@ import com.ibm.icu.text.MessageFormat;
|
||||||
public abstract class RefreshExclusion {
|
public abstract class RefreshExclusion {
|
||||||
|
|
||||||
public static final String CLASS_ATTRIBUTE_NAME = "class"; //$NON-NLS-1$
|
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 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$
|
public static final String DISPLAY_STRING_ATTRIBUTE_NAME = "displayString"; //$NON-NLS-1$
|
||||||
|
public static final String EXCLUSION_ELEMENT_NAME = "exclusion"; //$NON-NLS-1$
|
||||||
protected List<ExclusionInstance> fExclusionInstanceList = new LinkedList<ExclusionInstance>();
|
public static final String EXCLUSION_TYPE_ATTRIBUTE_NAME = "exclusionType"; //$NON-NLS-1$
|
||||||
protected List<RefreshExclusion> fNestedExclusions = new LinkedList<RefreshExclusion>();
|
public static final String EXTENSION_DATA_ELEMENT_NAME = "extensionData"; //$NON-NLS-1$
|
||||||
protected ExclusionType fExclusionType = ExclusionType.RESOURCE;
|
public static final String FILE_VALUE = "FILE"; //$NON-NLS-1$
|
||||||
protected RefreshExclusion fParentExclusion;
|
public static final String FOLDER_VALUE = "FOLDER"; //$NON-NLS-1$
|
||||||
protected IResource fParentResource;
|
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$
|
||||||
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 synchronized static List<RefreshExclusion> loadData(ICStorageElement parentElement,
|
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>();
|
List<RefreshExclusion> exclusions = new LinkedList<RefreshExclusion>();
|
||||||
|
|
||||||
|
@ -324,13 +112,15 @@ public abstract class RefreshExclusion {
|
||||||
else if (grandchild.getName().equals(INSTANCE_ELEMENT_NAME)) {
|
else if (grandchild.getName().equals(INSTANCE_ELEMENT_NAME)) {
|
||||||
|
|
||||||
// load the instance data
|
// load the instance data
|
||||||
ExclusionInstance instance = ExclusionInstance.loadInstanceData(grandchild, manager);
|
ExclusionInstance instance = ExclusionInstance.loadInstanceData(grandchild,
|
||||||
|
manager);
|
||||||
newExclusion.fExclusionInstanceList.add(instance);
|
newExclusion.fExclusionInstanceList.add(instance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// load nested exclusions
|
// load nested exclusions
|
||||||
List<RefreshExclusion> nestedExclusions = loadData(child, newExclusion, null, manager);
|
List<RefreshExclusion> nestedExclusions = loadData(child, newExclusion, null,
|
||||||
|
manager);
|
||||||
|
|
||||||
// add to parent
|
// add to parent
|
||||||
for (RefreshExclusion nestedExclusion : nestedExclusions) {
|
for (RefreshExclusion nestedExclusion : nestedExclusions) {
|
||||||
|
@ -345,9 +135,226 @@ public abstract class RefreshExclusion {
|
||||||
return exclusions;
|
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
|
* @return true if this exclusion supports exclusion instances
|
||||||
*/
|
*/
|
||||||
public abstract boolean supportsExclusionInstances();
|
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,8 +11,8 @@
|
||||||
package org.eclipse.cdt.core.resources;
|
package org.eclipse.cdt.core.resources;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Responsible for manufacturing a given type of RefreshExclusion. Called by the
|
* Responsible for manufacturing a given type of RefreshExclusion. Called by the RefreshScopeManager when
|
||||||
* RefreshScopeManager when loading persisted settings to instantiate exclusion objects.
|
* loading persisted settings to instantiate exclusion objects.
|
||||||
*
|
*
|
||||||
* @author crecoskie
|
* @author crecoskie
|
||||||
* @since 5.3
|
* @since 5.3
|
||||||
|
@ -34,22 +34,20 @@ public abstract class RefreshExclusionFactory {
|
||||||
*/
|
*/
|
||||||
abstract public ExclusionInstance createNewExclusionInstance();
|
abstract public ExclusionInstance createNewExclusionInstance();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the fully qualified classname of the type of the object that will
|
* Returns the fully qualified classname of the type of the object that will be returned by
|
||||||
* be returned by org.eclipse.cdt.core.resources.RefreshExclusionFactory.createNewExclusion()
|
* org.eclipse.cdt.core.resources.RefreshExclusionFactory.createNewExclusion()
|
||||||
*
|
*
|
||||||
* @return String
|
* @return String
|
||||||
*/
|
*/
|
||||||
abstract public String getExclusionClassname();
|
abstract public String getExclusionClassname();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the fully qualified classname of the type of the object that will
|
* Returns the fully qualified classname of the type of the object that will be returned by
|
||||||
* be returned by org.eclipse.cdt.core.resources.RefreshExclusionFactory.createNewExclusionInstance()
|
* org.eclipse.cdt.core.resources.RefreshExclusionFactory.createNewExclusionInstance()
|
||||||
*
|
*
|
||||||
* @return String
|
* @return String
|
||||||
*/
|
*/
|
||||||
abstract public String getInstanceClassname();
|
abstract public String getInstanceClassname();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,16 +43,14 @@ import org.eclipse.core.runtime.jobs.ISchedulingRule;
|
||||||
import org.eclipse.core.runtime.jobs.MultiRule;
|
import org.eclipse.core.runtime.jobs.MultiRule;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The RefreshScopeManager provides access to settings pertaining to refreshes performed during
|
* The RefreshScopeManager provides access to settings pertaining to refreshes performed during a build. Each
|
||||||
* a build. Each project may have a set of resources associated with it that are the set of resources
|
* project may have a set of resources associated with it that are the set of resources to be refreshed. An
|
||||||
* to be refreshed. An exclusion mechanism exists that allows for one to specify arbitrarily complicated,
|
* exclusion mechanism exists that allows for one to specify arbitrarily complicated, nested logic that
|
||||||
* nested logic that determines whether or not a given resource is refreshed according to previously
|
* determines whether or not a given resource is refreshed according to previously specified rules.
|
||||||
* specified rules.
|
|
||||||
*
|
*
|
||||||
* <strong>EXPERIMENTAL</strong>. This class or interface has been added as
|
* <strong>EXPERIMENTAL</strong>. This class or interface has been added as part of a work in progress. There
|
||||||
* part of a work in progress. There is no guarantee that this API will work or
|
* is no guarantee that this API will work or that it will remain the same. Please do not use this API without
|
||||||
* that it will remain the same. Please do not use this API without consulting
|
* consulting with the CDT team.
|
||||||
* with the CDT team.
|
|
||||||
*
|
*
|
||||||
* @author crecoskie
|
* @author crecoskie
|
||||||
* @since 5.3
|
* @since 5.3
|
||||||
|
@ -60,30 +58,39 @@ import org.eclipse.core.runtime.jobs.MultiRule;
|
||||||
*/
|
*/
|
||||||
public class RefreshScopeManager {
|
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 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 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 INSTANCE_CLASS = "instanceClass"; //$NON-NLS-1$
|
||||||
public static final String OTHER_VALUE = "OTHER"; //$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<IProject, LinkedHashSet<IResource>> fProjectToResourcesMap;
|
||||||
private HashMap<IResource, List<RefreshExclusion>> fResourceToExclusionsMap;
|
private HashMap<IResource, List<RefreshExclusion>> fResourceToExclusionsMap;
|
||||||
private HashMap<String, RefreshExclusionFactory> fClassnameToExclusionFactoryMap;
|
|
||||||
|
|
||||||
private static RefreshScopeManager fInstance;
|
private int fVersion = 1;
|
||||||
private boolean fIsLoading = false;
|
|
||||||
private boolean fIsLoaded = false;
|
|
||||||
|
|
||||||
private RefreshScopeManager() {
|
private RefreshScopeManager() {
|
||||||
fClassnameToExclusionFactoryMap = new HashMap<String, RefreshExclusionFactory>();
|
fClassnameToExclusionFactoryMap = new HashMap<String, RefreshExclusionFactory>();
|
||||||
|
@ -128,9 +135,11 @@ public class RefreshScopeManager {
|
||||||
IProject project = (IProject) delta.getResource();
|
IProject project = (IProject) delta.getResource();
|
||||||
|
|
||||||
if (delta.getKind() == IResourceDelta.ADDED
|
if (delta.getKind() == IResourceDelta.ADDED
|
||||||
|| (delta.getKind() == IResourceDelta.CHANGED && ((delta.getFlags() & IResourceDelta.OPEN) != 0) ) ) {
|
|| (delta.getKind() == IResourceDelta.CHANGED && ((delta
|
||||||
|
.getFlags() & IResourceDelta.OPEN) != 0))) {
|
||||||
|
|
||||||
loadSettings(ResourcesPlugin.getWorkspace().getRoot(), project);
|
loadSettings(ResourcesPlugin.getWorkspace()
|
||||||
|
.getRoot(), project);
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -158,54 +167,114 @@ public class RefreshScopeManager {
|
||||||
| IResourceChangeEvent.PRE_DELETE);
|
| IResourceChangeEvent.PRE_DELETE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void loadExtensions() {
|
public synchronized void addExclusion(IResource resource, RefreshExclusion exclusion) {
|
||||||
IExtensionPoint extension = Platform.getExtensionRegistry().getExtensionPoint(CCorePlugin.PLUGIN_ID,
|
getResourcesToExclusionsMap();
|
||||||
EXTENSION_ID);
|
|
||||||
if (extension != null) {
|
|
||||||
IExtension[] extensions = extension.getExtensions();
|
|
||||||
for (IExtension extension2 : extensions) {
|
|
||||||
IConfigurationElement[] configElements = extension2.getConfigurationElements();
|
|
||||||
for (IConfigurationElement configElement : configElements) {
|
|
||||||
|
|
||||||
if (configElement.getName().equals(EXCLUSION_FACTORY)) {
|
List<RefreshExclusion> exclusions = fResourceToExclusionsMap.get(resource);
|
||||||
String exclusionClassName = configElement.getAttribute(EXCLUSION_CLASS);
|
if (exclusions == null) {
|
||||||
String factoryClassName = configElement.getAttribute(FACTORY_CLASS);
|
exclusions = new LinkedList<RefreshExclusion>();
|
||||||
String instanceClassName = configElement.getAttribute(INSTANCE_CLASS);
|
fResourceToExclusionsMap.put(resource, exclusions);
|
||||||
|
}
|
||||||
|
|
||||||
if (factoryClassName != null) {
|
exclusions.add(exclusion);
|
||||||
try {
|
}
|
||||||
Object execExt = configElement.createExecutableExtension(FACTORY_CLASS);
|
|
||||||
if ((execExt instanceof RefreshExclusionFactory)) {
|
|
||||||
RefreshExclusionFactory exclusionFactory = (RefreshExclusionFactory) execExt;
|
|
||||||
|
|
||||||
if(exclusionClassName != null) {
|
public synchronized void addResourceToRefresh(IProject project, IResource resource) {
|
||||||
fClassnameToExclusionFactoryMap.put(exclusionClassName, exclusionFactory);
|
getProjectToResourcesMap();
|
||||||
}
|
LinkedHashSet<IResource> resourceSet = fProjectToResourcesMap.get(project);
|
||||||
|
|
||||||
if(instanceClassName != null) {
|
if (resourceSet == null) {
|
||||||
fClassnameToExclusionFactoryMap.put(instanceClassName, exclusionFactory);
|
resourceSet = new LinkedHashSet<IResource>();
|
||||||
}
|
fProjectToResourcesMap.put(project, resourceSet);
|
||||||
}
|
}
|
||||||
} catch (CoreException e) {
|
|
||||||
CCorePlugin.log(e);
|
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 static synchronized RefreshScopeManager getInstance() {
|
public synchronized void clearResourcesToRefresh(IProject project) {
|
||||||
if(fInstance == null) {
|
getProjectToResourcesMap();
|
||||||
fInstance = new RefreshScopeManager();
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
return fInstance;
|
resourceSet.remove(resource);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getVersion() {
|
public synchronized RefreshExclusion getExclusionForClassName(String className) {
|
||||||
return fVersion;
|
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) {
|
public synchronized RefreshExclusionFactory getFactoryForClassName(String className) {
|
||||||
|
@ -214,20 +283,78 @@ public class RefreshScopeManager {
|
||||||
return factory;
|
return factory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized RefreshExclusion getExclusionForClassName(String className) {
|
public synchronized ExclusionInstance getInstanceForClassName(String className) {
|
||||||
RefreshExclusionFactory factory = getFactoryForClassName(className);
|
RefreshExclusionFactory factory = getFactoryForClassName(className);
|
||||||
|
|
||||||
if(factory == null) {
|
if (factory == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return factory.createNewExclusion();
|
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.
|
* Returns the set of resources that should be refreshed for a project. These resources might have
|
||||||
* These resources might have associated exclusions.
|
* associated exclusions.
|
||||||
*
|
*
|
||||||
* @param project
|
* @param project
|
||||||
* @return List<IResource>
|
* @return List<IResource>
|
||||||
|
@ -246,171 +373,53 @@ public class RefreshScopeManager {
|
||||||
return new LinkedList<IResource>(resources);
|
return new LinkedList<IResource>(resources);
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void setResourcesToRefresh(IProject project, List<IResource> resources) {
|
public int getVersion() {
|
||||||
getProjectToResourcesMap();
|
return fVersion;
|
||||||
LinkedHashSet<IResource> resourceSet = new LinkedHashSet<IResource>(resources);
|
|
||||||
|
|
||||||
fProjectToResourcesMap.put(project, resourceSet);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void addResourceToRefresh(IProject project, IResource resource) {
|
public synchronized void loadExtensions() {
|
||||||
getProjectToResourcesMap();
|
IExtensionPoint extension = Platform.getExtensionRegistry().getExtensionPoint(
|
||||||
LinkedHashSet<IResource> resourceSet = fProjectToResourcesMap.get(project);
|
CCorePlugin.PLUGIN_ID, EXTENSION_ID);
|
||||||
|
if (extension != null) {
|
||||||
|
IExtension[] extensions = extension.getExtensions();
|
||||||
|
for (IExtension extension2 : extensions) {
|
||||||
|
IConfigurationElement[] configElements = extension2.getConfigurationElements();
|
||||||
|
for (IConfigurationElement configElement : configElements) {
|
||||||
|
|
||||||
if(resourceSet == null) {
|
if (configElement.getName().equals(EXCLUSION_FACTORY)) {
|
||||||
resourceSet = new LinkedHashSet<IResource>();
|
String exclusionClassName = configElement.getAttribute(EXCLUSION_CLASS);
|
||||||
fProjectToResourcesMap.put(project, resourceSet);
|
String factoryClassName = configElement.getAttribute(FACTORY_CLASS);
|
||||||
}
|
String instanceClassName = configElement.getAttribute(INSTANCE_CLASS);
|
||||||
|
|
||||||
resourceSet.add(resource);
|
if (factoryClassName != null) {
|
||||||
|
try {
|
||||||
|
Object execExt = configElement
|
||||||
|
.createExecutableExtension(FACTORY_CLASS);
|
||||||
|
if ((execExt instanceof RefreshExclusionFactory)) {
|
||||||
|
RefreshExclusionFactory exclusionFactory = (RefreshExclusionFactory) execExt;
|
||||||
|
|
||||||
}
|
if (exclusionClassName != null) {
|
||||||
|
fClassnameToExclusionFactoryMap.put(exclusionClassName,
|
||||||
|
exclusionFactory);
|
||||||
|
}
|
||||||
|
|
||||||
public synchronized void deleteResourceToRefresh(IProject project, IResource resource) {
|
if (instanceClassName != null) {
|
||||||
getProjectToResourcesMap();
|
fClassnameToExclusionFactoryMap.put(instanceClassName,
|
||||||
LinkedHashSet<IResource> resourceSet = fProjectToResourcesMap.get(project);
|
exclusionFactory);
|
||||||
|
}
|
||||||
if(resourceSet == null) {
|
}
|
||||||
resourceSet = new LinkedHashSet<IResource>();
|
} catch (CoreException e) {
|
||||||
return;
|
CCorePlugin.log(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
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 {
|
public synchronized void loadSettings() throws CoreException {
|
||||||
if(!fIsLoaded && !fIsLoading) {
|
if (!fIsLoaded && !fIsLoading) {
|
||||||
fIsLoading = true;
|
fIsLoading = true;
|
||||||
// iterate through all projects in the workspace. If they are C projects, attempt to load settings
|
// iterate through all projects in the workspace. If they are C projects, attempt to load settings
|
||||||
// from them.
|
// from them.
|
||||||
|
@ -434,13 +443,18 @@ public class RefreshScopeManager {
|
||||||
throws CoreException {
|
throws CoreException {
|
||||||
if (project.isOpen()) {
|
if (project.isOpen()) {
|
||||||
if (project.hasNature(CProjectNature.C_NATURE_ID)) {
|
if (project.hasNature(CProjectNature.C_NATURE_ID)) {
|
||||||
CProjectDescriptionManager descriptionManager = CProjectDescriptionManager.getInstance();
|
CProjectDescriptionManager descriptionManager = CProjectDescriptionManager
|
||||||
ICProjectDescription projectDescription = descriptionManager.getProjectDescription(project, false);
|
.getInstance();
|
||||||
|
ICProjectDescription projectDescription = descriptionManager.getProjectDescription(
|
||||||
|
project, false);
|
||||||
|
|
||||||
if (projectDescription == null) {
|
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
|
* then there's nothing to load... could be an old project that pre-dates the project
|
||||||
// created yet. Either way, just do nothing, because there's nothing to load.
|
* 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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -468,18 +482,18 @@ public class RefreshScopeManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
String resourceTypeString = child.getAttribute(RESOURCE_TYPE_ATTRIBUTE_NAME);
|
String resourceTypeString = child
|
||||||
|
.getAttribute(RESOURCE_TYPE_ATTRIBUTE_NAME);
|
||||||
|
|
||||||
if(resourceTypeString == null) {
|
if (resourceTypeString == null) {
|
||||||
// we'll do our best, but we won't be able to create handles to non-existent resources
|
// we'll do our best, but we won't be able to create handles to non-existent
|
||||||
|
// resources
|
||||||
resourceTypeString = OTHER_VALUE;
|
resourceTypeString = OTHER_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// find the resource
|
// find the resource
|
||||||
IResource resource = null;
|
IResource resource = null;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (resourceTypeString.equals(PROJECT_VALUE)) {
|
if (resourceTypeString.equals(PROJECT_VALUE)) {
|
||||||
resource = workspaceRoot.getProject(resourcePath);
|
resource = workspaceRoot.getProject(resourcePath);
|
||||||
}
|
}
|
||||||
|
@ -528,12 +542,79 @@ 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();
|
getResourcesToExclusionsMap();
|
||||||
List<RefreshExclusion> exclusions = fResourceToExclusionsMap.get(resource);
|
List<RefreshExclusion> exclusions = fResourceToExclusionsMap.get(resource);
|
||||||
if(exclusions != null) {
|
if (exclusions == null) {
|
||||||
exclusions.clear();
|
exclusions = new LinkedList<RefreshExclusion>();
|
||||||
|
fResourceToExclusionsMap.put(resource, exclusions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
exclusions.remove(exclusion);
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void setExclusions(IResource resource, List<RefreshExclusion> newExclusions) {
|
public synchronized void setExclusions(IResource resource, List<RefreshExclusion> newExclusions) {
|
||||||
|
@ -543,82 +624,11 @@ public class RefreshScopeManager {
|
||||||
fResourceToExclusionsMap.put(resource, exclusions);
|
fResourceToExclusionsMap.put(resource, exclusions);
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void clearAllExclusions() {
|
public synchronized void setResourcesToRefresh(IProject project, List<IResource> resources) {
|
||||||
if(fResourceToExclusionsMap != null)
|
getProjectToResourcesMap();
|
||||||
fResourceToExclusionsMap.clear();
|
LinkedHashSet<IResource> resourceSet = new LinkedHashSet<IResource>(resources);
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized void clearExclusionsForProject(IProject project) {
|
fProjectToResourcesMap.put(project, resourceSet);
|
||||||
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 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) {
|
public synchronized boolean shouldResourceBeRefreshed(IResource resource) {
|
||||||
|
@ -627,17 +637,17 @@ public class RefreshScopeManager {
|
||||||
boolean isInSomeTree = false;
|
boolean isInSomeTree = false;
|
||||||
IResource topLevelResource = null;
|
IResource topLevelResource = null;
|
||||||
|
|
||||||
for(IResource resourceToRefresh : resourcesToRefresh) {
|
for (IResource resourceToRefresh : resourcesToRefresh) {
|
||||||
if(resourceToRefresh.equals(resource)) {
|
if (resourceToRefresh.equals(resource)) {
|
||||||
isInSomeTree = true;
|
isInSomeTree = true;
|
||||||
topLevelResource = resource;
|
topLevelResource = resource;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// see if the resource is a child of our top level resources
|
// see if the resource is a child of our top level resources
|
||||||
if(resourceToRefresh instanceof IContainer) {
|
if (resourceToRefresh instanceof IContainer) {
|
||||||
IContainer container = (IContainer) resourceToRefresh;
|
IContainer container = (IContainer) resourceToRefresh;
|
||||||
if(container.getFullPath().isPrefixOf(resource.getFullPath())) {
|
if (container.getFullPath().isPrefixOf(resource.getFullPath())) {
|
||||||
isInSomeTree = true;
|
isInSomeTree = true;
|
||||||
topLevelResource = resourceToRefresh;
|
topLevelResource = resourceToRefresh;
|
||||||
break;
|
break;
|
||||||
|
@ -646,7 +656,7 @@ public class RefreshScopeManager {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!isInSomeTree) {
|
if (!isInSomeTree) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,10 +22,9 @@ import org.eclipse.core.resources.IResource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* <strong>EXPERIMENTAL</strong>. This class or interface has been added as
|
* <strong>EXPERIMENTAL</strong>. This class or interface has been added as part of a work in progress. There
|
||||||
* part of a work in progress. There is no guarantee that this API will work or
|
* is no guarantee that this API will work or that it will remain the same. Please do not use this API without
|
||||||
* that it will remain the same. Please do not use this API without consulting
|
* consulting with the CDT team.
|
||||||
* with the CDT team.
|
|
||||||
*
|
*
|
||||||
* @author vkong
|
* @author vkong
|
||||||
* @since 5.3
|
* @since 5.3
|
||||||
|
@ -33,7 +32,9 @@ import org.eclipse.core.resources.IResource;
|
||||||
*/
|
*/
|
||||||
public class ResourceExclusion extends RefreshExclusion {
|
public class ResourceExclusion extends RefreshExclusion {
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
* @see org.eclipse.cdt.core.resources.RefreshExclusion#getName()
|
* @see org.eclipse.cdt.core.resources.RefreshExclusion#getName()
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@ -41,26 +42,34 @@ public class ResourceExclusion extends RefreshExclusion {
|
||||||
return Messages.ResourceExclusion_name;
|
return Messages.ResourceExclusion_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
@Override
|
||||||
* @see org.eclipse.cdt.core.resources.RefreshExclusion#testExclusion(org.eclipse.core.resources.IResource)
|
public boolean supportsExclusionInstances() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see
|
||||||
|
* org.eclipse.cdt.core.resources.RefreshExclusion#testExclusion(org.eclipse.core.resources.IResource)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public synchronized boolean testExclusion(IResource resource) {
|
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<IResource> excludedResources = new LinkedList<IResource>();
|
||||||
List<ExclusionInstance> exclusionInstances = getExclusionInstances();
|
List<ExclusionInstance> exclusionInstances = getExclusionInstances();
|
||||||
|
|
||||||
for(ExclusionInstance instance : exclusionInstances) {
|
for (ExclusionInstance instance : exclusionInstances) {
|
||||||
excludedResources.add(instance.getResource());
|
excludedResources.add(instance.getResource());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (excludedResources.contains(resource)) {
|
if (excludedResources.contains(resource)) {
|
||||||
return true;
|
return true;
|
||||||
} else { //check to see if the given resource is part of this exclusion
|
} else { // check to see if the given resource is part of this exclusion
|
||||||
|
|
||||||
for(IResource excludedResource : excludedResources) {
|
for (IResource excludedResource : excludedResources) {
|
||||||
//TODO: need to update this for Phase 2 implementation
|
// TODO: need to update this for Phase 2 implementation
|
||||||
if (excludedResource instanceof IContainer) {
|
if (excludedResource instanceof IContainer) {
|
||||||
IContainer container = (IContainer) excludedResource;
|
IContainer container = (IContainer) excludedResource;
|
||||||
if (container.getFullPath().isPrefixOf(resource.getFullPath())) {
|
if (container.getFullPath().isPrefixOf(resource.getFullPath())) {
|
||||||
|
@ -72,9 +81,4 @@ public class ResourceExclusion extends RefreshExclusion {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean supportsExclusionInstances() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,9 @@ public class ResourceExclusionFactory extends RefreshExclusionFactory {
|
||||||
// TODO Auto-generated constructor stub
|
// TODO Auto-generated constructor stub
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
* @see org.eclipse.cdt.core.resources.RefreshExclusionFactory#createNewExclusion()
|
* @see org.eclipse.cdt.core.resources.RefreshExclusionFactory#createNewExclusion()
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@ -35,7 +37,9 @@ public class ResourceExclusionFactory extends RefreshExclusionFactory {
|
||||||
return new ResourceExclusion();
|
return new ResourceExclusion();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
* @see org.eclipse.cdt.core.resources.RefreshExclusionFactory#createNewExclusionInstance()
|
* @see org.eclipse.cdt.core.resources.RefreshExclusionFactory#createNewExclusionInstance()
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@ -44,7 +48,9 @@ public class ResourceExclusionFactory extends RefreshExclusionFactory {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
* @see org.eclipse.cdt.core.resources.RefreshExclusionFactory#getExclusionClassname()
|
* @see org.eclipse.cdt.core.resources.RefreshExclusionFactory#getExclusionClassname()
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@ -52,7 +58,9 @@ public class ResourceExclusionFactory extends RefreshExclusionFactory {
|
||||||
return ResourceExclusion.class.getName();
|
return ResourceExclusion.class.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
* @see org.eclipse.cdt.core.resources.RefreshExclusionFactory#getInstanceClassname()
|
* @see org.eclipse.cdt.core.resources.RefreshExclusionFactory#getInstanceClassname()
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -47,10 +47,9 @@ import org.eclipse.cdt.ui.resources.RefreshExclusionContributor;
|
||||||
import org.eclipse.cdt.internal.core.resources.ResourceExclusion;
|
import org.eclipse.cdt.internal.core.resources.ResourceExclusion;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <strong>EXPERIMENTAL</strong>. This class or interface has been added as
|
* <strong>EXPERIMENTAL</strong>. This class or interface has been added as part of a work in progress. There
|
||||||
* part of a work in progress. There is no guarantee that this API will work or
|
* is no guarantee that this API will work or that it will remain the same. Please do not use this API without
|
||||||
* that it will remain the same. Please do not use this API without consulting
|
* consulting with the CDT team.
|
||||||
* with the CDT team.
|
|
||||||
*
|
*
|
||||||
* @author vkong
|
* @author vkong
|
||||||
* @since 5.3
|
* @since 5.3
|
||||||
|
@ -58,7 +57,9 @@ import org.eclipse.cdt.internal.core.resources.ResourceExclusion;
|
||||||
*/
|
*/
|
||||||
public class ResourceExclusionContributor extends RefreshExclusionContributor {
|
public class ResourceExclusionContributor extends RefreshExclusionContributor {
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
* @see org.eclipse.cdt.ui.resources.RefreshExclusionContributor#createExclusion()
|
* @see org.eclipse.cdt.ui.resources.RefreshExclusionContributor#createExclusion()
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@ -66,20 +67,17 @@ public class ResourceExclusionContributor extends RefreshExclusionContributor {
|
||||||
ResourceExclusion newExclusion = new ResourceExclusion();
|
ResourceExclusion newExclusion = new ResourceExclusion();
|
||||||
newExclusion.setContributorId(getID());
|
newExclusion.setContributorId(getID());
|
||||||
|
|
||||||
//TODO change this for Phase 2
|
// TODO change this for Phase 2
|
||||||
newExclusion.setExclusionType(ExclusionType.FOLDER);
|
newExclusion.setExclusionType(ExclusionType.FOLDER);
|
||||||
return newExclusion;
|
return newExclusion;
|
||||||
}
|
}
|
||||||
|
|
||||||
private IResource getResourceRoot(RefreshExclusion exclusion) {
|
/*
|
||||||
if (exclusion.getParentExclusion() != null) {
|
* (non-Javadoc)
|
||||||
return getResourceRoot(exclusion.getParentExclusion());
|
*
|
||||||
}
|
* @see
|
||||||
return exclusion.getParentResource();
|
* 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
|
@Override
|
||||||
public void createProperiesUI(Composite parent, final RefreshExclusion exclusion) {
|
public void createProperiesUI(Composite parent, final RefreshExclusion exclusion) {
|
||||||
|
@ -109,7 +107,7 @@ public class ResourceExclusionContributor extends RefreshExclusionContributor {
|
||||||
|
|
||||||
java.util.List<ExclusionInstance> exclusionInstances = exclusion.getExclusionInstances();
|
java.util.List<ExclusionInstance> exclusionInstances = exclusion.getExclusionInstances();
|
||||||
|
|
||||||
//populate exclusion instance list
|
// populate exclusion instance list
|
||||||
if (exclusionInstances != null) {
|
if (exclusionInstances != null) {
|
||||||
Iterator<ExclusionInstance> iterator = exclusionInstances.iterator();
|
Iterator<ExclusionInstance> iterator = exclusionInstances.iterator();
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
|
@ -136,61 +134,67 @@ public class ResourceExclusionContributor extends RefreshExclusionContributor {
|
||||||
|
|
||||||
addButton.addSelectionListener(new SelectionAdapter() {
|
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
|
@Override
|
||||||
public void widgetSelected(SelectionEvent e) {
|
public void widgetSelected(SelectionEvent e) {
|
||||||
CheckedTreeSelectionDialog dialog = new CheckedTreeSelectionDialog(shell, WorkbenchLabelProvider.getDecoratingWorkbenchLabelProvider(),
|
CheckedTreeSelectionDialog dialog = new CheckedTreeSelectionDialog(shell,
|
||||||
|
WorkbenchLabelProvider.getDecoratingWorkbenchLabelProvider(),
|
||||||
new ITreeContentProvider() {
|
new ITreeContentProvider() {
|
||||||
|
|
||||||
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
|
|
||||||
}
|
|
||||||
|
|
||||||
public void dispose() {
|
public void dispose() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasChildren(Object element) {
|
public Object[] getChildren(Object parentElement) {
|
||||||
return getChildren(element).length > 0;
|
if (parentElement instanceof IContainer) {
|
||||||
}
|
IContainer container = (IContainer) parentElement;
|
||||||
|
if (container.isAccessible()) {
|
||||||
public Object getParent(Object element) {
|
try {
|
||||||
if (element instanceof IResource) {
|
java.util.List<IResource> children = new ArrayList<IResource>();
|
||||||
return ((IResource) element).getParent();
|
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 null;
|
return new Object[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object[] getElements(Object inputElement) {
|
public Object[] getElements(Object inputElement) {
|
||||||
return getChildren(inputElement);
|
return getChildren(inputElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object[] getChildren(Object parentElement) {
|
public Object getParent(Object element) {
|
||||||
if (parentElement instanceof IContainer) {
|
if (element instanceof IResource) {
|
||||||
IContainer container = (IContainer) parentElement;
|
return ((IResource) element).getParent();
|
||||||
if (container.isAccessible()) {
|
}
|
||||||
try {
|
return null;
|
||||||
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 boolean hasChildren(Object element) {
|
||||||
|
return getChildren(element).length > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
dialog.setInput(getResourceRoot(exclusion));
|
dialog.setInput(getResourceRoot(exclusion));
|
||||||
|
|
||||||
if (exclusionInstanceResources.values().size() > 0) {
|
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.setMessage(Messages.RefreshPolicyExceptionDialog_SelectResourceDialogMessage);
|
||||||
dialog.setTitle(Messages.RefreshPolicyExceptionDialog_SelectResourceDialogTitle);
|
dialog.setTitle(Messages.RefreshPolicyExceptionDialog_SelectResourceDialogTitle);
|
||||||
|
@ -199,17 +203,20 @@ public class ResourceExclusionContributor extends RefreshExclusionContributor {
|
||||||
Object[] selection = dialog.getResult();
|
Object[] selection = dialog.getResult();
|
||||||
exceptionsList.removeAll();
|
exceptionsList.removeAll();
|
||||||
exclusionInstanceResources.clear();
|
exclusionInstanceResources.clear();
|
||||||
final HashMap<String, ExclusionInstance> oldExclusionInstanceStrings = new LinkedHashMap<String, ExclusionInstance>(exclusionInstanceStrings);
|
final HashMap<String, ExclusionInstance> oldExclusionInstanceStrings = new LinkedHashMap<String, ExclusionInstance>(
|
||||||
|
exclusionInstanceStrings);
|
||||||
exclusionInstanceStrings.clear();
|
exclusionInstanceStrings.clear();
|
||||||
|
|
||||||
for (int i = 0; i < selection.length; i++) {
|
for (int i = 0; i < selection.length; i++) {
|
||||||
Object selected = selection[i];
|
Object selected = selection[i];
|
||||||
if (selected instanceof IFolder) {
|
if (selected instanceof IFolder) {
|
||||||
IPath path = ((IFolder)selected).getFullPath();
|
IPath path = ((IFolder) selected).getFullPath();
|
||||||
IPath relativePath = path.makeRelativeTo(getResourceRoot(exclusion).getFullPath());
|
IPath relativePath = path
|
||||||
|
.makeRelativeTo(getResourceRoot(exclusion).getFullPath());
|
||||||
|
|
||||||
exceptionsList.add(relativePath.toString());
|
exceptionsList.add(relativePath.toString());
|
||||||
ExclusionInstance instance = oldExclusionInstanceStrings.get(relativePath.toString());
|
ExclusionInstance instance = oldExclusionInstanceStrings.get(relativePath
|
||||||
|
.toString());
|
||||||
if (instance == null) {
|
if (instance == null) {
|
||||||
instance = new ExclusionInstance();
|
instance = new ExclusionInstance();
|
||||||
instance.setExclusionType(ExclusionType.FOLDER);
|
instance.setExclusionType(ExclusionType.FOLDER);
|
||||||
|
@ -225,7 +232,7 @@ public class ResourceExclusionContributor extends RefreshExclusionContributor {
|
||||||
exclusionInstanceResources.put(instance.getDisplayString(), selected);
|
exclusionInstanceResources.put(instance.getDisplayString(), selected);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//remove deprecated exclusion instances
|
// remove deprecated exclusion instances
|
||||||
oldExclusionInstanceStrings.keySet();
|
oldExclusionInstanceStrings.keySet();
|
||||||
Iterator<String> iterator = oldExclusionInstanceStrings.keySet().iterator();
|
Iterator<String> iterator = oldExclusionInstanceStrings.keySet().iterator();
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
|
@ -248,8 +255,11 @@ public class ResourceExclusionContributor extends RefreshExclusionContributor {
|
||||||
|
|
||||||
deleteButton.addSelectionListener(new SelectionAdapter() {
|
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
|
@Override
|
||||||
public void widgetSelected(SelectionEvent e) {
|
public void widgetSelected(SelectionEvent e) {
|
||||||
|
@ -261,16 +271,16 @@ public class ResourceExclusionContributor extends RefreshExclusionContributor {
|
||||||
String folderToRemove = selected[i];
|
String folderToRemove = selected[i];
|
||||||
ExclusionInstance instanceToRemove = exclusionInstanceStrings.get(folderToRemove);
|
ExclusionInstance instanceToRemove = exclusionInstanceStrings.get(folderToRemove);
|
||||||
|
|
||||||
// Iterator<Object> iterator = selectedFolders.iterator();
|
// Iterator<Object> iterator = selectedFolders.iterator();
|
||||||
|
|
||||||
// while (iterator.hasNext()) {
|
// while (iterator.hasNext()) {
|
||||||
// IPath path = ((IFolder)iterator.next()).getFullPath();
|
// IPath path = ((IFolder)iterator.next()).getFullPath();
|
||||||
// IPath relativePath = path.makeRelativeTo(getResourceRoot(exclusionRoot).getFullPath());
|
// IPath relativePath = path.makeRelativeTo(getResourceRoot(exclusionRoot).getFullPath());
|
||||||
// if (relativePath.toString().compareTo(folderToRemove) == 0) {
|
// if (relativePath.toString().compareTo(folderToRemove) == 0) {
|
||||||
// iterator.remove();
|
// iterator.remove();
|
||||||
// break;
|
// break;
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
exclusion.removeExclusionInstance(instanceToRemove);
|
exclusion.removeExclusionInstance(instanceToRemove);
|
||||||
exclusionInstanceStrings.remove(folderToRemove);
|
exclusionInstanceStrings.remove(folderToRemove);
|
||||||
exclusionInstanceResources.remove(folderToRemove);
|
exclusionInstanceResources.remove(folderToRemove);
|
||||||
|
@ -280,4 +290,11 @@ public class ResourceExclusionContributor extends RefreshExclusionContributor {
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private IResource getResourceRoot(RefreshExclusion exclusion) {
|
||||||
|
if (exclusion.getParentExclusion() != null) {
|
||||||
|
return getResourceRoot(exclusion.getParentExclusion());
|
||||||
|
}
|
||||||
|
return exclusion.getParentResource();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,10 +23,9 @@ import org.eclipse.core.runtime.Platform;
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <strong>EXPERIMENTAL</strong>. This class or interface has been added as
|
* <strong>EXPERIMENTAL</strong>. This class or interface has been added as part of a work in progress. There
|
||||||
* part of a work in progress. There is no guarantee that this API will work or
|
* is no guarantee that this API will work or that it will remain the same. Please do not use this API without
|
||||||
* that it will remain the same. Please do not use this API without consulting
|
* consulting with the CDT team.
|
||||||
* with the CDT team.
|
|
||||||
*
|
*
|
||||||
* @author crecoskie
|
* @author crecoskie
|
||||||
* @since 5.3
|
* @since 5.3
|
||||||
|
@ -36,20 +35,47 @@ public class RefreshExclusionContributionManager {
|
||||||
|
|
||||||
public static final String EXCLUSION_CONTRIBUTOR = "exclusionContributor"; //$NON-NLS-1$
|
public static final String EXCLUSION_CONTRIBUTOR = "exclusionContributor"; //$NON-NLS-1$
|
||||||
public static final String EXTENSION_ID = "RefreshExclusionContributor"; //$NON-NLS-1$
|
public static final String EXTENSION_ID = "RefreshExclusionContributor"; //$NON-NLS-1$
|
||||||
private LinkedHashMap<String, RefreshExclusionContributor> fIDtoContributorsMap;
|
|
||||||
private static RefreshExclusionContributionManager fInstance;
|
private static RefreshExclusionContributionManager fInstance;
|
||||||
|
|
||||||
|
public static synchronized RefreshExclusionContributionManager getInstance() {
|
||||||
|
if (fInstance == null) {
|
||||||
|
fInstance = new RefreshExclusionContributionManager();
|
||||||
|
}
|
||||||
|
|
||||||
|
return fInstance;
|
||||||
|
}
|
||||||
|
|
||||||
|
private LinkedHashMap<String, RefreshExclusionContributor> fIDtoContributorsMap;
|
||||||
|
|
||||||
private RefreshExclusionContributionManager() {
|
private RefreshExclusionContributionManager() {
|
||||||
fIDtoContributorsMap = new LinkedHashMap<String, RefreshExclusionContributor>();
|
fIDtoContributorsMap = new LinkedHashMap<String, RefreshExclusionContributor>();
|
||||||
loadExtensions();
|
loadExtensions();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static synchronized RefreshExclusionContributionManager getInstance() {
|
public RefreshExclusionContributor getContributor(String id) {
|
||||||
if(fInstance == null) {
|
return fIDtoContributorsMap.get(id);
|
||||||
fInstance = new RefreshExclusionContributionManager();
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
return fInstance;
|
else {
|
||||||
|
return new LinkedList<RefreshExclusionContributor>(fIDtoContributorsMap.values());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void loadExtensions() {
|
public synchronized void loadExtensions() {
|
||||||
|
@ -68,7 +94,7 @@ public class RefreshExclusionContributionManager {
|
||||||
String contributorClassName = configElement.getAttribute("class"); //$NON-NLS-1$
|
String contributorClassName = configElement.getAttribute("class"); //$NON-NLS-1$
|
||||||
boolean isTest = false;
|
boolean isTest = false;
|
||||||
String isTestString = configElement.getAttribute("isTest"); //$NON-NLS-1$
|
String isTestString = configElement.getAttribute("isTest"); //$NON-NLS-1$
|
||||||
if(isTestString != null) {
|
if (isTestString != null) {
|
||||||
isTest = Boolean.getBoolean(isTestString);
|
isTest = Boolean.getBoolean(isTestString);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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,10 +15,9 @@ import org.eclipse.swt.widgets.Composite;
|
||||||
import org.eclipse.cdt.core.resources.RefreshExclusion;
|
import org.eclipse.cdt.core.resources.RefreshExclusion;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <strong>EXPERIMENTAL</strong>. This class or interface has been added as
|
* <strong>EXPERIMENTAL</strong>. This class or interface has been added as part of a work in progress. There
|
||||||
* part of a work in progress. There is no guarantee that this API will work or
|
* is no guarantee that this API will work or that it will remain the same. Please do not use this API without
|
||||||
* that it will remain the same. Please do not use this API without consulting
|
* consulting with the CDT team.
|
||||||
* with the CDT team.
|
|
||||||
*
|
*
|
||||||
* @author crecoskie
|
* @author crecoskie
|
||||||
* @since 5.3
|
* @since 5.3
|
||||||
|
@ -27,25 +26,25 @@ import org.eclipse.cdt.core.resources.RefreshExclusion;
|
||||||
public abstract class RefreshExclusionContributor {
|
public abstract class RefreshExclusionContributor {
|
||||||
|
|
||||||
protected String fID;
|
protected String fID;
|
||||||
protected String fName;
|
|
||||||
protected boolean fIsTest;
|
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() {
|
public String getID() {
|
||||||
return fID;
|
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.
|
* Returns the human-readable name of this exclusion type.
|
||||||
*
|
*
|
||||||
|
@ -55,17 +54,20 @@ public abstract class RefreshExclusionContributor {
|
||||||
return fName;
|
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) {
|
public void setName(String name) {
|
||||||
fName = 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