/** * The simplest constructor. The action uses default name and other parameters. * * @param listComponent listComponent containing this action */ public ExcelAction(ListComponent listComponent) { this(listComponent, AppConfig.createExportDisplay(listComponent.getFrame()), ACTION_ID); }
/** * This method is invoked by the action owner component. * * @param component component invoking the action */ @Override public void actionPerform(Component component) { final Set<Entity> selected = target.getSelected(); target.getFrame().openWindow("admintools$generateScriptsDialog", WindowManager.OpenType.DIALOG, ParamsMap.of("selectedEntities", selected) ); }
/** * Creates a remove builder using list component, e.g. {@link Table} or {@link DataGrid}. * * @param listComponent list component * @param <E> type of entity */ public <E extends Entity> RemoveBuilder<E> builder(ListComponent<E> listComponent) { checkNotNullArgument(listComponent); checkNotNullArgument(listComponent.getFrame()); FrameOwner frameOwner = listComponent.getFrame().getFrameOwner(); Class<E> entityClass; DataUnit items = listComponent.getItems(); if (items instanceof ContainerDataUnit) { entityClass = ((ContainerDataUnit) items).getEntityMetaClass().getJavaClass(); } else { throw new IllegalStateException(String.format("Component %s is not bound to data", listComponent)); } return builder(entityClass, frameOwner) .withListComponent(listComponent); }
/** * Creates a screen builder using list component. * <p> * Example of building a lookup screen for adding row to table / tree component: * <pre>{@code * SomeCustomerListScreen screen = screenBuilders.lookup(customersTable) * .withScreen(SomeCustomerListScreen.class) * .build(); * }</pre> * * @param listComponent {@link Table}, {@link DataGrid} or another component containing the list of entities * @param <E> type of entity * @see #lookup(Class, FrameOwner) */ public <E extends Entity> LookupBuilder<E> lookup(ListComponent<E> listComponent) { checkNotNullArgument(listComponent); checkNotNullArgument(listComponent.getFrame()); FrameOwner frameOwner = listComponent.getFrame().getFrameOwner(); Class<E> entityClass; DataUnit items = listComponent.getItems(); if (items instanceof EntityDataUnit) { entityClass = ((EntityDataUnit) items).getEntityMetaClass().getJavaClass(); } else { throw new IllegalStateException(String.format("Component %s is not bound to data", listComponent)); } LookupBuilder<E> builder = new LookupBuilder<>(frameOwner, entityClass, lookupBuilderProcessor::buildLookup); builder.withListComponent(listComponent); return builder; }
Notifications notifications = getScreenContext(target.getFrame()).getNotifications(); notifications.create(NotificationType.ERROR) .withCaption(messages.getMainMessage("accessDenied.message")) Notifications notifications = getScreenContext(target.getFrame()).getNotifications(); notifications.create(NotificationType.ERROR) .withCaption(messages.getMainMessage("actions.BulkEdit.emptySelection"))
protected void confirmAndRemove(Set<Entity> selected) { Dialogs dialogs = ComponentsHelper.getScreenContext(target.getFrame()).getDialogs(); dialogs.createOptionDialog() .withCaption(getConfirmationTitle()) .withMessage(getConfirmationMessage()) .withActions( new DialogAction(Type.OK, Status.PRIMARY).withHandler(event -> { try { remove(selected); } finally { if (target instanceof Component.Focusable) { ((Component.Focusable) target).focus(); } Set<Entity> filtered = new HashSet<>(selected); filtered.retainAll(target.getDatasource().getItems()); //noinspection unchecked target.setSelected(filtered); } }), new DialogAction(Type.CANCEL).withHandler(event -> { // move focus to owner if (target instanceof Component.Focusable) { ((Component.Focusable) target).focus(); } })) .show(); }
protected void internalOpenEditor(CollectionDatasource datasource, Entity existingItem, Datasource parentDs, Map<String, Object> params) { LegacyFrame frameOwner = (LegacyFrame) target.getFrame().getFrameOwner();
protected void showPivotTable(ShowPivotMode mode) { ParamsMap paramsMap = ParamsMap.of(); if (mode == ALL_ROWS) { paramsMap.pair("dataItems", convertEntitiesToDataItems(target.getDatasource().getItems())); } else { paramsMap.pair("dataItems", convertEntitiesToDataItems(target.getSelected())); } paramsMap.pair("properties", getPropertiesWithLocale()); paramsMap.pair("nativeJson", nativeJson); WindowManager wm = target.getFrame().getWindowManager(); WindowConfig windowConfig = AppBeans.get(WindowConfig.NAME); wm.openWindow(windowConfig.getWindowInfo(SCREEN_ID), WindowManager.OpenType.NEW_TAB, paramsMap.create()); }
@SuppressWarnings("unchecked") protected void internalOpenEditor(CollectionDatasource datasource, Entity newItem, Datasource parentDs, Map<String, Object> params) { LegacyFrame frameOwner = (LegacyFrame) target.getFrame().getFrameOwner(); AbstractEditor window = frameOwner.openEditor(getWindowId(), newItem, getOpenType(), params, parentDs);
/** * This method is invoked by action owner component. Don't override it, there are special methods to * customize behaviour below. * * @param component component invoking action */ @Override public void actionPerform(Component component) { if (beforeActionPerformedHandler != null) { if (!beforeActionPerformedHandler.beforeActionPerformed()) { return; } } Map<String, Object> params = prepareWindowParams(); Window.Lookup.Handler handler = getHandler(); Window.Lookup.Handler itemsHandler = handler != null ? handler : new DefaultHandler(); WindowManager wm = (WindowManager) ComponentsHelper.getScreenContext(target.getFrame()).getScreens(); WindowInfo windowInfo = AppBeans.get(WindowConfig.class).getWindowInfo(getWindowId()); Window lookupWindow = wm.openLookup(windowInfo, itemsHandler, getOpenType(), params); if (target instanceof Component.Focusable) { lookupWindow.addCloseListener(actionId -> { // move focus to owner ((Component.Focusable) target).focus(); }); } }
); LegacyFrame frameOwner = (LegacyFrame) target.getFrame().getFrameOwner();
@Override public void actionPerform(Component component) { if (beforeActionPerformedHandler != null) { if (!beforeActionPerformedHandler.beforeActionPerformed()) return; } Messages messages = AppBeans.get(Messages.NAME); if (target.getSelected().isEmpty() || target.getDatasource().size() <= 1) { showPivotTable(ALL_ROWS); } else { Action[] actions = new Action[]{ new BaseAction("actions.showPivotAction.SELECTED_ROWS") .withCaption(messages.getMainMessage("actions.showPivotAction.SELECTED_ROWS")) .withHandler(event -> showPivotTable(SELECTED_ROWS)), new BaseAction("actions.showPivotAction.ALL_ROWS") .withCaption(messages.getMainMessage("actions.showPivotAction.ALL_ROWS")) .withHandler(event -> showPivotTable(ALL_ROWS)), new DialogAction(DialogAction.Type.CANCEL) }; WindowManager wm = target.getFrame().getWindowManager(); wm.showOptionDialog( messages.getMainMessage("actions.showPivotAction.dialogTitle"), messages.getMainMessage("actions.showPivotAction.dialogMessage"), Frame.MessageType.CONFIRMATION, actions); } }
Messages messages = AppBeans.get(Messages.NAME); Notifications notifications = getScreenContext(target.getFrame()).getNotifications(); notifications.create(NotificationType.ERROR) .withCaption(messages.getMainMessage("accessDenied.message")) Messages messages = AppBeans.get(Messages.NAME); Notifications notifications = getScreenContext(target.getFrame()).getNotifications(); notifications.create(NotificationType.HUMANIZED) .withCaption(messages.getMainMessage("actions.BulkEdit.emptySelection")) .create(); WindowManager wm = ((WindowManager) getScreenContext(target.getFrame()).getScreens()); WindowInfo windowInfo = AppBeans.get(WindowConfig.class).getWindowInfo("bulkEditor");