当前位置: 首页>>代码示例>>Java>>正文


Java DocumentEvent类代码示例

本文整理汇总了Java中org.eclipse.jface.text.DocumentEvent的典型用法代码示例。如果您正苦于以下问题:Java DocumentEvent类的具体用法?Java DocumentEvent怎么用?Java DocumentEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DocumentEvent类属于org.eclipse.jface.text包,在下文中一共展示了DocumentEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getDamageRegion

import org.eclipse.jface.text.DocumentEvent; //导入依赖的package包/类
@Override
public IRegion getDamageRegion(ITypedRegion partition, DocumentEvent event, boolean documentPartitioningChanged) {
	if (!documentPartitioningChanged) {
		try {

			IRegion info = fDocument.getLineInformationOfOffset(event.getOffset());
			int start = Math.max(partition.getOffset(), info.getOffset());

			int end = event.getOffset() + (event.getText() == null ? event.getLength() : event.getText().length());

			if (info.getOffset() <= end && end <= info.getOffset() + info.getLength()) {
				// optimize the case of the same line
				end = info.getOffset() + info.getLength();
			} else{
				end = endOfLineOf(end);
			}

			end = Math.min(partition.getOffset() + partition.getLength(), end);
			return new Region(start, end - start);

		} catch (BadLocationException x) {
		}
	}

	return partition;
}
 
开发者ID:de-jcup,项目名称:eclipse-batch-editor,代码行数:27,代码来源:PresentationSupport.java

示例2: validate

import org.eclipse.jface.text.DocumentEvent; //导入依赖的package包/类
@Override
public boolean validate(IDocument document, int offset, DocumentEvent event) {
	try {
		String content = document.get(fReplacementPosition.getOffset(), offset - fReplacementPosition.getOffset());
		if (fReplacementString.startsWith(content)) {
			return true;
		} else if (fReplacementString.length() > 0) {
			char c = fReplacementString.charAt(0);
			if ((c == '"' || c == '\'') && fReplacementString.startsWith(c + content)) {
				return true;
			}
		}
	} catch (BadLocationException e) {
		// ignore concurrently modified document
	}
	return false;
}
 
开发者ID:angelozerr,项目名称:ec4e,代码行数:18,代码来源:PositionBasedCompletionProposal.java

示例3: documentChanged

import org.eclipse.jface.text.DocumentEvent; //导入依赖的package包/类
@Override
public void documentChanged(DocumentEvent event) {
	IDocument document = event.getDocument();
	try {
		int startLine = DocumentHelper.getStartLine(event);
		if (!DocumentHelper.isRemove(event)) {
			if (DocumentLineList.this.getSize() != DocumentHelper.getNumberOfLines(document)) {
				int endLine = DocumentHelper.getEndLine(event, false);
				// Insert new lines
				for (int i = startLine; i < endLine; i++) {
					DocumentLineList.this.addLine(i + 1);
				}
			} else {
				// Update line
				DocumentLineList.this.updateLine(startLine);
			}
		} else {
			// Update line
			DocumentLineList.this.updateLine(startLine);
		}
		invalidateLine(startLine);
	} catch (BadLocationException e) {
		e.printStackTrace();
	}
}
 
开发者ID:eclipse,项目名称:tm4e,代码行数:26,代码来源:DocumentLineList.java

示例4: documentChanged

import org.eclipse.jface.text.DocumentEvent; //导入依赖的package包/类
@Override
public void documentChanged(DocumentEvent event) {
	synchronized (monitor) {
		lastDocumentChangeTimeStamp = System.currentTimeMillis();
		if (refreshOutlineInProgress) {
			/*
			 * already marked as refreshOutlineInProgress, nothing to do
			 */
			return;
		}
	}
	if (!r.isListeningToFurtherDocumentChanges()) {
		Thread t = new Thread(r, "waiting-for-keyboard-events");
		t.start();
	}
}
 
开发者ID:de-jcup,项目名称:egradle,代码行数:17,代码来源:AbstractGroovyBasedEditor.java

示例5: documentChanged

import org.eclipse.jface.text.DocumentEvent; //导入依赖的package包/类
public void documentChanged(DocumentEvent event) {
    // if this is enabled
    if ("\"".equals(event.getText())) {
        ITextSelection textSelection = (ITextSelection) this.editor.getSelectionProvider().getSelection();            
        try {
            char prev = document.getChar(textSelection.getOffset() - 1);
            String replacement = "\"";
            // TODO null checks?
            IProject project = ((FileEditorInput)editor.getEditorInput()).getFile().getProject();
            String lang = TexlipseProperties.getProjectProperty(project, TexlipseProperties.LANGUAGE_PROPERTY);
            if (Character.isWhitespace(prev)) {
                replacement = (String) quotes.get(lang + "o");
            } else if (Character.isLetterOrDigit(prev)) {
                replacement = (String) quotes.get(lang + "c");
            } else {
                return;
            }
            document.removeDocumentListener(this);
            document.replace(textSelection.getOffset(), 1, replacement);
            document.addDocumentListener(this);
            //editor.resetHighlightRange();
            //editor.setHighlightRange(textSelection.getOffset() + 1, 1, true);
            //editor.getSelectionProvider().setSelection(new TextSelection(textSelection.getOffset() + 3, 5));
        } catch (BadLocationException e) {}
    }
}
 
开发者ID:eclipse,项目名称:texlipse,代码行数:27,代码来源:TexQuoteListener.java

示例6: updateTextListeners

import org.eclipse.jface.text.DocumentEvent; //导入依赖的package包/类
/**
 * 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);
    }
  }
}
 
开发者ID:dsldevkit,项目名称:dsl-devkit,代码行数:24,代码来源:FixedXtextSourceViewer.java

示例7: computeChange

import org.eclipse.jface.text.DocumentEvent; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:grosenberg,项目名称:fluentmark,代码行数:26,代码来源:TypingRunDetector.java

示例8: getRepairEntryData

import org.eclipse.jface.text.DocumentEvent; //导入依赖的package包/类
/**
 * @since 2.4
 */
@Override
protected RepairEntryData getRepairEntryData(DocumentEvent e) throws Exception {
	int tokenStartsAt = 0;
	int tokenInfoIdx = 0;
	TokenSource source = createTokenSource(e.fDocument.get());
	CommonToken token = (CommonToken) source.nextToken();
	// find start idx
	while (true) {
		if (token == Token.EOF_TOKEN) {
			break;
		}
		if (tokenInfoIdx >= getInternalModifyableTokenInfos().size())
			break;
		TokenInfo tokenInfo = getInternalModifyableTokenInfos().get(tokenInfoIdx);
		if (tokenInfo.getAntlrTokenType() != token.getType()
				|| token.getStopIndex() - token.getStartIndex() + 1 != tokenInfo.getLength())
			break;
		if (tokenStartsAt + tokenInfo.getLength() > e.fOffset)
			break;
		tokenStartsAt += tokenInfo.getLength();
		tokenInfoIdx++;
		token = (CommonToken) source.nextToken();
	}
	return new RepairEntryData(tokenStartsAt, tokenInfoIdx, token, source);
}
 
开发者ID:cplutte,项目名称:bts,代码行数:29,代码来源:BacktrackingLexerDocumentTokenSource.java

示例9: updateWithOverStartEvent

import org.eclipse.jface.text.DocumentEvent; //导入依赖的package包/类
/**
 * Update the given position with the given event. The event overlaps with the start of the position.
 * 
 * @param position
 *            The position
 * @param event
 *            The event
 */
private void updateWithOverStartEvent(AttributedPosition position, DocumentEvent event) {
	int eventOffset = event.getOffset();
	int eventEnd = eventOffset + event.getLength();

	String newText = event.getText();
	if (newText == null)
		newText = ""; //$NON-NLS-1$
	int eventNewLength = newText.length();

	int excludedLength = eventNewLength;
	while (excludedLength > 0 && Character.isJavaIdentifierPart(newText.charAt(excludedLength - 1)))
		excludedLength--;
	int deleted = eventEnd - position.getOffset();
	int inserted = eventNewLength - excludedLength;
	position.update(eventOffset + excludedLength, position.getLength() - deleted + inserted);
}
 
开发者ID:cplutte,项目名称:bts,代码行数:25,代码来源:HighlightingPresenter.java

示例10: getRanges

import org.eclipse.jface.text.DocumentEvent; //导入依赖的package包/类
public List<StyleRange> getRanges(String expression) {
	final List<StyleRange> ranges = Lists.newArrayList();
	DocumentEvent event = new DocumentEvent();
	event.fDocument = new DummyDocument(expression);
	DocumentTokenSource tokenSource = tokenSourceProvider.get();
	tokenSource.updateStructure(event);
	Iterator<ILexerTokenRegion> iterator = tokenSource.getTokenInfos().iterator();
	while (iterator.hasNext()) {
		ILexerTokenRegion next = iterator.next();
		TextAttribute attribute = attributeProvider.getAttribute(tokenTypeMapper.getId(next.getLexerTokenType()));
		StyleRange range = new StyleRange(next.getOffset(), next.getLength(), attribute.getForeground(),
				attribute.getBackground());
		range.font = attribute.getFont();
		range.fontStyle = attribute.getStyle();
		ranges.add(range);
	}
	return ranges;
}
 
开发者ID:Yakindu,项目名称:statecharts,代码行数:19,代码来源:StyleRanges.java

示例11: fileChanged

import org.eclipse.jface.text.DocumentEvent; //导入依赖的package包/类
public void fileChanged(final char[] content, final boolean isFirstTimeRead) {
       Runnable runnable = new Runnable() {
           public void run() {
       		String text = new String(content);
       		int offset = calculateBacklogOffset();
   			String currentText = getStore().get(offset,getStore().getLength() - offset);
       		currentText = currentText.concat(text);
       		getStore().set(currentText);
       		getTracker().set(currentText);
       		if(isFirstTimeRead) {
       			offset = calculateBacklogOffset();
       			currentText = getStore().get(offset,getStore().getLength() - offset);
       			getStore().set(currentText);
       			getTracker().set(currentText);
       		}
       		//int newOffset = getStore().getLength() > content.length ? getStore().getLength() - content.length : 0;
       		DocumentEvent event = new DocumentEvent(LogDocument.this, getStore().getLength(), content.length, text);
       		fireDocumentChanged(event);
           }
       };
       if(Display.getDefault() != null) {
           Display.getDefault().asyncExec(runnable);
       }
}
 
开发者ID:anb0s,项目名称:LogViewer,代码行数:25,代码来源:LogDocument.java

示例12: getDamageRegion

import org.eclipse.jface.text.DocumentEvent; //导入依赖的package包/类
public IRegion getDamageRegion(ITypedRegion partition, DocumentEvent event, boolean documentPartitioningChanged) {
    if (!documentPartitioningChanged) {
        try {

            IRegion info= document.getLineInformationOfOffset(event.getOffset());
            int start= Math.max(partition.getOffset(), info.getOffset());

            int end= event.getOffset() + (event.getText() == null ? event.getLength() : event.getText().length());

            if (info.getOffset() <= end && end <= info.getOffset() + info.getLength()) {
                // optimize the case of the same line
                end= info.getOffset() + info.getLength();
            } else
                end= endOfLineOf(end);

            end= Math.min(partition.getOffset() + partition.getLength(), end);
            return new Region(start, end - start);

        } catch (BadLocationException x) {
            logger.logInfo("unable to find location in document to repair a given region",x); //$NON-NLS-1$
        }
    }
    return partition;
}
 
开发者ID:anb0s,项目名称:LogViewer,代码行数:25,代码来源:DamageRepairer.java

示例13: validate

import org.eclipse.jface.text.DocumentEvent; //导入依赖的package包/类
public boolean validate(IDocument document, int offset, DocumentEvent event) {
  try {
    int replaceOffset = getReplaceOffset();
    if (offset >= replaceOffset) {
      String content = document.get(replaceOffset, offset - replaceOffset);
      String templateName = fTemplate.getName().toLowerCase();
      boolean valid = templateName.startsWith(content.toLowerCase());
      if (!valid
          && fContext instanceof JavaDocContext
          && templateName.startsWith("<")) { // $NON-NLS-1$
        valid = templateName.startsWith(content.toLowerCase(), 1);
      }
      return valid;
    }
  } catch (BadLocationException e) {
    // concurrent modification - ignore
  }
  return false;
}
 
开发者ID:eclipse,项目名称:che,代码行数:20,代码来源:TemplateProposal.java

示例14: documentChanged

import org.eclipse.jface.text.DocumentEvent; //导入依赖的package包/类
public void documentChanged(DocumentEvent event)
{
    if ((fRememberedPosition != null) && !fRememberedPosition.isDeleted())
    {
        event.getDocument().removePosition(fRememberedPosition);
        fActiveRegion = new Region(fRememberedPosition.getOffset(), fRememberedPosition.getLength());
    }
    fRememberedPosition = null;
    ISourceViewer viewer = getSourceViewer();
    if (viewer != null)
    {
        StyledText widget = viewer.getTextWidget();
        if ((widget != null) && !widget.isDisposed())
        {
            widget.getDisplay().asyncExec(new Runnable() {

                public void run()
                {
                    deactivate();
                }
            });
        }
    }
}
 
开发者ID:ninneko,项目名称:velocity-edit,代码行数:25,代码来源:VelocityEditor.java

示例15: documentChanged

import org.eclipse.jface.text.DocumentEvent; //导入依赖的package包/类
@Override
public void documentChanged(DocumentEvent event) {
    if (event.getDocument() instanceof JsonDocument) {
        final JsonDocument document = (JsonDocument) event.getDocument();

        Display.getCurrent().asyncExec(new Runnable() {
            @Override
            public void run() {
                document.onChange();
                if (contentOutline != null) {
                    contentOutline.setInput(getEditorInput());
                }
                runValidate(false);
            }
        });
    }
}
 
开发者ID:RepreZen,项目名称:KaiZen-OpenAPI-Editor,代码行数:18,代码来源:JsonEditor.java


注:本文中的org.eclipse.jface.text.DocumentEvent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。