Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2007 Anyware Technologies 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: Anyware Technologies - initial API and implementation $Id: EcoreParserProvider.java,v 1.7 2009/05/06 14:19:21 jlescot Exp $ /
 
 
 package org.eclipse.emf.ecoretools.diagram.providers;
 
 
 import  org.eclipse.core.runtime.IAdaptable;
 import  org.eclipse.gmf.runtime.common.core.command.ICommand;
 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;

Generated:
 
 public class EcoreParserProvider extends AbstractProvider implements IParserProvider {

Generated:
 
 	private IParser eClassName_4001Parser;

Generated:
 
 	private IParser getEClassName_4001Parser() {
 		if ( == null) {
 			MessageFormatParser parser = new MessageFormatParser(features);
 		}
 	}

Generated:
 
 	private IParser ePackageName_4006Parser;

Generated:
 
 	private IParser getEPackageName_4006Parser() {
 		if ( == null) {
 			MessageFormatParser parser = new MessageFormatParser(features);
 		}
 	}

Generated:
 
 	private IParser eAnnotationSource_4007Parser;

Generated:
 
 	private IParser getEAnnotationSource_4007Parser() {
			MessageFormatParser parser = new MessageFormatParser(features);
		}
	}

Generated:
	private IParser eDataTypeName_4008Parser;

Generated:
	private IParser getEDataTypeName_4008Parser() {
		if ( == null) {
			MessageFormatParser parser = new MessageFormatParser(features);
		}
	}

Generated:

Generated:
			MessageFormatParser parser = new MessageFormatParser(features);
			parser.setViewPattern("<<javaclass>> {0}"); //$NON-NLS-1$
			parser.setEditorPattern("<<javaclass>> {0}"); //$NON-NLS-1$
			parser.setEditPattern("<<javaclass>> {0}"); //$NON-NLS-1$
		}
	}

Generated:
	private IParser eEnumName_4010Parser;

Generated:
	private IParser getEEnumName_4010Parser() {
		if ( == null) {
			MessageFormatParser parser = new MessageFormatParser(features);
		}
	}

Generated:
	private IParser eAttribute_2001Parser;

Generated:
	private IParser getEAttribute_2001Parser() {
		if ( == null) {
			MessageFormatParser parser = new MessageFormatParser(features);
		}
	}

Generated:
	private IParser eOperation_2002Parser;

Generated:
	private IParser getEOperation_2002Parser() {
		if ( == null) {
			MessageFormatParser parser = new MessageFormatParser(features);
		}
	}

Generated:
	private IParser eClassName_4002Parser;

Generated:
	private IParser getEClassName_4002Parser() {
		if ( == null) {
			MessageFormatParser parser = new MessageFormatParser(features);
		}
	}

Generated:
	private IParser eDataTypeName_4003Parser;

Generated:
	private IParser getEDataTypeName_4003Parser() {
		if ( == null) {
			MessageFormatParser parser = new MessageFormatParser(features);
		}
	}

Generated:

Generated:
			MessageFormatParser parser = new MessageFormatParser(features);
			parser.setViewPattern("<<javaclass>> {0}"); //$NON-NLS-1$
			parser.setEditorPattern("<<javaclass>> {0}"); //$NON-NLS-1$
			parser.setEditPattern("<<javaclass>> {0}"); //$NON-NLS-1$
		}
	}

Generated:
	private IParser eEnumName_4005Parser;

Generated:
	private IParser getEEnumName_4005Parser() {
		if ( == null) {
			MessageFormatParser parser = new MessageFormatParser(features);
		}
	}

Generated:
	private IParser eEnumLiteral_2006Parser;

Generated:
	private IParser getEEnumLiteral_2006Parser() {
		if ( == null) {
			MessageFormatParser parser = new MessageFormatParser(features);
		}
	}

Generated:

Generated:
			MessageFormatParser parser = new MessageFormatParser(features);
		}
	}

Generated:
	private IParser eReferenceName_4011Parser;

Generated:
	private IParser getEReferenceName_4011Parser() {
		if ( == null) {
			MessageFormatParser parser = new MessageFormatParser(features);
		}
	}

Generated:

Generated:
NOT
			MessageFormatParser parser = new MessageFormatParser(features) {
				// Bug 216102 : Cardinality edition could be more intuitive
				public ICommand getParseCommand(IAdaptable adapterString newStringint flags) {
					String parsableString = ((StringnewString).replace("*""-1").replace("?""-2"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
					if (parsableString.indexOf("..") == -1) { //$NON-NLS-1$
						parsableString = parsableString.concat("..").concat(parsableString); //$NON-NLS-1$
					}
					Object[] values = getEditProcessor().parse(parsableStringnew ParsePosition(0));
					return getParseCommand(adaptervaluesflags);
				}
			};
			parser.setViewPattern("{0}..{1,choice,-2#?|-1#*|-1<{1}}"); //$NON-NLS-1$
			parser.setEditorPattern("{0}..{1,choice,-2#?|-1#*|-1<{1}}"); //$NON-NLS-1$
			parser.setEditPattern("{0}..{1}"); //$NON-NLS-1$
		}
	}

Generated:
	protected IParser getParser(int visualID) {
		switch (visualID) {
		}
		return null;
	}

Utility method that consults ParserService

Generated:
	public static IParser getParser(IElementType typeEObject objectString parserHint) {
		return ParserService.getInstance().getParser(new HintAdapter(typeobjectparserHint));
	}

Generated:
	public IParser getParser(IAdaptable hint) {
		String vid = (Stringhint.getAdapter(String.class);
		if (vid != null) {
			return getParser(EcoreVisualIDRegistry.getVisualID(vid));
		}
		View view = (View) hint.getAdapter(View.class);
		if (view != null) {
			return getParser(EcoreVisualIDRegistry.getVisualID(view));
		}
		return null;
	}

Generated:
	public boolean provides(IOperation operation) {
		if (operation instanceof GetParserOperation) {
			IAdaptable hint = ((GetParserOperation) operation).getHint();
			if (EcoreElementTypes.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 typeEObject objectString parserHint) {
			super(objectparserHint);
			assert type != null;
			 = type;
		}

Generated:
		public Object getAdapter(Class adapter) {
			if (IElementType.class.equals(adapter)) {
				return ;
			}
			return super.getAdapter(adapter);
		}
	}
New to GrepCode? Check out our FAQ X