use of org.talend.sqlbuilder.sqlcontrol.AbstractSQLExecution in project tdi-studio-se by Talend.
the class SQLResultComposite method createTabItem.
/**
*
* DOC dev Comment method "createTabItem".
*
* @throws Exception throw all exception
*/
private void createTabItem() throws Exception {
lastTabNumber = lastTabNumber + 1;
final CTabItem tabItem = new CTabItem(tabFolder, SWT.NULL);
String labelText = Messages.getString("SQLResultComposite.Result") + ": " + lastTabNumber;
tabItem.setText(labelText);
//$NON-NLS-1$
tabItem.setData("tabLabel", labelText);
tabItem.setToolTipText(TextUtil.getWrappedText(sqlExecution.getSqlStatement()));
Composite composite = new Composite(tabFolder, SWT.NULL);
GridLayout layout = new GridLayout();
layout.numColumns = 1;
layout.marginLeft = 0;
layout.marginTop = 0;
layout.marginBottom = 0;
layout.horizontalSpacing = 0;
layout.verticalSpacing = 0;
layout.marginWidth = 0;
layout.marginHeight = 0;
composite.setLayout(layout);
composite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
tabItem.setControl(composite);
tabItem.setData(sqlExecution);
tabItem.addDisposeListener(new DisposeListener() {
public void widgetDisposed(final DisposeEvent e) {
BusyIndicator.showWhile(Display.getCurrent(), new Runnable() {
public void run() {
CTabItem tabItem = (CTabItem) e.getSource();
AbstractSQLExecution sqlExe = (AbstractSQLExecution) tabItem.getData();
sqlExe.stop();
tabItem.setData(null);
if (tabFolder != null && !tabFolder.isDisposed()) {
if (tabFolder.getItemCount() == 0) {
// this is last tab..
clearParent();
setDefaultMessage();
}
} else if (tabFolder.isDisposed()) {
clearParent();
setDefaultMessage();
}
}
});
}
});
createHeaderComposite(composite, tabItem);
createDetailComposite(composite, tabItem);
// refresh view
composite.layout();
tabFolder.layout();
tabFolder.redraw();
}
use of org.talend.sqlbuilder.sqlcontrol.AbstractSQLExecution in project tdi-studio-se by Talend.
the class DB2ExplainPlanExecution method displayResults.
private void displayResults(final ExplainNode node) {
Display.getDefault().asyncExec(new Runnable() {
@Override
@SuppressWarnings("deprecation")
public void run() {
clearCanvas();
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);
try {
//$NON-NLS-1$
composite.setData("parenttab", parentTab);
Composite pp = new Composite(composite, SWT.NULL);
pp.setLayout(new FillLayout());
pp.setLayoutData(new GridData(GridData.FILL_BOTH));
TreeViewer tv = new TreeViewer(pp, SWT.BORDER | SWT.FULL_SELECTION);
Tree tree = tv.getTree();
tree.setLinesVisible(true);
tree.setHeaderVisible(true);
TreeColumn tc = new TreeColumn(tree, SWT.NULL);
//$NON-NLS-1$
tc.setText("");
tc = new TreeColumn(tree, SWT.NULL);
//$NON-NLS-1$
tc.setText(Messages.getString("DB2ExplainPlanExecution.tableColumnText1"));
tc = new TreeColumn(tree, SWT.NULL);
//$NON-NLS-1$
tc.setText(Messages.getString("DB2ExplainPlanExecution.tableColumnText2"));
TableLayout tableLayout = new TableLayout();
tableLayout.addColumnData(new ColumnWeightData(6, 150, true));
tableLayout.addColumnData(new ColumnWeightData(1, 50, true));
tableLayout.addColumnData(new ColumnWeightData(1, 50, true));
tree.setLayout(tableLayout);
tv.setContentProvider(new ITreeContentProvider() {
@Override
public void dispose() {
}
@Override
public Object[] getChildren(Object parentElement) {
return ((ExplainNode) parentElement).getChildren();
}
@Override
public Object[] getElements(Object inputElement) {
ExplainNode nd = ((ExplainNode) inputElement);
return nd.getChildren();
}
@Override
public Object getParent(Object element) {
return ((ExplainNode) element).getParent();
}
@Override
public boolean hasChildren(Object element) {
if (((ExplainNode) element).getChildren().length > 0) {
return true;
}
return false;
}
@Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
});
tv.setLabelProvider(new TreeLabelProvider() {
});
tv.setInput(node);
tv.refresh();
tv.expandAll();
// make columns full size
for (int i = 0; i < tree.getColumnCount(); i++) {
tree.getColumn(i).pack();
}
final Composite parent = composite;
tree.addKeyListener(new KeyAdapter() {
@Override
public void keyReleased(KeyEvent e) {
switch(e.keyCode) {
case SWT.F5:
// refresh SQL Results
try {
//$NON-NLS-1$
Object o = parent.getData("parenttab");
if (o != null) {
AbstractSQLExecution sqlExec = (AbstractSQLExecution) ((TabItem) o).getData();
if (sqlExec != null) {
sqlExec.startExecution();
}
}
} catch (Exception e1) {
//$NON-NLS-1$
SqlBuilderPlugin.log(Messages.getString("DB2ExplainPlanExecution.logMessageError1"), e1);
}
break;
default:
return;
}
}
});
} catch (Exception e) {
// add message
String message = e.getMessage();
Label errorLabel = new Label(composite, SWT.FILL);
errorLabel.setText(message);
errorLabel.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
//$NON-NLS-1$
SqlBuilderPlugin.log(Messages.getString("DB2ExplainPlanExecution.logMessageError2"), e);
}
composite.layout();
composite.redraw();
}
;
});
}
use of org.talend.sqlbuilder.sqlcontrol.AbstractSQLExecution in project tdi-studio-se by Talend.
the class OracleExplainPlanExecution method displayResults.
private void displayResults(final ExplainNode node) {
Display.getDefault().asyncExec(new Runnable() {
@Override
@SuppressWarnings("deprecation")
public void run() {
clearCanvas();
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);
try {
//$NON-NLS-1$
composite.setData("parenttab", parentTab);
Composite pp = new Composite(composite, SWT.NULL);
pp.setLayout(new FillLayout());
pp.setLayoutData(new GridData(GridData.FILL_BOTH));
TreeViewer tv = new TreeViewer(pp, SWT.BORDER | SWT.FULL_SELECTION);
Tree tree = tv.getTree();
tree.setLinesVisible(true);
tree.setHeaderVisible(true);
TreeColumn tc = new TreeColumn(tree, SWT.NULL);
//$NON-NLS-1$
tc.setText("");
tc = new TreeColumn(tree, SWT.NULL);
//$NON-NLS-1$
tc.setText(Messages.getString("OracleExplainPlanExecution.tableColumnText1"));
tc = new TreeColumn(tree, SWT.NULL);
//$NON-NLS-1$
tc.setText(Messages.getString("OracleExplainPlanExecution.tableColumnText2"));
TableLayout tableLayout = new TableLayout();
tableLayout.addColumnData(new ColumnWeightData(6, 150, true));
tableLayout.addColumnData(new ColumnWeightData(1, 50, true));
tableLayout.addColumnData(new ColumnWeightData(1, 50, true));
tree.setLayout(tableLayout);
tv.setContentProvider(new ITreeContentProvider() {
@Override
public void dispose() {
}
@Override
public Object[] getChildren(Object parentElement) {
return ((ExplainNode) parentElement).getChildren();
}
@Override
public Object[] getElements(Object inputElement) {
ExplainNode nd = ((ExplainNode) inputElement);
return nd.getChildren();
}
@Override
public Object getParent(Object element) {
return ((ExplainNode) element).getParent();
}
@Override
public boolean hasChildren(Object element) {
if (((ExplainNode) element).getChildren().length > 0) {
return true;
}
return false;
}
@Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
});
tv.setLabelProvider(new TreeLabelProvider() {
});
tv.setInput(node);
tv.refresh();
tv.expandAll();
// make columns full size
for (int i = 0; i < tree.getColumnCount(); i++) {
tree.getColumn(i).pack();
}
final Composite parent = composite;
tree.addKeyListener(new KeyAdapter() {
@Override
public void keyReleased(KeyEvent e) {
switch(e.keyCode) {
case SWT.F5:
// refresh SQL Results
try {
//$NON-NLS-1$
Object o = parent.getData("parenttab");
if (o != null) {
AbstractSQLExecution sqlExec = (AbstractSQLExecution) ((TabItem) o).getData();
if (sqlExec != null) {
sqlExec.startExecution();
}
}
} catch (Exception e1) {
//$NON-NLS-1$
SqlBuilderPlugin.log(Messages.getString("OracleExplainPlanExecution.logMessage1"), e1);
}
break;
default:
return;
}
}
});
} catch (Exception e) {
// add message
String message = e.getMessage();
Label errorLabel = new Label(composite, SWT.FILL);
errorLabel.setText(message);
errorLabel.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
//$NON-NLS-1$
SqlBuilderPlugin.log(Messages.getString("OracleExplainPlanExecution.logMessage2"), e);
}
composite.layout();
composite.redraw();
}
;
});
}
Aggregations