Search in sources :

Example 1 with ShowEntityInfoAction

use of io.jmix.datatoolsui.action.ShowEntityInfoAction in project jmix by jmix-framework.

the class EntityInspectorBrowser method createShowEntityInfoAction.

private ShowEntityInfoAction createShowEntityInfoAction(Table table) {
    ShowEntityInfoAction showEntityInfoAction = actions.create(ShowEntityInfoAction.class);
    showEntityInfoAction.setTarget(table);
    return showEntityInfoAction;
}
Also used : ShowEntityInfoAction(io.jmix.datatoolsui.action.ShowEntityInfoAction)

Example 2 with ShowEntityInfoAction

use of io.jmix.datatoolsui.action.ShowEntityInfoAction 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)

Aggregations

ShowEntityInfoAction (io.jmix.datatoolsui.action.ShowEntityInfoAction)2 Action (io.jmix.ui.action.Action)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 ExcelExportAction (io.jmix.uiexport.action.ExcelExportAction)1