Search in sources :

Example 61 with StyledText

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

the class SchemaInfoEditorPart method createTextViewSpec.

/**
	 * Create Text View Spec
	 * 
	 */
private void createTextViewSpec() {
    Label specLabel = new Label(topComposite, SWT.LEFT | SWT.WRAP);
    specLabel.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
    specLabel.setText(Messages.lblQuerySpec);
    txtViewSpec = new StyledText(topComposite, SWT.WRAP | SWT.BORDER);
    txtViewSpec.setLayoutData(new GridData(GridData.FILL_BOTH));
    txtViewSpec.setEditable(false);
    txtViewSpec.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
    com.cubrid.common.ui.spi.util.CommonUITool.registerContextMenu(txtViewSpec, false);
    fillTextViewSpec();
}
Also used : StyledText(org.eclipse.swt.custom.StyledText) Label(org.eclipse.swt.widgets.Label) GridData(org.eclipse.swt.layout.GridData)

Example 62 with StyledText

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

the class CopyAllAction method run.

/**
	 * @see org.eclipse.jface.action.Action#run()
	 */
public void run() {
    TextTransfer textTransfer = TextTransfer.getInstance();
    Clipboard clipboard = CommonUITool.getClipboard();
    Control control = getFocusProvider();
    if (control instanceof StyledText) {
        StyledText stext = (StyledText) control;
        String data = stext.getText();
        if (data != null && !data.equals("")) {
            clipboard.setContents(new Object[] { data }, new Transfer[] { textTransfer });
            IAction pasteAction = ActionManager.getInstance().getAction(PasteAction.ID);
            FocusAction.changeActionStatus(pasteAction, stext);
        }
    } else {
        /*Copy from the active editor*/
        IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
        if (window != null) {
            IEditorPart editor = window.getActivePage().getActiveEditor();
            if (editor != null && editor instanceof ICopiableFromTable) {
                ICopiableFromTable copyAbleEditor = (ICopiableFromTable) editor;
                copyAbleEditor.copyAllItems();
            }
        }
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) ICopiableFromTable(com.cubrid.common.ui.query.editor.ICopiableFromTable) Control(org.eclipse.swt.widgets.Control) StyledText(org.eclipse.swt.custom.StyledText) IAction(org.eclipse.jface.action.IAction) Clipboard(org.eclipse.swt.dnd.Clipboard) IEditorPart(org.eclipse.ui.IEditorPart) TextTransfer(org.eclipse.swt.dnd.TextTransfer)

Example 63 with StyledText

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

the class CutAction method run.

/**
	 * @see org.eclipse.jface.action.Action#run()
	 */
public void run() {
    TextTransfer textTransfer = TextTransfer.getInstance();
    Clipboard clipboard = CommonUITool.getClipboard();
    Control control = getFocusProvider();
    if (control instanceof StyledText) {
        StyledText stext = (StyledText) control;
        String data = stext.getSelectionText();
        if (data != null && !data.equals("")) {
            clipboard.setContents(new Object[] { data }, new Transfer[] { textTransfer });
            Point range = stext.getSelectionRange();
            stext.replaceTextRange(range.x, range.y, "");
            stext.setSelection(range.x);
            IAction pasteAction = ActionManager.getInstance().getAction(PasteAction.ID);
            FocusAction.changeActionStatus(pasteAction, stext);
        }
    }
}
Also used : Control(org.eclipse.swt.widgets.Control) StyledText(org.eclipse.swt.custom.StyledText) IAction(org.eclipse.jface.action.IAction) Clipboard(org.eclipse.swt.dnd.Clipboard) Point(org.eclipse.swt.graphics.Point) TextTransfer(org.eclipse.swt.dnd.TextTransfer)

Example 64 with StyledText

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

the class CutAction method focusGained.

/**
	 * Notifies that the focus gained event
	 * 
	 * @param event an event containing information about the focus change
	 */
public void focusGained(FocusEvent event) {
    setEnabled(false);
    if (event.getSource() instanceof StyledText) {
        StyledText stext = (StyledText) event.getSource();
        boolean isEnabled = stext != null && stext.getSelectionText() != null && stext.getSelectionText().length() > 0 && stext.isEnabled() && stext.getEditable();
        setEnabled(isEnabled);
    }
}
Also used : StyledText(org.eclipse.swt.custom.StyledText)

Example 65 with StyledText

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

the class FindReplaceAction method focusGained.

/**
	 * Notifies that the focus gained event
	 * 
	 * @param event an event containing information about the focus change
	 */
public void focusGained(FocusEvent event) {
    setEnabled(false);
    if (event.getSource() instanceof StyledText) {
        StyledText stext = (StyledText) event.getSource();
        Object obj = stext.getData(SQLEditorComposite.SQL_EDITOR_FLAG);
        setEnabled(obj instanceof TextViewer);
    }
}
Also used : StyledText(org.eclipse.swt.custom.StyledText) TextViewer(org.eclipse.jface.text.TextViewer)

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