use of org.eclipse.swt.widgets.TableColumn in project cubrid-manager by CUBRID.
the class QueryRecordListComparator method createQueryCompareTab.
private void createQueryCompareTab(CTabFolder tabFolder) {
CTabItem item = new CTabItem(tabFolder, SWT.None | SWT.MULTI | SWT.V_SCROLL);
item.setText(Messages.tabItemQueryCompare);
Composite composite = new Composite(tabFolder, SWT.None);
composite.setLayout(new GridLayout());
item.setControl(composite);
Composite topComposite = new Composite(composite, SWT.None);
topComposite.setLayout(new FormLayout());
topComposite.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, 25));
Composite leftTopComposite = new Composite(topComposite, SWT.None);
FormData leftTopData = new FormData();
leftTopData.top = new FormAttachment(0, 0);
leftTopData.bottom = new FormAttachment(100, 0);
leftTopData.left = new FormAttachment(0, 0);
leftTopData.right = new FormAttachment(50, 0);
leftTopComposite.setLayoutData(leftTopData);
leftTopComposite.setLayout(new GridLayout(2, false));
Composite rightTopComposite = new Composite(topComposite, SWT.None);
FormData rightTopData = new FormData();
rightTopData.top = new FormAttachment(0, 0);
rightTopData.bottom = new FormAttachment(100, 0);
rightTopData.left = new FormAttachment(50, 0);
rightTopData.right = new FormAttachment(100, 0);
rightTopComposite.setLayoutData(rightTopData);
rightTopComposite.setLayout(new GridLayout(5, false));
Label leftLabel = new Label(leftTopComposite, SWT.None);
leftLabel.setText(Messages.lblQuery);
leftLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
queryRecordLeftCombo = new Combo(leftTopComposite, SWT.READ_ONLY);
queryRecordLeftCombo.setLayoutData(CommonUITool.createGridData(1, 1, 200, -1));
queryRecordLeftCombo.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
displayCompareQueryRecord();
}
public void widgetDefaultSelected(SelectionEvent e) {
}
});
Label rightLabel = new Label(rightTopComposite, SWT.None);
rightLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
rightLabel.setText(Messages.lblQuery);
queryRecordRightCombo = new Combo(rightTopComposite, SWT.READ_ONLY);
queryRecordRightCombo.setLayoutData(CommonUITool.createGridData(1, 1, 200, -1));
queryRecordRightCombo.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
displayCompareQueryRecord();
}
public void widgetDefaultSelected(SelectionEvent e) {
}
});
ToolBar leftToolBar = new ToolBar(rightTopComposite, SWT.None);
leftToolBar.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
compareItem = new ToolItem(leftToolBar, SWT.None);
compareItem.setImage(CommonUIPlugin.getImage("icons/action/refresh_tuning.png"));
compareItem.setToolTipText(Messages.itemTooltipCompare);
compareItem.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
displayCompareQueryRecord();
}
});
delQueryRecordItem = new ToolItem(leftToolBar, SWT.None);
delQueryRecordItem.setImage(CommonUIPlugin.getImage("icons/queryplan/delete_query.gif"));
delQueryRecordItem.setToolTipText(Messages.itemTooltipRemoveQuery);
delQueryRecordItem.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
if (CommonUITool.openConfirmBox(Messages.confirmDeleteQueryPlanOnTuner)) {
removeQueryRecord();
}
}
});
Composite folderPlaceComposite = new Composite(rightTopComposite, SWT.None);
folderPlaceComposite.setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
ToolBar rightToolBar = new ToolBar(rightTopComposite, SWT.None);
rightToolBar.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_END, 1, 1, -1, -1));
multiRunItem = new ToolItem(rightToolBar, SWT.None);
multiRunItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/query_multi_run.png"));
multiRunItem.setToolTipText(Messages.itemTooltipRunAgain);
multiRunItem.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
QueryRecord leftRecord = getSelectedLeftQueryRecord();
QueryRecord rightRecord = getSelectedRightQueryRecord();
if (leftRecord == null || rightRecord == null) {
CommonUITool.openErrorBox(Messages.errCompareQueryEmpty);
return;
}
runQueryPlanAgain(leftRecord.getQuery(), rightRecord.getQuery());
}
});
sqlModeItem = new ToolItem(rightToolBar, SWT.CHECK);
sqlModeItem.setImage(CommonUIPlugin.getImage("icons/queryplan/sql_compare.gif"));
sqlModeItem.setToolTipText(Messages.itemTooltipQuery);
sqlModeItem.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
updateCompareDisplayModel(DISPLAY_SQL);
}
});
textModelItem = new ToolItem(rightToolBar, SWT.CHECK);
textModelItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/qe_explain_mode_raw.png"));
textModelItem.setToolTipText(Messages.tooltip_qedit_explain_display_mode);
textModelItem.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
updateCompareDisplayModel(DISPLAY_TEXT);
}
});
treeModelItem = new ToolItem(rightToolBar, SWT.CHECK);
treeModelItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/qe_explain_mode_tree.png"));
treeModelItem.setToolTipText(Messages.tooltip_qedit_explain_display_mode);
treeModelItem.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
updateCompareDisplayModel(DISPLAY_TREE);
}
});
graphModelItem = new ToolItem(rightToolBar, SWT.CHECK);
graphModelItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/qe_explain_mode_graph.png"));
graphModelItem.setToolTipText(Messages.tooltip_qedit_explain_display_mode);
graphModelItem.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
updateCompareDisplayModel(DISPLAY_GRAPH);
}
});
Composite tablesComposite = new Composite(composite, SWT.None);
tablesComposite.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, 60));
tablesComposite.setLayout(new FormLayout());
/*Left composite*/
Composite leftTableComposite = new Composite(tablesComposite, SWT.BORDER);
leftTableComposite.setLayout(new GridLayout());
FormData leftTableData = new FormData();
leftTableData.top = new FormAttachment(0, 0);
leftTableData.bottom = new FormAttachment(100, 0);
leftTableData.left = new FormAttachment(0, 0);
leftTableData.right = new FormAttachment(50, -2);
leftTableComposite.setLayoutData(leftTableData);
/*Right composite*/
Composite rightTableComposite = new Composite(tablesComposite, SWT.BORDER);
rightTableComposite.setLayout(new GridLayout());
FormData rightTabelData = new FormData();
rightTabelData.top = new FormAttachment(0, 0);
rightTabelData.bottom = new FormAttachment(100, 0);
rightTabelData.left = new FormAttachment(50, 2);
rightTabelData.right = new FormAttachment(100, 0);
rightTableComposite.setLayoutData(rightTabelData);
compareLeftTableViewer = new TableViewer(leftTableComposite, SWT.FULL_SELECTION);
compareLeftTableViewer.getTable().setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
compareLeftTableViewer.getTable().setHeaderVisible(true);
compareLeftTableViewer.getTable().setLinesVisible(false);
compareLeftTableViewer.setContentProvider(new QueryPlanContentProvider());
compareLeftTableViewer.setLabelProvider(new QueryPlanLabelPrivoder(compareLeftTableViewer, false));
TableColumn fetchColumnLeft = new TableColumn(compareLeftTableViewer.getTable(), SWT.None);
fetchColumnLeft.setText(Messages.columnFetches);
fetchColumnLeft.setWidth(60);
TableColumn dirtyColumnLeft = new TableColumn(compareLeftTableViewer.getTable(), SWT.None);
dirtyColumnLeft.setText(Messages.columnDirties);
dirtyColumnLeft.setWidth(60);
TableColumn ioReadColumnLeft = new TableColumn(compareLeftTableViewer.getTable(), SWT.None);
ioReadColumnLeft.setText(Messages.columnIORead);
ioReadColumnLeft.setWidth(80);
TableColumn ioWriteColumnLeft = new TableColumn(compareLeftTableViewer.getTable(), SWT.None);
ioWriteColumnLeft.setText(Messages.columnIOWrite);
ioWriteColumnLeft.setWidth(80);
TableColumn costColumnLeft = new TableColumn(compareLeftTableViewer.getTable(), SWT.None);
costColumnLeft.setText(Messages.columnCost);
costColumnLeft.setWidth(60);
compareRightTableViewer = new TableViewer(rightTableComposite, SWT.FULL_SELECTION);
compareRightTableViewer.getTable().setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
compareRightTableViewer.getTable().setHeaderVisible(true);
compareRightTableViewer.getTable().setLinesVisible(false);
compareRightTableViewer.setContentProvider(new QueryPlanContentProvider());
compareRightTableViewer.setLabelProvider(new QueryPlanLabelPrivoder(compareRightTableViewer, false));
TableColumn fetchColumnRight = new TableColumn(compareRightTableViewer.getTable(), SWT.None);
fetchColumnRight.setText(Messages.columnFetches);
fetchColumnRight.setWidth(60);
TableColumn dirtyColumnRight = new TableColumn(compareRightTableViewer.getTable(), SWT.None);
dirtyColumnRight.setText(Messages.columnDirties);
dirtyColumnRight.setWidth(60);
TableColumn ioReadColumnRight = new TableColumn(compareRightTableViewer.getTable(), SWT.None);
ioReadColumnRight.setText(Messages.columnIORead);
ioReadColumnRight.setWidth(80);
TableColumn ioWriteColumnRight = new TableColumn(compareRightTableViewer.getTable(), SWT.None);
ioWriteColumnRight.setText(Messages.columnIOWrite);
ioWriteColumnRight.setWidth(80);
TableColumn costColumnRight = new TableColumn(compareRightTableViewer.getTable(), SWT.None);
costColumnRight.setText(Messages.columnCost);
costColumnRight.setWidth(60);
queryPlanCompareSashForm = new SashForm(composite, SWT.VERTICAL);
queryPlanCompareSashForm.setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
queryPlanCompareSashForm.setBackground(SASH_COLOR);
queryPlanCompareSashForm.setLayout(new GridLayout());
queryPlanCompareSashForm.setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
Composite textMergeComposite = new Composite(queryPlanCompareSashForm, SWT.None);
textMergeComposite.setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
textMergeComposite.setLayout(new FillLayout());
textMergeConfig = new CompareConfiguration();
textMergeConfig.setProperty(CompareConfiguration.SHOW_PSEUDO_CONFLICTS, Boolean.FALSE);
textMergeConfig.setProperty(CompareConfiguration.IGNORE_WHITESPACE, Boolean.TRUE);
textMergeConfig.setLeftEditable(false);
textMergeConfig.setRightEditable(false);
textMergeViewer = new TextMergeViewer(textMergeComposite, SWT.BORDER, textMergeConfig);
DiffNode queryDiffNode = new DiffNode(null, Differencer.CHANGE, null, new TextCompareInput(""), new TextCompareInput(""));
textMergeViewer.setInput(queryDiffNode);
Composite compareQueryPlanComposite = new Composite(queryPlanCompareSashForm, SWT.None);
compareQueryPlanComposite.setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
compareQueryPlanComposite.setLayout(new FormLayout());
DatabaseInfo databaseInfo = database == null ? null : database.getDatabaseInfo();
leftComparePlanComposite = new QueryPlanComposite(compareQueryPlanComposite, SWT.BORDER, null, databaseInfo);
FormData leftData = new FormData();
leftData.top = new FormAttachment(0, 0);
leftData.bottom = new FormAttachment(100, 0);
leftData.left = new FormAttachment(0, 0);
leftData.right = new FormAttachment(50, 0);
leftComparePlanComposite.setLayoutData(leftData);
rightComparePlanComposite = new QueryPlanComposite(compareQueryPlanComposite, SWT.BORDER, null, databaseInfo);
FormData rightData = new FormData();
rightData.top = new FormAttachment(0, 0);
rightData.bottom = new FormAttachment(100, 0);
rightData.left = new FormAttachment(50, 0);
rightData.right = new FormAttachment(100, 0);
rightComparePlanComposite.setLayoutData(rightData);
queryPlanCompareSashForm.setWeights(new int[] { 100, 0 });
}
use of org.eclipse.swt.widgets.TableColumn in project cubrid-manager by CUBRID.
the class QueryRecordListComparator method createResultColumn.
private void createResultColumn(final TableViewer tableViewer, final QueryRecord queryRecord) {
if (queryRecord != null) {
TableColumn[] tblColumn = new TableColumn[(queryRecord.getColumnInfoList() == null ? 0 : queryRecord.getColumnInfoList().size()) + 1];
tblColumn[0] = new TableColumn(tableViewer.getTable(), SWT.NONE);
tblColumn[0].setText("NO");
tblColumn[0].setWidth(40);
if (queryRecord.getColumnInfoList() == null) {
return;
}
final Map<String, ColumnComparator> colComparatorMap = new HashMap<String, ColumnComparator>();
for (int j = 0; j < queryRecord.getColumnInfoList().size(); j++) {
tblColumn[j + 1] = new TableColumn(tableViewer.getTable(), SWT.NONE);
ColumnInfo columnInfo = (ColumnInfo) queryRecord.getColumnInfoList().get(j);
String name = columnInfo.getName();
String type = columnInfo.getType();
tblColumn[j + 1].setText(name);
tblColumn[j + 1].setToolTipText(columnInfo.getComleteType());
tblColumn[j + 1].setData(columnInfo);
tblColumn[j + 1].pack();
ColumnComparator comparator = new ColumnComparator(columnInfo.getIndex(), type, true);
if (colComparatorMap != null) {
colComparatorMap.put(columnInfo.getIndex(), comparator);
}
tblColumn[j + 1].addSelectionListener(new SelectionListener() {
@SuppressWarnings("unchecked")
public void widgetSelected(SelectionEvent event) {
TableColumn column = (TableColumn) event.widget;
if (column == null || column.getText() == null || column.getText().trim().length() == 0) {
return;
}
TableColumn sortedColumn = tableViewer.getTable().getSortColumn();
int width = column.getWidth();
ColumnInfo columnInfo = (ColumnInfo) column.getData();
ColumnComparator comparator = colComparatorMap.get(columnInfo.getIndex());
tableViewer.getTable().setSortColumn(column);
tableViewer.getTable().setSortDirection(comparator.isAsc() ? SWT.UP : SWT.DOWN);
Collections.sort(queryRecord.getPageData(), comparator);
comparator.setAsc(!comparator.isAsc());
column.pack();
if (column.equals(sortedColumn)) {
column.setWidth(width);
} else {
column.setWidth(width + 25);
}
tableViewer.refresh();
}
public void widgetDefaultSelected(SelectionEvent event) {
}
});
}
}
}
use of org.eclipse.swt.widgets.TableColumn in project cubrid-manager by CUBRID.
the class CommonUITool method createCommonTableViewer.
/**
*
* Create the common table viewer that can be sorted by TableViewerSorter
* object,this viewer's input object must be List<Map<String,Object>> and
* Map's key must be column index,Map's value of the column must be String.
*
* @param parent the parent composite
* @param sorter the table sorter
* @param columnNameArr the column name array
* @param columnwidthArr the column width array
* @param gridData the gridData layout object
* @return the TableViewer object
*/
public static TableViewer createCommonTableViewer(Composite parent, ViewerSorter sorter, final String[] columnNameArr, int[] columnwidthArr, GridData gridData) {
final TableViewer tableViewer = new TableViewer(parent, SWT.V_SCROLL | SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.FULL_SELECTION);
tableViewer.setContentProvider(new TableContentProvider());
tableViewer.setLabelProvider(new TableLabelProvider());
if (sorter != null) {
tableViewer.setSorter(sorter);
}
tableViewer.getTable().setLinesVisible(true);
tableViewer.getTable().setHeaderVisible(true);
tableViewer.getTable().setLayoutData(gridData);
for (int i = 0; i < columnNameArr.length; i++) {
final TableColumn tblColumn = new TableColumn(tableViewer.getTable(), SWT.LEFT);
tblColumn.setText(columnNameArr[i]);
if (sorter != null) {
tblColumn.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
TableColumn column = (TableColumn) event.widget;
int j = 0;
for (j = 0; j < columnNameArr.length; j++) {
if (column.getText().equals(columnNameArr[j])) {
break;
}
}
TableViewerSorter sorter = ((TableViewerSorter) tableViewer.getSorter());
if (sorter == null) {
return;
}
sorter.doSort(j);
tableViewer.getTable().setSortColumn(column);
tableViewer.getTable().setSortDirection(sorter.isAsc() ? SWT.UP : SWT.DOWN);
tableViewer.refresh();
packTable(tableViewer);
}
});
}
if (columnwidthArr != null) {
tblColumn.setWidth(columnwidthArr[i]);
} else {
tblColumn.pack();
}
}
return tableViewer;
}
use of org.eclipse.swt.widgets.TableColumn in project cubrid-manager by CUBRID.
the class DiagStatusMonitorTemplateDialog method createTableSelectedItem.
/**
* This method initializes tableSelectedItem
*
*/
private void createTableSelectedItem() {
TableLayout tlayout = new TableLayout();
tlayout.addColumnData(new ColumnWeightData(150, 150, true));
tlayout.addColumnData(new ColumnWeightData(150, 150, true));
tagetTbl.setLayout(tlayout);
TableColumn categoryColumn = new TableColumn(tagetTbl, SWT.CENTER);
categoryColumn.setText(DIAG_CATEGORY);
TableColumn nameColumn = new TableColumn(tagetTbl, SWT.CENTER);
nameColumn.setText(DIAG_NAME);
}
use of org.eclipse.swt.widgets.TableColumn in project cubrid-manager by CUBRID.
the class ChartCompositePart method createSeriesTable.
/**
* Create basic info table
*
* @param parent the parent composite
*
*/
private void createSeriesTable(Composite parent) {
final Composite comp = new Composite(parent, SWT.NONE);
GridData gdBasic = new GridData(SWT.FILL, SWT.NONE, false, false);
comp.setLayoutData(gdBasic);
GridLayout layout = new GridLayout();
layout.verticalSpacing = 0;
layout.horizontalSpacing = 0;
layout.marginLeft = 0;
layout.marginRight = 0;
layout.marginTop = 0;
layout.marginBottom = 0;
comp.setLayout(layout);
final Label label = new Label(comp, SWT.CENTER);
label.setText(Messages.tblSeriesTtl);
seriesTableViewer = new TableViewer(comp, SWT.NO_SCROLL | SWT.BORDER);
Table seriesTable = seriesTableViewer.getTable();
seriesTable.setHeaderVisible(true);
seriesTable.setLinesVisible(true);
GridData tblSeries = new GridData(SWT.FILL, SWT.TOP, true, false);
tblSeries.heightHint = CommonUITool.getHeightHintOfTable(seriesTable);
seriesTable.setLayoutData(tblSeries);
TableLayout seriesLayout = new TableLayout();
setSeriesTableLayout(seriesLayout);
seriesTable.setLayout(seriesLayout);
TableColumn tblColumn = new TableColumn(seriesTable, SWT.CENTER);
tblColumn.setText("");
tblColumn.setResizable(false);
for (Map.Entry<String, ShowSetting> entry : settingMap.entrySet()) {
tblColumn = new TableColumn(seriesTable, SWT.CENTER);
tblColumn.setText(entry.getKey());
tblColumn.setToolTipText(entry.getKey());
tblColumn.setResizable(false);
}
List<String[]> chartTblLst = new ArrayList<String[]>();
String[] arrays = valueMap.values().toArray(new String[valueMap.size()]);
String[] arrays2 = new String[arrays.length + 1];
arrays2[0] = "";
System.arraycopy(arrays, 0, arrays2, 1, arrays.length);
chartTblLst.add(arrays2);
ChartTableContentProvider chartTableContentProvider = new ChartTableContentProvider();
seriesTableViewer.setContentProvider(chartTableContentProvider);
seriesTableViewer.setLabelProvider(new ChartTableLabelProvider());
seriesTableViewer.setInput(chartTblLst);
int index = 0;
for (Map.Entry<String, ShowSetting> entry : settingMap.entrySet()) {
org.eclipse.swt.graphics.Color color = new org.eclipse.swt.graphics.Color(comp.getDisplay(), entry.getValue().getSeriesRgb());
seriesTableViewer.getTable().getItem(0).setBackground(index + 1, color);
index++;
}
seriesTable.addControlListener(new ControlAdapter() {
public void controlResized(ControlEvent event) {
updateTableLayout();
}
});
}
Aggregations