List of usage examples for com.vaadin.ui GridLayout setSizeFull
@Override public void setSizeFull()
From source file:org.bubblecloud.ilves.ui.user.UserAccountFlowlet.java
License:Apache License
@Override public void initialize() { entityManager = getSite().getSiteContext().getObject(EntityManager.class); final GridLayout layout = new GridLayout(1, 3); layout.setSizeFull(); layout.setMargin(false);//ww w . j a v a2 s . c om layout.setSpacing(true); layout.setRowExpandRatio(1, 1f); layout.setColumnExpandRatio(1, 1f); setViewContent(layout); editor = new ValidatingEditor(SiteFields.getFieldDescriptors(User.class)); editor.setCaption("User"); editor.addListener((ValidatingEditorStateListener) this); editor.setWidth("380px"); layout.addComponent(editor, 0, 1); final HorizontalLayout editorButtonLayout = new HorizontalLayout(); editorButtonLayout.setSpacing(true); layout.addComponent(editorButtonLayout, 0, 2); saveButton = new Button("Save"); saveButton.setImmediate(true); editorButtonLayout.addComponent(saveButton); saveButton.addClickListener(new ClickListener() { /** Serial version UID. */ private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { editor.commit(); try { if (user.getPasswordHash() != null) { final int hashSize = 64; if (user.getPasswordHash().length() != hashSize) { try { PasswordLoginUtil.setUserPasswordHash(user.getOwner(), user, user.getPasswordHash()); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } } } // UserLogic.updateUser(user, // UserDao.getGroupMembers(entityManager, user)); user = entityManager.merge(user); SecurityService.updateUser(getSite().getSiteContext(), user); editor.setItem(new BeanItem<User>(user), false); entityManager.detach(user); } catch (final Throwable t) { if (entityManager.getTransaction().isActive()) { entityManager.getTransaction().rollback(); } throw new RuntimeException("Failed to save entity: " + user, t); } } }); discardButton = new Button("Discard"); discardButton.setImmediate(true); editorButtonLayout.addComponent(discardButton); discardButton.addClickListener(new ClickListener() { /** Serial version UID. */ private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { editor.discard(); } }); }
From source file:org.diretto.web.richwebclient.view.windows.UploadSettingsWindow.java
/** * Constructs an {@link UploadSettingsWindow}. * // ww w . j a v a 2 s . c om * @param mainWindow The corresponding {@code MainWindow} * @param uploadSection The corresponding {@code UploadSection} * @param fileInfo The {@code FileInfo} object * @param mediaType The {@code MediaType} of the file * @param uploadSettings The corresponding {@code UploadSettings} * @param otherFiles The names of the other upload files */ public UploadSettingsWindow(final MainWindow mainWindow, final UploadSection uploadSection, FileInfo fileInfo, MediaType mediaType, UploadSettings uploadSettings, List<String> otherFiles) { super("Upload Settings"); this.mainWindow = mainWindow; setModal(true); setStyleName(Reindeer.WINDOW_BLACK); setWidth("940px"); setHeight((((int) mainWindow.getHeight()) - 160) + "px"); setResizable(false); setClosable(false); setDraggable(false); setPositionX((int) (mainWindow.getWidth() / 2.0f) - 470); setPositionY(126); wrapperLayout = new HorizontalLayout(); wrapperLayout.setSizeFull(); wrapperLayout.setMargin(true, true, true, true); addComponent(wrapperLayout); mainLayout = new VerticalLayout(); mainLayout.setSizeFull(); mainLayout.setSpacing(true); HorizontalLayout titleLayout = new HorizontalLayout(); titleLayout.setWidth("100%"); mainLayout.addComponent(titleLayout); HorizontalLayout leftTitleLayout = new HorizontalLayout(); titleLayout.addComponent(leftTitleLayout); titleLayout.setComponentAlignment(leftTitleLayout, Alignment.MIDDLE_LEFT); Label fileNameLabel = StyleUtils.getLabelH2(fileInfo.getName()); leftTitleLayout.addComponent(fileNameLabel); leftTitleLayout.setComponentAlignment(fileNameLabel, Alignment.MIDDLE_LEFT); Label bullLabel = StyleUtils.getLabelHTML( " • "); leftTitleLayout.addComponent(bullLabel); leftTitleLayout.setComponentAlignment(bullLabel, Alignment.MIDDLE_LEFT); Label titleLabel = StyleUtils.getLabelHTML("<b>Title</b> "); leftTitleLayout.addComponent(titleLabel); leftTitleLayout.setComponentAlignment(titleLabel, Alignment.MIDDLE_LEFT); final TextField titleField = new TextField(); titleField.setMaxLength(50); titleField.setWidth("100%"); titleField.setImmediate(true); if (uploadSettings != null && uploadSettings.getTitle() != null) { titleField.setValue(uploadSettings.getTitle()); } titleField.focus(); titleField.setCursorPosition(((String) titleField.getValue()).length()); titleLayout.addComponent(titleField); titleLayout.setComponentAlignment(titleField, Alignment.MIDDLE_RIGHT); titleLayout.setExpandRatio(leftTitleLayout, 0); titleLayout.setExpandRatio(titleField, 1); mainLayout.addComponent(StyleUtils.getHorizontalLine()); GridLayout topGridLayout = new GridLayout(2, 3); topGridLayout.setColumnExpandRatio(0, 1.0f); topGridLayout.setColumnExpandRatio(1, 0.0f); topGridLayout.setWidth("100%"); topGridLayout.setSpacing(true); mainLayout.addComponent(topGridLayout); Label descriptionLabel = StyleUtils.getLabelBold("Description"); topGridLayout.addComponent(descriptionLabel, 0, 0); final TextArea descriptionArea = new TextArea(); descriptionArea.setSizeFull(); descriptionArea.setImmediate(true); if (uploadSettings != null && uploadSettings.getDescription() != null) { descriptionArea.setValue(uploadSettings.getDescription()); } topGridLayout.addComponent(descriptionArea, 0, 1); VerticalLayout tagsWrapperLayout = new VerticalLayout(); tagsWrapperLayout.setHeight("30px"); tagsWrapperLayout.setSpacing(false); topGridLayout.addComponent(tagsWrapperLayout, 0, 2); HorizontalLayout tagsLayout = new HorizontalLayout(); tagsLayout.setWidth("100%"); tagsLayout.setSpacing(true); Label tagsLabel = StyleUtils.getLabelBoldHTML("Tags "); tagsLabel.setSizeUndefined(); tagsLayout.addComponent(tagsLabel); tagsLayout.setComponentAlignment(tagsLabel, Alignment.MIDDLE_LEFT); addTagField = new TextField(); addTagField.setImmediate(true); addTagField.setInputPrompt("Enter new Tag"); addTagField.addShortcutListener(new ShortcutListener(null, KeyCode.ENTER, new int[0]) { private static final long serialVersionUID = -4767515198819351723L; @Override public void handleAction(Object sender, Object target) { if (target == addTagField) { addTag(); } } }); tagsLayout.addComponent(addTagField); tagsLayout.setComponentAlignment(addTagField, Alignment.MIDDLE_LEFT); tabSheet = new TabSheet(); tabSheet.setStyleName(Reindeer.TABSHEET_SMALL); tabSheet.addStyleName("view"); tabSheet.addListener(new ComponentDetachListener() { private static final long serialVersionUID = -657657505471281795L; @Override public void componentDetachedFromContainer(ComponentDetachEvent event) { tags.remove(tabSheet.getTab(event.getDetachedComponent()).getCaption()); } }); Button addTagButton = new Button("Add", new Button.ClickListener() { private static final long serialVersionUID = 5914473126402594623L; @Override public void buttonClick(ClickEvent event) { addTag(); } }); addTagButton.setStyleName(Reindeer.BUTTON_DEFAULT); tagsLayout.addComponent(addTagButton); tagsLayout.setComponentAlignment(addTagButton, Alignment.MIDDLE_LEFT); Label spaceLabel = StyleUtils.getLabelHTML(""); spaceLabel.setSizeUndefined(); tagsLayout.addComponent(spaceLabel); tagsLayout.setComponentAlignment(spaceLabel, Alignment.MIDDLE_LEFT); tagsLayout.addComponent(tabSheet); tagsLayout.setComponentAlignment(tabSheet, Alignment.MIDDLE_LEFT); tagsLayout.setExpandRatio(tabSheet, 1.0f); tagsWrapperLayout.addComponent(tagsLayout); tagsWrapperLayout.setComponentAlignment(tagsLayout, Alignment.TOP_LEFT); if (uploadSettings != null && uploadSettings.getTags() != null && uploadSettings.getTags().size() > 0) { for (String tag : uploadSettings.getTags()) { addTagField.setValue(tag); addTag(); } } Label presettingLabel = StyleUtils.getLabelBold("Presetting"); topGridLayout.addComponent(presettingLabel, 1, 0); final TwinColSelect twinColSelect; if (otherFiles != null && otherFiles.size() > 0) { twinColSelect = new TwinColSelect(null, otherFiles); } else { twinColSelect = new TwinColSelect(); } twinColSelect.setWidth("400px"); twinColSelect.setRows(10); topGridLayout.addComponent(twinColSelect, 1, 1); topGridLayout.setComponentAlignment(twinColSelect, Alignment.TOP_RIGHT); Label otherFilesLabel = StyleUtils .getLabelSmallHTML("Select the files which should get the settings of this file as presetting."); otherFilesLabel.setSizeUndefined(); topGridLayout.addComponent(otherFilesLabel, 1, 2); topGridLayout.setComponentAlignment(otherFilesLabel, Alignment.MIDDLE_CENTER); mainLayout.addComponent(StyleUtils.getHorizontalLine()); final UploadGoogleMap googleMap; if (uploadSettings != null && uploadSettings.getTopographicPoint() != null) { googleMap = new UploadGoogleMap(mediaType, 12, uploadSettings.getTopographicPoint().getLatitude(), uploadSettings.getTopographicPoint().getLongitude(), MapType.HYBRID); } else { googleMap = new UploadGoogleMap(mediaType, 12, 48.42255269321401d, 9.956477880477905d, MapType.HYBRID); } googleMap.setWidth("100%"); googleMap.setHeight("300px"); mainLayout.addComponent(googleMap); mainLayout.addComponent(StyleUtils.getHorizontalLine()); GridLayout bottomGridLayout = new GridLayout(3, 3); bottomGridLayout.setSizeFull(); bottomGridLayout.setSpacing(true); mainLayout.addComponent(bottomGridLayout); Label licenseLabel = StyleUtils.getLabelBold("License"); bottomGridLayout.addComponent(licenseLabel, 0, 0); final TextArea licenseArea = new TextArea(); licenseArea.setWidth("320px"); licenseArea.setHeight("175px"); licenseArea.setImmediate(true); if (uploadSettings != null && uploadSettings.getLicense() != null) { licenseArea.setValue(uploadSettings.getLicense()); } bottomGridLayout.addComponent(licenseArea, 0, 1); final Label startTimeLabel = StyleUtils.getLabelBold("Earliest possible Start Date"); startTimeLabel.setSizeUndefined(); bottomGridLayout.setComponentAlignment(startTimeLabel, Alignment.TOP_CENTER); bottomGridLayout.addComponent(startTimeLabel, 1, 0); final InlineDateField startTimeField = new InlineDateField(); startTimeField.setImmediate(true); startTimeField.setResolution(InlineDateField.RESOLUTION_SEC); boolean currentTimeAdjusted = false; if (uploadSettings != null && uploadSettings.getTimeRange() != null && uploadSettings.getTimeRange().getStartDateTime() != null) { startTimeField.setValue(uploadSettings.getTimeRange().getStartDateTime().toDate()); } else { currentTimeAdjusted = true; startTimeField.setValue(new Date()); } bottomGridLayout.setComponentAlignment(startTimeField, Alignment.TOP_CENTER); bottomGridLayout.addComponent(startTimeField, 1, 1); final CheckBox exactTimeCheckBox = new CheckBox("This is the exact point in time."); exactTimeCheckBox.setImmediate(true); bottomGridLayout.setComponentAlignment(exactTimeCheckBox, Alignment.TOP_CENTER); bottomGridLayout.addComponent(exactTimeCheckBox, 1, 2); final Label endTimeLabel = StyleUtils.getLabelBold("Latest possible Start Date"); endTimeLabel.setSizeUndefined(); bottomGridLayout.setComponentAlignment(endTimeLabel, Alignment.TOP_CENTER); bottomGridLayout.addComponent(endTimeLabel, 2, 0); final InlineDateField endTimeField = new InlineDateField(); endTimeField.setImmediate(true); endTimeField.setResolution(InlineDateField.RESOLUTION_SEC); if (uploadSettings != null && uploadSettings.getTimeRange() != null && uploadSettings.getTimeRange().getEndDateTime() != null) { endTimeField.setValue(uploadSettings.getTimeRange().getEndDateTime().toDate()); } else { endTimeField.setValue(startTimeField.getValue()); } bottomGridLayout.setComponentAlignment(endTimeField, Alignment.TOP_CENTER); bottomGridLayout.addComponent(endTimeField, 2, 1); if (!currentTimeAdjusted && ((Date) startTimeField.getValue()).equals((Date) endTimeField.getValue())) { exactTimeCheckBox.setValue(true); endTimeLabel.setEnabled(false); endTimeField.setEnabled(false); } exactTimeCheckBox.addListener(new ValueChangeListener() { private static final long serialVersionUID = 7193545421803538364L; @Override public void valueChange(ValueChangeEvent event) { if ((Boolean) event.getProperty().getValue()) { endTimeLabel.setEnabled(false); endTimeField.setEnabled(false); } else { endTimeLabel.setEnabled(true); endTimeField.setEnabled(true); } } }); mainLayout.addComponent(StyleUtils.getHorizontalLine()); HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setMargin(true, false, false, false); buttonLayout.setSpacing(false); HorizontalLayout uploadButtonLayout = new HorizontalLayout(); uploadButtonLayout.setMargin(false, true, false, false); uploadButton = new Button("Upload File", new Button.ClickListener() { private static final long serialVersionUID = 8013811216568950479L; @Override @SuppressWarnings("unchecked") public void buttonClick(ClickEvent event) { String titleValue = titleField.getValue().toString().trim(); Date startTimeValue = (Date) startTimeField.getValue(); Date endTimeValue = (Date) endTimeField.getValue(); boolean exactTimeValue = (Boolean) exactTimeCheckBox.getValue(); if (titleValue.equals("")) { ConfirmWindow confirmWindow = new ConfirmWindow(mainWindow, "Title Field", StyleUtils.getLabelHTML("A title entry is required.")); mainWindow.addWindow(confirmWindow); } else if (titleValue.length() < 5 || titleValue.length() > 50) { ConfirmWindow confirmWindow = new ConfirmWindow(mainWindow, "Title Field", StyleUtils .getLabelHTML("The number of characters of the title has to be between 5 and 50.")); mainWindow.addWindow(confirmWindow); } else if (!exactTimeValue && startTimeValue.after(endTimeValue)) { ConfirmWindow confirmWindow = new ConfirmWindow(mainWindow, "Date Entries", StyleUtils.getLabelHTML("The second date has to be after the first date.")); mainWindow.addWindow(confirmWindow); } else if (startTimeValue.after(new Date()) || (!exactTimeValue && endTimeValue.after(new Date()))) { ConfirmWindow confirmWindow = new ConfirmWindow(mainWindow, "Date Entries", StyleUtils.getLabelHTML("The dates are not allowed to be in the future.")); mainWindow.addWindow(confirmWindow); } else { disableButtons(); String descriptionValue = descriptionArea.getValue().toString().trim(); String licenseValue = licenseArea.getValue().toString().trim(); TopographicPoint topographicPointValue = googleMap.getMarkerPosition(); Collection<String> presettingValues = (Collection<String>) twinColSelect.getValue(); if (exactTimeValue) { endTimeValue = startTimeValue; } TimeRange timeRange = new TimeRange(new DateTime(startTimeValue), new DateTime(endTimeValue)); UploadSettings uploadSettings = new UploadSettings(titleValue, descriptionValue, licenseValue, new Vector<String>(tags), topographicPointValue, timeRange); mainWindow.removeWindow(event.getButton().getWindow()); requestRepaint(); uploadSection.upload(uploadSettings, new Vector<String>(presettingValues)); } } }); uploadButton.setStyleName(Reindeer.BUTTON_DEFAULT); uploadButtonLayout.addComponent(uploadButton); buttonLayout.addComponent(uploadButtonLayout); HorizontalLayout cancelButtonLayout = new HorizontalLayout(); cancelButtonLayout.setMargin(false, true, false, false); cancelButton = new Button("Cancel", new Button.ClickListener() { private static final long serialVersionUID = -2565870159504952913L; @Override public void buttonClick(ClickEvent event) { disableButtons(); mainWindow.removeWindow(event.getButton().getWindow()); requestRepaint(); uploadSection.cancelUpload(); } }); cancelButton.setStyleName(Reindeer.BUTTON_DEFAULT); cancelButtonLayout.addComponent(cancelButton); buttonLayout.addComponent(cancelButtonLayout); cancelAllButton = new Button("Cancel All", new Button.ClickListener() { private static final long serialVersionUID = -8578124709201789182L; @Override public void buttonClick(ClickEvent event) { disableButtons(); mainWindow.removeWindow(event.getButton().getWindow()); requestRepaint(); uploadSection.cancelAllUploads(); } }); cancelAllButton.setStyleName(Reindeer.BUTTON_DEFAULT); buttonLayout.addComponent(cancelAllButton); mainLayout.addComponent(buttonLayout); mainLayout.setComponentAlignment(buttonLayout, Alignment.BOTTOM_CENTER); wrapperLayout.addComponent(mainLayout); }
From source file:org.eclipse.hawkbit.ui.tenantconfiguration.AuthenticationConfigurationView.java
License:Open Source License
private void init() { final Panel rootPanel = new Panel(); rootPanel.setSizeFull();//from w ww . jav 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.eclipse.hawkbit.ui.tenantconfiguration.RepositoryConfigurationView.java
License:Open Source License
private void init() { final Panel rootPanel = new Panel(); rootPanel.setSizeFull();/*from ww w . j av a2s .c o m*/ rootPanel.addStyleName("config-panel"); final VerticalLayout vLayout = new VerticalLayout(); vLayout.setMargin(true); vLayout.setSizeFull(); final Label header = new Label(i18n.getMessage("configuration.repository.title")); header.addStyleName("config-panel-header"); vLayout.addComponent(header); final GridLayout gridLayout = new GridLayout(2, 2); gridLayout.setSpacing(true); gridLayout.setImmediate(true); gridLayout.setColumnExpandRatio(1, 1.0F); gridLayout.setSizeFull(); actionAutocloseCheckBox = SPUIComponentProvider.getCheckBox("", DIST_CHECKBOX_STYLE, null, false, ""); actionAutocloseCheckBox.setId(UIComponentIdProvider.REPOSITORY_ACTIONS_AUTOCLOSE_CHECKBOX); actionAutocloseCheckBox.setValue(actionAutocloseConfigurationItem.isConfigEnabled()); actionAutocloseCheckBox.addValueChangeListener(this); actionAutocloseConfigurationItem.addChangeListener(this); gridLayout.addComponent(actionAutocloseCheckBox, 0, 0); gridLayout.addComponent(actionAutocloseConfigurationItem, 1, 0); actionAutocleanupCheckBox = SPUIComponentProvider.getCheckBox("", DIST_CHECKBOX_STYLE, null, false, ""); actionAutocleanupCheckBox.setId(UIComponentIdProvider.REPOSITORY_ACTIONS_AUTOCLEANUP_CHECKBOX); actionAutocleanupCheckBox.setValue(actionAutocleanupConfigurationItem.isConfigEnabled()); actionAutocleanupCheckBox.addValueChangeListener(this); actionAutocleanupConfigurationItem.addChangeListener(this); gridLayout.addComponent(actionAutocleanupCheckBox, 0, 1); gridLayout.addComponent(actionAutocleanupConfigurationItem, 1, 1); vLayout.addComponent(gridLayout); rootPanel.setContent(vLayout); setCompositionRoot(rootPanel); }
From source file:org.groom.review.ui.flows.admin.RepositoriesFlowlet.java
License:Apache License
@Override public void initialize() { final List<FieldDescriptor> fieldDescriptors = ReviewFields.getFieldDescriptors(Repository.class); final List<FilterDescriptor> filterDefinitions = new ArrayList<FilterDescriptor>(); final EntityManager entityManager = getSite().getSiteContext().getObject(EntityManager.class); container = new LazyEntityContainer<Repository>(entityManager, true, true, false, Repository.class, 1000, new String[] { "path" }, new boolean[] { true }, "repositoryId"); ContainerUtil.addContainerProperties(container, fieldDescriptors); final GridLayout gridLayout = new GridLayout(1, 2); gridLayout.setSizeFull(); gridLayout.setMargin(false);/*from w ww . j a v a 2 s .c o m*/ gridLayout.setSpacing(true); gridLayout.setRowExpandRatio(1, 1f); setViewContent(gridLayout); final HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setSpacing(true); buttonLayout.setSizeUndefined(); gridLayout.addComponent(buttonLayout, 0, 0); final Table table = new FormattingTable(); grid = new Grid(table, container); grid.setFields(fieldDescriptors); grid.setFilters(filterDefinitions); grid.setWidth(100, Unit.PERCENTAGE); grid.setHeight(UI.getCurrent().getPage().getBrowserWindowHeight() - 285, Unit.PIXELS); table.setColumnCollapsed("repositoryId", true); gridLayout.addComponent(grid, 0, 1); final Button addButton = getSite().getButton("add"); buttonLayout.addComponent(addButton); addButton.addClickListener(new ClickListener() { /** Serial version UID. */ private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { final Repository repository = new Repository(); repository.setCreated(new Date()); repository.setModified(repository.getCreated()); repository.setOwner((Company) getSite().getSiteContext().getObject(Company.class)); final RepositoryFlowlet repositoryView = getFlow().forward(RepositoryFlowlet.class); repositoryView.edit(repository, true); } }); final Button editButton = getSite().getButton("edit"); buttonLayout.addComponent(editButton); editButton.addClickListener(new ClickListener() { /** Serial version UID. */ private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { final Repository entity = container.getEntity(grid.getSelectedItemId()); final RepositoryFlowlet repositoryView = getFlow().forward(RepositoryFlowlet.class); repositoryView.edit(entity, false); } }); final Button removeButton = getSite().getButton("remove"); buttonLayout.addComponent(removeButton); removeButton.addClickListener(new ClickListener() { /** Serial version UID. */ private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { container.removeItem(grid.getSelectedItemId()); container.commit(); } }); final Button cloneButton = new Button("Clone"); buttonLayout.addComponent(cloneButton); cloneButton.addClickListener(new ClickListener() { /** Serial version UID. */ private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { final Repository entity = container.getEntity(grid.getSelectedItemId()); Notification.show( Shell.execute("git clone --mirror " + entity.getUrl() + " " + entity.getPath(), ""), Notification.Type.TRAY_NOTIFICATION); } }); final Company company = getSite().getSiteContext().getObject(Company.class); container.removeDefaultFilters(); container.addDefaultFilter(new Compare.Equal("owner.companyId", company.getCompanyId())); grid.refresh(); }
From source file:org.groom.review.ui.flows.admin.RepositoryFlowlet.java
License:Apache License
@Override public void initialize() { entityManager = getSite().getSiteContext().getObject(EntityManager.class); final GridLayout gridLayout = new GridLayout(1, 2); gridLayout.setSizeFull(); gridLayout.setMargin(false);/* w w w .ja v a 2 s . c om*/ gridLayout.setSpacing(true); gridLayout.setRowExpandRatio(2, 1f); setViewContent(gridLayout); repositoryEditor = new ValidatingEditor(ReviewFields.getFieldDescriptors(Repository.class)); repositoryEditor.setCaption("Repository"); repositoryEditor.addListener((ValidatingEditorStateListener) this); gridLayout.addComponent(repositoryEditor, 0, 0); final HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setSpacing(true); gridLayout.addComponent(buttonLayout, 0, 1); saveButton = new Button("Save"); saveButton.setImmediate(true); buttonLayout.addComponent(saveButton); saveButton.addListener(new ClickListener() { /** Serial version UID. */ private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { repositoryEditor.commit(); entityManager.getTransaction().begin(); try { entity = entityManager.merge(entity); entity.setOwner((Company) getSite().getSiteContext().getObject(Company.class)); entity.setModified(new Date()); entityManager.persist(entity); entityManager.getTransaction().commit(); entityManager.detach(entity); repositoryEditor.discard(); } catch (final Throwable t) { if (entityManager.getTransaction().isActive()) { entityManager.getTransaction().rollback(); } throw new RuntimeException("Failed to save entity: " + entity, t); } } }); discardButton = new Button("Discard"); discardButton.setImmediate(true); buttonLayout.addComponent(discardButton); discardButton.addListener(new ClickListener() { /** Serial version UID. */ private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { repositoryEditor.discard(); } }); }
From source file:org.groom.review.ui.flows.admin.ReviewFlowlet.java
License:Apache License
@Override public void initialize() { entityManager = getSite().getSiteContext().getObject(EntityManager.class); final GridLayout gridLayout = new GridLayout(2, 2); gridLayout.setSizeFull(); gridLayout.setMargin(false);//from www.java 2s .c om gridLayout.setSpacing(true); gridLayout.setRowExpandRatio(0, 1f); gridLayout.setColumnExpandRatio(1, 1f); setViewContent(gridLayout); reviewEditor = new ValidatingEditor(ReviewFields.getFieldDescriptors(Review.class)); reviewEditor.setCaption("Review"); reviewEditor.addListener((ValidatingEditorStateListener) this); reviewEditor.setWidth(400, Unit.PIXELS); gridLayout.addComponent(reviewEditor, 0, 0); final HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setSpacing(true); gridLayout.addComponent(buttonLayout, 0, 1); beanQueryFactory = new BeanQueryFactory<FileDiffBeanQuery>(FileDiffBeanQuery.class); queryConfiguration = new HashMap<String, Object>(); beanQueryFactory.setQueryConfiguration(queryConfiguration); container = new LazyQueryContainer(beanQueryFactory, "path", 20, false); container.addContainerProperty("status", Character.class, null, true, false); container.addContainerProperty("path", String.class, null, true, false); final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); final Table table = new Table() { @Override protected String formatPropertyValue(Object rowId, Object colId, Property property) { Object v = property.getValue(); if (v instanceof Date) { Date dateValue = (Date) v; return format.format(v); } return super.formatPropertyValue(rowId, colId, property); } }; table.setSizeFull(); table.setContainerDataSource(container); table.setVisibleColumns(new Object[] { "status", "path" }); table.setColumnWidth("status", 20); //table.setColumnWidth("path", 500); table.setColumnHeaders( new String[] { getSite().localize("field-status"), getSite().localize("field-path") }); table.setColumnCollapsingAllowed(false); table.setSelectable(true); table.setMultiSelect(false); table.setImmediate(true); /*table.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent valueChangeEvent) { final String selectedPath = (String) table.getValue(); if (selectedPath != null) { final FileDiff fileDiff = ((NestingBeanItem<FileDiff>) table.getItem(selectedPath)).getBean(); final char status = fileDiff.getStatus(); if (status == 'A' || status == 'M') { final ReviewFileDiffFlowlet view = getViewSheet().forward(ReviewFileDiffFlowlet.class); view.setFileDiff(entity, fileDiff, 0); } } } });*/ gridLayout.addComponent(table, 1, 0); saveButton = new Button("Save"); saveButton.setImmediate(true); buttonLayout.addComponent(saveButton); saveButton.addListener(new ClickListener() { /** Serial version UID. */ private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { reviewEditor.commit(); entityManager.getTransaction().begin(); try { entity = entityManager.merge(entity); //entity.setAuthor(getSite().getSecurityProvider().getUser()); entity.setModified(new Date()); entityManager.persist(entity); entityManager.getTransaction().commit(); entityManager.detach(entity); reviewEditor.discard(); } catch (final Throwable t) { if (entityManager.getTransaction().isActive()) { entityManager.getTransaction().rollback(); } throw new RuntimeException("Failed to save entity: " + entity, t); } } }); discardButton = new Button("Discard"); discardButton.setImmediate(true); buttonLayout.addComponent(discardButton); discardButton.addListener(new ClickListener() { /** Serial version UID. */ private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { reviewEditor.discard(); } }); }
From source file:org.groom.review.ui.flows.admin.ReviewsFlowlet.java
License:Apache License
@Override public void initialize() { final List<FieldDescriptor> fieldDescriptors = ReviewFields.getFieldDescriptors(Review.class); final List<FilterDescriptor> filterDefinitions = new ArrayList<FilterDescriptor>(); filterDefinitions.add(//www . j a va 2 s . c o m new FilterDescriptor("title", "title", "Title", new TextField(), 200, "like", String.class, "")); final GridLayout gridLayout = new GridLayout(1, 2); gridLayout.setSizeFull(); gridLayout.setMargin(false); gridLayout.setSpacing(true); gridLayout.setRowExpandRatio(1, 1f); setViewContent(gridLayout); final HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setSpacing(true); buttonLayout.setSizeUndefined(); gridLayout.addComponent(buttonLayout, 0, 0); final EntityManager entityManager = getSite().getSiteContext().getObject(EntityManager.class); container = new LazyEntityContainer<Review>(entityManager, true, false, false, Review.class, 1000, new String[] { "created" }, new boolean[] { true }, "reviewId"); ContainerUtil.addContainerProperties(container, fieldDescriptors); final Table table = new FormattingTable(); grid = new Grid(table, container); grid.setFields(fieldDescriptors); grid.setFilters(filterDefinitions); grid.setWidth(100, Unit.PERCENTAGE); grid.setHeight(UI.getCurrent().getPage().getBrowserWindowHeight() - 285, Unit.PIXELS); table.setColumnCollapsed("reviewId", true); gridLayout.addComponent(grid, 0, 1); /*final Button addButton = getSite().getButton("add"); buttonLayout.addComponent(addButton); addButton.addClickListener(new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { final Review review = new Review(); review.setCreated(new Date()); review.setModified(review.getCreated()); review.setOwner((Company) getSite().getSiteContext().getObject(Company.class)); final ReviewFlowlet reviewView = getViewSheet().forward(ReviewFlowlet.class); reviewView.edit(review, true); } });*/ final Button editButton = getSite().getButton("edit"); buttonLayout.addComponent(editButton); editButton.addClickListener(new ClickListener() { /** Serial version UID. */ private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { final Review entity = container.getEntity(grid.getSelectedItemId()); final ReviewFlowlet reviewView = getFlow().forward(ReviewFlowlet.class); reviewView.edit(entity, false); } }); table.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { editButton.setEnabled(table.getValue() != null); } }); reviewButton = new Button("Report"); reviewButton.setImmediate(true); buttonLayout.addComponent(reviewButton); reviewButton.addListener(new ClickListener() { /** Serial version UID. */ private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { final Review entity = container.getEntity(grid.getSelectedItemId()); final Company company = getSite().getSiteContext().getObject(Company.class); getUI().getPage().open(company.getUrl() + "/../report?reviewId=" + entity.getReviewId(), "_blank"); } }); /*final Button removeButton = getSite().getButton("remove"); buttonLayout.addComponent(removeButton); removeButton.addClickListener(new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { container.removeItem(grid.getSelectedItemId()); container.commit(); } });*/ final Company company = getSite().getSiteContext().getObject(Company.class); container.removeDefaultFilters(); container.addDefaultFilter(new Compare.Equal("owner.companyId", company.getCompanyId())); grid.refresh(); }
From source file:org.groom.review.ui.flows.LogFlowlet.java
License:Apache License
@Override public void initialize() { entityManager = getSite().getSiteContext().getObject(EntityManager.class); final GridLayout gridLayout = new GridLayout(1, 3); gridLayout.setSizeFull(); gridLayout.setMargin(false);/*w w w. j a v a 2 s . c o m*/ gridLayout.setSpacing(true); gridLayout.setRowExpandRatio(2, 1f); setViewContent(gridLayout); final HorizontalLayout filterLayout = new HorizontalLayout(); filterLayout.setSpacing(true); filterLayout.setSizeUndefined(); gridLayout.addComponent(filterLayout, 0, 0); final HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setSpacing(true); buttonLayout.setSizeUndefined(); gridLayout.addComponent(buttonLayout, 0, 1); final Validator validator = new Validator() { @Override public void validate(Object o) throws InvalidValueException { final String value = (String) o; if (value.indexOf("..") != -1) { throw new InvalidValueException(".."); } for (int i = 0; i < value.length(); i++) { final char c = value.charAt(i); if (!(Character.isLetter(c) || Character.isDigit(c) || "-./".indexOf(c) != -1)) { throw new InvalidValueException("" + c); } } } }; repositoryField = new ComboBox(getSite().localize("field-repository")); repositoryField.setNullSelectionAllowed(false); repositoryField.setTextInputAllowed(true); repositoryField.setNewItemsAllowed(false); repositoryField.setInvalidAllowed(false); final List<Repository> repositories = ReviewDao.getRepositories(entityManager, (Company) getSite().getSiteContext().getObject(Company.class)); for (final Repository repository : repositories) { repositoryField.addItem(repository); repositoryField.setItemCaption(repository, repository.getPath()); if (repositoryField.getItemIds().size() == 1) { repositoryField.setValue(repository); } } filterLayout.addComponent(repositoryField); sinceField = new TextField(getSite().localize("field-since")); sinceField.setValue("master"); sinceField.setValidationVisible(true); sinceField.addValidator(validator); filterLayout.addComponent(sinceField); untilField = new TextField(getSite().localize("field-until")); untilField.setValidationVisible(true); untilField.addValidator(validator); filterLayout.addComponent(untilField); final BeanQueryFactory<CommitBeanQuery> beanQueryFactory = new BeanQueryFactory<CommitBeanQuery>( CommitBeanQuery.class); queryConfiguration = new HashMap<String, Object>(); beanQueryFactory.setQueryConfiguration(queryConfiguration); final LazyQueryContainer container = new LazyQueryContainer(beanQueryFactory, "hash", 200, false); container.addContainerFilter(new Compare.Equal("branch", sinceField.getValue())); container.addContainerProperty("hash", String.class, null, true, false); container.addContainerProperty("committerDate", Date.class, null, true, false); container.addContainerProperty("committer", String.class, null, true, false); container.addContainerProperty("authorDate", Date.class, null, true, false); container.addContainerProperty("author", String.class, null, true, false); container.addContainerProperty("tags", String.class, null, true, false); container.addContainerProperty("subject", String.class, null, true, false); final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); final Table table = new Table() { @Override protected String formatPropertyValue(Object rowId, Object colId, Property property) { Object v = property.getValue(); if (v instanceof Date) { Date dateValue = (Date) v; return format.format(v); } return super.formatPropertyValue(rowId, colId, property); } }; table.setWidth(100, Unit.PERCENTAGE); table.setHeight(UI.getCurrent().getPage().getBrowserWindowHeight() - 350, Unit.PIXELS); table.setContainerDataSource(container); table.setVisibleColumns( new Object[] { "hash", "committerDate", "committer", "authorDate", "author", "tags", "subject" }); table.setColumnWidth("hash", 50); table.setColumnWidth("committerDate", 120); table.setColumnWidth("committer", 100); table.setColumnWidth("authorDate", 120); table.setColumnWidth("author", 100); table.setColumnWidth("tags", 100); table.setColumnHeaders(new String[] { getSite().localize("field-hash"), getSite().localize("field-committer-date"), getSite().localize("field-committer"), getSite().localize("field-author-date"), getSite().localize("field-author"), getSite().localize("field-tags"), getSite().localize("field-subject") }); table.setColumnCollapsingAllowed(true); table.setColumnCollapsed("authorDate", true); table.setColumnCollapsed("author", true); table.setSelectable(true); table.setMultiSelect(true); table.setImmediate(true); gridLayout.addComponent(table, 0, 2); final Button refreshButton = new Button(getSite().localize("button-refresh")); buttonLayout.addComponent(refreshButton); refreshButton.setClickShortcut(ShortcutAction.KeyCode.ENTER); refreshButton.addStyleName("default"); refreshButton.addClickListener(new ClickListener() { /** Serial version UID. */ private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { repository = (Repository) repositoryField.getValue(); if (repository != null && sinceField.isValid() && untilField.isValid()) { queryConfiguration.put("repository", repository); final StringBuilder range = new StringBuilder(sinceField.getValue()); if (untilField.getValue().length() > 0) { range.append(".."); range.append(untilField); } container.removeAllContainerFilters(); container.addContainerFilter(new Compare.Equal("range", range.toString())); container.refresh(); } } }); final Button fetchButton = new Button("Fetch"); buttonLayout.addComponent(fetchButton); fetchButton.addClickListener(new ClickListener() { /** Serial version UID. */ private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { final Repository repository = (Repository) repositoryField.getValue(); Notification.show("Executed fetch. " + Shell.execute("git fetch", repository.getPath())); refreshButton.click(); } }); final Button addReviewButton = getSite().getButton("add-review"); addReviewButton.setEnabled(false); buttonLayout.addComponent(addReviewButton); addReviewButton.addClickListener(new ClickListener() { /** Serial version UID. */ private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { final Object[] selection = ((Set) table.getValue()).toArray(); if (selection != null && selection.length == 2) { final String hashOne = (String) selection[0]; final String hashTwo = (String) selection[1]; final Commit commitOne = ((NestingBeanItem<Commit>) container.getItem(hashOne)).getBean(); final Commit commitTwo = ((NestingBeanItem<Commit>) container.getItem(hashTwo)).getBean(); final Commit sinceCommit; final Commit untilCommit; if (commitOne.getCommitterDate().getTime() > commitTwo.getCommitterDate().getTime()) { sinceCommit = commitTwo; untilCommit = commitOne; } else { sinceCommit = commitOne; untilCommit = commitTwo; } createReview(sinceCommit.getHash(), untilCommit.getHash()); } else { final ReviewRangeDialog dialog = new ReviewRangeDialog(new ReviewRangeDialog.DialogListener() { @Override public void onOk(String sinceHash, String untilHash) { if (sinceHash.length() > 0 && untilHash.length() > 0) { createReview(sinceHash, untilHash); } } @Override public void onCancel() { } }, ((selection != null && selection.length == 1) ? "4b825dc642cb6eb9a060e54bf8d69288fbee4904" : ""), ((selection != null && selection.length == 1) ? (String) selection[0] : "")); dialog.setCaption("Please enter final comment."); UI.getCurrent().addWindow(dialog); dialog.getSinceField().focus(); } } }); table.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent valueChangeEvent) { final Set selection = (Set) table.getValue(); addReviewButton.setEnabled(selection != null && (selection.size() == 1 || selection.size() == 2)); } }); }
From source file:org.groom.review.ui.flows.reviewer.DashboardFlowlet.java
License:Apache License
@Override public void initialize() { final List<FieldDescriptor> fieldDescriptors = ReviewFields.getFieldDescriptors(Review.class); final List<FilterDescriptor> filterDefinitions = new ArrayList<FilterDescriptor>(); filterDefinitions.add(//from ww w. j ava 2 s . c o m new FilterDescriptor("title", "title", "Title", new TextField(), 200, "like", String.class, "")); final EntityManager entityManager = getSite().getSiteContext().getObject(EntityManager.class); container = new LazyEntityContainer<Review>(entityManager, true, false, false, Review.class, 0, new String[] { "created" }, new boolean[] { true }, "reviewId"); ContainerUtil.addContainerProperties(container, fieldDescriptors); final GridLayout gridLayout = new GridLayout(1, 2); gridLayout.setSizeFull(); gridLayout.setMargin(false); gridLayout.setSpacing(true); gridLayout.setRowExpandRatio(1, 1f); setViewContent(gridLayout); final HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setSpacing(true); buttonLayout.setSizeUndefined(); gridLayout.addComponent(buttonLayout, 0, 0); final Table table = new FormattingTable(); grid = new org.bubblecloud.ilves.component.grid.Grid(table, container); //grid.setWidth(550, Unit.PIXELS); grid.setFields(fieldDescriptors); grid.setFilters(filterDefinitions); grid.setHeight(UI.getCurrent().getPage().getBrowserWindowHeight() - 250, Unit.PIXELS); table.setNullSelectionAllowed(false); table.setColumnCollapsed("modified", true); table.setColumnCollapsed("reviewId", true); table.setColumnCollapsed("path", true); //table.setColumnCollapsed("sinceHash", true); //table.setColumnCollapsed("untilHash", true); table.setColumnCollapsed("completed", true); //table.setColumnCollapsed("reviewGroup", true); gridLayout.addComponent(grid, 0, 1); /*table.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent valueChangeEvent) { if (grid.getSelectedItemId() != null) { final Review entity = container.getEntity(grid.getSelectedItemId()); final ReviewFlowlet reviewView = getViewSheet().getFlowlet(ReviewFlowlet.class); reviewView.edit(entity, false); getViewSheet().forward(ReviewFlowlet.class); table.setValue(null); } } });*/ table.addItemClickListener(new ItemClickEvent.ItemClickListener() { @Override public void itemClick(ItemClickEvent event) { final Review entity = container.getEntity(event.getItemId()); final ReviewFlowlet reviewView = getFlow().getFlowlet(ReviewFlowlet.class); reviewView.edit(entity, false); getFlow().forward(ReviewFlowlet.class); //table.setValue(null); } }); final Company company = getSite().getSiteContext().getObject(Company.class); final User user = ((SecurityProviderSessionImpl) getSite().getSecurityProvider()).getUserFromSession(); container.removeDefaultFilters(); container.addDefaultFilter(new Compare.Equal("owner.companyId", company.getCompanyId())); container.addDefaultFilter(new Compare.Equal("completed", false)); final List<Group> groups = UserDao.getUserGroups(entityManager, company, user); Container.Filter groupsFilter = null; for (final Group group : groups) { final Container.Filter groupFilter = new Compare.Equal("reviewGroup", group); if (groupsFilter == null) { groupsFilter = groupFilter; } else { groupsFilter = new Or(groupsFilter, groupFilter); } } if (groupsFilter != null) { container.addDefaultFilter(groupsFilter); } grid.refresh(); }