Search in sources :

Example 1 with IFormField

use of org.eclipse.scout.rt.client.ui.form.fields.IFormField in project scout.rt by eclipse.

the class JsonTable method handleUiPrepareCellEdit.

protected void handleUiPrepareCellEdit(JsonEvent event) {
    ITableRow row = extractTableRow(event.getData());
    if (row == null) {
        LOG.info("Requested table-row doesn't exist anymore. Skip prepareCellEdit event");
        return;
    }
    IColumn column = extractColumn(event.getData());
    IFormField field = getModel().getUIFacade().prepareCellEditFromUI(row, column);
    if (field == null) {
        // caused the initially editable cell to be become non-editable.
        return;
    }
    IJsonAdapter<?> jsonField = attachAdapter(field);
    LOG.debug("Created new field adapter for cell editing. Adapter: {}", jsonField);
    JSONObject json = new JSONObject();
    json.put("columnId", event.getData().getString(PROP_COLUMN_ID));
    json.put("rowId", event.getData().getString(PROP_ROW_ID));
    json.put("fieldId", jsonField.getId());
    addActionEvent(EVENT_START_CELL_EDIT, json).protect();
}
Also used : IFormField(org.eclipse.scout.rt.client.ui.form.fields.IFormField) JSONObject(org.json.JSONObject) IColumn(org.eclipse.scout.rt.client.ui.basic.table.columns.IColumn) ITableRow(org.eclipse.scout.rt.client.ui.basic.table.ITableRow)

Example 2 with IFormField

use of org.eclipse.scout.rt.client.ui.form.fields.IFormField in project scout.rt by eclipse.

the class AbstractColumn method execPrepareEdit.

/**
 * Prepares the editing of a cell in the table.
 * <p>
 * Cell editing is canceled (normally by typing escape) or saved (normally by clicking another cell, typing enter).
 * <p>
 * When saved, the method {@link #completeEdit(ITableRow, IFormField)} /
 * {@link #interceptCompleteEdit(ITableRow, IFormField)} is called on this column.
 * <p>
 * Subclasses can override this method. The default returns an appropriate field based on the column data type.
 * <p>
 * The mapping from the cell value to the field value is achieved using {@link #cellToEditField(Object, String,
 * IMultiStatus, IFormField))}
 *
 * @param row
 *          on which editing occurs
 * @return a field for editing.
 */
@ConfigOperation
@Order(61)
protected IFormField execPrepareEdit(ITableRow row) {
    IFormField f = prepareEditInternal(row);
    if (f != null) {
        f.setLabelVisible(false);
        cellValueToEditor(row, f);
        f.markSaved();
    }
    return f;
}
Also used : IFormField(org.eclipse.scout.rt.client.ui.form.fields.IFormField) Order(org.eclipse.scout.rt.platform.Order) ConfigOperation(org.eclipse.scout.rt.platform.annotations.ConfigOperation)

Example 3 with IFormField

use of org.eclipse.scout.rt.client.ui.form.fields.IFormField in project scout.rt by eclipse.

the class ColumnMandatoryTest method testFieldNotMandatoryInColumn.

/**
 * Tests, if a field is not mandatory in a non-mandatory column
 */
@Test
public void testFieldNotMandatoryInColumn() {
    MandatoryTestTable testTable = new MandatoryTestTable();
    testTable.addRowByArray(getTestRow());
    IColumn col = testTable.getNonMandatoryTestColumn();
    IFormField field = col.prepareEdit(testTable.getRow(0));
    assertFalse(col.isMandatory());
    assertFalse(field.isMandatory());
}
Also used : IFormField(org.eclipse.scout.rt.client.ui.form.fields.IFormField) IColumn(org.eclipse.scout.rt.client.ui.basic.table.columns.IColumn) Test(org.junit.Test)

Example 4 with IFormField

use of org.eclipse.scout.rt.client.ui.form.fields.IFormField in project scout.rt by eclipse.

the class ColumnMandatoryTest method testMandatoryErrorIfNoValue.

/**
 * Tests, if a field is mandatory by setting value
 */
@Test
public void testMandatoryErrorIfNoValue() {
    MandatoryTestTable testTable = new MandatoryTestTable();
    testTable.addRowByArray(getTestRow());
    IColumn mandatoryCol = testTable.getMandatoryTestColumn();
    IFormField field = mandatoryCol.prepareEdit(testTable.getRow(0));
    assertTrue(mandatoryCol.isMandatory());
    assertTrue(field.isMandatory());
    assertTrue(field.isContentValid());
}
Also used : IFormField(org.eclipse.scout.rt.client.ui.form.fields.IFormField) IColumn(org.eclipse.scout.rt.client.ui.basic.table.columns.IColumn) Test(org.junit.Test)

Example 5 with IFormField

use of org.eclipse.scout.rt.client.ui.form.fields.IFormField in project scout.rt by eclipse.

the class RadioButtonGroupGrid method validate.

@Override
public void validate(ICompositeField compositeField) {
    // reset
    m_group = compositeField;
    m_gridColumns = 0;
    m_gridRows = 0;
    ArrayList<IFormField> list = new ArrayList<IFormField>();
    // filter
    for (IFormField f : m_group.getFields()) {
        if (f.isVisible()) {
            list.add(f);
        } else {
            GridData data = GridDataBuilder.createFromHints(f, 1);
            f.setGridDataInternal(data);
        }
    }
    m_fields = list.toArray(new IFormField[list.size()]);
    applyGridData();
}
Also used : IFormField(org.eclipse.scout.rt.client.ui.form.fields.IFormField) ArrayList(java.util.ArrayList) GridData(org.eclipse.scout.rt.client.ui.form.fields.GridData)

Aggregations

IFormField (org.eclipse.scout.rt.client.ui.form.fields.IFormField)60 Test (org.junit.Test)19 ArrayList (java.util.ArrayList)13 GridData (org.eclipse.scout.rt.client.ui.form.fields.GridData)12 IButton (org.eclipse.scout.rt.client.ui.form.fields.button.IButton)5 PlatformError (org.eclipse.scout.rt.platform.exception.PlatformError)5 PropertyChangeEvent (java.beans.PropertyChangeEvent)4 PropertyChangeListener (java.beans.PropertyChangeListener)4 HashMap (java.util.HashMap)4 HashSet (java.util.HashSet)4 IColumn (org.eclipse.scout.rt.client.ui.basic.table.columns.IColumn)4 IGroupBox (org.eclipse.scout.rt.client.ui.form.fields.groupbox.IGroupBox)4 IExtensibleObject (org.eclipse.scout.rt.shared.extension.IExtensibleObject)4 Map (java.util.Map)3 PlatformExceptionTranslator (org.eclipse.scout.rt.platform.exception.PlatformExceptionTranslator)3 LinkedList (java.util.LinkedList)2 ITable (org.eclipse.scout.rt.client.ui.basic.table.ITable)2 ICompositeField (org.eclipse.scout.rt.client.ui.form.fields.ICompositeField)2 IValueField (org.eclipse.scout.rt.client.ui.form.fields.IValueField)2 FindFieldByFormDataIdVisitor (org.eclipse.scout.rt.client.ui.form.internal.FindFieldByFormDataIdVisitor)2