Search in sources :

Example 1 with AbstractStringField

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

the class DefaultSearchFilterServiceTest method testStringField.

@Test
public void testStringField() {
    AbstractStringField stringField = new MyStringField();
    stringField.initField();
    runBasicAsserts(stringField);
    stringField.setValue("value");
    m_searchFilterService.applySearchDelegate(stringField, m_searchFilter, false);
    Assert.assertEquals(LABEL + " " + TEXTS.get("LogicLike") + " " + stringField.getDisplayText(), m_searchFilter.getDisplayTextsPlain());
}
Also used : AbstractStringField(org.eclipse.scout.rt.client.ui.form.fields.stringfield.AbstractStringField) Test(org.junit.Test)

Example 2 with AbstractStringField

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

the class DefaultSearchFilterService method applySearchDelegate.

@Override
public void applySearchDelegate(IFormField field, SearchFilter search, boolean includeChildren) {
    String label = field.getLabel();
    if (field.getParentField() instanceof ISequenceBox && field.getParentField() instanceof AbstractFormField) {
        AbstractFormField range = (AbstractFormField) field.getParentField();
        if (range.getInitialLabel() != null) {
            label = range.getInitialLabel() + (StringUtility.isNullOrEmpty(label) ? "" : " " + label);
        }
    }
    // composer
    if (field instanceof AbstractComposerField) {
        AbstractComposerField composerField = (AbstractComposerField) field;
        ITreeNode rootNode = composerField.getTree().getRootNode();
        if (rootNode != null) {
            StringBuilder buf = new StringBuilder();
            new ComposerDisplayTextBuilder().build(rootNode, buf, "");
            String s = buf.toString();
            if (StringUtility.hasText(s)) {
                search.addDisplayText(s);
            }
        }
        return;
    }
    // list box
    if (field instanceof AbstractListBox<?>) {
        AbstractListBox<?> valueField = (AbstractListBox<?>) field;
        if (!valueField.getValue().isEmpty()) {
            search.addDisplayText(label + " " + TEXTS.get("LogicIn") + " " + valueField.getDisplayText());
        }
        return;
    }
    // tree box
    if (field instanceof AbstractTreeBox<?>) {
        AbstractTreeBox<?> valueField = (AbstractTreeBox<?>) field;
        if (!valueField.getValue().isEmpty()) {
            search.addDisplayText(label + " " + TEXTS.get("LogicIn") + " " + valueField.getDisplayText());
        }
        return;
    }
    // string, html, label field
    if (field instanceof AbstractStringField || field instanceof AbstractHtmlField || field instanceof AbstractLabelField) {
        AbstractValueField<?> valueField = (AbstractValueField<?>) field;
        if (valueField.getValue() != null) {
            search.addDisplayText(label + " " + TEXTS.get("LogicLike") + " " + valueField.getDisplayText());
        }
        return;
    }
    // boolean field
    if (field instanceof AbstractBooleanField) {
        AbstractBooleanField valueField = (AbstractBooleanField) field;
        if (valueField.getValue() != null && valueField.getValue()) {
            search.addDisplayText(label);
        }
        return;
    }
    // radiobuttongroup field
    if (field instanceof AbstractRadioButtonGroup<?>) {
        AbstractRadioButtonGroup<?> valueField = (AbstractRadioButtonGroup<?>) field;
        if (valueField.getValue() != null) {
            IButton selectedButton = valueField.getSelectedButton();
            search.addDisplayText(label + " = " + (selectedButton != null ? selectedButton.getLabel() : ""));
        }
        return;
    }
    // value field
    if (field instanceof AbstractValueField<?>) {
        AbstractValueField<?> valueField = (AbstractValueField<?>) field;
        if (valueField.getValue() != null) {
            search.addDisplayText(label + " " + TEXTS.get("LogicEQ") + " " + valueField.getDisplayText());
        }
        return;
    }
    if (includeChildren) {
        applySearchDelegateForChildren(field, search);
    }
}
Also used : AbstractFormField(org.eclipse.scout.rt.client.ui.form.fields.AbstractFormField) AbstractHtmlField(org.eclipse.scout.rt.client.ui.form.fields.htmlfield.AbstractHtmlField) AbstractStringField(org.eclipse.scout.rt.client.ui.form.fields.stringfield.AbstractStringField) ISequenceBox(org.eclipse.scout.rt.client.ui.form.fields.sequencebox.ISequenceBox) ITreeNode(org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode) AbstractValueField(org.eclipse.scout.rt.client.ui.form.fields.AbstractValueField) AbstractLabelField(org.eclipse.scout.rt.client.ui.form.fields.labelfield.AbstractLabelField) IButton(org.eclipse.scout.rt.client.ui.form.fields.button.IButton) AbstractRadioButtonGroup(org.eclipse.scout.rt.client.ui.form.fields.radiobuttongroup.AbstractRadioButtonGroup) AbstractListBox(org.eclipse.scout.rt.client.ui.form.fields.listbox.AbstractListBox) AbstractComposerField(org.eclipse.scout.rt.client.ui.form.fields.composer.AbstractComposerField) ComposerDisplayTextBuilder(org.eclipse.scout.rt.client.ui.form.fields.composer.internal.ComposerDisplayTextBuilder) AbstractBooleanField(org.eclipse.scout.rt.client.ui.form.fields.booleanfield.AbstractBooleanField) AbstractTreeBox(org.eclipse.scout.rt.client.ui.form.fields.treebox.AbstractTreeBox)

Example 3 with AbstractStringField

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

the class P_BadVisitorCompositeField method testAddField.

@Test
public void testAddField() {
    P_TestCompositeField compositeField = new P_TestCompositeField();
    compositeField.setEnabled(false, false, false);
    IStringField add = new AbstractStringField() {
    };
    AbstractMenu menu = new AbstractMenu() {
    };
    add.getContextMenu().addChildAction(menu);
    compositeField.addField(add);
    assertFalse(add.isEnabledIncludingParents());
    assertTrue(add.isEnabled());
    assertFalse(menu.isEnabled());
}
Also used : AbstractMenu(org.eclipse.scout.rt.client.ui.action.menu.AbstractMenu) IStringField(org.eclipse.scout.rt.client.ui.form.fields.stringfield.IStringField) AbstractStringField(org.eclipse.scout.rt.client.ui.form.fields.stringfield.AbstractStringField) Test(org.junit.Test)

Example 4 with AbstractStringField

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

the class JsonAdapterRegistryTest method testCreateDisposeInSameRequest.

@Test
public void testCreateDisposeInSameRequest() throws Exception {
    UiSession session = new UiSessionMock();
    IStringField model = new AbstractStringField() {
    };
    IJsonAdapter<?> adapter = session.getOrCreateJsonAdapter(model, null);
    // Note: Additionally, registry contains the "root adapter"
    assertEquals(2, UiSessionTestUtility.getJsonAdapterRegistry(session).size());
    assertEquals(1, session.currentJsonResponse().adapterMap().size());
    assertEquals(0, session.currentJsonResponse().eventList().size());
    model.setDisplayText("Test");
    assertEquals(2, UiSessionTestUtility.getJsonAdapterRegistry(session).size());
    assertEquals(1, session.currentJsonResponse().adapterMap().size());
    assertEquals(1, session.currentJsonResponse().eventList().size());
    adapter.dispose();
    assertEquals(1, UiSessionTestUtility.getJsonAdapterRegistry(session).size());
    assertEquals(0, session.currentJsonResponse().adapterMap().size());
    assertEquals(0, session.currentJsonResponse().eventList().size());
}
Also used : UiSessionMock(org.eclipse.scout.rt.ui.html.json.fixtures.UiSessionMock) IStringField(org.eclipse.scout.rt.client.ui.form.fields.stringfield.IStringField) AbstractStringField(org.eclipse.scout.rt.client.ui.form.fields.stringfield.AbstractStringField) UiSession(org.eclipse.scout.rt.ui.html.UiSession) Test(org.junit.Test)

Aggregations

AbstractStringField (org.eclipse.scout.rt.client.ui.form.fields.stringfield.AbstractStringField)4 Test (org.junit.Test)3 IStringField (org.eclipse.scout.rt.client.ui.form.fields.stringfield.IStringField)2 AbstractMenu (org.eclipse.scout.rt.client.ui.action.menu.AbstractMenu)1 ITreeNode (org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode)1 AbstractFormField (org.eclipse.scout.rt.client.ui.form.fields.AbstractFormField)1 AbstractValueField (org.eclipse.scout.rt.client.ui.form.fields.AbstractValueField)1 AbstractBooleanField (org.eclipse.scout.rt.client.ui.form.fields.booleanfield.AbstractBooleanField)1 IButton (org.eclipse.scout.rt.client.ui.form.fields.button.IButton)1 AbstractComposerField (org.eclipse.scout.rt.client.ui.form.fields.composer.AbstractComposerField)1 ComposerDisplayTextBuilder (org.eclipse.scout.rt.client.ui.form.fields.composer.internal.ComposerDisplayTextBuilder)1 AbstractHtmlField (org.eclipse.scout.rt.client.ui.form.fields.htmlfield.AbstractHtmlField)1 AbstractLabelField (org.eclipse.scout.rt.client.ui.form.fields.labelfield.AbstractLabelField)1 AbstractListBox (org.eclipse.scout.rt.client.ui.form.fields.listbox.AbstractListBox)1 AbstractRadioButtonGroup (org.eclipse.scout.rt.client.ui.form.fields.radiobuttongroup.AbstractRadioButtonGroup)1 ISequenceBox (org.eclipse.scout.rt.client.ui.form.fields.sequencebox.ISequenceBox)1 AbstractTreeBox (org.eclipse.scout.rt.client.ui.form.fields.treebox.AbstractTreeBox)1 UiSession (org.eclipse.scout.rt.ui.html.UiSession)1 UiSessionMock (org.eclipse.scout.rt.ui.html.json.fixtures.UiSessionMock)1