Search in sources :

Example 21 with VerticalLayout

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

the class CmsTextDiff method diff.

/**
 * @see org.opencms.ui.dialogs.history.diff.I_CmsDiffProvider#diff(org.opencms.file.CmsObject, org.opencms.gwt.shared.CmsHistoryResourceBean, org.opencms.gwt.shared.CmsHistoryResourceBean)
 */
public Optional<Component> diff(CmsObject cms, CmsHistoryResourceBean v1, CmsHistoryResourceBean v2) throws CmsException {
    CmsResource resource1 = A_CmsAttributeDiff.readResource(cms, v1);
    String encoding = CmsLocaleManager.getResourceEncoding(cms, resource1);
    I_CmsResourceType type = OpenCms.getResourceManager().getResourceType(resource1);
    if ((type instanceof CmsResourceTypeXmlContent) || (type instanceof CmsResourceTypePlain) || (type instanceof CmsResourceTypeJsp) || (type instanceof CmsResourceTypeXmlPage) || (type instanceof CmsResourceTypePointer) || (type instanceof CmsResourceTypeBinary)) {
        CmsResource resource2 = A_CmsAttributeDiff.readResource(cms, v2);
        String path1 = resource1.getRootPath();
        String path2 = resource2.getRootPath();
        CmsFile file1 = cms.readFile(resource1);
        CmsFile file2 = cms.readFile(resource2);
        byte[] content1 = file1.getContents();
        byte[] content2 = file2.getContents();
        String originalSource = null;
        String copySource = null;
        I_CmsTextExtractor textExtractor = null;
        // only if both files have contents
        if ((content1.length > 0) && (content2.length > 0)) {
            if (path1.endsWith(".pdf") && path2.endsWith(".pdf")) {
                textExtractor = CmsExtractorPdf.getExtractor();
            } else if (path1.endsWith(".doc") && path2.endsWith(".doc")) {
                textExtractor = CmsExtractorMsOfficeOLE2.getExtractor();
            } else if (path1.endsWith(".xls") && path2.endsWith(".xls")) {
                textExtractor = CmsExtractorMsOfficeOLE2.getExtractor();
            } else if (path1.endsWith(".rtf") && path2.endsWith(".rtf")) {
                textExtractor = CmsExtractorRtf.getExtractor();
            } else if (path1.endsWith(".ppt") && path2.endsWith(".ppt")) {
                textExtractor = CmsExtractorMsOfficeOLE2.getExtractor();
            }
        }
        if (textExtractor != null) {
            try {
                // extract the content
                originalSource = textExtractor.extractText(content1).getContent();
                copySource = textExtractor.extractText(content2).getContent();
            } catch (Exception e) {
                // something goes wrong on extracting content
                // set the content to null, so the content dialog will not be shown
                originalSource = null;
                copySource = null;
                LOG.error(e.getMessage(), e);
            }
        } else if ((type instanceof CmsResourceTypePlain) || (type instanceof CmsResourceTypeJsp) || (type instanceof CmsResourceTypePointer)) {
            try {
                originalSource = new String(content1, encoding);
                copySource = new String(content2, encoding);
            } catch (UnsupportedEncodingException e) {
                LOG.error(e.getLocalizedMessage(), e);
            }
        }
        if ((copySource == null) || (originalSource == null)) {
            return Optional.absent();
        }
        try {
            CmsTextDiffPanel diffPanel = new CmsTextDiffPanel(originalSource, copySource, false, true);
            diffPanel.setWidth("100%");
            Panel panel = new Panel(CmsVaadinUtils.getMessageText(Messages.GUI_HISTORY_DIALOG_TEXT_COMPARISON_CAPTION_0));
            panel.setWidth("100%");
            VerticalLayout vl = new VerticalLayout();
            vl.setMargin(true);
            vl.addComponent(diffPanel);
            panel.setContent(vl);
            return Optional.<Component>fromNullable(panel);
        } catch (Exception e) {
            LOG.error(e.getLocalizedMessage(), e);
            return Optional.absent();
        }
    } else {
        return Optional.absent();
    }
}
Also used : CmsResourceTypePlain(org.opencms.file.types.CmsResourceTypePlain) CmsResourceTypeXmlPage(org.opencms.file.types.CmsResourceTypeXmlPage) CmsResourceTypeXmlContent(org.opencms.file.types.CmsResourceTypeXmlContent) I_CmsTextExtractor(org.opencms.search.extractors.I_CmsTextExtractor) UnsupportedEncodingException(java.io.UnsupportedEncodingException) CmsResourceTypeJsp(org.opencms.file.types.CmsResourceTypeJsp) CmsException(org.opencms.main.CmsException) IOException(java.io.IOException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) I_CmsResourceType(org.opencms.file.types.I_CmsResourceType) Panel(com.vaadin.ui.Panel) CmsFile(org.opencms.file.CmsFile) CmsResource(org.opencms.file.CmsResource) VerticalLayout(com.vaadin.v7.ui.VerticalLayout) CmsResourceTypePointer(org.opencms.file.types.CmsResourceTypePointer) Component(com.vaadin.ui.Component) CmsResourceTypeBinary(org.opencms.file.types.CmsResourceTypeBinary)

Example 22 with VerticalLayout

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

the class CmsPermissionDialog method addEntryTableToLayout.

/**
 * Adds list of entries to layout.<p>
 *
 * @param entries the ace list
 * @param layout layout
 * @param editable boolean
 * @param inheritedRes boolean
 */
private void addEntryTableToLayout(List<CmsAccessControlEntry> entries, VerticalLayout layout, boolean editable, boolean inheritedRes) {
    final CmsPermissionViewTable table = new CmsPermissionViewTable(m_cms, entries, editable, inheritedRes, m_parents, this);
    HorizontalLayout hl = new HorizontalLayout();
    Label label = new Label(CmsVaadinUtils.getMessageText(Messages.GUI_PERMISSION_COUNT_1, new Integer(table.getContainerDataSource().size())));
    label.addStyleName("o-report");
    hl.addComponent(label);
    TextField tableFilter = new TextField();
    tableFilter.setIcon(FontOpenCms.FILTER);
    tableFilter.setInputPrompt(CmsVaadinUtils.getMessageText(org.opencms.ui.apps.Messages.GUI_EXPLORER_FILTER_0));
    tableFilter.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON);
    tableFilter.setWidth("200px");
    tableFilter.addTextChangeListener(new TextChangeListener() {

        private static final long serialVersionUID = 1L;

        public void textChange(TextChangeEvent event) {
            table.filterTable(event.getText());
        }
    });
    hl.addComponent(tableFilter);
    hl.setWidth("100%");
    hl.setExpandRatio(label, 1);
    hl.setMargin(true);
    hl.setComponentAlignment(tableFilter, com.vaadin.ui.Alignment.MIDDLE_RIGHT);
    if (table.getContainerDataSource().size() == 0) {
        layout.addComponent(CmsVaadinUtils.getInfoLayout(Messages.GUI_PERMISSION_EMPTY_0));
    } else {
        layout.addComponent(hl);
        layout.addComponent(table);
        CmsVaadinUtils.centerWindow(this);
    }
}
Also used : TextChangeEvent(com.vaadin.v7.event.FieldEvents.TextChangeEvent) Label(com.vaadin.v7.ui.Label) TextField(com.vaadin.v7.ui.TextField) TextChangeListener(com.vaadin.v7.event.FieldEvents.TextChangeListener) HorizontalLayout(com.vaadin.v7.ui.HorizontalLayout)

Example 23 with VerticalLayout

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

the class CmsPermissionViewTable method getLayoutFromEntry.

/**
 * Makes item for table.<p>
 *
 * @param cms CmsObject
 * @param entry ACE
 * @param view permission table
 * @param resPath parentResource (or null)
 * @return VerticalLayout
 */
private VerticalLayout getLayoutFromEntry(CmsObject cms, CmsAccessControlEntry entry, final CmsPermissionView view, String resPath) {
    VerticalLayout res = new VerticalLayout();
    res.setSpacing(false);
    I_CmsPrincipal principal = null;
    try {
        principal = CmsPrincipal.readPrincipalIncludingHistory(cms, entry.getPrincipal());
    } catch (CmsException e) {
        principal = new CmsGroup(entry.getPrincipal(), null, "", "", 0);
    }
    if (principal != null) {
        CmsResourceInfo info = CmsAccountsApp.getPrincipalInfo(principal);
        if (view.isEditable()) {
            CssLayout cssl = new CssLayout();
            Button removeButton = new Button(FontOpenCms.TRASH_SMALL);
            removeButton.addStyleName("borderless o-toolbar-button o-resourceinfo-toolbar o-toolbar-icon-visible");
            removeButton.addClickListener(new ClickListener() {

                private static final long serialVersionUID = -6112693137800596485L;

                public void buttonClick(ClickEvent event) {
                    view.deletePermissionSet();
                }
            });
            cssl.addComponent(removeButton);
            info.setButtonWidget(cssl);
        }
        res.addComponent(info);
        if (resPath != null) {
            Label resLabel = new Label(CmsVaadinUtils.getMessageText(Messages.GUI_PERMISSION_INHERITED_FROM_1, resPath));
            resLabel.addStyleName("o-report");
            res.addComponent(resLabel);
        }
    }
    res.addComponent(view);
    return res;
}
Also used : I_CmsPrincipal(org.opencms.security.I_CmsPrincipal) CmsResourceInfo(org.opencms.ui.components.CmsResourceInfo) CssLayout(com.vaadin.ui.CssLayout) Button(com.vaadin.ui.Button) CmsGroup(org.opencms.file.CmsGroup) ClickEvent(com.vaadin.ui.Button.ClickEvent) CmsException(org.opencms.main.CmsException) Label(com.vaadin.v7.ui.Label) VerticalLayout(com.vaadin.v7.ui.VerticalLayout) ClickListener(com.vaadin.ui.Button.ClickListener)

Example 24 with VerticalLayout

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

the class CaseArchivingController method addAdditionalArchiveFields.

@Override
protected void addAdditionalArchiveFields(VerticalLayout verticalLayout) {
    archiveWithContacts = new CheckBox();
    archiveWithContacts.setCaption(I18nProperties.getString(Strings.confirmationArchiveCaseWithContacts));
    archiveWithContacts.setValue(false);
    verticalLayout.addComponent(archiveWithContacts);
}
Also used : CheckBox(com.vaadin.v7.ui.CheckBox)

Example 25 with VerticalLayout

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

the class CaseContactsView method createStatusFilterBar.

public HorizontalLayout createStatusFilterBar() {
    HorizontalLayout statusFilterLayout = new HorizontalLayout();
    statusFilterLayout.setSpacing(true);
    statusFilterLayout.setWidth("100%");
    statusFilterLayout.addStyleName(CssStyles.VSPACE_3);
    statusButtons = new HashMap<>();
    Button statusAll = ButtonHelper.createButton(Captions.all, e -> {
        criteria.contactStatus(null);
        navigateTo(criteria);
    }, ValoTheme.BUTTON_BORDERLESS, CssStyles.BUTTON_FILTER);
    statusAll.setCaptionAsHtml(true);
    statusFilterLayout.addComponent(statusAll);
    statusButtons.put(statusAll, I18nProperties.getCaption(Captions.all));
    activeStatusButton = statusAll;
    for (ContactStatus status : ContactStatus.values()) {
        Button statusButton = ButtonHelper.createButton(status.toString(), e -> {
            criteria.contactStatus(status);
            navigateTo(criteria);
        }, ValoTheme.BUTTON_BORDERLESS, CssStyles.BUTTON_FILTER, CssStyles.BUTTON_FILTER_LIGHT);
        statusButton.setData(status);
        statusButton.setCaptionAsHtml(true);
        statusFilterLayout.addComponent(statusButton);
        statusButtons.put(statusButton, status.toString());
    }
    statusFilterLayout.setExpandRatio(statusFilterLayout.getComponent(statusFilterLayout.getComponentCount() - 1), 1);
    // Bulk operation dropdown
    if (UserProvider.getCurrent().hasUserRight(UserRight.PERFORM_BULK_OPERATIONS)) {
        statusFilterLayout.setWidth(100, Unit.PERCENTAGE);
        MenuBar bulkOperationsDropdown = MenuBarHelper.createDropDown(Captions.bulkActions, new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.bulkEdit), VaadinIcons.ELLIPSIS_H, selectedItem -> {
            ControllerProvider.getContactController().showBulkContactDataEditComponent(grid.asMultiSelect().getSelectedItems(), getCaseRef().getUuid());
        }), new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.bulkCancelFollowUp), VaadinIcons.CLOSE, selectedItem -> {
            ControllerProvider.getContactController().cancelFollowUpOfAllSelectedItems(grid.asMultiSelect().getSelectedItems(), () -> navigateTo(criteria));
        }), new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.bulkLostToFollowUp), VaadinIcons.UNLINK, selectedItem -> {
            ControllerProvider.getContactController().setAllSelectedItemsToLostToFollowUp(grid.asMultiSelect().getSelectedItems(), () -> navigateTo(criteria));
        }), new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.bulkDelete), VaadinIcons.TRASH, selectedItem -> {
            ControllerProvider.getContactController().deleteAllSelectedItems(grid.asMultiSelect().getSelectedItems(), () -> navigateTo(criteria));
        }));
        statusFilterLayout.addComponent(bulkOperationsDropdown);
        statusFilterLayout.setComponentAlignment(bulkOperationsDropdown, Alignment.TOP_RIGHT);
        statusFilterLayout.setExpandRatio(bulkOperationsDropdown, 1);
    }
    if (UserProvider.getCurrent().hasUserRight(UserRight.CONTACT_IMPORT)) {
        Button importButton = ButtonHelper.createIconButton(Captions.actionImport, VaadinIcons.UPLOAD, e -> {
            Window popupWindow = VaadinUiUtil.showPopupWindow(new CaseContactsImportLayout(FacadeProvider.getCaseFacade().getCaseDataByUuid(criteria.getCaze().getUuid())));
            popupWindow.setCaption(I18nProperties.getString(Strings.headingImportCaseContacts));
            popupWindow.addCloseListener(c -> {
                grid.reload();
            });
        }, ValoTheme.BUTTON_PRIMARY);
        statusFilterLayout.addComponent(importButton);
        statusFilterLayout.setComponentAlignment(importButton, Alignment.MIDDLE_RIGHT);
        if (!UserProvider.getCurrent().hasUserRight(UserRight.PERFORM_BULK_OPERATIONS)) {
            statusFilterLayout.setExpandRatio(importButton, 1);
        }
    }
    if (UserProvider.getCurrent().hasUserRight(UserRight.CONTACT_EXPORT)) {
        VerticalLayout exportLayout = new VerticalLayout();
        exportLayout.setSpacing(true);
        exportLayout.setMargin(true);
        exportLayout.addStyleName(CssStyles.LAYOUT_MINIMAL);
        exportLayout.setWidth(200, Unit.PIXELS);
        PopupButton exportButton = ButtonHelper.createIconPopupButton(Captions.export, VaadinIcons.DOWNLOAD, exportLayout);
        statusFilterLayout.addComponent(exportButton);
        statusFilterLayout.setComponentAlignment(exportButton, Alignment.MIDDLE_RIGHT);
        if (!UserProvider.getCurrent().hasUserRight(UserRight.PERFORM_BULK_OPERATIONS)) {
            statusFilterLayout.setExpandRatio(exportButton, 1);
        }
        StreamResource streamResource = GridExportStreamResource.createStreamResourceWithSelectedItems(grid, () -> viewConfiguration.isInEagerMode() ? this.grid.asMultiSelect().getSelectedItems() : null, ExportEntityName.CONTACTS);
        addExportButton(streamResource, exportButton, exportLayout, VaadinIcons.TABLE, Captions.exportBasic, Descriptions.descExportButton);
        StreamResource extendedExportStreamResource = ContactDownloadUtil.createContactExportResource(grid.getCriteria(), this::getSelectedRows, null);
        addExportButton(extendedExportStreamResource, exportButton, exportLayout, VaadinIcons.FILE_TEXT, Captions.exportDetailed, Descriptions.descDetailedExportButton);
        Button btnCustomExport = ButtonHelper.createIconButton(Captions.exportCustom, VaadinIcons.FILE_TEXT, e -> {
            ControllerProvider.getCustomExportController().openContactExportWindow(grid.getCriteria(), this::getSelectedRows);
        }, ValoTheme.BUTTON_PRIMARY);
        btnCustomExport.setDescription(I18nProperties.getString(Strings.infoCustomExport));
        btnCustomExport.setWidth(100, Unit.PERCENTAGE);
        exportLayout.addComponent(btnCustomExport);
        // Warning if no filters have been selected
        Label warningLabel = new Label(I18nProperties.getString(Strings.infoExportNoFilters));
        warningLabel.setWidth(100, Unit.PERCENTAGE);
        exportLayout.addComponent(warningLabel);
        warningLabel.setVisible(false);
        exportButton.addClickListener(e -> warningLabel.setVisible(!criteria.hasAnyFilterActive()));
    }
    if (UserProvider.getCurrent().hasUserRight(UserRight.CONTACT_CREATE)) {
        final CaseDataDto caseDto = FacadeProvider.getCaseFacade().getCaseDataByUuid(this.getCaseRef().getUuid());
        final ExpandableButton lineListingButton = new ExpandableButton(Captions.lineListing).expand(e -> ControllerProvider.getContactController().openLineListingWindow(caseDto));
        statusFilterLayout.addComponent(lineListingButton);
        final Button newButton = ButtonHelper.createIconButtonWithCaption(Captions.contactNewContact, I18nProperties.getPrefixCaption(ContactDto.I18N_PREFIX, Captions.contactNewContact), VaadinIcons.PLUS_CIRCLE, e -> ControllerProvider.getContactController().create(this.getCaseRef()), ValoTheme.BUTTON_PRIMARY);
        statusFilterLayout.addComponent(newButton);
        statusFilterLayout.setComponentAlignment(newButton, Alignment.MIDDLE_RIGHT);
    }
    statusFilterLayout.addStyleName("top-bar");
    activeStatusButton = statusAll;
    return statusFilterLayout;
}
Also used : ContactCriteria(de.symeda.sormas.api.contact.ContactCriteria) I18nProperties(de.symeda.sormas.api.i18n.I18nProperties) Alignment(com.vaadin.ui.Alignment) Window(com.vaadin.ui.Window) DetailSubComponentWrapper(de.symeda.sormas.ui.utils.DetailSubComponentWrapper) ControllerProvider(de.symeda.sormas.ui.ControllerProvider) ExportEntityName(de.symeda.sormas.ui.utils.ExportEntityName) ContactDownloadUtil(de.symeda.sormas.ui.utils.ContactDownloadUtil) ViewModelProviders(de.symeda.sormas.ui.ViewModelProviders) CssStyles(de.symeda.sormas.ui.utils.CssStyles) ExpandableButton(de.symeda.sormas.ui.utils.components.expandablebutton.ExpandableButton) ContactIndexDto(de.symeda.sormas.api.contact.ContactIndexDto) MenuBarHelper(de.symeda.sormas.ui.utils.MenuBarHelper) VaadinIcons(com.vaadin.icons.VaadinIcons) ComboBoxHelper(de.symeda.sormas.ui.utils.ComboBoxHelper) ShortcutAction(com.vaadin.event.ShortcutAction) UserProvider(de.symeda.sormas.ui.UserProvider) ValoTheme(com.vaadin.ui.themes.ValoTheme) MenuBar(com.vaadin.ui.MenuBar) ComboBox(com.vaadin.v7.ui.ComboBox) Set(java.util.Set) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) Collectors(java.util.stream.Collectors) ContactClassification(de.symeda.sormas.api.contact.ContactClassification) ContactGrid(de.symeda.sormas.ui.contact.ContactGrid) ContactDto(de.symeda.sormas.api.contact.ContactDto) TextField(com.vaadin.v7.ui.TextField) Descriptions(de.symeda.sormas.api.i18n.Descriptions) RegionReferenceDto(de.symeda.sormas.api.infrastructure.region.RegionReferenceDto) StreamResource(com.vaadin.server.StreamResource) VaadinUiUtil(de.symeda.sormas.ui.utils.VaadinUiUtil) FacadeProvider(de.symeda.sormas.api.FacadeProvider) VerticalLayout(com.vaadin.ui.VerticalLayout) GridExportStreamResource(de.symeda.sormas.ui.utils.GridExportStreamResource) HashMap(java.util.HashMap) PopupButton(org.vaadin.hene.popupbutton.PopupButton) ViewConfiguration(de.symeda.sormas.ui.utils.ViewConfiguration) Label(com.vaadin.ui.Label) ButtonHelper(de.symeda.sormas.ui.utils.ButtonHelper) ContentMode(com.vaadin.shared.ui.ContentMode) ContactStatus(de.symeda.sormas.api.contact.ContactStatus) DistrictReferenceDto(de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto) UserDto(de.symeda.sormas.api.user.UserDto) Captions(de.symeda.sormas.api.i18n.Captions) UserReferenceDto(de.symeda.sormas.api.user.UserReferenceDto) UserRight(de.symeda.sormas.api.user.UserRight) Button(com.vaadin.ui.Button) LayoutUtil(de.symeda.sormas.ui.utils.LayoutUtil) HorizontalLayout(com.vaadin.ui.HorizontalLayout) CaseContactsImportLayout(de.symeda.sormas.ui.contact.importer.CaseContactsImportLayout) Strings(de.symeda.sormas.api.i18n.Strings) Collections(java.util.Collections) Window(com.vaadin.ui.Window) ExpandableButton(de.symeda.sormas.ui.utils.components.expandablebutton.ExpandableButton) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) Label(com.vaadin.ui.Label) MenuBar(com.vaadin.ui.MenuBar) HorizontalLayout(com.vaadin.ui.HorizontalLayout) MenuBarHelper(de.symeda.sormas.ui.utils.MenuBarHelper) PopupButton(org.vaadin.hene.popupbutton.PopupButton) StreamResource(com.vaadin.server.StreamResource) GridExportStreamResource(de.symeda.sormas.ui.utils.GridExportStreamResource) ExpandableButton(de.symeda.sormas.ui.utils.components.expandablebutton.ExpandableButton) PopupButton(org.vaadin.hene.popupbutton.PopupButton) Button(com.vaadin.ui.Button) ContactStatus(de.symeda.sormas.api.contact.ContactStatus) CaseContactsImportLayout(de.symeda.sormas.ui.contact.importer.CaseContactsImportLayout) VerticalLayout(com.vaadin.ui.VerticalLayout)

Aggregations

VerticalLayout (com.vaadin.v7.ui.VerticalLayout)34 VerticalLayout (com.vaadin.ui.VerticalLayout)25 Button (com.vaadin.ui.Button)22 Label (com.vaadin.ui.Label)18 Label (com.vaadin.v7.ui.Label)17 HorizontalLayout (com.vaadin.ui.HorizontalLayout)16 Window (com.vaadin.ui.Window)12 Component (com.vaadin.ui.Component)11 ValoTheme (com.vaadin.ui.themes.ValoTheme)11 I18nProperties (de.symeda.sormas.api.i18n.I18nProperties)11 VaadinIcons (com.vaadin.icons.VaadinIcons)10 Panel (com.vaadin.ui.Panel)10 TextField (com.vaadin.v7.ui.TextField)10 Strings (de.symeda.sormas.api.i18n.Strings)10 ButtonHelper (de.symeda.sormas.ui.utils.ButtonHelper)10 CssStyles (de.symeda.sormas.ui.utils.CssStyles)10 Captions (de.symeda.sormas.api.i18n.Captions)9 Alignment (com.vaadin.ui.Alignment)8 CheckBox (com.vaadin.v7.ui.CheckBox)8 OptionGroup (com.vaadin.v7.ui.OptionGroup)8