@Override public void sort(Object[] propertyIds, boolean[] ascendingFlags) { // table support sort only by one property Preconditions.checkArgument(propertyIds.length == 1); MetaPropertyPath propertyPath = (MetaPropertyPath) propertyIds[0]; boolean ascending = ascendingFlags[0]; SortInfo<MetaPropertyPath> info = new SortInfo<>(); info.setPropertyPath(propertyPath); info.setOrder(ascending ? Order.ASC : Order.DESC); getSortableDatasource().sort(new SortInfo[] {info}); }
@Override public Map<String, Object> getInitialValues() { Map<String, Object> params = new HashMap<>(); params.put("position", parametersDs.getItemIds().size()); params.put("report", getItem()); return params; }
parametersTable.addAction(paramDownButton.getAction()); parametersDs.addItemPropertyChangeListener(e -> { if ("position".equals(e.getProperty())) { ((DatasourceImplementation) parametersDs).modified(e.getItem());
seriesDs.addItemPropertyChangeListener(e -> showPreview()); seriesDs.addCollectionChangeListener(e -> { checkSeriesOrder(); showPreview();
@Override public void actionPerform(Component component) { ReportInputParameter parameter = (ReportInputParameter) target.getSingleSelected(); if (parameter != null) { List<ReportInputParameter> inputParameters = getItem().getInputParameters(); int index = parameter.getPosition(); if (index < parametersDs.getItemIds().size() - 1) { ReportInputParameter nextParameter = null; for (ReportInputParameter _param : inputParameters) { if (_param.getPosition() == index + 1) { nextParameter = _param; break; } } if (nextParameter != null) { parameter.setPosition(nextParameter.getPosition()); nextParameter.setPosition(index); sortParametersByPosition(); } } } }
@Override public Object firstItemId() { return getSortableDatasource().firstItemId(); }
protected void checkSeriesOrder() { Collection<ChartSeries> items = seriesDs.getItems(); int i = 1; for (ChartSeries item : items) { if (!Objects.equals(i, item.getOrder())) { item.setOrder(i); } i += 1; } }
protected void sortProcActors() { CollectionDatasource.Sortable.SortInfo procRoleOrderSortInfo = new CollectionDatasource.Sortable.SortInfo(); procRoleOrderSortInfo.setOrder(CollectionDatasource.Sortable.Order.ASC); procRoleOrderSortInfo.setPropertyPath(procActorsDs.getMetaClass().getPropertyPath("procRole.order")); CollectionDatasource.Sortable.SortInfo procActorOrderSortInfo = new CollectionDatasource.Sortable.SortInfo(); procActorOrderSortInfo.setOrder(CollectionDatasource.Sortable.Order.ASC); procActorOrderSortInfo.setPropertyPath(procActorsDs.getMetaClass().getPropertyPath("order")); ((CollectionDatasource.Sortable) procActorsDs).sort(new CollectionDatasource.Sortable.SortInfo[]{procRoleOrderSortInfo, procActorOrderSortInfo}); } }
protected void sortParametersByPosition() { MetaClass metaClass = metadata.getClassNN(ReportInputParameter.class); MetaPropertyPath mpp = new MetaPropertyPath(metaClass, metaClass.getProperty("position")); CollectionDatasource.Sortable.SortInfo<MetaPropertyPath> sortInfo = new CollectionDatasource.Sortable.SortInfo<>(); sortInfo.setOrder(CollectionDatasource.Sortable.Order.ASC); sortInfo.setPropertyPath(mpp); parametersDs.sort(new CollectionDatasource.Sortable.SortInfo[]{sortInfo}); }
protected void sortTableDsByItemsOrderNum() { if (listComponent.getDatasource() instanceof CollectionDatasource.Sortable) { CollectionDatasource.Sortable.SortInfo sortInfo = new CollectionDatasource.Sortable.SortInfo(); sortInfo.setOrder(CollectionDatasource.Sortable.Order.ASC); sortInfo.setPropertyPath(listComponent.getSingleSelected().getMetaClass().getPropertyPath("orderNum")); ((CollectionDatasource.Sortable) listComponent.getDatasource()).sort(new CollectionDatasource.Sortable.SortInfo[]{sortInfo}); } }
@Override protected boolean isApplicable() { if (target != null) { ReportInputParameter item = (ReportInputParameter) target.getSingleSelected(); if (item != null && parametersDs.getItem() == item) { return item.getPosition() > 0 && isUpdatePermitted(); } } return false; } });
@Override public void actionPerform(Component component) { ChartSeries selected = seriesTable.getSingleSelected(); //noinspection ConstantConditions Integer currentOrder = selected.getOrder(); Integer newOrder = up ? currentOrder - 1 : currentOrder + 1; Collection<ChartSeries> items = seriesDs.getItems(); ChartSeries changing = IterableUtils.get(items, currentOrder - 1); ChartSeries neighbor = IterableUtils.get(items, newOrder - 1); changing.setOrder(newOrder); neighbor.setOrder(currentOrder); sortSeriesByOrder(); }
protected void sortSeriesByOrder() { CollectionDatasource.Sortable.SortInfo<MetaPropertyPath> sortInfo = new CollectionDatasource.Sortable.SortInfo<>(); sortInfo.setOrder(CollectionDatasource.Sortable.Order.ASC); sortInfo.setPropertyPath(seriesDs.getMetaClass().getPropertyPath("order")); seriesDs.sort(new CollectionDatasource.Sortable.SortInfo[]{sortInfo}); } }
@Override public void sort(Object[] propertyIds, boolean[] ascendingFlags) { // A datasource supports sort only by single property Preconditions.checkArgument(propertyIds.length == 1); Preconditions.checkArgument(ascendingFlags.length == 1); MetaPropertyPath propertyPath = (MetaPropertyPath) propertyIds[0]; boolean ascending = ascendingFlags[0]; SortInfo<MetaPropertyPath> info = new SortInfo<>(); info.setPropertyPath(propertyPath); info.setOrder(ascending ? Order.ASC : Order.DESC); getSortableDatasource().sort(new SortInfo[]{info}); }