Java 类org.eclipse.jface.text.link.ILinkedModeListener 实例源码

项目:n4js    文件:IdentifierExitPolicy.java   
/**
 * {@inheritDoc}
 *
 * If the entered character is not a valid identifier part, it is processed after linked editing has been quit.
 * Exceptions are the {@link #exitCharacters} that have been passed into the constructor.
 */
@Override
public ExitFlags doExit(LinkedModeModel environment, VerifyEvent event, int offset, int length) {
    if (event.character == '\0')
        return null;
    for (char c : exitCharacters) {
        if (event.character == c) {
            return new ExitFlags(ILinkedModeListener.UPDATE_CARET, false);
        }
    }
    switch (event.character) {
    case SWT.CR:
        return new ExitFlags(ILinkedModeListener.UPDATE_CARET, false);
    default: {
        if (!Character.isJavaIdentifierPart(event.character)) {
            return new ExitFlags(ILinkedModeListener.UPDATE_CARET, true);
        }
        return null;
    }
    }
}
项目:ftc    文件:TweakedLinkedModeUI.java   
/**
 * Registers our auto edit vetoer with the viewer.
 *
 * @param viewer
 *            the viewer we want to veto ui-triggered changes within linked
 *            positions
 */
private void registerAutoEditVetoer(ITextViewer viewer) {
    try {
        String[] contentTypes = getContentTypes(viewer.getDocument());
        if (viewer instanceof ITextViewerExtension2) {
            ITextViewerExtension2 vExtension = ((ITextViewerExtension2) viewer);
            for (int i = 0; i < contentTypes.length; i++) {
                vExtension.prependAutoEditStrategy(fAutoEditVetoer, contentTypes[i]);
            }
        } else {
            Assert.isTrue(false);
        }

    } catch (BadPartitioningException e) {
        leave(ILinkedModeListener.EXIT_ALL);
    }
}
项目:texlipse    文件:BracketInserter.java   
public ExitFlags doExit(LinkedModeModel model, VerifyEvent event, int offset, int length) {

    if (fSize == fStack.size() && !isMasked(offset)) {
        if (event.character == fExitCharacter) {
            BracketLevel level= (BracketLevel) fStack.peek();
            if (level.fFirstPosition.offset > offset || level.fSecondPosition.offset < offset)
                return null;
            if (level.fSecondPosition.offset == offset && length == 0)
                // don't enter the character if if its the closing peer
                return new ExitFlags(ILinkedModeListener.UPDATE_CARET, false);
        }
        // when entering an anonymous class between the parenthesis', we don't want
        // to jump after the closing parenthesis when return is pressed
        if (event.character == SWT.CR && offset > 0) {
            IDocument document= sourceViewer.getDocument();
            try {
                if (document.getChar(offset - 1) == '{')
                    return new ExitFlags(ILinkedModeListener.EXIT_ALL, true);
            } catch (BadLocationException e) {
            }
        }
    }
    return null;
}
项目:typescript.java    文件:BracketInserter.java   
public ExitFlags doExit(LinkedModeModel model, VerifyEvent event, int offset, int length) {

            if (fSize == fStack.size() && !isMasked(offset)) {
                if (event.character == fExitCharacter) {
                    BracketLevel level = (BracketLevel) fStack.peek();
                    if (level.fFirstPosition.offset > offset || level.fSecondPosition.offset < offset)
                        return null;
                    if (level.fSecondPosition.offset == offset && length == 0)
                        // don't enter the character if if its the closing peer
                        return new ExitFlags(ILinkedModeListener.UPDATE_CARET, false);
                }
                // when entering an anonymous class between the parenthesis', we
                // don't want
                // to jump after the closing parenthesis when return is pressed
                if (event.character == SWT.CR && offset > 0) {
                    IDocument document = getSourceViewer().getDocument();
                    try {
                        if (document.getChar(offset - 1) == '{')
                            return new ExitFlags(ILinkedModeListener.EXIT_ALL, true);
                    } catch (BadLocationException e) {
                    }
                }
            }
            return null;
        }
项目:bts    文件:ConfigurableCompletionProposal.java   
public ExitFlags doExit(LinkedModeModel environment, VerifyEvent event, int offset, int length) {
    if (event.character == '\0')
        return null;
    for (char c: exitCharacters) {
        if (event.character == c) {
            return new ExitFlags(ILinkedModeListener.UPDATE_CARET, false);
        }
    }

    switch (event.character) {
        case SWT.CR:
            return new ExitFlags(ILinkedModeListener.UPDATE_CARET, false);
        default:
            return null;
    }
}
项目:bts    文件:RenameLinkedMode.java   
/**
 * PopUp gets closed and the focus goes back to the editor. Linked mode stays active and can be reenabled, i.e. by
 * putting the caret back into a linked editing position.
 */
public void linkedModeLeft() {
    if (linkedModeModel != null) {
        linkedModeModel.exit(ILinkedModeListener.NONE);
    }
    if (popup != null) {
        popup.close();
    }

    if (editor != null) {
        ISourceViewer viewer = editor.getInternalSourceViewer();
        if (viewer instanceof IEditingSupportRegistry) {
            IEditingSupportRegistry registry = (IEditingSupportRegistry) viewer;
            registry.unregister(focusEditingSupport);
        }
    }
}
项目:eclipse-wtp-json    文件:JSONCharacterPairInserter.java   
public ExitFlags doExit(LinkedModeModel model, VerifyEvent event,
        int offset, int length) {
    if (!isMasked(offset)) {
        if (event.character == fExit)
            return new ExitFlags(ILinkedModeListener.UPDATE_CARET,
                    false);
        if (event.character == '\r' || event.character == '\n'
                && offset > 0) {
            try {
                if (fDocument.getChar(offset - 1) == '{') {
                    return new ExitFlags(ILinkedModeListener.EXIT_ALL,
                            true);
                }
            } catch (BadLocationException e) {
            }
        }
    }
    return null;
}
项目:APICloud-Studio    文件:ExitPolicy.java   
public ExitFlags doExit(LinkedModeModel model, VerifyEvent event, int offset, int length)
{
    if (shouldInsertNewline())
    {
        if (event.character == '\n' || event.character == '\r')
        {
            return new ExitFlags(ILinkedModeListener.EXIT_ALL, true);
        }
    }

    if (event.character != fExitCharacter)
        return null;

    if (fSize == fStack.size() && !isEscaped(offset))
    {
        BracketLevel level = fStack.peek();
        if (offset < level.fFirstPosition.offset || level.fSecondPosition.offset < offset)
            return null;
        if (level.fSecondPosition.offset == offset && length == 0)
            // don't enter the character if it is the closing peer
            return new ExitFlags(ILinkedModeListener.UPDATE_CARET, false);
    }

    return null;
}
项目:Eclipse-Postfix-Code-Completion    文件:CompilationUnitEditor.java   
public ExitFlags doExit(LinkedModeModel model, VerifyEvent event, int offset, int length) {

            if (fSize == fStack.size() && !isMasked(offset)) {
                if (event.character == fExitCharacter) {
                    BracketLevel level= fStack.peek();
                    if (level.fFirstPosition.offset > offset || level.fSecondPosition.offset < offset)
                        return null;
                    if (level.fSecondPosition.offset == offset && length == 0)
                        // don't enter the character if if its the closing peer
                        return new ExitFlags(ILinkedModeListener.UPDATE_CARET, false);
                }
                // when entering an anonymous class between the parenthesis', we don't want
                // to jump after the closing parenthesis when return is pressed
                if (event.character == SWT.CR && offset > 0) {
                    IDocument document= getSourceViewer().getDocument();
                    try {
                        if (document.getChar(offset - 1) == '{')
                            return new ExitFlags(ILinkedModeListener.EXIT_ALL, true);
                    } catch (BadLocationException e) {
                    }
                }
            }
            return null;
        }
项目:idecore    文件:BracketInserter.java   
@Override
public ExitFlags doExit(LinkedModeModel model, VerifyEvent event, int offset, int length) {

    if (fSize == fStack.size() && !isMasked(offset)) {
        if (event.character == fExitCharacter) {
            BracketLevel level = fStack.peek();
            if (level.fFirstPosition.offset > offset || level.fSecondPosition.offset < offset)
                return null;
            if (level.fSecondPosition.offset == offset && length == 0)
                // don't enter the character if if its the closing peer
                return new ExitFlags(ILinkedModeListener.UPDATE_CARET, false);
        }
        // when entering an anonymous class between the parenthesis', we don't want
        // to jump after the closing parenthesis when return is pressed
        if (event.character == SWT.CR && offset > 0) {
            IDocument document = getSourceViewer().getDocument();
            try {
                if (document.getChar(offset - 1) == '{')
                    return new ExitFlags(ILinkedModeListener.EXIT_ALL, true);
            } catch (BadLocationException e) {}
        }
    }
    return null;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:CompilationUnitEditor.java   
public ExitFlags doExit(LinkedModeModel model, VerifyEvent event, int offset, int length) {

            if (fSize == fStack.size() && !isMasked(offset)) {
                if (event.character == fExitCharacter) {
                    BracketLevel level= fStack.peek();
                    if (level.fFirstPosition.offset > offset || level.fSecondPosition.offset < offset)
                        return null;
                    if (level.fSecondPosition.offset == offset && length == 0)
                        // don't enter the character if if its the closing peer
                        return new ExitFlags(ILinkedModeListener.UPDATE_CARET, false);
                }
                // when entering an anonymous class between the parenthesis', we don't want
                // to jump after the closing parenthesis when return is pressed
                if (event.character == SWT.CR && offset > 0) {
                    IDocument document= getSourceViewer().getDocument();
                    try {
                        if (document.getChar(offset - 1) == '{')
                            return new ExitFlags(ILinkedModeListener.EXIT_ALL, true);
                    } catch (BadLocationException e) {
                    }
                }
            }
            return null;
        }
项目:ec4e    文件:EditorConfigCompletionProposal.java   
@Override
public ExitFlags doExit(LinkedModeModel environment, VerifyEvent event, int offset, int length) {

    if (event.character == fExitCharacter) {
        if (environment.anyPositionContains(offset))
            return new ExitFlags(ILinkedModeListener.UPDATE_CARET, false);
        else
            return new ExitFlags(ILinkedModeListener.UPDATE_CARET, true);
    }

    switch (event.character) {
    case ';':
        return new ExitFlags(ILinkedModeListener.NONE, true);
    case SWT.CR:
        // when entering an anonymous class as a parameter, we don't
        // want
        // to jump after the parenthesis when return is pressed
        if (offset > 0) {
            try {
                if (fDocument.getChar(offset - 1) == '{')
                    return new ExitFlags(ILinkedModeListener.EXIT_ALL, true);
            } catch (BadLocationException e) {
            }
        }
        return null;
    default:
        return null;
    }
}
项目:ftc    文件:TweakedLinkedModeUI.java   
public void resume(LinkedModeModel model, int flags) {
    if ((flags & ILinkedModeListener.EXIT_ALL) != 0) {
        leave(flags);
    } else {
        connect();
        if ((flags & ILinkedModeListener.SELECT) != 0)
            select();
        ensureAnnotationModelInstalled();
        redraw();
    }
}
项目:ftc    文件:TweakedLinkedModeUI.java   
public void documentAboutToBeChanged(DocumentEvent event) {

            // default behavior: any document change outside a linked position
            // causes us to exit
            int end = event.getOffset() + event.getLength();
            for (int offset = event.getOffset(); offset <= end; offset++) {
                if (!fModel.anyPositionContains(offset)) {
                    ITextViewer viewer = fCurrentTarget.getViewer();
                    if (fFramePosition != null && viewer instanceof IEditingSupportRegistry) {
                        IEditingSupport[] helpers = ((IEditingSupportRegistry) viewer).getRegisteredSupports();
                        for (int i = 0; i < helpers.length; i++) {
                            if (helpers[i].isOriginator(null,
                                    new Region(fFramePosition.getOffset(), fFramePosition.getLength())))
                                return;
                        }
                    }

                    leave(ILinkedModeListener.EXTERNAL_MODIFICATION);
                    return;
                }
            }

            // Make sure that any document change is done inside a compound
            // change
            beginCompoundChangeIfNeeded();

        }
项目:ftc    文件:TweakedLinkedModeUI.java   
void next() {
    if (fIterator.hasNext(fFramePosition)) {
        switchPosition(fIterator.next(fFramePosition), true, true);
        return;
    }
    leave(ILinkedModeListener.UPDATE_CARET);
}
项目:ftc    文件:TweakedLinkedModeUI.java   
void previous() {
    if (fIterator.hasPrevious(fFramePosition)) {
        switchPosition(fIterator.previous(fFramePosition), true, true);
    } else
        // dont't update caret, but rather select the current frame
        leave(ILinkedModeListener.SELECT);
}
项目:ftc    文件:TweakedLinkedModeUI.java   
private void switchPosition(LinkedPosition pos, boolean select, boolean showProposals) {
    Assert.isNotNull(pos);
    if (pos.equals(fFramePosition))
        return;

    if (fFramePosition != null && fCurrentTarget != null)
        fPositionListener.linkingFocusLost(fFramePosition, fCurrentTarget);

    // undo
    endCompoundChangeIfNeeded();

    redraw(); // redraw current position being left - usually not needed
    IDocument oldDoc = fFramePosition == null ? null : fFramePosition.getDocument();
    IDocument newDoc = pos.getDocument();

    switchViewer(oldDoc, newDoc, pos);
    fFramePosition = pos;

    if (select)
        select();
    if (fFramePosition == fExitPosition && !fIterator.isCycling())
        leave(ILinkedModeListener.NONE);
    else {
        redraw(); // redraw new position
        ensureAnnotationModelInstalled();
    }
    if (showProposals)
        triggerContentAssist();
    if (fFramePosition != fExitPosition && fDoContextInfo)
        triggerContextInfo();

    if (fFramePosition != null && fCurrentTarget != null)
        fPositionListener.linkingFocusGained(fFramePosition, fCurrentTarget);

}
项目:ftc    文件:TweakedLinkedModeUI.java   
private void connect() {
    Assert.isNotNull(fCurrentTarget);
    ITextViewer viewer = fCurrentTarget.getViewer();
    Assert.isNotNull(viewer);
    fCurrentTarget.fWidget = viewer.getTextWidget();
    if (fCurrentTarget.fWidget == null)
        leave(ILinkedModeListener.EXIT_ALL);

    if (fCurrentTarget.fKeyListener == null) {
        fCurrentTarget.fKeyListener = new KeyListener();
        ((ITextViewerExtension) viewer).prependVerifyKeyListener(fCurrentTarget.fKeyListener);
    } else
        fCurrentTarget.fKeyListener.setEnabled(true);

    registerAutoEditVetoer(viewer);

    ((IPostSelectionProvider) viewer).addPostSelectionChangedListener(fSelectionListener);

    createAnnotationModel();

    showSelection();

    fCurrentTarget.fShell = fCurrentTarget.fWidget.getShell();
    if (fCurrentTarget.fShell == null)
        leave(ILinkedModeListener.EXIT_ALL);
    fCurrentTarget.fShell.addShellListener(fCloser);

    fAssistant.install(viewer);

    viewer.addTextInputListener(fCloser);

    viewer.getDocument().addDocumentListener(fDocumentListener);
}
项目:ftc    文件:TweakedLinkedModeUI.java   
private void unregisterAutoEditVetoer(ITextViewer viewer) {
    try {
        String[] contentTypes = getContentTypes(viewer.getDocument());
        if (viewer instanceof ITextViewerExtension2) {
            ITextViewerExtension2 vExtension = ((ITextViewerExtension2) viewer);
            for (int i = 0; i < contentTypes.length; i++) {
                vExtension.removeAutoEditStrategy(fAutoEditVetoer, contentTypes[i]);
            }
        } else {
            Assert.isTrue(false);
        }
    } catch (BadPartitioningException e) {
        leave(ILinkedModeListener.EXIT_ALL);
    }
}
项目:typescript.java    文件:TypeScriptCompletionProposal.java   
public ExitFlags doExit(LinkedModeModel environment, VerifyEvent event, int offset, int length) {

            if (event.character == fExitCharacter) {
                if (environment.anyPositionContains(offset))
                    return new ExitFlags(ILinkedModeListener.UPDATE_CARET, false);
                else
                    return new ExitFlags(ILinkedModeListener.UPDATE_CARET, true);
            }

            switch (event.character) {
            case ';':
                return new ExitFlags(ILinkedModeListener.NONE, true);
            case SWT.CR:
                // when entering an anonymous class as a parameter, we don't
                // want
                // to jump after the parenthesis when return is pressed
                if (offset > 0) {
                    try {
                        if (fDocument.getChar(offset - 1) == '{')
                            return new ExitFlags(ILinkedModeListener.EXIT_ALL, true);
                    } catch (BadLocationException e) {
                    }
                }
                return null;
            default:
                return null;
            }
        }
项目:typescript.java    文件:RenameLinkedMode.java   
@Override
public void left(LinkedModeModel model, int flags) {
    linkedModeLeft();
    if ((flags & ILinkedModeListener.UPDATE_CARET) != 0) {
        doRename(fShowPreview);
    }
}
项目:typescript.java    文件:RenameLinkedMode.java   
public void cancel() {
    fEditor.getTypeScriptFile().setDisableChanged(false);
    if (fLinkedModeModel != null) {
        fLinkedModeModel.exit(ILinkedModeListener.NONE);
    }
    linkedModeLeft();
}
项目:bts    文件:RenameLinkedMode.java   
public void left(LinkedModeModel model, int flags) {
    //boolean isValidNewName = updateNewName();
    if ((flags & ILinkedModeListener.UPDATE_CARET) != 0) {// && isValidNewName) {
        if (showPreview)
            controller.startRefactoring(RefactoringType.REFACTORING_PREVIEW);
        else
            controller.startRefactoring(RefactoringType.REFACTORING_DIRECT);
    } else {
        controller.cancelLinkedMode();
    }
}
项目:Eclipse-Postfix-Code-Completion    文件:AbstractJavaCompletionProposal.java   
public ExitFlags doExit(LinkedModeModel environment, VerifyEvent event, int offset, int length) {

            if (event.character == fExitCharacter) {
                if (environment.anyPositionContains(offset))
                    return new ExitFlags(ILinkedModeListener.UPDATE_CARET, false);
                else
                    return new ExitFlags(ILinkedModeListener.UPDATE_CARET, true);
            }

            switch (event.character) {
                case ';':
                    return new ExitFlags(ILinkedModeListener.NONE, true);
                case SWT.CR:
                    // 1) when entering an anonymous class as a parameter, we don't want
                    // to jump after the parenthesis when return is pressed
                    // 2) after auto completion of methods without parameters, exit from linked mode when return is pressed
                    if (offset > 0) {
                        try {
                            char prevOffsetChar= fDocument.getChar(offset - 1);
                            if (prevOffsetChar == '{' || prevOffsetChar == ';')
                                return new ExitFlags(ILinkedModeListener.EXIT_ALL, true);
                        } catch (BadLocationException e) {
                        }
                    }
                    return null;
                default:
                    return null;
            }
        }
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:AbstractJavaCompletionProposal.java   
public ExitFlags doExit(LinkedModeModel environment, VerifyEvent event, int offset, int length) {

            if (event.character == fExitCharacter) {
                if (environment.anyPositionContains(offset))
                    return new ExitFlags(ILinkedModeListener.UPDATE_CARET, false);
                else
                    return new ExitFlags(ILinkedModeListener.UPDATE_CARET, true);
            }

            switch (event.character) {
                case ';':
                    return new ExitFlags(ILinkedModeListener.NONE, true);
                case SWT.CR:
                    // when entering an anonymous class as a parameter, we don't want
                    // to jump after the parenthesis when return is pressed
                    if (offset > 0) {
                        try {
                            if (fDocument.getChar(offset - 1) == '{')
                                return new ExitFlags(ILinkedModeListener.EXIT_ALL, true);
                        } catch (BadLocationException e) {
                        }
                    }
                    return null;
                default:
                    return null;
            }
        }
项目:goclipse    文件:LangCompletionProposal.java   
@Override
public ExitFlags doExit(LinkedModeModel model, VerifyEvent event, int offset, int length) {
    switch (event.character) {
    case SWT.CR:
        int endOfReplacement = getReplaceOffset() + getEffectiveReplaceString(false).length();
        if(offset == endOfReplacement) {
            return new ExitFlags(ILinkedModeListener.EXIT_ALL, true);
        }
        return new ExitFlags(ILinkedModeListener.UPDATE_CARET, false);
    }
    return null;
}
项目:ftc    文件:TweakedLinkedModeUI.java   
public void left(LinkedModeModel model, int flags) {
    leave(ILinkedModeListener.EXIT_ALL | flags);
}
项目:ftc    文件:TweakedLinkedModeUI.java   
public void shellClosed(ShellEvent e) {
    leave(ILinkedModeListener.EXIT_ALL);
}
项目:ftc    文件:TweakedLinkedModeUI.java   
public void shellDeactivated(ShellEvent e) {
    // TODO re-enable after debugging
    // if (true) return;

    // from LinkedPositionUI:

    // don't deactivate on focus lost, since the proposal popups may
    // take focus
    // plus: it doesn't hurt if you can check with another window
    // without losing linked mode
    // since there is no intrusive popup sticking out.

    // need to check first what happens on reentering based on an open
    // action
    // Seems to be no problem

    // Better:
    // Check with content assistant and only leave if its not the
    // proposal shell that took the
    // focus away.

    StyledText text;
    final ITextViewer viewer;
    Display display;

    if (fCurrentTarget == null || (text = fCurrentTarget.fWidget) == null || text.isDisposed()
            || (display = text.getDisplay()) == null || display.isDisposed()
            || (viewer = fCurrentTarget.getViewer()) == null) {
        leave(ILinkedModeListener.EXIT_ALL);
    } else {
        // Post in UI thread since the assistant popup will only get the
        // focus after we lose it.
        display.asyncExec(new Runnable() {
            public void run() {
                if (fIsActive && viewer instanceof IEditingSupportRegistry) {
                    IEditingSupport[] helpers = ((IEditingSupportRegistry) viewer).getRegisteredSupports();
                    for (int i = 0; i < helpers.length; i++) {
                        if (helpers[i].ownsFocusShell())
                            return;
                    }
                }

                // else
                leave(ILinkedModeListener.EXIT_ALL);

            }
        });
    }
}
项目:ftc    文件:TweakedLinkedModeUI.java   
public void shellIconified(ShellEvent e) {
    leave(ILinkedModeListener.EXIT_ALL);
}
项目:ftc    文件:TweakedLinkedModeUI.java   
public void inputDocumentAboutToBeChanged(IDocument oldInput, IDocument newInput) {
    leave(ILinkedModeListener.EXIT_ALL);
}
项目:Eclipse-Postfix-Code-Completion    文件:RenameLinkedMode.java   
public void left(LinkedModeModel model, int flags) {
    linkedModeLeft();
    if ( (flags & ILinkedModeListener.UPDATE_CARET) != 0) {
        doRename(fShowPreview);
    }
}
项目:Eclipse-Postfix-Code-Completion    文件:RenameLinkedMode.java   
public void cancel() {
    if (fLinkedModeModel != null) {
        fLinkedModeModel.exit(ILinkedModeListener.NONE);
    }
    linkedModeLeft();
}
项目:Eclipse-Postfix-Code-Completion    文件:LinkedProposalModelPresenter.java   
public ExitFlags doExit(LinkedModeModel model, VerifyEvent event, int offset, int length) {
    if (event.character  == '=') {
        return new ExitFlags(ILinkedModeListener.EXIT_ALL, true);
    }
    return null;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:RenameLinkedMode.java   
public void left(LinkedModeModel model, int flags) {
    linkedModeLeft();
    if ( (flags & ILinkedModeListener.UPDATE_CARET) != 0) {
        doRename(fShowPreview);
    }
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:RenameLinkedMode.java   
public void cancel() {
    if (fLinkedModeModel != null) {
        fLinkedModeModel.exit(ILinkedModeListener.NONE);
    }
    linkedModeLeft();
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:LinkedProposalModelPresenter.java   
public ExitFlags doExit(LinkedModeModel model, VerifyEvent event, int offset, int length) {
    if (event.character  == '=') {
        return new ExitFlags(ILinkedModeListener.EXIT_ALL, true);
    }
    return null;
}