diff options
author | Stefan Dirix | 2017-02-24 13:07:32 +0000 |
---|---|---|
committer | Gerrit Code Review @ Eclipse.org | 2017-02-24 16:16:53 +0000 |
commit | 03504dc3c9822cb7b4672ef35c30d17cae232bb2 (patch) | |
tree | a43f2575dd2f116639d1d8946b4d46c75b7c686e /bundles | |
parent | e3d30244126b6fd89dcc9ac2a3b94527a7f0d1d2 (diff) | |
download | org.eclipse.emf.ecp.core-03504dc3c9822cb7b4672ef35c30d17cae232bb2.tar.gz org.eclipse.emf.ecp.core-03504dc3c9822cb7b4672ef35c30d17cae232bb2.tar.xz org.eclipse.emf.ecp.core-03504dc3c9822cb7b4672ef35c30d17cae232bb2.zip |
Bug 508485 - Remove leading '%' in container labels
Temporary fix until proper support for i18n in the JSON Forms renderer:
The exporter will remove leading % chars in the label and separate camel
casing by a space char.
Signed-off-by: Stefan Dirix <sdirix@eclipsesource.com>
Change-Id: I194389ae3f50b540882f4149341a5b3429c0795b
Diffstat (limited to 'bundles')
-rw-r--r-- | bundles/org.eclipse.emf.ecp.emf2web.json/src/org/eclipse/emf/ecp/emf2web/json/generator/FormsJsonGenerator.xtend | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/bundles/org.eclipse.emf.ecp.emf2web.json/src/org/eclipse/emf/ecp/emf2web/json/generator/FormsJsonGenerator.xtend b/bundles/org.eclipse.emf.ecp.emf2web.json/src/org/eclipse/emf/ecp/emf2web/json/generator/FormsJsonGenerator.xtend index c528681409..8039793907 100644 --- a/bundles/org.eclipse.emf.ecp.emf2web.json/src/org/eclipse/emf/ecp/emf2web/json/generator/FormsJsonGenerator.xtend +++ b/bundles/org.eclipse.emf.ecp.emf2web.json/src/org/eclipse/emf/ecp/emf2web/json/generator/FormsJsonGenerator.xtend @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2014-2015 EclipseSource Muenchen GmbH and others. + * Copyright (c) 2014-2017 EclipseSource Muenchen GmbH and others. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -109,7 +109,7 @@ class FormsJsonGenerator extends JsonGenerator { val jsonObject = new JsonObject jsonObject.withType(container.type) if(container.name!=null) { - jsonObject.withLabel(container.label) + jsonObject.withLabel(container.label.displayLabel) } jsonObject.withElements(container.children) } @@ -154,4 +154,23 @@ class FormsJsonGenerator extends JsonGenerator { refHelper.getLabel(control.domainModelReference) } + private def String getDisplayLabel(String containerLabel){ + if(containerLabel.trim.startsWith("%")){ + var label = containerLabel.trim.substring(1); + val split = label.split("(?<!(^|[A-Z]))(?=[A-Z])|(?<!^)(?=[A-Z][a-z])"); //$NON-NLS-1$ + if(split.get(0).length > 0){ + val charArray = split.get(0).toCharArray(); + charArray.set(0, Character.toUpperCase(charArray.get(0))) + split.set(0, new String(charArray)) + } + val sb = new StringBuilder(); + for (str : split) { + sb.append(str); + sb.append(" "); //$NON-NLS-1$ + } + return sb.toString.trim; + } + containerLabel + } + } |