Search in sources :

Example 1 with LookupComposite

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]);
}
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 2 with LookupComposite

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);
    }
}
Also used : MDetail(aero.minova.rcp.model.form.MDetail) MPart(org.eclipse.e4.ui.model.application.ui.basic.MPart) Control(org.eclipse.swt.widgets.Control) DetailAccessor(aero.minova.rcp.rcp.accessor.DetailAccessor) LookupComposite(aero.minova.rcp.widgets.LookupComposite) WFCDetailPart(aero.minova.rcp.rcp.parts.WFCDetailPart) ParameterizedCommand(org.eclipse.core.commands.ParameterizedCommand) Execute(org.eclipse.e4.core.di.annotations.Execute)

Example 3 with LookupComposite

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) {
    }
}
Also used : LookupComposite(aero.minova.rcp.widgets.LookupComposite) List(java.util.List) ExecutionException(java.util.concurrent.ExecutionException) LookupValue(aero.minova.rcp.model.LookupValue)

Example 4 with LookupComposite

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);
        }));
    }
}
Also used : LookupComposite(aero.minova.rcp.widgets.LookupComposite) Value(aero.minova.rcp.model.Value) LookupValue(aero.minova.rcp.model.LookupValue) List(java.util.List) LookupValue(aero.minova.rcp.model.LookupValue)

Example 5 with LookupComposite

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;
}
Also used : FormData(org.eclipse.swt.layout.FormData) LookupValueAccessor(aero.minova.rcp.rcp.accessor.LookupValueAccessor) LookupComposite(aero.minova.rcp.widgets.LookupComposite) Label(org.eclipse.swt.widgets.Label) IEclipseContext(org.eclipse.e4.core.contexts.IEclipseContext) Text(org.eclipse.swt.widgets.Text) FormAttachment(org.eclipse.swt.layout.FormAttachment) CssData(aero.minova.rcp.css.CssData) LookupContentProvider(aero.minova.rcp.widgets.LookupContentProvider)

Aggregations

LookupComposite (aero.minova.rcp.widgets.LookupComposite)7 MField (aero.minova.rcp.model.form.MField)3 Control (org.eclipse.swt.widgets.Control)3 LookupValue (aero.minova.rcp.model.LookupValue)2 DetailAccessor (aero.minova.rcp.rcp.accessor.DetailAccessor)2 List (java.util.List)2 NatTable (org.eclipse.nebula.widgets.nattable.NatTable)2 TextAssist (org.eclipse.nebula.widgets.opal.textassist.TextAssist)2 Text (org.eclipse.swt.widgets.Text)2 CssData (aero.minova.rcp.css.CssData)1 Value (aero.minova.rcp.model.Value)1 MDetail (aero.minova.rcp.model.form.MDetail)1 MSection (aero.minova.rcp.model.form.MSection)1 ApplicationPreferences (aero.minova.rcp.preferences.ApplicationPreferences)1 LookupValueAccessor (aero.minova.rcp.rcp.accessor.LookupValueAccessor)1 SectionAccessor (aero.minova.rcp.rcp.accessor.SectionAccessor)1 WFCDetailPart (aero.minova.rcp.rcp.parts.WFCDetailPart)1 LookupContentProvider (aero.minova.rcp.widgets.LookupContentProvider)1 ArrayList (java.util.ArrayList)1 ExecutionException (java.util.concurrent.ExecutionException)1