List of usage examples for org.apache.wicket.markup.html.link Link setEnabled
public final Component setEnabled(final boolean enabled)
From source file:com.cubeia.backoffice.web.MenuPanel.java
License:Open Source License
@SuppressWarnings("serial") public MenuPanel(String id, BasePage currentPage) { super(id);//from www . j a va 2 s. c om Class<? extends BasePage> currentPageClass = currentPage.getClass(); add(createPageLink("homePage", Home.class, currentPageClass)); add(createPageLink("userListPage", UserList.class, currentPageClass)); add(createPageLink("createUserPage", CreateUser.class, currentPageClass)); add(createPageLink("accountListPage", AccountList.class, currentPageClass)); add(createPageLink("createAccountPage", CreateAccount.class, currentPageClass)); add(createPageLink("createTransactionPage", CreateTransaction.class, currentPageClass)); add(createPageLink("currenciesPage", EditCurrencies.class, currentPageClass)); add(createPageLink("transactionListPage", TransactionList.class, currentPageClass)); add(createPageLink("operatorListPage", OperatorList.class, currentPageClass)); add(createPageLink("createOperatorPage", CreateOperator.class, currentPageClass)); // add(createPageLink("reportsPage", Reports.class, currentPageClass)); String signedInMessage; String signInOutMessage; Link<Void> signInOutLink; BackofficeAuthSession session = currentPage.getBackofficeSession(); if (session.isSignedIn()) { signedInMessage = "Logged in as " + session.getUserName(); signInOutMessage = "log out"; signInOutLink = new BookmarkablePageLink<Void>("signInOutLink", BackofficeSignOutPage.class); } else { signedInMessage = "Not logged in."; signInOutMessage = "log in"; // TODO: make this a panel signInOutLink = new BookmarkablePageLink<Void>("signInOutLink", Home.class); signInOutLink.setEnabled(false); signInOutLink.add(AttributeModifier.replace("style", "display: none;")); } signInOutLink.add(new Label("signInOutMessage", signInOutMessage)); add(signInOutLink); add(new Label("signedInMessage", signedInMessage)); // create external links List<String> extKeys = new ArrayList<String>(); if (externalMenuLinks != null) { extKeys.addAll(externalMenuLinks.keySet()); } Collections.sort(extKeys); add(new ListView<String>("externalLinkList", extKeys) { @Override protected void populateItem(ListItem<String> item) { String linkText = item.getModelObject(); String url = externalMenuLinks.get(linkText); item.add(new ExternalLink("link", url, linkText)); } }); }
From source file:com.doculibre.constellio.wicket.panels.results.tagging.SearchResultTaggingPanel.java
License:Open Source License
public SearchResultTaggingPanel(String id, final SolrDocument doc, final IDataProvider dataProviderParam) { super(id);//from w w w . ja v a2s. c om RecordCollectionServices collectionServices = ConstellioSpringUtils.getRecordCollectionServices(); final SimpleSearch simpleSearch; if (dataProviderParam instanceof FacetsDataProvider) { FacetsDataProvider dataProvider = (FacetsDataProvider) dataProviderParam; simpleSearch = dataProvider.getSimpleSearch(); } else { SearchResultsDataProvider dataProvider = (SearchResultsDataProvider) dataProviderParam; simpleSearch = dataProvider.getSimpleSearch(); } String collectionName = simpleSearch.getCollectionName(); RecordCollection collection = collectionServices.get(collectionName); if (!collection.isOpenSearch()) { RecordServices recordServices = ConstellioSpringUtils.getRecordServices(); Record record = recordServices.get(doc); recordModel = new RecordModel(record); final ModalWindow taggingModal = new ModalWindow("taggingModal"); taggingModal.setTitle(new StringResourceModel("tags", this, null)); taggingModal.setCssClassName(ModalWindow.CSS_CLASS_GRAY); taggingModal.setInitialWidth(800); taggingModal.setInitialHeight(450); taggingModal.setCloseButtonCallback(new CloseButtonCallback() { @Override public boolean onCloseButtonClicked(AjaxRequestTarget target) { target.addComponent(SearchResultTaggingPanel.this); return true; } }); add(taggingModal); IModel thesaurusListModel = new LoadableDetachableModel() { @Override protected Object load() { List<Thesaurus> thesaurusList = new ArrayList<Thesaurus>(); RecordCollectionServices collectionServices = ConstellioSpringUtils .getRecordCollectionServices(); String collectionName = simpleSearch.getCollectionName(); RecordCollection collection = collectionServices.get(collectionName); thesaurusList.add(null);// free text tags if (collection.getThesaurus() != null) { thesaurusList.add(collection.getThesaurus()); } return thesaurusList; } }; add(new ListView("taggingLinks", thesaurusListModel) { @Override protected void populateItem(ListItem item) { Thesaurus thesaurus = (Thesaurus) item.getModelObject(); final ReloadableEntityModel<Thesaurus> thesaurusModel = new ReloadableEntityModel<Thesaurus>( thesaurus); final String thesaurusName; if (thesaurus == null) { thesaurusName = getLocalizer().getString("tags", this); } else { thesaurusName = getLocalizer().getString("thesaurus", this); } AjaxLink link = new AjaxLink("taggingLink") { @Override public void onClick(AjaxRequestTarget target) { Thesaurus thesaurus = thesaurusModel.getObject(); SearchResultEditTaggingPanel editTaggingPanel = new SearchResultEditTaggingPanel( taggingModal.getContentId(), doc, dataProviderParam, thesaurus); taggingModal.setContent(editTaggingPanel); taggingModal.show(target); } @Override public boolean isEnabled() { boolean enabled = super.isEnabled(); if (enabled) { Record record = recordModel.getObject(); if (record != null) { ConstellioUser user = ConstellioSession.get().getUser(); if (user != null) { RecordCollection collection = record.getConnectorInstance() .getRecordCollection(); enabled = user.hasCollaborationPermission(collection); } else { enabled = false; } } else { enabled = false; } } return enabled; } @Override public void detachModels() { thesaurusModel.detach(); super.detachModels(); } }; item.add(link); link.add(new Label("thesaurusName", thesaurusName)); final IModel tagsModel = new LoadableDetachableModel() { @Override protected Object load() { Record record = recordModel.getObject(); Thesaurus thesaurus = thesaurusModel.getObject(); return new ArrayList<RecordTag>(record.getIncludedRecordTags(thesaurus)); } }; item.add(new ListView("tags", tagsModel) { @SuppressWarnings("unchecked") @Override protected void populateItem(ListItem item) { RecordTag recordTag = (RecordTag) item.getModelObject(); final RecordTagModel recordTagModel = new RecordTagModel(recordTag); Link addTagLink = new Link("addTagLink") { @Override public void onClick() { RecordTag recordTag = recordTagModel.getObject(); SimpleSearch clone = simpleSearch.clone(); clone.getTags().add(recordTag.getName(getLocale())); PageFactoryPlugin pageFactoryPlugin = PluginFactory .getPlugin(PageFactoryPlugin.class); if (StringUtils.isNotBlank(clone.getLuceneQuery())) { // ConstellioSession.get().addSearchHistory(clone); setResponsePage(pageFactoryPlugin.getSearchResultsPage(), SearchResultsPage.getParameters(clone)); } else { SimpleSearch newSearch = new SimpleSearch(); newSearch.setCollectionName(simpleSearch.getCollectionName()); newSearch.setSingleSearchLocale(simpleSearch.getSingleSearchLocale()); setResponsePage(pageFactoryPlugin.getSearchFormPage(), SearchFormPage.getParameters(newSearch)); } } @Override public void detachModels() { recordTagModel.detach(); super.detachModels(); } }; item.add(addTagLink); List<RecordTag> recordTags = (List<RecordTag>) tagsModel.getObject(); String tag = recordTag.getName(getLocale()); if (item.getIndex() < recordTags.size() - 1) { tag += ";"; } addTagLink.add(new Label("tag", tag)); addTagLink.setEnabled(false); } }); item.add(new WebMarkupContainer("noTags") { @SuppressWarnings("unchecked") @Override public boolean isVisible() { List<RecordTag> recordTags = (List<RecordTag>) tagsModel.getObject(); return super.isVisible() && recordTags.isEmpty(); } }); } }); } else { setVisible(false); } }
From source file:com.doculibre.constellio.wicket.panels.thesaurus.SkosConceptModalPanel.java
License:Open Source License
protected AbstractLink newDetailsLink(String id, SkosConcept skosConcept) { Link link = new Link(id) { @Override//from ww w .j a v a 2 s. c om public void onClick() { } }; link.setEnabled(false); return link; }
From source file:com.senacor.wbs.web.core.layout.Header.java
License:Apache License
public Header(final String id, final IModel titleModel, final IModel subTitleModel) { super(id);/*from w w w . j a v a 2 s.c o m*/ setRenderBodyOnly(true); add(new Label("title", titleModel)); add(new Label("subtitle", subTitleModel)); Link deLink = new Link("langde") { @Override public void onClick() { getSession().setLocale(Locale.GERMANY); } }; deLink.add(new AttributeModifier("title", true, new Model(Locale.GERMANY.getDisplayName(Locale.GERMANY)))); add(deLink); Link usLink = new Link("langus") { @Override public void onClick() { getSession().setLocale(Locale.US); } }; usLink.add(new AttributeModifier("title", true, new Model(Locale.US.getDisplayName(Locale.US)))); add(usLink); Link frLink = new Link("langfr") { @Override public void onClick() { getSession().setLocale(Locale.FRANCE); } }; frLink.add(new AttributeModifier("title", true, new Model(Locale.FRANCE.getDisplayName(Locale.FRANCE)))); frLink.setEnabled(false); Image inactiveFrImage = new Image("imgFrance"); frLink.add(inactiveFrImage); add(frLink); try { add(new AuthenticationStatePanel("loginPanel")); } catch (IllegalStateException e) { add(new Label("loginPanel")); } add(new ExternalLink("contactLink", new Model("http://www.senacor.de"), new ResourceModel("contact.link.label"))); add(new ExternalLink("imprintLink", new Model("http://www.senacor.de"), new ResourceModel("imprint.link.label"))); }
From source file:com.tysanclan.site.projectewok.pages.member.ProposeAchievementPage.java
License:Open Source License
private ListView<List<Long>> getIconListview(String id, List<AchievementIcon> icons, final IconClickResponder responder) { List<List<Long>> pagedList = new ArrayList<List<Long>>(1 + icons.size() / 5); for (int i = 0; i < icons.size(); i += 5) { int remaining = icons.size() - i; int limit = icons.size(); if (remaining > 5) { limit = i + 5;/*w w w. j ava 2 s .c o m*/ } List<Long> next = new ArrayList<Long>(limit - i); for (int j = i; j < limit; j++) { next.add(icons.get(j).getId()); } pagedList.add(next); } return new ListView<List<Long>>(id, pagedList) { private static final long serialVersionUID = 1L; @SpringBean private AchievementIconDAO iconDAO; @Override protected void populateItem(final ListItem<List<Long>> item) { item.add(new ListView<Long>("sublist", item.getModelObject()) { private static final long serialVersionUID = 1L; @Override protected void populateItem(final ListItem<Long> innerItem) { AchievementIcon icon = iconDAO.load(innerItem.getModelObject()); Link<AchievementIcon> iconLink = new Link<AchievementIcon>("iconLink", ModelMaker.wrap(icon)) { private static final long serialVersionUID = 1L; @Override public void onClick() { if (responder != null) { responder.onClick(getModelObject()); } } }; iconLink.setEnabled(responder != null); iconLink.setRenderBodyOnly(responder == null); iconLink.add(new Image("icon", new StoredImageResource(icon.getImage()))); innerItem.add(iconLink); } }); } }; }
From source file:cz.zcu.kiv.eegdatabase.wui.ui.search.SearchFacets.java
License:Apache License
public SearchFacets(String id, StringValue searchStringValue, final ResultCategory resultCategory) { super(id);//from w w w .j a va 2 s .c o m this.searchString = searchStringValue.toString(); this.resultCategory = resultCategory; categories = new ArrayList<FacetCategory>(); Map<String, Long> facets = searchService.getCategoryFacets(this.searchString); for (Map.Entry<String, Long> entry : facets.entrySet()) { if (entry.getValue() > 0) { FacetCategory facetCategory = new FacetCategory(entry.getKey(), entry.getValue()); categories.add(facetCategory); } } Collections.sort(categories); add(new ListView<FacetCategory>("categoryList", categories) { @Override protected void populateItem(ListItem<FacetCategory> category) { PageParameters pageParameters = new PageParameters(); pageParameters.add("searchString", searchString); pageParameters.add("category", category.getModelObject().getName()); String categoryName = getPropertyForType(category.getModelObject().getName()); String categoryValue = categoryName + " (" + category.getModelObject().getCount() + ")"; Link link = new BookmarkablePageLink<Void>("category", SearchPage.class, pageParameters); if (resultCategory != null && category.getModelObject().getName().equals(resultCategory.getValue())) { link.setEnabled(false); } category.add(link.add(new Label("categoryName", categoryValue))); } }); }
From source file:de.jetwick.ese.ui.FacetPanel.java
License:Apache License
public FacetPanel(String id) { super(id);/*from w ww .j a v a 2s .c o m*/ tr.put("userName", "User"); tagView = new ListView("filterNames", normalFacetFields) { @Override public void populateItem(final ListItem item) { final Entry<String, List<FacetHelper>> entry = (Entry<String, List<FacetHelper>>) item .getModelObject(); String keyValue = translate(entry.getKey()); String filter = getFilterName(entry.getKey()); if (filter != null) { item.add(new LabeledLink("filterName", "< " + keyValue) { @Override public void onClick(AjaxRequestTarget target) { onFacetChange(target, entry.getKey(), null, true); } }.add(new AttributeAppender("title", new Model("Remove all filters from '" + keyValue + "'"), " "))); } else item.add(new Label("filterName", keyValue)); item.add(new ListView("filterValues", entry.getValue()) { @Override protected void populateItem(ListItem li) { final FacetHelper h = (FacetHelper) li.getModelObject(); final String filter = h.getFilter(); final boolean selected = alreadyFiltered.contains(filter); Link link = new IndicatingAjaxFallbackLink("filterValueLink") { @Override public void onClick(AjaxRequestTarget target) { onFacetChange(target, h.key, h.value, selected); } }; // change style if filter is selected if (selected) link.add(new AttributeAppender("class", new Model("filter-rm"), " ")); else link.add(new AttributeAppender("class", new Model("filter-add"), " ")); link.add(new Label("filterValue", h.displayName)); // not clickable if filter would result in 0 docs if (h.count == 0) { link.setEnabled(false); link.add(new AttributeAppender("class", new Model("gray"), " ")); } li.add(new Label("filterCount", " (" + h.count + ")")); li.add(link); } }); } }; add(tagView); }
From source file:de.jetwick.ui.FacetPanel.java
License:Apache License
public FacetPanel(String id) { super(id);//from ww w . ja va 2 s . c o m // No Massive Tweeter tr.put(USER, "Tweeters"); tr.put("loc", "Location"); tr.put(DATE, "Date"); tr.put(LANG, "Language"); tr.put(IS_RT, "Content"); tr.put(IS_RT + ":true", "retweet"); tr.put(IS_RT + ":false", "original"); tr.put(DUP_COUNT, "Duplicates"); tr.put(FILTER_NO_DUPS, "without"); tr.put(FILTER_ONLY_DUPS, "only duplicated"); tr.put(URL_COUNT, "Links"); tr.put(FILTER_URL_ENTRY, "with"); tr.put(FILTER_NO_URL_ENTRY, "without"); tr.put(RT_COUNT, "Retweets"); tr.put(RT_COUNT + ":[5 TO *]", "5 and more"); tr.put(RT_COUNT + ":[20 TO *]", "20 and more"); tr.put(RT_COUNT + ":[50 TO *]", "50 and more"); tr.put(QUALITY, "Spam"); tr.put(FILTER_NO_SPAM, "without"); tr.put(FILTER_SPAM, "only spam"); tr.put(LANG + ":" + UNKNOWN_LANG, "Other"); tr.put(LANG + ":" + DE, "Deutsch"); tr.put(LANG + ":" + EN, "English"); tr.put(LANG + ":" + NL, "Nederlandse"); tr.put(LANG + ":" + RU, "P??"); tr.put(LANG + ":" + ES, "Espaol"); // backward compatibility tr.put(LANG + ":sp", "Espaol"); tr.put(LANG + ":" + FR, "Franais"); tr.put(LANG + ":" + PT, "Portugus"); tagView = new ListView("filterNames", normalFacetFields) { @Override public void populateItem(final ListItem item) { final Entry<String, List<FacetHelper>> entry = (Entry<String, List<FacetHelper>>) item .getModelObject(); String dtVal = translate(entry.getKey()); String filter = getFilterName(entry.getKey()); if (filter != null) { item.add(new LabeledLink("filterName", "< " + dtVal) { @Override public void onClick(AjaxRequestTarget target) { onRemoveAllFilter(target, entry.getKey()); } }.add(new AttributeAppender("title", new Model("Remove all filters from '" + dtVal + "'"), " "))); } else item.add(new Label("filterName", dtVal)); item.add(new ListView("filterValues", entry.getValue()) { @Override protected void populateItem(ListItem li) { final FacetHelper h = (FacetHelper) li.getModelObject(); final boolean selected = isAlreadyFiltered(h.getFilter()); final boolean excluded = isAlreadyExcluded(h.getFilter()); Link link = new IndicatingAjaxFallbackLink("filterValueLink") { @Override public void onClick(AjaxRequestTarget target) { if (selected) onFilterChange(target, h.key, h.value, null); else onFilterChange(target, h.key, h.value, false); } }; Link excludeLink = new IndicatingAjaxFallbackLink("filterExcludeLink") { @Override public void onClick(AjaxRequestTarget target) { if (excluded) onFilterChange(target, h.key, h.value, null); else onFilterChange(target, h.key, h.value, true); } }; li.add(new Label("filterCount", " (" + h.count + ")")); li.add(link); li.add(excludeLink); /* exlude does not work for filter queries like RT_COUNT.contains(h.key)*/ if (USER.contains(h.key) || LANG.contains(h.key)) excludeLink.setVisible(true); else excludeLink.setVisible(false); if (excluded) link.add(new AttributeAppender("class", new Model("filter-ex"), " ")); // change style if filter is selected if (selected) link.add(new AttributeAppender("class", new Model("filter-rm"), " ")); else link.add(new AttributeAppender("class", new Model("filter-add"), " ")); // TODO strike through if filter is excluded link.add(new Label("filterValue", h.displayName)); // not clickable if filter would result in 0 docs if (h.count == 0) { link.setEnabled(false); link.add(new AttributeAppender("class", new Model("gray"), " ")); } } }); } }; add(tagView); }
From source file:de.jetwick.ui.jschart.JSDateFilter.java
License:Apache License
public JSDateFilter(String id) { super(id);//w w w. ja v a2s .c o m final String dtVal = "Date Filter"; List<String> dateFilterList = new ArrayList<String>(); dateFilterList.add(dtKey); // TODO WICKET update dateFilter even if we call only update(rsp) ListView dateFilter = new ListView("dateFilterParent", dateFilterList) { @Override public void populateItem(final ListItem item) { String filter = getFilterName(dtKey); if (filter != null) { item.add(new LabeledLink("dateFilter", "Click to remove custom date filter") { @Override public void onClick(AjaxRequestTarget target) { onFilterChange(target, dtKey, null); } }.add(new AttributeAppender("title", new Model("Remove all filters from '" + dtVal + "'"), " "))); } else { String str = ""; if (totalHits > 0) str = "Select a date to filter results"; Label label = new Label("dateFilter", str); label.add(new AttributeAppender("class", new Model("gray"), " ")); item.add(label); } } }; add(dateFilter); ListView items = new ListView("items", facetList) { @Override public void populateItem(final ListItem item) { float zoomer = MAX_HEIGHT_IN_PX / max; final FacetHelper entry = (FacetHelper) item.getModelObject(); Label bar = new Label("itemSpan"); String additionalDateInfo = entry.count + " tweets"; String displayName = entry.displayName; try { Date date = Helper.toDate(displayName); int index = displayName.indexOf("T"); if (index > 0) additionalDateInfo += " on " + Helper.getMonthDay(date); displayName = Helper.getWeekDay(date); } catch (Exception ex) { } AttributeAppender app = new AttributeAppender("title", new Model(additionalDateInfo), " "); bar.add(app).add(new AttributeAppender("style", new Model("height:" + (int) (zoomer * entry.count) + "px"), " ")); final boolean selected = isAlreadyFiltered(entry.key, entry.value); Link link = new /*Indicating*/ AjaxFallbackLink("itemLink") { @Override public void onClick(AjaxRequestTarget target) { JSDateFilter.this.onFilterChange(target, entry.getFilter(), !selected); } }; link.add(app); Label label = new Label("itemLabel", displayName); link.add(bar).add(label); if (entry.count == 0) { link.setEnabled(false); link.add(new AttributeAppender("class", new Model("gray"), " ")); } if (selected) link.add(new AttributeAppender("class", new Model("filter-rm"), " ")); else link.add(new AttributeAppender("class", new Model("filter-add"), " ")); item.add(link); } }; add(items); }
From source file:de.voolk.marbles.web.pages.content.sidebar.DisplaySidebar.java
License:Open Source License
public DisplaySidebar(final DisplayPage page, String id, final IPage marblesPage) { super(id);//from ww w.j ava2 s .com add(new Link("edit") { @Override public void onClick() { PageParameters parameters = new PageParameters(); parameters.put("id", marblesPage.getId()); setResponsePage(EditPage.class, parameters); } }); add(new Link("print") { @Override public void onClick() { PageParameters parameters = new PageParameters(); parameters.put("id", marblesPage.getId()); setResponsePage(PrintPage.class, parameters); } }); deleteLink = new Link("delete") { @Override public void onClick() { this.setEnabled(false); new ReplacingConfirmationActionPanel(page.getAction(), new StringResourceModel( "delete.page.confirmation", DisplaySidebar.this, new Model<ValueMap>())) { @Override public void execute() { PageParameters parameters = new PageParameters(); parameters.put("id", marblesPage.getId()); setResponsePage(DeletePage.class, parameters); } @Override public void cancel() { super.cancel(); deleteLink.setEnabled(true); } }; } }; Link moveLink = new Link("move") { @Override public void onClick() { PageParameters parameters = new PageParameters(); parameters.put("id", marblesPage.getId()); setResponsePage(MovePage.class, parameters); } }; add(moveLink); Link renameLink = new Link("rename") { @Override public void onClick() { PageParameters parameters = new PageParameters(); parameters.put("id", marblesPage.getId()); setResponsePage(RenamePage.class, parameters); } }; add(renameLink); if (marblesPage.isRoot()) { moveLink.setEnabled(false); } IPageSession session = pageRepository.createSession(getIdentSession().getUser()); if (marblesPage.isRoot() || session.hasChildren(marblesPage)) { deleteLink.setEnabled(false); } add(deleteLink); }