List of usage examples for com.vaadin.ui GridLayout GridLayout
public GridLayout(int columns, int rows)
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 ww w .ja v a 2 s .c o 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.groom.translation.model.EntryFlowlet.java
License:Apache License
@Override public void initialize() { entityManager = getSite().getSiteContext().getObject(EntityManager.class); final GridLayout gridLayout = new GridLayout(1, 3); gridLayout.setSizeFull();// w w w . ja v a2 s .c o m gridLayout.setMargin(false); gridLayout.setSpacing(true); gridLayout.setRowExpandRatio(2, 1f); setViewContent(gridLayout); entryEditor = new ValidatingEditor(TranslationFields.getFieldDescriptors(Entry.class)); entryEditor.setCaption("Entry"); entryEditor.addListener((ValidatingEditorStateListener) this); gridLayout.addComponent(entryEditor, 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) { entryEditor.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); entryEditor.discard(); container.refresh(); } 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) { entryEditor.discard(); } }); final List<FieldDescriptor> fieldDescriptors = TranslationFields.getFieldDescriptors(Entry.class); final List<FilterDescriptor> filterDefinitions = new ArrayList<FilterDescriptor>(); container = new LazyEntityContainer<Entry>(entityManager, true, true, false, Entry.class, 1000, new String[] { "basename", "key", "language", "country" }, new boolean[] { true, true, true, true }, "entryId"); container.getQueryView().getQueryDefinition().setMaxQuerySize(1); ContainerUtil.addContainerProperties(container, fieldDescriptors); final Table table = new FormattingTable(); final Grid grid = new Grid(table, container); grid.setCaption("All Translations"); grid.setSizeFull(); grid.setFields(fieldDescriptors); grid.setFilters(filterDefinitions); table.setColumnCollapsed("entryId", true); table.setColumnCollapsed("path", true); table.setColumnCollapsed("created", true); table.setColumnCollapsed("modified", true); gridLayout.addComponent(grid, 0, 2); }
From source file:org.hip.vif.forum.usersettings.ui.ShowCompletedRatingView.java
License:Open Source License
/** Constructor for view to display the completed ratings given. * * @param inRatings {@link QueryResult} the participants involved in the review and rating process * @param inQuestions {@link QueryResult} the reviewed questions * @param inCompletions {@link QueryResult} the reviewed completions * @param inTexts {@link QueryResult} the reviewed texts * @param inTask {@link IPluggableWithLookup} the controlling task * @throws VException//from w w w.j av a2 s. c o m * @throws SQLException */ public ShowCompletedRatingView(final QueryResult inRatings, final QueryResult inQuestions, final QueryResult inCompletions, final QueryResult inTexts, final IPluggableWithLookup inTask) throws VException, SQLException { final VerticalLayout lLayout = new VerticalLayout(); setCompositionRoot(lLayout); final IMessages lMessages = Activator.getMessages(); lLayout.setStyleName("vif-view"); //$NON-NLS-1$ lLayout.addComponent(new Label(String.format(VIFViewHelper.TMPL_TITLE, "vif-title", //$NON-NLS-1$ lMessages.getMessage("ratings.completed.title")), ContentMode.HTML)); //$NON-NLS-1$ lLayout.addComponent(new Label(lMessages.getMessage("ui.rated.subtitle"), ContentMode.HTML)); //$NON-NLS-1$ listContributions(inQuestions, inCompletions, inTexts, inTask, lLayout, lMessages); lLayout.addComponent(RiplaViewHelper.createSpacer()); final GridLayout lRatings = new GridLayout(5, 3); lRatings.setStyleName("vif-rating"); //$NON-NLS-1$ lRatings.setWidth("100%"); //$NON-NLS-1$ lRatings.setColumnExpandRatio(4, 1); lLayout.addComponent(lRatings); // headers lRatings.addComponent(new Label("")); //$NON-NLS-1$ addComponentSized(new Label(lMessages.getMessage("ui.rated.column.correctness"), ContentMode.HTML), //$NON-NLS-1$ lRatings); addComponentSized(new Label(lMessages.getMessage("ui.rated.column.efficiency"), ContentMode.HTML), //$NON-NLS-1$ lRatings); addComponentSized(new Label(lMessages.getMessage("ui.rated.column.etiquette"), ContentMode.HTML), lRatings); //$NON-NLS-1$ Label lRemark = new Label(lMessages.getMessage("ui.rated.column.remark"), ContentMode.HTML); //$NON-NLS-1$ lRemark.setStyleName("vif-colhead vif-padding-left"); //$NON-NLS-1$ lRatings.addComponent(lRemark); lRatings.getComponent(0, 0).setWidth(350, Unit.PIXELS); // ratings final Map<Long, String> lParticipants = new HashMap<Long, String>(); final List<Line> lLines = new Vector<ShowCompletedRatingView.Line>(); while (inRatings.hasMoreElements()) { final GeneralDomainObject lRating = inRatings.nextAsDomainObject(); setParticipant(lRating, lParticipants); lLines.add(new Line(lRating)); } for (final Line lLine : lLines) { lRatings.addComponent(new Label(lLine.getInvolved(lParticipants, lMessages), ContentMode.HTML)); addComponentAligened(lLine.getCorrectness(), lRatings); addComponentAligened(lLine.getEfficiency(), lRatings); addComponentAligened(lLine.getEtiquette(), lRatings); lRemark = new Label(lLine.getRemark(), ContentMode.HTML); lRemark.setStyleName("vif-padding-left"); //$NON-NLS-1$ lRatings.addComponent(lRemark); } }
From source file:org.hip.vif.web.util.RatingsTable.java
License:Open Source License
private Component createRatingsTable(final RatingsHelper inRatings) { final GridLayout outLayout = new GridLayout(4, 6); outLayout.setWidth(400, Unit.PIXELS); outLayout.setStyleName("vif-ratings"); //$NON-NLS-1$ final IMessages lMessages = Activator.getMessages(); // first row: table header final Label lSpacer = new Label(""); //$NON-NLS-1$ lSpacer.setWidth(70, Unit.PIXELS);//from www . j a va2 s. c om outLayout.addComponent(lSpacer, 0, 0); outLayout.addComponent(createLabel(lMessages.getMessage("ratings.table.column.correctness")), 1, 0); //$NON-NLS-1$ outLayout.addComponent(createLabel(lMessages.getMessage("ratings.table.column.responsiveness")), 2, 0); //$NON-NLS-1$ outLayout.addComponent(createLabel(lMessages.getMessage("ratings.table.column.etiquette")), 3, 0); //$NON-NLS-1$ // first content: good addComponent(outLayout, RatingValue.GOOD.render(), 0, 1, Alignment.MIDDLE_CENTER); //$NON-NLS-1$ addComponent(outLayout, createLabel(inRatings.getCorrectnessA()), 1, 1, Alignment.MIDDLE_CENTER); addComponent(outLayout, createLabel(inRatings.getEfficiencyA()), 2, 1, Alignment.MIDDLE_CENTER); addComponent(outLayout, createLabel(inRatings.getEtiquetteA()), 3, 1, Alignment.MIDDLE_CENTER); // second content: average addComponent(outLayout, RatingValue.AVERAGE.render(), 0, 2, Alignment.MIDDLE_CENTER); //$NON-NLS-1$ addComponent(outLayout, createLabel(inRatings.getCorrectnessB()), 1, 2, Alignment.MIDDLE_CENTER); addComponent(outLayout, createLabel(inRatings.getEfficiencyB()), 2, 2, Alignment.MIDDLE_CENTER); addComponent(outLayout, createLabel(inRatings.getEtiquetteB()), 3, 2, Alignment.MIDDLE_CENTER); // third content: bad addComponent(outLayout, RatingValue.BAD.render(), 0, 3, Alignment.MIDDLE_CENTER); //$NON-NLS-1$ addComponent(outLayout, createLabel(inRatings.getCorrectnessC()), 1, 3, Alignment.MIDDLE_CENTER); addComponent(outLayout, createLabel(inRatings.getEfficiencyC()), 2, 3, Alignment.MIDDLE_CENTER); addComponent(outLayout, createLabel(inRatings.getEtiquetteC()), 3, 3, Alignment.MIDDLE_CENTER); // total addComponent(outLayout, new Label(lMessages.getMessage("ratings.table.label.total")), 0, 4, //$NON-NLS-1$ Alignment.MIDDLE_LEFT); addComponent(outLayout, createLabel(inRatings.getTotal1()), 1, 4, Alignment.MIDDLE_CENTER); addComponent(outLayout, createLabel(inRatings.getTotal2()), 2, 4, Alignment.MIDDLE_CENTER); addComponent(outLayout, createLabel(inRatings.getTotal3()), 3, 4, Alignment.MIDDLE_CENTER); // average addComponent(outLayout, new Label(lMessages.getMessage("ratings.table.label.mean")), 0, 5, //$NON-NLS-1$ Alignment.MIDDLE_LEFT); addComponent(outLayout, createLabel(inRatings.getMean1()), 1, 5, Alignment.MIDDLE_CENTER); addComponent(outLayout, createLabel(inRatings.getMean2()), 2, 5, Alignment.MIDDLE_CENTER); addComponent(outLayout, createLabel(inRatings.getMean3()), 3, 5, Alignment.MIDDLE_CENTER); return outLayout; }
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(/* www . j a v a 2 s.c o 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(); }
From source file:org.hoot.EntryFlowlet.java
License:Apache License
@Override public void initialize() { entityManager = getSite().getSiteContext().getObject(EntityManager.class); final GridLayout gridLayout = new GridLayout(1, 3); gridLayout.setSizeFull();//www .j a va 2 s. c om gridLayout.setMargin(false); gridLayout.setSpacing(true); gridLayout.setRowExpandRatio(2, 1f); setViewContent(gridLayout); entryEditor = new ValidatingEditor(HootFields.getFieldDescriptors(Entry.class)); entryEditor.setCaption("Entry"); entryEditor.addListener((ValidatingEditorStateListener) this); gridLayout.addComponent(entryEditor, 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) { entryEditor.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); entryEditor.discard(); container.refresh(); } 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) { entryEditor.discard(); } }); final List<FieldDescriptor> fieldDescriptors = HootFields.getFieldDescriptors(Entry.class); final List<FilterDescriptor> filterDefinitions = new ArrayList<FilterDescriptor>(); container = new LazyEntityContainer<Entry>(entityManager, true, true, false, Entry.class, 1000, new String[] { "basename", "key", "language", "country" }, new boolean[] { true, true, true, true }, "entryId"); container.getQueryView().getQueryDefinition().setMaxQuerySize(1); ContainerUtil.addContainerProperties(container, fieldDescriptors); final Table table = new FormattingTable(); final Grid grid = new Grid(table, container); grid.setCaption("All Translations"); grid.setSizeFull(); grid.setFields(fieldDescriptors); grid.setFilters(filterDefinitions); table.setColumnCollapsed("entryId", true); table.setColumnCollapsed("path", true); table.setColumnCollapsed("created", true); table.setColumnCollapsed("modified", true); gridLayout.addComponent(grid, 0, 2); }
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/* ww w .ja v a 2s . c o 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 ava2 s .c om*/ 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 ww w . j a v a 2s .c om 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 w w. ja v a2s . c om*/ 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); }