]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.browsing.ui.swt/src/org/simantics/browsing/ui/swt/contentassist/NamedObjectContentProposal.java
39cf3e4af26446fb04dd2f6c50bf252518f9685f
[simantics/platform.git] / bundles / org.simantics.browsing.ui.swt / src / org / simantics / browsing / ui / swt / contentassist / NamedObjectContentProposal.java
1 /*******************************************************************************\r
2  * Copyright (c) 2007, 2012 Association for Decentralized Information Management\r
3  * in Industry THTH ry.\r
4  * All rights reserved. This program and the accompanying materials\r
5  * are made available under the terms of the Eclipse Public License v1.0\r
6  * which accompanies this distribution, and is available at\r
7  * http://www.eclipse.org/legal/epl-v10.html\r
8  *\r
9  * Contributors:\r
10  *     VTT Technical Research Centre of Finland - initial API and implementation\r
11  *******************************************************************************/\r
12 package org.simantics.browsing.ui.swt.contentassist;\r
13 \r
14 /**\r
15  * @author Tuukka Lehtonen\r
16  */\r
17 public class NamedObjectContentProposal implements INamedObjectContentProposal {\r
18 \r
19     private final NamedObject<?> object;\r
20     private final int         position;\r
21 \r
22     public NamedObjectContentProposal(NamedObject<?> object, int position) {\r
23         this.object = object;\r
24         this.position = position;\r
25     }\r
26 \r
27     @Override\r
28     public INamedObject getNamedObject() {\r
29         return object;\r
30     }\r
31 \r
32     @SuppressWarnings("unchecked")\r
33     public <T> T getObject() {\r
34         return (T) object.getObject();\r
35     }\r
36 \r
37     @Override\r
38     public String getContent() {\r
39         return object.getName().substring(position);\r
40     }\r
41 \r
42     @Override\r
43     public int getCursorPosition() {\r
44         return object.getName().length();\r
45     }\r
46 \r
47     @Override\r
48     public String getLabel() {\r
49         return object.getLabel();\r
50     }\r
51 \r
52     @Override\r
53     public String getDescription() {\r
54         return object.getDescription();\r
55     }\r
56 \r
57     @Override\r
58     public String toString() {\r
59         return getClass().getSimpleName() + "[" + object.toString() + "]";\r
60     }\r
61 \r
62 }\r