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


Java TextAttribute類代碼示例

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


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

示例1: BatchSourceViewerConfiguration

import org.eclipse.jface.text.TextAttribute; //導入依賴的package包/類
/**
 * Creates configuration by given adaptable
 * 
 * @param adaptable
 *            must provide {@link ColorManager} and {@link IFile}
 */
public BatchSourceViewerConfiguration(IAdaptable adaptable) {
	IPreferenceStore generalTextStore = EditorsUI.getPreferenceStore();
	this.fPreferenceStore = new ChainedPreferenceStore(
			new IPreferenceStore[] { getPreferences().getPreferenceStore(), generalTextStore });

	Assert.isNotNull(adaptable, "adaptable may not be null!");
	this.annotationHoover = new BatchEditorAnnotationHoover();
	
	this.contentAssistant = new ContentAssistant();
	contentAssistProcessor = new BatchEditorSimpleWordContentAssistProcessor();
	contentAssistant.enableColoredLabels(true);
	
	contentAssistant.setContentAssistProcessor(contentAssistProcessor, IDocument.DEFAULT_CONTENT_TYPE);
	for (BatchDocumentIdentifier identifier: BatchDocumentIdentifiers.values()){
		contentAssistant.setContentAssistProcessor(contentAssistProcessor, identifier.getId());
	}
	
	contentAssistant.addCompletionListener(contentAssistProcessor.getCompletionListener());

	this.colorManager = adaptable.getAdapter(ColorManager.class);
	Assert.isNotNull(colorManager, " adaptable must support color manager");
	this.defaultTextAttribute = new TextAttribute(
			colorManager.getColor(getPreferences().getColor(COLOR_NORMAL_TEXT)));
	this.adaptable=adaptable;
}
 
開發者ID:de-jcup,項目名稱:eclipse-batch-editor,代碼行數:32,代碼來源:BatchSourceViewerConfiguration.java

示例2: BashSourceViewerConfiguration

import org.eclipse.jface.text.TextAttribute; //導入依賴的package包/類
/**
 * Creates configuration by given adaptable
 * 
 * @param adaptable
 *            must provide {@link ColorManager} and {@link IFile}
 */
public BashSourceViewerConfiguration(IAdaptable adaptable) {
	IPreferenceStore generalTextStore = EditorsUI.getPreferenceStore();
	this.fPreferenceStore = new ChainedPreferenceStore(
			new IPreferenceStore[] { getPreferences().getPreferenceStore(), generalTextStore });

	Assert.isNotNull(adaptable, "adaptable may not be null!");
	this.annotationHoover = new BashEditorAnnotationHoover();
	
	this.contentAssistant = new ContentAssistant();
	contentAssistProcessor = new BashEditorSimpleWordContentAssistProcessor();
	contentAssistant.enableColoredLabels(true);
	
	contentAssistant.setContentAssistProcessor(contentAssistProcessor, IDocument.DEFAULT_CONTENT_TYPE);
	for (BashDocumentIdentifier identifier: BashDocumentIdentifiers.values()){
		contentAssistant.setContentAssistProcessor(contentAssistProcessor, identifier.getId());
	}
	
	contentAssistant.addCompletionListener(contentAssistProcessor.getCompletionListener());

	this.colorManager = adaptable.getAdapter(ColorManager.class);
	Assert.isNotNull(colorManager, " adaptable must support color manager");
	this.defaultTextAttribute = new TextAttribute(
			colorManager.getColor(getPreferences().getColor(COLOR_NORMAL_TEXT)));
	this.adaptable=adaptable;
}
 
開發者ID:de-jcup,項目名稱:eclipse-bash-editor,代碼行數:32,代碼來源:BashSourceViewerConfiguration.java

示例3: ModelScanner

import org.eclipse.jface.text.TextAttribute; //導入依賴的package包/類
public ModelScanner(final ColorManager colorManager) {

    final IToken bracketsToken =
        new Token(new TextAttribute(colorManager.getColor(IValidationColorConstants.BRACKETS)));
    final IToken commToken =
        new Token(new TextAttribute(colorManager.getColor(IValidationColorConstants.COMMENT)));

    final List<IRule> rules = new ArrayList<>();

    rules.add(new WhitespaceRule(new ValidationWhitespaceDetector()));
    rules.add(new BracketsRule(bracketsToken));
    rules.add(new MultiLineRule("/**", "**/", commToken));
    rules.add(new EndOfLineRule("--", commToken));

    final IRule[] result = new IRule[rules.size()];
    rules.toArray(result);
    this.setRules(result);
  }
 
開發者ID:ModelWriter,項目名稱:Tarski,代碼行數:19,代碼來源:ModelScanner.java

示例4: XMLTextScanner

import org.eclipse.jface.text.TextAttribute; //導入依賴的package包/類
public XMLTextScanner( ColorManager colorManager) {

      ESCAPED_CHAR = new Token(new TextAttribute(colorManager.getColor(IXMLColorConstants.ESCAPED_CHAR)));
      CDATA_START = new Token(new TextAttribute(colorManager.getColor(IXMLColorConstants.CDATA)));
      CDATA_END = new Token(new TextAttribute(colorManager.getColor(IXMLColorConstants.CDATA)));
      CDATA_TEXT = new Token(new TextAttribute(colorManager.getColor(IXMLColorConstants.CDATA_TEXT)));
      IRule[] rules = new IRule[2];

      // Add rule to pick up escaped chars
      // Add rule to pick up start of CDATA section
      rules[0] = new CDataRule(CDATA_START, true);
      // Add a rule to pick up end of CDATA sections
      rules[1] = new CDataRule(CDATA_END, false);
      setRules(rules);

   }
 
開發者ID:nextinterfaces,項目名稱:http4e,代碼行數:17,代碼來源:XMLTextScanner.java

示例5: TexArgScanner

import org.eclipse.jface.text.TextAttribute; //導入依賴的package包/類
/**
 * A default constructor.
 * @param manager
 */
public TexArgScanner(ColorManager manager) {
    IToken commentToken = new Token(new TextAttribute(manager
            .getColor(ColorManager.COMMENT),
            null,
            manager.getStyle(ColorManager.COMMENT_STYLE)));

    //Commands are colored in argument color with command styles 
    IToken commandToken = new Token(
            new TextAttribute(
                    manager.getColor(ColorManager.CURLY_BRACKETS),
                    null,
                    manager.getStyle(ColorManager.COMMAND_STYLE)));

    List<IRule> rules = new ArrayList<IRule>();
    rules.add(new EndOfLineRule("%", commentToken, '\\'));
    rules.add(new WhitespaceRule(new WhitespaceDetector()));
    rules.add(new WordRule(new TexWord(), commandToken));

    IRule[] result = new IRule[rules.size()];
    rules.toArray(result);
    setRules(result);
}
 
開發者ID:eclipse,項目名稱:texlipse,代碼行數:27,代碼來源:TexArgScanner.java

示例6: TexOptArgScanner

import org.eclipse.jface.text.TextAttribute; //導入依賴的package包/類
/**
 * A default constructor.
 * @param manager
 */
public TexOptArgScanner(ColorManager manager) {
    IToken commentToken = new Token(new TextAttribute(manager
            .getColor(ColorManager.COMMENT),
            null,
            manager.getStyle(ColorManager.COMMENT_STYLE)));

    //Commands are colored in argument color with command styles 
    IToken commandToken = new Token(
            new TextAttribute(
                    manager.getColor(ColorManager.SQUARE_BRACKETS),
                    null,
                    manager.getStyle(ColorManager.COMMAND_STYLE)));

    List<IRule> rules = new ArrayList<IRule>();
    rules.add(new EndOfLineRule("%", commentToken, '\\'));
    rules.add(new WhitespaceRule(new WhitespaceDetector()));
    rules.add(new WordRule(new TexWord(), commandToken));

    IRule[] result = new IRule[rules.size()];
    rules.toArray(result);
    setRules(result);
}
 
開發者ID:eclipse,項目名稱:texlipse,代碼行數:27,代碼來源:TexOptArgScanner.java

示例7: XMLTextScanner

import org.eclipse.jface.text.TextAttribute; //導入依賴的package包/類
public XMLTextScanner(ColorManager colorManager) {

		ESCAPED_CHAR = new Token(new TextAttribute(colorManager
				.getColor(IXMLColorConstants.ESCAPED_CHAR)));
		CDATA_START = new Token(new TextAttribute(colorManager
				.getColor(IXMLColorConstants.CDATA)));
		CDATA_END = new Token(new TextAttribute(colorManager
				.getColor(IXMLColorConstants.CDATA)));
		CDATA_TEXT = new Token(new TextAttribute(colorManager
				.getColor(IXMLColorConstants.CDATA_TEXT)));
		IRule[] rules = new IRule[2];

		// Add rule to pick up escaped chars
		// Add rule to pick up start of CDATA section
		//rules[0] = new CDataRule(CDATA_START, true);
		// Add a rule to pick up end of CDATA sections
		//rules[1] = new CDataRule(CDATA_END, false);
		setRules(rules);

	}
 
開發者ID:ncleclipse,項目名稱:ncl30-eclipse,代碼行數:21,代碼來源:XMLTextScanner.java

示例8: XMLTagScanner

import org.eclipse.jface.text.TextAttribute; //導入依賴的package包/類
public XMLTagScanner(ColorManager manager) {
	IToken string = new Token(new TextAttribute(manager
			.getColor(IXMLColorConstants.STRING)));

	IToken attrValue = new Token(XML_ATTR_VALUE);

	IRule[] rules = new IRule[3];

	// Add rule for double quotes
	rules[0] = new SingleLineRule("\"", "\"", string, '\\');
	// Add a rule for single quotes
	rules[1] = new SingleLineRule("'", "'", string, '\\');
	// Add generic whitespace rule.
	rules[2] = new WhitespaceRule(new NCLWhitespaceDetector());

	setRules(rules);
}
 
開發者ID:ncleclipse,項目名稱:ncl30-eclipse,代碼行數:18,代碼來源:XMLTagScanner.java

示例9: adaptToColorChange

import org.eclipse.jface.text.TextAttribute; //導入依賴的package包/類
private void adaptToColorChange(Token token, PropertyChangeEvent event) {
	RGB rgb = null;

	Object value = event.getNewValue();
	if (value instanceof RGB) {
		rgb = (RGB) value;
	} else if (value instanceof String) {
		rgb = StringConverter.asRGB((String) value);
	}

	if (rgb != null) {

		String property = event.getProperty();
		Color color = colorMgr.getColor(property);
		if (!rgb.equals(color.getRGB())) {
			colorMgr.setValue(property, rgb);
			color = colorMgr.getColor(property);
		}

		Object data = token.getData();
		if (data instanceof TextAttribute) {
			TextAttribute oldAttr = (TextAttribute) data;
			token.setData(new TextAttribute(color, oldAttr.getBackground(), oldAttr.getStyle()));
		}
	}
}
 
開發者ID:grosenberg,項目名稱:fluentmark,代碼行數:27,代碼來源:AbstractBufferedRuleBasedScanner.java

示例10: adaptToStyleChange

import org.eclipse.jface.text.TextAttribute; //導入依賴的package包/類
private void adaptToStyleChange(Token token, PropertyChangeEvent event, int styleAttribute) {
	boolean eventValue = false;
	Object value = event.getNewValue();
	if (value instanceof Boolean)
		eventValue = ((Boolean) value).booleanValue();
	else if (IPreferenceStore.TRUE.equals(value)) eventValue = true;

	Object data = token.getData();
	if (data instanceof TextAttribute) {
		TextAttribute oldAttr = (TextAttribute) data;
		boolean activeValue = (oldAttr.getStyle() & styleAttribute) == styleAttribute;
		if (activeValue != eventValue)
			token.setData(new TextAttribute(oldAttr.getForeground(), oldAttr.getBackground(),
					eventValue ? oldAttr.getStyle() | styleAttribute : oldAttr.getStyle() & ~styleAttribute));
	}
}
 
開發者ID:grosenberg,項目名稱:fluentmark,代碼行數:17,代碼來源:AbstractBufferedRuleBasedScanner.java

示例11: getMergedAttributes

import org.eclipse.jface.text.TextAttribute; //導入依賴的package包/類
public TextAttribute getMergedAttributes(String[] ids) {
	if (ids.length < 2)
		throw new IllegalStateException();
	String mergedIds = getMergedIds(ids);
	TextAttribute result = getAttribute(mergedIds);
	if (result == null) {
		for(String id: ids) {
			result = merge(result, getAttribute(id));
		}
		if (result != null)
			attributes.put(mergedIds, result);
		else
			attributes.remove(mergedIds);
	}
	return result;
}
 
開發者ID:cplutte,項目名稱:bts,代碼行數:17,代碼來源:TextAttributeProvider.java

示例12: merge

import org.eclipse.jface.text.TextAttribute; //導入依賴的package包/類
private TextAttribute merge(TextAttribute first, TextAttribute second) {
	if (first == null)
		return second;
	if (second == null)
		return first;
	int style = first.getStyle() | second.getStyle();
	Color fgColor = second.getForeground();
	if (fgColor == null)
		fgColor = first.getForeground();
	Color bgColor = second.getBackground();
	if (bgColor == null)
		bgColor = first.getBackground();
	Font font = second.getFont();
	if (font == null)
		font = first.getFont();
	return new TextAttribute(fgColor, bgColor, style, font);
}
 
開發者ID:cplutte,項目名稱:bts,代碼行數:18,代碼來源:TextAttributeProvider.java

示例13: createPresentation

import org.eclipse.jface.text.TextAttribute; //導入依賴的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

示例14: addRange

import org.eclipse.jface.text.TextAttribute; //導入依賴的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

示例15: UmpleTagScanner

import org.eclipse.jface.text.TextAttribute; //導入依賴的package包/類
public UmpleTagScanner(ColorManager manager) {
	IToken string =
		new Token(
			new TextAttribute(manager.getColor(IUmpleColorConstants.STRING)));

	IRule[] rules = new IRule[3];

	// Add rule for double quotes
	rules[0] = new SingleLineRule("\"", "\"", string, '\\');
	// Add a rule for single quotes
	rules[1] = new SingleLineRule("'", "'", string, '\\');
	// Add generic whitespace rule.
	rules[2] = new WhitespaceRule(new UmpleWhitespaceDetector());

	setRules(rules);
}
 
開發者ID:umple,項目名稱:umple,代碼行數:17,代碼來源:UmpleTagScanner.java


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