List of usage examples for org.apache.wicket.markup.html.link ResourceLink ResourceLink
public ResourceLink(final String id, final IResource resource)
From source file:au.org.theark.report.web.component.viewReport.ReportOutputPanel.java
License:Open Source License
public void setReportResource(JRResource reportResource) { if (reportResource != null) { ResourceLink<Void> newLink = new ResourceLink<Void>("linkToReport", reportResource); newLink.setOutputMarkupPlaceholderTag(true); // allow link to be replaced even when invisible addOrReplace(newLink);/* w w w . j ava 2s. c o m*/ downloadReportLink = newLink; } else { if (!downloadReportLink.getClass().equals(ExternalLink.class)) { ExternalLink newLink = new ExternalLink("linkToReport", "", ""); newLink.setOutputMarkupPlaceholderTag(true); // allow link to be replaced even when invisible addOrReplace(newLink); downloadReportLink = newLink; } } }
From source file:au.org.theark.report.web.component.viewReport.ReportOutputPanel.java
License:Open Source License
public void setOtherIDReportResource(JRResource resource) { if (resource != null) { ResourceLink<Void> newLink = new ResourceLink<Void>("otherIDLink", resource); newLink.setOutputMarkupPlaceholderTag(true); addOrReplace(newLink);//from w w w . j a v a 2 s .c om otherIDLink = newLink; } else { if (!otherIDLink.getClass().equals(ExternalLink.class)) { ExternalLink newLink = new ExternalLink("otherIDLink", "", ""); newLink.setOutputMarkupPlaceholderTag(true); // allow link to be replaced even when invisible addOrReplace(newLink); otherIDLink = newLink; } } }
From source file:com.asptt.plongee.resa.util.UtilsFSpdf.java
public ResourceLink createWebResourcePdf(final Adherent adherent, final FicheSecurite fs) { Resource pdfResource = new WebResource() { @Override// w ww . ja v a 2s. co m public IResourceStream getResourceStream() { String nom = adherent.getNom(); final String realPath; if (null != fs) { realPath = catalinaBasePath.concat(Parameters.getString("fs.path")).concat(nom).concat("_FS") .concat(".pdf"); // Cration du pdf try { createPdfFS(realPath, fs); } catch (com.itextpdf.io.IOException ex) { java.util.logging.Logger.getLogger(UpdateListeFS.class.getName()).log(Level.SEVERE, null, ex); } catch (java.io.IOException ex) { java.util.logging.Logger.getLogger(UpdateListeFS.class.getName()).log(Level.SEVERE, null, ex); } } else { //Recherche du Certificat mdical nom = nom.substring(0, 1).toUpperCase() + nom.substring(1).toLowerCase(); String license = adherent.getNumeroLicense(); realPath = catalinaBasePath.concat(Parameters.getString("cm.path")).concat(nom).concat("_") .concat(license).concat(".pdf"); } java.io.File file = new java.io.File(realPath); // created FileResourceStream object by passing the above File object name "pdfFile". IResourceStream stream = new FileResourceStream(file); file.deleteOnExit(); //finally returns the stream return stream; } }; /* * Created PopupSettings object named "popupSettings" by passing some parameters in the * constructor and also setted the width and height for popup window. */ PopupSettings popupSettings = new PopupSettings(PopupSettings.RESIZABLE | PopupSettings.SCROLLBARS) .setHeight(500).setWidth(700); /* * Created ResourceLink object named "resourceLink" by passing above Resource object * named "pdfResource" as second parameters.The first parameter is "wicket:id" by which * markup identifies the component and renders it on web page. */ ResourceLink resourceLink = (ResourceLink) new ResourceLink("openPdf", pdfResource); //Setted the popupSettings properties of "resourceLink". resourceLink.setPopupSettings(popupSettings); //if file not found disable resourcelink in case of certificat mdical (fs == null) if (null == fs) { try { pdfResource.getResourceStream().getInputStream(); } catch (ResourceStreamNotFoundException ex) { resourceLink.setEnabled(false); } } //return resourceLink for added in page return resourceLink; }
From source file:com.inductiveautomation.xopc.drivers.modbus2.configuration.web.ModbusConfigurationUI.java
License:Open Source License
private void addComponents() { T settingsRecord = (T) getDefaultModelObject(); String mapString = (String) TypeUtilities.toString(settingsRecord.getAddressMap()); addressMap = MutableModbusAddressMap.fromParseableString(mapString); if (addressMap == null) { addressMap = new MutableModbusAddressMap(); }//from w ww. java 2 s.c om radix = addressMap.getDesignatorRadix(); final Form<Object> form = new Form<Object>("form") { @Override protected void onSubmit() { handleOnSubmit(); } }; form.add(new FeedbackPanel("feedback")); final WebMarkupContainer tableContainer = new WebMarkupContainer("table-container"); tableContainer.setOutputMarkupId(true); final WebMarkupContainer radixContainer = new WebMarkupContainer("radix-container") { @Override public boolean isVisible() { return entries.size() > 0; } }; radixContainer.setOutputMarkupId(true); radixContainer.add(new Label("radix-label", new LenientResourceModel("radixlabel", "Radix")) { @Override public boolean isVisible() { return entries.size() > 0; } }); final RequiredTextField<Integer> radixField = new RequiredTextField<Integer>("radix", new PropertyModel<Integer>(this, "radix")) { @Override public boolean isVisible() { return entries.size() > 0; } }; radixField.add(new OnChangeAjaxBehavior() { @Override protected void onUpdate(AjaxRequestTarget target) { try { Integer radix = Integer.parseInt(radixField.getValue()); setRadix(radix); } catch (Exception e) { } } }); radixContainer.add(radixField); tableContainer.add(radixContainer); radixContainer.add(new Link<Object>("set-radix") { @Override public void onClick() { if (addressMap != null) { } } @Override public boolean isVisible() { return false; } }); // Create the configuration entries for the listview for (DesignatorRange dr : addressMap.keySet()) { MutableDesignatorRange mdr = new MutableDesignatorRange(dr); MutableModbusRange mbr = new MutableModbusRange(addressMap.get(dr)); entries.add(new ModbusConfigurationEntry(mdr, mbr)); } // Create the listview listview = new ListEditor<ModbusConfigurationEntry>("config-listview", getListviewModel()) { @Override protected void onPopulateItem(ListItem<ModbusConfigurationEntry> item) { final ModbusConfigurationEntry configEntry = item.getModelObject(); item.add(newPrefixTextField(configEntry)); item.add(newStartTextField(configEntry)); item.add(newEndTextField(configEntry)); item.add(newStepCheckboxField(configEntry)); item.add(newModbusUnitIDTextField(configEntry)); item.add(newModbusAddressTypeDropdown(configEntry)); item.add(newModbusAddressTextField(configEntry)); item.add(new DeleteLink("delete-link")); } }; WebMarkupContainer noMappingsContainer = new WebMarkupContainer("no-mappings-container") { @Override public boolean isVisible() { return entries.size() == 0; } ; }; noMappingsContainer .add(new Label("no-mappings-label", new LenientResourceModel("nomappings", "No mappings."))); tableContainer.add(noMappingsContainer); tableContainer.add(listview); form.add(tableContainer); form.add(new SubmitLink("add-row-link") { { setDefaultFormProcessing(false); } @Override public void onSubmit() { listview.addItem(new ModbusConfigurationEntry()); } }); form.add(new Button("save")); add(form); // CSV export try { Link<IResource> exportLink = new ResourceLink<IResource>("export-link", new ExportCsvResource()); add(exportLink); } catch (Exception e) { Link<Object> exportLink = new Link<Object>("export-link") { @Override public void onClick() { } @Override public boolean isVisible() { return false; } }; add(exportLink); } // CSV import final FileUploadField uploadField = new FileUploadField("upload-field"); Form<?> uploadForm = new Form<Object>("upload-form") { @Override protected void onSubmit() { try { addressMap = ModbusCsvParser.fromCsv(uploadField.getFileUpload().getInputStream()); radix = addressMap.getDesignatorRadix(); listview.clear(); for (DesignatorRange dr : addressMap.keySet()) { MutableDesignatorRange mdr = new MutableDesignatorRange(dr); MutableModbusRange mbr = new MutableModbusRange(addressMap.get(dr)); listview.addItem(new ModbusConfigurationEntry(mdr, mbr)); } } catch (Exception e) { error("Error importing configuration from CSV file."); } } }; uploadForm.add(uploadField); SubmitLink importLink = new SubmitLink("import-link"); uploadForm.add(importLink); add(uploadForm); }
From source file:com.senacor.wbs.web.project.ProjectListPanel.java
License:Apache License
public ProjectListPanel(final String id, final List<Project> projects) { super(id);/* w ww .java 2s.c om*/ this.locale = getLocale(); SortableListDataProvider<Project> projectProvider = new SortableListDataProvider<Project>(projects) { @Override protected Locale getLocale() { return ProjectListPanel.this.getLocale(); } public IModel model(final Object object) { return new CompoundPropertyModel(object); } }; projectProvider.setSort("name", true); dataView = new DataView("projects", projectProvider, 4) { @Override protected void populateItem(final Item item) { Project project = (Project) item.getModelObject(); PageParameters pageParameters = new PageParameters(); pageParameters.put("projectId", project.getId()); item.add(new BookmarkablePageLink("tasks", ProjectDetailsPage.class, pageParameters) .add(new Label("id"))); item.add(new Label("kuerzel")); item.add(new Label("titel", project.getName())); item.add(new Label("budget")); item.add(new Label("costPerHour")); item.add(new Label("start")); item.add(new Label("ende")); item.add(new Label("state")); // Alternieren der Farbe zwischen geraden und // ungeraden Zeilen item.add(new AttributeModifier("class", true, new AbstractReadOnlyModel() { @Override public Object getObject() { return (item.getIndex() % 2 == 1) ? "even" : "odd"; } })); } }; add(dataView); Form localeForm = new Form("localeForm"); ImageButton deButton = new ImageButton("langde", new ResourceReference(BaseWBSPage.class, "de.png")) { @Override public void onSubmit() { ProjectListPanel.this.locale = Locale.GERMANY; } }; localeForm.add(deButton); ImageButton usButton = new ImageButton("langus", new ResourceReference(BaseWBSPage.class, "us.png")) { @Override public void onSubmit() { ProjectListPanel.this.locale = Locale.US; } }; localeForm.add(usButton); add(localeForm); final IResourceStream pdfResourceStream = new AbstractResourceStreamWriter() { public void write(final OutputStream output) { Document document = new Document(); try { PdfWriter.getInstance(document, output); document.open(); // document.add(new // Paragraph("WBS-Projektliste")); // document.add(new Paragraph("")); PdfPTable table = new PdfPTable(new float[] { 1f, 1f, 2f, 1f }); PdfPCell cell = new PdfPCell(new Paragraph("WBS-Projektliste")); cell.setColspan(4); cell.setGrayFill(0.8f); table.addCell(cell); table.addCell("ID"); table.addCell("Krzel"); table.addCell("Titel"); table.addCell("Budget in PT"); for (Project project : projects) { table.addCell("" + project.getId()); table.addCell(project.getKuerzel()); table.addCell(project.getName()); table.addCell("" + project.getBudget()); } document.add(table); document.close(); } catch (DocumentException e) { throw new RuntimeException(e); } } public String getContentType() { return "application/pdf"; } }; WebResource projectsResource = new WebResource() { { setCacheable(false); } @Override public IResourceStream getResourceStream() { return pdfResourceStream; } @Override protected void setHeaders(final WebResponse response) { super.setHeaders(response); // response.setAttachmentHeader("projekte.pdf"); } }; WebResource projectsResourceDL = new WebResource() { { setCacheable(false); } @Override public IResourceStream getResourceStream() { return pdfResourceStream; } @Override protected void setHeaders(final WebResponse response) { super.setHeaders(response); response.setAttachmentHeader("projekte.pdf"); } }; ResourceLink pdfDownload = new ResourceLink("pdfDownload", projectsResourceDL); ResourceLink pdfPopup = new ResourceLink("pdfPopup", projectsResource); PopupSettings popupSettings = new PopupSettings(PopupSettings.STATUS_BAR); popupSettings.setWidth(500); popupSettings.setHeight(700); pdfPopup.setPopupSettings(popupSettings); Link pdfReqTarget = new Link("pdfReqTarget") { @Override public void onClick() { RequestCycle.get() .setRequestTarget(new ResourceStreamRequestTarget(pdfResourceStream, "projekte.pdf")); } }; add(pdfReqTarget); add(pdfDownload); add(pdfPopup); add(new OrderByBorder("orderByKuerzel", "kuerzel", projectProvider)); add(new OrderByBorder("orderByName", "name", projectProvider)); add(new OrderByBorder("orderByBudget", "budget", projectProvider)); add(new OrderByBorder("orderByCostPerHour", "costPerHour", projectProvider)); add(new OrderByBorder("orderByStart", "start", projectProvider)); add(new OrderByBorder("orderByEnde", "ende", projectProvider)); add(new OrderByBorder("orderByState", "state", projectProvider)); add(new PagingNavigator("projectsNavigator", dataView)); }
From source file:cz.zcu.kiv.eegdatabase.wui.ui.licenses.components.DownloadRequestAttachmentPanel.java
License:Apache License
public DownloadRequestAttachmentPanel(String id, IModel<PersonalLicense> model) { super(id);//w w w . j a v a 2 s .c om boolean isContent = model.getObject() != null && model.getObject().getAttachmentContent() != null; ByteArrayResource res; if (isContent) { byte[] attachmentContent = facade .getPersonalLicenseAttachmentContent(model.getObject().getPersonalLicenseId()); res = new ByteArrayResource("", attachmentContent, model.getObject().getAttachmentFileName()); } else { res = new ByteArrayResource(""); } add(new ResourceLink<Void>("link", res).setVisibilityAllowed(isContent)); }
From source file:cz.zcu.kiv.eegdatabase.wui.ui.licenses.components.LicenseDownloadLinkPanel.java
License:Open Source License
public LicenseDownloadLinkPanel(String id, IModel<License> model) { super(id);/*from w ww . j av a 2 s .com*/ final License license = model.getObject(); boolean isContent = license != null && license.getAttachmentFileName() != null; ByteArrayResource res; if (isContent) { res = new ByteArrayResource("", licenseFacade.getLicenseAttachmentContent(license.getLicenseId()), license.getAttachmentFileName()); } else { res = new ByteArrayResource(""); } ResourceLink<Void> downloadLink = new ResourceLink<Void>("download", res); downloadLink.setVisibilityAllowed(isContent); downloadLink.add(new Label("fileName", new Model<String>(license.getAttachmentFileName())) .setVisibilityAllowed(isContent)); add(downloadLink); //add(new Label("noFile", new Model<String>("")).setVisibilityAllowed(!isContent)); }
From source file:cz.zcu.kiv.eegdatabase.wui.ui.licenses.components.LicenseEditForm.java
License:Apache License
private void addLicenseDetails() { licenseDetails = new WebMarkupContainer("licenseDetails"); licenseDetails.setVisible(false);/*from w w w .j ava 2s. c om*/ form.add(licenseDetails); Label title = new Label("title", new PropertyModel<String>(form.getModel(), "license.title")); licenseDetails.add(title); Label type = new Label("type", new PropertyModel<String>(form.getModel(), "license.licenseType")); licenseDetails.add(type); Label description = new Label("description", new PropertyModel<String>(form.getModel(), "license.description")); licenseDetails.add(description); PropertyModel<String> linkModel = new PropertyModel<String>(form.getModel(), "license.link"); licenseLink = new ExternalLink("link", linkModel, linkModel); licenseDetails.add(licenseLink); downloadLink = new ResourceLink<Void>("fileDownload", (IResource) null); downloadLink.setVisible(false); Label fileName = new Label("fileName", new PropertyModel<String>(form.getModel(), "license.attachmentFileName")); downloadLink.add(fileName); licenseDetails.add(downloadLink); }
From source file:cz.zcu.kiv.eegdatabase.wui.ui.licenses.components.LicenseEditForm.java
License:Apache License
@SuppressWarnings("serial") private void addBlueprintSelect() { IModel<License> selectedBlueprintModel = new Model<License>(); licenseChoice = new AjaxDropDownChoice<License>("blueprintSelect", selectedBlueprintModel, blueprintsModel, new ChoiceRenderer<License>("title")) { @Override/* www . j ava 2s . c o m*/ protected void onSelectionChangeAjaxified(AjaxRequestTarget target, final License option) { if (option == null || option.getLicenseId() == 0) { form.getModelObject().setLicense(null); form.getModelObject().setPrice(BigDecimal.ZERO); saveButton.setVisibilityAllowed(false); priceInput.setEnabled(false); licenseDetails.setVisible(false); } else { priceInput.setEnabled(option.getLicenseType() == LicenseType.COMMERCIAL); licenseDetails.setVisible(true); licenseLink.setVisible(option.getLink() != null); if (option.getAttachmentFileName() != null) { ByteArrayResource res; res = new ByteArrayResource("", licenseFacade.getLicenseAttachmentContent(option.getLicenseId()), option.getAttachmentFileName()) { @Override public void configureResponse(final AbstractResource.ResourceResponse response, final IResource.Attributes attributes) { response.setCacheDuration(Duration.NONE); response.setFileName(option.getAttachmentFileName()); } }; ResourceLink<Void> newLink = new ResourceLink<Void>("fileDownload", res); newLink.add(new Label("fileName", option.getAttachmentFileName())); downloadLink.replaceWith(newLink); downloadLink = newLink; downloadLink.setVisible(true); } else { downloadLink.setVisible(false); } form.getModelObject().setLicense(option); saveButton.setVisibilityAllowed(true); } target.add(form); } }; licenseChoice.setNullValid(true); form.add(licenseChoice); }
From source file:cz.zcu.kiv.eegdatabase.wui.ui.licenses.components.LicensePriceForm.java
License:Apache License
private void addLicenseDetails() { licenseDetails = new WebMarkupContainer("licenseDetails"); licenseDetails.setVisible(false);// w w w . j ava 2 s .c o m form.add(licenseDetails); Label title = new Label("title"); licenseDetails.add(title); Label type = new Label("licenseType"); licenseDetails.add(type); Label description = new Label("description"); licenseDetails.add(description); PropertyModel<String> linkModel = new PropertyModel<String>(form.getModel(), "link"); licenseLink = new ExternalLink("link", linkModel, linkModel); licenseDetails.add(licenseLink); downloadLink = new ResourceLink<Void>("fileDownload", (IResource) null); downloadLink.setVisible(false); Label fileName = new Label("fileName", new PropertyModel<String>(form.getModel(), "attachmentFileName")); downloadLink.add(fileName); licenseDetails.add(downloadLink); }