1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.ui.workbench;
14 import org.simantics.db.ReadGraph;
15 import org.simantics.db.Resource;
16 import org.simantics.db.common.utils.NameUtils;
17 import org.simantics.db.exception.AdaptionException;
18 import org.simantics.db.exception.DatabaseException;
19 import org.simantics.db.request.Read;
22 * @author Tuukka Lehtonen
24 public class TitleRequest implements Read<String> {
26 private final String editorId;
28 private final IResourceEditorInput input;
30 public TitleRequest(String editorId, IResourceEditorInput input) {
31 this.editorId = editorId;
36 public String perform(ReadGraph graph) throws DatabaseException {
37 Resource r = input.getResource();
41 IEditorNamingService ems = EditorNaming.getNamingService(graph, r);
43 n = ems.getName(graph, editorId, input);
46 return "no input resource";
47 n = graph.adapt(r, String.class);
51 } catch (AdaptionException e) {
52 return NameUtils.getSafeName(graph, r);