| /******************************************************************************* |
| * Copyright (c) 2018 Agence spatiale canadienne / Canadian Space Agency |
| * 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: |
| * Pierre Allard, |
| * Regent L'Archeveque - initial API and implementation |
| * |
| * SPDX-License-Identifier: EPL-1.0 |
| *******************************************************************************/ |
| package org.eclipse.apogy.examples.robotic_arm.ui.converters; |
| |
| import org.eclipse.apogy.common.converters.IConverter; |
| import org.eclipse.apogy.core.invocator.ApogyCoreInvocatorFacade; |
| import org.eclipse.apogy.core.invocator.InvocatorSession; |
| import org.eclipse.apogy.core.invocator.Variable; |
| import org.eclipse.apogy.examples.robotic_arm.RoboticArm; |
| import org.eclipse.emf.ecore.EObject; |
| |
| public class VariableToRoboticArmConverter implements IConverter { |
| @Override |
| public boolean canConvert(Object object) { |
| InvocatorSession activeSession = ApogyCoreInvocatorFacade.INSTANCE.getActiveInvocatorSession(); |
| |
| if (activeSession != null) { |
| EObject inst = ApogyCoreInvocatorFacade.INSTANCE.getInstance((Variable) object); |
| |
| if ((inst instanceof RoboticArm) == true) { |
| return true; |
| } |
| } |
| |
| return false; |
| } |
| |
| @Override |
| public Object convert(Object object) throws Exception { |
| return ApogyCoreInvocatorFacade.INSTANCE.getInstance((Variable) object); |
| } |
| |
| @Override |
| public Class<?> getInputType() { |
| return Variable.class; |
| } |
| |
| @Override |
| public Class<?> getOutputType() { |
| return RoboticArm.class; |
| } |
| } |