|
1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 |
|
17 |
|
18 package com.symbian.smt.gui; |
|
19 |
|
20 import org.eclipse.core.expressions.PropertyTester; |
|
21 import org.eclipse.core.resources.IFile; |
|
22 import org.eclipse.core.runtime.CoreException; |
|
23 |
|
24 import com.symbian.smt.gui.nature.Nature; |
|
25 |
|
26 /** |
|
27 * @author barbararosi-schwartz |
|
28 * |
|
29 */ |
|
30 public class FileTester extends PropertyTester { |
|
31 |
|
32 /** |
|
33 * |
|
34 */ |
|
35 public FileTester() { |
|
36 } |
|
37 |
|
38 /* (non-Javadoc) |
|
39 * @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object) |
|
40 */ |
|
41 public boolean test(Object element, String property, Object[] args, Object expectedValue) { |
|
42 IFile file = (IFile) element; |
|
43 |
|
44 if (property.equals("belongsToSMMProject")) { |
|
45 try { |
|
46 boolean belongsToSMMProject = file.getProject().hasNature(Nature.ID); |
|
47 return expectedValue == null ? belongsToSMMProject : (belongsToSMMProject == ((Boolean) expectedValue).booleanValue()); |
|
48 } |
|
49 catch (CoreException e) { |
|
50 Logger.log(e.getMessage(), e); |
|
51 return false; |
|
52 } |
|
53 |
|
54 } |
|
55 |
|
56 return false; |
|
57 } |
|
58 |
|
59 } |