use of org.eclipse.swt.custom.CTabFolder in project cubrid-manager by CUBRID.
the class QueryEditorPart method createCombinedQueryEditorCTabFolder.
/**
* create editor CTabFolder all sql editor tab will add to this
*/
public void createCombinedQueryEditorCTabFolder() {
combinedQueryEditortabFolder = new CTabFolder(topComposite, SWT.TOP);
combinedQueryEditortabFolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
combinedQueryEditortabFolder.setUnselectedImageVisible(true);
combinedQueryEditortabFolder.setUnselectedCloseVisible(false);
combinedQueryEditortabFolder.setBorderVisible(true);
combinedQueryEditortabFolder.setSimple(false);
combinedQueryEditortabFolder.setSelectionBackground(CombinedQueryEditorComposite.BACK_COLOR);
combinedQueryEditortabFolder.setSelectionForeground(ResourceManager.getColor(SWT.COLOR_BLACK));
combinedQueryEditortabFolder.setMinimizeVisible(false);
combinedQueryEditortabFolder.setMaximizeVisible(false);
combinedQueryEditortabFolder.setTabHeight(22);
combinedQueryEditortabFolder.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
CTabItem item = combinedQueryEditortabFolder.getSelection();
if (item instanceof SubQueryEditorTabItem) {
SubQueryEditorTabItem queryResultTabItem = (SubQueryEditorTabItem) item;
combinedQueryComposite = queryResultTabItem.getControl();
combinedQueryComposite.refreshEditorComposite();
InfoWindowManager.getInstance().updateContent(QueryEditorPart.this);
}
}
});
TabContextMenuManager ctxmenu = new TabContextMenuManager(combinedQueryEditortabFolder);
ctxmenu.createContextMenu();
//add a default SQL Tab item
addEditorTab();
}
use of org.eclipse.swt.custom.CTabFolder in project cubrid-manager by CUBRID.
the class QueryEditorPart method runQueryPlanOnly.
/**
* Fetch execution plans while running SQLs
*
* @param queries String
*/
private void runQueryPlanOnly(Vector<String> qVector) {
try {
connection.getConnection(true);
} catch (SQLException e) {
CommonUITool.openErrorBox(e.getLocalizedMessage());
return;
}
if (!connection.hasConnection()) {
return;
}
// clearPlan();
CUBRIDStatementProxy statement = null;
int i = 0;
try {
int len = qVector.size();
for (i = 0; i < len; i++) {
String sql = qVector.get(i).toString();
statement = getStatement(connection.getConnection(), false);
StructQueryPlan sq = new StructQueryPlan(sql, statement.getQueryplan(sql), new Date());
if (combinedQueryComposite.getQueryPlanResultComp().isDisposed()) {
combinedQueryComposite.newQueryPlanComp();
}
combinedQueryComposite.getQueryPlanResultComp().makePlan(sq, i);
QueryUtil.freeQuery(statement);
statement = null;
if (collectExecStats) {
displayTuneModeResult(new TuneModeModel(sq, null));
}
}
} catch (Exception ee) {
int errorCode = 0;
if (SQLException.class.isInstance(ee)) {
errorCode = ((SQLException) ee).getErrorCode();
}
String errmsg = "";
if (isAutocommit) {
try {
queryAction(QUERY_ACTION.ROLLBACK);
} catch (SQLException e1) {
LOGGER.error("", e1);
}
}
SQLEditorComposite sqlEditorComp = combinedQueryComposite.getSqlEditorComp();
sqlEditorComp.txtFind((String) qVector.get(i), 0, false, false, true, false);
StyledText txaEdit = sqlEditorComp.getText();
int line = txaEdit.getLineAtOffset(txaEdit.getSelection().x) + 1;
String errorLineMsg = Messages.bind(Messages.errWhere, line);
errmsg += Messages.runError + errorCode + StringUtil.NEWLINE + errorLineMsg + StringUtil.NEWLINE + Messages.errorHead + ee.getMessage();
CTabFolder queryResultTabFolder = combinedQueryComposite.getQueryResultComp().getQueryResultTabFolder();
StyledText logMessagesArea = combinedQueryComposite.getQueryResultComp().getLogMessagesArea();
QueryResultComposite queryResult = combinedQueryComposite.getQueryResultComp();
queryResultTabFolder.setSelection(0);
String logMessage = logMessagesArea.getText();
if (logMessage != null && logMessage.length() > 0) {
logMessage += StringUtil.NEWLINE;
}
logMessagesArea.setText(logMessage + StringUtil.NEWLINE + errmsg);
logMessagesArea.setTopIndex(logMessagesArea.getLineCount() - 1);
queryResult.setSelection();
LOGGER.error(ee.getMessage(), ee);
} finally {
QueryUtil.freeQuery(statement);
statement = null;
}
autoCommitItem.setEnabled(true);
queryPlanItem.setEnabled(true);
setPstmtParaItem.setEnabled(true);
isRunning = false;
}
use of org.eclipse.swt.custom.CTabFolder in project cubrid-manager by CUBRID.
the class ColumnViewerSorter method createTabFolder.
public void createTabFolder(Composite parent) {
tabFolder = new CTabFolder(parent, SWT.TOP);
tabFolder.setLayout(new FillLayout());
tabFolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
tabFolder.setSimple(false);
tabFolder.setUnselectedImageVisible(true);
tabFolder.setUnselectedCloseVisible(true);
tabFolder.setSelectionBackground(ResourceManager.getColor(136, 161, 227));
tabFolder.setSelectionForeground(ResourceManager.getColor(SWT.COLOR_BLACK));
Menu menu = new Menu(tabFolder.getShell(), SWT.POP_UP);
tabFolder.setMenu(menu);
MenuItem closeItem = new MenuItem(menu, SWT.PUSH);
closeItem.setText(Messages.tablesDetailInfoPartCloseMenu);
closeItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
CTabItem item = tabFolder.getSelection();
item.dispose();
}
});
MenuItem closeOthersItem = new MenuItem(menu, SWT.PUSH);
closeOthersItem.setText(Messages.tablesDetailInfoPartCloseOthersMenu);
closeOthersItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
CTabItem[] items = tabFolder.getItems();
CTabItem selectedItem = tabFolder.getSelection();
for (CTabItem item : items) {
if (!item.equals(selectedItem)) {
item.dispose();
}
}
}
});
MenuItem closeAllItem = new MenuItem(menu, SWT.PUSH);
closeAllItem.setText(Messages.tablesDetailInfoPartCloseAllMenu);
closeAllItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
CTabItem[] items = tabFolder.getItems();
for (CTabItem item : items) {
item.dispose();
}
}
});
}
use of org.eclipse.swt.custom.CTabFolder in project cubrid-manager by CUBRID.
the class QueryPlanCompositeWithHistory method initialize.
/**
* Initializing a Plan Tab
*/
private void initialize() {
createPlanToolbar();
//create the plan tab folder and history sash
plansHistorySash = new SashForm(this, SWT.HORIZONTAL);
plansHistorySash.setLayout(new GridLayout(2, true));
plansHistorySash.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
//create left plan tab folder
plansTabFolder = new CTabFolder(plansHistorySash, SWT.BOTTOM | SWT.CLOSE);
plansTabFolder.setSimple(false);
plansTabFolder.setUnselectedImageVisible(true);
plansTabFolder.setUnselectedCloseVisible(true);
plansTabFolder.setSelectionBackground(CombinedQueryEditorComposite.BACK_COLOR);
plansTabFolder.setSelectionForeground(ResourceManager.getColor(SWT.COLOR_BLACK));
plansTabFolder.setLayout(new GridLayout(1, true));
plansTabFolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
TabContextMenuManager tabContextMenuManager = new TabContextMenuManager(plansTabFolder);
tabContextMenuManager.createContextMenu();
//create the right plan history table
planHistoryTable = new Table(plansHistorySash, SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER);
planHistoryTable.setLayout(new GridLayout(1, true));
planHistoryTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
planHistoryTable.setHeaderVisible(true);
planHistoryTable.setLinesVisible(true);
planHistoryTable.addMouseListener(new MouseListener() {
public void mouseDoubleClick(MouseEvent event) {
int selectionIndex = planHistoryTable.getSelectionIndex();
if (selectionIndex < 0) {
return;
}
TableItem tableItem = planHistoryTable.getItem(planHistoryTable.getSelectionIndex());
if (tableItem == null) {
return;
}
int uid = Integer.valueOf(tableItem.getText(0));
StructQueryPlan sq = planHistoryList.get(uid - 1);
PlanTabItem tabItem = findPlanTab(uid);
if (tabItem == null) {
tabItem = newPlanTab(uid);
}
plansTabFolder.setSelection(tabItem);
printPlan(tabItem, sq);
}
public void mouseDown(MouseEvent event) {
}
public void mouseUp(MouseEvent event) {
}
});
int i = 0;
planHistoryTblCols[i] = new TableColumn(planHistoryTable, SWT.RIGHT);
// No
planHistoryTblCols[i].setText(Messages.qedit_plan_history_col1);
planHistoryTblCols[i].setMoveable(true);
planHistoryTblCols[i].setWidth(20);
addNumberSorter(planHistoryTable, planHistoryTblCols[i]);
sortType.put(planHistoryTblCols[i], "NUMBER");
planHistoryTblCols[++i] = new TableColumn(planHistoryTable, SWT.LEFT);
// Date
planHistoryTblCols[i].setText(Messages.qedit_plan_history_col2);
planHistoryTblCols[i].setMoveable(true);
planHistoryTblCols[i].setWidth(100);
addStringSorter(planHistoryTable, planHistoryTblCols[i]);
sortType.put(planHistoryTblCols[i], "STRING");
planHistoryTblCols[++i] = new TableColumn(planHistoryTable, SWT.RIGHT);
// Cost
planHistoryTblCols[i].setText(Messages.qedit_plan_history_col4);
planHistoryTblCols[i].setMoveable(true);
planHistoryTblCols[i].setWidth(90);
addNumberSorter(planHistoryTable, planHistoryTblCols[i]);
sortType.put(planHistoryTblCols[i], "NUMBER");
planHistoryTblCols[++i] = new TableColumn(planHistoryTable, SWT.LEFT);
// Cost
planHistoryTblCols[i].setText(Messages.qedit_plan_history_col3);
planHistoryTblCols[i].setMoveable(false);
planHistoryTblCols[i].setWidth(90);
addStringSorter(planHistoryTable, planHistoryTblCols[i]);
sortType.put(planHistoryTblCols[i], "STRING");
sashPlanWeight = new int[] { 80, 20 };
plansHistorySash.setWeights(sashPlanWeight);
newPlanTab(1);
plansTabFolder.setSelection(0);
hideHistoryPane();
refreshToolbarStatus(QueryOptions.getQueryPlanDisplayType());
}
use of org.eclipse.swt.custom.CTabFolder in project cubrid-manager by CUBRID.
the class RecentlyUsedSQLComposite method initialize.
/**
* Create the SQL history composite
*/
public void initialize() {
Composite toolBarComposite = new Composite(this, SWT.NONE);
GridLayout gridLayout = new GridLayout(1, false);
gridLayout.verticalSpacing = 0;
gridLayout.horizontalSpacing = 10;
gridLayout.marginWidth = 0;
gridLayout.marginHeight = 0;
gridLayout.numColumns = 2;
toolBarComposite.setLayout(gridLayout);
toolBarComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
ToolBar delHistoryToolBar = new ToolBar(toolBarComposite, SWT.FLAT | SWT.RIGHT);
delHistoryToolBar.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, true, false));
ToolItem delHistory = new ToolItem(delHistoryToolBar, SWT.PUSH);
delHistory.setImage(CommonUIPlugin.getImage("icons/action/table_record_delete.png"));
delHistory.setDisabledImage(CommonUIPlugin.getImage("icons/action/table_record_delete_disabled.png"));
delHistory.setToolTipText(Messages.tooltip_qedit_sql_history_delete);
delHistory.setText(Messages.btn_qedit_sql_history_delete);
delHistory.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
if (sqlHistoryTable.getTable().getSelectionIndices().length == 0) {
MessageDialog.openError(PlatformUI.getWorkbench().getDisplay().getActiveShell(), Messages.error, Messages.sql_history_delete_error);
return;
}
MessageBox messageBox = new MessageBox(getShell(), SWT.ICON_QUESTION | SWT.YES | SWT.NO);
messageBox.setText(Messages.tooltip_qedit_sql_history_delete);
messageBox.setMessage(Messages.sql_history_delete_message);
// remove data ,both view and model
int buttonID = messageBox.open();
if (buttonID == SWT.YES) {
deleteHistory();
}
}
});
// help messages
Label helpMsg = new Label(toolBarComposite, SWT.None);
helpMsg.setText(Messages.recentlyUsedSQLHelp);
helpMsg.setLayoutData(new GridData(SWT.TRAIL, SWT.CENTER, true, false));
// create the query result tab folder
recentlyUsedSQLTabFolder = new CTabFolder(this, SWT.BOTTOM);
recentlyUsedSQLTabFolder.setSimple(false);
recentlyUsedSQLTabFolder.setUnselectedImageVisible(true);
recentlyUsedSQLTabFolder.setUnselectedCloseVisible(true);
recentlyUsedSQLTabFolder.setSelectionBackground(CombinedQueryEditorComposite.BACK_COLOR);
recentlyUsedSQLTabFolder.setSelectionForeground(ResourceManager.getColor(SWT.COLOR_BLACK));
recentlyUsedSQLTabFolder.setLayout(new GridLayout(1, true));
recentlyUsedSQLTabFolder.setLayoutData(new GridData(GridData.FILL_BOTH));
//TabContextMenuManager tabContextMenuManager = new TabContextMenuManager(recentlyUsedSQLTabFolder);
//tabContextMenuManager.createContextMenu();
recentlyUsedSQLTabItem = new CTabItem(resultTabFolder, SWT.NONE);
recentlyUsedSQLTabItem.setText(Messages.qedit_sql_history_folder);
recentlyUsedSQLTabItem.setControl(this);
recentlyUsedSQLTabItem.setShowClose(false);
final SashForm bottomSash = new SashForm(recentlyUsedSQLTabFolder, SWT.VERTICAL);
bottomSash.SASH_WIDTH = SASH_WIDTH;
bottomSash.setBackground(CombinedQueryEditorComposite.BACK_COLOR);
createHistoryTable(bottomSash);
SashForm tailSash = new SashForm(bottomSash, SWT.HORIZONTAL);
tailSash.SASH_WIDTH = SASH_WIDTH;
tailSash.setBackground(CombinedQueryEditorComposite.BACK_COLOR);
logMessageArea = new StyledText(tailSash, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.READ_ONLY);
CommonUITool.registerCopyPasteContextMenu(logMessageArea, false);
bottomSash.setWeights(new int[] { 80, 20 });
logMessageArea.setToolTipText(Messages.tooltipHowToExpandLogPane);
logMessageArea.addFocusListener(new FocusListener() {
public void focusLost(FocusEvent e) {
bottomSash.setWeights(new int[] { 80, 20 });
}
public void focusGained(FocusEvent e) {
bottomSash.setWeights(new int[] { 20, 80 });
}
});
CTabItem tabItem = new CTabItem(recentlyUsedSQLTabFolder, SWT.NONE);
tabItem.setText(Messages.qedit_sql_history);
tabItem.setControl(bottomSash);
tabItem.setShowClose(false);
recentlyUsedSQLTabFolder.setSelection(tabItem);
}
Aggregations