| /******************************************************************************* |
| * Copyright (c) 2010-2011, Istvan Rath and Zoltan Ujhelyi |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v1.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/epl-v10.html |
| * |
| * Contributors: |
| * Istvan Rath - initial API and implementation |
| *******************************************************************************/ |
| |
| package org.eclipse.viatra2.visualisation.common.labelproviders.natives; |
| |
| import org.eclipse.viatra2.core.IModelSpace; |
| import org.eclipse.viatra2.errors.VPMRuntimeException; |
| import org.eclipse.viatra2.logger.Logger; |
| import org.eclipse.viatra2.natives.ASMNativeFunction; |
| import org.eclipse.viatra2.visualisation.IVisualisationDescriptor; |
| import org.eclipse.viatra2.visualisation.VisualisationPlugin; |
| |
| /** |
| * @author Zoltan Ujhelyi |
| * |
| */ |
| public abstract class AbstractVisualisationFunction implements |
| ASMNativeFunction { |
| |
| protected IVisualisationDescriptor descriptor; |
| |
| /* (non-Javadoc) |
| * @see org.eclipse.viatra2.natives.ASMNativeFunction#evaluate(org.eclipse.viatra2.core.IModelSpace, java.lang.Object[]) |
| */ |
| @Override |
| public Object evaluate(IModelSpace msp, Object[] params) |
| throws VPMRuntimeException { |
| descriptor = VisualisationPlugin.getVisualisationManager().getVisualisation(msp.getFramework()); |
| if (descriptor != null) { |
| return run(msp, params); |
| } else { |
| msp.getFramework().getLogger().message(Logger.WARNING, "Visualisation is not initialized"); |
| return Boolean.FALSE; |
| } |
| } |
| |
| protected abstract Object run(IModelSpace msp, Object[] params) throws VPMRuntimeException; |
| |
| } |