1 /* 2 * The contents of this file are subject to the terms of the Common Development 3 * and Distribution License (the License). You may not use this file except in 4 * compliance with the License. 5 * 6 * You can obtain a copy of the License at http://www.netbeans.org/cddl.html 7 * or http://www.netbeans.org/cddl.txt. 8 * 9 * When distributing Covered Code, include this CDDL Header Notice in each file 10 * and include the License file at http://www.netbeans.org/cddl.txt. 11 * If applicable, add the following below the CDDL Header, with the fields 12 * enclosed by brackets [] replaced by your own identifying information: 13 * "Portions Copyrighted [year] [name of copyright owner]" 14 * 15 * The Original Software is NetBeans. The Initial Developer of the Original 16 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun 17 * Microsystems, Inc. All Rights Reserved. 18 */ 19 20 package org.openide.cookies; 21 22 import java.util.NoSuchElementException; 23 24 import org.openide.nodes.Node; 25 import org.openide.src.SourceElement; 26 27 /** A cookie for obtaining a source hierarchy from data objects. 28 * 29 * @author Dafe Simonek, Petr Hamernik 30 */ 31 public interface SourceCookie extends Node.Cookie { 32 33 /** Returns a source element describing the hierarchy 34 * of the source. 35 * 36 * @return the element 37 */ 38 public SourceElement getSource (); 39 40 /** Extended source cookie permitting for bidirectional translation with Swing text elements. 41 */ 42 public interface Editor extends SourceCookie, EditorCookie { 43 /** Translate a source element to text. 44 * 45 * @param element an element from the source hierarchy 46 * @return a text element 47 */ 48 public javax.swing.text.Element sourceToText(org.openide.src.Element element); 49 50 /** Translate a text element to a source element, if it is possible to do so. 51 * 52 * @param element a text element 53 * @return the element from the source hierarchy 54 * @exception NoSuchElementException if the text element doesn't match 55 * any element from the source hierarchy 56 */ 57 public org.openide.src.Element textToSource(javax.swing.text.Element element) 58 throws NoSuchElementException; 59 60 /** Find the element at the specified offset in the document. 61 * @param offset The position of the element 62 * @return the element at the position. 63 */ 64 public org.openide.src.Element findElement(int offset); 65 } 66 } 67