Search in sources :

Example 21 with TableNode

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;
    }
}
Also used : Dictionary(net.sourceforge.sqlexplorer.sessiontree.model.utility.Dictionary) INode(net.sourceforge.sqlexplorer.dbstructure.nodes.INode) ArrayList(java.util.ArrayList) TableNode(net.sourceforge.sqlexplorer.dbstructure.nodes.TableNode) SQLTextViewer(net.sourceforge.sqlexplorer.sqleditor.SQLTextViewer) Point(org.eclipse.swt.graphics.Point) IRegion(org.eclipse.jface.text.IRegion) BadLocationException(org.eclipse.jface.text.BadLocationException)

Aggregations

TableNode (net.sourceforge.sqlexplorer.dbstructure.nodes.TableNode)21 INode (net.sourceforge.sqlexplorer.dbstructure.nodes.INode)15 DataSet (net.sourceforge.sqlexplorer.dataset.DataSet)12 ResultSet (java.sql.ResultSet)7 ArrayList (java.util.ArrayList)7 SQLException (java.sql.SQLException)5 Iterator (java.util.Iterator)3 TreeSet (java.util.TreeSet)3 List (java.util.List)2 DatabaseNode (net.sourceforge.sqlexplorer.dbstructure.nodes.DatabaseNode)2 SQLEditor (net.sourceforge.sqlexplorer.plugin.editors.SQLEditor)2 SQLEditorInput (net.sourceforge.sqlexplorer.plugin.editors.SQLEditorInput)2 ITableInfo (net.sourceforge.squirrel_sql.fw.sql.ITableInfo)2 TableColumnInfo (net.sourceforge.squirrel_sql.fw.sql.TableColumnInfo)2 Point (org.eclipse.swt.graphics.Point)2 Statement (java.sql.Statement)1 ExplorerException (net.sourceforge.sqlexplorer.ExplorerException)1 SQLCannotConnectException (net.sourceforge.sqlexplorer.SQLCannotConnectException)1 ColumnInfoTab (net.sourceforge.sqlexplorer.dbdetail.tab.ColumnInfoTab)1 ColumnPriviligesTab (net.sourceforge.sqlexplorer.dbdetail.tab.ColumnPriviligesTab)1