List of usage examples for com.vaadin.ui HorizontalLayout setSizeUndefined
@Override public void setSizeUndefined()
From source file:org.escidoc.browser.elabsmodul.views.helpers.LabsLayoutHelper.java
License:Open Source License
public static HorizontalLayout createHorizontalLayoutWithPublicationDataForStudy(final String labelTxt, Property dataProperty, boolean isMotNotResPublication, LabsStudyTableHelper helper, boolean required) { synchronized (LOCK_2) { Preconditions.checkNotNull(labelTxt, "Label is null"); Preconditions.checkNotNull(dataProperty, "DataSource is null"); Preconditions.checkNotNull(helper, "Helper is null"); HorizontalLayout horizontalLayout = new HorizontalLayout(); horizontalLayout.setSizeUndefined(); horizontalLayout.setEnabled(true); horizontalLayout.setSpacing(true); horizontalLayout.setStyleName(STYLE_ELABS_HOR_PANEL_FOR_TABLE); Label label = new Label(); label.setWidth(LABEL_WIDTH);/*from w w w .j av a 2s . c om*/ label.setValue( DIV_ALIGN_RIGHT + (required ? ELabsViewContants.REQUIRED_SIGN : "") + labelTxt + DIV_END); label.setContentMode(Label.CONTENT_XHTML); label.setDescription(USER_DESCR_ON_LABEL_TO_EDIT); label.setStyleName(STYLE_ELABS_HOR_PANEL); horizontalLayout.addComponent(label, 0); if (isMotNotResPublication) { horizontalLayout.addComponent(helper.createTableLayoutForMotPublications(), 1); } else { horizontalLayout.addComponent(helper.createTableLayoutForResPublications(), 1); } horizontalLayout.setComponentAlignment(label, Alignment.TOP_LEFT); return horizontalLayout; } }
From source file:org.escidoc.browser.elabsmodul.views.helpers.LabsLayoutHelper.java
License:Open Source License
public static HorizontalLayout createHorizontalLayoutWithELabsLabelAndCheckBoxData(final String labelTxt, final String checkBoxDescription, Property dataProperty, boolean required) { final HorizontalLayout horizontalLayout = new HorizontalLayout(); horizontalLayout.setSizeUndefined(); horizontalLayout.setDescription(USER_DESCR_ON_HOR_LAYOUT_TO_EDIT); horizontalLayout.setEnabled(true);/* w w w . j a va 2s . c o m*/ horizontalLayout.setSpacing(true); horizontalLayout.setHeight(HOR_PANEL_HEIGHT); horizontalLayout.setStyleName(STYLE_ELABS_HOR_PANEL); Label label = new Label(); label.setWidth(LABEL_WIDTH); label.setValue(DIV_ALIGN_RIGHT + (required ? ELabsViewContants.REQUIRED_SIGN : "") + labelTxt + DIV_END); label.setContentMode(Label.CONTENT_XHTML); label.setDescription(USER_DESCR_ON_LABEL_TO_EDIT); final CheckBox checkBox = new CheckBox(checkBoxDescription, dataProperty); checkBox.setEnabled(true); checkBox.setVisible(true); checkBox.setWidth(TEXT_WIDTH); checkBox.setStyleName(STYLE_ELABS_TEXT_AS_LABEL); checkBox.setDescription(USER_DESCR_ON_LABEL_TO_EDIT); horizontalLayout.addComponent(label, 0); horizontalLayout.addComponent(checkBox, 1); horizontalLayout.setComponentAlignment(label, Alignment.MIDDLE_LEFT); horizontalLayout.setComponentAlignment(checkBox, Alignment.MIDDLE_RIGHT); return horizontalLayout; }
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();// w w w . j a v a2s .co m 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 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.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(// ww w.j a v a 2s . c om 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();//ww w .ja v a 2 s.co m gridLayout.setMargin(false); 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 w w w . ja v a 2 s .c om 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(); }
From source file:org.groom.translation.model.EntriesFlowlet.java
License:Apache License
@Override public void initialize() { final List<FieldDescriptor> fieldDescriptors = TranslationFields.getFieldDescriptors(Entry.class); final List<FilterDescriptor> filterDefinitions = new ArrayList<FilterDescriptor>(); filterDefinitions.add(new FilterDescriptor("basename", "basename", "Basename", new TextField(), 200, "like", String.class, "")); filterDefinitions.add(new FilterDescriptor("language", "language", "Language", new TextField(), 30, "=", String.class, "")); filterDefinitions.add(//from w w w . j av a 2s. co m new FilterDescriptor("country", "country", "Country", new TextField(), 30, "=", String.class, "")); filterDefinitions .add(new FilterDescriptor("key", "key", "Key", new TextField(), 200, "like", String.class, "")); filterDefinitions.add( new FilterDescriptor("value", "value", "Value", new TextField(), 200, "like", String.class, "")); final EntityManager entityManager = getSite().getSiteContext().getObject(EntityManager.class); container = new LazyEntityContainer<Entry>(entityManager, true, true, false, Entry.class, 1000, new String[] { "basename", "key", "language", "country" }, new boolean[] { true, true, true, true }, "entryId"); ContainerUtil.addContainerProperties(container, fieldDescriptors); final GridLayout gridLayout = new GridLayout(1, 3); 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, 1); final Table table = new FormattingTable(); grid = new Grid(table, container); grid.setFields(fieldDescriptors); grid.setFilters(filterDefinitions); table.setColumnCollapsed("entryId", true); table.setColumnCollapsed("path", true); table.setColumnCollapsed("created", true); table.setColumnCollapsed("modified", true); grid.setHeight(UI.getCurrent().getPage().getBrowserWindowHeight() - 350, Unit.PIXELS); gridLayout.addComponent(grid, 0, 2); /*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 Entry entry = new Entry(); entry.setCreated(new Date()); entry.setModified(entry.getCreated()); entry.setOwner((Company) getSite().getSiteContext().getObject(Company.class)); final EntryFlowlet entryView = getFlow().forward(EntryFlowlet.class); entryView.edit(entry, 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 Entry entity = container.getEntity(grid.getSelectedItemId()); final EntryFlowlet entryView = getFlow().forward(EntryFlowlet.class); entryView.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) { final Entry entity = container.getEntity(grid.getSelectedItemId()); entity.setDeleted(new Date()); entity.setAuthor(getSite().getSecurityProvider().getUser()); entityManager.getTransaction().begin(); try { entityManager.persist(entityManager.merge(entity)); entityManager.getTransaction().commit(); } catch (final Exception e) { if (entityManager.getTransaction().isActive()) { entityManager.getTransaction().rollback(); } throw new RuntimeException(e); } container.refresh(); } }); final Button unRemoveButton = getSite().getButton("unremove"); buttonLayout.addComponent(unRemoveButton); unRemoveButton.addClickListener(new ClickListener() { /** Serial version UID. */ private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { final Entry entity = container.getEntity(grid.getSelectedItemId()); entity.setDeleted(null); entity.setAuthor(getSite().getSecurityProvider().getUser()); entityManager.getTransaction().begin(); try { entityManager.persist(entityManager.merge(entity)); entityManager.getTransaction().commit(); } catch (final Exception e) { if (entityManager.getTransaction().isActive()) { entityManager.getTransaction().rollback(); } throw new RuntimeException(e); } container.refresh(); } }); /* final Button permanentRemoveButton = getSite().getButton("permanent-remove"); buttonLayout.addComponent(permanentRemoveButton); permanentRemoveButton.addClickListener(new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { final Entry entity = container.getEntity(grid.getSelectedItemId()); entity.setDeleted(null); entityManager.getTransaction().begin(); try { entityManager.remove(entityManager.merge(entity)); entityManager.getTransaction().commit(); } catch (final Exception e) { if (entityManager.getTransaction().isActive()) { entityManager.getTransaction().rollback(); } throw new RuntimeException(e); } container.refresh(); } }); */ final Button synchronizeButton = getSite().getButton("synchronize"); buttonLayout.addComponent(synchronizeButton); synchronizeButton.addClickListener(new ClickListener() { /** Serial version UID. */ private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { TranslationSynchronizer.startSynchronize(); Notification.show(getSite().localize("message-synchronization-started")); } }); final Company company = getSite().getSiteContext().getObject(Company.class); container.removeDefaultFilters(); container.addDefaultFilter(new Compare.Equal("owner.companyId", company.getCompanyId())); grid.refresh(); repositoryField = new ComboBox(getSite().localize("field-repository")); repositoryField.setNullSelectionAllowed(false); repositoryField.setTextInputAllowed(true); repositoryField.setNewItemsAllowed(false); repositoryField.setInvalidAllowed(false); repositoryField.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { container.removeDefaultFilters(); container.addDefaultFilter(new Compare.Equal("owner.companyId", company.getCompanyId())); final Repository repository = (Repository) repositoryField.getValue(); if (repository != null) { container.addDefaultFilter( new Compare.Equal("repository.repositoryId", repository.getRepositoryId())); } } }); 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); } } final VerticalLayout verticalLayout = new VerticalLayout(); verticalLayout.setMargin(new MarginInfo(false, false, true, false)); verticalLayout.addComponent(repositoryField); gridLayout.addComponent(verticalLayout, 0, 0); }
From source file:org.hip.vif.app.admin.scr.ToolbarItemLogout.java
License:Open Source License
@SuppressWarnings("serial") @Override//from w w w . j a v a 2 s . c o m public Component getComponent() { final HorizontalLayout out = new HorizontalLayout(); out.setSizeUndefined(); final Button lLogout = new Button(Activator.getMessages().getMessage("toolbar.logout.label")); lLogout.addClickListener(new Button.ClickListener() { @Override public void buttonClick(final ClickEvent inEvent) { if (inEvent.getButton() != lLogout) { return; } if (listener != null) { listener.processAction(new IToolbarAction() { @Override public void run() { VaadinSession.getCurrent().getAttribute(IRiplaEventDispatcher.class) .dispatch(IRiplaEventDispatcher.Event.LOGOUT, new HashMap<String, Object>()); } }); } } }); lLogout.setStyleName(BaseTheme.BUTTON_LINK); out.addComponent(lLogout); return out; }
From source file:org.hip.vif.app.admin.scr.ToolbarItemUsername.java
License:Open Source License
@Override public IToolbarItemCreator getCreator() { return new IToolbarItemCreator() { @Override//from w w w.j a v a 2 s. c o m public Component createToolbarItem(final RiplaApplication inApplication, final User inUser) { if (inUser == null) { return null; } final HorizontalLayout out = new HorizontalLayout(); out.setSizeUndefined(); out.addComponent(new Label( Activator.getMessages().getFormattedMessage("toolbar.username.label", inUser.getName()))); return out; } }; }
From source file:org.hoot.EntriesFlowlet.java
License:Apache License
@Override public void initialize() { final List<FieldDescriptor> fieldDescriptors = HootFields.getFieldDescriptors(Entry.class); final List<FilterDescriptor> filterDefinitions = new ArrayList<FilterDescriptor>(); filterDefinitions.add(new FilterDescriptor("basename", "basename", "Basename", new TextField(), 200, "like", String.class, "")); filterDefinitions.add(new FilterDescriptor("language", "language", "Language", new TextField(), 30, "=", String.class, "")); filterDefinitions.add(//from ww w . j av a2 s . co m new FilterDescriptor("country", "country", "Country", new TextField(), 30, "=", String.class, "")); filterDefinitions .add(new FilterDescriptor("key", "key", "Key", new TextField(), 200, "like", String.class, "")); filterDefinitions.add( new FilterDescriptor("value", "value", "Value", new TextField(), 200, "like", String.class, "")); final EntityManager entityManager = getSite().getSiteContext().getObject(EntityManager.class); container = new LazyEntityContainer<Entry>(entityManager, true, true, false, Entry.class, 1000, new String[] { "basename", "key", "language", "country" }, new boolean[] { true, true, true, true }, "entryId"); 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 Grid(table, container); grid.setFields(fieldDescriptors); grid.setFilters(filterDefinitions); table.setColumnCollapsed("entryId", true); table.setColumnCollapsed("path", true); table.setColumnCollapsed("created", true); table.setColumnCollapsed("modified", true); grid.setHeight(UI.getCurrent().getPage().getBrowserWindowHeight() - 250, Unit.PIXELS); 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 Entry entry = new Entry(); entry.setCreated(new Date()); entry.setModified(entry.getCreated()); entry.setOwner((Company) getSite().getSiteContext().getObject(Company.class)); final EntryFlowlet entryView = getFlow().forward(EntryFlowlet.class); entryView.edit(entry, 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 Entry entity = container.getEntity(grid.getSelectedItemId()); final EntryFlowlet entryView = getFlow().forward(EntryFlowlet.class); entryView.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) { final Entry entity = container.getEntity(grid.getSelectedItemId()); entity.setDeleted(new Date()); entity.setAuthor(getSite().getSecurityProvider().getUser()); entityManager.getTransaction().begin(); try { entityManager.persist(entityManager.merge(entity)); entityManager.getTransaction().commit(); } catch (final Exception e) { if (entityManager.getTransaction().isActive()) { entityManager.getTransaction().rollback(); } throw new RuntimeException(e); } container.refresh(); } }); final Button unRemoveButton = getSite().getButton("unremove"); buttonLayout.addComponent(unRemoveButton); unRemoveButton.addClickListener(new ClickListener() { /** Serial version UID. */ private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { final Entry entity = container.getEntity(grid.getSelectedItemId()); entity.setDeleted(null); entity.setAuthor(getSite().getSecurityProvider().getUser()); entityManager.getTransaction().begin(); try { entityManager.persist(entityManager.merge(entity)); entityManager.getTransaction().commit(); } catch (final Exception e) { if (entityManager.getTransaction().isActive()) { entityManager.getTransaction().rollback(); } throw new RuntimeException(e); } container.refresh(); } }); /* final Button permanentRemoveButton = getSite().getButton("permanent-remove"); buttonLayout.addComponent(permanentRemoveButton); permanentRemoveButton.addClickListener(new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { final Entry entity = container.getEntity(grid.getSelectedItemId()); entity.setDeleted(null); entityManager.getTransaction().begin(); try { entityManager.remove(entityManager.merge(entity)); entityManager.getTransaction().commit(); } catch (final Exception e) { if (entityManager.getTransaction().isActive()) { entityManager.getTransaction().rollback(); } throw new RuntimeException(e); } container.refresh(); } }); */ final Button synchronizeButton = getSite().getButton("synchronize"); buttonLayout.addComponent(synchronizeButton); synchronizeButton.addClickListener(new ClickListener() { /** Serial version UID. */ private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { HootSynchronizer.startSynchronize(); } }); final Company company = getSite().getSiteContext().getObject(Company.class); container.removeDefaultFilters(); container.addDefaultFilter(new Compare.Equal("owner.companyId", company.getCompanyId())); grid.refresh(); }