Search in sources :

Example 66 with Field

use of com.vaadin.v7.ui.Field in project opencms-core by alkacon.

the class CmsEditModuleForm method updateModule.

/**
 * Writes the form data back to the module.<p>
 */
public void updateModule() {
    try {
        m_fieldGroup.commit();
        // validate 'dynamic' tabs here
        TreeMap<String, String> params = Maps.newTreeMap();
        for (I_CmsEditableGroupRow row : m_parameterGroup.getRows()) {
            TextField paramField = (TextField) (row.getComponent());
            String paramStr = paramField.getValue();
            int eqPos = paramStr.indexOf("=");
            if (eqPos >= 0) {
                String key = paramStr.substring(0, eqPos);
                key = key.trim();
                String value = paramStr.substring(eqPos + 1);
                value = value.trim();
                if (!CmsStringUtil.isEmpty(key)) {
                    params.put(key, value);
                }
            }
        }
        m_module.setParameters(params);
        List<CmsExportPoint> exportPoints = Lists.newArrayList();
        for (I_CmsEditableGroupRow row : m_exportPointGroup.getRows()) {
            CmsExportPointWidget widget = (CmsExportPointWidget) (row.getComponent());
            String source = widget.getUri().trim();
            String target = widget.getDestination().trim();
            if (CmsStringUtil.isEmpty(source) || CmsStringUtil.isEmpty(target)) {
                continue;
            }
            CmsExportPoint point = new CmsExportPoint(source, target);
            exportPoints.add(point);
        }
        m_module.setExportPoints(exportPoints);
        List<CmsModuleDependency> dependencies = Lists.newArrayList();
        for (CmsModuleDependencyWidget widget : getFormRowChildren(m_dependencies, CmsModuleDependencyWidget.class)) {
            String moduleName = widget.getModuleName();
            String moduleVersion = widget.getModuleVersion();
            try {
                CmsModuleDependency dep = new CmsModuleDependency(moduleName, new CmsModuleVersion(moduleVersion));
                dependencies.add(dep);
            } catch (Exception e) {
                LOG.debug(e.getLocalizedMessage(), e);
            }
        }
        m_module.setDependencies(dependencies);
        List<String> moduleResources = Lists.newArrayList();
        for (I_CmsEditableGroupRow row : m_moduleResourcesGroup.getRows()) {
            CmsModuleResourceSelectField field = (CmsModuleResourceSelectField) (row.getComponent());
            String moduleResource = field.getValue().trim();
            if (!moduleResource.isEmpty()) {
                moduleResources.add(moduleResource);
            }
        }
        m_module.setResources(moduleResources);
        List<String> excludedResources = Lists.newArrayList();
        for (I_CmsEditableGroupRow row : m_excludedResourcesGroup.getRows()) {
            CmsModuleResourceSelectField field = (CmsModuleResourceSelectField) (row.getComponent());
            String moduleResource = field.getValue().trim();
            if (!moduleResource.isEmpty()) {
                excludedResources.add(moduleResource);
            }
        }
        m_module.setExcludeResources(excludedResources);
        if (!m_oldModuleInstance.isAutoIncrement() && m_module.isAutoIncrement()) {
            m_module.setCheckpointTime(System.currentTimeMillis());
        }
        CmsObject cms = A_CmsUI.getCmsObject();
        if (m_new) {
            createModuleFolders(cms, m_module);
            OpenCms.getModuleManager().addModule(cms, m_module);
        } else {
            OpenCms.getModuleManager().updateModule(cms, m_module);
        }
        CmsVaadinUtils.getWindow(this).close();
        m_updateCallback.run();
    } catch (CommitException e) {
        if (e.getCause() instanceof FieldGroup.FieldGroupInvalidValueException) {
            int minTabIdx = 999;
            for (Field<?> field : e.getInvalidFields().keySet()) {
                int tabIdx = getTabIndex(field);
                if (tabIdx != -1) {
                    minTabIdx = Math.min(tabIdx, minTabIdx);
                }
            }
            m_tabs.setSelectedTab(minTabIdx);
        } else {
            CmsErrorDialog.showErrorDialog(e);
        }
        return;
    } catch (Exception e) {
        CmsErrorDialog.showErrorDialog(e);
    }
}
Also used : CommitException(com.vaadin.v7.data.fieldgroup.FieldGroup.CommitException) BeanFieldGroup(com.vaadin.v7.data.fieldgroup.BeanFieldGroup) FieldGroup(com.vaadin.v7.data.fieldgroup.FieldGroup) CmsExportPoint(org.opencms.db.CmsExportPoint) CmsExportPoint(org.opencms.db.CmsExportPoint) CmsException(org.opencms.main.CmsException) CmsLockException(org.opencms.lock.CmsLockException) CommitException(com.vaadin.v7.data.fieldgroup.FieldGroup.CommitException) AbstractField(com.vaadin.v7.ui.AbstractField) CmsComponentField(org.opencms.ui.util.CmsComponentField) Field(com.vaadin.v7.ui.Field) TextField(com.vaadin.v7.ui.TextField) CmsObject(org.opencms.file.CmsObject) CmsModuleVersion(org.opencms.module.CmsModuleVersion) CmsModuleDependency(org.opencms.module.CmsModuleDependency) TextField(com.vaadin.v7.ui.TextField) I_CmsEditableGroupRow(org.opencms.ui.components.editablegroup.I_CmsEditableGroupRow)

Example 67 with Field

use of com.vaadin.v7.ui.Field in project opencms-core by alkacon.

the class CmsMessageBundleEditorOptions method initAddKeyInput.

/**
 * Initializes the input field for new keys {@link #m_addKeyInput}.
 */
private void initAddKeyInput() {
    // the input field for the key
    m_addKeyInput = new TextField();
    m_addKeyInput.setWidth("100%");
    m_addKeyInput.setInputPrompt(m_messages.key(Messages.GUI_INPUT_PROMPT_ADD_KEY_0));
    final ShortcutListener shortCutListener = new ShortcutListener("Add key via ENTER", KeyCode.ENTER, null) {

        private static final long serialVersionUID = 1L;

        @Override
        public void handleAction(Object sender, Object target) {
            handleAddKey();
        }
    };
    m_addKeyInput.addFocusListener(new FocusListener() {

        private static final long serialVersionUID = 1L;

        public void focus(FocusEvent event) {
            m_addKeyInput.addShortcutListener(shortCutListener);
        }
    });
    m_addKeyInput.addBlurListener(new BlurListener() {

        private static final long serialVersionUID = 1L;

        public void blur(BlurEvent event) {
            m_addKeyInput.removeShortcutListener(shortCutListener);
        }
    });
}
Also used : ShortcutListener(com.vaadin.event.ShortcutListener) BlurListener(com.vaadin.event.FieldEvents.BlurListener) TextField(com.vaadin.v7.ui.TextField) BlurEvent(com.vaadin.event.FieldEvents.BlurEvent) FocusListener(com.vaadin.event.FieldEvents.FocusListener) FocusEvent(com.vaadin.event.FieldEvents.FocusEvent)

Example 68 with Field

use of com.vaadin.v7.ui.Field in project opencms-core by alkacon.

the class CmsMessageBundleEditorOptions method initLowerRightComponent.

/**
 * Initializes the lower right component {@link #m_lowerRightComponent}, with all its components, i.e.,
 * the "Add key" input field {@link #m_addKeyInput} and the "Add key" button.
 */
private void initLowerRightComponent() {
    initAddKeyInput();
    Component addKeyButton = createAddKeyButton();
    HorizontalLayout addKeyWrapper = new HorizontalLayout(addKeyButton);
    addKeyWrapper.setComponentAlignment(addKeyButton, Alignment.MIDDLE_CENTER);
    addKeyWrapper.setHeight("100%");
    addKeyWrapper.setWidth(CmsMessageBundleEditorTypes.OPTION_COLUMN_WIDTH_PX);
    FormLayout inputForm = new FormLayout(m_addKeyInput);
    inputForm.setWidth("100%");
    HorizontalLayout lowerRight = new HorizontalLayout();
    lowerRight.setWidth("100%");
    lowerRight.addComponent(inputForm);
    lowerRight.addComponent(addKeyWrapper);
    lowerRight.setExpandRatio(inputForm, 1f);
    m_lowerRightComponent = lowerRight;
}
Also used : FormLayout(com.vaadin.ui.FormLayout) Component(com.vaadin.ui.Component) HorizontalLayout(com.vaadin.v7.ui.HorizontalLayout)

Example 69 with Field

use of com.vaadin.v7.ui.Field in project opencms-core by alkacon.

the class CmsDbSynchronizationView method addResource.

/**
 * Adds a resource to form.<p>
 *
 * @param path of resource to add
 */
protected void addResource(String path) {
    CmsPathSelectField field = new CmsPathSelectField();
    field.setCmsObject(m_cms);
    field.setUseRootPaths(true);
    field.setValue(path);
    field.addValueChangeListener(new ValueChangeListener() {

        private static final long serialVersionUID = 8646438704383992571L;

        public void valueChange(ValueChangeEvent event) {
            setOkButtonEnabled(true);
        }
    });
    m_componentsToValidate.add(field);
    CmsRemovableFormRow<CmsPathSelectField> row = new CmsRemovableFormRow<CmsPathSelectField>(field, CmsVaadinUtils.getMessageText(Messages.GUI_DATABASEAPP_SYNC_REMOVE_RESOURCE_0));
    row.setCaption(CmsVaadinUtils.getMessageText(Messages.GUI_DATABASEAPP_SYNC_RESOURCE_0));
    row.setRemoveRunnable(new Runnable() {

        public void run() {
            setOkButtonEnabled(true);
        }
    });
    m_resources.addComponent(row);
}
Also used : ValueChangeEvent(com.vaadin.v7.data.Property.ValueChangeEvent) ValueChangeListener(com.vaadin.v7.data.Property.ValueChangeListener) CmsRemovableFormRow(org.opencms.ui.components.CmsRemovableFormRow) CmsPathSelectField(org.opencms.ui.components.fileselect.CmsPathSelectField)

Example 70 with Field

use of com.vaadin.v7.ui.Field in project opencms-core by alkacon.

the class CmsEditSiteForm method isValidAliase.

/**
 * Are the aliase valid?<p>
 *
 * @return true if ok
 */
boolean isValidAliase() {
    boolean ret = true;
    for (I_CmsEditableGroupRow row : m_aliasGroup.getRows()) {
        FormLayout layout = (FormLayout) (row.getComponent());
        TextField field = (TextField) layout.getComponent(0);
        ret = ret & field.isValid();
    }
    return ret;
}
Also used : FormLayout(com.vaadin.ui.FormLayout) TextField(com.vaadin.v7.ui.TextField) I_CmsEditableGroupRow(org.opencms.ui.components.editablegroup.I_CmsEditableGroupRow)

Aggregations

TextField (com.vaadin.v7.ui.TextField)36 Field (com.vaadin.v7.ui.Field)34 ComboBox (com.vaadin.v7.ui.ComboBox)32 AbstractField (com.vaadin.v7.ui.AbstractField)23 DateField (com.vaadin.v7.ui.DateField)20 Label (com.vaadin.ui.Label)19 Disease (de.symeda.sormas.api.Disease)15 FacadeProvider (de.symeda.sormas.api.FacadeProvider)15 DistrictReferenceDto (de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto)15 FieldVisibilityCheckers (de.symeda.sormas.api.utils.fieldvisibility.FieldVisibilityCheckers)15 NullableOptionGroup (de.symeda.sormas.ui.utils.NullableOptionGroup)15 I18nProperties (de.symeda.sormas.api.i18n.I18nProperties)14 Strings (de.symeda.sormas.api.i18n.Strings)14 AbstractEditForm (de.symeda.sormas.ui.utils.AbstractEditForm)14 DateComparisonValidator (de.symeda.sormas.ui.utils.DateComparisonValidator)14 FieldHelper (de.symeda.sormas.ui.utils.FieldHelper)14 LayoutUtil.fluidRowLocs (de.symeda.sormas.ui.utils.LayoutUtil.fluidRowLocs)14 Collections (java.util.Collections)14 Button (com.vaadin.ui.Button)13 CssStyles (de.symeda.sormas.ui.utils.CssStyles)13