@Override public void init(Map<String, Object> params) { super.init(params); add.setWindowId("dashboard$WidgetTemplate.browse"); } }
@Override public Action createAction(ListComponent holder) { return AddAction.create(holder); } },
protected Map<String, Object> prepareWindowParams() { Map<String, Object> windowParams = getWindowParams(); Map<String, Object> supplierParams = null; if (windowParamsSupplier != null) { supplierParams = windowParamsSupplier.get(); } Map<String, Object> params = Collections.emptyMap(); if (supplierParams != null || windowParams != null) { params = new HashMap<>(); params.putAll(windowParams != null ? windowParams : Collections.emptyMap()); params.putAll(supplierParams != null ? supplierParams : Collections.emptyMap()); } return params; }
protected AddAction createAddAction(MetaProperty metaProperty, CollectionDatasource propertyDs, Table table, MetaClass propertyMetaClass) { Lookup.Handler addHandler = createAddHandler(metaProperty, propertyDs); AddAction addAction = new AddAction(table, addHandler, OPEN_TYPE); addAction.setWindowId(EntityInspectorBrowse.SCREEN_NAME); HashMap<String, Object> params = new HashMap<>(); params.put("entity", propertyMetaClass.getName()); MetaProperty inverseProperty = metaProperty.getInverse(); if (inverseProperty != null) params.put("parentProperty", inverseProperty.getName()); addAction.setWindowParams(params); addAction.setOpenType(OPEN_TYPE); addAction.setShortcut(configuration.getConfig(ClientConfig.class).getTableAddShortcut()); return addAction; }
/** * 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(); }); } }
/** * Constructor that allows to specify the action name and how the lookup screen opens. * @param target component containing this action * @param handler lookup handler. If null, an instance of {@link DefaultHandler} will be used. * @param openType how to open the editor screen * @param id action's name */ public AddAction(ListComponent target, @Nullable Window.Lookup.Handler handler, OpenType openType, String id) { super(id, null); this.target = target; this.handler = handler; this.openType = openType; Messages messages = AppBeans.get(Messages.NAME); this.caption = messages.getMainMessage("actions.Add"); this.icon = AppBeans.get(Icons.class).get(CubaIcon.ADD_ACTION); Configuration configuration = AppBeans.get(Configuration.NAME); ClientConfig clientConfig = configuration.getConfig(ClientConfig.class); setShortcut(clientConfig.getTableAddShortcut()); }