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();
}
}
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);
}
}
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;
}
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);
}
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;
}
Aggregations