Search in sources :

Example 21 with CompositeObject

use of org.eclipse.scout.rt.platform.util.CompositeObject in project scout.rt by eclipse.

the class ColumnSet method calculateDisplayableIndexes.

private void calculateDisplayableIndexes() {
    int viewIndex = 0;
    Map<CompositeObject, Integer> displayableMap = new TreeMap<CompositeObject, Integer>();
    for (int modelIndex = 0; modelIndex < getColumnCount(); modelIndex++) {
        IColumn col = getColumn(modelIndex);
        if (col.isDisplayable()) {
            displayableMap.put(new CompositeObject(modelIndex), modelIndex);
        }
    }
    m_displayableIndexes = new int[displayableMap.size()];
    viewIndex = 0;
    for (int modelIndex : displayableMap.values()) {
        m_displayableIndexes[viewIndex++] = modelIndex;
    }
}
Also used : CompositeObject(org.eclipse.scout.rt.platform.util.CompositeObject) IColumn(org.eclipse.scout.rt.client.ui.basic.table.columns.IColumn) TreeMap(java.util.TreeMap)

Example 22 with CompositeObject

use of org.eclipse.scout.rt.platform.util.CompositeObject in project scout.rt by eclipse.

the class ColumnSet method getAllColumnsInUserOrder.

public List<IColumn<?>> getAllColumnsInUserOrder() {
    List<IColumn<?>> visibleCols = getVisibleColumns();
    int counter = 0;
    TreeMap<CompositeObject, IColumn<?>> sortMap = new TreeMap<CompositeObject, IColumn<?>>();
    for (IColumn col : visibleCols) {
        counter++;
        sortMap.put(new CompositeObject(col.getVisibleColumnIndexHint(), counter), col);
    }
    for (IColumn<?> column : getColumns()) {
        if (column.isDisplayable() && column.isVisible()) {
        // already in map
        } else {
            counter++;
            sortMap.put(new CompositeObject(column.getVisibleColumnIndexHint(), counter), column);
        }
    }
    return CollectionUtility.arrayList(sortMap.values());
}
Also used : CompositeObject(org.eclipse.scout.rt.platform.util.CompositeObject) IColumn(org.eclipse.scout.rt.client.ui.basic.table.columns.IColumn) TreeMap(java.util.TreeMap)

Example 23 with CompositeObject

use of org.eclipse.scout.rt.platform.util.CompositeObject in project scout.rt by eclipse.

the class AbstractCalendar method updateComponentsInternal.

private void updateComponentsInternal(List<ICalendarItemProvider> changedProviders) {
    Range<Date> d = getViewRange();
    if (d.getFrom() != null && d.getTo() != null) {
        for (ICalendarItemProvider p : changedProviders) {
            LinkedList<CalendarComponent> components = new LinkedList<CalendarComponent>();
            for (ICalendarItem item : p.getItems(d.getFrom(), d.getTo())) {
                components.add(new CalendarComponent(this, p, item));
            }
            m_componentsByProvider.put(p.getClass(), components);
        }
        // filter and resolve item conflicts
        Set<Class<? extends ICalendarItemProvider>> providerTypes = new HashSet<Class<? extends ICalendarItemProvider>>(changedProviders.size());
        for (ICalendarItemProvider provider : changedProviders) {
            providerTypes.add(provider.getClass());
        }
        interceptFilterCalendarItems(providerTypes, m_componentsByProvider);
        // complete list
        TreeMap<CompositeObject, CalendarComponent> sortMap = new TreeMap<CompositeObject, CalendarComponent>();
        int index = 0;
        for (Collection<CalendarComponent> c : m_componentsByProvider.values()) {
            for (CalendarComponent comp : c) {
                sortMap.put(new CompositeObject(comp.getFromDate(), index++), comp);
            }
        }
        propertySupport.setPropertySet(PROP_COMPONENTS, CollectionUtility.hashSet(sortMap.values()));
        // validate selection
        setSelectedComponent(getSelectedComponent());
    }
}
Also used : ICalendarItem(org.eclipse.scout.rt.shared.services.common.calendar.ICalendarItem) ICalendarItemProvider(org.eclipse.scout.rt.client.ui.basic.calendar.provider.ICalendarItemProvider) TreeMap(java.util.TreeMap) Date(java.util.Date) LinkedList(java.util.LinkedList) CompositeObject(org.eclipse.scout.rt.platform.util.CompositeObject) HashSet(java.util.HashSet)

Example 24 with CompositeObject

use of org.eclipse.scout.rt.platform.util.CompositeObject in project scout.rt by eclipse.

the class CompositeObjectTest method setUp.

@Before
public void setUp() {
    m_compObjLongValue = new CompositeObject(1234L);
    m_compObjDoubleValue = new CompositeObject(9876d);
    m_compObjLongArray = new CompositeObject(1234L, 5678L, 8901L);
    m_compObjDoubleArray = new CompositeObject(9876d, 5432d, 2109d);
}
Also used : CompositeObject(org.eclipse.scout.rt.platform.util.CompositeObject) Before(org.junit.Before)

Example 25 with CompositeObject

use of org.eclipse.scout.rt.platform.util.CompositeObject in project scout.rt by eclipse.

the class CompositeObjectTest method testEqualsNotComparable.

@Test
public void testEqualsNotComparable() {
    // not of type comparable -> uses toString()
    CompositeObject a = new CompositeObject(new A(123456L));
    CompositeObject b = new CompositeObject(new B(123456L));
    CompositeObject c = new CompositeObject(new C(123456L));
    CompositeObject c2 = new CompositeObject(new C(123456L));
    assertTrue(a.equals(b));
    assertTrue(b.equals(a));
    assertTrue(a.equals(c));
    assertFalse(c.equals(a));
    assertTrue(b.equals(c));
    assertFalse(c.equals(b));
    assertFalse(c.equals(c2));
    assertFalse(c2.equals(c));
}
Also used : CompositeObject(org.eclipse.scout.rt.platform.util.CompositeObject) Test(org.junit.Test)

Aggregations

CompositeObject (org.eclipse.scout.rt.platform.util.CompositeObject)29 TreeMap (java.util.TreeMap)16 IColumn (org.eclipse.scout.rt.client.ui.basic.table.columns.IColumn)7 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 Map (java.util.Map)2 IBookmarkAdapter (org.eclipse.scout.rt.client.services.common.bookmark.IBookmarkAdapter)2 ITable (org.eclipse.scout.rt.client.ui.basic.table.ITable)2 ITableRow (org.eclipse.scout.rt.client.ui.basic.table.ITableRow)2 INumberColumn (org.eclipse.scout.rt.client.ui.basic.table.columns.INumberColumn)2 IForm (org.eclipse.scout.rt.client.ui.form.IForm)2 ICompositeField (org.eclipse.scout.rt.client.ui.form.fields.ICompositeField)2 IValueField (org.eclipse.scout.rt.client.ui.form.fields.IValueField)2 Test (org.junit.Test)2 PropertyDescriptor (java.beans.PropertyDescriptor)1 Method (java.lang.reflect.Method)1 Collection (java.util.Collection)1 Date (java.util.Date)1 LinkedList (java.util.LinkedList)1