Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 291755 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/core/internal/resources/Filter.java (-1 / +2 lines)
Lines 7-12 Link Here
7
 * 
7
 * 
8
 * Contributors:
8
 * Contributors:
9
 *     Serge Beauchamp (Freescale Semiconductor) - initial API and implementation
9
 *     Serge Beauchamp (Freescale Semiconductor) - initial API and implementation
10
 *     IBM Corporation - ongoing implementation
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.core.internal.resources;
12
package org.eclipse.core.internal.resources;
12
13
Lines 64-70 Link Here
64
		return false;
65
		return false;
65
	}
66
	}
66
67
67
	public String getArguments() {
68
	public Object getArguments() {
68
		return description.getArguments();
69
		return description.getArguments();
69
	}
70
	}
70
71
(-)src/org/eclipse/core/internal/resources/FilterDescription.java (-16 / +21 lines)
Lines 7-33 Link Here
7
 * 
7
 * 
8
 * Contributors:
8
 * Contributors:
9
 *     Serge Beauchamp (Freescale Semiconductor) - initial API and implementation
9
 *     Serge Beauchamp (Freescale Semiconductor) - initial API and implementation
10
 *     IBM Corporation - ongoing implementation
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.core.internal.resources;
12
package org.eclipse.core.internal.resources;
12
13
13
import java.util.Iterator;
14
import java.util.Iterator;
14
15
import java.util.LinkedList;
15
import java.util.LinkedList;
16
import org.eclipse.core.runtime.IPath;
16
import org.eclipse.core.resources.*;
17
18
import org.eclipse.core.resources.IResourceFilter;
19
20
import org.eclipse.core.resources.IResource;
21
import org.eclipse.core.runtime.*;
17
import org.eclipse.core.runtime.*;
22
18
23
/**
19
/**
24
 * Class for describing the characteristics of filters that are stored
20
 * Class for describing the characteristics of filters that are stored
25
 * in the project description.
21
 * in the project description.
26
 */
22
 */
27
public class FilterDescription implements Comparable {
23
public class FilterDescription implements Comparable, IResourceFilter {
28
24
29
	private String id;
25
	private String id;
30
	private String arguments;
26
	private Object arguments;
31
27
32
	/**
28
	/**
33
	 * The project relative path.
29
	 * The project relative path.
Lines 45-51 Link Here
45
		this.arguments = null;
41
		this.arguments = null;
46
	}
42
	}
47
43
48
	public FilterDescription(IResource resource, int type, String filterID, String arguments) {
44
	public FilterDescription(IResource resource, int type, String filterID, Object arguments) {
49
		super();
45
		super();
50
		Assert.isNotNull(resource);
46
		Assert.isNotNull(resource);
51
		Assert.isNotNull(filterID);
47
		Assert.isNotNull(filterID);
Lines 55-61 Link Here
55
		this.arguments = arguments;
51
		this.arguments = arguments;
56
	}
52
	}
57
53
58
	public FilterDescription(IPath projectRelativePath, int type, String filterID, String arguments) {
54
	private FilterDescription(IPath projectRelativePath, int type, String filterID, Object arguments) {
59
		super();
55
		super();
60
		Assert.isNotNull(projectRelativePath);
56
		Assert.isNotNull(projectRelativePath);
61
		Assert.isNotNull(filterID);
57
		Assert.isNotNull(filterID);
Lines 69-85 Link Here
69
		if (!(o.getClass() == FilterDescription.class))
65
		if (!(o.getClass() == FilterDescription.class))
70
			return false;
66
			return false;
71
		FilterDescription other = (FilterDescription) o;
67
		FilterDescription other = (FilterDescription) o;
72
		return path.equals(other.path) && 
68
		return path.equals(other.path) && type == other.type && id.equals(other.id) && ((arguments == null) ? (arguments == other.arguments) : (arguments.equals(other.arguments)));
73
				type == other.type &&
74
				id.equals(other.id)&&
75
				((arguments == null) ? (arguments == other.arguments) : (arguments.equals(other.arguments)));
76
	}
69
	}
77
70
78
	public String getFilterID() {
71
	public String getFilterID() {
79
		return id;
72
		return id;
80
	}
73
	}
81
74
82
	public String getArguments() {
75
	public Object getArguments() {
83
		return arguments;
76
		return arguments;
84
	}
77
	}
85
78
Lines 103-109 Link Here
103
		this.id = id;
96
		this.id = id;
104
	}
97
	}
105
98
106
	public void setArguments(String arguments) {
99
	public void setArguments(Object arguments) {
107
		this.arguments = arguments;
100
		this.arguments = arguments;
108
	}
101
	}
109
102
Lines 148-151 Link Here
148
		}
141
		}
149
		return copy;
142
		return copy;
150
	}
143
	}
144
145
	public String getId() {
146
		return id;
147
	}
148
149
	public IPath getPath() {
150
		return path;
151
	}
152
153
	public IProject getProject() {
154
		return null;
155
	}
151
}
156
}
(-)src/org/eclipse/core/internal/resources/ModelObjectWriter.java (-26 / +35 lines)
Lines 20-27 Link Here
20
import org.eclipse.core.internal.events.BuildCommand;
20
import org.eclipse.core.internal.events.BuildCommand;
21
import org.eclipse.core.internal.localstore.SafeFileOutputStream;
21
import org.eclipse.core.internal.localstore.SafeFileOutputStream;
22
import org.eclipse.core.internal.utils.FileUtil;
22
import org.eclipse.core.internal.utils.FileUtil;
23
import org.eclipse.core.resources.IProject;
23
import org.eclipse.core.resources.*;
24
import org.eclipse.core.resources.IncrementalProjectBuilder;
25
import org.eclipse.core.runtime.IPath;
24
import org.eclipse.core.runtime.IPath;
26
25
27
//
26
//
Lines 76-85 Link Here
76
		//cases to avoid dirtying .project files unnecessarily.	
75
		//cases to avoid dirtying .project files unnecessarily.	
77
		if (!command.isConfigurable())
76
		if (!command.isConfigurable())
78
			return false;
77
			return false;
79
		return !command.isBuilding(IncrementalProjectBuilder.AUTO_BUILD) || 
78
		return !command.isBuilding(IncrementalProjectBuilder.AUTO_BUILD) || !command.isBuilding(IncrementalProjectBuilder.CLEAN_BUILD) || !command.isBuilding(IncrementalProjectBuilder.FULL_BUILD) || !command.isBuilding(IncrementalProjectBuilder.INCREMENTAL_BUILD);
80
			!command.isBuilding(IncrementalProjectBuilder.CLEAN_BUILD) || 
81
			!command.isBuilding(IncrementalProjectBuilder.FULL_BUILD) || 
82
			!command.isBuilding(IncrementalProjectBuilder.INCREMENTAL_BUILD);
83
	}
79
	}
84
80
85
	protected void write(LinkDescription description, XMLWriter writer) {
81
	protected void write(LinkDescription description, XMLWriter writer) {
Lines 93-106 Link Here
93
		writer.endTag(LINK);
89
		writer.endTag(LINK);
94
	}
90
	}
95
91
96
	protected void write(FilterDescription description, XMLWriter writer) {
92
	protected void write(IResourceFilter description, XMLWriter writer) {
97
		writer.startTag(FILTER, null);
93
		writer.startTag(FILTER, null);
98
		if (description != null) {
94
		if (description != null) {
99
			writer.printSimpleTag(NAME, description.getProjectRelativePath());
95
			writer.printSimpleTag(NAME, description.getPath());
100
			writer.printSimpleTag(TYPE, Integer.toString(description.getType()));
96
			writer.printSimpleTag(TYPE, Integer.toString(description.getType()));
101
			writer.printSimpleTag(ID, description.getFilterID());
97
			writer.printSimpleTag(ID, description.getId());
102
			if (description.getArguments() != null)
98
			if (description.getArguments() != null) {
103
				writer.printSimpleTag(ARGUMENTS, description.getArguments());
99
				if (description.getArguments() instanceof String) {
100
					writer.printSimpleTag(ARGUMENTS, description.getArguments());
101
				} else if (description.getArguments() instanceof IResourceFilter[]) {
102
					writer.startTag(ARGUMENTS, null);
103
					IResourceFilter[] array = (IResourceFilter[]) description.getArguments();
104
					for (int i = 0; i < array.length; i++) {
105
						write(array[i], writer);
106
					}
107
					writer.endTag(ARGUMENTS);
108
				} else
109
					writer.printSimpleTag(ARGUMENTS, ""); //$NON-NLS-1$
110
111
			}
112
104
		}
113
		}
105
		writer.endTag(FILTER);
114
		writer.endTag(FILTER);
106
	}
115
	}
Lines 176-183 Link Here
176
			write((LinkDescription) obj, writer);
185
			write((LinkDescription) obj, writer);
177
			return;
186
			return;
178
		}
187
		}
179
		if (obj instanceof FilterDescription) {
188
		if (obj instanceof IResourceFilter) {
180
			write((FilterDescription) obj, writer);
189
			write((IResourceFilter) obj, writer);
181
			return;
190
			return;
182
		}
191
		}
183
		if (obj instanceof VariableDescription) {
192
		if (obj instanceof VariableDescription) {
Lines 237-255 Link Here
237
	protected void write(String name, Map table, XMLWriter writer) {
246
	protected void write(String name, Map table, XMLWriter writer) {
238
		writer.startTag(name, null);
247
		writer.startTag(name, null);
239
		if (table != null) {
248
		if (table != null) {
240
		// ensure consistent order of map elements
249
			// ensure consistent order of map elements
241
		List sorted = new ArrayList(table.keySet());
250
			List sorted = new ArrayList(table.keySet());
242
		Collections.sort(sorted);
251
			Collections.sort(sorted);
243
		
252
244
		for (Iterator it = sorted.iterator(); it.hasNext();) {
253
			for (Iterator it = sorted.iterator(); it.hasNext();) {
245
			String key = (String) it.next();
254
				String key = (String) it.next();
246
			Object value = table.get(key);
255
				Object value = table.get(key);
247
			writer.startTag(DICTIONARY, null);
256
				writer.startTag(DICTIONARY, null);
248
			{
257
				{
249
				writer.printSimpleTag(KEY, key);
258
					writer.printSimpleTag(KEY, key);
250
				writer.printSimpleTag(VALUE, value);
259
					writer.printSimpleTag(VALUE, value);
251
			}
260
				}
252
			writer.endTag(DICTIONARY);
261
				writer.endTag(DICTIONARY);
253
			}
262
			}
254
		}
263
		}
255
		writer.endTag(name);
264
		writer.endTag(name);
(-)src/org/eclipse/core/internal/resources/ProjectDescriptionReader.java (-12 / +33 lines)
Lines 474-480 Link Here
474
	 */
474
	 */
475
	private void endFilterElement(String elementName) {
475
	private void endFilterElement(String elementName) {
476
		if (elementName.equals(FILTER)) {
476
		if (elementName.equals(FILTER)) {
477
			state = S_FILTERED_RESOURCES;
478
			// Pop off the filter description
477
			// Pop off the filter description
479
			FilterDescription filter = (FilterDescription) objectStack.pop();
478
			FilterDescription filter = (FilterDescription) objectStack.pop();
480
			// Make sure that you have something reasonable
479
			// Make sure that you have something reasonable
Lines 495-508 Link Here
495
				return;
494
				return;
496
			}
495
			}
497
496
498
			// The HashMap of filtered resources is the next thing on the stack
497
			if (objectStack.peek() instanceof HashMap) {
499
			HashMap map = ((HashMap) objectStack.peek());
498
				state = S_FILTERED_RESOURCES;
500
			LinkedList/*FilterDescription*/ list = (LinkedList/*FilterDescription*/) map.get(filter.getProjectRelativePath());
499
				// The HashMap of filtered resources is the next thing on the stack
501
			if (list == null) {
500
				HashMap map = ((HashMap) objectStack.peek());
502
				list = new LinkedList/*FilterDescription*/();
501
				LinkedList/*FilterDescription*/list = (LinkedList/*FilterDescription*/) map.get(filter.getProjectRelativePath());
503
				map.put(filter.getProjectRelativePath(), list);
502
				if (list == null) {
503
					list = new LinkedList/*FilterDescription*/();
504
					map.put(filter.getProjectRelativePath(), list);
505
				}
506
				list.add(filter);
507
			}
508
			
509
			if (objectStack.peek() instanceof ArrayList) {
510
				state = S_FILTER_ARGUMENTS;
511
				ArrayList l = ((ArrayList) objectStack.peek());
512
				l.add(filter);
504
			}
513
			}
505
			list.add(filter);
506
		}
514
		}
507
	}
515
	}
508
516
Lines 603-611 Link Here
603
611
604
	private void endFilterArguments(String elementName) {
612
	private void endFilterArguments(String elementName) {
605
		if (elementName.equals(ARGUMENTS)) {
613
		if (elementName.equals(ARGUMENTS)) {
606
			String newArguments = charBuffer.toString();
614
			ArrayList filters = (ArrayList) objectStack.pop();
607
			// objectStack has a FilterDescription on it. Set the type on this FilterDescription.
615
			Object newArguments = charBuffer.toString();
608
			String oldArguments = ((FilterDescription) objectStack.peek()).getArguments();
616
			
617
			if (filters.size() > 0)
618
				newArguments = filters.toArray(new IResourceFilter[filters.size()]);
619
			
620
			Object oldArguments = ((FilterDescription) objectStack.peek()).getArguments();
609
			if (oldArguments != null) {
621
			if (oldArguments != null) {
610
				parseProblem(NLS.bind(Messages.projRead_badArguments, oldArguments, newArguments));
622
				parseProblem(NLS.bind(Messages.projRead_badArguments, oldArguments, newArguments));
611
			} else
623
			} else
Lines 958-964 Link Here
958
			case S_FILTERED_RESOURCES :
970
			case S_FILTERED_RESOURCES :
959
				if (elementName.equals(FILTER)) {
971
				if (elementName.equals(FILTER)) {
960
					state = S_FILTER;
972
					state = S_FILTER;
961
					// Push place holders for the name, type, id and argumkents of
973
					// Push place holders for the name, type, id and arguments of
962
					// this filter.
974
					// this filter.
963
					objectStack.push(new FilterDescription());
975
					objectStack.push(new FilterDescription());
964
				}
976
				}
Lines 972-977 Link Here
972
					state = S_FILTER_ID;
984
					state = S_FILTER_ID;
973
				} else if (elementName.equals(ARGUMENTS)) {
985
				} else if (elementName.equals(ARGUMENTS)) {
974
					state = S_FILTER_ARGUMENTS;
986
					state = S_FILTER_ARGUMENTS;
987
					objectStack.push(new ArrayList());
988
				}
989
				break;
990
			case S_FILTER_ARGUMENTS:
991
				if (elementName.equals(FILTER)) {
992
					state = S_FILTER;
993
					// Push place holders for the name, type, id and arguments of
994
					// this filter.
995
					objectStack.push(new FilterDescription());
975
				}
996
				}
976
				break;
997
				break;
977
			case S_VARIABLE:
998
			case S_VARIABLE:
(-)src/org/eclipse/core/internal/resources/RegexFilterFactory.java (-2 / +2 lines)
Lines 38-44 Link Here
38
		}
38
		}
39
	}
39
	}
40
40
41
	public IFileInfoFilter instantiate(IProject project, String arguments) {
41
	public IFileInfoFilter instantiate(IProject project, Object arguments) {
42
		return new RegexFilterType(project, arguments);
42
		return new RegexFilterType(project, (String)arguments);
43
	}
43
	}
44
}
44
}
(-)src/org/eclipse/core/internal/resources/Resource.java (-4 / +4 lines)
Lines 707-715 Link Here
707
707
708
708
709
	/* (non-Javadoc)
709
	/* (non-Javadoc)
710
	 * @see org.eclipse.core.resources.IContainer#addFilter(String, int, String, IProgressMonitor)
710
	 * @see org.eclipse.core.resources.IContainer#addFilter(String, int, Object, IProgressMonitor)
711
	 */
711
	 */
712
	public void addFilter(String filterID, int type, String arguments, int updateFlags, IProgressMonitor monitor) throws CoreException {
712
	public void addFilter(String filterID, int type, Object arguments, int updateFlags, IProgressMonitor monitor) throws CoreException {
713
		Assert.isNotNull(filterID);
713
		Assert.isNotNull(filterID);
714
		Assert.isNotNull(getProject());
714
		Assert.isNotNull(getProject());
715
		monitor = Policy.monitorFor(monitor);
715
		monitor = Policy.monitorFor(monitor);
Lines 754-762 Link Here
754
	}
754
	}
755
755
756
	/* (non-Javadoc)
756
	/* (non-Javadoc)
757
	 * @see org.eclipse.core.resources.IFolder#removeFilter(String, int, String, IProgressMonitor)
757
	 * @see org.eclipse.core.resources.IFolder#removeFilter(String, int, Object, IProgressMonitor)
758
	 */
758
	 */
759
	public void removeFilter(String filterID, int type, String arguments, int updateFlags, IProgressMonitor monitor) throws CoreException {
759
	public void removeFilter(String filterID, int type, Object arguments, int updateFlags, IProgressMonitor monitor) throws CoreException {
760
		Assert.isNotNull(filterID);
760
		Assert.isNotNull(filterID);
761
		monitor = Policy.monitorFor(monitor);
761
		monitor = Policy.monitorFor(monitor);
762
		try {
762
		try {
(-)src/org/eclipse/core/resources/IContainer.java (-6 / +6 lines)
Lines 484-495 Link Here
484
	 * @exception OperationCanceledException if the operation is canceled. 
484
	 * @exception OperationCanceledException if the operation is canceled. 
485
	 * Cancelation can occur even if no progress monitor is provided.
485
	 * Cancelation can occur even if no progress monitor is provided.
486
	 *
486
	 *
487
	 * @see IContainer#removeFilter(String, int, String, int, IProgressMonitor)
487
	 * @see IContainer#removeFilter(String, int, Object, int, IProgressMonitor)
488
	 * @see IContainer#getFilters()
488
	 * @see IContainer#getFilters()
489
	 * 
489
	 * 
490
	 * @since 3.6
490
	 * @since 3.6
491
	 */
491
	 */
492
	public void addFilter(String filterID, int type, String arguments, int updateFlags, IProgressMonitor monitor) throws CoreException;
492
	public void addFilter(String filterID, int type, Object arguments, int updateFlags, IProgressMonitor monitor) throws CoreException;
493
493
494
	/**
494
	/**
495
	 * Remove the filter matching the arguments from this folder's filter list  
495
	 * Remove the filter matching the arguments from this folder's filter list  
Lines 508-519 Link Here
508
	 * @exception OperationCanceledException if the operation is canceled. 
508
	 * @exception OperationCanceledException if the operation is canceled. 
509
	 * Cancelation can occur even if no progress monitor is provided.
509
	 * Cancelation can occur even if no progress monitor is provided.
510
	 *
510
	 *
511
	 * @see IContainer#addFilter(String, int, String, int, IProgressMonitor)
511
	 * @see IContainer#addFilter(String, int, Object, int, IProgressMonitor)
512
	 * @see IContainer#getFilters()
512
	 * @see IContainer#getFilters()
513
	 * 
513
	 * 
514
	 * @since 3.6
514
	 * @since 3.6
515
	 */
515
	 */
516
	public void removeFilter(String filterID, int type, String arguments, int updateFlags, IProgressMonitor monitor) throws CoreException;
516
	public void removeFilter(String filterID, int type, Object arguments, int updateFlags, IProgressMonitor monitor) throws CoreException;
517
517
518
	/**
518
	/**
519
	 * Retrieve the filters for this folder.
519
	 * Retrieve the filters for this folder.
Lines 524-531 Link Here
524
	 * <ul>
524
	 * <ul>
525
	 * <li> This resource is not a folder.</li>
525
	 * <li> This resource is not a folder.</li>
526
	 *
526
	 *
527
	 * @see IContainer#addFilter(String, int, String, int, IProgressMonitor)
527
	 * @see IContainer#addFilter(String, int, Object, int, IProgressMonitor)
528
	 * @see IContainer#removeFilter(String, int, String, int, IProgressMonitor)
528
	 * @see IContainer#removeFilter(String, int, Object, int, IProgressMonitor)
529
	 * 
529
	 * 
530
	 * @since 3.6
530
	 * @since 3.6
531
	 */
531
	 */
(-)src/org/eclipse/core/resources/IFileInfoFilterFactory.java (-1 / +1 lines)
Lines 28-32 Link Here
28
	 * @param arguments the test arguments, or <code>null</code> if not applicable
28
	 * @param arguments the test arguments, or <code>null</code> if not applicable
29
	 * for this filter type.
29
	 * for this filter type.
30
	 */
30
	 */
31
	public IFileInfoFilter instantiate(IProject project, String arguments);
31
	public IFileInfoFilter instantiate(IProject project, Object arguments);
32
}
32
}
(-)src/org/eclipse/core/resources/IResource.java (-2 / +2 lines)
Lines 1716-1723 Link Here
1716
	 * 
1716
	 * 
1717
	 * @return <code>true</code> if this resource has filters, and 
1717
	 * @return <code>true</code> if this resource has filters, and 
1718
	 *   <code>false</code> otherwise
1718
	 *   <code>false</code> otherwise
1719
	 * @see IContainer#addFilter(String, int, String, int, IProgressMonitor)
1719
	 * @see IContainer#addFilter(String, int, Object, int, IProgressMonitor)
1720
	 * @see IContainer#removeFilter(String, int, String, int, IProgressMonitor)
1720
	 * @see IContainer#removeFilter(String, int, Object, int, IProgressMonitor)
1721
	 * @since 3.6
1721
	 * @since 3.6
1722
	 */
1722
	 */
1723
	public boolean hasFilters();
1723
	public boolean hasFilters();
(-)src/org/eclipse/core/resources/IResourceFilter.java (-3 / +3 lines)
Lines 17-24 Link Here
17
 * Interface for resource filters.  A filter determines which file system
17
 * Interface for resource filters.  A filter determines which file system
18
 * objects will be visible when a local refresh is performed for an IContainer.
18
 * objects will be visible when a local refresh is performed for an IContainer.
19
 *
19
 *
20
 * @see IFolder#addFilter(String, int, String, int, IProgressMonitor)
20
 * @see IFolder#addFilter(String, int, Object, int, IProgressMonitor)
21
 * @see IFolder#removeFilter(String, int, String, int, IProgressMonitor)
21
 * @see IFolder#removeFilter(String, int, Object, int, IProgressMonitor)
22
 * @see IFolder#getFilters()
22
 * @see IFolder#getFilters()
23
 * @noimplement This interface is not intended to be implemented by clients.
23
 * @noimplement This interface is not intended to be implemented by clients.
24
 * @since 3.6
24
 * @since 3.6
Lines 88-94 Link Here
88
	 * 
88
	 * 
89
	 * @return the argument string, or null
89
	 * @return the argument string, or null
90
	 */
90
	 */
91
	public String getArguments();
91
	public Object getArguments();
92
92
93
	/**
93
	/**
94
	 * Returns the project which contains this filter.
94
	 * Returns the project which contains this filter.
(-)src/org/eclipse/ui/internal/ide/dialogs/ResourceFilterGroup.java (-31 / +35 lines)
Lines 91-97 Link Here
91
import org.eclipse.ui.internal.ide.IDEWorkbenchMessages;
91
import org.eclipse.ui.internal.ide.IDEWorkbenchMessages;
92
import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin;
92
import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin;
93
import org.eclipse.ui.internal.ide.IIDEHelpContextIds;
93
import org.eclipse.ui.internal.ide.IIDEHelpContextIds;
94
import org.eclipse.ui.internal.ide.misc.CompoundResourceFilter;
95
import org.eclipse.ui.plugin.AbstractUIPlugin;
94
import org.eclipse.ui.plugin.AbstractUIPlugin;
96
95
97
/**
96
/**
Lines 179-185 Link Here
179
		}
178
		}
180
179
181
		boolean changed = false;
180
		boolean changed = false;
182
		public LinkedList/* <IResourceFilter> */trash = new LinkedList/* <IResourceFilter> */();
181
		public LinkedList/* <IResourceFilter> */trash = new LinkedList/*
182
																	 * <IResourceFilter
183
																	 * >
184
																	 */();
183
185
184
		public void add(FilterCopy newFilter) {
186
		public void add(FilterCopy newFilter) {
185
			super.addChild(newFilter);
187
			super.addChild(newFilter);
Lines 347-355 Link Here
347
								.bind(
349
								.bind(
348
										IDEWorkbenchMessages.ResourceFilterPage_includeOnlyColumn,
350
										IDEWorkbenchMessages.ResourceFilterPage_includeOnlyColumn,
349
										null);
351
										null);
350
					return NLS.bind(
352
					return NLS
351
							IDEWorkbenchMessages.ResourceFilterPage_excludeAllColumn,
353
							.bind(
352
							null);
354
									IDEWorkbenchMessages.ResourceFilterPage_excludeAllColumn,
355
									null);
353
				}
356
				}
354
				return getFilterTypeName(filter);
357
				return getFilterTypeName(filter);
355
			}
358
			}
Lines 367-379 Link Here
367
									IDEWorkbenchMessages.ResourceFilterPage_filesColumn,
370
									IDEWorkbenchMessages.ResourceFilterPage_filesColumn,
368
									null);
371
									null);
369
				if (includeFolders)
372
				if (includeFolders)
370
					return NLS.bind(
373
					return NLS
371
							IDEWorkbenchMessages.ResourceFilterPage_foldersColumn,
374
							.bind(
372
							null);
375
									IDEWorkbenchMessages.ResourceFilterPage_foldersColumn,
376
									null);
373
			}
377
			}
374
			if (column.equals(FilterTypeUtil.ARGUMENTS)) {
378
			if (column.equals(FilterTypeUtil.ARGUMENTS)) {
375
				if (filter.hasStringArguments())
379
				if (filter.hasStringArguments())
376
					return filter.getArguments();
380
					return filter.getArguments() != null ? filter
381
							.getArguments().toString() : ""; //$NON-NLS-1$
377
				if ((filter.getChildrenLimit() > 0)
382
				if ((filter.getChildrenLimit() > 0)
378
						&& !filter.isUnderAGroupFilter())
383
						&& !filter.isUnderAGroupFilter())
379
					return "< " + getFilterTypeName(filter) + " >"; //$NON-NLS-1$ //$NON-NLS-2$
384
					return "< " + getFilterTypeName(filter) + " >"; //$NON-NLS-1$ //$NON-NLS-2$
Lines 1156-1163 Link Here
1156
			else
1161
			else
1157
				filter.setType(type);
1162
				filter.setType(type);
1158
		}
1163
		}
1159
		if (property.equals(FilterTypeUtil.ARGUMENTS))
1164
		if (property.equals(FilterTypeUtil.ARGUMENTS)) {
1160
			filter.setArguments((String) value);
1165
			filter.setArguments(value.equals("") ? null : value); //$NON-NLS-1$
1166
		}
1161
	}
1167
	}
1162
1168
1163
	static IFilterDescriptor getDescriptor(String id) {
1169
	static IFilterDescriptor getDescriptor(String id) {
Lines 1206-1212 Link Here
1206
					(filter.getType() & IResourceFilter.INHERITABLE) != 0);
1212
					(filter.getType() & IResourceFilter.INHERITABLE) != 0);
1207
1213
1208
		if (property.equals(ARGUMENTS))
1214
		if (property.equals(ARGUMENTS))
1209
			return filter.getArguments();
1215
			return filter.getArguments() != null ? filter.getArguments() : ""; //$NON-NLS-1$
1210
		return null;
1216
		return null;
1211
	}
1217
	}
1212
1218
Lines 1310-1317 Link Here
1310
}
1316
}
1311
1317
1312
class FilterCopy implements IResourceFilter {
1318
class FilterCopy implements IResourceFilter {
1313
	static String EMPTY = ""; //$NON-NLS-1$
1319
	Object arguments = null;
1314
	String arguments = EMPTY;
1315
	String id = null;
1320
	String id = null;
1316
	IPath path = null;
1321
	IPath path = null;
1317
	IProject project = null;
1322
	IProject project = null;
Lines 1366-1373 Link Here
1366
		path = filter.getPath();
1371
		path = filter.getPath();
1367
		project = filter.getProject();
1372
		project = filter.getProject();
1368
		type = filter.getType();
1373
		type = filter.getType();
1369
		if (arguments == null)
1370
			arguments = EMPTY;
1371
	}
1374
	}
1372
1375
1373
	public boolean hasChanged() {
1376
	public boolean hasChanged() {
Lines 1387-1393 Link Here
1387
		id = FilterTypeUtil.getDefaultFilterID();
1390
		id = FilterTypeUtil.getDefaultFilterID();
1388
	}
1391
	}
1389
1392
1390
	public String getArguments() {
1393
	public Object getArguments() {
1391
		return arguments;
1394
		return arguments;
1392
	}
1395
	}
1393
1396
Lines 1407-1413 Link Here
1407
		return type;
1410
		return type;
1408
	}
1411
	}
1409
1412
1410
	public void setArguments(String arguments) {
1413
	public void setArguments(Object arguments) {
1411
		this.arguments = arguments;
1414
		this.arguments = arguments;
1412
		argumentsChanged();
1415
		argumentsChanged();
1413
	}
1416
	}
Lines 1487-1499 Link Here
1487
		if (children == null) {
1490
		if (children == null) {
1488
			if (getChildrenLimit() > 0) {
1491
			if (getChildrenLimit() > 0) {
1489
				children = new LinkedList();
1492
				children = new LinkedList();
1490
				IResourceFilter[] filters = CompoundResourceFilter.unserialize(
1493
				IResourceFilter[] filters = (IResourceFilter[]) getArguments();
1491
						getProject(), getArguments());
1494
				if (filters != null)
1492
				for (int i = 0; i < filters.length; i++) {
1495
					for (int i = 0; i < filters.length; i++) {
1493
					FilterCopy child = new FilterCopy(filters[i]);
1496
						FilterCopy child = new FilterCopy(filters[i]);
1494
					child.parent = this;
1497
						child.parent = this;
1495
					children.add(child);
1498
						children.add(child);
1496
				}
1499
					}
1497
			}
1500
			}
1498
		}
1501
		}
1499
	}
1502
	}
Lines 1523-1531 Link Here
1523
	protected void argumentsChanged() {
1526
	protected void argumentsChanged() {
1524
		initializeChildren();
1527
		initializeChildren();
1525
		if (children != null)
1528
		if (children != null)
1526
			arguments = CompoundResourceFilter
1529
			arguments = (FilterCopy[]) children.toArray(new FilterCopy[0]);
1527
					.serialize((FilterCopy[]) children
1528
							.toArray(new FilterCopy[0]));
1529
		FilterCopy up = parent;
1530
		FilterCopy up = parent;
1530
		while (up != null) {
1531
		while (up != null) {
1531
			up.serializeChildren();
1532
			up.serializeChildren();
Lines 1680-1686 Link Here
1680
	 * 
1681
	 * 
1681
	 */
1682
	 */
1682
	private void setArgumentLabelEnabled() {
1683
	private void setArgumentLabelEnabled() {
1683
		Color color = argumentsLabel.getDisplay().getSystemColor(filter.hasStringArguments() ? SWT.COLOR_BLACK : SWT.COLOR_GRAY); 
1684
		Color color = argumentsLabel.getDisplay().getSystemColor(
1685
				filter.hasStringArguments() ? SWT.COLOR_BLACK : SWT.COLOR_GRAY);
1684
		argumentsLabel.setForeground(color);
1686
		argumentsLabel.setForeground(color);
1685
	}
1687
	}
1686
1688
Lines 1707-1713 Link Here
1707
	private void createIdArea(Font font, Composite composite) {
1709
	private void createIdArea(Font font, Composite composite) {
1708
		GridData data;
1710
		GridData data;
1709
		Group idComposite = createGroup(font, composite, NLS.bind(
1711
		Group idComposite = createGroup(font, composite, NLS.bind(
1710
				IDEWorkbenchMessages.ResourceFilterPage_columnFilterID, null), true);
1712
				IDEWorkbenchMessages.ResourceFilterPage_columnFilterID, null),
1713
				true);
1711
		idCombo = new Combo(idComposite, SWT.READ_ONLY);
1714
		idCombo = new Combo(idComposite, SWT.READ_ONLY);
1712
		idCombo.setItems(FilterTypeUtil.getFilterNames(filter
1715
		idCombo.setItems(FilterTypeUtil.getFilterNames(filter
1713
				.getChildrenLimit() > 0));
1716
				.getChildrenLimit() > 0));
Lines 1797-1803 Link Here
1797
	 * @param composite
1800
	 * @param composite
1798
	 * @return the group
1801
	 * @return the group
1799
	 */
1802
	 */
1800
	private Group createGroup(Font font, Composite composite, String text, boolean grabExcessVerticalSpace) {
1803
	private Group createGroup(Font font, Composite composite, String text,
1804
			boolean grabExcessVerticalSpace) {
1801
		GridLayout layout;
1805
		GridLayout layout;
1802
		GridData data;
1806
		GridData data;
1803
		Group modeComposite = new Group(composite, SWT.NONE);
1807
		Group modeComposite = new Group(composite, SWT.NONE);
(-)src/org/eclipse/ui/internal/ide/misc/AndResourceFilter.java (-2 / +2 lines)
Lines 37-43 Link Here
37
		}
37
		}
38
	}
38
	}
39
39
40
	public IFileInfoFilter instantiate(IProject project, String arguments) {
40
	public IFileInfoFilter instantiate(IProject project, Object arguments) {
41
		return new AndFileInfoFilter(project, unserialize(project, arguments));
41
		return new AndFileInfoFilter(project,(IResourceFilter[])arguments);
42
	}
42
	}
43
}
43
}
(-)src/org/eclipse/ui/internal/ide/misc/CompoundResourceFilter.java (-97 / +2 lines)
Lines 11-37 Link Here
11
 *******************************************************************************/
11
 *******************************************************************************/
12
package org.eclipse.ui.internal.ide.misc;
12
package org.eclipse.ui.internal.ide.misc;
13
13
14
import java.io.IOException;
15
import java.io.StringReader;
16
import java.io.StringWriter;
17
import java.util.LinkedList;
18
19
import org.eclipse.core.filesystem.IFileInfoFilter;
14
import org.eclipse.core.filesystem.IFileInfoFilter;
20
import org.eclipse.core.resources.IFilterDescriptor;
15
import org.eclipse.core.resources.IFilterDescriptor;
21
import org.eclipse.core.resources.IProject;
16
import org.eclipse.core.resources.IProject;
22
import org.eclipse.core.resources.IResourceFilter;
17
import org.eclipse.core.resources.IResourceFilter;
23
import org.eclipse.core.runtime.IPath;
24
import org.eclipse.ui.IMemento;
25
import org.eclipse.ui.WorkbenchException;
26
import org.eclipse.ui.XMLMemento;
27
18
28
/**
19
/**
29
 * Resource Filter Type allowing serializing sub filters as the arguments
20
 * Resource Filter Type allowing serializing sub filters as the arguments
30
 */
21
 */
31
public class CompoundResourceFilter {
22
public class CompoundResourceFilter {
32
23
33
	private static final String T_FILTERS = "filters"; //$NON-NLS-1$
34
35
	protected IFileInfoFilter instantiate(IProject project,
24
	protected IFileInfoFilter instantiate(IProject project,
36
			IResourceFilter filter) {
25
			IResourceFilter filter) {
37
		IFilterDescriptor desc = project.getWorkspace().getFilterDescriptor(
26
		IFilterDescriptor desc = project.getWorkspace().getFilterDescriptor(
Lines 42-139 Link Here
42
		return null;
31
		return null;
43
	}
32
	}
44
33
45
	private static final String T_FILTER = "filter"; //$NON-NLS-1$
46
	private static final String T_TYPE = "type"; //$NON-NLS-1$
47
	private static final String T_ID = "id"; //$NON-NLS-1$
48
	private static final String T_ARGUMENTS = "arguments"; //$NON-NLS-1$
49
50
	/**
51
	 * Unserialize the filters stored in a memento
52
	 * 
53
	 * @param project
54
	 * @param memento
55
	 * @return the filter array
56
	 */
57
	public static IResourceFilter[] unserialize(final IProject project,
58
			String memento) {
59
		LinkedList filters = new LinkedList();
60
		XMLMemento mementoObject = null;
61
		try {
62
			mementoObject = XMLMemento
63
					.createReadRoot(new StringReader(memento));
64
		} catch (WorkbenchException e) {
65
			return new IResourceFilter[0];
66
		}
67
		IMemento childMem = mementoObject.getChild(T_FILTERS);
68
		if (childMem != null) {
69
			IMemento[] elementMem = childMem.getChildren(T_FILTER);
70
			for (int i = 0; i < elementMem.length; i++) {
71
				final String id = elementMem[i].getString(T_ID);
72
				final int type = elementMem[i].getInteger(T_TYPE).intValue();
73
				IMemento argumentMem = elementMem[i].getChild(T_ARGUMENTS);
74
				final String arguments = argumentMem != null ? argumentMem
75
						.getTextData() : ""; //$NON-NLS-1$
76
				filters.add(new IResourceFilter() {
77
					public String getArguments() {
78
						return arguments;
79
					}
80
81
					public String getId() {
82
						return id;
83
					}
84
85
					public IPath getPath() {
86
						return null;
87
					}
88
89
					public IProject getProject() {
90
						return project;
91
					}
92
93
					public int getType() {
94
						return type;
95
					}
96
				});
97
			}
98
		}
99
		return (IResourceFilter[]) filters.toArray(new IResourceFilter[0]);
100
	}
101
102
	/**
103
	 * Serialize filters into in a memento
104
	 * 
105
	 * @param filters
106
	 * @return the memento
107
	 */
108
	public static String serialize(IResourceFilter[] filters) {
109
		XMLMemento memento = XMLMemento.createWriteRoot("memento"); //$NON-NLS-1$
110
111
		IMemento expandedMem = memento.createChild(T_FILTERS);
112
		for (int i = 0; i < filters.length; i++) {
113
			IMemento elementMem = expandedMem.createChild(T_FILTER);
114
			elementMem.putString(T_ID, filters[i].getId());
115
			elementMem.putInteger(T_TYPE, filters[i].getType());
116
			IMemento argumentMem = elementMem.createChild(T_ARGUMENTS);
117
			argumentMem.putTextData(filters[i].getArguments());
118
		}
119
120
		StringWriter writer = new StringWriter();
121
		try {
122
			memento.save(writer);
123
		} catch (IOException e) {
124
			return ""; //$NON-NLS-1$
125
		}
126
		return writer.toString();
127
	}
128
129
	protected abstract class FileInfoFilter implements IFileInfoFilter {
34
	protected abstract class FileInfoFilter implements IFileInfoFilter {
130
		protected IFileInfoFilter[] filterTypes;
35
		protected IFileInfoFilter[] filterTypes;
131
		protected IResourceFilter[] filters;
36
		protected IResourceFilter[] filters;
132
37
133
		public FileInfoFilter(IProject project, IResourceFilter[] filters) {
38
		public FileInfoFilter(IProject project, IResourceFilter[] filters) {
134
			this.filters = filters;
39
			this.filters = filters;
135
			filterTypes = new IFileInfoFilter[filters.length];
40
			filterTypes = new IFileInfoFilter[filters!=null ? filters.length : 0];
136
			for (int i = 0; i < filters.length; i++)
41
			for (int i = 0; i < filterTypes.length; i++)
137
				filterTypes[i] = instantiate(project, filters[i]);
42
				filterTypes[i] = instantiate(project, filters[i]);
138
		}
43
		}
139
	}
44
	}
(-)src/org/eclipse/ui/internal/ide/misc/NotResourceFilter.java (-2 / +2 lines)
Lines 37-43 Link Here
37
		}
37
		}
38
	}
38
	}
39
39
40
	public IFileInfoFilter instantiate(IProject project, String arguments) {
40
	public IFileInfoFilter instantiate(IProject project, Object arguments) {
41
		return new NotFileInfoFilter(project, unserialize(project, arguments));
41
		return new NotFileInfoFilter(project, (IResourceFilter[])arguments);
42
	}
42
	}
43
}
43
}
(-)src/org/eclipse/ui/internal/ide/misc/OrResourceFilter.java (-2 / +2 lines)
Lines 40-46 Link Here
40
		}
40
		}
41
	}
41
	}
42
42
43
	public IFileInfoFilter instantiate(IProject project, String arguments) {
43
	public IFileInfoFilter instantiate(IProject project, Object arguments) {
44
		return new OrFileInfoFilter(project, unserialize(project, arguments));
44
		return new OrFileInfoFilter(project, (IResourceFilter[])arguments);
45
	}
45
	}
46
}
46
}
(-)src/org/eclipse/ui/internal/ide/misc/StringMatcherFilter.java (-2 / +2 lines)
Lines 51-58 Link Here
51
51
52
	}
52
	}
53
53
54
	public IFileInfoFilter instantiate(IProject project, String arguments) {
54
	public IFileInfoFilter instantiate(IProject project, Object arguments) {
55
		return new FilterType(arguments);
55
		return new FilterType((String)arguments);
56
	}
56
	}
57
57
58
}
58
}

Return to bug 291755