List of usage examples for org.apache.wicket.ajax.markup.html AjaxLink add
public MarkupContainer add(final Component... children)
From source file:org.ujorm.wicket.component.link.MessageLink.java
License:Apache License
@Override protected void onInitialize() { super.onInitialize(); final AjaxLink link = new AjaxLink("link") { @Override/* ww w .j av a2 s.c om*/ public void onClick(AjaxRequestTarget target) { MessageLink.this.onClick(target); } }; add(link); link.add(new Label("message", getDefaultModel())); }
From source file:org.wicketstuff.console.templates.TitleColumn.java
License:Apache License
@Override public void populateItem(final Item<ICellPopulator<ScriptTemplate>> item, final String componentId, final IModel<ScriptTemplate> rowModel) { final AjaxLink<ScriptTemplate> link = new TitleLink("link", rowModel); link.add(new Label("label", createLabelModel(rowModel))); link.add(new AttributeAppender("title", new PropertyModel<String>(rowModel, "title"))); final Fragment fragment = new Fragment(componentId, "titleFragment", tablePanel); fragment.add(link);//from w ww .j a va 2 s . com item.add(fragment); }
From source file:org.wicketstuff.jmx.markup.html.table.OperationInvocationResultPanel.java
License:Apache License
public OperationInvocationResultPanel(String id, final MBeanOperationInfo operation, Object result, final JmxMBeanWrapper mbean, final OperationInvocationPanel invokePanel) { super(id);//from w w w .j a va2 s . c o m this.setOutputMarkupId(true); IModel messageModel = null; // if the result is an exception, something went wrong -> provide error // message if (result instanceof Exception) { messageModel = new StringResourceModel("jmx.invocation.exception", this, null, new Object[] { result }); } else { // check if the return type is void -> result is of no interest if (operation.getReturnType().equals("void")) { messageModel = new StringResourceModel("jmx.invocation.success", this, null); } else { messageModel = new StringResourceModel("jmx.invocation.success.with.result", this, null, new Object[] { result }); } } add(new Label("message", messageModel)); AjaxLink backLink = new AjaxLink("backLink") { private static final long serialVersionUID = 1L; public void onClick(AjaxRequestTarget target) { OperationInvocationResultPanel.this.replaceWith(invokePanel); target.addComponent(invokePanel); } }; add(backLink); backLink.add(new Label("linkLabel", new StringResourceModel("jmx.backLink.label", backLink, null))); }
From source file:org.wicketstuff.mbeanview.AttributeValuesPanel.java
License:Apache License
public AttributeValuesPanel(String id, final IModel<MBeanServer> server, final ObjectName objectName, MBeanAttributeInfo[] beanAttributeInfos) { super(id, server); add(modalOutput = new ModalWindow("modalOutput")); modalOutput.setCookieName("modalOutput"); Form<Void> form = new Form<Void>("form"); add(form);/*from www . j av a2 s . c o m*/ ListView<MBeanAttributeInfo> attributes = new ListView<MBeanAttributeInfo>("attributes", Arrays.asList(beanAttributeInfos)) { private static final long serialVersionUID = 1L; @Override protected void populateItem(final ListItem<MBeanAttributeInfo> item) { final MBeanAttributeInfo info = item.getModelObject(); item.add(new Label("name", info.getName())); final AttributeModel model = new AttributeModel(server, objectName, info) { @Override protected void onError(Throwable throwable) { item.error(throwable.toString()); } }; AjaxLink<Void> link = new AjaxLink<Void>("value") { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { modalOutput.setContent(new DataViewPanel(modalOutput.getContentId(), model)); modalOutput.setTitle(info.getName()); modalOutput.show(target); } @Override public boolean isEnabled() { return model.getObject() instanceof Collection || model.getObject() != null && model.getObject().getClass().isArray(); } @Override public boolean isVisible() { return !info.isWritable(); } }; item.add(link); link.add(new Label("label", model)); item.add(new TextField<Object>("editableValue", model, Object.class) { private static final long serialVersionUID = 1L; @Override public boolean isVisible() { return info.isWritable(); } @Override public <C> IConverter<C> getConverter(Class<C> type) { return new ValueConverter(item.getModelObject().getType()); } }); item.add(new FencedFeedbackPanel("feedback", item)); } }; attributes.setReuseItems(true); form.add(attributes); form.add(new Button("submit")); }
From source file:ro.nextreports.server.web.core.LocationPanel.java
License:Apache License
public LocationPanel(String id, final String sectionId) { super(id);//from w w w . j a va2 s . co m this.sectionId = sectionId; add(new ListView<String>("location", new LocationModel()) { private static final long serialVersionUID = 1L; @Override protected void populateItem(ListItem<String> item) { final String path = item.getModelObject(); AjaxLink<String> link = new AjaxLink<String>("link", new Model<String>(path)) { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { Entity entity; try { entity = storageService.getEntity(path); } catch (NotFoundException e) { entity = getRoot(); } onEntityClicked(entity, target); } }; link.add(new Label("text", StorageUtil.getName(path))); item.add(link); if (SectionContextUtil.getCurrentPath(sectionId).equals(path)) { // is last item.add(AttributeAppender.append("class", "bread-current")); } } }); add(new Label("lookFor", new LookForModel())); }
From source file:ro.nextreports.server.web.core.migration.ExportPanel.java
License:Apache License
@SuppressWarnings("unchecked") public ExportPanel(String id) { super(id);/* ww w. ja v a 2 s .c o m*/ final FeedbackPanel feedbackPanel = new FeedbackPanel("feedback"); feedbackPanel.setOutputMarkupId(true); add(feedbackPanel); Form<Void> exportForm = new Form<Void>("exportForm"); add(exportForm); final Model<ArrayList<String>> choiceModel = new Model<ArrayList<String>>(); final ListMultipleChoice listChoice = new ListMultipleChoice("listChoice", choiceModel, new PropertyModel<String>(this, "list")); listChoice.setMaxRows(10); listChoice.setOutputMarkupId(true); exportForm.add(listChoice); AjaxLink addLink = new AjaxLink<Void>("addElement") { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { ModalWindow dialog = findParent(BasePage.class).getDialog(); dialog.setTitle(getString("Settings.migration.export.entity.add")); dialog.setInitialWidth(350); dialog.setUseInitialHeight(false); AddEntityPanel addEntityPanel = new AddEntityPanel() { private static final long serialVersionUID = 1L; @Override public void onOk(AjaxRequestTarget target) { Iterator<Entity> entities = getEntities(); if (!entities.hasNext()) { error(getString("Settings.migration.export.entity.select")); target.add(getFeedbackPanel()); return; } while (entities.hasNext()) { Entity entity = entities.next(); String path = entity.getPath(); path = path.substring(StorageConstants.NEXT_SERVER_ROOT.length() + 1); if (!list.contains(path)) { list.add(path); } } ModalWindow.closeCurrent(target); target.add(listChoice); } }; dialog.setContent(new FormPanel<Void>(dialog.getContentId(), addEntityPanel, true) { private static final long serialVersionUID = 1L; @Override protected void onConfigure() { super.onConfigure(); setOkButtonValue(getString("add")); } }); dialog.show(target); } }; addLink.add(new SimpleTooltipBehavior(getString("Settings.migration.export.entity.add"))); exportForm.add(addLink); AjaxSubmitLink removeLink = new AjaxSubmitLink("removeElement", exportForm) { private static final long serialVersionUID = 1L; @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { for (String sel : choiceModel.getObject()) { for (Iterator<?> it = list.iterator(); it.hasNext();) { if (sel.equals(it.next())) { it.remove(); } } } if (target != null) { target.add(listChoice); } } @Override protected void onError(AjaxRequestTarget target, Form<?> form) { target.add(form); } }; removeLink.add(new SimpleTooltipBehavior(getString("Settings.migration.export.entity.remove"))); exportForm.add(removeLink); TextField<String> exportField = new TextField<String>("exportPath", new PropertyModel<String>(this, "exportPath")); exportField.setLabel(new Model<String>(getString("Settings.migration.export.path"))); exportForm.add(exportField); exportForm.add(new AjaxSubmitLink("export") { @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { // we do not use TextField validation with setRequired because we have a submit button (remove entity) // which must work without validation if ((exportPath == null) || "".endsWith(exportPath.trim())) { error(getString("Settings.migration.export.path.select")); target.add(feedbackPanel); return; } NextServerApplication.setMaintenance(true); MigrationObject mo = new MigrationObject(); List<DataSource> dsList = new ArrayList<DataSource>(); List<Report> reportList = new ArrayList<Report>(); List<Chart> chartList = new ArrayList<Chart>(); List<DashboardState> dashboards = new ArrayList<DashboardState>(); mo.setDataSources(dsList); mo.setReports(reportList); mo.setCharts(chartList); mo.setDashboards(dashboards); FileOutputStream fos = null; try { if (list.size() == 0) { error(getString("Settings.migration.export.entity.select")); } else { for (String pathM : list) { populateLists(pathM, mo); } XStream xstream = new XStream(new DomDriver()); SimpleDateFormat sdf = new SimpleDateFormat("dd_MM_yyyy_hh_mm"); fos = new FileOutputStream( exportPath + File.separator + "migration-" + sdf.format(new Date()) + ".xml"); xstream.toXML(mo, fos); info(getString("Settings.migration.export.info")); } } catch (Throwable t) { error(t.getMessage()); } finally { NextServerApplication.setMaintenance(false); if (fos != null) { try { fos.close(); } catch (IOException e) { e.printStackTrace(); } } } target.add(feedbackPanel); } @Override protected void onError(AjaxRequestTarget target, Form<?> form) { target.add(feedbackPanel); } }); }
From source file:ro.nextreports.server.web.dashboard.DashboardNavigationPanel.java
License:Apache License
private AjaxLink createTitleLink(final Object object, int index) { final String dashboardId = getDashboardId(object); String title = getTitle(object); String owner;/* w ww. j a va 2s . c o m*/ try { owner = dashboardService.getDashboardOwner(dashboardId); } catch (NotFoundException e) { // never happening throw new RuntimeException(e); } AjaxLink<Void> titleLink = new AjaxLink<Void>("titleLink") { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { SectionContext sectionContext = NextServerSession.get().getSectionContext(DashboardSection.ID); sectionContext.getData().put(SectionContextConstants.SELECTED_DASHBOARD_ID, dashboardId); DashboardBrowserPanel browserPanel = findParent(DashboardBrowserPanel.class); target.add(browserPanel); // don't work (see decebal's post on wiquery forum) /* if (isLink(object)) { DashboardPanel dashboardPanel = browserPanel.getDashboardPanel(); dashboardPanel.disableSortable(target); } */ } }; IModel<String> linkImageModel = new LoadableDetachableModel<String>() { private static final long serialVersionUID = 1L; @Override protected String load() { String imagePath = "images/dashboard.png"; if (isLink(object)) { imagePath = "images/dashboard_link.png"; } return imagePath; } }; final ContextImage link = new ContextImage("titleImage", linkImageModel); titleLink.add(link); if (index == 0) { title = getString("dashboard.my"); } titleLink.add(new Label("title", title)); if (isLink(object)) { titleLink.add(new SimpleTooltipBehavior(getString("DashboardNavigationPanel.owner") + ": " + owner)); } return titleLink; }
From source file:sk.lazyman.gizmo.component.data.LinkPanel.java
License:Apache License
public LinkPanel(String id, IModel<String> label) { super(id);// ww w . ja va 2s. com AjaxLink link = new AjaxLink(ID_LINK) { @Override public void onClick(AjaxRequestTarget target) { LinkPanel.this.onClick(target); } }; link.add(new Label(ID_LABEL, label)); link.add(new VisibleEnableBehaviour() { @Override public boolean isEnabled() { return LinkPanel.this.isEnabled(); } }); add(link); }
From source file:sk.lazyman.gizmo.component.ProjectItemList.java
License:Apache License
private void createItemBody(final ListItem<ProjectListItem<T>> item) { item.add(AttributeAppender.append("class", new AbstractReadOnlyModel<String>() { @Override//from w w w .j a v a 2s . c o m public String getObject() { ProjectListItem i = item.getModelObject(); return i.isSelected() ? "list-group-item-info" : null; } })); AjaxLink link = new AjaxLink(ID_LINK) { @Override public void onClick(AjaxRequestTarget target) { itemSelected(target, item.getModelObject()); } }; item.add(link); Label name = new Label(ID_NAME, new PropertyModel<>(item.getModel(), ProjectListItem.F_NAME)); name.setRenderBodyOnly(true); link.add(name); Label description = new Label(ID_DESCRIPTION, new PropertyModel<>(item.getModel(), ProjectListItem.F_DESCRIPTION)); description.setRenderBodyOnly(true); link.add(description); AjaxLink edit = new AjaxLink(ID_EDIT) { @Override public void onClick(AjaxRequestTarget target) { editPerformed(target, item.getModelObject()); } }; item.add(edit); item.add(new Label(ID_PROPERTIES, createPropertiesModel())); }
From source file:transactions.TransactionsWritablePanel.java
License:Open Source License
/** * DOCUMENT: Constructs ...//from w ww. ja va2s. co m * * @param id DOCUMENT: id description. */ public TransactionsWritablePanel(final String id) { super(id); setVersioned(true); setOutputMarkupId(true); add(new Form("toolbar") .add(new DropDownChoice<DateFilterEnum>("when", new PropertyModel(this, "when"), Lists.newArrayList(DateFilterEnum.values())).add(newFilteringBehavior())) .add(new TextField<String>("refNum", new PropertyModel(this, "refNum")).add(newFilteringBehavior())) .add(new TextField<Integer>("transId", new PropertyModel(this, "transId")) .add(newFilteringBehavior()))); add(transactionsView = new PageableListView<CoreTransactionDTO>("transactions", getTransactionsModel(), 6) { @Override protected void populateItem(ListItem<CoreTransactionDTO> item) { final IModel<CoreTransactionDTO> model = item.getModel(); item.add(new Label("id", new PropertyModel(model, "id"))); AjaxLink link = new AjaxLink("ref") { @Override public void onClick(AjaxRequestTarget target) { transaction = model.getObject(); target.add(detailsContainer); } }; link.add(new Label("label", new PropertyModel(model, "transactionReferenceCode"))); item.add(link); item.add(new Label("type", new PropertyModel(model, "transactionTypeId.id"))); item.add(new Label("status", new PropertyModel(model, "status"))); item.add(new Label("created", new PropertyModel(model, "creationDate"))); } }); add(new PagingNavigation("navigator", transactionsView)); detailsContainer = new WebMarkupContainer("detailsContainer"); add(detailsContainer.setOutputMarkupId(true)); detailsContainer.add(new ListView<CoreStepDTO>("details", getStepsModel()) { @Override protected void populateItem(ListItem<CoreStepDTO> item) { IModel<CoreStepDTO> model = item.getModel(); item.add(new Label("name", new PropertyModel(model, "operation"))); item.add(new Label("status", new PropertyModel(model, "resultId.name"))); item.add(new Label("msgs", new PropertyModel(model, "coreMessageCollection"))); } }); }