Search in sources :

Example 1 with ExcelExportAction

use of io.jmix.uiexport.action.ExcelExportAction in project jmix by jmix-framework.

the class EntityInspectorBrowser method createExcelExportAction.

private ExcelExportAction createExcelExportAction(Table table) {
    ExcelExportAction excelExportAction = actions.create(ExcelExportAction.class);
    excelExportAction.setTarget(table);
    return excelExportAction;
}
Also used : ExcelExportAction(io.jmix.uiexport.action.ExcelExportAction)

Example 2 with ExcelExportAction

use of io.jmix.uiexport.action.ExcelExportAction in project jmix by jmix-framework.

the class EntityInspectorBrowser method createButtonsPanel.

protected void createButtonsPanel(Table table) {
    ButtonsPanel buttonsPanel = table.getButtonsPanel();
    Button createButton = uiComponents.create(Button.class);
    CreateAction createAction = createCreateAction(table);
    table.addAction(createAction);
    createButton.setAction(createAction);
    createButton.setIcon(icons.get(JmixIcon.CREATE_ACTION));
    Button editButton = uiComponents.create(Button.class);
    EditAction editAction = createEditAction(table);
    table.addAction(editAction);
    editButton.setAction(editAction);
    editButton.setIcon(icons.get(JmixIcon.EDIT_ACTION));
    Button removeButton = uiComponents.create(Button.class);
    RemoveAction removeAction = createRemoveAction(table);
    if (metadataTools.isSoftDeletable(selectedMeta.getJavaClass()) && ShowMode.ALL.equals(showMode.getValue())) {
        removeAction.setAfterActionPerformedHandler(removedItems -> entitiesDl.load());
    }
    table.addAction(removeAction);
    removeButton.setAction(removeAction);
    removeButton.setIcon(icons.get(JmixIcon.REMOVE_ACTION));
    removeButton.setFrame(getWindow().getFrame());
    Button excelButton = uiComponents.create(Button.class);
    ExcelExportAction excelExportAction = createExcelExportAction(table);
    excelButton.setAction(excelExportAction);
    excelButton.setFrame(getWindow().getFrame());
    Button refreshButton = uiComponents.create(Button.class);
    RefreshAction refreshAction = createRefreshAction(table);
    refreshButton.setAction(refreshAction);
    refreshButton.setIcon(icons.get(JmixIcon.REFRESH_ACTION));
    refreshButton.setFrame(getWindow().getFrame());
    PopupButton exportPopupButton = uiComponents.create(PopupButton.class);
    exportPopupButton.setCaption(messages.getMessage(EntityInspectorBrowser.class, "export"));
    exportPopupButton.setIcon(icons.get(JmixIcon.DOWNLOAD));
    ExportAction exportJSONAction = new ExportAction("exportJSON");
    exportJSONAction.setFormat(JSON);
    exportJSONAction.setTable(table);
    exportJSONAction.setMetaClass(selectedMeta);
    exportPopupButton.addAction(exportJSONAction);
    ExportAction exportZIPAction = new ExportAction("exportZIP");
    exportZIPAction.setFormat(ZIP);
    exportZIPAction.setTable(table);
    exportZIPAction.setMetaClass(selectedMeta);
    exportPopupButton.addAction(exportZIPAction);
    FileUploadField importUpload = uiComponents.create(FileUploadField.class);
    importUpload.setPasteZone(tableBox);
    importUpload.setPermittedExtensions(Sets.newHashSet(".json", ".zip"));
    importUpload.setUploadButtonIcon(icons.get(JmixIcon.UPLOAD));
    importUpload.setUploadButtonCaption(messages.getMessage(EntityInspectorBrowser.class, "import"));
    importUpload.addFileUploadSucceedListener(event -> {
        byte[] fileBytes = importUpload.getValue();
        String fileName = event.getFileName();
        try {
            Collection<Object> importedEntities;
            if (JSON.getFileExt().equals(Files.getFileExtension(fileName))) {
                String content = new String(fileBytes, StandardCharsets.UTF_8);
                importedEntities = entityImportExport.importEntitiesFromJson(content, createEntityImportPlan(content, selectedMeta));
            } else {
                importedEntities = entityImportExport.importEntitiesFromZIP(fileBytes, createEntityImportPlan(selectedMeta));
            }
            notifications.create(Notifications.NotificationType.HUMANIZED).withDescription(messages.formatMessage(EntityInspectorBrowser.class, "importSuccessful", importedEntities.size())).show();
        } catch (Exception e) {
            notifications.create(Notifications.NotificationType.ERROR).withCaption(messages.getMessage(EntityInspectorBrowser.class, "importFailed")).withDescription(messages.formatMessage(EntityInspectorBrowser.class, "importFailedMessage", fileName, nullToEmpty(e.getMessage()))).show();
            log.error("Entities import error", e);
        }
        entitiesDl.load();
    });
    Button restoreButton = uiComponents.create(Button.class);
    Action restoreAction = createRestoreAction(table);
    table.addAction(restoreAction);
    restoreButton.setAction(restoreAction);
    Action showEntityInfoAction = createShowEntityInfoAction(table);
    table.addAction(showEntityInfoAction);
    Button wipeOutButton = null;
    if (metadataTools.isSoftDeletable(selectedMeta.getJavaClass())) {
        wipeOutButton = uiComponents.create(Button.class);
        Action wipeOutAction = createWipeOutAction(table);
        table.addAction(wipeOutAction);
        wipeOutButton.setAction(wipeOutAction);
    }
    buttonsPanel.add(createButton);
    buttonsPanel.add(editButton);
    buttonsPanel.add(removeButton);
    buttonsPanel.add(refreshButton);
    buttonsPanel.add(excelButton);
    buttonsPanel.add(exportPopupButton);
    buttonsPanel.add(importUpload);
    buttonsPanel.add(restoreButton);
    if (wipeOutButton != null) {
        buttonsPanel.add(wipeOutButton);
    }
}
Also used : ItemTrackingAction(io.jmix.ui.action.ItemTrackingAction) CreateAction(io.jmix.ui.action.list.CreateAction) EditAction(io.jmix.ui.action.list.EditAction) Action(io.jmix.ui.action.Action) DialogAction(io.jmix.ui.action.DialogAction) RefreshAction(io.jmix.ui.action.list.RefreshAction) ListAction(io.jmix.ui.action.ListAction) ShowEntityInfoAction(io.jmix.datatoolsui.action.ShowEntityInfoAction) ExcelExportAction(io.jmix.uiexport.action.ExcelExportAction) RemoveAction(io.jmix.ui.action.list.RemoveAction) EditAction(io.jmix.ui.action.list.EditAction) RefreshAction(io.jmix.ui.action.list.RefreshAction) ExcelExportAction(io.jmix.uiexport.action.ExcelExportAction) ExcelExportAction(io.jmix.uiexport.action.ExcelExportAction) CreateAction(io.jmix.ui.action.list.CreateAction) RemoveAction(io.jmix.ui.action.list.RemoveAction)

Example 3 with ExcelExportAction

use of io.jmix.uiexport.action.ExcelExportAction in project jmix by jmix-framework.

the class ShowReportTableScreen method createTable.

protected Table createTable(String dataSetName, KeyValueCollectionContainer collectionContainer, Map<String, Set<JmixTableData.ColumnInfo>> headerMap) {
    Table table = uiComponents.create(GroupTable.class);
    table.setId(dataSetName + "Table");
    Set<JmixTableData.ColumnInfo> headers = headerMap.get(dataSetName);
    createColumns(collectionContainer, table, headers);
    table.setItems(new ContainerGroupTableItems(collectionContainer));
    table.setWidth("100%");
    table.setMultiSelect(true);
    table.setColumnControlVisible(false);
    table.setColumnReorderingAllowed(false);
    Action excelExportAction = actions.create(ExcelExportAction.ID);
    Button excelButton = uiComponents.create(Button.class);
    excelButton.setAction(excelExportAction);
    ButtonsPanel buttonsPanel = uiComponents.create(ButtonsPanel.class);
    table.setButtonsPanel(buttonsPanel);
    table.addAction(excelExportAction);
    buttonsPanel.add(excelButton);
    return table;
}
Also used : Action(io.jmix.ui.action.Action) ExcelExportAction(io.jmix.uiexport.action.ExcelExportAction) ContainerGroupTableItems(io.jmix.ui.component.data.table.ContainerGroupTableItems)

Aggregations

ExcelExportAction (io.jmix.uiexport.action.ExcelExportAction)3 Action (io.jmix.ui.action.Action)2 ShowEntityInfoAction (io.jmix.datatoolsui.action.ShowEntityInfoAction)1 DialogAction (io.jmix.ui.action.DialogAction)1 ItemTrackingAction (io.jmix.ui.action.ItemTrackingAction)1 ListAction (io.jmix.ui.action.ListAction)1 CreateAction (io.jmix.ui.action.list.CreateAction)1 EditAction (io.jmix.ui.action.list.EditAction)1 RefreshAction (io.jmix.ui.action.list.RefreshAction)1 RemoveAction (io.jmix.ui.action.list.RemoveAction)1 ContainerGroupTableItems (io.jmix.ui.component.data.table.ContainerGroupTableItems)1