1 /*******************************************************************************
\r
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
\r
3 * in Industry THTH ry.
\r
4 * All rights reserved. This program and the accompanying materials
\r
5 * are made available under the terms of the Eclipse Public License v1.0
\r
6 * which accompanies this distribution, and is available at
\r
7 * http://www.eclipse.org/legal/epl-v10.html
\r
10 * VTT Technical Research Centre of Finland - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.simantics.browsing.ui.common.node;
\r
14 import org.eclipse.core.expressions.PropertyTester;
\r
15 import org.eclipse.jface.viewers.IStructuredSelection;
\r
16 import org.simantics.browsing.ui.NodeContext;
\r
17 import org.simantics.utils.ui.AdaptionUtils;
\r
19 public class StandardNodeTester extends PropertyTester {
\r
22 * Tests if the received resource is an instance of any of the URIs
\r
23 * listed in the arguments.
\r
25 private static final String FUNCTION = "standardNodeFunction";
\r
28 public boolean test(final Object receiver, final String property, final Object[] args, final Object expectedValue) {
\r
30 // System.out.println("TEST: " + receiver + ", " + property + ", " + Arrays.toString(args) + ", " + expectedValue);
\r
32 if (!(receiver instanceof IStructuredSelection))
\r
35 NodeContext context = AdaptionUtils.adaptToSingle(receiver, NodeContext.class);
\r
37 if (context == null)
\r
40 if(FUNCTION.equals(property)) {
\r
42 Object function = context.getConstant(StandardNodes.FUNCTION);
\r
43 if(function == null) return false;
\r
44 return args[0].equals(function.toString());
\r