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);
}
}
});
}
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);
}
}
Aggregations