Example usage for com.vaadin.ui Label setVisible

List of usage examples for com.vaadin.ui Label setVisible

Introduction

In this page you can find the example usage for com.vaadin.ui Label setVisible.

Prototype

@Override
    public void setVisible(boolean visible) 

Source Link

Usage

From source file:org.hip.vif.forum.usersettings.ui.AbstactUsersettingsView.java

License:Open Source License

/** @param inMessages {@link IMessages}
 * @param inSubtitle {@link Label}/*from   ww  w  .  ja  v  a 2  s.  co  m*/
 * @param inMsgKey
 * @return {@link VerticalLayout} */
protected VerticalLayout createLayout(final IMessages inMessages, final Label inSubtitle,
        final String inMsgKey) {
    final VerticalLayout lLayout = new VerticalLayout();
    setCompositionRoot(lLayout);

    lLayout.setStyleName("vif-table"); //$NON-NLS-1$
    lLayout.addComponent(
            new Label(String.format(VIFViewHelper.TMPL_TITLE, "vif-pagetitle", inMessages.getMessage(inMsgKey)), //$NON-NLS-1$
                    ContentMode.HTML));

    inSubtitle.setVisible(false);
    lLayout.addComponent(inSubtitle);
    return lLayout;
}

From source file:org.hip.vif.forum.usersettings.ui.BookmarkListView.java

License:Open Source License

/** View constructor
 *
 * @param inBookmarks {@link BookmarkContainer}
 * @param inTask {@link BookmarksManageTask} */
public BookmarkListView(final BookmarkContainer inBookmarks, final BookmarksManageTask inTask) {
    super();//  w w w.  j  av  a  2  s. c  om

    confirmationMode = false;
    final IMessages lMessages = Activator.getMessages();
    final Label lSubtitle = new Label(String.format(VIFViewHelper.TMPL_WARNING,
            lMessages.getMessage("ui.usersettings.delete.bookmark.warning")), ContentMode.HTML); //$NON-NLS-1$
    final VerticalLayout lLayout = createLayout(lMessages, lSubtitle, "usersettings.menu.bookmarks"); //$NON-NLS-1$

    if (inBookmarks.getItemIds().isEmpty()) {
        lLayout.addComponent(new Label(lMessages.getMessage("ui.usersettings.bookmark.empty"))); //$NON-NLS-1$
        return;
    }

    final Table lTable = createTable(inTask);
    lTable.setContainerDataSource(inBookmarks);
    lTable.addGeneratedColumn(BookmarkContainer.ITEM_CHK,
            new VIFViewHelper.CheckBoxColumnGenerator(new VIFViewHelper.IConfirmationModeChecker() {
                @Override
                public boolean inConfirmationMode() { // NOPMD
                    return confirmationMode;
                }
            }));
    lTable.setPageLength(VIFViewHelper.getTablePageLength(inBookmarks.size()));
    lTable.setVisibleColumns(BookmarkContainer.NATURAL_COL_ORDER);
    lTable.setColumnHeaders(VIFViewHelper.getColumnHeaders(BookmarkContainer.COL_HEADERS, lMessages));
    lLayout.addComponent(lTable);

    lLayout.addComponent(RiplaViewHelper.createSpacer());
    final Button lDelete = new Button(lMessages.getMessage("ui.usersettings.button.delete")); //$NON-NLS-1$
    lDelete.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(final ClickEvent inEvent) { // NOPMD
            if (confirmationMode) {
                if (!inTask.deleteBookmarks()) {
                    Notification.show(lMessages.getMessage("errmsg.bookmark.delete"), Type.WARNING_MESSAGE); //$NON-NLS-1$
                }
            } else {
                if (VIFViewHelper.processAction(inBookmarks)) {
                    confirmationMode = true;
                    inBookmarks.addContainerFilter(new SelectedFilter(BookmarkContainer.ITEM_CHECKED));
                    lSubtitle.setVisible(true);
                    lTable.setSelectable(false);
                    lTable.setPageLength(0);
                }
            }
        }
    });
    lLayout.addComponent(lDelete);
}

From source file:org.hip.vif.forum.usersettings.ui.SubscriptionListView.java

License:Open Source License

/** View constructor.
 *
 * @param inSubscriptions {@link SubscriptionContainer}
 * @param inTask {@link SubscriptionsManageTask} */
public SubscriptionListView(final SubscriptionContainer inSubscriptions, final SubscriptionsManageTask inTask) {
    super();//ww  w.  j a v a2 s  .  c om
    confirmationMode = false;
    final IMessages lMessages = Activator.getMessages();

    final Label lSubtitle = new Label(String.format(VIFViewHelper.TMPL_WARNING,
            lMessages.getMessage("ui.usersettings.delete.subscription.warning")), ContentMode.HTML); //$NON-NLS-1$
    final VerticalLayout lLayout = createLayout(lMessages, lSubtitle, "usersettings.menu.subscription"); //$NON-NLS-1$

    if (inSubscriptions.getItemIds().isEmpty()) {
        lLayout.addComponent(new Label(lMessages.getMessage("ui.usersettings.subscription.empty"))); //$NON-NLS-1$
        return;
    }

    final Table lTable = createTable(inTask);
    lTable.setContainerDataSource(inSubscriptions);

    lTable.addGeneratedColumn(SubscriptionContainer.ITEM_CHK,
            new VIFViewHelper.CheckBoxColumnGenerator(new VIFViewHelper.IConfirmationModeChecker() {
                @Override
                public boolean inConfirmationMode() { // NOPMD
                    return confirmationMode;
                }
            }));
    lTable.addGeneratedColumn(SubscriptionContainer.ITEM_LOCAL, new Table.ColumnGenerator() {
        @Override
        public Object generateCell(final Table inSource, final Object inItemId, final Object inColumnId) { // NOPMD
            return createCheck((SubscriptionBean) inItemId, inTask, lMessages);
        }
    });

    lTable.setPageLength(VIFViewHelper.getTablePageLength(inSubscriptions.size()));

    lTable.setVisibleColumns(SubscriptionContainer.NATURAL_COL_ORDER);
    lTable.setColumnHeaders(VIFViewHelper.getColumnHeaders(SubscriptionContainer.COL_HEADERS, lMessages));
    lLayout.addComponent(lTable);

    lLayout.addComponent(RiplaViewHelper.createSpacer());
    final Button lDelete = new Button(lMessages.getMessage("ui.usersettings.button.delete")); //$NON-NLS-1$
    lDelete.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(final ClickEvent inEvent) { // NOPMD
            if (confirmationMode) {
                if (!inTask.deleteSubscriptions()) {
                    Notification.show(lMessages.getMessage("errmsg.subscription.delete"), Type.WARNING_MESSAGE); //$NON-NLS-1$
                }
            } else {
                if (VIFViewHelper.processAction(inSubscriptions)) {
                    confirmationMode = true;
                    inSubscriptions.addContainerFilter(new SelectedFilter(SubscriptionContainer.ITEM_CHECKED));
                    lSubtitle.setVisible(true);
                    lTable.setSelectable(false);
                    lTable.setPageLength(0);
                }
            }
        }
    });
    lLayout.addComponent(lDelete);
}

From source file:org.ikasan.dashboard.ui.administration.window.NewPolicyWindow.java

License:BSD License

public void init() {
    this.setModal(true);
    this.setResizable(false);

    this.setWidth("600px");
    this.setHeight("400px");

    GridLayout gridLayout = new GridLayout(2, 8);
    gridLayout.setWidth("100%");
    gridLayout.setMargin(true);//from   w  ww  .  j av a  2 s  .c om
    gridLayout.setSpacing(true);

    gridLayout.setColumnExpandRatio(0, .1f);
    gridLayout.setColumnExpandRatio(1, .9f);

    Label createNewPolicyLabel = new Label("Create a New Policy");
    createNewPolicyLabel.setStyleName(ValoTheme.LABEL_HUGE);

    gridLayout.addComponent(createNewPolicyLabel, 0, 0, 1, 0);

    Label nameLabel = new Label("Name:");
    nameLabel.setSizeUndefined();
    this.policyName = new TextField();
    this.policyName.addValidator(new StringLengthValidator("A name must be entered.", 1, null, false));
    this.policyName.setWidth("80%");

    gridLayout.addComponent(nameLabel, 0, 1);
    gridLayout.setComponentAlignment(nameLabel, Alignment.MIDDLE_RIGHT);
    gridLayout.addComponent(policyName, 1, 1);

    Label descriptionLabel = new Label("Description");
    descriptionLabel.setSizeUndefined();
    this.policyDescription = new TextArea();
    this.policyDescription
            .addValidator(new StringLengthValidator("A description must be entered.", 1, null, false));
    this.policyDescription.setRows(4);
    this.policyDescription.setWidth("80%");

    this.policyName.setValidationVisible(false);
    this.policyDescription.setValidationVisible(false);

    gridLayout.addComponent(descriptionLabel, 0, 2);
    gridLayout.setComponentAlignment(descriptionLabel, Alignment.TOP_RIGHT);
    gridLayout.addComponent(policyDescription, 1, 2);

    Button createButton = new Button("Create");
    Button cancelButton = new Button("Cancel");

    HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setSpacing(true);
    buttonLayout.addComponent(createButton);
    buttonLayout.setComponentAlignment(createButton, Alignment.MIDDLE_CENTER);
    buttonLayout.addComponent(cancelButton);
    buttonLayout.setComponentAlignment(cancelButton, Alignment.MIDDLE_CENTER);

    BeanItem<Policy> policyItem = new BeanItem<Policy>(this.policy);

    this.policyName.setPropertyDataSource(policyItem.getItemProperty("name"));
    this.policyDescription.setPropertyDataSource(policyItem.getItemProperty("description"));

    Label linkTypeLabel = new Label("Policy Link Type");
    linkTypeLabel.setSizeUndefined();
    gridLayout.addComponent(linkTypeLabel, 0, 3);
    gridLayout.setComponentAlignment(linkTypeLabel, Alignment.TOP_RIGHT);
    this.linkTypeCombo.setWidth("80%");
    gridLayout.addComponent(this.linkTypeCombo, 1, 3);

    List<PolicyLinkType> policyLinkTypes = this.securityService.getAllPolicyLinkTypes();

    this.linkTypeCombo.removeAllItems();

    for (PolicyLinkType policyLinkType : policyLinkTypes) {
        this.linkTypeCombo.addItem(policyLinkType);
        this.linkTypeCombo.setItemCaption(policyLinkType, policyLinkType.getName());
    }

    policyLinkHintLabel.setCaptionAsHtml(true);
    policyLinkHintLabel.setCaption(VaadinIcons.QUESTION_CIRCLE_O.getHtml()
            + " You are linking this policy to an entity. Click link below to search for the entity to link to.");
    policyLinkHintLabel.addStyleName(ValoTheme.LABEL_TINY);
    policyLinkHintLabel.addStyleName(ValoTheme.LABEL_LIGHT);
    policyLinkHintLabel.setVisible(false);
    gridLayout.addComponent(policyLinkHintLabel, 0, 4, 1, 4);

    linkButton.setStyleName(ValoTheme.BUTTON_LINK);
    linkButton.setVisible(false);
    linkButton.addClickListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            PolicyLinkType policyLinkType = (PolicyLinkType) NewPolicyWindow.this.linkTypeCombo.getValue();

            if (policyLinkType.getName().equals(PolicyLinkTypeConstants.MAPPING_CONFIGURATION_LINK_TYPE)) {
                NewPolicyWindow.this.policyAssociationMappingSearchWindow.clear();
                UI.getCurrent().addWindow(NewPolicyWindow.this.policyAssociationMappingSearchWindow);
            } else if (policyLinkType.getName().equals(PolicyLinkTypeConstants.MODULE_LINK_TYPE)) {
                NewPolicyWindow.this.policyAssociationModuleSearchWindow.clear();
                UI.getCurrent().addWindow(NewPolicyWindow.this.policyAssociationModuleSearchWindow);
            } else if (policyLinkType.getName().equals(PolicyLinkTypeConstants.FLOW_LINK_TYPE)) {
                NewPolicyWindow.this.policyAssociationFlowSearchWindow.clear();
                UI.getCurrent().addWindow(NewPolicyWindow.this.policyAssociationFlowSearchWindow);
            } else if (policyLinkType.getName().equals(PolicyLinkTypeConstants.BUSINESS_STREAM_LINK_TYPE)) {
                NewPolicyWindow.this.policyAssociationBusinessStreamSearchWindow.clear();
                UI.getCurrent().addWindow(NewPolicyWindow.this.policyAssociationBusinessStreamSearchWindow);
            }
        }
    });
    gridLayout.addComponent(this.linkButton, 1, 5);

    final Label linkedEntityLabel = new Label("Linked to");
    linkedEntityLabel.setSizeUndefined();

    this.linkedEntity = new TextArea();
    this.linkedEntity.addValidator(new StringLengthValidator(
            "If a Policy Link Type is selected, you must link to an approptiate entity.", 1, null, false));
    this.linkedEntity.setWidth("80%");
    this.linkedEntity.setValidationVisible(false);
    this.linkedEntity.setHeight("60px");

    gridLayout.addComponent(linkedEntityLabel, 0, 6);
    gridLayout.setComponentAlignment(linkedEntityLabel, Alignment.TOP_RIGHT);
    gridLayout.addComponent(linkedEntity, 1, 6);
    linkedEntityLabel.setVisible(false);
    linkedEntity.setVisible(false);

    this.policyAssociationMappingSearchWindow.addCloseListener(new Window.CloseListener() {
        // inline close-listener
        public void windowClose(CloseEvent e) {
            if (policyAssociationMappingSearchWindow.getMappingConfiguration() != null) {
                NewPolicyWindow.this.linkedEntity.setValue(
                        policyAssociationMappingSearchWindow.getMappingConfiguration().toStringLite());
                NewPolicyWindow.this.associatedEntityId = NewPolicyWindow.this.policyAssociationMappingSearchWindow
                        .getMappingConfiguration().getId();
            }
        }
    });

    this.policyAssociationFlowSearchWindow.addCloseListener(new Window.CloseListener() {
        // inline close-listener
        public void windowClose(CloseEvent e) {
            if (policyAssociationFlowSearchWindow.getFlow() != null) {
                NewPolicyWindow.this.linkedEntity
                        .setValue(policyAssociationFlowSearchWindow.getFlow().toString());
                NewPolicyWindow.this.associatedEntityId = NewPolicyWindow.this.policyAssociationFlowSearchWindow
                        .getFlow().getId();
            }
        }
    });

    this.policyAssociationModuleSearchWindow.addCloseListener(new Window.CloseListener() {
        // inline close-listener
        public void windowClose(CloseEvent e) {
            if (policyAssociationModuleSearchWindow.getModule() != null) {
                NewPolicyWindow.this.linkedEntity
                        .setValue(policyAssociationModuleSearchWindow.getModule().toString());
                NewPolicyWindow.this.associatedEntityId = NewPolicyWindow.this.policyAssociationModuleSearchWindow
                        .getModule().getId();
            }
        }
    });

    this.policyAssociationBusinessStreamSearchWindow.addCloseListener(new Window.CloseListener() {
        // inline close-listener
        public void windowClose(CloseEvent e) {
            if (policyAssociationBusinessStreamSearchWindow.getBusinessStream() != null) {
                NewPolicyWindow.this.linkedEntity
                        .setValue(policyAssociationBusinessStreamSearchWindow.getBusinessStream().toString());
                NewPolicyWindow.this.associatedEntityId = NewPolicyWindow.this.policyAssociationBusinessStreamSearchWindow
                        .getBusinessStream().getId();
            }
        }

    });

    this.linkTypeCombo.addValueChangeListener(new Property.ValueChangeListener() {
        public void valueChange(ValueChangeEvent event) {
            final PolicyLinkType policyLinkType = (PolicyLinkType) event.getProperty().getValue();

            if (policyLinkType != null) {
                linkButton.setVisible(true);
                linkedEntityLabel.setVisible(true);
                linkedEntity.setVisible(true);
                policyLinkHintLabel.setVisible(true);
            } else {
                linkButton.setVisible(false);
                linkedEntityLabel.setVisible(false);
                linkedEntity.setVisible(false);
                policyLinkHintLabel.setVisible(false);
            }
        }
    });

    gridLayout.addComponent(buttonLayout, 0, 7, 1, 7);
    gridLayout.setComponentAlignment(buttonLayout, Alignment.MIDDLE_CENTER);

    createButton.addClickListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            try {
                NewPolicyWindow.this.policyName.validate();
                NewPolicyWindow.this.policyDescription.validate();

                if (linkTypeCombo.getValue() != null) {
                    NewPolicyWindow.this.linkedEntity.validate();
                }
            } catch (InvalidValueException e) {
                NewPolicyWindow.this.policyName.setValidationVisible(true);
                NewPolicyWindow.this.policyDescription.setValidationVisible(true);
                NewPolicyWindow.this.linkedEntity.setValidationVisible(true);

                return;
            }

            NewPolicyWindow.this.policyName.setValidationVisible(false);
            NewPolicyWindow.this.policyDescription.setValidationVisible(false);
            NewPolicyWindow.this.linkedEntity.setValidationVisible(false);

            if (linkTypeCombo.getValue() != null) {
                PolicyLinkType policyLinkType = (PolicyLinkType) linkTypeCombo.getValue();
                String linkedEntityName = linkedEntity.getValue();
                PolicyLink policyLink = new PolicyLink(policyLinkType, associatedEntityId, linkedEntityName);

                securityService.savePolicyLink(policyLink);

                policy.setPolicyLink(policyLink);

                try {
                    securityService.savePolicy(policy);
                } catch (DataIntegrityViolationException e) {
                    Notification.show(
                            "Policy name must be unique. Please confirm that this policy does not already exist!",
                            Notification.Type.ERROR_MESSAGE);

                    return;
                } catch (RuntimeException e) {
                    StringWriter sw = new StringWriter();
                    PrintWriter pw = new PrintWriter(sw);
                    e.printStackTrace(pw);

                    Notification.show("Caught exception trying to save a Policy!", sw.toString(),
                            Notification.Type.ERROR_MESSAGE);

                    return;
                }
            } else {
                PolicyLink policyLink = policy.getPolicyLink();
                policy.setPolicyLink(null);

                try {
                    securityService.savePolicy(policy);
                } catch (DataIntegrityViolationException e) {
                    Notification.show(
                            "Policy name must be unique. Please confirm that this policy does not already exist!",
                            Notification.Type.ERROR_MESSAGE);

                    return;
                } catch (RuntimeException e) {
                    StringWriter sw = new StringWriter();
                    PrintWriter pw = new PrintWriter(sw);
                    e.printStackTrace(pw);

                    Notification.show("Caught exception trying to save a Policy!", sw.toString(),
                            Notification.Type.ERROR_MESSAGE);

                    return;
                }

                if (policyLink != null) {
                    securityService.deletePolicyLink(policyLink);
                }
            }

            Notification.show("New policy successfully created!");

            UI.getCurrent().removeWindow(NewPolicyWindow.this);
        }
    });

    cancelButton.addClickListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            UI.getCurrent().removeWindow(NewPolicyWindow.this);
        }
    });

    this.setContent(gridLayout);
}

From source file:org.ikasan.dashboard.ui.mappingconfiguration.panel.MappingConfigurationSearchPanel.java

License:BSD License

/**
 * Helper method to initialise this object.
 *//*from   ww  w  .  j  a  v a  2 s.  c o  m*/
@SuppressWarnings("serial")
protected void init() {
    this.addStyleName(ValoTheme.PANEL_BORDERLESS);

    final Label typeLabel = new Label("Type:");
    final Label sourceContextLabel = new Label("Source Context:");
    final Label targetContextLabel = new Label("Target Context:");

    final GridLayout contentLayout = new GridLayout(4, 6);
    contentLayout.setColumnExpandRatio(0, .15f);
    contentLayout.setColumnExpandRatio(1, .35f);
    contentLayout.setColumnExpandRatio(2, .05f);
    contentLayout.setColumnExpandRatio(3, .45f);
    contentLayout.setWidth("100%");
    contentLayout.setSpacing(true);

    Label errorOccurrenceDetailsLabel = new Label("Mapping Configuration Search");
    errorOccurrenceDetailsLabel.setStyleName(ValoTheme.LABEL_HUGE);
    contentLayout.addComponent(errorOccurrenceDetailsLabel, 0, 0, 1, 0);

    Label clientLabel = new Label("Client:");
    clientLabel.setSizeUndefined();
    contentLayout.addComponent(clientLabel, 0, 1);
    contentLayout.setComponentAlignment(clientLabel, Alignment.MIDDLE_RIGHT);

    this.clientComboBox.setWidth(80, Unit.PERCENTAGE);
    this.clientComboBox.addValueChangeListener(new ValueChangeListener() {
        public void valueChange(ValueChangeEvent event) {
            if (event.getProperty() != null && event.getProperty().getValue() != null) {
                typeComboBox.refresh(((ConfigurationServiceClient) event.getProperty().getValue()).getName());
                sourceContextComboBox
                        .refresh(((ConfigurationServiceClient) event.getProperty().getValue()).getName(), null);
                targetContextComboBox.refresh(
                        ((ConfigurationServiceClient) event.getProperty().getValue()).getName(), null, null);

                typeLabel.setVisible(true);
                typeComboBox.setVisible(true);
            }
        }
    });
    contentLayout.addComponent(clientComboBox, 1, 1);

    typeLabel.setSizeUndefined();
    contentLayout.addComponent(typeLabel, 0, 2);
    contentLayout.setComponentAlignment(typeLabel, Alignment.MIDDLE_RIGHT);
    typeLabel.setVisible(false);

    this.typeComboBox.setWidth(80, Unit.PERCENTAGE);
    this.typeComboBox.setVisible(false);
    this.typeComboBox.addValueChangeListener(new ValueChangeListener() {
        public void valueChange(ValueChangeEvent event) {
            String client = null;

            if (clientComboBox.getValue() != null) {
                client = ((ConfigurationServiceClient) clientComboBox.getValue()).getName();
            }

            if (event.getProperty() != null && event.getProperty().getValue() != null) {
                sourceContextComboBox.refresh(client,
                        ((ConfigurationType) event.getProperty().getValue()).getName());
                targetContextComboBox.refresh(client,
                        ((ConfigurationType) event.getProperty().getValue()).getName(), null);

                sourceContextLabel.setVisible(true);
                sourceContextComboBox.setVisible(true);
            }
        }
    });
    contentLayout.addComponent(this.typeComboBox, 1, 2);

    sourceContextLabel.setSizeUndefined();
    contentLayout.addComponent(sourceContextLabel, 0, 3);
    contentLayout.setComponentAlignment(sourceContextLabel, Alignment.MIDDLE_RIGHT);
    sourceContextLabel.setVisible(false);

    this.sourceContextComboBox.setWidth(80, Unit.PERCENTAGE);
    this.sourceContextComboBox.setVisible(false);
    this.sourceContextComboBox.addValueChangeListener(new ValueChangeListener() {
        public void valueChange(ValueChangeEvent event) {
            String type = null;
            String client = null;

            if (typeComboBox.getValue() != null) {
                type = ((ConfigurationType) typeComboBox.getValue()).getName();
            }

            if (clientComboBox.getValue() != null) {
                client = ((ConfigurationServiceClient) clientComboBox.getValue()).getName();
            }

            if (event.getProperty() != null && event.getProperty().getValue() != null) {
                targetContextComboBox.refresh(client, type,
                        ((ConfigurationContext) event.getProperty().getValue()).getName());

                targetContextLabel.setVisible(true);
                targetContextComboBox.setVisible(true);
            }
        }
    });
    contentLayout.addComponent(this.sourceContextComboBox, 1, 3);

    targetContextLabel.setSizeUndefined();
    contentLayout.addComponent(targetContextLabel, 0, 4);
    contentLayout.setComponentAlignment(targetContextLabel, Alignment.MIDDLE_RIGHT);
    targetContextLabel.setVisible(false);

    this.targetContextComboBox.setWidth(80, Unit.PERCENTAGE);
    this.targetContextComboBox.setVisible(false);
    contentLayout.addComponent(this.targetContextComboBox, 1, 4);

    Label actionsLabel = newActions.getActionsLabel();
    actionsLabel.setStyleName(ValoTheme.LABEL_HUGE);
    contentLayout.addComponent(actionsLabel, 2, 0, 3, 0);

    Label createNewClientLabel = newActions.getNewClientLabel();
    createNewClientLabel.setSizeUndefined();
    contentLayout.addComponent(createNewClientLabel, 2, 1);
    contentLayout.setComponentAlignment(createNewClientLabel, Alignment.MIDDLE_RIGHT);
    contentLayout.addComponent(newActions.getNewClientButton(), 3, 1);
    contentLayout.setComponentAlignment(newActions.getNewClientButton(), Alignment.MIDDLE_LEFT);

    Label createNewTypeLabel = newActions.getNewTypeLabel();
    createNewTypeLabel.setSizeUndefined();
    contentLayout.addComponent(createNewTypeLabel, 2, 2);
    contentLayout.setComponentAlignment(createNewTypeLabel, Alignment.MIDDLE_RIGHT);
    contentLayout.addComponent(newActions.getNewTypeButton(), 3, 2);
    contentLayout.setComponentAlignment(newActions.getNewTypeButton(), Alignment.MIDDLE_LEFT);

    Label createContextTypeLabel = newActions.getNewContextLabel();
    createContextTypeLabel.setSizeUndefined();
    contentLayout.addComponent(createContextTypeLabel, 2, 3);
    contentLayout.setComponentAlignment(createContextTypeLabel, Alignment.MIDDLE_RIGHT);
    contentLayout.addComponent(newActions.getNewContextButton(), 3, 3);
    contentLayout.setComponentAlignment(newActions.getNewContextButton(), Alignment.MIDDLE_LEFT);

    Label createMappingConfigurationLabel = newActions.getNewMappingConfigurationLabel();
    createMappingConfigurationLabel.setSizeUndefined();
    contentLayout.addComponent(createMappingConfigurationLabel, 2, 4);
    contentLayout.setComponentAlignment(createMappingConfigurationLabel, Alignment.MIDDLE_RIGHT);
    contentLayout.addComponent(newActions.getNewMappingConfigurationButton(), 3, 4);
    contentLayout.setComponentAlignment(newActions.getNewMappingConfigurationButton(), Alignment.MIDDLE_LEFT);

    Label importMappingConfigurationLabel = newActions.getImportMappingConfigurationLabel();
    importMappingConfigurationLabel.setSizeUndefined();
    contentLayout.addComponent(importMappingConfigurationLabel, 2, 5);
    contentLayout.setComponentAlignment(importMappingConfigurationLabel, Alignment.MIDDLE_RIGHT);
    contentLayout.addComponent(newActions.getImportMappingConfigurationButton(), 3, 5);
    contentLayout.setComponentAlignment(newActions.getImportMappingConfigurationButton(),
            Alignment.MIDDLE_LEFT);

    Button button = new Button("Search");
    button.setStyleName(ValoTheme.BUTTON_SMALL);
    button.addClickListener(searchButtonClickListener);

    contentLayout.addComponent(button, 1, 5);

    this.setContent(contentLayout);
}

From source file:org.ikasan.dashboard.ui.topology.window.WiretapConfigurationWindow.java

License:BSD License

/**
  * Helper method to initialise this object.
  * //from  ww w . ja va  2 s. c om
  * @param message
  */
protected void init() {
    setModal(true);
    setHeight("90%");
    setWidth("90%");

    GridLayout layout = new GridLayout(2, 10);
    layout.setSizeFull();
    layout.setSpacing(true);
    layout.setMargin(true);
    layout.setColumnExpandRatio(0, .25f);
    layout.setColumnExpandRatio(1, .75f);

    Label wiretapLabel = new Label("Wiretap Configuration");
    wiretapLabel.setStyleName(ValoTheme.LABEL_HUGE);
    layout.addComponent(wiretapLabel);

    Label moduleNameLabel = new Label();
    moduleNameLabel.setContentMode(ContentMode.HTML);
    moduleNameLabel.setValue(VaadinIcons.ARCHIVE.getHtml() + " Module Name:");
    moduleNameLabel.setSizeUndefined();
    layout.addComponent(moduleNameLabel, 0, 1);
    layout.setComponentAlignment(moduleNameLabel, Alignment.MIDDLE_RIGHT);

    TextField moduleNameTextField = new TextField();
    moduleNameTextField.setRequired(true);
    moduleNameTextField.setValue(this.component.getFlow().getModule().getName());
    moduleNameTextField.setReadOnly(true);
    moduleNameTextField.setWidth("80%");
    layout.addComponent(moduleNameTextField, 1, 1);

    Label flowNameLabel = new Label();
    flowNameLabel.setContentMode(ContentMode.HTML);
    flowNameLabel.setValue(VaadinIcons.AUTOMATION.getHtml() + " Flow Name:");
    flowNameLabel.setSizeUndefined();
    layout.addComponent(flowNameLabel, 0, 2);
    layout.setComponentAlignment(flowNameLabel, Alignment.MIDDLE_RIGHT);

    TextField flowNameTextField = new TextField();
    flowNameTextField.setRequired(true);
    flowNameTextField.setValue(this.component.getFlow().getName());
    flowNameTextField.setReadOnly(true);
    flowNameTextField.setWidth("80%");
    layout.addComponent(flowNameTextField, 1, 2);

    Label componentNameLabel = new Label();
    componentNameLabel.setContentMode(ContentMode.HTML);
    componentNameLabel.setValue(VaadinIcons.COG.getHtml() + " Component Name:");
    componentNameLabel.setSizeUndefined();
    layout.addComponent(componentNameLabel, 0, 3);
    layout.setComponentAlignment(componentNameLabel, Alignment.MIDDLE_RIGHT);

    TextField componentNameTextField = new TextField();
    componentNameTextField.setRequired(true);
    componentNameTextField.setValue(this.component.getName());
    componentNameTextField.setReadOnly(true);
    componentNameTextField.setWidth("80%");
    layout.addComponent(componentNameTextField, 1, 3);

    Label errorCategoryLabel = new Label("Relationship:");
    errorCategoryLabel.setSizeUndefined();
    layout.addComponent(errorCategoryLabel, 0, 4);
    layout.setComponentAlignment(errorCategoryLabel, Alignment.MIDDLE_RIGHT);

    final ComboBox relationshipCombo = new ComboBox();
    //      relationshipCombo.addValidator(new StringLengthValidator(
    //               "An relationship must be selected!", 1, -1, false));
    relationshipCombo.setImmediate(false);
    relationshipCombo.setValidationVisible(false);
    relationshipCombo.setRequired(true);
    relationshipCombo.setRequiredError("A relationship must be selected!");
    relationshipCombo.setHeight("30px");
    relationshipCombo.setNullSelectionAllowed(false);
    layout.addComponent(relationshipCombo, 1, 4);
    relationshipCombo.addItem("before");
    relationshipCombo.setItemCaption("before", "Before");
    relationshipCombo.addItem("after");
    relationshipCombo.setItemCaption("after", "After");

    Label jobTypeLabel = new Label("Job Type:");
    jobTypeLabel.setSizeUndefined();
    layout.addComponent(jobTypeLabel, 0, 5);
    layout.setComponentAlignment(jobTypeLabel, Alignment.MIDDLE_RIGHT);

    final ComboBox jobTopCombo = new ComboBox();
    //      jobTopCombo.addValidator(new StringLengthValidator(
    //               "A job type must be selected!", 1, -1, false));
    jobTopCombo.setImmediate(false);
    jobTopCombo.setValidationVisible(false);
    jobTopCombo.setRequired(true);
    jobTopCombo.setRequiredError("A job type must be selected!");
    jobTopCombo.setHeight("30px");
    jobTopCombo.setNullSelectionAllowed(false);
    layout.addComponent(jobTopCombo, 1, 5);
    jobTopCombo.addItem("loggingJob");
    jobTopCombo.setItemCaption("loggingJob", "Logging Job");
    jobTopCombo.addItem("wiretapJob");
    jobTopCombo.setItemCaption("wiretapJob", "Wiretap Job");

    final Label timeToLiveLabel = new Label("Time to Live:");
    timeToLiveLabel.setSizeUndefined();
    timeToLiveLabel.setVisible(false);
    layout.addComponent(timeToLiveLabel, 0, 6);
    layout.setComponentAlignment(timeToLiveLabel, Alignment.MIDDLE_RIGHT);

    final TextField timeToLiveTextField = new TextField();
    timeToLiveTextField.setRequired(true);
    timeToLiveTextField.setValidationVisible(false);
    jobTopCombo.setRequiredError("A time to live value must be entered!");
    timeToLiveTextField.setVisible(false);
    timeToLiveTextField.setWidth("40%");
    layout.addComponent(timeToLiveTextField, 1, 6);

    jobTopCombo.addValueChangeListener(new ComboBox.ValueChangeListener() {

        /* (non-Javadoc)
         * @see com.vaadin.data.Property.ValueChangeListener#valueChange(com.vaadin.data.Property.ValueChangeEvent)
         */
        @Override
        public void valueChange(ValueChangeEvent event) {
            String value = (String) event.getProperty().getValue();

            if (value.equals("wiretapJob")) {
                timeToLiveLabel.setVisible(true);
                timeToLiveTextField.setVisible(true);
            } else {
                timeToLiveLabel.setVisible(false);
                timeToLiveTextField.setVisible(false);
            }
        }

    });

    GridLayout buttonLayouts = new GridLayout(3, 1);
    buttonLayouts.setSpacing(true);

    Button saveButton = new Button("Save");
    saveButton.setStyleName(ValoTheme.BUTTON_SMALL);
    saveButton.addClickListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            try {
                relationshipCombo.validate();
                jobTopCombo.validate();

                if (timeToLiveTextField.isVisible()) {
                    timeToLiveTextField.validate();
                }
            } catch (InvalidValueException e) {
                relationshipCombo.setValidationVisible(true);
                relationshipCombo.markAsDirty();
                jobTopCombo.setValidationVisible(true);
                jobTopCombo.markAsDirty();

                if (timeToLiveTextField.isVisible()) {
                    timeToLiveTextField.setValidationVisible(true);
                    timeToLiveTextField.markAsDirty();
                }

                Notification.show("There are errors on the wiretap creation form!", Type.ERROR_MESSAGE);
                return;
            }

            createWiretap((String) relationshipCombo.getValue(), (String) jobTopCombo.getValue(),
                    timeToLiveTextField.getValue());
        }
    });

    Button cancelButton = new Button("Cancel");
    cancelButton.setStyleName(ValoTheme.BUTTON_SMALL);
    cancelButton.addClickListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            close();
        }
    });

    buttonLayouts.addComponent(saveButton);
    buttonLayouts.addComponent(cancelButton);

    layout.addComponent(buttonLayouts, 0, 7, 1, 7);
    layout.setComponentAlignment(buttonLayouts, Alignment.MIDDLE_CENTER);

    Panel paramPanel = new Panel();
    paramPanel.setStyleName("dashboard");
    paramPanel.setWidth("100%");
    paramPanel.setContent(layout);

    triggerTable = new Table();

    Label existingWiretapLabel = new Label("Existing Wiretaps");
    existingWiretapLabel.setStyleName(ValoTheme.LABEL_HUGE);
    layout.addComponent(existingWiretapLabel, 0, 8, 1, 8);

    layout.addComponent(triggerTable, 0, 9, 1, 9);
    layout.setComponentAlignment(triggerTable, Alignment.TOP_CENTER);

    this.triggerTable.setWidth("80%");
    this.triggerTable.setHeight(150, Unit.PIXELS);
    this.triggerTable.setCellStyleGenerator(new IkasanCellStyleGenerator());
    this.triggerTable.addStyleName(ValoTheme.TABLE_SMALL);
    this.triggerTable.addStyleName("ikasan");
    this.triggerTable.addContainerProperty("Job Type", String.class, null);
    this.triggerTable.addContainerProperty("Relationship", String.class, null);
    this.triggerTable.addContainerProperty("Trigger Parameters", String.class, null);
    this.triggerTable.addContainerProperty("", Button.class, null);

    refreshTriggerTable();

    GridLayout wrapper = new GridLayout(1, 1);
    wrapper.setMargin(true);
    wrapper.setSizeFull();
    wrapper.addComponent(paramPanel);

    this.setContent(wrapper);
}

From source file:probe.com.view.core.ToggleBtn.java

public ToggleBtn(String strBtn1Label, String strBtn2Label, String btn1Comment, String btn2Comment, int width) {

    final Label btn1CommentLabel = new Label(btn1Comment);
    btn1CommentLabel.setStyleName(Reindeer.LABEL_SMALL);
    btn1CommentLabel.setWidth("120px");
    final Label btn2CommentLabel = new Label(btn2Comment);
    btn2CommentLabel.setStyleName(Reindeer.LABEL_SMALL);
    btn2CommentLabel.setVisible(false);
    btn2CommentLabel.setWidth("120px");

    this.setSpacing(true);
    Label btn1Label = new Label(strBtn1Label);
    btn1Label.setStyleName(Reindeer.LABEL_SMALL);
    Label btn2Label = new Label(strBtn2Label);
    btn2Label.setStyleName(Reindeer.LABEL_SMALL);
    toggleSwichButton = new HorizontalLayout();
    toggleSwichButton.setStyleName("toggleleft");
    toggleSwichButton.setWidth("50px");
    toggleSwichButton.setHeight("15px");
    toggleSwichButton.addLayoutClickListener(new LayoutEvents.LayoutClickListener() {

        @Override//from  w ww  .j  ava  2s  . c  o  m
        public void layoutClick(LayoutEvents.LayoutClickEvent event) {
            if (toggleSwichButton.getStyleName().equalsIgnoreCase("toggleleft")) {
                toggleSwichButton.setStyleName("toggleright");
                btn1CommentLabel.setVisible(false);
                btn2CommentLabel.setVisible(true);
            } else {
                toggleSwichButton.setStyleName("toggleleft");
                btn1CommentLabel.setVisible(true);
                btn2CommentLabel.setVisible(false);
            }
        }
    });

    this.addComponent(btn1CommentLabel);//commentLabel
    this.setComponentAlignment(btn1CommentLabel, Alignment.TOP_LEFT);//commentLabel
    this.addComponent(btn2CommentLabel);//commentLabel
    this.setComponentAlignment(btn2CommentLabel, Alignment.TOP_LEFT);//commentLabel
    VerticalLayout spacer = new VerticalLayout();
    width = Math.max((width - 120 - 75 - 75 - 55), 1);
    spacer.setHeight("15px");
    spacer.setWidth(width + "px");
    spacer.setStyleName(Reindeer.LAYOUT_WHITE);
    this.addComponent(spacer);
    this.addComponent(btn1Label);
    this.addComponent(toggleSwichButton);
    this.addComponent(btn2Label);

}