Example usage for org.apache.wicket.extensions.ajax.markup.html.modal ModalWindow show

List of usage examples for org.apache.wicket.extensions.ajax.markup.html.modal ModalWindow show

Introduction

In this page you can find the example usage for org.apache.wicket.extensions.ajax.markup.html.modal ModalWindow show.

Prototype

public void show(final IPartialPageRequestHandler target) 

Source Link

Document

Shows the modal window.

Usage

From source file:org.apache.syncope.console.pages.ResultStatusModalPage.java

License:Apache License

private ResultStatusModalPage(final Builder builder) {
    super();//from  www  . jav a 2s  . c o m
    this.subject = builder.subject;
    statusUtils = new StatusUtils(this.userRestClient);
    if (builder.mode == null) {
        this.mode = UserModalPage.Mode.ADMIN;
    } else {
        this.mode = builder.mode;
    }

    final BaseModalPage page = this;

    final WebMarkupContainer container = new WebMarkupContainer("container");
    container.setOutputMarkupId(true);
    add(container);

    final Fragment fragment = new Fragment("resultFrag",
            mode == UserModalPage.Mode.SELF ? "userSelfResultFrag" : "propagationResultFrag", this);
    fragment.setOutputMarkupId(true);
    container.add(fragment);

    if (mode == UserModalPage.Mode.ADMIN) {
        // add Syncope propagation status
        PropagationStatus syncope = new PropagationStatus();
        syncope.setResource("Syncope");
        syncope.setStatus(PropagationTaskExecStatus.SUCCESS);

        List<PropagationStatus> propagations = new ArrayList<PropagationStatus>();
        propagations.add(syncope);
        propagations.addAll(subject.getPropagationStatusTOs());

        fragment.add(new Label("info",
                ((subject instanceof UserTO) && ((UserTO) subject).getUsername() != null)
                        ? ((UserTO) subject).getUsername()
                        : ((subject instanceof RoleTO) && ((RoleTO) subject).getName() != null)
                                ? ((RoleTO) subject).getName()
                                : String.valueOf(subject.getId())));

        final ListView<PropagationStatus> propRes = new ListView<PropagationStatus>("resources", propagations) {

            private static final long serialVersionUID = -1020475259727720708L;

            @Override
            protected void populateItem(final ListItem<PropagationStatus> item) {
                final PropagationStatus propTO = (PropagationStatus) item.getDefaultModelObject();

                final ListView attributes = getConnObjectView(propTO);

                final Fragment attrhead;
                if (attributes.getModelObject() == null || attributes.getModelObject().isEmpty()) {
                    attrhead = new Fragment("attrhead", "emptyAttrHeadFrag", page);
                } else {
                    attrhead = new Fragment("attrhead", "attrHeadFrag", page);
                }

                item.add(attrhead);
                item.add(attributes);

                attrhead.add(new Label("resource", propTO.getResource()));

                attrhead.add(new Label("propagation",
                        propTO.getStatus() == null ? "UNDEFINED" : propTO.getStatus().toString()));

                final Image image;
                final String alt, title;
                final ModalWindow failureWindow = new ModalWindow("failureWindow");
                final AjaxLink<?> failureWindowLink = new AjaxLink<Void>("showFailureWindow") {

                    private static final long serialVersionUID = -7978723352517770644L;

                    @Override
                    public void onClick(AjaxRequestTarget target) {
                        failureWindow.show(target);
                    }
                };

                switch (propTO.getStatus()) {

                case SUCCESS:
                case SUBMITTED:
                case CREATED:
                    image = new Image("icon", IMG_STATUSES + Status.ACTIVE.toString() + Constants.PNG_EXT);
                    alt = "success icon";
                    title = "success";
                    failureWindow.setVisible(false);
                    failureWindowLink.setEnabled(false);
                    break;

                default:
                    image = new Image("icon", IMG_STATUSES + Status.SUSPENDED.toString() + Constants.PNG_EXT);
                    alt = "failure icon";
                    title = "failure";
                }

                image.add(new Behavior() {

                    private static final long serialVersionUID = 1469628524240283489L;

                    @Override
                    public void onComponentTag(final Component component, final ComponentTag tag) {
                        tag.put("alt", alt);
                        tag.put("title", title);
                    }
                });
                final FailureMessageModalPage executionFailureMessagePage;
                if (propTO.getFailureReason() == null) {
                    executionFailureMessagePage = new FailureMessageModalPage(failureWindow.getContentId(),
                            StringUtils.EMPTY);
                } else {
                    executionFailureMessagePage = new FailureMessageModalPage(failureWindow.getContentId(),
                            propTO.getFailureReason());
                }

                failureWindow.setPageCreator(new ModalWindow.PageCreator() {

                    private static final long serialVersionUID = -7834632442532690940L;

                    @Override
                    public Page createPage() {
                        return executionFailureMessagePage;
                    }
                });
                failureWindow.setCookieName("failureWindow");
                failureWindow.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
                failureWindowLink.add(image);
                attrhead.add(failureWindowLink);
                attrhead.add(failureWindow);
            }
        };
        fragment.add(propRes);
    }

    final AjaxLink<Void> close = new IndicatingAjaxLink<Void>("close") {

        private static final long serialVersionUID = -7978723352517770644L;

        @Override
        public void onClick(final AjaxRequestTarget target) {
            if (mode == UserModalPage.Mode.SELF && anonymousUser.equals(SyncopeSession.get().getUsername())) {
                SyncopeSession.get().invalidate();
            }
            builder.window.close(target);
        }
    };
    container.add(close);

    setOutputMarkupId(true);
}

From source file:org.apache.syncope.console.pages.Schema.java

License:Apache License

private <T extends AbstractSchemaModalPage> List<IColumn> getColumns(final WebMarkupContainer webContainer,
        final ModalWindow modalWindow, final AttributableType attributableType, final SchemaType schemaType,
        final Collection<String> fields) {

    List<IColumn> columns = new ArrayList<IColumn>();

    for (final String field : fields) {
        final Field clazzField = ReflectionUtils.findField(schemaType.getToClass(), field);

        if (clazzField != null) {
            if (clazzField.getType().equals(Boolean.class) || clazzField.getType().equals(boolean.class)) {
                columns.add(new AbstractColumn<AbstractSchemaTO, String>(new ResourceModel(field)) {

                    private static final long serialVersionUID = 8263694778917279290L;

                    @Override/*from w w w . j av a 2  s. com*/
                    public void populateItem(final Item<ICellPopulator<AbstractSchemaTO>> item,
                            final String componentId, final IModel<AbstractSchemaTO> model) {

                        BeanWrapper bwi = new BeanWrapperImpl(model.getObject());
                        Object obj = bwi.getPropertyValue(field);

                        item.add(new Label(componentId, ""));
                        item.add(new AttributeModifier("class", new Model<String>(obj.toString())));
                    }

                    @Override
                    public String getCssClass() {
                        return "small_fixedsize";
                    }
                });
            } else {
                IColumn column = new PropertyColumn(new ResourceModel(field), field, field) {

                    private static final long serialVersionUID = 3282547854226892169L;

                    @Override
                    public String getCssClass() {
                        String css = super.getCssClass();
                        if ("name".equals(field)) {
                            css = StringUtils.isBlank(css) ? "medium_fixedsize" : css + " medium_fixedsize";
                        }
                        return css;
                    }
                };
                columns.add(column);
            }
        }
    }

    columns.add(new AbstractColumn<AbstractSchemaTO, String>(new ResourceModel("actions", "")) {

        private static final long serialVersionUID = 2054811145491901166L;

        @Override
        public String getCssClass() {
            return "action";
        }

        @Override
        public void populateItem(final Item<ICellPopulator<AbstractSchemaTO>> item, final String componentId,
                final IModel<AbstractSchemaTO> model) {

            final AbstractSchemaTO schemaTO = model.getObject();

            final ActionLinksPanel panel = new ActionLinksPanel(componentId, model, getPageReference());

            panel.addWithRoles(new ActionLink() {

                private static final long serialVersionUID = -3722207913631435501L;

                @Override
                public void onClick(final AjaxRequestTarget target) {
                    modalWindow.setPageCreator(new ModalWindow.PageCreator() {

                        private static final long serialVersionUID = -7834632442532690940L;

                        @Override
                        public Page createPage() {
                            AbstractSchemaModalPage page = SchemaModalPageFactory
                                    .getSchemaModalPage(attributableType, schemaType);

                            page.setSchemaModalPage(Schema.this.getPageReference(), modalWindow, schemaTO,
                                    false);

                            return page;
                        }
                    });

                    modalWindow.show(target);
                }
            }, ActionType.EDIT, allowedReadRoles);

            panel.addWithRoles(new ActionLink() {

                private static final long serialVersionUID = -3722207913631435501L;

                @Override
                public void onClick(final AjaxRequestTarget target) {

                    switch (schemaType) {
                    case DERIVED:
                        restClient.deleteDerSchema(attributableType, schemaTO.getName());
                        break;

                    case VIRTUAL:
                        restClient.deleteVirSchema(attributableType, schemaTO.getName());
                        break;

                    default:
                        restClient.deleteSchema(attributableType, schemaTO.getName());
                        break;
                    }

                    info(getString(Constants.OPERATION_SUCCEEDED));
                    feedbackPanel.refresh(target);

                    target.add(webContainer);
                }
            }, ActionType.DELETE, allowedDeleteRoles);

            item.add(panel);
        }
    });

    return columns;
}

From source file:org.apache.syncope.console.pages.TaskModalPage.java

License:Apache License

public TaskModalPage(final AbstractTaskTO taskTO) {
    final ModalWindow taskExecMessageWin = new ModalWindow("taskExecMessageWin");
    taskExecMessageWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
    taskExecMessageWin.setCookieName("task-exec-message-win-modal");
    add(taskExecMessageWin);//from   www.  ja  v  a2s.  com

    form = new Form<AbstractTaskTO>(FORM);
    form.setModel(new CompoundPropertyModel<AbstractTaskTO>(taskTO));
    add(form);

    profile = new WebMarkupContainer("profile");
    profile.setOutputMarkupId(true);
    form.add(profile);

    executions = new WebMarkupContainer("executionContainer");
    executions.setOutputMarkupId(true);
    form.add(executions);

    final Label idLabel = new Label("idLabel", new ResourceModel("id"));
    profile.add(idLabel);

    final AjaxTextFieldPanel id = new AjaxTextFieldPanel("id", getString("id"),
            new PropertyModel<String>(taskTO, "id"));

    id.setEnabled(false);
    profile.add(id);

    final List<IColumn<TaskExecTO, String>> columns = new ArrayList<IColumn<TaskExecTO, String>>();

    final int paginatorRows = 10;

    columns.add(new PropertyColumn<TaskExecTO, String>(new ResourceModel("id"), "id", "id"));

    columns.add(new DatePropertyColumn<TaskExecTO>(new ResourceModel("startDate"), "startDate", "startDate"));

    columns.add(new DatePropertyColumn<TaskExecTO>(new ResourceModel("endDate"), "endDate", "endDate"));

    columns.add(new PropertyColumn<TaskExecTO, String>(new ResourceModel("status"), "status", "status"));

    columns.add(new ActionColumn<TaskExecTO, String>(new ResourceModel("actions", "")) {

        private static final long serialVersionUID = 2054811145491901166L;

        @Override
        public ActionLinksPanel getActions(final String componentId, final IModel<TaskExecTO> model) {

            final TaskExecTO taskExecutionTO = model.getObject();

            final ActionLinksPanel panel = new ActionLinksPanel(componentId, model, getPageReference());

            panel.add(new ActionLink() {

                private static final long serialVersionUID = -3722207913631435501L;

                @Override
                public void onClick(final AjaxRequestTarget target) {
                    taskExecMessageWin.setPageCreator(new ModalWindow.PageCreator() {

                        private static final long serialVersionUID = -7834632442532690940L;

                        @Override
                        public Page createPage() {
                            return new ExecMessageModalPage(model.getObject().getMessage());
                        }
                    });
                    taskExecMessageWin.show(target);
                }
            }, ActionLink.ActionType.EDIT, TASKS, StringUtils.hasText(model.getObject().getMessage()));

            panel.add(new ActionLink() {

                private static final long serialVersionUID = -3722207913631435501L;

                @Override
                public void onClick(final AjaxRequestTarget target) {
                    try {
                        taskRestClient.deleteExecution(taskExecutionTO.getId());

                        taskTO.getExecutions().remove(taskExecutionTO);

                        info(getString(Constants.OPERATION_SUCCEEDED));
                    } catch (SyncopeClientException scce) {
                        error(scce.getMessage());
                    }

                    feedbackPanel.refresh(target);
                    target.add(executions);
                }
            }, ActionLink.ActionType.DELETE, TASKS);

            return panel;
        }

        @Override
        public Component getHeader(final String componentId) {
            final ActionLinksPanel panel = new ActionLinksPanel(componentId, new Model(), getPageReference());

            panel.add(new ActionLink() {

                private static final long serialVersionUID = -7978723352517770644L;

                @Override
                public void onClick(final AjaxRequestTarget target) {
                    if (target != null) {
                        final AjaxFallbackDefaultDataTable<TaskExecTO, String> currentTable = new AjaxFallbackDefaultDataTable<TaskExecTO, String>(
                                "executionsTable", columns,
                                new TaskExecutionsProvider(getCurrentTaskExecution(taskTO)), paginatorRows);
                        currentTable.setOutputMarkupId(true);
                        target.add(currentTable);
                        executions.addOrReplace(currentTable);
                    }
                }
            }, ActionLink.ActionType.RELOAD, TASKS, "list");

            return panel;
        }
    });

    final AjaxFallbackDefaultDataTable<TaskExecTO, String> table = new AjaxFallbackDefaultDataTable<TaskExecTO, String>(
            "executionsTable", columns, new TaskExecutionsProvider(getCurrentTaskExecution(taskTO)),
            paginatorRows);

    executions.add(table);
}

From source file:org.apache.syncope.console.pages.Users.java

License:Apache License

public Users(final PageParameters parameters) {
    super(parameters);

    // Modal window for editing user attributes
    final ModalWindow editModalWin = new ModalWindow("editModal");
    editModalWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
    editModalWin.setInitialHeight(EDIT_MODAL_WIN_HEIGHT);
    editModalWin.setInitialWidth(EDIT_MODAL_WIN_WIDTH);
    editModalWin.setCookieName("edit-modal");
    add(editModalWin);/*www  .ja va 2  s  .  co  m*/

    final AbstractSearchResultPanel searchResult = new UserSearchResultPanel("searchResult", true, null,
            getPageReference(), restClient);
    add(searchResult);

    final AbstractSearchResultPanel listResult = new UserSearchResultPanel("listResult", false, null,
            getPageReference(), restClient);
    add(listResult);

    // create new user
    final AjaxLink<Void> createLink = new ClearIndicatingAjaxLink<Void>("createLink", getPageReference()) {

        private static final long serialVersionUID = -7978723352517770644L;

        @Override
        protected void onClickInternal(final AjaxRequestTarget target) {
            editModalWin.setPageCreator(new ModalWindow.PageCreator() {

                private static final long serialVersionUID = -7834632442532690940L;

                @Override
                public Page createPage() {
                    return new EditUserModalPage(Users.this.getPageReference(), editModalWin, new UserTO());
                }
            });

            editModalWin.show(target);
        }
    };
    MetaDataRoleAuthorizationStrategy.authorize(createLink, ENABLE,
            xmlRolesReader.getAllAllowedRoles("Users", "create"));
    add(createLink);

    setWindowClosedReloadCallback(editModalWin);

    final Form searchForm = new Form("searchForm");
    add(searchForm);

    final UserSearchPanel searchPanel = new UserSearchPanel.Builder("searchPanel").build();
    searchForm.add(searchPanel);

    final ClearIndicatingAjaxButton searchButton = new ClearIndicatingAjaxButton("search",
            new ResourceModel("search"), getPageReference()) {

        private static final long serialVersionUID = -958724007591692537L;

        @Override
        protected void onSubmitInternal(final AjaxRequestTarget target, final Form<?> form) {
            final String fiql = searchPanel.buildFIQL();
            LOG.debug("FIQL: " + fiql);

            doSearch(target, fiql, searchResult);

            Session.get().getFeedbackMessages().clear();
            searchPanel.getSearchFeedback().refresh(target);
        }

        @Override
        protected void onError(final AjaxRequestTarget target, final Form<?> form) {

            searchPanel.getSearchFeedback().refresh(target);
        }
    };

    searchForm.add(searchButton);
    searchForm.setDefaultButton(searchButton);
}

From source file:org.apache.syncope.console.SyncopeApplication.java

License:Apache License

public void setupNavigationPanel(final WebPage page, final XMLRolesReader xmlRolesReader,
        final boolean notsel) {
    final ModalWindow infoModal = new ModalWindow("infoModal");
    page.add(infoModal);//from w w w .jav a2s . c  o  m
    infoModal.setInitialWidth(350);
    infoModal.setInitialHeight(300);
    infoModal.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
    infoModal.setCookieName("infoModal");
    infoModal.setPageCreator(new ModalWindow.PageCreator() {

        private static final long serialVersionUID = -7834632442532690940L;

        @Override
        public Page createPage() {
            return new InfoModalPage();
        }
    });

    final AjaxLink<Page> infoLink = new AjaxLink<Page>("infoLink") {

        private static final long serialVersionUID = -7978723352517770644L;

        @Override
        public void onClick(final AjaxRequestTarget target) {
            infoModal.show(target);
        }
    };
    page.add(infoLink);

    BookmarkablePageLink<Page> schemaLink = new BookmarkablePageLink<Page>("schema", Schema.class);
    MetaDataRoleAuthorizationStrategy.authorize(schemaLink, WebPage.ENABLE,
            xmlRolesReader.getAllAllowedRoles("Schema", "list"));
    page.add(schemaLink);
    schemaLink.add(new Image("schemaIcon", new ContextRelativeResource(
            IMG_PREFIX + (notsel ? IMG_NOTSEL : "") + "schema" + Constants.PNG_EXT)));

    BookmarkablePageLink<Page> usersLink = new BookmarkablePageLink<Page>("users", Users.class);
    MetaDataRoleAuthorizationStrategy.authorize(usersLink, WebPage.ENABLE,
            xmlRolesReader.getAllAllowedRoles("Users", "list"));
    page.add(usersLink);
    usersLink.add(new Image("usersIcon", new ContextRelativeResource(
            IMG_PREFIX + (notsel ? IMG_NOTSEL : "") + "users" + Constants.PNG_EXT)));

    BookmarkablePageLink<Page> rolesLink = new BookmarkablePageLink<Page>("roles", Roles.class);
    MetaDataRoleAuthorizationStrategy.authorize(rolesLink, WebPage.ENABLE,
            xmlRolesReader.getAllAllowedRoles("Roles", "list"));
    page.add(rolesLink);
    rolesLink.add(new Image("rolesIcon", new ContextRelativeResource(
            IMG_PREFIX + (notsel ? IMG_NOTSEL : "") + "roles" + Constants.PNG_EXT)));

    BookmarkablePageLink<Page> resourcesLink = new BookmarkablePageLink<Page>("resources", Resources.class);
    MetaDataRoleAuthorizationStrategy.authorize(resourcesLink, WebPage.ENABLE,
            xmlRolesReader.getAllAllowedRoles("Resources", "list"));
    page.add(resourcesLink);
    resourcesLink.add(new Image("resourcesIcon", new ContextRelativeResource(
            IMG_PREFIX + (notsel ? IMG_NOTSEL : "") + "resources" + Constants.PNG_EXT)));

    BookmarkablePageLink<Page> todoLink = new BookmarkablePageLink<Page>("todo", Todo.class);
    MetaDataRoleAuthorizationStrategy.authorize(todoLink, WebPage.ENABLE,
            xmlRolesReader.getAllAllowedRoles("Approval", "list"));
    page.add(todoLink);
    todoLink.add(new Image("todoIcon",
            new ContextRelativeResource(IMG_PREFIX + (notsel ? IMG_NOTSEL : "") + "todo" + Constants.PNG_EXT)));

    BookmarkablePageLink<Page> reportLink = new BookmarkablePageLink<Page>("reports", Reports.class);
    MetaDataRoleAuthorizationStrategy.authorize(reportLink, WebPage.ENABLE,
            xmlRolesReader.getAllAllowedRoles("Reports", "list"));
    page.add(reportLink);
    reportLink.add(new Image("reportsIcon", new ContextRelativeResource(
            IMG_PREFIX + (notsel ? IMG_NOTSEL : "") + "reports" + Constants.PNG_EXT)));

    BookmarkablePageLink<Page> configurationLink = new BookmarkablePageLink<Page>("configuration",
            Configuration.class);
    MetaDataRoleAuthorizationStrategy.authorize(configurationLink, WebPage.ENABLE,
            xmlRolesReader.getAllAllowedRoles("Configuration", "list"));
    page.add(configurationLink);
    configurationLink.add(new Image("configurationIcon", new ContextRelativeResource(
            IMG_PREFIX + (notsel ? IMG_NOTSEL : "") + "configuration" + Constants.PNG_EXT)));

    BookmarkablePageLink<Page> taskLink = new BookmarkablePageLink<Page>("tasks", Tasks.class);
    MetaDataRoleAuthorizationStrategy.authorize(taskLink, WebPage.ENABLE,
            xmlRolesReader.getAllAllowedRoles("Tasks", "list"));
    page.add(taskLink);
    taskLink.add(new Image("tasksIcon", new ContextRelativeResource(
            IMG_PREFIX + (notsel ? IMG_NOTSEL : "") + "tasks" + Constants.PNG_EXT)));

    page.add(new BookmarkablePageLink<Page>("logout", Logout.class));
}

From source file:org.apache.syncope.console.SyncopeApplication.java

License:Apache License

public void setupEditProfileModal(final WebPage page, final UserSelfRestClient userSelfRestClient) {
    // Modal window for editing user profile
    final ModalWindow editProfileModalWin = new ModalWindow("editProfileModal");
    editProfileModalWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
    editProfileModalWin.setInitialHeight(EDIT_PROFILE_WIN_HEIGHT);
    editProfileModalWin.setInitialWidth(EDIT_PROFILE_WIN_WIDTH);
    editProfileModalWin.setCookieName("edit-profile-modal");
    page.add(editProfileModalWin);//from w  w w. jav a 2 s.co  m

    final AjaxLink<Page> editProfileLink = new AjaxLink<Page>("editProfileLink") {

        private static final long serialVersionUID = -7978723352517770644L;

        @Override
        public void onClick(final AjaxRequestTarget target) {
            final UserTO userTO = SyncopeSession.get().isAuthenticated() ? userSelfRestClient.read()
                    : new UserTO();

            editProfileModalWin.setPageCreator(new ModalWindow.PageCreator() {

                private static final long serialVersionUID = -7834632442532690940L;

                @Override
                public Page createPage() {
                    return new UserSelfModalPage(page.getPageReference(), editProfileModalWin, userTO);
                }
            });

            editProfileModalWin.show(target);
        }
    };

    editProfileLink.add(new Label("username", SyncopeSession.get().getUsername()));

    if ("admin".equals(SyncopeSession.get().getUsername())) {
        editProfileLink.setEnabled(false);
    }

    page.add(editProfileLink);
}

From source file:org.artifactory.webapp.actionable.action.CopyAction.java

License:Open Source License

@Override
public void onAction(RepoAwareItemEvent event) {
    RepoPath repoPath = event.getRepoPath();

    //Create a modal window and add the move path panel to it
    ItemEventTargetComponents eventTargetComponents = event.getTargetComponents();

    ModalWindow modalWindow = eventTargetComponents.getModalWindow();
    CopyPathPanel panel = new CopyPathPanel(modalWindow.getContentId(), repoPath);

    BaseModalPanel modalPanel = new PanelNestingBorderedModal(panel);
    modalPanel.setWidth(500);//  w  ww. j a  v a2s  .co m
    modalPanel.setTitle(String.format("Copy '%s'", repoPath));
    modalWindow.setContent(modalPanel);
    modalWindow.show(event.getTarget());
}

From source file:org.artifactory.webapp.actionable.action.DeleteVersionsAction.java

License:Open Source License

@Override
public void onAction(RepoAwareItemEvent event) {
    RepoAwareActionableItem source = event.getSource();
    org.artifactory.fs.ItemInfo info = source.getItemInfo();
    RepoPath itemPath = info.getRepoPath();
    if (!info.isFolder() && itemPath.getParent() != null) {
        itemPath = itemPath.getParent();
    }/*from   www. ja  va  2  s  .  co m*/
    RepositoryService repositoryService = getRepoService();
    ItemSearchResults<VersionUnitSearchResult> results = repositoryService.getVersionUnitsUnder(itemPath);

    List<VersionUnit> versionUnits = Lists.newArrayList();
    for (VersionUnitSearchResult result : results.getResults()) {
        versionUnits.add(result.getVersionUnit());
    }

    ItemEventTargetComponents eventTargetComponents = event.getTargetComponents();
    ModalWindow modalWindow = eventTargetComponents.getModalWindow();
    WebMarkupContainer nodePanelContainer = eventTargetComponents.getNodePanelContainer();
    TreeBrowsePanel browseRepoPanel = (TreeBrowsePanel) nodePanelContainer.getParent();

    DeleteVersionsPanel panel = new DeleteVersionsPanel(modalWindow.getContentId(), versionUnits,
            browseRepoPanel, event.getSource());
    BaseModalPanel modalPanel = new PanelNestingBorderedModal(panel);
    modalPanel.setTitle("Delete Versions");
    modalWindow.setContent(modalPanel);
    AjaxRequestTarget target = event.getTarget();

    //VfsQueryDb returns -1 if userQueryLimit was exceeded.
    boolean exceededQueryLimit = results.getFullResultsCount() == -1;
    String warnMessage = "";
    String bubbleMessage = "";

    if (exceededQueryLimit) {
        modalWindow.setInitialWidth(700); //So that the warning text and the bubble are inline

        warnMessage = "The results shown are limited. Try executing Delete Versions from a node lower in the "
                + "hierarchy.";

        bubbleMessage = "The results shown are limited by the artifactory.search.userQueryLimit system property."
                + "\n You can modify it to get more results, but this can dramatically impact performance on large "
                + "repositories.";
    }
    Label label = new Label("largeQueryWarn", warnMessage);
    HelpBubble bubble = new HelpBubble("largeQueryWarn.help", bubbleMessage);
    panel.add(label);
    panel.add(bubble);
    label.setVisible(exceededQueryLimit);
    bubble.setVisible(exceededQueryLimit);
    modalWindow.show(target);
}

From source file:org.artifactory.webapp.actionable.action.MoveAction.java

License:Open Source License

@Override
public void onAction(RepoAwareItemEvent event) {
    RepoPath repoPath = event.getRepoPath();

    // create a modal window and add the move path panel to it
    ItemEventTargetComponents eventTargetComponents = event.getTargetComponents();
    // should be the tree
    Component tree = eventTargetComponents.getRefreshableComponent();

    WebMarkupContainer nodaPanelContainer = eventTargetComponents.getNodePanelContainer();
    TreeBrowsePanel browseRepoPanel = (TreeBrowsePanel) nodaPanelContainer.getParent();

    ModalWindow modalWindow = eventTargetComponents.getModalWindow();
    MovePathPanel panel = new MovePathPanel(modalWindow.getContentId(), repoPath, tree, browseRepoPanel);

    BaseModalPanel modalPanel = new PanelNestingBorderedModal(panel);
    modalPanel.setWidth(500);//from w w w .ja  va 2 s .  c o  m
    modalPanel.setTitle(String.format("Move '%s'", repoPath));
    modalWindow.setContent(modalPanel);
    modalWindow.show(event.getTarget());
}

From source file:org.artifactory.webapp.actionable.action.ViewAction.java

License:Open Source License

private void showModal(RepoAwareItemEvent e, String title, Component content) {
    ModalWindow modalWindow = e.getTargetComponents().getModalWindow();
    CodeModalPanel modelPanel = new CodeModalPanel(content);
    modelPanel.setTitle(title);//  w ww . j av a 2s .com
    modalWindow.setContent(modelPanel);
    AjaxRequestTarget target = e.getTarget();
    modalWindow.show(target);
}