use of org.eclipse.jface.viewers.TableLayout in project translationstudio8 by heartsome.
the class ExportExternalDialog method createDialogArea.
protected Control createDialogArea(Composite parent) {
Composite tparent = (Composite) super.createDialogArea(parent);
GridDataFactory.createFrom(new GridData(GridData.FILL_BOTH)).hint(600, SWT.DEFAULT).applyTo(tparent);
final Group groupFile = new Group(tparent, SWT.NONE);
groupFile.setText(Messages.getString("ExportDocxDialog.lable.xliff"));
groupFile.setLayout(new GridLayout(1, false));
groupFile.setLayoutData(new GridData(GridData.FILL_BOTH));
final TableViewer tbv = new TableViewer(groupFile, SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
final Table table = tbv.getTable();
table.setHeaderVisible(true);
table.setLinesVisible(true);
TableLayout tableLayout = new TableLayout();
table.setLayout(tableLayout);
GridDataFactory.swtDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).hint(SWT.DEFAULT, 90).applyTo(table);
tableLayout.addColumnData(new ColumnWeightData(1));
new TableColumn(table, SWT.NONE).setText(Messages.getString("ExportDocxDialog.lable.nodot"));
tableLayout.addColumnData(new ColumnWeightData(10));
new TableColumn(table, SWT.NONE).setText(Messages.getString("ExportDocxDialog.lable.fullPath"));
tableLayout.addColumnData(new ColumnWeightData(2));
new TableColumn(table, SWT.NONE).setText(Messages.getString("ExportDocxDialog.lable.srcLang"));
tableLayout.addColumnData(new ColumnWeightData(2));
new TableColumn(table, SWT.NONE).setText(Messages.getString("ExportDocxDialog.lable.tgtLang"));
tbv.setLabelProvider(new TableViewLabelProvider());
tbv.setContentProvider(new ArrayContentProvider());
tbv.setInput(xlfBeans);
final Group groupExportType = new Group(tparent, SWT.NONE);
groupExportType.setText(Messages.getString("ExportDocxDialog.lable.exporttype"));
groupExportType.setLayout(new GridLayout(3, false));
groupExportType.setLayoutData(new GridData(GridData.FILL_BOTH));
final Label lblExportType = new Label(groupExportType, SWT.NONE);
lblExportType.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
lblExportType.setText(Messages.getString("ExportDocxDialog.lable.exportchoose"));
cmb = new Combo(groupExportType, SWT.NONE | SWT.READ_ONLY);
GridDataFactory.swtDefaults().span(2, 1).grab(true, false).align(SWT.FILL, SWT.FILL).applyTo(cmb);
for (String type : ExportExternal.getExportTypes()) {
cmb.add(type);
}
cmb.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
final int exportCode = ExportExternal.getExportTypeCode(cmb.getSelectionIndex());
btnHsproofNote.setEnabled(exportCode == ExportExternal.EXPORT_HSPROOF);
btnHsproofState.setEnabled(btnHsproofNote.getEnabled());
btnNotrans.setEnabled(exportCode != ExportExternal.EXPORT_TMX && btnFilterWhenState.getSelection());
if (ExportExternal.EXPORT_TMX == exportCode && btnFilterWhenState.getSelection()) {
btnNotrans.setSelection(false);
}
}
});
final Label lblR8State = new Label(groupExportType, SWT.NONE);
lblR8State.setText(Messages.getString("ExportDocxDialog.lable.hsproof"));
btnHsproofState = new Button(groupExportType, SWT.CHECK);
btnHsproofState.setText(Messages.getString("ExportDocxDialog.statusBtn"));
btnHsproofNote = new Button(groupExportType, SWT.CHECK);
btnHsproofNote.setText(Messages.getString("ExportDocxDialog.commentBtn"));
final Group groupFilter = new Group(tparent, SWT.NONE);
groupFilter.setText(Messages.getString("ExportDocxDialog.lable.filter"));
groupFilter.setLayout(new GridLayout(3, false));
groupFilter.setLayoutData(new GridData(GridData.FILL_BOTH));
// 过滤大类
btnAllTrans = new Button(groupFilter, SWT.RADIO);
btnAllTrans.setText(Messages.getString("ExportDocxDialog.lable.filterAll"));
btnAllTrans.setSelection(true);
btnAllTrans.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (btnAllTrans.getSelection()) {
setFilterDefaultValue();
}
}
});
btnOnlySpecial = new Button(groupFilter, SWT.RADIO);
btnOnlySpecial.setText(Messages.getString("ExportDocxDialog.onlyExportBtn"));
btnOnlySpecial.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (btnOnlySpecial.getSelection()) {
setFilterDefaultValue();
}
}
;
});
btnFilterWhenState = new Button(groupFilter, SWT.RADIO);
btnFilterWhenState.setText(Messages.getString("ExportDocxDialog.lable.hasState"));
btnFilterWhenState.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (btnFilterWhenState.getSelection()) {
setFilterDefaultValue();
}
}
;
});
// 大类细节
cmpFilterAllTrans = new Composite(groupFilter, SWT.NONE);
cmpFilterAllTrans.setLayout(new GridLayout(1, false));
cmpFilterAllTrans.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
btnExceptLocked = new Button(cmpFilterAllTrans, SWT.CHECK);
btnExceptLocked.setText(Messages.getString("ExportDocxDialog.lable.exceptLock"));
btnExceptLocked.setEnabled(true);
btnExceptContextMatch = new Button(cmpFilterAllTrans, SWT.CHECK);
btnExceptContextMatch.setText(Messages.getString("ExportDocxDialog.lable.exceptCxtMatch"));
btnExceptContextMatch.setEnabled(true);
btnExceptFullMatch = new Button(cmpFilterAllTrans, SWT.CHECK);
btnExceptFullMatch.setText(Messages.getString("ExportDocxDialog.lable.exceptFullMatch"));
cmpFilterOnlySpecial = new Composite(groupFilter, SWT.NONE);
cmpFilterOnlySpecial.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
cmpFilterOnlySpecial.setLayout(new GridLayout(1, false));
btnHasNote = new Button(cmpFilterOnlySpecial, SWT.CHECK);
btnHasNote.setText(Messages.getString("ExportDocxDialog.onlyExportNoteBtn"));
btnNeedReview = new Button(cmpFilterOnlySpecial, SWT.CHECK);
btnNeedReview.setText(Messages.getString("ExportDocxDialog.onlyExportReviewBtn"));
cmpFilterWhenState = new Composite(groupFilter, SWT.NONE);
cmpFilterWhenState.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
cmpFilterWhenState.setLayout(new GridLayout(1, false));
btnNotrans = new Button(cmpFilterWhenState, SWT.CHECK);
btnNotrans.setText(Messages.getString("ExportDocxDialog.lable.state.noTrans"));
btnNotrans.setText(Messages.getString("ExportDocxDialog.lable.state.noTrans"));
btnNewtrans = new Button(cmpFilterWhenState, SWT.CHECK);
btnNewtrans.setText(Messages.getString("ExportDocxDialog.lable.state.new"));
btnNewtrans.setText(Messages.getString("ExportDocxDialog.lable.state.new"));
btnTransed = new Button(cmpFilterWhenState, SWT.CHECK);
btnTransed.setText(Messages.getString("ExportDocxDialog.lable.state.hasTrans"));
btnApproved = new Button(cmpFilterWhenState, SWT.CHECK);
btnApproved.setText(Messages.getString("ExportDocxDialog.lable.state.hasApprove"));
Composite cmpSaveas = new Composite(tparent, SWT.NONE);
cmpSaveas.setLayout(GridLayoutFactory.swtDefaults().numColumns(3).create());
cmpSaveas.setLayoutData(new GridData(GridData.FILL_BOTH));
Label lblSaveas = new Label(cmpSaveas, SWT.NONE);
lblSaveas.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
lblSaveas.setText(Messages.getString("ExportDocxDialog.lable.saveas"));
txtSaveas = new Text(cmpSaveas, SWT.BORDER | SWT.READ_ONLY);
txtSaveas.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
txtSaveas.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
getButton(IDialogConstants.OK_ID).setEnabled(!txtSaveas.getText().isEmpty());
}
});
Button btnSaveas = new Button(cmpSaveas, SWT.NONE);
btnSaveas.setText(Messages.getString("ExportDocxDialog.browseDocxBtn"));
btnSaveas.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
DirectoryDialog dialog = new DirectoryDialog(getShell());
dialog.setFilterPath(dialogSetting.get("defaultPath"));
String path = dialog.open();
if (path != null) {
txtSaveas.setText(path);
dialogSetting.put("defaultPath", path);
}
}
});
setDefaultValue();
return parent;
}
use of org.eclipse.jface.viewers.TableLayout in project tdi-studio-se by Talend.
the class BusinessAssignmentComposite method createControls.
public void createControls(Composite parent) {
composite = widgetFactory.createFlatFormComposite(parent);
adapterFactory = new BusinessItemProviderAdapterFactory();
tableViewer = new TableViewer(composite, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
tableViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
tableViewer.setLabelProvider(new RepositoryFactoryProxyLabelProvider(adapterFactory));
Table table = tableViewer.getTable();
TableLayout tableLayout = new TableLayout();
table.setLayout(tableLayout);
table.setHeaderVisible(true);
table.setLinesVisible(true);
final String[] columnProperties = new String[] { Messages.getString("AssignmentPropertySection.Type"), Messages.getString("AssignmentPropertySection.Name"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
Messages.getString("AssignmentPropertySection.Comment") };
TableColumn column1 = new TableColumn(table, SWT.NONE);
tableLayout.addColumnData(new ColumnPixelData(125, true));
column1.setText(columnProperties[0]);
TableColumn column2 = new TableColumn(table, SWT.NONE);
tableLayout.addColumnData(new ColumnPixelData(125, true));
column2.setText(columnProperties[1]);
TableColumn column3 = new TableColumn(table, SWT.NONE);
tableLayout.addColumnData(new ColumnWeightData(1, 150, true));
column3.setText(columnProperties[2]);
tableViewer.setColumnProperties(columnProperties);
final IItemPropertyDescriptor itemPropertyDescriptor = getItemPropertyDescriptor();
tableViewer.setCellModifier(new ICellModifier() {
@Override
public boolean canModify(Object element, String property) {
return property.equals(columnProperties[2]);
}
@Override
public Object getValue(Object element, String property) {
return EmfPropertyHelper.getValue(itemPropertyDescriptor, element);
}
@Override
public void modify(Object element, String property, Object value) {
if (element instanceof TableItem) {
TableItem tableItem = (TableItem) element;
itemPropertyDescriptor.setPropertyValue(tableItem.getData(), value);
}
}
});
CellEditor[] cellEditors = new CellEditor[3];
cellEditors[2] = new TextCellEditor(table);
tableViewer.setCellEditors(cellEditors);
// createKeyListener(table);
createSelectionListener();
createPopupMenu();
createDoubleClickListener();
handleLayout(parent, table, column1, column2, column3);
}
use of org.eclipse.jface.viewers.TableLayout in project tdi-studio-se by Talend.
the class VersionSection method createControls.
@Override
public void createControls(Composite parent, TabbedPropertySheetPage aTabbedPropertySheetPage) {
super.createControls(parent, aTabbedPropertySheetPage);
composite = getWidgetFactory().createFlatFormComposite(parent);
tableViewer = new TableViewer(composite, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
final Table table = tableViewer.getTable();
TableLayout tableLayout = new TableLayout();
table.setLayout(tableLayout);
table.setHeaderVisible(true);
table.setLinesVisible(true);
final String[] columnProperties = new String[] { //$NON-NLS-1$
Messages.getString("VersionSection.Version"), //$NON-NLS-1$
Messages.getString("VersionSection.CreationDate"), Messages.getString("VersionSection.ModificationDate"), //$NON-NLS-1$ //$NON-NLS-2$
Messages.getString("VersionSection.Status") };
final TableColumn column1 = new TableColumn(table, SWT.NONE);
tableLayout.addColumnData(new ColumnPixelData(125, true));
column1.setText(columnProperties[0]);
final TableColumn column2 = new TableColumn(table, SWT.NONE);
tableLayout.addColumnData(new ColumnPixelData(125, true));
column2.setText(columnProperties[1]);
final TableColumn column3 = new TableColumn(table, SWT.NONE);
tableLayout.addColumnData(new ColumnPixelData(125, true));
column3.setText(columnProperties[2]);
final TableColumn column4 = new TableColumn(table, SWT.NONE);
tableLayout.addColumnData(new ColumnWeightData(1, 150, true));
column4.setText(columnProperties[3]);
tableViewer.setColumnProperties(columnProperties);
Object layoutData = parent.getLayoutData();
if (layoutData instanceof GridData) {
GridData gridData = (GridData) layoutData;
gridData.grabExcessVerticalSpace = true;
gridData.verticalAlignment = SWT.FILL;
}
FormData formData = new FormData();
formData.left = new FormAttachment(0);
formData.top = new FormAttachment(0);
formData.right = new FormAttachment(100);
formData.bottom = new FormAttachment(100);
table.setLayoutData(formData);
tableViewer.setContentProvider(new IStructuredContentProvider() {
public Object[] getElements(Object inputElement) {
IRepositoryViewObject repositoryObject = ((IRepositoryViewObject) inputElement);
if (repositoryObject.getProperty() == null) {
return null;
}
RepositoryNode parentRepositoryNode = RepositoryNodeUtilities.getParentRepositoryNodeFromSelection(repositoryObject);
try {
List<IRepositoryViewObject> allVersion = ProxyRepositoryFactory.getInstance().getAllVersion(repositoryObject.getId());
Collections.sort(allVersion, new IRepositoryObjectComparator());
Object[] objects = new Object[allVersion.size()];
for (int i = 0; i < objects.length; i++) {
IRepositoryViewObject repositoryObjectVersion = allVersion.get(i);
RepositoryNode repositoryNode = createRepositoryNode(parentRepositoryNode, repositoryObjectVersion);
objects[i] = repositoryNode;
}
return objects;
} catch (PersistenceException e) {
return null;
}
}
private RepositoryNode createRepositoryNode(RepositoryNode parentRepositoryNode, IRepositoryViewObject repositoryObjectVersion) {
ERepositoryObjectType itemType = ERepositoryObjectType.getItemType(repositoryObjectVersion.getProperty().getItem());
RepositoryNode repositoryNode = new RepositoryNode(repositoryObjectVersion, parentRepositoryNode, ENodeType.REPOSITORY_ELEMENT);
repositoryNode.setProperties(EProperties.CONTENT_TYPE, itemType);
repositoryNode.setProperties(EProperties.LABEL, repositoryObjectVersion.getLabel());
return repositoryNode;
}
public void dispose() {
}
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
});
tableViewer.setLabelProvider(new ITableLabelProvider() {
public Image getColumnImage(Object element, int columnIndex) {
return null;
}
public String getColumnText(Object element, int columnIndex) {
RepositoryNode repositoryNode = (RepositoryNode) element;
switch(columnIndex) {
case 0:
return repositoryNode.getObject().getVersion();
case 1:
if (repositoryNode.getObject().getCreationDate() != null) {
return FORMATTER.format(repositoryNode.getObject().getCreationDate());
} else {
return null;
}
case 2:
if (repositoryNode.getObject().getModificationDate() != null) {
return FORMATTER.format(repositoryNode.getObject().getModificationDate());
} else {
return null;
}
case 3:
if (repositoryNode.getObject().getStatusCode() != null) {
return repositoryNode.getObject().getStatusCode();
} else {
return null;
}
default:
return null;
}
}
public void addListener(ILabelProviderListener listener) {
}
public void dispose() {
}
public boolean isLabelProperty(Object element, String property) {
return false;
}
public void removeListener(ILabelProviderListener listener) {
}
});
//$NON-NLS-1$
MenuManager menuMgr = new MenuManager("#PopUp");
menuMgr.setRemoveAllWhenShown(true);
menuMgr.addMenuListener(new IMenuListener() {
public void menuAboutToShow(IMenuManager mgr) {
ISelection selection = tableViewer.getSelection();
if (selection instanceof IStructuredSelection) {
IStructuredSelection structuredSelection = (IStructuredSelection) selection;
List<ITreeContextualAction> contextualsActions = ActionsHelper.getRepositoryContextualsActions();
for (ITreeContextualAction action : contextualsActions) {
if (action.isReadAction() || action.isEditAction() || action.isPropertiesAction()) {
action.init(null, structuredSelection);
if (action.isVisible()) {
mgr.add(action);
}
}
}
}
}
});
Menu menu = menuMgr.createContextMenu(tableViewer.getControl());
tableViewer.getControl().setMenu(menu);
Listener sortListener = new Listener() {
private int direction = 1;
public void handleEvent(Event e) {
final TableColumn column = (TableColumn) e.widget;
if (column == table.getSortColumn()) {
direction = -direction;
}
if (direction == 1) {
table.setSortDirection(SWT.DOWN);
} else {
table.setSortDirection(SWT.UP);
}
table.setSortColumn(column);
tableViewer.setSorter(new ViewerSorter() {
int index = 0;
@Override
public void sort(Viewer viewer, Object[] elements) {
while (index < table.getColumns().length && table.getColumn(index) != column) {
index++;
}
super.sort(viewer, elements);
}
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
ITableLabelProvider labelProvider = (ITableLabelProvider) tableViewer.getLabelProvider();
String columnText = labelProvider.getColumnText(e1, index) != null ? labelProvider.getColumnText(e1, index) : //$NON-NLS-1$
"";
String columnText2 = labelProvider.getColumnText(e2, index) != null ? labelProvider.getColumnText(e2, index) : //$NON-NLS-1$
"";
return getComparator().compare(columnText, columnText2) * direction;
}
});
}
};
column1.addListener(SWT.Selection, sortListener);
column2.addListener(SWT.Selection, sortListener);
column3.addListener(SWT.Selection, sortListener);
column4.addListener(SWT.Selection, sortListener);
table.setSortColumn(column1);
table.setSortDirection(SWT.DOWN);
aTabbedPropertySheetPage.getSite().setSelectionProvider(this);
}
use of org.eclipse.jface.viewers.TableLayout 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.eclipse.jface.viewers.TableLayout 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