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

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

Introduction

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

Prototype

public ModalWindow(final String id) 

Source Link

Document

Creates a new modal window component.

Usage

From source file:org.alienlabs.hatchetharry.view.page.HomePage.java

License:Open Source License

@SuppressFBWarnings(value = "EC_UNRELATED_TYPES", justification = "If we put 'test'.equals(pp.get('test').toString()) it breaks everything!")
public HomePage(final PageParameters pp) throws Exception {
    this.session = HatchetHarrySession.get();

    final ServletWebRequest servletWebRequest = (ServletWebRequest) this.getRequest();
    final HttpServletRequest request = servletWebRequest.getContainerRequest();
    final String req = request.getQueryString();

    if ((req != null) && req.contains("endMatch=true")) {
        HomePage.LOGGER.info("restart match for player: " + this.session.getPlayer().getId() + " & match: "
                + this.session.getGameId());

        final ConsoleLogStrategy logger = AbstractConsoleLogStrategy.chooseStrategy(ConsoleLogType.GAME, null,
                null, null, null, this.session.getPlayer().getName(), null, null, null, Boolean.FALSE,
                this.session.getGameId());
        final NotifierCometChannel ncc = new NotifierCometChannel(NotifierAction.END_GAME_ACTION, null, null,
                this.session.getPlayer().getName(), null, null, null, "");

        final List<BigInteger> allPlayersInGameExceptMe = this.persistenceService
                .giveAllPlayersFromGameExceptMe(this.session.getGameId(), this.session.getPlayer().getId());
        EventBusPostService.post(allPlayersInGameExceptMe, new ConsoleLogCometChannel(logger), ncc);

        request.getSession(false).invalidate();
        throw new RestartResponseException(HomePage.class);
    }//  w ww . ja v  a  2 s  .  c om

    if ((pp != null) && (pp.get("displayTooltips") != null)
            && ("true".equals(pp.get("displayTooltips").toString()))) {
        this.session.setDisplayTooltips(Boolean.TRUE);
    }

    // Resources
    this.addHeadResources();

    final FacebookSdk fsdk = new FacebookSdk("fb-root", "1398596203720626");
    fsdk.setFbAdmins("goupilpierre@wanadoo.fr");
    this.add(fsdk);

    if (this.session.isGameCreated().booleanValue()) {
        this.gameId = new Label("matchId", "Match id: " + this.session.getGameId().longValue());
        this.gameId.setOutputMarkupId(true);
    } else {
        this.gameId = new Label("matchId", "No match at the moment");
        this.gameId.setOutputMarkupId(true);
    }

    this.gameIdParent = new WebMarkupContainer("matchIdParent");
    this.gameIdParent.setOutputMarkupId(true);
    this.gameIdParent.add(this.gameId);
    this.add(this.gameIdParent);

    this.galleryParent = new WebMarkupContainer("galleryParent");
    this.galleryParent.setMarkupId("galleryParent");
    this.galleryParent.setOutputMarkupId(true);
    this.add(this.galleryParent);

    this.galleryRevealParent = new WebMarkupContainer("galleryRevealParent");
    this.galleryRevealParent.setMarkupId("galleryRevealParent");
    this.galleryRevealParent.setOutputMarkupId(true);
    this.galleryReveal = new WebMarkupContainer("galleryReveal");
    this.galleryReveal.setOutputMarkupId(true);
    this.galleryRevealParent.add(this.galleryReveal);
    this.add(this.galleryRevealParent);

    this.parentPlaceholder = new WebMarkupContainer("parentPlaceholder");
    this.parentPlaceholder.setOutputMarkupId(true);
    this.add(this.parentPlaceholder);

    this.opponentParentPlaceholder = new WebMarkupContainer("opponentParentPlaceholder");
    this.opponentParentPlaceholder.setOutputMarkupId(true);
    this.add(this.opponentParentPlaceholder);

    if (!this.session.isGameCreated().booleanValue()) {
        this.dataGenerator.afterPropertiesSet();
        this.createPlayer();

        this.buildHandCards();
        this.buildHandMarkup();
        this.buildDataBox(this.player.getGame().getId().longValue());
    } else {
        if (this.session.getPlayer() == null) {
            this.createPlayer();
        } else {
            this.restoreBattlefieldState();
        }
        this.player = this.session.getPlayer();

        this.buildHandCards();
        this.buildDataBox(this.player.getGame().getId().longValue());
    }

    // Side
    this.sideParent = new WebMarkupContainer("sideParent");
    this.sideParent.setOutputMarkupId(true);

    this.allPlayerSidesInGame = this.persistenceService
            .getAllPlayersOfGame(this.session.getGameId().longValue());
    final ListDataProvider<Player> data = new ListDataProvider<>(this.allPlayerSidesInGame);

    this.allSidesInGame = this.populateSides(data);

    this.sideParent.add(this.allSidesInGame);
    this.add(this.sideParent);

    this.graveyardParent = new WebMarkupContainer("graveyardParent");
    this.graveyardParent.setMarkupId("graveyardParent");
    this.graveyardParent.setOutputMarkupId(true);
    this.add(this.graveyardParent);

    this.exileParent = new WebMarkupContainer("exileParent");
    this.exileParent.setMarkupId("exileParent");
    this.exileParent.setOutputMarkupId(true);
    this.add(this.exileParent);

    // Welcome message
    final Label message1 = new Label("message1", "version 0.24.0 (release Battlefield),");
    final Label message2 = new Label("message2", "built on Monday, 19th of January 2015.");
    this.add(message1, message2);

    // Comet clock channel
    this.clockPanel = new ClockPanel("clockPanel", Model.of("###"));
    this.clockPanel.setOutputMarkupId(true);
    this.clockPanel.setMarkupId("clock");
    this.add(this.clockPanel);

    // Sides
    this.secondSidePlaceholderParent = new WebMarkupContainer("secondSidePlaceholderParent");
    this.secondSidePlaceholderParent.setOutputMarkupId(true);
    this.secondSidePlaceholderParent.setMarkupId("secondSidePlaceholderParent");
    final WebMarkupContainer secondSidePlaceholder = new WebMarkupContainer("secondSidePlaceholder");
    secondSidePlaceholder.setOutputMarkupId(true);
    secondSidePlaceholder.setMarkupId("secondSidePlaceholder");
    this.secondSidePlaceholderParent.add(secondSidePlaceholder);

    this.firstSidePlaceholderParent = new WebMarkupContainer("firstSidePlaceholderParent");
    this.firstSidePlaceholderParent.setOutputMarkupId(true);
    this.firstSidePlaceholderParent.setMarkupId("firstSidePlaceholderParent");
    final WebMarkupContainer firstSidePlaceholder = new WebMarkupContainer("firstSidePlaceholder");
    firstSidePlaceholder.setOutputMarkupId(true);
    this.firstSidePlaceholderParent.add(firstSidePlaceholder);

    this.add(this.secondSidePlaceholderParent, this.firstSidePlaceholderParent);

    // Placeholders for CardPanel-adding with AjaxRequestTarget
    this.createCardPanelPlaceholders();

    this.buildGraveyardMarkup();
    this.buildExileMarkup();
    this.buildDock();

    // Links from the menubar
    this.aboutWindow = new ModalWindow("aboutWindow");
    this.aboutWindow = this.generateAboutLink("aboutLink", this.aboutWindow);
    this.teamInfoWindow = new ModalWindow("teamInfoWindow");
    this.teamInfoWindow = this.generateTeamInfoLink("teamInfoLink", this.teamInfoWindow);

    /*
     * Links from the drop-down menu, which appears when the width of the
     * view port is < than its height. (AKA a little bit of responsive Web
     * design)
     */
    this.aboutWindow = this.generateAboutLink("aboutLinkResponsive", this.aboutWindow);

    this.mulliganWindow = new ModalWindow("mulliganWindow");
    this.generateMulliganLink("mulliganLink", this.mulliganWindow);
    this.generateMulliganLink("mulliganLinkResponsive", this.mulliganWindow);
    this.askMulliganWindow = new ModalWindow("askMulliganWindow");
    this.askMulliganWindow.setInitialWidth(500);
    this.askMulliganWindow.setInitialHeight(100);
    this.askMulliganWindow.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
    this.askMulliganWindow.setMaskType(ModalWindow.MaskType.SEMI_TRANSPARENT);
    this.add(this.askMulliganWindow);

    this.teamInfoWindow = this.generateTeamInfoLink("teamInfoLinkResponsive", this.teamInfoWindow);

    final GameNotifierBehavior notif = new GameNotifierBehavior(this);
    this.add(notif);

    this.createGameWindow = new ModalWindow("createMatchWindow");
    this.add(this.createGameWindow = this.generateCreateGameModalWindow("createMatchLink", this.player,
            this.createGameWindow));
    this.add(this.createGameWindow = this.generateCreateGameModalWindow("createMatchLinkResponsive",
            this.player, this.createGameWindow));

    this.joinGameWindow = new ModalWindow("joinMatchWindow");
    this.add(this.joinGameWindow = this.generateJoinGameModalWindow("joinMatchLink", this.player,
            this.joinGameWindow));
    this.add(this.joinGameWindow = this.generateJoinGameModalWindow("joinMatchLinkResponsive", this.player,
            this.joinGameWindow));

    this.joinGameWithoutIdWindow = new ModalWindow("joinMatchWithoutIdWindow");
    this.add(this.joinGameWithoutIdWindow = this.generateJoinGameWithoutIdModalWindow("joinMatchWithoutIdLink",
            this.player, this.joinGameWithoutIdWindow));
    this.add(this.joinGameWithoutIdWindow = this.generateJoinGameWithoutIdModalWindow(
            "joinMatchWithoutIdLinkResponsive", this.player, this.joinGameWithoutIdWindow));

    this.generatePlayCardLink();
    this.add(this.generatePlayCardFromGraveyardLink("playCardFromGraveyardLinkDesktop"));
    this.add(this.generatePlayCardFromGraveyardLink("playCardFromGraveyardLinkResponsive"));
    this.generateCardPanels();

    this.generateDrawCardLink();
    final RedrawArrowsBehavior rab = new RedrawArrowsBehavior(this.player.getGame().getId());
    this.add(rab);

    // Comet chat channel
    this.add(new ChatPanel("chatPanel"));

    this.buildEndTurnLink();
    this.buildInResponseLink();
    this.buildFineForMeLink();
    this.buildUntapAllLink();
    this.buildUntapAndDrawLink();
    this.buildCombatLink();

    this.importDeckDialog = new ImportDeckDialog("importDeckDialog");
    this.add(this.importDeckDialog);
    this.generateImportDeckLink("importDeckLink");
    this.generateImportDeckLink("importDeckLinkResponsive");

    this.allOpenRevealTopLibraryCardWindows = new ArrayList<>();
    this.generateRevealTopLibraryCardLink("revealTopLibraryCardLink", "revealTopLibraryCardWindow");
    this.generateRevealTopLibraryCardLink("revealTopLibraryCardLinkResponsive",
            "revealTopLibraryCardWindowResponsive");

    this.createTokenWindow = new ModalWindow("createTokenWindow");
    this.generateCreateTokenLink("createTokenLink", this.createTokenWindow);
    this.generateCreateTokenLink("createTokenLinkResponsive", this.createTokenWindow);

    this.countCardsWindow = new ModalWindow("countCardsWindow");
    this.generateCountCardsLink("countCardsLink", this.countCardsWindow);
    this.generateCountCardsLink("countCardsLinkResponsive", this.countCardsWindow);
    this.generateDiscardAtRandomLink("discardAtRandomLink");
    this.generateDiscardAtRandomLink("discardAtRandomLinkResponsive");
    this.generateInsertDivisionLink("insertDivisionLink");
    this.generateInsertDivisionLink("insertDivisionLinkResponsive");
    this.generateShuffleLibraryLink("shuffleLibraryLink");
    this.generateShuffleLibraryLink("shuffleLibraryLinkResponsive");

    this.loginWindow = new ModalWindow("loginWindow");
    this.generateLoginLink("loginLink", this.loginWindow);
    this.generateLoginLink("loginLinkResponsive", this.loginWindow);
    final FacebookLoginBehavior flb = new FacebookLoginBehavior();
    this.add(flb);

    this.preferencesWindow = new ModalWindow("preferencesWindow");
    this.generatePreferencesLink("preferencesLink", this.preferencesWindow);
    this.generatePreferencesLink("preferencesLinkResponsive", this.preferencesWindow);

    this.generateEndMatchLink("endMatchLink");
    this.generateEndMatchLink("endMatchLinkResponsive");
    this.generateHideAllTooltipsLink("hideAllTooltipsLink");
    this.generateHideAllTooltipsLink("hideAllTooltipsLinkResponsive");

    this.conferenceParent = new WebMarkupContainer("conferenceParent");
    this.conferenceParent.setOutputMarkupId(true);
    final ConferencePanel conference = new ConferencePanel("conference");
    conference.setOutputMarkupId(true);
    this.conferenceParent.add(conference);
    this.add(this.conferenceParent);
    this.generateOpenConferenceLink("conferenceOpener");
    this.generateOpenConferenceLink("conferenceOpenerResponsive");

    this.generateRevealHandLink("revealHandLink");
    this.generateRevealHandLink("revealHandLinkResponsive");

    // For console logs & chat messages
    this.add(new MessageRedisplayBehavior(this.session.getGameId()));

    this.drawModeParent = new WebMarkupContainer("drawModeParent");
    this.drawModeParent.setOutputMarkupId(true);

    if (this.session.getPlayer().getGame().isDrawMode().booleanValue()) {
        this.drawModeParent.add(new ExternalImage("drawModeOn", "image/draw_mode_on.png"));
    } else {
        this.drawModeParent.add(new WebMarkupContainer("drawModeOn").setVisible(false));
    }

    this.add(this.drawModeParent);

    if (this.session.isLoggedIn().booleanValue()) {
        this.username = new Label("username", "Logged in as " + this.session.getUsername());
        this.username.setOutputMarkupId(true);
    } else {
        this.username = new Label("username", "Not logged in");
        this.username.setOutputMarkupId(true);
    }

    this.usernameParent = new WebMarkupContainer("usernameParent");
    this.usernameParent.setOutputMarkupId(true);
    this.usernameParent.add(this.username);
    this.add(this.usernameParent);
}

From source file:org.alienlabs.hatchetharry.view.page.HomePage.java

License:Open Source License

private void generateRevealTopLibraryCardLink(final String id, final String idModalWindow) {
    final ModalWindow window = new ModalWindow(idModalWindow);
    window.setWindowClosedCallback(new WindowClosedCallback() {
        private static final long serialVersionUID = 1L;

        @Override/*from w w w  . ja  v  a 2  s  .c  o m*/
        public void onClose(final AjaxRequestTarget target) {
            if (HomePage.this.session.getTopCardIndex() > 0L) {
                HomePage.this.session
                        .setTopCardIndex(Long.valueOf(HomePage.this.session.getTopCardIndex() - 1L));
            }

        }
    });
    window.setInitialWidth(500);
    window.setInitialHeight(510);

    final List<MagicCard> allCardsInLibrary = this.persistenceService.getAllCardsInLibraryForDeckAndPlayer(
            this.session.getGameId(), this.session.getPlayer().getId(),
            this.session.getPlayer().getDeck().getDeckId());
    final MagicCard firstCard;

    if (allCardsInLibrary.isEmpty()) {
        firstCard = null;
    } else {
        firstCard = allCardsInLibrary.get(this.session.getTopCardIndex().intValue());
    }

    window.setContent(new RevealTopLibraryCardModalWindow(window.getContentId(), window, firstCard));

    window.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
    window.setMaskType(ModalWindow.MaskType.SEMI_TRANSPARENT);
    window.setOutputMarkupId(true);

    this.revealTopLibraryCardWindow = window;
    this.add(this.revealTopLibraryCardWindow);

    final AjaxLink<Void> revealTopLibraryCardLink = new AjaxLink<Void>(id) {
        private static final long serialVersionUID = 1L;

        @SuppressWarnings("boxing")
        @SuppressFBWarnings({ "PATH_TRAVERSAL_IN", "PATH_TRAVERSAL_IN" })
        @Override
        public void onClick(final AjaxRequestTarget target) {
            final List<MagicCard> _allCardsInLibrary = HomePage.this.persistenceService
                    .getAllCardsInLibraryForDeckAndPlayer(HomePage.this.session.getGameId(),
                            HomePage.this.session.getPlayer().getId(),
                            HomePage.this.session.getPlayer().getDeck().getDeckId());
            if (_allCardsInLibrary.isEmpty()) {
                return;
            }

            final MagicCard _firstCard = _allCardsInLibrary
                    .get(HomePage.this.session.getTopCardIndex().intValue());
            final String topCardName = _firstCard.getBigImageFilename();

            final String cardPath = ResourceBundle.getBundle(HatchetHarryApplication.class.getCanonicalName())
                    .getString("SharedResourceFolder");
            final String cardPathAndName = cardPath.replace("/cards", "") + topCardName;
            final File from = new File(cardPathAndName);
            final File to = new File(cardPath + "topLibraryCard.jpg");

            try {
                Files.copy(from, to);
            } catch (final IOException e) {
                HomePage.LOGGER.error(
                        "could not copy from: " + cardPathAndName + " to: " + cardPath + "topLibraryCard.jpg",
                        e);
            }

            final Long _gameId = HomePage.this.persistenceService
                    .getPlayer(HomePage.this.session.getPlayer().getId()).getGame().getId();
            final RevealTopLibraryCardCometChannel chan = new RevealTopLibraryCardCometChannel(
                    HomePage.this.session.getPlayer().getName(), _firstCard,
                    HomePage.this.session.getTopCardIndex());
            final ConsoleLogStrategy logger = AbstractConsoleLogStrategy.chooseStrategy(
                    ConsoleLogType.REVEAL_TOP_CARD_OF_LIBRARY, null, null, null, _firstCard.getTitle(),
                    HomePage.this.session.getPlayer().getName(), null,
                    HomePage.this.session.getTopCardIndex() + 1L, null, Boolean.FALSE, _gameId);
            final List<BigInteger> allPlayersInGame = HomePage.this.persistenceService
                    .giveAllPlayersFromGame(_gameId);

            EventBusPostService.post(allPlayersInGame, chan, new ConsoleLogCometChannel(logger));
        }
    };

    revealTopLibraryCardLink.setOutputMarkupId(true).setMarkupId(id);
    this.add(revealTopLibraryCardLink);
}

From source file:org.apache.directory.fortress.web.panel.AuditAuthzListPanel.java

License:Apache License

private void addUserSearchModal() {
    final ModalWindow usersModalWindow;
    listForm.add(usersModalWindow = new ModalWindow("usersearchmodal"));
    final UserSearchModalPanel userSearchModalPanel = new UserSearchModalPanel(usersModalWindow.getContentId(),
            usersModalWindow);/*from   w  ww  . j  a  v  a  2  s.c  o m*/
    usersModalWindow.setContent(userSearchModalPanel);
    usersModalWindow.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() {
        /** Default serialVersionUID */
        private static final long serialVersionUID = 1L;

        @Override
        public void onClose(AjaxRequestTarget target) {
            User userSelection = userSearchModalPanel.getUserSelection();
            if (userSelection != null) {
                LOG.debug("modal selected:" + userSelection.getUserId());
                UserAudit userAudit = (UserAudit) listForm.getModelObject();
                userAudit.setUserId(userSelection.getUserId());
                target.add(userFld);
            }
        }
    });
    listForm.add(new SecureIndicatingAjaxLink("userAssignLinkLbl", GlobalIds.REVIEW_MGR, GlobalIds.FIND_USERS) {
        /** Default serialVersionUID */
        private static final long serialVersionUID = 1L;

        public void onClick(AjaxRequestTarget target) {
            UserAudit userAudit = (UserAudit) listForm.getModelObject();
            String msg = "clicked on users search";
            msg += "userSelection: " + userAudit.getUserId();
            userSearchModalPanel.setSearchVal(userAudit.getUserId());
            LOG.debug(msg);
            target.prependJavaScript(GlobalIds.WICKET_WINDOW_UNLOAD_CONFIRMATION_FALSE);
            usersModalWindow.show(target);
        }

        @Override
        protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
            super.updateAjaxAttributes(attributes);
            AjaxCallListener ajaxCallListener = new AjaxCallListener() {
                /** Default serialVersionUID */
                private static final long serialVersionUID = 1L;

                @Override
                public CharSequence getFailureHandler(Component component) {
                    return GlobalIds.WINDOW_LOCATION_REPLACE_COMMANDER_HOME_HTML;
                }
            };
            attributes.getAjaxCallListeners().add(ajaxCallListener);
        }
    });
    usersModalWindow.setTitle("User Search Modal");
    usersModalWindow.setInitialWidth(1000);
    usersModalWindow.setInitialHeight(700);
    usersModalWindow.setCookieName("user-search-modal");
}

From source file:org.apache.directory.fortress.web.panel.AuditAuthzListPanel.java

License:Apache License

private void addPermSearchModal() {
    final ModalWindow permsModalWindow;
    UserAudit userAudit = (UserAudit) listForm.getModelObject();
    listForm.add(permsModalWindow = new ModalWindow("permsearchmodal"));
    final PermSearchModalPanel permSearchModalPanel = new PermSearchModalPanel(permsModalWindow.getContentId(),
            permsModalWindow, userAudit.isAdmin());
    permsModalWindow.setContent(permSearchModalPanel);
    permsModalWindow.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() {
        /** Default serialVersionUID */
        private static final long serialVersionUID = 1L;

        @Override/*from w  w w . j a  va  2 s. co m*/
        public void onClose(AjaxRequestTarget target) {
            Permission permSelection = permSearchModalPanel.getSelection();
            if (permSelection != null) {
                UserAudit userAudit = (UserAudit) listForm.getModelObject();
                LOG.debug("modal selected:" + permSelection.getAbstractName());
                permission = permSelection;
                userAudit.setObjName(permSelection.getObjName());
                userAudit.setOpName(permSelection.getOpName());
                target.add(objFld);
                target.add(opFld);
            }
        }
    });
    listForm.add(new SecureIndicatingAjaxLink("permLinkLbl", GlobalIds.REVIEW_MGR, GlobalIds.FIND_PERMISSIONS) {
        /** Default serialVersionUID */
        private static final long serialVersionUID = 1L;

        public void onClick(AjaxRequestTarget target) {
            UserAudit userAudit = (UserAudit) listForm.getModelObject();
            String msg = "clicked on perms search";
            msg += "permSelection: " + permission;
            permSearchModalPanel.setSearchVal(userAudit.getObjName());
            permSearchModalPanel.setAdmin(userAudit.isAdmin());
            LOG.debug(msg);
            target.prependJavaScript(GlobalIds.WICKET_WINDOW_UNLOAD_CONFIRMATION_FALSE);
            permsModalWindow.show(target);
        }

        @Override
        protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
            super.updateAjaxAttributes(attributes);
            AjaxCallListener ajaxCallListener = new AjaxCallListener() {
                /** Default serialVersionUID */
                private static final long serialVersionUID = 1L;

                @Override
                public CharSequence getFailureHandler(Component component) {
                    return GlobalIds.WINDOW_LOCATION_REPLACE_COMMANDER_HOME_HTML;
                }
            };
            attributes.getAjaxCallListeners().add(ajaxCallListener);
        }
    });
    String title;
    if (userAudit.isAdmin())
        title = "Admin Permission Search Modal";
    else
        title = "Permission Search Modal";

    permsModalWindow.setTitle(title);
    permsModalWindow.setInitialWidth(650);
    permsModalWindow.setInitialHeight(450);
    permsModalWindow.setCookieName("perm-search-modal");
}

From source file:org.apache.directory.fortress.web.panel.AuditModListPanel.java

License:Apache License

private void addUserSearchModal() {
    final ModalWindow usersModalWindow;
    listForm.add(usersModalWindow = new ModalWindow("usersearchmodal"));
    final UserSearchModalPanel userSearchModalPanel = new UserSearchModalPanel(usersModalWindow.getContentId(),
            usersModalWindow);//from  ww w . j a v  a2s  . c  o m
    usersModalWindow.setContent(userSearchModalPanel);
    usersModalWindow.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() {
        /** Default serialVersionUID */
        private static final long serialVersionUID = 1L;

        @Override
        public void onClose(AjaxRequestTarget target) {
            User userSelection = userSearchModalPanel.getUserSelection();
            if (userSelection != null) {
                LOG.debug("modal selected:" + userSelection.getUserId());
                UserAudit userAudit = (UserAudit) listForm.getModelObject();
                userAudit.setUserId(userSelection.getUserId());
                userAudit.setInternalUserId(userSelection.getInternalId());
                target.add(userFld);
            }
        }
    });
    listForm.add(new SecureIndicatingAjaxLink("userAssignLinkLbl", GlobalIds.REVIEW_MGR, GlobalIds.FIND_USERS) {
        /** Default serialVersionUID */
        private static final long serialVersionUID = 1L;

        public void onClick(AjaxRequestTarget target) {
            UserAudit userAudit = (UserAudit) listForm.getModelObject();
            String msg = "clicked on users search";
            msg += "userSelection: " + userAudit.getUserId();
            userSearchModalPanel.setSearchVal(userAudit.getUserId());
            LOG.debug(msg);
            target.prependJavaScript(GlobalIds.WICKET_WINDOW_UNLOAD_CONFIRMATION_FALSE);
            usersModalWindow.show(target);
        }

        @Override
        protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
            super.updateAjaxAttributes(attributes);
            AjaxCallListener ajaxCallListener = new AjaxCallListener() {
                /** Default serialVersionUID */
                private static final long serialVersionUID = 1L;

                @Override
                public CharSequence getFailureHandler(Component component) {
                    return GlobalIds.WINDOW_LOCATION_REPLACE_COMMANDER_HOME_HTML;
                }
            };
            attributes.getAjaxCallListeners().add(ajaxCallListener);
        }
    });
    usersModalWindow.setTitle("User Search Modal");
    usersModalWindow.setInitialWidth(1000);
    usersModalWindow.setInitialHeight(700);
    usersModalWindow.setCookieName("user-search-modal");
}

From source file:org.apache.directory.fortress.web.panel.AuditModListPanel.java

License:Apache License

private void addPermSearchModal() {
    final ModalWindow permsModalWindow;
    listForm.add(permsModalWindow = new ModalWindow("permsearchmodal"));
    final PermSearchModalPanel permSearchModalPanel = new PermSearchModalPanel(permsModalWindow.getContentId(),
            permsModalWindow, true);// w  w w  .j  a  va2s  . c om
    permsModalWindow.setContent(permSearchModalPanel);
    permsModalWindow.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() {
        /** Default serialVersionUID */
        private static final long serialVersionUID = 1L;

        @Override
        public void onClose(AjaxRequestTarget target) {
            Permission permSelection = permSearchModalPanel.getSelection();
            if (permSelection != null) {
                UserAudit userAudit = (UserAudit) listForm.getModelObject();
                LOG.debug("modal selected:" + permSelection.getAbstractName());
                permission = permSelection;
                userAudit.setObjName(permSelection.getObjName());
                userAudit.setOpName(permSelection.getOpName());
                target.add(objFld);
                target.add(opFld);
            }
        }
    });
    listForm.add(new SecureIndicatingAjaxLink("permLinkLbl", GlobalIds.REVIEW_MGR, GlobalIds.FIND_PERMISSIONS) {
        /** Default serialVersionUID */
        private static final long serialVersionUID = 1L;

        public void onClick(AjaxRequestTarget target) {
            UserAudit userAudit = (UserAudit) listForm.getModelObject();
            String msg = "clicked on perms search";
            msg += "permSelection: " + permission;
            permSearchModalPanel.setSearchVal(userAudit.getOpName());
            permSearchModalPanel.setAdmin(true);
            LOG.debug(msg);
            target.prependJavaScript(GlobalIds.WICKET_WINDOW_UNLOAD_CONFIRMATION_FALSE);
            permsModalWindow.show(target);
        }

        @Override
        protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
            super.updateAjaxAttributes(attributes);
            AjaxCallListener ajaxCallListener = new AjaxCallListener() {
                /** Default serialVersionUID */
                private static final long serialVersionUID = 1L;

                @Override
                public CharSequence getFailureHandler(Component component) {
                    return GlobalIds.WINDOW_LOCATION_REPLACE_COMMANDER_HOME_HTML;
                }
            };
            attributes.getAjaxCallListeners().add(ajaxCallListener);
        }
    });
    permsModalWindow.setTitle("Admin Permission Search Modal");
    permsModalWindow.setInitialWidth(650);
    permsModalWindow.setInitialHeight(450);
    permsModalWindow.setCookieName("perm-search-modal");
}

From source file:org.apache.directory.fortress.web.panel.GroupListPanel.java

License:Apache License

private void addMemberSearchModal(Radio memberRb) {
    final ModalWindow memberModalWindow;
    listForm.add(memberModalWindow = new ModalWindow("membersearchmodal"));
    final UserSearchModalPanel userSearchModalPanel = new UserSearchModalPanel(memberModalWindow.getContentId(),
            memberModalWindow);/* ww  w .j a v a2  s  .c  o  m*/
    memberModalWindow.setContent(userSearchModalPanel);
    memberModalWindow.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() {
        /** Default serialVersionUID */
        private static final long serialVersionUID = 1L;

        @Override
        public void onClose(AjaxRequestTarget target) {
            User user = userSearchModalPanel.getUserSelection();
            if (user != null) {
                searchVal = user.getUserId();
                selectedRadioButton = MEMBERS;
                target.add(radioGroup);
            }
        }
    });

    memberRb.add(new SecureIndicatingAjaxLink("memberAssignLinkLbl", GlobalIds.REVIEW_MGR, "findUsers") {
        /** Default serialVersionUID */
        private static final long serialVersionUID = 1L;

        public void onClick(AjaxRequestTarget target) {
            String msg = "clicked on ou search";
            msg += "memberSelection: " + searchVal;
            userSearchModalPanel.setSearchVal(searchVal);
            log.debug(msg);
            target.prependJavaScript(GlobalIds.WICKET_WINDOW_UNLOAD_CONFIRMATION_FALSE);
            memberModalWindow.show(target);
        }

        @Override
        protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
            super.updateAjaxAttributes(attributes);
            AjaxCallListener ajaxCallListener = new AjaxCallListener() {
                /** Default serialVersionUID */
                private static final long serialVersionUID = 1L;

                @Override
                public CharSequence getFailureHandler(Component component) {
                    return GlobalIds.WINDOW_LOCATION_REPLACE_COMMANDER_HOME_HTML;
                }
            };
            attributes.getAjaxCallListeners().add(ajaxCallListener);
        }
    });

    memberModalWindow.setTitle("Member Search Modal");
    memberModalWindow.setInitialWidth(450);
    memberModalWindow.setInitialHeight(450);
    memberModalWindow.setCookieName("member-modal");
}

From source file:org.apache.directory.fortress.web.panel.ObjectListPanel.java

License:Apache License

private void addOUSearchModal(Radio ouRb) {
    final ModalWindow ousModalWindow;
    listForm.add(ousModalWindow = new ModalWindow("ousearchmodal"));
    final OUSearchModalPanel ouSearchModalPanel = new OUSearchModalPanel(ousModalWindow.getContentId(),
            ousModalWindow, false);/*  w  w  w  .ja  v  a2  s  .  co  m*/
    ousModalWindow.setContent(ouSearchModalPanel);
    ousModalWindow.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() {
        /** Default serialVersionUID */
        private static final long serialVersionUID = 1L;

        @Override
        public void onClose(AjaxRequestTarget target) {
            OrgUnit ou = ouSearchModalPanel.getSelection();
            if (ou != null) {
                searchVal = ou.getName();
                selectedRadioButton = OUS;
                target.add(radioGroup);
            }
        }
    });

    ouRb.add(new SecureIndicatingAjaxLink("ouAssignLinkLbl", GlobalIds.DEL_REVIEW_MGR, "searchOU") {
        /** Default serialVersionUID */
        private static final long serialVersionUID = 1L;

        public void onClick(AjaxRequestTarget target) {
            String msg = "clicked on ou search";
            msg += "ouSelection: " + searchVal;
            ouSearchModalPanel.setSearchVal(searchVal);
            log.debug(msg);
            target.prependJavaScript(GlobalIds.WICKET_WINDOW_UNLOAD_CONFIRMATION_FALSE);
            ousModalWindow.show(target);
        }

        @Override
        protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
            super.updateAjaxAttributes(attributes);
            AjaxCallListener ajaxCallListener = new AjaxCallListener() {
                /** Default serialVersionUID */
                private static final long serialVersionUID = 1L;

                @Override
                public CharSequence getFailureHandler(Component component) {
                    return GlobalIds.WINDOW_LOCATION_REPLACE_COMMANDER_HOME_HTML;
                }
            };
            attributes.getAjaxCallListeners().add(ajaxCallListener);
        }
    });

    ousModalWindow.setTitle("Permission Object Organizational Unit Search Modal");
    ousModalWindow.setInitialWidth(450);
    ousModalWindow.setInitialHeight(450);
    ousModalWindow.setCookieName("permou-modal");
}

From source file:org.apache.directory.fortress.web.panel.PermListPanel.java

License:Apache License

private void addObjectSearchModal() {
    final ModalWindow objectsModalWindow;
    listForm.add(objectsModalWindow = new ModalWindow("objectsearchmodal"));
    final ObjectSearchModalPanel objectSearchModalPanel = new ObjectSearchModalPanel(
            objectsModalWindow.getContentId(), objectsModalWindow, isAdmin);
    objectsModalWindow.setContent(objectSearchModalPanel);

    objectsModalWindow.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() {
        /** Default serialVersionUID */
        private static final long serialVersionUID = 1L;

        @Override// w  w  w.j  a v a 2 s .  com
        public void onClose(AjaxRequestTarget target) {
            PermObj permObj = objectSearchModalPanel.getSelection();

            if (permObj != null) {
                permObject = permObj.getObjName();
                target.add(permObjectFld);
            }
        }
    });

    listForm.add(new SecureIndicatingAjaxLink("objectAssignLinkLbl", GlobalIds.REVIEW_MGR, "findPermObjs") {
        /** Default serialVersionUID */
        private static final long serialVersionUID = 1L;

        public void onClick(AjaxRequestTarget target) {
            String msg = "clicked on object search";
            msg += "objectSelection: " + permObject;
            objectSearchModalPanel.setSearchVal(permObject);
            objectSearchModalPanel.setAdmin(isAdmin);
            log.debug(msg);
            target.prependJavaScript(GlobalIds.WICKET_WINDOW_UNLOAD_CONFIRMATION_FALSE);
            objectsModalWindow.show(target);
        }

        @Override
        protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
            super.updateAjaxAttributes(attributes);

            AjaxCallListener ajaxCallListener = new AjaxCallListener() {
                /** Default serialVersionUID */
                private static final long serialVersionUID = 1L;

                @Override
                public CharSequence getFailureHandler(Component component) {
                    return GlobalIds.WINDOW_LOCATION_REPLACE_COMMANDER_HOME_HTML;
                }
            };

            attributes.getAjaxCallListeners().add(ajaxCallListener);
        }
    });

    String modalLabel;

    if (isAdmin) {
        modalLabel = "Admin Permission Object Search Modal";
    } else {
        modalLabel = "RBAC Permission Object Search Modal";
    }

    objectsModalWindow.setTitle(modalLabel);
    objectsModalWindow.setInitialWidth(700);
    objectsModalWindow.setInitialHeight(450);
    objectsModalWindow.setCookieName("objects-modal");
}

From source file:org.apache.directory.fortress.web.panel.RoleAdminDetailPanel.java

License:Apache License

private void addPermOUSearchModal() {
    final ModalWindow permousModalWindow;
    add(permousModalWindow = new ModalWindow("permoumodal"));
    final OUSearchModalPanel permouSearchModalPanel = new OUSearchModalPanel(permousModalWindow.getContentId(),
            permousModalWindow, false);//from w w w . ja  v a2 s  .  c  o  m
    permousModalWindow.setContent(permouSearchModalPanel);
    permousModalWindow.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() {
        /** Default serialVersionUID */
        private static final long serialVersionUID = 1L;

        @Override
        public void onClose(AjaxRequestTarget target) {
            OrgUnit ou = permouSearchModalPanel.getSelection();
            if (ou != null) {
                permouSelection = ou.getName();
                AdminRole adminRole = (AdminRole) getDefaultModelObject();
                adminRole.setOsP(permouSelection);
                target.add(permouCB);
            }
        }
    });

    add(new AjaxButton(GlobalIds.PERMOU_SEARCH) {
        /** Default serialVersionUID */
        private static final long serialVersionUID = 1L;

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            String msg = "clicked on permission OU search";
            msg += permouSelection != null ? ": " + permouSelection : "";
            permouSearchModalPanel.setSearchVal(permouSelection);
            LOG.debug(msg);
            target.prependJavaScript(GlobalIds.WICKET_WINDOW_UNLOAD_CONFIRMATION_FALSE);
            permousModalWindow.show(target);
        }

        @Override
        protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
            super.updateAjaxAttributes(attributes);
            AjaxCallListener ajaxCallListener = new AjaxCallListener() {
                /** Default serialVersionUID */
                private static final long serialVersionUID = 1L;

                @Override
                public CharSequence getFailureHandler(Component component) {
                    return GlobalIds.WINDOW_LOCATION_REPLACE_COMMANDER_HOME_HTML;
                }
            };
            attributes.getAjaxCallListeners().add(ajaxCallListener);
        }
    });

    permousModalWindow.setTitle("Perm Organization Selection Modal");
    permousModalWindow.setInitialWidth(450);
    permousModalWindow.setInitialHeight(450);
    permousModalWindow.setCookieName("permou-modal");

    add(new AjaxButton("permou.delete") {
        /** Default serialVersionUID */
        private static final long serialVersionUID = 1L;

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            String msg = "clicked on permous.delete";
            if (StringUtils.isNotEmpty(permouSelection)) {
                msg += " selection:" + permouSelection;
                AdminRole adminRole = (AdminRole) form.getModel().getObject();
                if (adminRole.getOsPSet() != null) {
                    adminRole.getOsPSet().remove(permouSelection);
                    permous.remove(permouSelection);
                    permouSelection = "";
                    target.add(permouCB);
                    msg += ", was removed from local, commit to persist changes on server";
                } else {
                    msg += ", no action taken because org unit does not have parent set";
                }
            } else {
                msg += ", no action taken because parents selection is empty";
            }
            LOG.debug(msg);
        }

        @Override
        protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
            super.updateAjaxAttributes(attributes);
            AjaxCallListener ajaxCallListener = new AjaxCallListener() {
                /** Default serialVersionUID */
                private static final long serialVersionUID = 1L;

                @Override
                public CharSequence getFailureHandler(Component component) {
                    return GlobalIds.WINDOW_LOCATION_REPLACE_COMMANDER_HOME_HTML;
                }
            };
            attributes.getAjaxCallListeners().add(ajaxCallListener);
        }
    });
}