blob: ac91f169bcb24b8cd66b40b193ffd70b41e91b59 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
/*******************************************************************************
* Copyright (c) 2004, 2007 Boeing.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
package org.eclipse.osee.framework.core.dsl.ui.integration.wizards;
import java.util.logging.Level;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceVisitor;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.osee.framework.core.dsl.ui.integration.internal.Activator;
import org.eclipse.osee.framework.jdk.core.type.MutableBoolean;
import org.eclipse.osee.framework.logging.OseeLog;
/**
* @author Roberto E. Escobar
*/
public class OseeTypesViewerFilter extends ViewerFilter {
private boolean processIFile(Object resource) {
boolean toReturn = false;
if (resource instanceof IFile) {
IFile aFile = (IFile) resource;
String currentExtension = aFile.getFileExtension();
if (currentExtension.equalsIgnoreCase("osee")) {
toReturn = true;
}
}
return toReturn;
}
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
if (element instanceof IProject) {
if (((IProject) element).isOpen()) {
return true;
}
} else if (element instanceof IContainer) {
IContainer container = (IContainer) element;
String name = container.getName();
if (!name.startsWith(".") && !name.equals("osee")) {
final MutableBoolean mutable = new MutableBoolean(false);
try {
container.accept(new IResourceVisitor() {
@Override
public boolean visit(IResource resource) {
mutable.setValue(processIFile(resource));
return mutable.getValue();
}
}, IResource.DEPTH_INFINITE, true);
} catch (CoreException ex) {
OseeLog.log(Activator.class, Level.SEVERE, ex);
}
return mutable.getValue();
}
} else {
return processIFile(element);
}
return false;
}
}
|