Search in sources :

Example 81 with ITable

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

the class JsonTableTest method testSelectionEvent.

/**
 * Tests whether the model row gets correctly selected
 */
@Test
public void testSelectionEvent() throws JSONException {
    Table table = createTableFixture(5);
    assertNull(table.getSelectedRow());
    ITableRow row = table.getRow(2);
    JsonTable<ITable> jsonTable = UiSessionTestUtility.newJsonAdapter(m_uiSession, table, null);
    jsonTable.toJson();
    // ----------
    JsonEvent event = createJsonRowsSelectedEvent(jsonTable.getOrCreateRowId(row));
    jsonTable.handleUiEvent(event);
    assertTrue(row.isSelected());
}
Also used : Table(org.eclipse.scout.rt.ui.html.json.table.fixtures.Table) ITable(org.eclipse.scout.rt.client.ui.basic.table.ITable) ListBoxTable(org.eclipse.scout.rt.ui.html.json.table.fixtures.ListBoxTable) JsonEvent(org.eclipse.scout.rt.ui.html.json.JsonEvent) 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 82 with ITable

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

the class AbstractTableField method createTable.

@SuppressWarnings("unchecked")
protected T createTable() {
    List<ITable> contributedFields = m_contributionHolder.getContributionsByClass(ITable.class);
    ITable result = CollectionUtility.firstElement(contributedFields);
    if (result != null) {
        return (T) result;
    }
    Class<? extends ITable> configuredTable = getConfiguredTable();
    if (configuredTable != null) {
        return (T) ConfigurationUtility.newInnerInstance(this, configuredTable);
    }
    return null;
}
Also used : ITable(org.eclipse.scout.rt.client.ui.basic.table.ITable)

Example 83 with ITable

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

the class AbstractTableField method validateContent.

@Override
public IValidateContentDescriptor validateContent() {
    IValidateContentDescriptor desc = super.validateContent();
    // super check
    if (desc != null) {
        return desc;
    }
    ITable table = getTable();
    // check cells
    ValidateTableFieldDescriptor tableDesc = null;
    TreeSet<String> columnNames = new TreeSet<String>();
    if (table != null) {
        for (ITableRow row : table.getRows()) {
            for (IColumn col : table.getColumns()) {
                if (!col.isContentValid(row)) {
                    if (tableDesc == null) {
                        tableDesc = new ValidateTableFieldDescriptor(this, row, col);
                    }
                    columnNames.add(getColumnName(col));
                }
            }
        }
        table.ensureInvalidColumnsVisible();
    }
    if (tableDesc != null) {
        tableDesc.setDisplayText(TEXTS.get("TableName") + " " + getLabel() + ": " + CollectionUtility.format(columnNames));
    }
    return tableDesc;
}
Also used : IColumn(org.eclipse.scout.rt.client.ui.basic.table.columns.IColumn) TreeSet(java.util.TreeSet) IValidateContentDescriptor(org.eclipse.scout.rt.client.ui.form.fields.IValidateContentDescriptor) ITable(org.eclipse.scout.rt.client.ui.basic.table.ITable) ITableRow(org.eclipse.scout.rt.client.ui.basic.table.ITableRow)

Example 84 with ITable

use of org.eclipse.scout.rt.client.ui.basic.table.ITable 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 85 with ITable

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

the class JsonOutline method attachDetailTable.

protected void attachDetailTable(IPage page) {
    ITable table = page.getTable(false);
    if (table == null) {
        return;
    }
    table.setProperty(JsonOutlineTable.PROP_PAGE, page);
    IJsonAdapter<?> detailTableAdapter = attachGlobalAdapter(table);
    m_jsonDetailTables.add(detailTableAdapter);
}
Also used : ITable(org.eclipse.scout.rt.client.ui.basic.table.ITable)

Aggregations

ITable (org.eclipse.scout.rt.client.ui.basic.table.ITable)89 Test (org.junit.Test)64 ITableRow (org.eclipse.scout.rt.client.ui.basic.table.ITableRow)45 TableWith3Cols (org.eclipse.scout.rt.ui.html.json.table.fixtures.TableWith3Cols)28 JSONObject (org.json.JSONObject)23 JsonEvent (org.eclipse.scout.rt.ui.html.json.JsonEvent)16 JSONArray (org.json.JSONArray)12 ITableRowFilter (org.eclipse.scout.rt.client.ui.basic.table.ITableRowFilter)11 Table (org.eclipse.scout.rt.ui.html.json.table.fixtures.Table)10 ArrayList (java.util.ArrayList)9 ListBoxTable (org.eclipse.scout.rt.ui.html.json.table.fixtures.ListBoxTable)8 IMenu (org.eclipse.scout.rt.client.ui.action.menu.IMenu)6 AbstractTable (org.eclipse.scout.rt.client.ui.basic.table.AbstractTable)6 ITableField (org.eclipse.scout.rt.client.ui.form.fields.tablefield.ITableField)5 TableWithLongColumn (org.eclipse.scout.rt.ui.html.json.table.fixtures.TableWithLongColumn)5 IColumn (org.eclipse.scout.rt.client.ui.basic.table.columns.IColumn)4 IOutline (org.eclipse.scout.rt.client.ui.desktop.outline.IOutline)4 IPageWithTable (org.eclipse.scout.rt.client.ui.desktop.outline.pages.IPageWithTable)4 IProposalField (org.eclipse.scout.rt.client.ui.form.fields.smartfield.IProposalField)4 OrderedCollection (org.eclipse.scout.rt.platform.util.collection.OrderedCollection)4