List of usage examples for org.apache.wicket.ajax.markup.html AjaxLink AjaxLink
public AjaxLink(final String id)
From source file:com.norconex.jefmon.settings.update.SettingsPage.java
License:Apache License
private void initializeComponents() { try {// w w w. j a v a2s.c o m PropertyUtils.copyProperties(dirtyConfig, getJEFMonConfig()); } catch (Exception e) { throw new WicketRuntimeException(e); } AjaxLink<String> nameBack = new AjaxLink<String>("nameBack") { private static final long serialVersionUID = -7790485617549321158L; @Override public void onClick(AjaxRequestTarget target) { setResponsePage(InstancePage.class); } }; nameBack.add(new Label("name", getJEFMonConfig().getInstanceName())); add(nameBack); Form<Void> form = new Form<Void>("form"); form.setOutputMarkupId(true); add(form); final FeedbackPanel feedback = new FeedbackPanel("feedback"); feedback.setOutputMarkupId(true); form.add(feedback); form.add(createConfigPanel("configPanel", dirtyConfig)); final AjaxButton saveButton = new AjaxButton("save") { private static final long serialVersionUID = 8835758195954072646L; @Override protected void onAfterSubmit(AjaxRequestTarget target, Form<?> theform) { try { ConfigurationDAO.saveConfig(dirtyConfig); PropertyUtils.copyProperties(getJEFMonConfig(), dirtyConfig); } catch (IOException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) { throw new WicketRuntimeException("Cannot save configuration.", e); } success(getString("success")); setResponsePage(InstancePage.class); } @Override protected void onError(AjaxRequestTarget target, Form<?> theForm) { target.add(feedback); } }; form.add(saveButton); form.setDefaultButton(saveButton); AjaxLink<String> closeButton = new AjaxLink<String>("close") { private static final long serialVersionUID = 6062171472516887030L; @Override public void onClick(AjaxRequestTarget target) { setResponsePage(InstancePage.class); } }; form.add(closeButton); }
From source file:com.premiumminds.webapp.wicket.bootstrap.BootstrapPaginator.java
License:Open Source License
/** * Creates a paginator/*from www . j av a 2s . c om*/ * * @param id component id * @param totalResults model for total results * @param resultsPerPage number of results per page */ @SuppressWarnings("serial") public BootstrapPaginator(String id, IModel<Integer> totalResults, int resultsPerPage) { super(id, Model.of(0)); stripTags = Application.get().getMarkupSettings().getStripWicketTags(); setOutputMarkupId(true); this.totalResults = totalResults; this.numberResultsPerPage = resultsPerPage; add(new SquaresContainer("first") { @Override protected void onConfigure() { super.onConfigure(); setEnabled(getModelObject() > 0); setVisible(showFirstButton && (!hiddenFirstButton || getThreshold() > 0)); } }.add(new AjaxLink<Void>("link") { @Override public void onClick(AjaxRequestTarget target) { BootstrapPaginator.this.setModelObject(0); target.add(BootstrapPaginator.this); onPageChange(target, BootstrapPaginator.this.getModel()); } })); add(new SquaresContainer("previous") { @Override protected void onConfigure() { super.onConfigure(); setEnabled(BootstrapPaginator.this.getModelObject() > 0); setVisible(showPreviousButton && (!hiddenPreviousButton || BootstrapPaginator.this.getModelObject() > 0)); } }.add(new AjaxLink<Void>("link") { @Override public void onClick(AjaxRequestTarget target) { BootstrapPaginator.this.setModelObject(BootstrapPaginator.this.getModelObject() - 1); target.add(BootstrapPaginator.this); onPageChange(target, BootstrapPaginator.this.getModel()); } })); add(new SquaresContainer("next") { @Override protected void onConfigure() { super.onConfigure(); setEnabled(BootstrapPaginator.this.getModelObject() < getTotalPages() - 1); setVisible(showNextButton && (!hiddenNextButton || BootstrapPaginator.this.getModelObject() < (getTotalPages() - 1))); } }.add(new AjaxLink<Void>("link") { @Override public void onClick(AjaxRequestTarget target) { BootstrapPaginator.this.setModelObject(BootstrapPaginator.this.getModelObject() + 1); target.add(BootstrapPaginator.this); onPageChange(target, BootstrapPaginator.this.getModel()); } })); add(new SquaresContainer("last") { @Override protected void onConfigure() { super.onConfigure(); setEnabled(BootstrapPaginator.this.getModelObject() < getTotalPages() - 1); setVisible( showLastButton && (!hiddenLastButton || getThreshold() < (getTotalPages() - pagesToShow))); } }.add(new AjaxLink<Void>("link") { @Override public void onClick(AjaxRequestTarget target) { BootstrapPaginator.this.setModelObject(getTotalPages() - 1); target.add(BootstrapPaginator.this); onPageChange(target, BootstrapPaginator.this.getModel()); } })); add(new WebMarkupContainer("previousPages") { @Override protected void onConfigure() { super.onConfigure(); setVisible(showMorePagesInformation && getThreshold() > 0); } }); add(new WebMarkupContainer("nextPages") { @Override protected void onConfigure() { super.onConfigure(); setVisible(showMorePagesInformation && getThreshold() < (getTotalPages() - pagesToShow)); } }); IModel<Integer> pages = new LoadableDetachableModel<Integer>() { @Override protected Integer load() { return Math.min(getTotalPages(), pagesToShow); } }; add(new Loop("page", pages) { @Override protected void populateItem(final LoopItem item) { final int threshold = getThreshold(); item.add(AttributeModifier.append("class", new LoadableDetachableModel<String>() { @Override protected String load() { return item.getIndex() + getThreshold() == BootstrapPaginator.this.getModelObject() ? "active" : ""; } })); item.add(new AjaxLink<Void>("link") { @Override protected void onConfigure() { super.onConfigure(); }; @Override public void onClick(AjaxRequestTarget target) { BootstrapPaginator.this.setModelObject(item.getIndex() + threshold); target.add(BootstrapPaginator.this); onPageChange(target, BootstrapPaginator.this.getModel()); } }.add(new Label("label", new LoadableDetachableModel<Integer>() { @Override protected Integer load() { return item.getIndex() + threshold + 1; } }))); } }); }
From source file:com.premiumminds.wicket.crudifier.table.ButtonColumn.java
License:Open Source License
public Component createComponent(String id, final T object, Component resourceBase, Map<Class<?>, IObjectRenderer<?>> renderers) { ButtonPanel panel = new ButtonPanel(id); panel.add(new AjaxLink<Void>("button") { private static final long serialVersionUID = 4260049524761483954L; {/*from ww w . j a v a 2s .c o m*/ add(AttributeModifier.append("class", getCssClass())); } @Override public void onClick(AjaxRequestTarget target) { ButtonColumn.this.onClick(Model.of(object), target); } }.add(new Label("label", resourceBase.getString(propertyName + ".button.label", new Model<String>(), "Button")))); return panel; }
From source file:com.romeikat.datamessie.core.base.ui.panel.DynamicListViewPanel.java
License:Open Source License
private AjaxLink<Void> createRemoveLink(final ListItem<T> listItem) { final AjaxLink<Void> removeLink = new AjaxLink<Void>("removeLink") { private static final long serialVersionUID = 1L; @Override/*ww w .j a v a 2 s . c om*/ public void onClick(final AjaxRequestTarget target) { final int index = listItem.getIndex(); // Get current list final List<T> items = itemModel.getObject(); // Remove rule items.remove(index); // Update rules itemsList.setList(items); // Update model itemModel.setObject(items); // Render view target.add(itemsListContainer); } }; return removeLink; }
From source file:com.romeikat.datamessie.core.base.ui.panel.DynamicListViewPanel.java
License:Open Source License
private AjaxLink<Void> createMoveDownLink(final ListItem<T> listItem) { final AjaxLink<Void> moveDownLink = new AjaxLink<Void>("moveDownLink") { private static final long serialVersionUID = 1L; @Override//ww w .j av a 2 s . c o m public void onClick(final AjaxRequestTarget target) { final int index = listItem.getIndex(); // Get current list final List<T> items = itemModel.getObject(); // Swap rules Collections.swap(items, index, index + 1); // Update rules itemsList.setList(items); // Update model itemModel.setObject(items); // Render view target.add(itemsListContainer); } @Override public void onConfigure() { final List<T> items = itemModel.getObject(); final boolean visible = listItem.getIndex() != items.size() - 1; setVisible(visible); } }; return moveDownLink; }
From source file:com.romeikat.datamessie.core.base.ui.panel.DynamicListViewPanel.java
License:Open Source License
private AjaxLink<Void> createMoveUpLink(final ListItem<T> listItem) { final AjaxLink<Void> moveUpLink = new AjaxLink<Void>("moveUpLink") { private static final long serialVersionUID = 1L; @Override/* ww w . java 2 s . com*/ public void onClick(final AjaxRequestTarget target) { final int index = listItem.getIndex(); // Get current list final List<T> items = itemModel.getObject(); // Swap rules Collections.swap(items, index, index - 1); // Update rules itemsList.setList(items); // Update model itemModel.setObject(items); // Render view target.add(itemsListContainer); } @Override public void onConfigure() { final boolean visible = listItem.getIndex() != 0; setVisible(visible); } }; return moveUpLink; }
From source file:com.romeikat.datamessie.core.base.ui.panel.DynamicListViewPanel.java
License:Open Source License
private AjaxLink<Void> createAddLink() { final AjaxLink<Void> addLink = new AjaxLink<Void>("addLink") { private static final long serialVersionUID = 1L; @Override//from w w w . java 2 s . c o m public void onClick(final AjaxRequestTarget target) { final T item = DynamicListViewPanel.this.newItem(); // Get rules final List<T> items = itemModel.getObject(); // Add new rule items.add(item); // Update rules itemsList.setList(items); // Update model itemModel.setObject(items); // Render view target.add(itemsListContainer); } }; return addLink; }
From source file:com.romeikat.datamessie.core.base.ui.panel.TaskExecutionsPanel.java
License:Open Source License
public TaskExecutionsPanel(final String id) { super(id);/* w w w . j a v a 2s. c om*/ // Model taskExecutionsModel = new LoadableDetachableModel<List<TaskExecutionDto>>() { private static final long serialVersionUID = 1L; @Override protected List<TaskExecutionDto> load() { final List<TaskExecutionDto> taskExecutions = taskExecutionService .getVisibleTaskExecutionsOrderedByLatestActivityDesc(); // Reverse so the latest one is the first one return taskExecutions; } }; // Task executions taskExecutionsList = new ListView<TaskExecutionDto>("taskExecutionsList", taskExecutionsModel) { private static final long serialVersionUID = 1L; @Override protected void populateItem(final ListItem<TaskExecutionDto> item) { final IModel<TaskExecutionDto> taskExecutionModel = item.getModel(); final TaskExecutionDto taskExecution = taskExecutionModel.getObject(); // Link to works final AjaxLink<Void> modalContentWindowLink = new AjaxLink<Void>("modalContentWindowLink") { private static final long serialVersionUID = 1L; @Override public void onClick(final AjaxRequestTarget target) { final ModalContentWindow modalContentWindow = TaskExecutionsPanel.this .allocateModalWindow(); if (modalContentWindow != null) { final TaskExecutionWorksPanel detailsPanel = new TaskExecutionWorksPanel( modalContentWindow, taskExecutionModel); detailsPanel.show(target); } } }; String taskLabelContent = taskExecution.getName(); if (taskExecution.getStatus() != null) { taskLabelContent += " (" + taskExecution.getStatus().getName().toLowerCase() + ")"; } final Label taskLabel = new Label("taskLabel", taskLabelContent); modalContentWindowLink.add(taskLabel); item.add(modalContentWindowLink); } }; taskExecutionsList.setOutputMarkupId(true); add(taskExecutionsList); }
From source file:com.romeikat.datamessie.core.base.ui.panel.TaskExecutionWorksPanel.java
License:Open Source License
public TaskExecutionWorksPanel(final ModalContentWindow modalContentWindow, final IModel<TaskExecutionDto> taskExecutionModel) { super(modalContentWindow, null); this.taskExecutionModel = taskExecutionModel; setTitle("Task Details"); // Model/* www .j a v a 2 s . c o m*/ taskExecutionWorksModel = new LoadableDetachableModel<List<TaskExecutionWorkDto>>() { private static final long serialVersionUID = 1L; @Override protected List<TaskExecutionWorkDto> load() { final TaskExecutionDto taskExecution = taskExecutionModel.getObject(); if (taskExecution == null) { return Collections.emptyList(); } final List<TaskExecutionWorkDto> taskExecutionWorks = taskExecution.getWorks(); final int taskExecutionWorksSize = taskExecutionWorks.size(); if (taskExecutionWorksSize <= MAX_TASK_EXECUTION_WORKS) { return taskExecutionWorks; } return taskExecutionWorks.subList(taskExecutionWorksSize - MAX_TASK_EXECUTION_WORKS, taskExecutionWorksSize); } }; // Task execution works taskExecutionsWorkList = new ListView<TaskExecutionWorkDto>("worksList", taskExecutionWorksModel) { private static final long serialVersionUID = 1L; @Override protected void populateItem(final ListItem<TaskExecutionWorkDto> item) { final IModel<TaskExecutionWorkDto> taskExecutionWorkModel = item.getModel(); final TaskExecutionWorkDto taskExecutionWork = taskExecutionWorkModel.getObject(); final StringBuilder workLabelContent = new StringBuilder(); final boolean empty = taskExecutionWork.getMessage() == null; if (!empty) { // Start if (taskExecutionWork.getStart() != null) { workLabelContent.append( DateConverter.INSTANCE_UI.convertToString(new Date(taskExecutionWork.getStart()))); workLabelContent.append(": "); } // Message if (taskExecutionWork.getMessage() != null) { workLabelContent.append(taskExecutionWork.getMessage()); } // Duration if (taskExecutionWork.getDuration() != null) { final long seconds = Math.round(taskExecutionWork.getDuration() / 1000d); workLabelContent.append(" ("); workLabelContent.append(seconds); workLabelContent.append(" s)"); } } final Label workLabel = new Label("workLabel", workLabelContent.toString()); item.add(workLabel); } }; taskExecutionsWorkList.setOutputMarkupId(true); add(taskExecutionsWorkList); updateLink = new AjaxLink<Void>("updateLink") { private static final long serialVersionUID = 1L; @Override public void onConfigure() { super.onConfigure(); final TaskExecutionDto taskExecution = TaskExecutionWorksPanel.this.taskExecutionModel.getObject(); final boolean visible = taskExecution.getStatus() != TaskExecutionStatus.COMPLETED && taskExecution.getStatus() != TaskExecutionStatus.CANCELLED && taskExecution.getStatus() != TaskExecutionStatus.FAILED; setVisible(visible); } @Override public void onClick(final AjaxRequestTarget target) { target.add(TaskExecutionWorksPanel.this); target.add(((AbstractAuthenticatedPage) getPage()).getTaskExecutionsPanel()); } }; add(updateLink); final String confirmation = "Would you really like to cancel the execution of this task?"; cancelLink = new AjaxConfirmationLink<Void>("cancelLink", confirmation) { private static final long serialVersionUID = 1L; @Override public void onConfigure() { super.onConfigure(); final TaskExecutionDto taskExecution = TaskExecutionWorksPanel.this.taskExecutionModel.getObject(); final boolean visible = taskExecution.getStatus() != TaskExecutionStatus.COMPLETED && taskExecution.getStatus() != TaskExecutionStatus.CANCEL_REQUESTED && taskExecution.getStatus() != TaskExecutionStatus.CANCELLED && taskExecution.getStatus() != TaskExecutionStatus.FAILED; setVisible(visible); } @Override public void onClick(final AjaxRequestTarget target) { final TaskExecutionDto taskExecution = TaskExecutionWorksPanel.this.taskExecutionModel.getObject(); taskManager.cancelTask(taskExecution.getId()); target.add(TaskExecutionWorksPanel.this); target.add(((AbstractAuthenticatedPage) getPage()).getTaskExecutionsPanel()); modalContentWindow.close(target); } }; add(cancelLink); }
From source file:com.senacor.wbs.web.border.ToggleBorder.java
License:Apache License
public ToggleBorder(String id, IModel titleModel) { super(id, titleModel); add(CSSPackageResource.getHeaderContribution(this.getClass(), "ToggleBorder.css")); setOutputMarkupId(true);//w ww .j a v a 2 s .c om PackageResource rollUp = PackageResource.get(ToggleBorder.this.getClass(), "up.png"); Image rollUpImage = new Image("rollUpImage", rollUp) { @Override public boolean isVisible() { return isExpanded; } }; PackageResource rollDown = PackageResource.get(ToggleBorder.this.getClass(), "down.png"); Image rollDownImage = new Image("rollDownImage", rollDown) { @Override public boolean isVisible() { return !isExpanded; } }; AbstractLink headerLink = new AjaxLink("header") { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { isExpanded = !isExpanded; target.addComponent(ToggleBorder.this); } }; headerLink.add(new Label("title", titleModel)); headerLink.add(rollUpImage); headerLink.add(rollDownImage); add(headerLink); final WebMarkupContainer content = new WebMarkupContainer("content"); content.add(getBodyContainer()); content.add(new AttributeAppender("style", true, new AbstractReadOnlyModel() { @Override public String getObject() { return (isExpanded ? "display:block" : "display:none"); } }, ";")); add(content); }