|
Re: Synchronization between Property Sheet and Tree View outline [message #206246 is a reply to message #206229] |
Mon, 22 September 2008 13:54 |
Eclipse User |
|
|
|
Originally posted by: me.urszeidler.de
You will need to configure a propertyConstributer :
<extension
point="org.eclipse.ui.views.properties.tabbed.propertyContributor ">
<?gmfgen generated="false"?>
<propertyContributor
contributorId="de.urszeidler.eclipse.callchain.diagram"
labelProvider=" de.urszeidler.eclipse.callchain.diagram.sheet.CallchainSheet LabelProvider "
typeMapper=" de.urszeidler.eclipse.callchain.diagram.CallchainGMF2EMFType Mapper ">
<propertyCategory category="domain"/>
<propertyCategory category="visual"/>
<propertyCategory category="extra"/>
<propertyCategory category="advanced"/>
</propertyContributor>
</extension>
and a Typemapper :
/*
* (c) urs zeidler
*/
package de.urszeidler.eclipse.callchain.diagram;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.Platform;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.ui.views.properties.tabbed.AbstractTypeMapper;
import org.eclipse.ui.views.properties.tabbed.ITypeMapper;
/**
* <p>
* CallchainGMF2EMFTypeMapper
* </p>
* Created : 05.06.2008
* @author urs
* @version $Revision$, $Id$
*/
public class CallchainGMF2EMFTypeMapper extends AbstractTypeMapper
implements
ITypeMapper {
public Class<?> mapType(Object object) {
EObject eObject = adaptObject(object);
if (eObject != null) {
return eObject.getClass();
}
return super.mapType(object);
}
/**
* Returns the EObject associated with the given object. Returns
<code>null</code> if no such object can be found.
*
*
* @param object The object to look up its associated EObject
* @return the EObject associated to the given object, or
<code>null</code> if this object does not have any.
*/
public static EObject adaptObject(Object object)
{
if (object == null)
{
return null;
}
else if (object instanceof EObject)
{
return (EObject) object;
}
else if (object instanceof IAdaptable)
{
// Try IAdaptable
IAdaptable adapted = (IAdaptable) object;
Object eObject = adapted.getAdapter(EObject.class);
if (eObject != null)
{
return (EObject) eObject;
}
}
else
{
// Try registered adapter
Object adapted =
Platform.getAdapterManager().getAdapter(object, EObject.class);
if (adapted != null)
{
return (EObject) adapted;
}
}
return null;
}
}
greetings urs.
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03902 seconds