Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » scout » [neon] Problems migrating ITableColumnFilterManager to TableUserFilterManager
[neon] Problems migrating ITableColumnFilterManager to TableUserFilterManager [message #1751084] Wed, 04 January 2017 11:13
Urs Beeli is currently offline Urs BeeliFriend
Messages: 557
Registered: October 2012
Location: Bern, Switzerland
Senior Member
While migrating our projects from Mars to Neon I stumbled across some code that I don't manage to migrate.

The migration guide (https://eclipsescout.github.io/6.0/migration-guide.html) mentions that ITableColumnFilterManager has been replaced by TableUserFilterManager.

However, we implemented our own filter manager and I struggle to migrate its internals (not having written it myself with the author on maternity leave until April) as these do not seem to be mentioned in the migration guide.

What I have done so far:
In the table field, replaced:
  @Override
  protected ITableColumnFilterManager createColumnFilterManager() {
    return new MyTableColumnFilterManager(this);
  }

with
  @Override
  protected TableUserFilterManager createUserFilterManager() {
    return new MyTableColumnFilterManager(this);
  }


In the form containing the table, replaced
MyTableColumnFilterManager filterManager = (MyTableColumnFilterManager) getTable().getColumnFilterManager();
filterManager.applyIntegerComparableFilter(getTable().getZugColumn(), from, to);

with
MyTableColumnFilterManager filterManager = (MyTableColumnFilterManager) getTable().getUserFilterManager();


And I changed our filter manager class from
public class MyTableColumnFilterManager extends DefaultTableColumnFilterManager {
  public MyTableColumnFilterManager(ITable table) {
    super(table);
  }

  public void applyIntegerComparableFilter(IColumn filterCol, Integer from, Integer to) {
    ComparableColumnFilter<Integer> comparableFilter = (ComparableColumnFilter<Integer>) getFilter(filterCol);
    if (comparableFilter == null) {
      comparableFilter = new ComparableColumnFilter(filterCol);
    }
    comparableFilter.setMinimumValue(from);
    comparableFilter.setMaximumValue(to);
    serializeAndRefresh(filterCol, comparableFilter);
  }

  private <T> void serializeAndRefresh(IColumn filterCol, ITableColumnFilter<T> filter) {
    try {
      filter.setColumn(null);
      byte[] serialized = SerializationUtility.createObjectSerializer().serialize(filter);
      setSerializedFilter(serialized, filterCol);
    } catch (IOException e) {
      LOG.error("not serializable", e);
    } finally {
      filter.setColumn(filterCol);
    }
    refresh();
  }
}

to
public class MyTableColumnFilterManager extends TableUserFilterManager {
  public MyTableColumnFilterManager(AbstractTable table) {
    super(table);
  }

  public void applyIntegerComparableFilter(IColumn filterCol, Integer from, Integer to) {
    NumberColumnUserFilterState comparableFilter = (NumberColumnUserFilterState) getFilter(filterCol);
    if (comparableFilter == null) {
      comparableFilter = new NumberColumnUserFilterState(filterCol);
    }
    comparableFilter.setNumberFrom(new BigDecimal(from));
    comparableFilter.setNumberTo(new BigDecimal(to));
    serializeAndRefresh(filterCol, comparableFilter);
  }

  private <T> void serializeAndRefresh(IColumn filterCol, IUserFilterState filter) {
    try {
      filter.setColumn(null); // this gives a compilation error, how do I tell the filter which column it applies to -> how do I do this now?
      byte[] serialized = SerializationUtility.createObjectSerializer().serialize(filter);
      setSerializedFilter(serialized, filterCol); // this gives a compilation error as it no longer seems to take the column argument -> how to fix it if it is still needed
    } catch (IOException e) {
      LOG.error("not serializable", e);
    } finally {
      filter.setColumn(filterCol);
    }
    refresh(); // this gives a compilation error, it seems to no longer exist -> what do I need to do instead?
  }
}


However, I don't understand what exactly serializeAndRefresh() did in Mars and don't see how the column information is passed to the filter in Neon. Also the refresh() methods no longer seem to exist.

How do I tell a Neon based filter which columns to filter for?
Previous Topic:[neon] Migration question: Jobs
Next Topic:[Blog Post] Business Applications on Blockchains: Eclipse Scout, Ethereum and web3j
Goto Forum:
  


Current Time: Fri May 26 05:58:51 GMT 2017

Powered by FUDForum. Page generated in 0.02905 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software