Package: ResourcesSelectionDialog$ResourceExtensionFilter
ResourcesSelectionDialog$ResourceExtensionFilter
name | instruction | branch | complexity | line | method | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ResourcesSelectionDialog.ResourceExtensionFilter(ResourcesSelectionDialog) |
|
|
|
|
|
||||||||||||||||||||
matchItem(Object) |
|
|
|
|
|
Coverage
1: /**
2: *
3: * Copyright (c) 2009-2010 Thales Corporate Services S.A.S.
4: * This program and the accompanying materials
5: * are made available under the terms of the Eclipse Public License v2.0
6: * which accompanies this distribution, and is available at
7: * https://www.eclipse.org/legal/epl-v2.0
8: *
9: * SPDX-License-Identifier: EPL-2.0
10: *
11: * Contributors:
12: * Thales Corporate Services S.A.S - initial API and implementation
13: *
14: */
15:
16: package org.eclipse.egf.core.ui.dialogs;
17:
18: import org.eclipse.core.resources.IContainer;
19: import org.eclipse.core.resources.IResource;
20: import org.eclipse.swt.widgets.Shell;
21: import org.eclipse.ui.dialogs.FilteredResourcesSelectionDialog;
22:
23: /**
24: * @author xiaoru chen
25: *
26: */
27: public class ResourcesSelectionDialog extends FilteredResourcesSelectionDialog {
28:
29: private final String fileExtension;
30:
31: public ResourcesSelectionDialog(Shell shell, boolean multi, IContainer container, int typesMask, String fileExtension) {
32: super(shell, multi, container, typesMask);
33: this.fileExtension = fileExtension == null ? "" : fileExtension.toLowerCase(); //$NON-NLS-1$
34: }
35:
36: @Override
37: protected ItemsFilter createFilter() {
38: return new ResourceExtensionFilter();
39: }
40:
41: /**
42: * Filters resources using pattern and showDerived flag. It overrides
43: * ItemsFilter.
44: */
45: protected class ResourceExtensionFilter extends ResourceFilter {
46:
47: @Override
48: public boolean matchItem(Object item) {
49: boolean match = super.matchItem(item);
50:• if (!match || ("".equals(fileExtension) && match)) { //$NON-NLS-1$
51: return match;
52: }
53: String currentExtension = ((IResource) item).getFileExtension();
54:• return (!(currentExtension == null) && fileExtension.equals(currentExtension.toLowerCase()));
55: }
56:
57: }
58:
59: }