@Override protected AbstractLink newLink(String id) { return new ResourceLink<Object>(id, new DatabaseExportResource() { @Override protected ResourceResponse newResourceResponse(Attributes attrs) { ResourceResponse resourceResponse = super.newResourceResponse(attrs); resourceResponse.setFileName("schema.gz"); return resourceResponse; } @Override protected void configureODatabaseExport(ODatabaseExport dbExport) { dbExport.setOptions("-excludeAll=true -includeSchema=true"); } }); }
@Override protected AbstractLink newLink(String id) { return new ResourceLink<>(id, new AbstractResource() { @Override protected ResourceResponse newResourceResponse(Attributes attributes) { ResourceResponse resourceResponse = new ResourceResponse(); resourceResponse.setContentType("text/xml"); resourceResponse.setFileName((String)BpmnPanel.this.getModelObject().field("name")); resourceResponse.setWriteCallback(new WriteCallback() { @Override public void writeData(Attributes attributes) throws IOException { OutputStream out = attributes.getResponse().getOutputStream(); out.write((byte[])BpmnPanel.this.getModelObject().field("bytes")); } }); return resourceResponse; } }); }
@Override protected AbstractLink newLink(String id) { IResource resource = new ResourceStreamResource() { @Override protected IResourceStream getResourceStream(Attributes attrs) { return new DataExportResourceStreamWriter(dataExporter, table); } }.setFileName(fileNameModel.getObject() + "." + dataExporter.getFileNameExtension()); return new ResourceLink<Void>(id, resource); }
@Override protected void populateItem(ListItem<URI> item) { ResourceStreamResource lopZipStream = makeZipLogStream(item.getModel()); lopZipStream.setFileName("log.zip"); ResourceLink<?> downloadLink = new ResourceLink<>("log", lopZipStream); downloadLink.add(new Label("label", Paths.get(item.getModelObject()).getFileName().toString())); item.add(downloadLink); } });
@Override protected void populateItem(ListItem<URI> item) { ResourceStreamResource lopZipStream = makeZipLogStream(item.getModel()); lopZipStream.setFileName("log.zip"); ResourceLink downloadLink = new ResourceLink("log", lopZipStream); downloadLink.add(new Label("label", Paths.get(item.getModelObject()).getFileName().toString())); item.add(downloadLink); } });
@Override protected void populateItem(ListItem<URI> item) { ResourceStreamResource lopZipStream = makeZipLogStream(item.getModel()); lopZipStream.setFileName("log.zip"); ResourceLink downloadLink = new ResourceLink("log", lopZipStream); downloadLink.add(new Label("label", Paths.get(item.getModelObject()).getFileName().toString())); item.add(downloadLink); } });
@Override protected void onInitialize() { super.onInitialize(); add(new ResourceLink<Void>("download", new ServerLogResourceReference())); List<String> lines = ServerLogResource.readServerLog(); String content; if (lines.size() > MAX_DISPLAY_LINES) { add(new Label("warning", "Too many log entries, displaying recent " + MAX_DISPLAY_LINES)); content = Joiner.on("\n").join(lines.subList(lines.size()-MAX_DISPLAY_LINES, lines.size())); } else { add(new WebMarkupContainer("warning").setVisible(false)); content = Joiner.on("\n").join(lines); } add(new Label("logContent", content)); }
protected void initialize() { add((dataLink = new ResourceLink<byte[]>("data", new AbstractResource() { @Override protected ResourceResponse newResourceResponse(Attributes attributes) { ResourceResponse resourceResponse = new ResourceResponse(); resourceResponse.setContentType("application/octet-stream"); String filename = nameModel.getObject(); resourceResponse.setFileName(filename); resourceResponse.setWriteCallback(new WriteCallback() { @Override public void writeData(Attributes attributes) throws IOException { byte[] data = (byte[])BinaryViewPanel.this.getModelObject(); if(data!=null) { OutputStream outputStream = attributes.getResponse().getOutputStream(); outputStream.write((byte[])BinaryViewPanel.this.getModelObject()); } } }); return resourceResponse; } })).setBody(nameModel)); }
ResourceEditor(String id, JcrNodeModel nodeModel) { super(id); JcrResourceStream stream = new JcrResourceStream(nodeModel); ResourceLink link = new ResourceLink("resource-link", new JcrResource(stream)); add(link); String size; long length = stream.length(); if (length / ONE_GB > 0) { size = String.valueOf(length / ONE_GB) + " GB"; } else if (length / ONE_MB > 0) { size = String.valueOf(length / ONE_MB) + " MB"; } else if (length / ONE_KB > 0) { size = String.valueOf(length / ONE_KB) + " KB"; } else { size = String.valueOf(length) + " bytes"; } link.add(new Label("resource-link-text", "download (" + size + ")")); }
/** * Creates a new link to the exported data for the provided {@link IDataExporter}. * * @param componentId * The component of the link. * @param dataExporter * The data exporter to use to export the data. * @return a new link to the exported data for the provided {@link IDataExporter}. */ protected Component createExportLink(String componentId, final IDataExporter dataExporter) { IResource resource = new ResourceStreamResource() { @Override protected IResourceStream getResourceStream(Attributes attributes) { return new DataExportResourceStreamWriter(dataExporter, getTable()); } }.setFileName(fileNameModel.getObject() + "." + dataExporter.getFileNameExtension()); return new ResourceLink<Void>(componentId, resource) .setBody(dataExporter.getDataFormatNameModel()); }
public BirtManagementPanel(String id,final AbstractBirtReportPanel reportPanel) { super(id); final AjaxPagingNavigator pager = new AjaxPagingNavigator(PAGER_NAME, reportPanel) { private static final long serialVersionUID = 1L; @Override protected void onAjaxEvent(AjaxRequestTarget target) { target.add(reportPanel); target.add(this); } }; add(pager); add(new ResourceLink<>("HTML", new HtmlBirtResource(reportPanel))); add(new ResourceLink<>("PDF", new PDFBirtResource(reportPanel))); add(new ResourceLink<>("Excel", new ExcelBirtResource(reportPanel))); add(new ParamsListView("params",reportPanel.getParametersDefenitions(),reportPanel,pager)); add(new ParamsListView("hiddenParams",reportPanel.getHiddenParametersDefinitions(),reportPanel,pager)); } ////////////////////////////////////////////////////////////////////////
log.error("Unexpected exception while determining download filename", e); final Link downloadLink = new ResourceLink("binary-download-lnk", resource); downloadLink.add(new Label("binary-download-text", "download (" + getSizeString(stream.length()) + ")")); add(downloadLink);
.getGuideline(aModel.getObject().getProject(), guidelineFileName)); ResourceStreamResource resource = new ResourceStreamResource(stream); ResourceLink<Void> rlink = new ResourceLink<>("guideine", resource); rlink.setPopupSettings(popupSettings); item.add(new Label("guidelineName", guidelineFileName));
public RootPlugin(IPluginContext context, IPluginConfig config) { super(context, config); addPinger(); addActiveLogout(); if (config.getString(RenderService.MODEL_ID) != null) { String modelId = config.getString(RenderService.MODEL_ID); ModelReference<Node> modelService = new ModelReference<>(modelId, new JcrNodeModel("/")); modelService.init(context); parameterHistoryBehavior = new ParameterHistoryBehavior(modelService); context.registerService(parameterHistoryBehavior, IObserver.class.getName()); add(parameterHistoryBehavior); } PageLayoutSettings plSettings = new PageLayoutSettings(); try { PluginConfigMapper.populate(plSettings, config.getPluginConfig("yui.config")); } catch (MappingException e) { throw new RuntimeException(e); } add(new PageLayoutBehavior(plSettings)); add(new Label("pageTitle", getPageTitle(config))); final String faviconPath = config.getString("favicon.path", "console-red.ico"); add(new ResourceLink("faviconLink", new PackageResourceReference(RootPlugin.class, faviconPath))); }
form.add(new ResourceLink<Void>("backupNow", new AbstractResource() {
add(new ResourceLink("faviconLink", iconReference));
export.setCacheable(false); ResourceLink<Object> resourceLink = new ResourceLink<Object>("export", export); resourceLink.add(new SimpleAttributeModifier("value", new ResourceModel("AdminPage.export.button").getObject().toString())); form.add(resourceLink);
export.setCacheable(false); ResourceLink<Object> resourceLink = new ResourceLink<Object>("export", export); resourceLink.add(new SimpleAttributeModifier("value", new ResourceModel("AdminPage.export.button").getObject().toString())); form.add(resourceLink);
add(new ResourceLink<Void>("raw", new RawBlobResourceReference(), RawBlobResource.paramsOf(context.getProject(), context.getBlobIdent()))); add(new CheckBox("blame", Model.of(context.getMode() == Mode.BLAME)) {
Link<IResource> exportLink = new ResourceLink<IResource>("export-link", new ExportCsvResource()); add(exportLink); } catch (Exception e) {