Search in sources :

Example 51 with StyledText

use of org.eclipse.swt.custom.StyledText 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;
}
Also used : TuneModeModel(com.cubrid.common.ui.query.control.tunemode.TuneModeModel) SQLEditorComposite(com.cubrid.common.ui.query.control.SQLEditorComposite) QueryResultComposite(com.cubrid.common.ui.query.control.QueryResultComposite) StyledText(org.eclipse.swt.custom.StyledText) CTabFolder(org.eclipse.swt.custom.CTabFolder) SQLException(java.sql.SQLException) CUBRIDStatementProxy(com.cubrid.jdbc.proxy.driver.CUBRIDStatementProxy) Point(org.eclipse.swt.graphics.Point) StructQueryPlan(com.cubrid.common.core.queryplan.StructQueryPlan) Date(java.util.Date) PartInitException(org.eclipse.ui.PartInitException) SQLException(java.sql.SQLException) IOException(java.io.IOException)

Example 52 with StyledText

use of org.eclipse.swt.custom.StyledText in project cubrid-manager by CUBRID.

the class QueryEditorPart method queryErrSkipOrNot.

/**
	 * Open a message dialog to confirm skip query error or not.
	 *
	 * @param ee SQLException
	 * @param errorSql String
	 * @return value boolean[]
	 *
	 */
public boolean[] queryErrSkipOrNot(final SQLException ee, String errorSql) {
    final boolean[] value = new boolean[2];
    SQLEditorComposite sqlEditorComp = combinedQueryComposite.getSqlEditorComp();
    StyledText txaEdit = sqlEditorComp.getText();
    if (txaEdit != null && !txaEdit.isDisposed()) {
        sqlEditorComp.txtFind(errorSql, 0, false, false, true, false);
        line = txaEdit.getLineAtOffset(txaEdit.getSelection().x) + 1;
    }
    String errorLineMsg = Messages.bind(Messages.errWhere, line);
    String errMsg = Messages.skipOrNot + StringUtil.NEWLINE + StringUtil.NEWLINE + Messages.runError + ee.getErrorCode() + StringUtil.NEWLINE + errorLineMsg + StringUtil.NEWLINE + Messages.errorHead + ee.getMessage();
    MessageDialog dialog = new MessageDialog(QueryEditorPart.this.getEditorSite().getShell(), Messages.warning, null, errMsg, MessageDialog.QUESTION, new String[] { Messages.btnYes, Messages.btnNo }, 1) {

        Button btn = null;

        protected Control createCustomArea(Composite parent) {
            btn = new Button(parent, SWT.CHECK);
            btn.setText(Messages.showOneTimeTip);
            return btn;
        }

        protected void buttonPressed(int buttonId) {
            value[0] = btn.getSelection();
            if (buttonId == IDialogConstants.CANCEL_ID) {
                value[1] = false;
            } else {
                value[1] = true;
            }
            close();
        }
    };
    dialog.open();
    return value;
}
Also used : SQLEditorComposite(com.cubrid.common.ui.query.control.SQLEditorComposite) StyledText(org.eclipse.swt.custom.StyledText) Composite(org.eclipse.swt.widgets.Composite) MultiDBQueryComposite(com.cubrid.common.ui.query.control.MultiDBQueryComposite) QueryResultComposite(com.cubrid.common.ui.query.control.QueryResultComposite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) SQLEditorComposite(com.cubrid.common.ui.query.control.SQLEditorComposite) CombinedQueryEditorComposite(com.cubrid.common.ui.query.control.CombinedQueryEditorComposite) Button(org.eclipse.swt.widgets.Button) MessageDialog(org.eclipse.jface.dialogs.MessageDialog)

Example 53 with StyledText

use of org.eclipse.swt.custom.StyledText in project cubrid-manager by CUBRID.

the class BLOBCellPopupDialog method createTextComposite.

/**
	 *
	 * Create the text composite
	 *
	 */
private void createTextComposite() {
    columnValueText = new StyledText(dataComposite, SWT.WRAP | SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
    //columnValueText.setEditable(false);
    if (value.hasLoadAll()) {
        CommonUITool.registerContextMenu(columnValueText, isEditable);
    }
    GridData gd = new GridData(GridData.FILL_BOTH);
    gd.horizontalSpan = 3;
    gd.heightHint = 280;
    gd.widthHint = 500;
    columnValueText.setLayoutData(gd);
    dataComposite.layout();
}
Also used : StyledText(org.eclipse.swt.custom.StyledText) GridData(org.eclipse.swt.layout.GridData)

Example 54 with StyledText

use of org.eclipse.swt.custom.StyledText in project cubrid-manager by CUBRID.

the class DataCompareEditorPart method createContent.

private void createContent(Composite parent) {
    compareTableViewer = new TableViewer(parent, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
    compareTableViewer.setUseHashlookup(true);
    compareTableViewer.setColumnProperties(columnNames);
    CommonUITool.createGridLayout(compareTableViewer.getTable(), 1, 0, 10, 0, 10, 0, 0, 0, 0);
    compareTableViewer.getTable().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    compareTableViewer.getTable().setLinesVisible(true);
    compareTableViewer.getTable().setHeaderVisible(true);
    sorter = new DataCompareSchemaListViewSorter();
    sorter.setSortType(DataCompareSchemaListViewSorter.SORT_TABLE);
    compareTableViewer.setSorter(sorter);
    makeContextMenu(compareTableViewer);
    final TableViewerColumn firstCol = new TableViewerColumn(compareTableViewer, SWT.NONE);
    firstCol.getColumn().setWidth(30);
    firstCol.getColumn().setResizable(false);
    firstCol.getColumn().setAlignment(SWT.CENTER);
    firstCol.getColumn().setImage(CommonUIPlugin.getImage("icons/unchecked.gif"));
    firstCol.getColumn().addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            TableItem[] items = compareTableViewer.getTable().getItems();
            if (items == null) {
                return;
            }
            for (TableItem item : items) {
                DataCompare dataCompare = (DataCompare) item.getData();
                dataCompare.setUse(isSelectAll);
            }
            compareTableViewer.refresh();
            Image image = null;
            if (isSelectAll) {
                image = CommonUIPlugin.getImage("icons/checked.gif");
            } else {
                image = CommonUIPlugin.getImage("icons/unchecked.gif");
            }
            firstCol.getColumn().setImage(image);
            isSelectAll = !isSelectAll;
        }
    });
    TableViewerColumn col = new TableViewerColumn(compareTableViewer, SWT.NONE);
    col.getColumn().setWidth(200);
    col.getColumn().setText(Messages.lblDataCompareTable);
    makeSortTableColumn(col, DataCompareSchemaListViewSorter.SORT_TABLE);
    col = new TableViewerColumn(compareTableViewer, SWT.LEFT);
    col.getColumn().setWidth(100);
    col.getColumn().setText(Messages.lblDataCompareRecordSource);
    makeSortTableColumn(col, DataCompareSchemaListViewSorter.SORT_SOURCE_RECORDS);
    col = new TableViewerColumn(compareTableViewer, SWT.LEFT);
    col.getColumn().setWidth(100);
    col.getColumn().setText(Messages.lblDataCompareRecordTarget);
    makeSortTableColumn(col, DataCompareSchemaListViewSorter.SORT_TARGET_RECORDS);
    col = new TableViewerColumn(compareTableViewer, SWT.LEFT);
    col.getColumn().setWidth(100);
    col.getColumn().setText(Messages.lblDataCompareRecordProgress);
    makeSortTableColumn(col, DataCompareSchemaListViewSorter.SORT_PROGRESS);
    col = new TableViewerColumn(compareTableViewer, SWT.LEFT);
    col.getColumn().setWidth(100);
    col.getColumn().setText(Messages.lblDataCompareRecordMatch);
    makeSortTableColumn(col, DataCompareSchemaListViewSorter.SORT_MATCHES);
    col = new TableViewerColumn(compareTableViewer, SWT.LEFT);
    col.getColumn().setWidth(100);
    col.getColumn().setText(Messages.lblDataCompareRecordNoMatch);
    makeSortTableColumn(col, DataCompareSchemaListViewSorter.SORT_NOT_MATCHES);
    col = new TableViewerColumn(compareTableViewer, SWT.LEFT);
    col.getColumn().setWidth(100);
    col.getColumn().setText(Messages.lblDataCompareRecordNotExist);
    makeSortTableColumn(col, DataCompareSchemaListViewSorter.SORT_NOT_EXISTS);
    col = new TableViewerColumn(compareTableViewer, SWT.LEFT);
    col.getColumn().setWidth(300);
    col.getColumn().setText(Messages.lblDataCompareRecordError);
    makeSortTableColumn(col, DataCompareSchemaListViewSorter.SORT_ERROR);
    CellEditor[] cellEditor = new CellEditor[1];
    cellEditor[0] = new CheckboxCellEditor(compareTableViewer.getTable());
    compareTableViewer.setCellEditors(cellEditor);
    compareTableViewer.setCellModifier(new DataCompareCellModifier(this));
    compareTableViewer.setContentProvider(new DataCompareSchemaListContentProvider());
    compareTableViewer.setLabelProvider(new DataCompareSchemaListLabelProvider());
    compareList = new ArrayList<DataCompare>();
    compareTableViewer.setInput(compareList);
    txtProgress = new StyledText(parent, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL);
    txtProgress.setEditable(false);
    txtProgress.setWordWrap(true);
    txtProgress.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, 100));
    txtProgress.setBackground(txtProgress.getDisplay().getSystemColor(SWT.COLOR_BLACK));
    txtProgress.setForeground(txtProgress.getDisplay().getSystemColor(SWT.COLOR_GREEN));
    compareTableViewer.getTable().setToolTipText(Messages.msgYouCanSeeDetailDblclick);
    compareTableViewer.getTable().addKeyListener(new KeyAdapter() {

        public void keyReleased(KeyEvent e) {
            if (e.character == ' ') {
                TableItem[] items = compareTableViewer.getTable().getSelection();
                if (items == null) {
                    return;
                }
                for (TableItem item : items) {
                    DataCompare dataCompare = (DataCompare) item.getData();
                    dataCompare.setUse(!dataCompare.isUse());
                }
                compareTableViewer.refresh();
            }
        }
    });
    compareTableViewer.addDoubleClickListener(new IDoubleClickListener() {

        public void doubleClick(DoubleClickEvent event) {
            if (!refreshedRecordCounts) {
                CommonUITool.openWarningBox(Messages.msgClickRefreshToEsimateDiff);
                return;
            }
            IStructuredSelection selection = (IStructuredSelection) event.getSelection();
            DataCompare model = (DataCompare) selection.getFirstElement();
            if (!model.isSameSchema()) {
                CommonUITool.openWarningBox(Messages.msgTheSchemaDiff);
                return;
            }
            if (model.getRecordsTarget() == -1) {
                CommonUITool.openWarningBox(Messages.msgTargetNotFound);
                return;
            }
            if (model.getRecordsSource() == 0 && model.getRecordsTarget() > 0) {
                CommonUITool.openWarningBox(Messages.msgTargetNoData);
                return;
            }
            if (model.getRecordsSource() == 0) {
                CommonUITool.openWarningBox(Messages.msgNoDataToCompare);
                return;
            }
            if (model.getProgressPosition() == 0) {
                CommonUITool.openWarningBox(Messages.msgNotYetCompared);
                return;
            }
            if (model.getNotMatches() == 0 && model.getNotExists() == 0) {
                CommonUITool.openWarningBox(Messages.msgSameData);
                return;
            }
            showDataCompareDetailEditor(model.getSchemaInfo());
        }
    });
}
Also used : StyledText(org.eclipse.swt.custom.StyledText) CheckboxCellEditor(org.eclipse.jface.viewers.CheckboxCellEditor) CellEditor(org.eclipse.jface.viewers.CellEditor) CheckboxCellEditor(org.eclipse.jface.viewers.CheckboxCellEditor) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) TableItem(org.eclipse.swt.widgets.TableItem) KeyAdapter(org.eclipse.swt.events.KeyAdapter) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) Image(org.eclipse.swt.graphics.Image) KeyEvent(org.eclipse.swt.events.KeyEvent) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) DataCompare(com.cubrid.common.ui.compare.data.model.DataCompare) TableViewer(org.eclipse.jface.viewers.TableViewer) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn)

Example 55 with StyledText

use of org.eclipse.swt.custom.StyledText in project cubrid-manager by CUBRID.

the class JdbcOptionComposite method focusCell.

public void focusCell(final TableItem item, final int row, final int col) {
    final StyledText text = new StyledText(jdbcInfoTv.getTable(), SWT.SINGLE);
    Listener textListener = new TableItemEditor(text, item, row, col);
    text.addListener(SWT.FocusOut, textListener);
    text.addListener(SWT.Traverse, textListener);
    text.addListener(SWT.FocusIn, textListener);
    text.addTraverseListener(new TraverseListener() {

        public void keyTraversed(TraverseEvent e) {
            if (e.detail == SWT.TRAVERSE_TAB_NEXT || e.detail == SWT.TRAVERSE_TAB_PREVIOUS) {
                e.doit = false;
                int newColumn = col == 0 ? 1 : 0;
                focusCell(item, row, newColumn);
            } else if (e.detail == SWT.TRAVERSE_RETURN) {
                e.doit = false;
                addButton.setFocus();
            }
        }
    });
    text.setEditable(true);
    editor.setEditor(text, item, col);
    text.setText(item.getText(col));
    text.selectAll();
    try {
        text.setFocus();
    } catch (Exception e) {
    }
}
Also used : StyledText(org.eclipse.swt.custom.StyledText) Listener(org.eclipse.swt.widgets.Listener) TraverseListener(org.eclipse.swt.events.TraverseListener) MouseListener(org.eclipse.swt.events.MouseListener) TraverseEvent(org.eclipse.swt.events.TraverseEvent) TraverseListener(org.eclipse.swt.events.TraverseListener)

Aggregations

StyledText (org.eclipse.swt.custom.StyledText)329 Point (org.eclipse.swt.graphics.Point)102 GridData (org.eclipse.swt.layout.GridData)68 Composite (org.eclipse.swt.widgets.Composite)63 GridLayout (org.eclipse.swt.layout.GridLayout)62 Control (org.eclipse.swt.widgets.Control)46 SelectionEvent (org.eclipse.swt.events.SelectionEvent)32 Label (org.eclipse.swt.widgets.Label)32 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)30 Display (org.eclipse.swt.widgets.Display)30 Shell (org.eclipse.swt.widgets.Shell)30 Rectangle (org.eclipse.swt.graphics.Rectangle)27 Color (org.eclipse.swt.graphics.Color)25 FillLayout (org.eclipse.swt.layout.FillLayout)25 Button (org.eclipse.swt.widgets.Button)23 Text (org.eclipse.swt.widgets.Text)21 StyleRange (org.eclipse.swt.custom.StyleRange)20 Font (org.eclipse.swt.graphics.Font)20 Event (org.eclipse.swt.widgets.Event)20 Test (org.junit.Test)20