org.apache.wicket.markup.html.link.ResourceLink Java Examples

The following examples show how to use org.apache.wicket.markup.html.link.ResourceLink. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ServerLogPage.java    From onedev with MIT License 7 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();

	add(new ResourceLink<Void>("download", new ServerLogDownloadResourceReference()));
	
	List<String> lines = ServerLogDownloadResource.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));
}
 
Example #2
Source File: BirtManagementPanel.java    From Orienteer with Apache License 2.0 6 votes vote down vote up
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));
	
}
 
Example #3
Source File: ExportOSchemaCommand.java    From Orienteer with Apache License 2.0 6 votes vote down vote up
@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");
		}
		
	});
}
 
Example #4
Source File: WidgetPopupMenuModel.java    From nextreports-server with Apache License 2.0 6 votes vote down vote up
private Link<TableResource> createSaveToExcelLink(final IModel<Widget> model) {
	ByteArrayResource download;
	if (model.getObject() instanceof PivotWidget) {
		PivotWidget pivotWidget = (PivotWidget)model.getObject();												
		download = new PivotResource(pivotWidget);		
	} else if (model.getObject() instanceof DrillDownWidget) {
		download = new TableResource(model.getObject().getId(), ((DrillDownWidget)model.getObject()).getDrillEntityContext());
	} else {
		download = new TableResource(model.getObject().getId(), null);
	}
	ResourceLink resourceLink =  new ResourceLink<TableResource>(MenuPanel.LINK_ID, download);
	// see busy-indicator.js
	// we do not want a busy indicator in this situation
	resourceLink.add(new AttributeAppender("class", new Model<String>("noBusyIndicator"), " "));
	return resourceLink;
}
 
Example #5
Source File: GuidelinesDialogContent.java    From webanno with Apache License 2.0 5 votes vote down vote up
public GuidelinesDialogContent(String aId, final ModalWindow modalWindow,
        final IModel<AnnotatorState> aModel)
{
    super(aId);

    // Overall progress by Projects
    RepeatingView guidelineRepeater = new RepeatingView("guidelineRepeater");
    add(guidelineRepeater);
    
    for (String guidelineFileName : projectService
            .listGuidelines(aModel.getObject().getProject())) {
        AbstractItem item = new AbstractItem(guidelineRepeater.newChildId());

        guidelineRepeater.add(item);

        // Add a popup window link to display annotation guidelines
        PopupSettings popupSettings = new PopupSettings(RESIZABLE | SCROLLBARS)
                        .setHeight(500)
                        .setWidth(700);

        IResourceStream stream = new FileResourceStream(projectService
                .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));
        item.add(rlink);
    }
    
    add(new LambdaAjaxLink("cancel", (target) -> modalWindow.close(target)));
}
 
Example #6
Source File: ExportCommand.java    From Orienteer with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example #7
Source File: AnalysisPanel.java    From nextreports-server with Apache License 2.0 5 votes vote down vote up
private ResourceLink<CsvResource> getCsvLink() {    	
 	return  new ResourceLink<CsvResource>("csvExport", csvResource) {
 		@Override
public boolean isVisible() {				
	return !dataProvider.isEmpty();
}	
 	};
 }
 
Example #8
Source File: AnalysisPanel.java    From nextreports-server with Apache License 2.0 5 votes vote down vote up
private ResourceLink<XlsResource> getXlsLink() {
 	return  new ResourceLink<XlsResource>("xlsExport", xlsResource) {
 		@Override
public boolean isVisible() {				
	return !dataProvider.isEmpty();
}	
 	};
 }
 
Example #9
Source File: AnalysisPanel.java    From nextreports-server with Apache License 2.0 5 votes vote down vote up
private ResourceLink<XlsxResource> getXlsxLink() {
 	return  new ResourceLink<XlsxResource>("xlsxExport", xlsxResource) {
 		@Override
public boolean isVisible() {				
	return !dataProvider.isEmpty();
}	
 	};
 }
 
Example #10
Source File: DownloadActionContributor.java    From nextreports-server with Apache License 2.0 5 votes vote down vote up
public AbstractLink getLink(ActionContext context) {
    List<Chart> charts = new ArrayList<Chart>();
    for (Entity entity : context.getEntities()) {
        charts.add((Chart)entity);
    }
    ChartResource download = new ChartResource(charts);
    
    return new ResourceLink<ReportResource>(context.getLinkId(), download);
}
 
Example #11
Source File: DownloadActionContributor.java    From nextreports-server with Apache License 2.0 5 votes vote down vote up
public AbstractLink getLink(ActionContext context) {
    List<Report> reports = new ArrayList<Report>();
    for (Entity entity : context.getEntities()) {
        reports.add((Report)entity);
    }
    ReportResource download = new ReportResource(reports);

    return new ResourceLink<ReportResource>(context.getLinkId(), download);
}
 
Example #12
Source File: AuditTableRendererPanel.java    From nextreports-server with Apache License 2.0 5 votes vote down vote up
private Link<TableResource> createSaveToExcelLink(final IModel<TableData> model) {
	SimpleDateFormat sdf = new SimpleDateFormat("yyyy_MM_dd_HH-mm-ss");
	String fileName = "audit-" +  type.toLowerCase() + "-" + sdf.format(new Date()) + ".xls";
	ByteArrayResource download = new TableResource(excludeColumns(model.getObject()), fileName);		
	ResourceLink resourceLink =  new ResourceLink<TableResource>("download", download);
	// see busy-indicator.js
	// we do not want a busy indicator in this situation
	resourceLink.add(new AttributeAppender("class", new Model<String>("noBusyIndicator"), " "));
	return resourceLink;
}
 
Example #13
Source File: BuildLogPage.java    From onedev with MIT License 4 votes vote down vote up
public Component renderOptions(String componentId) {
	Fragment fragment = new Fragment(componentId, "optionsFrag", this);
	fragment.add(new ResourceLink<Void>("download", new BuildLogDownloadResourceReference(), 
			BuildLogDownloadResource.paramsOf(projectModel.getObject(), getBuild().getNumber())));
	return fragment;
}
 
Example #14
Source File: ConsoleImportProjectPage.java    From artifact-listener with Apache License 2.0 4 votes vote down vote up
public ConsoleImportProjectPage(PageParameters parameters) {
	super(parameters);
	
	addHeadPageTitleKey("console.import.project");
	
	// File select form
	final FileUploadField fileSelect = new FileUploadField("fileSelectInput", this.fileUploadsModel);
	fileSelect.setLabel(new ResourceModel("console.import.project.file"));
	fileSelect.add(AttributeModifier.replace("accept", getAcceptAttribute()));
	
	Form<Void> form = new Form<Void>("fileSelectForm") {
		private static final long serialVersionUID = 1L;

		@Override
		protected void onSubmit() {
			File file = null;
			try {
				FileUpload fileUpload = fileSelect.getFileUpload();
				
				if (fileUpload == null) {
					getSession().error(getString("console.import.project.error.noFile"));
					return;
				}
				
				file = File.createTempFile("uploaded-", ".xls", configurer.getTmpDirectory());
				fileUpload.writeTo(file);
				
				projectImportDataService.importProjects(file);
				
				Session.get().success(getString("console.import.project.success"));
			} catch (Exception e) {
				LOGGER.error("Unable to parse " + fileSelect.getFileUpload().getClientFileName() + " file", e);
				
				Session.get().error(getString("console.import.project.error"));
			} finally {
				FileUtils.deleteQuietly(file);
			}
		}
	};
	form.add(fileSelect);
	
	// Example excel file download link
	form.add(new ResourceLink<Void>("downloadTemplate", ProjectImportModelResourceReference.get()));
	
	form.add(new SubmitLink("importButton"));
	
	add(form);
}