Example usage for com.vaadin.ui Label setCaption

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

Introduction

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

Prototype

@Override
    public void setCaption(String caption) 

Source Link

Usage

From source file:org.eclipse.hawkbit.ui.management.footer.ActionTypeOptionGroupLayout.java

License:Open Source License

private void createOptionGroup() {
    actionTypeOptionGroup = new FlexibleOptionGroup();
    actionTypeOptionGroup.addItem(ActionTypeOption.SOFT);
    actionTypeOptionGroup.addItem(ActionTypeOption.FORCED);
    actionTypeOptionGroup.addItem(ActionTypeOption.AUTO_FORCED);
    selectDefaultOption();/*from   w  w  w  .j a  va2s  .co m*/

    final FlexibleOptionGroupItemComponent forceItem = actionTypeOptionGroup
            .getItemComponent(ActionTypeOption.FORCED);
    forceItem.setStyleName(STYLE_DIST_WINDOW_ACTIONTYPE);
    // set Id for Forced radio button.
    forceItem.setId("save.action.radio.forced");
    addComponent(forceItem);
    final Label forceLabel = new Label();
    forceLabel.setStyleName("statusIconPending");
    forceLabel.setIcon(FontAwesome.BOLT);
    forceLabel.setCaption("Forced");
    forceLabel.setDescription(i18n.getMessage("tooltip.forced.item"));
    forceLabel.setStyleName("padding-right-style");
    addComponent(forceLabel);

    final FlexibleOptionGroupItemComponent softItem = actionTypeOptionGroup
            .getItemComponent(ActionTypeOption.SOFT);
    softItem.setId(UIComponentIdProvider.ACTION_DETAILS_SOFT_ID);
    softItem.setStyleName(STYLE_DIST_WINDOW_ACTIONTYPE);
    addComponent(softItem);
    final Label softLabel = new Label();
    softLabel.setSizeFull();
    softLabel.setCaption("Soft");
    softLabel.setDescription(i18n.getMessage("tooltip.soft.item"));
    softLabel.setStyleName("padding-right-style");
    addComponent(softLabel);

    final FlexibleOptionGroupItemComponent autoForceItem = actionTypeOptionGroup
            .getItemComponent(ActionTypeOption.AUTO_FORCED);
    autoForceItem.setStyleName(STYLE_DIST_WINDOW_ACTIONTYPE);
    // setted Id for Time Forced radio button.
    autoForceItem.setId(UIComponentIdProvider.ACTION_TYPE_OPTION_GROUP_SAVE_TIMEFORCED);
    addComponent(autoForceItem);
    final Label autoForceLabel = new Label();
    autoForceLabel.setStyleName("statusIconPending");
    autoForceLabel.setIcon(FontAwesome.HISTORY);
    autoForceLabel.setCaption("Time Forced");
    autoForceLabel.setDescription(i18n.getMessage("tooltip.timeforced.item"));
    autoForceLabel.setStyleName(STYLE_DIST_WINDOW_ACTIONTYPE);
    addComponent(autoForceLabel);

    forcedTimeDateField = new DateField();
    forcedTimeDateField.setInvalidAllowed(false);
    forcedTimeDateField.setInvalidCommitted(false);
    forcedTimeDateField.setEnabled(false);
    forcedTimeDateField.setStyleName("dist-window-forcedtime");

    final TimeZone tz = SPDateTimeUtil.getBrowserTimeZone();
    forcedTimeDateField.setValue(
            Date.from(LocalDateTime.now().plusWeeks(2).atZone(SPDateTimeUtil.getTimeZoneId(tz)).toInstant()));
    forcedTimeDateField.setImmediate(true);
    forcedTimeDateField.setTimeZone(tz);
    forcedTimeDateField.setLocale(HawkbitCommonUtil.getLocale());
    forcedTimeDateField.setResolution(Resolution.MINUTE);
    forcedTimeDateField.addStyleName(ValoTheme.DATEFIELD_SMALL);
    addComponent(forcedTimeDateField);
}

From source file:org.eclipse.hawkbit.ui.management.miscs.AbstractActionTypeOptionGroupLayout.java

License:Open Source License

protected void addForcedItemWithLabel() {
    final FlexibleOptionGroupItemComponent forceItem = actionTypeOptionGroup
            .getItemComponent(ActionTypeOption.FORCED);
    forceItem.setStyleName(STYLE_DIST_WINDOW_ACTIONTYPE);
    forceItem.setId(UIComponentIdProvider.SAVE_ACTION_RADIO_FORCED);
    addComponent(forceItem);/*from   w w w  .j  ava2s  . c  o m*/
    final Label forceLabel = new Label();
    forceLabel.setStyleName("statusIconPending");
    forceLabel.setIcon(FontAwesome.BOLT);
    forceLabel.setCaption(i18n.getMessage(UIMessageIdProvider.CAPTION_ACTION_FORCED));
    forceLabel.setDescription(i18n.getMessage(UIMessageIdProvider.TOOLTIP_FORCED_ITEM));
    forceLabel.setStyleName("padding-right-style");
    addComponent(forceLabel);
}

From source file:org.eclipse.hawkbit.ui.management.miscs.AbstractActionTypeOptionGroupLayout.java

License:Open Source License

protected void addSoftItemWithLabel() {
    final FlexibleOptionGroupItemComponent softItem = actionTypeOptionGroup
            .getItemComponent(ActionTypeOption.SOFT);
    softItem.setId(UIComponentIdProvider.ACTION_DETAILS_SOFT_ID);
    softItem.setStyleName(STYLE_DIST_WINDOW_ACTIONTYPE);
    addComponent(softItem);/*from  www . j a va 2 s.c  o m*/
    final Label softLabel = new Label();
    softLabel.setSizeFull();
    softLabel.setCaption(i18n.getMessage(UIMessageIdProvider.CAPTION_ACTION_SOFT));
    softLabel.setDescription(i18n.getMessage(UIMessageIdProvider.TOOLTIP_SOFT_ITEM));
    softLabel.setStyleName("padding-right-style");
    addComponent(softLabel);
}

From source file:org.eclipse.hawkbit.ui.management.miscs.ActionTypeOptionGroupAssignmentLayout.java

License:Open Source License

private void addAutoForceItemWithLabelAndDateField() {
    final FlexibleOptionGroupItemComponent autoForceItem = actionTypeOptionGroup
            .getItemComponent(ActionTypeOption.AUTO_FORCED);
    autoForceItem.setStyleName(STYLE_DIST_WINDOW_ACTIONTYPE);
    autoForceItem.setId(UIComponentIdProvider.ACTION_TYPE_OPTION_GROUP_SAVE_TIMEFORCED);
    addComponent(autoForceItem);/* w  w w  . ja va 2  s  .c o  m*/
    final Label autoForceLabel = new Label();
    autoForceLabel.setStyleName("statusIconPending");
    autoForceLabel.setIcon(FontAwesome.HISTORY);
    autoForceLabel.setCaption(i18n.getMessage(UIMessageIdProvider.CAPTION_ACTION_TIME_FORCED));
    autoForceLabel.setDescription(i18n.getMessage(UIMessageIdProvider.TOOLTIP_TIMEFORCED_ITEM));
    autoForceLabel.setStyleName(STYLE_DIST_WINDOW_ACTIONTYPE);
    addComponent(autoForceLabel);

    forcedTimeDateField = new DateField();
    forcedTimeDateField.setInvalidAllowed(false);
    forcedTimeDateField.setInvalidCommitted(false);
    forcedTimeDateField.setEnabled(false);
    forcedTimeDateField.setStyleName("dist-window-forcedtime");

    final TimeZone tz = SPDateTimeUtil.getBrowserTimeZone();
    forcedTimeDateField.setValue(
            Date.from(LocalDateTime.now().plusWeeks(2).atZone(SPDateTimeUtil.getTimeZoneId(tz)).toInstant()));
    forcedTimeDateField.setImmediate(true);
    forcedTimeDateField.setTimeZone(tz);
    forcedTimeDateField.setLocale(HawkbitCommonUtil.getCurrentLocale());
    forcedTimeDateField.setResolution(Resolution.MINUTE);
    forcedTimeDateField.addStyleName(ValoTheme.DATEFIELD_SMALL);
    addComponent(forcedTimeDateField);
}

From source file:org.eclipse.hawkbit.ui.management.miscs.ActionTypeOptionGroupLayout.java

License:Open Source License

private void createOptionGroup() {
    actionTypeOptionGroup = new FlexibleOptionGroup();
    actionTypeOptionGroup.addItem(ActionTypeOption.SOFT);
    actionTypeOptionGroup.addItem(ActionTypeOption.FORCED);
    actionTypeOptionGroup.addItem(ActionTypeOption.AUTO_FORCED);
    selectDefaultOption();/*from  w  ww  . ja  v  a2 s .com*/

    final FlexibleOptionGroupItemComponent forceItem = actionTypeOptionGroup
            .getItemComponent(ActionTypeOption.FORCED);
    forceItem.setStyleName(STYLE_DIST_WINDOW_ACTIONTYPE);
    forceItem.setId(UIComponentIdProvider.SAVE_ACTION_RADIO_FORCED);
    addComponent(forceItem);
    final Label forceLabel = new Label();
    forceLabel.setStyleName("statusIconPending");
    forceLabel.setIcon(FontAwesome.BOLT);
    forceLabel.setCaption(i18n.getMessage(UIMessageIdProvider.CAPTION_ACTION_FORCED));
    forceLabel.setDescription(i18n.getMessage(UIMessageIdProvider.TOOLTIP_FORCED_ITEM));
    forceLabel.setStyleName("padding-right-style");
    addComponent(forceLabel);

    final FlexibleOptionGroupItemComponent softItem = actionTypeOptionGroup
            .getItemComponent(ActionTypeOption.SOFT);
    softItem.setId(UIComponentIdProvider.ACTION_DETAILS_SOFT_ID);
    softItem.setStyleName(STYLE_DIST_WINDOW_ACTIONTYPE);
    addComponent(softItem);
    final Label softLabel = new Label();
    softLabel.setSizeFull();
    softLabel.setCaption(i18n.getMessage(UIMessageIdProvider.CAPTION_ACTION_SOFT));
    softLabel.setDescription(i18n.getMessage(UIMessageIdProvider.TOOLTIP_SOFT_ITEM));
    softLabel.setStyleName("padding-right-style");
    addComponent(softLabel);

    final FlexibleOptionGroupItemComponent autoForceItem = actionTypeOptionGroup
            .getItemComponent(ActionTypeOption.AUTO_FORCED);
    autoForceItem.setStyleName(STYLE_DIST_WINDOW_ACTIONTYPE);
    autoForceItem.setId(UIComponentIdProvider.ACTION_TYPE_OPTION_GROUP_SAVE_TIMEFORCED);
    addComponent(autoForceItem);
    final Label autoForceLabel = new Label();
    autoForceLabel.setStyleName("statusIconPending");
    autoForceLabel.setIcon(FontAwesome.HISTORY);
    autoForceLabel.setCaption(i18n.getMessage(UIMessageIdProvider.CAPTION_ACTION_TIME_FORCED));
    autoForceLabel.setDescription(i18n.getMessage(UIMessageIdProvider.TOOLTIP_TIMEFORCED_ITEM));
    autoForceLabel.setStyleName(STYLE_DIST_WINDOW_ACTIONTYPE);
    addComponent(autoForceLabel);

    forcedTimeDateField = new DateField();
    forcedTimeDateField.setInvalidAllowed(false);
    forcedTimeDateField.setInvalidCommitted(false);
    forcedTimeDateField.setEnabled(false);
    forcedTimeDateField.setStyleName("dist-window-forcedtime");

    final TimeZone tz = SPDateTimeUtil.getBrowserTimeZone();
    forcedTimeDateField.setValue(
            Date.from(LocalDateTime.now().plusWeeks(2).atZone(SPDateTimeUtil.getTimeZoneId(tz)).toInstant()));
    forcedTimeDateField.setImmediate(true);
    forcedTimeDateField.setTimeZone(tz);
    forcedTimeDateField.setLocale(HawkbitCommonUtil.getLocale());
    forcedTimeDateField.setResolution(Resolution.MINUTE);
    forcedTimeDateField.addStyleName(ValoTheme.DATEFIELD_SMALL);
    addComponent(forcedTimeDateField);
}

From source file:org.eclipse.hawkbit.ui.rollout.rollout.AutoStartOptionGroupLayout.java

License:Open Source License

private void createOptionGroup() {
    autoStartOptionGroup = new FlexibleOptionGroup();
    autoStartOptionGroup.addItem(AutoStartOption.MANUAL);
    autoStartOptionGroup.addItem(AutoStartOption.AUTO_START);
    autoStartOptionGroup.addItem(AutoStartOption.SCHEDULED);
    selectDefaultOption();//w w  w  . j  a  v a2  s  .  c  o  m

    final FlexibleOptionGroupItemComponent manualItem = autoStartOptionGroup
            .getItemComponent(AutoStartOption.MANUAL);
    manualItem.setStyleName(STYLE_DIST_WINDOW_AUTO_START);
    // set Id for Forced radio button.
    manualItem.setId(UIComponentIdProvider.ROLLOUT_START_MANUAL_ID);
    addComponent(manualItem);
    final Label manualLabel = new Label();
    manualLabel.setStyleName("statusIconPending");
    manualLabel.setIcon(FontAwesome.HAND_PAPER_O);
    manualLabel.setCaption(i18n.getMessage("caption.rollout.start.manual"));
    manualLabel.setDescription(i18n.getMessage("caption.rollout.start.manual.desc"));
    manualLabel.setStyleName("padding-right-style");
    addComponent(manualLabel);

    final FlexibleOptionGroupItemComponent autoStartItem = autoStartOptionGroup
            .getItemComponent(AutoStartOption.AUTO_START);
    autoStartItem.setId(UIComponentIdProvider.ROLLOUT_START_AUTO_ID);
    autoStartItem.setStyleName(STYLE_DIST_WINDOW_AUTO_START);
    addComponent(autoStartItem);
    final Label autoStartLabel = new Label();
    autoStartLabel.setSizeFull();
    autoStartLabel.setIcon(FontAwesome.PLAY);
    autoStartLabel.setCaption(i18n.getMessage("caption.rollout.start.auto"));
    autoStartLabel.setDescription(i18n.getMessage("caption.rollout.start.auto.desc"));
    autoStartLabel.setStyleName("padding-right-style");
    addComponent(autoStartLabel);

    final FlexibleOptionGroupItemComponent scheduledItem = autoStartOptionGroup
            .getItemComponent(AutoStartOption.SCHEDULED);
    scheduledItem.setStyleName(STYLE_DIST_WINDOW_AUTO_START);
    // setted Id for Time Forced radio button.
    scheduledItem.setId(UIComponentIdProvider.ROLLOUT_START_SCHEDULED_ID);
    addComponent(scheduledItem);
    final Label scheduledLabel = new Label();
    scheduledLabel.setStyleName("statusIconPending");
    scheduledLabel.setIcon(FontAwesome.CLOCK_O);
    scheduledLabel.setCaption(i18n.getMessage("caption.rollout.start.scheduled"));
    scheduledLabel.setDescription(i18n.getMessage("caption.rollout.start.scheduled.desc"));
    scheduledLabel.setStyleName(STYLE_DIST_WINDOW_AUTO_START);
    addComponent(scheduledLabel);

    startAtDateField = new DateField();
    startAtDateField.setInvalidAllowed(false);
    startAtDateField.setInvalidCommitted(false);
    startAtDateField.setEnabled(false);
    startAtDateField.setStyleName("dist-window-forcedtime");

    final TimeZone tz = SPDateTimeUtil.getBrowserTimeZone();
    startAtDateField.setValue(Date
            .from(LocalDateTime.now().plusMinutes(30).atZone(SPDateTimeUtil.getTimeZoneId(tz)).toInstant()));
    startAtDateField.setImmediate(true);
    startAtDateField.setTimeZone(tz);
    startAtDateField.setLocale(HawkbitCommonUtil.getCurrentLocale());
    startAtDateField.setResolution(Resolution.MINUTE);
    startAtDateField.addStyleName(ValoTheme.DATEFIELD_SMALL);
    addComponent(startAtDateField);
}

From source file:org.ikasan.dashboard.ui.administration.panel.PolicyManagementPanel.java

License:BSD License

@SuppressWarnings({ "serial" })
protected void init() {
    this.setWidth("100%");
    this.setHeight("100%");

    this.createAssociatedRolesPanel();
    this.createPolicyDropPanel();

    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);//from  w  ww  .  j av  a  2 s .  c o m
    layout.setSpacing(true);
    layout.setWidth("100%");

    Panel policyAdministrationPanel = new Panel();
    policyAdministrationPanel.addStyleName(ValoTheme.PANEL_BORDERLESS);
    policyAdministrationPanel.setHeight("100%");
    policyAdministrationPanel.setWidth("100%");

    GridLayout gridLayout = new GridLayout(2, 6);
    gridLayout.setSizeFull();

    Label roleManagementLabel = new Label("Policy Management");
    roleManagementLabel.setStyleName(ValoTheme.LABEL_HUGE);
    gridLayout.addComponent(roleManagementLabel, 0, 0, 1, 0);

    Label roleSearchHintLabel = new Label();
    roleSearchHintLabel.setCaptionAsHtml(true);
    roleSearchHintLabel.setCaption(
            VaadinIcons.QUESTION_CIRCLE_O.getHtml() + " Type into the Policy Name field to find a policy.");
    roleSearchHintLabel.addStyleName(ValoTheme.LABEL_TINY);
    roleSearchHintLabel.addStyleName(ValoTheme.LABEL_LIGHT);
    gridLayout.addComponent(roleSearchHintLabel, 0, 1, 1, 1);

    Layout controlLayout = this.initControlLayout();

    gridLayout.addComponent(controlLayout, 0, 2, 1, 2);

    GridLayout formLayout = new GridLayout(2, 4);
    formLayout.setWidth("100%");
    formLayout.setSpacing(true);
    formLayout.setColumnExpandRatio(0, 1);
    formLayout.setColumnExpandRatio(1, 5);

    Label policyNameLabel = new Label("Policy Name:");
    policyNameLabel.setSizeUndefined();
    final DragAndDropWrapper policyNameFieldWrap = initPolicyNameField();

    formLayout.addComponent(policyNameLabel, 0, 0);
    formLayout.setComponentAlignment(policyNameLabel, Alignment.MIDDLE_RIGHT);
    formLayout.addComponent(policyNameFieldWrap, 1, 0);

    Label descriptionLabel = new Label("Description:");
    descriptionLabel.setSizeUndefined();
    this.descriptionField = new TextArea();
    this.descriptionField.setWidth("70%");
    this.descriptionField.setHeight("60px");
    formLayout.addComponent(descriptionLabel, 0, 1);
    formLayout.setComponentAlignment(descriptionLabel, Alignment.TOP_RIGHT);
    formLayout.addComponent(this.descriptionField, 1, 1);

    this.linkTypeLabel.setSizeUndefined();
    formLayout.addComponent(this.linkTypeLabel, 0, 2);
    formLayout.setComponentAlignment(this.linkTypeLabel, Alignment.MIDDLE_RIGHT);
    this.linkType.setWidth("70%");
    formLayout.addComponent(this.linkType, 1, 2);
    this.linkTypeLabel.setVisible(false);
    this.linkType.setVisible(false);

    this.linkedEntityLabel.setSizeUndefined();
    this.linkedEntity = new TextArea();
    this.linkedEntity.setWidth("70%");
    this.linkedEntity.setHeight("60px");

    formLayout.addComponent(this.linkedEntityLabel, 0, 3);
    formLayout.setComponentAlignment(this.linkedEntityLabel, Alignment.MIDDLE_RIGHT);
    formLayout.addComponent(linkedEntity, 1, 3);
    this.linkedEntityLabel.setVisible(false);
    this.linkedEntity.setVisible(false);

    gridLayout.addComponent(formLayout, 0, 3, 1, 3);

    Label roleTableHintLabel = new Label();
    roleTableHintLabel.setCaptionAsHtml(true);
    roleTableHintLabel.setCaption(VaadinIcons.QUESTION_CIRCLE_O.getHtml()
            + " The Roles table below displays the roles that are assigned the current policy.");
    roleTableHintLabel.addStyleName(ValoTheme.LABEL_TINY);
    roleTableHintLabel.addStyleName(ValoTheme.LABEL_LIGHT);
    gridLayout.addComponent(roleTableHintLabel, 0, 4, 1, 4);

    gridLayout.addComponent(this.roleTable, 0, 5, 1, 5);

    policyAdministrationPanel.setContent(gridLayout);
    layout.addComponent(policyAdministrationPanel);

    HorizontalLayout roleMemberPanelLayout = new HorizontalLayout();
    roleMemberPanelLayout.setMargin(true);
    roleMemberPanelLayout.addComponent(this.policyDropPanel);
    roleMemberPanelLayout.setSizeFull();

    HorizontalSplitPanel hsplit = new HorizontalSplitPanel();
    hsplit.setFirstComponent(layout);
    hsplit.setSecondComponent(roleMemberPanelLayout);

    // Set the position of the splitter as percentage
    hsplit.setSplitPosition(65, Unit.PERCENTAGE);
    hsplit.setLocked(true);

    this.setContent(hsplit);
}

From source file:org.ikasan.dashboard.ui.administration.panel.PolicyManagementPanel.java

License:BSD License

/**
 * /*  ww w.  ja  v a2  s  . c  om*/
 */
protected void createPolicyDropPanel() {
    this.policyDropPanel = new Panel();

    Label rolePoliciesLabel = new Label("Role/Policy Associations");
    rolePoliciesLabel.setStyleName(ValoTheme.LABEL_HUGE);

    this.policyDropPanel.addStyleName(ValoTheme.PANEL_BORDERLESS);
    this.policyDropPanel.setHeight("100%");
    this.policyDropPanel.setWidth("100%");

    this.rolesCombo = new ComboBox("Roles");
    this.rolesCombo.setWidth("90%");
    this.rolesCombo.addValueChangeListener(new Property.ValueChangeListener() {
        public void valueChange(ValueChangeEvent event) {
            final Role role = (Role) event.getProperty().getValue();

            if (role != null) {
                List<Policy> policies = securityService.getAllPoliciesWithRole(role.getName());

                PolicyManagementPanel.this.policyDropTable.removeAllItems();

                for (final Policy policy : policies) {
                    Button deleteButton = new Button();
                    deleteButton.setIcon(VaadinIcons.TRASH);
                    deleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
                    deleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS);
                    deleteButton.setDescription("Remove Policy from this Role");

                    deleteButton.addClickListener(new Button.ClickListener() {
                        public void buttonClick(ClickEvent event) {
                            role.getPolicies().remove(policy);
                            PolicyManagementPanel.this.saveRole(role);

                            PolicyManagementPanel.this.policyDropTable.removeItem(policy.getName());
                            PolicyManagementPanel.this.roleTable.removeItem(role);
                        }
                    });

                    PolicyManagementPanel.this.policyDropTable
                            .addItem(new Object[] { policy.getName(), deleteButton }, policy.getName());
                }
            }
        }
    });

    this.policyDropTable = new Table();
    this.policyDropTable.addContainerProperty("Role Policies", String.class, null);
    this.policyDropTable.addContainerProperty("", Button.class, null);
    this.policyDropTable.setHeight("700px");
    this.policyDropTable.setWidth("300px");

    this.policyDropTable.setDragMode(TableDragMode.ROW);
    this.policyDropTable.setDropHandler(new DropHandler() {
        @Override
        public void drop(final DragAndDropEvent dropEvent) {
            // criteria verify that this is safe
            logger.info("Trying to drop: " + dropEvent);

            if (rolesCombo.getValue() == null) {
                // Do nothing if there is no role selected
                logger.info("Ignoring drop: " + dropEvent);
                return;
            }

            final WrapperTransferable t = (WrapperTransferable) dropEvent.getTransferable();

            final AutocompleteField sourceContainer = (AutocompleteField) t.getDraggedComponent();
            logger.info("sourceContainer.getText(): " + sourceContainer.getText());

            Button deleteButton = new Button();
            deleteButton.setIcon(VaadinIcons.TRASH);
            deleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
            deleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS);
            deleteButton.setDescription("Remove Policy from this Role");

            final Policy policy = PolicyManagementPanel.this.securityService
                    .findPolicyByName(sourceContainer.getText());

            final Role selectedRole = PolicyManagementPanel.this.securityService
                    .findRoleByName(((Role) rolesCombo.getValue()).getName());

            deleteButton.addClickListener(new Button.ClickListener() {
                public void buttonClick(ClickEvent event) {
                    selectedRole.getPolicies().remove(policy);
                    PolicyManagementPanel.this.saveRole(selectedRole);

                    policyDropTable.removeItem(policy.getName());
                    roleTable.removeItem(selectedRole);
                }
            });

            PolicyManagementPanel.this.policyDropTable.addItem(
                    new Object[] { sourceContainer.getText(), deleteButton }, sourceContainer.getText());

            selectedRole.getPolicies().add(policy);

            PolicyManagementPanel.this.saveRole(selectedRole);
            policy.getRoles().add(selectedRole);

            PolicyManagementPanel.this.roleTable.removeAllItems();

            for (final Role role : policy.getRoles()) {
                Button roleDeleteButton = new Button();
                roleDeleteButton.setIcon(VaadinIcons.TRASH);
                roleDeleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
                deleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS);
                deleteButton.setDescription("Remove Policy from this Role");

                roleDeleteButton.addClickListener(new Button.ClickListener() {
                    public void buttonClick(ClickEvent event) {
                        selectedRole.getPolicies().remove(policy);
                        PolicyManagementPanel.this.saveRole(selectedRole);

                        PolicyManagementPanel.this.roleTable.removeItem(role);
                        PolicyManagementPanel.this.policyDropTable.removeItem(policy.getName());
                    }
                });

                PolicyManagementPanel.this.roleTable.addItem(new Object[] { role.getName(), roleDeleteButton },
                        role);
            }
        }

        @Override
        public AcceptCriterion getAcceptCriterion() {
            return AcceptAll.get();
        }
    });

    GridLayout layout = new GridLayout();
    layout.setSpacing(true);
    layout.setWidth("100%");
    layout.setHeight("100%");

    layout.addComponent(rolePoliciesLabel);
    layout.addComponent(this.rolesCombo);

    Label policyDropHintLabel = new Label();
    policyDropHintLabel.setCaptionAsHtml(true);
    policyDropHintLabel.setCaption(VaadinIcons.QUESTION_CIRCLE_O.getHtml()
            + " Drop a policy into the table below to associate with a role.");
    policyDropHintLabel.addStyleName(ValoTheme.LABEL_TINY);
    policyDropHintLabel.addStyleName(ValoTheme.LABEL_LIGHT);
    layout.addComponent(policyDropHintLabel);

    layout.addComponent(this.policyDropTable);

    this.policyDropPanel.setContent(layout);
}

From source file:org.ikasan.dashboard.ui.administration.panel.PrincipalManagementPanel.java

License:BSD License

@SuppressWarnings("deprecation")
protected void init() {
    this.setWidth("100%");
    this.setHeight("100%");

    VerticalLayout layout = new VerticalLayout();
    layout.setSpacing(true);// www . j  av a2 s.c om
    layout.setSizeFull();

    Panel securityAdministrationPanel = new Panel();
    securityAdministrationPanel.addStyleName(ValoTheme.PANEL_BORDERLESS);
    securityAdministrationPanel.setHeight("100%");
    securityAdministrationPanel.setWidth("100%");

    GridLayout gridLayout = new GridLayout(2, 5);
    gridLayout.setWidth("100%");
    gridLayout.setHeight("100%");
    gridLayout.setMargin(true);
    gridLayout.setSizeFull();

    Label groupManagementLabel = new Label("Group Management");
    groupManagementLabel.setStyleName(ValoTheme.LABEL_HUGE);
    gridLayout.addComponent(groupManagementLabel, 0, 0, 1, 0);

    Label groupSearchHintLabel = new Label();
    groupSearchHintLabel.setCaptionAsHtml(true);
    groupSearchHintLabel.setCaption(
            VaadinIcons.QUESTION_CIRCLE_O.getHtml() + " Type into the Group Name field to find a group.");
    groupSearchHintLabel.addStyleName(ValoTheme.LABEL_TINY);
    groupSearchHintLabel.addStyleName(ValoTheme.LABEL_LIGHT);
    gridLayout.addComponent(groupSearchHintLabel, 0, 1, 1, 1);

    Label principalNameLabel = new Label("Group Name:");
    principalNameLabel.setSizeUndefined();

    principalNameField = new AutocompleteField<IkasanPrincipal>();
    principalNameField.setWidth("70%");

    final DragAndDropWrapper principalNameFieldWrap = new DragAndDropWrapper(principalNameField);
    principalNameFieldWrap.setDragStartMode(DragStartMode.COMPONENT);

    principalTypeField.setWidth("70%");
    descriptionField.setWidth("70%");
    descriptionField.setHeight("60px");

    roleTable.addContainerProperty("Role", String.class, null);
    roleTable.addContainerProperty("", Button.class, null);
    roleTable.setHeight("610px");
    roleTable.setWidth("300px");

    userTable.addContainerProperty("Associated Users", String.class, null);
    userTable.setHeight("610px");
    userTable.setWidth("300px");

    principalDropTable.addContainerProperty("Members", String.class, null);
    principalDropTable.addContainerProperty("", Button.class, null);
    principalDropTable.setHeight("700px");
    principalDropTable.setWidth("300px");

    principalNameField.setQueryListener(new AutocompleteQueryListener<IkasanPrincipal>() {
        @Override
        public void handleUserQuery(AutocompleteField<IkasanPrincipal> field, String query) {
            for (IkasanPrincipal principal : securityService.getPrincipalByNameLike(query)) {
                field.addSuggestion(principal, principal.getName());
            }
        }
    });

    principalNameField.setSuggestionPickedListener(new AutocompleteSuggestionPickedListener<IkasanPrincipal>() {
        @Override
        public void onSuggestionPicked(final IkasanPrincipal principal) {
            PrincipalManagementPanel.this.principal = principal;
            PrincipalManagementPanel.this.setValues();
        }
    });

    GridLayout formLayout = new GridLayout(2, 3);
    formLayout.setWidth("100%");
    formLayout.setHeight("135px");
    formLayout.setSpacing(true);

    formLayout.setColumnExpandRatio(0, .1f);
    formLayout.setColumnExpandRatio(1, .8f);

    formLayout.addComponent(principalNameLabel, 0, 0);
    formLayout.setComponentAlignment(principalNameLabel, Alignment.MIDDLE_RIGHT);
    formLayout.addComponent(principalNameFieldWrap, 1, 0);

    Label principalTypeLabel = new Label("Group Type:");
    principalTypeLabel.setSizeUndefined();
    formLayout.addComponent(principalTypeLabel, 0, 1);
    formLayout.setComponentAlignment(principalTypeLabel, Alignment.MIDDLE_RIGHT);
    formLayout.addComponent(principalTypeField, 1, 1);

    Label descriptionLabel = new Label("Description:");
    descriptionLabel.setSizeUndefined();
    formLayout.addComponent(descriptionLabel, 0, 2);
    formLayout.setComponentAlignment(descriptionLabel, Alignment.TOP_RIGHT);
    formLayout.addComponent(descriptionField, 1, 2);

    gridLayout.addComponent(formLayout, 0, 2, 1, 2);

    principalDropTable.setDragMode(TableDragMode.ROW);
    principalDropTable.setDropHandler(new DropHandler() {
        @Override
        public void drop(final DragAndDropEvent dropEvent) {
            // criteria verify that this is safe
            logger.info("Trying to drop: " + dropEvent);

            if (rolesCombo.getValue() == null) {
                // Do nothing if there is no role selected
                logger.info("Ignoring drop: " + dropEvent);
                return;
            }

            final WrapperTransferable t = (WrapperTransferable) dropEvent.getTransferable();

            final AutocompleteField sourceContainer = (AutocompleteField) t.getDraggedComponent();
            logger.info("sourceContainer.getText(): " + sourceContainer.getText());

            Button deleteButton = new Button();

            deleteButton.setIcon(VaadinIcons.TRASH);
            deleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
            deleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS);

            final IkasanPrincipal principal = securityService.findPrincipalByName(sourceContainer.getText());
            final Role roleToRemove = (Role) rolesCombo.getValue();

            deleteButton.addClickListener(new Button.ClickListener() {
                public void buttonClick(ClickEvent event) {
                    principalDropTable.removeItem(principal.getName());

                    principal.getRoles().remove(roleToRemove);

                    securityService.savePrincipal(principal);

                    if (principalNameField.getText().equals(principal.getName())) {
                        roleTable.removeItem(roleToRemove);
                    }
                }
            });

            principalDropTable.addItem(new Object[] { sourceContainer.getText(), deleteButton },
                    sourceContainer.getText());

            principal.getRoles().add((Role) rolesCombo.getValue());

            securityService.savePrincipal(principal);

            roleTable.removeAllItems();

            for (final Role role : principal.getRoles()) {
                Button roleDeleteButton = new Button();
                roleDeleteButton.setIcon(VaadinIcons.TRASH);
                roleDeleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
                roleDeleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS);

                roleDeleteButton.addClickListener(new Button.ClickListener() {
                    public void buttonClick(ClickEvent event) {
                        roleTable.removeItem(role);

                        principal.getRoles().remove(role);

                        securityService.savePrincipal(principal);

                        principalDropTable.removeItem(principal.getName());
                    }
                });

                roleTable.addItem(new Object[] { role.getName(), roleDeleteButton }, role);
            }
        }

        @Override
        public AcceptCriterion getAcceptCriterion() {
            return AcceptAll.get();
        }
    });

    Label roleTableHintLabel = new Label();
    roleTableHintLabel.setCaptionAsHtml(true);
    roleTableHintLabel.setCaption(VaadinIcons.QUESTION_CIRCLE_O.getHtml()
            + " The Roles table below displays the roles that are assigned to the group. Roles can be deleted from this table.");
    roleTableHintLabel.addStyleName(ValoTheme.LABEL_TINY);
    roleTableHintLabel.addStyleName(ValoTheme.LABEL_LIGHT);
    gridLayout.addComponent(roleTableHintLabel, 0, 3, 1, 3);

    gridLayout.addComponent(roleTable, 0, 4);
    gridLayout.addComponent(userTable, 1, 4);

    this.rolesCombo = new ComboBox("Roles");
    this.rolesCombo.setWidth("90%");
    this.rolesCombo.addListener(new Property.ValueChangeListener() {
        public void valueChange(ValueChangeEvent event) {
            final Role role = (Role) event.getProperty().getValue();

            if (role != null) {
                logger.info("Value changed got Role: " + role);

                List<IkasanPrincipal> principals = securityService.getAllPrincipalsWithRole(role.getName());

                principalDropTable.removeAllItems();

                for (final IkasanPrincipal principal : principals) {
                    Button deleteButton = new Button();

                    deleteButton.setIcon(VaadinIcons.TRASH);
                    deleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
                    deleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS);

                    deleteButton.addClickListener(new Button.ClickListener() {
                        public void buttonClick(ClickEvent event) {
                            principalDropTable.removeItem(principal.getName());

                            principal.getRoles().remove(role);

                            securityService.savePrincipal(principal);

                            if (principalNameField.getText().equals(principal.getName())) {
                                roleTable.removeItem(role);
                            }
                        }
                    });

                    principalDropTable.addItem(new Object[] { principal.getName(), deleteButton },
                            principal.getName());
                }
            }
        }
    });

    Panel roleMemberPanel = new Panel();

    roleMemberPanel.addStyleName(ValoTheme.PANEL_BORDERLESS);
    roleMemberPanel.setHeight("100%");
    roleMemberPanel.setWidth("100%");

    GridLayout roleMemberLayout = new GridLayout();
    roleMemberLayout.setSpacing(true);
    roleMemberLayout.setWidth("100%");
    roleMemberLayout.setHeight("100%");

    Label roleGroupLabels = new Label("Role/Group Associations");
    roleGroupLabels.setStyleName(ValoTheme.LABEL_HUGE);
    gridLayout.addComponent(roleGroupLabels);

    Label groupDragHintLabel = new Label();
    groupDragHintLabel.setCaptionAsHtml(true);
    groupDragHintLabel.setCaption(VaadinIcons.QUESTION_CIRCLE_O.getHtml()
            + " Drop groups into the table below to assign them the role.");

    roleMemberLayout.addComponent(roleGroupLabels);
    roleMemberLayout.addComponent(groupDragHintLabel);
    roleMemberLayout.addComponent(this.rolesCombo);
    roleMemberLayout.addComponent(this.principalDropTable);

    roleMemberPanel.setContent(roleMemberLayout);

    securityAdministrationPanel.setContent(gridLayout);
    layout.addComponent(securityAdministrationPanel);

    VerticalLayout roleMemberPanelLayout = new VerticalLayout();
    roleMemberPanelLayout.setWidth("100%");
    roleMemberPanelLayout.setHeight("100%");
    roleMemberPanelLayout.setMargin(true);
    roleMemberPanelLayout.addComponent(roleMemberPanel);
    roleMemberPanelLayout.setSizeFull();

    HorizontalSplitPanel hsplit = new HorizontalSplitPanel();
    hsplit.setFirstComponent(layout);
    hsplit.setSecondComponent(roleMemberPanelLayout);

    // Set the position of the splitter as percentage
    hsplit.setSplitPosition(65, Unit.PERCENTAGE);
    hsplit.setLocked(true);

    this.setContent(hsplit);
}

From source file:org.ikasan.dashboard.ui.administration.panel.RoleManagementPanel.java

License:BSD License

@SuppressWarnings({ "serial" })
protected void init() {
    this.setWidth("100%");
    this.setHeight("100%");

    this.initPolicyNameField();
    this.createPolicyDropPanel();

    VerticalLayout layout = new VerticalLayout();
    layout.setSizeFull();//  w ww  .  j a  v  a2s . c  o  m

    Panel roleAdministrationPanel = new Panel();
    roleAdministrationPanel.addStyleName(ValoTheme.PANEL_BORDERLESS);
    roleAdministrationPanel.setHeight("100%");
    roleAdministrationPanel.setWidth("100%");

    GridLayout gridLayout = new GridLayout(2, 6);
    gridLayout.setWidth("100%");
    gridLayout.setHeight("100%");
    gridLayout.setMargin(true);
    gridLayout.setSizeFull();

    Label roleManagementLabel = new Label("Role Management");
    roleManagementLabel.setStyleName(ValoTheme.LABEL_HUGE);
    gridLayout.addComponent(roleManagementLabel, 0, 0, 1, 0);

    Label roleSearchHintLabel = new Label();
    roleSearchHintLabel.setCaptionAsHtml(true);
    roleSearchHintLabel.setCaption(
            VaadinIcons.QUESTION_CIRCLE_O.getHtml() + " Type into the Role Name field to find a role.");
    roleSearchHintLabel.addStyleName(ValoTheme.LABEL_TINY);
    roleSearchHintLabel.addStyleName(ValoTheme.LABEL_LIGHT);
    gridLayout.addComponent(roleSearchHintLabel, 0, 1, 1, 1);

    Layout controlLayout = this.initControlLayout();

    gridLayout.addComponent(controlLayout, 0, 2, 1, 2);

    Label roleNameLabel = new Label("Role Name:");
    roleNameLabel.setSizeUndefined();
    initRoleNameField();

    GridLayout formLayout = new GridLayout(2, 2);
    formLayout.setWidth("100%");
    formLayout.setHeight("115px");
    formLayout.setSpacing(true);

    formLayout.setColumnExpandRatio(0, 1);
    formLayout.setColumnExpandRatio(1, 5);

    this.roleNameField.setWidth("70%");
    formLayout.addComponent(roleNameLabel, 0, 0);
    formLayout.setComponentAlignment(roleNameLabel, Alignment.MIDDLE_RIGHT);
    formLayout.addComponent(this.roleNameField, 1, 0);

    Label descriptionLabel = new Label("Description:");
    descriptionLabel.setSizeUndefined();
    this.descriptionField = new TextArea();
    this.descriptionField.setWidth("70%");
    this.descriptionField.setHeight("60px");
    formLayout.addComponent(descriptionLabel, 0, 1);
    formLayout.setComponentAlignment(descriptionLabel, Alignment.TOP_RIGHT);
    formLayout.addComponent(descriptionField, 1, 1);

    gridLayout.addComponent(formLayout, 0, 3, 1, 3);

    Label roleTableHintLabel = new Label();
    roleTableHintLabel.setCaptionAsHtml(true);
    roleTableHintLabel.setCaption(VaadinIcons.QUESTION_CIRCLE_O.getHtml()
            + " The Associated Users/Groups table below displays the users/groups that are assigned the current role.");
    roleTableHintLabel.addStyleName(ValoTheme.LABEL_TINY);
    roleTableHintLabel.addStyleName(ValoTheme.LABEL_LIGHT);
    gridLayout.addComponent(roleTableHintLabel, 0, 4, 1, 4);

    this.associatedPrincipalsTable = new Table();
    this.associatedPrincipalsTable.addItemClickListener(this.associatedPrincipalItemClickListener);
    this.associatedPrincipalsTable.addContainerProperty("Associated Users/Groups", String.class, null);
    this.associatedPrincipalsTable.addContainerProperty("", Button.class, null);
    this.associatedPrincipalsTable.setHeight("600px");
    this.associatedPrincipalsTable.setWidth("650px");

    gridLayout.addComponent(this.associatedPrincipalsTable, 0, 5, 1, 5);

    roleAdministrationPanel.setContent(gridLayout);
    layout.addComponent(roleAdministrationPanel);

    HorizontalLayout policyDropPanelLayout = new HorizontalLayout();
    policyDropPanelLayout.setMargin(true);
    policyDropPanelLayout.addComponent(this.policyDropPanel);
    policyDropPanelLayout.setSizeFull();

    HorizontalSplitPanel hsplit = new HorizontalSplitPanel();
    hsplit.setFirstComponent(layout);
    hsplit.setSecondComponent(policyDropPanelLayout);

    // Set the position of the splitter as percentage
    hsplit.setSplitPosition(65, Unit.PERCENTAGE);
    hsplit.setLocked(true);

    this.setContent(hsplit);
}