* Contributors:
* Igor Malinin - initial contribution
*
- * $Id: TagDoubleClickStrategy.java,v 1.2 2005-05-06 00:55:41 stefanbjarni Exp $
+ * $Id: TagDoubleClickStrategy.java,v 1.3 2006-10-21 23:14:13 pombredanne Exp $
*/
package net.sourceforge.phpeclipse.xml.ui.internal.text;
import org.eclipse.jface.text.ITextViewer;
import org.eclipse.jface.text.ITypedRegion;
-
/**
*
*
/*
* @see org.eclipse.jface.text.ITextDoubleClickStrategy#doubleClicked(ITextViewer)
*/
- public void doubleClicked( ITextViewer viewer ) {
+ public void doubleClicked(ITextViewer viewer) {
int offset = viewer.getSelectedRange().x;
- if ( offset < 0 ) {
+ if (offset < 0) {
return;
}
try {
IDocument document = viewer.getDocument();
- ITypedRegion region = document.getPartition( offset );
+ ITypedRegion region = document.getPartition(offset);
int start = region.getOffset();
- if ( offset == start && document.getChar(offset) == '<' ) {
- region = document.getPartition( offset );
+ if (offset == start && document.getChar(offset) == '<') {
+ region = document.getPartition(offset);
offset = region.getOffset() + region.getLength();
- if ( document.getChar(offset - 1) != '>' ) {
- while ( true ) {
- if ( offset >= document.getLength() ) {
+ if (document.getChar(offset - 1) != '>') {
+ while (true) {
+ if (offset >= document.getLength()) {
break;
}
- region = document.getPartition( offset );
+ region = document.getPartition(offset);
offset = region.getOffset() + region.getLength();
- if ( XMLPartitionScanner.XML_ATTRIBUTE
- .equals(region.getType()) ) {
+ if (XMLPartitionScanner.XML_ATTRIBUTE.equals(region
+ .getType())) {
continue;
}
- if ( XMLPartitionScanner.XML_TAG
- .equals(region.getType()) ) {
- if ( document.getChar(region.getOffset()) == '<' ) {
+ if (XMLPartitionScanner.XML_TAG
+ .equals(region.getType())) {
+ if (document.getChar(region.getOffset()) == '<') {
break;
}
- if ( document.getChar(offset - 1) == '>' ) {
+ if (document.getChar(offset - 1) == '>') {
break;
}
}
}
- viewer.setSelectedRange( start, offset - start );
+ viewer.setSelectedRange(start, offset - start);
return;
}
int end = start + region.getLength();
- if ( offset == end - 1 && document.getChar(offset) == '>' ) {
- region = document.getPartition( offset );
+ if (offset == end - 1 && document.getChar(offset) == '>') {
+ region = document.getPartition(offset);
offset = region.getOffset();
- if ( document.getChar(offset) != '<' ) {
- while ( true ) {
- if ( offset <= 0 ) {
+ if (document.getChar(offset) != '<') {
+ while (true) {
+ if (offset <= 0) {
break;
}
- region = document.getPartition( offset - 1 );
+ region = document.getPartition(offset - 1);
offset = region.getOffset();
- if ( XMLPartitionScanner.XML_ATTRIBUTE
- .equals(region.getType()) ) {
+ if (XMLPartitionScanner.XML_ATTRIBUTE.equals(region
+ .getType())) {
continue;
}
- if ( XMLPartitionScanner.XML_TAG
- .equals(region.getType()) ) {
- if ( document.getChar(offset) == '<' ) {
+ if (XMLPartitionScanner.XML_TAG
+ .equals(region.getType())) {
+ if (document.getChar(offset) == '<') {
break;
}
}
}
- viewer.setSelectedRange( offset, end - offset );
+ viewer.setSelectedRange(offset, end - offset);
return;
}
- super.doubleClicked( viewer );
- } catch ( BadLocationException e ) {}
+ super.doubleClicked(viewer);
+ } catch (BadLocationException e) {
+ }
}
}