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


Java TextPresentation類代碼示例

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


TextPresentation類屬於org.eclipse.jface.text包,在下文中一共展示了TextPresentation類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: colorize

import org.eclipse.jface.text.TextPresentation; //導入依賴的package包/類
@Override
public void colorize(TextPresentation presentation, Throwable error) {
	add(presentation);
	if (waitForToLineNumber != null) {
		int offset = presentation.getExtent().getOffset() + presentation.getExtent().getLength();
		try {
			if (waitForToLineNumber != document.getLineOfOffset(offset)) {
				return;
			} else {
				waitForToLineNumber = null;
			}
		} catch (BadLocationException e) {
			e.printStackTrace();
		}
	}
	((Command) command).setStyleRanges("[" + currentRanges.toString() + "]");
	synchronized (lock) {
		lock.notifyAll();
	}
}
 
開發者ID:eclipse,項目名稱:tm4e,代碼行數:21,代碼來源:StyleRangesCollector.java

示例2: createUpdateRunnable

import org.eclipse.jface.text.TextPresentation; //導入依賴的package包/類
/**
 * Create a runnable for updating the presentation.
 * <p>
 * NOTE: Called from background thread.
 * </p>
 * 
 * @param textPresentation
 *            the text presentation
 * @param addedPositions
 *            the added positions
 * @param removedPositions
 *            the removed positions
 * @return the runnable or <code>null</code>, if reconciliation should be canceled
 */
public Runnable createUpdateRunnable(final TextPresentation textPresentation,
		List<AttributedPosition> addedPositions, List<AttributedPosition> removedPositions) {
	if (fSourceViewer == null || textPresentation == null)
		return null;

	// TODO: do clustering of positions and post multiple fast runnables
	final AttributedPosition[] added = new AttributedPosition[addedPositions.size()];
	addedPositions.toArray(added);
	final AttributedPosition[] removed = new AttributedPosition[removedPositions.size()];
	removedPositions.toArray(removed);

	if (isCanceled())
		return null;

	Runnable runnable = new Runnable() {
		public void run() {
			updatePresentation(textPresentation, added, removed);
		}
	};
	return runnable;
}
 
開發者ID:cplutte,項目名稱:bts,代碼行數:36,代碼來源:HighlightingPresenter.java

示例3: createPresentation

import org.eclipse.jface.text.TextPresentation; //導入依賴的package包/類
public void createPresentation(TextPresentation presentation, ITypedRegion region) {
    int start= region.getOffset();
    int length= 0;
    boolean firstToken= true;
    TextAttribute attribute = getTokenTextAttribute(Token.UNDEFINED);

    scanner.setRange(document,start,region.getLength());

    while (true) {
        IToken resultToken = scanner.nextToken();
        if (resultToken.isEOF()) {
            break;
        }
        if(resultToken.equals(Token.UNDEFINED)) {
        	continue;
        }
        if (!firstToken) {
        	addRange(presentation,start,length,attribute,true);
        }
        firstToken = false;
        attribute = getTokenTextAttribute(resultToken);
        start = scanner.getTokenOffset();
        length = scanner.getTokenLength();
    }
    addRange(presentation,start,length,attribute,true);
}
 
開發者ID:anb0s,項目名稱:LogViewer,代碼行數:27,代碼來源:DamageRepairer.java

示例4: addRange

import org.eclipse.jface.text.TextPresentation; //導入依賴的package包/類
/**
 * Adds style information to the given text presentation.
 *
 * @param presentation the text presentation to be extended
 * @param offset the offset of the range to be styled
 * @param length the length of the range to be styled
 * @param attr the attribute describing the style of the range to be styled
 * @param wholeLine the boolean switch to declare that the whole line should be colored
 */
private void addRange(TextPresentation presentation, int offset, int length, TextAttribute attr, boolean wholeLine) {
    if (attr != null) {
        int style= attr.getStyle();
        int fontStyle= style & (SWT.ITALIC | SWT.BOLD | SWT.NORMAL);
        if(wholeLine) {
            try {
                int line = document.getLineOfOffset(offset);
                int start = document.getLineOffset(line);
                length = document.getLineLength(line);
                offset = start;
            } catch (BadLocationException e) {
            }
        }
        StyleRange styleRange = new StyleRange(offset,length,attr.getForeground(),attr.getBackground(),fontStyle);
        styleRange.strikeout = (style & TextAttribute.STRIKETHROUGH) != 0;
        styleRange.underline = (style & TextAttribute.UNDERLINE) != 0;
        presentation.addStyleRange(styleRange);
    }
}
 
開發者ID:anb0s,項目名稱:LogViewer,代碼行數:29,代碼來源:DamageRepairer.java

示例5: updatePresentation

import org.eclipse.jface.text.TextPresentation; //導入依賴的package包/類
public String updatePresentation( Drawable drawable, String hoverInfo,
   TextPresentation presentation, int maxWidth, int maxHeight )
{
   ZDebug.print( 5, "updatePresentation( ", drawable, ", ", hoverInfo, ", ", presentation, ", ", maxWidth, ", ", maxHeight, " )" );
  
   HTMLFormat html = new HTMLFormat();
   html.format( hoverInfo );
   
   for( StyleRange style : html.getStyleList() ) {
      presentation.addStyleRange( style );
   }
   
   if( drawable instanceof StyledText ) {
      StyledText styled = (StyledText) drawable;
      styled.setWordWrap( html.isWordWrap() );
      if( !html.isWordWrap() ) {
         SWTUtil.fontPreference( styled, ExternalPreference.FONT_EDITOR_TEXT );
      }
   }
   
   return html.getBuffer();
}
 
開發者ID:brocade,項目名稱:vTM-eclipse,代碼行數:23,代碼來源:TrafficScriptInfoPresenter.java

示例6: setInformation

import org.eclipse.jface.text.TextPresentation; //導入依賴的package包/類
/**
 * @see IInformationControl#setInformation(String)
 */
@SuppressWarnings("deprecation")
public void setInformation(String content) {
	if (fPresenter == null) {
		fText.setText(content);
	} else {
		fPresentation.clear();
		content= fPresenter.updatePresentation(fShell.getDisplay(), content, fPresentation, Math.max(fMaxWidth, 260), fMaxHeight);
		if (content != null) {
			fText.setText(content);
			TextPresentation.applyTextPresentation(fPresentation, fText);
		} else {
			fText.setText("");  //$NON-NLS-1$
		}
	}
}
 
開發者ID:apicloudcom,項目名稱:APICloud-Studio,代碼行數:19,代碼來源:InformationControl.java

示例7: createPresentation

import org.eclipse.jface.text.TextPresentation; //導入依賴的package包/類
/**
 * @see IPresentationRepairer#createPresentation(TextPresentation, ITypedRegion)
 */
public void createPresentation(TextPresentation presentation, ITypedRegion region)
{
	wipeExistingScopes(region);
	synchronized (getLockObject(fDocument))
	{
		try
		{
			fDocument.addPositionCategory(ICommonConstants.SCOPE_CATEGORY);
			fDocument.addPosition(
					ICommonConstants.SCOPE_CATEGORY,
					new TypedPosition(region.getOffset(), region.getLength(), (String) fDefaultTextAttribute
							.getData()));
		}
		catch (Exception e)
		{
			IdeLog.logError(CommonEditorPlugin.getDefault(), e);
		}
	}

	addRange(presentation, region.getOffset(), region.getLength(), getTextAttribute(region));
}
 
開發者ID:apicloudcom,項目名稱:APICloud-Studio,代碼行數:25,代碼來源:NonRuleBasedDamagerRepairer.java

示例8: createPresentation

import org.eclipse.jface.text.TextPresentation; //導入依賴的package包/類
@Override
protected TextPresentation createPresentation(IRegion damage, IDocument document)
{
	if (IdeLog.isInfoEnabled(CommonEditorPlugin.getDefault(), IDebugScopes.PRESENTATION))
	{
		IdeLog.logInfo(
				CommonEditorPlugin.getDefault(),
				MessageFormat
						.format("Initiating presentation reconciling for region at offset {0}, length {1} in document of length {2}", //$NON-NLS-1$
								damage.getOffset(), damage.getLength(), document.getLength()),
				IDebugScopes.PRESENTATION);
	}
	synchronized (this)
	{
		delayedRegions.append(damage);
	}
	try
	{
		return createPresentation(nextDamagedRegion(), document, new NullProgressMonitor());
	}
	finally
	{
		triggerDelayedCreatePresentation();
	}
}
 
開發者ID:apicloudcom,項目名稱:APICloud-Studio,代碼行數:26,代碼來源:CommonPresentationReconciler.java

示例9: updatePresentation

import org.eclipse.jface.text.TextPresentation; //導入依賴的package包/類
/**
 * Update the presentation.
 *
 * @param textPresentation the text presentation
 * @param addedPositions the added positions
 * @param removedPositions the removed positions
 */
private void updatePresentation(TextPresentation textPresentation, List<Position> addedPositions, List<Position> removedPositions) {
	Runnable runnable= fJobPresenter.createUpdateRunnable(textPresentation, addedPositions, removedPositions);
	if (runnable == null)
		return;

	JavaEditor editor= fEditor;
	if (editor == null)
		return;

	IWorkbenchPartSite site= editor.getSite();
	if (site == null)
		return;

	Shell shell= site.getShell();
	if (shell == null || shell.isDisposed())
		return;

	Display display= shell.getDisplay();
	if (display == null || display.isDisposed())
		return;

	display.asyncExec(runnable);
}
 
開發者ID:trylimits,項目名稱:Eclipse-Postfix-Code-Completion,代碼行數:31,代碼來源:SemanticHighlightingReconciler.java

示例10: createUpdateRunnable

import org.eclipse.jface.text.TextPresentation; //導入依賴的package包/類
/**
 * Create a runnable for updating the presentation.
 * <p>
 * NOTE: Called from background thread.
 * </p>
 * @param textPresentation the text presentation
 * @param addedPositions the added positions
 * @param removedPositions the removed positions
 * @return the runnable or <code>null</code>, if reconciliation should be canceled
 */
public Runnable createUpdateRunnable(final TextPresentation textPresentation, List<Position> addedPositions, List<Position> removedPositions) {
	if (fSourceViewer == null || textPresentation == null)
		return null;

	// TODO: do clustering of positions and post multiple fast runnables
	final HighlightedPosition[] added= new SemanticHighlightingManager.HighlightedPosition[addedPositions.size()];
	addedPositions.toArray(added);
	final SemanticHighlightingManager.HighlightedPosition[] removed= new SemanticHighlightingManager.HighlightedPosition[removedPositions.size()];
	removedPositions.toArray(removed);

	if (isCanceled())
		return null;

	Runnable runnable= new Runnable() {
		public void run() {
			updatePresentation(textPresentation, added, removed);
		}
	};
	return runnable;
}
 
開發者ID:trylimits,項目名稱:Eclipse-Postfix-Code-Completion,代碼行數:31,代碼來源:SemanticHighlightingPresenter.java

示例11: adaptTextPresentation

import org.eclipse.jface.text.TextPresentation; //導入依賴的package包/類
protected void adaptTextPresentation(TextPresentation presentation, int offset, int insertLength) {

		int yoursStart= offset;
		int yoursEnd=   offset + insertLength -1;
		yoursEnd= Math.max(yoursStart, yoursEnd);

		Iterator<?> e= presentation.getAllStyleRangeIterator();
		while (e.hasNext()) {

			StyleRange range= (StyleRange) e.next();

			int myStart= range.start;
			int myEnd=   range.start + range.length -1;
			myEnd= Math.max(myStart, myEnd);

			if (myEnd < yoursStart)
				continue;

			if (myStart < yoursStart)
				range.length += insertLength;
			else
				range.start += insertLength;
		}
	}
 
開發者ID:forcedotcom,項目名稱:idecore,代碼行數:25,代碼來源:HTMLTextPresenter.java

示例12: trim

import org.eclipse.jface.text.TextPresentation; //導入依賴的package包/類
private static String trim(StringBuffer buffer, TextPresentation presentation) {

		int length= buffer.length();

		int end= length -1;
		while (end >= 0 && Character.isWhitespace(buffer.charAt(end)))
			-- end;

		if (end == -1)
			return ""; //$NON-NLS-1$

		if (end < length -1)
			buffer.delete(end + 1, length);
		else
			end= length;

		int start= 0;
		while (start < end && Character.isWhitespace(buffer.charAt(start)))
			++ start;

		buffer.delete(0, start);
		presentation.setResultWindow(new Region(start, buffer.length()));
		return buffer.toString();
	}
 
開發者ID:forcedotcom,項目名稱:idecore,代碼行數:25,代碼來源:HTMLTextPresenter.java

示例13: updatePresentation

import org.eclipse.jface.text.TextPresentation; //導入依賴的package包/類
@Override
		public String updatePresentation(Display display, String hoverInfo,
				TextPresentation presentation, int maxWidth, int maxHeight) {
			this.display = display;
			
			
			StringBuilder sb = new StringBuilder();
			try {
				DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
				DocumentBuilder builder = builderFactory.newDocumentBuilder();
//				hoverInfo = Utils.escapeHtml(hoverInfo);
				Document doc = builder.parse(
						new InputSource(new StringReader("<root>" + hoverInfo + "</root>")));
				parseDocument(doc, presentation, sb);
			} catch (Exception e) {
				e.printStackTrace();
				return hoverInfo;
			}
			
			return sb.toString();
		}
 
開發者ID:peq,項目名稱:rustyeclipse,代碼行數:22,代碼來源:RustInformationControl.java

示例14: makeChange

import org.eclipse.jface.text.TextPresentation; //導入依賴的package包/類
private void makeChange(TextPresentation presentation, int point, List<StyleRangeCustom> styles, StringBuilder sb) {
	List<StyleRangeCustom> activeStyles = Lists.newArrayList();
	int end = Integer.MAX_VALUE;
	for (StyleRangeCustom s : styles) {
		if (s.start <= point) {
			if (s.stop > point) {
				activeStyles.add(s);
				end = Math.min(end, s.stop);
			}
		} else {
			end = Math.min(end, s.start);
		}
	}
	if (activeStyles.isEmpty()) {
		return;
	}
	StyleRange range = new StyleRange(point, end - point, null, null);
	for (StyleRangeCustom r : activeStyles) {
		r.style(range);
	}
	presentation.addStyleRange(range);
	
}
 
開發者ID:peq,項目名稱:rustyeclipse,代碼行數:24,代碼來源:RustInformationControl.java

示例15: createInformationPresenter

import org.eclipse.jface.text.TextPresentation; //導入依賴的package包/類
@Override
protected NSISInformationControl.IInformationPresenter createInformationPresenter()
{
    return new WrappingInformationPresenter("\t\t") { //$NON-NLS-1$
        @Override
        public String updatePresentation(Display display, String hoverInfo, TextPresentation presentation,
                int maxWidth, int maxHeight)
        {
            String hoverInfo2 = super.updatePresentation(display, hoverInfo, presentation, maxWidth, maxHeight);
            int n = hoverInfo2.indexOf(' ');
            if (n <= 0)
            {
                n = hoverInfo2.length();
            }
            presentation.addStyleRange(new StyleRange(0, n, display.getSystemColor(SWT.COLOR_INFO_FOREGROUND),
                    display.getSystemColor(SWT.COLOR_INFO_BACKGROUND), SWT.BOLD));
            return hoverInfo2;
        }
    };
}
 
開發者ID:henrikor2,項目名稱:eclipsensis,代碼行數:21,代碼來源:NSISHelpInformationControlCreator.java


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