Search in sources :

Example 1 with MField

use of aero.minova.rcp.model.form.MField in project aero.minova.rcp by minova-afis.

the class WFCDetailPart method createMField.

public MField createMField(Field field, MSection mSection, String suffix) {
    String fieldName = suffix + field.getName();
    try {
        MField f = ModelToViewModel.convert(field, locale);
        f.addValueChangeListener(this);
        f.setName(fieldName);
        getDetail().putField(f);
        if (field.isVisible()) {
            f.setMSection(mSection);
            mSection.addTabField(f);
        }
        return f;
    } catch (NullPointerException e) {
        showErrorMissingSQLIndex(field, fieldName, e);
    }
    return null;
}
Also used : MField(aero.minova.rcp.model.form.MField)

Example 2 with MField

use of aero.minova.rcp.model.form.MField in project aero.minova.rcp by minova-afis.

the class TabUtil method getTabListForSectionComposite.

/**
 * Gibt einen Array mit den Controls für die TabListe des Composites der Section zurück.
 *
 * @param mSection
 *            der Section
 * @param composite
 *            der Section
 * @return Array mit Controls
 */
public static Control[] getTabListForSectionComposite(MSection mSection, Composite composite) {
    List<Control> tabList = new ArrayList<>();
    Control[] compositeChilds = composite.getChildren();
    for (Control control : compositeChilds) {
        if (control instanceof LookupComposite || control instanceof TextAssist || control instanceof Text) {
            MField field = (MField) control.getData(Constants.CONTROL_FIELD);
            if (!field.isReadOnly()) {
                tabList.add(control);
            }
        } else if (control instanceof NatTable) {
            tabList.add(control);
        }
    }
    return tabList.toArray(new Control[0]);
}
Also used : Control(org.eclipse.swt.widgets.Control) LookupComposite(aero.minova.rcp.widgets.LookupComposite) ArrayList(java.util.ArrayList) TextAssist(org.eclipse.nebula.widgets.opal.textassist.TextAssist) Text(org.eclipse.swt.widgets.Text) NatTable(org.eclipse.nebula.widgets.nattable.NatTable) MField(aero.minova.rcp.model.form.MField)

Example 3 with MField

use of aero.minova.rcp.model.form.MField in project aero.minova.rcp by minova-afis.

the class WFCDetailCASRequestsUtil method createReadTableFromForm.

/**
 * Die Primary-Keys werden aus der übergebenen Tabelle gelesen. Nur die erste Zeile wird betrachtet
 *
 * @param tableForm
 * @param keyTable
 * @return
 */
private Table createReadTableFromForm(Form tableForm, Table keyTable) {
    Map<String, String> keysToValue = mDetail.getOptionPageKeys(tableForm.getDetail().getProcedureSuffix());
    // Hauptmaske oder keine key-zu-value Map in xbs gegeben
    boolean useColumnName = tableForm.equals(form) || keysToValue == null;
    RowBuilder builder = RowBuilder.newRow();
    Map<String, Value> newKeys = new HashMap<>();
    Row row = keyTable.getRows().get(0);
    for (Field f : dataFormService.getFieldsFromForm(tableForm)) {
        int indexInRow = -1;
        // Spalte für Feld finden
        if (useColumnName) {
            indexInRow = keyTable.getColumnIndex(f.getName());
        } else if (keysToValue.containsKey(f.getName())) {
            MField correspondingField = mDetail.getField(keysToValue.get(f.getName()));
            indexInRow = keyTable.getColumnIndex(correspondingField.getName());
        }
        // Wert in Zeile setzten
        if (indexInRow >= 0 && "primary".equals(f.getKeyType()) && row.getValue(indexInRow) != null) {
            builder.withValue(row.getValue(indexInRow).getValue());
            newKeys.put(f.getName(), row.getValue(indexInRow));
        } else {
            builder.withValue(null);
        }
    }
    // Keys nur für die Hauptmaske setzen
    if (!newKeys.equals(getKeys()) && tableForm.equals(form)) {
        setKeys(newKeys);
    }
    Table rowIndexTable = dataFormService.getTableFromFormDetail(tableForm, Constants.READ_REQUEST);
    Row r = builder.create();
    rowIndexTable.addRow(r);
    return rowIndexTable;
}
Also used : MLookupField(aero.minova.rcp.model.form.MLookupField) MBooleanField(aero.minova.rcp.model.form.MBooleanField) MField(aero.minova.rcp.model.form.MField) Field(aero.minova.rcp.form.model.xsd.Field) MParamStringField(aero.minova.rcp.model.form.MParamStringField) Table(aero.minova.rcp.model.Table) HashMap(java.util.HashMap) Value(aero.minova.rcp.model.Value) ReferenceValue(aero.minova.rcp.model.ReferenceValue) RowBuilder(aero.minova.rcp.model.builder.RowBuilder) Row(aero.minova.rcp.model.Row) MField(aero.minova.rcp.model.form.MField)

Example 4 with MField

use of aero.minova.rcp.model.form.MField in project aero.minova.rcp by minova-afis.

the class WFCDetailCASRequestsUtil method callProcedure.

/*
	 * Die übergebene Procedur wird aufgerufen. Als Parameter werden die Werte des aktuell geladenen Datensatzes übergeben
	 * @param p
	 */
public void callProcedure(Procedure p) {
    Table t = new Table();
    t.setName(p.getName());
    Row r = new Row();
    for (EventParam ep : p.getParam()) {
        MField f = mDetail.getField(ep.getFieldName());
        t.addColumn(new aero.minova.rcp.model.Column(ep.getFieldName(), f.getDataType(), OutputType.valueOf(ep.getType())));
        r.addValue(f.getValue());
    }
    t.addRow(r);
    dataService.callProcedureAsync(t);
}
Also used : EventParam(aero.minova.rcp.form.model.xsd.EventParam) Table(aero.minova.rcp.model.Table) Row(aero.minova.rcp.model.Row) MField(aero.minova.rcp.model.form.MField)

Example 5 with MField

use of aero.minova.rcp.model.form.MField in project aero.minova.rcp by minova-afis.

the class WFCDetailCASRequestsUtil method redrawSection.

/**
 * Zeichnet alle Felder der MSection neu. Falls Param-String Felder enthalten sind werden die aktuellen MFields dieser gezeichnet, alte Felder werden
 * entfernt
 *
 * @param sectionID
 */
public void redrawSection(MSection mSection) {
    // SubFelder von Param-String Feldern entfernen
    List<MField> toRemove = new ArrayList<>();
    for (MField mField : mDetail.getFields()) {
        if (mField instanceof MParamStringField && mField.getmSection().equals(mSection)) {
            toRemove.addAll(((MParamStringField) mField).getSubMFields());
            ((MParamStringField) mField).clearSubMFields();
        }
    }
    mSection.getTabList().removeAll(toRemove);
    MinovaSection section = ((SectionAccessor) mSection.getSectionAccessor()).getSection();
    mDetail.getFields().removeAll(toRemove);
    List<MField> visibleMFields = new ArrayList<>();
    List<MField> toTraverse = new ArrayList<>();
    List<MParamStringField> paramStringFields = new ArrayList<>();
    toTraverse.addAll(mSection.getTabList());
    for (MField f : toTraverse) {
        visibleMFields.add(f);
        if (f instanceof MParamStringField) {
            String name = f.getName();
            String suffix = name.contains("\\.") ? name.substring(name.lastIndexOf("\\."), name.length()) : "";
            MParamStringField mParamString = (MParamStringField) f;
            paramStringFields.add(mParamString);
            for (Field subField : mParamString.getSubFields()) {
                MField subMField = wfcDetailPart.createMField(subField, mSection, suffix);
                visibleMFields.add(subMField);
                mParamString.addSubMField(subMField);
            }
        }
    }
    // Ganzen Body/ Client Area der Section entfernen
    section.getClient().dispose();
    // Neuen Body erstellen
    Composite clientComposite = wfcDetailPart.getFormToolkit().createComposite(section);
    clientComposite.setLayout(new FormLayout());
    wfcDetailPart.getFormToolkit().paintBordersFor(clientComposite);
    section.setClient(clientComposite);
    // Felder zeichnen
    wfcDetailPart.createUIFields(visibleMFields, clientComposite);
    // Sortieren der Fields nach Tab-Index.
    TabUtil.sortTabList(mSection);
    // Setzen der TabListe für die einzelnen Sections.
    clientComposite.setTabList(TabUtil.getTabListForSectionComposite(mSection, clientComposite));
    // Setzen der TabListe der Sections im Part.
    clientComposite.getParent().setTabList(TabUtil.getTabListForSection(clientComposite.getParent(), mSection, wfcDetailPart.isSelectAllControls()));
    // Zwischengespeicherten Wert wieder eintragen
    paramStringFields.stream().forEach(f -> f.setValue(new Value(f.getCacheValue().getStringValue() + " "), false));
    section.requestLayout();
    section.style();
    TranslateUtil.translate(clientComposite, translationService, wfcDetailPart.getLocale());
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) MLookupField(aero.minova.rcp.model.form.MLookupField) MBooleanField(aero.minova.rcp.model.form.MBooleanField) MField(aero.minova.rcp.model.form.MField) Field(aero.minova.rcp.form.model.xsd.Field) MParamStringField(aero.minova.rcp.model.form.MParamStringField) MParamStringField(aero.minova.rcp.model.form.MParamStringField) Composite(org.eclipse.swt.widgets.Composite) ArrayList(java.util.ArrayList) Value(aero.minova.rcp.model.Value) ReferenceValue(aero.minova.rcp.model.ReferenceValue) SectionAccessor(aero.minova.rcp.rcp.accessor.SectionAccessor) MinovaSection(aero.minova.rcp.css.widgets.MinovaSection) MField(aero.minova.rcp.model.form.MField)

Aggregations

MField (aero.minova.rcp.model.form.MField)33 Row (aero.minova.rcp.model.Row)8 Table (aero.minova.rcp.model.Table)8 ArrayList (java.util.ArrayList)8 Value (aero.minova.rcp.model.Value)7 MBooleanField (aero.minova.rcp.model.form.MBooleanField)7 MLookupField (aero.minova.rcp.model.form.MLookupField)7 CanExecute (org.eclipse.e4.core.di.annotations.CanExecute)6 Field (aero.minova.rcp.form.model.xsd.Field)5 LookupValue (aero.minova.rcp.model.LookupValue)5 MGrid (aero.minova.rcp.model.form.MGrid)5 MParamStringField (aero.minova.rcp.model.form.MParamStringField)5 ReferenceValue (aero.minova.rcp.model.ReferenceValue)4 ApplicationPreferences (aero.minova.rcp.preferences.ApplicationPreferences)4 WFCDetailPart (aero.minova.rcp.rcp.parts.WFCDetailPart)4 Entry (aero.minova.rcp.form.setup.xbs.Map.Entry)3 Node (aero.minova.rcp.form.setup.xbs.Node)3 Preferences (aero.minova.rcp.form.setup.xbs.Preferences)3 Column (aero.minova.rcp.model.Column)3 MDateTimeField (aero.minova.rcp.model.form.MDateTimeField)3