1 /*******************************************************************************
\r
2 * Copyright (c) 2006 Sybase, Inc. and others.
\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 * Sybase, Inc. - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.eclipse.jst.pagedesigner.viewer;
\r
14 import org.eclipse.jface.viewers.ISelection;
\r
19 public class DesignRange implements ISelection
\r
21 private final DesignPosition _start;
\r
22 private final DesignPosition _end;
\r
28 public DesignRange(DesignPosition start, DesignPosition end) {
\r
34 * @return the start position in the range
\r
36 public DesignPosition getStartPosition() {
\r
41 * @return the end position in the range
\r
43 public DesignPosition getEndPosition() {
\r
48 * @return true if the range is valid
\r
50 public boolean isValid() {
\r
51 return _start != null && _start.isValid() && _end != null
\r
58 * @see org.eclipse.jface.viewers.ISelection#isEmpty()
\r
60 public boolean isEmpty() {
\r
61 // FIXME: temp implementation, need revisit.
\r
62 return !isValid() || _start.equals(_end);
\r
67 * @return a buffer with the debug dum
\r
69 public StringBuffer debugDump(StringBuffer buffer) {
\r
70 if (_start != null) {
\r
71 buffer.append("Start: ").append(_start); //$NON-NLS-1$
\r
73 buffer.append("Start: null"); //$NON-NLS-1$
\r
76 buffer.append("End: ").append(_end); //$NON-NLS-1$
\r
78 buffer.append("End: null"); //$NON-NLS-1$
\r
83 public String toString() {
\r
84 StringBuffer buffer = new StringBuffer();
\r
85 return debugDump(buffer).toString();
\r