KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > ui > text > TypingRun


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jdt.internal.ui.text;
12
13
14
15 /**
16  * Describes a run of similar typing changes.
17  * <p>
18  * XXX to be extended with further information, e.g. offset, length, and
19  * content of the run.
20  * </p>
21  *
22  * @since 3.0
23  */

24 public final class TypingRun {
25     /**
26      * A change of type <code>DELETE</code> deletes one single character (through delete or
27      * backspace or empty paste).
28      */

29     public static final ChangeType DELETE= new ChangeType(true, "DELETE"); //$NON-NLS-1$
30
/**
31      * A change of type <code>INSERT</code> inserts one single character
32      * (normal typing).
33      */

34     public static final ChangeType INSERT= new ChangeType(true, "INSERT"); //$NON-NLS-1$
35
/**
36      * A change of type <code>NO_CHANGE</code> does not change anything.
37      */

38     public static final ChangeType NO_CHANGE= new ChangeType(false, "NO_CHANGE"); //$NON-NLS-1$
39
/**
40      * A change of type <code>OVERTYPE</code> replaces one single character
41      * (overwrite mode, pasting a single character).
42      */

43     public static final ChangeType OVERTYPE= new ChangeType(true, "OVERTYPE"); //$NON-NLS-1$
44
/**
45      * A change of type <code>SELECTION</code> does not change text, but
46      * changes the focus, or selection. Such a change ends all typing runs.
47      */

48     public static final ChangeType SELECTION= new ChangeType(false, "SELECTION"); //$NON-NLS-1$
49
/**
50      * A change of type <code>UNKNOWN</code> modifies text in an
51      * unspecified way. An example is pasting more than one character, or
52      * deleting an entire selection, or reverting a file. Such a change ends
53      * all typing runs and cannot form a typing run with any other change,
54      * including a change of type <code>UNKNOWN</code>.
55      */

56     public static final ChangeType UNKNOWN= new ChangeType(true, "UNKNOWN"); //$NON-NLS-1$
57

58
59     /**
60      * Enumeration of change types.
61      *
62      * @since 3.0
63      */

64     public static final class ChangeType {
65         private final boolean fIsModification;
66         private final String JavaDoc fName;
67
68         /** Private ctor for type safe enumeration. */
69         private ChangeType(boolean isRunPart, String JavaDoc name) {
70             fIsModification= isRunPart;
71             fName= name;
72         }
73
74         /**
75          * Returns <code>true</code> if changes of this type modify text.
76          *
77          * @return <code>true</code> if changes of this type modify text,
78          * <code>false</code> otherwise
79          */

80         boolean isModification() {
81             return fIsModification;
82         }
83
84         /*
85          * @see java.lang.Object#toString()
86          */

87         public String JavaDoc toString() {
88             return fName;
89         }
90     }
91
92     /**
93      * Creates a new run.
94      *
95      * @param type the type of the run
96      */

97     TypingRun(ChangeType type) {
98         this.type= type;
99     }
100
101     /** The change type of this run. */
102     public final ChangeType type;
103 }
104
Popular Tags