Search in sources :

Example 1 with ItemClickEvent

use of com.vaadin.v7.event.ItemClickEvent in project opencms-core by alkacon.

the class CmsRoleTable method init.

/**
 * initializes table.
 *
 * @param roles list of user
 */
private void init(List<CmsRole> roles) {
    CmsRole.applySystemRoleOrder(roles);
    m_menu = new CmsContextMenu();
    m_menu.setAsTableContextMenu(this);
    m_container = new IndexedContainer();
    for (TableProperty prop : TableProperty.values()) {
        m_container.addContainerProperty(prop, prop.getType(), prop.getDefault());
        setColumnHeader(prop, prop.getName());
    }
    setContainerDataSource(m_container);
    setItemIconPropertyId(TableProperty.Icon);
    setRowHeaderMode(RowHeaderMode.ICON_ONLY);
    setColumnWidth(null, 40);
    setSelectable(true);
    setVisibleColumns(TableProperty.Name, TableProperty.OU);
    for (CmsRole role : roles) {
        Item item = m_container.addItem(role);
        item.getItemProperty(TableProperty.Name).setValue(role.getName(A_CmsUI.get().getLocale()));
        item.getItemProperty(TableProperty.Description).setValue(role.getDescription(A_CmsUI.get().getLocale()));
        item.getItemProperty(TableProperty.OU).setValue(role.getOuFqn());
    }
    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(((CmsRole) getValue()).getId().getStringValue()));
                m_menu.openForTable(event, event.getItemId(), event.getPropertyId(), CmsRoleTable.this);
            } else if (event.getButton().equals(MouseButton.LEFT) && event.getPropertyId().equals(TableProperty.Name)) {
                updateApp((CmsRole) getValue());
            }
        }
    });
    setCellStyleGenerator(new CellStyleGenerator() {

        private static final long serialVersionUID = 1L;

        public String getStyle(Table source, Object itemId, Object propertyId) {
            if (TableProperty.Name.equals(propertyId)) {
                return " " + OpenCmsTheme.HOVER_COLUMN;
            }
            return "";
        }
    });
    setVisibleColumns(TableProperty.Name, TableProperty.Description, TableProperty.OU);
}
Also used : Item(com.vaadin.v7.data.Item) CmsContextMenu(org.opencms.ui.contextmenu.CmsContextMenu) CmsRole(org.opencms.security.CmsRole) ItemClickListener(com.vaadin.v7.event.ItemClickEvent.ItemClickListener) Table(com.vaadin.v7.ui.Table) IndexedContainer(com.vaadin.v7.data.util.IndexedContainer) CmsObject(org.opencms.file.CmsObject) ItemClickEvent(com.vaadin.v7.event.ItemClickEvent)

Example 2 with ItemClickEvent

use of com.vaadin.v7.event.ItemClickEvent in project opencms-core by alkacon.

the class CmsProjectsTable method onItemClick.

/**
 * Handles the table item clicks.<p>
 *
 * @param event the click event
 */
@SuppressWarnings("unchecked")
void onItemClick(ItemClickEvent event) {
    if (!event.isCtrlKey() && !event.isShiftKey()) {
        // don't interfere with multi-selection using control key
        if (event.getButton().equals(MouseButton.RIGHT) || (event.getPropertyId() == null)) {
            CmsUUID itemId = (CmsUUID) event.getItemId();
            Set<CmsUUID> value = (Set<CmsUUID>) getValue();
            if (value == null) {
                select(itemId);
            } else if (!value.contains(itemId)) {
                setValue(null);
                select(itemId);
            }
            m_menu.setEntries(getMenuEntries(), (Set<CmsUUID>) getValue());
            m_menu.openForTable(event, this);
        } else if (event.getButton().equals(MouseButton.LEFT) && PROP_NAME.equals(event.getPropertyId())) {
            Item item = event.getItem();
            CmsUUID id = (CmsUUID) item.getItemProperty(PROP_ID).getValue();
            m_manager.openSubView(A_CmsWorkplaceApp.addParamToState(CmsProjectManager.PATH_NAME_FILES, "projectId", id.toString()), true);
        } else if (event.getButton().equals(MouseButton.LEFT) && PROP_RESOURCES.equals(event.getPropertyId())) {
            Item item = event.getItem();
            showProjectResources(item);
        }
    }
}
Also used : Item(com.vaadin.v7.data.Item) Set(java.util.Set) CmsUUID(org.opencms.util.CmsUUID)

Example 3 with ItemClickEvent

use of com.vaadin.v7.event.ItemClickEvent in project SORMAS-Project by hzi-braunschweig.

the class AbstractTableField method createEditColumn.

protected void createEditColumn(Table table) {
    ColumnGenerator editColumnGenerator = new ColumnGenerator() {

        @Override
        public Object generateCell(Table source, Object itemId, Object columnId) {
            return generateEditCell(itemId);
        }
    };
    table.addGeneratedColumn(EDIT_COLUMN_ID, editColumnGenerator);
    table.setColumnWidth(EDIT_COLUMN_ID, 20);
    table.setColumnHeader(EDIT_COLUMN_ID, "");
    table.addItemClickListener(new ItemClickListener() {

        @SuppressWarnings("unchecked")
        @Override
        public void itemClick(ItemClickEvent event) {
            if (event.isDoubleClick() || EDIT_COLUMN_ID.equals(event.getPropertyId())) {
                final E entry = (E) event.getItemId();
                if (entry != null) {
                    editEntry(entry, false, result -> onEntryChanged(result));
                }
            }
        }
    });
}
Also used : Arrays(java.util.Arrays) ItemClickListener(com.vaadin.v7.event.ItemClickEvent.ItemClickListener) ConversionException(com.vaadin.v7.data.util.converter.Converter.ConversionException) ColumnGenerator(com.vaadin.v7.ui.Table.ColumnGenerator) Table(com.vaadin.v7.ui.Table) I18nProperties(de.symeda.sormas.api.i18n.I18nProperties) VerticalLayout(com.vaadin.ui.VerticalLayout) LoggerFactory(org.slf4j.LoggerFactory) Alignment(com.vaadin.ui.Alignment) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) EntityDto(de.symeda.sormas.api.EntityDto) BeanItemContainer(com.vaadin.v7.data.util.BeanItemContainer) CssStyles(de.symeda.sormas.ui.utils.CssStyles) ObjectUtils(org.apache.commons.lang3.ObjectUtils) FieldAccessCellStyleGenerator(de.symeda.sormas.ui.utils.FieldAccessCellStyleGenerator) Label(com.vaadin.ui.Label) VaadinIcons(com.vaadin.icons.VaadinIcons) LinkedHashSet(java.util.LinkedHashSet) ButtonHelper(de.symeda.sormas.ui.utils.ButtonHelper) ValoTheme(com.vaadin.ui.themes.ValoTheme) Property(com.vaadin.v7.data.Property) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) DataHelper(de.symeda.sormas.api.utils.DataHelper) Collection(java.util.Collection) Set(java.util.Set) InvalidValueException(com.vaadin.v7.data.Validator.InvalidValueException) Captions(de.symeda.sormas.api.i18n.Captions) Consumer(java.util.function.Consumer) ItemSetChangeEvent(com.vaadin.v7.data.Container.ItemSetChangeEvent) List(java.util.List) Button(com.vaadin.ui.Button) ItemClickEvent(com.vaadin.v7.event.ItemClickEvent) HorizontalLayout(com.vaadin.ui.HorizontalLayout) CustomField(com.vaadin.v7.ui.CustomField) ItemSetChangeListener(com.vaadin.v7.data.Container.ItemSetChangeListener) CloneFailedException(org.apache.commons.lang3.exception.CloneFailedException) UiFieldAccessCheckers(de.symeda.sormas.api.utils.fieldaccess.UiFieldAccessCheckers) Component(com.vaadin.ui.Component) Table(com.vaadin.v7.ui.Table) ItemClickListener(com.vaadin.v7.event.ItemClickEvent.ItemClickListener) ColumnGenerator(com.vaadin.v7.ui.Table.ColumnGenerator) ItemClickEvent(com.vaadin.v7.event.ItemClickEvent)

Example 4 with ItemClickEvent

use of com.vaadin.v7.event.ItemClickEvent 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)

Example 5 with ItemClickEvent

use of com.vaadin.v7.event.ItemClickEvent in project opencms-core by alkacon.

the class CmsGroupTable method init.

/**
 * Initializes the table.<p>
 *
 * @param ou name
 */
protected void init(String ou) {
    m_menu = new CmsContextMenu();
    m_menu.setAsTableContextMenu(this);
    m_container = new IndexedContainer();
    for (TableProperty prop : TableProperty.values()) {
        m_container.addContainerProperty(prop, prop.getType(), prop.getDefault());
        setColumnHeader(prop, prop.getName());
    }
    m_app.addGroupContainerProperties(m_container);
    setContainerDataSource(m_container);
    setItemIconPropertyId(TableProperty.Icon);
    setRowHeaderMode(RowHeaderMode.ICON_ONLY);
    setColumnWidth(null, 40);
    setSelectable(true);
    setMultiSelect(true);
    for (CmsGroup group : m_groups) {
        Item item = m_container.addItem(group);
        m_app.fillGroupItem(item, group, m_indirects);
    }
    addItemClickListener(new ItemClickListener() {

        private static final long serialVersionUID = 4807195510202231174L;

        @SuppressWarnings("unchecked")
        public void itemClick(ItemClickEvent event) {
            changeValueIfNotMultiSelect(event.getItemId());
            if (event.getButton().equals(MouseButton.RIGHT) || (event.getPropertyId() == null)) {
                Set<String> groupIds = new HashSet<String>();
                for (CmsGroup group : (Set<CmsGroup>) getValue()) {
                    groupIds.add(group.getId().getStringValue());
                }
                m_menu.setEntries(getMenuEntries(), groupIds);
                m_menu.openForTable(event, event.getItemId(), event.getPropertyId(), CmsGroupTable.this);
                return;
            }
            if (event.getButton().equals(MouseButton.LEFT) && event.getPropertyId().equals(TableProperty.Name)) {
                updateApp((((Set<CmsGroup>) getValue()).iterator().next()).getId().getStringValue());
            }
        }
    });
    setCellStyleGenerator(new CellStyleGenerator() {

        private static final long serialVersionUID = 1L;

        public String getStyle(Table source, Object itemId, Object propertyId) {
            String css = "";
            if (((Boolean) source.getItem(itemId).getItemProperty(TableProperty.INDIRECT).getValue()).booleanValue()) {
                css += " " + OpenCmsTheme.TABLE_CELL_DISABLED + " " + OpenCmsTheme.EXPIRED;
            }
            if (TableProperty.Name.equals(propertyId)) {
                css += " " + OpenCmsTheme.HOVER_COLUMN;
            }
            return css;
        }
    });
    setVisibleColumns(TableProperty.Name, TableProperty.Description, TableProperty.OU);
}
Also used : CmsContextMenu(org.opencms.ui.contextmenu.CmsContextMenu) ItemClickListener(com.vaadin.v7.event.ItemClickEvent.ItemClickListener) HashSet(java.util.HashSet) Set(java.util.Set) Table(com.vaadin.v7.ui.Table) IndexedContainer(com.vaadin.v7.data.util.IndexedContainer) CmsGroup(org.opencms.file.CmsGroup) ItemClickEvent(com.vaadin.v7.event.ItemClickEvent) Item(com.vaadin.v7.data.Item) CmsObject(org.opencms.file.CmsObject)

Aggregations

Item (com.vaadin.v7.data.Item)6 ItemClickEvent (com.vaadin.v7.event.ItemClickEvent)6 ItemClickListener (com.vaadin.v7.event.ItemClickEvent.ItemClickListener)6 Table (com.vaadin.v7.ui.Table)6 IndexedContainer (com.vaadin.v7.data.util.IndexedContainer)5 Set (java.util.Set)4 CmsObject (org.opencms.file.CmsObject)4 CmsContextMenu (org.opencms.ui.contextmenu.CmsContextMenu)4 HashSet (java.util.HashSet)3 CmsException (org.opencms.main.CmsException)3 Component (com.vaadin.ui.Component)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 VaadinIcons (com.vaadin.icons.VaadinIcons)1 Alignment (com.vaadin.ui.Alignment)1 Button (com.vaadin.ui.Button)1 HorizontalLayout (com.vaadin.ui.HorizontalLayout)1 Label (com.vaadin.ui.Label)1 VerticalLayout (com.vaadin.ui.VerticalLayout)1 ValoTheme (com.vaadin.ui.themes.ValoTheme)1