本文整理匯總了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();
}
示例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));
}
示例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;
}
示例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 );
}
}
示例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 () );
}
}
示例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 );
}
}
示例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 );
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}