From: Tuukka Lehtonen Date: Fri, 5 May 2017 14:25:08 +0000 (+0300) Subject: Changed external reference flag texts to obey current name/label mode X-Git-Tag: v1.29.0~72 X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=commitdiff_plain;h=8b94180c57f10788d52eb15b8ef3d73b4461de93;hp=53e9b3dac5648f360cd91478d9e6e7a495631b08 Changed external reference flag texts to obey current name/label mode Text shown in external reference type diagram flags now obeys the currently selected Name/Label model that can be controlled using code in class org.simantics.NameLabelUtil. Previously the text shown in normal diagram external reference flags was always preferring to show the Label property of diagrams and related modules and if labels were not defined, the Name property would be used instead. refs #7178 Change-Id: I85efb6e68f92fdb18d1445037da5285700ca5398 --- diff --git a/bundles/org.simantics.diagram/src/org/simantics/diagram/query/FlagTextQuery.java b/bundles/org.simantics.diagram/src/org/simantics/diagram/query/FlagTextQuery.java index 0c097c53d..3db108909 100644 --- a/bundles/org.simantics.diagram/src/org/simantics/diagram/query/FlagTextQuery.java +++ b/bundles/org.simantics.diagram/src/org/simantics/diagram/query/FlagTextQuery.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 Association for Decentralized Information Management + * Copyright (c) 2007, 2017 Association for Decentralized Information Management * in Industry THTH ry. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -8,15 +8,16 @@ * * Contributors: * VTT Technical Research Centre of Finland - initial API and implementation + * Semantum Oy - #7178 Use NameLabelUtil *******************************************************************************/ package org.simantics.diagram.query; import java.util.ArrayList; import java.util.Collection; +import org.simantics.NameLabelUtil; import org.simantics.db.ReadGraph; import org.simantics.db.Resource; -import org.simantics.db.Statement; import org.simantics.db.common.request.ResourceRead; import org.simantics.db.common.utils.NameUtils; import org.simantics.db.exception.DatabaseException; @@ -125,16 +126,7 @@ public class FlagTextQuery extends ResourceRead { } public static String getSafeLabel(ReadGraph graph, Resource r) throws DatabaseException { - Layer0 l0 = Layer0.getInstance(graph); - Statement stm = graph.getPossibleStatement(r, l0.HasLabel); - if (stm != null) { - String label = NameUtils.getSafeLabel(graph, r); - if (!label.isEmpty()) - return label; - //if (!stm.isAsserted(r)) - // return label; - } - return NameUtils.getSafeName(graph, r); + return NameLabelUtil.modalName(graph, r); } }