use of com.vaadin.ui.Button in project opennms by OpenNMS.
the class BreadcrumbComponent method createButton.
private static Button createButton(GraphContainer container, Breadcrumb breadcrumb) {
final Button button = new Button();
final String layerName = getLayerName(container, breadcrumb.getTargetNamespace());
if (breadcrumb.getSourceVertices().isEmpty()) {
button.setCaption(layerName);
} else {
String sourceLayerName = getLayerName(container, breadcrumb.getSourceVertices().get(0).getNamespace());
if (breadcrumb.getSourceVertices().size() > 2) {
button.setCaption("Multiple " + layerName);
button.setDescription(String.format("Multiple vertices from %s", sourceLayerName));
} else {
button.setCaption(breadcrumb.getSourceVertices().stream().map(VertexRef::getLabel).collect(Collectors.joining(", ")));
button.setDescription(String.format("%s from %s", button.getCaption(), sourceLayerName));
}
}
button.addStyleName(BaseTheme.BUTTON_LINK);
button.addClickListener((event) -> breadcrumb.clicked(container));
return button;
}
use of com.vaadin.ui.Button in project opennms by OpenNMS.
the class WallboardConfigView method addNewTabComponent.
/**
* This method is used to add a new {@link TabSheet.Tab} component. It creates a new window querying the user for the name of the new {@link Wallboard}.
*/
protected void addNewTabComponent() {
final Window window = new Window("New Ops Board");
window.setModal(true);
window.setClosable(false);
window.setResizable(false);
window.addCloseListener(new Window.CloseListener() {
@Override
public void windowClose(Window.CloseEvent e) {
m_dashboardOverview.refreshTable();
}
});
getUI().addWindow(window);
window.setContent(new VerticalLayout() {
TextField name = new TextField("Ops Board Name");
{
addComponent(new FormLayout() {
{
setSizeUndefined();
setMargin(true);
String newName = "Untitled";
int i = 1;
if (WallboardProvider.getInstance().containsWallboard(newName)) {
do {
i++;
newName = "Untitled #" + i;
} while (WallboardProvider.getInstance().containsWallboard(newName));
}
name.setValue(newName);
addComponent(name);
name.focus();
name.selectAll();
name.addValidator(new AbstractStringValidator("Title must be unique") {
@Override
protected boolean isValidValue(String s) {
return (!WallboardProvider.getInstance().containsWallboard(s) && !"".equals(s));
}
});
}
});
addComponent(new HorizontalLayout() {
{
setMargin(true);
setSpacing(true);
setWidth("100%");
Button cancel = new Button("Cancel");
cancel.setDescription("Cancel editing");
cancel.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(Button.ClickEvent event) {
// NMS-7560: Toggle the tab in order to allow us to click it again
m_tabSheet.togglePlusTab();
window.close();
}
});
cancel.setClickShortcut(ShortcutAction.KeyCode.ESCAPE, null);
addComponent(cancel);
setExpandRatio(cancel, 1);
setComponentAlignment(cancel, Alignment.TOP_RIGHT);
Button ok = new Button("Save");
ok.setDescription("Save configuration");
ok.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(Button.ClickEvent event) {
if (name.isValid()) {
Wallboard wallboard = new Wallboard();
wallboard.setTitle(name.getValue());
WallboardProvider.getInstance().addWallboard(wallboard);
WallboardProvider.getInstance().save();
WallboardEditor wallboardEditor = new WallboardEditor(m_dashletSelector, wallboard);
TabSheet.Tab tab = m_tabSheet.addTab(wallboardEditor, wallboard.getTitle());
wallboardEditor.setTab(tab);
m_wallboardEditorMap.put(wallboard, tab);
tab.setClosable(true);
m_tabSheet.setSelectedTab(tab);
window.close();
}
}
});
ok.setClickShortcut(ShortcutAction.KeyCode.ENTER, null);
addComponent(ok);
}
});
}
});
}
use of com.vaadin.ui.Button in project charts by vaadin.
the class ChangingThemeAndLang method getChart.
@Override
protected Component getChart() {
ChartOptions.get().setTheme(new HighChartsDefaultTheme());
HorizontalLayout buttons = new HorizontalLayout();
content.addComponent(buttons);
Button vaadin = new Button("Vaadin", new ThemeChangeListener(VaadinTheme.class));
vaadin.setId("vaadin-button");
buttons.addComponent(vaadin);
Button grid = new Button("Grid", new ThemeChangeListener(GridTheme.class));
grid.setId("grid-button");
buttons.addComponent(grid);
Button skies = new Button("Skies", new ThemeChangeListener(SkiesTheme.class));
skies.setId("skies-button");
buttons.addComponent(skies);
Button gray = new Button("Gray", new ThemeChangeListener(GrayTheme.class));
gray.setId("gray-button");
buttons.addComponent(gray);
Button highchart = new Button("Highcharts", new ThemeChangeListener(HighChartsDefaultTheme.class));
highchart.setId("hs-button");
buttons.addComponent(highchart);
chart = PercentageArea.createNewChart();
chart.setWidth("100%");
chart.setHeight("400px");
return chart;
}
use of com.vaadin.ui.Button in project charts by vaadin.
the class TimeDataWithIrregularIntervalsAndLocalizedTexts method getChart.
@Override
protected Component getChart() {
// localizations
final Lang fi = new Lang();
fi.setDecimalPoint(",");
fi.setShortMonths(new String[] { "Tammi", "Helmi", "Maalis", "Huhti", "Touko", "Kesä", "Heinä", "Elo", "Syys", "Loka", "Marras", "Joulu" });
fi.setMonths(new String[] { "Tammikuu", "Helmikuu", "Maaliskuu", "Huhtikuu", "Toukokuu", "Kesäkuu", "Heinäkuu", "Elokuu", "Syyskuu", "Lokakuu", "Marraskuu", "Joulukuu" });
fi.setWeekdays(new String[] { "Ma", "Ti", "Ke", "To", "Pe", "La", "Su" });
final Lang en = new Lang();
en.setDecimalPoint(".");
en.setShortMonths(new String[] { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" });
en.setMonths(new String[] { "January", "February", "March", "April", "May", "June", "Jule", "August", "September", "October", "November", "December" });
en.setWeekdays(new String[] { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" });
final Chart chart = new Chart();
chart.setHeight("450px");
chart.setWidth("100%");
final Configuration configuration = chart.getConfiguration();
configuration.getChart().setType(ChartType.SPLINE);
configuration.getTitle().setText("Lumen syvyys Vikjafjellet-tunturilla, Norja");
configuration.getSubTitle().setText("Lokalisointiesimerkki");
configuration.getTooltip().setFormatter("");
configuration.getxAxis().setType(AxisType.DATETIME);
configuration.getxAxis().setDateTimeLabelFormats(new DateTimeLabelFormats());
configuration.getxAxis().getDateTimeLabelFormats().setMonth("%B");
YAxis yAxis = configuration.getyAxis();
yAxis.setTitle(new AxisTitle("Lumen syvyys (m)"));
yAxis.setMin(0);
DataSeries ls = new DataSeries();
PlotOptionsSpline plotOptionsSpline = new PlotOptionsSpline();
plotOptionsSpline.setDataLabels(new DataLabels(true));
plotOptionsSpline.setEnableMouseTracking(false);
plotOptionsSpline.getDataLabels().setFormatter("return Highcharts.dateFormat('%a %d %B',this.x);");
ls.setPlotOptions(plotOptionsSpline);
ls.setName("Talvi 2009-2010");
Object[][] data3 = getData3();
for (int i = 0; i < data3.length; i++) {
Object[] ds = data3[i];
DataSeriesItem item = new DataSeriesItem((Date) ds[0], (Double) ds[1]);
ls.add(item);
}
configuration.addSeries(ls);
chart.drawChart(configuration);
final Button enButton = new Button("English");
enButton.setId("en-button");
enButton.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
ChartOptions.get().setLang(en);
}
});
final Button fiButton = new Button("Finnish");
fiButton.setId("fi-button");
fiButton.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
ChartOptions.get().setLang(fi);
}
});
HorizontalLayout horizontalLayout = new HorizontalLayout(enButton, fiButton);
horizontalLayout.setSpacing(false);
VerticalLayout verticalLayout = new VerticalLayout(horizontalLayout, chart);
verticalLayout.setSpacing(false);
verticalLayout.setMargin(false);
return verticalLayout;
}
use of com.vaadin.ui.Button in project charts by vaadin.
the class TimeSeriesIntervalUnit method getChart.
@Override
protected Component getChart() {
final Chart chart = new Chart();
chart.setHeight("450px");
chart.setWidth("100%");
Configuration configuration = chart.getConfiguration();
configuration.getChart().setSpacingRight(20);
configuration.getTitle().setText("Point interval test");
configuration.getxAxis().setType(AxisType.DATETIME);
final PlotOptionsSeries plotOptions = new PlotOptionsSeries();
try {
DateFormat df = new SimpleDateFormat("yyyyMMdd");
plotOptions.setPointStart(df.parse("20150101"));
} catch (ParseException e) {
e.printStackTrace();
}
plotOptions.setPointInterval(1);
plotOptions.setPointIntervalUnit(IntervalUnit.MONTH);
configuration.setPlotOptions(plotOptions);
ListSeries ls = new ListSeries();
ls.setData(29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4);
configuration.setSeries(ls);
VerticalLayout layout = new VerticalLayout();
layout.setSpacing(false);
layout.setMargin(false);
layout.addComponent(chart);
layout.addComponent(new Button("one day interval", new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
plotOptions.setPointInterval(24 * 3600 * 1000);
plotOptions.setPointIntervalUnit(null);
chart.drawChart();
}
}));
return layout;
}
Aggregations