/******************************************************************************* | |
* <copyright> | |
* | |
* Copyright (c) 2013, 2013 SAP AG. | |
* 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: | |
* SAP AG - initial API, implementation and documentation | |
* | |
* </copyright> | |
* | |
*******************************************************************************/ | |
package org.eclipse.fmc.blockdiagram.editor.extension; | |
import org.eclipse.fmc.blockdiagram.editor.model.FMCType; | |
import org.eclipse.graphiti.dt.IDiagramTypeProvider; | |
import org.eclipse.graphiti.features.ICopyFeature; | |
import org.eclipse.graphiti.features.IPasteFeature; | |
import org.eclipse.graphiti.features.IPrintFeature; | |
import org.eclipse.graphiti.features.ISaveImageFeature; | |
import org.eclipse.graphiti.features.context.ICopyContext; | |
import org.eclipse.graphiti.features.context.IPasteContext; | |
import org.eclipse.graphiti.features.impl.AbstractFeatureProvider; | |
import org.eclipse.graphiti.features.impl.IIndependenceSolver; | |
/** | |
* All extensions providing new features to the editor must extend this class. | |
* | |
* @author Benjamin Schmeling | |
* | |
*/ | |
public class ExtensionFeatureProvider extends AbstractFeatureProvider { | |
/** | |
* The main constructor. | |
* | |
* @param diagramTypeProvider The diagram type provider. | |
*/ | |
public ExtensionFeatureProvider(IDiagramTypeProvider diagramTypeProvider) { | |
super(diagramTypeProvider); | |
setIndependenceSolver(new IIndependenceSolver() { | |
/* | |
* (non-Javadoc) | |
* | |
* @see org.eclipse.graphiti.features.impl.IIndependenceSolver# | |
* getKeyForBusinessObject(java.lang.Object) | |
*/ | |
@Override | |
public String getKeyForBusinessObject(Object bo) { | |
if (bo instanceof FMCType) { | |
FMCType type = (FMCType) bo; | |
return type.name(); | |
} else | |
return null; | |
} | |
/* | |
* (non-Javadoc) | |
* | |
* @see org.eclipse.graphiti.features.impl.IIndependenceSolver# | |
* getBusinessObjectForKey(java.lang.String) | |
*/ | |
@Override | |
public Object getBusinessObjectForKey(String key) { | |
return FMCType.valueOf(key); | |
} | |
}); | |
} | |
/* | |
* (non-Javadoc) | |
* | |
* @see | |
* org.eclipse.graphiti.features.IFeatureProvider#getCopyFeature(org.eclipse | |
* .graphiti.features.context.ICopyContext) | |
*/ | |
@Override | |
public final ICopyFeature getCopyFeature(ICopyContext context) { | |
return null; | |
} | |
/* | |
* (non-Javadoc) | |
* | |
* @see | |
* org.eclipse.graphiti.features.IFeatureProvider#getPasteFeature(org.eclipse | |
* .graphiti.features.context.IPasteContext) | |
*/ | |
@Override | |
public final IPasteFeature getPasteFeature(IPasteContext context) { | |
return null; | |
} | |
@Override | |
public IPrintFeature getPrintFeature() { | |
// TODO Auto-generated method stub | |
return null; | |
} | |
@Override | |
public ISaveImageFeature getSaveImageFeature() { | |
// TODO Auto-generated method stub | |
return null; | |
} | |
} |