List of usage examples for com.vaadin.ui HorizontalLayout setPrimaryStyleName
@Override public void setPrimaryStyleName(String style)
From source file:ch.bfh.ti.soed.hs16.srs.red.ui.helper.SubWindowReservation.java
License:Open Source License
public SubWindowReservation() { this.layout = new VerticalLayout(); this.id = new Label("id"); this.name = new Label("name"); this.roomTitle = new Label("select room"); this.startTime = new Label("start time"); this.endTime = new Label("end time"); this.textFieldId = new TextField(); this.textFieldName = new TextField(); this.rooms = new ComboBox(); this.dateFieldStart = new DateField(); this.dateFieldEnd = new DateField(); this.buttonSave = new Button("save"); this.buttonDelete = new Button("delete"); dateFieldStart.setResolution(Resolution.MINUTE); dateFieldEnd.setResolution(Resolution.MINUTE); /*--------------------------------- add objects to horizontal container/*w w w .ja va 2 s . c om*/ ---------------------------------*/ HorizontalLayout idContainer = new HorizontalLayout(id, textFieldId); HorizontalLayout nameContainer = new HorizontalLayout(name, textFieldName); HorizontalLayout roomContainer = new HorizontalLayout(roomTitle, rooms); HorizontalLayout startContainer = new HorizontalLayout(startTime, dateFieldStart); HorizontalLayout endContainer = new HorizontalLayout(endTime, dateFieldEnd); HorizontalLayout buttons = new HorizontalLayout(buttonSave, buttonDelete); /*--------------------------------- add style names ---------------------------------*/ layout.setPrimaryStyleName(CSS_NAME); idContainer.setPrimaryStyleName(CSS_NAME + "-horizontalContainer"); nameContainer.setPrimaryStyleName(CSS_NAME + "-horizontalContainer"); roomContainer.setPrimaryStyleName(CSS_NAME + "-horizontalContainer"); startContainer.setPrimaryStyleName(CSS_NAME + "-horizontalContainer"); endContainer.setPrimaryStyleName(CSS_NAME + "-horizontalContainer"); buttons.setPrimaryStyleName(CSS_NAME + "-horizontalContainer"); /*--------------------------------- add to root layout ---------------------------------*/ this.layout.addComponents(idContainer, nameContainer, roomContainer, startContainer, endContainer, buttons); }
From source file:com.adonis.ui.menu.Menu.java
private void createViewButtonWithEditableImage(final String name, String caption, String nameImage) { Button button = new Button(caption, new ClickListener() { @Override//www . j a v a 2s. c o m public void buttonClick(ClickEvent event) { navigator.navigateTo(name); } }); button.setPrimaryStyleName(ValoTheme.BUTTON_FRIENDLY); // button.setWidth(50, Unit.PERCENTAGE); image.setWidth(90, Unit.PIXELS); image.setHeight(90, Unit.PIXELS); FileReader.createDirectoriesFromCurrent(getInitialPath()); final Image image = new Image("", new ThemeResource("img/" + nameImage)); try { FileReader.copyFile(VaadinUtils.getResourcePath(nameImage), VaadinUtils.getInitialPath() + File.separator + nameImage); image.setSource(new FileResource(new File(VaadinUtils.getInitialPath() + File.separator + nameImage))); } catch (IOException e) { e.printStackTrace(); image.setSource(new ThemeResource("img/" + nameImage)); } // image.setWidth(50, Unit.PERCENTAGE); image.setWidth(90, Unit.PIXELS); image.setHeight(90, Unit.PIXELS); HorizontalLayout horizontalLayout = new HorizontalLayout(); horizontalLayout.setPrimaryStyleName(ValoTheme.MENU_ITEM); horizontalLayout.addComponents(image, button); image.addClickListener(new MouseEvents.ClickListener() { @Override public void click(MouseEvents.ClickEvent event) { uploadFieldImage = new UploadField(); uploadFieldImage.setAcceptFilter("image/*"); uploadFieldImage.getUpload().addListener(new com.vaadin.v7.ui.Upload.FailedListener() { @Override public void uploadFailed(com.vaadin.v7.ui.Upload.FailedEvent event) { uploadFieldImage.clearDefaulLayout(); horizontalLayout.removeComponent(uploadFieldImage); } private static final long serialVersionUID = 1L; }); horizontalLayout.addComponent(uploadFieldImage, 2); uploadFieldImage.getUpload().addListener(new com.vaadin.v7.ui.Upload.SucceededListener() { @Override public void uploadSucceeded(com.vaadin.v7.ui.Upload.SucceededEvent event) { File file = (File) uploadFieldImage.getValue(); try { showUploadedImage(uploadFieldImage, image, file.getName(), nameImage); } catch (IOException e) { e.printStackTrace(); } uploadFieldImage.clearDefaulLayout(); horizontalLayout.removeComponent(uploadFieldImage); } }); uploadFieldImage.setFieldType(UploadField.FieldType.FILE); horizontalLayout.markAsDirty(); // image.setWidth(50, Unit.PERCENTAGE); image.setWidth(90, Unit.PIXELS); image.setHeight(90, Unit.PIXELS); image.setVisible(false); image.markAsDirty(); horizontalLayout.addComponent(image, 0); } }); button.setVisible(true); image.setVisible(true); menuItemsLayout.addComponents(horizontalLayout); viewButtons.put(name, button); }
From source file:org.opennms.features.vaadin.surveillanceviews.ui.dashboard.SurveillanceViewGraphComponent.java
License:Open Source License
/** * Constructor for instantiating this component. * * @param surveillanceViewService the surveillance view service to be used * @param enabled the flag should links be enabled? *///from ww w .jav a 2s . c om public SurveillanceViewGraphComponent(SurveillanceViewService surveillanceViewService, boolean enabled) { /** * set the fields */ m_surveillanceViewService = surveillanceViewService; m_enabled = enabled; /** * create layout for caption */ HorizontalLayout horizontalLayout = new HorizontalLayout(); horizontalLayout.setWidth(100, Unit.PERCENTAGE); horizontalLayout.setSpacing(false); horizontalLayout.setPrimaryStyleName("v-caption-surveillance-view"); horizontalLayout.addComponent(new Label("Resource Graphs")); addComponent(horizontalLayout); /** * create node selection box */ m_nodeSelect = new NativeSelect(); m_nodeSelect.setNullSelectionAllowed(false); m_nodeSelect.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent valueChangeEvent) { Integer onmsNodeId = (Integer) m_nodeSelect.getValue(); m_resourceSelect.removeAllItems(); if (onmsNodeId != null) { Map<OnmsResourceType, List<OnmsResource>> map = getSurveillanceViewService() .getResourceTypeMapForNodeId(onmsNodeId); for (OnmsResourceType onmsResourceType : map.keySet()) { for (OnmsResource onmsResource : map.get(onmsResourceType)) { m_resourceSelect.addItem(onmsResource.getId()); m_resourceSelect.setItemCaption(onmsResource.getId(), onmsResourceType.getLabel() + ": " + onmsResource.getLabel()); } } Iterator<?> i = m_resourceSelect.getItemIds().iterator(); if (i.hasNext()) { m_resourceSelect.select(i.next()); } } } }); /** * create resource selection box */ m_resourceSelect = new NativeSelect(); m_resourceSelect.setNullSelectionAllowed(false); m_resourceSelect.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent valueChangeEvent) { String onmsResourceId = (String) m_resourceSelect.getValue(); m_graphSelect.removeAllItems(); if (onmsResourceId != null) { Map<String, String> map = getSurveillanceViewService() .getGraphResultsForResourceId(onmsResourceId); for (String string : map.keySet()) { m_graphSelect.addItem(map.get(string)); m_graphSelect.setItemCaption(map.get(string), string); } Iterator<?> i = m_graphSelect.getItemIds().iterator(); if (i.hasNext()) { m_graphSelect.select(i.next()); } } } }); /** * create graph selection box */ m_graphSelect = new NativeSelect(); m_graphSelect.setNullSelectionAllowed(false); m_graphSelect.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent valueChangeEvent) { String graphName = (String) m_graphSelect.getValue(); String resourceId = (String) m_resourceSelect.getValue(); replaceGraph(graphName, resourceId); } }); /** * set box sizes to full */ m_nodeSelect.setSizeFull(); m_resourceSelect.setSizeFull(); m_graphSelect.setSizeFull(); /** * add box styles */ m_nodeSelect.addStyleName("surveillance-view"); m_resourceSelect.addStyleName("surveillance-view"); m_graphSelect.addStyleName("surveillance-view"); /** * create layout for storing the graph */ m_graphLayout = new VerticalLayout(); m_graphLayout.setSizeUndefined(); m_graphLayout.setWidth(100, Unit.PERCENTAGE); /** * create layout for selection boxes */ HorizontalLayout selectionBoxesLayout = new HorizontalLayout(); selectionBoxesLayout.setSizeFull(); selectionBoxesLayout.addComponent(m_nodeSelect); selectionBoxesLayout.addComponent(m_resourceSelect); selectionBoxesLayout.addComponent(m_graphSelect); m_graphLayout.setId("graphLayout"); /** * ...and call it when page is constructed. Also add a resize listener... */ addAttachListener(new AttachListener() { @Override public void attach(AttachEvent attachEvent) { getUI().getPage().addBrowserWindowResizeListener(SurveillanceViewGraphComponent.this); } }); /** * ... and remove the resize listener on detach event */ addDetachListener(new DetachListener() { @Override public void detach(DetachEvent detachEvent) { getUI().getPage().removeBrowserWindowResizeListener(SurveillanceViewGraphComponent.this); } }); /** * add layout for selection boxes and image */ addComponent(selectionBoxesLayout); addComponent(m_graphLayout); }