use of org.eclipse.swt.custom.SashForm in project cubrid-manager by CUBRID.
the class QueryResultComposite method makeLogResult.
/**
* Make the log result contents.
*
* @param sqlStr String
* @param messageStr String
*/
public void makeLogResult(String sqlStr, String messageStr) {
resultTabFolder.setSelection(queryResultTabItem);
SashForm tailSash = new SashForm(queryResultTabFolder, SWT.NONE);
tailSash.SASH_WIDTH = SASH_WIDTH;
tailSash.setBackground(CombinedQueryEditorComposite.BACK_COLOR);
String text = messageStr;
logMessagesArea = new StyledText(tailSash, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.READ_ONLY | SWT.WRAP);
CommonUITool.registerCopyPasteContextMenu(logMessagesArea, false);
logMessagesArea.setText(text);
int splitLineLength = QueryUtil.SPLIT_LINE_FOR_QUERY_RESULT.length();
for (int sp = 0; ; ) {
int redStringLength = splitLineLength;
sp = text.indexOf(QueryUtil.SPLIT_LINE_FOR_QUERY_RESULT, sp);
if (sp == -1) {
break;
}
if (sp != 0) {
int lastSp = text.lastIndexOf("\n", sp - 2);
if (lastSp == -1) {
redStringLength += sp;
sp = 0;
} else {
redStringLength += (sp - lastSp);
sp = lastSp + 1;
}
}
boolean isErrorMsg = false;
try {
if (text.substring(sp, sp + redStringLength).indexOf(Messages.queryFail) != -1) {
isErrorMsg = true;
}
} catch (Exception e) {
}
StyleRange eachStyle = new StyleRange();
eachStyle.start = sp;
eachStyle.length = redStringLength;
eachStyle.fontStyle = SWT.NORMAL;
eachStyle.foreground = Display.getDefault().getSystemColor(isErrorMsg ? SWT.COLOR_RED : SWT.COLOR_BLUE);
logMessagesArea.setStyleRange(eachStyle);
sp += redStringLength;
}
logResultTabItem = new CTabItem(queryResultTabFolder, SWT.NONE);
logResultTabItem.setText(Messages.qedit_logsresult);
logResultTabItem.setControl(tailSash);
editor.getCombinedQueryComposite().getRecentlyUsedSQLComposite().refreshRecentlyUsedSQLList();
}
use of org.eclipse.swt.custom.SashForm in project cubrid-manager by CUBRID.
the class QueryResultComposite method makeResult.
/**
* make the result contents.
*
* @param result QueryExecuter
*/
private void makeResult(final QueryExecuter result, CTabFolder parentFolder) {
editor.getCombinedQueryComposite().getRecentlyUsedSQLComposite().refreshRecentlyUsedSQLList();
//final CTabFolder queryResultTabFolder = ((QueryResultComposite)queryResultTabItem.getControl()).queryResultTabFolder;
ViewForm viewForm = new ViewForm(parentFolder, SWT.NONE);
// create the bottom sash
final SashForm tableLogSash = new SashForm(viewForm, SWT.VERTICAL);
tableLogSash.SASH_WIDTH = SASH_WIDTH;
tableLogSash.setBackground(CombinedQueryEditorComposite.BACK_COLOR);
final Composite resultContainer = new Composite(tableLogSash, SWT.None);
resultContainer.setLayout(new FormLayout());
final Table resultTable = new Table(resultContainer, SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.HIDE_SELECTION);
setDropTraget(resultTable);
resultTable.setHeaderVisible(true);
resultTable.setLinesVisible(true);
resultTable.setBackground(BACKGROUND_NORMAL);
CommonUITool.hackForYosemite(resultTable);
// display data compare label for multiple queries
if (this.multiResultsCompare == true) {
Composite compareButtonComposite = new Composite(resultContainer, SWT.None);
compareButtonComposite.setLayout(new FillLayout());
displayDataCompareLabel(compareButtonComposite, resultTable);
FormData tableData = new FormData();
tableData.top = new FormAttachment(0, 0);
tableData.bottom = new FormAttachment(100, -28);
tableData.left = new FormAttachment(0, 0);
tableData.right = new FormAttachment(100, 0);
resultTable.setLayoutData(tableData);
FormData compareData = new FormData();
compareData.top = new FormAttachment(100, -28);
compareData.bottom = new FormAttachment(100, 0);
compareData.left = new FormAttachment(0, 0);
compareData.right = new FormAttachment(100, 0);
compareButtonComposite.setLayoutData(compareData);
} else {
FormData tableData = new FormData();
tableData.top = new FormAttachment(0, 0);
tableData.bottom = new FormAttachment(100, 0);
tableData.left = new FormAttachment(0, 0);
tableData.right = new FormAttachment(100, 0);
resultTable.setLayoutData(tableData);
}
final SashForm logSash = new SashForm(tableLogSash, SWT.HORIZONTAL);
logSash.SASH_WIDTH = SASH_WIDTH;
logSash.setBackground(CombinedQueryEditorComposite.BACK_COLOR);
logSash.setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
StyledText messagesArea = new StyledText(logSash, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.READ_ONLY | SWT.WRAP);
CommonUITool.registerCopyPasteContextMenu(messagesArea, false, false);
tableLogSash.setWeights(new int[] { 8, 2 });
messagesArea.setToolTipText(Messages.tooltipHowToExpandLogPane);
messagesArea.addFocusListener(new FocusListener() {
public void focusLost(FocusEvent e) {
tableLogSash.setWeights(new int[] { 8, 2 });
}
public void focusGained(FocusEvent e) {
tableLogSash.setWeights(new int[] { 2, 8 });
}
});
TableCursor cursor = new TableCursor(resultTable, SWT.NONE);
TableSelectSupport tableSelectSupport = new TableSelectSupport(resultTable, cursor);
if (this.multiResultsCompare == true) {
result.setMultiResultsCompare(true);
result.setBaseQueryExecuter(this.baseQueryExecuter);
}
result.makeResult(tableSelectSupport, messagesArea, isMutliQuery);
// Auto set column size, maximum is 300px,minimum is 50px
for (int i = 1; i < resultTable.getColumnCount(); i++) {
resultTable.getColumns()[i].pack();
if (resultTable.getColumns()[i].getWidth() > 300) {
resultTable.getColumns()[i].setWidth(300);
}
if (resultTable.getColumns()[i].getWidth() < 50) {
resultTable.getColumns()[i].setWidth(50);
}
}
// fill the view form action on top right corner
ToolBar topRightToolBar = new ToolBar(viewForm, SWT.FLAT);
ToolBarManager toolBarManager = new ToolBarManager(topRightToolBar);
result.makeActions(toolBarManager, resultTable);
// fill the view form action on top right corner
ToolBar topLeftToolBar = new ToolBar(viewForm, SWT.FLAT);
swRecordItem = new ToolItem(topLeftToolBar, SWT.CHECK);
result.swRecordItem = swRecordItem;
swRecordItem.setToolTipText(Messages.getOidOn);
swRecordItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/query_update.png"));
swRecordItem.setEnabled(true);
swRecordItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
if (editor.isCollectExecStats()) {
result.swRecordItem.setSelection(false);
CommonUITool.openErrorBox(getShell(), Messages.errNotEditableOnStat);
return;
}
if (!result.isContainPrimayKey()) {
result.swRecordItem.setSelection(false);
CommonUITool.openErrorBox(getShell(), Messages.errNoPrimaryKey);
return;
}
if (!result.isSingleTableQuery()) {
result.swRecordItem.setSelection(false);
CommonUITool.openErrorBox(getShell(), Messages.errNotInOneTable);
return;
}
if (!checkConnection()) {
result.swRecordItem.setSelection(false);
CommonUITool.openErrorBox(getShell(), Messages.errMsgExecuteInResult);
return;
}
result.tblResult.forceFocus();
if (result.swRecordItem.getSelection()) {
result.swRecordItem.setToolTipText(Messages.getOidOn);
result.setEditMode(true);
result.insertRecordItem.setEnabled(true);
if (result.tblResult.getSelectionCount() > 0) {
result.delRecordItem.setEnabled(true);
}
} else {
if (result.isModifiedResult()) {
result.swRecordItem.setSelection(true);
CommonUITool.openErrorBox(getShell(), Messages.errHasNoCommit);
return;
}
result.swRecordItem.setToolTipText(Messages.getOidOff);
result.setEditMode(false);
result.insertRecordItem.setEnabled(false);
result.delRecordItem.setEnabled(false);
}
}
});
//added by kevin, for insert record
insertRecordItem = new ToolItem(topLeftToolBar, SWT.PUSH);
result.insertRecordItem = insertRecordItem;
insertRecordItem.setToolTipText(com.cubrid.common.ui.cubrid.table.Messages.insertInstanceMsgTitle);
insertRecordItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/table_record_insert.png"));
insertRecordItem.setDisabledImage(CommonUIPlugin.getImage("icons/queryeditor/table_record_insert_disabled.png"));
insertRecordItem.setEnabled(false);
insertRecordItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
if (!result.getEditable()) {
CommonUITool.openErrorBox(getShell(), Messages.errNotEditable);
return;
}
if (!checkConnection()) {
CommonUITool.openErrorBox(getShell(), Messages.errMsgExecuteInResult);
return;
}
result.insertSaveItem.setEnabled(result.getEditable());
result.rollbackModifiedItem.setEnabled(result.getEditable());
result.addNewItem();
}
});
delRecordItem = new ToolItem(topLeftToolBar, SWT.PUSH);
result.delRecordItem = delRecordItem;
delRecordItem.setToolTipText(Messages.delete);
delRecordItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/table_record_delete.png"));
delRecordItem.setDisabledImage(CommonUIPlugin.getImage("icons/queryeditor/table_record_delete_disabled.png"));
delRecordItem.setEnabled(false);
delRecordItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
if (!result.getEditable()) {
CommonUITool.openErrorBox(getShell(), Messages.errNotEditable);
return;
}
if (!checkConnection()) {
CommonUITool.openErrorBox(getShell(), Messages.errMsgExecuteInResult);
return;
}
result.tblResult.forceFocus();
result.deleteRecord(result.tblResult, null);
}
});
insertSaveItem = new ToolItem(topLeftToolBar, SWT.PUSH);
result.insertSaveItem = insertSaveItem;
insertSaveItem.setToolTipText(Messages.insertCommit);
insertSaveItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/query_commit.png"));
insertSaveItem.setDisabledImage(CommonUIPlugin.getImage("icons/queryeditor/query_commit_disabled.png"));
insertSaveItem.setEnabled(false);
insertSaveItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
if (!checkConnection()) {
CommonUITool.openErrorBox(getShell(), Messages.errMsgExecuteInResult);
return;
}
if (result.getQueryEditor().isActive()) {
CommonUITool.openWarningBox(Messages.msgActiveTran);
return;
}
if (!CommonUITool.openConfirmBox(getShell(), (Messages.msgCommitEdited))) {
return;
}
try {
if (result.saveInsertedUpdatedDeletedRecords()) {
insertSaveItem.setEnabled(false);
result.rollbackModifiedItem.setEnabled(false);
result.swRecordItem.setSelection(false);
}
result.swRecordItem.setSelection(false);
result.insertRecordItem.setEnabled(false);
result.delRecordItem.setEnabled(false);
result.setEditMode(false);
} catch (ParamSetException e) {
if (e.getParameter() != null && !StringUtil.isEmpty(e.getParameter().getDataType())) {
CommonUITool.openErrorBox(Messages.bind(Messages.errTextTypeNotMatch, e.getParameter().getDataType()) + StringUtil.NEWLINE + e.getLocalizedMessage());
} else {
CommonUITool.openErrorBox(getShell(), e.getLocalizedMessage());
}
} catch (SQLException e) {
e.printStackTrace();
CommonUITool.openErrorBox(getShell(), e.getErrorCode() + StringUtil.NEWLINE + e.getMessage());
/*Can't edit any data if necessary*/
// result.setEditMode(false);
// delRecordItem.setEnabled(false);
// insertRecordItem.setEnabled(false);
// insertSaveItem.setEnabled(false) ;
// swRecordItem.setEnabled(false);
// rollbackModifiedItem.setEnabled(false);
result.getTblResult().setBackground(BACKGROUND_DIRTY);
}
}
});
rollbackModifiedItem = new ToolItem(topLeftToolBar, SWT.PUSH);
result.rollbackModifiedItem = rollbackModifiedItem;
rollbackModifiedItem.setToolTipText(Messages.insertRollback);
rollbackModifiedItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/query_rollback.png"));
rollbackModifiedItem.setDisabledImage(CommonUIPlugin.getImage("icons/queryeditor/query_rollback_disabled.png"));
rollbackModifiedItem.setEnabled(false);
rollbackModifiedItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
if (!CommonUITool.openConfirmBox(getShell(), (Messages.msgRollbackEdited))) {
return;
}
result.tblResult.forceFocus();
insertSaveItem.setEnabled(false);
rollbackModifiedItem.setEnabled(false);
result.clearModifiedLog();
QueryInfo queryInfo = result.getQueryInfo();
queryInfo.setCurrentPage(queryInfo.getCurrentPage());
result.makeItem();
result.updateActions();
result.swRecordItem.setSelection(false);
result.insertRecordItem.setEnabled(false);
result.delRecordItem.setEnabled(false);
result.setEditMode(false);
result.tblResult.setBackground(BACKGROUND_NORMAL);
}
});
if (!isMutliQuery) {
new ToolItem(topLeftToolBar, SWT.SEPARATOR);
copyInsertSqlFromRecordsItem = new ToolItem(topLeftToolBar, SWT.PUSH);
copyInsertSqlFromRecordsItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/record_to_insert.png"));
copyInsertSqlFromRecordsItem.setToolTipText(Messages.makeInsertFromSelectedRecord);
copyInsertSqlFromRecordsItem.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
if (editor == null) {
return;
}
String text = editor.getQueryExecuter().makeInsertQueryWithSelectedRecords();
if (StringUtil.isEmpty(text)) {
CommonUITool.openErrorBox(getShell(), Messages.canNotMakeQueryBecauseNoSelected);
return;
}
CommonUITool.copyContentToClipboard(text);
}
public void widgetDefaultSelected(SelectionEvent e) {
}
});
copyUpdateSqlFromRecordsItem = new ToolItem(topLeftToolBar, SWT.PUSH);
copyUpdateSqlFromRecordsItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/record_to_update.png"));
copyUpdateSqlFromRecordsItem.setToolTipText(Messages.makeUpdateFromSelectedRecord);
copyUpdateSqlFromRecordsItem.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
if (editor == null) {
return;
}
String text = editor.getQueryExecuter().makeUpdateQueryWithSelectedRecords();
if (StringUtil.isEmpty(text)) {
CommonUITool.openErrorBox(getShell(), Messages.canNotMakeQueryBecauseNoSelected);
return;
}
CommonUITool.copyContentToClipboard(text);
}
public void widgetDefaultSelected(SelectionEvent e) {
}
});
}
new ToolItem(topLeftToolBar, SWT.SEPARATOR);
final ToolItem exportDataItem = new ToolItem(topLeftToolBar, SWT.PUSH);
exportDataItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/table_data_export.png"));
exportDataItem.setToolTipText(Messages.msgExportAllQueryResults);
exportDataItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
CTabItem[] items = queryResultTabFolder.getItems();
if (items == null || items.length == 0) {
return;
}
List<QueryExecuter> qeList = new ArrayList<QueryExecuter>();
for (CTabItem item : items) {
if (!(item.getData() instanceof QueryExecuter)) {
continue;
}
QueryExecuter qe = (QueryExecuter) item.getData();
qeList.add(qe);
}
if (qeList.isEmpty()) {
return;
}
ExportQueryResultDialog dialog = new ExportQueryResultDialog(getShell(), qeList);
dialog.open();
}
});
new ToolItem(topLeftToolBar, SWT.SEPARATOR);
final ToolItem showLogItem = new ToolItem(topLeftToolBar, SWT.PUSH);
showLogItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/qe_panel_down.png"));
showLogItem.setToolTipText(Messages.tooltip_qedit_log_show_hide);
showLogItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
if (tableLogSash.getMaximizedControl() == null) {
tableLogSash.setMaximizedControl(resultContainer);
showLogItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/qe_panel_up.png"));
tableLogSash.layout(true);
} else {
tableLogSash.setMaximizedControl(null);
showLogItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/qe_panel_down.png"));
tableLogSash.layout(true);
}
}
});
new ToolItem(topLeftToolBar, SWT.SEPARATOR);
viewForm.setContent(tableLogSash);
viewForm.setTopRight(topRightToolBar);
viewForm.setTopLeft(topLeftToolBar);
final QueryTableTabItem queryTableTabItem = new QueryTableTabItem(parentFolder, SWT.NONE);
queryTableTabItem.setText(Messages.qedit_result + (result.idx + 1));
queryTableTabItem.setControl(viewForm);
queryTableTabItem.setData(result);
queryTableTabItem.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
InfoWindowManager.getInstance().updateContent(editor);
}
});
parentFolder.setSelection(queryTableTabItem);
tableSelectSupport.addSelectChangeListener(new ISelectionChangeListener() {
@SuppressWarnings("unchecked")
public void selectionChanged(SelectionChangeEvent event) {
boolean active = event.selectedArray.length > 0;
boolean canEdit = active && result.getEditable() && result.isEditMode();
if (delRecordItem != null) {
delRecordItem.setEnabled(canEdit);
}
if (copyInsertSqlFromRecordsItem != null) {
copyInsertSqlFromRecordsItem.setEnabled(active);
}
if (copyUpdateSqlFromRecordsItem != null) {
copyUpdateSqlFromRecordsItem.setEnabled(active);
}
/*TOOLS-3632 Add calculation info*/
int count = event.selectedArray.length;
BigDecimal sum = new BigDecimal(0);
BigDecimal average = null;
int numericCount = 0;
QueryResultTableCalcInfo queryResultTableCalcInfo = null;
StatusLineContrItem statusCont = LayoutManager.getInstance().getStatusLineContrItem();
if (count > 1) {
for (Point p : event.selectedArray) {
TableColumn column = result.tblResult.getColumn(p.x);
if (column == null) {
continue;
}
ColumnInfo columnInfo = (ColumnInfo) column.getData();
if (columnInfo == null) {
continue;
}
String dataType = columnInfo.getType();
if (!DataType.isNumberType(dataType)) {
continue;
}
TableItem item = result.tblResult.getItem(p.y);
if (item == null || item.getData() == null) {
continue;
}
Map<String, CellValue> dataMap = (Map<String, CellValue>) item.getData();
CellValue cellValue = dataMap.get(Integer.toString(p.x));
if (cellValue != null && cellValue.getValue() != null) {
numericCount++;
Object value = cellValue.getValue();
if (value instanceof Integer) {
sum = sum.add(new BigDecimal((Integer) value));
} else if (value instanceof Short) {
sum = sum.add(new BigDecimal((Short) value));
} else if (value instanceof Long) {
sum = sum.add(new BigDecimal((Long) value));
} else if (value instanceof Float) {
sum = sum.add(new BigDecimal((Float) value));
} else if (value instanceof Double) {
sum = sum.add(new BigDecimal((Double) value));
} else if (value instanceof BigDecimal) {
sum = sum.add((BigDecimal) value);
}
}
}
if (numericCount > 0) {
average = sum.divide(new BigDecimal(numericCount), 3, RoundingMode.HALF_UP);
queryResultTableCalcInfo = new QueryResultTableCalcInfo(count, average, sum);
} else {
queryResultTableCalcInfo = new QueryResultTableCalcInfo(count);
}
}
queryTableTabItem.setQueryResultTableCalcInfo(queryResultTableCalcInfo);
InfoWindowManager.getInstance().updateContent(editor);
statusCont.changeStuatusLineForViewOrEditPart(editor.getSelectedDatabase(), editor);
}
});
}
use of org.eclipse.swt.custom.SashForm in project cubrid-manager by CUBRID.
the class TuneModeResultComposite method createQueryCompareTab.
private void createQueryCompareTab(Composite comp) {
Composite composite = new Composite(comp, SWT.None);
composite.setLayout(new GridLayout());
composite.setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
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(1, 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(4, false));
useLeft = new Button(leftTopComposite, SWT.CHECK);
useLeft.setText(Messages.lblTuneModeOrgPlan);
useLeft.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
useLeft.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
if (useLeft.getSelection()) {
useRight.setSelection(false);
} else {
useRight.setSelection(true);
}
}
});
useLeft.setSelection(true);
useRight = new Button(rightTopComposite, SWT.CHECK);
useRight.setText(Messages.lblTuneModeNewPlan);
useRight.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
useRight.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
if (useRight.getSelection()) {
useLeft.setSelection(false);
} else {
useLeft.setSelection(true);
}
}
});
useRight.setSelection(false);
ToolBar leftToolBar = new ToolBar(rightTopComposite, SWT.None);
leftToolBar.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
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));
sqlModeItem = new ToolItem(rightToolBar, SWT.CHECK);
sqlModeItem.setImage(CommonUIPlugin.getImage("icons/queryplan/sql_compare.gif"));
sqlModeItem.setToolTipText(Messages.itemTooltipQuery);
//sqlModeItem.setText(Messages.lblTuneCompareQueryBtn);
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.setText(Messages.lblPlanRawBtn);
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.setText(Messages.lblPlanTreeBtn);
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.setText(Messages.lblPlanGraph);
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 TuneModeResultContentProvider());
compareLeftTableViewer.setLabelProvider(new TuneModeResultLabelProvider(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 TuneModeResultContentProvider());
compareRightTableViewer.setLabelProvider(new TuneModeResultLabelProvider(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));
queryPlanCompareSashForm.setSashWidth(0);
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());
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 });
updateCompareDisplayModel(DISPLAY_TREE);
}
use of org.eclipse.swt.custom.SashForm in project cubrid-manager by CUBRID.
the class QueryEditorPart method fillInToolbar.
public void fillInToolbar() {
qeToolBar.addDatabaseChangedListener(new Listener() {
public void handleEvent(Event event) {
Object data = event.data;
if (data instanceof CubridDatabase) {
CubridDatabase database = (CubridDatabase) data;
if (database == DatabaseNavigatorMenu.NULL_DATABASE) {
resetJDBCConnection();
} else {
initConnection(database);
}
ServerInfo serverInfo = database.getServer() == null ? null : database.getServer().getServerInfo();
boolean autoCommit = QueryOptions.getAutoCommit(serverInfo);
setAutocommit(autoCommit);
}
}
});
final ToolBar toolBar = qeToolBar;
// [TOOLS-2425]Support shard broker
changeShardIdValItem = new ToolItem(toolBar, SWT.PUSH);
changeShardIdValItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/change_shard_id.png"));
changeShardIdValItem.setDisabledImage(CommonUIPlugin.getImage("icons/queryeditor/change_shard_id_disabled.png"));
changeShardIdValItem.setToolTipText(Messages.changeShardId);
changeShardIdValItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
CubridDatabase cubridDatabase = getSelectedDatabase();
if (cubridDatabase != null) {
DatabaseInfo dbInfo = cubridDatabase.getDatabaseInfo();
if (dbInfo != null && dbInfo.isShard()) {
ShardIdSelectionDialog dialog = new ShardIdSelectionDialog(Display.getDefault().getActiveShell());
dialog.setDatabaseInfo(dbInfo);
dialog.setShardId(shardId);
dialog.setShardVal(shardVal);
dialog.setShardQueryType(shardQueryType);
if (dialog.open() == IDialogConstants.OK_ID) {
shardId = dialog.getShardId();
shardVal = dialog.getShardVal();
shardQueryType = dialog.getShardQueryType();
changeQueryEditorPartNameWithShard();
}
}
}
}
});
CubridDatabase cubridDatabase = getSelectedDatabase();
if (cubridDatabase == null || CubridDatabase.hasValidDatabaseInfo(cubridDatabase) && cubridDatabase.getDatabaseInfo().isShard()) {
changeShardIdValItem.setEnabled(false);
}
new ToolItem(toolBar, SWT.SEPARATOR);
runItem = new ToolItem(toolBar, SWT.PUSH);
runItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/query_run.png"));
runItem.setDisabledImage(CommonUIPlugin.getImage("icons/queryeditor/query_run_disabled.png"));
runItem.setToolTipText(Messages.run + "(F5)");
runItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
hideToolTip();
runQuery(false);
}
});
multiRunItem = new ToolItem(toolBar, SWT.PUSH);
multiRunItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/query_multi_run.png"));
multiRunItem.setToolTipText(Messages.runMultiQuery + "(F8)");
multiRunItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
changeMultiQueryMode();
}
});
queryPlanItem = new ToolItem(toolBar, SWT.PUSH);
queryPlanItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/query_execution_plan.png"));
queryPlanItem.setToolTipText(Messages.queryPlanTip + "(F6)");
queryPlanItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
hideToolTip();
runQuery(true);
}
});
ToolItem historyItem = new ToolItem(toolBar, SWT.PUSH);
historyItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/query_history.png"));
historyItem.setToolTipText(Messages.queryHistory + "(F7)");
historyItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
hideToolTip();
getCombinedQueryComposite().select(2, -1);
}
});
setPstmtParaItem = new ToolItem(toolBar, SWT.PUSH);
setPstmtParaItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/qe_set_param.png"));
setPstmtParaItem.setToolTipText(Messages.tipSetPstmt);
setPstmtParaItem.setEnabled(false);
setPstmtParaItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
hideToolTip();
if (combinedQueryComposite.getSqlEditorComp().isDisposed()) {
return;
}
PstmtSQLDialog dialog = new PstmtSQLDialog(getSite().getShell(), getSelectedDatabase());
dialog.create();
dialog.setEditorInput((QueryUnit) getEditorInput());
String queries = getSelectedText();
dialog.setSql(queries);
dialog.open();
}
});
tuneModeItem = new ToolItem(toolBar, SWT.CHECK);
tuneModeItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/tune_mode.png"));
tuneModeItem.setToolTipText(Messages.tipExecStat + "(F9)");
tuneModeItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
hideToolTip();
boolean isTuneMode = tuneModeItem.getSelection();
changeCollectExecStats(isTuneMode);
if (isTuneMode) {
showToolTip(qeToolBar, tuneModeItem, Messages.ttQeToolbarTuneModeTitle, Messages.ttQeToolbarTuneModeMSg);
} else {
hideToolTip();
}
}
});
new ToolItem(toolBar, SWT.SEPARATOR);
final ToolItem addEditorItem = new ToolItem(toolBar, SWT.PUSH);
addEditorItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/tab_item_add.png"));
addEditorItem.setToolTipText(Messages.queryEditorAddTabItemTooltip + "(Ctrl+Shift+T)");
addEditorItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
hideToolTip();
addEditorTab();
}
});
new ToolItem(toolBar, SWT.SEPARATOR);
runBatchItem = new ToolItem(toolBar, SWT.PUSH);
runBatchItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/run_batch_sql.png"));
runBatchItem.setToolTipText(Messages.batchRun);
runBatchItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
hideToolTip();
try {
// FIXME extract utility
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IViewPart view = page.findView(FavoriteQueryNavigatorView.ID);
if (view != null) {
page.hideView(view);
} else {
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(FavoriteQueryNavigatorView.ID, null, IWorkbenchPage.VIEW_ACTIVATE);
}
} catch (PartInitException e) {
LOGGER.error(e.getMessage(), e);
}
}
});
new ToolItem(toolBar, SWT.SEPARATOR);
ToolItem itemFormatterr = new ToolItem(toolBar, SWT.PUSH);
itemFormatterr.setImage(CommonUIPlugin.getImage("icons/queryeditor/query_format.png"));
itemFormatterr.setToolTipText(Messages.formatTip + "(Ctrl+Shift+F)");
itemFormatterr.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
hideToolTip();
combinedQueryComposite.getSqlEditorComp().format();
}
});
ToolItem itemIndent = new ToolItem(toolBar, SWT.PUSH);
itemIndent.setImage(CommonUIPlugin.getImage("icons/queryeditor/query_indent_add.png"));
itemIndent.setToolTipText(Messages.indentTip + "(Tab)");
itemIndent.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
hideToolTip();
if (combinedQueryComposite.getSqlEditorComp().isDisposed()) {
return;
}
combinedQueryComposite.getSqlEditorComp().indent();
}
});
ToolItem itemUnindent = new ToolItem(toolBar, SWT.PUSH);
itemUnindent.setImage(CommonUIPlugin.getImage("icons/queryeditor/query_indent_delete.png"));
itemUnindent.setToolTipText(Messages.unIndentTip + "(Shift+Tab)");
itemUnindent.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
hideToolTip();
if (combinedQueryComposite.getSqlEditorComp().isDisposed()) {
return;
}
combinedQueryComposite.getSqlEditorComp().unindent();
}
});
ToolItem clearItem = new ToolItem(toolBar, SWT.PUSH);
clearItem.setImage(CommonUIPlugin.getImage("/icons/queryeditor/clear_sql.png"));
clearItem.setToolTipText(Messages.clear);
clearItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
hideToolTip();
if (combinedQueryComposite.getSqlEditorComp().isDisposed()) {
return;
}
if (!CommonUITool.openConfirmBox(Messages.msgClear)) {
return;
}
combinedQueryComposite.getSqlEditorComp().setQueries("");
}
});
new ToolItem(toolBar, SWT.SEPARATOR);
ToolItem itemComment = new ToolItem(toolBar, SWT.PUSH);
itemComment.setImage(CommonUIPlugin.getImage("icons/queryeditor/query_comment_add.png"));
itemComment.setToolTipText(Messages.commentTip + "(Ctrl+/)");
itemComment.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
hideToolTip();
if (combinedQueryComposite.getSqlEditorComp().isDisposed()) {
return;
}
combinedQueryComposite.getSqlEditorComp().comment();
}
});
ToolItem itemUncomment = new ToolItem(toolBar, SWT.PUSH);
itemUncomment.setImage(CommonUIPlugin.getImage("icons/queryeditor/query_comment_delete.png"));
itemUncomment.setToolTipText(Messages.unCommentTip + "(Ctrl+/)");
itemUncomment.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
hideToolTip();
if (combinedQueryComposite.getSqlEditorComp().isDisposed()) {
return;
}
combinedQueryComposite.getSqlEditorComp().uncomment();
}
});
new ToolItem(toolBar, SWT.SEPARATOR);
commitItem = new ToolItem(toolBar, SWT.PUSH);
commitItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/query_commit.png"));
commitItem.setDisabledImage(CommonUIPlugin.getImage("icons/queryeditor/query_commit_disabled.png"));
commitItem.setToolTipText(Messages.commit);
commitItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
hideToolTip();
commit();
}
});
commitItem.setEnabled(false);
rollbackItem = new ToolItem(toolBar, SWT.PUSH);
rollbackItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/query_rollback.png"));
rollbackItem.setDisabledImage(CommonUIPlugin.getImage("icons/queryeditor/query_rollback_disabled.png"));
rollbackItem.setToolTipText(Messages.rollback);
rollbackItem.setEnabled(false);
rollbackItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
hideToolTip();
rollback();
}
});
autoCommitItem = new ToolItem(toolBar, SWT.CHECK);
autoCommitItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/query_auto_false.png"));
autoCommitItem.setToolTipText(Messages.autoCommit);
autoCommitItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
hideToolTip();
if (checkActive()) {
return;
}
setAutocommit(autoCommitItem.getSelection());
if (connection != null) {
try {
connection.setAutoCommit(isAutocommit());
} catch (SQLException e) {
}
}
}
});
setAutocommit(true);
new ToolItem(toolBar, SWT.SEPARATOR);
ToolItem openItem = new ToolItem(toolBar, SWT.PUSH);
openItem.setImage(CommonUIPlugin.getImage("/icons/queryeditor/file_open.png"));
openItem.setToolTipText(Messages.open);
openItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
hideToolTip();
doOpen();
}
});
ToolItem saveItem = new ToolItem(toolBar, SWT.PUSH);
saveItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/file_save.png"));
saveItem.setToolTipText(Messages.save);
saveItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
hideToolTip();
doSave(new NullProgressMonitor());
}
});
ToolItem saveAsItem = new ToolItem(toolBar, SWT.PUSH);
saveAsItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/file_saveas.png"));
saveAsItem.setToolTipText(Messages.saveAs);
saveAsItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
hideToolTip();
doSaveAs();
}
});
//Fill in the show or hide result pane tool item
new ToolItem(toolBar, SWT.SEPARATOR);
showResultItem = new ToolItem(toolBar, SWT.PUSH);
showResultItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/qe_panel_down.png"));
showResultItem.setToolTipText(Messages.tooltip_qedit_result_show_hide);
showResultItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
hideToolTip();
CTabFolder resultTabFolder = combinedQueryComposite.getResultTabFolder();
SashForm topSash = combinedQueryComposite.getTopSash();
if (resultTabFolder.getMinimized()) {
resultTabFolder.setMinimized(false);
resultTabFolder.setMaximized(false);
topSash.setMaximizedControl(null);
showResultItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/qe_panel_down.png"));
topSash.layout(true);
} else if (!resultTabFolder.getMaximized() && !resultTabFolder.getMinimized()) {
resultTabFolder.setMinimized(true);
topSash.setMaximizedControl(combinedQueryComposite.getSqlEditorComp().getParent());
showResultItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/qe_panel_up.png"));
topSash.layout(true);
}
}
});
topComposite.pack();
packToolBar();
}
use of org.eclipse.swt.custom.SashForm in project cubrid-manager by CUBRID.
the class QueryRecordListComparator method displayQuery.
/**
* Display the query data
*
* @param queryRecord
*/
private void displayQuery(final QueryRecord queryRecord) {
if (queryResultComposite != null && !queryResultComposite.isDisposed()) {
queryResultComposite.dispose();
}
queryResultComposite = new Composite(queryResultContainer, SWT.None);
queryResultComposite.setLayout(new FillLayout());
ViewForm viewForm = new ViewForm(queryResultComposite, SWT.NONE);
viewForm.setLayout(new FillLayout());
final SashForm tableLogSash = new SashForm(viewForm, SWT.VERTICAL);
tableLogSash.SASH_WIDTH = SASH_WIDTH;
tableLogSash.setBackground(BACK_COLOR);
/*Create table view*/
final TableViewer resultTableViewer = new TableViewer(tableLogSash, SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.HIDE_SELECTION);
TableCursor cursor = new TableCursor(resultTableViewer.getTable(), SWT.NONE);
TableSelectSupport tableSelectSupport = new TableSelectSupport(resultTableViewer.getTable(), cursor);
String fontString = QueryOptions.getFontString(database.getDatabaseInfo().getServerInfo());
Font tmpFont = ResourceManager.getFont(fontString);
if (tmpFont == null) {
String[] fontData = QueryOptions.getDefaultFont();
tmpFont = ResourceManager.getFont(fontData[0], Integer.valueOf(fontData[1]), Integer.valueOf(fontData[2]));
}
Font font = tmpFont;
resultTableViewer.getTable().setFont(font);
int[] fontColor = QueryOptions.getFontColor(database.getDatabaseInfo().getServerInfo());
Color color = ResourceManager.getColor(fontColor[0], fontColor[1], fontColor[2]);
resultTableViewer.getTable().setForeground(color);
/*Set font and foreground*/
tableSelectSupport.getTableCursor().setFont(font);
tableSelectSupport.getTableCursor().setForeground(color);
final SashForm logSash = new SashForm(tableLogSash, SWT.HORIZONTAL);
logSash.SASH_WIDTH = SASH_WIDTH;
logSash.setBackground(BACK_COLOR);
logSash.setLayout(new FillLayout());
StyledText messagesArea = new StyledText(logSash, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.READ_ONLY | SWT.WRAP);
messagesArea.setToolTipText(Messages.tooltipHowToExpandLogPane);
messagesArea.addFocusListener(new FocusListener() {
public void focusLost(FocusEvent e) {
tableLogSash.setWeights(new int[] { 8, 2 });
}
public void focusGained(FocusEvent e) {
tableLogSash.setWeights(new int[] { 2, 8 });
}
});
tableLogSash.setWeights(new int[] { 8, 2 });
viewForm.setContent(tableLogSash);
resultTableViewer.getTable().setHeaderVisible(true);
resultTableViewer.getTable().setLinesVisible(true);
if (queryRecord != null) {
QueryResultLabelProvider labelProvider = new QueryResultLabelProvider(queryRecord);
QueryResultContentProvider contentProvider = new QueryResultContentProvider();
resultTableViewer.setLabelProvider(labelProvider);
resultTableViewer.setContentProvider(contentProvider);
createResultColumn(resultTableViewer, queryRecord);
resultTableViewer.setInput(queryRecord.getPageData());
setQueryMessage(messagesArea, queryRecord);
}
CommonUITool.packTable(resultTableViewer.getTable(), 10, 150);
queryResultContainer.layout();
}
Aggregations