mirror of
https://gitee.com/jmix/cuba.git
synced 2024-12-05 04:38:10 +08:00
PL-8102 Excel action silently exports only one selected row without suggesting to export all rows
This commit is contained in:
parent
dd6426b7e4
commit
9cfd6a5137
@ -20,6 +20,7 @@ import com.haulmont.cuba.core.global.AppBeans;
|
||||
import com.haulmont.cuba.gui.AppConfig;
|
||||
import com.haulmont.cuba.gui.components.*;
|
||||
import com.haulmont.cuba.gui.components.DialogAction.Type;
|
||||
import com.haulmont.cuba.gui.components.Frame.MessageType;
|
||||
import com.haulmont.cuba.gui.export.ExcelExporter;
|
||||
import com.haulmont.cuba.gui.export.ExportDisplay;
|
||||
import com.haulmont.cuba.gui.theme.ThemeConstantsManager;
|
||||
@ -85,40 +86,36 @@ public class ExcelAction extends BaseAction implements Action.HasBeforeActionPer
|
||||
if (!beforeActionPerformedHandler.beforeActionPerformed())
|
||||
return;
|
||||
}
|
||||
if (table.getSelected().size() > 0) {
|
||||
if (table.getSelected().size() > 1) {
|
||||
String title = messages.getMainMessage("actions.exportSelectedTitle");
|
||||
String caption = messages.getMainMessage("actions.exportSelectedCaption");
|
||||
Action[] actions = new Action[]{
|
||||
new AbstractAction("actions.export.SELECTED_ROWS", Status.PRIMARY) {
|
||||
{
|
||||
setCaption(messages.getMainMessage(getId()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerform(Component component) {
|
||||
export(ExportMode.SELECTED_ROWS);
|
||||
}
|
||||
},
|
||||
new AbstractAction("actions.export.ALL_ROWS") {
|
||||
{
|
||||
setCaption(messages.getMainMessage(getId()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerform(Component component) {
|
||||
export(ExportMode.ALL_ROWS);
|
||||
}
|
||||
},
|
||||
new DialogAction(Type.CANCEL)
|
||||
};
|
||||
Frame frame = table.getFrame();
|
||||
frame.showOptionDialog(title, caption, Frame.MessageType.CONFIRMATION, actions);
|
||||
} else {
|
||||
export(ExportMode.SELECTED_ROWS);
|
||||
}
|
||||
} else {
|
||||
if (table.getSelected().isEmpty() || table.getDatasource().size() <= 1) {
|
||||
export(ExportMode.ALL_ROWS);
|
||||
} else {
|
||||
String title = messages.getMainMessage("actions.exportSelectedTitle");
|
||||
String caption = messages.getMainMessage("actions.exportSelectedCaption");
|
||||
|
||||
AbstractAction exportSelectedAction = new AbstractAction("actions.export.SELECTED_ROWS", Status.PRIMARY) {
|
||||
@Override
|
||||
public void actionPerform(Component component) {
|
||||
export(ExportMode.SELECTED_ROWS);
|
||||
}
|
||||
};
|
||||
exportSelectedAction.setCaption(messages.getMainMessage(exportSelectedAction.getId()));
|
||||
|
||||
AbstractAction exportAllAction = new AbstractAction("actions.export.ALL_ROWS") {
|
||||
@Override
|
||||
public void actionPerform(Component component) {
|
||||
export(ExportMode.ALL_ROWS);
|
||||
}
|
||||
};
|
||||
exportAllAction.setCaption(messages.getMainMessage(exportAllAction.getId()));
|
||||
|
||||
Action[] actions = new Action[]{
|
||||
exportSelectedAction,
|
||||
exportAllAction,
|
||||
new DialogAction(Type.CANCEL)
|
||||
};
|
||||
Frame frame = table.getFrame();
|
||||
frame.showOptionDialog(title, caption, MessageType.CONFIRMATION, actions);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user