Search in sources :

Example 36 with ToolItem

use of org.eclipse.swt.widgets.ToolItem in project cubrid-manager by CUBRID.

the class ColumnViewerSorter method createPartControl.

public void createPartControl(Composite parent) {
    parent.setLayout(new GridLayout(1, false));
    ToolBar toolBar = new ToolBar(parent, SWT.LEFT_TO_RIGHT | SWT.FLAT);
    toolBar.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    ToolItem refreshItem = new ToolItem(toolBar, SWT.PUSH);
    refreshItem.setText(Messages.tablesDetailInfoPartRefreshBtn);
    refreshItem.setToolTipText(Messages.tablesDetailInfoPartBtnRefreshTip);
    refreshItem.setImage(CommonUIPlugin.getImage("icons/action/refresh.png"));
    refreshItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            refresh();
        }
    });
    new ToolItem(toolBar, SWT.SEPARATOR);
    ToolItem countItem = new ToolItem(toolBar, SWT.PUSH);
    countItem.setText(Messages.tablesDetailInfoPartBtnEsitmateRecord);
    countItem.setToolTipText(Messages.tablesDetailInfoPartBtnEsitmateRecordTip);
    countItem.setImage(CommonUIPlugin.getImage("icons/action/count.gif"));
    countItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            List<TableDetailInfo> list = new ArrayList<TableDetailInfo>();
            TableItem[] items = tableListView.getTable().getSelection();
            for (TableItem item : items) {
                list.add((TableDetailInfo) item.getData());
            }
            // Check selected size and confirm
            if (list.size() == 0) {
                CommonUITool.openWarningBox(Messages.tablesDetailInfoPartAlertNotSelected);
                return;
            }
            if (CommonUITool.openConfirmBox(Messages.tablesDetailInfoPartBtnEsitmateRecordAlert)) {
                LoadTableRecordCountsProgress progress = new LoadTableRecordCountsProgress(database, list);
                progress.getTableCounts();
                tableListView.refresh();
            }
        }
    });
    new ToolItem(toolBar, SWT.SEPARATOR);
    ToolItem viewDataItem = new ToolItem(toolBar, SWT.PUSH);
    viewDataItem.setText(Messages.tablesDetailInfoPartBtnViewData);
    viewDataItem.setToolTipText(Messages.tablesDetailInfoPartBtnViewDataTip);
    viewDataItem.setImage(CommonUIPlugin.getImage("icons/action/table_select_all.png"));
    viewDataItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            TableItem[] items = tableListView.getTable().getSelection();
            if (items.length == 1) {
                TableDetailInfo tableDetailInfo = (TableDetailInfo) items[0].getData();
                String query = SQLGenerateUtils.getSelectSQLWithLimit(tableDetailInfo.getTableName(), 1, 100);
                QueryEditorUtil.openQueryEditorAndRunQuery(database, query, true, true);
            } else {
                CommonUITool.openInformationBox(Messages.tablesDetailInfoPartBtnViewDataSelectOne);
            }
        }
    });
    new ToolItem(toolBar, SWT.SEPARATOR);
    ToolItem copyTableNamesItem = new ToolItem(toolBar, SWT.PUSH);
    copyTableNamesItem.setText(Messages.tablesDetailInfoPartBtnCopyTableNames);
    copyTableNamesItem.setToolTipText(Messages.tablesDetailInfoPartBtnCopyTableNamesTip);
    copyTableNamesItem.setImage(CommonUIPlugin.getImage("icons/action/copy_table_name.gif"));
    copyTableNamesItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            List<String> nameList = new ArrayList<String>();
            for (TableDetailInfo tablesDetailInfoPOJO : tableList) {
                nameList.add(tablesDetailInfoPOJO.getTableName());
            }
            if (nameList.size() == 0) {
                CommonUITool.openWarningBox(Messages.tablesDetailInfoPartBtnCopySuccessFailed);
                return;
            }
            copyNamesToClipboard(nameList);
            CommonUITool.openInformationBox(Messages.tablesDetailInfoPartBtnCopySuccessTitle, Messages.tablesDetailInfoPartBtnCopySuccessMsg);
        }
    });
    new ToolItem(toolBar, SWT.SEPARATOR);
    ToolItem copyColumnNamesItem = new ToolItem(toolBar, SWT.PUSH);
    copyColumnNamesItem.setText(Messages.tablesDetailInfoPartBtnCopyColumnNames);
    copyColumnNamesItem.setToolTipText(Messages.tablesDetailInfoPartBtnCopyColumnNamesTip);
    copyColumnNamesItem.setImage(CommonUIPlugin.getImage("icons/action/copy_column_name.gif"));
    copyColumnNamesItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            TablesDetailInfoCTabItem tabItem = (TablesDetailInfoCTabItem) tabFolder.getSelection();
            schemaInfo = tabItem.getTableInfoComposite().getData();
            if (schemaInfo == null) {
                CommonUITool.openWarningBox(Messages.tablesDetailInfoPartBtnCopySuccessFailed);
                return;
            }
            List<String> nameList = new ArrayList<String>();
            for (DBAttribute att : schemaInfo.getAttributes()) {
                nameList.add(att.getName());
            }
            copyNamesToClipboard(nameList);
            CommonUITool.openInformationBox(Messages.tablesDetailInfoPartBtnCopySuccessTitle, Messages.tablesDetailInfoPartBtnCopySuccessMsg);
        }
    });
    new ToolItem(toolBar, SWT.SEPARATOR);
    final NewTableAction newTableAction = (NewTableAction) ActionManager.getInstance().getAction(NewTableAction.ID);
    ToolItem newTableItem = new ToolItem(toolBar, SWT.PUSH);
    newTableItem.setText(newTableAction.getText());
    newTableItem.setImage(CommonUITool.getImage(newTableAction.getImageDescriptor()));
    newTableItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            newTableAction.run(database);
        }
    });
    ScrolledComposite scrolledComp = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL);
    scrolledComp.setLayout(new FillLayout());
    scrolledComp.setExpandHorizontal(true);
    scrolledComp.setExpandVertical(true);
    scrolledComp.setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
    topSash = new SashForm(scrolledComp, SWT.VERTICAL);
    topSash.setBackground(ResourceManager.getColor(136, 161, 227));
    GridLayout gridLayout = new GridLayout();
    gridLayout.verticalSpacing = 0;
    gridLayout.marginWidth = 0;
    gridLayout.marginHeight = 0;
    gridLayout.horizontalSpacing = 0;
    topSash.setLayout(gridLayout);
    topSash.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    topSash.SASH_WIDTH = 1;
    scrolledComp.setContent(topSash);
    createTablesDetailInfoTable(topSash);
    createTabFolder(topSash);
    topSash.setWeights(new int[] { 70, 30 });
    this.setInputs();
}
Also used : TablesDetailInfoCTabItem(com.cubrid.common.ui.cubrid.table.dashboard.control.TableDashboardComposite.TablesDetailInfoCTabItem) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) TableItem(org.eclipse.swt.widgets.TableItem) TableDetailInfo(com.cubrid.common.core.common.model.TableDetailInfo) FillLayout(org.eclipse.swt.layout.FillLayout) SashForm(org.eclipse.swt.custom.SashForm) GridLayout(org.eclipse.swt.layout.GridLayout) DBAttribute(com.cubrid.common.core.common.model.DBAttribute) NewTableAction(com.cubrid.common.ui.cubrid.table.action.NewTableAction) ToolBar(org.eclipse.swt.widgets.ToolBar) SelectionEvent(org.eclipse.swt.events.SelectionEvent) GridData(org.eclipse.swt.layout.GridData) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) ArrayList(java.util.ArrayList) List(java.util.List) LoadTableRecordCountsProgress(com.cubrid.common.ui.spi.progress.LoadTableRecordCountsProgress) ToolItem(org.eclipse.swt.widgets.ToolItem)

Example 37 with ToolItem

use of org.eclipse.swt.widgets.ToolItem in project cubrid-manager by CUBRID.

the class QueryPlanCompositeWithHistory method createPlanToolbar.

private void createPlanToolbar() {
    Composite toolBarComposite = new Composite(this, SWT.NONE);
    GridLayout gridLayout = new GridLayout(2, false);
    gridLayout.verticalSpacing = 0;
    gridLayout.horizontalSpacing = 10;
    gridLayout.marginWidth = 0;
    gridLayout.marginHeight = 0;
    toolBarComposite.setLayout(gridLayout);
    toolBarComposite.setLayoutData(new GridData(SWT.FILL, SWT.NONE, false, false));
    ToolBar toolBar = new ToolBar(toolBarComposite, SWT.FLAT | SWT.RIGHT);
    dispModeTextItem = new ToolItem(toolBar, SWT.CHECK);
    dispModeTextItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/qe_explain_mode_raw.png"));
    dispModeTextItem.setToolTipText(Messages.tooltip_qedit_explain_display_mode + "(F11)");
    dispModeTextItem.setText(Messages.lblPlanRawBtn);
    dispModeTextItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            showSelectedPlan(PLAN_DISPLAY_MODE.TEXT.getInt());
        }
    });
    new ToolItem(toolBar, SWT.SEPARATOR);
    dispModeTreeItem = new ToolItem(toolBar, SWT.CHECK);
    dispModeTreeItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/qe_explain_mode_tree.png"));
    dispModeTreeItem.setToolTipText(Messages.tooltip_qedit_explain_display_mode + "(F11)");
    dispModeTreeItem.setText(Messages.lblPlanTreeBtn);
    dispModeTreeItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            showSelectedPlan(PLAN_DISPLAY_MODE.TREE.getInt());
        }
    });
    new ToolItem(toolBar, SWT.SEPARATOR);
    dispModeGraphItem = new ToolItem(toolBar, SWT.CHECK);
    dispModeGraphItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/qe_explain_mode_graph.png"));
    dispModeGraphItem.setToolTipText(Messages.tooltip_qedit_explain_display_mode + "(F11)");
    dispModeGraphItem.setText(Messages.lblPlanGraph);
    dispModeGraphItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            showSelectedPlan(PLAN_DISPLAY_MODE.GRAPH.getInt());
        }
    });
    new ToolItem(toolBar, SWT.SEPARATOR);
    editTableItem = new ToolItem(toolBar, SWT.None);
    editTableItem.setImage(CommonUIPlugin.getImage("icons/navigator/schema_table_item.png"));
    editTableItem.setText(Messages.lblPlanEditTable);
    editTableItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            QueryPlanComposite comp = getSelectedQueryPlanComposite();
            String tableName = comp.getSelectedTable();
            if (StringUtil.isEmpty(tableName)) {
                CommonUITool.openErrorBox(Messages.msgPlanEditTable);
                return;
            }
            ISchemaNode node = new DefaultSchemaNode(tableName, tableName, null);
            node.setDatabase(editor.getSelectedDatabase());
            EditTableAction action = (EditTableAction) ActionManager.getInstance().getAction(EditTableAction.ID);
            if (action == null) {
                CommonUITool.openErrorBox(Messages.errPlanEditNoAction);
                return;
            }
            action.run((ISchemaNode) node);
        }
    });
    editIndexItem = new ToolItem(toolBar, SWT.None);
    editIndexItem.setImage(CommonUIPlugin.getImage("icons/navigator/table_index_item.png"));
    editIndexItem.setText(Messages.lblPlanEditIndex);
    editIndexItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            QueryPlanComposite comp = getSelectedQueryPlanComposite();
            String tableName = comp.getSelectedTable();
            //				String indexName = comp.getSelectedIndex();
            if (StringUtil.isEmpty(tableName)) {
                CommonUITool.openErrorBox(Messages.msgPlanEditIndex);
                return;
            }
            ISchemaNode node = new DefaultSchemaNode(tableName, tableName, null);
            node.setDatabase(editor.getSelectedDatabase());
            EditTableAction action = (EditTableAction) ActionManager.getInstance().getAction(EditTableAction.ID);
            if (action == null) {
                CommonUITool.openErrorBox(Messages.errPlanEditNoAction);
                return;
            }
            action.editIndexMode((ISchemaNode) node);
        }
    });
    ToolItem comparePlanItem = new ToolItem(toolBar, SWT.None);
    comparePlanItem.setImage(CommonUIPlugin.getImage("icons/queryplan/use_compare_queryplan.png"));
    comparePlanItem.setText(Messages.lblComparePlan);
    comparePlanItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            QueryPlanComposite comp = getSelectedQueryPlanComposite();
            StructQueryPlan sq = comp.getQueryPlan();
            TuneModeModel tuneModeModel = new TuneModeModel(sq, null);
            editor.displayTuneModeResult(tuneModeModel);
        }
    });
    ToolBar delHistoryToolBar = new ToolBar(toolBarComposite, SWT.FLAT);
    delHistoryToolBar.setLayoutData(new GridData(SWT.END, SWT.CENTER, true, true));
    // Show/hide of the history pane
    historyShowHideItem = new ToolItem(delHistoryToolBar, SWT.PUSH);
    historyShowHideItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/qe_explain_history_hide.png"));
    historyShowHideItem.setToolTipText(Messages.tooltip_qedit_explain_history_show_hide);
    historyShowHideItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            boolean isShow = !planHistoryTable.getVisible();
            if (isShow) {
                showHistoryPane();
            } else {
                hideHistoryPane();
            }
        }
    });
    new ToolItem(delHistoryToolBar, SWT.SEPARATOR);
    // Collecting histories switch
    historySwitchItem = new ToolItem(delHistoryToolBar, SWT.CHECK);
    historySwitchItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/qe_explain_history_switch.png"));
    historySwitchItem.setToolTipText(Messages.tooltip_qedit_explain_history_switch);
    historySwitchItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            collectToHistoryFlag = !historySwitchItem.getSelection();
        }
    });
    historySwitchItem.setSelection(true);
    new ToolItem(delHistoryToolBar, SWT.SEPARATOR);
    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_explain_history_delete);
    delHistory.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            if (planHistoryTable.getSelectionIndices().length == 0) {
                MessageDialog.openError(PlatformUI.getWorkbench().getDisplay().getActiveShell(), Messages.error, Messages.explain_history_delete_error);
                return;
            }
            deleteHistory();
        }
    });
}
Also used : Composite(org.eclipse.swt.widgets.Composite) QueryPlanComposite(com.cubrid.common.ui.query.control.queryplan.QueryPlanComposite) ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) EditTableAction(com.cubrid.common.ui.cubrid.table.action.EditTableAction) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) QueryPlanComposite(com.cubrid.common.ui.query.control.queryplan.QueryPlanComposite) DefaultSchemaNode(com.cubrid.common.ui.spi.model.DefaultSchemaNode) TuneModeModel(com.cubrid.common.ui.query.control.tunemode.TuneModeModel) GridLayout(org.eclipse.swt.layout.GridLayout) GridData(org.eclipse.swt.layout.GridData) ToolBar(org.eclipse.swt.widgets.ToolBar) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ToolItem(org.eclipse.swt.widgets.ToolItem) StructQueryPlan(com.cubrid.common.core.queryplan.StructQueryPlan)

Example 38 with ToolItem

use of org.eclipse.swt.widgets.ToolItem 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);
}
Also used : CTabFolder(org.eclipse.swt.custom.CTabFolder) StyledText(org.eclipse.swt.custom.StyledText) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) CTabItem(org.eclipse.swt.custom.CTabItem) FocusEvent(org.eclipse.swt.events.FocusEvent) MessageBox(org.eclipse.swt.widgets.MessageBox) SashForm(org.eclipse.swt.custom.SashForm) GridLayout(org.eclipse.swt.layout.GridLayout) GridData(org.eclipse.swt.layout.GridData) ToolBar(org.eclipse.swt.widgets.ToolBar) SelectionEvent(org.eclipse.swt.events.SelectionEvent) FocusListener(org.eclipse.swt.events.FocusListener) ToolItem(org.eclipse.swt.widgets.ToolItem)

Example 39 with ToolItem

use of org.eclipse.swt.widgets.ToolItem in project cubrid-manager by CUBRID.

the class QueryRecordListComparator method displayQueryPlan.

/**
	 * Display query record for tuner tab
	 *
	 * @param queryRecord
	 */
private void displayQueryPlan(final QueryRecord queryRecord) {
    if (queryPlanComposite != null && !queryPlanComposite.isDisposed()) {
        queryPlanComposite.dispose();
    }
    queryPlanComposite = new Composite(queryPlanContainer, SWT.BORDER);
    queryPlanComposite.setLayout(new GridLayout());
    ToolBar queryPlanToolBar = new ToolBar(queryPlanComposite, SWT.None);
    queryPlanToolBar.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    hideItem = new ToolItem(queryPlanToolBar, SWT.CHECK);
    hideItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/qe_panel_down.png"));
    hideItem.setToolTipText(Messages.tooltip_qedit_explain_display_mode);
    dispModeTextItem = new ToolItem(queryPlanToolBar, SWT.CHECK);
    dispModeTextItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/qe_explain_mode_raw.png"));
    dispModeTextItem.setToolTipText(Messages.tooltip_qedit_explain_display_mode);
    dispModeTreeItem = new ToolItem(queryPlanToolBar, SWT.CHECK);
    dispModeTreeItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/qe_explain_mode_tree.png"));
    dispModeTreeItem.setToolTipText(Messages.tooltip_qedit_explain_display_mode);
    dispModeGraphItem = new ToolItem(queryPlanToolBar, SWT.CHECK);
    dispModeGraphItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/qe_explain_mode_graph.png"));
    dispModeGraphItem.setToolTipText(Messages.tooltip_qedit_explain_display_mode);
    TableViewer statisticsViewer = new TableViewer(queryPlanComposite, SWT.FULL_SELECTION);
    statisticsViewer.getTable().setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, 50));
    statisticsViewer.getTable().setHeaderVisible(true);
    statisticsViewer.getTable().setLinesVisible(false);
    TableColumn itemColumn = new TableColumn(statisticsViewer.getTable(), SWT.None);
    itemColumn.setText(Messages.columnItem);
    itemColumn.setWidth(60);
    TableColumn fetchColumn = new TableColumn(statisticsViewer.getTable(), SWT.None);
    fetchColumn.setText(Messages.columnFetches);
    fetchColumn.setWidth(60);
    TableColumn dirtyColumn = new TableColumn(statisticsViewer.getTable(), SWT.None);
    dirtyColumn.setText(Messages.columnDirties);
    dirtyColumn.setWidth(60);
    TableColumn ioReadColumn = new TableColumn(statisticsViewer.getTable(), SWT.None);
    ioReadColumn.setText(Messages.columnIORead);
    ioReadColumn.setWidth(80);
    TableColumn ioWriteColumn = new TableColumn(statisticsViewer.getTable(), SWT.None);
    ioWriteColumn.setText(Messages.columnIOWrite);
    ioWriteColumn.setWidth(80);
    TableColumn costColumn = new TableColumn(statisticsViewer.getTable(), SWT.None);
    costColumn.setText(Messages.columnCost);
    costColumn.setWidth(60);
    statisticsViewer.setContentProvider(new QueryPlanContentProvider());
    statisticsViewer.setLabelProvider(new QueryPlanLabelPrivoder(statisticsViewer, true));
    List<QueryRecord> recordList = new ArrayList<QueryRecord>();
    if (queryRecord != null) {
        recordList.add(queryRecord);
    }
    if (lastRecord != null) {
        recordList.add(lastRecord);
    }
    statisticsViewer.setInput(recordList);
    final SashForm queryPlanSashForm = new SashForm(queryPlanComposite, SWT.VERTICAL);
    queryPlanSashForm.setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
    queryPlanSashForm.setBackground(SASH_COLOR);
    queryPlanSashForm.setLayout(new GridLayout());
    queryPlanSashForm.SASH_WIDTH = 2;
    DatabaseInfo databaseInfo = database == null ? null : database.getDatabaseInfo();
    final QueryPlanComposite nowPlanComposite = new QueryPlanComposite(queryPlanSashForm, SWT.None, queryRecord == null ? null : queryRecord.getQueryPlan(), databaseInfo);
    final QueryPlanComposite beforePlanComposite = new QueryPlanComposite(queryPlanSashForm, SWT.None, lastRecord == null ? null : lastRecord.getQueryPlan(), databaseInfo);
    queryPlanSashForm.setWeights(new int[] { 500, 500 });
    hideItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            isHiden = !isHiden;
            performHideOperation(queryPlanSashForm, isHiden);
        }
    });
    dispModeTextItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            updateTunerPlanDisplayModel(nowPlanComposite, beforePlanComposite, DISPLAY_TEXT);
        }
    });
    dispModeTreeItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            updateTunerPlanDisplayModel(nowPlanComposite, beforePlanComposite, DISPLAY_TREE);
        }
    });
    dispModeGraphItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            updateTunerPlanDisplayModel(nowPlanComposite, beforePlanComposite, DISPLAY_GRAPH);
        }
    });
    performHideOperation(queryPlanSashForm, isHiden);
    updateTunerPlanDisplayModel(nowPlanComposite, beforePlanComposite, tunerDisplayModel);
    queryPlanContainer.layout();
}
Also used : Composite(org.eclipse.swt.widgets.Composite) QueryPlanComposite(com.cubrid.common.ui.query.control.queryplan.QueryPlanComposite) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ArrayList(java.util.ArrayList) QueryPlanComposite(com.cubrid.common.ui.query.control.queryplan.QueryPlanComposite) QueryRecord(com.cubrid.common.ui.query.tuner.QueryRecord) TableColumn(org.eclipse.swt.widgets.TableColumn) SashForm(org.eclipse.swt.custom.SashForm) GridLayout(org.eclipse.swt.layout.GridLayout) ToolBar(org.eclipse.swt.widgets.ToolBar) SelectionEvent(org.eclipse.swt.events.SelectionEvent) TableViewer(org.eclipse.jface.viewers.TableViewer) ToolItem(org.eclipse.swt.widgets.ToolItem)

Example 40 with ToolItem

use of org.eclipse.swt.widgets.ToolItem in project cubrid-manager by CUBRID.

the class QueryRecordListComparator method createQueryTunerTab.

private void createQueryTunerTab(CTabFolder tabFolder) {
    CTabItem item = new CTabItem(tabFolder, SWT.None | SWT.MULTI | SWT.V_SCROLL);
    item.setText(Messages.tabItemQueryTuner);
    tabFolder.setSelection(item);
    SashForm form = new SashForm(tabFolder, SWT.HORIZONTAL);
    item.setControl(form);
    form.setLayout(new FillLayout());
    /*Left composite*/
    Composite leftComposite = new Composite(form, SWT.BORDER);
    leftComposite.setLayout(new GridLayout());
    /*Right composite*/
    queryPlanContainer = new Composite(form, SWT.BORDER);
    queryPlanContainer.setLayout(new FillLayout());
    form.setWeights(new int[] { 40, 60 });
    ToolBar toolBar = new ToolBar(leftComposite, SWT.None);
    runItem = new ToolItem(toolBar, SWT.None);
    runItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/query_run.png"));
    runItem.setDisabledImage(CommonUIPlugin.getImage("icons/queryeditor/query_run_disabled.png"));
    runItem.setToolTipText(Messages.run);
    runItem.setEnabled(false);
    runItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            runQuery();
        }
    });
    runPlanItem = new ToolItem(toolBar, SWT.None);
    runPlanItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/query_execution_plan.png"));
    runPlanItem.setToolTipText(Messages.queryPlanTip);
    runPlanItem.setEnabled(false);
    runPlanItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            runQueryPlan();
        }
    });
    saveQueryItem = new ToolItem(toolBar, SWT.None);
    saveQueryItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/file_save.png"));
    saveQueryItem.setToolTipText(Messages.ttSaveQueryTuning);
    saveQueryItem.setEnabled(false);
    saveQueryItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            saveQueryRecord();
        }
    });
    SashForm sashForm = new SashForm(leftComposite, SWT.VERTICAL);
    sashForm.setBackground(SASH_COLOR);
    sashForm.setLayout(new FillLayout());
    sashForm.setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
    CompositeRuler ruler = new CompositeRuler();
    LineNumberRulerColumn lineCol = new LineNumberRulerColumn();
    lineCol.setBackground(ResourceManager.getColor(new RGB(236, 233, 216)));
    ruler.addDecorator(0, lineCol);
    sqlTextViewer = new SQLTextViewer(sashForm, ruler, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER, this);
    viewerConfig = new SQLViewerConfiguration(this);
    sqlTextViewer.configure(viewerConfig);
    SQLDocument document = new SQLDocument();
    IDocumentPartitioner partitioner = new FastPartitioner(new SQLPartitionScanner(), SQLPartitionScanner.getAllTypes());
    document.setDocumentPartitioner(ISQLPartitions.SQL_PARTITIONING, partitioner);
    partitioner.connect(document);
    sqlTextViewer.setDocument(document);
    undoManager = new TextViewerUndoManager(50);
    undoManager.connect(sqlTextViewer);
    contentAssistant = viewerConfig.getContentAssistant(sqlTextViewer);
    contentAssistant.install(sqlTextViewer);
    recentlyUsedSQLcontentAssistant = viewerConfig.getRecentlyUsedContentAssistant(sqlTextViewer);
    recentlyUsedSQLcontentAssistant.install(sqlTextViewer);
    formatHandler = new TextViewerOperationHandler(sqlTextViewer, ISourceViewer.FORMAT);
    contentAssistHandler = new TextViewerOperationHandler(sqlTextViewer, ISourceViewer.CONTENTASSIST_PROPOSALS);
    StyledText text = (StyledText) sqlTextViewer.getTextWidget();
    text.setIndent(1);
    text.setData(SQL_EDITOR_FLAG, sqlTextViewer);
    addTextViewerListener(text);
    queryResultContainer = new Composite(sashForm, SWT.None);
    queryResultContainer.setLayout(new FillLayout());
    displayQuery(null);
    displayQueryPlan(null);
}
Also used : LineNumberRulerColumn(org.eclipse.jface.text.source.LineNumberRulerColumn) SQLDocument(com.cubrid.common.ui.query.editor.SQLDocument) StyledText(org.eclipse.swt.custom.StyledText) Composite(org.eclipse.swt.widgets.Composite) QueryPlanComposite(com.cubrid.common.ui.query.control.queryplan.QueryPlanComposite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) CompositeRuler(org.eclipse.jface.text.source.CompositeRuler) FillLayout(org.eclipse.swt.layout.FillLayout) SQLTextViewer(com.cubrid.common.ui.query.editor.SQLTextViewer) RGB(org.eclipse.swt.graphics.RGB) CTabItem(org.eclipse.swt.custom.CTabItem) SQLViewerConfiguration(com.cubrid.common.ui.query.editor.SQLViewerConfiguration) SashForm(org.eclipse.swt.custom.SashForm) TextViewerUndoManager(org.eclipse.jface.text.TextViewerUndoManager) GridLayout(org.eclipse.swt.layout.GridLayout) IDocumentPartitioner(org.eclipse.jface.text.IDocumentPartitioner) FastPartitioner(org.eclipse.jface.text.rules.FastPartitioner) ToolBar(org.eclipse.swt.widgets.ToolBar) SelectionEvent(org.eclipse.swt.events.SelectionEvent) TextViewerOperationHandler(com.cubrid.common.ui.query.control.TextViewerOperationHandler) SQLPartitionScanner(com.cubrid.common.ui.query.editor.SQLPartitionScanner) ToolItem(org.eclipse.swt.widgets.ToolItem)

Aggregations

ToolItem (org.eclipse.swt.widgets.ToolItem)140 ToolBar (org.eclipse.swt.widgets.ToolBar)110 SelectionEvent (org.eclipse.swt.events.SelectionEvent)91 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)81 GridData (org.eclipse.swt.layout.GridData)73 Composite (org.eclipse.swt.widgets.Composite)64 GridLayout (org.eclipse.swt.layout.GridLayout)58 Image (org.eclipse.swt.graphics.Image)36 Label (org.eclipse.swt.widgets.Label)32 Point (org.eclipse.swt.graphics.Point)26 DisposeEvent (org.eclipse.swt.events.DisposeEvent)25 DisposeListener (org.eclipse.swt.events.DisposeListener)24 Cursor (org.eclipse.swt.graphics.Cursor)20 FillLayout (org.eclipse.swt.layout.FillLayout)18 SelectionListener (org.eclipse.swt.events.SelectionListener)17 TableViewer (org.eclipse.jface.viewers.TableViewer)16 Text (org.eclipse.swt.widgets.Text)16 Display (org.eclipse.swt.widgets.Display)15 ArrayList (java.util.ArrayList)14 List (java.util.List)14