Search in sources :

Example 1 with JDBCResultSetMetaDataImpl

use of org.jkiss.dbeaver.model.impl.jdbc.exec.JDBCResultSetMetaDataImpl in project dbeaver by dbeaver.

the class DB2BaseTableToolDialog method getScriptListener.

@Override
protected SQLScriptProgressListener<DB2Table> getScriptListener() {
    final int nbExtraColumns = getNumberExtraResultingColumns();
    return new SQLScriptStatusDialog<DB2Table>(getTitle() + " " + DB2Messages.dialog_table_tools_progress, null) {

        @Override
        protected void createStatusColumns(Tree objectTree) {
            TreeColumn msgColumn = new TreeColumn(objectTree, SWT.NONE);
            msgColumn.setText(DB2Messages.dialog_table_tools_result);
            for (int i = 0; i < nbExtraColumns; i++) {
                new TreeColumn(objectTree, SWT.NONE);
            }
        }

        // DF: This method is for tools that return resultsets
        @Override
        public void processObjectResults(@NotNull DB2Table db2Table, @Nullable DBCStatement statement, @Nullable DBCResultSet resultSet) throws DBCException {
            if (resultSet == null) {
                return;
            }
            // Retrive column names
            JDBCResultSetMetaDataImpl rsMetaData = (JDBCResultSetMetaDataImpl) resultSet.getMeta();
            try {
                TreeItem treeItem = getTreeItem(db2Table);
                Font f = UIUtils.makeBoldFont(treeItem.getFont());
                if (treeItem != null) {
                    // Display the column names
                    TreeItem subItem = null;
                    subItem = new TreeItem(treeItem, SWT.NONE);
                    subItem.setFont(f);
                    for (int i = 0; i < rsMetaData.getColumnCount(); i++) {
                        subItem.setText(i, rsMetaData.getColumnName(i + 1));
                        subItem.setGrayed(true);
                    }
                    // Display the data for each row
                    while (resultSet.nextRow()) {
                        subItem = new TreeItem(treeItem, SWT.NONE);
                        for (int i = 0; i < rsMetaData.getColumnCount(); i++) {
                            subItem.setText(i, CommonUtils.toString(resultSet.getAttributeValue(i)));
                        }
                    }
                    treeItem.setExpanded(true);
                }
            } catch (SQLException e) {
                throw new DBCException(e.getMessage());
            }
        }
    };
}
Also used : TreeItem(org.eclipse.swt.widgets.TreeItem) SQLException(java.sql.SQLException) DBCException(org.jkiss.dbeaver.model.exec.DBCException) NotNull(org.jkiss.code.NotNull) DBCStatement(org.jkiss.dbeaver.model.exec.DBCStatement) JDBCResultSetMetaDataImpl(org.jkiss.dbeaver.model.impl.jdbc.exec.JDBCResultSetMetaDataImpl) SQLScriptStatusDialog(org.jkiss.dbeaver.ui.editors.sql.dialogs.SQLScriptStatusDialog) Font(org.eclipse.swt.graphics.Font) DB2Table(org.jkiss.dbeaver.ext.db2.model.DB2Table) TreeColumn(org.eclipse.swt.widgets.TreeColumn) Tree(org.eclipse.swt.widgets.Tree) DBCResultSet(org.jkiss.dbeaver.model.exec.DBCResultSet) Nullable(org.jkiss.code.Nullable)

Example 2 with JDBCResultSetMetaDataImpl

use of org.jkiss.dbeaver.model.impl.jdbc.exec.JDBCResultSetMetaDataImpl in project dbeaver by serge-rider.

the class DB2BaseTableToolDialog method getScriptListener.

@Override
protected SQLScriptProgressListener<DB2Table> getScriptListener() {
    final int nbExtraColumns = getNumberExtraResultingColumns();
    return new SQLScriptStatusDialog<DB2Table>(getShell(), getTitle() + " " + DB2Messages.dialog_table_tools_progress, null) {

        @Override
        protected void createStatusColumns(Tree objectTree) {
            TreeColumn msgColumn = new TreeColumn(objectTree, SWT.NONE);
            msgColumn.setText(DB2Messages.dialog_table_tools_result);
            for (int i = 0; i < nbExtraColumns; i++) {
                new TreeColumn(objectTree, SWT.NONE);
            }
        }

        @Override
        public void endObjectProcessing(@NotNull DB2Table db2Table, Exception exception) {
            TreeItem treeItem = getTreeItem(db2Table);
            if (exception == null) {
                treeItem.setText(1, DB2Messages.dialog_table_tools_success_title);
            } else {
                treeItem.setText(1, exception.getMessage());
            }
            UIUtils.packColumns(treeItem.getParent(), false, null);
        }

        // DF: This method is for tools that return resultsets
        @Override
        public void processObjectResults(@NotNull DB2Table db2Table, @Nullable DBCStatement statement, @Nullable DBCResultSet resultSet) throws DBCException {
            if (resultSet == null) {
                return;
            }
            // Retrive column names
            JDBCResultSetMetaDataImpl rsMetaData = (JDBCResultSetMetaDataImpl) resultSet.getMeta();
            try {
                TreeItem treeItem = getTreeItem(db2Table);
                Font f = UIUtils.makeBoldFont(treeItem.getFont());
                if (treeItem != null) {
                    // Display the column names
                    TreeItem subItem = null;
                    subItem = new TreeItem(treeItem, SWT.NONE);
                    subItem.setFont(f);
                    for (int i = 0; i < rsMetaData.getColumnCount(); i++) {
                        subItem.setText(i, rsMetaData.getColumnName(i + 1));
                        subItem.setGrayed(true);
                    }
                    // Display the data for each row
                    while (resultSet.nextRow()) {
                        subItem = new TreeItem(treeItem, SWT.NONE);
                        for (int i = 0; i < rsMetaData.getColumnCount(); i++) {
                            subItem.setText(i, CommonUtils.toString(resultSet.getAttributeValue(i)));
                        }
                    }
                    treeItem.setExpanded(true);
                }
            } catch (SQLException e) {
                throw new DBCException(e.getMessage());
            }
        }
    };
}
Also used : TreeItem(org.eclipse.swt.widgets.TreeItem) SQLException(java.sql.SQLException) DBCException(org.jkiss.dbeaver.model.exec.DBCException) NotNull(org.jkiss.code.NotNull) DBCStatement(org.jkiss.dbeaver.model.exec.DBCStatement) JDBCResultSetMetaDataImpl(org.jkiss.dbeaver.model.impl.jdbc.exec.JDBCResultSetMetaDataImpl) SQLScriptStatusDialog(org.jkiss.dbeaver.ui.dialogs.sql.SQLScriptStatusDialog) DBCException(org.jkiss.dbeaver.model.exec.DBCException) SQLException(java.sql.SQLException) Font(org.eclipse.swt.graphics.Font) DB2Table(org.jkiss.dbeaver.ext.db2.model.DB2Table) TreeColumn(org.eclipse.swt.widgets.TreeColumn) Tree(org.eclipse.swt.widgets.Tree) DBCResultSet(org.jkiss.dbeaver.model.exec.DBCResultSet) Nullable(org.jkiss.code.Nullable)

Example 3 with JDBCResultSetMetaDataImpl

use of org.jkiss.dbeaver.model.impl.jdbc.exec.JDBCResultSetMetaDataImpl in project dbeaver by dbeaver.

the class DB2BaseTableToolDialog method getScriptListener.

@Override
protected SQLScriptProgressListener<DB2Table> getScriptListener() {
    final int nbExtraColumns = getNumberExtraResultingColumns();
    return new SQLScriptStatusDialog<DB2Table>(getTitle() + " " + DB2Messages.dialog_table_tools_progress, null) {

        @Override
        protected void createStatusColumns(Tree objectTree) {
            TreeColumn msgColumn = new TreeColumn(objectTree, SWT.NONE);
            msgColumn.setText(DB2Messages.dialog_table_tools_result);
            for (int i = 0; i < nbExtraColumns; i++) {
                new TreeColumn(objectTree, SWT.NONE);
            }
        }

        @Override
        public void endObjectProcessing(@NotNull DB2Table db2Table, Exception exception) {
            TreeItem treeItem = getTreeItem(db2Table);
            if (exception == null) {
                treeItem.setText(1, DB2Messages.dialog_table_tools_success_title);
            } else {
                treeItem.setText(1, exception.getMessage());
            }
            UIUtils.packColumns(treeItem.getParent(), false, null);
        }

        // DF: This method is for tools that return resultsets
        @Override
        public void processObjectResults(@NotNull DB2Table db2Table, @Nullable DBCStatement statement, @Nullable DBCResultSet resultSet) throws DBCException {
            if (resultSet == null) {
                return;
            }
            // Retrive column names
            JDBCResultSetMetaDataImpl rsMetaData = (JDBCResultSetMetaDataImpl) resultSet.getMeta();
            try {
                TreeItem treeItem = getTreeItem(db2Table);
                Font f = UIUtils.makeBoldFont(treeItem.getFont());
                if (treeItem != null) {
                    // Display the column names
                    TreeItem subItem = null;
                    subItem = new TreeItem(treeItem, SWT.NONE);
                    subItem.setFont(f);
                    for (int i = 0; i < rsMetaData.getColumnCount(); i++) {
                        subItem.setText(i, rsMetaData.getColumnName(i + 1));
                        subItem.setGrayed(true);
                    }
                    // Display the data for each row
                    while (resultSet.nextRow()) {
                        subItem = new TreeItem(treeItem, SWT.NONE);
                        for (int i = 0; i < rsMetaData.getColumnCount(); i++) {
                            subItem.setText(i, CommonUtils.toString(resultSet.getAttributeValue(i)));
                        }
                    }
                    treeItem.setExpanded(true);
                }
            } catch (SQLException e) {
                throw new DBCException(e.getMessage());
            }
        }
    };
}
Also used : TreeItem(org.eclipse.swt.widgets.TreeItem) SQLException(java.sql.SQLException) DBCException(org.jkiss.dbeaver.model.exec.DBCException) NotNull(org.jkiss.code.NotNull) DBCStatement(org.jkiss.dbeaver.model.exec.DBCStatement) JDBCResultSetMetaDataImpl(org.jkiss.dbeaver.model.impl.jdbc.exec.JDBCResultSetMetaDataImpl) SQLScriptStatusDialog(org.jkiss.dbeaver.ui.dialogs.sql.SQLScriptStatusDialog) DBCException(org.jkiss.dbeaver.model.exec.DBCException) SQLException(java.sql.SQLException) Font(org.eclipse.swt.graphics.Font) DB2Table(org.jkiss.dbeaver.ext.db2.model.DB2Table) TreeColumn(org.eclipse.swt.widgets.TreeColumn) Tree(org.eclipse.swt.widgets.Tree) DBCResultSet(org.jkiss.dbeaver.model.exec.DBCResultSet) Nullable(org.jkiss.code.Nullable)

Example 4 with JDBCResultSetMetaDataImpl

use of org.jkiss.dbeaver.model.impl.jdbc.exec.JDBCResultSetMetaDataImpl in project dbeaver by serge-rider.

the class DB2BaseTableToolDialog method getScriptListener.

@Override
protected SQLScriptProgressListener<DB2Table> getScriptListener() {
    final int nbExtraColumns = getNumberExtraResultingColumns();
    return new SQLScriptStatusDialog<DB2Table>(getTitle() + " " + DB2Messages.dialog_table_tools_progress, null) {

        @Override
        protected void createStatusColumns(Tree objectTree) {
            TreeColumn msgColumn = new TreeColumn(objectTree, SWT.NONE);
            msgColumn.setText(DB2Messages.dialog_table_tools_result);
            for (int i = 0; i < nbExtraColumns; i++) {
                new TreeColumn(objectTree, SWT.NONE);
            }
        }

        // DF: This method is for tools that return resultsets
        @Override
        public void processObjectResults(@NotNull DB2Table db2Table, @Nullable DBCStatement statement, @Nullable DBCResultSet resultSet) throws DBCException {
            if (resultSet == null) {
                return;
            }
            // Retrive column names
            JDBCResultSetMetaDataImpl rsMetaData = (JDBCResultSetMetaDataImpl) resultSet.getMeta();
            try {
                TreeItem treeItem = getTreeItem(db2Table);
                Font f = UIUtils.makeBoldFont(treeItem.getFont());
                if (treeItem != null) {
                    // Display the column names
                    TreeItem subItem = null;
                    subItem = new TreeItem(treeItem, SWT.NONE);
                    subItem.setFont(f);
                    for (int i = 0; i < rsMetaData.getColumnCount(); i++) {
                        subItem.setText(i, rsMetaData.getColumnName(i + 1));
                        subItem.setGrayed(true);
                    }
                    // Display the data for each row
                    while (resultSet.nextRow()) {
                        subItem = new TreeItem(treeItem, SWT.NONE);
                        for (int i = 0; i < rsMetaData.getColumnCount(); i++) {
                            subItem.setText(i, CommonUtils.toString(resultSet.getAttributeValue(i)));
                        }
                    }
                    treeItem.setExpanded(true);
                }
            } catch (SQLException e) {
                throw new DBCException(e.getMessage());
            }
        }
    };
}
Also used : TreeItem(org.eclipse.swt.widgets.TreeItem) SQLException(java.sql.SQLException) DBCException(org.jkiss.dbeaver.model.exec.DBCException) NotNull(org.jkiss.code.NotNull) DBCStatement(org.jkiss.dbeaver.model.exec.DBCStatement) JDBCResultSetMetaDataImpl(org.jkiss.dbeaver.model.impl.jdbc.exec.JDBCResultSetMetaDataImpl) SQLScriptStatusDialog(org.jkiss.dbeaver.ui.editors.sql.dialogs.SQLScriptStatusDialog) Font(org.eclipse.swt.graphics.Font) DB2Table(org.jkiss.dbeaver.ext.db2.model.DB2Table) TreeColumn(org.eclipse.swt.widgets.TreeColumn) Tree(org.eclipse.swt.widgets.Tree) DBCResultSet(org.jkiss.dbeaver.model.exec.DBCResultSet) Nullable(org.jkiss.code.Nullable)

Aggregations

SQLException (java.sql.SQLException)4 Font (org.eclipse.swt.graphics.Font)4 Tree (org.eclipse.swt.widgets.Tree)4 TreeColumn (org.eclipse.swt.widgets.TreeColumn)4 TreeItem (org.eclipse.swt.widgets.TreeItem)4 NotNull (org.jkiss.code.NotNull)4 Nullable (org.jkiss.code.Nullable)4 DB2Table (org.jkiss.dbeaver.ext.db2.model.DB2Table)4 DBCException (org.jkiss.dbeaver.model.exec.DBCException)4 DBCResultSet (org.jkiss.dbeaver.model.exec.DBCResultSet)4 DBCStatement (org.jkiss.dbeaver.model.exec.DBCStatement)4 JDBCResultSetMetaDataImpl (org.jkiss.dbeaver.model.impl.jdbc.exec.JDBCResultSetMetaDataImpl)4 SQLScriptStatusDialog (org.jkiss.dbeaver.ui.dialogs.sql.SQLScriptStatusDialog)2 SQLScriptStatusDialog (org.jkiss.dbeaver.ui.editors.sql.dialogs.SQLScriptStatusDialog)2