當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。