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


Java StyledString类代码示例

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


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

示例1: getStyledText

import org.eclipse.jface.viewers.StyledString; //导入依赖的package包/类
@Override
public StyledString getStyledText(final Object element) {
	if (element instanceof IEObjectDescription) {
		final String text = getText(element);
		final StyledString string = new StyledString(text);

		final int[] matchingRegion = getMatchingRegions(text);
		if (null != matchingRegion) {
			for (int i = 0; i < matchingRegion.length; i = i + 2) {
				string.setStyle(matchingRegion[i], matchingRegion[i + 1], boldStyler);
			}
		}

		final int indexOf = text.indexOf(NAME_SEPARATOR);
		if (-1 < indexOf) {
			string.setStyle(indexOf, text.length() - indexOf, qualifierStyler);
		}
		return string;
	}
	return new StyledString();
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:22,代码来源:OpenTypeSelectionDialog.java

示例2: getStyledText

import org.eclipse.jface.viewers.StyledString; //导入依赖的package包/类
@Override
public StyledString getStyledText(Object element) {
	if (element instanceof WorkingSet) {
		final WorkingSet workingSet = (WorkingSet) element;
		final WorkingSetManager manager = workingSet.getWorkingSetManager();

		final String name = workingSet.getName();
		final List<String> allNames = transform(manager.getAllWorkingSets(), ws -> ws.getName());
		if (containsDuplicates(name, allNames)) {
			final String suffix = " [" + workingSet.getId() + "]";
			final StyledString string = new StyledString(name);
			string.append(suffix, COUNTER_STYLER);
			return string;
		}
	}
	return new StyledString(getText(element));
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:18,代码来源:WorkingSetLabelProvider.java

示例3: getConnectionString

import org.eclipse.jface.viewers.StyledString; //导入依赖的package包/类
private StyledString getConnectionString ( final ConnectionHolder holder )
{
    final ConnectionService service = holder.getConnectionService ();

    final ConnectionDescriptor desc = holder.getConnectionInformation ();

    final StyledString str = new StyledString ( makeLabel ( desc.getConnectionInformation () ) );

    if ( service != null )
    {
        str.append ( " [", StyledString.DECORATIONS_STYLER ); //$NON-NLS-1$
        final Connection connection = service.getConnection ();
        if ( connection != null )
        {
            str.append ( String.format ( "%s", holder.getConnectionState () ), StyledString.DECORATIONS_STYLER ); //$NON-NLS-1$
        }
        str.append ( "]", StyledString.DECORATIONS_STYLER ); //$NON-NLS-1$
    }

    if ( desc.getServiceId () != null )
    {
        str.append ( String.format ( " (%s)", desc.getServiceId () ), StyledString.QUALIFIER_STYLER ); //$NON-NLS-1$ 
    }

    return str;
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:27,代码来源:ConnectionLabelProvider.java

示例4: updateLabel

import org.eclipse.jface.viewers.StyledString; //导入依赖的package包/类
@Override
public void updateLabel ( final StyledViewerLabel label, final Object element )
{
    if ( element instanceof QueryListWrapper )
    {
        label.setText ( "Test Queries" );
    }
    else if ( element instanceof QueryBean )
    {
        final QueryBean query = (QueryBean)element;
        final StyledString text = new StyledString ();
        text.append ( String.format ( "%.20s:%.40s", query.getFilterType (), query.getFilterData () ) );
        text.append ( " " );
        text.append ( String.format ( "%s", query.getCount () ), StyledString.COUNTER_STYLER );
        text.append ( " " );
        text.append ( String.format ( "[%s]", query.getState () ), StyledString.DECORATIONS_STYLER );
        label.setStyledText ( text );
        label.setTooltipText ( String.format ( "%s%n%s", query.getFilterType (), query.getFilterData () ) );
    }
    else
    {
        super.updateLabel ( label, element );
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:25,代码来源:LabelProvider.java

示例5: update

import org.eclipse.jface.viewers.StyledString; //导入依赖的package包/类
@Override
public void update ( final ViewerCell cell )
{
    final Object ele = cell.getElement ();
    if ( ele instanceof GroupEntry )
    {
        cell.setText ( String.format ( Messages.FlagsDetailsPart_GroupSumFormat, ( (GroupEntry)ele ).getActiveCount (), ( (GroupEntry)ele ).getCount () ) );
    }
    else if ( ele instanceof AttributeEntry )
    {
        final StyledString str = new StyledString ();

        if ( ( (AttributeEntry)ele ).isActive () )
        {
            str.append ( Messages.FlagsDetailsPart_ActiveMarker, this.activeStyler );
        }
        else
        {
            str.append ( Messages.FlagsDetailsPart_InactiveMarker, this.inactiveStyler );
        }

        cell.setText ( str.getString () );
        cell.setStyleRanges ( str.getStyleRanges () );
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:26,代码来源:FlagsDetailsPart.java

示例6: updateLabel

import org.eclipse.jface.viewers.StyledString; //导入依赖的package包/类
@Override
public void updateLabel ( final StyledViewerLabel label, final Object element )
{
    logger.debug ( "Update label: {}", element ); //$NON-NLS-1$

    if ( element instanceof BrowserEntryBean )
    {
        final BrowserEntryBean entry = (BrowserEntryBean)element;
        final StyledString string = new StyledString ( entry.getEntry ().getId () );
        label.setStyledText ( string );

        final Set<BrowserType> types = entry.getEntry ().getTypes ();
        if ( types.contains ( BrowserType.EVENTS ) )
        {
            label.setImage ( Activator.getDefault ().getImageRegistry ().get ( ImageConstants.IMG_EVENTS ) );
        }
        else if ( types.contains ( BrowserType.MONITORS ) )
        {
            label.setImage ( Activator.getDefault ().getImageRegistry ().get ( ImageConstants.IMG_MONITORS ) );
        }
    }
    else
    {
        super.updateLabel ( label, element );
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:27,代码来源:ConnectionLabelProvider.java

示例7: update

import org.eclipse.jface.viewers.StyledString; //导入依赖的package包/类
protected void update ( final ViewerCell cell, final ServerEndpoint element )
{
    final StyledString str = new StyledString ();

    final boolean running = element.isRunning ();

    str.append ( element.getLabel () );

    cell.setText ( str.getString () );
    cell.setStyleRanges ( str.getStyleRanges () );

    if ( element.getError () != null )
    {
        cell.setImage ( this.errorImage );
    }
    else
    {
        cell.setImage ( running ? this.runningImage : this.stoppedImage );
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:21,代码来源:ServerLabelProvider.java

示例8: getStyledText

import org.eclipse.jface.viewers.StyledString; //导入依赖的package包/类
@Override
public StyledString getStyledText(Object element) {

	if(!(element instanceof IScannable<?>)) return new StyledString();

	final String       text       = getText(element);
	final StyledString styledText = new StyledString(text!=null?text:"");

	IScannable<?> scannable = (IScannable<?>)element;
	try {

		if (scannable.getUnit() != null) {
			styledText.append("    ");
			styledText.append(scannable.getUnit(), StyledString.DECORATIONS_STYLER);

		} else {

			// Intentionally do nothing!
		}
	} catch (Exception ne) {
		String message = ne.getMessage() == null ? "" : ne.getMessage();
		return styledText.append(message, StyledString.QUALIFIER_STYLER);
	}

	return styledText;
}
 
开发者ID:eclipse,项目名称:scanning,代码行数:27,代码来源:ScannableValueLabelProvider.java

示例9: appendResultsToStyledString

import org.eclipse.jface.viewers.StyledString; //导入依赖的package包/类
/**
 * Turn the results into a styled string for display to user, highlighting key values
 * @param results The ValidationResults
 * @return a StyledString to display on the view
 */
private StyledString appendResultsToStyledString(ValidateResults results) {
	StyledString styledString = new StyledString();
	if (results.getResults() != null) {
		if (results.getResults() instanceof String) {
			// Print out all the results from the raw PVStructure string, but style key information
			String resultString = (String)results.getResults();
			styledString.append(resultString);

			// Style the duration
			adjustStyleOfDuration(styledString, resultString);

			// Style the axes to move
			adjustStyleOfAxesToMove(styledString, resultString);

		} else {
			// not a string, just print out the results object
			 styledString.append(results.getResults().toString());
		}
	}

	return styledString;

}
 
开发者ID:eclipse,项目名称:scanning,代码行数:29,代码来源:ValidateResultsView.java

示例10: getStyledDisplayString

import org.eclipse.jface.viewers.StyledString; //导入依赖的package包/类
@Override
public StyledString getStyledDisplayString(IDocument document, int offset, BoldStylerProvider boldStylerProvider) {
	// Highlight matched prefix
	StyledString styledDisplayString = new StyledString();
	styledDisplayString.append(getStyledDisplayString());

	String pattern = getPatternToEmphasizeMatch(document, offset);
	if (pattern != null && pattern.length() > 0) {
		String displayString = styledDisplayString.getString();
		int[] bestSequence = completionEntry.getMatcher().bestSubsequence(displayString, pattern);
		int highlightAdjustment = 0;
		for (int index : bestSequence) {
			styledDisplayString.setStyle(index + highlightAdjustment, 1, boldStylerProvider.getBoldStyler());
		}
	}
	return styledDisplayString;
}
 
开发者ID:angelozerr,项目名称:ec4e,代码行数:18,代码来源:EditorConfigCompletionProposal.java

示例11: getStyledText

import org.eclipse.jface.viewers.StyledString; //导入依赖的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

示例12: getStyledText

import org.eclipse.jface.viewers.StyledString; //导入依赖的package包/类
@Override
public StyledString getStyledText(Object element) {
	PathPlaceholder pathPlaceholder = (PathPlaceholder) element;
	StyledString sb = new StyledString();
	sb.append(pathPlaceholder.getName());
	sb.append(" (");
	if (isUnmodifiable(pathPlaceholder)) {
		sb.append("non modifiable, ");
	}
	sb.append(
			MessageFormat.format("{0} matches",
					Integer.toString(placeholderStats.getUsageCount(pathPlaceholder.getName()))),
			StyledString.COUNTER_STYLER);
	sb.append(')');
	sb.append(" - ");
	if (pathPlaceholder.getPath() != null) {
		sb.append(pathPlaceholder.getPath().toString());
	}
	return sb;
}
 
开发者ID:cchabanois,项目名称:mesfavoris,代码行数:21,代码来源:PathPlaceholderTableLabelProvider.java

示例13: getStyledText

import org.eclipse.jface.viewers.StyledString; //导入依赖的package包/类
@Override
public StyledString getStyledText(Context context, Bookmark bookmark) {
	BookmarkFolder bookmarkFolder = (BookmarkFolder) bookmark;
	StyledString result = super.getStyledText(context, bookmark);
	RemoteBookmarkFolder remoteBookmarkFolder = remoteBookmarksStoreManager
			.getRemoteBookmarkFolder(bookmarkFolder.getId());
	if (remoteBookmarkFolder != null) {
		IRemoteBookmarksStore remoteBookmarksStore = remoteBookmarksStoreManager
				.getRemoteBookmarksStore(remoteBookmarkFolder.getRemoteBookmarkStoreId());
		Optional<Integer> bookmarksCount = getBookmarksCount(remoteBookmarkFolder);
		if (bookmarksCount.isPresent()) {
			result.append(String.format(" (%d)", bookmarksCount.get()), stylerProvider.getStyler(null,
					Display.getCurrent().getSystemColor(SWT.COLOR_DARK_YELLOW), null));
		}
		if (remoteBookmarksStore.getState() == State.connected && isReadOnly(remoteBookmarkFolder)) {
			result.append(" [readonly]", stylerProvider.getStyler(null,
					Display.getCurrent().getSystemColor(SWT.COLOR_DARK_YELLOW), null));
		}
	}

	return result;
}
 
开发者ID:cchabanois,项目名称:mesfavoris,代码行数:23,代码来源:BookmarkFolderLabelProvider.java

示例14: update

import org.eclipse.jface.viewers.StyledString; //导入依赖的package包/类
public void update(ViewerCell cell) {
	Object element = cell.getElement();

	if (!(element instanceof ItemsListSeparator)
			&& provider instanceof IStyledLabelProvider) {
		IStyledLabelProvider styledLabelProvider = (IStyledLabelProvider) provider;
		StyledString styledString = getStyledText(element,
				styledLabelProvider);

		cell.setText(styledString.getString());
		cell.setStyleRanges(styledString.getStyleRanges());
		cell.setImage(styledLabelProvider.getImage(element));
	} else {
		cell.setText(getText(element));
		cell.setImage(getImage(element));
	}
	cell.setFont(getFont(element));
	cell.setForeground(getForeground(element));
	cell.setBackground(getBackground(element));

	super.update(cell);
}
 
开发者ID:tlaplus,项目名称:tlaplus,代码行数:23,代码来源:FilteredItemsSelectionDialog.java

示例15: getStyledText

import org.eclipse.jface.viewers.StyledString; //导入依赖的package包/类
public StyledString getStyledText(Object element) {
	final String text = getText(element);
	if (text == null || EMPTY_STRING.equals(text)) {
		return new StyledString();
	}
	
	final StyledString string = new StyledString(text);
	
	if (element instanceof Spec) {
		string.setStyle(0, string.length(), StyledString.QUALIFIER_STYLER);
	} else if (element instanceof Model && text.indexOf(DELIM) != -1) {
		final int index = text.indexOf(DELIM);
		string.setStyle(index, text.length() - index, StyledString.DECORATIONS_STYLER);
	} else if (element instanceof ItemsListSeparator) {
		string.setStyle(0, string.length(), StyledString.QUALIFIER_STYLER);
	}
	return string;
}
 
开发者ID:tlaplus,项目名称:tlaplus,代码行数:19,代码来源:TLAFilteredItemsSelectionDialog.java


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