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.2 2006-10-21 23:13:54 pombredanne 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;
35 selectWord(viewer, viewer.getDocument(), offset);
38 protected void selectWord(ITextViewer textViewer, IDocument document,
43 char c = document.getChar(start);
45 if (!Character.isUnicodeIdentifierPart(c)) {
52 int length = document.getLength();
55 while (end < length) {
56 char c = document.getChar(end);
58 if (!Character.isUnicodeIdentifierPart(c)) {
66 textViewer.setSelectedRange(start, 0);
68 textViewer.setSelectedRange(start + 1, end - start - 1);
70 } catch (BadLocationException x) {