Example usage for com.vaadin.event.dd.acceptcriteria SourceIs SourceIs

List of usage examples for com.vaadin.event.dd.acceptcriteria SourceIs SourceIs

Introduction

In this page you can find the example usage for com.vaadin.event.dd.acceptcriteria SourceIs SourceIs.

Prototype

public SourceIs(Component... component) 

Source Link

Usage

From source file:com.jiangyifen.ec2.ui.mgr.system.tabsheet.DynQueueMemberManagement.java

public DynQueueMemberManagement() {
    this.setWidth("100%");
    this.setMargin(true);
    this.setSpacing(true);

    domain = SpringContextHolder.getDomain();
    userService = SpringContextHolder.getBean("userService");
    queueService = SpringContextHolder.getBean("queueService");
    userQueueService = SpringContextHolder.getBean("userQueueService");
    queueMemberRelationService = SpringContextHolder.getBean("queueMemberRelationService");
    phone2PhoneSettingService = SpringContextHolder.getBean("phone2PhoneSettingService");

    queueContainer = new BeanItemContainer<Queue>(Queue.class);
    List<Queue> allQueues = queueService.getAllByDomain(domain, true);
    for (Queue queue : allQueues) {
        if (queue.getDynamicmember() && queue.getIsModifyable()) {
            queueContainer.addBean(queue);
        }//from   w w w. j a va  2  s  .  c  o m
    }

    priorityError = new Notification(" <B>?</B>?<B> >0 </B>",
            Notification.TYPE_ERROR_MESSAGE);
    priorityError.setDelayMsec(1000);
    priorityError.setHtmlContentAllowed(true);
    priorityError.setPosition(Notification.POSITION_CENTERED);

    usernameToPriority = new TreeMap<String, Integer>();

    // ?  
    createQueueSelectComponents();

    // ?(?????) 
    HorizontalLayout centerHLayout = createCenterHLayout();
    this.addComponent(centerHLayout);

    // ?(???)
    createBottomComponents();

    // ?
    makeTableDragAble(new SourceIs(rightTable), leftTable, true);
    makeTableDragAble(new SourceIs(leftTable), rightTable, false);

    //  ??
    createPriorityConfirmWindow();

    // ?
    for (Queue queue : allQueues) {
        if (queue.getDynamicmember()) {
            queueSelector.select(queue);
            break;
        }
    }
}

From source file:com.jiangyifen.ec2.ui.mgr.system.tabsheet.MgrPhone2PhoneSettingView.java

public MgrPhone2PhoneSettingView() {
    this.setMargin(true);
    this.setWidth("100%");
    this.setSpacing(true);

    domain = SpringContextHolder.getDomain();
    loginUser = SpringContextHolder.getLoginUser();
    userService = SpringContextHolder.getBean("userService");
    queueService = SpringContextHolder.getBean("queueService");
    userQueueService = SpringContextHolder.getBean("userQueueService");
    queueMemberRelationService = SpringContextHolder.getBean("queueMemberRelationService");
    phone2PhoneSettingService = SpringContextHolder.getBean("phone2PhoneSettingService");
    staticQueueMemberService = SpringContextHolder.getBean("staticQueueMemberService");

    notification = new Notification("");
    notification.setDelayMsec(1000);/*from www  . jav  a 2s  .  co m*/
    notification.setHtmlContentAllowed(true);

    VerticalLayout panelContent = new VerticalLayout();
    panelContent.setSpacing(true);
    panelContent.setMargin(true);
    panelContent.setWidth("100%");

    panel = new Panel("?");
    panel.setContent(panelContent);
    panel.setStyleName("light");
    this.addComponent(panel);

    // ?
    createStartSetting(panelContent);

    // ?CSR ?
    createLicensed2Csr(panelContent);

    // 
    createDaysOfWeekType(panelContent);

    // 
    createDayOfWeek(panelContent);

    // 
    createRunRedirectTime(panelContent);

    // 
    createRedirectType(panelContent);

    // ?? 
    createNoanwserTimeout(panelContent);

    // ??
    createSpecifiedPhone(panelContent);

    // ??
    createPhoneArea(panelContent);

    // ????
    createCsrSelectTables(panelContent);

    // ?
    makeTableDragAble(new SourceIs(rightTable), leftTable, true);
    makeTableDragAble(new SourceIs(leftTable), rightTable, false);

    // ?
    HorizontalLayout operators = createOperatorButtons();
    this.addComponent(operators);
}

From source file:com.liferay.mail.vaadin.FolderTree.java

License:Open Source License

public AcceptCriterion getAcceptCriterion() {
    TargetDetailIs isMiddle = new TargetDetailIs("detail", "MIDDLE");
    SourceIs isFromMessageList = new SourceIs(messageList.getTable());

    List<TargetItemIs> rootItemCriterias = new ArrayList<TargetItemIs>();
    for (Object root : rootItemIds()) {
        rootItemCriterias.add(new TargetItemIs(this, root));
    }/*  w  w w  . j av  a2s  . c  om*/
    Or or = new Or(rootItemCriterias.toArray(new TargetItemIs[rootItemCriterias.size()]));
    Not notRootItem = new Not(or);

    return new And(isMiddle, isFromMessageList, notRootItem);
}

From source file:com.rdonasco.security.group.controllers.GroupEditorViewController.java

License:Apache License

private void configureRoleCapabilityTable() {
    Table roleCapabilitiesTable = getControlledView().getGroupRolesTable();
    roleCapabilitiesTable.setSelectable(true);
    roleCapabilitiesTable.setContainerDataSource(groupRolesContainer);
    roleCapabilitiesTable.setVisibleColumns(EDITABLE_COLUMNS);
    roleCapabilitiesTable.setColumnHeaders(EDITABLE_HEADERS);
    roleCapabilitiesTable.setCellStyleGenerator(CELL_STYLE_GENERATOR);
    groupRolesDropHandler = new DropHandler() {
        private static final long serialVersionUID = 1L;

        @Override/*  w  w  w .  java  2  s .  co  m*/
        public void drop(DragAndDropEvent dropEvent) {
            try {
                final DataBoundTransferable transferredData = (DataBoundTransferable) dropEvent
                        .getTransferable();
                final Container sourceContainer = transferredData.getSourceContainer();
                if (transferredData.getItemId() instanceof RoleItemVO) {
                    sessionSecurityChecker.checkCapabilityTo(ActionConstants.ADD,
                            GroupConstants.RESOURCE_GROUP_ROLES);
                    LOG.log(Level.FINE, "drop allowed at group role panel");
                    final RoleItemVO roleItemVO = (RoleItemVO) transferredData.getItemId();
                    addDroppedRoleItemVO(roleItemVO);
                    for (Object object : sourceContainer.getItemIds()) {
                        if (getAvailableRolesTableSource().isSelected(object)) {
                            addDroppedRoleItemVO((RoleItemVO) object);
                        }
                    }

                } else {
                    LOG.log(Level.FINE, "invalid data dropped in group role panel");
                }
            } catch (Exception e) {
                exceptionPopupProvider.popUpErrorException(e);
            }
        }

        @Override
        public AcceptCriterion getAcceptCriterion() {
            ClientSideCriterion sourceCriterion = new SourceIs(getAvailableRolesTableSource());
            return new And(sourceCriterion);
        }

        private void addDroppedRoleItemVO(final RoleItemVO roleItemVO) {
            final GroupRoleItemVO newGroupRoleItemVO = createGroupRoleItemVO(roleItemVO.getRoleVO());
            BeanItem<GroupRoleItemVO> addedItem = groupRolesContainer.addItem(newGroupRoleItemVO);
            LOG.log(Level.FINE, "addedItem = {0}", addedItem);
        }
    };
    getControlledView().getGroupRolesTable().setDropHandler(groupRolesDropHandler);
}

From source file:com.rdonasco.security.user.controllers.UserEditorViewController.java

License:Apache License

private void configureCapabilitiesTab() {
    configureTabContentLayout(getControlledView().getCapabilitiesLayout(),
            userCapabilitiesViewController.getControlledView(),
            getAvailableCapabilitiesViewController().getControlledView());
    // configure drag and drop of capabilities
    userCapabilitiesViewController.setValidDraggedObjectSource(
            new SourceIs(getAvailableCapabilitiesViewController().getControlledView().getEditorTable()));

}

From source file:com.rdonasco.security.user.controllers.UserEditorViewController.java

License:Apache License

private void configureRolesTab() {
    configureTabContentLayout(getControlledView().getRolesLayout(), userRolesViewController.getControlledView(),
            getAvailableRolesViewController().getControlledView());
    // Configure drag and drop of roles
    userRolesViewController.setValidDraggedObjectSource(
            new SourceIs(getAvailableRolesViewController().getControlledView().getEditorTable()));

}

From source file:com.rdonasco.security.user.controllers.UserEditorViewController.java

License:Apache License

private void configureGroupsTab() {
    configureTabContentLayout(getControlledView().getGroupsLayout(),
            userGroupsViewController.getControlledView(),
            getAvailableGroupsViewController().getControlledView());
    // Configure drag and drop of roles
    userGroupsViewController.setValidDraggedObjectSource(
            new SourceIs(getAvailableGroupsViewController().getControlledView().getEditorTable()));

}

From source file:org.escidoc.browser.ui.view.helpers.DragnDropHelper.java

License:Open Source License

protected void createDragComponents() throws EscidocClientException {
    tree = new Tree();
    table = new Table("Drag from table to tree");
    table.setWidth("100%");
    tableDelete = new Table();

    initializeTree(new SourceIs(table));
    initializeTable(new SourceIs(tree));

    Panel pn = new Panel();
    pn.setHeight("100%");
    VerticalLayout vlTree = new VerticalLayout();
    vlTree.addComponent(new Label("Drag from Tree to Table to add new OU"));

    vlTree.addComponent(tf);//from   w w  w  .  jav  a2s  .c o  m
    vlTree.addComponent(tree);

    HorizontalLayout hl = new HorizontalLayout();
    pn.setContent(vlTree);
    hl.addComponent(pn);

    VerticalLayout vl = new VerticalLayout();
    vl.setWidth("100%");
    hl.addComponent(vl);
    vl.addComponent(table);

    if (canRemoveOperation()) {
        initializeDeleteTable(new SourceIs(table));
        vl.addComponent(tableDelete);
        vl.setComponentAlignment(tableDelete, Alignment.TOP_RIGHT);
    }
    addComponent(hl);

}

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

License:BSD License

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

    VerticalLayout layout = new VerticalLayout();
    layout.setSizeFull();/*from w  w w. java  2s . c om*/

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

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

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

    Label userSearchHintLabel = new Label();
    userSearchHintLabel.setCaptionAsHtml(true);
    userSearchHintLabel.setCaption(VaadinIcons.QUESTION_CIRCLE_O.getHtml()
            + " Type into the Username, Firstname or Surname fields to find a user.");
    userSearchHintLabel.addStyleName(ValoTheme.LABEL_TINY);
    userSearchHintLabel.addStyleName(ValoTheme.LABEL_LIGHT);
    gridLayout.addComponent(userSearchHintLabel, 0, 1, 1, 1);

    Label usernameLabel = new Label("Username:");

    usernameField.setWidth("40%");

    final DragAndDropWrapper usernameFieldWrap = new DragAndDropWrapper(usernameField);
    usernameFieldWrap.setDragStartMode(DragStartMode.COMPONENT);

    firstName = new AutocompleteField<User>();
    firstName.setWidth("40%");
    surname = new AutocompleteField<User>();
    surname.setWidth("40%");
    final TextField department = new TextField();
    department.setWidth("40%");
    final TextField email = new TextField();
    email.setWidth("40%");

    final Table roleTable = new Table();
    roleTable.addContainerProperty("Role", String.class, null);
    roleTable.addContainerProperty("", Button.class, null);
    roleTable.setHeight("520px");
    roleTable.setWidth("250px");

    usernameField.setQueryListener(new AutocompleteQueryListener<User>() {
        @Override
        public void handleUserQuery(AutocompleteField<User> field, String query) {
            for (User user : userService.getUserByUsernameLike(query)) {
                field.addSuggestion(user, user.getUsername());
            }
        }
    });

    usernameField.setSuggestionPickedListener(new AutocompleteSuggestionPickedListener<User>() {
        @Override
        public void onSuggestionPicked(User user) {
            UserManagementPanel.this.user = user;
            firstName.setText(user.getFirstName());
            surname.setText(user.getSurname());
            department.setValue(user.getDepartment());
            email.setValue(user.getEmail());

            final IkasanPrincipal principal = securityService.findPrincipalByName(user.getUsername());

            roleTable.removeAllItems();

            for (final Role role : principal.getRoles()) {
                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) {
                        roleTable.removeItem(role);

                        principal.getRoles().remove(role);

                        securityService.savePrincipal(principal);

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

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

            associatedPrincipalsTable.removeAllItems();

            for (IkasanPrincipal ikasanPrincipal : user.getPrincipals()) {
                if (!ikasanPrincipal.getType().equals("user")) {
                    associatedPrincipalsTable.addItem(new Object[] { ikasanPrincipal.getName() },
                            ikasanPrincipal);
                }
            }
        }
    });

    firstName.setQueryListener(new AutocompleteQueryListener<User>() {
        @Override
        public void handleUserQuery(AutocompleteField<User> field, String query) {
            for (User user : userService.getUserByFirstnameLike(query)) {
                field.addSuggestion(user, user.getFirstName() + " " + user.getSurname());
            }
        }
    });

    firstName.setSuggestionPickedListener(new AutocompleteSuggestionPickedListener<User>() {
        @Override
        public void onSuggestionPicked(User user) {
            UserManagementPanel.this.user = user;
            usernameField.setText(user.getUsername());
            firstName.setText(user.getFirstName());
            surname.setText(user.getSurname());
            department.setValue(user.getDepartment());
            email.setValue(user.getEmail());

            final IkasanPrincipal principal = securityService.findPrincipalByName(user.getUsername());

            roleTable.removeAllItems();

            for (final Role role : principal.getRoles()) {
                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) {
                        roleTable.removeItem(role);

                        principal.getRoles().remove(role);

                        securityService.savePrincipal(principal);

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

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

            associatedPrincipalsTable.removeAllItems();

            for (IkasanPrincipal ikasanPrincipal : user.getPrincipals()) {
                if (!ikasanPrincipal.getType().equals("user")) {
                    associatedPrincipalsTable.addItem(new Object[] { ikasanPrincipal.getName() },
                            ikasanPrincipal);
                }
            }
        }
    });

    surname.setQueryListener(new AutocompleteQueryListener<User>() {
        @Override
        public void handleUserQuery(AutocompleteField<User> field, String query) {
            for (User user : userService.getUserBySurnameLike(query)) {
                field.addSuggestion(user, user.getFirstName() + " " + user.getSurname());
            }
        }
    });

    surname.setSuggestionPickedListener(new AutocompleteSuggestionPickedListener<User>() {
        @Override
        public void onSuggestionPicked(User user) {
            UserManagementPanel.this.user = user;
            usernameField.setText(user.getUsername());
            firstName.setText(user.getFirstName());
            surname.setText(user.getSurname());
            department.setValue(user.getDepartment());
            email.setValue(user.getEmail());

            final IkasanPrincipal principal = securityService.findPrincipalByName(user.getUsername());

            roleTable.removeAllItems();

            for (final Role role : principal.getRoles()) {
                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) {
                        roleTable.removeItem(role);

                        principal.getRoles().remove(role);

                        securityService.savePrincipal(principal);

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

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

                associatedPrincipalsTable.removeAllItems();

                for (IkasanPrincipal ikasanPrincipal : user.getPrincipals()) {
                    if (!ikasanPrincipal.getType().equals("user")) {
                        associatedPrincipalsTable.addItem(new Object[] { ikasanPrincipal.getName() },
                                ikasanPrincipal);
                    }
                }
            }
        }
    });

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

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

    usernameLabel.setSizeUndefined();
    formLayout.addComponent(usernameLabel, 0, 0);
    formLayout.setComponentAlignment(usernameLabel, Alignment.MIDDLE_RIGHT);
    formLayout.addComponent(usernameFieldWrap, 1, 0);

    Label firstNameLabel = new Label("First name:");
    firstNameLabel.setSizeUndefined();
    formLayout.addComponent(firstNameLabel, 0, 1);
    formLayout.setComponentAlignment(firstNameLabel, Alignment.MIDDLE_RIGHT);
    formLayout.addComponent(firstName, 1, 1);

    Label surnameLabel = new Label("Surname:");
    surnameLabel.setSizeUndefined();
    formLayout.addComponent(surnameLabel, 0, 2);
    formLayout.setComponentAlignment(surnameLabel, Alignment.MIDDLE_RIGHT);
    formLayout.addComponent(surname, 1, 2);

    Label departmentLabel = new Label("Department:");
    departmentLabel.setSizeUndefined();
    formLayout.addComponent(departmentLabel, 0, 3);
    formLayout.setComponentAlignment(departmentLabel, Alignment.MIDDLE_RIGHT);
    formLayout.addComponent(department, 1, 3);

    Label emailLabel = new Label("Email address:");
    emailLabel.setSizeUndefined();
    formLayout.addComponent(emailLabel, 0, 4);
    formLayout.setComponentAlignment(emailLabel, Alignment.MIDDLE_RIGHT);
    formLayout.addComponent(email, 1, 4);

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

    Label rolesAndGroupsHintLabel1 = new Label();
    rolesAndGroupsHintLabel1.setCaptionAsHtml(true);
    rolesAndGroupsHintLabel1.setCaption(VaadinIcons.QUESTION_CIRCLE_O.getHtml()
            + " The Roles table below displays the roles that the user has. Roles can be deleted from this table.");
    rolesAndGroupsHintLabel1.addStyleName(ValoTheme.LABEL_TINY);
    rolesAndGroupsHintLabel1.addStyleName(ValoTheme.LABEL_LIGHT);
    rolesAndGroupsHintLabel1.setWidth(300, Unit.PIXELS);
    gridLayout.addComponent(rolesAndGroupsHintLabel1, 0, 3, 1, 3);

    Label rolesAndGroupsHintLabel2 = new Label();
    rolesAndGroupsHintLabel2.setCaptionAsHtml(true);
    rolesAndGroupsHintLabel2.setCaption(VaadinIcons.QUESTION_CIRCLE_O.getHtml()
            + " The Groups table below displays all the LDAP groups that the user is a member of. You cannot manage these "
            + "from this application.");
    rolesAndGroupsHintLabel2.addStyleName(ValoTheme.LABEL_TINY);
    rolesAndGroupsHintLabel2.addStyleName(ValoTheme.LABEL_LIGHT);
    rolesAndGroupsHintLabel2.setWidth(300, Unit.PIXELS);
    gridLayout.addComponent(rolesAndGroupsHintLabel2, 0, 4, 1, 4);

    final ClientSideCriterion acceptCriterion = new SourceIs(usernameField);

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

    userDropTable.setDragMode(TableDragMode.ROW);
    userDropTable.setDropHandler(new DropHandler() {
        @Override
        public void drop(final DragAndDropEvent dropEvent) {
            if (rolesCombo.getValue() == null) {
                // Do nothing if there is no role selected
                logger.info("Ignoring drop: " + dropEvent);
                return;
            }

            // criteria verify that this is safe
            logger.info("Trying to drop: " + dropEvent);

            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) {
                    userDropTable.removeItem(principal.getName());

                    principal.getRoles().remove(roleToRemove);

                    securityService.savePrincipal(principal);

                    if (UserManagementPanel.this.usernameField.getText().equals(principal.getName())) {
                        roleTable.removeItem(roleToRemove);
                    }
                }
            });

            userDropTable.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);

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

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

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

    gridLayout.addComponent(roleTable, 0, 5);

    this.associatedPrincipalsTable.addContainerProperty("Groups", String.class, null);
    this.associatedPrincipalsTable.addItemClickListener(this.associatedPrincipalItemClickListener);
    associatedPrincipalsTable.setHeight("520px");
    associatedPrincipalsTable.setWidth("400px");

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

    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) {
                logger.info("Value changed got Role: " + role);

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

                userDropTable.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) {
                            userDropTable.removeItem(principal.getName());

                            principal.getRoles().remove(role);

                            securityService.savePrincipal(principal);

                            if (UserManagementPanel.this.usernameField.getText().equals(principal.getName())) {
                                roleTable.removeItem(role);
                            }
                        }
                    });

                    userDropTable.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%");

    Label roleMemberAssociationsLabel = new Label("Role/Member Associations");
    roleMemberAssociationsLabel.setStyleName(ValoTheme.LABEL_HUGE);

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

    roleMemberLayout.addComponent(roleMemberAssociationsLabel);
    roleMemberLayout.addComponent(userDragHintLabel);
    roleMemberLayout.addComponent(this.rolesCombo);
    roleMemberLayout.addComponent(this.userDropTable);

    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:uicomponents.PoolingTable.java

License:Open Source License

public PoolingTable(String name, TabSheet selectionTables, Map<Integer, Integer> usedTimes,
        List<String> factorLabels) {
    this.selectionTables = selectionTables;
    all = (Table) selectionTables.getTab(0).getComponent();
    used = (Table) selectionTables.getTab(1).getComponent();
    labels = factorLabels;/*from   www .  ja  va  2s.  com*/

    this.usedTimes = usedTimes;
    setSpacing(true);

    HorizontalLayout tableButtonComponent = new HorizontalLayout();
    tableButtonComponent.setCaption("Sample Pool");
    tableButtonComponent.setSpacing(true);
    secondaryName = new StandardTextField("Secondary Name");
    secondaryName.setValue(name);
    secondaryName.setStyleName(Styles.fieldTheme);
    moveLeft = new Button();
    Styles.iconButton(moveLeft, FontAwesome.ARROW_CIRCLE_LEFT);

    moveLeft.addStyleName("large_font_awesome");
    addComponent(secondaryName);
    poolIDs = new HashSet<Integer>();
    poolTable = new Table();
    initTable();
    tableButtonComponent.addComponent(poolTable);
    tableButtonComponent.addComponent(moveLeft);
    addComponent(Styles.questionize(tableButtonComponent,
            "You can add samples to the active pool by " + "selecting them from the right and clicking "
                    + FontAwesome.ARROW_CIRCLE_LEFT.getHtml() + " or by dragging them over with your mouse.",
            "Adding Samples to Pools"));

    initDragAndDrop(new Or(new SourceIs(all), new SourceIs(used)));
    initButtonMover(all, used);
}