use of org.csstudio.autocomplete.ui.util.SSTextLayout in project yamcs-studio by yamcs.
the class ContentProposalPopup method initializeTextLayouts.
private void initializeTextLayouts() {
Display display = Display.getCurrent();
FontData defaultFontData = display.getSystemFont().getFontData()[0];
String fontName = defaultFontData.getName();
int fontHeight = defaultFontData.getHeight();
Font headerFont = new Font(display, new FontData(fontName, fontHeight, SWT.ITALIC | SWT.BOLD));
Font noFont = new Font(display, new FontData(fontName, fontHeight, SWT.NORMAL));
Color black = display.getSystemColor(SWT.COLOR_BLACK);
int index = 0;
textLayouts = new SSTextLayout[getTableLength()];
for (Proposal proposal : proposalList.getTopProposalList()) {
textLayouts[index] = AutoCompleteUIPlugin.getUIHelper().newTextLayout();
String text = getString(proposal);
textLayouts[index].init(display, text);
textLayouts[index].addStyle(noFont, black, 0, text.length());
if (proposal.getStyles() != null && !proposal.getStyles().isEmpty()) {
for (ProposalStyle style : proposal.getStyles()) {
FontData newFontData = new FontData(fontName, fontHeight, style.fontStyle);
Font font = new Font(display, newFontData);
Color color = display.getSystemColor(style.fontColor);
textLayouts[index].addStyle(font, color, style.from, style.to);
}
}
index++;
}
for (String provider : proposalList.getProviderList()) {
textLayouts[index] = AutoCompleteUIPlugin.getUIHelper().newTextLayout();
int count = proposalList.getCount(provider);
String headerText = provider + " (" + count + " matching items)";
textLayouts[index].init(display, headerText);
textLayouts[index].addStyle(headerFont, black, 0, headerText.length());
index++;
for (Proposal proposal : proposalList.getProposals(provider)) {
textLayouts[index] = AutoCompleteUIPlugin.getUIHelper().newTextLayout();
String text = getString(proposal);
textLayouts[index].init(display, text);
textLayouts[index].addStyle(noFont, black, 0, text.length());
if (proposal.getStyles() != null && !proposal.getStyles().isEmpty()) {
for (ProposalStyle style : proposal.getStyles()) {
FontData newFontData = new FontData(fontName, fontHeight, style.fontStyle);
Font font = new Font(display, newFontData);
Color color = display.getSystemColor(style.fontColor);
textLayouts[index].addStyle(font, color, style.from, style.to);
}
}
index++;
}
}
for (SSTextLayout sstl : textLayouts) if (sstl != null && sstl.getBounds() != null && sstl.getBounds().width > maxItemWidth)
maxItemWidth = sstl.getBounds().width;
adjustTableBounds();
}
Aggregations