Search in sources :

Example 1 with AbstractLink

use of org.apache.wicket.markup.html.link.AbstractLink in project midpoint by Evolveum.

the class MenuLinkPanel method initLayout.

private void initLayout(IModel<InlineMenuItem> item) {
    InlineMenuItem dto = item.getObject();
    AbstractLink a;
    if (dto.isSubmit()) {
        a = new AjaxSubmitLink(ID_MENU_ITEM_LINK) {

            @Override
            protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
                MenuLinkPanel.this.onSubmit(target, form, dto.getAction(), item);
            }

            @Override
            protected void onError(AjaxRequestTarget target, Form<?> form) {
                MenuLinkPanel.this.onError(target, form, dto.getAction());
            }

            @Override
            protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
                super.updateAjaxAttributes(attributes);
                attributes.setEventPropagation(AjaxRequestAttributes.EventPropagation.BUBBLE);
            }
        };
    } else {
        a = new AjaxLink(ID_MENU_ITEM_LINK) {

            @Override
            public void onClick(AjaxRequestTarget target) {
                MenuLinkPanel.this.onClick(target, dto.getAction(), item);
            }

            @Override
            protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
                super.updateAjaxAttributes(attributes);
                attributes.setEventPropagation(AjaxRequestAttributes.EventPropagation.BUBBLE);
            }
        };
    }
    add(a);
    a.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            if (dto.getAction() == null) {
                return false;
            }
            return true;
        }
    });
    Label span = new Label(ID_MENU_ITEM_LABEL, dto.getLabel());
    span.setRenderBodyOnly(true);
    a.add(span);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxRequestAttributes(org.apache.wicket.ajax.attributes.AjaxRequestAttributes) Label(org.apache.wicket.markup.html.basic.Label) AjaxSubmitLink(org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AbstractLink(org.apache.wicket.markup.html.link.AbstractLink) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink)

Example 2 with AbstractLink

use of org.apache.wicket.markup.html.link.AbstractLink in project midpoint by Evolveum.

the class PageTasks method initLayout.

private void initLayout() {
    refreshPanel = new AutoRefreshPanel(ID_REFRESH_PANEL, refreshModel, this, false);
    add(refreshPanel);
    Form mainForm = new Form(ID_MAIN_FORM);
    add(mainForm);
    List<IColumn<TaskDto, String>> taskColumns = initTaskColumns();
    TaskDtoProviderOptions options = TaskDtoProviderOptions.minimalOptions();
    options.setGetNextRunStartTime(true);
    options.setUseClusterInformation(true);
    options.setResolveObjectRef(true);
    TaskDtoProvider provider = new TaskDtoProvider(PageTasks.this, options) {

        @Override
        protected void saveProviderPaging(ObjectQuery query, ObjectPaging paging) {
            TasksStorage storage = getSessionStorage().getTasks();
            storage.setPaging(paging);
        }

        @Override
        public TaskDto createTaskDto(PrismObject<TaskType> task, Task opTask, OperationResult result) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException {
            TaskDto dto = super.createTaskDto(task, opTask, result);
            addInlineMenuToTaskRow(dto);
            return dto;
        }
    };
    provider.setQuery(createTaskQuery());
    BoxedTablePanel<TaskDto> taskTable = new BoxedTablePanel(ID_TASK_TABLE, provider, taskColumns, UserProfileStorage.TableId.PAGE_TASKS_PANEL, (int) getItemsPerPage(UserProfileStorage.TableId.PAGE_TASKS_PANEL)) {

        @Override
        protected WebMarkupContainer createHeader(String headerId) {
            return new SearchFragment(headerId, ID_TABLE_HEADER, PageTasks.this, searchModel);
        }

        @Override
        protected WebMarkupContainer createButtonToolbar(String id) {
            String fileName = "TaskType_" + createStringResource("MainObjectListPanel.exportFileName").getString();
            CSVDataExporter csvDataExporter = new CSVDataExporter();
            ResourceStreamResource resource = (new ResourceStreamResource() {

                protected IResourceStream getResourceStream() {
                    return new ExportToolbar.DataExportResourceStreamWriter(csvDataExporter, getTaskTable().getDataTable());
                }
            }).setFileName(fileName + "." + csvDataExporter.getFileNameExtension());
            AbstractLink exportDataLink = (new ResourceLink(id, resource)).setBody(csvDataExporter.getDataFormatNameModel());
            exportDataLink.add(new AttributeAppender("class", " btn btn-primary btn-sm"));
            return exportDataLink;
        }
    };
    taskTable.setOutputMarkupId(true);
    TasksStorage storage = getSessionStorage().getTasks();
    taskTable.setCurrentPage(storage.getPaging());
    mainForm.add(taskTable);
    List<IColumn<NodeDto, String>> nodeColumns = initNodeColumns();
    BoxedTablePanel nodeTable = new BoxedTablePanel(ID_NODE_TABLE, new NodeDtoProvider(PageTasks.this) {

        @Override
        public NodeDto createNodeDto(PrismObject<NodeType> node) {
            NodeDto dto = super.createNodeDto(node);
            addInlineMenuToNodeRow(dto);
            return dto;
        }
    }, nodeColumns, UserProfileStorage.TableId.PAGE_TASKS_NODES_PANEL, (int) getItemsPerPage(UserProfileStorage.TableId.PAGE_TASKS_NODES_PANEL));
    nodeTable.setOutputMarkupId(true);
    nodeTable.setShowPaging(false);
    mainForm.add(nodeTable);
    initDiagnosticButtons();
}
Also used : Task(com.evolveum.midpoint.task.api.Task) CSVDataExporter(org.apache.wicket.extensions.markup.html.repeater.data.table.export.CSVDataExporter) Form(org.apache.wicket.markup.html.form.Form) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PrismObject(com.evolveum.midpoint.prism.PrismObject) ResourceStreamResource(org.apache.wicket.request.resource.ResourceStreamResource) AutoRefreshPanel(com.evolveum.midpoint.web.component.refresh.AutoRefreshPanel) ResourceLink(org.apache.wicket.markup.html.link.ResourceLink) BoxedTablePanel(com.evolveum.midpoint.web.component.data.BoxedTablePanel) AttributeAppender(org.apache.wicket.behavior.AttributeAppender) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) TasksStorage(com.evolveum.midpoint.web.session.TasksStorage) AbstractLink(org.apache.wicket.markup.html.link.AbstractLink)

Example 3 with AbstractLink

use of org.apache.wicket.markup.html.link.AbstractLink in project midpoint by Evolveum.

the class AuditLogViewerPanel method addOrReplaceTable.

private void addOrReplaceTable(Form mainForm) {
    AuditEventRecordProvider provider = new AuditEventRecordProvider(AuditLogViewerPanel.this) {

        private static final long serialVersionUID = 1L;

        public Map<String, Object> getParameters() {
            Map<String, Object> parameters = new HashMap<String, Object>();
            AuditSearchDto search = auditSearchDto.getObject();
            parameters.put("from", search.getFrom());
            parameters.put("to", search.getTo());
            if (search.getChannel() != null) {
                parameters.put("channel", QNameUtil.qNameToUri(search.getChannel()));
            }
            parameters.put("hostIdentifier", search.getHostIdentifier());
            if (search.getInitiatorName() != null) {
                parameters.put("initiatorName", search.getInitiatorName().getOid());
            }
            if (search.getTargetOwnerName() != null) {
                parameters.put("targetOwnerName", search.getTargetOwnerName().getOid());
            }
            List<String> targetOids = new ArrayList<>();
            if (isNotEmpty(search.getTargetNamesObjects())) {
                targetOids.addAll(search.getTargetNamesObjects().stream().map(ObjectType::getOid).collect(toList()));
            }
            if (isNotEmpty(search.getTargetNames())) {
                targetOids.addAll(search.getTargetNames().stream().map(ObjectReferenceType::getOid).collect(toList()));
            }
            if (!targetOids.isEmpty()) {
                parameters.put("targetNames", targetOids);
            }
            if (search.getChangedItem().toItemPath() != null) {
                ItemPath itemPath = search.getChangedItem().toItemPath();
                parameters.put("changedItem", CanonicalItemPath.create(itemPath).asString());
            }
            parameters.put("eventType", search.getEventType());
            parameters.put("eventStage", search.getEventStage());
            parameters.put("outcome", search.getOutcome());
            if (isNotEmpty(search.getvalueRefTargetNames())) {
                parameters.put(AuditEventRecordProvider.VALUE_REF_TARGET_NAMES_KEY, search.getvalueRefTargetNames().stream().map(ObjectType::getName).map(PolyStringType::getOrig).collect(toList()));
            }
            return parameters;
        }

        @Override
        protected void saveCurrentPage(long from, long count) {
            if (count != 0) {
                auditLogStorage.setPageNumber(from / count);
            }
        }
    };
    UserProfileStorage userProfile = pageBase.getSessionStorage().getUserProfile();
    int pageSize = DEFAULT_PAGE_SIZE;
    if (userProfile.getTables().containsKey(UserProfileStorage.TableId.PAGE_AUDIT_LOG_VIEWER)) {
        pageSize = userProfile.getPagingSize(UserProfileStorage.TableId.PAGE_AUDIT_LOG_VIEWER);
    }
    List<IColumn<AuditEventRecordType, String>> columns = initColumns();
    BoxedTablePanel<AuditEventRecordType> table = new BoxedTablePanel<AuditEventRecordType>(ID_TABLE, provider, columns, UserProfileStorage.TableId.PAGE_AUDIT_LOG_VIEWER, pageSize) {

        private static final long serialVersionUID = 1L;

        @Override
        protected WebMarkupContainer createButtonToolbar(String id) {
            String fileName = "AuditLogViewer_" + createStringResource("MainObjectListPanel.exportFileName").getString();
            CSVDataExporter csvDataExporter = new CSVDataExporter() {

                @Override
                public <T> void exportData(IDataProvider<T> dataProvider, List<IExportableColumn<T, ?>> columns, OutputStream outputStream) throws IOException {
                    ((AuditEventRecordProvider) dataProvider).setExportSize(true);
                    super.exportData(dataProvider, columns, outputStream);
                    ((AuditEventRecordProvider) dataProvider).setExportSize(false);
                }
            };
            ResourceStreamResource resource = (new ResourceStreamResource() {

                protected IResourceStream getResourceStream() {
                    return new ExportToolbar.DataExportResourceStreamWriter(csvDataExporter, getAuditLogViewerTable().getDataTable());
                }
            }).setFileName(fileName + "." + csvDataExporter.getFileNameExtension());
            AbstractLink exportDataLink = (new ResourceLink(id, resource)).setBody(csvDataExporter.getDataFormatNameModel());
            exportDataLink.add(new AttributeAppender("class", " btn btn-primary btn-sm"));
            return exportDataLink;
        }

        @Override
        public void setShowPaging(boolean show) {
        //we don't need to do anything here
        }
    };
    table.setShowPaging(true);
    table.setCurrentPage(auditLogStorage.getPageNumber());
    table.setOutputMarkupId(true);
    mainForm.addOrReplace(table);
}
Also used : PolyStringType(com.evolveum.prism.xml.ns._public.types_3.PolyStringType) CSVDataExporter(org.apache.wicket.extensions.markup.html.repeater.data.table.export.CSVDataExporter) HashMap(java.util.HashMap) AuditSearchDto(com.evolveum.midpoint.web.page.admin.reports.dto.AuditSearchDto) OutputStream(java.io.OutputStream) ArrayList(java.util.ArrayList) IDataProvider(org.apache.wicket.markup.repeater.data.IDataProvider) AuditEventRecordProvider(com.evolveum.midpoint.web.page.admin.reports.dto.AuditEventRecordProvider) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) UserProfileStorage(com.evolveum.midpoint.web.session.UserProfileStorage) ResourceStreamResource(org.apache.wicket.request.resource.ResourceStreamResource) ResourceLink(org.apache.wicket.markup.html.link.ResourceLink) List(java.util.List) ArrayList(java.util.ArrayList) Collectors.toList(java.util.stream.Collectors.toList) BoxedTablePanel(com.evolveum.midpoint.web.component.data.BoxedTablePanel) AttributeAppender(org.apache.wicket.behavior.AttributeAppender) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) AuditEventRecordType(com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventRecordType) AbstractLink(org.apache.wicket.markup.html.link.AbstractLink) CanonicalItemPath(com.evolveum.midpoint.prism.path.CanonicalItemPath) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 4 with AbstractLink

use of org.apache.wicket.markup.html.link.AbstractLink in project ocvn by devgateway.

the class BasePage method newAdminMenu.

protected NavbarDropDownButton newAdminMenu() {
    // admin menu
    NavbarDropDownButton adminMenu = new NavbarDropDownButton(new StringResourceModel("navbar.admin", this, null)) {

        private static final long serialVersionUID = 1L;

        @Override
        protected List<AbstractLink> newSubMenuButtons(final String arg0) {
            List<AbstractLink> list = new ArrayList<>();
            list.add(new MenuBookmarkablePageLink<ListGroupPage>(ListGroupPage.class, null, new StringResourceModel("navbar.groups", this, null)).setIconType(FontAwesomeIconType.tags));
            // list.add(new
            // MenuBookmarkablePageLink<ListTestFormPage>(ListTestFormPage.class,
            // null,
            // new StringResourceModel("navbar.testcomponents", this, null))
            // .setIconType(FontAwesomeIconType.android));
            list.add(new MenuBookmarkablePageLink<ListVietnamImportSourceFiles>(ListVietnamImportSourceFiles.class, null, new StringResourceModel("navbar.importfiles", this, null)).setIconType(FontAwesomeIconType.file_archive_o));
            list.add(new MenuBookmarkablePageLink<VietnamImportPage>(VietnamImportPage.class, null, new StringResourceModel("navbar.import", this, null)).setIconType(FontAwesomeIconType.cloud_upload));
            list.add(new MenuBookmarkablePageLink<ListUserPage>(ListUserPage.class, null, new StringResourceModel("navbar.users", this, null)).setIconType(FontAwesomeIconType.users));
            list.add(new MenuBookmarkablePageLink<SpringEndpointsPage>(SpringEndpointsPage.class, null, new StringResourceModel("navbar.springendpoints", this, null)).setIconType(FontAwesomeIconType.anchor));
            list.add(new MenuBookmarkablePageLink<JminixRedirectPage>(JminixRedirectPage.class, null, new StringResourceModel("navbar.jminix", this, null)).setIconType(FontAwesomeIconType.bug));
            // MenuBookmarkablePageLink<HALRedirectPage> halBrowserLink =
            // new MenuBookmarkablePageLink<HALRedirectPage>(
            // HALRedirectPage.class, null, new StringResourceModel(
            // "navbar.halbrowser", this, null)) {
            // private static final long serialVersionUID = 1L;
            //
            // @Override
            // protected void onComponentTag(ComponentTag tag) {
            // super.onComponentTag(tag);
            // tag.put("target", "_blank");
            // }
            // };
            // halBrowserLink.setIconType(FontAwesomeIconType.rss).setEnabled(true);
            // list.add(halBrowserLink);
            MenuBookmarkablePageLink<UIRedirectPage> uiBrowserLink = new MenuBookmarkablePageLink<UIRedirectPage>(UIRedirectPage.class, null, new StringResourceModel("navbar.ui", this, null)) {

                private static final long serialVersionUID = 1L;

                @Override
                protected void onComponentTag(final ComponentTag tag) {
                    super.onComponentTag(tag);
                    tag.put("target", "_blank");
                }
            };
            uiBrowserLink.setIconType(FontAwesomeIconType.dashboard).setEnabled(true);
            list.add(new MenuBookmarkablePageLink<Void>(EditAdminSettingsPage.class, new StringResourceModel("navbar.adminSettings", BasePage.this, null)).setIconType(FontAwesomeIconType.briefcase));
            list.add(new MenuBookmarkablePageLink<Void>(ListAllDashboardsPage.class, new StringResourceModel("navbar.allDashboard", BasePage.this, null)).setIconType(FontAwesomeIconType.filter));
            list.add(uiBrowserLink);
            return list;
        }
    };
    adminMenu.setIconType(GlyphIconType.cog);
    MetaDataRoleAuthorizationStrategy.authorize(adminMenu, Component.RENDER, SecurityConstants.Roles.ROLE_ADMIN);
    return adminMenu;
}
Also used : NavbarDropDownButton(de.agilecoders.wicket.core.markup.html.bootstrap.navbar.NavbarDropDownButton) ComponentTag(org.apache.wicket.markup.ComponentTag) ArrayList(java.util.ArrayList) MenuBookmarkablePageLink(de.agilecoders.wicket.core.markup.html.bootstrap.button.dropdown.MenuBookmarkablePageLink) AbstractLink(org.apache.wicket.markup.html.link.AbstractLink) StringResourceModel(org.apache.wicket.model.StringResourceModel)

Example 5 with AbstractLink

use of org.apache.wicket.markup.html.link.AbstractLink in project ocvn by devgateway.

the class BasePage method newLanguageMenu.

public NavbarDropDownButton newLanguageMenu() {
    final NavbarDropDownButton languageDropDown = new NavbarDropDownButton(new StringResourceModel("navbar.lang", this, null)) {

        private static final long serialVersionUID = 319842753824102674L;

        @Override
        protected List<AbstractLink> newSubMenuButtons(final String buttonMarkupId) {
            final List<AbstractLink> list = new ArrayList<>();
            for (final Locale l : WebConstants.AVAILABLE_LOCALES) {
                final PageParameters params = new PageParameters(BasePage.this.getPageParameters());
                params.set(WebConstants.LANGUAGE_PARAM, l.getLanguage());
                list.add(new MenuBookmarkablePageLink<Page>(BasePage.this.getPageClass(), params, Model.of(l.getDisplayName())));
            }
            return list;
        }
    };
    languageDropDown.setIconType(GlyphIconType.flag);
    return languageDropDown;
}
Also used : NavbarDropDownButton(de.agilecoders.wicket.core.markup.html.bootstrap.navbar.NavbarDropDownButton) Locale(java.util.Locale) ArrayList(java.util.ArrayList) Page(org.apache.wicket.Page) EditUserPage(org.devgateway.toolkit.forms.wicket.page.user.EditUserPage) VietnamImportPage(org.devgateway.ocvn.forms.wicket.page.VietnamImportPage) ListGroupPage(org.devgateway.toolkit.forms.wicket.page.lists.ListGroupPage) RedirectPage(org.apache.wicket.markup.html.pages.RedirectPage) GenericWebPage(org.apache.wicket.markup.html.GenericWebPage) ListAllDashboardsPage(org.devgateway.ocds.forms.wicket.page.list.ListAllDashboardsPage) LogoutPage(org.devgateway.toolkit.forms.wicket.page.user.LogoutPage) ListMyDashboardsPage(org.devgateway.ocds.forms.wicket.page.list.ListMyDashboardsPage) ListUserPage(org.devgateway.toolkit.forms.wicket.page.lists.ListUserPage) PageParameters(org.apache.wicket.request.mapper.parameter.PageParameters) AbstractLink(org.apache.wicket.markup.html.link.AbstractLink) StringResourceModel(org.apache.wicket.model.StringResourceModel)

Aggregations

AbstractLink (org.apache.wicket.markup.html.link.AbstractLink)5 ArrayList (java.util.ArrayList)3 BoxedTablePanel (com.evolveum.midpoint.web.component.data.BoxedTablePanel)2 NavbarDropDownButton (de.agilecoders.wicket.core.markup.html.bootstrap.navbar.NavbarDropDownButton)2 AttributeAppender (org.apache.wicket.behavior.AttributeAppender)2 IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)2 CSVDataExporter (org.apache.wicket.extensions.markup.html.repeater.data.table.export.CSVDataExporter)2 ResourceLink (org.apache.wicket.markup.html.link.ResourceLink)2 StringResourceModel (org.apache.wicket.model.StringResourceModel)2 ResourceStreamResource (org.apache.wicket.request.resource.ResourceStreamResource)2 PrismObject (com.evolveum.midpoint.prism.PrismObject)1 CanonicalItemPath (com.evolveum.midpoint.prism.path.CanonicalItemPath)1 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)1 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)1 Task (com.evolveum.midpoint.task.api.Task)1 AutoRefreshPanel (com.evolveum.midpoint.web.component.refresh.AutoRefreshPanel)1 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)1 AuditEventRecordProvider (com.evolveum.midpoint.web.page.admin.reports.dto.AuditEventRecordProvider)1 AuditSearchDto (com.evolveum.midpoint.web.page.admin.reports.dto.AuditSearchDto)1 TasksStorage (com.evolveum.midpoint.web.session.TasksStorage)1