try {
if ("java".equals(extension))
{
final ITextEditor textEditor = (ITextEditor)wEditor.getJavaEditor();
final IDocument document = ((textEditor).getDocumentProvider()).getDocument(textEditor.getEditorInput());
final FindReplaceDocumentAdapter frda = new FindReplaceDocumentAdapter(document);
final IRegion region = frda.find(0, '"' + wicketId + '"', true, true, false, false);
if (region != null)
{
textEditor.selectAndReveal(region.getOffset() + 1, wicketId.length());
wEditor.setActiveEditor(wEditor.getJavaEditor());
}
}
else if ("html".equals(extension))
{
final ITextEditor textEditor = (ITextEditor)wEditor.getHtmlEditor();
final IDocument document = ((textEditor).getDocumentProvider()).getDocument(textEditor.getEditorInput());
final FindReplaceDocumentAdapter frda = new FindReplaceDocumentAdapter(document);
final IRegion region = frda.find(0, "wicket:id=\"" + wicketId, true, true, true, false);
if (region != null)
{
textEditor.selectAndReveal(region.getOffset() + 11, wicketId.length());
wEditor.setActiveEditor(wEditor.getHtmlEditor());
}
}
else if ("properties".equals(extension) && propertiesEditor != null)
{
final ITextEditor textEditor = (ITextEditor)propertiesEditor;
final IDocument document = ((textEditor).getDocumentProvider()).getDocument(textEditor.getEditorInput());
final FindReplaceDocumentAdapter frda = new FindReplaceDocumentAdapter(document);
IRegion regionBegin = frda.find(0, wicketId, true, true, true, false);
if (regionBegin != null)
{
regionBegin = frda.find(regionBegin.getOffset(), "=", true, true, false, false);
if (regionBegin != null)
{
final IRegion lineRegion = document.getLineInformationOfOffset(regionBegin.getOffset());
final int selectionLength = lineRegion.getOffset() + lineRegion.getLength() - regionBegin.getOffset();
textEditor.selectAndReveal(regionBegin.getOffset() + 1, selectionLength);