-/*******************************************************************************\r
- * Copyright (c) 2014 Association for Decentralized Information Management\r
- * in Industry THTH ry.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- * VTT Technical Research Centre of Finland - initial API and implementation\r
- * Semantum Oy - initial API and implementation\r
- *******************************************************************************/\r
-package org.simantics.ui.workbench;\r
-\r
-import org.simantics.databoard.Bindings;\r
-import org.simantics.db.ReadGraph;\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.common.request.UnaryRead;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.layer0.Layer0;\r
-\r
-/**\r
- * A simple request that takes an IResourceEditorInput as input and calculates\r
- * the following editor title from it:\r
- * <code>input-name (input-parent-name)</code>.\r
- * \r
- * @author Hannu Niemistö\r
- * @author Tuukka Lehtonen\r
- * @see TitleRequest\r
- */\r
-public class TitleWithParentNameRequest extends UnaryRead<IResourceEditorInput, String> {\r
-\r
- public TitleWithParentNameRequest(IResourceEditorInput input) {\r
- super(input);\r
- }\r
-\r
- @Override\r
- public String perform(ReadGraph graph) throws DatabaseException {\r
- Layer0 L0 = Layer0.getInstance(graph);\r
- Resource r = parameter.getResource();\r
- Resource parent = graph.getPossibleObject(r, L0.PartOf);\r
- String name = safeName(graph, r, "No name", L0);\r
- String parentName = safeName(graph, parent, "No parent", L0);\r
- return name + " (" + parentName + ")";\r
- }\r
-\r
- protected String safeName(ReadGraph graph, Resource r, String noNameValue, Layer0 L0) throws DatabaseException {\r
- if (r != null) {\r
- String name = graph.getPossibleRelatedValue(r, L0.HasName, Bindings.STRING);\r
- if (name != null) {\r
- return name;\r
- }\r
- }\r
- return noNameValue;\r
- }\r
- \r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2014 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
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VTT Technical Research Centre of Finland - initial API and implementation
+ * Semantum Oy - initial API and implementation
+ *******************************************************************************/
+package org.simantics.ui.workbench;
+
+import org.simantics.databoard.Bindings;
+import org.simantics.db.ReadGraph;
+import org.simantics.db.Resource;
+import org.simantics.db.common.request.UnaryRead;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.layer0.Layer0;
+
+/**
+ * A simple request that takes an IResourceEditorInput as input and calculates
+ * the following editor title from it:
+ * <code>input-name (input-parent-name)</code>.
+ *
+ * @author Hannu Niemistö
+ * @author Tuukka Lehtonen
+ * @see TitleRequest
+ */
+public class TitleWithParentNameRequest extends UnaryRead<IResourceEditorInput, String> {
+
+ public TitleWithParentNameRequest(IResourceEditorInput input) {
+ super(input);
+ }
+
+ @Override
+ public String perform(ReadGraph graph) throws DatabaseException {
+ Layer0 L0 = Layer0.getInstance(graph);
+ Resource r = parameter.getResource();
+ Resource parent = graph.getPossibleObject(r, L0.PartOf);
+ String name = safeName(graph, r, "No name", L0);
+ String parentName = safeName(graph, parent, "No parent", L0);
+ return name + " (" + parentName + ")";
+ }
+
+ protected String safeName(ReadGraph graph, Resource r, String noNameValue, Layer0 L0) throws DatabaseException {
+ if (r != null) {
+ String name = graph.getPossibleRelatedValue(r, L0.HasName, Bindings.STRING);
+ if (name != null) {
+ return name;
+ }
+ }
+ return noNameValue;
+ }
+
+}