use of aero.minova.rcp.widgets.LookupComposite 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.widgets.LookupComposite in project aero.minova.rcp by minova-afis.
the class TraverseEnterHandler method execute.
@Execute
public void execute() {
MPart part = partService.getActivePart();
boolean popupOpen = false;
if (part.getObject() instanceof WFCDetailPart) {
MDetail mDetail = ((WFCDetailPart) part.getObject()).getDetail();
if (((DetailAccessor) mDetail.getDetailAccessor()).getSelectedControl() != null) {
// aktuell selektiertes Feld holen
Control focussedControl = ((DetailAccessor) mDetail.getDetailAccessor()).getSelectedControl();
// Ist ein Popup offen?
if (focussedControl instanceof LookupComposite) {
LookupComposite lookup = (LookupComposite) focussedControl;
// Wir holen uns den Status des Popup des Lookup
popupOpen = lookup.popupIsOpen();
}
// nächstes Pflichtfeld suchen und fokussieren
getNextRequired(focussedControl, mDetail, popupOpen);
}
}
// Bei offenem Lookup-Popup wollen wir nicht speichern
if (!popupOpen) {
// ParameterizedCommand des SaveDetailsHandlers erstellen und ausführen
ParameterizedCommand cmd = commandService.createCommand(Constants.AERO_MINOVA_RCP_RCP_COMMAND_SAVEDETAIL, null);
handlerService.executeHandler(cmd);
}
}
use of aero.minova.rcp.widgets.LookupComposite in project aero.minova.rcp by minova-afis.
the class LookupValueAccessor method updatePossibleValues.
public void updatePossibleValues() {
LookupComposite up = ((LookupComposite) control);
CompletableFuture<List<LookupValue>> listLookup = dataService.listLookup((MLookupField) field, true);
try {
List<LookupValue> l = listLookup.get();
up.getContentProvider().setValuesOnly(l);
if (l.size() == 1) {
field.setValue(l.get(0), true);
}
} catch (InterruptedException | ExecutionException e) {
}
}
use of aero.minova.rcp.widgets.LookupComposite in project aero.minova.rcp by minova-afis.
the class LookupValueAccessor method updateControlFromValue.
/*
* Wenn wir einen Wert anfragen sollten wir immer nur einen erhalten. Die Ausnahme funktioniert nur bei einer Anfrage über KeyText. Dann wird der 1.
* genommen.
*/
@Override
protected void updateControlFromValue(Control control, Value value) {
// we see this control disposed in our unit tests
if (control.isDisposed()) {
return;
}
if (LOG) {
try {
System.out.println("updateControlFromValue " + value.toString());
} catch (NullPointerException npe) {
System.out.println("updateControlFromValue null");
}
}
if (value == null) {
((LookupComposite) control).getDescription().setText("");
((LookupComposite) control).setText("");
if (((LookupComposite) control).getEditable()) {
((LookupComposite) control).setMessage("...");
if (LOG) {
System.out.println("Lookup " + ((LookupComposite) control).getLabel().getText() + " ist null");
}
}
return;
}
if (value instanceof LookupValue) {
LookupValue lv = (LookupValue) value;
((LookupComposite) control).getContentProvider().translateLookup(lv);
((LookupComposite) control).getDescription().setText(lv.description);
((LookupComposite) control).setText(lv.keyText);
((LookupComposite) control).setMessage("...");
if (LOG) {
System.out.println("Lookup " + ((LookupComposite) control).getLabel().getText() + " ist leer");
}
} else {
Integer keyLong = null;
String keyText = null;
if (value.getType() == DataType.INTEGER) {
keyLong = value.getIntegerValue();
} else {
keyText = value.getStringValue();
}
CompletableFuture<List<LookupValue>> resolveLookup = dataService.resolveLookup((MLookupField) field, true, keyLong, keyText);
resolveLookup.thenAccept(llv -> sync.asyncExec(() -> {
Value v = llv.isEmpty() ? null : llv.get(0);
field.setValue(v, false);
updateControlFromValue(control, v);
}));
}
}
use of aero.minova.rcp.widgets.LookupComposite in project aero.minova.rcp by minova-afis.
the class LookupField method create.
public static Control create(Composite composite, MField field, int row, int column, Locale locale, MPerspective perspective) {
Label label = FieldLabel.create(composite, field);
IEclipseContext context = perspective.getContext();
LookupComposite lookupControl = new LookupComposite(composite, SWT.BORDER | SWT.LEFT);
lookupControl.setMessage("...");
lookupControl.setLabel(label);
// In Context injected, damit TranslationService genutzt werden kann
ContextInjectionFactory.inject(lookupControl, context);
LookupContentProvider contentProvider = new LookupContentProvider(field.getLookupTable());
contentProvider.setLookup(lookupControl);
lookupControl.setContentProvider(contentProvider);
// In Context injected, damit TranslationService genutzt werden kann
ContextInjectionFactory.inject(contentProvider, context);
Label descriptionLabel = LabelFactory.newLabel(SWT.LEFT).create(composite);
FormData lookupFormData = new FormData();
FormData labelFormData = new FormData();
FormData descriptionLabelFormData = new FormData();
LookupValueAccessor lookupValueAccessor = new LookupValueAccessor(field, lookupControl);
ContextInjectionFactory.inject(lookupValueAccessor, context);
field.setValueAccessor(lookupValueAccessor);
lookupControl.setData(Constants.CONTROL_FIELD, field);
lookupFormData.top = new FormAttachment(composite, FieldUtil.MARGIN_TOP + row * FieldUtil.COLUMN_HEIGHT);
lookupFormData.left = new FormAttachment((column == 0) ? 25 : 75);
lookupFormData.width = FieldUtil.TEXT_WIDTH;
// Lookup-Felder sollen immer genau eine Zeile hoch sein
CssData cssData = new CssData(CssType.TEXT_FIELD, column, row, field.getNumberColumnsSpanned(), 1, field.isFillToRight() || field.isFillHorizontal());
lookupControl.setData(CssData.CSSDATA_KEY, cssData);
labelFormData.top = new FormAttachment(lookupControl, 0, SWT.CENTER);
labelFormData.right = new FormAttachment(lookupControl, FieldUtil.MARGIN_LEFT * -1, SWT.LEFT);
labelFormData.width = FieldUtil.COLUMN_WIDTH;
descriptionLabelFormData.top = new FormAttachment(lookupControl, 0, SWT.CENTER);
// etwas Abstand zw. LookupWidget und Text
descriptionLabelFormData.left = new FormAttachment(lookupControl, FieldUtil.UNIT_GAP, SWT.RIGHT);
if (field.getNumberColumnsSpanned() == 4) {
descriptionLabelFormData.width = FieldUtil.MARGIN_LEFT * 2 + FieldUtil.COLUMN_WIDTH * 2;
} else {
descriptionLabelFormData.width = 0;
}
if (field.getNumberRowsSpanned() > 1) {
// ZB für Contact Lookups
descriptionLabelFormData.height = field.getNumberRowsSpanned() * FieldUtil.COLUMN_HEIGHT;
descriptionLabelFormData.top = new FormAttachment(lookupControl, 0, SWT.TOP);
}
label.setData(AERO_MINOVA_RCP_LOOKUP, lookupControl);
FieldLabel.layout(label, lookupControl, row, column, field.getNumberRowsSpanned());
lookupControl.setLayoutData(lookupFormData);
lookupControl.setDescription(descriptionLabel);
descriptionLabel.setLayoutData(descriptionLabelFormData);
descriptionLabel.setData(CSSSWTConstants.CSS_CLASS_NAME_KEY, "DescriptionLabel");
lookupControl.addTraverseListener(e -> {
Text text = ((Text) e.getSource());
LookupComposite t = (LookupComposite) text.getParent();
switch(e.detail) {
case SWT.TRAVERSE_TAB_PREVIOUS:
case SWT.TRAVERSE_TAB_NEXT:
case SWT.TRAVERSE_RETURN:
t.fillSelectedValue();
e.doit = true;
break;
}
});
return lookupControl;
}
Aggregations