KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ant > internal > ui > AntDoubleClickStrategy


1 /*******************************************************************************
2  * Copyright (c) 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11
12 package org.eclipse.ant.internal.ui;
13
14 import org.eclipse.ant.internal.ui.editor.text.XMLTextHover;
15 import org.eclipse.jface.text.IRegion;
16 import org.eclipse.jface.text.ITextDoubleClickStrategy;
17 import org.eclipse.jface.text.ITextViewer;
18
19 public class AntDoubleClickStrategy implements ITextDoubleClickStrategy {
20
21     /* (non-Javadoc)
22      * @see org.eclipse.jface.text.ITextDoubleClickStrategy#doubleClicked(org.eclipse.jface.text.ITextViewer)
23      */

24     public void doubleClicked(ITextViewer textViewer) {
25         int offset= textViewer.getSelectedRange().x;
26
27         if (offset < 0) {
28             return;
29         }
30         IRegion region= XMLTextHover.getRegion(textViewer, offset);
31         if (region != null) {
32             textViewer.setSelectedRange(region.getOffset(), region.getLength());
33         }
34     }
35 }
Popular Tags