Example usage for org.apache.wicket.markup.html.link Link setVisibilityAllowed

List of usage examples for org.apache.wicket.markup.html.link Link setVisibilityAllowed

Introduction

In this page you can find the example usage for org.apache.wicket.markup.html.link Link setVisibilityAllowed.

Prototype

public final Component setVisibilityAllowed(boolean allowed) 

Source Link

Document

Sets whether or not this component is allowed to be visible.

Usage

From source file:cz.zcu.kiv.eegdatabase.wui.components.page.MenuPage.java

License:Apache License

public MenuPage() {

    feedback = new BaseFeedbackMessagePanel("base_feedback");
    add(feedback);//from   w  ww. j  a va  2  s. c  o  m

    boolean signedIn = EEGDataBaseSession.get().isSignedIn();

    String labelMessage;
    Class<?> pageClass;
    String labelLink;

    if (signedIn) {
        labelMessage = ResourceUtils.getString("general.header.logged");
        labelMessage += EEGDataBaseSession.get().getLoggedUser().getUsername();
        labelLink = ResourceUtils.getString("general.page.myaccount.link");
        pageClass = AccountOverViewPage.class;
    } else {
        labelMessage = ResourceUtils.getString("general.header.notlogged");
        labelLink = ResourceUtils.getString("action.register");
        pageClass = RegistrationPage.class;
    }

    BookmarkablePageLink headerLink = new BookmarkablePageLink("userHeaderLink", pageClass);
    headerLink.add(new Label("linkLabel", labelLink));
    add(headerLink);

    BookmarkablePageLink cart = new BookmarkablePageLink("cart", ShoppingCartPage.class);
    String cartLabel = ResourceUtils.getString("general.page.myCart.link") + " ";
    if (signedIn) {
        //
        cart.add(new Label("cartSizeLabel", new Model() {
            @Override
            public Serializable getObject() {
                String cartSize = "" + EEGDataBaseSession.get().getShoppingCart().size();
                return cartSize;
            }
        }));

    }
    cart.add(new Label("cartLabel", cartLabel));
    cart.setVisibilityAllowed(signedIn);
    add(cart);

    Link<Void> link = new Link<Void>("logout") {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick() {
            EEGDataBaseSession.get().invalidate();
            setResponsePage(EEGDataBaseApplication.get().getHomePage());
        }
    };
    link.setVisibilityAllowed(signedIn);
    add(link);

    StringValue searchString = EEGDataBaseSession.get().getSearchString();
    MenuSearchPanel panel = new MenuSearchPanel("menuSearchPanel", searchString);
    add(panel);
    if (!signedIn) {
        panel.setVisible(false);
    }

    add(new Label("userLogStatusLabel", labelMessage));

    add(new MainMenu("mainMenu"));

    add(new ExternalLink("footerLink", ResourceUtils.getString("general.footer.link"),
            ResourceUtils.getString("general.footer.link.title")));

    int year = Calendar.getInstance().get(Calendar.YEAR);

    add(new Label("year", ResourceUtils.getString("general.footer.year") + year));
}

From source file:cz.zcu.kiv.eegdatabase.wui.ui.security.ConfirmPage.java

License:Apache License

private void setupConfirmation(PageParameters parameters) {

    boolean confirm = false;
    IModel<String> titleText;
    IModel<String> messageText;
    IModel<String> message2Text;

    if (!parameters.get(EMAIL).isNull()) {
        titleText = ResourceUtils.getModel("pageTitle.registrationSuccessfull");
        messageText = new Model<String>(ResourceUtils.getString("text.registrationSuccessfull.youNeedConfirm")
                + parameters.get(EMAIL).toString());
        message2Text = messageText;

    } else {/*from   w  ww.j  a  va 2 s  . co  m*/

        if (parameters.get(CONFIRM_ACTIVATION).isNull() || parameters.get(CONFIRM_ACTIVATION).isEmpty()) {
            throw new RestartResponseAtInterceptPageException(HomePage.class);
        }

        String activationHashCode = parameters.get(CONFIRM_ACTIVATION).toString();

        Person person = personFacade.getPersonByHash(activationHashCode);
        if (person == null) {
            titleText = ResourceUtils.getModel("pageTitle.registrationFalse");
            messageText = ResourceUtils.getModel("text.registrationExpired");
            message2Text = messageText;
        } else if (person.isConfirmed()) {
            titleText = ResourceUtils.getModel("pageTitle.confirmationRepeated");
            messageText = ResourceUtils.getModel("text.registrationConfirmedOnce");
            message2Text = messageText;
        } else if (confirmedInTime(System.currentTimeMillis(), person)) {
            confirm = true;
            person.setConfirmed(true);
            personFacade.update(person);
            titleText = ResourceUtils.getModel("pageTitle.confirmationSuccessfull");
            messageText = ResourceUtils.getModel("text.registrationSuccessfull.youCanLogIn.part1");
            message2Text = ResourceUtils.getModel("text.registrationSuccessfull.youCanLogIn.part2");
        } else {
            personFacade.delete(person);
            titleText = ResourceUtils.getModel("pageTitle.registrationFalse");
            messageText = ResourceUtils.getModel("text.registrationExpired");
            message2Text = messageText;
        }
    }

    Label title = new Label(TITLE_ID, titleText);
    Label message = new Label(MESSAGE_ID, messageText);
    Label message2 = new Label(MESSAGE_2_ID, message2Text);
    Link<Void> link = new Link<Void>("link") {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick() {
            setResponsePage(HomePage.class);
        }
    };
    add(title, message, message2, link);
    link.setVisibilityAllowed(confirm);
    message2.setVisibilityAllowed(confirm);

}

From source file:org.apache.jetspeed.portlets.rpad.RemotePortletAppDeployer.java

License:Apache License

@SuppressWarnings("unchecked")
public RemotePortletAppDeployer() {
    deployer = new JetspeedPortletDeployer();
    Form form = new Form("form");
    repositories = getRepositoryManager().getRepositories();
    form.add(new DropDownChoice("repositorySelection", new PropertyModel(this, "selectedRepository"),
            repositories, new ChoiceRenderer("name", "name")));

    Button selectButton = new Button("selectButton") {

        private static final long serialVersionUID = 1L;

        public void onSubmit() {

        }//from   ww  w  . jav  a2  s  .  c o  m
    };

    form.add(selectButton);
    add(form);

    IModel getRepo = new LoadableDetachableModel() {

        protected Object load() {
            return getRepo();
        }
    };

    final PageableListView listview = new PageableListView("repositories", getRepo, 10) {

        private static final long serialVersionUID = 1L;

        // This method is called for each 'entry' in the list.
        @Override
        protected void populateItem(final ListItem item) {
            final PortletApplication application = (PortletApplication) item.getModelObject();
            item.add(new Label("groupId", application.getGroupId()));
            item.add(new Label("artifactId", application.getArtifactId()));
            item.add(new Label("name", application.getName()));
            item.add(new Label("version", application.getVersion()));
            item.add(new Label("type", application.getPackaging()));
            Link actionLink = new Link("action", item.getModel()) {

                public void onClick() {
                    PortletApplication portletApplication = (PortletApplication) getModelObject();
                    deployer.deploy(portletApplication, getServiceLocator().getDeploymentManager());
                }
            };
            actionLink.setVisibilityAllowed(true);
            actionLink.setOutputMarkupId(true);
            if (deployer.getStatus() == PortletDeployer.DEPLOYING) {
                actionLink.setVisible(false);
            }
            item.add(actionLink);
        }
    };
    listview.setOutputMarkupId(true);
    final WebMarkupContainer tableGroup = new WebMarkupContainer("tableGroup");
    tableGroup.setOutputMarkupId(true);
    //tableGroup.add(new AjaxSelfUpdatingTimerBehavior(Duration.seconds(5)));
    tableGroup.add(new PagingNavigator("navigator", listview));
    tableGroup.add(listview);
    final MultiLineLabel statusLabel = new MultiLineLabel("status", new PropertyModel(this, "message"));
    statusLabel.setOutputMarkupId(true);
    final Label tickerLabel = new Label("ticker", new PropertyModel(this, "ticker"));
    tickerLabel.setOutputMarkupId(true);
    add(new AbstractAjaxTimerBehavior(Duration.seconds(3)) {
        protected void onTimer(AjaxRequestTarget target) {
            setMessage(deployer.getMessage());
            target.addComponent(tickerLabel);
            target.addComponent(statusLabel);
            target.addComponent(tableGroup);
        }
    });
    add(statusLabel);
    add(tickerLabel);
    add(tableGroup);

}