Search in sources :

Example 1 with I_CmsDiffProvider

use of org.opencms.ui.dialogs.history.diff.I_CmsDiffProvider in project opencms-core by alkacon.

the class CmsHistoryDialog method tryCompare.

/**
 * Opens the 'compare' view for the two selected versions of the resource.<p>
 *
 * @throws CmsException if something goes wrong
 */
public void tryCompare() throws CmsException {
    CmsObject cms = A_CmsUI.getCmsObject();
    CheckBox check1 = m_group1.getSelected();
    CheckBox check2 = m_group2.getSelected();
    if (!canCompare(check1, check2)) {
        Notification.show(CmsVaadinUtils.getMessageText(Messages.GUI_HISTORY_DIALOG_SELECT_TWO_DIFFERENT_VERSIONS_0));
    } else {
        CmsHistoryResourceBean bean1 = (CmsHistoryResourceBean) (check1.getData());
        CmsHistoryResourceBean bean2 = (CmsHistoryResourceBean) (check2.getData());
        VerticalLayout diffContainer = new VerticalLayout();
        diffContainer.setSpacing(true);
        for (I_CmsDiffProvider diff : m_diffs) {
            Optional<Component> optionalDiff = diff.diff(cms, bean1, bean2);
            if (optionalDiff.isPresent()) {
                diffContainer.addComponent(optionalDiff.get());
            }
        }
        Panel panel = new Panel();
        panel.setSizeFull();
        diffContainer.setWidth("100%");
        diffContainer.setMargin(true);
        panel.addStyleName(ValoTheme.PANEL_BORDERLESS);
        panel.setContent(diffContainer);
        openChildDialog(CmsHistoryDialog.this, panel, CmsVaadinUtils.getMessageText(Messages.GUI_HISTORY_DIALOG_COMPARE_0));
    }
}
Also used : Panel(com.vaadin.ui.Panel) CmsHistoryResourceBean(org.opencms.gwt.shared.CmsHistoryResourceBean) CmsObject(org.opencms.file.CmsObject) I_CmsDiffProvider(org.opencms.ui.dialogs.history.diff.I_CmsDiffProvider) CheckBox(com.vaadin.v7.ui.CheckBox) VerticalLayout(com.vaadin.v7.ui.VerticalLayout) Component(com.vaadin.ui.Component)

Aggregations

Component (com.vaadin.ui.Component)1 Panel (com.vaadin.ui.Panel)1 CheckBox (com.vaadin.v7.ui.CheckBox)1 VerticalLayout (com.vaadin.v7.ui.VerticalLayout)1 CmsObject (org.opencms.file.CmsObject)1 CmsHistoryResourceBean (org.opencms.gwt.shared.CmsHistoryResourceBean)1 I_CmsDiffProvider (org.opencms.ui.dialogs.history.diff.I_CmsDiffProvider)1