List of usage examples for com.vaadin.ui HorizontalLayout setMargin
@Override public void setMargin(boolean enabled)
From source file:org.openeos.usertask.ui.internal.vaadin.TasksWindow.java
License:Apache License
private Component createToolbar() { HorizontalLayout hLayout = new HorizontalLayout(); hLayout.setMargin(false); hLayout.setWidth("100%"); hLayout.setSpacing(false);//from w w w .j av a 2 s . c o m hLayout.setStyleName(Reindeer.LAYOUT_BLACK); addToolbarButtons(hLayout); return hLayout; }
From source file:org.openeos.usertask.ui.internal.vaadin.TasksWindow.java
License:Apache License
private void addToolbarButtons(HorizontalLayout hLayout) { HorizontalLayout newLayout = new HorizontalLayout(); newLayout.setMargin(false); Button buttonRefresh = new Button(); buttonRefresh.setStyleName(Reindeer.BUTTON_LINK); buttonRefresh.setIcon(Resources.ICON_32_REFRESH); buttonRefresh.setDescription("Refresh"); buttonRefresh.addListener(new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override//from ww w .j av a2 s . com public void buttonClick(ClickEvent event) { refresh(); } }); newLayout.addComponent(buttonRefresh); Button buttonNew = new Button(); buttonNew.setStyleName(Reindeer.BUTTON_LINK); buttonNew.setIcon(Resources.ICON_32_NEW); buttonNew.setDescription("New task"); buttonNew.addListener(new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { newTask(); } }); newLayout.addComponent(buttonNew); hLayout.addComponent(newLayout); }
From source file:org.openeos.usertask.ui.internal.vaadin.TasksWindow.java
License:Apache License
private Component createTaskSummary(UserTask task) { // TextField name = new TextField("Name"); // name.setValue(task.getName()); // name.setReadOnly(true); // name.setWidth("100%"); TextField priority = new TextField("Priority"); priority.setValue(Integer.toString(task.getPriority())); priority.setReadOnly(true);// ww w. j ava 2 s . c om TextField status = new TextField("Status"); status.setValue(task.getStatus().getDescription()); status.setReadOnly(true); TextArea description = new TextArea("Description"); description.setSizeFull(); description.setValue(task.getDescription()); description.setReadOnly(true); description.setRows(3); ComponentContainer buttons = createSummaryButtons(task); VerticalLayout secondColumnFields = new VerticalLayout(); secondColumnFields.setMargin(false); secondColumnFields.setSizeFull(); secondColumnFields.addComponent(priority); secondColumnFields.addComponent(status); HorizontalLayout fieldsLayout = new HorizontalLayout(); fieldsLayout.setSizeFull(); fieldsLayout.setMargin(false); fieldsLayout.setSpacing(false); fieldsLayout.addComponent(description); fieldsLayout.addComponent(secondColumnFields); fieldsLayout.setExpandRatio(description, 4.0f); fieldsLayout.setExpandRatio(secondColumnFields, 1.0f); HorizontalLayout mainLayout = new HorizontalLayout(); mainLayout.setMargin(true); mainLayout.setSpacing(false); mainLayout.setSizeFull(); mainLayout.addComponent(fieldsLayout); mainLayout.addComponent(buttons); mainLayout.setComponentAlignment(buttons, Alignment.TOP_LEFT); mainLayout.setExpandRatio(fieldsLayout, 1.0f); Panel panel = new Panel("Summary"); panel.setStyleName("background-transparent"); panel.setContent(mainLayout); return panel; }
From source file:org.openeos.vaadin.main.internal.MainApplication.java
License:Apache License
private Layout getHeader() { HorizontalLayout header = new HorizontalLayout(); header.setWidth("100%"); header.setMargin(true); header.setSpacing(true);/*from w w w .ja v a 2s . co m*/ // header.setStyleName(Reindeer.LAYOUT_BLACK); CssLayout titleLayout = new CssLayout(); H2 title = new H2("Dynamic Vaadin OSGi Demo"); titleLayout.addComponent(title); SmallText description = new SmallText( "Select the \"Bundle View\" tab and activate/stop OSGi bundles dynamically."); description.setSizeUndefined(); titleLayout.addComponent(description); header.addComponent(titleLayout); Component notificationArea = notificationManager.getComponent(this); header.addComponent(notificationArea); header.setComponentAlignment(notificationArea, Alignment.MIDDLE_RIGHT); return header; }
From source file:org.opennms.features.topology.api.support.DialogWindow.java
License:Open Source License
private Layout createMainArea(final String description) { HorizontalLayout layout = new HorizontalLayout(); layout.setSpacing(true);/*from ww w . java 2s.com*/ layout.setMargin(true); layout.setWidth(100, Unit.PERCENTAGE); Label label = new Label(description, ContentMode.PREFORMATTED); label.setWidth(100, Unit.PERCENTAGE); layout.addComponent(label); return layout; }
From source file:org.opennms.features.topology.api.support.DialogWindow.java
License:Open Source License
private Layout createFooter() { HorizontalLayout footer = new HorizontalLayout(); footer.setSpacing(true);//from w ww. j a va 2s. com footer.setMargin(true); footer.setWidth(100, Unit.PERCENTAGE); footer.addComponent(okayButton); footer.setComponentAlignment(okayButton, Alignment.BOTTOM_RIGHT); return footer; }
From source file:org.opennms.features.topology.app.internal.TopologyUI.java
License:Open Source License
@Override public void menuBarUpdated(CommandManager commandManager) { if (m_menuBar != null) { m_rootLayout.removeComponent(m_menuBar); }/* w w w .ja va 2 s .c o m*/ if (m_contextMenu != null) { m_contextMenu.detach(); } m_menuBar = commandManager.getMenuBar(m_graphContainer, this); m_menuBar.setWidth(100, Unit.PERCENTAGE); // Set expand ratio so that extra space is not allocated to this vertical component if (m_showHeader) { m_rootLayout.addComponent(m_menuBar, 1); } else { m_rootLayout.addComponent(m_menuBar, 0); } m_contextMenu = commandManager .getContextMenu(new DefaultOperationContext(this, m_graphContainer, DisplayLocation.CONTEXTMENU)); m_contextMenu.setAsContextMenuOf(this); // Add Menu Item to share the View with others m_menuBar.addItem("Share", FontAwesome.SHARE, new MenuBar.Command() { @Override public void menuSelected(MenuItem selectedItem) { // create the share link String fragment = getPage().getLocation().getFragment(); String url = getPage().getLocation().toString().replace("#" + getPage().getLocation().getFragment(), ""); String shareLink = String.format("%s?%s=%s", url, TopologyUIRequestHandler.PARAMETER_HISTORY_FRAGMENT, fragment); // Create the Window Window shareWindow = new Window(); shareWindow.setCaption("Share Link"); shareWindow.setModal(true); shareWindow.setClosable(true); shareWindow.setResizable(false); shareWindow.setWidth(400, Unit.PIXELS); TextArea shareLinkField = new TextArea(); shareLinkField.setValue(shareLink); shareLinkField.setReadOnly(true); shareLinkField.setRows(3); shareLinkField.setWidth(100, Unit.PERCENTAGE); // Close Button Button close = new Button("Close"); close.setClickShortcut(ShortcutAction.KeyCode.ESCAPE, null); close.addClickListener(event -> shareWindow.close()); // Layout for Buttons HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setMargin(true); buttonLayout.setSpacing(true); buttonLayout.setWidth("100%"); buttonLayout.addComponent(close); buttonLayout.setComponentAlignment(close, Alignment.BOTTOM_RIGHT); // Content Layout VerticalLayout verticalLayout = new VerticalLayout(); verticalLayout.setMargin(true); verticalLayout.setSpacing(true); verticalLayout.addComponent( new Label("Please use the following link to share the current view with others.")); verticalLayout.addComponent(shareLinkField); verticalLayout.addComponent(buttonLayout); shareWindow.setContent(verticalLayout); getUI().addWindow(shareWindow); } }); updateMenuItems(); }
From source file:org.opennms.features.topology.app.internal.ui.NoContentAvailableWindow.java
License:Open Source License
public NoContentAvailableWindow(final GraphContainer graphContainer) { super("No focus defined"); setResizable(false);/*from w w w . j ava 2 s . c o m*/ setClosable(false); setDraggable(true); setModal(false); setWidth(500, Sizeable.Unit.PIXELS); setHeight(300, Sizeable.Unit.PIXELS); Label label = new Label("This means" + "<ul>" + "<li>the last vertex was removed from focus or</li>" + "<li>no default focus is available.</li>" + "</ul>" + "To add a vertex to focus" + "<ul>" + "<li>manually add a vertex to focus via the search box</li>" + "<li>use the default focus</li>" + "</ul>", ContentMode.HTML); final HorizontalLayout defaultLayout = new HorizontalLayout(); defaultLayout.setMargin(true); defaultLayout.setSpacing(true); noDefaultsAvailable = new Label("No vertices found.<br/>Please add vertices manually.", ContentMode.HTML); noDefaultsAvailable.setVisible(false); Button defaultFocusButton = new Button("Use Default Focus"); defaultFocusButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { Criteria defaultCriteria = graphContainer.getBaseTopology().getDefaultCriteria(); if (defaultCriteria != null) { // check if there is already a criteria registered for focus vertices. If so, remove them Criteria[] allCriteria = graphContainer.getCriteria(); for (Criteria criterion : allCriteria) { graphContainer.removeCriteria(criterion); } graphContainer.addCriteria(defaultCriteria); // add default criteria graphContainer.redoLayout(); // we need to redo the layout noDefaultsAvailable.setVisible(false); } else { noDefaultsAvailable.setVisible(true); } } }); defaultLayout.setMargin(true); defaultLayout.addComponent(defaultFocusButton); defaultLayout.addComponent(noDefaultsAvailable); VerticalLayout contentLayout = new VerticalLayout(); contentLayout.setMargin(true); contentLayout.addComponent(label); contentLayout.addComponent(defaultLayout); setContent(contentLayout); }
From source file:org.opennms.features.topology.app.internal.ui.ToolbarPanel.java
License:Open Source License
public ToolbarPanel(final ToolbarPanelController controller) { addStyleName(Styles.TOOLBAR);//from w w w. java 2 s . c om this.layoutManager = controller.getLayoutManager(); final Property<Double> scale = controller.getScaleProperty(); final Boolean[] eyeClosed = new Boolean[] { false }; final Button showFocusVerticesBtn = new Button(); showFocusVerticesBtn.setIcon(FontAwesome.EYE); showFocusVerticesBtn.setDescription("Toggle Highlight Focus Nodes"); showFocusVerticesBtn.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { if (eyeClosed[0]) { showFocusVerticesBtn.setIcon(FontAwesome.EYE); } else { showFocusVerticesBtn.setIcon(FontAwesome.EYE_SLASH); } eyeClosed[0] = !eyeClosed[0]; // toggle controller.toggleHighlightFocus(); } }); final Button magnifyBtn = new Button(); magnifyBtn.setIcon(FontAwesome.PLUS); magnifyBtn.setDescription("Magnify"); magnifyBtn.addClickListener( (Button.ClickListener) event -> scale.setValue(Math.min(1, scale.getValue() + 0.25))); final Button demagnifyBtn = new Button(); demagnifyBtn.setIcon(FontAwesome.MINUS); demagnifyBtn.setDescription("Demagnify"); demagnifyBtn.addClickListener( (Button.ClickListener) event -> scale.setValue(Math.max(0, scale.getValue() - 0.25))); m_szlOutBtn = new Button(); m_szlOutBtn.setId("szlOutBtn"); m_szlOutBtn.setIcon(FontAwesome.ANGLE_DOWN); m_szlOutBtn.setDescription("Decrease Semantic Zoom Level"); m_szlOutBtn.setEnabled(controller.getSemanticZoomLevel() > 0); m_szlOutBtn.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { int szl = controller.getSemanticZoomLevel(); if (szl > 0) { setSemanticZoomLevel(controller, szl - 1); controller.saveHistory(); } } }); final Button szlInBtn = new Button(); szlInBtn.setId("szlInBtn"); szlInBtn.setIcon(FontAwesome.ANGLE_UP); szlInBtn.setDescription("Increase Semantic Zoom Level"); szlInBtn.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { setSemanticZoomLevel(controller, controller.getSemanticZoomLevel() + 1); controller.saveHistory(); } }); m_zoomLevelLabel.setId("szlInputLabel"); m_panBtn = new Button(); m_panBtn.setIcon(FontAwesome.ARROWS); m_panBtn.setDescription("Pan Tool"); m_panBtn.addStyleName(Styles.SELECTED); m_selectBtn = new Button(); m_selectBtn.setIcon(IonicIcons.ANDROID_EXPAND); m_selectBtn.setDescription("Selection Tool"); m_selectBtn.setStyleName("toolbar-button"); m_selectBtn.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { m_selectBtn.addStyleName(Styles.SELECTED); m_panBtn.removeStyleName(Styles.SELECTED); controller.setActiveTool(ActiveTool.select); } }); m_panBtn.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { m_panBtn.addStyleName(Styles.SELECTED); m_selectBtn.removeStyleName(Styles.SELECTED); controller.setActiveTool(ActiveTool.pan); } }); Button showAllMapBtn = new Button(); showAllMapBtn.setId("showEntireMapBtn"); showAllMapBtn.setIcon(FontAwesome.GLOBE); showAllMapBtn.setDescription("Show Entire Map"); showAllMapBtn.addClickListener((Button.ClickListener) event -> controller.showAllMap()); Button centerSelectionBtn = new Button(); centerSelectionBtn.setIcon(FontAwesome.LOCATION_ARROW); centerSelectionBtn.setDescription("Center On Selection"); centerSelectionBtn.addClickListener((Button.ClickListener) event -> controller.centerMapOnSelection()); Button shareButton = new Button("", FontAwesome.SHARE_SQUARE_O); shareButton.setDescription("Share"); shareButton.addClickListener((x) -> { // Create the share link String fragment = getUI().getPage().getLocation().getFragment(); String url = getUI().getPage().getLocation().toString().replace("#" + fragment, ""); String shareLink = String.format("%s?%s=%s", url, PARAMETER_HISTORY_FRAGMENT, fragment); // Create the Window Window shareWindow = new Window(); shareWindow.setCaption("Share Link"); shareWindow.setModal(true); shareWindow.setClosable(true); shareWindow.setResizable(false); shareWindow.setWidth(400, Sizeable.Unit.PIXELS); TextArea shareLinkField = new TextArea(); shareLinkField.setValue(shareLink); shareLinkField.setReadOnly(true); shareLinkField.setRows(3); shareLinkField.setWidth(100, Sizeable.Unit.PERCENTAGE); // Close Button Button close = new Button("Close"); close.setClickShortcut(ShortcutAction.KeyCode.ESCAPE, null); close.addClickListener(event -> shareWindow.close()); // Layout for Buttons HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setMargin(true); buttonLayout.setSpacing(true); buttonLayout.setWidth("100%"); buttonLayout.addComponent(close); buttonLayout.setComponentAlignment(close, Alignment.BOTTOM_RIGHT); // Content Layout VerticalLayout verticalLayout = new VerticalLayout(); verticalLayout.setMargin(true); verticalLayout.setSpacing(true); verticalLayout.addComponent( new Label("Please use the following link to share the current view with others.")); verticalLayout.addComponent(shareLinkField); verticalLayout.addComponent(buttonLayout); shareWindow.setContent(verticalLayout); getUI().addWindow(shareWindow); }); // Refresh Button Button refreshButton = new Button(); refreshButton.setId("refreshNow"); refreshButton.setIcon(FontAwesome.REFRESH); refreshButton.setDescription("Refresh Now"); refreshButton.addClickListener((event) -> controller.refreshUI()); // Layer Layout layerLayout = new VerticalLayout(); layerLayout.setId("layerComponent"); layerLayout.setSpacing(true); layerLayout.setMargin(true); // Layer Button layerButton = new Button(); layerButton.setId("layerToggleButton"); layerButton.setIcon(FontAwesome.BARS); layerButton.setDescription("Layers"); layerButton.addClickListener((event) -> { boolean isCollapsed = layerButton.getStyleName().contains(Styles.EXPANDED); setLayerLayoutVisible(!isCollapsed); }); // Save button layerSaveButton = new Button(); layerSaveButton.setId("saveLayerButton"); layerSaveButton.setIcon(FontAwesome.FLOPPY_O); layerSaveButton.addClickListener((event) -> controller.saveLayout()); // Actual Layout for the Toolbar CssLayout contentLayout = new CssLayout(); contentLayout.addStyleName("toolbar-component"); contentLayout.addComponent(createGroup(szlInBtn, m_zoomLevelLabel, m_szlOutBtn)); contentLayout.addComponent( createGroup(refreshButton, centerSelectionBtn, showAllMapBtn, layerButton, showFocusVerticesBtn)); contentLayout.addComponent(createGroup(m_panBtn, m_selectBtn)); contentLayout.addComponent(createGroup(magnifyBtn, demagnifyBtn)); contentLayout.addComponent(createGroup(shareButton)); contentLayout.addComponent(createGroup(layerSaveButton)); // Toolbar addComponent(contentLayout); }
From source file:org.opennms.features.vaadin.config.DataCollectionGroupAdminPanel.java
License:Open Source License
/** * Instantiates a new data collection group administration panel. * * @param dataCollectionDao the OpenNMS data collection configuration DAO *//*from w w w . java 2 s .c om*/ public DataCollectionGroupAdminPanel(final DataCollectionConfigDao dataCollectionDao) { setCaption("Data Collection Groups"); final HorizontalLayout toolbar = new HorizontalLayout(); toolbar.setMargin(true); final Label comboLabel = new Label("Select Data Collection Group File"); toolbar.addComponent(comboLabel); toolbar.setComponentAlignment(comboLabel, Alignment.MIDDLE_LEFT); final File datacollectionDir = new File(ConfigFileConstants.getFilePathString(), "datacollection"); final ComboBox dcGroupSource = new ComboBox(); toolbar.addComponent(dcGroupSource); dcGroupSource.setImmediate(true); dcGroupSource.setNullSelectionAllowed(false); dcGroupSource.setContainerDataSource(new XmlFileContainer(datacollectionDir, false)); dcGroupSource.setItemCaptionPropertyId(FilesystemContainer.PROPERTY_NAME); dcGroupSource.addValueChangeListener(new ComboBox.ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { final File file = (File) event.getProperty().getValue(); if (file == null) return; try { LOG.info("Loading data collection data from {}", file); DatacollectionGroup dcGroup = JaxbUtils.unmarshal(DatacollectionGroup.class, file); m_selectedGroup = dcGroup.getName(); addDataCollectionGroupPanel(dataCollectionDao, file, dcGroup); } catch (Exception e) { LOG.error("an error ocurred while parsing the data collection configuration {}: {}", file, e.getMessage(), e); Notification.show("Can't parse file " + file + " because " + e.getMessage()); } } }); final Button add = new Button("Add New Data Collection File"); toolbar.addComponent(add); add.addClickListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { PromptWindow w = new PromptWindow("New Data Collection Group", "Group Name") { @Override public void textFieldChanged(String fieldValue) { File file = new File(datacollectionDir, fieldValue.replaceAll(" ", "_") + ".xml"); LOG.info("Adding new data collection file {}", file); DatacollectionGroup dcGroup = new DatacollectionGroup(); dcGroup.setName(fieldValue); addDataCollectionGroupPanel(dataCollectionDao, file, dcGroup); } }; getUI().addWindow(w); } }); final Button remove = new Button("Remove Selected Data Collection File"); toolbar.addComponent(remove); remove.addClickListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { if (dcGroupSource.getValue() == null) { Notification.show("Please select a data collection group configuration file."); return; } final File file = (File) dcGroupSource.getValue(); ConfirmDialog.show(getUI(), "Are you sure?", "Do you really want to remove the file " + file.getName() + "?\nThis cannot be undone and OpenNMS won't be able to collect the metrics defined on this file.", "Yes", "No", new ConfirmDialog.Listener() { public void onClose(ConfirmDialog dialog) { if (dialog.isConfirmed()) { LOG.info("deleting file {}", file); if (file.delete()) { try { // Updating datacollection-config.xml File configFile = ConfigFileConstants .getFile(ConfigFileConstants.DATA_COLLECTION_CONF_FILE_NAME); DatacollectionConfig config = JaxbUtils .unmarshal(DatacollectionConfig.class, configFile); boolean modified = false; for (SnmpCollection collection : config.getSnmpCollections()) { for (Iterator<IncludeCollection> it = collection .getIncludeCollections().iterator(); it.hasNext();) { IncludeCollection ic = it.next(); if (m_selectedGroup != null && m_selectedGroup .equals(ic.getDataCollectionGroup())) { it.remove(); modified = true; } } } if (modified) { LOG.info("updating data colleciton configuration on {}.", configFile); JaxbUtils.marshal(config, new FileWriter(configFile)); } // Updating UI Components dcGroupSource.select(null); removeDataCollectionGroupPanel(); } catch (Exception e) { LOG.error( "an error ocurred while saving the data collection configuration: {}", e.getMessage(), e); Notification.show( "Can't save data collection configuration. " + e.getMessage(), Notification.Type.ERROR_MESSAGE); } } else { Notification.show("Cannot delete file " + file, Notification.Type.WARNING_MESSAGE); } } } }); } }); addComponent(toolbar); addComponent(new Label("")); setComponentAlignment(toolbar, Alignment.MIDDLE_RIGHT); }