/** * Formats a message. If the message begins with "@", the remainder is assumed to be a label * identifier that is resolved. * * @param msg Message to format or, if starts with "@", a label reference. * @param args Optional replaceable parameters. * @return The formatted message. */ public static String formatMessage(String msg, Object... args) { return formatMessage(msg, null, args); }
public SearchException(String label, Throwable cause) { super(StrUtil.formatMessage(label), cause); }
@Override public String toString() { return label == null ? super.toString() : StrUtil.formatMessage(label); }
public FrameworkRuntimeException(String msg, Throwable cause, String throwableContext, Object... args) { super(StrUtil.formatMessage(msg, args), cause); this.throwableContext = throwableContext; errorCode = msg.startsWith("@") ? msg.substring(1) : null; }
public FrameworkCheckedException(String msg, Throwable cause, String throwableContext, Object... params) { super(StrUtil.formatMessage(msg, params), cause); this.throwableContext = throwableContext; errorCode = msg.startsWith("@") ? msg.substring(1) : null; }
/** * Returns true if the text corresponds to a specific response type. * * @param text Text to test. * @param label The label. * @return True if represents the specified response type. */ private boolean isResponseType(String text, String label) { return label.equals(text) || StrUtil.formatMessage(label).equals(text); }
/** * Displays the description information for a property. * * @param propertyName Property name. * @param propertyDescription Property description. */ private void setPropertyDescription(String propertyName, String propertyDescription) { propInfo.setTitle(StrUtil.formatMessage(propertyName)); lblPropertyInfo.setLabel(StrUtil.formatMessage(propertyDescription)); }
public String createLabelText(Object value, String prefix) { String text = StringUtils.trimToEmpty(value == null ? null : value instanceof Collection ? createLabelText((Collection<?>) value) : value instanceof Date ? DateUtil.formatDate((Date) value) : value instanceof String ? StrUtil.formatMessage((String) value) : value.toString()); return text.isEmpty() ? "" : StrUtil.formatMessage(StringUtils.defaultString(prefix)) + text; }
/** * Creates a chat session bound to the specified session id. * * @param sessionId The chat session id. * @param originator If true, this user is originating the chat session. * @return The controller for the chat session. */ protected static SessionController create(String sessionId, boolean originator) { Map<String, Object> args = new HashMap<>(); args.put("id", sessionId); args.put("title", StrUtil.formatMessage("@cwf.chat.session.title")); args.put("originator", originator ? true : null); Window dlg = PopupDialog.show(DIALOG, args, true, true, false, null); return (SessionController) FrameworkController.getController(dlg); }
private void updateCount() { grid.setTitle(StrUtil.formatMessage("@cwf.sessiontracker.msg.sessions.total", model.size())); }
/** * Clears any current validation error and displays a new validation error for the specified * input element. * * @param target The target input element. * @param message The validation error message. */ protected void wrongValue(BaseUIComponent target, String message) { if (wrongValueTarget != null) { wrongValueTarget.setBalloon(null); } wrongValueTarget = target; if (target != null && message != null) { target.setBalloon(StrUtil.formatMessage(message)); } }
/** * Adds a newly joined participant to the active participant list. * * @param participant Participant to add. */ @Override public void onParticipantAdded(IPublisherInfo participant, boolean fromRefresh) { if (model.add(participant) && !fromRefresh && !participant.equals(chatService.getSelf())) { addDialog(StrUtil.formatMessage("@cwf.chat.session.event.join", participant.getUserName()), null, false); } outstandingInvitations.remove(participant); }
private void showError(String message) { if (message == null) { txtLayout.setBalloon(null); } else { txtLayout.setBalloon(StrUtil.formatMessage(message)); txtLayout.focus(); } } }
/** * Remove a participant from the list; * * @param participant Participant to remove. */ @Override public void onParticipantRemoved(IPublisherInfo participant) { if (model.remove(participant)) { addDialog(StrUtil.formatMessage("@cwf.chat.session.event.leave", participant.getUserName()), null, false); } }
/** * Sets the context menu's owner. This modifies the member menu item states to reflect the * current owner. * * @param owner Menu's owner. */ public void setOwner(ElementUI owner) { if (this.owner != owner) { this.owner = owner; mnuHeader.setLabel( owner == null ? "" : StrUtil.formatMessage("@cwf.shell.designer.menu.title", owner.getDisplayName())); updateControls(); } }
private Button addButton(String label, String flavor, IEventListener listener) { Button button = new Button(StrUtil.formatMessage(label)); button.addClass("flavor:btn-" + flavor); button.addEventListener(ClickEvent.TYPE, listener); toolbar.addChild(button); return button; }
@Override public void afterInitialized(BaseComponent root) { window = (Window) root; window.setTitle(StrUtil.formatMessage(root.getAttribute("title", ""))); lblPrompt.setLabel(StrUtil.formatMessage(root.getAttribute("prompt", ""))); LayoutIdentifier dfltLayout = root.getAttribute("dfltLayout", LayoutIdentifier.class); txtLayout.setValue(dfltLayout == null ? null : dfltLayout.name); boolean shared = dfltLayout == null ? LayoutManager.defaultIsShared() : dfltLayout.shared; (shared ? rbShared : rbPrivate).setChecked(true); radioGroup.setVisible(!root.getAttribute("hideScope", false)); allowDups = root.getAttribute("allowDups", true); }
/** * Updates the visibility of menu items * * @param enabled The enabled status. */ private void updateMenus(boolean enabled) { menu.setImage(enabled ? DesignConstants.DESIGN_ICON_ACTIVE : DesignConstants.DESIGN_ICON_INACTIVE); mnuDesignMode.addStyle("border-bottom", enabled ? "2px solid lightgray" : null); menu.setHint( StrUtil.formatMessage(enabled ? DesignConstants.DESIGN_HINT_ACTIVE : DesignConstants.DESIGN_HINT_INACTIVE)); BaseUIComponent child = (BaseUIComponent) menu.getFirstChild(); while (child != null) { child.setVisible(enabled || child == mnuDesignMode); child = (BaseUIComponent) child.getNextSibling(); } } }
@Override public void afterInitialized(BaseComponent root) { window = (Window) root; shared = defaultIsShared(); boolean manage = root.getAttribute("manage", false); window.setTitle(StrUtil.formatMessage(manage ? CAP_LAYOUT_MANAGE : CAP_LAYOUT_LOAD)); lblPrompt.setLabel(StrUtil.formatMessage(manage ? MSG_LAYOUT_MANAGE : MSG_LAYOUT_LOAD)); modelAndView = lstLayouts.getModelAndView(String.class); modelAndView.setRenderer(renderer); pnlSelect.setVisible(!manage); tbManage.setVisible(manage); ((Radiobutton) radioGroup.getChildAt(shared ? 0 : 1)).setChecked(true); pnlScope.addClass(manage ? "pull-right" : "pull-left"); upload.bind(btnImport); refresh(root.getAttribute("dflt", "")); }
@Override public void eventCallback(String eventName, Object eventData) { String s = tboxEventResults.getValue(); if (!(eventData instanceof String)) { try { eventData = JSONUtil.serialize(eventData, true); } catch (Exception e) {} } s += "\n\n" + eventName + ":\n" + eventData; tboxEventResults.setValue(s); info("Received", eventName); if (!chkScrollLock.isChecked()) { String js = StrUtil.formatMessage("$('#%1$s').scrollTop($('#%1$s')[0].scrollHeight);", tboxEventResults.getId()); ClientUtil.eval(js); } }