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
10 * VTT Technical Research Centre of Finland - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.simantics.browsing.ui.swt.contentassist;
\r
15 * @author Tuukka Lehtonen
\r
17 public class NamedObjectContentProposal implements INamedObjectContentProposal {
\r
19 private final NamedObject<?> object;
\r
20 private final int position;
\r
22 public NamedObjectContentProposal(NamedObject<?> object, int position) {
\r
23 this.object = object;
\r
24 this.position = position;
\r
28 public INamedObject getNamedObject() {
\r
32 @SuppressWarnings("unchecked")
\r
33 public <T> T getObject() {
\r
34 return (T) object.getObject();
\r
38 public String getContent() {
\r
39 return object.getName().substring(position);
\r
43 public int getCursorPosition() {
\r
44 return object.getName().length();
\r
48 public String getLabel() {
\r
49 return object.getLabel();
\r
53 public String getDescription() {
\r
54 return object.getDescription();
\r
58 public String toString() {
\r
59 return getClass().getSimpleName() + "[" + object.toString() + "]";
\r