/** * checkPrincipal, throws SecurityException if not * * @param principal principal */ public void checkPrincipal(Principal principal) { if (!hasPrincipal(principal)) { final String msg = Messages.getFormattedString(Messages.getString("tsl2nano.login.noprincipal"), new Object[] { getUser(), principal.getName() }); throw new SecurityException(msg); } }
/** * constructor * * @param id * @param shortDescription * @param longDescription * @param actionMode mode {@link IAction#MODE_DLG_CANCEL} or {@link IAction#MODE_DLG_OK}. * @param showFinishDialog whether to show a finish info dialog. */ public SecureAction(String id, String shortDescription, String longDescription, int actionMode) { super(id, Messages.getStringOpt(shortDescription, true), Messages.getStringOpt(longDescription)); this.actionMode = actionMode; LOG.info("creating dialog action with action-id and permission-id: '" + id + "' and label '" + shortDescription); }
/** * checkDelegate * @param interfaze * @param delegate */ static <T> void checkDelegate(Class<T> interfaze, T delegate) { if (delegate == null || !interfaze.isAssignableFrom(delegate.getClass())) { throw new ManagedException("the delegate instance must implement the service interface!\ninterface: " + interfaze + "\ndelegate: " + Messages.stripParameterBrackets(String.valueOf(delegate)) + "\n\nmostly the reason are missing appserver-client-libraries to your client."); } }
/** * will search for the actionId in the resource bundle - then in tsl2nano base bundle - if not found, the action * simple name will be returned * * @param actionId full action id * @param actionSimpleName simple action name * @param if true, the tooltip for the action will be evaluated * @return text to show on action */ public static final String getActionText(String actionId, boolean tooltip) { final String tooltip_postfix = (tooltip ? Messages.POSTFIX_TOOLTIP : ""); final String actionSimpleName = actionId.substring(actionId.lastIndexOf(".") + 1); String text = Messages.getString(actionId + tooltip_postfix); if (Messages.unknown(text)) { text = Messages.getString("tsl2nano." + actionSimpleName + tooltip_postfix); if (Messages.unknown(text)) { return StringUtil.toFirstUpper(actionSimpleName); } else if (tooltip) { return ""; } else { return text; } } return text; }
/** * constructor * * @param method */ public MethodAction(Method method) { super(createId(method), createName(method), Messages.getStringOpt(method.toGenericString())); setMethod(method); String imagePath = getId() + ".icon"; if (Messages.hasKey(imagePath)) { setImagePath(Messages.getString(imagePath)); } else { setImagePath(DEFAULT_ICON); } }
@Override public COLLECTIONTYPE action() throws Exception { //TODO: fire refresh event searchStatus = Messages.getFormattedString("tsl2nano.searchdialog.searchrunning"); ENV.get(Profiler.class).starting(this, getName()); COLLECTIONTYPE result = (COLLECTIONTYPE) getBeanFinder().getData((String) getParameter(0)); searchStatus = Messages.getFormattedString("tsl2nano.searchdialog.searchresultcount", result.size()); if (openAction != null) { openAction.setDefault(true); } return result; }
/** * getActionId * * @param beanType presenters bean type to create an action for * @param packedInList whether it is a bean instance or a bean container * @param actionName simple action name * @return full action id */ public static final String getActionId(Class<?> beanType, boolean packedInList, String actionName) { final String type = BeanClass.getName(beanType).toLowerCase() + (packedInList ? Messages.getString("tsl2nano.list") .toLowerCase() : ""); return type + "." + actionName.toLowerCase(); }
public Collection<T> getData(T from, Object to) { searchStatus = Messages.getFormattedString("tsl2nano.searchdialog.searchrunning"); ENV.get(Profiler.class).starting(this, getName()); Message.send(searchStatus); searchStatus = Messages.getFormattedString("tsl2nano.searchdialog.searchresultcount", result.size()); Message.send(searchStatus);
/** * provides a map containing all formatted single value attributes of the given bean * * @param bean bean to evaluate * @param keyPrefix (optional) key name prefix (normally ending with a dot) * @param translateKeys if true, all keys will be translated * @param filterAttributes attributes to be filtered (ignored) * @param format formatter (use {@link DefaultFormat} if unknown) * @return map containing formatted values */ public static Map<String, Object> toFormattedMap(Object bean, String keyPrefix, boolean translateKeys, Format format, String... filterAttributes) { final Map<String, Object> valueMap = keyPrefix != null ? BeanUtil.toValueMap(bean, keyPrefix, true, filterAttributes) : BeanUtil.toValueMap(bean, true, true, false, filterAttributes); final Set<String> keySet = valueMap.keySet(); final Map<String, Object> formattedMap = new LinkedHashMap<String, Object>(); for (final String k : keySet) { final String key = translateKeys ? Messages.getString(k) : k; formattedMap.put(key, format.format(valueMap.get(k))); } return formattedMap; }
@Override public String ask(Properties env) { String ask = constraints.getType().getSimpleName(); if (constraints.getMinimum() != null || constraints.getMaximum() != null) { ask += " between " + constraints.getMinimum() != null ? constraints.getMinimum() : "<any>" + constraints.getMaximum() != null ? constraints.getMaximum() : "<any>"; } else if (constraints.getAllowedValues() != null) { ask += " as one of: " + StringUtil.toString(constraints.getAllowedValues(), 60); } return Messages.getFormattedString("tsl2nano.entervalue", ask, StringUtil.toFirstUpper(name)) + POSTFIX_QUESTION; }
public static String translate(String name) { return StringUtil.toFirstUpper(Messages.getStringOpt(name)); }
Messages.getFormattedString("tsl2nano.searchdialog.searchresultcount", this.collection.size());
@Override public Object action() throws Exception { //TODO: fire refresh event getBeanFinder().reset(); if (!isStaticCollection && collection != null) { collection.clear(); } setSelected(); searchStatus = isStaticCollection || !hasMode(MODE_SEARCHABLE) ? "" : Messages .getString("tsl2nano.searchdialog.nosearch"); return null; }
if (actionSortColumn == null) { actionSortColumn = new CommonAction<Object>(name + POSTFIX_SORT, Messages.getStringOpt(getPresentable().getLabel(), true), getDescription()) {
/** * creates a save action for the given bean. the action-id will be 'bean.getClass().save' - that will be used as * permission id, too. * * @param bean bean to save * @param actionId action id (important for user permissions!) */ protected SecureAction<T> createSaveAction(final Object bean, String actionId) { final String saveLabel = BeanContainer.isInitialized() && BeanContainer.instance().isPersistable(getDefiningClass(clazz)) && !CompositionFactory.contains(bean) ? Messages .getString("tsl2nano.save") : Messages.getString("tsl2nano.assign"); return new SaveAction(bean, actionId, saveLabel, saveLabel, IAction.MODE_DLG_OK); }