Lines 17-28
Link Here
|
17 |
*******************************************************************************/ |
17 |
*******************************************************************************/ |
18 |
package org.eclipse.core.internal.resources; |
18 |
package org.eclipse.core.internal.resources; |
19 |
|
19 |
|
20 |
import org.eclipse.core.resources.IFile; |
20 |
import org.eclipse.core.runtime.CoreException; |
21 |
import org.eclipse.core.runtime.IProgressMonitor; |
|
|
22 |
|
23 |
import org.eclipse.core.internal.utils.Messages; |
24 |
import org.eclipse.core.internal.utils.Policy; |
25 |
import org.eclipse.core.runtime.OperationCanceledException; |
26 |
|
21 |
|
27 |
import java.net.URI; |
22 |
import java.net.URI; |
28 |
import java.net.URISyntaxException; |
23 |
import java.net.URISyntaxException; |
Lines 716-827
Link Here
|
716 |
* @see IContainer#createFilter(int, IFileInfoMatcherDescription, int, IProgressMonitor) |
711 |
* @see IContainer#createFilter(int, IFileInfoMatcherDescription, int, IProgressMonitor) |
717 |
*/ |
712 |
*/ |
718 |
public IResourceFilterDescription createFilter(int type, IFileInfoMatcherDescription matcherDescription, int updateFlags, IProgressMonitor monitor) throws CoreException { |
713 |
public IResourceFilterDescription createFilter(int type, IFileInfoMatcherDescription matcherDescription, int updateFlags, IProgressMonitor monitor) throws CoreException { |
719 |
Assert.isNotNull(getProject()); |
714 |
// Assert.isNotNull(getProject()); |
720 |
monitor = Policy.monitorFor(monitor); |
715 |
// monitor = Policy.monitorFor(monitor); |
721 |
FilterDescription filter = null; |
716 |
FilterDescription filter = null; |
722 |
try { |
717 |
// try { |
723 |
String message = NLS.bind(Messages.links_creating, getFullPath()); |
718 |
// String message = NLS.bind(Messages.links_creating, getFullPath()); |
724 |
monitor.beginTask(message, Policy.totalWork); |
719 |
// monitor.beginTask(message, Policy.totalWork); |
725 |
Policy.checkCanceled(monitor); |
720 |
// Policy.checkCanceled(monitor); |
726 |
checkValidPath(path, FOLDER | PROJECT, true); |
721 |
// checkValidPath(path, FOLDER | PROJECT, true); |
727 |
final ISchedulingRule rule = workspace.getRuleFactory().createRule(this); |
722 |
// final ISchedulingRule rule = workspace.getRuleFactory().createRule(this); |
728 |
try { |
723 |
// try { |
729 |
workspace.prepareOperation(rule, monitor); |
724 |
// workspace.prepareOperation(rule, monitor); |
730 |
workspace.broadcastEvent(LifecycleEvent.newEvent(LifecycleEvent.PRE_FILTER_ADD, this)); |
725 |
// workspace.broadcastEvent(LifecycleEvent.newEvent(LifecycleEvent.PRE_FILTER_ADD, this)); |
731 |
workspace.beginOperation(true); |
726 |
// workspace.beginOperation(true); |
732 |
monitor.worked(Policy.opWork * 5 / 100); |
727 |
// monitor.worked(Policy.opWork * 5 / 100); |
733 |
//save the filter in the project description |
728 |
//save the filter in the project description |
734 |
filter = new FilterDescription(this, type, matcherDescription); |
729 |
filter = new FilterDescription(this, type, matcherDescription); |
735 |
filter.setId(System.currentTimeMillis()); |
730 |
// filter.setId(System.currentTimeMillis()); |
736 |
|
731 |
|
737 |
Project project = (Project) getProject(); |
732 |
// Project project = (Project) getProject(); |
738 |
project.internalGetDescription().addFilter(getProjectRelativePath(), filter); |
733 |
// project.internalGetDescription().addFilter(getProjectRelativePath(), filter); |
739 |
project.writeDescription(IResource.NONE); |
734 |
// project.writeDescription(IResource.NONE); |
740 |
monitor.worked(Policy.opWork * 5 / 100); |
735 |
// monitor.worked(Policy.opWork * 5 / 100); |
741 |
|
736 |
|
742 |
//refresh to discover any new resources below this folder |
737 |
IMarker filterMarker = createMarker("org.eclipse.core.resources.filtermarker"); //$NON-NLS-1$ |
743 |
if (getType() != IResource.FILE) { |
738 |
filterMarker.setAttribute("type", new Integer(type)); //$NON-NLS-1$ |
744 |
//refresh either in background or foreground |
739 |
filterMarker.setAttribute("matcherDescription", matcherDescription); //$NON-NLS-1$ |
745 |
if ((updateFlags & IResource.BACKGROUND_REFRESH) != 0) { |
740 |
filter.setId(filterMarker.getId()); |
746 |
workspace.refreshManager.refresh(this); |
741 |
|
747 |
monitor.worked(Policy.opWork * 90 / 100); |
742 |
//refresh to discover any new resources below this folder |
748 |
} else { |
743 |
if (getType() != IResource.FILE) { |
749 |
refreshLocal(DEPTH_INFINITE, Policy.subMonitorFor(monitor, Policy.opWork * 90 / 100)); |
744 |
//refresh either in background or foreground |
750 |
} |
745 |
if ((updateFlags & IResource.BACKGROUND_REFRESH) != 0) { |
751 |
} else |
746 |
workspace.refreshManager.refresh(this); |
752 |
monitor.worked(Policy.opWork * 90 / 100); |
747 |
// monitor.worked(Policy.opWork * 90 / 100); |
753 |
} catch (OperationCanceledException e) { |
748 |
} else { |
754 |
workspace.getWorkManager().operationCanceled(); |
749 |
refreshLocal(DEPTH_INFINITE, null/*Policy.subMonitorFor(monitor, Policy.opWork * 90 / 100)*/); |
755 |
throw e; |
750 |
} |
756 |
} finally { |
751 |
} |
757 |
workspace.endOperation(rule, true, Policy.subMonitorFor(monitor, Policy.endOpWork)); |
752 |
// } else |
758 |
} |
753 |
// monitor.worked(Policy.opWork * 90 / 100); |
759 |
} finally { |
754 |
// } catch (OperationCanceledException e) { |
760 |
monitor.done(); |
755 |
|
761 |
} |
756 |
// workspace.getWorkManager().operationCanceled(); |
|
|
757 |
// throw e; |
758 |
// } finally { |
759 |
// workspace.endOperation(rule, true, Policy.subMonitorFor(monitor, Policy.endOpWork)); |
760 |
// } |
761 |
// } finally { |
762 |
// monitor.done(); |
763 |
// } |
762 |
return filter; |
764 |
return filter; |
763 |
} |
765 |
} |
764 |
|
766 |
|
765 |
public void removeFilter(IResourceFilterDescription filterDescription, int updateFlags, IProgressMonitor monitor) throws CoreException { |
767 |
public void removeFilter(IResourceFilterDescription filterDescription, int updateFlags, IProgressMonitor monitor) throws CoreException { |
766 |
monitor = Policy.monitorFor(monitor); |
768 |
// monitor = Policy.monitorFor(monitor); |
767 |
try { |
769 |
// try { |
768 |
String message = NLS.bind(Messages.links_creating, getFullPath()); |
770 |
// String message = NLS.bind(Messages.links_creating, getFullPath()); |
769 |
monitor.beginTask(message, Policy.totalWork); |
771 |
// monitor.beginTask(message, Policy.totalWork); |
770 |
Policy.checkCanceled(monitor); |
772 |
// Policy.checkCanceled(monitor); |
771 |
checkValidPath(path, FOLDER | PROJECT, true); |
773 |
// checkValidPath(path, FOLDER | PROJECT, true); |
772 |
final ISchedulingRule rule = workspace.getRuleFactory().createRule(this); |
774 |
// final ISchedulingRule rule = workspace.getRuleFactory().createRule(this); |
773 |
try { |
775 |
// try { |
774 |
workspace.prepareOperation(rule, monitor); |
776 |
// workspace.prepareOperation(rule, monitor); |
775 |
workspace.broadcastEvent(LifecycleEvent.newEvent(LifecycleEvent.PRE_FILTER_REMOVE, this)); |
777 |
// workspace.broadcastEvent(LifecycleEvent.newEvent(LifecycleEvent.PRE_FILTER_REMOVE, this)); |
776 |
workspace.beginOperation(true); |
778 |
// workspace.beginOperation(true); |
777 |
monitor.worked(Policy.opWork * 5 / 100); |
779 |
// monitor.worked(Policy.opWork * 5 / 100); |
778 |
//save the filter in the project description |
780 |
// //save the filter in the project description |
779 |
Project project = (Project) getProject(); |
781 |
// Project project = (Project) getProject(); |
780 |
project.internalGetDescription().removeFilter(getProjectRelativePath(), (FilterDescription)filterDescription); |
782 |
// project.internalGetDescription().removeFilter(getProjectRelativePath(), (FilterDescription)filterDescription); |
781 |
project.writeDescription(IResource.NONE); |
783 |
// project.writeDescription(IResource.NONE); |
782 |
monitor.worked(Policy.opWork * 5 / 100); |
784 |
// monitor.worked(Policy.opWork * 5 / 100); |
783 |
|
785 |
|
784 |
//refresh to discover any new resources below this linked location |
786 |
IMarker filterMarker = findMarker(((FilterDescription) filterDescription).getId()); |
785 |
if (getType() != IResource.FILE) { |
787 |
filterMarker.delete(); |
786 |
//refresh either in background or foreground |
788 |
|
787 |
if ((updateFlags & IResource.BACKGROUND_REFRESH) != 0) { |
789 |
// //refresh to discover any new resources below this linked location |
788 |
workspace.refreshManager.refresh(this); |
790 |
if (getType() != IResource.FILE) { |
789 |
monitor.worked(Policy.opWork * 90 / 100); |
791 |
//refresh either in background or foreground |
790 |
} else { |
792 |
if ((updateFlags & IResource.BACKGROUND_REFRESH) != 0) { |
791 |
refreshLocal(DEPTH_INFINITE, Policy.subMonitorFor(monitor, Policy.opWork * 90 / 100)); |
793 |
workspace.refreshManager.refresh(this); |
792 |
} |
794 |
// monitor.worked(Policy.opWork * 90 / 100); |
793 |
} else |
795 |
} else { |
794 |
monitor.worked(Policy.opWork * 90 / 100); |
796 |
refreshLocal(DEPTH_INFINITE, null /*Policy.subMonitorFor(monitor, Policy.opWork * 90 / 100)*/); |
795 |
} catch (OperationCanceledException e) { |
797 |
} |
796 |
workspace.getWorkManager().operationCanceled(); |
798 |
} |
797 |
throw e; |
799 |
// } else |
798 |
} finally { |
800 |
// monitor.worked(Policy.opWork * 90 / 100); |
799 |
workspace.endOperation(rule, true, Policy.subMonitorFor(monitor, Policy.endOpWork)); |
801 |
// } catch (OperationCanceledException e) { |
800 |
} |
802 |
// workspace.getWorkManager().operationCanceled(); |
801 |
} finally { |
803 |
// throw e; |
802 |
monitor.done(); |
804 |
// } finally { |
803 |
} |
805 |
// workspace.endOperation(rule, true, Policy.subMonitorFor(monitor, Policy.endOpWork)); |
|
|
806 |
// } |
807 |
// } finally { |
808 |
// monitor.done(); |
809 |
// } |
804 |
} |
810 |
} |
805 |
|
811 |
|
806 |
/* (non-Javadoc) |
812 |
/* (non-Javadoc) |
807 |
* @see org.eclipse.core.resources.IContainer#getFilters() |
813 |
* @see org.eclipse.core.resources.IContainer#getFilters() |
808 |
*/ |
814 |
*/ |
809 |
public IResourceFilterDescription[] getFilters() throws CoreException { |
815 |
public IResourceFilterDescription[] getFilters() throws CoreException { |
810 |
IResourceFilterDescription[] results = null; |
816 |
IMarker[] filterMarkers = findMarkers("org.eclipse.core.resources.filtermarker", false, IResource.DEPTH_ZERO); //$NON-NLS-1$ |
811 |
checkValidPath(path, FOLDER | PROJECT, true); |
817 |
|
812 |
Project project = (Project) getProject(); |
818 |
FilterDescription[] filterDescriptions = new FilterDescription[filterMarkers.length]; |
813 |
ProjectDescription desc = project.internalGetDescription(); |
819 |
|
814 |
if (desc != null) { |
820 |
for (int i = 0; i < filterMarkers.length; i++) { |
815 |
LinkedList/*<FilterDescription>*/ list = desc.getFilter(getProjectRelativePath()); |
821 |
FilterDescription filterDescription = new FilterDescription(this, ((Integer) filterMarkers[i].getAttribute("type")).intValue(), //$NON-NLS-1$ |
816 |
if (list != null) { |
822 |
(FileInfoMatcherDescription) filterMarkers[i].getAttribute("matcherDescription")); //$NON-NLS-1$ |
817 |
results = new IResourceFilterDescription[list.size()]; |
823 |
filterDescription.setId(filterMarkers[i].getId()); |
818 |
for (int i = 0; i < list.size(); i++) { |
824 |
filterDescriptions[i] = filterDescription; |
819 |
results[i] = (FilterDescription) list.get(i); |
|
|
820 |
} |
821 |
return results; |
822 |
} |
823 |
} |
825 |
} |
824 |
return new IResourceFilterDescription[0]; |
826 |
|
|
|
827 |
return filterDescriptions; |
828 |
|
829 |
// IResourceFilterDescription[] results = null; |
830 |
// checkValidPath(path, FOLDER | PROJECT, true); |
831 |
// Project project = (Project) getProject(); |
832 |
// ProjectDescription desc = project.internalGetDescription(); |
833 |
// if (desc != null) { |
834 |
// LinkedList/*<FilterDescription>*/ list = desc.getFilter(getProjectRelativePath()); |
835 |
// if (list != null) { |
836 |
// results = new IResourceFilterDescription[list.size()]; |
837 |
// for (int i = 0; i < list.size(); i++) { |
838 |
// results[i] = (FilterDescription) list.get(i); |
839 |
// } |
840 |
// return results; |
841 |
// } |
842 |
// } |
843 |
// return new IResourceFilterDescription[0]; |
825 |
} |
844 |
} |
826 |
|
845 |
|
827 |
/* (non-Javadoc) |
846 |
/* (non-Javadoc) |
Lines 991-1008
Link Here
|
991 |
} |
1010 |
} |
992 |
} |
1011 |
} |
993 |
|
1012 |
|
994 |
List filters = findFilters(); |
1013 |
// List filters = findFilters(); |
995 |
if ((filters != null) && (filters.size() > 0)) { |
1014 |
// if ((filters != null) && (filters.size() > 0)) { |
996 |
// delete resource filters |
1015 |
// // delete resource filters |
997 |
Project project = (Project) getProject(); |
1016 |
// Project project = (Project) getProject(); |
998 |
ProjectDescription description = project.internalGetDescription(); |
1017 |
// ProjectDescription description = project.internalGetDescription(); |
999 |
if (description != null) { |
1018 |
// if (description != null) { |
1000 |
for (Iterator it = filters.iterator(); it.hasNext();) |
1019 |
// for (Iterator it = filters.iterator(); it.hasNext();) |
1001 |
description.setFilters(((IResource) it.next()).getProjectRelativePath(), null); |
1020 |
// description.setFilters(((IResource) it.next()).getProjectRelativePath(), null); |
1002 |
project.internalSetDescription(description, true); |
1021 |
// project.internalSetDescription(description, true); |
1003 |
project.writeDescription(IResource.FORCE); |
1022 |
// project.writeDescription(IResource.FORCE); |
1004 |
} |
1023 |
// } |
1005 |
} |
1024 |
// } |
1006 |
|
1025 |
|
1007 |
// Delete properties after the resource is deleted from the tree. See bug 84584. |
1026 |
// Delete properties after the resource is deleted from the tree. See bug 84584. |
1008 |
CoreException err = null; |
1027 |
CoreException err = null; |
Lines 1046-1071
Link Here
|
1046 |
* Returns a list of all filtered resources at or below this resource, or null if there |
1065 |
* Returns a list of all filtered resources at or below this resource, or null if there |
1047 |
* are no links. |
1066 |
* are no links. |
1048 |
*/ |
1067 |
*/ |
1049 |
private List findFilters() { |
1068 |
// private List findFilters() { |
1050 |
Project project = (Project) getProject(); |
1069 |
// Project project = (Project) getProject(); |
1051 |
ProjectDescription description = project.internalGetDescription(); |
1070 |
// ProjectDescription description = project.internalGetDescription(); |
1052 |
List filters = null; |
1071 |
// List filters = null; |
1053 |
if (description != null) { |
1072 |
// if (description != null) { |
1054 |
HashMap filterMap = description.getFilters(); |
1073 |
// HashMap filterMap = description.getFilters(); |
1055 |
if (filterMap != null) { |
1074 |
// if (filterMap != null) { |
1056 |
IPath myPath = getProjectRelativePath(); |
1075 |
// IPath myPath = getProjectRelativePath(); |
1057 |
for (Iterator it = filterMap.keySet().iterator(); it.hasNext();) { |
1076 |
// for (Iterator it = filterMap.keySet().iterator(); it.hasNext();) { |
1058 |
IPath filterPath = (IPath) it.next(); |
1077 |
// IPath filterPath = (IPath) it.next(); |
1059 |
if (myPath.isPrefixOf(filterPath)) { |
1078 |
// if (myPath.isPrefixOf(filterPath)) { |
1060 |
if (filters == null) |
1079 |
// if (filters == null) |
1061 |
filters = new ArrayList(); |
1080 |
// filters = new ArrayList(); |
1062 |
filters.add(workspace.newResource(project.getFullPath().append(filterPath), IResource.FOLDER)); |
1081 |
// filters.add(workspace.newResource(project.getFullPath().append(filterPath), IResource.FOLDER)); |
1063 |
} |
1082 |
// } |
1064 |
} |
1083 |
// } |
1065 |
} |
1084 |
// } |
1066 |
} |
1085 |
// } |
1067 |
return filters; |
1086 |
// return filters; |
1068 |
} |
1087 |
// } |
1069 |
|
1088 |
|
1070 |
/* (non-Javadoc) |
1089 |
/* (non-Javadoc) |
1071 |
* @see IResource#equals(Object) |
1090 |
* @see IResource#equals(Object) |
Lines 1169-1183
Link Here
|
1169 |
project.writeDescription(IResource.NONE); |
1188 |
project.writeDescription(IResource.NONE); |
1170 |
} |
1189 |
} |
1171 |
|
1190 |
|
1172 |
List filters = findFilters(); |
1191 |
// List filters = findFilters(); |
1173 |
if ((filters != null) && (filters.size() > 0)) { |
1192 |
// if ((filters != null) && (filters.size() > 0)) { |
1174 |
// delete resource filters |
1193 |
// // delete resource filters |
1175 |
Project project = (Project) getProject(); |
1194 |
// Project project = (Project) getProject(); |
1176 |
ProjectDescription description = project.internalGetDescription(); |
1195 |
// ProjectDescription description = project.internalGetDescription(); |
1177 |
for (Iterator it = filters.iterator(); it.hasNext();) |
1196 |
// for (Iterator it = filters.iterator(); it.hasNext();) |
1178 |
description.setFilters(((IResource) it.next()).getProjectRelativePath(), null); |
1197 |
// description.setFilters(((IResource) it.next()).getProjectRelativePath(), null); |
1179 |
project.writeDescription(IResource.NONE); |
1198 |
// project.writeDescription(IResource.NONE); |
1180 |
} |
1199 |
// } |
1181 |
|
1200 |
|
1182 |
// check if we deleted a preferences file |
1201 |
// check if we deleted a preferences file |
1183 |
ProjectPreferences.deleted(this); |
1202 |
ProjectPreferences.deleted(this); |
Lines 1552-1560
Link Here
|
1552 |
ProjectDescription desc = ((Project) project).internalGetDescription(); |
1571 |
ProjectDescription desc = ((Project) project).internalGetDescription(); |
1553 |
if (desc == null) |
1572 |
if (desc == null) |
1554 |
return false; |
1573 |
return false; |
1555 |
LinkedList/*<FilterDescription>*/ filters = desc.getFilter(getProjectRelativePath()); |
1574 |
LinkedList filters; |
1556 |
if ((filters != null) && (filters.size() > 0)) |
1575 |
try { |
1557 |
return true; |
1576 |
filters = new LinkedList(Arrays.asList(getFilters())) /*desc.getFilter(getProjectRelativePath())*/; |
|
|
1577 |
if ((filters != null) && (filters.size() > 0)) |
1578 |
return true; |
1579 |
} catch (CoreException e) { |
1580 |
// TODO Auto-generated catch block |
1581 |
e.printStackTrace(); |
1582 |
} |
1583 |
|
1558 |
return false; |
1584 |
return false; |
1559 |
} |
1585 |
} |
1560 |
|
1586 |
|
Lines 2182-2188
Link Here
|
2182 |
LinkedList/*<Filter>*/currentExcludeFilters = new LinkedList/*<FilterDescription>*/(); |
2208 |
LinkedList/*<Filter>*/currentExcludeFilters = new LinkedList/*<FilterDescription>*/(); |
2183 |
LinkedList/*<FilterDescription>*/filters = null; |
2209 |
LinkedList/*<FilterDescription>*/filters = null; |
2184 |
if (project.internalGetDescription() != null) { |
2210 |
if (project.internalGetDescription() != null) { |
2185 |
filters = project.internalGetDescription().getFilter(relativePath); |
2211 |
try { |
|
|
2212 |
filters = new LinkedList(Arrays.asList(getFilters())); |
2213 |
} catch (CoreException e) { |
2214 |
// TODO Auto-generated catch block |
2215 |
e.printStackTrace(); |
2216 |
} |
2217 |
|
2186 |
if (filters != null) { |
2218 |
if (filters != null) { |
2187 |
Iterator/*FilterDescription*/it = filters.iterator(); |
2219 |
Iterator/*FilterDescription*/it = filters.iterator(); |
2188 |
while (it.hasNext()) { |
2220 |
while (it.hasNext()) { |
Lines 2204-2210
Link Here
|
2204 |
// verify inherited filters |
2236 |
// verify inherited filters |
2205 |
while (relativePath.segmentCount() > 0) { |
2237 |
while (relativePath.segmentCount() > 0) { |
2206 |
relativePath = relativePath.removeLastSegments(1); |
2238 |
relativePath = relativePath.removeLastSegments(1); |
2207 |
filters = project.internalGetDescription().getFilter(relativePath); |
2239 |
try { |
|
|
2240 |
filters = new LinkedList(Arrays.asList(getFilters())); |
2241 |
} catch (CoreException e) { |
2242 |
// TODO Auto-generated catch block |
2243 |
e.printStackTrace(); |
2244 |
} |
2208 |
if (filters != null) { |
2245 |
if (filters != null) { |
2209 |
Iterator/*FilterDescription*/it = filters.iterator(); |
2246 |
Iterator/*FilterDescription*/it = filters.iterator(); |
2210 |
while (it.hasNext()) { |
2247 |
while (it.hasNext()) { |