Search in sources :

Example 11 with Select

use of com.vaadin.v7.ui.Select in project SORMAS-Project by hzi-braunschweig.

the class SormasFieldGroupFieldFactory method populateWithEnumData.

@SuppressWarnings("unchecked")
@Override
protected void populateWithEnumData(AbstractSelect select, Class<? extends Enum> enumClass) {
    select.removeAllItems();
    for (Object p : select.getContainerPropertyIds()) {
        select.removeContainerProperty(p);
    }
    select.addContainerProperty(CAPTION_PROPERTY_ID, String.class, "");
    select.setItemCaptionPropertyId(CAPTION_PROPERTY_ID);
    EnumSet<?> enumSet = EnumSet.allOf(enumClass);
    for (Object r : enumSet) {
        boolean visible = true;
        if (fieldVisibilityCheckers != null) {
            visible = fieldVisibilityCheckers.isVisible(enumClass, ((Enum<?>) r).name());
        }
        if (visible) {
            Item newItem = select.addItem(r);
            newItem.getItemProperty(CAPTION_PROPERTY_ID).setValue(r.toString());
        }
    }
}
Also used : Item(com.vaadin.v7.data.Item)

Example 12 with Select

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

the class CmsRestoreDeletedDialog method initDeletedResources.

/**
 * Fills the list of resources to select from.<p>
 *
 * @param cms the cms context
 * @param deletedResources the deleted resources
 *
 * @throws CmsException if something goes wrong
 */
private void initDeletedResources(CmsObject cms, List<I_CmsHistoryResource> deletedResources) throws CmsException {
    Collections.sort(deletedResources, new Comparator<I_CmsHistoryResource>() {

        public int compare(I_CmsHistoryResource first, I_CmsHistoryResource second) {
            return first.getRootPath().compareTo(second.getRootPath());
        }
    });
    m_deletedResourceContainer.removeAllComponents();
    m_selectionContainer = new IndexedContainer();
    m_selectionContainer.addContainerProperty(PROP_SELECTED, Boolean.class, Boolean.FALSE);
    m_okButton.setEnabled(!deletedResources.isEmpty());
    if (deletedResources.isEmpty()) {
        m_deletedResourceContainer.addComponent(new Label(CmsVaadinUtils.getMessageText(org.opencms.workplace.list.Messages.GUI_LIST_EMPTY_0)));
    }
    for (I_CmsHistoryResource deleted : deletedResources) {
        I_CmsResourceType resType = OpenCms.getResourceManager().getResourceType(deleted.getTypeId());
        String typeName = resType.getTypeName();
        CmsExplorerTypeSettings explorerType = OpenCms.getWorkplaceManager().getExplorerTypeSetting(typeName);
        String title = cms.getRequestContext().removeSiteRoot(deleted.getRootPath());
        String subtitle = CmsVaadinUtils.getMessageText(org.opencms.ui.Messages.GUI_RESTOREDELETED_DATE_VERSION_2, CmsVfsService.formatDateTime(cms, deleted.getDateLastModified()), "" + deleted.getVersion());
        if (explorerType == null) {
            explorerType = OpenCms.getWorkplaceManager().getExplorerTypeSetting(deleted.isFile() ? CmsResourceTypeUnknownFile.RESOURCE_TYPE_NAME : CmsResourceTypeUnknownFolder.RESOURCE_TYPE_NAME);
        }
        CmsResourceInfo info = new CmsResourceInfo(title, subtitle, CmsResourceUtil.getBigIconResource(explorerType, deleted.getName()));
        info.setWidth("100%");
        HorizontalLayout hl = new HorizontalLayout();
        hl.setWidth("100%");
        CheckBox checkbox = new CheckBox();
        hl.addComponent(checkbox);
        hl.addComponent(info);
        hl.setExpandRatio(info, 1);
        hl.setComponentAlignment(checkbox, Alignment.MIDDLE_LEFT);
        m_selectionContainer.addItem(deleted.getStructureId());
        checkbox.setPropertyDataSource(m_selectionContainer.getItem(deleted.getStructureId()).getItemProperty(PROP_SELECTED));
        m_deletedResourceContainer.addComponent(hl);
    }
}
Also used : I_CmsResourceType(org.opencms.file.types.I_CmsResourceType) CmsResourceInfo(org.opencms.ui.components.CmsResourceInfo) I_CmsHistoryResource(org.opencms.file.history.I_CmsHistoryResource) CheckBox(com.vaadin.v7.ui.CheckBox) IndexedContainer(com.vaadin.v7.data.util.IndexedContainer) Label(com.vaadin.v7.ui.Label) CmsExplorerTypeSettings(org.opencms.workplace.explorer.CmsExplorerTypeSettings) HorizontalLayout(com.vaadin.v7.ui.HorizontalLayout)

Example 13 with Select

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

the class CmsDataViewPanel method updateFilters.

/**
 * Changes the displayed filters to a new set.<p>
 *
 * @param newFilters the new filters
 */
public void updateFilters(List<CmsDataViewFilter> newFilters) {
    if (newFilters.isEmpty()) {
        m_filterContainer.setVisible(false);
    }
    if (m_filters.equals(newFilters)) {
        return;
    }
    m_filterContainer.removeAllComponents();
    m_filters = newFilters;
    m_filterMap.clear();
    for (CmsDataViewFilter filter : newFilters) {
        m_filterMap.put(filter.getId(), filter);
        final CmsDataViewFilter finalFilter = filter;
        ComboBox select = new ComboBox(filter.getNiceName());
        select.setWidth("175px");
        select.setNullSelectionAllowed(false);
        select.setPageLength(0);
        Map<String, String> options = filter.getOptions();
        for (Map.Entry<String, String> entry : options.entrySet()) {
            String key = entry.getKey();
            String value = entry.getValue();
            select.addItem(key);
            select.setItemCaption(key, value);
        }
        select.setValue(filter.getValue());
        if (filter.getHelpText() != null) {
            select.setDescription(filter.getHelpText());
        }
        select.addValueChangeListener(new ValueChangeListener() {

            private static final long serialVersionUID = 1L;

            public void valueChange(ValueChangeEvent event) {
                String newValue = (String) (event.getProperty().getValue());
                updateFilter(finalFilter.getId(), newValue);
            }
        });
        m_filterContainer.addComponent(select);
    }
}
Also used : ValueChangeEvent(com.vaadin.v7.data.Property.ValueChangeEvent) ValueChangeListener(com.vaadin.v7.data.Property.ValueChangeListener) ComboBox(com.vaadin.v7.ui.ComboBox) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) CmsDataViewFilter(org.opencms.widgets.dataview.CmsDataViewFilter)

Example 14 with Select

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

the class CmsCategoryTree method setSelectedCategories.

/**
 * Sets the selected categories.<p>
 *
 * @param categories the categories to select
 */
public void setSelectedCategories(Collection<CmsCategory> categories) {
    for (Entry<CmsCategory, CheckBox> entry : m_checkboxes.entrySet()) {
        entry.getValue().setValue(Boolean.valueOf(categories.contains(entry.getKey())));
        CmsCategory parentCat = (CmsCategory) getParent(entry.getKey());
        if (parentCat != null) {
            setCollapsed(parentCat, false);
        }
    }
}
Also used : CheckBox(com.vaadin.v7.ui.CheckBox) CmsCategory(org.opencms.relations.CmsCategory)

Example 15 with Select

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

the class CmsPropertyTable method init.

/**
 * Fills table with items.<p>
 */
public void init() {
    try {
        List<CmsPropertyDefinition> properties = A_CmsUI.getCmsObject().readAllPropertyDefinitions();
        m_container = new IndexedContainer();
        for (TableColumn col : TableColumn.values()) {
            m_container.addContainerProperty(col, col.getType(), col.getDefaultValue());
        }
        setContainerDataSource(m_container);
        setItemIconPropertyId(TableColumn.Icon);
        setRowHeaderMode(RowHeaderMode.ICON_ONLY);
        setVisibleColumns(TableColumn.Name);
        for (CmsPropertyDefinition prop : properties) {
            Item item = m_container.addItem(prop);
            item.getItemProperty(TableColumn.Name).setValue(prop.getName());
        }
        addItemClickListener(new ItemClickListener() {

            private static final long serialVersionUID = 4807195510202231174L;

            public void itemClick(ItemClickEvent event) {
                setValue(null);
                select(event.getItemId());
                if (event.getButton().equals(MouseButton.RIGHT) || (event.getPropertyId() == null)) {
                    m_menu.setEntries(getMenuEntries(), Collections.singleton(((CmsPropertyDefinition) getValue()).getName()));
                    m_menu.openForTable(event, event.getItemId(), event.getPropertyId(), CmsPropertyTable.this);
                } else if (TableColumn.Name.equals(event.getPropertyId())) {
                    showResources(((CmsPropertyDefinition) getValue()).getName());
                }
            }
        });
        setCellStyleGenerator(new CellStyleGenerator() {

            private static final long serialVersionUID = 1L;

            public String getStyle(Table source, Object itemId, Object propertyId) {
                if (TableColumn.Name.equals(propertyId)) {
                    return " " + OpenCmsTheme.HOVER_COLUMN;
                }
                return null;
            }
        });
    } catch (CmsException e) {
    // 
    }
}
Also used : ItemClickListener(com.vaadin.v7.event.ItemClickEvent.ItemClickListener) Table(com.vaadin.v7.ui.Table) IndexedContainer(com.vaadin.v7.data.util.IndexedContainer) ItemClickEvent(com.vaadin.v7.event.ItemClickEvent) CmsPropertyDefinition(org.opencms.file.CmsPropertyDefinition) Item(com.vaadin.v7.data.Item) CmsException(org.opencms.main.CmsException)

Aggregations

Item (com.vaadin.v7.data.Item)7 CheckBox (com.vaadin.v7.ui.CheckBox)6 IndexedContainer (com.vaadin.v7.data.util.IndexedContainer)4 ComboBox (com.vaadin.v7.ui.ComboBox)4 ArrayList (java.util.ArrayList)4 Button (com.vaadin.ui.Button)3 Label (com.vaadin.ui.Label)3 ItemClickEvent (com.vaadin.v7.event.ItemClickEvent)3 ItemClickListener (com.vaadin.v7.event.ItemClickEvent.ItemClickListener)3 OptionGroup (com.vaadin.v7.ui.OptionGroup)3 Table (com.vaadin.v7.ui.Table)3 List (java.util.List)3 CmsException (org.opencms.main.CmsException)3 VaadinIcons (com.vaadin.icons.VaadinIcons)2 ContentMode (com.vaadin.shared.ui.ContentMode)2 Alignment (com.vaadin.ui.Alignment)2 HorizontalLayout (com.vaadin.ui.HorizontalLayout)2 ValoTheme (com.vaadin.ui.themes.ValoTheme)2 AbstractSelect (com.vaadin.v7.ui.AbstractSelect)2 Date (java.util.Date)2