| /* |
| * 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: |
| * Michael Golubev (Borland) - UML2Tools tweaked version |
| * |
| * Generates code for labels without labelModelFacet's, assuming they have the default parser provider 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"» |
| «EXTENSION xpt::GenModelUtils» |
| |
| «AROUND getText FOR gmfgen::GenChildLabelNode-» |
| «REM» |
| Default GMF code works for labelModelFacet |
| We want to extend whis for GenChildLabelNode with modelFacet, say for Properties at profile diagram |
| «ENDREM»«-» |
| «IF null != modelFacet && null == labelModelFacet-» |
| «EXPAND getDiagramLabelTextForLabelWithModelFacetOnly(this, this) FOR modelFacet-» |
| «ELSE-» |
| «targetDef.proceed()-» |
| «ENDIF-» |
| «ENDAROUND» |
| |
| «AROUND getDiagramLabelText(List[gmfgen::GenLabel] labels) FOR gmfgen::GenCommonBase-» |
| «IF labels.isEmpty()-» |
| «ERROR "Empty list of labels passed"-» |
| «ENDIF-» |
| «LET (gmfgen::GenLabel) labels.select(l | null != l.modelFacet).first() AS label-» |
| «IF null == label-» |
| return ""; |
| «ELSE-» |
| «targetDef.proceed()-» |
| «ENDIF-» |
| «ENDLET-» |
| «ENDAROUND» |
| |
| «DEFINE getDiagramLabelTextForLabelWithModelFacetOnly(gmfgen::GenCommonBase elementTypeHolder, gmfgen::GenCommonBase hintHolder) FOR gmfgen::TypeModelFacet-» |
| «REM» |
| At the time of writing, below is almost exact copy of the GMF getDiagramLabelText() DEFINE |
| «ENDREM»«-» |
| org.eclipse.core.runtime.IAdaptable hintAdapter = new «elementTypeHolder.getDiagram().getParserProviderQualifiedClassName()».HintAdapter(«elementTypeHolder.getDiagram().getElementTypesQualifiedClassName()».«elementTypeHolder.getUniqueIdentifier()», (view.getElement() != null ? view.getElement() : view), «EXPAND hintForCaseWithModelFacetOnly(hintHolder)»); |
| org.eclipse.gmf.runtime.common.ui.services.parser.IParser parser = org.eclipse.gmf.runtime.common.ui.services.parser.ParserService.getInstance().getParser(hintAdapter); |
| |
| if (parser != null) { |
| return parser.getPrintString(hintAdapter, org.eclipse.gmf.runtime.common.ui.services.parser.ParserOptions.NONE.intValue()); |
| } else { |
| «hintHolder.getDiagram().editorGen.plugin.getActivatorQualifiedClassName()».getInstance().logError("Parser was not found for label " + «hintHolder.visualID»); «EXPAND xpt::Common::nonNLS» |
| «EXPAND xpt::navigator::NavigatorLabelProvider::returnEmptyString-» |
| } |
| «ENDDEFINE» |
| |
| «DEFINE hintForCaseWithModelFacetOnly(gmfgen::GenCommonBase hintHolder) FOR gmfgen::ModelFacet»«EXPAND xpt::editor::VisualIDRegistry::getTypeMethodCall FOR hintHolder.getDiagram()»(«EXPAND xpt::editor::VisualIDRegistry::visualID FOR hintHolder»)«ENDDEFINE» |