Search in sources :

Example 1 with DataSetTable

use of net.sourceforge.sqlexplorer.dataset.DataSetTable in project tdq-studio-se by Talend.

the class SQLExecution method displayResults.

/**
 * Display SQL Results in result pane
 * @param sqlResult the results of the query
 */
protected void displayResults(final SQLResult sqlResult) {
    // Switch to the UI thread to execute this
    getEditor().getSite().getShell().getDisplay().asyncExec(new Runnable() {

        public void run() {
            ResultsTab resultsTab = allocateResultsTab(sqlResult.getQuery());
            if (resultsTab == null)
                return;
            String caption = sqlResult.getDataSet().getCaption();
            if (caption != null)
                resultsTab.getTabItem().setText(caption);
            try {
                // set initial message
                setProgressMessage(Messages.getString("SQLResultsView.ConnectionWait"));
                Composite composite = resultsTab.getParent();
                GridLayout gLayout = new GridLayout();
                gLayout.numColumns = 2;
                gLayout.marginLeft = 0;
                gLayout.horizontalSpacing = 0;
                gLayout.verticalSpacing = 0;
                gLayout.marginWidth = 0;
                gLayout.marginHeight = 0;
                composite.setLayout(gLayout);
                int resultCount = sqlResult.getDataSet().getRows().length;
                String statusMessage = Messages.getString("SQLResultsView.Time.Prefix") + " " + sqlResult.getExecutionTimeMillis() + " " + Messages.getString("SQLResultsView.Time.Postfix");
                getEditor().setMessage(statusMessage);
                if (resultCount > 0)
                    statusMessage = statusMessage + "  " + Messages.getString("SQLResultsView.Count.Prefix") + " " + resultCount;
                Query sql = sqlResult.getQuery();
                int lineNo = sql.getLineNo();
                lineNo = getQueryParser().adjustLineNo(lineNo);
                getEditor().addMessage(new Message(Message.Status.SUCCESS, lineNo, 0, sql.getQuerySql(), statusMessage));
                new DataSetTable(composite, sqlResult.getDataSet(), statusMessage);
                composite.setData("parenttab", resultsTab.getTabItem());
                composite.layout();
                composite.redraw();
                // reset to start message in case F5 will be used
                setProgressMessage(Messages.getString("SQLResultsView.ConnectionWait"));
            } catch (Exception e) {
                // add message
                if (resultsTab != null) {
                    String message = e.getMessage();
                    Label errorLabel = new Label(resultsTab.getParent(), SWT.FILL);
                    errorLabel.setText(message);
                    errorLabel.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
                }
                SQLExplorerPlugin.error("Error creating result tab", e);
            }
        }
    });
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) Query(net.sourceforge.sqlexplorer.parsers.Query) Message(net.sourceforge.sqlexplorer.plugin.editors.Message) DataSetTable(net.sourceforge.sqlexplorer.dataset.DataSetTable) ResultsTab(net.sourceforge.sqlexplorer.sqleditor.results.ResultsTab) Label(org.eclipse.swt.widgets.Label) GridData(org.eclipse.swt.layout.GridData) SQLException(java.sql.SQLException)

Example 2 with DataSetTable

use of net.sourceforge.sqlexplorer.dataset.DataSetTable in project tdq-studio-se by Talend.

the class AbstractDataSetTab method fillDetailComposite.

public final void fillDetailComposite(Composite composite) {
    try {
        _composite = composite;
        DataSet dataSet = getCachedDataSet();
        if (dataSet == null) {
            Label label = new Label(composite, SWT.FILL);
            label.setText(Messages.getString("DatabaseDetailView.NoInformation"));
            label.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
            return;
        }
        // store for later use in dataset table
        // $NON-NLS-1$
        composite.setData("IDetailTab", this);
        new DataSetTable(composite, dataSet, getStatusMessage());
    } catch (Exception e) {
        // couldn't get results.. clean mess up
        Control[] controls = composite.getChildren();
        for (int i = 0; i < controls.length; i++) {
            controls[i].dispose();
        }
        // and show error message
        Label label = new Label(composite, SWT.FILL);
        // $NON-NLS-2$
        label.setText(Messages.getString("DatabaseDetailView.Tab.Unavailable") + " " + e.getMessage());
        label.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
        SQLExplorerPlugin.error(Messages.getString("AbstractDataSetTab.error"), e);
    }
}
Also used : DataSet(net.sourceforge.sqlexplorer.dataset.DataSet) DataSetTable(net.sourceforge.sqlexplorer.dataset.DataSetTable) Label(org.eclipse.swt.widgets.Label) GridData(org.eclipse.swt.layout.GridData)

Aggregations

DataSetTable (net.sourceforge.sqlexplorer.dataset.DataSetTable)2 GridData (org.eclipse.swt.layout.GridData)2 Label (org.eclipse.swt.widgets.Label)2 SQLException (java.sql.SQLException)1 DataSet (net.sourceforge.sqlexplorer.dataset.DataSet)1 Query (net.sourceforge.sqlexplorer.parsers.Query)1 Message (net.sourceforge.sqlexplorer.plugin.editors.Message)1 ResultsTab (net.sourceforge.sqlexplorer.sqleditor.results.ResultsTab)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Composite (org.eclipse.swt.widgets.Composite)1