Search in sources :

Example 21 with Translator

use of org.olat.core.gui.translator.Translator in project OpenOLAT by OpenOLAT.

the class MultiSelectColumnDescriptor method getHeaderKey.

public String getHeaderKey() {
    // render as checkbox icon to minimize used space for header
    Translator trans = (table != null ? table.getTranslator() : null);
    String choice = (trans != null ? trans.translate("table.header.multiselect") : "");
    return "<i class='o_icon o_icon_checkbox_checked o_icon-lg' title=\"" + choice + "\"> </i>";
}
Also used : Translator(org.olat.core.gui.translator.Translator)

Example 22 with Translator

use of org.olat.core.gui.translator.Translator in project OpenOLAT by OpenOLAT.

the class FolderHelper method extractFileType.

/**
 * Extract the type of file based on suffix.
 *
 * @param filePath
 * @param locale
 * @return File type based on file extension.
 */
public static String extractFileType(String filePath, Locale locale) {
    int lastDot = filePath.lastIndexOf('.');
    if (lastDot > 0) {
        if (lastDot < filePath.length())
            return filePath.substring(lastDot + 1).toLowerCase();
    }
    Translator translator = Util.createPackageTranslator(FolderHelper.class, locale);
    return translator.translate("UnknownFile");
}
Also used : Translator(org.olat.core.gui.translator.Translator)

Example 23 with Translator

use of org.olat.core.gui.translator.Translator in project OpenOLAT by OpenOLAT.

the class DialogBoxUIFactory method createYesNoDialog.

/**
 * The Yes-No dialog has two buttons. the following events are fired:
 * <ul>
 * <li>yes -> ButtonClickedEvent with position 0</li>
 * <li>no -> ButtonClickedEvent with position 1</li>
 * <li>Event.CANCELLED_EVENT: when user clicks the close icon in the window bar</li>
 * </ul>
 * <p>
 * Initial Date: 26.11.2007<br>
 *
 * @author Florian Gnaegi, frentix GmbH, http://www.frentix.com
 */
public static DialogBoxController createYesNoDialog(UserRequest ureq, WindowControl wControl, String title, String text) {
    Translator trans = Util.createPackageTranslator(DialogBoxUIFactory.class, ureq.getLocale());
    List<String> yesNoButtons = new ArrayList<String>();
    yesNoButtons.add(trans.translate("yes"));
    yesNoButtons.add(trans.translate("no"));
    DialogBoxController dialogCtr = new DialogBoxController(ureq, wControl, title, text, yesNoButtons);
    return dialogCtr;
}
Also used : Translator(org.olat.core.gui.translator.Translator) ArrayList(java.util.ArrayList)

Example 24 with Translator

use of org.olat.core.gui.translator.Translator in project OpenOLAT by OpenOLAT.

the class DialogBoxUIFactory method createResourceLockedMessage.

/**
 * create the default info message shown for an unsuccessfully acquired lock - must not be called if lock was successfully acquired!
 * @param ureq
 * @param wControl
 * @param lockEntry must be not null
 * @param i18nLockMsgKey must be not null and valid key in the given translator
 * @param translator must be not null
 * @return DialogController
 */
public static DialogBoxController createResourceLockedMessage(UserRequest ureq, WindowControl wControl, LockResult lockEntry, String i18nLockMsgKey, Translator translator) {
    if (lockEntry.isSuccess()) {
        throw new AssertException("do not create a 'is locked message' if lock was succesfull! concerns lock:" + lockEntry.getOwner());
    }
    String fullName = CoreSpringFactory.getImpl(UserManager.class).getUserDisplayName(lockEntry.getOwner());
    String[] i18nParams = new String[] { StringHelper.escapeHtml(fullName), Formatter.getInstance(ureq.getLocale()).formatTime(new Date(lockEntry.getLockAquiredTime())) };
    String lockMsg = translator.translate(i18nLockMsgKey, i18nParams);
    Translator trans = Util.createPackageTranslator(DialogBoxUIFactory.class, ureq.getLocale());
    List<String> okButton = new ArrayList<String>();
    okButton.add(trans.translate("ok"));
    DialogBoxController ctrl = new DialogBoxController(ureq, wControl, null, lockMsg, okButton);
    ctrl.setCssClass("o_warning");
    return ctrl;
}
Also used : AssertException(org.olat.core.logging.AssertException) Translator(org.olat.core.gui.translator.Translator) UserManager(org.olat.user.UserManager) ArrayList(java.util.ArrayList) Date(java.util.Date)

Example 25 with Translator

use of org.olat.core.gui.translator.Translator in project OpenOLAT by OpenOLAT.

the class Renderer method render.

/**
 * used by the renderer, and also by the panel and tabbedpane renderer to delegate rendering
 * @param sb
 * @param source
 * @param args
 */
public void render(StringOutput sb, Component source, String[] args) {
    GlobalSettings gset = getGlobalSettings();
    boolean ajaxon = gset.getAjaxFlags().isIframePostEnabled();
    // wrap with div's so javascript can replace this component by doing a document.getElementById(cid).innerHTML and so on.
    boolean domReplaceable = source.isDomReplaceable();
    boolean useSpan = source.getSpanAsDomReplaceable();
    boolean domReplacementWrapperRequired = source.isDomReplacementWrapperRequired();
    boolean forceDebugDivs = gset.isIdDivsForced();
    if (source.isVisible()) {
        int lev = renderResult.getNestedLevel();
        if (lev > 60)
            throw new AssertException("components were nested more than 60 times, assuming endless loop bug: latest comp name: " + source.getComponentName());
        Translator componentTranslator = source.getTranslator();
        // identifier for dom replacement
        if (domReplaceable && domReplacementWrapperRequired && (ajaxon || forceDebugDivs)) {
            if (useSpan) {
                sb.append("<span id='o_c").append(source.getDispatchID());
            } else {
                sb.append("<div id='o_c").append(source.getDispatchID());
            }
            if (Settings.isDebuging()) {
            // sb.append("' title='").append(source.getComponentName());
            }
            sb.append("'>");
        }
        ComponentRenderer cr = findComponentRenderer(source);
        URLBuilder cubu = urlBuilder.createCopyFor(source);
        renderResult.incNestedLevel();
        // ---- for gui debug mode, direct the rendering to a special componentrenderer
        InterceptHandlerInstance dhi = renderResult.getInterceptHandlerInstance();
        if (dhi != null) {
            cr = dhi.createInterceptComponentRenderer(cr);
        }
        try {
            int preRenderLength = sb.length();
            cr.render(this, sb, source, cubu, componentTranslator, renderResult, args);
            if (preRenderLength == sb.length()) {
                // Add bugfix for IE min-height on empty div problem: min-height does
                // not get applied when div contains an empty comment.
                // Affects IE6, IE7
                sb.append("<!-- empty -->");
            }
            source.setDirty(false);
        } catch (Exception e) {
            // in order to produce a decent error msg, we need to postpone the
            // exception
            renderResult.setRenderExceptionInfo("exception while rendering component '" + source.getComponentName() + "' (" + source.getClass().getName() + ") " + source.getListenerInfo() + "<br />Message of exception: " + e.getMessage(), e);
        }
        renderResult.decNestedLevel();
        if (ajaxon && domReplaceable && domReplacementWrapperRequired) {
            if (useSpan) {
                sb.append("</span>");
            } else {
                sb.append("</div>");
            }
        }
    } else {
        // not visible
        if (domReplaceable && (ajaxon || forceDebugDivs)) {
            // browser dom tree
            if (useSpan) {
                sb.append("<span id=\"o_c").append(source.getDispatchID()).append("\"></span>");
            } else {
                // Add bugfix for IE min-height on empty div problem: min-height does
                // not get applied when div contains an empty comment.
                // Affects IE6, IE7
                sb.append("<div id=\"o_c").append(source.getDispatchID()).append("\"><!-- empty --></div>");
            }
        }
    }
}
Also used : AssertException(org.olat.core.logging.AssertException) ComponentRenderer(org.olat.core.gui.components.ComponentRenderer) Translator(org.olat.core.gui.translator.Translator) GlobalSettings(org.olat.core.gui.GlobalSettings) InterceptHandlerInstance(org.olat.core.gui.render.intercept.InterceptHandlerInstance) AssertException(org.olat.core.logging.AssertException)

Aggregations

Translator (org.olat.core.gui.translator.Translator)586 Identity (org.olat.core.id.Identity)62 Date (java.util.Date)54 Controller (org.olat.core.gui.control.Controller)54 RepositoryEntry (org.olat.repository.RepositoryEntry)54 Locale (java.util.Locale)52 PackageTranslator (org.olat.core.gui.translator.PackageTranslator)46 ArrayList (java.util.ArrayList)40 TabbableController (org.olat.core.gui.control.generic.tabbable.TabbableController)40 NodeEditController (org.olat.course.editor.NodeEditController)40 TitleItem (org.olat.core.commons.services.notifications.model.TitleItem)36 Roles (org.olat.core.id.Roles)36 NodeRunConstructionResult (org.olat.course.run.navigation.NodeRunConstructionResult)36 SubscriptionListItem (org.olat.core.commons.services.notifications.model.SubscriptionListItem)32 Publisher (org.olat.core.commons.services.notifications.Publisher)30 SubscriptionInfo (org.olat.core.commons.services.notifications.SubscriptionInfo)30 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)30 MailBundle (org.olat.core.util.mail.MailBundle)28 ICourse (org.olat.course.ICourse)26 UserPropertyHandler (org.olat.user.propertyhandlers.UserPropertyHandler)26