Search in sources :

Example 16 with FormLayout

use of com.vaadin.ui.FormLayout in project opennms by OpenNMS.

the class BusinessServiceVertexStatusInfoPanelItemProvider method createComponent.

private Component createComponent(BusinessServiceVertex vertex, GraphContainer container) {
    final FormLayout rootLayout = new FormLayout();
    rootLayout.setSizeFull();
    rootLayout.setSpacing(false);
    rootLayout.setMargin(false);
    rootLayout.addStyleName("severity");
    final BusinessServiceStateMachine stateMachine = SimulationAwareStateMachineFactory.createStateMachine(businessServiceManager, container.getCriteria());
    final Status overallStatus = BusinessServicesStatusProvider.getStatus(stateMachine, vertex);
    rootLayout.addComponent(createStatusLabel("Overall", overallStatus));
    rootLayout.addComponent(new Label());
    final BusinessServiceGraph graph = stateMachine.getGraph();
    final BusinessService businessService = businessServiceManager.getBusinessServiceById(vertex.getServiceId());
    final Set<GraphVertex> impactingVertices = getImpactingVertices(stateMachine, graph, businessService);
    for (final Edge edge : businessService.getEdges()) {
        // Get the topology vertex for the child to determine the display label
        final Vertex childVertex = businessServicesTopologyProvider.getVertex(edge.accept(new EdgeVisitor<VertexRef>() {

            @Override
            public VertexRef visit(final IpServiceEdge edge) {
                return new IpServiceVertex(edge.getIpService(), 0);
            }

            @Override
            public VertexRef visit(final ReductionKeyEdge edge) {
                return new ReductionKeyVertex(edge.getReductionKey(), 0);
            }

            @Override
            public VertexRef visit(final ChildEdge edge) {
                return new BusinessServiceVertex(edge.getChild(), 0);
            }
        }));
        final Status edgeStatus = stateMachine.getOperationalStatus(edge);
        rootLayout.addComponent(createStatusLabel(childVertex.getLabel(), edgeStatus, String.format("%s &times; %d <i class=\"pull-right glyphicon %s\"></i>", edgeStatus.getLabel(), edge.getWeight(), impactingVertices.contains(graph.getVertexByEdgeId(edge.getId())) ? "glyphicon-flash" : "")));
    }
    return rootLayout;
}
Also used : FormLayout(com.vaadin.ui.FormLayout) Status(org.opennms.netmgt.bsm.service.model.Status) Vertex(org.opennms.features.topology.api.topo.Vertex) IpServiceVertex(org.opennms.features.topology.plugins.topo.bsm.IpServiceVertex) GraphVertex(org.opennms.netmgt.bsm.service.model.graph.GraphVertex) BusinessServiceVertex(org.opennms.features.topology.plugins.topo.bsm.BusinessServiceVertex) ReductionKeyVertex(org.opennms.features.topology.plugins.topo.bsm.ReductionKeyVertex) ReductionKeyVertex(org.opennms.features.topology.plugins.topo.bsm.ReductionKeyVertex) ChildEdge(org.opennms.netmgt.bsm.service.model.edge.ChildEdge) Label(com.vaadin.ui.Label) UIHelper.createLabel(org.opennms.netmgt.vaadin.core.UIHelper.createLabel) IpServiceEdge(org.opennms.netmgt.bsm.service.model.edge.IpServiceEdge) BusinessServiceGraph(org.opennms.netmgt.bsm.service.model.graph.BusinessServiceGraph) EdgeVisitor(org.opennms.netmgt.bsm.service.model.edge.EdgeVisitor) IpServiceVertex(org.opennms.features.topology.plugins.topo.bsm.IpServiceVertex) ReductionKeyEdge(org.opennms.netmgt.bsm.service.model.edge.ReductionKeyEdge) BusinessService(org.opennms.netmgt.bsm.service.model.BusinessService) GraphVertex(org.opennms.netmgt.bsm.service.model.graph.GraphVertex) BusinessServiceStateMachine(org.opennms.netmgt.bsm.service.BusinessServiceStateMachine) ChildEdge(org.opennms.netmgt.bsm.service.model.edge.ChildEdge) ReductionKeyEdge(org.opennms.netmgt.bsm.service.model.edge.ReductionKeyEdge) Edge(org.opennms.netmgt.bsm.service.model.edge.Edge) IpServiceEdge(org.opennms.netmgt.bsm.service.model.edge.IpServiceEdge) BusinessServiceVertex(org.opennms.features.topology.plugins.topo.bsm.BusinessServiceVertex)

Example 17 with FormLayout

use of com.vaadin.ui.FormLayout in project cia by Hack23.

the class FormFactoryImpl method addFormPanelTextFields.

@Override
public <T extends Serializable> void addFormPanelTextFields(final AbstractOrderedLayout panelContent, final T item, final Class<T> beanType, final List<String> displayProperties) {
    final Panel formPanel = new Panel();
    formPanel.setSizeFull();
    panelContent.addComponent(formPanel);
    if (displayProperties.size() > SIZE_FOR_GRID) {
        panelContent.setExpandRatio(formPanel, ContentRatio.GRID);
    } else {
        panelContent.setExpandRatio(formPanel, ContentRatio.SMALL_GRID);
    }
    final FormLayout formContent = new FormLayout();
    formPanel.setContent(formContent);
    formContent.setWidth(ContentSize.FULL_SIZE);
    final Binder<T> binder = new Binder<>(beanType);
    binder.setBean(item);
    binder.setReadOnly(true);
    PropertyDescriptor[] propertyDescriptors = null;
    try {
        final BeanInfo info = Introspector.getBeanInfo(item.getClass());
        propertyDescriptors = info.getPropertyDescriptors();
    } catch (final IntrospectionException exception) {
        LOGGER.error("No able to getfieldtypes for type:+ item.getClass()", exception);
    }
    createDisplayPropertyConverters(displayProperties, formContent, binder, propertyDescriptors);
}
Also used : FormLayout(com.vaadin.ui.FormLayout) Panel(com.vaadin.ui.Panel) Binder(com.vaadin.data.Binder) BeanValidationBinder(com.vaadin.data.BeanValidationBinder) PropertyDescriptor(java.beans.PropertyDescriptor) BeanInfo(java.beans.BeanInfo) IntrospectionException(java.beans.IntrospectionException)

Example 18 with FormLayout

use of com.vaadin.ui.FormLayout in project cia by Hack23.

the class EmailPageModContentFactoryImpl method createContent.

@Secured({ "ROLE_ADMIN" })
@Override
public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
    final VerticalLayout content = createPanelContent();
    final String pageId = getPageId(parameters);
    getMenuItemFactory().createMainPageMenuBar(menuBar);
    LabelFactory.createHeader2Label(content, ADMIN_EMAIL);
    final VerticalLayout emailLayout = new VerticalLayout();
    emailLayout.setSizeFull();
    final Panel formPanel = new Panel();
    formPanel.setSizeFull();
    emailLayout.addComponent(formPanel);
    final FormLayout formContent = new FormLayout();
    formPanel.setContent(formContent);
    final SendEmailRequest sendEmailRequest = new SendEmailRequest();
    sendEmailRequest.setSessionId(RequestContextHolder.currentRequestAttributes().getSessionId());
    sendEmailRequest.setEmail("");
    sendEmailRequest.setSubject("");
    sendEmailRequest.setContent("");
    final ClickListener sendEmailListener = new SendEmailClickListener(sendEmailRequest);
    getFormFactory().addRequestInputFormFields(formContent, sendEmailRequest, SendEmailRequest.class, SEND_EMAIL_REQUEST_FORM_FIELDS, EMAIL, sendEmailListener);
    content.addComponent(emailLayout);
    content.setExpandRatio(emailLayout, ContentRatio.LARGE_FORM);
    panel.setCaption(NAME + "::" + ADMIN_EMAIL);
    getPageActionEventHelper().createPageEvent(ViewAction.VISIT_ADMIN_EMAIL_VIEW, ApplicationEventGroup.ADMIN, NAME, null, pageId);
    return content;
}
Also used : FormLayout(com.vaadin.ui.FormLayout) SendEmailClickListener(com.hack23.cia.web.impl.ui.application.views.pageclicklistener.SendEmailClickListener) Panel(com.vaadin.ui.Panel) VerticalLayout(com.vaadin.ui.VerticalLayout) ClickListener(com.vaadin.ui.Button.ClickListener) SendEmailClickListener(com.hack23.cia.web.impl.ui.application.views.pageclicklistener.SendEmailClickListener) SendEmailRequest(com.hack23.cia.service.api.action.admin.SendEmailRequest) Secured(org.springframework.security.access.annotation.Secured)

Example 19 with FormLayout

use of com.vaadin.ui.FormLayout in project cia by Hack23.

the class SearchDocumentPageModContentFactoryImpl method createContent.

@Secured({ "ROLE_ANONYMOUS", "ROLE_USER", "ROLE_ADMIN" })
@Override
public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
    final VerticalLayout panelContent = createPanelContent();
    final String pageId = getPageId(parameters);
    documentMenuItemFactory.createDocumentsMenuBar(menuBar);
    final VerticalLayout searchLayout = new VerticalLayout();
    searchLayout.setSizeFull();
    panelContent.addComponent(searchLayout);
    final VerticalLayout searchresultLayout = new VerticalLayout();
    searchresultLayout.setSizeFull();
    final Panel formPanel = new Panel();
    formPanel.setSizeFull();
    searchresultLayout.addComponent(formPanel);
    final FormLayout formContent = new FormLayout();
    formPanel.setContent(formContent);
    panelContent.addComponent(searchresultLayout);
    panelContent.setExpandRatio(searchresultLayout, ContentRatio.LARGE);
    final SearchDocumentRequest searchRequest = new SearchDocumentRequest();
    searchRequest.setSessionId(RequestContextHolder.currentRequestAttributes().getSessionId());
    searchRequest.setMaxResults(MAX_RESULT_SIZE);
    searchRequest.setSearchExpression("");
    getFormFactory().addRequestInputFormFields(formContent, searchRequest, SearchDocumentRequest.class, AS_LIST, SEARCH, new SearchDocumentClickListener(searchRequest, new SearchDocumentResponseHandlerImpl(getGridFactory(), formPanel, searchresultLayout)));
    getPageActionEventHelper().createPageEvent(ViewAction.VISIT_DOCUMENT_VIEW, ApplicationEventGroup.USER, NAME, parameters, pageId);
    return panelContent;
}
Also used : FormLayout(com.vaadin.ui.FormLayout) Panel(com.vaadin.ui.Panel) SearchDocumentResponseHandlerImpl(com.hack23.cia.web.impl.ui.application.views.pageclicklisteners.handlers.impl.SearchDocumentResponseHandlerImpl) SearchDocumentClickListener(com.hack23.cia.web.impl.ui.application.views.pageclicklistener.SearchDocumentClickListener) SearchDocumentRequest(com.hack23.cia.service.api.action.user.SearchDocumentRequest) VerticalLayout(com.vaadin.ui.VerticalLayout) Secured(org.springframework.security.access.annotation.Secured)

Example 20 with FormLayout

use of com.vaadin.ui.FormLayout in project tutorials by eugenp.

the class VaadinUI method init.

@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
protected void init(VaadinRequest vaadinRequest) {
    final VerticalLayout verticalLayout = new VerticalLayout();
    verticalLayout.setSpacing(true);
    verticalLayout.setMargin(true);
    final GridLayout gridLayout = new GridLayout(3, 2);
    gridLayout.setSpacing(true);
    gridLayout.setMargin(true);
    final HorizontalLayout horizontalLayout = new HorizontalLayout();
    horizontalLayout.setSpacing(true);
    horizontalLayout.setMargin(true);
    final FormLayout formLayout = new FormLayout();
    formLayout.setSpacing(true);
    formLayout.setMargin(true);
    final GridLayout buttonLayout = new GridLayout(3, 5);
    buttonLayout.setMargin(true);
    buttonLayout.setSpacing(true);
    final Label label = new Label();
    label.setId("Label");
    label.setValue("Label Value");
    label.setCaption("Label");
    gridLayout.addComponent(label);
    final Link link = new Link("Baeldung", new ExternalResource("http://www.baeldung.com/"));
    link.setId("Link");
    link.setTargetName("_blank");
    gridLayout.addComponent(link);
    final TextField textField = new TextField();
    textField.setId("TextField");
    textField.setCaption("TextField:");
    textField.setValue("TextField Value");
    textField.setIcon(FontAwesome.USER);
    gridLayout.addComponent(textField);
    final TextArea textArea = new TextArea();
    textArea.setCaption("TextArea");
    textArea.setId("TextArea");
    textArea.setValue("TextArea Value");
    gridLayout.addComponent(textArea);
    final DateField dateField = new DateField("DateField", new Date(0));
    dateField.setId("DateField");
    gridLayout.addComponent(dateField);
    final PasswordField passwordField = new PasswordField();
    passwordField.setId("PasswordField");
    passwordField.setCaption("PasswordField:");
    passwordField.setValue("password");
    gridLayout.addComponent(passwordField);
    final RichTextArea richTextArea = new RichTextArea();
    richTextArea.setCaption("Rich Text Area");
    richTextArea.setValue("<h1>RichTextArea</h1>");
    richTextArea.setSizeFull();
    Panel richTextPanel = new Panel();
    richTextPanel.setContent(richTextArea);
    final InlineDateField inlineDateField = new InlineDateField();
    inlineDateField.setValue(new Date(0));
    inlineDateField.setCaption("Inline Date Field");
    horizontalLayout.addComponent(inlineDateField);
    Button normalButton = new Button("Normal Button");
    normalButton.setId("NormalButton");
    normalButton.addClickListener(e -> {
        label.setValue("CLICK");
    });
    buttonLayout.addComponent(normalButton);
    Button tinyButton = new Button("Tiny Button");
    tinyButton.addStyleName("tiny");
    buttonLayout.addComponent(tinyButton);
    Button smallButton = new Button("Small Button");
    smallButton.addStyleName("small");
    buttonLayout.addComponent(smallButton);
    Button largeButton = new Button("Large Button");
    largeButton.addStyleName("large");
    buttonLayout.addComponent(largeButton);
    Button hugeButton = new Button("Huge Button");
    hugeButton.addStyleName("huge");
    buttonLayout.addComponent(hugeButton);
    Button disabledButton = new Button("Disabled Button");
    disabledButton.setDescription("This button cannot be clicked");
    disabledButton.setEnabled(false);
    buttonLayout.addComponent(disabledButton);
    Button dangerButton = new Button("Danger Button");
    dangerButton.addStyleName("danger");
    buttonLayout.addComponent(dangerButton);
    Button friendlyButton = new Button("Friendly Button");
    friendlyButton.addStyleName("friendly");
    buttonLayout.addComponent(friendlyButton);
    Button primaryButton = new Button("Primary Button");
    primaryButton.addStyleName("primary");
    buttonLayout.addComponent(primaryButton);
    NativeButton nativeButton = new NativeButton("Native Button");
    buttonLayout.addComponent(nativeButton);
    Button iconButton = new Button("Icon Button");
    iconButton.setIcon(FontAwesome.ALIGN_LEFT);
    buttonLayout.addComponent(iconButton);
    Button borderlessButton = new Button("BorderLess Button");
    borderlessButton.addStyleName("borderless");
    buttonLayout.addComponent(borderlessButton);
    Button linkButton = new Button("Link Button");
    linkButton.addStyleName("link");
    buttonLayout.addComponent(linkButton);
    Button quietButton = new Button("Quiet Button");
    quietButton.addStyleName("quiet");
    buttonLayout.addComponent(quietButton);
    horizontalLayout.addComponent(buttonLayout);
    final CheckBox checkbox = new CheckBox("CheckBox");
    checkbox.setValue(true);
    checkbox.addValueChangeListener(e -> checkbox.setValue(!checkbox.getValue()));
    formLayout.addComponent(checkbox);
    List<String> numbers = new ArrayList<String>();
    numbers.add("One");
    numbers.add("Ten");
    numbers.add("Eleven");
    ComboBox comboBox = new ComboBox("ComboBox");
    comboBox.addItems(numbers);
    formLayout.addComponent(comboBox);
    ListSelect listSelect = new ListSelect("ListSelect");
    listSelect.addItems(numbers);
    listSelect.setRows(2);
    formLayout.addComponent(listSelect);
    NativeSelect nativeSelect = new NativeSelect("NativeSelect");
    nativeSelect.addItems(numbers);
    formLayout.addComponent(nativeSelect);
    TwinColSelect twinColSelect = new TwinColSelect("TwinColSelect");
    twinColSelect.addItems(numbers);
    Grid grid = new Grid("Grid");
    grid.setColumns("Column1", "Column2", "Column3");
    grid.addRow("Item1", "Item2", "Item3");
    grid.addRow("Item4", "Item5", "Item6");
    Panel panel = new Panel("Panel");
    panel.setContent(grid);
    panel.setSizeUndefined();
    Panel serverPushPanel = new Panel("Server Push");
    FormLayout timeLayout = new FormLayout();
    timeLayout.setSpacing(true);
    timeLayout.setMargin(true);
    currentTime = new Label("No TIME...");
    timeLayout.addComponent(currentTime);
    serverPushPanel.setContent(timeLayout);
    serverPushPanel.setSizeUndefined();
    ScheduledExecutorService scheduleExecutor = Executors.newScheduledThreadPool(1);
    Runnable task = () -> {
        currentTime.setValue("Current Time : " + Instant.now());
    };
    scheduleExecutor.scheduleWithFixedDelay(task, 0, 1, TimeUnit.SECONDS);
    FormLayout dataBindingLayout = new FormLayout();
    dataBindingLayout.setSpacing(true);
    dataBindingLayout.setMargin(true);
    BindData bindData = new BindData("BindData");
    BeanFieldGroup beanFieldGroup = new BeanFieldGroup(BindData.class);
    beanFieldGroup.setItemDataSource(bindData);
    TextField bindedTextField = (TextField) beanFieldGroup.buildAndBind("BindName", "bindName");
    bindedTextField.setWidth("250px");
    dataBindingLayout.addComponent(bindedTextField);
    FormLayout validatorLayout = new FormLayout();
    validatorLayout.setSpacing(true);
    validatorLayout.setMargin(true);
    HorizontalLayout textValidatorLayout = new HorizontalLayout();
    textValidatorLayout.setSpacing(true);
    textValidatorLayout.setMargin(true);
    TextField stringValidator = new TextField();
    stringValidator.setNullSettingAllowed(true);
    stringValidator.setNullRepresentation("");
    stringValidator.addValidator(new StringLengthValidator("String must have 2-5 characters lenght", 2, 5, true));
    stringValidator.setValidationVisible(false);
    textValidatorLayout.addComponent(stringValidator);
    Button buttonStringValidator = new Button("Validate String");
    buttonStringValidator.addClickListener(e -> {
        try {
            stringValidator.setValidationVisible(false);
            stringValidator.validate();
        } catch (InvalidValueException err) {
            stringValidator.setValidationVisible(true);
        }
    });
    textValidatorLayout.addComponent(buttonStringValidator);
    validatorLayout.addComponent(textValidatorLayout);
    verticalLayout.addComponent(gridLayout);
    verticalLayout.addComponent(richTextPanel);
    verticalLayout.addComponent(horizontalLayout);
    verticalLayout.addComponent(formLayout);
    verticalLayout.addComponent(twinColSelect);
    verticalLayout.addComponent(panel);
    verticalLayout.addComponent(serverPushPanel);
    verticalLayout.addComponent(dataBindingLayout);
    verticalLayout.addComponent(validatorLayout);
    setContent(verticalLayout);
}
Also used : NativeButton(com.vaadin.ui.NativeButton) BeanFieldGroup(com.vaadin.data.fieldgroup.BeanFieldGroup) InlineDateField(com.vaadin.ui.InlineDateField) TextArea(com.vaadin.ui.TextArea) RichTextArea(com.vaadin.ui.RichTextArea) Grid(com.vaadin.ui.Grid) Label(com.vaadin.ui.Label) ArrayList(java.util.ArrayList) TwinColSelect(com.vaadin.ui.TwinColSelect) HorizontalLayout(com.vaadin.ui.HorizontalLayout) InvalidValueException(com.vaadin.data.Validator.InvalidValueException) RichTextArea(com.vaadin.ui.RichTextArea) GridLayout(com.vaadin.ui.GridLayout) NativeButton(com.vaadin.ui.NativeButton) Button(com.vaadin.ui.Button) VerticalLayout(com.vaadin.ui.VerticalLayout) TextField(com.vaadin.ui.TextField) PasswordField(com.vaadin.ui.PasswordField) FormLayout(com.vaadin.ui.FormLayout) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) ComboBox(com.vaadin.ui.ComboBox) StringLengthValidator(com.vaadin.data.validator.StringLengthValidator) ListSelect(com.vaadin.ui.ListSelect) ExternalResource(com.vaadin.server.ExternalResource) Date(java.util.Date) Panel(com.vaadin.ui.Panel) CheckBox(com.vaadin.ui.CheckBox) NativeSelect(com.vaadin.ui.NativeSelect) InlineDateField(com.vaadin.ui.InlineDateField) DateField(com.vaadin.ui.DateField) Link(com.vaadin.ui.Link)

Aggregations

FormLayout (com.vaadin.ui.FormLayout)20 VerticalLayout (com.vaadin.ui.VerticalLayout)10 Panel (com.vaadin.ui.Panel)8 Secured (org.springframework.security.access.annotation.Secured)6 Button (com.vaadin.ui.Button)5 ClickListener (com.vaadin.ui.Button.ClickListener)4 HorizontalLayout (com.vaadin.ui.HorizontalLayout)4 Label (com.vaadin.ui.Label)4 Status (org.opennms.netmgt.bsm.service.model.Status)3 ResponsiveRow (com.jarektoro.responsivelayout.ResponsiveRow)2 Window (com.vaadin.ui.Window)2 AbstractBusinessServiceVertex (org.opennms.features.topology.plugins.topo.bsm.AbstractBusinessServiceVertex)2 BusinessService (org.opennms.netmgt.bsm.service.model.BusinessService)2 UIHelper.createButton (org.opennms.netmgt.vaadin.core.UIHelper.createButton)2 FormHelper (au.com.vaadinutils.crud.FormHelper)1 CKEditorEmailField (au.com.vaadinutils.fields.CKEditorEmailField)1 OutputFormat (au.com.vaadinutils.jasper.JasperManager.OutputFormat)1 ReportEmailScheduleEntity (au.com.vaadinutils.jasper.scheduler.entities.ReportEmailScheduleEntity)1 TopVerticalLayout (au.com.vaadinutils.layout.TopVerticalLayout)1 Strings (com.google.common.base.Strings)1