List of usage examples for com.vaadin.ui HorizontalSplitPanel setSplitPosition
public void setSplitPosition(float pos, boolean reverse)
From source file:de.unioninvestment.portal.explorer.view.vfs.VFSMainView.java
License:Apache License
public VFSMainView(ConfigBean cb, VFSFileExplorerPortlet instance) throws Exception { final String vfsUrl = cb.getVfsUrl(); if (vfsUrl.length() != 0) { removeAllComponents();//from www.j av a 2s . c o m explorerPanel.setStyleName(Reindeer.PANEL_LIGHT); filePanel.setStyleName(Reindeer.PANEL_LIGHT); FileSystemOptions opts = new FileSystemOptions(); logger.log(Level.INFO, "Check Type "); if (cb.getVfsType().equalsIgnoreCase("FTP") || cb.getVfsType().equalsIgnoreCase("SFTP")) { if (cb.getUsername() != null && cb.getUsername().length() > 0) { StaticUserAuthenticator auth = new StaticUserAuthenticator(null, cb.getUsername(), cb.getPassword()); DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(opts, auth); } } if (cb.getVfsType().equalsIgnoreCase("FTP")) { FtpFileSystemConfigBuilder.getInstance().setUserDirIsRoot(opts, true); FtpFileSystemConfigBuilder.getInstance().setPassiveMode(opts, true); } if (cb.getVfsType().equalsIgnoreCase("SFTP")) { SftpFileSystemConfigBuilder.getInstance().setUserDirIsRoot(opts, true); if (cb.getKeyfile() != null && cb.getKeyfile().length() > 0) { logger.log(Level.INFO, "Keyfile " + cb.getKeyfile()); SftpFileSystemConfigBuilder.getInstance().setStrictHostKeyChecking(opts, "no"); File keyFile = new File(cb.getKeyfile()); SftpFileSystemConfigBuilder.getInstance().setIdentities(opts, new File[] { keyFile }); } SftpFileSystemConfigBuilder.getInstance().setProxyType(opts, SftpFileSystemConfigBuilder.PROXY_HTTP); if (cb.getProxyHost() != null && cb.getProxyHost().length() > 0) { SftpFileSystemConfigBuilder.getInstance().setProxyHost(opts, cb.getProxyHost()); logger.log(Level.INFO, "ProxyHost " + cb.getProxyHost()); } if (cb.getProxyPort() != null && cb.getProxyPort().length() > 0) { SftpFileSystemConfigBuilder.getInstance().setProxyPort(opts, Integer.valueOf(cb.getProxyPort())); logger.log(Level.INFO, "ProxyPort " + cb.getProxyPort()); } } DefaultFileSystemManager fsManager = null; fsManager = getManager(); final HorizontalSplitPanel panel = new HorizontalSplitPanel(); panel.setHeight(500, UNITS_PIXELS); panel.setWidth(1400, UNITS_PIXELS); panel.setSplitPosition(350, Sizeable.UNITS_PIXELS); panel.setFirstComponent(explorerPanel); panel.setSecondComponent(filePanel); addComponent(panel); final Embedded image = new Embedded(); image.setType(Embedded.TYPE_IMAGE); image.setSource(FOLDER); image.setHeight(15, Sizeable.UNITS_PIXELS); explorerPanel.setSizeFull(); filePanel.setSizeFull(); explorerPanel.addComponent(tree); filePanel.addComponent(new TableView(instance, fsManager, opts, cb)); tree.setImmediate(true); tree.addListener(new ItemClickEvent.ItemClickListener() { private static final long serialVersionUID = 1L; @Override public void itemClick(ItemClickEvent event) { VFSFileExplorerPortlet app = (VFSFileExplorerPortlet) getApplication(); String newDir = (String) event.getItemId(); app.getEventBus().fireEvent(new TableChangedEvent(newDir)); } }); scanDirectory(fsManager, opts, vfsUrl); } else { addComponent(new Label("Please configure Portlet !")); } }
From source file:edu.cornell.qatarmed.planrnaseq.AnnotateRNAseqSQL.java
private void initLayout() { /* Root of the user interface component tree is set */ HorizontalSplitPanel splitPanel = new HorizontalSplitPanel(); setContent(splitPanel);/*from w w w.ja v a 2s.com*/ /* Build the component tree */ VerticalLayout leftLayout = new VerticalLayout(); VerticalSplitPanel rightSplitPanel = new VerticalSplitPanel(); // VerticalSplitPanel leftSplitPanel = new VerticalSplitPanel(); splitPanel.addComponent(leftLayout); splitPanel.addComponent(rightSplitPanel); VerticalLayout rightTopLayout = new VerticalLayout(); // rightTopLayout.addComponent(rightTopForm); rightTopTabsheet.setSizeFull(); rightTopLayout.addComponent(rightTopTabsheet); rightTopTabsheet.addTab(rightTopForm, "Study Details"); rightTopTabsheet.addTab(rightTopAnnotationForm, "Annotate"); rightTopLayout.setSizeFull(); rightSplitPanel.addComponent(rightTopLayout); HorizontalSplitPanel rightBottomLayout = new HorizontalSplitPanel(); // HorizontalLayout rightBottomLayout = new HorizontalLayout(); VerticalLayout rightBottomLeftLayout = new VerticalLayout(); VerticalLayout rightBottomRightLayout = new VerticalLayout(); rightBottomLayout.addComponent(rightBottomLeftLayout); rightBottomLayout.addComponent(rightBottomRightLayout); // rightBottomLayout.setExpandRatio(rightBottomLeftLayout, 1); // rightBottomLayout.setExpandRatio(rightBottomRightLayout, 3); rightBottomLayout.setSplitPosition(30f, Unit.PERCENTAGE); rightBottomLayout.setSizeFull(); rightBottomTabsheet.setSizeFull(); rightSplitPanel.addComponent(rightBottomLayout); splitPanel.setSplitPosition(50f, Unit.PERCENTAGE); // rightSplitPanel.setWidth("20%"); /* //make form asking parameters and add it to leftLaayout VerticalLayout formLayout = new VerticalLayout(); // TextField studyName = new TextField("RNAseq Study Name"); formLayout.addComponent(studyName); List replist = new ArrayList(); ComboBox numReplicates = new ComboBox("Replicates", replist); formLayout.addComponent(numReplicates); leftLayout.addComponent(formLayout); */ HorizontalLayout leftTopLayout = new HorizontalLayout(); leftLayout.addComponent(leftTopLayout); leftTopLayout.addComponent(searchField); leftTopLayout.addComponent(searchButton); leftTopLayout.setWidth("100%"); searchField.setWidth("100%"); leftTopLayout.setExpandRatio(searchField, 1); leftLayout.addComponent(bioprojectSummaryTable); // leftLayout.setExpandRatio(searchField, 0); leftLayout.setExpandRatio(bioprojectSummaryTable, 1); bioprojectSummaryTable.setSizeFull(); /* Set the contents in the left of the split panel to use all the space */ leftLayout.setSizeFull(); /* VerticalLayout resultLayout = new VerticalLayout(); rightLayout.addComponent(resultLayout); VerticalLayout chartLayout = new VerticalLayout(); rightLayout.addComponent(chartLayout); chartLayout.setVisible(false); */ rightBottomLeftLayout.addComponent(tree); rightBottomRightLayout.addComponent(rightBottomTabsheet); rightBottomTabsheet.addTab(myform, "Selected Biosample"); myform.setSizeFull(); VerticalLayout rbTabBiosampleSummaryLayout = new VerticalLayout(); // Right bottom Biosample Summary rightBottomTabsheet.addTab(rbTabBiosampleSummaryLayout, "All Biosamples"); rbTabBiosampleSummaryLayout.addComponent(biosampleSummaryTable); rbTabBiosampleSummaryLayout.setSizeFull(); initDataAndSubcomponent(); rightTopLayout.setSizeFull(); rightBottomRightLayout.setSizeFull(); }
From source file:edu.cornell.qatarmed.planrnaseq.AnnotateView.java
public void initLayout() { /* Root of the user interface component tree is set */ HorizontalSplitPanel splitPanel = new HorizontalSplitPanel(); addComponent(splitPanel);// w w w.j ava 2 s .c o m // panel = new Panel(); // panel.setContent(splitPanel); splitPanel.setSizeFull(); //setCompositionRoot(splitPanel); // panel.setContent(splitPanel); /* Build the component tree */ VerticalLayout leftLayout = new VerticalLayout(); VerticalSplitPanel rightSplitPanel = new VerticalSplitPanel(); // VerticalSplitPanel leftSplitPanel = new VerticalSplitPanel(); splitPanel.addComponent(leftLayout); splitPanel.addComponent(rightSplitPanel); VerticalLayout rightTopLayout = new VerticalLayout(); // rightTopLayout.addComponent(rightTopForm); rightTopTabsheet.setSizeFull(); rightTopLayout.addComponent(rightTopTabsheet); rightTopTabsheet.addTab(rightTopForm, "Study Details"); rightTopTabsheet.addTab(rightTopAnnotationForm, "Annotate"); rightTopLayout.setSizeFull(); rightSplitPanel.addComponent(rightTopLayout); HorizontalSplitPanel rightBottomLayout = new HorizontalSplitPanel(); // HorizontalLayout rightBottomLayout = new HorizontalLayout(); VerticalLayout rightBottomLeftLayout = new VerticalLayout(); VerticalLayout rightBottomRightLayout = new VerticalLayout(); rightBottomLayout.addComponent(rightBottomLeftLayout); rightBottomLayout.addComponent(rightBottomRightLayout); // rightBottomLayout.setExpandRatio(rightBottomLeftLayout, 1); // rightBottomLayout.setExpandRatio(rightBottomRightLayout, 3); rightBottomLayout.setSplitPosition(30f, Unit.PERCENTAGE); rightBottomLayout.setSizeFull(); rightBottomTabsheet.setSizeFull(); rightSplitPanel.addComponent(rightBottomLayout); splitPanel.setSplitPosition(50f, Unit.PERCENTAGE); // rightSplitPanel.setWidth("20%"); /* //make form asking parameters and add it to leftLaayout VerticalLayout formLayout = new VerticalLayout(); // TextField studyName = new TextField("RNAseq Study Name"); formLayout.addComponent(studyName); List replist = new ArrayList(); ComboBox numReplicates = new ComboBox("Replicates", replist); formLayout.addComponent(numReplicates); leftLayout.addComponent(formLayout); */ HorizontalLayout leftTopLayout = new HorizontalLayout(); leftLayout.addComponent(leftTopLayout); leftTopLayout.addComponent(searchField); leftTopLayout.addComponent(searchButton); leftTopLayout.setWidth("100%"); searchField.setWidth("100%"); leftTopLayout.setExpandRatio(searchField, 1); leftLayout.addComponent(bioprojectSummaryTable); // leftLayout.setExpandRatio(searchField, 0); leftLayout.setExpandRatio(bioprojectSummaryTable, 1); bioprojectSummaryTable.setSizeFull(); /* Set the contents in the left of the split panel to use all the space */ leftLayout.setSizeFull(); /* VerticalLayout resultLayout = new VerticalLayout(); rightLayout.addComponent(resultLayout); VerticalLayout chartLayout = new VerticalLayout(); rightLayout.addComponent(chartLayout); chartLayout.setVisible(false); */ rightBottomLeftLayout.addComponent(tree); rightBottomRightLayout.addComponent(rightBottomTabsheet); rightBottomTabsheet.addTab(myform, "Selected Biosample"); myform.setSizeFull(); VerticalLayout rbTabBiosampleSummaryLayout = new VerticalLayout(); // Right bottom Biosample Summary rightBottomTabsheet.addTab(rbTabBiosampleSummaryLayout, "All Biosamples"); rbTabBiosampleSummaryLayout.addComponent(biosampleSummaryTable); rbTabBiosampleSummaryLayout.setSizeFull(); initDataAndSubcomponent(); rightTopLayout.setSizeFull(); rightBottomRightLayout.setSizeFull(); }
From source file:edu.cornell.qatarmed.planrnaseq.BrowseAndAnnotate.java
public void initLayout() { /* Root of the user interface component tree is set */ VerticalLayout mainLayout = new VerticalLayout(); Label titleLabel = new Label("<span style=\"color:rgb(255,255,255)\">MetaRNA-Seq: An interactive " + "tool to browse and annotate RNA-Seq meta-data</span>", ContentMode.HTML); titleLabel.addStyleName("maintitle"); HorizontalSplitPanel splitPanel = new HorizontalSplitPanel(); mainLayout.addComponent(titleLabel); mainLayout.addComponent(splitPanel); setContent(mainLayout);/*from w ww .j av a 2s . com*/ splitPanel.setSizeFull(); mainLayout.setSizeFull(); mainLayout.setExpandRatio(splitPanel, 1); /* Build the component tree */ // VerticalLayout leftLayout = new VerticalLayout(); // moved this to class level as it is been accessed by other function VerticalSplitPanel rightSplitPanel = new VerticalSplitPanel(); // VerticalSplitPanel leftSplitPanel = new VerticalSplitPanel(); splitPanel.addComponent(leftLayout); splitPanel.addComponent(rightSplitPanel); VerticalLayout rightTopLayout = new VerticalLayout(); // rightTopLayout.addComponent(rightTopForm); rightTopTabsheet.setSizeFull(); rightTopLayout.addComponent(rightTopTabsheet); rightTopTabsheet.addTab(startHelpLayout, "Start Help"); StartHelp sh = new StartHelp(); startHelpLayout.addComponent(sh); rightTopTabsheet.addTab(rightTopForm, "Study Details"); rightTopTabsheet.addTab(rightTopAnnotationForm, "Annotate"); rightTopLayout.setSizeFull(); rightSplitPanel.addComponent(rightTopLayout); HorizontalSplitPanel rightBottomLayout = new HorizontalSplitPanel(); // HorizontalLayout rightBottomLayout = new HorizontalLayout(); VerticalLayout rightBottomLeftLayout = new VerticalLayout(); VerticalLayout rightBottomRightLayout = new VerticalLayout(); rightBottomLayout.addComponent(rightBottomLeftLayout); rightBottomLayout.addComponent(rightBottomRightLayout); // rightBottomLayout.setExpandRatio(rightBottomLeftLayout, 1); // rightBottomLayout.setExpandRatio(rightBottomRightLayout, 3); rightBottomLayout.setSplitPosition(30f, Unit.PERCENTAGE); rightBottomLayout.setSizeFull(); rightBottomTabsheet.setSizeFull(); rightSplitPanel.addComponent(rightBottomLayout); splitPanel.setSplitPosition(50f, Unit.PERCENTAGE); //HorizontalLayout leftTopLayout = new HorizontalLayout(); // moved this to class level as it is been accessed by other function leftLayout.addComponent(leftTopLayout); leftTopLayout.addComponent(searchField); leftTopLayout.addComponent(searchButton); leftTopLayout.addComponent(slowSearchButton); leftTopLayout.addComponent(guidedSearchButton); leftTopLayout.setWidth("100%"); searchField.setWidth("100%"); leftTopLayout.setExpandRatio(searchField, 1); leftLayout.addComponent(bioprojectSummaryTable); // leftLayout.setExpandRatio(searchField, 0); leftLayout.setExpandRatio(bioprojectSummaryTable, 1); bioprojectSummaryTable.setSizeFull(); /* Set the contents in the left of the split panel to use all the space */ leftLayout.setSizeFull(); rightBottomLeftLayout.addComponent(tree); rightBottomRightLayout.addComponent(rightBottomTabsheet); rightBottomTabsheet.addTab(myform, "Details of selected Item"); myform.setSizeFull(); VerticalLayout rbTabBiosampleSummaryLayout = new VerticalLayout(); // Right bottom Biosample Summary // rightBottomTabsheet.addTab(rbTabBiosampleSummaryLayout, "All Biosamples"); rbTabBiosampleSummaryLayout.addComponent(biosampleSummaryTable); rbTabBiosampleSummaryLayout.setSizeFull(); initDataAndSubcomponent(); rightTopLayout.setSizeFull(); rightBottomRightLayout.setSizeFull(); }
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 .j ava 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);/*w ww . j av a 2s. co m*/ if (left != null) { if (!(left instanceof Panel)) { left = new Panel(left); } 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.bull.examples.vaadin.osgi.portal.PortalOSGiApplication.java
License:Open Source License
@Override public void init(VaadinRequest request) { HorizontalSplitPanel split = new HorizontalSplitPanel(); split.setSizeFull();/* w w w .j av a 2s . c o m*/ split.setSplitPosition(250, Unit.PIXELS); tree = new Tree(); for (PortalModule module : getPortalModuleService().getModules()) { tree.addItem(module.getId()); tree.setItemCaption(module.getId(), module.getName()); } tree.addItemClickListener(new ItemClickListener() { @Override public void itemClick(ItemClickEvent event) { PortalModule module = getPortalModuleService().getModule((String) event.getItemId()); Iterator<Component> it = tabs.iterator(); Component found = null; while (it.hasNext()) { Component c = it.next(); if (tabs.getTab(c).getCaption().equals(module.getName())) { found = c; break; } } if (found == null) { Tab addTab = tabs.addTab(module.createComponent(eventBus), module.getName()); addTab.setClosable(true); } else { tabs.setSelectedTab(found); } } }); tabs = new TabSheet(); tabs.setSizeFull(); split.setFirstComponent(tree); split.setSecondComponent(tabs); setContent(split); getPortalModuleService().addListener(this); }
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);/*www . java 2 s.co 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);// w ww. ja v a2 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();/*ww w . j a v a2 s . 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); }