org.apache.wicket.extensions.markup.html.repeater.data.sort.SortOrder Java Examples

The following examples show how to use org.apache.wicket.extensions.markup.html.repeater.data.sort.SortOrder. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EingangsrechnungListPage.java    From projectforge-webapp with GNU General Public License v3.0 6 votes vote down vote up
@SuppressWarnings("serial")
@Override
protected void init()
{
  dataTable = createDataTable(createColumns(this, true), "datum", SortOrder.DESCENDING);
  form.add(dataTable);
  addExcelExport(getString("fibu.common.creditor"), getString("fibu.eingangsrechnungen"));
  if (Configuration.getInstance().isCostConfigured() == true) {
    final ContentMenuEntryPanel exportExcelButton = new ContentMenuEntryPanel(getNewContentMenuChildId(), new Link<Object>("link") {
      @Override
      public void onClick()
      {
        exportExcelWithCostAssignments();
      };
    }, getString("fibu.rechnung.kostExcelExport")).setTooltip(getString("fibu.rechnung.kostExcelExport.tootlip"));
    addContentMenuEntry(exportExcelButton);
  }
}
 
Example #2
Source File: TestModels.java    From wicket-orientdb with Apache License 2.0 6 votes vote down vote up
@Test
public void testOIndexDataProvider()
{
	OSchema schema = wicket.getTester().getSchema();
	OClass oClass = schema.getClass("OUser");
	OIndexesDataProvider provider = new OIndexesDataProvider(oClass, true);
	provider.setSort("name", SortOrder.ASCENDING);
	Iterator<? extends OIndex<?>> it = provider.iterator(0, -1);
	List<OIndex<?>> allIndexes = new ArrayList<OIndex<?>>(oClass.getIndexes());
	while(it.hasNext())
	{
		OIndex<?> oIndex = it.next();
		assertTrue(allIndexes.remove(provider.model(oIndex).getObject()));
	}
	assertTrue(allIndexes.size()==0);
	provider.detach();
}
 
Example #3
Source File: TestModels.java    From wicket-orientdb with Apache License 2.0 6 votes vote down vote up
@Test
public void testOQueryProvider()
{
	OQueryDataProvider<OUser> provider = new OQueryDataProvider<OUser>("select from OUser where name <> :other", OUser.class);
	provider.setSort("name", SortOrder.ASCENDING);
	provider.setParameter("other", Model.of("blalba"));
	Iterator<OUser> it = provider.iterator(0, -1);
	List<ODocument> allUsers = wicket.getTester().getMetadata().getSecurity().getAllUsers();
	assertTrue(provider.size()==allUsers.size());
	while(it.hasNext())
	{
		OUser oUser = it.next();
		assertTrue(allUsers.contains(provider.model(oUser).getObject().getDocument()));
	}
	provider.detach();
	assertTrue(provider.size()==allUsers.size());
}
 
Example #4
Source File: TestFilters.java    From wicket-orientdb with Apache License 2.0 6 votes vote down vote up
@Test
@SuppressWarnings("unchecked")
public void testCollectionFilterCriteria() {
    List<Integer> models = Lists.newArrayList();
    models.add(NUM_VALUE_1);
    models.add(NUM_VALUE_2);
    IModel<Collection<Integer>> collectionModel = new CollectionModel<>(models);
    IFilterCriteriaManager manager = new FilterCriteriaManager(wicket.getProperty(NUMBER_FIELD));
    manager.addFilterCriteria(manager.createCollectionFilterCriteria(collectionModel, Model.of(true)));
    String field = wicket.getProperty(NUMBER_FIELD).getObject().getName();
    queryModel.addFilterCriteriaManager(field, manager);
    queryModel.setSort(NUMBER_FIELD, SortOrder.ASCENDING);
    assertTrue(queryModel.getObject().size() == 2);
    assertTrue(queryModel.getObject().get(0).field(NUMBER_FIELD).equals(NUM_VALUE_1));
    assertTrue(queryModel.getObject().get(1).field(NUMBER_FIELD).equals(NUM_VALUE_2));
}
 
Example #5
Source File: TestFilters.java    From wicket-orientdb with Apache License 2.0 6 votes vote down vote up
@Test
public void testRangeFilterCriteria() {
    List<Integer> models = Lists.newArrayList();
    models.add(NUM_VALUE_1);
    models.add(NUM_VALUE_3);
    IModel<List<Integer>> listModel = new ListModel<>(models);
    IFilterCriteriaManager manager = new FilterCriteriaManager(wicket.getProperty(NUMBER_FIELD));
    manager.addFilterCriteria(manager.createRangeFilterCriteria(listModel, Model.of(true)));
    String field = wicket.getProperty(NUMBER_FIELD).getObject().getName();
    queryModel.addFilterCriteriaManager(field, manager);
    queryModel.setSort(NUMBER_FIELD, SortOrder.ASCENDING);
    assertTrue("size must be 3, but it is - " + queryModel.size(), queryModel.size() == 3);
    assertTrue(queryModel.getObject().get(0).field(NUMBER_FIELD).equals(NUM_VALUE_1));
    assertTrue(queryModel.getObject().get(1).field(NUMBER_FIELD).equals(NUM_VALUE_2));
    assertTrue(queryModel.getObject().get(2).field(NUMBER_FIELD).equals(NUM_VALUE_3));
}
 
Example #6
Source File: RechnungListPage.java    From projectforge-webapp with GNU General Public License v3.0 6 votes vote down vote up
@SuppressWarnings("serial")
@Override
protected void init()
{
  dataTable = createDataTable(createColumns(this, true), "nummer", SortOrder.DESCENDING);
  form.add(dataTable);
  addExcelExport(getString("fibu.common.debitor"), getString("fibu.rechnungen"));
  if (Configuration.getInstance().isCostConfigured() == true) {
    final ContentMenuEntryPanel exportExcelButton = new ContentMenuEntryPanel(getNewContentMenuChildId(), new Link<Object>("link") {
      @Override
      public void onClick()
      {
        exportExcelWithCostAssignments();
      };
    }, getString("fibu.rechnung.kostExcelExport")).setTooltip(getString("fibu.rechnung.kostExcelExport.tootlip"));
    addContentMenuEntry(exportExcelButton);
  }
}
 
Example #7
Source File: SemesterPage.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
@Override
public Iterator<? extends Semester> iterator(long first, long count) {			
	List<Semester>myList = getData();
	if (needToSortList) {
		log.debug("sorting the collection");
		String prop = getSort().getProperty();
		SortOrder order =  getSortState().getPropertySortOrder(prop);			
		Comparator<Semester> comp = ComparatorFactory.createComparator(prop);
		Collections.sort(myList, comp);
		if (order == SortOrder.DESCENDING) {
			Collections.reverse(myList);
		}
		needToSortList = false;
	}
	else {
		log.debug("skipped sorting because the sort order should be the same as before..");
	}
	
	int fint = (int)first;
	int fcount = (int)count;
	return myList.subList(fint, fint + fcount).iterator();
}
 
Example #8
Source File: AuftragListPage.java    From projectforge-webapp with GNU General Public License v3.0 6 votes vote down vote up
@SuppressWarnings("serial")
@Override
protected void init()
{
  dataTable = createDataTable(createColumns(this, true), "nummer", SortOrder.DESCENDING);
  form.add(dataTable);
  final ContentMenuEntryPanel exportExcelButton = new ContentMenuEntryPanel(getNewContentMenuChildId(), new Link<Object>("link") {
    @Override
    public void onClick()
    {
      final List<AuftragDO> list = getList();
      final byte[] xls = orderExport.export(list);
      if (xls == null || xls.length == 0) {
        form.addError("datatable.no-records-found");
        return;
      }
      final String filename = "ProjectForge-OrderExport_" + DateHelper.getDateAsFilenameSuffix(new Date()) + ".xls";
      DownloadUtils.setDownloadTarget(xls, filename);
    };
  }, getString("exportAsXls")).setTooltip(getString("tooltip.export.excel"));
  addContentMenuEntry(exportExcelButton);

}
 
Example #9
Source File: Kost1ListPage.java    From projectforge-webapp with GNU General Public License v3.0 6 votes vote down vote up
@SuppressWarnings("serial")
@Override
protected void init()
{
  dataTable = createDataTable(createColumns(this, true), "formattedNumber", SortOrder.ASCENDING);
  form.add(dataTable);
  {
    // Excel export
    final SubmitLink excelExportLink = new SubmitLink(ContentMenuEntryPanel.LINK_ID, form) {
      @Override
      public void onSubmit()
      {
        exportExcel();
      }
    };
    final ContentMenuEntryPanel excelExportButton = new ContentMenuEntryPanel(getNewContentMenuChildId(), excelExportLink,
        getString("exportAsXls")).setTooltip(getString("tooltip.export.excel"));
    addContentMenuEntry(excelExportButton);
  }
}
 
Example #10
Source File: AnalysisDataProvider.java    From nextreports-server with Apache License 2.0 6 votes vote down vote up
public List<String> getHeader() {		
	List<String> result = analysisReader.getHeader(analysis);
	if (result.isEmpty()) {
		return result;
	}
	SortParam<String> sort = getSort();							
	if (sort == null) {			
		setSort(result.get(0), SortOrder.ASCENDING);
		List<String> sortProperty = new ArrayList<String>();
		sortProperty.add(result.get(0));
		analysis.setSortProperty(sortProperty);
		List<Boolean> asc = new ArrayList<Boolean>();
		asc.add(true);
		analysis.setAscending(asc);
	}
	return result;
}
 
Example #11
Source File: OrienteerHeadersToolbar.java    From Orienteer with Apache License 2.0 6 votes vote down vote up
private WebMarkupContainer newIconContainer(String id, final S property, final ISortStateLocator<S> locator) {
    return new WebMarkupContainer(id) {
        @Override
        protected void onComponentTag(ComponentTag tag) {
            super.onComponentTag(tag);
            ISortState<S> sortState = locator.getSortState();
            SortOrder sortOrder = sortState.getPropertySortOrder(property);
            String iconClass;
            if (sortOrder == SortOrder.ASCENDING) {
                iconClass = FAIconType.sort_asc.getCssClass();
            } else if (sortOrder == SortOrder.DESCENDING) {
                iconClass = FAIconType.sort_desc.getCssClass();
            } else {
                iconClass = FAIconType.sort.getCssClass();
            }
            if (!Strings.isEmpty(iconClass)) {
                tag.append("class", iconClass, " ");
            }
        }
    };
}
 
Example #12
Source File: OClustersWidget.java    From Orienteer with Apache License 2.0 6 votes vote down vote up
public OClustersWidget(String id, IModel<Void> model, IModel<ODocument> widgetDocumentModel) {
    super(id, model, widgetDocumentModel);


    IModel<DisplayMode> modeModel = DisplayMode.VIEW.asModel();
    List<IColumn<OCluster, String>> columns = new ArrayList<IColumn<OCluster,String>>();
    columns.add(new OClusterColumn(NAME, modeModel));
    columns.add(new OClusterMetaColumn(CONFLICT_STRATEGY, modeModel));
    columns.add(new OClusterMetaColumn(ID, modeModel));
    columns.add(new OClusterMetaColumn(COUNT, modeModel));

    AbstractJavaSortableDataProvider<OCluster, String> provider =  new OClustersDataProvider();
    provider.setSort(NAME, SortOrder.ASCENDING);
    GenericTablePanel<OCluster> tablePanel = new GenericTablePanel<OCluster>("tablePanel", columns, provider ,20);
    OrienteerDataTable<OCluster, String> table = tablePanel.getDataTable();
    addTableCommands(table, modeModel);
    add(tablePanel);
}
 
Example #13
Source File: LiquidityEntryListPage.java    From projectforge-webapp with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void init()
{
  dataTable = createDataTable(createColumns(this, true), "dateOfPayment", SortOrder.ASCENDING);
  form.add(dataTable);
  @SuppressWarnings("serial")
  final ContentMenuEntryPanel liquidityForecastButton = new ContentMenuEntryPanel(getNewContentMenuChildId(), new Link<Object>("link") {
    @Override
    public void onClick()
    {
      final LiquidityForecastPage page = new LiquidityForecastPage(new PageParameters()).setForecast(getForecast());
      page.setReturnToPage(LiquidityEntryListPage.this);
      setResponsePage(page);
    };
  }, getString("plugins.liquidityplanning.forecast"));
  addContentMenuEntry(liquidityForecastButton);
  addExcelExport("liquidity", getString("plugins.liquidityplanning.entry.title.heading"));
}
 
Example #14
Source File: EmployeeSalaryListPage.java    From projectforge-webapp with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void init()
{
  final List<IColumn<EmployeeSalaryDO, String>> columns = createColumns(this, true);
  dataTable = createDataTable(columns, "employee.user.lastname", SortOrder.ASCENDING);
  form.add(dataTable);
  addExcelExport(getString("fibu.employee.salaries"), getString("fibu.employee.salaries"));
  {
    // Excel export
    @SuppressWarnings("serial")
    final SubmitLink excelExportLink = new SubmitLink(ContentMenuEntryPanel.LINK_ID, form) {
      @Override
      public void onSubmit()
      {
        if (form.getSearchFilter().getMonth() < 0 || form.getSearchFilter().getMonth() > 11) {
          form.addError("fibu.employee.salary.error.monthNotGiven");
          return;
        }
        exportExcel();
      }
    };
    final ContentMenuEntryPanel excelExportButton = new ContentMenuEntryPanel(getNewContentMenuChildId(), excelExportLink,
        getString("fibu.rechnung.kostExcelExport")).setTooltip(getString("fibu.employee.salary.exportXls.tooltip"));
    addContentMenuEntry(excelExportButton);
  }
}
 
Example #15
Source File: SemesterPage.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
@Override
public Iterator<? extends Semester> iterator(long first, long count) {			
	List<Semester>myList = getData();
	if (needToSortList) {
		log.debug("sorting the collection");
		String prop = getSort().getProperty();
		SortOrder order =  getSortState().getPropertySortOrder(prop);			
		Comparator<Semester> comp = ComparatorFactory.createComparator(prop);
		Collections.sort(myList, comp);
		if (order == SortOrder.DESCENDING) {
			Collections.reverse(myList);
		}
		needToSortList = false;
	}
	else {
		log.debug("skipped sorting because the sort order should be the same as before..");
	}
	
	int fint = (int)first;
	int fcount = (int)count;
	return myList.subList(fint, fint + fcount).iterator();
}
 
Example #16
Source File: EmployeeListPage.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void init()
{
  final List<IColumn<EmployeeDO, String>> columns = createColumns(this, true);
  dataTable = createDataTable(columns, "user.lastname", SortOrder.ASCENDING);
  form.add(dataTable);
  addExcelExport(getString("fibu.employee.title.heading"), "employees");
}
 
Example #17
Source File: OClusterSecurityWidget.java    From Orienteer with Apache License 2.0 5 votes vote down vote up
public OClusterSecurityWidget(String id, IModel<OCluster> model,
                                 IModel<ODocument> widgetDocumentModel) {
	super(id, model, widgetDocumentModel);

	List<IColumn<ORole, String>> sColumns = new ArrayList<IColumn<ORole,String>>();
	OClass oRoleClass = OrientDbWebSession.get().getDatabase().getMetadata().getSchema().getClass("ORole");
	sColumns.add(new AbstractColumn<ORole, String>(new OClassNamingModel(oRoleClass), "name") {

		@Override
		public void populateItem(Item<ICellPopulator<ORole>> cellItem,
				String componentId, IModel<ORole> rowModel) {
			cellItem.add(new LinkViewPanel(componentId, new PropertyModel<ODocument>(rowModel, "document")));
		}
	});
	sColumns.add(new SecurityRightsColumn(OrientPermission.CREATE));
	sColumns.add(new SecurityRightsColumn(OrientPermission.READ));
	sColumns.add(new SecurityRightsColumn(OrientPermission.UPDATE));
	sColumns.add(new SecurityRightsColumn(OrientPermission.DELETE));
	
	OQueryDataProvider<ORole> sProvider = new OQueryDataProvider<ORole>("select from ORole", ORole.class);
	sProvider.setSort("name", SortOrder.ASCENDING);
	GenericTablePanel<ORole> tablePanel = new GenericTablePanel<ORole>("tablePanel", sColumns, sProvider ,20);
	OSecurityHelper.secureComponent(tablePanel, OSecurityHelper.requireOClass("ORole", Component.ENABLE, OrientPermission.UPDATE));

	OrienteerDataTable<ORole, String> sTable = tablePanel.getDataTable();
	Command<ORole> saveCommand = new AbstractSaveCommand<ORole>(sTable, null);
	sTable.addCommand(saveCommand);
	sTable.setCaptionModel(new ResourceModel("cluster.security"));
	add(tablePanel);
	add(DisableIfPrototypeBehavior.INSTANCE, UpdateOnActionPerformedEventBehavior.INSTANCE_ALL_CONTINUE);
}
 
Example #18
Source File: ProjektListPage.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void init()
{
  dataTable = createDataTable(createColumns(this, true), "kost", SortOrder.ASCENDING);
  form.add(dataTable);
  final BookmarkablePageLink<Void> addTemplatesLink = UserPrefListPage.createLink("link", UserPrefArea.PROJEKT_FAVORITE);
  final ContentMenuEntryPanel menuEntry = new ContentMenuEntryPanel(getNewContentMenuChildId(), addTemplatesLink, getString("favorites"));
  addContentMenuEntry(menuEntry);
}
 
Example #19
Source File: MyListPageSortableDataProvider.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
public MyListPageSortableDataProvider(final SortParam<String> sortParam, final SortParam<String> secondSortParam,
    final AbstractListPage< ? , ? , T> listPage)
{
  this.listPage = listPage;
  // set default sort
  if (sortParam != null) {
    setSort(sortParam);
  } else {
    setSort("NOSORT", SortOrder.ASCENDING);
  }
}
 
Example #20
Source File: CustomerListPage.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void init()
{
  dataTable = createDataTable(createColumns(this, true), "kost", SortOrder.ASCENDING);
  form.add(dataTable);

  final BookmarkablePageLink<Void> addTemplatesLink = UserPrefListPage.createLink(ContentMenuEntryPanel.LINK_ID,
      UserPrefArea.KUNDE_FAVORITE);
  final ContentMenuEntryPanel menuEntry = new ContentMenuEntryPanel(getNewContentMenuChildId(), addTemplatesLink, getString("favorites"));
  addContentMenuEntry(menuEntry);
}
 
Example #21
Source File: SchemaOClassesModalPanel.java    From Orienteer with Apache License 2.0 5 votes vote down vote up
private GenericTablePanel<OClass> createGenericTablePanel(String id) {
    AbstractJavaSortableDataProvider<OClass, String> provider = getProvider();
    provider.setSort("name", SortOrder.ASCENDING);
    List<IColumn<OClass, String>> columns = getColumns();
    GenericTablePanel<OClass> tablePanel = new GenericTablePanel<>(id, columns, provider, 20);
    addCommands(tablePanel.getDataTable());
    return tablePanel;
}
 
Example #22
Source File: ReportsDataProvider.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
public ReportsDataProvider(PrefsData prefsData, ReportDef reportDef, boolean logInfo) {
	Injector.get().inject(this);
	
	this.prefsData = prefsData;
	this.setReportDef(reportDef);
	this.logInfo = logInfo;
	
       // set default sort
	if(!reportDef.getReportParams().isHowSort() || reportDef.getReportParams().getHowSortBy() == null) {
		setSort(COL_USERNAME, SortOrder.ASCENDING);
	}else{
		setSort(reportDef.getReportParams().getHowSortBy(),
				reportDef.getReportParams().getHowSortAscending() ? SortOrder.ASCENDING : SortOrder.DESCENDING);
	}
}
 
Example #23
Source File: OQueryModel.java    From wicket-orientdb with Apache License 2.0 5 votes vote down vote up
/**
 * Set sorting configration
 * @param sortableParameter sortable parameter to sort on
 * @param order {@link SortOrder} to sort on
 * @return this {@link OQueryModel}
 */
public OQueryModel<K> setSort(String sortableParameter, SortOrder order)
{
	setSortableParameter(sortableParameter);
	setAscending(SortOrder.ASCENDING.equals(order));
	return this;
}
 
Example #24
Source File: OQueryDataProvider.java    From wicket-orientdb with Apache License 2.0 5 votes vote down vote up
/**
 * Set sort
 * @param property property to sort on
 * @param order order to apply: true is for ascending, false is for descending
 */
public void setSort(String property, Boolean order) {
	SortOrder sortOrder = order==null?SortOrder.ASCENDING:(order?SortOrder.ASCENDING:SortOrder.DESCENDING);
	if(property==null) {
		if(order==null) setSort(null);
		else setSort("@rid", sortOrder);
	} else {
		super.setSort(property, sortOrder);
	}
}
 
Example #25
Source File: PolicyRuleDirectoryPanel.java    From syncope with Apache License 2.0 5 votes vote down vote up
public PolicyRuleDataProvider(final int paginatorRows) {
    super(paginatorRows);

    // Default sorting
    setSort("implementationKey", SortOrder.ASCENDING);
    comparator = new SortableDataProviderComparator<>(this);
}
 
Example #26
Source File: ContactListPage.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
/**
 * @see org.projectforge.web.wicket.AbstractListPage#init()
 */
@Override
protected void init()
{
  dataTable = createDataTable(createColumns(this, true), "lastUpdate", SortOrder.DESCENDING);
  form.add(dataTable);
}
 
Example #27
Source File: TimesheetListPage.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void createDataTable()
{
  final List<IColumn<TimesheetDO, String>> columns = createColumns(this, !isMassUpdateMode(), isMassUpdateMode(), form.getSearchFilter(),
      taskTree, userFormatter, dateTimeFormatter);
  dataTable = createDataTable(columns, "startTime", SortOrder.DESCENDING);
  form.add(dataTable);
}
 
Example #28
Source File: TrainingAttendeeListPage.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
/**
 * @see org.projectforge.web.wicket.AbstractListPage#init()
 */
@Override
protected void init()
{
  dataTable = createDataTable(createColumns(this, true), "lastUpdate", SortOrder.DESCENDING);
  form.add(dataTable);
  addExcelExport(getString("plugins.skillmatrix.skilltraining.attendee.menu"), getString("plugins.skillmatrix.skilltraining.attendee.menu"));
}
 
Example #29
Source File: TestModels.java    From wicket-orientdb with Apache License 2.0 5 votes vote down vote up
@Test
public void testOQueryProviderContextVariables()
{
	OQueryDataProvider<OUser> provider = new OQueryDataProvider<OUser>("select from OUser where name = $name", OUser.class);
	provider.setSort("name", SortOrder.ASCENDING);
	provider.setContextVariable("name", Model.of("admin"));
	Iterator<OUser> it = provider.iterator(0, -1);
	assertEquals(1, provider.size());
	assertEquals("admin", it.next().getName());
}
 
Example #30
Source File: AccountingRecordListPage.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void init()
{
  final List<IColumn<BuchungssatzDO, String>> columns = createColumns(this, true);
  dataTable = createDataTable(columns, "formattedSatzNummer", SortOrder.ASCENDING);
  form.add(dataTable);
}