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


Java Styler类代码示例

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


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

示例1: getStyledText

import org.eclipse.jface.viewers.StyledString.Styler; //导入依赖的package包/类
@Override
public StyledString getStyledText(Context context, Bookmark bookmark) {
	StyledString styledString = super.getStyledText(context, bookmark);
	BookmarkFolder bookmarkFolder = (BookmarkFolder) bookmark;
	BookmarkId bookmarkId = bookmarkFolder.getId();
	Optional<BookmarkMapping> bookmarkMapping = bookmarkMappings.getMapping(bookmarkId);
	if (!bookmarkMapping.isPresent()) {
		return styledString;
	}
	String sharingUser = bookmarkMapping.get().getProperties().get(BookmarkMapping.PROP_SHARING_USER);
	if (sharingUser == null) {
		return styledString;
	}
	Styler styler = stylerProvider.getStyler(null, Display.getCurrent().getSystemColor(SWT.COLOR_DARK_YELLOW),
			null);
	styledString.append(String.format(" [Shared by %s]", sharingUser), styler);
	return styledString;
}
 
开发者ID:cchabanois,项目名称:mesfavoris,代码行数:19,代码来源:GDriveBookmarkFolderLabelProvider.java

示例2: getStyledText

import org.eclipse.jface.viewers.StyledString.Styler; //导入依赖的package包/类
@Override
public StyledString getStyledText(Object element) {
	if (isNormalMethodWrapper(element)) {
		MethodWrapper wrapper= (MethodWrapper)element;
		String decorated= getElementLabel(wrapper);
		
		StyledString styledLabel= super.getStyledText(wrapper.getMember());
		StyledString styledDecorated= StyledCellLabelProvider.styleDecoratedString(decorated, StyledString.COUNTER_STYLER, styledLabel);
		if (isSpecialConstructorNode(wrapper)) {
			decorated= Messages.format(CallHierarchyMessages.CallHierarchyLabelProvider_constructor_label, decorated);
			styledDecorated= StyledCellLabelProvider.styleDecoratedString(decorated, ColoringLabelProvider.INHERITED_STYLER, styledDecorated);
		}
		return styledDecorated;
	}
	
	String specialLabel= getSpecialLabel(element);
	Styler styler= element instanceof RealCallers ? ColoringLabelProvider.INHERITED_STYLER : null;
	return new StyledString(specialLabel, styler);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:20,代码来源:CallHierarchyLabelProvider.java

示例3: markMatchingRegions

import org.eclipse.jface.viewers.StyledString.Styler; //导入依赖的package包/类
private void markMatchingRegions(StyledString string, int index, int[] matchingRegions, Styler styler) {
	if (matchingRegions != null) {
		int offset= -1;
		int length= 0;
		for (int i= 0; i + 1 < matchingRegions.length; i= i + 2) {
			if (offset == -1)
				offset= index + matchingRegions[i];
			
			// Concatenate adjacent regions
			if (i + 2 < matchingRegions.length && matchingRegions[i] + matchingRegions[i + 1] == matchingRegions[i + 2]) {
				length= length + matchingRegions[i + 1];
			} else {
				string.setStyle(offset, length + matchingRegions[i + 1], styler);
				offset= -1;
				length= 0;
			}
		}
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:20,代码来源:FilteredTypesSelectionDialog.java

示例4: getStyledText

import org.eclipse.jface.viewers.StyledString.Styler; //导入依赖的package包/类
/**
 * The default implementation of this returns the styled text label for the given element.
 * @param element
 *            the element to evaluate the styled string for
 * @return the styled string.
 * @since 3.7
 */
public StyledString getStyledText(Object element) {
	IWorkbenchAdapter3 adapter = getAdapter3(element);
	if (adapter == null) {
		// If adapter class doesn't implement IWorkbenchAdapter3 than use
		// StyledString with text of element. Since the output of getText is
		// already decorated, so we don't need to call decorateText again
		// here.
		return new StyledString(getText(element));
	}
	StyledString styledString = adapter.getStyledText(element);
	// Now, re-use any existing decorateText implementation, to decorate
	// this styledString.
	String decorated = decorateText(styledString.getString(), element);
	Styler styler = getDecorationStyle(element);
	return StyledCellLabelProvider.styleDecoratedString(decorated, styler, styledString);
}
 
开发者ID:heartsome,项目名称:translationstudio8,代码行数:24,代码来源:WorkbenchLabelProvider.java

示例5: getStyledText

import org.eclipse.jface.viewers.StyledString.Styler; //导入依赖的package包/类
/**
 * Returns the styled text for the label of the given element.
 * 
 * @param element
 *            the element for which to provide the styled label text
 * @return the styled text string used to label the element
 */
protected StyledString getStyledText(Object element) {
	StyledString styledString = super.getStyledText(element);
	if (this.decorator == null) {
		return styledString;
	}

	String label = styledString.getString();
	String decorated;
	if (this.decorator instanceof LabelDecorator) {
		decorated = ((LabelDecorator) this.decorator).decorateText(label,
				element, getDecorationContext());
	} else {
		decorated = this.decorator.decorateText(label, element);
	}
	if (decorated == null)
		return styledString;

	Styler style = getDecorationStyle(element);
	return StyledCellLabelProvider.styleDecoratedString(decorated, style, styledString);
}
 
开发者ID:ghillairet,项目名称:gef-gwt,代码行数:28,代码来源:DecoratingStyledCellLabelProvider.java

示例6: styleDecoratedString

import org.eclipse.jface.viewers.StyledString.Styler; //导入依赖的package包/类
/**
 * Applies decoration styles to the decorated string and adds the styles of the previously
 * undecorated string.
 * <p>
 * If the <code>decoratedString</code> contains the <code>styledString</code>, then the result
 * keeps the styles of the <code>styledString</code> and styles the decorations with the
 * <code>decorationStyler</code>. Otherwise, the decorated string is returned without any
 * styles.
 * 
 * @param decoratedString the decorated string
 * @param decorationStyler the styler to use for the decoration or <code>null</code> for no
 *            styles
 * @param styledString the original styled string
 * 
 * @return the styled decorated string (can be the given <code>styledString</code>)
 * @since 3.5
 */
public static StyledString styleDecoratedString(String decoratedString, Styler decorationStyler, StyledString styledString) {
	String label= styledString.getString();
	int originalStart= decoratedString.indexOf(label);
	if (originalStart == -1) {
		return new StyledString(decoratedString); // the decorator did something wild
	}

	if (decoratedString.length() == label.length())
		return styledString;

	if (originalStart > 0) {
		StyledString newString= new StyledString(decoratedString.substring(0, originalStart), decorationStyler);
		newString.append(styledString);
		styledString= newString;
	}
	if (decoratedString.length() > originalStart + label.length()) { // decorator appended something
		return styledString.append(decoratedString.substring(originalStart + label.length()), decorationStyler);
	}
	return styledString; // no change
}
 
开发者ID:ghillairet,项目名称:gef-gwt,代码行数:38,代码来源:StyledCellLabelProvider.java

示例7: getStyledText

import org.eclipse.jface.viewers.StyledString.Styler; //导入依赖的package包/类
@Override
public StyledString getStyledText(Object element) {
	if(element instanceof IExplorerNode){
		
		IExplorerNode node = (IExplorerNode)element;
	
		return new StyledString(node.getName(), new Styler() {
			
			@Override
			public void applyStyles(TextStyle textStyle) {
				textStyle.foreground = ColorResources.COLOR_CS_BLUE_DARK;						
			}
			
		});
		
	}
	return null;
}
 
开发者ID:CloudScale-Project,项目名称:Environment,代码行数:19,代码来源:AlternativeResourceNode.java

示例8: getStyledText

import org.eclipse.jface.viewers.StyledString.Styler; //导入依赖的package包/类
@Override
public StyledString getStyledText(Object element) {
    if (element instanceof DataAndImageTreeNode) {
        @SuppressWarnings("rawtypes")
        DataAndImageTreeNode treeNode = (DataAndImageTreeNode) element;
        Object data = treeNode.data;
        if (data instanceof HierarchyNodeModel) {
            HierarchyNodeModel model = (HierarchyNodeModel) data;
            String spaces = "     ";
            StyledString styledString = new StyledString(model.name + spaces);
            if (model.moduleName != null && model.moduleName.trim().length() > 0) {
                Styler styler = StyledString.createColorRegistryStyler(JFacePreferences.DECORATIONS_COLOR, null);
                styledString.append("(" + model.moduleName + ")", styler);
            }
            return styledString;
        }
        return new StyledString(data.toString());
    }
    return new StyledString(element == null ? "" : element.toString());
}
 
开发者ID:fabioz,项目名称:Pydev,代码行数:21,代码来源:HierarchyLabelProvider.java

示例9: markMatchingRegions

import org.eclipse.jface.viewers.StyledString.Styler; //导入依赖的package包/类
private void markMatchingRegions(StyledString string, int index, int[] matchingRegions, Styler styler) {
	if (matchingRegions != null) {
		int offset = -1;
		int length = 0;
		for (int i = 0; i + 1 < matchingRegions.length; i = i + 2) {
			if (offset == -1)
				offset = index + matchingRegions[i];

			// Concatenate adjacent regions
			if (i + 2 < matchingRegions.length
					&& matchingRegions[i] + matchingRegions[i + 1] == matchingRegions[i + 2]) {
				length = length + matchingRegions[i + 1];
			} else {
				string.setStyle(offset, length + matchingRegions[i + 1], styler);
				offset = -1;
				length = 0;
			}
		}
	}
}
 
开发者ID:angelozerr,项目名称:angularjs-eclipse,代码行数:21,代码来源:FilteredAngularElementsSelectionDialog.java

示例10: BlockControlImage

import org.eclipse.jface.viewers.StyledString.Styler; //导入依赖的package包/类
public BlockControlImage ( final ControlImage controlImage, final int style, final RegistrationManager registrationManager )
{
    super ( controlImage.getClientSpace (), style );

    this.controlImage = controlImage;

    this.registrationManager = registrationManager;

    setLayout ( new FillLayout () );

    this.icon = new Label ( this, SWT.NONE );
    this.icon.setImage ( getEmptyImage () );
    this.icon.addMouseListener ( new MouseAdapter () {
        @Override
        public void mouseUp ( final MouseEvent e )
        {
            toggleBlock ();
        }
    } );

    this.registrationManager.addListener ( this );

    final LocalResourceManager resources = new LocalResourceManager ( JFaceResources.getResources (), this.icon );

    this.boldFont = resources.createFont ( JFaceResources.getDefaultFontDescriptor ().withStyle ( SWT.BOLD ) );
    this.boldStyler = new Styler () {

        @Override
        public void applyStyles ( final TextStyle textStyle )
        {
            textStyle.font = BlockControlImage.this.boldFont;
        }
    };
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:35,代码来源:BlockControlImage.java

示例11: getStyledText

import org.eclipse.jface.viewers.StyledString.Styler; //导入依赖的package包/类
@Override
public StyledString getStyledText(Object element) {
	Pattern pattern = viewerConfig.getSearchString().trim().isEmpty() ? null
			: Pattern.compile(viewerConfig.getSearchString());

	Object value = getPropertyValue(element);
	if(value == null)
		return new StyledString();
	
	String stringValue = property.getRange().equals(String.class) ?
			(String)value 
				: Collection.class.isAssignableFrom(property.getRange()) ?
						((Collection<?>)value).stream().map(Object::toString).collect(Collectors.joining(", ")) :
							null;
	
	StyledString styledString  = new StyledString();
	Styler styler = element instanceof TermService ? TERM_STYLER : VARIATION_STYLER;
	if(stringValue != null) {
		Matcher matcher;
		int b = 0;
		int e = 0;
		if (pattern != null && (matcher = pattern.matcher(stringValue)).find()) {
			b = matcher.start();
			e = matcher.end();
		}
		styledString.append(stringValue.substring(0, Ints.min(b, stringValue.length())), styler);
		styledString.append(stringValue.substring(Ints.min(b, stringValue.length()), Ints.min(e, stringValue.length())),
				TermSuiteUI.STYLE_GRAYED_BOLD);
		styledString.append(stringValue.substring(Ints.min(e, stringValue.length()), stringValue.length()),
				styler);
	} else if(property.isDecimalNumber()) {
		double v = (double)value;
		styledString.append(String.format("%.2f", v), styler);
	} else if(property.getRange().equals(Boolean.class))
		styledString.append(String.format("%d", (boolean)value ? 1 : 0), styler);
	else 
		styledString.append(String.format("%d", value), styler);
	return styledString;
}
 
开发者ID:termsuite,项目名称:termsuite-ui,代码行数:40,代码来源:TermLabelProvider.java

示例12: getStyler

import org.eclipse.jface.viewers.StyledString.Styler; //导入依赖的package包/类
public Styler getStyler(Font font, Color foreground, Color backGround) {
	StylerDescriptor descriptor = new StylerDescriptor(font, foreground,
			backGround);
	Styler styler = stylers.get(descriptor);
	if (styler != null) {
		return styler;
	}
	styler = new FontColorStyler(descriptor);
	stylers.put(descriptor, styler);
	return styler;
}
 
开发者ID:cchabanois,项目名称:mesfavoris,代码行数:12,代码来源:StylerProvider.java

示例13: toStyledString

import org.eclipse.jface.viewers.StyledString.Styler; //导入依赖的package包/类
public StyledString toStyledString(CommandStackView styleProvider) {

        Styler identifierStyler = styleProvider != null ? styleProvider.getIdentifierStyler(this) : null;
        Styler bracketStyler = styleProvider != null ? styleProvider.getBracketStyler(this) : null;
        Styler argNameSyler = styleProvider != null ? styleProvider.getArgNameStyler(this) : null;
        Styler errorStyler = styleProvider != null ? styleProvider.getErrorStyler(this) : null;
        Styler numberStyler = styleProvider != null ? styleProvider.getNumberStyler(this) : null;

        StyledString str = new StyledString();
        str.append(getSelectedAlias(), identifierStyler);
        str.append("(", bracketStyler);
        boolean first = true;
        for (ArgumentInfo arg : meta.getArgumentList()) {
            String value = getAssignedStringValue(arg);

            if (value == null && arg.hasInitialValue())
                continue;

            if (!first)
                str.append("\n, ", bracketStyler);
            first = false;
            str.append(arg.getName() + ": ", argNameSyler);

            if (value == null) {
                str.append("  ", errorStyler);
            } else {
                boolean needQuotationMark = ArgumentTableBuilder.STRING.equals(arg.getType().getEngType())
                        || ArgumentTableBuilder.ENUM.equals(arg.getType().getEngType());
                if (needQuotationMark)
                    str.append("\"", isValid(arg) ? numberStyler : errorStyler);
                str.append(value, isValid(arg) ? numberStyler : errorStyler);
                if (needQuotationMark)
                    str.append("\"", isValid(arg) ? numberStyler : errorStyler);
            }
        }
        str.append(")", bracketStyler);
        return str;
    }
 
开发者ID:yamcs,项目名称:yamcs-studio,代码行数:39,代码来源:StackedCommand.java

示例14: getIdentifierStyler

import org.eclipse.jface.viewers.StyledString.Styler; //导入依赖的package包/类
public Styler getIdentifierStyler(StackedCommand cmd) {
    if (cmd.getStackedState() == StackedState.ISSUED)
        return issuedStyler;
    else if (cmd.getStackedState() == StackedState.SKIPPED)
        return skippedStyler;

    return null;
}
 
开发者ID:yamcs,项目名称:yamcs-studio,代码行数:9,代码来源:CommandStackView.java

示例15: getBracketStyler

import org.eclipse.jface.viewers.StyledString.Styler; //导入依赖的package包/类
public Styler getBracketStyler(StackedCommand cmd) {
    if (cmd.getStackedState() == StackedState.ISSUED)
        return issuedStyler;
    else if (cmd.getStackedState() == StackedState.SKIPPED)
        return skippedStyler;

    return bracketStyler;
}
 
开发者ID:yamcs,项目名称:yamcs-studio,代码行数:9,代码来源:CommandStackView.java


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