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;
}
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]);
}
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;
}
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);
}
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());
}
Aggregations