List of usage examples for com.vaadin.ui GridLayout setComponentAlignment
@Override public void setComponentAlignment(Component childComponent, Alignment alignment)
From source file:org.eclipse.hawkbit.ui.tenantconfiguration.AuthenticationConfigurationView.java
License:Open Source License
private void init() { final Panel rootPanel = new Panel(); rootPanel.setSizeFull();/*ww w .ja v a 2 s .com*/ rootPanel.addStyleName("config-panel"); final VerticalLayout vLayout = new VerticalLayout(); vLayout.setMargin(true); vLayout.setSizeFull(); final Label header = new Label(i18n.getMessage("configuration.authentication.title")); header.addStyleName("config-panel-header"); vLayout.addComponent(header); final GridLayout gridLayout = new GridLayout(3, 4); gridLayout.setSpacing(true); gridLayout.setImmediate(true); gridLayout.setSizeFull(); gridLayout.setColumnExpandRatio(1, 1.0F); certificateAuthCheckbox = SPUIComponentProvider.getCheckBox("", DIST_CHECKBOX_STYLE, null, false, ""); certificateAuthCheckbox.setValue(certificateAuthenticationConfigurationItem.isConfigEnabled()); certificateAuthCheckbox.addValueChangeListener(this); certificateAuthenticationConfigurationItem.addChangeListener(this); gridLayout.addComponent(certificateAuthCheckbox, 0, 0); gridLayout.addComponent(certificateAuthenticationConfigurationItem, 1, 0); targetSecTokenCheckBox = SPUIComponentProvider.getCheckBox("", DIST_CHECKBOX_STYLE, null, false, ""); targetSecTokenCheckBox.setValue(targetSecurityTokenAuthenticationConfigurationItem.isConfigEnabled()); targetSecTokenCheckBox.addValueChangeListener(this); targetSecurityTokenAuthenticationConfigurationItem.addChangeListener(this); gridLayout.addComponent(targetSecTokenCheckBox, 0, 1); gridLayout.addComponent(targetSecurityTokenAuthenticationConfigurationItem, 1, 1); gatewaySecTokenCheckBox = SPUIComponentProvider.getCheckBox("", DIST_CHECKBOX_STYLE, null, false, ""); gatewaySecTokenCheckBox.setId("gatewaysecuritycheckbox"); gatewaySecTokenCheckBox.setValue(gatewaySecurityTokenAuthenticationConfigurationItem.isConfigEnabled()); gatewaySecTokenCheckBox.addValueChangeListener(this); gatewaySecurityTokenAuthenticationConfigurationItem.addChangeListener(this); gridLayout.addComponent(gatewaySecTokenCheckBox, 0, 2); gridLayout.addComponent(gatewaySecurityTokenAuthenticationConfigurationItem, 1, 2); downloadAnonymousCheckBox = SPUIComponentProvider.getCheckBox("", DIST_CHECKBOX_STYLE, null, false, ""); downloadAnonymousCheckBox.setId(UIComponentIdProvider.DOWNLOAD_ANONYMOUS_CHECKBOX); downloadAnonymousCheckBox.setValue(anonymousDownloadAuthenticationConfigurationItem.isConfigEnabled()); downloadAnonymousCheckBox.addValueChangeListener(this); anonymousDownloadAuthenticationConfigurationItem.addChangeListener(this); gridLayout.addComponent(downloadAnonymousCheckBox, 0, 3); gridLayout.addComponent(anonymousDownloadAuthenticationConfigurationItem, 1, 3); final Link linkToSecurityHelp = SPUIComponentProvider.getHelpLink(i18n, uiProperties.getLinks().getDocumentation().getSecurity()); gridLayout.addComponent(linkToSecurityHelp, 2, 3); gridLayout.setComponentAlignment(linkToSecurityHelp, Alignment.BOTTOM_RIGHT); vLayout.addComponent(gridLayout); rootPanel.setContent(vLayout); setCompositionRoot(rootPanel); }
From source file:org.hip.vif.forum.usersettings.ui.ShowCompletedRatingView.java
License:Open Source License
private void addComponentSized(final Component inComponent, final GridLayout inLayout) { inComponent.setWidth(110, Unit.PIXELS); inComponent.setStyleName("vif-colhead vif-center"); //$NON-NLS-1$ inLayout.addComponent(inComponent);/*from w w w. j a v a 2s .c o m*/ inLayout.setComponentAlignment(inComponent, Alignment.MIDDLE_CENTER); }
From source file:org.hip.vif.forum.usersettings.ui.ShowCompletedRatingView.java
License:Open Source License
private void addComponentAligened(final Component inComponent, final GridLayout inLayout) { inLayout.addComponent(inComponent);/*from w w w . jav a 2 s . c o m*/ inLayout.setComponentAlignment(inComponent, Alignment.MIDDLE_CENTER); }
From source file:org.hip.vif.web.util.RatingsTable.java
License:Open Source License
private void addComponent(final GridLayout inLayout, final Component inComponen, final int inColumn, final int inRow, final Alignment inAlignment) { inLayout.addComponent(inComponen, inColumn, inRow); inLayout.setComponentAlignment(inComponen, inAlignment); }
From source file:org.iespuigcastellar.attendancemanager.screenlayouts.NoModalWindowTeacherMainLayout.java
License:Open Source License
private void initLayout() { datePopupDateField = new PopupDateField(""); datePopupDateField.setDescription(app.locale.getString("TEACHERMAINLAYOUT_DATEFIELD_DESCRIPTION")); datePopupDateField.setValue(new java.util.Date()); datePopupDateField.setResolution(PopupDateField.RESOLUTION_DAY); datePopupDateField.setImmediate(true); datePopupDateField.addListener(ValueChangeEvent.class, this, "changedDate"); classblockComboBox = new ComboBox(); classblockComboBox.setInputPrompt(app.locale.getString("TEACHERMAINLAYOUT_CLASSBLOCK_INPUTPROMPT")); classblockComboBox.setDescription(app.locale.getString("TEACHERMAINLAYOUT_CLASSBLOCK_DESCRIPTION")); classblockComboBox.setFilteringMode(Filtering.FILTERINGMODE_CONTAINS); classblockComboBox.setImmediate(true); classblockComboBox.addContainerProperty("name", String.class, ""); classblockComboBox.setItemCaptionPropertyId("name"); classblockComboBox.addListener(ValueChangeEvent.class, this, "changedClassblock"); Button logoutButton = new Button(app.locale.getString("TEACHERMAINLAYOUT_LOGOUTBUTTON_CAPTION")); logoutButton.addListener(new Button.ClickListener() { @Override//from w w w . j ava 2s.co m public void buttonClick(ClickEvent event) { Logger.log("User " + app.user.getLogin() + " closes session"); app.storage.close(); getApplication().close(); } }); GridLayout optionsGridLayout = new GridLayout(2, 1); HorizontalLayout haLayout = new HorizontalLayout(); haLayout.setSpacing(true); //haLayout.setWidth("100%"); // Fix layout errors, but bad display haLayout.addComponent(new PasswordChangeLayout()); haLayout.addComponent(datePopupDateField); haLayout.addComponent(classblockComboBox); optionsGridLayout.addComponent(haLayout); optionsGridLayout.addComponent(logoutButton); optionsGridLayout.setComponentAlignment(logoutButton, Alignment.TOP_RIGHT); optionsGridLayout.setWidth("100%"); addComponent(optionsGridLayout); table.setSizeFull(); table.setImmediate(true); table.setColumnReorderingAllowed(true); table.setColumnCollapsingAllowed(true); table.addContainerProperty("Name", String.class, null); table.addContainerProperty("Surname 1", String.class, null); table.addContainerProperty("Surname 2", String.class, null); table.addContainerProperty("Miss", CheckBox.class, null); table.addContainerProperty("Excused", CheckBox.class, null); table.addContainerProperty("Delay", CheckBox.class, null); table.addContainerProperty("Expulsion", CheckBox.class, null); table.setColumnExpandRatio("Name", 1); table.setColumnExpandRatio("Surname 1", 1); table.setColumnExpandRatio("Surname 2", 1); table.setColumnHeaders(new String[] { app.locale.getString("TEACHERMAINLAYOUT_TABLECOLUMN_NAME"), app.locale.getString("TEACHERMAINLAYOUT_TABLECOLUMN_SURNAME1"), app.locale.getString("TEACHERMAINLAYOUT_TABLECOLUMN_SURNAME2"), app.locale.getString("TEACHERMAINLAYOUT_TABLECOLUMN_MISS"), app.locale.getString("TEACHERMAINLAYOUT_TABLECOLUMN_EXCUSED"), app.locale.getString("TEACHERMAINLAYOUT_TABLECOLUMN_DELAY"), app.locale.getString("TEACHERMAINLAYOUT_TABLECOLUMN_EXPULSION") }); addComponent(table); setExpandRatio(table, 1); setSizeFull(); }
From source file:org.iespuigcastellar.attendancemanager.screenlayouts.TeacherMainLayout.java
License:Open Source License
private void initLayout() { passwordChangeWindow = new PasswordChangeWindow(); passwordChangeWindow.setCaption(app.locale.getString("TEACHERMAINLAYOUT_CHANGEMYPASSWORD_BUTTON")); datePopupDateField = new PopupDateField(""); datePopupDateField.setDescription(app.locale.getString("TEACHERMAINLAYOUT_DATEFIELD_DESCRIPTION")); datePopupDateField.setValue(new java.util.Date()); datePopupDateField.setResolution(PopupDateField.RESOLUTION_DAY); datePopupDateField.setImmediate(true); datePopupDateField.addListener(ValueChangeEvent.class, this, "changedDate"); classblockComboBox = new ComboBox(); classblockComboBox.setInputPrompt(app.locale.getString("TEACHERMAINLAYOUT_CLASSBLOCK_INPUTPROMPT")); classblockComboBox.setDescription(app.locale.getString("TEACHERMAINLAYOUT_CLASSBLOCK_DESCRIPTION")); classblockComboBox.setFilteringMode(Filtering.FILTERINGMODE_CONTAINS); classblockComboBox.setImmediate(true); classblockComboBox.addContainerProperty("name", String.class, ""); classblockComboBox.setItemCaptionPropertyId("name"); classblockComboBox.addListener(ValueChangeEvent.class, this, "changedClassblock"); Button logoutButton = new Button(app.locale.getString("TEACHERMAINLAYOUT_LOGOUTBUTTON_CAPTION")); logoutButton.addListener(new Button.ClickListener() { @Override//w w w. j ava2s .c o m public void buttonClick(ClickEvent event) { Logger.log("User " + app.user.getLogin() + " closes session"); app.storage.close(); getApplication().close(); } }); Button changePasswordButton = new Button(app.locale.getString("TEACHERMAINLAYOUT_CHANGEMYPASSWORD_BUTTON")); changePasswordButton.setIcon(new ThemeResource("../runo/icons/16/user.png")); changePasswordButton.setStyleName(Button.STYLE_LINK); changePasswordButton.addListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { // Open window if not open already if (passwordChangeWindow.getParent() != null) { // Window already open } else { // open window getWindow().addWindow(passwordChangeWindow); } } }); GridLayout optionsGridLayout = new GridLayout(2, 1); HorizontalLayout haLayout = new HorizontalLayout(); haLayout.setSpacing(true); haLayout.addComponent(changePasswordButton); haLayout.setComponentAlignment(changePasswordButton, Alignment.MIDDLE_LEFT); haLayout.addComponent(datePopupDateField); haLayout.addComponent(classblockComboBox); optionsGridLayout.addComponent(haLayout); optionsGridLayout.addComponent(logoutButton); optionsGridLayout.setComponentAlignment(logoutButton, Alignment.TOP_RIGHT); optionsGridLayout.setWidth("100%"); addComponent(optionsGridLayout); table.setSizeFull(); table.setImmediate(true); table.setColumnReorderingAllowed(true); table.setColumnCollapsingAllowed(true); table.addContainerProperty("Name", String.class, null); table.addContainerProperty("Surname 1", String.class, null); table.addContainerProperty("Surname 2", String.class, null); table.addContainerProperty("Miss", CheckBox.class, null); table.addContainerProperty("Excused", CheckBox.class, null); table.addContainerProperty("Delay", CheckBox.class, null); table.addContainerProperty("Expulsion", CheckBox.class, null); table.setColumnExpandRatio("Name", 1); table.setColumnExpandRatio("Surname 1", 1); table.setColumnExpandRatio("Surname 2", 1); table.setColumnHeaders(new String[] { app.locale.getString("TEACHERMAINLAYOUT_TABLECOLUMN_NAME"), app.locale.getString("TEACHERMAINLAYOUT_TABLECOLUMN_SURNAME1"), app.locale.getString("TEACHERMAINLAYOUT_TABLECOLUMN_SURNAME2"), app.locale.getString("TEACHERMAINLAYOUT_TABLECOLUMN_MISS"), app.locale.getString("TEACHERMAINLAYOUT_TABLECOLUMN_EXCUSED"), app.locale.getString("TEACHERMAINLAYOUT_TABLECOLUMN_DELAY"), app.locale.getString("TEACHERMAINLAYOUT_TABLECOLUMN_EXPULSION") }); addComponent(table); setExpandRatio(table, 1); setSizeFull(); }
From source file:org.ikasan.dashboard.ui.administration.panel.PlatformConfigurationPanel.java
License:BSD License
protected Panel createMapPanel(final ConfigurationParameterMapImpl parameter) { Panel paramPanel = new Panel(); paramPanel.setStyleName("dashboard"); paramPanel.setWidth("100%"); GridLayout paramLayout = new GridLayout(2, 3); paramLayout.setSpacing(true);//from w w w .ja va2 s . com paramLayout.setSizeFull(); paramLayout.setMargin(true); paramLayout.setColumnExpandRatio(0, .25f); paramLayout.setColumnExpandRatio(1, .75f); Label label = new Label("Platform Configuration"); label.addStyleName(ValoTheme.LABEL_HUGE); label.setSizeUndefined(); paramLayout.addComponent(label, 0, 0, 1, 0); paramLayout.setComponentAlignment(label, Alignment.TOP_LEFT); final Map<String, String> valueMap = parameter.getValue(); final GridLayout mapLayout = new GridLayout(5, (valueMap.size() != 0 ? valueMap.size() : 1) + 1); mapLayout.setColumnExpandRatio(0, .05f); mapLayout.setColumnExpandRatio(1, .425f); mapLayout.setColumnExpandRatio(2, .05f); mapLayout.setColumnExpandRatio(3, .425f); mapLayout.setColumnExpandRatio(4, .05f); mapLayout.setMargin(true); mapLayout.setSpacing(true); mapLayout.setWidth("100%"); int i = 0; for (final String key : valueMap.keySet()) { final Label keyLabel = new Label("Name:"); final Label valueLabel = new Label("Value:"); final TextField keyField = new TextField(); keyField.setValue(key); keyField.setWidth("100%"); keyField.setNullSettingAllowed(false); keyField.addValidator( new NonZeroLengthStringValidator("Then configuration value name cannot be empty!")); keyField.setValidationVisible(false); final TextField valueField = new TextField(); valueField.setWidth("100%"); valueField.setValue(valueMap.get(key)); valueField.setNullSettingAllowed(false); valueField.addValidator(new NonZeroLengthStringValidator("Then configuration value cannot be empty!")); valueField.setValidationVisible(false); mapLayout.addComponent(keyLabel, 0, i); mapLayout.setComponentAlignment(keyLabel, Alignment.MIDDLE_RIGHT); mapLayout.addComponent(keyField, 1, i); mapLayout.addComponent(valueLabel, 2, i); mapLayout.setComponentAlignment(valueLabel, Alignment.MIDDLE_RIGHT); mapLayout.addComponent(valueField, 3, i); final String mapKey = parameter.getName() + i; TextFieldKeyValuePair pair = new TextFieldKeyValuePair(); pair.key = keyField; pair.value = valueField; this.mapTextFields.put(mapKey, pair); final Button removeButton = new Button("remove"); removeButton.setStyleName(ValoTheme.BUTTON_LINK); removeButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { valueMap.remove(key); mapLayout.removeComponent(keyLabel); mapLayout.removeComponent(valueLabel); mapLayout.removeComponent(keyField); mapLayout.removeComponent(valueField); mapLayout.removeComponent(removeButton); mapTextFields.remove(mapKey); } }); mapLayout.addComponent(removeButton, 4, i); i++; } final Button addButton = new Button("add"); addButton.setStyleName(ValoTheme.BUTTON_LINK); addButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { final Label keyLabel = new Label("Name:"); final Label valueLabel = new Label("Value:"); final TextField keyField = new TextField(); keyField.setWidth("100%"); keyField.setNullSettingAllowed(false); keyField.addValidator( new NonZeroLengthStringValidator("Then configuration value name cannot be empty!")); keyField.setValidationVisible(false); final TextField valueField = new TextField(); valueField.setWidth("100%"); valueField.setNullSettingAllowed(false); valueField.addValidator( new NonZeroLengthStringValidator("Then configuration value cannot be empty!")); valueField.setValidationVisible(false); mapLayout.insertRow(mapLayout.getRows()); mapLayout.removeComponent(addButton); mapLayout.addComponent(keyLabel, 0, mapLayout.getRows() - 2); mapLayout.setComponentAlignment(keyLabel, Alignment.MIDDLE_RIGHT); mapLayout.addComponent(keyField, 1, mapLayout.getRows() - 2); mapLayout.addComponent(valueLabel, 2, mapLayout.getRows() - 2); mapLayout.setComponentAlignment(valueLabel, Alignment.MIDDLE_RIGHT); mapLayout.addComponent(valueField, 3, mapLayout.getRows() - 2); final String mapKey = parameter.getName() + mapTextFields.size(); TextFieldKeyValuePair pair = new TextFieldKeyValuePair(); pair.key = keyField; pair.value = valueField; mapTextFields.put(mapKey, pair); final Button removeButton = new Button("remove"); removeButton.setStyleName(ValoTheme.BUTTON_LINK); removeButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { mapLayout.removeComponent(keyLabel); mapLayout.removeComponent(valueLabel); mapLayout.removeComponent(keyField); mapLayout.removeComponent(valueField); mapLayout.removeComponent(removeButton); mapTextFields.remove(mapKey); } }); mapLayout.addComponent(removeButton, 4, mapLayout.getRows() - 2); mapLayout.addComponent(addButton, 0, mapLayout.getRows() - 1); } }); mapLayout.addComponent(addButton, 0, mapLayout.getRows() - 1); Panel mapPanel = new Panel(); mapPanel.setStyleName(ValoTheme.PANEL_BORDERLESS); mapPanel.setContent(mapLayout); Button saveButton = new Button("Save"); saveButton.addStyleName(ValoTheme.BUTTON_SMALL); saveButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { try { for (TextFieldKeyValuePair textField : mapTextFields.values()) { textField.key.validate(); textField.value.validate(); } } catch (InvalidValueException e) { for (TextFieldKeyValuePair textField : mapTextFields.values()) { textField.key.setValidationVisible(true); textField.value.setValidationVisible(true); } Notification.show("Validation errors have occurred!", Type.ERROR_MESSAGE); return; } HashMap<String, String> map = new HashMap<String, String>(); logger.info("Saving map: " + mapTextFields.size()); for (String key : mapTextFields.keySet()) { if (key.startsWith(parameter.getName())) { TextFieldKeyValuePair pair = mapTextFields.get(key); logger.info("Saving for key: " + key); if (pair.key.getValue() != "") { map.put(pair.key.getValue(), pair.value.getValue()); } } } parameter.setValue(map); PlatformConfigurationPanel.this.configurationManagement.saveConfiguration(platformConfiguration); Notification notification = new Notification("Saved", "The configuration has been saved successfully!", Type.HUMANIZED_MESSAGE); notification.setStyleName(ValoTheme.NOTIFICATION_CLOSABLE); notification.show(Page.getCurrent()); } }); paramLayout.addComponent(mapPanel, 0, 1, 1, 1); paramLayout.setComponentAlignment(mapPanel, Alignment.TOP_CENTER); paramLayout.addComponent(saveButton, 0, 2, 1, 2); paramLayout.setComponentAlignment(saveButton, Alignment.TOP_CENTER); paramPanel.setContent(paramLayout); return paramPanel; }
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);/*w ww .j av a 2 s .c o m*/ layout.setSpacing(true); layout.setWidth("100%"); Panel policyAdministrationPanel = new Panel(); policyAdministrationPanel.addStyleName(ValoTheme.PANEL_BORDERLESS); policyAdministrationPanel.setHeight("100%"); policyAdministrationPanel.setWidth("100%"); GridLayout gridLayout = new GridLayout(2, 6); gridLayout.setSizeFull(); Label roleManagementLabel = new Label("Policy Management"); roleManagementLabel.setStyleName(ValoTheme.LABEL_HUGE); gridLayout.addComponent(roleManagementLabel, 0, 0, 1, 0); Label roleSearchHintLabel = new Label(); roleSearchHintLabel.setCaptionAsHtml(true); roleSearchHintLabel.setCaption( VaadinIcons.QUESTION_CIRCLE_O.getHtml() + " Type into the Policy Name field to find a policy."); roleSearchHintLabel.addStyleName(ValoTheme.LABEL_TINY); roleSearchHintLabel.addStyleName(ValoTheme.LABEL_LIGHT); gridLayout.addComponent(roleSearchHintLabel, 0, 1, 1, 1); Layout controlLayout = this.initControlLayout(); gridLayout.addComponent(controlLayout, 0, 2, 1, 2); GridLayout formLayout = new GridLayout(2, 4); formLayout.setWidth("100%"); formLayout.setSpacing(true); formLayout.setColumnExpandRatio(0, 1); formLayout.setColumnExpandRatio(1, 5); Label policyNameLabel = new Label("Policy Name:"); policyNameLabel.setSizeUndefined(); final DragAndDropWrapper policyNameFieldWrap = initPolicyNameField(); formLayout.addComponent(policyNameLabel, 0, 0); formLayout.setComponentAlignment(policyNameLabel, Alignment.MIDDLE_RIGHT); formLayout.addComponent(policyNameFieldWrap, 1, 0); Label descriptionLabel = new Label("Description:"); descriptionLabel.setSizeUndefined(); this.descriptionField = new TextArea(); this.descriptionField.setWidth("70%"); this.descriptionField.setHeight("60px"); formLayout.addComponent(descriptionLabel, 0, 1); formLayout.setComponentAlignment(descriptionLabel, Alignment.TOP_RIGHT); formLayout.addComponent(this.descriptionField, 1, 1); this.linkTypeLabel.setSizeUndefined(); formLayout.addComponent(this.linkTypeLabel, 0, 2); formLayout.setComponentAlignment(this.linkTypeLabel, Alignment.MIDDLE_RIGHT); this.linkType.setWidth("70%"); formLayout.addComponent(this.linkType, 1, 2); this.linkTypeLabel.setVisible(false); this.linkType.setVisible(false); this.linkedEntityLabel.setSizeUndefined(); this.linkedEntity = new TextArea(); this.linkedEntity.setWidth("70%"); this.linkedEntity.setHeight("60px"); formLayout.addComponent(this.linkedEntityLabel, 0, 3); formLayout.setComponentAlignment(this.linkedEntityLabel, Alignment.MIDDLE_RIGHT); formLayout.addComponent(linkedEntity, 1, 3); this.linkedEntityLabel.setVisible(false); this.linkedEntity.setVisible(false); gridLayout.addComponent(formLayout, 0, 3, 1, 3); Label roleTableHintLabel = new Label(); roleTableHintLabel.setCaptionAsHtml(true); roleTableHintLabel.setCaption(VaadinIcons.QUESTION_CIRCLE_O.getHtml() + " The Roles table below displays the roles that are assigned the current policy."); roleTableHintLabel.addStyleName(ValoTheme.LABEL_TINY); roleTableHintLabel.addStyleName(ValoTheme.LABEL_LIGHT); gridLayout.addComponent(roleTableHintLabel, 0, 4, 1, 4); gridLayout.addComponent(this.roleTable, 0, 5, 1, 5); policyAdministrationPanel.setContent(gridLayout); layout.addComponent(policyAdministrationPanel); HorizontalLayout roleMemberPanelLayout = new HorizontalLayout(); roleMemberPanelLayout.setMargin(true); roleMemberPanelLayout.addComponent(this.policyDropPanel); roleMemberPanelLayout.setSizeFull(); HorizontalSplitPanel hsplit = new HorizontalSplitPanel(); hsplit.setFirstComponent(layout); hsplit.setSecondComponent(roleMemberPanelLayout); // Set the position of the splitter as percentage hsplit.setSplitPosition(65, Unit.PERCENTAGE); hsplit.setLocked(true); this.setContent(hsplit); }
From source file:org.ikasan.dashboard.ui.administration.panel.PrincipalManagementPanel.java
License:BSD License
@SuppressWarnings("deprecation") protected void init() { this.setWidth("100%"); this.setHeight("100%"); VerticalLayout layout = new VerticalLayout(); layout.setSpacing(true);/*from ww w . ja va2s . 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 www . j ava 2 s.com*/ 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); }