diff -r 631a44165bcf -r 033392511bf7 carbidecpp22devenv/plugins/org.eclipse.gmf.templates.legacy_1.0.0.v20090614-0839/codegen.templates/xpt/parsers/NativeParser.xpt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/carbidecpp22devenv/plugins/org.eclipse.gmf.templates.legacy_1.0.0.v20090614-0839/codegen.templates/xpt/parsers/NativeParser.xpt Fri Dec 04 11:06:59 2009 -0600 @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2007 Borland Software Corporation + * + * 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: + * Dmitry Stadnik (Borland) - initial API and implementation + */ + +«IMPORT "http://www.eclipse.org/gmf/2008/GenModel"» +«IMPORT "http://www.eclipse.org/emf/2002/GenModel"» +«IMPORT "http://www.eclipse.org/emf/2002/Ecore"» + +«DEFINE className FOR gmfgen::GenDiagram»NativeParser«ENDDEFINE» + +«DEFINE qualifiedClassName FOR gmfgen::GenDiagram»«parsersPackageName».«EXPAND className»«ENDDEFINE» + +«DEFINE NativeParser FOR gmfgen::GenDiagram-» +«EXPAND xpt::Common::copyright FOR editorGen-» +package «parsersPackageName»; + +«EXPAND xpt::Common::generatedClassComment» +public class «EXPAND className» extends «EXPAND xpt::parsers::AbstractParser::qualifiedClassName» { + + «EXPAND xpt::Common::generatedMemberComment» + public «EXPAND className»(org.eclipse.emf.ecore.EAttribute[] features) { + super(features); + if (features.length != 1) { + throw new IllegalArgumentException(java.util.Arrays.toString(features)); + } + } + + «EXPAND xpt::Common::generatedMemberComment» + protected org.eclipse.emf.ecore.EAttribute getAttribute() { + return features[0]; + } + + «EXPAND xpt::Common::generatedMemberComment» + public String getPrintString(org.eclipse.core.runtime.IAdaptable adapter, int flags) { + org.eclipse.emf.ecore.EObject element = + (org.eclipse.emf.ecore.EObject) adapter.getAdapter(org.eclipse.emf.ecore.EObject.class); + org.eclipse.emf.ecore.EAttribute feature = getAttribute(); + String s = org.eclipse.emf.ecore.util.EcoreUtil.convertToString( + feature.getEAttributeType(), element.eGet(feature)); + return s != null ? s : ""; «EXPAND xpt::Common::nonNLS» + } + + «EXPAND xpt::Common::generatedMemberComment» + public String getEditString(org.eclipse.core.runtime.IAdaptable adapter, int flags) { + return getPrintString(adapter, flags); + } + + «EXPAND xpt::Common::generatedMemberComment» + public org.eclipse.gmf.runtime.common.ui.services.parser.IParserEditStatus isValidEditString( + org.eclipse.core.runtime.IAdaptable adapter, String editString) { + return org.eclipse.gmf.runtime.common.ui.services.parser.ParserEditStatus.EDITABLE_STATUS; + } + + «EXPAND xpt::Common::generatedMemberComment» + public org.eclipse.gmf.runtime.common.core.command.ICommand getParseCommand( + org.eclipse.core.runtime.IAdaptable adapter, String newString, int flags) { + org.eclipse.emf.ecore.EAttribute feature = getAttribute(); + Object value = org.eclipse.emf.ecore.util.EcoreUtil.createFromString(feature.getEAttributeType(), newString); + return getParseCommand(adapter, new Object[] { value }, flags); + } + «EXPAND additions-» +} +«ENDDEFINE» + +«DEFINE additions FOR gmfgen::GenDiagram»«ENDDEFINE»