Search in sources :

Example 1 with TextViewer

use of org.eclipse.jface.text.TextViewer in project cubrid-manager by CUBRID.

the class UndoAction method run.

/**
	 * @see org.eclipse.jface.action.Action#run()
	 */
public void run() {
    Control control = getFocusProvider();
    if (!(control instanceof StyledText)) {
        return;
    }
    StyledText stext = (StyledText) control;
    Object obj = stext.getData(SQLEditorComposite.SQL_EDITOR_FLAG);
    if (obj instanceof TextViewer) {
        TextViewer viewer = (TextViewer) obj;
        if (viewer.getUndoManager() != null) {
            viewer.getUndoManager().undo();
        }
        IAction redoAction = ActionManager.getInstance().getAction(RedoAction.ID);
        FocusAction.changeActionStatus(redoAction, stext);
        FocusAction.changeActionStatus(this, stext);
    }
}
Also used : Control(org.eclipse.swt.widgets.Control) StyledText(org.eclipse.swt.custom.StyledText) IAction(org.eclipse.jface.action.IAction) TextViewer(org.eclipse.jface.text.TextViewer)

Example 2 with TextViewer

use of org.eclipse.jface.text.TextViewer in project cubrid-manager by CUBRID.

the class RedoAction method run.

/**
	 * @see org.eclipse.jface.action.Action#run()
	 */
public void run() {
    Control control = getFocusProvider();
    if (!(control instanceof StyledText)) {
        return;
    }
    StyledText stext = (StyledText) control;
    Object obj = stext.getData(SQLEditorComposite.SQL_EDITOR_FLAG);
    if (obj instanceof TextViewer) {
        TextViewer viewer = (TextViewer) obj;
        if (viewer.getUndoManager() != null) {
            viewer.getUndoManager().redo();
        }
        IAction undoAction = ActionManager.getInstance().getAction(UndoAction.ID);
        FocusAction.changeActionStatus(undoAction, stext);
        IAction copyAction = ActionManager.getInstance().getAction(CopyAction.ID);
        FocusAction.changeActionStatus(copyAction, stext);
        FocusAction.changeActionStatus(this, stext);
    }
}
Also used : Control(org.eclipse.swt.widgets.Control) StyledText(org.eclipse.swt.custom.StyledText) IAction(org.eclipse.jface.action.IAction) TextViewer(org.eclipse.jface.text.TextViewer)

Example 3 with TextViewer

use of org.eclipse.jface.text.TextViewer in project cubrid-manager by CUBRID.

the class RedoAction 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);
        boolean isEnabled = obj instanceof TextViewer;
        if (isEnabled) {
            TextViewer viewer = (TextViewer) obj;
            isEnabled = viewer.getUndoManager() != null && viewer.getUndoManager().redoable();
        }
        setEnabled(isEnabled);
    }
}
Also used : StyledText(org.eclipse.swt.custom.StyledText) TextViewer(org.eclipse.jface.text.TextViewer)

Example 4 with TextViewer

use of org.eclipse.jface.text.TextViewer 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)

Example 5 with TextViewer

use of org.eclipse.jface.text.TextViewer in project cubrid-manager by CUBRID.

the class TextEditorFindReplaceMediator method findPrevious.

/**
	 *
	 * Find previous searched string
	 *
	 * @return boolean
	 */
public static boolean findPrevious() {
    TextViewer st = getCurrentTextEditor();
    if (st == null) {
        return false;
    }
    String searchedStr = st.getTextWidget().getSelectionText();
    if (searchedStr == null || searchedStr.trim().length() == 0) {
        return false;
    }
    FindReplaceOption findReplaceOption = new FindReplaceOption();
    findReplaceOption.setSearchedStr(searchedStr);
    return findAndSelect(st.getTextWidget().getCaretOffset(), false, findReplaceOption) >= 0;
}
Also used : FindReplaceOption(com.cubrid.tool.editor.dialog.FindReplaceOption) TextViewer(org.eclipse.jface.text.TextViewer)

Aggregations

TextViewer (org.eclipse.jface.text.TextViewer)13 StyledText (org.eclipse.swt.custom.StyledText)6 FindReplaceOption (com.cubrid.tool.editor.dialog.FindReplaceOption)2 IAction (org.eclipse.jface.action.IAction)2 Control (org.eclipse.swt.widgets.Control)2 IFindReplaceTarget (org.eclipse.jface.text.IFindReplaceTarget)1 IFindReplaceTargetExtension (org.eclipse.jface.text.IFindReplaceTargetExtension)1 IFindReplaceTargetExtension3 (org.eclipse.jface.text.IFindReplaceTargetExtension3)1 IUndoManager (org.eclipse.jface.text.IUndoManager)1 Region (org.eclipse.jface.text.Region)1