List of usage examples for org.apache.wicket.markup.html.link ResourceLink ResourceLink
public ResourceLink(final String id, final IResource resource)
From source file:org.hippoecm.frontend.plugins.console.editor.BinaryEditor.java
License:Apache License
public BinaryEditor(String id, JcrPropertyModel model, final IPluginContext pluginContext) { super(id, model); final IResourceStream stream = new BinaryResourceStream(model); // download/* www. j a va 2 s .c o m*/ final ResourceStreamResource resource = new ResourceStreamResource(stream); resource.setCacheDuration(Duration.NONE); try { final Node node = model.getProperty().getParent().getParent(); final StringBuilder fileName = new StringBuilder(node.getName()); if (isExtractedTextProperty(model.getProperty())) { fileName.append(".txt"); } resource.setFileName(fileName.toString()); } catch (RepositoryException e) { 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); // upload IDialogFactory factory = new IDialogFactory() { private static final long serialVersionUID = 1L; public IDialogService.Dialog createDialog() { return new BinaryUploadDialog(model); } }; final IDialogService service = pluginContext.getService(IDialogService.class.getName(), IDialogService.class); final DialogLink uploadLink = new DialogLink("binary-upload-link", new Model<>("Upload binary"), factory, service); add(uploadLink); // Jackrabbit Binary Content Identifier if this Binary is in BinaryStore. final Label contentIdentityValueLabel = new Label("content-identity-value", new PropertyModel<String>(this, "contentIdentity")); contentIdentityValueLabel.setOutputMarkupPlaceholderTag(true); contentIdentityValueLabel.setVisible(false); add(contentIdentityValueLabel); final AjaxLink contentIdentityShowLink = new AjaxLink("content-identity-show-link") { @Override public void onClick(AjaxRequestTarget target) { setContentIdentity(retrieveJackrabbitContentIdentity()); target.add(contentIdentityValueLabel.setVisible(true)); target.add(this.setVisible(false)); } }; add(contentIdentityShowLink); }
From source file:org.hippoecm.frontend.plugins.console.RootPlugin.java
License:Apache License
public RootPlugin(IPluginContext context, IPluginConfig config) { super(context, config); addPinger();// w ww .j a v a 2 s . c om 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))); }
From source file:org.hippoecm.frontend.plugins.gallery.editor.ImageDisplayPlugin.java
License:Apache License
private Fragment createEmbedFragment(String id, final JcrResourceStream resource, final String filename) throws RepositoryException { Fragment fragment = new Fragment(id, "embed", this); fragment.add(new Label("filesize", Model.of(formatter.format(resource.length().bytes())))); fragment.add(new Label("mimetype", Model.of(resource.getContentType()))); fragment.add(new ResourceLink<Void>("link", new JcrResource(resource) { private static final long serialVersionUID = 1L; @Override//from w w w . j a v a 2 s.c om protected ResourceResponse newResourceResponse(final Attributes attributes) { ResourceResponse response = super.newResourceResponse(attributes); response.setContentDisposition(ContentDisposition.ATTACHMENT); response.setFileName(filename); return response; } }) { private static final long serialVersionUID = 1L; @Override protected void onDetach() { resource.detach(); super.onDetach(); } }); final Node node = getModelObject(); addImageMetaData(node, fragment); return fragment; }
From source file:org.hippoecm.frontend.plugins.login.LoginPlugin.java
License:Apache License
public LoginPlugin(IPluginContext context, IPluginConfig config) { super(context, config); add(CssClass.append("hippo-login-plugin")); add(new Label("pageTitle", getString("page.title"))); final ResourceReference iconReference = getFaviconReference(); add(new ResourceLink("faviconLink", iconReference)); String[] supported = config.getStringArray(SUPPORTED_BROWSERS); if (supported != null) { add(new BrowserCheckBehavior(supported)); }/* www. j a va 2 s.co m*/ // In case of using a different edition, add extra CSS rules to show the required styling if (config.containsKey(EDITION)) { final String edition = config.getString(EDITION); editionCss = new CssResourceReference(LoginPlugin.class, "login_" + edition + ".css"); } ExternalLink termsAndConditions = new ExternalLink("termsAndConditions", TERMS_AND_CONDITIONS_LINK) { @Override public boolean isVisible() { return UsageStatisticsSettings.get().isEnabled(); } }; termsAndConditions.setOutputMarkupId(true); add(termsAndConditions); final boolean autoComplete = getPluginConfig().getAsBoolean(AUTOCOMPLETE, true); String[] localeArray = GlobalSettings.get().getStringArray(LOCALES); if (localeArray == null || localeArray.length == 0) { localeArray = DEFAULT_LOCALES; } add(createLoginPanel("login-panel", autoComplete, Arrays.asList(localeArray), new LoginPluginHandler(termsAndConditions))); add(new Label("pinger")); }
From source file:org.isisaddons.wicket.pdfjs.cpt.ui.PdfJsViewerPanel.java
License:Apache License
@Override protected MarkupContainer addComponentForRegular() { MarkupContainer containerIfRegular = new WebMarkupContainer("scalarIfRegular"); addOrReplace(containerIfRegular);/*from www . ja v a2 s . c o m*/ final ObjectAdapter adapter = scalarModel.getObject(); if (adapter != null) { final PdfJsViewerFacet pdfJsViewerFacet = scalarModel.getFacet(PdfJsViewerFacet.class); final PdfJsViewerAdvisor.InstanceKey instanceKey = buildKey(); final PdfJsConfig config = pdfJsViewerFacet != null ? pdfJsViewerFacet.configFor(instanceKey) : new PdfJsConfig(); config.withDocumentUrl(urlFor(IResourceListener.INTERFACE, null)); PdfJsPanel pdfJsPanel = new PdfJsPanel(ID_SCALAR_VALUE, config); MarkupContainer prevPageButton = createComponent("prevPage", config); MarkupContainer nextPageButton = createComponent("nextPage", config); MarkupContainer currentZoomSelect = createComponent("currentZoom", config); MarkupContainer currentPageLabel = createComponent("currentPage", config); MarkupContainer totalPagesLabel = createComponent("totalPages", config); MarkupContainer currentHeightSelect = createComponent("currentHeight", config); MarkupContainer printButton = createComponent("print", config); //MarkupContainer downloadButton = createComponent("download", config); final Blob blob = getBlob(); final IResource bar = new ByteArrayResource(blob.getMimeType().getBaseType(), blob.getBytes(), blob.getName()); final ResourceLink<Void> downloadLink = new ResourceLink<>("download", bar); containerIfRegular.addOrReplace(pdfJsPanel, prevPageButton, nextPageButton, currentPageLabel, totalPagesLabel, currentZoomSelect, currentHeightSelect, printButton, downloadLink); // Label fileNameIfCompact = new Label("fileNameIfCompact", blob.getName()); // downloadLink.add(fileNameIfCompact); containerIfRegular.addOrReplace( new NotificationPanel(ID_FEEDBACK, pdfJsPanel, new ComponentFeedbackMessageFilter(pdfJsPanel))); } else { permanentlyHide(ID_SCALAR_VALUE, ID_FEEDBACK); } return containerIfRegular; }
From source file:org.isisaddons.wicket.pdfjs.cpt.ui.PdfJsViewerPanel.java
License:Apache License
@Override protected Component addComponentForCompact() { final Blob blob = getBlob(); if (blob == null) { return null; }//from w w w . ja va 2 s .c om WebMarkupContainer containerIfCompact = new WebMarkupContainer("scalarIfCompact"); addOrReplace(containerIfCompact); final IResource bar = new ByteArrayResource(blob.getMimeType().getBaseType(), blob.getBytes(), blob.getName()); final ResourceLink<Void> downloadLink = new ResourceLink<>("scalarIfCompactDownload", bar); containerIfCompact.add(downloadLink); Label fileNameIfCompact = new Label("fileNameIfCompact", blob.getName()); downloadLink.add(fileNameIfCompact); return containerIfCompact; }
From source file:org.onehippo.forge.resetpassword.frontend.ResetPassword.java
License:Apache License
/** * ResetPassword initializer./*w w w . j a va 2 s . c o m*/ * @param context plugin context * @param config plugin config */ public ResetPassword(final IPluginContext context, final IPluginConfig config) { super(context, new JavaPluginConfig(config)); configurationPath = config.getString("labels.location"); add(CssClass.append("hippo-login-plugin")); add(new Label("pageTitle", getString("page.title"))); add(new ResourceLink("faviconLink", DEFAULT_FAVICON)); final Configuration configuration = getCustomPluginUserSession(); final Map<String, String> labelsMap = configuration != null ? configuration.getLabelMap() : new HashMap<>(); final int urlDuration = configuration != null ? configuration.getDurationsMap().get(Configuration.URL_VALIDITY_IN_MINUTES).intValue() : DEFAULT_URL_VALIDITY_IN_MINUTES; final IRequestParameters requestParameters = getRequest().getQueryParameters(); final String code = requestParameters.getParameterValue(PARAM_CODE).toString(); final String uid = requestParameters.getParameterValue(PARAM_UID).toString(); final boolean hasParameters = StringUtils.isNotEmpty(code) && StringUtils.isNotEmpty(uid); final boolean autocomplete = getPluginConfig().getAsBoolean("signin.form.autocomplete", true); final PanelInfo panelInfo = new PanelInfo(autocomplete, uid, configuration, context, config); final Panel resetPasswordForm = new ResetPasswordPanel(panelInfo); resetPasswordForm.setVisible(!hasParameters); add(resetPasswordForm); final Panel setPasswordForm = new SetPasswordPanel(panelInfo, code, resetPasswordForm); setPasswordForm.setVisible(hasParameters); add(setPasswordForm); // In case of using a different edition, add extra CSS rules to show the required styling if (config.containsKey(EDITION)) { final String edition = config.getString(EDITION); editionCss = new CssResourceReference(LoginPlugin.class, "login_" + edition + ".css"); } final ExternalLink termsAndConditions = new ExternalLink("termsAndConditions", TERMS_AND_CONDITIONS_LINK) { private static final long serialVersionUID = 1L; @Override public boolean isVisible() { return UsageStatisticsSettings.get().isEnabled(); } }; termsAndConditions.setOutputMarkupId(true); add(termsAndConditions); }
From source file:org.patientview.radar.web.pages.admin.AdminConsultantsPage.java
License:Open Source License
public AdminConsultantsPage() { final ConsultantsDataProvider consultantsDataProvider = new ConsultantsDataProvider(utilityManager); add(new ResourceLink("exportPdf", RadarResourceFactory.getExportResource(exportManager.getConsultantsExportData(ExportType.PDF), "consultants" + AdminsBasePage.EXPORT_FILE_NAME_SUFFIX, ExportType.PDF))); add(new ResourceLink("exportExcel", RadarResourceFactory.getExportResource(exportManager.getConsultantsExportData(ExportType.EXCEL), "consultants" + AdminsBasePage.EXPORT_FILE_NAME_SUFFIX, ExportType.EXCEL))); add(new BookmarkablePageLink<AdminConsultantPage>("addNewConsultant", AdminConsultantPage.class)); final WebMarkupContainer consultantsContainer = new WebMarkupContainer("consultantsContainer"); consultantsContainer.setOutputMarkupId(true); add(consultantsContainer);//w w w. j a va 2s .c om final DataView<Consultant> consultantList = new DataView<Consultant>("consultants", consultantsDataProvider) { @Override protected void populateItem(Item<Consultant> item) { builtDataViewRow(item); } }; consultantList.setItemsPerPage(RESULTS_PER_PAGE); consultantsContainer.add(consultantList); // add paging element consultantsContainer .add(new RadarAjaxPagingNavigator("navigator", consultantList, consultantsDataProvider.size())); // add sort links to the table column headers for (Map.Entry<String, String> entry : getSortFields().entrySet()) { add(new SortLink(entry.getKey(), entry.getValue(), consultantsDataProvider, consultantList, Arrays.asList(consultantsContainer))); } }
From source file:org.patientview.radar.web.pages.admin.AdminPatientsPage.java
License:Open Source License
public AdminPatientsPage() { final PatientUserDataProvider patientsDataProvider = new PatientUserDataProvider(userManager); final FeedbackPanel feedback = new FeedbackPanel("feedback"); feedback.setOutputMarkupId(true);/* w w w .j av a2s . c o m*/ feedback.setOutputMarkupPlaceholderTag(true); add(feedback); // TODO: need to hook these up add(new ResourceLink("exportPdf", RadarResourceFactory.getExportResource(exportManager.getPatientsExportData(ExportType.PDF), "patients-users" + AdminsBasePage.EXPORT_FILE_NAME_SUFFIX, ExportType.PDF))); add(new ResourceLink("exportExcel", RadarResourceFactory.getExportResource(exportManager.getPatientsExportData(ExportType.EXCEL), "patients-users" + AdminsBasePage.EXPORT_FILE_NAME_SUFFIX, ExportType.EXCEL))); final WebMarkupContainer patientsContainer = new WebMarkupContainer("patientsContainer"); patientsContainer.setOutputMarkupId(true); add(patientsContainer); final DataView<PatientUser> patientList = new DataView<PatientUser>("patients", patientsDataProvider) { @Override protected void populateItem(Item<PatientUser> item) { builtDataViewRow(item, feedback); } }; patientList.setItemsPerPage(RESULTS_PER_PAGE); patientsContainer.add(patientList); // add paging element patientsContainer.add(new RadarAjaxPagingNavigator("navigator", patientList, patientsDataProvider.size())); // add sort links to the table column headers for (Map.Entry<String, String> entry : getSortFields().entrySet()) { add(new SortLink(entry.getKey(), entry.getValue(), patientsDataProvider, patientList, Arrays.asList(patientsContainer))); } }
From source file:org.patientview.radar.web.pages.admin.AdminUsersPage.java
License:Open Source License
public AdminUsersPage() { final ProfessionalUserDataProvider professionalUserDataProvider = new ProfessionalUserDataProvider( userManager);/*from ww w. ja v a 2 s . c o m*/ add(new ResourceLink("exportPdf", RadarResourceFactory.getExportResource(exportManager.getProfessionalUsersExportData(ExportType.PDF), "users" + AdminsBasePage.EXPORT_FILE_NAME_SUFFIX, ExportType.PDF))); add(new ResourceLink("exportExcel", RadarResourceFactory.getExportResource( exportManager.getProfessionalUsersExportData(ExportType.EXCEL), "users" + AdminsBasePage.EXPORT_FILE_NAME_SUFFIX, ExportType.EXCEL))); add(new BookmarkablePageLink<AdminUserPage>("addNewUser", AdminUserPage.class)); final WebMarkupContainer usersContainer = new WebMarkupContainer("usersContainer"); usersContainer.setOutputMarkupId(true); add(usersContainer); final DataView<ProfessionalUser> userList = new DataView<ProfessionalUser>("users", professionalUserDataProvider) { @Override protected void populateItem(Item<ProfessionalUser> item) { builtDataViewRow(item); } }; userList.setItemsPerPage(RESULTS_PER_PAGE); usersContainer.add(userList); // add paging element usersContainer .add(new RadarAjaxPagingNavigator("navigator", userList, professionalUserDataProvider.size())); // add sort links to the table column headers for (Map.Entry<String, String> entry : getSortFields().entrySet()) { add(new SortLink(entry.getKey(), entry.getValue(), professionalUserDataProvider, userList, Arrays.asList(usersContainer))); } // button to clear all the filter fields for each colum final ClearLink clearButton = new ClearLink("clearButton", professionalUserDataProvider, userList, usersContainer); add(clearButton); // add a search field to the top of each column - these will AND each search for (Map.Entry<String, String> entry : getFilterFields().entrySet()) { add(new SearchField(entry.getKey(), entry.getValue(), professionalUserDataProvider, userList, Arrays.asList(usersContainer, clearButton))); } // add a date filter add(new SearchDateField("searchDateRegistered", ProfessionalUserFilter.UserField.REGISTRATION_DATE.getDatabaseFieldName(), professionalUserDataProvider, userList, Arrays.asList(usersContainer, clearButton))); }