X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.g2d%2Fsrc%2Forg%2Fsimantics%2Fg2d%2Felement%2Fhandler%2FTextEditor.java;h=d126b4eed486d9b42439aa5249ccc8ba4b68f302;hp=50793876c410a2f5cc30e2dc489d8c85c43ce196;hb=0ae2b770234dfc3cbb18bd38f324125cf0faca07;hpb=24e2b34260f219f0d1644ca7a138894980e25b14 diff --git a/bundles/org.simantics.g2d/src/org/simantics/g2d/element/handler/TextEditor.java b/bundles/org.simantics.g2d/src/org/simantics/g2d/element/handler/TextEditor.java index 50793876c..d126b4eed 100644 --- a/bundles/org.simantics.g2d/src/org/simantics/g2d/element/handler/TextEditor.java +++ b/bundles/org.simantics.g2d/src/org/simantics/g2d/element/handler/TextEditor.java @@ -1,84 +1,84 @@ -/******************************************************************************* - * 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.g2d.element.handler; - -import org.simantics.g2d.element.IElement; -import org.simantics.g2d.utils.TextSegment; - -/** - * A handler for supporting inline editing of elements. - * - * @author Antti Villberg - */ -public interface TextEditor extends ElementHandler { - - public interface Modifier { - /** - * Returns the value for the property referred by this modifier. Must - * not return null since the existence of this Modifier - * should be enough proof that a modifiable value actually does exist. - * - * @return the original property value to be modified - */ - public String getValue(IElement element); - - /** - * @param text the text to test for validity - * @return null if the specified label is valid for this - * modifier or an error message if the label is invalid - */ - public String isValid(IElement element, String text); - - /** - * @param element the element to modify - * @param text the new text value to set for the specified element - * @throws IllegalArgumentException if the specified text is invalid - */ - void modify(IElement element, String text) throws IllegalArgumentException; - } - - boolean isActive(IElement e); - void setActive(IElement e, boolean value); - - String getText(IElement e); - void setText(IElement e, String text); - - Modifier getModifier(IElement e); - void setModifier(IElement e, Modifier modifier); - - /** - * @param e - * @return null if there is no selection - */ - TextSegment getSelection(IElement e); - - /** - * @param e - * @param segment a valid selection for the current text or - * null to remove selection - */ - void setSelection(IElement e, TextSegment segment); - - /** - * @param e - * @return a value between [0, {@link #getText(IElement)}.length()] or - * null if no caret. - */ - Integer getCaretPosition(IElement e); - - /** - * @param e - * @param position null to remove caret position - */ - void setCaretPosition(IElement e, Integer position); - -} +/******************************************************************************* + * 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.g2d.element.handler; + +import org.simantics.g2d.element.IElement; +import org.simantics.g2d.utils.TextSegment; + +/** + * A handler for supporting inline editing of elements. + * + * @author Antti Villberg + */ +public interface TextEditor extends ElementHandler { + + public interface Modifier { + /** + * Returns the value for the property referred by this modifier. Must + * not return null since the existence of this Modifier + * should be enough proof that a modifiable value actually does exist. + * + * @return the original property value to be modified + */ + public String getValue(IElement element); + + /** + * @param text the text to test for validity + * @return null if the specified label is valid for this + * modifier or an error message if the label is invalid + */ + public String isValid(IElement element, String text); + + /** + * @param element the element to modify + * @param text the new text value to set for the specified element + * @throws IllegalArgumentException if the specified text is invalid + */ + void modify(IElement element, String text) throws IllegalArgumentException; + } + + boolean isActive(IElement e); + void setActive(IElement e, boolean value); + + String getText(IElement e); + void setText(IElement e, String text); + + Modifier getModifier(IElement e); + void setModifier(IElement e, Modifier modifier); + + /** + * @param e + * @return null if there is no selection + */ + TextSegment getSelection(IElement e); + + /** + * @param e + * @param segment a valid selection for the current text or + * null to remove selection + */ + void setSelection(IElement e, TextSegment segment); + + /** + * @param e + * @return a value between [0, {@link #getText(IElement)}.length()] or + * null if no caret. + */ + Integer getCaretPosition(IElement e); + + /** + * @param e + * @param position null to remove caret position + */ + void setCaretPosition(IElement e, Integer position); + +}