Search in sources :

Example 91 with TableViewer

use of org.eclipse.jface.viewers.TableViewer in project cubrid-manager by CUBRID.

the class TableContentProvider method createPartControl.

/**
	 * Create part controls
	 * 
	 * @param parent of the controls
	 * 
	 */
public void createPartControl(Composite parent) {
    Composite backPanel = new Composite(parent, SWT.NONE);
    backPanel.setLayout(new GridLayout(1, false));
    backPanel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    Composite progressPanel = new Composite(backPanel, SWT.NONE);
    progressPanel.setLayout(new GridLayout(3, false));
    progressPanel.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
    progressIndicator = new ProgressIndicator(progressPanel, SWT.NONE);
    progressIndicator.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true));
    btnStop = new Button(progressPanel, SWT.NONE);
    btnStop.setText(Messages.btnStop);
    btnStop.setImage(CommonUIPlugin.getImage("icons/queryeditor/query_run_stop.png"));
    btnStop.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            processStop();
        }
    });
    openLogFolderButton = new Button(progressPanel, SWT.NONE);
    openLogFolderButton.setText(Messages.runSQLOpenBtn);
    openLogFolderButton.setEnabled(false);
    openLogFolderButton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            try {
                java.awt.Desktop.getDesktop().open(new File(importConfig.getErrorLogFolderPath()));
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    });
    progressTableViewer = new TableViewer(backPanel, SWT.BORDER | SWT.FULL_SELECTION);
    progressTableViewer.getTable().setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true));
    progressTableViewer.getTable().setLinesVisible(true);
    progressTableViewer.getTable().setHeaderVisible(true);
    final TableViewerColumn tableName = new TableViewerColumn(progressTableViewer, SWT.NONE);
    final TableViewerColumn totalCount = new TableViewerColumn(progressTableViewer, SWT.NONE);
    final TableViewerColumn parseCount = new TableViewerColumn(progressTableViewer, SWT.NONE);
    final TableViewerColumn failedCount = new TableViewerColumn(progressTableViewer, SWT.NONE);
    final TableViewerColumn status = new TableViewerColumn(progressTableViewer, SWT.NONE);
    final TableViewerColumn elapsedTime = new TableViewerColumn(progressTableViewer, SWT.NONE);
    final TableViewerColumn buttonColumn = new TableViewerColumn(progressTableViewer, SWT.NONE);
    tableName.getColumn().setWidth(250);
    tableName.getColumn().setText(Messages.columnName);
    totalCount.getColumn().setWidth(100);
    totalCount.getColumn().setText(Messages.columnCount);
    parseCount.getColumn().setWidth(100);
    parseCount.getColumn().setText(Messages.columnFinished);
    failedCount.getColumn().setWidth(100);
    failedCount.getColumn().setText(Messages.columnFailed);
    status.getColumn().setWidth(100);
    status.getColumn().setText(Messages.columnStatus);
    elapsedTime.getColumn().setWidth(130);
    elapsedTime.getColumn().setText(Messages.columnTime);
    buttonColumn.getColumn().setWidth(90);
    progressTableViewer.setContentProvider(new TableContentProvider());
    progressTableViewer.setLabelProvider(new TableLabelProvider());
    progressTableViewer.addDoubleClickListener(new IDoubleClickListener() {

        public void doubleClick(DoubleClickEvent event) {
            IStructuredSelection selection = (IStructuredSelection) event.getSelection();
            ImportMonitor monitor = (ImportMonitor) selection.getFirstElement();
            openViewDialog(monitor);
        }
    });
    Composite historyComposite = new Composite(backPanel, SWT.NONE);
    historyComposite.setLayout(new GridLayout(4, false));
    historyComposite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false));
    historyLabel = new Label(historyComposite, SWT.NONE);
    historyLabel.setText(Messages.lblHistory);
    historyText = new Text(historyComposite, SWT.BORDER);
    historyText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    saveButton = new Button(historyComposite, SWT.NONE);
    saveButton.setText(Messages.btnSaveAndClose);
    saveButton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            if (historyText.getText().trim().length() == 0) {
                CommonUITool.openErrorBox(Messages.errHistoryEmpty);
                return;
            }
            if (ImportConfigManager.getInstance().getConfig(historyText.getText()) != null) {
                CommonUITool.openErrorBox(Messages.errHistoryExist);
                return;
            }
            importConfig.setName(historyText.getText().trim());
            ImportConfigManager.getInstance().addConfig(importConfig);
            close();
        }
    });
    closeButton = new Button(historyComposite, SWT.NONE);
    closeButton.setText(Messages.btnClose);
    closeButton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            close();
        }
    });
    setHistroyWidgetStatus(false);
    init();
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ImportMonitor(com.cubrid.common.ui.cubrid.table.dialog.imp.model.ImportMonitor) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) Text(org.eclipse.swt.widgets.Text) IOException(java.io.IOException) ITableLabelProvider(org.eclipse.jface.viewers.ITableLabelProvider) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) ProgressIndicator(org.eclipse.jface.dialogs.ProgressIndicator) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) File(java.io.File) TableViewer(org.eclipse.jface.viewers.TableViewer) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn)

Example 92 with TableViewer

use of org.eclipse.jface.viewers.TableViewer in project cubrid-manager by CUBRID.

the class TableEditorPart method createPartitionTabItem.

private void createPartitionTabItem(final TabFolder tabFolder) {
    loadPartitionInfoList();
    final TabItem partTabItem = new TabItem(tabFolder, SWT.NONE);
    final Composite parentComp = new Composite(tabFolder, SWT.NONE);
    {
        GridLayout gd = new GridLayout();
        parentComp.setLayout(gd);
    }
    partTabItem.setControl(parentComp);
    partTabItem.setText(Messages.tabItemPartition);
    partitionTableView = new TableViewer(parentComp, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER);
    final Table partitionTable = partitionTableView.getTable();
    {
        partitionTable.setLayout(TableViewUtil.createTableViewLayout(new int[] { 20, 15, 10, 20, 25, 10 }));
        GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
        gd.heightHint = 350;
        partitionTable.setLayoutData(gd);
    }
    partitionTable.setHeaderVisible(true);
    partitionTable.setLinesVisible(true);
    CommonUITool.hackForYosemite(partitionTable);
    TableViewUtil.createTableColumn(partitionTable, SWT.CENTER, Messages.tblColTableName);
    TableViewUtil.createTableColumn(partitionTable, SWT.CENTER, Messages.tblColPartitionName);
    TableViewUtil.createTableColumn(partitionTable, SWT.CENTER, Messages.tblColType);
    TableViewUtil.createTableColumn(partitionTable, SWT.CENTER, Messages.tblColExpr);
    TableViewUtil.createTableColumn(partitionTable, SWT.CENTER, Messages.tblColExprValue);
    TableViewUtil.createTableColumn(partitionTable, SWT.CENTER, Messages.tblColRows);
    partitionTableView.setLabelProvider(new PartitionTableLabelProvider());
    partitionTableView.setContentProvider(new PartitionContentProvider());
    partitionTableView.setInput(partitionInfoList);
    partitionTableView.addDoubleClickListener(new IDoubleClickListener() {

        public void doubleClick(DoubleClickEvent event) {
            editPartition();
        }
    });
    tabFolder.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(final SelectionEvent event) {
            if (tabFolder.getSelection()[0].getText().equals(Messages.tabItemPartition)) {
                partitionTableView.refresh();
            }
        }
    });
    createPartitionTabButtons(parentComp);
}
Also used : PartitionContentProvider(com.cubrid.common.ui.cubrid.table.control.PartitionContentProvider) TabItem(org.eclipse.swt.widgets.TabItem) PartitionTableLabelProvider(com.cubrid.common.ui.cubrid.table.control.PartitionTableLabelProvider) GridLayout(org.eclipse.swt.layout.GridLayout) Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) TableViewer(org.eclipse.jface.viewers.TableViewer)

Example 93 with TableViewer

use of org.eclipse.jface.viewers.TableViewer in project cubrid-manager by CUBRID.

the class RecentlyUsedSQLComposite method createHistoryTable.

/**
	 * createHistoryTable
	 * @param bottomSash
	 */
public void createHistoryTable(SashForm bottomSash) {
    sqlHistoryTable = new TableViewer(bottomSash, SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.MULTI);
    sqlHistoryTable.getTable().setHeaderVisible(true);
    sqlHistoryTable.getTable().setLinesVisible(true);
    //		final TableViewerColumn columnNO = new TableViewerColumn(
    //				sqlHistoryTable, SWT.CENTER);
    //		columnNO.getColumn().setWidth(40);
    //		columnNO.getColumn().setText("NO");
    final TableViewerColumn columnRunTime = new TableViewerColumn(sqlHistoryTable, SWT.LEFT);
    columnRunTime.getColumn().setWidth(155);
    columnRunTime.getColumn().setText(Messages.recentlyUsedSQLColumnRunTime);
    columnRunTime.getColumn().addSelectionListener(new SelectionAdapter() {

        boolean asc = true;

        @Override
        public void widgetSelected(SelectionEvent e) {
            sqlHistoryTable.setSorter(asc ? Sorter.EXECUTETIME_ASC : Sorter.EXECUTETIME_DESC);
            sqlHistoryTable.getTable().setSortDirection(asc ? SWT.DOWN : SWT.UP);
            asc = !asc;
        }
    });
    final TableViewerColumn columnSQL = new TableViewerColumn(sqlHistoryTable, SWT.LEFT);
    columnSQL.getColumn().setWidth(250);
    columnSQL.getColumn().setText(Messages.recentlyUsedSQLColumn);
    columnSQL.getColumn().addSelectionListener(new SelectionAdapter() {

        boolean asc = true;

        @Override
        public void widgetSelected(SelectionEvent e) {
            sqlHistoryTable.setSorter(asc ? Sorter.SQL_ASC : Sorter.SQL_DEC);
            sqlHistoryTable.getTable().setSortDirection(asc ? SWT.DOWN : SWT.UP);
            asc = !asc;
        }
    });
    final TableViewerColumn columnElapseTime = new TableViewerColumn(sqlHistoryTable, SWT.LEFT);
    columnElapseTime.getColumn().setWidth(100);
    columnElapseTime.getColumn().setText(Messages.recentlyUsedSQLColumnElapseTime);
    columnElapseTime.getColumn().addSelectionListener(new SelectionAdapter() {

        boolean asc = true;

        @Override
        public void widgetSelected(SelectionEvent e) {
            sqlHistoryTable.setSorter(asc ? Sorter.ELAPSETIME_ASC : Sorter.ELAPSETIME_DESC);
            sqlHistoryTable.getTable().setSortDirection(asc ? SWT.DOWN : SWT.UP);
            asc = !asc;
        }
    });
    final TableViewerColumn columnInfo = new TableViewerColumn(sqlHistoryTable, SWT.LEFT);
    columnInfo.getColumn().setWidth(300);
    columnInfo.getColumn().setText(Messages.recentlyUsedSQLColumnLOG);
    columnInfo.getColumn().addSelectionListener(new SelectionAdapter() {

        boolean asc = true;

        @Override
        public void widgetSelected(SelectionEvent e) {
            sqlHistoryTable.setSorter(asc ? Sorter.LOG_ASC : Sorter.LOG_DESC);
            sqlHistoryTable.getTable().setSortDirection(asc ? SWT.DOWN : SWT.UP);
            asc = !asc;
        }
    });
    sqlHistoryTable.setContentProvider(new HistorySQLContentProvider());
    provider = new HistorySQLLabelProvider();
    sqlHistoryTable.setLabelProvider(provider);
    sqlHistoryTable.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(final SelectionChangedEvent event) {
            SQLHistoryDetail history = (SQLHistoryDetail) sqlHistoryTable.getElementAt(sqlHistoryTable.getTable().getSelectionIndex());
            if (history != null) {
                logMessageArea.setText(history.getExecuteInfo() + StringUtil.NEWLINE + history.getSql());
            }
        }
    });
    sqlHistoryTable.addDoubleClickListener(new IDoubleClickListener() {

        public void doubleClick(DoubleClickEvent event) {
            IStructuredSelection selection = (IStructuredSelection) event.getSelection();
            SQLHistoryDetail history = (SQLHistoryDetail) selection.getFirstElement();
            logMessageArea.setText(history.getExecuteInfo() + StringUtil.NEWLINE + StringUtil.NEWLINE + history.getSql());
            int start = editor.getAllQueries().length();
            editor.setQuery(StringUtil.NEWLINE + history.getSql(), true, false, false);
            int end = start + history.getSql().length();
            // "/n" take a postion ,so both start and end should + 1
            editor.setSelection(start + 1, end + 1);
        }
    });
}
Also used : SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) SelectionEvent(org.eclipse.swt.events.SelectionEvent) TableViewer(org.eclipse.jface.viewers.TableViewer) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn)

Example 94 with TableViewer

use of org.eclipse.jface.viewers.TableViewer 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 95 with TableViewer

use of org.eclipse.jface.viewers.TableViewer in project cubrid-manager by CUBRID.

the class QueryRecordListComparator method createQueryCompareTab.

private void createQueryCompareTab(CTabFolder tabFolder) {
    CTabItem item = new CTabItem(tabFolder, SWT.None | SWT.MULTI | SWT.V_SCROLL);
    item.setText(Messages.tabItemQueryCompare);
    Composite composite = new Composite(tabFolder, SWT.None);
    composite.setLayout(new GridLayout());
    item.setControl(composite);
    Composite topComposite = new Composite(composite, SWT.None);
    topComposite.setLayout(new FormLayout());
    topComposite.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, 25));
    Composite leftTopComposite = new Composite(topComposite, SWT.None);
    FormData leftTopData = new FormData();
    leftTopData.top = new FormAttachment(0, 0);
    leftTopData.bottom = new FormAttachment(100, 0);
    leftTopData.left = new FormAttachment(0, 0);
    leftTopData.right = new FormAttachment(50, 0);
    leftTopComposite.setLayoutData(leftTopData);
    leftTopComposite.setLayout(new GridLayout(2, false));
    Composite rightTopComposite = new Composite(topComposite, SWT.None);
    FormData rightTopData = new FormData();
    rightTopData.top = new FormAttachment(0, 0);
    rightTopData.bottom = new FormAttachment(100, 0);
    rightTopData.left = new FormAttachment(50, 0);
    rightTopData.right = new FormAttachment(100, 0);
    rightTopComposite.setLayoutData(rightTopData);
    rightTopComposite.setLayout(new GridLayout(5, false));
    Label leftLabel = new Label(leftTopComposite, SWT.None);
    leftLabel.setText(Messages.lblQuery);
    leftLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    queryRecordLeftCombo = new Combo(leftTopComposite, SWT.READ_ONLY);
    queryRecordLeftCombo.setLayoutData(CommonUITool.createGridData(1, 1, 200, -1));
    queryRecordLeftCombo.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            displayCompareQueryRecord();
        }

        public void widgetDefaultSelected(SelectionEvent e) {
        }
    });
    Label rightLabel = new Label(rightTopComposite, SWT.None);
    rightLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    rightLabel.setText(Messages.lblQuery);
    queryRecordRightCombo = new Combo(rightTopComposite, SWT.READ_ONLY);
    queryRecordRightCombo.setLayoutData(CommonUITool.createGridData(1, 1, 200, -1));
    queryRecordRightCombo.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            displayCompareQueryRecord();
        }

        public void widgetDefaultSelected(SelectionEvent e) {
        }
    });
    ToolBar leftToolBar = new ToolBar(rightTopComposite, SWT.None);
    leftToolBar.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    compareItem = new ToolItem(leftToolBar, SWT.None);
    compareItem.setImage(CommonUIPlugin.getImage("icons/action/refresh_tuning.png"));
    compareItem.setToolTipText(Messages.itemTooltipCompare);
    compareItem.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            widgetDefaultSelected(e);
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            displayCompareQueryRecord();
        }
    });
    delQueryRecordItem = new ToolItem(leftToolBar, SWT.None);
    delQueryRecordItem.setImage(CommonUIPlugin.getImage("icons/queryplan/delete_query.gif"));
    delQueryRecordItem.setToolTipText(Messages.itemTooltipRemoveQuery);
    delQueryRecordItem.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            widgetDefaultSelected(e);
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            if (CommonUITool.openConfirmBox(Messages.confirmDeleteQueryPlanOnTuner)) {
                removeQueryRecord();
            }
        }
    });
    Composite folderPlaceComposite = new Composite(rightTopComposite, SWT.None);
    folderPlaceComposite.setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
    ToolBar rightToolBar = new ToolBar(rightTopComposite, SWT.None);
    rightToolBar.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_END, 1, 1, -1, -1));
    multiRunItem = new ToolItem(rightToolBar, SWT.None);
    multiRunItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/query_multi_run.png"));
    multiRunItem.setToolTipText(Messages.itemTooltipRunAgain);
    multiRunItem.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            widgetDefaultSelected(e);
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            QueryRecord leftRecord = getSelectedLeftQueryRecord();
            QueryRecord rightRecord = getSelectedRightQueryRecord();
            if (leftRecord == null || rightRecord == null) {
                CommonUITool.openErrorBox(Messages.errCompareQueryEmpty);
                return;
            }
            runQueryPlanAgain(leftRecord.getQuery(), rightRecord.getQuery());
        }
    });
    sqlModeItem = new ToolItem(rightToolBar, SWT.CHECK);
    sqlModeItem.setImage(CommonUIPlugin.getImage("icons/queryplan/sql_compare.gif"));
    sqlModeItem.setToolTipText(Messages.itemTooltipQuery);
    sqlModeItem.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            widgetDefaultSelected(e);
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            updateCompareDisplayModel(DISPLAY_SQL);
        }
    });
    textModelItem = new ToolItem(rightToolBar, SWT.CHECK);
    textModelItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/qe_explain_mode_raw.png"));
    textModelItem.setToolTipText(Messages.tooltip_qedit_explain_display_mode);
    textModelItem.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            widgetDefaultSelected(e);
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            updateCompareDisplayModel(DISPLAY_TEXT);
        }
    });
    treeModelItem = new ToolItem(rightToolBar, SWT.CHECK);
    treeModelItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/qe_explain_mode_tree.png"));
    treeModelItem.setToolTipText(Messages.tooltip_qedit_explain_display_mode);
    treeModelItem.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            widgetDefaultSelected(e);
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            updateCompareDisplayModel(DISPLAY_TREE);
        }
    });
    graphModelItem = new ToolItem(rightToolBar, SWT.CHECK);
    graphModelItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/qe_explain_mode_graph.png"));
    graphModelItem.setToolTipText(Messages.tooltip_qedit_explain_display_mode);
    graphModelItem.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            widgetDefaultSelected(e);
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            updateCompareDisplayModel(DISPLAY_GRAPH);
        }
    });
    Composite tablesComposite = new Composite(composite, SWT.None);
    tablesComposite.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, 60));
    tablesComposite.setLayout(new FormLayout());
    /*Left composite*/
    Composite leftTableComposite = new Composite(tablesComposite, SWT.BORDER);
    leftTableComposite.setLayout(new GridLayout());
    FormData leftTableData = new FormData();
    leftTableData.top = new FormAttachment(0, 0);
    leftTableData.bottom = new FormAttachment(100, 0);
    leftTableData.left = new FormAttachment(0, 0);
    leftTableData.right = new FormAttachment(50, -2);
    leftTableComposite.setLayoutData(leftTableData);
    /*Right composite*/
    Composite rightTableComposite = new Composite(tablesComposite, SWT.BORDER);
    rightTableComposite.setLayout(new GridLayout());
    FormData rightTabelData = new FormData();
    rightTabelData.top = new FormAttachment(0, 0);
    rightTabelData.bottom = new FormAttachment(100, 0);
    rightTabelData.left = new FormAttachment(50, 2);
    rightTabelData.right = new FormAttachment(100, 0);
    rightTableComposite.setLayoutData(rightTabelData);
    compareLeftTableViewer = new TableViewer(leftTableComposite, SWT.FULL_SELECTION);
    compareLeftTableViewer.getTable().setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
    compareLeftTableViewer.getTable().setHeaderVisible(true);
    compareLeftTableViewer.getTable().setLinesVisible(false);
    compareLeftTableViewer.setContentProvider(new QueryPlanContentProvider());
    compareLeftTableViewer.setLabelProvider(new QueryPlanLabelPrivoder(compareLeftTableViewer, false));
    TableColumn fetchColumnLeft = new TableColumn(compareLeftTableViewer.getTable(), SWT.None);
    fetchColumnLeft.setText(Messages.columnFetches);
    fetchColumnLeft.setWidth(60);
    TableColumn dirtyColumnLeft = new TableColumn(compareLeftTableViewer.getTable(), SWT.None);
    dirtyColumnLeft.setText(Messages.columnDirties);
    dirtyColumnLeft.setWidth(60);
    TableColumn ioReadColumnLeft = new TableColumn(compareLeftTableViewer.getTable(), SWT.None);
    ioReadColumnLeft.setText(Messages.columnIORead);
    ioReadColumnLeft.setWidth(80);
    TableColumn ioWriteColumnLeft = new TableColumn(compareLeftTableViewer.getTable(), SWT.None);
    ioWriteColumnLeft.setText(Messages.columnIOWrite);
    ioWriteColumnLeft.setWidth(80);
    TableColumn costColumnLeft = new TableColumn(compareLeftTableViewer.getTable(), SWT.None);
    costColumnLeft.setText(Messages.columnCost);
    costColumnLeft.setWidth(60);
    compareRightTableViewer = new TableViewer(rightTableComposite, SWT.FULL_SELECTION);
    compareRightTableViewer.getTable().setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
    compareRightTableViewer.getTable().setHeaderVisible(true);
    compareRightTableViewer.getTable().setLinesVisible(false);
    compareRightTableViewer.setContentProvider(new QueryPlanContentProvider());
    compareRightTableViewer.setLabelProvider(new QueryPlanLabelPrivoder(compareRightTableViewer, false));
    TableColumn fetchColumnRight = new TableColumn(compareRightTableViewer.getTable(), SWT.None);
    fetchColumnRight.setText(Messages.columnFetches);
    fetchColumnRight.setWidth(60);
    TableColumn dirtyColumnRight = new TableColumn(compareRightTableViewer.getTable(), SWT.None);
    dirtyColumnRight.setText(Messages.columnDirties);
    dirtyColumnRight.setWidth(60);
    TableColumn ioReadColumnRight = new TableColumn(compareRightTableViewer.getTable(), SWT.None);
    ioReadColumnRight.setText(Messages.columnIORead);
    ioReadColumnRight.setWidth(80);
    TableColumn ioWriteColumnRight = new TableColumn(compareRightTableViewer.getTable(), SWT.None);
    ioWriteColumnRight.setText(Messages.columnIOWrite);
    ioWriteColumnRight.setWidth(80);
    TableColumn costColumnRight = new TableColumn(compareRightTableViewer.getTable(), SWT.None);
    costColumnRight.setText(Messages.columnCost);
    costColumnRight.setWidth(60);
    queryPlanCompareSashForm = new SashForm(composite, SWT.VERTICAL);
    queryPlanCompareSashForm.setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
    queryPlanCompareSashForm.setBackground(SASH_COLOR);
    queryPlanCompareSashForm.setLayout(new GridLayout());
    queryPlanCompareSashForm.setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
    Composite textMergeComposite = new Composite(queryPlanCompareSashForm, SWT.None);
    textMergeComposite.setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
    textMergeComposite.setLayout(new FillLayout());
    textMergeConfig = new CompareConfiguration();
    textMergeConfig.setProperty(CompareConfiguration.SHOW_PSEUDO_CONFLICTS, Boolean.FALSE);
    textMergeConfig.setProperty(CompareConfiguration.IGNORE_WHITESPACE, Boolean.TRUE);
    textMergeConfig.setLeftEditable(false);
    textMergeConfig.setRightEditable(false);
    textMergeViewer = new TextMergeViewer(textMergeComposite, SWT.BORDER, textMergeConfig);
    DiffNode queryDiffNode = new DiffNode(null, Differencer.CHANGE, null, new TextCompareInput(""), new TextCompareInput(""));
    textMergeViewer.setInput(queryDiffNode);
    Composite compareQueryPlanComposite = new Composite(queryPlanCompareSashForm, SWT.None);
    compareQueryPlanComposite.setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
    compareQueryPlanComposite.setLayout(new FormLayout());
    DatabaseInfo databaseInfo = database == null ? null : database.getDatabaseInfo();
    leftComparePlanComposite = new QueryPlanComposite(compareQueryPlanComposite, SWT.BORDER, null, databaseInfo);
    FormData leftData = new FormData();
    leftData.top = new FormAttachment(0, 0);
    leftData.bottom = new FormAttachment(100, 0);
    leftData.left = new FormAttachment(0, 0);
    leftData.right = new FormAttachment(50, 0);
    leftComparePlanComposite.setLayoutData(leftData);
    rightComparePlanComposite = new QueryPlanComposite(compareQueryPlanComposite, SWT.BORDER, null, databaseInfo);
    FormData rightData = new FormData();
    rightData.top = new FormAttachment(0, 0);
    rightData.bottom = new FormAttachment(100, 0);
    rightData.left = new FormAttachment(50, 0);
    rightData.right = new FormAttachment(100, 0);
    rightComparePlanComposite.setLayoutData(rightData);
    queryPlanCompareSashForm.setWeights(new int[] { 100, 0 });
}
Also used : DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) CompareConfiguration(org.eclipse.compare.CompareConfiguration) Label(org.eclipse.swt.widgets.Label) DiffNode(org.eclipse.compare.structuremergeviewer.DiffNode) Combo(org.eclipse.swt.widgets.Combo) CTabItem(org.eclipse.swt.custom.CTabItem) TextMergeViewer(org.eclipse.compare.contentmergeviewer.TextMergeViewer) GridLayout(org.eclipse.swt.layout.GridLayout) SelectionEvent(org.eclipse.swt.events.SelectionEvent) TextCompareInput(com.cubrid.common.ui.compare.schema.control.TextCompareInput) FormAttachment(org.eclipse.swt.layout.FormAttachment) ToolItem(org.eclipse.swt.widgets.ToolItem) FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) Composite(org.eclipse.swt.widgets.Composite) QueryPlanComposite(com.cubrid.common.ui.query.control.queryplan.QueryPlanComposite) QueryPlanComposite(com.cubrid.common.ui.query.control.queryplan.QueryPlanComposite) QueryRecord(com.cubrid.common.ui.query.tuner.QueryRecord) FillLayout(org.eclipse.swt.layout.FillLayout) TableColumn(org.eclipse.swt.widgets.TableColumn) SashForm(org.eclipse.swt.custom.SashForm) ToolBar(org.eclipse.swt.widgets.ToolBar) TableViewer(org.eclipse.jface.viewers.TableViewer) SelectionListener(org.eclipse.swt.events.SelectionListener)

Aggregations

TableViewer (org.eclipse.jface.viewers.TableViewer)273 GridData (org.eclipse.swt.layout.GridData)161 Composite (org.eclipse.swt.widgets.Composite)152 Table (org.eclipse.swt.widgets.Table)128 GridLayout (org.eclipse.swt.layout.GridLayout)111 SelectionEvent (org.eclipse.swt.events.SelectionEvent)105 TableColumn (org.eclipse.swt.widgets.TableColumn)91 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)79 Label (org.eclipse.swt.widgets.Label)72 TableViewerColumn (org.eclipse.jface.viewers.TableViewerColumn)70 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)61 Button (org.eclipse.swt.widgets.Button)61 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)60 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)56 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)52 DoubleClickEvent (org.eclipse.jface.viewers.DoubleClickEvent)37 IDoubleClickListener (org.eclipse.jface.viewers.IDoubleClickListener)37 ArrayList (java.util.ArrayList)28 Point (org.eclipse.swt.graphics.Point)26 Event (org.eclipse.swt.widgets.Event)26