Search in sources :

Example 6 with Resources

use of net.sourceforge.processdash.i18n.Resources in project processdash by dtuma.

the class ExcelReport method writeNoPermission.

public static void writeNoPermission(PrintWriter out) {
    Resources resources = Resources.getDashBundle("Permissions");
    String title = resources.getHTML("Export_Reports.No_Permission_Title");
    out.print("<html>\n<head>\n<title>");
    out.print(title);
    out.print("</title>\n</head>\n<body>\n<h1>");
    out.print(title);
    out.print("</h1>\n<p>");
    out.print(resources.getHTML("Export_Reports.No_Permission_Message"));
    out.print("</p>\n</body>\n</html>\n");
}
Also used : Resources(net.sourceforge.processdash.i18n.Resources)

Example 7 with Resources

use of net.sourceforge.processdash.i18n.Resources in project processdash by dtuma.

the class EVReport method printAlternateViewLink.

private void printAlternateViewLink(Element view) {
    // Get the URI of the report
    String uri = view.getAttribute("href");
    if (uri.startsWith("/"))
        uri = uri.substring(1);
    // Get the resource bundle for messages
    String resourcePrefix = view.getAttribute("resources");
    Resources res = Resources.getDashBundle(resourcePrefix);
    // Construct the link HTML and print it
    String linkHtml = StringUtils.findAndReplace(SHOW_ALT_LINK, "[URI]", uri);
    interpOutLink(linkHtml, EVReportSettings.PURPOSE_OTHER, res);
}
Also used : Resources(net.sourceforge.processdash.i18n.Resources)

Example 8 with Resources

use of net.sourceforge.processdash.i18n.Resources in project processdash by dtuma.

the class TinyCGIBase method parseResourceFile.

protected void parseResourceFile(String context, String filename) throws IOException {
    String bundleName = resolveRelativeURI(context, filename);
    int pos = bundleName.indexOf("//");
    if (pos != -1)
        bundleName = bundleName.substring(pos + 1);
    pos = bundleName.lastIndexOf('.');
    if (pos != -1 && bundleName.indexOf('/', pos) == -1)
        bundleName = bundleName.substring(0, pos);
    try {
        Resources bundle = Resources.getTemplateBundle(bundleName);
        getInterpolator().addResources(bundle);
    } catch (MissingResourceException mre) {
        System.out.println("Couldn't find resource file: " + bundleName);
        System.out.println("(Specified as '" + filename + "' from '" + context + "')");
    }
}
Also used : MissingResourceException(java.util.MissingResourceException) Resources(net.sourceforge.processdash.i18n.Resources)

Example 9 with Resources

use of net.sourceforge.processdash.i18n.Resources in project processdash by dtuma.

the class TinyCGIBase method parseInputFile.

/* Read name=value pairs from the given URI. If the URI is not
     * absolute (e.g. "/reports/foo"), it is interpreted relative
     * to the current request. */
protected void parseInputFile(String scriptPath, String filename) throws IOException {
    if (filename == null || filename.length() == 0)
        return;
    WebServer t = getTinyWebServer();
    String origFilename = filename;
    try {
        filename = resolveRelativeURI(scriptPath, filename);
        parseInput(filename, t.getRequestAsString(filename));
        // values from it as well.
        try {
            String bundleName = filename;
            int pos = bundleName.indexOf("//");
            if (pos != -1)
                bundleName = bundleName.substring(pos + 1);
            pos = bundleName.lastIndexOf('.');
            if (pos != -1 && bundleName.indexOf('/', pos) == -1)
                bundleName = bundleName.substring(0, pos);
            Resources bundle = Resources.getTemplateBundle(bundleName);
            parameters.putAll(bundle.asMap());
        } catch (Exception e) {
        // it is not an error if no companion bundle was found.
        }
    } catch (IOException ioe) {
        System.out.println("Couldn't read file: " + filename);
        System.out.println("(Specified as '" + origFilename + "' from '" + scriptPath + "')");
    }
}
Also used : WebServer(net.sourceforge.processdash.net.http.WebServer) Resources(net.sourceforge.processdash.i18n.Resources) IOException(java.io.IOException) TinyCGIException(net.sourceforge.processdash.net.http.TinyCGIException) MalformedURLException(java.net.MalformedURLException) MissingResourceException(java.util.MissingResourceException) IOException(java.io.IOException)

Example 10 with Resources

use of net.sourceforge.processdash.i18n.Resources in project processdash by dtuma.

the class BrokenDataFileHandler method repairLostFiles.

private boolean repairLostFiles(Component dialogParent) {
    if (lostFiles == null || lostFiles.length == 0)
        return true;
    // sort the files so that backups are first, followed by temp files.
    // this allows our repair logic to prefer applying a backup-based
    // repair, as it is more reliable than a temp-file-based repair.
    Arrays.sort(lostFiles, new Comparator<File>() {

        public int compare(File f1, File f2) {
            return getFileType(f1) - getFileType(f2);
        }

        private int getFileType(File f) {
            return (isBackupFile(f) ? 1 : 2);
        }
    });
    int unrepairedCount = 0;
    for (int i = 0; i < lostFiles.length; i++) {
        File file = lostFiles[i];
        if (repairFile(file))
            lostFiles[i] = null;
        else
            unrepairedCount++;
    }
    if (unrepairedCount == 0)
        return true;
    // If there are unrepaired files, display an error dialog
    ProcessDashboard.dropSplashScreen();
    Resources r = Resources.getDashBundle("ProcessDashboard.Errors");
    String message = getCorruptFileStr() + "\n" + r.getString("Lost_Data_Message");
    String title = r.getString("Lost_Data_Title");
    int response = JOptionPane.showConfirmDialog(dialogParent, message, title, JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE);
    return response == JOptionPane.YES_OPTION;
}
Also used : Resources(net.sourceforge.processdash.i18n.Resources) File(java.io.File)

Aggregations

Resources (net.sourceforge.processdash.i18n.Resources)20 MissingResourceException (java.util.MissingResourceException)5 Document (org.w3c.dom.Document)3 File (java.io.File)2 IOException (java.io.IOException)2 MalformedURLException (java.net.MalformedURLException)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 List (java.util.List)2 ErrorReporter (net.sourceforge.processdash.ui.lib.ErrorReporter)2 SAXException (org.xml.sax.SAXException)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 FileNotFoundException (java.io.FileNotFoundException)1 URL (java.net.URL)1 MessageFormat (java.text.MessageFormat)1 Date (java.util.Date)1 HashSet (java.util.HashSet)1 LinkedList (java.util.LinkedList)1 Map (java.util.Map)1 Set (java.util.Set)1