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