Search in sources :

Example 6 with ValueChangeListener

use of com.vaadin.v7.data.Property.ValueChangeListener in project opencms-core by alkacon.

the class CmsEditSiteForm method setUpComboBoxSSL.

/**
 * Sets up the ComboBox for the SSL Mode.<p>
 */
private void setUpComboBoxSSL() {
    IndexedContainer container = getSSLModeContainer("caption", true, null);
    m_simpleFieldEncryption.setContainerDataSource(container);
    m_simpleFieldEncryption.setItemCaptionPropertyId("caption");
    m_simpleFieldEncryption.setNullSelectionAllowed(false);
    m_simpleFieldEncryption.setNewItemsAllowed(false);
    m_simpleFieldEncryption.select(CmsSSLMode.getDefault());
    m_simpleFieldEncryption.addValueChangeListener(new ValueChangeListener() {

        private static final long serialVersionUID = 3267990233897064320L;

        public void valueChange(ValueChangeEvent event) {
            if (m_blockChange) {
                return;
            }
            handleSSLChange();
        }
    });
    m_fieldSecureServer.setVisible(CmsSSLMode.getDefault().equals(CmsSSLMode.SECURE_SERVER));
    m_fieldExclusiveError.setVisible(CmsSSLMode.getDefault().equals(CmsSSLMode.SECURE_SERVER));
    m_fieldExclusiveURL.setVisible(CmsSSLMode.getDefault().equals(CmsSSLMode.SECURE_SERVER));
}
Also used : ValueChangeEvent(com.vaadin.v7.data.Property.ValueChangeEvent) ValueChangeListener(com.vaadin.v7.data.Property.ValueChangeListener) IndexedContainer(com.vaadin.v7.data.util.IndexedContainer)

Example 7 with ValueChangeListener

use of com.vaadin.v7.data.Property.ValueChangeListener in project opencms-core by alkacon.

the class CmsListManager method initUI.

/**
 * @see org.opencms.ui.apps.A_CmsWorkplaceApp#initUI(org.opencms.ui.apps.I_CmsAppUIContext)
 */
@Override
public void initUI(I_CmsAppUIContext uiContext) {
    super.initUI(uiContext);
    m_publishButton = CmsToolBar.createButton(FontOpenCms.PUBLISH, CmsVaadinUtils.getMessageText(Messages.GUI_PUBLISH_BUTTON_TITLE_0));
    if (CmsAppWorkplaceUi.isOnlineProject()) {
        // disable publishing in online project
        m_publishButton.setEnabled(false);
        m_publishButton.setDescription(CmsVaadinUtils.getMessageText(Messages.GUI_TOOLBAR_NOT_AVAILABLE_ONLINE_0));
    }
    m_publishButton.addClickListener(new ClickListener() {

        /**
         * Serial version id.
         */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            publish();
        }
    });
    uiContext.addToolbarButton(m_publishButton);
    m_editCurrentButton = CmsToolBar.createButton(FontOpenCms.PEN, CmsVaadinUtils.getMessageText(Messages.GUI_LISTMANAGER_EDIT_CONFIG_0));
    m_editCurrentButton.addClickListener(new ClickListener() {

        /**
         * Serial version id.
         */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            editListConfiguration(m_currentResource);
        }
    });
    uiContext.addToolbarButton(m_editCurrentButton);
    m_infoButton = CmsToolBar.createButton(FontOpenCms.INFO, CmsVaadinUtils.getMessageText(org.opencms.ui.Messages.GUI_RESOURCE_INFO_0));
    m_infoButton.addClickListener(new ClickListener() {

        /**
         * Serial version id.
         */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            DialogContext context = new DialogContext(CmsProjectManagerConfiguration.APP_ID, ContextType.fileTable, m_resultTable, Collections.singletonList(m_currentResource));
            CmsResourceInfoAction action = new CmsResourceInfoAction();
            action.openDialog(context, CmsResourceStatusTabId.tabRelationsTo.name());
        }
    });
    uiContext.addToolbarButton(m_infoButton);
    m_toggleSeriesButton = CmsToolBar.createButton(FontOpenCms.LIST, CmsVaadinUtils.getMessageText(Messages.GUI_LISTMANAGER_TOGGLE_SERIES_BUTTON_0));
    m_toggleSeriesButton.addClickListener(new ClickListener() {

        /**
         * Serial version id.
         */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            toggleDateSeries();
        }
    });
    uiContext.addToolbarButton(m_toggleSeriesButton);
    m_createNewButton = CmsToolBar.createButton(FontOpenCms.WAND, CmsVaadinUtils.getMessageText(Messages.GUI_LISTMANAGER_CREATE_NEW_0));
    m_createNewButton.addClickListener(new ClickListener() {

        /**
         * Serial version id.
         */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            createNew();
        }
    });
    uiContext.addToolbarButton(m_createNewButton);
    m_rootLayout.setMainHeightFull(true);
    m_resultLayout = new HorizontalSplitPanel();
    m_resultLayout.setSizeFull();
    m_resultFacets = new CmsResultFacets(this);
    m_resultFacets.setWidth("100%");
    m_resultLayout.setFirstComponent(m_resultFacets);
    LinkedHashMap<CmsResourceTableProperty, Integer> tableColumns = new LinkedHashMap<CmsResourceTableProperty, Integer>();
    // insert columns a specific positions
    for (Map.Entry<CmsResourceTableProperty, Integer> columnsEntry : CmsFileTable.DEFAULT_TABLE_PROPERTIES.entrySet()) {
        if (columnsEntry.getKey().equals(CmsResourceTableProperty.PROPERTY_RESOURCE_NAME)) {
            tableColumns.put(INFO_PROPERTY_LABEL, Integer.valueOf(0));
        } else if (columnsEntry.getKey().equals(CmsResourceTableProperty.PROPERTY_RESOURCE_TYPE)) {
            tableColumns.put(INSTANCEDATE_PROPERTY, Integer.valueOf(0));
        }
        tableColumns.put(columnsEntry.getKey(), columnsEntry.getValue());
    }
    tableColumns.put(BLACKLISTED_PROPERTY, Integer.valueOf(CmsResourceTable.INVISIBLE));
    tableColumns.put(INFO_PROPERTY, Integer.valueOf(CmsResourceTable.INVISIBLE));
    m_resultTable = new CmsResultTable(null, tableColumns);
    m_resultTable.applyWorkplaceAppSettings();
    CmsResourceContextMenuBuilder menuBuilderOverView = new CmsResourceContextMenuBuilder();
    menuBuilderOverView.addMenuItemProvider(OpenCms.getWorkplaceAppManager().getMenuItemProvider());
    menuBuilderOverView.addMenuItemProvider(new I_CmsContextMenuItemProvider() {

        @Override
        public List<I_CmsContextMenuItem> getMenuItems() {
            return Arrays.<I_CmsContextMenuItem>asList(new CmsContextMenuActionItem(new CmsEditDialogAction() {

                @Override
                public void executeAction(I_CmsDialogContext context) {
                    editListConfiguration(context.getResources().get(0));
                }
            }, null, 10, 1000));
        }
    });
    CmsResourceContextMenuBuilder menuBuilder = new CmsResourceContextMenuBuilder();
    menuBuilder.addMenuItemProvider(OpenCms.getWorkplaceAppManager().getMenuItemProvider());
    menuBuilder.addMenuItemProvider(new I_CmsContextMenuItemProvider() {

        @Override
        public List<I_CmsContextMenuItem> getMenuItems() {
            return Arrays.<I_CmsContextMenuItem>asList(new CmsContextMenuActionItem(new A_CmsWorkplaceAction() {

                @Override
                public void executeAction(I_CmsDialogContext context) {
                    CmsUUID structureId = context.getResources().get(0).getStructureId();
                    m_currentConfig.getBlacklist().add(structureId);
                    saveBlacklist(m_currentConfig);
                    context.finish(Collections.singletonList(structureId));
                }

                @Override
                public String getId() {
                    return "hideresource";
                }

                @Override
                public String getTitleKey() {
                    return Messages.GUI_LISTMANAGER_BLACKLIST_MENU_ENTRY_0;
                }

                @Override
                public CmsMenuItemVisibilityMode getVisibility(CmsObject cms, List<CmsResource> resources) {
                    if ((m_currentConfig != null) && (resources != null) && (resources.size() == 1) && !m_currentConfig.getBlacklist().contains(resources.get(0).getStructureId())) {
                        return CmsEditDialogAction.VISIBILITY.getVisibility(cms, Collections.singletonList(m_currentResource));
                    } else {
                        return CmsMenuItemVisibilityMode.VISIBILITY_INVISIBLE;
                    }
                }
            }, null, 10, 0), new CmsContextMenuActionItem(new A_CmsWorkplaceAction() {

                @Override
                public void executeAction(I_CmsDialogContext context) {
                    CmsUUID structureId = context.getResources().get(0).getStructureId();
                    m_currentConfig.getBlacklist().remove(structureId);
                    saveBlacklist(m_currentConfig);
                    context.finish(Collections.singletonList(structureId));
                }

                @Override
                public String getId() {
                    return "showresource";
                }

                @Override
                public String getTitleKey() {
                    return Messages.GUI_LISTMANAGER_REMOVE_FROM_BLACKLIST_MENU_ENTRY_0;
                }

                @Override
                public CmsMenuItemVisibilityMode getVisibility(CmsObject cms, List<CmsResource> resources) {
                    if ((m_currentConfig != null) && (resources != null) && (resources.size() == 1) && m_currentConfig.getBlacklist().contains(resources.get(0).getStructureId())) {
                        return CmsEditDialogAction.VISIBILITY.getVisibility(cms, Collections.singletonList(m_currentResource));
                    } else {
                        return CmsMenuItemVisibilityMode.VISIBILITY_INVISIBLE;
                    }
                }
            }, null, 10, 0), new CmsContextMenuActionItem(new EditAction(), null, 10, 1000), new CmsContextMenuActionItem(new DeleteAction(), null, 10, 1000));
        }
    });
    m_resultTable.setMenuBuilder(menuBuilder);
    m_resultTable.addAdditionalStyleGenerator(new CellStyleGenerator() {

        private static final long serialVersionUID = 1L;

        @Override
        public String getStyle(Table source, Object itemId, Object propertyId) {
            String style = "";
            Item item = source.getItem(itemId);
            Boolean blacklisted = (Boolean) item.getItemProperty(BLACKLISTED_PROPERTY).getValue();
            if (blacklisted.booleanValue()) {
                style += OpenCmsTheme.PROJECT_OTHER + " ";
            } else if (CmsResourceTableProperty.PROPERTY_TITLE.equals(propertyId) && ((item.getItemProperty(CmsResourceTableProperty.PROPERTY_RELEASED_NOT_EXPIRED) == null) || ((Boolean) item.getItemProperty(CmsResourceTableProperty.PROPERTY_RELEASED_NOT_EXPIRED).getValue()).booleanValue())) {
                style += OpenCmsTheme.IN_NAVIGATION + " ";
            }
            if (INFO_PROPERTY_LABEL.equals(propertyId)) {
                if (blacklisted.booleanValue()) {
                    style += OpenCmsTheme.TABLE_COLUMN_BOX_BLACK;
                } else {
                    Object value = item.getItemProperty(INFO_PROPERTY).getValue();
                    if (value == null) {
                        style += OpenCmsTheme.TABLE_COLUMN_BOX_GRAY;
                    } else {
                        I_CmsSerialDateValue.DateType type = I_CmsSerialDateValue.DateType.valueOf((String) value);
                        switch(type) {
                            case SERIES:
                                style += OpenCmsTheme.TABLE_COLUMN_BOX_BLUE_LIGHT;
                                break;
                            case SINGLE:
                                style += OpenCmsTheme.TABLE_COLUMN_BOX_GRAY;
                                break;
                            case EXTRACTED:
                                style += OpenCmsTheme.TABLE_COLUMN_BOX_ORANGE;
                                break;
                            default:
                                break;
                        }
                    }
                }
            }
            return style;
        }
    });
    final ItemDescriptionGenerator defaultDescriptionGenerator = new CmsResourceTable.DefaultItemDescriptionGenerator();
    m_resultTable.setsetItemDescriptionGenerator(new ItemDescriptionGenerator() {

        private static final long serialVersionUID = 1L;

        public String generateDescription(Component source, Object itemId, Object propertyId) {
            Item item = ((Table) source).getItem(itemId);
            if (INFO_PROPERTY_LABEL.equals(propertyId) && ((Boolean) item.getItemProperty(BLACKLISTED_PROPERTY).getValue()).booleanValue()) {
                return CmsVaadinUtils.getMessageText(Messages.GUI_LISTMANAGER_COLUMN_BLACKLISTED_0);
            }
            return defaultDescriptionGenerator.generateDescription(source, itemId, propertyId);
        }
    });
    m_resultTable.setContextProvider(this);
    m_resultTable.addPropertyProvider(this);
    m_resultTable.setSizeFull();
    m_resultLayout.setSecondComponent(m_resultTable);
    m_overviewTable = new CmsFileTable(this);
    m_overviewTable.applyWorkplaceAppSettings();
    m_overviewTable.setMenuBuilder(menuBuilderOverView);
    m_overviewTable.setSizeFull();
    m_tableFilter = new TextField();
    m_tableFilter.setIcon(FontOpenCms.FILTER);
    m_tableFilter.setInputPrompt(Messages.get().getBundle(UI.getCurrent().getLocale()).key(Messages.GUI_EXPLORER_FILTER_0));
    m_tableFilter.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON);
    m_tableFilter.setWidth("200px");
    m_tableFilter.addTextChangeListener(new TextChangeListener() {

        private static final long serialVersionUID = 1L;

        @Override
        public void textChange(TextChangeEvent event) {
            filterTable(event.getText());
        }
    });
    m_infoLayout.addComponent(m_tableFilter);
    m_localeSelect = new ComboBox();
    m_localeSelect.setNullSelectionAllowed(false);
    m_localeSelect.setWidth("100px");
    m_localeSelect.addValueChangeListener(new ValueChangeListener() {

        /**
         * Serial version id.
         */
        private static final long serialVersionUID = 1L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            changeContentLocale((Locale) event.getProperty().getValue());
        }
    });
    m_infoLayout.addComponent(m_localeSelect);
    m_resultSorter = new ComboBox();
    m_resultSorter.setNullSelectionAllowed(false);
    m_resultSorter.setWidth("200px");
    for (int i = 0; i < SORT_OPTIONS[0].length; i++) {
        m_resultSorter.addItem(SORT_OPTIONS[0][i]);
        m_resultSorter.setItemCaption(SORT_OPTIONS[0][i], CmsVaadinUtils.getMessageText(SORT_OPTIONS[1][i]));
    }
    m_resultSorter.addValueChangeListener(new ValueChangeListener() {

        /**
         * Serial version id.
         */
        private static final long serialVersionUID = 1L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            sortResult();
        }
    });
    m_infoLayout.addComponent(m_resultSorter);
    m_textSearch = new TextField();
    m_textSearch.setIcon(FontOpenCms.SEARCH);
    m_textSearch.setInputPrompt(CmsVaadinUtils.getMessageText(Messages.GUI_LISTMANAGER_SEARCH_0));
    m_textSearch.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON);
    m_textSearch.setWidth("200px");
    m_textSearch.addValueChangeListener(new ValueChangeListener() {

        /**
         * Serial version id.
         */
        private static final long serialVersionUID = 1L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            search((String) event.getProperty().getValue());
        }
    });
    m_infoLayout.addComponent(m_textSearch);
    m_resultLayout.setSecondComponent(m_resultTable);
    m_resultLayout.setSplitPosition(CmsFileExplorer.LAYOUT_SPLIT_POSITION, Unit.PIXELS);
}
Also used : CmsResourceTableProperty(org.opencms.ui.components.CmsResourceTableProperty) Locale(java.util.Locale) CmsMenuItemVisibilityMode(org.opencms.ui.contextmenu.CmsMenuItemVisibilityMode) CmsResourceInfoAction(org.opencms.ui.actions.CmsResourceInfoAction) ClickEvent(com.vaadin.ui.Button.ClickEvent) CellStyleGenerator(com.vaadin.v7.ui.Table.CellStyleGenerator) I_CmsContextMenuItemProvider(org.opencms.ui.contextmenu.I_CmsContextMenuItemProvider) LinkedHashMap(java.util.LinkedHashMap) CmsContextMenuActionItem(org.opencms.ui.actions.CmsContextMenuActionItem) Item(com.vaadin.v7.data.Item) I_CmsContextMenuItem(org.opencms.ui.contextmenu.I_CmsContextMenuItem) CmsContextMenuActionItem(org.opencms.ui.actions.CmsContextMenuActionItem) CmsObject(org.opencms.file.CmsObject) ValueChangeListener(com.vaadin.v7.data.Property.ValueChangeListener) TextField(com.vaadin.v7.ui.TextField) ArrayList(java.util.ArrayList) List(java.util.List) CmsSolrResultList(org.opencms.search.solr.CmsSolrResultList) CmsUUID(org.opencms.util.CmsUUID) Component(com.vaadin.ui.Component) TextChangeListener(com.vaadin.v7.event.FieldEvents.TextChangeListener) ClickListener(com.vaadin.ui.Button.ClickListener) CmsResourceContextMenuBuilder(org.opencms.ui.contextmenu.CmsResourceContextMenuBuilder) Table(com.vaadin.v7.ui.Table) CmsFileTable(org.opencms.ui.components.CmsFileTable) CmsResourceTable(org.opencms.ui.components.CmsResourceTable) CmsFileTableDialogContext(org.opencms.ui.components.CmsFileTableDialogContext) I_CmsDialogContext(org.opencms.ui.I_CmsDialogContext) A_CmsWorkplaceAction(org.opencms.ui.actions.A_CmsWorkplaceAction) ComboBox(com.vaadin.v7.ui.ComboBox) ValueChangeEvent(com.vaadin.v7.data.Property.ValueChangeEvent) ItemDescriptionGenerator(com.vaadin.v7.ui.AbstractSelect.ItemDescriptionGenerator) I_CmsDialogContext(org.opencms.ui.I_CmsDialogContext) CmsResource(org.opencms.file.CmsResource) TextChangeEvent(com.vaadin.v7.event.FieldEvents.TextChangeEvent) HorizontalSplitPanel(com.vaadin.ui.HorizontalSplitPanel) CmsEditDialogAction(org.opencms.ui.actions.CmsEditDialogAction) CmsObject(org.opencms.file.CmsObject) CmsFileTable(org.opencms.ui.components.CmsFileTable) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap)

Example 8 with ValueChangeListener

use of com.vaadin.v7.data.Property.ValueChangeListener in project opencms-core by alkacon.

the class CmsGitToolOptionsPanel method updateNewModuleSelector.

/**
 * Updates the selection widget for adding new modules.<p>
 */
public void updateNewModuleSelector() {
    ComboBox newModuleSelector = createModuleSelector();
    ((AbstractLayout) (m_moduleSelector.getParent())).replaceComponent(m_moduleSelector, newModuleSelector);
    m_moduleSelector = newModuleSelector;
    m_moduleSelector.addValueChangeListener(new ValueChangeListener() {

        private static final long serialVersionUID = 1L;

        public void valueChange(ValueChangeEvent event) {
            String moduleName = (String) (event.getProperty().getValue());
            addSelectableModule(moduleName);
            updateNewModuleSelector();
        }
    });
}
Also used : ValueChangeEvent(com.vaadin.v7.data.Property.ValueChangeEvent) ValueChangeListener(com.vaadin.v7.data.Property.ValueChangeListener) ComboBox(com.vaadin.v7.ui.ComboBox) AbstractLayout(com.vaadin.ui.AbstractLayout)

Example 9 with ValueChangeListener

use of com.vaadin.v7.data.Property.ValueChangeListener in project opencms-core by alkacon.

the class A_CmsSelectResourceTypeDialog method initViews.

/**
 * Initializes the view selector, using the given view id as an initial value.<p>
 *
 * @param startId the start view
 *
 * @return the start view
 */
private CmsElementView initViews(CmsUUID startId) {
    Map<CmsUUID, CmsElementView> viewMap = OpenCms.getADEManager().getElementViews(A_CmsUI.getCmsObject());
    List<CmsElementView> viewList = new ArrayList<CmsElementView>(viewMap.values());
    Collections.sort(viewList, new Comparator<CmsElementView>() {

        public int compare(CmsElementView arg0, CmsElementView arg1) {
            return ComparisonChain.start().compare(arg0.getOrder(), arg1.getOrder()).result();
        }
    });
    getViewSelector().setItemCaptionMode(ItemCaptionMode.EXPLICIT);
    m_typeHelper = createTypeHelper();
    m_typeHelper.precomputeTypeLists(A_CmsUI.getCmsObject(), m_folderResource.getRootPath(), A_CmsUI.getCmsObject().getRequestContext().removeSiteRoot(m_folderResource.getRootPath()), viewList, null);
    // also collect types in LinkedHashMap to preserve order and ensure uniqueness
    LinkedHashMap<String, CmsResourceTypeBean> allTypes = Maps.newLinkedHashMap();
    for (CmsElementView view : viewList) {
        if (view.hasPermission(A_CmsUI.getCmsObject(), m_folderResource)) {
            List<CmsResourceTypeBean> typeBeans = m_typeHelper.getPrecomputedTypes(view);
            if (typeBeans.isEmpty()) {
                continue;
            }
            for (CmsResourceTypeBean typeBean : typeBeans) {
                allTypes.put(typeBean.getType(), typeBean);
            }
            getViewSelector().addItem(view.getId());
            getViewSelector().setItemCaption(view.getId(), view.getTitle(A_CmsUI.getCmsObject(), A_CmsUI.get().getLocale()));
        }
    }
    getViewSelector().addItem(VIEW_ALL.getId());
    getViewSelector().setItemCaption(VIEW_ALL.getId(), CmsVaadinUtils.getMessageText(Messages.GUI_VIEW_ALL_0));
    m_allTypes = Lists.newArrayList(allTypes.values());
    if (allTypes.size() <= 8) {
        startId = ID_VIEW_ALL;
    }
    if (getViewSelector().getItem(startId) == null) {
        startId = (CmsUUID) (getViewSelector().getItemIds().iterator().next());
    }
    getViewSelector().addValueChangeListener(new ValueChangeListener() {

        private static final long serialVersionUID = 1L;

        public void valueChange(ValueChangeEvent event) {
            CmsUUID viewId = (CmsUUID) (event.getProperty().getValue());
            CmsElementView selectedView;
            if (viewId.equals(ID_VIEW_ALL)) {
                selectedView = VIEW_ALL;
            } else {
                selectedView = OpenCms.getADEManager().getElementViews(A_CmsUI.getCmsObject()).get(event.getProperty().getValue());
            }
            init(selectedView, useDefault());
            if (selectedView != VIEW_ALL) {
                VaadinService.getCurrentRequest().getWrappedSession().setAttribute(SETTING_STANDARD_VIEW, (event.getProperty().getValue()));
            }
        }
    });
    if (startId.equals(ID_VIEW_ALL)) {
        return VIEW_ALL;
    } else {
        return OpenCms.getADEManager().getElementViews(A_CmsUI.getCmsObject()).get(startId);
    }
}
Also used : CmsElementView(org.opencms.ade.configuration.CmsElementView) ArrayList(java.util.ArrayList) CmsResourceTypeBean(org.opencms.ade.galleries.shared.CmsResourceTypeBean) ValueChangeEvent(com.vaadin.v7.data.Property.ValueChangeEvent) ValueChangeListener(com.vaadin.v7.data.Property.ValueChangeListener) CmsUUID(org.opencms.util.CmsUUID)

Example 10 with ValueChangeListener

use of com.vaadin.v7.data.Property.ValueChangeListener in project opencms-core by alkacon.

the class CmsMessageBundleEditorOptions method initLanguageSwitch.

/**
 * Initializes the language switcher UI Component {@link #m_languageSwitch}, including {@link #m_languageSelect}.
 * @param locales the locales that can be selected.
 * @param current the currently selected locale.
 */
private void initLanguageSwitch(Collection<Locale> locales, Locale current) {
    FormLayout languages = new FormLayout();
    languages.setHeight("100%");
    languages.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    ComboBox languageSelect = new ComboBox();
    languageSelect.setCaption(m_messages.key(Messages.GUI_LANGUAGE_SWITCHER_LABEL_0));
    languageSelect.setNullSelectionAllowed(false);
    // set Locales
    for (Locale locale : locales) {
        languageSelect.addItem(locale);
        String caption = locale.getDisplayName(UI.getCurrent().getLocale());
        if (CmsLocaleManager.getDefaultLocale().equals(locale)) {
            caption += " (" + Messages.get().getBundle(UI.getCurrent().getLocale()).key(Messages.GUI_DEFAULT_LOCALE_0) + ")";
        }
        languageSelect.setItemCaption(locale, caption);
    }
    languageSelect.setValue(current);
    languageSelect.setNewItemsAllowed(false);
    languageSelect.setTextInputAllowed(false);
    languageSelect.addValueChangeListener(new ValueChangeListener() {

        private static final long serialVersionUID = 1L;

        public void valueChange(ValueChangeEvent event) {
            m_listener.handleLanguageChange((Locale) event.getProperty().getValue());
        }
    });
    if (locales.size() == 1) {
        languageSelect.setEnabled(false);
    }
    languages.addComponent(languageSelect);
    m_languageSwitch = languages;
}
Also used : FormLayout(com.vaadin.ui.FormLayout) Locale(java.util.Locale) ValueChangeEvent(com.vaadin.v7.data.Property.ValueChangeEvent) ValueChangeListener(com.vaadin.v7.data.Property.ValueChangeListener) ComboBox(com.vaadin.v7.ui.ComboBox)

Aggregations

ValueChangeListener (com.vaadin.v7.data.Property.ValueChangeListener)21 ValueChangeEvent (com.vaadin.v7.data.Property.ValueChangeEvent)20 ComboBox (com.vaadin.v7.ui.ComboBox)17 TextField (com.vaadin.v7.ui.TextField)11 Label (com.vaadin.ui.Label)10 DateField (com.vaadin.v7.ui.DateField)8 FacadeProvider (de.symeda.sormas.api.FacadeProvider)8 I18nProperties (de.symeda.sormas.api.i18n.I18nProperties)8 FieldVisibilityCheckers (de.symeda.sormas.api.utils.fieldvisibility.FieldVisibilityCheckers)8 AbstractEditForm (de.symeda.sormas.ui.utils.AbstractEditForm)8 FieldHelper (de.symeda.sormas.ui.utils.FieldHelper)8 List (java.util.List)8 Converter (com.vaadin.v7.data.util.converter.Converter)7 Captions (de.symeda.sormas.api.i18n.Captions)7 Strings (de.symeda.sormas.api.i18n.Strings)7 DistrictReferenceDto (de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto)7 CheckBox (com.vaadin.v7.ui.CheckBox)6 Field (com.vaadin.v7.ui.Field)6 Disease (de.symeda.sormas.api.Disease)6 FacilityDto (de.symeda.sormas.api.infrastructure.facility.FacilityDto)6