Search in sources :

Example 66 with StyledText

use of org.eclipse.swt.custom.StyledText 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 67 with StyledText

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

the class InformationWindow method createContents.

protected Control createContents(Composite parent) {
    final Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayout(new FillLayout());
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));
    infoText = new StyledText(composite, SWT.None);
    infoText.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
    infoText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_INFO_FOREGROUND));
    infoText.setEditable(false);
    infoText.setEnabled(false);
    infoText.addMouseTrackListener(new MouseTrackListener() {

        public void mouseHover(MouseEvent e) {
            increaseAlpha();
        }

        public void mouseExit(MouseEvent e) {
            reduceAlpha();
        }

        public void mouseEnter(MouseEvent e) {
            increaseAlpha();
        }
    });
    parentShell.addControlListener(new ControlListener() {

        public void controlResized(ControlEvent e) {
            updateLocation();
        }

        public void controlMoved(ControlEvent e) {
            updateLocation();
        }
    });
    if (Platform.getOS().equals(Platform.OS_WIN32)) {
        parentShell.addPaintListener(new PaintListener() {

            public void paintControl(PaintEvent e) {
                updateLocation();
            }
        });
    }
    this.getShell().setAlpha(minAlpha);
    updateLocation();
    return parent;
}
Also used : StyledText(org.eclipse.swt.custom.StyledText) MouseEvent(org.eclipse.swt.events.MouseEvent) PaintEvent(org.eclipse.swt.events.PaintEvent) CombinedQueryEditorComposite(com.cubrid.common.ui.query.control.CombinedQueryEditorComposite) Composite(org.eclipse.swt.widgets.Composite) PaintListener(org.eclipse.swt.events.PaintListener) MouseTrackListener(org.eclipse.swt.events.MouseTrackListener) GridData(org.eclipse.swt.layout.GridData) ControlListener(org.eclipse.swt.events.ControlListener) FillLayout(org.eclipse.swt.layout.FillLayout) ControlEvent(org.eclipse.swt.events.ControlEvent)

Example 68 with StyledText

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

the class RowDetailDialog method createColumnValueGroup.

/**
	 * Create column value group
	 *
	 * @param parent Composite
	 */
private void createColumnValueGroup(Composite parent) {
    Group group = new Group(parent, SWT.NONE);
    {
        group.setText(Messages.grpColumnValue);
        GridData gridData = new GridData(GridData.FILL_BOTH);
        gridData.horizontalSpan = 2;
        group.setLayoutData(gridData);
        GridLayout layout = new GridLayout();
        layout.numColumns = 2;
        group.setLayout(layout);
    }
    final Label descLabel = new Label(group, SWT.NONE);
    {
        descLabel.setText(Messages.lblColumnValue);
        GridData gd = new GridData(GridData.FILL_HORIZONTAL);
        gd.horizontalSpan = 2;
        descLabel.setLayoutData(gd);
    }
    {
        if (isCanUpdate()) {
            columnValueText = new StyledText(group, SWT.WRAP | SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
            CommonUITool.registerContextMenu(columnValueText, true);
        } else {
            columnValueText = new StyledText(group, SWT.WRAP | SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.READ_ONLY);
            CommonUITool.registerContextMenu(columnValueText, false);
        }
        GridData gd = new GridData(GridData.FILL_BOTH);
        gd.horizontalSpan = 2;
        gd.heightHint = 300;
        columnValueText.setLayoutData(gd);
        columnValueText.addModifyListener(new ModifyListener() {

            public void modifyText(ModifyEvent event) {
                setUpdateButtonEnable();
            }
        });
    }
    setNullBtn = new Button(group, SWT.CHECK);
    {
        setNullBtn.setText(com.cubrid.common.ui.cubrid.table.Messages.btnSetNull);
        GridData gd = new GridData(GridData.FILL_HORIZONTAL);
        gd.horizontalSpan = 2;
        setNullBtn.setLayoutData(gd);
        setNullBtn.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent event) {
                if (setNullBtn.getSelection()) {
                    columnValueText.setText(DataType.NULL_EXPORT_FORMAT);
                } else {
                    columnValueText.setText(dataItem.getText(selComboIndex + 1));
                }
            }
        });
    }
}
Also used : Group(org.eclipse.swt.widgets.Group) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) StyledText(org.eclipse.swt.custom.StyledText) ModifyListener(org.eclipse.swt.events.ModifyListener) Button(org.eclipse.swt.widgets.Button) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Example 69 with StyledText

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

the class QueryResultComposite method makeEmptyResult.

/**
	 * Make empty result contents.
	 * 
	 */
public void makeEmptyResult() {
    resultTabFolder.setSelection(queryResultTabItem);
    SashForm bottomSash = new SashForm(queryResultTabFolder, SWT.VERTICAL);
    bottomSash.SASH_WIDTH = SASH_WIDTH;
    bottomSash.setBackground(CombinedQueryEditorComposite.BACK_COLOR);
    Table table = new Table(bottomSash, SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.MULTI);
    setDropTraget(table);
    table.setHeaderVisible(true);
    table.setLinesVisible(true);
    TableColumn tableColumn = new TableColumn(table, SWT.NONE);
    tableColumn.setWidth(60);
    SashForm tailSash = new SashForm(bottomSash, SWT.HORIZONTAL);
    tailSash.SASH_WIDTH = SASH_WIDTH;
    tailSash.setBackground(CombinedQueryEditorComposite.BACK_COLOR);
    new StyledText(tailSash, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.READ_ONLY);
    bottomSash.setWeights(new int[] { 70, 30 });
    CTabItem tabItem = new CTabItem(queryResultTabFolder, SWT.NONE);
    tabItem.setText(Messages.qedit_result);
    tabItem.setControl(bottomSash);
    queryResultTabFolder.setSelection(tabItem);
}
Also used : SashForm(org.eclipse.swt.custom.SashForm) Table(org.eclipse.swt.widgets.Table) StyledText(org.eclipse.swt.custom.StyledText) TableColumn(org.eclipse.swt.widgets.TableColumn) CTabItem(org.eclipse.swt.custom.CTabItem)

Example 70 with StyledText

use of org.eclipse.swt.custom.StyledText 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

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