use of net.sourceforge.sqlexplorer.dbstructure.nodes.TableNode in project tdq-studio-se by Talend.
the class MouseClickListener method getCurrentTextRegion.
private IRegion getCurrentTextRegion(ISourceViewer viewer) {
if (viewer == null)
return null;
Dictionary dictionary = ((SQLTextViewer) viewer).dictionary;
if (dictionary == null)
return null;
int offset = getCurrentTextOffset(viewer);
if (offset == -1)
return null;
try {
IRegion reg = selectWord(viewer.getDocument(), offset);
if (reg == null)
return null;
String selection = viewer.getDocument().get(reg.getOffset(), reg.getLength());
if (selection == null)
return null;
Object obj = dictionary.getByTableName(selection.toLowerCase());
if (obj == null)
return null;
else {
if (!(obj instanceof ArrayList))
return null;
ArrayList ls = (ArrayList) obj;
if (ls.isEmpty())
return null;
Object node = ((ArrayList) obj).get(0);
if (node instanceof TableNode)
activeTableNode = (INode) node;
else
return null;
}
return reg;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
Aggregations