Example usage for org.apache.wicket.ajax.markup.html AjaxLink add

List of usage examples for org.apache.wicket.ajax.markup.html AjaxLink add

Introduction

In this page you can find the example usage for org.apache.wicket.ajax.markup.html AjaxLink add.

Prototype

public MarkupContainer add(final Component... children) 

Source Link

Document

Adds the child component(s) to this container.

Usage

From source file:main.java.info.jtrac.wicket.ItemRelatePanel.java

License:Apache License

public ItemRelatePanel(String id, boolean isItemViewPage) {
    super(id);//  www .  jav  a2 s  .  co  m
    ItemSearch itemSearch = getCurrentItemSearch();
    refId = itemSearch == null ? null : itemSearch.getRelatingItemRefId();
    if (refId != null) {
        final YuiDialog dialog = new YuiDialog("itemWindow");
        add(dialog);
        AjaxLink link = new AjaxLink("link") {
            public void onClick(AjaxRequestTarget target) {
                Item item = getJtrac().loadItemByRefId(refId);
                dialog.show(target, refId, new ItemViewPanel(YuiDialog.CONTENT_ID, item, true));
            }
        };
        link.add(new Label("refId", refId));
        if (isItemViewPage) {
            add(new WebMarkupContainer("link").setVisible(false));
            add(new WebMarkupContainer("message").setVisible(false));
            add(new RelateForm("form").add(link));
        } else {
            add(new Label("message", localize("item_list.searchingForRelated")));
            add(link);
            add(new WebMarkupContainer("form").setVisible(false));
        }
        add(new Link("cancel") {
            public void onClick() {
                Item item = getJtrac().loadItemByRefId(refId);
                setCurrentItemSearch(null);
                setResponsePage(ItemViewPage.class, new PageParameters("0=" + item.getRefId()));
            }
        });
    } else {
        setVisible(false);
    }
}

From source file:main.java.info.jtrac.wicket.ItemRelateRemovePage.java

License:Apache License

public ItemRelateRemovePage(long itemId, final ItemItem itemItem) {
    this.itemId = itemId;
    this.itemItem = itemItem;
    add(new ConfirmForm("form"));
    final String relatingRefId = itemItem.getItem().getRefId();
    final String relatedRefId = itemItem.getRelatedItem().getRefId();
    final YuiDialog relatingDialog = new YuiDialog("relatingDialog");
    final YuiDialog relatedDialog = new YuiDialog("relatedDialog");
    add(relatingDialog);//from w  w w. j  av  a2s .co m
    add(relatedDialog);
    AjaxLink relating = new AjaxLink("relating") {
        public void onClick(AjaxRequestTarget target) {
            Item relating = getJtrac().loadItem(itemItem.getItem().getId());
            relatingDialog.show(target, relatingRefId, new ItemViewPanel(YuiDialog.CONTENT_ID, relating, true));
        }
    };
    relating.add(new Label("refId", relatingRefId));
    add(relating);

    // TODO refactor, duplicate code in ItemViewPanel
    String message = null;
    if (itemItem.getType() == DUPLICATE_OF) {
        message = localize("item_view.duplicateOf");
    } else if (itemItem.getType() == DEPENDS_ON) {
        message = localize("item_view.dependsOn");
    } else if (itemItem.getType() == RELATED) {
        message = localize("item_view.relatedTo");
    }
    add(new Label("message", message));

    AjaxLink related = new AjaxLink("related") {
        public void onClick(AjaxRequestTarget target) {
            Item related = getJtrac().loadItem(itemItem.getRelatedItem().getId());
            relatedDialog.show(target, relatedRefId, new ItemViewPanel(YuiDialog.CONTENT_ID, related, true));
        }
    };
    related.add(new Label("refId", itemItem.getRelatedItem().getRefId()));
    add(related);

}

From source file:net.dontdrinkandroot.wicket.bootstrap.component.button.ButtonGroupChoice.java

License:Apache License

public ButtonGroupChoice(String id, IModel<T> model, IModel<List<T>> choicesModel) {

    super(id, model);

    this.setOutputMarkupId(true);
    this.add(new CssClassAppender(BootstrapCssClass.BTN_GROUP));

    final RepeatingView choicesView = new RepeatingView("choice");
    choicesView.setOutputMarkupId(true);
    this.add(choicesView);

    for (final T choice : choicesModel.getObject()) {

        AjaxLink<Void> choiceLink = new AjaxLink<Void>(choicesView.newChildId()) {

            @Override/*from  www.  j a v  a 2  s .c  o m*/
            public void onClick(AjaxRequestTarget target) {

                ButtonGroupChoice.this.onSelectionChanged(choice, target);
            }
        };
        choiceLink.setBody(this.getDisplayModel(choice));
        choiceLink.add(new CssClassAppender(new Model<BootstrapCssClass>() {

            @Override
            public BootstrapCssClass getObject() {

                if (ButtonGroupChoice.this.getModelObject().equals(choice)) {
                    super.getObject();
                }

                return null;
            }
        }));

        choicesView.add(choiceLink);
    }
}

From source file:net.form105.web.base.component.command.CommandPanel.java

License:Apache License

@SuppressWarnings("unchecked")
private ListView createListView() {
    ListView lView = new ListView("commandLabels", linkList) {
        private static final long serialVersionUID = 1L;

        @Override//w ww .  j  ava  2  s . c  om
        protected void populateItem(ListItem item) {
            IPageAction action = (IPageAction) item.getModelObject();
            SubmitLink submitLink;
            if (action instanceof AbstractFormAction) {
                AbstractFormAction<T> formAction = (AbstractFormAction<T>) action;
                submitLink = new SubmitLink("commandLink", formAction.getForm()) {

                    private static final long serialVersionUID = 1L;

                    public void onSubmit() {
                        setResponsePage(this.getPage());
                    }
                };

                Label label = new Label("commandLabel", formAction.getName());
                submitLink.add(label);
                item.add(submitLink);

            } else if (action instanceof IAjaxLinkToPanelAction) {
                IAjaxLinkToPanelAction ajaxLinkAction = (IAjaxLinkToPanelAction) action;
                AjaxLink ajaxLink = new AjaxLink("commandLink") {

                    private static final long serialVersionUID = 1L;

                    @Override
                    public void onClick(AjaxRequestTarget target) {
                        Page page = getPage();
                        ((BasePage) page).ajaxRequestReceived(target, null, EventType.ADD_EVENT);

                    }

                };
                Label label = new Label("commandLabel", ajaxLinkAction.getName());
                ajaxLink.add(label);
                item.add(ajaxLink);

            } else if (action instanceof IAjaxLinkToModalWindowAction) {
                IAjaxLinkToModalWindowAction ajaxModalAction = (IAjaxLinkToModalWindowAction) action;
                AjaxLink ajaxLink = new AjaxLink("commandLink") {

                    private static final long serialVersionUID = 1L;

                    @Override
                    public void onClick(AjaxRequestTarget target) {
                        Page page = getPage();
                        ((BasePage) page).ajaxRequestReceived(target, null, EventType.ADD_MODAL);
                    }
                };
                Label label = new Label("commandLabel", ajaxModalAction.getName());
                ajaxLink.add(label);
                item.add(ajaxLink);
            }
        }
    };
    return lView;
}

From source file:net.rrm.ehour.ui.common.panel.entryselector.EntrySelectorPanel.java

License:Open Source License

private void addHideInactiveFilter(Form<Void> form) {
    final HideInactiveFilter hideInactiveFilter = new HideInactiveFilter();
    hideInactiveFilter.setHideInactive(getEhourWebSession().getHideInactiveSelections());

    final WebMarkupContainer filterIcon = new WebMarkupContainer("filterIcon");
    addFilterIconAttributes(filterIcon, getEhourWebSession().getHideInactiveSelections());
    filterIcon.setOutputMarkupId(true);//from www  .ja va 2s.c  o m

    final AjaxLink<Void> hideInactiveLink = new AjaxLink<Void>("filterToggle") {
        @Override
        public void onClick(AjaxRequestTarget target) {
            Boolean hideInactiveSelections = getEhourWebSession().toggleHideInactiveSelections();
            HideInactiveFilter inactiveFilter = new HideInactiveFilter(hideInactiveSelections);
            send(getPage(), Broadcast.DEPTH, new InactiveFilterChangedEvent(inactiveFilter, target));

            target.appendJavaScript(jsRefresh());

            filterIcon.removeAll();
            addFilterIconAttributes(filterIcon, getEhourWebSession().getHideInactiveSelections());
            target.add(filterIcon);
        }

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

            attributes.getAjaxCallListeners().add(new LoadingSpinnerDecorator());
        }
    };

    hideInactiveLink.setVisible(showHideInactiveLink);
    hideInactiveLink.add(filterIcon);
    form.add(hideInactiveLink);
}

From source file:net.rrm.ehour.ui.manage.assignment.AssignmentListPanel.java

License:Open Source License

private ListView<ProjectAssignment> getProjectAssignmentLists(
        final List<ProjectAssignment> projectAssignments) {
    assignmentListView = new ListView<ProjectAssignment>("assignments", projectAssignments) {
        @Override// w w  w .j av a 2 s  .  co  m
        protected void populateItem(ListItem<ProjectAssignment> item) {
            final ProjectAssignment assignment = item.getModelObject();

            AjaxLink<Void> link = new AjaxLink<Void>("itemLink") {
                @Override
                public void onClick(AjaxRequestTarget target) {
                    EventPublisher.publishAjaxEvent(AssignmentListPanel.this,
                            new PayloadAjaxEvent<>(AssignmentAjaxEventType.ASSIGNMENT_EDIT, assignment));
                }
            };

            AjaxLink<Void> imgLink = new AjaxLink<Void>("imgLink") {
                @Override
                public void onClick(AjaxRequestTarget target) {
                    EventPublisher.publishAjaxEvent(AssignmentListPanel.this,
                            new PayloadAjaxEvent<>(AssignmentAjaxEventType.ASSIGNMENT_EDIT, assignment));
                }
            };

            item.add(imgLink);
            item.add(link);
            link.add(new Label("project", assignment.getProject().getFullName()));
            item.add(new Label("customer", assignment.getProject().getCustomer().getFullName()));

            Label dateStart = new Label("dateStart",
                    new DateModel(assignment.getDateStart(), config, DateModel.DATESTYLE_FULL_SHORT));
            dateStart.setEscapeModelStrings(false);
            item.add(dateStart);

            Label dateEnd = new Label("dateEnd",
                    new DateModel(assignment.getDateEnd(), config, DateModel.DATESTYLE_FULL_SHORT));
            dateEnd.setEscapeModelStrings(false);
            item.add(dateEnd);

            item.add(new Label("assignmentType", new ResourceModel(
                    WebUtils.getResourceKeyForProjectAssignmentType(assignment.getAssignmentType()))));

            item.add(new Label("role",
                    (StringUtils.isBlank(assignment.getRole())) ? "--" : assignment.getRole()));

            item.add(new Label("currency",
                    Currency.getInstance(config.getCurrency()).getSymbol(config.getCurrency())));
            item.add(new Label("rate", new Model<>(assignment.getHourlyRate())));

        }
    };

    return assignmentListView;
}

From source file:net.rrm.ehour.ui.timesheet.panel.ProjectOverviewPanel.java

License:Open Source License

/**
 * Create fold link (also contains the creation of the summary row)
 *//*from  ww w  .  j  ava2  s.co  m*/
@SuppressWarnings("serial")
private Component createFoldLink(final Component original) {
    AjaxLink<String> foldLink = new AjaxLink<String>(ID_FOLD_LINK) {
        @Override
        public void onClick(AjaxRequestTarget target) {
            boolean isVisible = original.isVisible();

            original.setVisible(!isVisible);
            target.add(original);

            WebMarkupContainer img = createFoldImage(!isVisible);
            this.get(ID_FOLD_IMG).replaceWith(img);
            target.add(img);
        }
    };

    final WebMarkupContainer originalImage = createFoldImage(false);
    foldLink.add(originalImage);
    return foldLink;
}

From source file:net.tirasa.jpasqlazure.web.pages.panel.ActionLinkPanel.java

License:Apache License

public ActionLinkPanel(String id, IModel<?> model, AjaxLink link, String label) {
    super(id, model);
    link.add(new Label("label", label));
    add(link);//from  w ww  . j av  a2 s  .  c  o  m
}

From source file:nl.knaw.dans.dccd.web.datapanels.ObjectTypeSelectionPanel.java

License:Apache License

public ObjectTypeSelectionPanel(String id, IModel<?> model) {
    super(id, model);

    EntityAttribute attr = (EntityAttribute) this.getDefaultModelObject();
    // assume object is a ControlledVoc
    final ControlledVoc cvoc = (ControlledVoc) attr.getEntryObject();

    // TESTING/*from  w  ww. j  av  a  2 s  .c o  m*/
    //String labelStr = "";
    //if (cvoc != null && cvoc.isSetValue())
    //   labelStr = cvoc.getValue();
    //Label label = new Label("label", "Initial term: " + labelStr);
    //add(label);

    // Build multilingual selectable table
    // first just a table... ListView
    MultiLingualTridasTerms terms = DccdVocabularyService.getService()
            .getMultiLingualTridasTerms("object.type");

    final int descriptionIndex = terms.getDescriptionIndex();

    final int MAX_LANG = 4; // Note: fixed in html

    // iterate the lines
    List<List<String>> termLines = terms.getTermLines();
    ListView<List<String>> termlist = new ListView<List<String>>("termlist", termLines) {
        private static final long serialVersionUID = -3651087863165431582L;

        protected void populateItem(ListItem item) {
            List<String> line = (List<String>) item.getModel().getObject();

            // fixed to columns max.
            for (int i = 0; i < MAX_LANG; i++) {
                if (line.size() < (i + 1)) {
                    item.add(new Label("term_" + i, ""));//empty
                } else {
                    // TODO make selectable...
                    //item.add(new Label("term_"+i, line.get(i)));
                    final String termStr = line.get(i);
                    // Note: could use AjaxFallbackLink, but without Ajax DCCD is almost unusable...
                    AjaxLink link = new AjaxLink("linkterm_" + i) {
                        private static final long serialVersionUID = -1L;

                        @Override
                        public void onClick(AjaxRequestTarget target) {
                            selectedTerm = termStr;

                            logger.debug("selected term: " + selectedTerm);

                            // update
                            cvoc.setValue(selectedTerm);
                            onSelectionChanged(target);
                        }
                    };
                    item.add(link);
                    link.add(new Label("term_" + i, termStr));
                }
            }

            // description
            if (descriptionIndex >= MAX_LANG) {
                item.add(new Label("term_description", line.get(descriptionIndex)));
            } else {
                item.add(new Label("term_description", ""));// empty
            }
        }
    };
    add(termlist);
    termlist.setReuseItems(true); // speedup, the list is not changing during a session!

    // Add headers for the columns
    for (int i = 0; i < MAX_LANG; i++) {
        String languageCode = terms.getLanguageCode(i);

        if (languageCode.isEmpty())
            add(new Label("title_" + i, ""));//empty
        else
            add(new Label("title_" + i, languageCode.toUpperCase())); // TODO get display string for this code
    }

    // TODO could make this into a sortable pagable GridView....

}

From source file:nl.mpi.lamus.web.components.UnlinkedNodesPanel.java

License:Open Source License

private List<IColumn<WorkspaceTreeNode, String>> createColumns() {

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

    columns.add(new TreeColumn<WorkspaceTreeNode, String>(
            Model.of(getLocalizer().getString("unlinked_nodes_table_column_node", this))));

    columns.add(new PropertyColumn<WorkspaceTreeNode, String>(
            Model.of(getLocalizer().getString("unlinked_nodes_table_column_type", this)), "type"));

    columns.add(new PropertyColumn<WorkspaceTreeNode, String>(
            Model.of(getLocalizer().getString("unlinked_nodes_table_column_status", this)), "statusAsString"));

    columns.add(new AbstractColumn<WorkspaceTreeNode, String>(Model.of("")) {

        @Override//  www.jav  a  2  s. co  m
        public void populateItem(Item<ICellPopulator<WorkspaceTreeNode>> cellItem, String componentId,
                IModel<WorkspaceTreeNode> model) {

            if (model.getObject().getParent() != null) {
                cellItem.add(new Label(componentId).setVisible(false));
                return;
            }

            AjaxLink<WorkspaceTreeNode> deleteLink = new AutoDisablingAjaxLink<WorkspaceTreeNode>(componentId,
                    model) {

                @Override
                public void onClick(AjaxRequestTarget target) {

                    try {
                        workspaceService.deleteNode(LamusSession.get().getUserId(), getModelObject());

                        target.add(UnlinkedNodesPanel.this);

                    } catch (WorkspaceException | ProtectedNodeException ex) {
                        error(ex.getMessage());
                    }
                }

            };
            deleteLink.setBody(Model.of(getLocalizer().getString("unlinked_nodes_table_column_remove_button",
                    UnlinkedNodesPanel.this)));
            deleteLink.add(AttributeModifier.append("class", new Model<>("tableActionLink")));
            cellItem.add(deleteLink);
        }
    });

    return columns;
}