Java 类org.eclipse.jface.text.TextEvent 实例源码

项目:mesfavoris    文件:BookmarkCommentArea.java   
private ITextListener getTextListener() {
    return new ITextListener() {

        @Override
        public void textChanged(final TextEvent event) {
            if (bookmark == null || !getSourceViewer().isEditable()) {
                return;
            }
            final String newComment = getDocument().get();
            try {
                SetBookmarkCommentOperation operation = new SetBookmarkCommentOperation(bookmarkDatabase);
                operation.setComment(bookmark.getId(), newComment);
            } catch (BookmarksException e) {
                // never happen
            }
        }
    };
}
项目:dsl-devkit    文件:FixedXtextSourceViewer.java   
/**
 * Informs all registered text listeners about the change specified by the
 * widget command. This method does not use a robust iterator.
 *
 * @param cmd
 *          the widget command translated into a text event sent to all text listeners
 */
@Override
protected void updateTextListeners(final WidgetCommand cmd) {
  List<ITextListener> textListeners = fTextListeners;
  if (textListeners != null) {
    textListeners = new ArrayList<ITextListener>(textListeners);
    DocumentEvent event = cmd.event;
    if (event instanceof SlaveDocumentEvent) {
      event = ((SlaveDocumentEvent) event).getMasterEvent();
    }
    TextEvent e = new TextEvent(cmd.start, cmd.length, cmd.text, cmd.preservedText, event, redraws()) {};
    for (int i = 0; i < textListeners.size(); i++) {
      ITextListener l = textListeners.get(i);
      l.textChanged(e);
    }
  }
}
项目:fluentmark    文件:TypingRunDetector.java   
/**
 * Computes the change abstraction given a text event.
 *
 * @param event the text event to analyze
 * @return a change object describing the event
 */
private Change computeChange(TextEvent event) {
    DocumentEvent e = event.getDocumentEvent();
    if (e == null) return new Change(TypingRun.NO_CHANGE, -1);

    int start = e.getOffset();
    int end = e.getOffset() + e.getLength();
    String newText = e.getText();
    if (newText == null) newText = new String();

    if (start == end) {
        // no replace / delete / overwrite
        if (newText.length() == 1) return new Change(TypingRun.INSERT, end + 1);
    } else if (start == end - 1) {
        if (newText.length() == 1) return new Change(TypingRun.OVERTYPE, end);
        if (newText.length() == 0) return new Change(TypingRun.DELETE, start);
    }

    return new Change(TypingRun.UNKNOWN, -1);
}
项目:bts    文件:EmbeddedEditorFactory.java   
protected OperationHistoryListener installUndoRedoSupport(SourceViewer viewer, IDocument document, final EmbeddedEditorActions actions) {
            IDocumentUndoManager undoManager = DocumentUndoManagerRegistry.getDocumentUndoManager(document);
            final IUndoContext context = undoManager.getUndoContext();

            // XXX cp uncommented

//          IOperationHistory operationHistory = PlatformUI.getWorkbench().getOperationSupport().getOperationHistory();
            OperationHistoryListener operationHistoryListener = new OperationHistoryListener(context, new IUpdate() {
                public void update() {
                    actions.updateAction(ITextEditorActionConstants.REDO);
                    actions.updateAction(ITextEditorActionConstants.UNDO);
                }
            });
            viewer.addTextListener(new ITextListener() {

                public void textChanged(TextEvent event) {
                    actions.updateAction(ITextEditorActionConstants.REDO);
                    actions.updateAction(ITextEditorActionConstants.UNDO);

                }
            });
//          
//          operationHistory.addOperationHistoryListener(operationHistoryListener);
            return operationHistoryListener;
        }
项目:PDFReporter-Studio    文件:XMLEditor.java   
/**
 * When the editor is graphically created then add a text change listener
 * to the viewer
 */
@Override
public void createPartControl(Composite parent) {
    super.createPartControl(parent);
    getSourceViewer().addTextListener(new ITextListener() {

        @Override
        public void textChanged(TextEvent event) {
            if (outlinePage != null) {
                String text = getSourceViewer().getTextWidget().getText();
                try{
                    outlinePage.setInput(text);
                }catch(Exception ex){

                }
            }
        }
    });
}
项目:APICloud-Studio    文件:CommonLineNumberRulerColumn.java   
public void textChanged(TextEvent event) {

            fCachedRedrawState= event.getViewerRedrawState();
            if (!fCachedRedrawState)
                return;

            if (updateNumberOfDigits()) {
                computeIndentations();
                layout(event.getViewerRedrawState());
                return;
            }

            boolean viewerCompletelyShown= isViewerEntirelyShown();
            if (viewerCompletelyShown || fSensitiveToTextChanges || event.getDocumentEvent() == null)
                doPostRedraw();
            fSensitiveToTextChanges= viewerCompletelyShown;
        }
项目:Eclipse-Postfix-Code-Completion    文件:TypingRunDetector.java   
/**
 * Computes the change abstraction given a text event.
 *
 * @param event the text event to analyze
 * @return a change object describing the event
 */
private Change computeChange(TextEvent event) {
    DocumentEvent e= event.getDocumentEvent();
    if (e == null)
        return new Change(TypingRun.NO_CHANGE, -1);

    int start= e.getOffset();
    int end= e.getOffset() + e.getLength();
    String newText= e.getText();
    if (newText == null)
        newText= new String();

    if (start == end) {
        // no replace / delete / overwrite
        if (newText.length() == 1)
            return new Change(TypingRun.INSERT, end + 1);
    } else if (start == end - 1) {
        if (newText.length() == 1)
            return new Change(TypingRun.OVERTYPE, end);
        if (newText.length() == 0)
            return new Change(TypingRun.DELETE, start);
    }

    return new Change(TypingRun.UNKNOWN, -1);
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:TypingRunDetector.java   
/**
 * Computes the change abstraction given a text event.
 *
 * @param event the text event to analyze
 * @return a change object describing the event
 */
private Change computeChange(TextEvent event) {
    DocumentEvent e= event.getDocumentEvent();
    if (e == null)
        return new Change(TypingRun.NO_CHANGE, -1);

    int start= e.getOffset();
    int end= e.getOffset() + e.getLength();
    String newText= e.getText();
    if (newText == null)
        newText= new String();

    if (start == end) {
        // no replace / delete / overwrite
        if (newText.length() == 1)
            return new Change(TypingRun.INSERT, end + 1);
    } else if (start == end - 1) {
        if (newText.length() == 1)
            return new Change(TypingRun.OVERTYPE, end);
        if (newText.length() == 0)
            return new Change(TypingRun.DELETE, start);
    }

    return new Change(TypingRun.UNKNOWN, -1);
}
项目:n4js    文件:WizardPreviewProvider.java   
private void configureSourceViewer(SourceViewer viewer) {
    viewer.setEditable(false);

    viewer.addTextListener(new ITextListener() {
        @Override
        public void textChanged(TextEvent event) {
            updateHighlighting();
            sourceViewer.getTextWidget().setFont(editorFont);
        }
    });

}
项目:tm4e    文件:TMPresentationReconciler.java   
/**
 * Translates the given text event into the corresponding range of the viewer's
 * document.
 * 
 * @param e
 *            the text event
 * @return the widget region corresponding the region of the given event or
 *         <code>null</code> if none
 * @since 2.1
 */
private IRegion widgetRegion2ModelRegion(TextEvent e) {

    String text = e.getText();
    int length = text == null ? 0 : text.length();

    if (viewer instanceof ITextViewerExtension5) {
        ITextViewerExtension5 extension = (ITextViewerExtension5) viewer;
        return extension.widgetRange2ModelRange(new Region(e.getOffset(), length));
    }

    IRegion visible = viewer.getVisibleRegion();
    IRegion region = new Region(e.getOffset() + visible.getOffset(), length);
    return region;
}
项目:tm4e    文件:TMPresentationReconcilerTestGenerator.java   
@Override
public void textChanged(TextEvent event) {
    if (event.getDocumentEvent() != null) {
        return;
    }

    String command = "viewer.invalidateTextPresentation(" + event.getOffset() + ", " + event.getLength() + ");";
    write("\t\t" + command, true);

    //commands.add(new Command(command));

}
项目:typescript.java    文件:RenameInformationPopup.java   
@Override
public void textChanged(TextEvent event) {
    if (!event.getViewerRedrawState())
        return;
    updatePopupLocation(false);
    updateVisibility(); //only for hiding outside editor area
}
项目:Pydev    文件:CopiedOverviewRuler.java   
@Override
public void textChanged(TextEvent e) {
    if (fTextViewer != null && e.getDocumentEvent() == null && e.getViewerRedrawState()) {
        // handle only changes of visible document
        redraw();
    }
}
项目:tm4e    文件:TMPresentationReconciler.java   
@Override
public void textChanged(TextEvent e) {
    if (!e.getViewerRedrawState()) {
        return;
    }
    // changed text: propagate previous style, which will be overridden
    // later asynchronously by TM
    if (e.getDocumentEvent() != null) {
        int diff = e.getText().length() - e.getLength();
        if (diff > 0 && e.getOffset() > 0) {
            StyleRange range = viewer.getTextWidget().getStyleRangeAtOffset(e.getOffset() - 1);
            if (range != null) {
                range.length += diff;
                viewer.getTextWidget().setStyleRange(range);
            }
        }
    } else { // TextViewer#invalidateTextPresentation is called (because
                // of validation, folding, etc)
        // case 2), do the colorization.
        IDocument document = viewer.getDocument();
        if (document != null) {
            IRegion region = null;
            int fromLineNumber = -1;
            int toLineNumber = -1;
            if (e.getOffset() == 0 && e.getLength() == 0 && e.getText() == null) {
                // redraw state change, damage the whole document
                fromLineNumber = 0;
                toLineNumber = document.getNumberOfLines() - 1;
            } else {
                region = widgetRegion2ModelRegion(e);
                if (region != null) {
                    if (region.getLength() == 0) {
                        // Some text was removed, don't colorize it.
                        return;
                    }
                    try {
                        String text = document.get(region.getOffset(), region.getLength());
                        DocumentEvent de = new DocumentEvent(document, region.getOffset(), region.getLength(),
                                text);
                        fromLineNumber = DocumentHelper.getStartLine(de);
                        toLineNumber = DocumentHelper.getEndLine(de, false);
                    } catch (BadLocationException x) {
                    }
                }
            }
            if (enabled) {
                // case where there is grammar & theme -> update text presentation with the
                // grammar tokens
                ITMModel model = getTMModelManager().connect(document);
                colorize(fromLineNumber, toLineNumber, region, (TMDocumentModel) model);
            } else {
                if (region != null) {
                    // case where there is no grammar & theme -> update text presentation with the
                    // default styles (ex: to support highlighting with GenericEditor)
                    TextPresentation presentation = new TextPresentation(region, 100);
                    presentation.setDefaultStyleRange(
                            new StyleRange(region.getOffset(), region.getLength(), null, null));
                    applyTextRegionCollection(presentation);
                }
            }
        }
    }
}
项目:JAADAS    文件:SootResourceManager.java   
public void textChanged(TextEvent e){
}
项目:tlaplus    文件:DirtyMarkingListener.java   
public void textChanged(TextEvent event)
{
    perform();
}
项目:fluentmark    文件:FluentMkPreview.java   
@Override
public void textChanged(TextEvent event) {
    viewjob.update();
}
项目:fluentmark    文件:TypingRunDetector.java   
@Override
public void textChanged(TextEvent event) {
    handleTextChanged(event);
}
项目:velocity-edit    文件:VelocityEditor.java   
public void textChanged(TextEvent event) {
    try {
        if (null != event.getText()) {
            if (event.getText().length() == 0) {
                validateInput(false);
                refreshOutline();
            }
            if (event.getText().length() == 1) {
                for (int i = 0; i < chars.length; i++) {
                    if (event.getText().equals(chars[i])) {
                        validateInput(false);
                        break;
                    }
                }
                try {
                    int offset = getCursorOffset();
                    ITypedRegion region = (ITypedRegion) getRegion(offset-1);
                    IDirective directive = DirectiveFactory.getDirective(region.getType(), region, getSourceViewer().getDocument());
                    if (null != directive) {
                        refreshOutline();
                        return;
                    }
                }
                catch (Exception e1) {}
                if (event.getText().equals("\n") || event.getText().equals("d")
                        || event.getText().equals(")")
                        || event.getText().equals(">")
                        || event.getText().equals("\"")) {
                    refreshOutline();
                }
            } else {
                for (int i = 0; i < chars.length; i++) {
                    if (event.getText().indexOf(chars[i]) >= 0) {
                        validateInput(false);
                        refreshOutline();
                        break;
                    }
                }
                if (event.getText().indexOf("\n") >= 0
                        || event.getText().indexOf(")") >= 0) {
                    refreshOutline();
                }
            }
        } else {
            refreshOutline();
        }
    }
    catch (Throwable t) {}
}
项目:Eclipse-Postfix-Code-Completion    文件:RenameInformationPopup.java   
public void textChanged(TextEvent event) {
    if (!event.getViewerRedrawState())
        return;
    updatePopupLocation(false);
    updateVisibility(); //only for hiding outside editor area
}
项目:Eclipse-Postfix-Code-Completion    文件:TypingRunDetector.java   
public void textChanged(TextEvent event) {
    handleTextChanged(event);
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:RenameInformationPopup.java   
public void textChanged(TextEvent event) {
    if (!event.getViewerRedrawState())
        return;
    updatePopupLocation(false);
    updateVisibility(); //only for hiding outside editor area
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:TypingRunDetector.java   
public void textChanged(TextEvent event) {
    handleTextChanged(event);
}
项目:birt    文件:ReportXMLSourceEditorFormPage.java   
public void createPartControl( Composite parent )
{
    reportXMLEditor.createPartControl( parent );
    Control[] children = parent.getChildren( );
    control = children[children.length - 1];

    ModuleHandle model = getModel( );

    // suport the mediator
    SessionHandleAdapter.getInstance( )
            .getMediator( model )
            .addColleague( this );

    // Add Command Stack Listener
    if ( model != null && model.getCommandStack( ) != null )
    {
        getCommandStack( model ).addCommandStackListener( getCommandStackListener( ) );
        hookModelEventManager( model );
    }

    reportXMLEditor.getTextViewer( ).addTextListener( new ITextListener( ) {

        public void textChanged( TextEvent event )
        {
            if ( !isTextModified( ) && event.getOffset( ) != 0 )
            {
                markDirty( );
            }
        }
    } );

    reportXMLEditor.getTextViewer( )
            .getTextWidget( )
            .addModifyListener( new ModifyListener( ) {

                public void modifyText( ModifyEvent e )
                {
                    markDirty( );
                }
            } );
}
项目:e4macs    文件:WithMinibuffer.java   
public void textChanged(TextEvent event) {
    if (event.getDocumentEvent() != null)
        leave(true);
}
项目:e4macs    文件:UniversalMinibuffer.java   
public void textChanged(TextEvent event) {
    // During execution of sub-command, text can change
    if (!isExecuting()) {
        super.textChanged(event);
    }
}
项目:e4macs    文件:SearchMinibuffer.java   
public void textChanged(TextEvent event) {
        if (event.getDocumentEvent() != null) {
//          leave();
        }
    }
项目:Pydev    文件:OfflineActionTarget.java   
@Override
public void textChanged(TextEvent event) {
    if (event.getDocumentEvent() != null)
        leave();
}
项目:byteman-editor    文件:BytemanRuleEditor.java   
@Override
public void textChanged(TextEvent event) {
    if(event.getDocumentEvent() != null) {
        validator.resetCount();
    }
}
项目:fluentmark    文件:TypingRunDetector.java   
/**
 * Handles an incoming text event.
 *
 * @param event the text event that describes the text modification
 */
void handleTextChanged(TextEvent event) {
    Change type = computeChange(event);
    handleChange(type);
}
项目:Eclipse-Postfix-Code-Completion    文件:TypingRunDetector.java   
/**
 * Handles an incoming text event.
 *
 * @param event the text event that describes the text modification
 */
void handleTextChanged(TextEvent event) {
    Change type= computeChange(event);
    handleChange(type);
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:TypingRunDetector.java   
/**
 * Handles an incoming text event.
 *
 * @param event the text event that describes the text modification
 */
void handleTextChanged(TextEvent event) {
    Change type= computeChange(event);
    handleChange(type);
}