use of org.eclipse.jface.viewers.TableTreeViewer in project tdq-studio-se by Talend.
the class ExplainExecution method displayResults.
private void displayResults(final ExplainNode node, final Query query) {
getEditor().getSite().getShell().getDisplay().asyncExec(new Runnable() {
public void run() {
ResultsTab resultsTab = allocateResultsTab(query);
try {
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);
composite.setData("parenttab", resultsTab.getTabItem());
Composite pp = new Composite(composite, 0);
pp.setLayout(new FillLayout());
pp.setLayoutData(new GridData(1808));
TableTreeViewer tv = new TableTreeViewer(pp, 0x10800);
Table table = tv.getTableTree().getTable();
table.setLinesVisible(true);
table.setHeaderVisible(true);
TableColumn tc = new TableColumn(table, 0);
tc.setText("");
tc = new TableColumn(table, 0);
tc.setText("Cost");
tc = new TableColumn(table, 0);
tc.setText("Cardinality");
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));
table.setLayout(tableLayout);
tv.setContentProvider(new ITreeContentProvider() {
public void dispose() {
}
public Object[] getChildren(Object parentElement) {
return ((ExplainNode) parentElement).getChildren();
}
public Object[] getElements(Object inputElement) {
ExplainNode nd = (ExplainNode) inputElement;
return nd.getChildren();
}
public Object getParent(Object element) {
return ((ExplainNode) element).getParent();
}
public boolean hasChildren(Object element) {
return ((ExplainNode) element).getChildren().length > 0;
}
public void inputChanged(Viewer viewer1, Object obj, Object obj1) {
}
});
tv.setLabelProvider(new TreeLabelProvider() {
});
tv.setInput(node);
tv.refresh();
tv.expandAll();
for (int i = 0; i < table.getColumnCount(); i++) table.getColumn(i).pack();
final ExplainPlanActionGroup actionGroup = new ExplainPlanActionGroup(tv, node.getChildren()[0]);
MenuManager menuManager = new MenuManager("ExplainPlanContextMenu");
menuManager.setRemoveAllWhenShown(true);
org.eclipse.swt.widgets.Menu contextMenu = menuManager.createContextMenu(table);
tv.getControl().setMenu(contextMenu);
menuManager.addMenuListener(new IMenuListener() {
public void menuAboutToShow(IMenuManager manager) {
actionGroup.fillContextMenu(manager);
}
});
composite.layout();
composite.redraw();
} catch (Exception e) {
if (resultsTab != null) {
Composite composite = resultsTab.getParent();
String message = e.getMessage();
Label errorLabel = new Label(composite, 4);
errorLabel.setText(message);
errorLabel.setLayoutData(new GridData(4, 128, true, false));
}
SQLExplorerPlugin.error("Error creating explain tab", e);
}
}
});
}
Aggregations