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:ontopoly.components.FieldInstanceAssociationNaryField.java

License:Apache License

public FieldInstanceAssociationNaryField(String id, FieldInstanceAssociationNaryPanel _parentPanel,
        RoleFieldModel roleFieldModel, List<RoleFieldModel> otherRoleFieldModels,
        FieldValueModel _fieldValueModel, FieldsViewModel fieldsViewModel, final boolean readonly,
        boolean traversable, final int arity) {
    super(id);/*  ww  w  . j  a  v  a2 s .  c o m*/
    this.fieldValueModel = _fieldValueModel;
    this.parentPanel = _parentPanel;
    this.arity = arity;
    FieldInstanceModel fieldInstanceModel = fieldValueModel.getFieldInstanceModel();

    // register current player
    this.currentFieldModel = roleFieldModel;
    this.currentTopicModel = new TopicModel<Topic>(fieldInstanceModel.getFieldInstance().getInstance());
    selectedPlayers.put(roleFieldModel, currentTopicModel);

    RoleField.ValueIF fieldValue = (RoleField.ValueIF) fieldValueModel.getFieldValue();

    RepeatingView rv = new RepeatingView("roles");
    rv.setVisible(!readonly || fieldValueModel.isExistingValue());
    add(rv);

    Iterator<RoleFieldModel> oiter = otherRoleFieldModels.iterator();
    while (oiter.hasNext()) {
        final RoleFieldModel ofieldModel = oiter.next();
        RoleField ofield = ofieldModel.getRoleField();

        final WebMarkupContainer parent = new WebMarkupContainer(rv.newChildId()) {
            @Override
            public boolean isVisible() {
                // hide if read-only and not complete
                if (readonly && selectedPlayers.size() != arity)
                    return false;
                else
                    return true;
            }
        };
        parent.setOutputMarkupId(true);
        rv.add(parent);
        parent.add(new Label("label", new Model<String>(ofield.getRoleType().getName())));
        //! parent.add(new Label("label", new Model(ofield.getFieldName())));

        // register other player
        Topic topic = (fieldValue == null ? null
                : fieldValue.getPlayer(ofield, fieldInstanceModel.getFieldInstance().getInstance()));
        final TopicModel<Topic> topicModel = new TopicModel<Topic>(topic);
        // NOTE: should not use same model as selected model as the model would then be updated immediately
        selectedPlayers.put(ofieldModel, new TopicModel<Topic>(topic));

        TopicLink<Topic> playerLink = new TopicLink<Topic>("player", topicModel);
        playerLink.setEnabled(traversable);
        playerLink.setVisible(topic != null);
        parent.add(playerLink);

        EditMode editMode = ofield.getEditMode();
        final boolean allowAdd = !editMode.isNewValuesOnly();
        final boolean allowCreate = !editMode.isExistingValuesOnly();

        if (readonly || fieldValueModel.isExistingValue() || !allowAdd) {
            // unused components
            parent.add(new Label("select").setVisible(false));
            parent.add(new Label("find").setVisible(false));
            parent.add(new Label("findModal").setVisible(false));

        } else {

            InterfaceControl interfaceControl = ofield.getInterfaceControl();
            if (interfaceControl.isAutoComplete()) {
                final AssociationFieldAutoCompleteTextField autoCompleteField = new AssociationFieldAutoCompleteTextField(
                        "select", new TopicModel<Topic>(null), ofieldModel) {
                    @Override
                    protected void filterPlayers(List<Topic> players) {
                        AbstractOntopolyPage page = (AbstractOntopolyPage) getPage();
                        page.filterTopics(players);
                    }

                    @Override
                    protected void onTopicSelected(Topic topic) {
                        topicModel.setObject(topic);
                        boolean changesMade = onNewSelection(ofieldModel, topic);
                        // replace ourselves with a topic link
                        if (changesMade)
                            parent.replace(new TopicLink<Topic>("select", new TopicModel<Topic>(topic)));
                    }
                };
                autoCompleteField.getTextField().add(new AjaxFormComponentUpdatingBehavior("onchange") {
                    @Override
                    protected void onUpdate(AjaxRequestTarget target) {
                        if (needsUpdate)
                            FieldInstanceAssociationNaryField.this.onUpdate(target);
                        else
                            target.addComponent(parent);
                    }
                });

                autoCompleteField.setOutputMarkupId(true);
                parent.add(autoCompleteField);

                // unused components
                parent.add(new Label("find").setVisible(false));
                parent.add(new Label("findModal").setVisible(false));

            } else if (interfaceControl.isDropDownList()) {
                PossiblePlayersModel choicesModel = new PossiblePlayersModel(fieldInstanceModel, ofieldModel) {
                    @Override
                    protected void filterPlayers(Collection<Topic> players) {
                        AbstractOntopolyPage page = (AbstractOntopolyPage) getPage();
                        page.filterTopics(players);
                    }
                };

                TopicDropDownChoice<Topic> choice = new TopicDropDownChoice<Topic>("select", topicModel,
                        choicesModel) {
                    @Override
                    protected void onModelChanged() {
                        super.onModelChanged();
                        onNewSelection(ofieldModel, getModel().getObject());
                    }
                };
                choice.setOutputMarkupId(true);
                choice.add(new AjaxFormComponentUpdatingBehavior("onchange") {
                    @Override
                    protected void onUpdate(AjaxRequestTarget target) {
                        FieldInstanceAssociationNaryField.this.onUpdate(target);
                    }

                    @Override
                    protected void onError(AjaxRequestTarget target, RuntimeException e) {
                        FieldInstanceAssociationNaryField.this.onError(target, e);
                    }
                });
                parent.add(choice);

                // unused components
                parent.add(new Label("find").setVisible(false));
                parent.add(new Label("findModal").setVisible(false));

            } else if (interfaceControl.isSearchDialog() || interfaceControl.isBrowseDialog()) {

                // unused components
                parent.add(new TopicLink<Topic>("select", topicModel));

                // "search"/"browse" button
                final ModalWindow findModal = new ModalWindow("findModal");
                parent.add(findModal);

                int activeTab = (interfaceControl.isSearchDialog() ? ModalFindPage.ACTIVE_TAB_SEARCH
                        : ModalFindPage.ACTIVE_TAB_BROWSE);

                findModal.setContent(
                        new ModalFindPage<String>(findModal.getContentId(), fieldInstanceModel, activeTab) {
                            @Override
                            protected boolean isMaxOneCardinality() {
                                return true;
                            }

                            @Override
                            protected void onSelectionConfirmed(AjaxRequestTarget target,
                                    Collection<String> selected) {
                                if (!selected.isEmpty()) {
                                    String topicId = selected.iterator().next();
                                    TopicMap topicMap = fieldValueModel.getFieldInstanceModel()
                                            .getFieldInstance().getInstance().getTopicMap();
                                    Topic topic = topicMap.getTopicById(topicId);
                                    topicModel.setObject(topic);
                                    onNewSelection(ofieldModel, topic);
                                    if (needsUpdate)
                                        FieldInstanceAssociationNaryField.this.onUpdate(target);
                                    else
                                        target.addComponent(parent);
                                }
                            }

                            @Override
                            protected void onCloseCancel(AjaxRequestTarget target) {
                                findModal.close(target);
                            }

                            @Override
                            protected void onCloseOk(AjaxRequestTarget target) {
                                findModal.close(target);
                            }
                        });
                findModal.setTitle(new ResourceModel("ModalWindow.title.find.topic").getObject().toString());
                findModal.setCookieName("findModal");

                OntopolyImageLink findButton = new OntopolyImageLink("find", "search.gif",
                        new ResourceModel("icon.search.find-topic")) {
                    @Override
                    public boolean isVisible() {
                        return !readonly;
                    }

                    @Override
                    public void onClick(AjaxRequestTarget target) {
                        findModal.show(target);
                    }
                };
                parent.add(findButton);

            } else {
                throw new RuntimeException("Unsupported interface control: " + interfaceControl);
            }
        }

        // create button
        if (readonly || fieldValueModel.isExistingValue() || !allowCreate) {
            parent.add(new Label("create").setVisible(false));
        } else {
            // always use popup window
            int createAction = FieldInstanceCreatePlayerPanel.CREATE_ACTION_POPUP;
            FieldInstanceCreatePlayerPanel createPanel = new FieldInstanceCreatePlayerPanel("create",
                    fieldInstanceModel, fieldsViewModel, ofieldModel, parentPanel, createAction) {
                @Override
                protected Topic createInstance(TopicType topicType) {
                    Topic currentTopic = currentTopicModel.getTopic();
                    RoleField currentField = currentFieldModel.getRoleField();
                    RoleField createField = ofieldModel.getRoleField();
                    Topic createdTopic = null;

                    // check with page to see if add is allowed
                    AbstractOntopolyPage page = (AbstractOntopolyPage) getPage();
                    if (page.isCreateAllowed(currentTopic, currentField, topicType, createField)) {
                        // create a new topic instance
                        createdTopic = topicType.createInstance(null);
                        topicModel.setObject(createdTopic);
                        performNewSelection(ofieldModel, createdTopic);
                    }
                    return createdTopic;
                }

                @Override
                protected void performNewSelection(RoleFieldModel ofieldModel, Topic selectedTopic) {
                    FieldInstanceAssociationNaryField.this.performNewSelection(ofieldModel, selectedTopic);
                }

                @Override
                protected void hideInstancePage(AjaxRequestTarget target) {
                    if (needsUpdate)
                        FieldInstanceAssociationNaryField.this.onUpdate(target);
                    else
                        target.addComponent(parent);
                }
            };
            createPanel.setOutputMarkupId(true);
            parent.add(createPanel);
        }
    }
}

From source file:ontopoly.components.FieldInstanceCreatePlayerPanel.java

License:Apache License

protected void showInstancePage(AjaxRequestTarget target, Topic topic, TopicType topicType, Component c) {
    // open modal window
    final ModalWindow createModal = new ModalWindow("createModal");
    TopicModel<Topic> topicModel = new TopicModel<Topic>(topic);
    TopicTypeModel topicTypeModel = new TopicTypeModel(topicType);
    createModal.setContent(/*from  www .j  a v a2 s  .com*/
            new ModalInstancePage(createModal.getContentId(), topicModel, topicTypeModel, fieldsViewModel) {
                @Override
                protected void onCloseOk(AjaxRequestTarget target) {
                    // close modal and update parent
                    createModal.close(target);
                    FieldInstanceCreatePlayerPanel.this.hideInstancePage(target);
                }
            });
    createModal.setTitle(new ResourceModel("ModalWindow.title.edit.new").getObject().toString()
            + topicType.getName() + "...");
    createModal.setCookieName("createModal");

    createModal.setCloseButtonCallback(new ModalWindow.CloseButtonCallback() {
        public boolean onCloseButtonClicked(AjaxRequestTarget target) {
            // modal already closed, now update parent 
            FieldInstanceCreatePlayerPanel.this.hideInstancePage(target);
            return true;
        }
    });

    replace(createModal);
    createModal.show(target);
    target.addComponent(this);
}

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

License:Open Source License

private ModalWindow generateAboutLink(final String id, final ModalWindow window) {
    window.setInitialWidth(450);/*from   w  w w.  j av a2  s  . c  om*/
    window.setInitialHeight(700);
    window.setTitle("About HatchetHarry");
    window.setContent(new AboutModalWindow(window.getContentId(), window));
    window.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
    window.setMaskType(ModalWindow.MaskType.SEMI_TRANSPARENT);
    this.add(window);

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

        @Override
        public void onClick(final AjaxRequestTarget target) {
            target.prependJavaScript(BattlefieldService.HIDE_MENUS);
            target.appendJavaScript("Wicket.Window.unloadConfirmation = false;");
            window.show(target);
        }
    };

    aboutLink.setOutputMarkupId(true);
    window.setOutputMarkupId(true);
    this.add(aboutLink);
    return window;
}

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

License:Open Source License

private ModalWindow generateMulliganLink(final String id, final ModalWindow window) {
    window.setInitialWidth(500);//from w w  w .j  a v  a 2 s.com
    window.setInitialHeight(150);
    window.setTitle("HatchetHarry - Mulligan");
    window.setContent(new MulliganModalWindow(window, window.getContentId()));
    window.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
    window.setMaskType(ModalWindow.MaskType.SEMI_TRANSPARENT);
    this.add(window);

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

        @Override
        public void onClick(final AjaxRequestTarget target) {
            target.prependJavaScript(BattlefieldService.HIDE_MENUS);
            target.appendJavaScript("Wicket.Window.unloadConfirmation = false;");
            window.show(target);
        }
    };

    mulliganLink.setOutputMarkupId(true);
    window.setOutputMarkupId(true);
    this.add(mulliganLink);
    return window;
}

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

License:Open Source License

private ModalWindow generateTeamInfoLink(final String id, final ModalWindow window) {
    window.setInitialWidth(475);//ww  w.  ja va  2  s.co  m
    window.setInitialHeight(750);
    window.setTitle("HatchetHarry Team info");
    window.setContent(new TeamInfoModalWindow(window.getContentId(), window));
    window.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
    window.setMaskType(ModalWindow.MaskType.SEMI_TRANSPARENT);
    this.add(window);

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

        @Override
        public void onClick(final AjaxRequestTarget target) {
            target.prependJavaScript(BattlefieldService.HIDE_MENUS);
            target.appendJavaScript("Wicket.Window.unloadConfirmation = false;");
            window.show(target);
        }
    };

    teamInfoLink.setOutputMarkupId(true);
    window.setOutputMarkupId(true);
    this.add(teamInfoLink);
    return window;
}

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

License:Open Source License

private ModalWindow generateCreateGameModalWindow(final String id, final Player _player,
        final ModalWindow window) {
    window.setInitialWidth(475);/*from w ww . j a v a 2  s. c o m*/
    window.setInitialHeight(550);
    window.setTitle("Create a match");

    window.setContent(new CreateGameModalWindow(window, window.getContentId(), _player, this));
    window.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
    window.setMaskType(ModalWindow.MaskType.SEMI_TRANSPARENT);

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

        @Override
        public void onClick(final AjaxRequestTarget _target) {
            _target.prependJavaScript(BattlefieldService.HIDE_MENUS);
            _target.appendJavaScript("Wicket.Window.unloadConfirmation = false;");
            window.show(_target);
        }
    };

    this.createGameLink.setOutputMarkupId(true).setMarkupId(id);
    this.createGameWindow.setOutputMarkupId(true);

    this.add(this.createGameLink);

    return window;
}

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

License:Open Source License

private ModalWindow generateJoinGameModalWindow(final String id, final Player _player,
        final ModalWindow window) {
    window.setInitialWidth(475);//from  www .  ja va  2 s. c om
    window.setInitialHeight(430);
    window.setTitle("Join a match");

    window.setContent(
            new JoinGameModalWindow(window, window.getContentId(), _player, this.dataBoxParent, this));
    window.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
    window.setMaskType(ModalWindow.MaskType.SEMI_TRANSPARENT);

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

        @Override
        public void onClick(final AjaxRequestTarget _target) {
            _target.prependJavaScript(BattlefieldService.HIDE_MENUS);
            _target.appendJavaScript("Wicket.Window.unloadConfirmation = false;");
            window.show(_target);
        }
    };

    this.joinGameLink.setOutputMarkupId(true).setMarkupId(id);
    window.setOutputMarkupId(true);

    this.add(this.joinGameLink);

    return window;
}

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

License:Open Source License

private ModalWindow generateJoinGameWithoutIdModalWindow(final String id, final Player _player,
        final ModalWindow window) {
    window.setInitialWidth(475);//from  w  w  w  . ja v a 2s .com
    window.setInitialHeight(500);
    window.setTitle("Join a match without ID");

    window.setContent(
            new JoinGameWithoutIdModalWindow(window, window.getContentId(), _player, this.dataBoxParent, this));
    window.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
    window.setMaskType(ModalWindow.MaskType.SEMI_TRANSPARENT);

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

        @Override
        public void onClick(final AjaxRequestTarget _target) {
            _target.prependJavaScript(BattlefieldService.HIDE_MENUS);
            _target.appendJavaScript("Wicket.Window.unloadConfirmation = false;");
            window.show(_target);
        }
    };

    this.joinGameWithoutIdLink.setOutputMarkupId(true).setMarkupId(id);
    window.setOutputMarkupId(true);

    this.add(this.joinGameWithoutIdLink);

    return window;
}

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 w w.j a v a  2s .  c om
    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 .  ja  v  a  2  s  .c o 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");
}