Search in sources :

Example 1 with ItemStyleGenerator

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

the class CmsCopyMoveDialog method initForm.

/**
 * Initializes the form fields.<p>
 *
 * @return the form component
 */
private FormLayout initForm() {
    FormLayout form = new FormLayout();
    form.setWidth("100%");
    m_targetPath = new CmsPathSelectField();
    m_targetPath.setCaption(CmsVaadinUtils.getMessageText(org.opencms.workplace.commons.Messages.GUI_COPY_MOVE_TARGET_0));
    m_targetPath.setFileSelectCaption(CmsVaadinUtils.getMessageText(Messages.GUI_COPY_MOVE_SELECT_TARGET_CAPTION_0));
    m_targetPath.setResourceFilter(CmsResourceFilter.ONLY_VISIBLE_NO_DELETED.addRequireFolder());
    m_targetPath.setWidth("100%");
    form.addComponent(m_targetPath);
    if (m_dialogMode != DialogMode.move) {
        m_actionCombo = new ComboBox();
        m_actionCombo.setCaption(CmsVaadinUtils.getMessageText(org.opencms.ui.Messages.GUI_COPYPAGE_COPY_MODE_0));
        m_actionCombo.setNullSelectionAllowed(false);
        m_actionCombo.setNewItemsAllowed(false);
        m_actionCombo.setWidth("100%");
        if (m_context.getResources().size() == 1) {
            if (m_context.getResources().get(0).isFile()) {
                m_actionCombo.addItem(Action.copy_all);
                m_actionCombo.setItemCaption(Action.copy_all, CmsVaadinUtils.getMessageText(org.opencms.workplace.commons.Messages.GUI_COPY_AS_NEW_0));
                m_actionCombo.addItem(Action.copy_sibling_all);
                m_actionCombo.setItemCaption(Action.copy_sibling_all, CmsVaadinUtils.getMessageText(org.opencms.workplace.commons.Messages.GUI_CREATE_SIBLING_0));
                if (m_dialogMode == DialogMode.copy_and_move) {
                    m_actionCombo.addItem(Action.move);
                    m_actionCombo.setItemCaption(Action.move, CmsVaadinUtils.getMessageText(org.opencms.workplace.commons.Messages.GUI_COPY_MOVE_MOVE_FILE_0));
                }
            } else {
                CmsResource folder = m_context.getResources().get(0);
                m_hasContainerPageDefaultFile = hasContainerPageDefaultFile(folder);
                if (m_hasContainerPageDefaultFile) {
                    m_actionCombo.addItem(Action.container_page_automatic);
                    m_actionCombo.setItemCaption(Action.container_page_automatic, CmsVaadinUtils.getMessageText(Messages.GUI_COPY_MOVE_AUTOMATIC_0));
                    m_actionCombo.addItem(Action.container_page_copy);
                    m_actionCombo.setItemCaption(Action.container_page_copy, CmsVaadinUtils.getMessageText(Messages.GUI_COPY_MOVE_CONTAINERPAGE_COPY_0));
                    m_actionCombo.addItem(Action.container_page_reuse);
                    m_actionCombo.setItemCaption(Action.container_page_reuse, CmsVaadinUtils.getMessageText(Messages.GUI_COPY_MOVE_CONTAINERPAGE_REUSE_0));
                }
                if (CmsResourceTypeFolderSubSitemap.isSubSitemap(folder)) {
                    m_actionCombo.addItem(Action.sub_sitemap);
                    m_actionCombo.setItemCaption(Action.sub_sitemap, CmsVaadinUtils.getMessageText(Messages.GUI_COPY_MOVE_SUBSITEMAP_0));
                }
                m_actionCombo.addItem(Action.copy_sibling_mixed);
                m_actionCombo.setItemCaption(Action.copy_sibling_mixed, CmsVaadinUtils.getMessageText(org.opencms.workplace.commons.Messages.GUI_COPY_ALL_NO_SIBLINGS_0));
                m_actionCombo.addItem(Action.copy_all);
                m_actionCombo.setItemCaption(Action.copy_all, CmsVaadinUtils.getMessageText(org.opencms.workplace.commons.Messages.GUI_COPY_ALL_0));
                m_actionCombo.addItem(Action.copy_sibling_all);
                m_actionCombo.setItemCaption(Action.copy_sibling_all, CmsVaadinUtils.getMessageText(org.opencms.workplace.commons.Messages.GUI_COPY_MULTI_CREATE_SIBLINGS_0));
                if (m_dialogMode == DialogMode.copy_and_move) {
                    m_actionCombo.addItem(Action.move);
                    m_actionCombo.setItemCaption(Action.move, CmsVaadinUtils.getMessageText(org.opencms.workplace.commons.Messages.GUI_COPY_MOVE_MOVE_FOLDER_0));
                }
            }
        } else {
            m_actionCombo.addItem(Action.copy_sibling_mixed);
            m_actionCombo.setItemCaption(Action.copy_sibling_mixed, CmsVaadinUtils.getMessageText(org.opencms.workplace.commons.Messages.GUI_COPY_ALL_NO_SIBLINGS_0));
            m_actionCombo.addItem(Action.copy_all);
            m_actionCombo.setItemCaption(Action.copy_all, CmsVaadinUtils.getMessageText(org.opencms.workplace.commons.Messages.GUI_COPY_ALL_0));
            m_actionCombo.addItem(Action.copy_sibling_all);
            m_actionCombo.setItemCaption(Action.copy_sibling_all, CmsVaadinUtils.getMessageText(org.opencms.workplace.commons.Messages.GUI_COPY_MULTI_CREATE_SIBLINGS_0));
            if (m_dialogMode == DialogMode.copy_and_move) {
                m_actionCombo.addItem(Action.move);
                m_actionCombo.setItemCaption(Action.move, CmsVaadinUtils.getMessageText(org.opencms.workplace.commons.Messages.GUI_COPY_MOVE_MOVE_RESOURCES_0));
            }
        }
        m_actionCombo.setItemStyleGenerator(new ItemStyleGenerator() {

            private static final long serialVersionUID = 1L;

            public String getStyle(ComboBox source, Object itemId) {
                String style = null;
                if (m_defaultActions.contains(itemId)) {
                    style = "bold";
                }
                return style;
            }
        });
        form.addComponent(m_actionCombo);
        m_actionCombo.addValueChangeListener(event -> updateOverwriteExisting());
    }
    if (m_context.getResources().size() > 1) {
        m_overwriteExisting = new CheckBox(CmsVaadinUtils.getMessageText(org.opencms.workplace.commons.Messages.GUI_COPY_MULTI_OVERWRITE_0));
        m_overwriteExisting.setValue(Boolean.FALSE);
        form.addComponent(m_overwriteExisting);
        updateOverwriteExisting();
    }
    return form;
}
Also used : FormLayout(com.vaadin.ui.FormLayout) CmsResource(org.opencms.file.CmsResource) ComboBox(com.vaadin.v7.ui.ComboBox) CheckBox(com.vaadin.v7.ui.CheckBox) CmsPathSelectField(org.opencms.ui.components.fileselect.CmsPathSelectField) CmsObject(org.opencms.file.CmsObject) ItemStyleGenerator(com.vaadin.v7.ui.ComboBox.ItemStyleGenerator)

Aggregations

FormLayout (com.vaadin.ui.FormLayout)1 CheckBox (com.vaadin.v7.ui.CheckBox)1 ComboBox (com.vaadin.v7.ui.ComboBox)1 ItemStyleGenerator (com.vaadin.v7.ui.ComboBox.ItemStyleGenerator)1 CmsObject (org.opencms.file.CmsObject)1 CmsResource (org.opencms.file.CmsResource)1 CmsPathSelectField (org.opencms.ui.components.fileselect.CmsPathSelectField)1