List of usage examples for org.apache.wicket.model ResourceModel ResourceModel
public ResourceModel(String resourceKey, IModel<String> defaultValue)
From source file:com.evolveum.midpoint.gui.impl.component.input.QNameIChoiceRenderer.java
License:Apache License
@Override public Object getDisplayValue(QName qname) { if (qname == null) { return null; }/* ww w.j ava 2 s . c o m*/ String realPrefix = prefix != null && !prefix.isEmpty() ? (prefix + ".") : ""; String key = realPrefix + qname.getLocalPart(); return new ResourceModel(key, key).getObject(); }
From source file:com.evolveum.midpoint.web.component.input.QNameObjectTypeChoiceRenderer.java
License:Apache License
@Override public Object getDisplayValue(QName qname) { if (qname == null) { return null; }/*from w ww .j ava 2 s. c o m*/ String key = "ObjectType." + qname.getLocalPart(); return new ResourceModel(key, key).getObject(); }
From source file:com.evolveum.midpoint.web.util.StringResourceChoiceRenderer.java
License:Apache License
@Override public Object getDisplayValue(String object) { return new ResourceModel(keyPrefix + "." + object, object).getObject(); }
From source file:com.googlecode.wicketwebbeans.containers.BeanForm.java
License:Apache License
/** * Construct a new BeanForm./*from www .ja va 2 s . c o m*/ * * @param id the Wicket id for the panel. * @param bean the bean to be displayed. This may be an IModel or regular bean object. * The bean may be a List or, if an IModel, a model that returns a List. If so, the bean is display is * displayed using BeanTablePanel. Otherwise BeanGridPanel is used. * @param beanMetaData the meta data for the bean. If bean is a List or model of a List, then this must be * the BeanMetaData for a single element (row) of the List. * @param container an optional container to use in place of the default BeanGridPanel or BeanTablePanel. This container must must be a Panel and * implement a constructor of the form: <p> * <code>public Constructor(String id, final Object bean, BeanMetaData beanMetaData, TabMetaData tabMetaData)</code> * <p> * where id = Wicket component ID<br> * bean = the bean, or IModel containing the bean<br> * beanMetaData = the BeanMetaData for bean<br> * tabMetaData = the tab metadata<p> * May be null. */ @SuppressWarnings("serial") public BeanForm(String id, final Object bean, final BeanMetaData beanMetaData, final Class<? extends Panel> container) { super(id); this.bean = bean; this.beanMetaData = beanMetaData; this.container = container; form = new Form("f") { // Track whether the form is in submit processing. @Override public boolean process() { ++submitCnt; try { return super.process(); } finally { --submitCnt; } } }; form.setOutputMarkupId(true); add(form); String title = beanMetaData.getLabel(); form.add(new Label("title", title)); form.add(new Label("beanFormIndicatorErrorLabel", new ResourceModel("beanFormError.msg", "An error occurred on the server. Your session may have timed out."))); beanMetaData.consumeParameter(PARAM_ROWS); final HiddenField hiddenFocusField = new HiddenField<String>("focusField", new PropertyModel<String>(this, "focusField")); hiddenFocusField.add(new AbstractBehavior() { @Override public void onComponentTag(Component component, ComponentTag tag) { tag.put("id", "bfFocusField"); super.onComponentTag(component, tag); } }); form.add(hiddenFocusField); formVisitor = new FormVisitor(); createTabs(bean, beanMetaData, container); // Use a FeedbackMessageFilter to handle messages for multiple BeanForms on a page. This is because messages are stored on the session. IFeedbackMessageFilter feedbackFilter = new IFeedbackMessageFilter() { public boolean accept(FeedbackMessage message) { // If the reporter is a field and this is refreshing because of a non-Ajax form submit, it's very likely that the field has been detached // from its parent because it is in a list view. As a result, findParent doesn't return the BeanForm. Component reporter = message.getReporter(); AbstractField reporterField = (AbstractField) (reporter instanceof AbstractField ? reporter : reporter.findParent(AbstractField.class)); if (reporterField != null) { return reporterField.getBeanForm().getId().equals(BeanForm.this.getId()); } Component parent = (reporter instanceof BeanForm ? reporter : reporter.findParent(BeanForm.class)); return reporter == BeanForm.this || parent == null || parent == BeanForm.this; } }; feedback = new FeedbackPanel("feedback", feedbackFilter); feedback.setOutputMarkupId(true); form.add(feedback); createGlobalActions(); }
From source file:de.tudarmstadt.ukp.clarin.webanno.webapp.home.page.ApplicationPageBase.java
License:Apache License
@SuppressWarnings({ "serial" })
private void commonInit() {
// getSession().setLocale(Locale.ENGLISH);
logoutPanel = new LogoutPanel("logoutPanel");
feedbackPanel = new FeedbackPanel("feedbackPanel");
feedbackPanel.setOutputMarkupId(true);
feedbackPanel.add(new AttributeModifier("class", "error"));
feedbackPanel.setFilter(new IFeedbackMessageFilter() {
@Override//from w w w. j ava 2s.c om
public boolean accept(FeedbackMessage aMessage) {
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
String username = auth != null ? auth.getName() : "SYSTEM";
if (aMessage.isFatal()) {
LOG.fatal(username + ": " + aMessage.getMessage());
} else if (aMessage.isError()) {
LOG.error(username + ": " + aMessage.getMessage());
} else if (aMessage.isWarning()) {
LOG.warn(username + ": " + aMessage.getMessage());
} else if (aMessage.isInfo()) {
LOG.info(username + ": " + aMessage.getMessage());
} else if (aMessage.isDebug()) {
LOG.debug(username + ": " + aMessage.getMessage());
}
return true;
}
});
versionLabel = new Label("version", SettingsUtil.getVersionString());
embeddedDbWarning = new Label("embeddedDbWarning", "USE THIS INSTALLATION FOR TESTING ONLY -- "
+ "AN EMBEDDED DATABASE IS NOT RECOMMENDED FOR PRODUCTION USE");
embeddedDbWarning.setVisible(false);
try {
String driver = repository.getDatabaseDriverName();
embeddedDbWarning.setVisible(StringUtils.contains(driver.toLowerCase(Locale.US), "hsql"));
} catch (Throwable e) {
LOG.warn("Unable to determine which database is being used", e);
}
// Override warning about embedded database.
Properties settings = SettingsUtil.getSettings();
if ("false".equalsIgnoreCase(settings.getProperty("warnings.embeddedDatabase"))) {
embeddedDbWarning.setVisible(false);
}
// Display a warning when using an unsupported browser
RequestCycle requestCycle = RequestCycle.get();
WebClientInfo clientInfo;
if (Session.exists()) {
WebSession session = WebSession.get();
clientInfo = session.getClientInfo();
} else {
clientInfo = new WebClientInfo(requestCycle);
}
ClientProperties clientProperties = clientInfo.getProperties();
browserWarning = new Label("browserWarning",
"THIS BROWSER IS NOT SUPPORTED -- " + "PLEASE USE CHROME OR SAFARI");
browserWarning.setVisible(!clientProperties.isBrowserSafari() && !clientProperties.isBrowserChrome());
// Override warning about browser.
if ("false".equalsIgnoreCase(settings.getProperty("warnings.unsupportedBrowser"))) {
browserWarning.setVisible(false);
}
boolean helpAvailable;
try {
Application.get().getResourceSettings().getLocalizer().getString("page.help.link", this);
Application.get().getResourceSettings().getLocalizer().getString("page.help", this);
helpAvailable = true;
} catch (MissingResourceException e) {
helpAvailable = false;
}
add(helpLink = new ExternalLink("helpLink", new ResourceModel("page.help.link", ""),
new ResourceModel("page.help", "")));
helpLink.setPopupSettings(new PopupSettings("_blank"));
helpLink.setVisible(helpAvailable);
add(logoutPanel);
add(feedbackPanel);
add(versionLabel);
add(embeddedDbWarning);
add(browserWarning);
}
From source file:net.databinder.auth.components.DataProfilePageBase.java
License:Open Source License
public DataProfilePageBase(ReturnPage returnPage) { add(new Label("title", new ResourceModel("data.auth.title.update", "Update Account"))); add(new Label("text", new ResourceModel("data.auth.update", "Update Account"))); add(profileSocket("profileSocket", returnPage)); }
From source file:net.databinder.auth.components.DataSignInPageBase.java
License:Open Source License
public DataSignInPageBase(PageParameters params, ReturnPage returnPage) { AuthApplication<T> app = null; try {//from www . j a v a 2 s . c om app = ((AuthApplication<T>) Application.get()); } catch (ClassCastException e) { } // make sure the user is not trying to sign in or register with the wrong page if (app == null || !app.getSignInPageClass().isInstance(this)) throw new UnauthorizedInstantiationException(DataSignInPageBase.class); if (params != null) { String username = params.get("username").toString(); String token = params.get("token").toString(); // e-mail auth, for example if (username != null && token != null) { T user = app.getUser(username); if (user != null && app.getToken(user).equals(token)) getAuthSession().signIn(user, true); setResponsePage(((Application) app).getHomePage()); RequestCycle.get() .scheduleRequestHandlerAfterCurrent(new RenderPageRequestHandler( new PageProvider(((Application) app).getHomePage(), params), RenderPageRequestHandler.RedirectPolicy.NEVER_REDIRECT)); return; } } add(new Label("title", new ResourceModel("data.auth.title.sign_in", "Please sign in"))); sourceList = new SourceList(); add(profileSocket = profileSocket("profileSocket", returnPage)); add(new WebMarkupContainer("profileLinkWrapper") { public boolean isVisible() { return profileLink.isEnabled(); } }.add((profileLink = sourceList.new SourceLink("profileLink", profileSocket)) .add(new Label("text", getString("data.auth.register_link", null, "Register now")))) .add(new Label("text", getString("data.auth.pre_register_link", null, "Don't have an account?")))); add(signinSocket = signinSocket("signinSocket", returnPage)); add(new WebMarkupContainer("signinLinkWrapper") { @Override public boolean isVisible() { return signinLink.isEnabled(); } }.add(new Label("text", getString("data.auth.pre_sign_in_link", null, "Already have an account?"))) .add((signinLink = sourceList.new SourceLink("signinLink", signinSocket)) .add(new Label("text", getString("data.auth.sign_in_link", null, "Sign in"))))); signinLink.onClick(); // show sign in first }
From source file:net.unbewaff.wicketcrudr.providers.editorpanel.PalettePanel.java
License:Apache License
/** * factory method for the available items header * * @param componentId//from ww w . j ava2s .co m * component id of the returned header component * * @return available items component */ protected Component newAvailableHeader(final String componentId) { return new Label(componentId, new ResourceModel("palette.available", "Available")); }
From source file:net.unbewaff.wicketcrudr.providers.editorpanel.PalettePanel.java
License:Apache License
/** * factory method for the selected items header * * @param componentId//from w w w. ja va 2 s. c o m * component id of the returned header component * * @return header component */ protected Component newSelectedHeader(final String componentId) { return new Label(componentId, new ResourceModel("palette.selected", "Selected")); }
From source file:nl.knaw.dans.common.wicket.components.pagebrowse.PageBrowsePanel.java
License:Apache License
List<PageBrowseLink> computeLinks() {
PageBrowseData model = getModelObject();
List<PageBrowseLink> links = new ArrayList<PageBrowseLink>();
if (model.hasPrevious()) {
links.add(new PageBrowseLink(getCurrentPage() - 1, getPageSize(),
new ResourceModel(RK_PREVIOUS, "previous"), true, linkListeners));
}/*from w w w.j a v a2 s . c om*/
if (getWindowStart() > 1) {
links.add(new PageBrowseLink(1, getPageSize(), new Model<String>("" + 1), true, linkListeners));
}
if (getWindowStart() > 1 + 1) {
links.add(new PageBrowseLink(-1, getPageSize(), new Model<String>("..."), false, linkListeners));
}
for (int i = getWindowStart(); i <= getWindowEnd(); i++) {
links.add(new PageBrowseLink(i, getPageSize(), new Model<String>("" + i), i != getCurrentPage(),
linkListeners));
}
if (getWindowEnd() < getLastPage() - 1) {
links.add(new PageBrowseLink(-1, getPageSize(), new Model<String>("..."), false, linkListeners));
}
if (getWindowEnd() < getLastPage()) {
links.add(new PageBrowseLink(getLastPage(), getPageSize(), new Model<String>("" + getLastPage()), true,
linkListeners));
}
if (model.hasNext()) {
links.add(new PageBrowseLink(getCurrentPage() + 1, getPageSize(), new ResourceModel(RK_NEXT, "next"),
true, linkListeners));
}
return links;
}