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://solareclipse.sourceforge.net/legal/cpl-v10.html
9 * Igor Malinin - initial contribution
11 * $Id: TextDoubleClickStrategy.java,v 1.1 2004-09-02 18:26:49 jsurfer Exp $
14 package net.sourceforge.phpeclipse.ui.text;
16 import org.eclipse.jface.text.BadLocationException;
17 import org.eclipse.jface.text.IDocument;
18 import org.eclipse.jface.text.ITextDoubleClickStrategy;
19 import org.eclipse.jface.text.ITextViewer;
22 * @author Igor Malinin
24 public class TextDoubleClickStrategy implements ITextDoubleClickStrategy {
27 * @see org.eclipse.jface.text.ITextDoubleClickStrategy#doubleClicked(ITextViewer)
29 public void doubleClicked(ITextViewer viewer) {
30 int offset = viewer.getSelectedRange().x;
31 if (offset < 0) { return; }
33 selectWord(viewer, viewer.getDocument(), offset);
36 protected void selectWord(ITextViewer textViewer, IDocument document,
41 char c = document.getChar(start);
43 if (!Character.isUnicodeIdentifierPart(c)) {
50 int length = document.getLength();
53 while (end < length) {
54 char c = document.getChar(end);
56 if (!Character.isUnicodeIdentifierPart(c)) {
64 textViewer.setSelectedRange(start, 0);
66 textViewer.setSelectedRange(start + 1, end - start - 1);
68 } catch (BadLocationException x) {