Search in sources :

Example 1 with AbstractTable

use of org.eclipse.scout.rt.client.ui.basic.table.AbstractTable in project scout.rt by eclipse.

the class AbstractProposalColumnTest method testLookupRowWithUntrimmedText2.

@Test
public void testLookupRowWithUntrimmedText2() throws Exception {
    final AbstractProposalColumn<Long> column = new AbstractProposalColumn<Long>() {

        @Override
        protected boolean getConfiguredEditable() {
            return true;
        }

        @Override
        protected boolean getConfiguredTrimText() {
            return true;
        }
    };
    column.setCodeTypeClass(TestCodeType.class);
    final ITable table = new AbstractTable() {

        @Override
        protected void injectColumnsInternal(OrderedCollection<IColumn<?>> columns) {
            columns.addFirst(column);
        }
    };
    ITableRow row = table.addRow();
    @SuppressWarnings("unchecked") IProposalField<Long> field = (IProposalField<Long>) column.prepareEditInternal(row);
    field.getUIFacade().acceptProposalFromUI(" a ", false, false);
    column.completeEdit(row, field);
    assertEquals("a", column.getValue(row));
}
Also used : AbstractTable(org.eclipse.scout.rt.client.ui.basic.table.AbstractTable) IProposalField(org.eclipse.scout.rt.client.ui.form.fields.smartfield.IProposalField) OrderedCollection(org.eclipse.scout.rt.platform.util.collection.OrderedCollection) ITable(org.eclipse.scout.rt.client.ui.basic.table.ITable) ITableRow(org.eclipse.scout.rt.client.ui.basic.table.ITableRow) Test(org.junit.Test)

Example 2 with AbstractTable

use of org.eclipse.scout.rt.client.ui.basic.table.AbstractTable in project scout.rt by eclipse.

the class AbstractProposalColumnTest method testLookupRowWithUntrimmedText1.

@Test
public void testLookupRowWithUntrimmedText1() throws Exception {
    final AbstractProposalColumn<Long> column = new AbstractProposalColumn<Long>() {

        @Override
        protected boolean getConfiguredEditable() {
            return true;
        }

        @Override
        protected boolean getConfiguredTrimText() {
            return false;
        }
    };
    column.setCodeTypeClass(TestCodeType.class);
    final ITable table = new AbstractTable() {

        @Override
        protected void injectColumnsInternal(OrderedCollection<IColumn<?>> columns) {
            columns.addFirst(column);
        }
    };
    ITableRow row = table.addRow();
    @SuppressWarnings("unchecked") IProposalField<Long> field = (IProposalField<Long>) column.prepareEditInternal(row);
    field.getUIFacade().acceptProposalFromUI(" a ", false, true);
    column.completeEdit(row, field);
    assertEquals(" a ", column.getValue(row));
}
Also used : AbstractTable(org.eclipse.scout.rt.client.ui.basic.table.AbstractTable) IProposalField(org.eclipse.scout.rt.client.ui.form.fields.smartfield.IProposalField) OrderedCollection(org.eclipse.scout.rt.platform.util.collection.OrderedCollection) ITable(org.eclipse.scout.rt.client.ui.basic.table.ITable) ITableRow(org.eclipse.scout.rt.client.ui.basic.table.ITableRow) Test(org.junit.Test)

Example 3 with AbstractTable

use of org.eclipse.scout.rt.client.ui.basic.table.AbstractTable in project scout.rt by eclipse.

the class AbstractListBox method initConfig.

@Override
protected void initConfig() {
    m_fields = CollectionUtility.emptyArrayList();
    m_movedFormFieldsByClass = new HashMap<Class<? extends IFormField>, IFormField>();
    super.initConfig();
    setFilterActiveRows(getConfiguredFilterActiveRows());
    setFilterActiveRowsValue(TriState.TRUE);
    setFilterCheckedRows(getConfiguredFilterCheckedRows());
    setFilterCheckedRowsValue(getConfiguredFilterCheckedRows());
    List<ITable> contributedTables = m_contributionHolder.getContributionsByClass(ITable.class);
    m_table = CollectionUtility.firstElement(contributedTables);
    if (m_table == null) {
        Class<? extends ITable> configuredTable = getConfiguredTable();
        if (configuredTable != null) {
            m_table = ConfigurationUtility.newInnerInstance(this, configuredTable);
        }
    }
    if (m_table != null) {
        if (m_table instanceof AbstractTable) {
            ((AbstractTable) m_table).setContainerInternal(this);
        }
        updateActiveRowsFilter();
        updateCheckedRowsFilter();
        m_table.addTableListener(new TableAdapter() {

            @Override
            public void tableChanged(TableEvent e) {
                switch(e.getType()) {
                    case TableEvent.TYPE_ROWS_SELECTED:
                        {
                            if (!getTable().isCheckable()) {
                                syncTableToValue();
                            }
                            break;
                        }
                    case TableEvent.TYPE_ROWS_CHECKED:
                        {
                            if (getTable().isCheckable()) {
                                syncTableToValue();
                            }
                            break;
                        }
                }
            }
        });
        // default icon
        if (m_table.getDefaultIconId() == null && this.getConfiguredIconId() != null) {
            m_table.setDefaultIconId(this.getConfiguredIconId());
        }
        m_table.setEnabled(isEnabled());
    } else {
        LOG.warn("there is no inner class of type ITable in {}", getClass().getName());
    }
    // lookup call
    Class<? extends ILookupCall<KEY>> lookupCallClass = getConfiguredLookupCall();
    if (lookupCallClass != null) {
        ILookupCall<KEY> call = BEANS.get(lookupCallClass);
        setLookupCall(call);
    }
    // code type
    if (getConfiguredCodeType() != null) {
        setCodeTypeClass(getConfiguredCodeType());
    }
    // local property listener
    addPropertyChangeListener(new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent e) {
            if (m_table == null) {
                return;
            }
            String name = e.getPropertyName();
            if (PROP_ENABLED_COMPUTED.equals(name)) {
                boolean newEnabled = ((Boolean) e.getNewValue()).booleanValue();
                m_table.setEnabled(newEnabled);
            } else if (PROP_FILTER_CHECKED_ROWS_VALUE.equals(name)) {
                updateCheckedRowsFilter();
            } else if (PROP_FILTER_ACTIVE_ROWS_VALUE.equals(name)) {
                updateActiveRowsFilter();
            }
        }
    });
    // add fields
    List<Class<? extends IFormField>> fieldClasses = getConfiguredFields();
    List<IFormField> contributedFields = m_contributionHolder.getContributionsByClass(IFormField.class);
    List<IFormField> fieldList = new ArrayList<IFormField>(fieldClasses.size() + contributedFields.size());
    for (Class<? extends IFormField> fieldClazz : fieldClasses) {
        IFormField f = ConfigurationUtility.newInnerInstance(this, fieldClazz);
        fieldList.add(f);
    }
    fieldList.addAll(contributedFields);
    Collections.sort(fieldList, new OrderedComparator());
    for (IFormField f : fieldList) {
        f.setParentFieldInternal(this);
    }
    m_fields = fieldList;
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeListener(java.beans.PropertyChangeListener) ArrayList(java.util.ArrayList) TableAdapter(org.eclipse.scout.rt.client.ui.basic.table.TableAdapter) IFormField(org.eclipse.scout.rt.client.ui.form.fields.IFormField) AbstractTable(org.eclipse.scout.rt.client.ui.basic.table.AbstractTable) TableEvent(org.eclipse.scout.rt.client.ui.basic.table.TableEvent) OrderedComparator(org.eclipse.scout.rt.platform.OrderedComparator) ITable(org.eclipse.scout.rt.client.ui.basic.table.ITable)

Example 4 with AbstractTable

use of org.eclipse.scout.rt.client.ui.basic.table.AbstractTable in project scout.rt by eclipse.

the class AbstractProposalColumnTest method testLookupRowWithTooLongText2.

@Test
public void testLookupRowWithTooLongText2() throws Exception {
    final AbstractProposalColumn<Long> column = new AbstractProposalColumn<Long>() {

        @Override
        protected boolean getConfiguredEditable() {
            return true;
        }

        @Override
        protected int getConfiguredMaxLength() {
            return 8;
        }
    };
    column.setCodeTypeClass(TestCodeType.class);
    final ITable table = new AbstractTable() {

        @Override
        protected void injectColumnsInternal(OrderedCollection<IColumn<?>> columns) {
            columns.addFirst(column);
        }
    };
    ITableRow row = table.addRow();
    @SuppressWarnings("unchecked") IProposalField<Long> field = (IProposalField<Long>) column.prepareEditInternal(row);
    field.getUIFacade().acceptProposalFromUI("1234567890", false, false);
    column.completeEdit(row, field);
    assertEquals("12345678", column.getValue(row));
}
Also used : AbstractTable(org.eclipse.scout.rt.client.ui.basic.table.AbstractTable) IProposalField(org.eclipse.scout.rt.client.ui.form.fields.smartfield.IProposalField) OrderedCollection(org.eclipse.scout.rt.platform.util.collection.OrderedCollection) ITable(org.eclipse.scout.rt.client.ui.basic.table.ITable) ITableRow(org.eclipse.scout.rt.client.ui.basic.table.ITableRow) Test(org.junit.Test)

Example 5 with AbstractTable

use of org.eclipse.scout.rt.client.ui.basic.table.AbstractTable in project scout.rt by eclipse.

the class AbstractProposalColumnTest method testLookupRowWithTooLongText1.

@Test
public void testLookupRowWithTooLongText1() throws Exception {
    final AbstractProposalColumn<Long> column = new AbstractProposalColumn<Long>() {

        @Override
        protected boolean getConfiguredEditable() {
            return true;
        }

        @Override
        protected int getConfiguredMaxLength() {
            return 32;
        }
    };
    column.setCodeTypeClass(TestCodeType.class);
    final ITable table = new AbstractTable() {

        @Override
        protected void injectColumnsInternal(OrderedCollection<IColumn<?>> columns) {
            columns.addFirst(column);
        }
    };
    ITableRow row = table.addRow();
    @SuppressWarnings("unchecked") IProposalField<Long> field = (IProposalField<Long>) column.prepareEditInternal(row);
    field.getUIFacade().acceptProposalFromUI("1234567890", false, false);
    column.completeEdit(row, field);
    assertEquals("1234567890", column.getValue(row));
}
Also used : AbstractTable(org.eclipse.scout.rt.client.ui.basic.table.AbstractTable) IProposalField(org.eclipse.scout.rt.client.ui.form.fields.smartfield.IProposalField) OrderedCollection(org.eclipse.scout.rt.platform.util.collection.OrderedCollection) ITable(org.eclipse.scout.rt.client.ui.basic.table.ITable) ITableRow(org.eclipse.scout.rt.client.ui.basic.table.ITableRow) Test(org.junit.Test)

Aggregations

AbstractTable (org.eclipse.scout.rt.client.ui.basic.table.AbstractTable)5 ITable (org.eclipse.scout.rt.client.ui.basic.table.ITable)5 ITableRow (org.eclipse.scout.rt.client.ui.basic.table.ITableRow)4 IProposalField (org.eclipse.scout.rt.client.ui.form.fields.smartfield.IProposalField)4 OrderedCollection (org.eclipse.scout.rt.platform.util.collection.OrderedCollection)4 Test (org.junit.Test)4 PropertyChangeEvent (java.beans.PropertyChangeEvent)1 PropertyChangeListener (java.beans.PropertyChangeListener)1 ArrayList (java.util.ArrayList)1 TableAdapter (org.eclipse.scout.rt.client.ui.basic.table.TableAdapter)1 TableEvent (org.eclipse.scout.rt.client.ui.basic.table.TableEvent)1 IFormField (org.eclipse.scout.rt.client.ui.form.fields.IFormField)1 OrderedComparator (org.eclipse.scout.rt.platform.OrderedComparator)1