List of usage examples for org.apache.wicket.markup.html.link ExternalLink add
public MarkupContainer add(final Component... children)
From source file:com.cubeia.backoffice.web.util.ExternalLinkPanel.java
License:Open Source License
public ExternalLinkPanel(String id, String text, String toolTip, String url) { super(id);/*w ww . j av a2s . com*/ ExternalLink link = new ExternalLink("link", url); link.add(new Label("label", text)); if (toolTip != null) { link.add(new AttributeModifier("title", Model.of(toolTip))); } add(link); }
From source file:com.doculibre.constellio.wicket.panels.results.DefaultSearchResultPanel.java
License:Open Source License
public DefaultSearchResultPanel(String id, SolrDocument doc, final SearchResultsDataProvider dataProvider) { super(id);//from w w w. j a v a 2s . c om RecordCollectionServices collectionServices = ConstellioSpringUtils.getRecordCollectionServices(); RecordServices recordServices = ConstellioSpringUtils.getRecordServices(); SearchInterfaceConfigServices searchInterfaceConfigServices = ConstellioSpringUtils .getSearchInterfaceConfigServices(); String collectionName = dataProvider.getSimpleSearch().getCollectionName(); RecordCollection collection = collectionServices.get(collectionName); Record record = recordServices.get(doc); if (record != null) { SearchInterfaceConfig searchInterfaceConfig = searchInterfaceConfigServices.get(); IndexField uniqueKeyField = collection.getUniqueKeyIndexField(); IndexField defaultSearchField = collection.getDefaultSearchIndexField(); IndexField urlField = collection.getUrlIndexField(); IndexField titleField = collection.getTitleIndexField(); if (urlField == null) { urlField = uniqueKeyField; } if (titleField == null) { titleField = urlField; } final String recordURL = record.getUrl(); final String displayURL; if (record.getDisplayUrl().startsWith("/get?file=")) { HttpServletRequest req = ((WebRequest) getRequest()).getHttpServletRequest(); displayURL = ContextUrlUtils.getContextUrl(req) + record.getDisplayUrl(); } else { displayURL = record.getDisplayUrl(); } String title = record.getDisplayTitle(); final String protocol = StringUtils.substringBefore(displayURL, ":"); boolean linkEnabled = isLinkEnabled(protocol); // rcupration des champs highlight partir de la cl unique // du document, dans le cas de Nutch c'est l'URL QueryResponse response = dataProvider.getQueryResponse(); Map<String, Map<String, List<String>>> highlighting = response.getHighlighting(); Map<String, List<String>> fieldsHighlighting = highlighting.get(recordURL); String titleHighlight = getTitleFromHighlight(titleField.getName(), fieldsHighlighting); if (titleHighlight != null) { title = titleHighlight; } String excerpt = null; String description = getDescription(record); String summary = getSummary(record); if (StringUtils.isNotBlank(description) && searchInterfaceConfig.isDescriptionAsExcerpt()) { excerpt = description; } else { excerpt = getExcerptFromHighlight(defaultSearchField.getName(), fieldsHighlighting); if (excerpt == null) { excerpt = description; } } toggleSummaryLink = new WebMarkupContainer("toggleSummaryLink"); add(toggleSummaryLink); toggleSummaryLink.setVisible(StringUtils.isNotBlank(summary)); toggleSummaryLink.add(new AttributeModifier("onclick", new LoadableDetachableModel() { @Override protected Object load() { return "toggleSearchResultSummary('" + summaryLabel.getMarkupId() + "')"; } })); summaryLabel = new Label("summary", summary); add(summaryLabel); summaryLabel.setOutputMarkupId(true); summaryLabel.setVisible(StringUtils.isNotBlank(summary)); ExternalLink titleLink; if (displayURL.startsWith("file://")) { HttpServletRequest req = ((WebRequest) getRequest()).getHttpServletRequest(); String newDisplayURL = ContextUrlUtils.getContextUrl(req) + "app/getSmbFile?" + SmbServletPage.RECORD_ID + "=" + record.getId() + "&" + SmbServletPage.COLLECTION + "=" + collectionName; titleLink = new ExternalLink("titleLink", newDisplayURL); } else { titleLink = new ExternalLink("titleLink", displayURL); } final RecordModel recordModel = new RecordModel(record); AttributeModifier computeClickAttributeModifier = new AttributeModifier("onmousedown", true, new LoadableDetachableModel() { @Override protected Object load() { Record record = recordModel.getObject(); SimpleSearch simpleSearch = dataProvider.getSimpleSearch(); WebRequest webRequest = (WebRequest) RequestCycle.get().getRequest(); HttpServletRequest httpRequest = webRequest.getHttpServletRequest(); return ComputeSearchResultClickServlet.getCallbackJavascript(httpRequest, simpleSearch, record); } }); titleLink.add(computeClickAttributeModifier); titleLink.setEnabled(linkEnabled); boolean resultsInNewWindow; PageParameters params = RequestCycle.get().getPageParameters(); if (params != null && params.getString(POPUP_LINK) != null) { resultsInNewWindow = params.getBoolean(POPUP_LINK); } else { resultsInNewWindow = searchInterfaceConfig.isResultsInNewWindow(); } titleLink.add(new SimpleAttributeModifier("target", resultsInNewWindow ? "_blank" : "_self")); // Add title title = StringUtils.remove(title, "\n"); title = StringUtils.remove(title, "\r"); if (StringUtils.isEmpty(title)) { title = StringUtils.defaultString(displayURL); title = StringUtils.substringAfterLast(title, "/"); title = StringUtils.substringBefore(title, "?"); try { title = URLDecoder.decode(title, "UTF-8"); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } if (title.length() > 120) { title = title.substring(0, 120) + " ..."; } } Label titleLabel = new Label("title", title); titleLink.add(titleLabel.setEscapeModelStrings(false)); add(titleLink); Label excerptLabel = new Label("excerpt", excerpt); add(excerptLabel.setEscapeModelStrings(false)); // add(new ExternalLink("url", url, // url).add(computeClickAttributeModifier).setEnabled(linkEnabled)); if (displayURL.startsWith("file://")) { // Creates a Windows path for file URLs String urlLabel = StringUtils.substringAfter(displayURL, "file:"); urlLabel = StringUtils.stripStart(urlLabel, "/"); urlLabel = "\\\\" + StringUtils.replace(urlLabel, "/", "\\"); try { urlLabel = URLDecoder.decode(urlLabel, "UTF-8"); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } add(new Label("url", urlLabel)); } else { add(new Label("url", displayURL)); } final ReloadableEntityModel<RecordCollection> collectionModel = new ReloadableEntityModel<RecordCollection>( collection); add(new ListView("searchResultFields", new LoadableDetachableModel() { @Override protected Object load() { RecordCollection collection = collectionModel.getObject(); return collection.getSearchResultFields(); } /** * Detaches from the current request. Implement this method with * custom behavior, such as setting the model object to null. */ protected void onDetach() { recordModel.detach(); collectionModel.detach(); } }) { @Override protected void populateItem(ListItem item) { SearchResultField searchResultField = (SearchResultField) item.getModelObject(); IndexFieldServices indexFieldServices = ConstellioSpringUtils.getIndexFieldServices(); Record record = recordModel.getObject(); IndexField indexField = searchResultField.getIndexField(); Locale locale = getLocale(); String indexFieldTitle = indexField.getTitle(locale); if (StringUtils.isBlank(indexFieldTitle)) { indexFieldTitle = indexField.getName(); } StringBuffer fieldValueSb = new StringBuffer(); List<Object> fieldValues = indexFieldServices.extractFieldValues(record, indexField); Map<String, String> defaultLabelledValues = indexFieldServices .getDefaultLabelledValues(indexField, locale); for (Object fieldValue : fieldValues) { if (fieldValueSb.length() > 0) { fieldValueSb.append("\n"); } String fieldValueLabel = indexField.getLabelledValue("" + fieldValue, locale); if (fieldValueLabel == null) { fieldValueLabel = defaultLabelledValues.get("" + fieldValue); } if (fieldValueLabel == null) { fieldValueLabel = "" + fieldValue; } fieldValueSb.append(fieldValueLabel); } item.add(new Label("indexField", indexFieldTitle)); item.add(new MultiLineLabel("indexFieldValue", fieldValueSb.toString())); item.setVisible(fieldValueSb.length() > 0); } @SuppressWarnings("unchecked") @Override public boolean isVisible() { boolean visible = super.isVisible(); if (visible) { List<SearchResultField> searchResultFields = (List<SearchResultField>) getModelObject(); visible = !searchResultFields.isEmpty(); } return visible; } }); // md5 ConstellioSession session = ConstellioSession.get(); ConstellioUser user = session.getUser(); // TODO Provide access to unauthenticated users ? String md5 = ""; if (user != null) { IntelliGIDServiceInfo intelligidServiceInfo = ConstellioSpringUtils.getIntelliGIDServiceInfo(); if (intelligidServiceInfo != null) { Collection<Object> md5Coll = doc.getFieldValues(IndexField.MD5); if (md5Coll != null) { for (Object md5Obj : md5Coll) { try { String md5Str = new String(Hex.encodeHex(Base64.decodeBase64(md5Obj.toString()))); InputStream is = HttpClientHelper .get(intelligidServiceInfo.getIntelligidUrl() + "/connector/checksum", "md5=" + URLEncoder.encode(md5Str, "ISO-8859-1"), "username=" + URLEncoder.encode(user.getUsername(), "ISO-8859-1"), "password=" + URLEncoder.encode(Base64.encodeBase64String( ConstellioSession.get().getPassword().getBytes())), "ISO-8859-1"); try { Document xmlDocument = new SAXReader().read(is); Element root = xmlDocument.getRootElement(); for (Iterator<Element> it = root.elementIterator("fichier"); it.hasNext();) { Element fichier = it.next(); String url = fichier.attributeValue("url"); md5 += "<a href=\"" + url + "\">" + url + "</a> "; } } finally { IOUtils.closeQuietly(is); } } catch (Exception e) { e.printStackTrace(); } } } } } Label md5Label = new Label("md5", md5) { public boolean isVisible() { boolean visible = super.isVisible(); if (visible) { visible = StringUtils.isNotBlank(this.getModelObjectAsString()); } return visible; } }; md5Label.setEscapeModelStrings(false); add(md5Label); add(new ElevatePanel("elevatePanel", record, dataProvider.getSimpleSearch())); } else { setVisible(false); } }
From source file:com.francetelecom.clara.cloud.presentation.common.Footer.java
License:Apache License
public void initComponents() { ExternalLink contactUsLink = new ExternalLink("contactUsLink", "mailto:" + contactUsBean.getMailTo()); contactUsLink.add(new Label("contactUsLabel", getStringResourceModel("portal.design.footer.contact.us"))); add(contactUsLink);/* w w w . jav a2s.c o m*/ ExternalLink helpLink = new ExternalLink("helpLink", getStringResourceModel("portal.design.footer.help.link")); Label helpLinkLabel = new Label("helpLinkLabel", getStringResourceModel("portal.design.footer.help")); helpLink.add(helpLinkLabel); add(helpLink); boolean mock = Boolean.valueOf(WicketApplication.get().getInitParameter("mockMode")); String version = "version " + getString("portal.build.version"); String completeVersion = mock ? version + " (mock)" : version; Label versionLabel = new Label("version", completeVersion); versionLabel.add(new AttributeModifier("title", getString("portal.build.timestamp") + " " + getString("portal.build.user"))); add(versionLabel); }
From source file:com.francetelecom.clara.cloud.presentation.HomePage.java
License:Apache License
private ExternalLink getHypericExternalLink() { String hypericPortalUrl = hypericBean.getServerURL(); ExternalLink hypericPortalLink = new ExternalLink("hyperic-portal-url", hypericPortalUrl); hypericPortalLink .add(new CacheActivatedImage("image.monitoring_info_icon", getString("monitoring_info_icon"))); hypericPortalLink.add(new AttributeModifier("title", new Model<String>(getString("portal.design.fun.monitorinfo.title")))); hypericPortalLink.add(/* ww w. ja v a 2 s .co m*/ new AttributeModifier("alt", new Model<String>(getString("portal.design.fun.monitorinfo.title")))); return hypericPortalLink; }
From source file:com.francetelecom.clara.cloud.presentation.HomePage.java
License:Apache License
private ExternalLink getSplunkExternalLink() { String splunkServerUrl = splunkBean.getServerURL(); ExternalLink externalLink = new ExternalLink("splunk-access-url", splunkServerUrl); externalLink.add(new CacheActivatedImage("image.splunk_info_icon", getString("splunk_info_icon"))); externalLink.add(//from w ww . j a va 2 s. c o m new AttributeModifier("title", new Model<String>(getString("portal.design.fun.logsinfo.title")))); externalLink .add(new AttributeModifier("alt", new Model<String>(getString("portal.design.fun.logsinfo.alt")))); return externalLink; }
From source file:com.gitblit.wicket.pages.DocsPage.java
License:Apache License
public DocsPage(PageParameters params) { super(params); String objectId = WicketUtils.getObject(params); MarkupProcessor processor = new MarkupProcessor(app().settings(), app().xssFilter()); Repository r = getRepository();/*from ww w . j a v a 2 s . co m*/ UserModel currentUser = (GitBlitWebSession.get().getUser() != null) ? GitBlitWebSession.get().getUser() : UserModel.ANONYMOUS; final boolean userCanEdit = currentUser.canEdit(getRepositoryModel()); RevCommit head = JGitUtils.getCommit(r, objectId); final String commitId = getBestCommitId(head); List<String> extensions = processor.getAllExtensions(); List<PathModel> paths = JGitUtils.getDocuments(r, extensions); List<MarkupDocument> roots = processor.getRootDocs(r, repositoryName, commitId); Fragment fragment = null; if (roots.isEmpty()) { // no identified root documents fragment = new Fragment("docs", "noIndexFragment", DocsPage.this); setResponsePage(NoDocsPage.class, params); } else { // root documents, use tabbed ui of index/root and document list fragment = new Fragment("docs", "tabsFragment", DocsPage.this); ListDataProvider<MarkupDocument> docDp = new ListDataProvider<MarkupDocument>(roots); // tab titles DataView<MarkupDocument> tabTitles = new DataView<MarkupDocument>("tabTitle", docDp) { private static final long serialVersionUID = 1L; int counter; @Override public void populateItem(final Item<MarkupDocument> item) { MarkupDocument doc = item.getModelObject(); String file = StringUtils.getLastPathElement(doc.documentPath); file = StringUtils.stripFileExtension(file); String name = file.replace('_', ' ').replace('-', ' '); ExternalLink link = new ExternalLink("link", "#" + file); link.add(new Label("label", name.toUpperCase()).setRenderBodyOnly(true)); item.add(link); if (counter == 0) { counter++; item.add(new AttributeModifier("class", "active")); } } }; fragment.add(tabTitles); // tab content DataView<MarkupDocument> tabsView = new DataView<MarkupDocument>("tabContent", docDp) { private static final long serialVersionUID = 1L; int counter; @Override public void populateItem(final Item<MarkupDocument> item) { MarkupDocument doc = item.getModelObject(); item.add(new BookmarkablePageLink<Void>("editLink", EditFilePage.class, WicketUtils.newPathParameter(repositoryName, commitId, doc.documentPath)) .setEnabled(userCanEdit)); // document page links item.add(new BookmarkablePageLink<Void>("blameLink", BlamePage.class, WicketUtils.newPathParameter(repositoryName, commitId, doc.documentPath))); item.add(new BookmarkablePageLink<Void>("historyLink", HistoryPage.class, WicketUtils.newPathParameter(repositoryName, commitId, doc.documentPath))); String rawUrl = RawServlet.asLink(getContextUrl(), repositoryName, commitId, doc.documentPath); item.add(new ExternalLink("rawLink", rawUrl)); // document content String file = StringUtils.getLastPathElement(doc.documentPath); file = StringUtils.stripFileExtension(file); Component content = new Label("content", doc.html).setEscapeModelStrings(false); if (!MarkupSyntax.PLAIN.equals(doc.syntax)) { content.add(new AttributeModifier("class", "markdown")); } item.add(content); item.add(new AttributeModifier("id", file)); if (counter == 0) { counter++; item.add(new AttributeModifier("class", "tab-pane active")); } } }; fragment.add(tabsView); } // document list final ByteFormat byteFormat = new ByteFormat(); Fragment docs = new Fragment("documents", "documentsFragment", DocsPage.this); ListDataProvider<PathModel> pathsDp = new ListDataProvider<PathModel>(paths); DataView<PathModel> pathsView = new DataView<PathModel>("document", pathsDp) { private static final long serialVersionUID = 1L; int counter; @Override public void populateItem(final Item<PathModel> item) { PathModel entry = item.getModelObject(); item.add(WicketUtils.newImage("docIcon", "file_world_16x16.png")); item.add(new Label("docSize", byteFormat.format(entry.size))); item.add(new LinkPanel("docName", "list", StringUtils.stripFileExtension(entry.name), DocPage.class, WicketUtils.newPathParameter(repositoryName, commitId, entry.path))); // links item.add(new BookmarkablePageLink<Void>("view", DocPage.class, WicketUtils.newPathParameter(repositoryName, commitId, entry.path))); item.add(new BookmarkablePageLink<Void>("edit", EditFilePage.class, WicketUtils.newPathParameter(repositoryName, commitId, entry.path)) .setEnabled(userCanEdit)); String rawUrl = RawServlet.asLink(getContextUrl(), repositoryName, commitId, entry.path); item.add(new ExternalLink("raw", rawUrl)); item.add(new BookmarkablePageLink<Void>("blame", BlamePage.class, WicketUtils.newPathParameter(repositoryName, commitId, entry.path))); item.add(new BookmarkablePageLink<Void>("history", HistoryPage.class, WicketUtils.newPathParameter(repositoryName, commitId, entry.path))); WicketUtils.setAlternatingBackground(item, counter); counter++; } }; docs.add(pathsView); fragment.add(docs); add(fragment); }
From source file:com.gitblit.wicket.panels.LinkPanel.java
License:Apache License
public LinkPanel(String wicketId, String linkCssClass, String label, String href, boolean newWindow) { super(wicketId); this.labelModel = new Model<String>(label); ExternalLink link = new ExternalLink("link", href); if (newWindow) { link.add(new AttributeModifier("target", "_blank")); }//from w w w . ja v a 2s . com if (linkCssClass != null) { link.add(new AttributeModifier("class", linkCssClass)); } link.add(new Label("icon").setVisible(false)); link.add(new Label("label", labelModel)); add(link); }
From source file:com.marc.lastweek.web.components.classifiedaddetails.ClassifiedAdDetailPanel.java
License:Open Source License
public ClassifiedAdDetailPanel(String id, final Long classifiedAdId) { super(id);/*from w w w .j a va 2 s .c o m*/ add(HeaderContributor.forJavaScript(SLIDER_URL)); final ClassifiedAd classifiedAd = LastweekApplication.get().getGeneralService().find(ClassifiedAd.class, classifiedAdId); final String title = classifiedAd.getTitle(); final String description = classifiedAd.getDescription(); final Double price = classifiedAd.getPrice(); final Integer flag = classifiedAd.getFlag(); final Integer state = classifiedAd.getState(); final String hashCode = classifiedAd.getHashCode(); final int sourceCode = classifiedAd.getSource().intValue(); final Calendar publicationDate = classifiedAd.getPublicationDate(); Folder imageFolder = LastweekApplication.get().getImageService().findFolderFromName(hashCode); List<File> images = LastweekApplication.get().getImageService().getAllTemporalFiles(imageFolder); if (images.size() != 0) { // final File file = images.get(0); // this.add(new ClassifiedAdImagePanel("imagePanel", file)); this.add(new JQueryImagegallery("gallery", images)); } else { // this.add(new Label("imagePanel", new // Model("No hay fotos disponibles"))); this.add(new Label("gallery", new Model("No hay fotos disponibles"))); } // TODO: add image, add province and category this.add(new Label("classifiedAdPublicationDate", ViewUtils.labelizer(DateUtils.getDaysFromThen(publicationDate)))); this.add(new Label("classifiedAdTitle", ViewUtils.labelizer(title))); this.add(new Label("classifiedAdDescription", ViewUtils.labelizer(description)) .setEscapeModelStrings(false)); this.add(new Label("classifiedAdPrice", ViewUtils.labelizer(price))); this.add(new Label("provinceName", ViewUtils.labelizer(classifiedAd.getProvince().getName()))); this.add(new Label("categoryName", ViewUtils.labelizer(classifiedAd.getCategory().getName()))); this.add(new Label("subcategoryName", ViewUtils.labelizer(classifiedAd.getSubcategory().getName()))); this.add(new Link("classifiedAdDescriptionLink") { private static final long serialVersionUID = 7411597974910148218L; @Override public void onClick() { // TODO: add onClick } }); final ContactPanel contactPanel = new ContactPanel("contactPanel", null, classifiedAdId); this.add(contactPanel); contactPanel.setOutputMarkupId(true); this.add(new Link("classifiedAdContactLink") { private static final long serialVersionUID = -4262681914874430193L; @Override public void onClick() { // TODO: add onClick } }); // this.add(new Label("userDataEmail", ViewUtils.labelizer(classifiedAd // .getUserData().getEmail()))); this.add(new Label("userDataName", ViewUtils.labelizer(classifiedAd.getUserData().getName()))); WebMarkupContainer showPhoneDiv = new WebMarkupContainer("showPhoneDiv"); showPhoneDiv.setVisible(classifiedAd.getShowPhone().booleanValue()); Label phone = new Label("userDataPhone", ViewUtils.labelizer(classifiedAd.getUserData().getPhone())); showPhoneDiv.add(phone); this.add(showPhoneDiv); ExternalLink classifiedAdSourceLink = new ExternalLink("classifiedAdSourceLink", classifiedAd.getSourceURL()) { private static final long serialVersionUID = -5872308114085631059L; @Override public boolean isVisible() { if (sourceCode == ClassifiedAd.SOURCE_OUR) return false; return true; } }; classifiedAdSourceLink.add(new Label("classifiedAdSource", ViewUtils.labelizer(CommonNamingValues.getSourceName(classifiedAd.getSource())))); this.add(classifiedAdSourceLink); // TODO: Put strings in properties files final Label flagClassifiedAdLabel = new Label("flagClassifiedAdSpan", "Marcar anuncio como inapropiado"); Link flagClassifiedAdLink = new Link("flagClassifiedAdLink") { private static final long serialVersionUID = -4262681914874430193L; @Override public void onClick() { ModifiedClassifiedAdTO modifiedClassifiedAdTO = new ModifiedClassifiedAdTO(classifiedAdId, title, description, price, Integer.valueOf(flag.intValue() + 1), state, hashCode); LastweekApplication.get().getGeneralService().modify(ClassifiedAd.class, modifiedClassifiedAdTO); this.setEnabled(false); this.setVisible(false); info("El anuncio ha sido marcado como inapropiado."); } }; flagClassifiedAdLink.add(flagClassifiedAdLabel); this.add(flagClassifiedAdLink); Link addToFavoritesLink = new Link("addToFavoritesLink") { private static final long serialVersionUID = 8340452899324058655L; @Override public void onClick() { LastweekSession.get().addFavorite(classifiedAdId); info("Anuncio aadido a favoritos"); this.setVisible(false); } @Override public boolean isVisible() { if (LastweekSession.get().containsFavorite(classifiedAdId)) return false; return true; } }; this.add(addToFavoritesLink); }
From source file:com.norconex.commons.wicket.bootstrap.table.BootstrapPagingNavigator.java
License:Apache License
@Override protected AbstractLink newPagingNavigationLink(String id, IPageable pageable, int pageNumber) { ExternalLink navCont = new ExternalLink(id + "Cont", (String) null); // add css for enable/disable link long pageIndex = pageable.getCurrentPage() + pageNumber; navCont.add(new AttributeModifier("class", new BootstrapPageLinkCssModel(pageable, pageIndex, "disabled"))); // change original wicket-link, so that it always generates href navCont.add(new PagingNavigationLink<Void>(id, pageable, pageNumber)); return navCont; }
From source file:com.norconex.commons.wicket.bootstrap.table.BootstrapPagingNavigator.java
License:Apache License
@Override protected AbstractLink newPagingNavigationIncrementLink(String id, IPageable pageable, int increment) { ExternalLink navCont = new ExternalLink(id + "Cont", (String) null); // add css for enable/disable link long pageIndex = pageable.getCurrentPage() + increment; navCont.add(new AttributeModifier("class", new BootstrapPageLinkIncrementCssModel(pageable, pageIndex))); // change original wicket-link, so that it always generates href navCont.add(new PagingNavigationIncrementLink<Void>(id, pageable, increment)); return navCont; }