]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.ui/src/org/simantics/ui/workbench/ToolTipRequest.java
Modified OpenWith for further customization.
[simantics/platform.git] / bundles / org.simantics.ui / src / org / simantics / ui / workbench / ToolTipRequest.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management
3  * in Industry THTH ry.
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
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.ui.workbench;
13
14 import org.simantics.Simantics;
15 import org.simantics.db.ReadGraph;
16 import org.simantics.db.Resource;
17 import org.simantics.db.exception.DatabaseException;
18 import org.simantics.db.request.Read;
19 import org.simantics.project.IProject;
20
21 /**
22  * @author Tuukka Lehtonen
23  */
24 public class ToolTipRequest implements Read<String> {
25
26     private final String               editorId;
27
28     private final IResourceEditorInput input;
29
30     public ToolTipRequest(String editorId, IResourceEditorInput input) {
31         this.editorId = editorId;
32         this.input = input;
33     }
34
35     @Override
36     public String perform(ReadGraph graph) throws DatabaseException {
37         Resource r = input.getResource();
38
39         IProject p = Simantics.peekProject();
40         if (p != null) {
41             IEditorNamingService ems = EditorNaming.getNamingService(graph, r); 
42             if (ems instanceof IEditorNamingService2)
43                 return ((IEditorNamingService2) ems).getToolTipText(graph, editorId, input);
44         }
45
46         return graph.syncRequest(new TitleRequest(editorId, input));
47     }
48
49 }