use of com.google.gwt.user.client.ui.Anchor in project opennms by OpenNMS.
the class TagPanel method updatePanel.
private void updatePanel() {
int minCount = Integer.MAX_VALUE, maxCount = Integer.MIN_VALUE;
Map<String, Integer> tagCounts = new TreeMap<String, Integer>();
for (String tag : m_delegate) {
if (tagCounts.containsKey(tag)) {
tagCounts.put(tag, tagCounts.get(tag).intValue() + 1);
} else {
tagCounts.put(tag, 1);
}
}
for (int entry : tagCounts.values()) {
if (entry < minCount)
minCount = entry;
if (entry > maxCount)
maxCount = entry;
}
tagPanel.clear();
for (final Map.Entry<String, Integer> entry : tagCounts.entrySet()) {
final String tagText = entry.getKey();
final Anchor tagLabel = new Anchor();
double rawValue = (double) (entry.getValue() - minCount) * TagStyles.COUNT / (double) (maxCount - minCount);
tagLabel.setHTML(tagText.replace(" ", " "));
tagLabel.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
selectTag(tagText);
m_eventBus.fireEvent(new TagSelectedEvent(tagText));
}
});
switch((int) Math.round(rawValue)) {
case (0):
tagLabel.addStyleName(tagStyles.tag0());
break;
case (1):
tagLabel.addStyleName(tagStyles.tag1());
break;
case (2):
tagLabel.addStyleName(tagStyles.tag2());
break;
case (3):
tagLabel.addStyleName(tagStyles.tag3());
break;
case (4):
tagLabel.addStyleName(tagStyles.tag4());
break;
case (5):
tagLabel.addStyleName(tagStyles.tag5());
break;
case (6):
tagLabel.addStyleName(tagStyles.tag6());
break;
case (7):
tagLabel.addStyleName(tagStyles.tag7());
break;
case (8):
tagLabel.addStyleName(tagStyles.tag8());
break;
case (9):
tagLabel.addStyleName(tagStyles.tag9());
break;
default:
tagLabel.addStyleName(tagStyles.tag9());
}
tagPanel.add(tagLabel);
// without this, the tag cloud doesn't wrap properly
tagPanel.add(new InlineHTML(" "));
}
}
use of com.google.gwt.user.client.ui.Anchor in project gwt-cs by iSergio.
the class ShowcaseBrandsProvider method get.
@Override
public List<Anchor> get() {
Anchor anchor = new Anchor("Ol3-Cesium");
List<Anchor> list = new ArrayList<Anchor>();
list.add(anchor);
return list;
}
use of com.google.gwt.user.client.ui.Anchor in project activityinfo by bedatadriven.
the class DataEntryPage method createNewInterfaceLink.
private Component createNewInterfaceLink() {
betaLinkPanel = new ContentPanel();
betaLinkPanel.setHeaderVisible(false);
betaLinkPanel.setLayout(new CenterLayout());
Anchor betaLink = new Anchor(I18N.CONSTANTS.tryNewDataEntryInterface());
betaLink.addClickHandler(clickEvent -> {
if (!clickEvent.isControlKeyDown()) {
navigateToNewNewInterface();
} else {
navigateToNewInterface();
}
});
betaLinkPanel.add(betaLink);
return betaLinkPanel;
}
use of com.google.gwt.user.client.ui.Anchor in project ovirt-engine by oVirt.
the class SubTabClusterGeneralPresenter method addTextAndLinkAlert.
/**
* Create a widget containing text and a link that triggers the execution of a command.
*
* @param view
* the view where the alert should be added
* @param text
* the text content of the alert
* @param commands
* the command that should be executed when the link is clicked
*/
private void addTextAndLinkAlert(final ViewDef view, final String text, final UICommand... commands) {
// Create a flow panel containing the text and the link:
final FlowPanel alertPanel = new FlowPanel();
int start = 0;
for (final UICommand command : commands) {
// Find the open and close positions of the link within the message:
// $NON-NLS-1$
final int openIndex = text.indexOf("<a>", start);
// $NON-NLS-1$
final int closeIndex = text.indexOf("</a>", start);
if (openIndex == -1 || closeIndex == -1 || closeIndex < openIndex) {
break;
}
// Extract the text before, inside and after the tags:
final String beforeText = text.substring(start, openIndex);
final String betweenText = text.substring(openIndex + 3, closeIndex);
start = closeIndex + 4;
// Create the label for the text before the tag:
final Label beforeLabel = new Label(beforeText);
// $NON-NLS-1$ //$NON-NLS-2$
beforeLabel.getElement().getStyle().setProperty("display", "inline");
alertPanel.add(beforeLabel);
// Create the anchor:
final Anchor betweenAnchor = new Anchor(betweenText);
// $NON-NLS-1$ //$NON-NLS-2$
betweenAnchor.getElement().getStyle().setProperty("display", "inline");
alertPanel.add(betweenAnchor);
// Add a listener to the anchor so that the command is executed when
// it is clicked:
betweenAnchor.addClickHandler(event -> command.execute());
}
if (start < text.length()) {
final String afterText = text.substring(start);
// Create the label for the text after the tag:
final Label afterLabel = new Label(afterText);
// $NON-NLS-1$ //$NON-NLS-2$
afterLabel.getElement().getStyle().setProperty("display", "inline");
alertPanel.add(afterLabel);
}
if (start > 0) {
// Add the alert to the view:
view.addAlert(alertPanel);
}
}
use of com.google.gwt.user.client.ui.Anchor in project ovirt-engine by oVirt.
the class HostFenceAgentPopupView method initEditors.
private void initEditors() {
pmTypeEditor = new ListModelListBoxEditor<>(new StringRenderer<String>());
pmEncryptOptionsEditor = new EntityModelCheckBoxEditor(Align.RIGHT);
pmEncryptOptionsEditor.setUsePatternFly(true);
pmSecureEditor = new EntityModelCheckBoxEditor(Align.RIGHT);
pmSecureEditor.setUsePatternFly(true);
fencingOptionsUrl = new Anchor(constants.fencingOptionsLabel());
}
Aggregations