| package people.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 people.PeoplePackage; |
| import people.diagram.edit.parts.PersonNameEditPart; |
| import people.diagram.parsers.MessageFormatParser; |
| import people.diagram.part.PeopleVisualIDRegistry; |
| |
| /** |
| * @generated |
| */ |
| public class PeopleParserProvider extends AbstractProvider implements |
| IParserProvider { |
| |
| /** |
| * @generated |
| */ |
| private IParser personName_5001Parser; |
| |
| /** |
| * @generated |
| */ |
| private IParser getPersonName_5001Parser() { |
| if (personName_5001Parser == null) { |
| EAttribute[] features = new EAttribute[] { PeoplePackage.eINSTANCE |
| .getPerson_Name() }; |
| EAttribute[] editableFeatures = new EAttribute[] { PeoplePackage.eINSTANCE |
| .getPerson_Name() }; |
| MessageFormatParser parser = new MessageFormatParser(features, |
| editableFeatures); |
| personName_5001Parser = parser; |
| } |
| return personName_5001Parser; |
| } |
| |
| /** |
| * @generated |
| */ |
| protected IParser getParser(int visualID) { |
| switch (visualID) { |
| case PersonNameEditPart.VISUAL_ID: |
| return getPersonName_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(PeopleVisualIDRegistry.getVisualID(vid)); |
| } |
| View view = (View) hint.getAdapter(View.class); |
| if (view != null) { |
| return getParser(PeopleVisualIDRegistry.getVisualID(view)); |
| } |
| return null; |
| } |
| |
| /** |
| * @generated |
| */ |
| public boolean provides(IOperation operation) { |
| if (operation instanceof GetParserOperation) { |
| IAdaptable hint = ((GetParserOperation) operation).getHint(); |
| if (PeopleElementTypes.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); |
| } |
| } |
| |
| } |