protected void initRoles() { rolesTable.addAction(new ExcludeAction(rolesTable, false, true) { @Override public boolean isEnabled() { return super.isEnabled() && isUpdatePermitted(); } }); addRoleBtn.setAction(new AbstractAction("actions.Add") { @Override public void actionPerform(Component component) { if (lookupRolesDs.getItem() != null && !rolesDs.containsItem(lookupRolesDs.getItem().getId())) { rolesDs.addItem(lookupRolesDs.getItem()); } } @Override public boolean isEnabled() { return super.isEnabled() && isUpdatePermitted(); } }); }
@Override public void initFrame() { addSimpleRegionAction = new AddSimpleRegionAction(); addTabulatedRegionAction = new AddTabulatedRegionAction(); wizard.addSimpleRegionBtn.setAction(addSimpleRegionAction); wizard.addTabulatedRegionBtn.setAction(addTabulatedRegionAction); wizard.addRegionPopupBtn.addAction(addSimpleRegionAction); wizard.addRegionPopupBtn.addAction(addTabulatedRegionAction); wizard.regionsTable.addGeneratedColumn("regionsGeneratedColumn", new ReportRegionTableColumnGenerator()); editRegionAction = new EditRegionAction(); removeRegionAction = new RemoveRegionAction(); wizard.moveDownBtn.setAction(new OrderableItemMoveAction<>("downItem", Direction.DOWN, wizard.regionsTable)); wizard.moveUpBtn.setAction(new OrderableItemMoveAction<>("upItem", Direction.UP, wizard.regionsTable)); wizard.removeBtn.setAction(removeRegionAction); } }
protected Button createActionBtn(String actionName, List<String> options) { if (!isActionAllowed(actionName)) { return null; } Button button = uiComponents.create(Button.class); button.setAction(filterActions.get(actionName)); if (options.contains("no-caption")) { button.setCaption(null); button.setDescription(filterActions.get(actionName).getCaption()); } if (options.contains("no-icon")) { button.setIcon(null); } return button; }
protected void loadInvoke(Button component, boolean enabled, boolean visible, Element element) { if (!StringUtils.isBlank(element.attributeValue("action"))) { return; } final String methodName = element.attributeValue("invoke"); if (StringUtils.isBlank(methodName)) { return; } String actionBaseId = component.getId(); if (StringUtils.isEmpty(actionBaseId)) { actionBaseId = methodName; } DeclarativeAction action = new DeclarativeAction(actionBaseId + "_invoke", component.getCaption(), component.getDescription(), component.getIcon(), enabled, visible, methodName, component.getFrame() ); component.setAction(action); }
protected void initDownloadAction() { wizard.downloadTemplateFile.setCaption(wizard.generateTemplateFileName(wizard.templateFileFormat.getValue().toString().toLowerCase())); wizard.downloadTemplateFile.setAction(new AbstractAction("generateNewTemplateAndGet") { @Override public void actionPerform(Component component) { byte[] newTemplate = null; try { wizard.getItem().setName(wizard.reportName.getValue().toString()); newTemplate = wizard.reportWizardService.generateTemplate(wizard.getItem(), wizard.templateFileFormat.getValue()); ExportDisplay exportDisplay = AppConfig.createExportDisplay((Frame) wizard.getComponent("saveStep")); exportDisplay.show(new ByteArrayDataProvider(newTemplate), wizard.downloadTemplateFile.getCaption(), ExportFormat.getByExtension(wizard.templateFileFormat.getValue().toString().toLowerCase())); } catch (TemplateGenerationException e) { wizard.showNotification(wizard.getMessage("templateGenerationException"), Frame.NotificationType.WARNING); } if (newTemplate != null) { wizard.lastGeneratedTemplate = newTemplate; } } }); }
protected Button createButton(Action action) { Button removeButton = factory.createComponent(Button.class); removeButton.setAction(action); removeButton.addStyleName(DashboardStyleConstants.DASHBOARD_EDIT_BUTTON); removeButton.setIcon(action.getIcon()); removeButton.setCaption(""); return removeButton; }
@Override public void initFrame() { initReportTypeOptionGroup(); initTemplateFormatLookupField(); initEntityLookupField(); wizard.entity.addValueChangeListener(new ChangeReportNameListener()); wizard.setQueryButton.setAction(new SetQueryAction()); }
protected void initCancelAction() { cancelProcessBtn = componentsFactory.createComponent(Button.class); cancelProcessBtn.setWidth(buttonWidth); cancelProcessAction = new CancelProcessAction(procInstance); cancelProcessAction.addBeforeActionPredicate(beforeCancelProcessPredicate); cancelProcessAction.addAfterActionListener(afterCancelProcessListener); cancelProcessBtn.setAction(cancelProcessAction); actionsBox.add(cancelProcessBtn); }
@Override public void setSidePanelToggleButton(Button toggleButton) { if (this.toggleButton != null) { toggleButton.setAction(null); } if (toggleButton != null) { AbstractAction toggleAction = new AbstractAction("toggleSideMenu") { @Override public void actionPerform(Component component) { toggleSidePanel(); } }; toggleAction.setCaption(toggleButton.getCaption()); toggleAction.setIcon(toggleButton.getIcon()); toggleAction.setDescription(toggleButton.getDescription()); toggleAction.setEnabled(toggleButton.isEnabled()); toggleAction.setVisible(toggleButton.isVisible()); toggleButton.setAction(toggleAction); } this.toggleButton = toggleButton; }
protected void initCompleteTaskUI() { if (taskInfoEnabled) initTaskInfoGrid(); noActionsAvailableLbl.setVisible(false); Map<String, ProcFormDefinition> outcomesWithForms = processFormService.getOutcomesWithForms(procTask); if (!outcomesWithForms.isEmpty()) { for (Map.Entry<String, ProcFormDefinition> entry : outcomesWithForms.entrySet()) { CompleteProcTaskAction action = new CompleteProcTaskAction(procTask, entry.getKey(), entry.getValue()); completeProcTaskActions.add(action); } } else { ProcFormDefinition form = processFormService.getDefaultCompleteTaskForm(procInstance.getProcDefinition()); CompleteProcTaskAction action = new CompleteProcTaskAction(procTask, BpmConstants.DEFAULT_TASK_OUTCOME, form); action.setCaption(getMessage("completeTask")); completeProcTaskActions.add(action); } for (CompleteProcTaskAction completeProcTaskAction : completeProcTaskActions) { completeProcTaskAction.addBeforeActionPredicate(beforeCompleteTaskPredicate); completeProcTaskAction.addAfterActionListener(afterCompleteTaskListener); completeProcTaskAction.setProcessVariablesSupplier(completeTaskActionProcessVariablesSupplier); completeProcTaskAction.setScreenParametersSupplier(completeTaskActionScreenParametersSupplier); Button actionBtn = componentsFactory.createComponent(Button.class); actionBtn.setWidth(buttonWidth); actionBtn.setAction(completeProcTaskAction); actionsBox.add(actionBtn); } }
protected void createCommitButtons() { buttonsPanel = uiComponents.create(ButtonsPanel.class); commitButton = uiComponents.create(Button.class); commitButton.setIcon("icons/ok.png"); commitButton.setCaption(messages.getMessage(EntityInspectorEditor.class, "commit")); commitButton.setAction(new CommitAction()); cancelButton = uiComponents.create(Button.class); cancelButton.setIcon("icons/cancel.png"); cancelButton.setCaption(messages.getMessage(EntityInspectorEditor.class, "cancel")); cancelButton.setAction(new CancelAction()); buttonsPanel.add(commitButton); buttonsPanel.add(cancelButton); buttonsBox.add(buttonsPanel); }
protected void initClaimTaskUI() { if (taskInfoEnabled) initTaskInfoGrid(); noActionsAvailableLbl.setVisible(false); Button claimTaskBtn = componentsFactory.createComponent(Button.class); claimTaskBtn.setWidth(buttonWidth); claimProcTaskAction = new ClaimProcTaskAction(procTask); claimProcTaskAction.addBeforeActionPredicate(beforeClaimTaskPredicate); claimProcTaskAction.addAfterActionListener(afterClaimTaskListener); claimTaskBtn.setAction(claimProcTaskAction); actionsBox.add(claimTaskBtn); }
protected void addClearBtn() { clearBtn = uiComponents.create(Button.class); clearBtn.setIconFromSet(CubaIcon.PICKERFIELD_CLEAR); clearBtn.setStyleName("c-listeditor-button"); clearBtn.setCaption(""); clearBtn.setAction(new BaseAction("clear") .withCaption("Clear") .withHandler(event -> actualField.setValue(null) )); layout.add(clearBtn); }
@Override public void beforeShowFrame() { wizard.setupButtonsVisibility(); wizard.runBtn.setAction(new AbstractAction("runReport") { @Override public void actionPerform(Component component) { if (wizard.getItem().getReportRegions().isEmpty()) { wizard.showNotification(wizard.getMessage("addRegionsWarn"), Frame.NotificationType.TRAY); return; } wizard.lastGeneratedTmpReport = wizard.buildReport(true); if (wizard.lastGeneratedTmpReport != null) { wizard.reportGuiManager.runReport( wizard.lastGeneratedTmpReport, wizard); } } }); showAddRegion(); wizard.setCorrectReportOutputType(); wizard.getDialogOptions() .setHeight(wizard.wizardHeight).setHeightUnit(SizeUnit.PIXELS) .center(); }
@Override public void init(Map<String, Object> params) { super.init(params); windowConfig = AppBeans.get(WindowConfig.class); procTasksTable.addGeneratedColumn("assigned", entity -> { CheckBox checkBox = componentsFactory.createComponent(CheckBox.class); checkBox.setValue(entity.getProcActor() != null); return checkBox; }); Action openEntityEditorAction = new OpenEntityEditorAction(); procTasksTable.addAction(openEntityEditorAction); openEntityEditorBtn.setAction(openEntityEditorAction); procTasksTable.setItemClickAction(openEntityEditorAction); }
protected void initStartProcessUI() { taskInfoGrid.setVisible(false); noActionsAvailableLbl.setVisible(false); startProcessBtn = componentsFactory.createComponent(Button.class); startProcessBtn.setWidth(buttonWidth); startProcessAction = new StartProcessAction(procInstance); startProcessAction.addBeforeActionPredicate(beforeStartProcessPredicate); startProcessAction.addAfterActionListener(afterStartProcessListener); startProcessAction.setProcessVariablesSupplier(startProcessActionProcessVariablesSupplier); startProcessAction.setScreenParametersSupplier(startProcessActionScreenParametersSupplier); startProcessBtn.setAction(startProcessAction); actionsBox.add(startProcessBtn); }
@Override protected void postInit() { super.postInit(); if (PersistenceHelper.isNew(getItem())) { getItem().setCreatedBy(accessHelper.getCurrentSessionLogin()); } if (StringUtils.isNotEmpty(widgetTemplateDs.getItem().getWidgetModel())) { Widget widget = converter.widgetFromJson(widgetTemplateDs.getItem().getWidgetModel()); setWidgetTypeLookupValue(widget, widgetTypeLookup); } editWidgetButton.setAction(new BaseAction("openWidgetEditor") { @Override public void actionPerform(Component component) { WidgetTemplate widgetTemplate = widgetTemplateDs.getItem(); if (StringUtils.isNotEmpty(widgetTemplate.getWidgetModel())) { Widget widget = converter.widgetFromJson(widgetTemplateDs.getItem().getWidgetModel()); openWidgetEditor(widget); } } }); if (!accessHelper.getCurrentSessionLogin().equals(getItem().getCreatedBy())) { fieldGroup.getField("isAvailableForAllUsers").setVisible(false); } openWidgetEditor = true; ((AbstractDatasource) widgetTemplateDs).setModified(false); }
private BoxLayout createThirdRowAttrsLayout() { BoxLayout thirdRowAttrsLayout = wizard.componentsFactory.createComponent(HBoxLayout.class); thirdRowAttrsLayout.setSpacing(true); Label entityLbl = wizard.componentsFactory.createComponent(Label.class); entityLbl.setStyleName(BOLD_LABEL_STYLE); entityLbl.setValue(wizard.getMessage("attributes")); Button editBtn = wizard.componentsFactory.createComponent(Button.class); editBtn.setCaption(generateAttrsBtnCaption()); editBtn.setStyleName("link"); editBtn.setWidth(WIDTH_PERCENT_100); editBtn.setAction(editRegionAction); thirdRowAttrsLayout.add(entityLbl); thirdRowAttrsLayout.add(editBtn); return thirdRowAttrsLayout; }
protected Table createTable(String dataSetName, GroupDatasource dataSource) { Table table = componentsFactory.createComponent(GroupTable.class); table.setId(dataSetName + "Table"); createColumns(dataSource, table); table.setDatasource(dataSource); table.setWidth("100%"); table.setMultiSelect(true); ExcelAction excelAction = ExcelAction.create(table); excelAction.setFileName(dataSetName); Button excelButton = componentsFactory.createComponent(Button.class); excelButton.setAction(excelAction); ButtonsPanel buttonsPanel = componentsFactory.createComponent(ButtonsPanel.class); table.setButtonsPanel(buttonsPanel); table.addAction(excelAction); buttonsPanel.add(excelButton); return table; }
protected void addRow(Object value, ComponentContainer parent, boolean isReadOnly) { BoxLayout row = componentsFactory.createComponent(HBoxLayout.class); row.setSpacing(true); row.setWidthFull(); TextField valueField = componentsFactory.createComponent(TextField.class); valueField.setValue(value); valueField.setEditable(!isReadOnly); row.add(valueField); row.expand(valueField); Button btnRemove = componentsFactory.createComponent(Button.class); btnRemove.setIconFromSet(CubaIcon.TIMES); btnRemove.setDescription(messages.getMessage(getClass(), "editAttribute.array.btnRemove")); Action removeRowAction = new BaseAction("removeRow") .withCaption("") .withHandler(actionPerformedEvent -> parent.remove(row) ); removeRowAction.setEnabled(!isReadOnly); btnRemove.setAction(removeRowAction); row.add(btnRemove); parent.add(row); }