X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.ui%2Fsrc%2Forg%2Fsimantics%2Fui%2Fworkbench%2FTitleRequest.java;fp=bundles%2Forg.simantics.ui%2Fsrc%2Forg%2Fsimantics%2Fui%2Fworkbench%2FTitleRequest.java;h=790a43c07f6446ab96e9c70882d26b5a8e5caaf5;hb=0ae2b770234dfc3cbb18bd38f324125cf0faca07;hp=ba68cf963e9b9b46ff88bcc90a35d03121c2ddcc;hpb=24e2b34260f219f0d1644ca7a138894980e25b14;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.ui/src/org/simantics/ui/workbench/TitleRequest.java b/bundles/org.simantics.ui/src/org/simantics/ui/workbench/TitleRequest.java index ba68cf963..790a43c07 100644 --- a/bundles/org.simantics.ui/src/org/simantics/ui/workbench/TitleRequest.java +++ b/bundles/org.simantics.ui/src/org/simantics/ui/workbench/TitleRequest.java @@ -1,56 +1,56 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 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 - *******************************************************************************/ -package org.simantics.ui.workbench; - -import org.simantics.db.ReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.common.utils.NameUtils; -import org.simantics.db.exception.AdaptionException; -import org.simantics.db.exception.DatabaseException; -import org.simantics.db.request.Read; - -/** - * @author Tuukka Lehtonen - */ -public class TitleRequest implements Read { - - private final String editorId; - - private final IResourceEditorInput input; - - public TitleRequest(String editorId, IResourceEditorInput input) { - this.editorId = editorId; - this.input = input; - } - - @Override - public String perform(ReadGraph graph) throws DatabaseException { - Resource r = input.getResource(); - - try { - String n = null; - IEditorNamingService ems = EditorNaming.getNamingService(graph, r); - if (ems != null) - n = ems.getName(graph, editorId, input); - if (n == null) { - if (r == null) - return "no input resource"; - n = graph.adapt(r, String.class); - } - - return n; - } catch (AdaptionException e) { - return NameUtils.getSafeName(graph, r); - } - } - +/******************************************************************************* + * Copyright (c) 2007, 2010 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 + *******************************************************************************/ +package org.simantics.ui.workbench; + +import org.simantics.db.ReadGraph; +import org.simantics.db.Resource; +import org.simantics.db.common.utils.NameUtils; +import org.simantics.db.exception.AdaptionException; +import org.simantics.db.exception.DatabaseException; +import org.simantics.db.request.Read; + +/** + * @author Tuukka Lehtonen + */ +public class TitleRequest implements Read { + + private final String editorId; + + private final IResourceEditorInput input; + + public TitleRequest(String editorId, IResourceEditorInput input) { + this.editorId = editorId; + this.input = input; + } + + @Override + public String perform(ReadGraph graph) throws DatabaseException { + Resource r = input.getResource(); + + try { + String n = null; + IEditorNamingService ems = EditorNaming.getNamingService(graph, r); + if (ems != null) + n = ems.getName(graph, editorId, input); + if (n == null) { + if (r == null) + return "no input resource"; + n = graph.adapt(r, String.class); + } + + return n; + } catch (AdaptionException e) { + return NameUtils.getSafeName(graph, r); + } + } + } \ No newline at end of file