List of usage examples for com.vaadin.ui HorizontalSplitPanel setLocked
public void setLocked(boolean locked)
From source file:com.esspl.datagen.ui.ExplorerView.java
License:Open Source License
public ExplorerView(final DataGenApplication dataApp, DatabaseSessionManager databaseSessionManager) { log.debug("ExplorerView - constructor start"); dataGenApplication = dataApp;//from w w w .j a v a 2s .co m setCaption("Tables"); setSizeFull(); final HorizontalSplitPanel sp = new HorizontalSplitPanel(); sp.setSizeFull(); sp.setLocked(true); TableSelectorView tableSelectorView = new TableSelectorView(databaseSessionManager, dataGenApplication); tableSelectorView.setDetailsListener(new DetailsListener() { @Override public void showDetails(Component component) { component.setSizeFull(); sp.setSecondComponent(component); } }); sp.setFirstComponent(tableSelectorView); sp.setSplitPosition(210, UNITS_PIXELS); setCompositionRoot(sp); }
From source file:com.m4gik.views.MainView.java
/** * @param split//from w ww . java2 s .co m */ private void addPanelRight(final HorizontalSplitPanel split) { right.setSizeFull(); split.setSecondComponent(right); split.setLocked(true); right.addTab(buildWelcomeScreen(), "Welcome"); right.addTab(buildMusic(playerLayout), "Music Player"); right.addTab(buildLicenseScreen(), "License"); right.addListener(new Listener() { private static final long serialVersionUID = 3585077764011982717L; @Override public void componentEvent(Event event) { if (right.getSelectedTab() == music) { split.setSplitPosition(20, Sizeable.Unit.PERCENTAGE); split.setLocked(false); } else { split.setSplitPosition(1, Sizeable.Unit.PIXELS); split.setLocked(true); } } }); }
From source file:com.m4gik.views.MainView.java
/** * @param root/* w ww.j a v a2 s . com*/ */ private void addSplitPanel(VerticalLayout root) { final HorizontalSplitPanel split = new HorizontalSplitPanel(); split.setStyleName(Runo.SPLITPANEL_REDUCED); split.setSplitPosition(1, Sizeable.Unit.PIXELS); split.setLocked(true); root.addComponent(split); root.setExpandRatio(split, 1); addPanelLeft(split); addPanelRight(split); }
From source file:com.vaushell.treetasker.application.window.UserWindow.java
License:Open Source License
/** * Displays the user's view./* w w w . j av a 2s . c o m*/ */ public void setUserView() { mainLayout.removeComponent(controller.getLoginLayout()); mainLayout.addComponent(controller.getActionBar()); HorizontalSplitPanel splitPanel = new HorizontalSplitPanel(); splitPanel.setWidth("1000px"); splitPanel.setHeight("100%"); splitPanel.setSplitPosition(30); splitPanel.setLocked(true); splitPanel.setMargin(true); splitPanel.setStyleName("content"); splitPanel.addComponent(controller.getTree()); splitPanel.addComponent(controller.getContent()); controller.refresh(); mainLayout.addComponent(splitPanel); mainLayout.setExpandRatio(splitPanel, 1); mainLayout.setComponentAlignment(splitPanel, Alignment.TOP_CENTER); }
From source file:fi.jasoft.qrcode.demo.QRCodeDemo.java
License:Apache License
@Override protected void init(VaadinRequest request) { VerticalLayout content = new VerticalLayout(); content.setSizeFull();//from w w w .ja v a 2 s . c o m setContent(content); Label header = new Label("QR Code Generator"); header.setStyleName(ValoTheme.LABEL_H2); content.addComponent(header); HorizontalSplitPanel root = new HorizontalSplitPanel(); root.setSizeFull(); root.setSplitPosition(50, Unit.PERCENTAGE); root.setLocked(true); Panel panel = new Panel(root); panel.setSizeFull(); content.addComponent(panel); content.setExpandRatio(panel, 1); VerticalLayout first = new VerticalLayout(); first.setSizeFull(); root.setFirstComponent(first); first.addComponent( new HorizontalLayout(createPrimaryColorSelect(), createSecondaryColorSelect(), createSizeSelect())); code = new QRCode(); code.setWidth("100px"); code.setHeight("100px"); final TextArea text = new TextArea("Text embedded in QR Code"); text.setPlaceholder("Type the message of the QR code here"); text.setSizeFull(); text.setValueChangeMode(ValueChangeMode.LAZY); text.addValueChangeListener(e -> { code.setValue(e.getValue()); }); first.addComponent(text); first.setExpandRatio(text, 1); VerticalLayout vl = new VerticalLayout(); vl.setSizeFull(); vl.addComponent(code); vl.setComponentAlignment(code, Alignment.MIDDLE_CENTER); root.setSecondComponent(vl); }
From source file:net.sourceforge.javydreamercsw.validation.manager.web.ValidationManagerUI.java
License:Apache License
private Component getContentComponent() { HorizontalSplitPanel hsplit = new HorizontalSplitPanel(); hsplit.setLocked(true); if (left != null) { if (!(left instanceof Panel)) { left = new Panel(left); }/* ww w. j ava2 s .c om*/ if (user != null) { hsplit.setFirstComponent(left); } } tabSheet.removeAllComponents(); //Build the right component main = tabSheet.addTab(new VerticalLayout(), TRANSLATOR.translate("general.main")); Lookup.getDefault().lookupAll(IMainContentProvider.class).forEach((provider) -> { Iterator<Component> it = tabSheet.iterator(); Component me = findMainProvider(provider.getComponentCaption()); if (me == null) { if (provider.shouldDisplay()) { LOG.log(Level.FINE, "Loading: {0}", TRANSLATOR.translate(provider.getComponentCaption())); tabSheet.addTab(provider.getContent(), TRANSLATOR.translate(provider.getComponentCaption())); } } else { provider.update(); } //Hide if needed if (me != null && !provider.shouldDisplay()) { tabSheet.removeComponent(me); } }); hsplit.setSecondComponent(tabSheet); //This is a tabbed pane. Enable/Disable the panes based on role if (getUser() != null) { roles.clear(); user.update();//Get any recent changes user.getRoleList().forEach((r) -> { roles.add(r.getRoleName()); }); } hsplit.setSplitPosition(25, Unit.PERCENTAGE); return hsplit; }
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 w w.j av a 2s . 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.PrincipalManagementPanel.java
License:BSD License
@SuppressWarnings("deprecation") protected void init() { this.setWidth("100%"); this.setHeight("100%"); VerticalLayout layout = new VerticalLayout(); layout.setSpacing(true);/* ww w. j a va 2 s. c o m*/ 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();//from w ww.java 2 s . c om 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); }
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();//w ww . j av a 2 s . 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); }