use of com.vaadin.ui.Component in project opennms by OpenNMS.
the class SurveillanceView method setView.
/**
* Set the view to be displayed by this component.
*
* @param view the view to be displayed
*/
public void setView(View view) {
/**
* set the field
*/
m_view = view;
/**
* check whether refreshing is enabled
*/
m_refreshEnabled = (m_view.getRefreshSeconds() > 0);
m_countdown = m_view.getRefreshSeconds();
/**
* alter the table header
*/
m_surveillanceViewTableHeader.setCaptionText("Surveillance view: " + m_view.getName());
m_surveillanceViewTableHeader.select(m_view.getName());
m_surveillanceViewTableHeader.getNativeSelect().setEnabled(m_enabled);
/**
* remove old components
*/
removeAllComponents();
/**
* create the layout
*/
upperLayout = new VerticalLayout();
upperLayout.setId("surveillance-window");
upperLayout.setSpacing(false);
/**
* create surveillance view table...
*/
m_surveillanceViewTable = new SurveillanceViewTable(m_view, m_surveillanceViewService, m_dashboard, m_enabled);
/**
* ...and add the header and the table itself
*/
upperLayout.addComponent(new Label("<div id=\"surveillanceview\"/>", ContentMode.HTML));
upperLayout.addComponent(m_surveillanceViewTableHeader);
upperLayout.addComponent(m_surveillanceViewTable);
if (!m_dashboard) {
addComponent(upperLayout);
} else {
/**
* if dashboard should be displayed add the detail tables and components
*/
CssLayout leftCssLayout = new CssLayout() {
@Override
protected String getCss(Component c) {
return "padding-bottom: 6px;";
}
};
leftCssLayout.setPrimaryStyleName("col-md-11");
leftCssLayout.setId("dashboard-content");
CssLayout rightCssLayout = new CssLayout();
rightCssLayout.setPrimaryStyleName("col-md-1");
lowerLayout = new VerticalLayout();
lowerLayout.setSpacing(true);
/**
* create the tables and components
*/
SurveillanceViewAlarmTable surveillanceViewAlarmTable = new SurveillanceViewAlarmTable(m_surveillanceViewService, m_enabled);
SurveillanceViewNotificationTable surveillanceViewNotificationTable = new SurveillanceViewNotificationTable(m_surveillanceViewService, m_enabled);
SurveillanceViewNodeRtcTable surveillanceViewNodeRtcTable = new SurveillanceViewNodeRtcTable(m_surveillanceViewService, m_enabled);
SurveillanceViewGraphComponent surveillanceViewGraphComponent = new SurveillanceViewGraphComponent(m_surveillanceViewService, m_enabled);
/**
* add them to the layout
*/
surveillanceViewAlarmTable.setId("alarms");
lowerLayout.addComponent(surveillanceViewAlarmTable);
surveillanceViewNotificationTable.setId("notifications");
lowerLayout.addComponent(surveillanceViewNotificationTable);
surveillanceViewNodeRtcTable.setId("outages");
lowerLayout.addComponent(surveillanceViewNodeRtcTable);
surveillanceViewGraphComponent.setId("resourcegraphs");
lowerLayout.addComponent(surveillanceViewGraphComponent);
/**
* associate the detail tables and components with the surveillance view table
*/
m_surveillanceViewTable.addDetailsTable(surveillanceViewAlarmTable);
m_surveillanceViewTable.addDetailsTable(surveillanceViewNotificationTable);
m_surveillanceViewTable.addDetailsTable(surveillanceViewNodeRtcTable);
m_surveillanceViewTable.addDetailsTable(surveillanceViewGraphComponent);
/**
* add the layout to this component
*/
addComponent(lowerLayout);
leftCssLayout.addComponent(upperLayout);
leftCssLayout.addComponent(lowerLayout);
CssLayout resultsSidebar = new CssLayout();
resultsSidebar.setPrimaryStyleName("resource-graphs-sidebar hidden-print hidden-xs hidden-sm sidebar-fixed");
resultsSidebar.setId("results-sidebar");
resultsSidebar.addComponent(new Label("<ul class=\"nav nav-stacked\">\n" + " <li>\n" + " <a href=\"#surveillanceview\" data-target=\"#surveillanceview\">Surveillance View</a>\n" + " </li>\n" + " <li>\n" + " <a href=\"#alarms\" data-target=\"#alarms\">Alarms</a>\n" + " </li>\n" + " <li>\n" + " <a href=\"#notifications\" data-target=\"#notifications\">Notifications</a>\n" + " </li>\n" + " <li>\n" + " <a href=\"#outages\" data-target=\"#outages\">Outages</a>\n" + " </li>\n" + " <li>\n" + " <a href=\"#resourcegraphs\" data-target=\"#resourcegraphs\">Resource Graphs</a>\n" + " </li>\n" + " </ul>" + "<script type=\"text/javascript\">\n" + " $('body').scrollspy({ target: '#results-sidebar' });\n" + "</script>\n", ContentMode.HTML));
rightCssLayout.addComponent(resultsSidebar);
addComponent(leftCssLayout);
addComponent(rightCssLayout);
}
}
use of com.vaadin.ui.Component in project opennms by OpenNMS.
the class DashboardBody method setDashletSpecs.
/**
* This method sets the {@link List} of {@link DashletSpec} instances.
*
* @param dashletSpecs the list of {@link DashletSpec} instances
*/
public void setDashletSpecs(List<DashletSpec> dashletSpecs) {
m_displayDashlets = new HashMap<Component, DashletComponent>();
int c = 0;
List<DashletSpec> dashboardSuitableDashlets = new LinkedList<>();
if (dashletSpecs.size() == 0) {
return;
} else {
for (DashletSpec dashletSpec : dashletSpecs) {
if (suitableForDashboard(dashletSpec)) {
dashboardSuitableDashlets.add(dashletSpec);
}
}
}
if (dashboardSuitableDashlets.size() == 0) {
return;
}
int columns = (int) Math.ceil(Math.sqrt(dashboardSuitableDashlets.size()));
int rows = (int) Math.ceil((double) dashboardSuitableDashlets.size() / (double) columns);
setColumns(columns);
setRows(rows);
int i = 0;
removeAllComponents();
for (int y = 0; y < rows; y++) {
for (int x = 0; x < columns; x++) {
if (i < dashboardSuitableDashlets.size()) {
Dashlet dashlet = getDashletInstance(dashboardSuitableDashlets.get(i));
DashletComponent dashletComponent = dashlet.getDashboardComponent();
m_displayDashlets.put(dashletComponent.getComponent(), dashletComponent);
dashletComponent.refresh();
String caption = dashlet.getName();
if (dashlet.getDashletSpec().getTitle() != null) {
if (!"".equals(dashlet.getDashletSpec().getTitle())) {
caption += ": " + "" + dashlet.getDashletSpec().getTitle();
}
}
addComponent(createPanel(dashletComponent.getComponent(), caption), x, y);
i++;
}
}
}
}
use of com.vaadin.ui.Component in project opennms by OpenNMS.
the class NodeMapsApplication method getTabSheet.
/**
* Gets a {@link TabSheet} view for all widgets in this manager.
*
* @return TabSheet
*/
private Component getTabSheet() {
// Use an absolute layout for the bottom panel
AbsoluteLayout bottomLayout = new AbsoluteLayout();
bottomLayout.setSizeFull();
final TabSheet tabSheet = new TabSheet();
tabSheet.setSizeFull();
for (final SelectionAwareTable view : new SelectionAwareTable[] { m_alarmTable, m_nodeTable }) {
// Icon can be null
tabSheet.addTab(view, (view == m_alarmTable ? "Alarms" : "Nodes"), null);
// components to the tab bar
try {
final Component[] extras = ((HasExtraComponents) view).getExtraComponents();
if (extras != null && extras.length > 0) {
// For any extra controls, add a horizontal layout that will float
// on top of the right side of the tab panel
final HorizontalLayout extraControls = new HorizontalLayout();
extraControls.setHeight(32, Unit.PIXELS);
extraControls.setSpacing(true);
// Add the extra controls to the layout
for (final Component component : extras) {
extraControls.addComponent(component);
extraControls.setComponentAlignment(component, Alignment.MIDDLE_RIGHT);
}
// Add a TabSheet.SelectedTabChangeListener to show or hide the extra controls
tabSheet.addSelectedTabChangeListener(new SelectedTabChangeListener() {
@Override
public void selectedTabChange(final SelectedTabChangeEvent event) {
final TabSheet source = (TabSheet) event.getSource();
if (source == tabSheet) {
// If the first tab was selected...
if (source.getSelectedTab() == view) {
extraControls.setVisible(true);
} else {
extraControls.setVisible(false);
}
}
}
});
// Place the extra controls on the absolute layout
bottomLayout.addComponent(extraControls, "top:0px;right:5px;z-index:100");
}
} catch (ClassCastException e) {
}
view.setSizeFull();
}
// Add the tabsheet to the layout
bottomLayout.addComponent(tabSheet, "top: 0; left: 0; bottom: 0; right: 0;");
return bottomLayout;
}
use of com.vaadin.ui.Component in project charts by vaadin.
the class PieChart method getChart.
@Override
protected Component getChart() {
Component ret = createChart();
ret.setWidth("100%");
ret.setHeight("450px");
return ret;
}
use of com.vaadin.ui.Component in project charts by vaadin.
the class LibraryData method setup.
@Override
protected void setup() {
searchField.addValueChangeListener(e -> {
try {
result = Helmet.search(searchField.getValue());
updateChart();
updateSearchNavi();
} catch (IOException exc) {
// TODO Auto-generated catch block
exc.printStackTrace();
}
});
searchField.setValue("orwell");
HorizontalLayout searchNavi = new HorizontalLayout();
searchNavi.addComponent(searchField);
searchNavi.addComponent(prevButton);
searchNavi.addComponent(pageLabel);
searchNavi.addComponent(nextButton);
updateSearchNavi();
searchNavi.setWidth("100%");
content = this;
Component map = getChart();
content.setSizeFull();
content.addComponent(searchNavi);
content.addComponent(map);
content.setExpandRatio(map, 1);
}
Aggregations