2 * Copyright (c) 2002-2004 Widespace, OU 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
9 * Igor Malinin - initial contribution
11 * $Id: SimpleDoubleClickStrategy.java,v 1.3 2006-10-21 23:14:13 pombredanne Exp $
14 package net.sourceforge.phpeclipse.xml.ui.internal.text;
16 import net.sourceforge.phpeclipse.ui.text.TextDoubleClickStrategy;
18 import org.eclipse.jface.text.BadLocationException;
19 import org.eclipse.jface.text.IDocument;
20 import org.eclipse.jface.text.ITextViewer;
21 import org.eclipse.jface.text.ITypedRegion;
26 * @author Igor Malinin
28 public class SimpleDoubleClickStrategy extends TextDoubleClickStrategy {
30 * @see org.eclipse.jface.text.ITextDoubleClickStrategy#doubleClicked(ITextViewer)
32 public void doubleClicked(ITextViewer viewer) {
33 int offset = viewer.getSelectedRange().x;
39 IDocument document = viewer.getDocument();
41 ITypedRegion region = document.getPartition(offset);
43 int start = region.getOffset();
44 int length = region.getLength();
46 if (offset == start) {
47 viewer.setSelectedRange(start, length);
51 int end = start + length - 1;
53 if (offset == end && document.getChar(end) == '>') {
54 viewer.setSelectedRange(start, length);
58 super.doubleClicked(viewer);
59 } catch (BadLocationException e) {