Search in sources :

Example 11 with IFormField

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

the class TabBoxGrid method validate.

@Override
public void validate(ITabBox tabBox) {
    // reset
    m_gridColumns = 0;
    m_gridRows = 0;
    ArrayList<IFormField> list = new ArrayList<IFormField>();
    // filter
    for (IFormField f : tabBox.getGroupBoxes()) {
        if (f.isVisible()) {
            list.add(f);
        } else {
            GridData data = GridDataBuilder.createFromHints(f, 1);
            f.setGridDataInternal(data);
        }
    }
    m_fields = list.toArray(new IFormField[list.size()]);
    layoutStatic();
}
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)

Example 12 with IFormField

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

the class SplitBoxGrid method validate.

@Override
public void validate(ISplitBox splitBox) {
    // reset
    m_gridColumns = 2;
    m_gridRows = 1;
    ArrayList<IFormField> list = new ArrayList<IFormField>();
    // filter
    for (IFormField f : splitBox.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()]);
    layoutStatic();
}
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)

Example 13 with IFormField

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

the class MoveFormFieldsHandler method moveFields.

public void moveFields() {
    P_FormFieldVisitor visitor = new P_FormFieldVisitor();
    m_form.visitFields(visitor);
    if (m_moveDescriptors.isEmpty()) {
        return;
    }
    StringBuilder sb = new StringBuilder();
    for (MoveDescriptor<IFormField> moveItem : m_moveDescriptors) {
        IFormField field = moveItem.getModel();
        ICompositeField oldContainer = field.getParentField();
        ICompositeField newContainer = findContainer(oldContainer, moveItem.getNewContainerIdentifer(), null);
        if (newContainer != null) {
            Double newOrder = moveItem.getNewOrder();
            if (newOrder != null) {
                field.setOrder(newOrder);
            }
            try {
                field.setFieldChanging(true);
                oldContainer.moveFieldTo(field, newContainer);
            // field grid is not rebuilt for performance reasons and because this handler is intended to be used during initConfig of a form.
            } finally {
                field.setFieldChanging(false);
            }
        } else {
            if (sb.length() == 0) {
                sb.append("Invalid field move commands:");
            }
            sb.append("  \nField '").append(field).append("' cannot be moved into container '").append(newContainer).append("'");
        }
    }
    if (sb.length() > 0) {
        throw new IllegalArgumentException(sb.toString());
    }
}
Also used : IFormField(org.eclipse.scout.rt.client.ui.form.fields.IFormField) ICompositeField(org.eclipse.scout.rt.client.ui.form.fields.ICompositeField)

Example 14 with IFormField

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

the class AbstractForm method doCancel.

@Override
public void doCancel() {
    if (!isBlockingInternal()) {
        return;
    }
    m_closeType = IButton.SYSTEM_TYPE_CANCEL;
    try {
        // ensure all fields have the right save-needed-state
        checkSaveNeeded();
        // find any fields that needs save
        P_AbstractCollectingFieldVisitor<IFormField> collector = new P_AbstractCollectingFieldVisitor<IFormField>() {

            @Override
            public boolean visitField(IFormField field, int level, int fieldIndex) {
                if (field.isSaveNeeded()) {
                    collect(field);
                    return false;
                } else {
                    return true;
                }
            }
        };
        visitFields(collector);
        if (collector.getCollectionCount() > 0 && isAskIfNeedSave()) {
            int result = MessageBoxes.createYesNoCancel().withDisplayParent(this).withHeader(getCancelVerificationText()).withSeverity(IStatus.INFO).show();
            if (result == IMessageBox.YES_OPTION) {
                doOk();
                return;
            } else if (result == IMessageBox.NO_OPTION) {
                doClose();
                return;
            } else {
                VetoException e = new VetoException(TEXTS.get("UserCancelledOperation"));
                e.consume();
                throw e;
            }
        }
        discardStateInternal();
        doFinally();
        disposeFormInternal();
    } catch (RuntimeException | PlatformError e) {
        m_closeType = IButton.SYSTEM_TYPE_NONE;
        throw BEANS.get(PlatformExceptionTranslator.class).translate(e).withContextInfo("form", getClass().getName());
    }
}
Also used : VetoException(org.eclipse.scout.rt.platform.exception.VetoException) IFormField(org.eclipse.scout.rt.client.ui.form.fields.IFormField) PlatformError(org.eclipse.scout.rt.platform.exception.PlatformError) PlatformExceptionTranslator(org.eclipse.scout.rt.platform.exception.PlatformExceptionTranslator)

Example 15 with IFormField

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

the class AbstractForm method startWizardStep.

@Override
public void startWizardStep(IWizardStep wizardStep, Class<? extends IFormHandler> handlerType) {
    if (handlerType != null) {
        IFormHandler formHandler = ConfigurationUtility.newInnerInstance(this, handlerType);
        setHandler(formHandler);
    }
    m_wizardStep = wizardStep;
    setShowOnStart(false);
    setAskIfNeedSave(false);
    final String systemButtonHiddenInWizard = "systemButtonHiddenInWizard";
    // hide top level process buttons with a system type
    for (IFormField f : getRootGroupBox().getFields()) {
        if (f instanceof IButton) {
            IButton b = (IButton) f;
            if (b.getSystemType() != IButton.SYSTEM_TYPE_NONE) {
                // hide
                b.setVisible(false, systemButtonHiddenInWizard);
            }
        }
    }
    // start
    start();
}
Also used : IFormField(org.eclipse.scout.rt.client.ui.form.fields.IFormField) IButton(org.eclipse.scout.rt.client.ui.form.fields.button.IButton)

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