當前位置: 首頁>>代碼示例>>Java>>正文


Java DocumentEvent.getText方法代碼示例

本文整理匯總了Java中org.eclipse.jface.text.DocumentEvent.getText方法的典型用法代碼示例。如果您正苦於以下問題:Java DocumentEvent.getText方法的具體用法?Java DocumentEvent.getText怎麽用?Java DocumentEvent.getText使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.jface.text.DocumentEvent的用法示例。


在下文中一共展示了DocumentEvent.getText方法的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: 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

示例3: 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

示例4: 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

示例5: 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(HighlightedPosition 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:trylimits,項目名稱:Eclipse-Postfix-Code-Completion,代碼行數:23,代碼來源:SemanticHighlightingPresenter.java

示例6: 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:trylimits,項目名稱:Eclipse-Postfix-Code-Completion,代碼行數:31,代碼來源:TypingRunDetector.java

示例7: getDamageRegion

import org.eclipse.jface.text.DocumentEvent; //導入方法依賴的package包/類
public IRegion getDamageRegion(final ITypedRegion partition, final DocumentEvent e,
        final boolean documentPartitioningChanged) {
    if (!documentPartitioningChanged) {
        String source = fDocument.get();
        int start = source.substring(0, e.getOffset()).lastIndexOf("/*");
        if (start == -1) {
            start = 0;
        }
        int end = source.indexOf("*/", e.getOffset());
        int end2 = e.getOffset() + (e.getText() == null ? e.getLength() : e.getText().length());
        if (end == -1) {
            end = source.length();
        } else if (end2 > end) {
            end = end2;
        } else {
            end++;
        }

        return new Region(start, end - start);
    }
    return partition;
}
 
開發者ID:apache,項目名稱:syncope,代碼行數:23,代碼來源:JavaScriptDamagerRepairer.java

示例8: getDamageRegion

import org.eclipse.jface.text.DocumentEvent; //導入方法依賴的package包/類
public IRegion getDamageRegion(final ITypedRegion partition, final DocumentEvent e,
        final boolean documentPartitioningChanged) {
    if (!documentPartitioningChanged) {
        String source = fDocument.get();
        int start = source.substring(0, e.getOffset()).lastIndexOf('<');
        if (start == -1) {
            start = 0;
        }
        int end = source.indexOf('>', e.getOffset());
        int nextEnd = source.indexOf('>', end + 1);
        if (nextEnd >= 0 && nextEnd > end) {
            end = nextEnd;
        }
        int end2 = e.getOffset() + (e.getText() == null ? e.getLength() : e.getText().length());
        if (end == -1) {
            end = source.length();
        } else if (end2 > end) {
            end = end2;
        } else {
            end++;
        }

        return new Region(start, end - start);
    }
    return partition;
}
 
開發者ID:apache,項目名稱:syncope,代碼行數:27,代碼來源:HTMLTagDamagerRepairer.java

示例9: getDamageRegion

import org.eclipse.jface.text.DocumentEvent; //導入方法依賴的package包/類
/**
 * @see IPresentationDamager#getDamageRegion(ITypedRegion, DocumentEvent, boolean)
 */
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 e) {
		}
	}

	return partition;
}
 
開發者ID:xbony2,項目名稱:Minetweaker-IDE,代碼行數:27,代碼來源:NonRuleBasedDamagerRepairer.java

示例10: getDamageRegion

import org.eclipse.jface.text.DocumentEvent; //導入方法依賴的package包/類
/**
 * @see IPresentationDamager#getDamageRegion(ITypedRegion, DocumentEvent, boolean)
 */
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:convertigo,項目名稱:convertigo-eclipse,代碼行數:40,代碼來源:NonRuleBasedDamagerRepairer.java

示例11: documentChanged

import org.eclipse.jface.text.DocumentEvent; //導入方法依賴的package包/類
@Override
     public void documentChanged(DocumentEvent event) 
     {
// This is the part of the code where we format the event (either encounter a ? xxx ? or xxxx? or auto-complete scenario, this will format and isolate
// query in 'line' and search for code snippets using query.
 		String insertion = event.getText();
 		if (insertion == "") return;
 		
 		// Check to see if the document change was an "undo" change.
 		// If it was, make sure we don't make a query again.
 		String check_undo = getLine();
 		check_undo = check_undo.trim();
 		if (check_undo.startsWith("?")) check_undo = check_undo.substring(1);
 		if (check_undo.endsWith("?")) check_undo = check_undo.substring(0, check_undo.length()-1);
 		if (InputHandler.previous_queries.contains(check_undo)) {
	InputHandler.previous_queries.remove(InputHandler.previous_queries.indexOf(check_undo));
	return;
 		}

 		// Check if we have a correctly formatted query.
 		// If the query is formatted correctly, perform the query.
 		if (insertion.length() >= 1)
 		{
 			String line = getLine();
 			String newline = line.trim();
 			if (!(newline.endsWith("?"))) return;
 			doQuery(event,line);
 		}
     }
 
開發者ID:ctreude,項目名稱:nlp2code,代碼行數:30,代碼來源:QueryDocListener.java

示例12: documentChanged

import org.eclipse.jface.text.DocumentEvent; //導入方法依賴的package包/類
@Override
public void documentChanged(DocumentEvent event) {
	String text = event.getText();
	if (!InputHandler.previous_search.contains(text)) {
		IDocument doc = event.getDocument();
		doc.removeDocumentListener(InputHandler.doclistener);
		CycleAnswersHandler.changed_doc = true;
	}
}
 
開發者ID:ctreude,項目名稱:nlp2code,代碼行數:10,代碼來源:CycleDocListener.java

示例13: getDamageRegion

import org.eclipse.jface.text.DocumentEvent; //導入方法依賴的package包/類
/**
 * @see IPresentationDamager#getDamageRegion(ITypedRegion, DocumentEvent, boolean)
 */
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:ncleclipse,項目名稱:ncl30-eclipse,代碼行數:34,代碼來源:NonRuleBasedDamagerRepairer.java

示例14: documentAboutToBeChanged

import org.eclipse.jface.text.DocumentEvent; //導入方法依賴的package包/類
@Override
public void documentAboutToBeChanged(DocumentEvent event) {
	if (isDisableChanged()) {
		return;
	}
	setDirty(true);
	if (getProject().getProjectSettings().getSynchStrategy() == SynchStrategy.CHANGE) {
		synchronized (synchLock) {
			try {
				String newText = event.getText();
				int position = event.getOffset();

				Location loc = getLocation(position);
				int line = loc.getLine();
				int offset = loc.getOffset();

				Location endLoc = getLocation(position + event.getLength());
				int endLine = endLoc.getLine();
				int endOffset = endLoc.getOffset();

				getProject().getClient().changeFile(getName(), line, offset, endLine, endOffset, newText);
			} catch (Throwable e) {
				e.printStackTrace();
			} finally {
				setDirty(false);
				synchLock.notifyAll();
			}
		}
	}
}
 
開發者ID:angelozerr,項目名稱:typescript.java,代碼行數:31,代碼來源:IDETypeScriptFile.java

示例15: updateWithOverEndEvent

import org.eclipse.jface.text.DocumentEvent; //導入方法依賴的package包/類
/**
 * Update the given position with the given event. The event overlaps with the end of the position.
 * 
 * @param position
 *            The position
 * @param event
 *            The event
 */
private void updateWithOverEndEvent(AttributedPosition position, DocumentEvent event) {
	String newText = event.getText();
	if (newText == null)
		newText = ""; //$NON-NLS-1$
	int eventNewLength = newText.length();

	int includedLength = 0;
	while (includedLength < eventNewLength && Character.isJavaIdentifierPart(newText.charAt(includedLength)))
		includedLength++;
	position.setLength(event.getOffset() - position.getOffset() + includedLength);
}
 
開發者ID:cplutte,項目名稱:bts,代碼行數:20,代碼來源:HighlightingPresenter.java


注:本文中的org.eclipse.jface.text.DocumentEvent.getText方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。