diff options
Diffstat (limited to 'plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/propsheet/LabelProvider.xtend')
-rw-r--r-- | plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/propsheet/LabelProvider.xtend | 43 |
1 files changed, 21 insertions, 22 deletions
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/propsheet/LabelProvider.xtend b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/propsheet/LabelProvider.xtend index a19cf81a844..5fe0d312b8d 100644 --- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/propsheet/LabelProvider.xtend +++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/xtend/xpt/propsheet/LabelProvider.xtend @@ -1,17 +1,17 @@ -/******************************************************************************* - * Copyright (c) 2007, 2020 Borland Software Corporation, CEA LIST, Artal and others +/***************************************************************************** + * Copyright (c) 2007, 2010, 2013, 2021 Borland Software Corporation, CEA LIST, Artal and others * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * + * https://www.eclipse.org/legal/epl-2.0/ + * * SPDX-License-Identifier: EPL-2.0 * - * Contributors: - * Artem Tikhomirov (Borland) - initial API and implementation - * Michael Golubev (Montages) - #386838 - migrate to Xtend2 - * Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174 + * Contributors: + * Artem Tikhomirov (Borland) - initial API and implementation + * Michael Golubev (Montages) - #386838 - migrate to Xtend2 + * Etienne Allogo (ARTAL) - etienne.allogo@artal.fr - Bug 569174 : 1.4 Merge papyrus extension templates into codegen.xtend *****************************************************************************/ package xpt.propsheet @@ -21,9 +21,11 @@ import xpt.Common import xpt.navigator.NavigatorGroup import xpt.editor.VisualIDRegistry import xpt.providers.ElementTypes +import xpt.CodeStyle @com.google.inject.Singleton class LabelProvider { @Inject extension Common; + @Inject extension CodeStyle; @Inject ElementTypes xptElementTypes; @Inject NavigatorGroup group; @@ -44,34 +46,35 @@ import xpt.providers.ElementTypes def LabelProvider(GenPropertySheet it) ''' «copyright(editorGen)» package «packageName(it)»; - + «generatedClassComment» public class «className(it)» «extendsList(it)» «implementsList(it)» { - + «getTextMethod(it)» «getImageMethod(it)» «unwrapMethods(it)» - - «additions(it)» + } ''' def getTextMethod(GenPropertySheet it) ''' «generatedMemberComment» + «overrideI» public String getText(Object element) { element = unwrap(element); - «IF editorGen.navigator != null» + «IF editorGen.navigator !== null» if (element instanceof «group.qualifiedClassName(editorGen.navigator)») { return ((«group.qualifiedClassName(editorGen.navigator)») element).getGroupName(); } «ENDIF» org.eclipse.gmf.runtime.emf.type.core.IElementType etype = getElementType(getView(element)); - return etype == null ? "" : etype.getDisplayName(); + return etype == null ? "" : etype.getDisplayName(); «nonNLS» } ''' def getImageMethod(GenPropertySheet it) ''' «generatedMemberComment» + «overrideI» public org.eclipse.swt.graphics.Image getImage(Object element) { org.eclipse.gmf.runtime.emf.type.core.IElementType etype = getElementType(getView(unwrap(element))); return etype == null ? null : «xptElementTypes.qualifiedClassName(editorGen.diagram)».getImage(etype); @@ -86,24 +89,23 @@ import xpt.providers.ElementTypes } return element; } - + «generatedMemberComment» private org.eclipse.gmf.runtime.notation.View getView(Object element) { if (element instanceof org.eclipse.gmf.runtime.notation.View) { return (org.eclipse.gmf.runtime.notation.View) element; } if (element instanceof org.eclipse.core.runtime.IAdaptable) { - return (org.eclipse.gmf.runtime.notation.View) - ((org.eclipse.core.runtime.IAdaptable) element).getAdapter(org.eclipse.gmf.runtime.notation.View.class); + return ((org.eclipse.core.runtime.IAdaptable) element).getAdapter(org.eclipse.gmf.runtime.notation.View.class); } return null; } - + «generatedMemberComment» private org.eclipse.gmf.runtime.emf.type.core.IElementType getElementType(org.eclipse.gmf.runtime.notation.View view) { // For intermediate views climb up the containment hierarchy to find the one associated with an element type. while (view != null) { - int vid = «visualId.qualifiedClassName(editorGen.diagram)».getVisualID(view); + String vid = «visualId.qualifiedClassName(editorGen.diagram)».getVisualID(view); org.eclipse.gmf.runtime.emf.type.core.IElementType etype = «xptElementTypes.qualifiedClassName(editorGen.diagram)».getElementType(vid); if (etype != null) { @@ -115,7 +117,4 @@ import xpt.providers.ElementTypes return null; } ''' - - def additions(GenPropertySheet it) '''''' - } |