01: /*******************************************************************************
02: * Copyright (c) 2007 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: ******************************************************************************/package org.eclipse.ui.internal;
11:
12: import org.eclipse.core.expressions.PropertyTester;
13:
14: /**
15: * Tests various workbench window properties.
16: *
17: * @since 3.3
18: *
19: */
20: public class WorkbenchWindowPropertyTester extends PropertyTester {
21:
22: private static final String PROPERTY_IS_COOLBAR_VISIBLE = "isCoolbarVisible"; //$NON-NLS-1$
23: private static final String PROPERTY_IS_PERSPECTIVEBAR_VISIBLE = "isPerspectiveBarVisible"; //$NON-NLS-1$
24:
25: /*
26: * (non-Javadoc)
27: *
28: * @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object,
29: * java.lang.String, java.lang.Object[], java.lang.Object)
30: */
31: public boolean test(Object receiver, String property,
32: Object[] args, Object expectedValue) {
33:
34: if (args.length == 0 && receiver instanceof WorkbenchWindow) {
35: boolean defaultExpectedValue = true;
36: if (expectedValue != null) {
37: if (expectedValue instanceof Boolean)
38: defaultExpectedValue = ((Boolean) expectedValue)
39: .booleanValue();
40: else
41: return false; // cant work with anything else
42: }
43: final WorkbenchWindow window = (WorkbenchWindow) receiver;
44: if (PROPERTY_IS_COOLBAR_VISIBLE.equals(property)) {
45: return defaultExpectedValue == window
46: .getCoolBarVisible();
47: } else if (PROPERTY_IS_PERSPECTIVEBAR_VISIBLE
48: .equals(property)) {
49: return defaultExpectedValue == window
50: .getPerspectiveBarVisible();
51: }
52: }
53: return false;
54: }
55: }
|