KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > WorkbenchWindowPropertyTester


1 /*******************************************************************************
2  * Copyright (c) 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  ******************************************************************************/

11
12 package org.eclipse.ui.internal;
13
14 import org.eclipse.core.expressions.PropertyTester;
15
16 /**
17  * Tests various workbench window properties.
18  *
19  * @since 3.3
20  *
21  */

22 public class WorkbenchWindowPropertyTester extends PropertyTester {
23
24     private static final String JavaDoc PROPERTY_IS_COOLBAR_VISIBLE = "isCoolbarVisible"; //$NON-NLS-1$
25
private static final String JavaDoc PROPERTY_IS_PERSPECTIVEBAR_VISIBLE = "isPerspectiveBarVisible"; //$NON-NLS-1$
26

27     /*
28      * (non-Javadoc)
29      *
30      * @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object,
31      * java.lang.String, java.lang.Object[], java.lang.Object)
32      */

33     public boolean test(Object JavaDoc receiver, String JavaDoc property, Object JavaDoc[] args,
34             Object JavaDoc expectedValue) {
35         
36         if (args.length == 0 && receiver instanceof WorkbenchWindow) {
37             boolean defaultExpectedValue = true;
38             if (expectedValue != null) {
39                 if (expectedValue instanceof Boolean JavaDoc)
40                     defaultExpectedValue = ((Boolean JavaDoc) expectedValue).booleanValue();
41                 else
42                     return false; // cant work with anything else
43
}
44             final WorkbenchWindow window = (WorkbenchWindow) receiver;
45             if (PROPERTY_IS_COOLBAR_VISIBLE.equals(property)) {
46                 return defaultExpectedValue == window.getCoolBarVisible();
47             } else if (PROPERTY_IS_PERSPECTIVEBAR_VISIBLE.equals(property)) {
48                 return defaultExpectedValue == window.getPerspectiveBarVisible();
49             }
50         }
51         return false;
52     }
53 }
54
Popular Tags