Search in sources :

Example 56 with CheckBox

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

the class CmsHistoryDialog method buildHistoryTable.

/**
 * Builds a table containing the different versions of a resource.<p>
 *
 * @param historyList the list of history resource beans from which to construct the table
 *
 * @return the table
 */
private Table buildHistoryTable(CmsHistoryResourceCollection historyList) {
    final CmsObject cms = A_CmsUI.getCmsObject();
    try {
        CmsBeanTableBuilder<CmsHistoryRow> builder = CmsBeanTableBuilder.newInstance(CmsHistoryRow.class, A_CmsUI.get().getDisplayType().toString());
        List<CmsHistoryRow> rows = Lists.newArrayList();
        for (CmsHistoryResourceBean bean : historyList.getResources()) {
            final CmsHistoryResourceBean beanFinal = bean;
            final CmsUUID structureId = bean.getStructureId();
            CmsHistoryRow row = new CmsHistoryRow(bean);
            rows.add(row);
            m_group1.add(row.getCheckBoxV1());
            m_group2.add(row.getCheckBoxV2());
            final Integer version = bean.getVersion().getVersionNumber();
            if (version != null) {
                row.getRestoreButton().addClickListener(new ClickListener() {

                    private static final long serialVersionUID = 1L;

                    public void buttonClick(ClickEvent event) {
                        actionRestore(cms, structureId, version);
                    }
                });
            }
            row.getPreviewButton().addClickListener(new ClickListener() {

                private static final long serialVersionUID = 1L;

                @SuppressWarnings("synthetic-access")
                public void buttonClick(ClickEvent event) {
                    actionPreview(beanFinal);
                }
            });
            for (CheckBox checkBox : Arrays.asList(row.getCheckBoxV1(), row.getCheckBoxV2())) {
                checkBox.setData(bean);
            }
        }
        Table result = builder.buildTable(rows);
        result.setPageLength(Math.min(rows.size(), 12));
        result.setSortEnabled(false);
        return result;
    } catch (Exception e) {
        return null;
    }
}
Also used : CmsHistoryResourceBean(org.opencms.gwt.shared.CmsHistoryResourceBean) Table(com.vaadin.v7.ui.Table) ClickEvent(com.vaadin.ui.Button.ClickEvent) CmsRpcException(org.opencms.gwt.CmsRpcException) CmsException(org.opencms.main.CmsException) CmsObject(org.opencms.file.CmsObject) CheckBox(com.vaadin.v7.ui.CheckBox) CmsUUID(org.opencms.util.CmsUUID) ClickListener(com.vaadin.ui.Button.ClickListener)

Example 57 with CheckBox

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

the class CmsLogicalCheckboxGroup method remove.

/**
 * Removes a check box from the group.<p>
 *
 * @param checkBox the check box
 */
public void remove(CheckBox checkBox) {
    m_checkboxes.remove(checkBox);
    if (m_selected == checkBox) {
        m_selected = null;
    }
    ValueChangeListener listener = m_listeners.get(checkBox);
    if (listener != null) {
        checkBox.removeValueChangeListener(m_listeners.get(checkBox));
    }
}
Also used : ValueChangeListener(com.vaadin.v7.data.Property.ValueChangeListener)

Example 58 with CheckBox

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

the class CmsLogicalCheckboxGroup method add.

/**
 * Adds a check box to the group.<p>
 *
 * @param checkBox the check box to add
 */
public void add(final CheckBox checkBox) {
    checkBox.setValue(Boolean.FALSE);
    m_checkboxes.add(checkBox);
    ValueChangeListener listener = new ValueChangeListener() {

        private static final long serialVersionUID = 1L;

        @SuppressWarnings("synthetic-access")
        public void valueChange(ValueChangeEvent event) {
            if (m_runningEvent) {
                return;
            } else {
                try {
                    m_runningEvent = true;
                    if (((Boolean) event.getProperty().getValue()).booleanValue()) {
                        if ((m_selected != null) && (m_selected != checkBox)) {
                            m_selected.setValue(Boolean.FALSE);
                        }
                        setActiveCheckBox(checkBox);
                    } else {
                        setActiveCheckBox(null);
                        m_selected = null;
                    }
                // TODO Auto-generated method stub
                } finally {
                    m_runningEvent = false;
                }
            }
        }
    };
    checkBox.addValueChangeListener(listener);
    m_listeners.put(checkBox, listener);
}
Also used : ValueChangeEvent(com.vaadin.v7.data.Property.ValueChangeEvent) ValueChangeListener(com.vaadin.v7.data.Property.ValueChangeListener)

Example 59 with CheckBox

use of com.vaadin.v7.ui.CheckBox 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 60 with CheckBox

use of com.vaadin.v7.ui.CheckBox 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

CheckBox (com.vaadin.v7.ui.CheckBox)40 CheckBox (com.codename1.ui.CheckBox)18 Label (com.vaadin.ui.Label)15 ComboBox (com.vaadin.v7.ui.ComboBox)14 Button (com.codename1.ui.Button)12 TextField (com.vaadin.v7.ui.TextField)12 I18nProperties (de.symeda.sormas.api.i18n.I18nProperties)12 Form (com.codename1.ui.Form)11 Disease (de.symeda.sormas.api.Disease)11 Captions (de.symeda.sormas.api.i18n.Captions)11 DistrictReferenceDto (de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto)11 NullableOptionGroup (de.symeda.sormas.ui.utils.NullableOptionGroup)11 List (java.util.List)11 Container (com.codename1.ui.Container)10 FacadeProvider (de.symeda.sormas.api.FacadeProvider)10 Strings (de.symeda.sormas.api.i18n.Strings)10 Label (com.codename1.ui.Label)9 TextField (com.codename1.ui.TextField)9 HorizontalLayout (com.vaadin.ui.HorizontalLayout)9 AbstractEditForm (de.symeda.sormas.ui.utils.AbstractEditForm)9