package org.eclipse.gmf.tooling.examples.affixednode.diagram.providers; import org.eclipse.core.runtime.IAdaptable; import org.eclipse.emf.ecore.EAttribute; import org.eclipse.emf.ecore.EObject; import org.eclipse.gmf.runtime.common.core.service.AbstractProvider; import org.eclipse.gmf.runtime.common.core.service.IOperation; import org.eclipse.gmf.runtime.common.ui.services.parser.GetParserOperation; import org.eclipse.gmf.runtime.common.ui.services.parser.IParser; import org.eclipse.gmf.runtime.common.ui.services.parser.IParserProvider; import org.eclipse.gmf.runtime.common.ui.services.parser.ParserService; import org.eclipse.gmf.runtime.emf.type.core.IElementType; import org.eclipse.gmf.runtime.emf.ui.services.parser.ParserHintAdapter; import org.eclipse.gmf.runtime.notation.View; import org.eclipse.gmf.tooling.examples.affixednode.AffixedNodePackage; import org.eclipse.gmf.tooling.examples.affixednode.diagram.edit.parts.BundleNameEditPart; import org.eclipse.gmf.tooling.examples.affixednode.diagram.parsers.MessageFormatParser; import org.eclipse.gmf.tooling.examples.affixednode.diagram.part.AffixednodeVisualIDRegistry; /** * @generated */ public class AffixednodeParserProvider extends AbstractProvider implements IParserProvider { /** * @generated */ private IParser bundleName_5001Parser; /** * @generated */ private IParser getBundleName_5001Parser() { if (bundleName_5001Parser == null) { EAttribute[] features = new EAttribute[] { AffixedNodePackage.eINSTANCE.getBundle_Name() }; MessageFormatParser parser = new MessageFormatParser(features); bundleName_5001Parser = parser; } return bundleName_5001Parser; } /** * @generated */ protected IParser getParser(int visualID) { switch (visualID) { case BundleNameEditPart.VISUAL_ID: return getBundleName_5001Parser(); } return null; } /** * Utility method that consults ParserService * @generated */ public static IParser getParser(IElementType type, EObject object, String parserHint) { return ParserService.getInstance().getParser(new HintAdapter(type, object, parserHint)); } /** * @generated */ public IParser getParser(IAdaptable hint) { String vid = (String) hint.getAdapter(String.class); if (vid != null) { return getParser(AffixednodeVisualIDRegistry.getVisualID(vid)); } View view = (View) hint.getAdapter(View.class); if (view != null) { return getParser(AffixednodeVisualIDRegistry.getVisualID(view)); } return null; } /** * @generated */ public boolean provides(IOperation operation) { if (operation instanceof GetParserOperation) { IAdaptable hint = ((GetParserOperation) operation).getHint(); if (AffixednodeElementTypes.getElement(hint) == null) { return false; } return getParser(hint) != null; } return false; } /** * @generated */ private static class HintAdapter extends ParserHintAdapter { /** * @generated */ private final IElementType elementType; /** * @generated */ public HintAdapter(IElementType type, EObject object, String parserHint) { super(object, parserHint); assert type != null; elementType = type; } /** * @generated */ public Object getAdapter(Class adapter) { if (IElementType.class.equals(adapter)) { return elementType; } return super.getAdapter(adapter); } } }