KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > debug > internal > ui > views > console > InputPartition


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

11 package org.eclipse.debug.internal.ui.views.console;
12
13
14 import org.eclipse.debug.internal.ui.DebugUIPlugin;
15
16 /**
17  * A partition in a console document that contains input from the keyboard.
18  */

19 public class InputPartition extends StreamPartition {
20     
21     /**
22      * Once an input partition has been written to standard-in, it cannot
23      * be modified.
24      */

25     private boolean fReadOnly = false;
26
27     /**
28      * Partition type
29      */

30     public static final String JavaDoc INPUT_PARTITION_TYPE = DebugUIPlugin.getUniqueIdentifier() + ".INPUT_PARTITION_TYPE"; //$NON-NLS-1$
31

32     
33     public InputPartition(String JavaDoc streamIdentifier, int offset, int length) {
34         super(streamIdentifier, offset, length, INPUT_PARTITION_TYPE);
35     }
36     
37     /**
38      * @see org.eclipse.debug.internal.ui.views.console.StreamPartition#createNewPartition(String, int, int)
39      */

40     public StreamPartition createNewPartition(String JavaDoc streamIdentifier, int offset, int length) {
41         return new InputPartition(streamIdentifier, offset, length);
42     }
43     
44     /**
45      * Sets whether this partition is read-only.
46      *
47      * @param readOnly whether this partition is read-only
48      */

49     public void setReadOnly(boolean readOnly) {
50         fReadOnly = readOnly;
51     }
52     
53     /**
54      * Returns whether this partition is read-only.
55      *
56      * @return whether this partition is read-only
57      */

58     public boolean isReadOnly() {
59         return fReadOnly;
60     }
61     
62     /**
63      * Returns whether this partition is allowed to be combined with the
64      * given partition. Once read-only, this partition cannot be combined.
65      *
66      * @param partition
67      * @return boolean
68      */

69     public boolean canBeCombinedWith(StreamPartition partition) {
70         return (!isReadOnly() && super.canBeCombinedWith(partition));
71     }
72 }
73
Popular Tags