use of com.vaadin.ui.HorizontalLayout 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.HorizontalLayout in project opennms by OpenNMS.
the class BSMDashlet method createRow.
private HorizontalLayout createRow(BusinessService service) {
HorizontalLayout rowLayout = new HorizontalLayout();
rowLayout.setSizeFull();
rowLayout.setSpacing(true);
final Status severity = m_businessServiceManager.getOperationalStatus(service);
Label nameLabel = new Label(service.getName());
nameLabel.setSizeFull();
nameLabel.setStyleName("h3");
nameLabel.addStyleName("bright");
nameLabel.addStyleName("severity");
nameLabel.addStyleName(severity.getLabel());
rowLayout.addComponent(nameLabel);
return rowLayout;
}
use of com.vaadin.ui.HorizontalLayout in project opennms by OpenNMS.
the class AlarmsDashlet method createAlarmComponent.
/**
* Returns the component for visualising the alarms data.
*
* @param onmsAlarm an {@link OnmsAlarm} instance
* @param onmsNode an {@link OnmsNode} instance
* @return component for this alarm
*/
public Component createAlarmComponent(OnmsAlarm onmsAlarm, OnmsNode onmsNode) {
Calendar calendar = Calendar.getInstance();
String ago = getHumanReadableFormat((calendar.getTimeInMillis() / 1000) - (onmsAlarm.getLastEventTime().getTime() / 1000));
HorizontalLayout horizontalLayout = new HorizontalLayout();
horizontalLayout.setWidth("100%");
horizontalLayout.addStyleName("alerts");
horizontalLayout.addStyleName(onmsAlarm.getSeverity().name().toLowerCase());
Label labelAgo = new Label();
labelAgo.setSizeUndefined();
labelAgo.addStyleName("alerts-font");
labelAgo.setValue(ago);
Label labelId = new Label();
labelId.setSizeUndefined();
labelId.addStyleName("alerts-font");
if (onmsNode != null) {
labelId.setValue(onmsNode.getLabel() + " (" + onmsNode.getNodeId() + ")");
} else {
labelId.setValue("-");
}
Label labelUei = new Label();
labelUei.setSizeUndefined();
labelUei.addStyleName("alerts-font");
labelUei.setValue(onmsAlarm.getUei());
horizontalLayout.addComponent(labelAgo);
horizontalLayout.addComponent(labelId);
horizontalLayout.addComponent(labelUei);
horizontalLayout.setExpandRatio(labelAgo, 1.0f);
horizontalLayout.setExpandRatio(labelId, 3.0f);
horizontalLayout.setExpandRatio(labelUei, 3.0f);
return horizontalLayout;
}
use of com.vaadin.ui.HorizontalLayout in project opennms by OpenNMS.
the class AlarmDetailsDashlet method createAlarmComponent.
/**
* Returns the component for visualising the alarms data.
*
* @param onmsAlarm an {@link OnmsAlarm} instance
* @param onmsNode an {@link OnmsNode} instance
* @return component for this alarm
*/
@Deprecated
public Component createAlarmComponent(OnmsAlarm onmsAlarm, OnmsNode onmsNode) {
HorizontalLayout horizontalLayout = new HorizontalLayout();
horizontalLayout.setSizeFull();
horizontalLayout.addStyleName("alert-details");
horizontalLayout.addStyleName("alert-details-font");
horizontalLayout.addStyleName(onmsAlarm.getSeverity().name().toLowerCase());
VerticalLayout verticalLayout1 = new VerticalLayout();
VerticalLayout verticalLayout2 = new VerticalLayout();
horizontalLayout.addComponent(verticalLayout1);
horizontalLayout.addComponent(verticalLayout2);
Label lastEvent = new Label();
lastEvent.setSizeUndefined();
lastEvent.addStyleName("alert-details-font");
lastEvent.setCaption("Last event");
lastEvent.setValue(StringUtils.toStringEfficiently(onmsAlarm.getLastEventTime()));
Label firstEvent = new Label();
firstEvent.setSizeUndefined();
firstEvent.addStyleName("alert-details-font");
firstEvent.setCaption("First event");
firstEvent.setValue(StringUtils.toStringEfficiently(onmsAlarm.getFirstEventTime()));
verticalLayout1.addComponent(firstEvent);
verticalLayout1.addComponent(lastEvent);
Label nodeId = new Label();
nodeId.setSizeUndefined();
nodeId.addStyleName("alert-details-font");
nodeId.setCaption("Node Id");
if (onmsNode != null) {
nodeId.setValue(onmsNode.getNodeId());
} else {
nodeId.setValue("-");
}
Label nodeLabel = new Label();
nodeLabel.setSizeUndefined();
nodeLabel.addStyleName("alert-details-font");
nodeLabel.setCaption("Node Label");
if (onmsNode != null) {
nodeLabel.setValue(onmsNode.getLabel());
} else {
nodeLabel.setValue("-");
}
Label logMessage = new Label();
logMessage.addStyleName("alert-details-font");
logMessage.setSizeFull();
logMessage.setCaption("Log message");
logMessage.setValue(onmsAlarm.getLogMsg().replaceAll("<[^>]*>", ""));
HorizontalLayout horizontalLayout2 = new HorizontalLayout();
horizontalLayout2.setSizeFull();
horizontalLayout2.setSpacing(true);
horizontalLayout2.addComponent(nodeId);
horizontalLayout2.addComponent(nodeLabel);
verticalLayout2.addComponent(horizontalLayout2);
verticalLayout2.addComponent(logMessage);
horizontalLayout.setExpandRatio(verticalLayout1, 1.0f);
horizontalLayout.setExpandRatio(verticalLayout2, 4.0f);
return horizontalLayout;
}
use of com.vaadin.ui.HorizontalLayout 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);
}
});
}
});
}
Aggregations