2 * $RCSfile: JSDoubleClickStrategy.java,v $
5 * CH-1700 Fribourg, Switzerland
8 *========================================================================
9 * Modifications history
10 *========================================================================
11 * $Log: not supported by cvs2svn $
12 * Revision 1.1 2004/02/05 03:13:28 agfitzp
13 * Initial submission, outline view is broken due to refactoring
15 * Revision 1.1 2003/05/28 15:17:12 agfitzp
16 * net.sourceforge.phpeclipse.js.ui 0.0.1 code base
18 *========================================================================
21 package net.sourceforge.phpeclipse.js.ui.editors;
23 import org.eclipse.jface.text.BadLocationException;
24 import org.eclipse.jface.text.IDocument;
25 import org.eclipse.jface.text.ITextDoubleClickStrategy;
26 import org.eclipse.jface.text.ITextViewer;
32 * @author $Author: jsurfer $, $Date: 2004-09-02 18:23:49 $
34 * @version $Revision: 1.1 $
36 public class JSDoubleClickStrategy implements ITextDoubleClickStrategy
38 protected ITextViewer fText;
41 * Creates a new JSDoubleClickStrategy object.
43 public JSDoubleClickStrategy()
53 public void doubleClicked(ITextViewer part)
55 int pos = part.getSelectedRange().x;
64 if(!selectComment(pos))
77 protected boolean selectComment(int caretPos)
79 IDocument doc = fText.getDocument();
99 if(c == Character.LINE_SEPARATOR || c == '\"')
116 int length = doc.getLength();
121 c = doc.getChar(pos);
123 if(c == Character.LINE_SEPARATOR || c == '\"')
138 int offset = startPos + 1;
139 int len = endPos - offset;
140 fText.setSelectedRange(offset, len);
144 catch(BadLocationException x)
158 protected boolean selectWord(int caretPos)
160 IDocument doc = fText.getDocument();
171 c = doc.getChar(pos);
173 if(!Character.isJavaIdentifierPart(c))
185 int length = doc.getLength();
189 c = doc.getChar(pos);
191 if(!Character.isJavaIdentifierPart(c))
200 selectRange(startPos, endPos);
204 catch(BadLocationException x)
211 private void selectRange(int startPos, int stopPos)
213 int offset = startPos + 1;
214 int length = stopPos - offset;
215 fText.setSelectedRange(offset, length);