List of usage examples for org.apache.wicket.markup.html WebPage getString
public final String getString(final String key)
From source file:org.projectforge.plugins.marketing.AddressCampaignValueListPage.java
License:Open Source License
@SuppressWarnings("serial") protected static final List<IColumn<AddressDO, String>> createColumns(final WebPage page, final boolean sortable, final boolean massUpdateMode, final AddressCampaignValueFilter searchFilter, final Map<Integer, PersonalAddressDO> personalAddressMap, final Map<Integer, AddressCampaignValueDO> addressCampaignValueMap) { final List<IColumn<AddressDO, String>> columns = new ArrayList<IColumn<AddressDO, String>>(); final CellItemListener<AddressDO> cellItemListener = new CellItemListener<AddressDO>() { public void populateItem(final Item<ICellPopulator<AddressDO>> item, final String componentId, final IModel<AddressDO> rowModel) { final AddressDO address = rowModel.getObject(); final Serializable highlightedRowId; if (page instanceof AbstractListPage<?, ?, ?>) { highlightedRowId = ((AbstractListPage<?, ?, ?>) page).getHighlightedRowId(); } else { highlightedRowId = null; }/*from ww w .j a v a 2 s . co m*/ final PersonalAddressDO personalAddress = personalAddressMap.get(address.getId()); appendCssClasses(item, address.getId(), highlightedRowId, address.isDeleted()); if (address.isDeleted() == true) { // Do nothing further } else if (personalAddress != null && personalAddress.isFavoriteCard() == true) { appendCssClasses(item, RowCssClass.FAVORITE_ENTRY); } if (address.getAddressStatus().isIn(AddressStatus.LEAVED, AddressStatus.OUTDATED) == true || address.getContactStatus().isIn(ContactStatus.DEPARTED, ContactStatus.NON_ACTIVE, ContactStatus.PERSONA_INGRATA, ContactStatus.UNINTERESTING, ContactStatus.DEPARTED) == true) { appendCssClasses(item, RowCssClass.MARKED_AS_DELETED); } } }; if (page instanceof AddressCampaignValueMassUpdatePage) { columns.add(new CellItemListenerPropertyColumn<AddressDO>(new Model<String>(page.getString("created")), getSortable("created", sortable), "created", cellItemListener)); } else if (massUpdateMode == true && page instanceof AddressCampaignValueListPage) { final AddressCampaignValueListPage addressCampaignValueListPage = (AddressCampaignValueListPage) page; columns.add(new CellItemListenerPropertyColumn<AddressDO>("", null, "selected", cellItemListener) { @Override public void populateItem(final Item<ICellPopulator<AddressDO>> item, final String componentId, final IModel<AddressDO> rowModel) { final AddressDO address = rowModel.getObject(); final CheckBoxPanel checkBoxPanel = new CheckBoxPanel(componentId, addressCampaignValueListPage.new SelectItemModel(address.getId()), null); item.add(checkBoxPanel); cellItemListener.populateItem(item, componentId, rowModel); addRowClick(item, massUpdateMode); } }); } else { columns.add(new CellItemListenerPropertyColumn<AddressDO>(new Model<String>(page.getString("created")), getSortable("created", sortable), "created", cellItemListener) { @Override public void populateItem(final Item<ICellPopulator<AddressDO>> item, final String componentId, final IModel<AddressDO> rowModel) { final AddressDO address = rowModel.getObject(); final AddressCampaignValueDO addressCampaignValue = addressCampaignValueMap .get(address.getId()); final Integer addressCampaignValueId = addressCampaignValue != null ? addressCampaignValue.getId() : null; item.add(new ListSelectActionPanel(componentId, rowModel, AddressCampaignValueEditPage.class, addressCampaignValueId, page, DateTimeFormatter.instance().getFormattedDateTime(address.getCreated()), AddressCampaignValueEditPage.PARAMETER_ADDRESS_ID, String.valueOf(address.getId()), AddressCampaignValueEditPage.PARAMETER_ADDRESS_CAMPAIGN_ID, String.valueOf(searchFilter.getAddressCampaignId()))); addRowClick(item); cellItemListener.populateItem(item, componentId, rowModel); } }); } columns.add(new CellItemListenerPropertyColumn<AddressDO>(new Model<String>(page.getString("name")), getSortable("name", sortable), "name", cellItemListener)); columns.add(new CellItemListenerPropertyColumn<AddressDO>(new Model<String>(page.getString("firstName")), getSortable("firstName", sortable), "firstName", cellItemListener)); columns.add(new CellItemListenerPropertyColumn<AddressDO>(new Model<String>(page.getString("organization")), getSortable("organization", sortable), "organization", cellItemListener)); columns.add(new CellItemListenerPropertyColumn<AddressDO>( new Model<String>(page.getString("address.contactStatus")), getSortable("contactStatus", sortable), "contactStatus", cellItemListener)); columns.add( new AbstractColumn<AddressDO, String>(new Model<String>(page.getString("address.addressText"))) { @Override public void populateItem(final Item<ICellPopulator<AddressDO>> item, final String componentId, final IModel<AddressDO> rowModel) { final AddressDO address = rowModel.getObject(); final String addressText = StringHelper.listToString("|", address.getMailingAddressText(), address.getMailingZipCode() + " " + address.getMailingCity(), address.getMailingCountry()); if (massUpdateMode == false) { final AddressEditLinkPanel addressEditLinkPanel = new AddressEditLinkPanel(componentId, page, address, addressText); item.add(addressEditLinkPanel); } else { item.add(new Label(componentId, addressText)); } cellItemListener.populateItem(item, componentId, rowModel); } }); columns.add(new CellItemListenerPropertyColumn<AddressDO>( new Model<String>(page.getString("address.addressStatus")), getSortable("addressStatus", sortable), "addressStatus", cellItemListener)); columns.add(new AbstractColumn<AddressDO, String>(new Model<String>(page.getString("value"))) { @Override public void populateItem(final Item<ICellPopulator<AddressDO>> item, final String componentId, final IModel<AddressDO> rowModel) { final AddressDO address = rowModel.getObject(); final Integer id = address.getId(); final AddressCampaignValueDO addressCampaignValue = addressCampaignValueMap.get(id); if (addressCampaignValue != null) { item.add(new Label(componentId, addressCampaignValue.getValue())); item.add(AttributeModifier.append("style", new Model<String>("white-space: nowrap;"))); } else { item.add(new Label(componentId, "")); } cellItemListener.populateItem(item, componentId, rowModel); } }); columns.add(new AbstractColumn<AddressDO, String>(new Model<String>(page.getString("comment"))) { @Override public void populateItem(final Item<ICellPopulator<AddressDO>> item, final String componentId, final IModel<AddressDO> rowModel) { final AddressDO address = rowModel.getObject(); final Integer id = address.getId(); final AddressCampaignValueDO addressCampaignValue = addressCampaignValueMap.get(id); if (addressCampaignValue != null) { item.add(new Label(componentId, addressCampaignValue.getComment())); item.add(AttributeModifier.append("style", new Model<String>("white-space: nowrap;"))); } else { item.add(new Label(componentId, "")); } cellItemListener.populateItem(item, componentId, rowModel); } }); return columns; }
From source file:org.projectforge.web.core.SearchAreaPanel.java
License:Open Source License
/** * @param page Needed, because in constructor this panel is not yet added to a page. * @param id// w w w . j a v a 2s.c o m * @param filter * @param registryEntry the area to show. */ @SuppressWarnings("serial") public SearchAreaPanel(final WebPage page, final String id, final SearchPageFilter filter, final WebRegistryEntry webRegistryEntry) { super(id); final long millis = System.currentTimeMillis(); final Class<? extends IListPageColumnsCreator<?>> listPageColumnsCreatorClass = webRegistryEntry .getListPageColumnsCreatorClass(); final IListPageColumnsCreator<?> listPageColumnsCreator = listPageColumnsCreatorClass == null ? null : (IListPageColumnsCreator<?>) BeanHelper.newInstance(listPageColumnsCreatorClass, PageParameters.class, new PageParameters()); if (listPageColumnsCreator == null) { setVisible(false); return; } if (listPageColumnsCreator instanceof AbstractListPage) { ((AbstractListPage<?, ?, ?>) listPageColumnsCreator).setCalledBySearchPage(true); } final Integer number = statisticsCache.getNumberOfEntities(webRegistryEntry.getDOClass()); final Class<? extends BaseSearchFilter> registeredFilterClass = webRegistryEntry.getSearchFilterClass(); final boolean isTaskDependentFilter = registeredFilterClass != null && TaskDependentFilter.class.isAssignableFrom(registeredFilterClass); if (number > MAXIMUM_ENTRIES_WITHOUT_FILTER_SETTINGS && (filter.getSearchString() == null || filter.getSearchString().length() < 3) && (isTaskDependentFilter == false || filter.getTask() == null) && filter.getStartTimeOfModification() == null && filter.getStopTimeOfModification() == null) { // Don't search to large tables if to less filter settings are given. setVisible(false); return; } filter.updateUseModificationFilterFlag(); final BaseSearchFilter baseSearchFilter; if (isTaskDependentFilter == true) { baseSearchFilter = (BaseSearchFilter) BeanHelper.newInstance(registeredFilterClass, new Class<?>[] { BaseSearchFilter.class }, filter); ((TaskDependentFilter) baseSearchFilter).setTaskId(filter.getTaskId()); baseSearchFilter.copyBaseSearchFieldsFrom(filter); } else { baseSearchFilter = filter; } final List<SearchResultData> searchResult = searchDao.getEntries(baseSearchFilter, webRegistryEntry.getDOClass(), webRegistryEntry.getDao()); boolean hasError = false; if (searchResult == null) { // An error occured! hasError = true; } else if (searchResult.size() == 0) { // No hits. setVisible(false); return; } boolean hasMore = false; if (hasError == true) { add(WicketUtils.getInvisibleComponent("dataTable")); } else { final List<ExtendedBaseDO<Integer>> list = new ArrayList<ExtendedBaseDO<Integer>>(); for (final SearchResultData data : searchResult) { if (data.getDataObject() != null) { list.add(data.getDataObject()); } else { // Empty entry means: more entries found. hasMore = true; break; } } final List<?> columns = listPageColumnsCreator.createColumns(page, false); @SuppressWarnings({ "rawtypes", "unchecked" }) final DataTable<?, String> dataTable = new DefaultDataTable("dataTable", columns, new MySortableDataProvider("NOSORT", SortOrder.DESCENDING) { @Override public List<?> getList() { return list; } @Override protected IModel<?> getModel(final Object object) { return new Model((Serializable) object); } }, filter.getMaxRows()); add(dataTable); } final Label hasMoreEntries; if (hasError == true) { hasMoreEntries = new Label("hasMoreEntries", page.getString("search.error") + " | "); } else { hasMoreEntries = new Label("hasMoreEntries", page.getString("moreEntriesAvailable") + " | "); hasMoreEntries.setVisible(false); } add(hasMoreEntries); Component showMoreEntrieslink = null; if (hasMore == true) { final int maxRows = filter.getMaxRows(); if (maxRows < SearchForm.MAX_PAGE_SIZE) { showMoreEntrieslink = new Link<Void>("showMoreEntrieslink") { /** * @see org.apache.wicket.markup.html.link.Link#onClick() */ @Override public void onClick() { for (final int number : AbstractListForm.PAGE_SIZES) { if (number > maxRows) { filter.setMaxRows(number); break; } } filter.setArea(webRegistryEntry.getId()); } }; add(showMoreEntrieslink); } else { hasMoreEntries.setVisible(true); } } if (showMoreEntrieslink == null) { add(new Label("showMoreEntrieslink", "[invisible]").setVisible(false)); } if (listPageColumnsCreator instanceof AbstractListPage<?, ?, ?>) { add(new Link<Void>("listPageLink") { /** * @see org.apache.wicket.markup.html.link.Link#onClick() */ @Override public void onClick() { final AbstractListPage<?, ?, ?> listPage = (AbstractListPage<?, ?, ?>) listPageColumnsCreator; listPage.copySearchFieldsFrom(filter); setResponsePage(listPage); } }); } else { add(new Label("listPageLink", "[invisible]").setVisible(false)); } final long duration = System.currentTimeMillis() - millis; add(new Label("areaTitle", page.getString(webRegistryEntry.getI18nTitleHeading()))); add(new Label("timeOfSearch", NumberFormatter.format(duration))); }
From source file:org.projectforge.web.timesheet.TimesheetListPage.java
License:Open Source License
/** * For re-usage in other pages./*from www .ja v a2 s . c om*/ * @param page * @param isMassUpdateMode * @param timesheetFilter If given, then the long format filter setting will be used for displaying the description, otherwise the short * description is used. */ @SuppressWarnings("serial") protected static final List<IColumn<TimesheetDO, String>> createColumns(final WebPage page, final boolean sortable, final boolean isMassUpdateMode, final TimesheetFilter timesheetFilter, final TaskTree taskTree, final UserFormatter userFormatter, final DateTimeFormatter dateTimeFormatter) { final List<IColumn<TimesheetDO, String>> columns = new ArrayList<IColumn<TimesheetDO, String>>(); final CellItemListener<TimesheetDO> cellItemListener = new CellItemListener<TimesheetDO>() { public void populateItem(final Item<ICellPopulator<TimesheetDO>> item, final String componentId, final IModel<TimesheetDO> rowModel) { final TimesheetDO timesheet = rowModel.getObject(); final Serializable highlightedRowId; if (page instanceof AbstractListPage<?, ?, ?>) { highlightedRowId = ((AbstractListPage<?, ?, ?>) page).getHighlightedRowId(); } else { highlightedRowId = null; } appendCssClasses(item, timesheet.getId(), highlightedRowId, timesheet.isDeleted()); } }; if (page instanceof TimesheetMassUpdatePage) { columns.add(new UserPropertyColumn<TimesheetDO>(page.getString("timesheet.user"), getSortable("user.fullname", sortable), "user", cellItemListener) .withUserFormatter(userFormatter)); } else { // Show first column not for TimesheetMassUpdatePage! if (isMassUpdateMode == true && page instanceof TimesheetListPage) { final TimesheetListPage timesheetListPage = (TimesheetListPage) page; columns.add( new CellItemListenerPropertyColumn<TimesheetDO>("", null, "selected", cellItemListener) { @Override public void populateItem(final Item<ICellPopulator<TimesheetDO>> item, final String componentId, final IModel<TimesheetDO> rowModel) { final TimesheetDO timesheet = rowModel.getObject(); final CheckBoxPanel checkBoxPanel = new CheckBoxPanel(componentId, timesheetListPage.new SelectItemModel(timesheet.getId()), null); item.add(checkBoxPanel); cellItemListener.populateItem(item, componentId, rowModel); addRowClick(item, isMassUpdateMode); } }); columns.add(new UserPropertyColumn<TimesheetDO>(page.getString("timesheet.user"), getSortable("user.fullname", sortable), "user", cellItemListener) .withUserFormatter(userFormatter)); } else { columns.add(new UserPropertyColumn<TimesheetDO>(page.getString("timesheet.user"), getSortable("user.fullname", sortable), "user", cellItemListener) { @Override public void populateItem(final Item<ICellPopulator<TimesheetDO>> item, final String componentId, final IModel<TimesheetDO> rowModel) { item.add(new ListSelectActionPanel(componentId, rowModel, TimesheetEditPage.class, rowModel.getObject().getId(), page, getLabelString(rowModel))); cellItemListener.populateItem(item, componentId, rowModel); addRowClick(item); } }.withUserFormatter(userFormatter)); } } final SystemInfoCache systemInfoCache = SystemInfoCache.instance(); if (systemInfoCache.isCost2EntriesExists() == true) { columns.add( new CellItemListenerPropertyColumn<TimesheetDO>(new Model<String>(page.getString("fibu.kunde")), getSortable("kost2.projekt.kunde.name", sortable), "kost2.projekt.kunde.name", cellItemListener)); columns.add(new CellItemListenerPropertyColumn<TimesheetDO>( new Model<String>(page.getString("fibu.projekt")), getSortable("kost2.projekt.name", sortable), "kost2.projekt.name", cellItemListener)); } columns.add(new TaskPropertyColumn<TimesheetDO>(page.getString("task"), getSortable("task.title", sortable), "task", cellItemListener).withTaskTree(taskTree)); if (systemInfoCache.isCost2EntriesExists() == true) { columns.add(new CellItemListenerPropertyColumn<TimesheetDO>(page.getString("fibu.kost2"), getSortable("kost2.shortDisplayName", sortable), "kost2.shortDisplayName", cellItemListener)); } columns.add(new CellItemListenerPropertyColumn<TimesheetDO>(page.getString("calendar.weekOfYearShortLabel"), getSortable("formattedWeekOfYear", sortable), "formattedWeekOfYear", cellItemListener)); columns.add(new CellItemListenerPropertyColumn<TimesheetDO>(page.getString("calendar.dayOfWeekShortLabel"), getSortable("startTime", sortable), "startTime", cellItemListener) { @Override public void populateItem(final Item<ICellPopulator<TimesheetDO>> item, final String componentId, final IModel<TimesheetDO> rowModel) { final TimesheetDO timesheet = rowModel.getObject(); final Label label = new Label(componentId, dateTimeFormatter.getFormattedDate( timesheet.getStartTime(), DateFormats.getFormatString(DateFormatType.DAY_OF_WEEK_SHORT))); cellItemListener.populateItem(item, componentId, rowModel); item.add(label); } }); columns.add(new CellItemListenerPropertyColumn<TimesheetDO>(page.getString("timePeriod"), getSortable("startTime", sortable), "timePeriod", cellItemListener) { @Override public void populateItem(final Item<ICellPopulator<TimesheetDO>> item, final String componentId, final IModel<TimesheetDO> rowModel) { final TimesheetDO timesheet = rowModel.getObject(); final Label label = new Label(componentId, dateTimeFormatter.getFormattedTimePeriod(timesheet.getTimePeriod())); label.setEscapeModelStrings(false); cellItemListener.populateItem(item, componentId, rowModel); item.add(label); } }); columns.add(new CellItemListenerPropertyColumn<TimesheetDO>(page.getString("timesheet.duration"), getSortable("duration", sortable), "duration", cellItemListener) { @Override public void populateItem(final Item<ICellPopulator<TimesheetDO>> item, final String componentId, final IModel<TimesheetDO> rowModel) { final TimesheetDO timesheet = rowModel.getObject(); final Label label = new Label(componentId, dateTimeFormatter.getFormattedDuration(timesheet.getDuration())); label.setEscapeModelStrings(false); cellItemListener.populateItem(item, componentId, rowModel); item.add(label); } }); columns.add(new CellItemListenerPropertyColumn<TimesheetDO>(page.getString("timesheet.location"), getSortable("location", sortable), "location", cellItemListener)); columns.add(new CellItemListenerPropertyColumn<TimesheetDO>(page.getString("description"), getSortable("shortDescription", sortable), "shortDescription", cellItemListener) { @Override public void populateItem(final Item<ICellPopulator<TimesheetDO>> item, final String componentId, final IModel<TimesheetDO> rowModel) { final TimesheetDO timesheet = rowModel.getObject(); final Label label = new Label(componentId, new Model<String>() { @Override public String getObject() { String text; if (timesheetFilter != null && timesheetFilter.isLongFormat() == true) { text = HtmlHelper.escapeXml(timesheet.getDescription()); } else { text = HtmlHelper.escapeXml(timesheet.getShortDescription()); } if (isMassUpdateMode == true) { return text; } else { return JiraUtils.linkJiraIssues(text); // Not in mass update mode: link on table row results otherwises in JIRA-Link. } } }); label.setEscapeModelStrings(false); cellItemListener.populateItem(item, componentId, rowModel); item.add(label); } }); return columns; }