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 / +1 lines)
Lines 64-70 Link Here
64
		return false;
64
		return false;
65
	}
65
	}
66
66
67
	public String getArguments() {
67
	public Object getArguments() {
68
		return description.getArguments();
68
		return description.getArguments();
69
	}
69
	}
70
70
(-)src/org/eclipse/core/internal/resources/FilterDescription.java (-11 / +22 lines)
Lines 10-33 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.core.internal.resources;
11
package org.eclipse.core.internal.resources;
12
12
13
import java.util.Iterator;
13
import org.eclipse.core.resources.IProject;
14
15
import java.util.LinkedList;
16
import org.eclipse.core.runtime.IPath;
14
import org.eclipse.core.runtime.IPath;
17
15
18
import org.eclipse.core.resources.IResourceFilter;
16
import java.util.Iterator;
19
17
import java.util.LinkedList;
20
import org.eclipse.core.resources.IResource;
18
import org.eclipse.core.resources.IResource;
19
import org.eclipse.core.resources.IResourceFilter;
21
import org.eclipse.core.runtime.*;
20
import org.eclipse.core.runtime.*;
22
21
23
/**
22
/**
24
 * Class for describing the characteristics of filters that are stored
23
 * Class for describing the characteristics of filters that are stored
25
 * in the project description.
24
 * in the project description.
26
 */
25
 */
27
public class FilterDescription implements Comparable {
26
public class FilterDescription implements Comparable, IResourceFilter {
28
27
29
	private String id;
28
	private String id;
30
	private String arguments;
29
	private Object arguments;
31
30
32
	/**
31
	/**
33
	 * The project relative path.
32
	 * The project relative path.
Lines 45-51 Link Here
45
		this.arguments = null;
44
		this.arguments = null;
46
	}
45
	}
47
46
48
	public FilterDescription(IResource resource, int type, String filterID, String arguments) {
47
	public FilterDescription(IResource resource, int type, String filterID, Object arguments) {
49
		super();
48
		super();
50
		Assert.isNotNull(resource);
49
		Assert.isNotNull(resource);
51
		Assert.isNotNull(filterID);
50
		Assert.isNotNull(filterID);
Lines 55-61 Link Here
55
		this.arguments = arguments;
54
		this.arguments = arguments;
56
	}
55
	}
57
56
58
	public FilterDescription(IPath projectRelativePath, int type, String filterID, String arguments) {
57
	private FilterDescription(IPath projectRelativePath, int type, String filterID, Object arguments) {
59
		super();
58
		super();
60
		Assert.isNotNull(projectRelativePath);
59
		Assert.isNotNull(projectRelativePath);
61
		Assert.isNotNull(filterID);
60
		Assert.isNotNull(filterID);
Lines 79-85 Link Here
79
		return id;
78
		return id;
80
	}
79
	}
81
80
82
	public String getArguments() {
81
	public Object getArguments() {
83
		return arguments;
82
		return arguments;
84
	}
83
	}
85
84
Lines 103-109 Link Here
103
		this.id = id;
102
		this.id = id;
104
	}
103
	}
105
104
106
	public void setArguments(String arguments) {
105
	public void setArguments(Object arguments) {
107
		this.arguments = arguments;
106
		this.arguments = arguments;
108
	}
107
	}
109
108
Lines 148-151 Link Here
148
		}
147
		}
149
		return copy;
148
		return copy;
150
	}
149
	}
150
151
	public String getId() {
152
		return id;
153
	}
154
155
	public IPath getPath() {
156
		return path;
157
	}
158
159
	public IProject getProject() {
160
		return null;
161
	}
151
}
162
}
(-)src/org/eclipse/core/internal/resources/ModelObjectWriter.java (-7 / +26 lines)
Lines 12-17 Link Here
12
 *******************************************************************************/
12
 *******************************************************************************/
13
package org.eclipse.core.internal.resources;
13
package org.eclipse.core.internal.resources;
14
14
15
import org.eclipse.core.resources.IResourceFilter;
16
15
import java.io.IOException;
17
import java.io.IOException;
16
import java.io.OutputStream;
18
import java.io.OutputStream;
17
import java.net.URI;
19
import java.net.URI;
Lines 93-106 Link Here
93
		writer.endTag(LINK);
95
		writer.endTag(LINK);
94
	}
96
	}
95
97
96
	protected void write(FilterDescription description, XMLWriter writer) {
98
	protected void write(IResourceFilter description, XMLWriter writer) {
97
		writer.startTag(FILTER, null);
99
		writer.startTag(FILTER, null);
98
		if (description != null) {
100
		if (description != null) {
99
			writer.printSimpleTag(NAME, description.getProjectRelativePath());
101
			writer.printSimpleTag(NAME, description.getPath());
100
			writer.printSimpleTag(TYPE, Integer.toString(description.getType()));
102
			writer.printSimpleTag(TYPE, Integer.toString(description.getType()));
101
			writer.printSimpleTag(ID, description.getFilterID());
103
			writer.printSimpleTag(ID, description.getId());
102
			if (description.getArguments() != null)
104
			if (description.getArguments() != null){
103
				writer.printSimpleTag(ARGUMENTS, description.getArguments());
105
				if (description.getArguments() instanceof String){
106
					writer.printSimpleTag(ARGUMENTS, description.getArguments());
107
				}
108
				else if (description.getArguments() instanceof IResourceFilter[]){
109
						writer.startTag(ARGUMENTS, null);
110
//						List sorted = new ArrayList();
111
						IResourceFilter[] array = (IResourceFilter[])description.getArguments();
112
						for (int i=0; i< array.length; i ++){
113
							write(array[i], writer);
114
						}	
115
//						Collections.sort(sorted);
116
						
117
						writer.endTag(ARGUMENTS);
118
				}
119
				else writer.printSimpleTag(ARGUMENTS, ""); //$NON-NLS-1$
120
					
121
			}
122
				
104
		}
123
		}
105
		writer.endTag(FILTER);
124
		writer.endTag(FILTER);
106
	}
125
	}
Lines 176-183 Link Here
176
			write((LinkDescription) obj, writer);
195
			write((LinkDescription) obj, writer);
177
			return;
196
			return;
178
		}
197
		}
179
		if (obj instanceof FilterDescription) {
198
		if (obj instanceof IResourceFilter) {
180
			write((FilterDescription) obj, writer);
199
			write((IResourceFilter) obj, writer);
181
			return;
200
			return;
182
		}
201
		}
183
		if (obj instanceof VariableDescription) {
202
		if (obj instanceof VariableDescription) {
(-)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 (-9 / +5 lines)
Lines 90-96 Link Here
90
import org.eclipse.ui.internal.ide.IDEWorkbenchMessages;
90
import org.eclipse.ui.internal.ide.IDEWorkbenchMessages;
91
import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin;
91
import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin;
92
import org.eclipse.ui.internal.ide.IIDEHelpContextIds;
92
import org.eclipse.ui.internal.ide.IIDEHelpContextIds;
93
import org.eclipse.ui.internal.ide.misc.CompoundResourceFilter;
94
import org.eclipse.ui.plugin.AbstractUIPlugin;
93
import org.eclipse.ui.plugin.AbstractUIPlugin;
95
94
96
/**
95
/**
Lines 372-378 Link Here
372
			}
371
			}
373
			if (column.equals(FilterTypeUtil.ARGUMENTS)) {
372
			if (column.equals(FilterTypeUtil.ARGUMENTS)) {
374
				if (filter.hasStringArguments())
373
				if (filter.hasStringArguments())
375
					return filter.getArguments();
374
					return filter.getArguments().toString();
376
				if ((filter.getChildrenLimit() > 0)
375
				if ((filter.getChildrenLimit() > 0)
377
						&& !filter.isUnderAGroupFilter())
376
						&& !filter.isUnderAGroupFilter())
378
					return "< " + getFilterTypeName(filter) + " >"; //$NON-NLS-1$ //$NON-NLS-2$
377
					return "< " + getFilterTypeName(filter) + " >"; //$NON-NLS-1$ //$NON-NLS-2$
Lines 1310-1316 Link Here
1310
1309
1311
class FilterCopy implements IResourceFilter {
1310
class FilterCopy implements IResourceFilter {
1312
	static String EMPTY = ""; //$NON-NLS-1$
1311
	static String EMPTY = ""; //$NON-NLS-1$
1313
	String arguments = EMPTY;
1312
	Object arguments = EMPTY;
1314
	String id = null;
1313
	String id = null;
1315
	IPath path = null;
1314
	IPath path = null;
1316
	IProject project = null;
1315
	IProject project = null;
Lines 1386-1392 Link Here
1386
		id = FilterTypeUtil.getDefaultFilterID();
1385
		id = FilterTypeUtil.getDefaultFilterID();
1387
	}
1386
	}
1388
1387
1389
	public String getArguments() {
1388
	public Object getArguments() {
1390
		return arguments;
1389
		return arguments;
1391
	}
1390
	}
1392
1391
Lines 1486-1493 Link Here
1486
		if (children == null) {
1485
		if (children == null) {
1487
			if (getChildrenLimit() > 0) {
1486
			if (getChildrenLimit() > 0) {
1488
				children = new LinkedList();
1487
				children = new LinkedList();
1489
				IResourceFilter[] filters = CompoundResourceFilter.unserialize(
1488
				IResourceFilter[] filters = (IResourceFilter[])getArguments(); //CompoundResourceFilter.unserialize(getProject(), getArguments());
1490
						getProject(), getArguments());
1491
				for (int i = 0; i < filters.length; i++) {
1489
				for (int i = 0; i < filters.length; i++) {
1492
					FilterCopy child = new FilterCopy(filters[i]);
1490
					FilterCopy child = new FilterCopy(filters[i]);
1493
					child.parent = this;
1491
					child.parent = this;
Lines 1522-1530 Link Here
1522
	protected void argumentsChanged() {
1520
	protected void argumentsChanged() {
1523
		initializeChildren();
1521
		initializeChildren();
1524
		if (children != null)
1522
		if (children != null)
1525
			arguments = CompoundResourceFilter
1523
			arguments = (FilterCopy[]) children.toArray(new FilterCopy[0]);
1526
					.serialize((FilterCopy[]) children
1527
							.toArray(new FilterCopy[0]));
1528
		FilterCopy up = parent;
1524
		FilterCopy up = parent;
1529
		while (up != null) {
1525
		while (up != null) {
1530
			up.serializeChildren();
1526
			up.serializeChildren();
(-)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 (-78 / +69 lines)
Lines 11-36 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$
24
	//	private static final String T_FILTERS = "filters"; //$NON-NLS-1$
34
25
35
	protected IFileInfoFilter instantiate(IProject project,
26
	protected IFileInfoFilter instantiate(IProject project,
36
			IResourceFilter filter) {
27
			IResourceFilter filter) {
Lines 42-51 Link Here
42
		return null;
33
		return null;
43
	}
34
	}
44
35
45
	private static final String T_FILTER = "filter"; //$NON-NLS-1$
36
	//	private static final String T_FILTER = "filter"; //$NON-NLS-1$
46
	private static final String T_TYPE = "type"; //$NON-NLS-1$
37
	//	private static final String T_TYPE = "type"; //$NON-NLS-1$
47
	private static final String T_ID = "id"; //$NON-NLS-1$
38
	//	private static final String T_ID = "id"; //$NON-NLS-1$
48
	private static final String T_ARGUMENTS = "arguments"; //$NON-NLS-1$
39
	//	private static final String T_ARGUMENTS = "arguments"; //$NON-NLS-1$
49
40
50
	/**
41
	/**
51
	 * Unserialize the filters stored in a memento
42
	 * Unserialize the filters stored in a memento
Lines 54-103 Link Here
54
	 * @param memento
45
	 * @param memento
55
	 * @return the filter array
46
	 * @return the filter array
56
	 */
47
	 */
57
	public static IResourceFilter[] unserialize(final IProject project,
48
	// public static IResourceFilter[] unserialize(final IProject project,
58
			String memento) {
49
	// String memento) {
59
		LinkedList filters = new LinkedList();
50
	// LinkedList filters = new LinkedList();
60
		XMLMemento mementoObject = null;
51
	// XMLMemento mementoObject = null;
61
		try {
52
	// try {
62
			mementoObject = XMLMemento
53
	// mementoObject = XMLMemento
63
					.createReadRoot(new StringReader(memento));
54
	// .createReadRoot(new StringReader(memento));
64
		} catch (WorkbenchException e) {
55
	// } catch (WorkbenchException e) {
65
			return new IResourceFilter[0];
56
	// return new IResourceFilter[0];
66
		}
57
	// }
67
		IMemento childMem = mementoObject.getChild(T_FILTERS);
58
	// IMemento childMem = mementoObject.getChild(T_FILTERS);
68
		if (childMem != null) {
59
	// if (childMem != null) {
69
			IMemento[] elementMem = childMem.getChildren(T_FILTER);
60
	// IMemento[] elementMem = childMem.getChildren(T_FILTER);
70
			for (int i = 0; i < elementMem.length; i++) {
61
	// for (int i = 0; i < elementMem.length; i++) {
71
				final String id = elementMem[i].getString(T_ID);
62
	// final String id = elementMem[i].getString(T_ID);
72
				final int type = elementMem[i].getInteger(T_TYPE).intValue();
63
	// final int type = elementMem[i].getInteger(T_TYPE).intValue();
73
				IMemento argumentMem = elementMem[i].getChild(T_ARGUMENTS);
64
	// IMemento argumentMem = elementMem[i].getChild(T_ARGUMENTS);
74
				final String arguments = argumentMem != null ? argumentMem
65
	// final String arguments = argumentMem != null ? argumentMem
75
						.getTextData() : ""; //$NON-NLS-1$
66
	//						.getTextData() : ""; //$NON-NLS-1$
76
				filters.add(new IResourceFilter() {
67
	// filters.add(new IResourceFilter() {
77
					public String getArguments() {
68
	// public String getArguments() {
78
						return arguments;
69
	// return arguments;
79
					}
70
	// }
80
71
	//
81
					public String getId() {
72
	// public String getId() {
82
						return id;
73
	// return id;
83
					}
74
	// }
84
75
	//
85
					public IPath getPath() {
76
	// public IPath getPath() {
86
						return null;
77
	// return null;
87
					}
78
	// }
88
79
	//
89
					public IProject getProject() {
80
	// public IProject getProject() {
90
						return project;
81
	// return project;
91
					}
82
	// }
92
83
	//
93
					public int getType() {
84
	// public int getType() {
94
						return type;
85
	// return type;
95
					}
86
	// }
96
				});
87
	// });
97
			}
88
	// }
98
		}
89
	// }
99
		return (IResourceFilter[]) filters.toArray(new IResourceFilter[0]);
90
	// return (IResourceFilter[]) filters.toArray(new IResourceFilter[0]);
100
	}
91
	// }
101
92
102
	/**
93
	/**
103
	 * Serialize filters into in a memento
94
	 * Serialize filters into in a memento
Lines 105-130 Link Here
105
	 * @param filters
96
	 * @param filters
106
	 * @return the memento
97
	 * @return the memento
107
	 */
98
	 */
108
	public static String serialize(IResourceFilter[] filters) {
99
	// public static String serialize(IResourceFilter[] filters) {
109
		XMLMemento memento = XMLMemento.createWriteRoot("memento"); //$NON-NLS-1$
100
	//		XMLMemento memento = XMLMemento.createWriteRoot("memento"); //$NON-NLS-1$
110
101
	//
111
		IMemento expandedMem = memento.createChild(T_FILTERS);
102
	// IMemento expandedMem = memento.createChild(T_FILTERS);
112
		for (int i = 0; i < filters.length; i++) {
103
	// for (int i = 0; i < filters.length; i++) {
113
			IMemento elementMem = expandedMem.createChild(T_FILTER);
104
	// IMemento elementMem = expandedMem.createChild(T_FILTER);
114
			elementMem.putString(T_ID, filters[i].getId());
105
	// elementMem.putString(T_ID, filters[i].getId());
115
			elementMem.putInteger(T_TYPE, filters[i].getType());
106
	// elementMem.putInteger(T_TYPE, filters[i].getType());
116
			IMemento argumentMem = elementMem.createChild(T_ARGUMENTS);
107
	// IMemento argumentMem = elementMem.createChild(T_ARGUMENTS);
117
			argumentMem.putTextData(filters[i].getArguments());
108
	// argumentMem.putTextData(filters[i].getArguments());
118
		}
109
	// }
119
110
	//
120
		StringWriter writer = new StringWriter();
111
	// StringWriter writer = new StringWriter();
121
		try {
112
	// try {
122
			memento.save(writer);
113
	// memento.save(writer);
123
		} catch (IOException e) {
114
	// } catch (IOException e) {
124
			return ""; //$NON-NLS-1$
115
	//			return ""; //$NON-NLS-1$
125
		}
116
	// }
126
		return writer.toString();
117
	// return writer.toString();
127
	}
118
	// }
128
119
129
	protected abstract class FileInfoFilter implements IFileInfoFilter {
120
	protected abstract class FileInfoFilter implements IFileInfoFilter {
130
		protected IFileInfoFilter[] filterTypes;
121
		protected IFileInfoFilter[] filterTypes;
(-)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