use of net.sourceforge.processdash.i18n.Resources in project processdash by dtuma.
the class BrokenDataFileHandler method repairFilesWithNullBytes.
/**
* If any files have been corrupted with null bytes, attempt to find
* replacements from a backup. If successful, display a warning to the user
* about what just happened.
*/
private void repairFilesWithNullBytes(Component dialogParent) {
if (nullByteFiles == null || nullByteFiles.isEmpty())
return;
Set<String> repairedNullFiles = new TreeSet<String>();
for (File file : nullByteFiles) {
if (shouldRepairNull(file) && repairNullByteFile(file))
repairedNullFiles.add(" " + file.getPath());
}
if (repairedNullFiles.isEmpty())
return;
// If we repaired any null files, display a warning. (No warning is
// displayed for files that could not be repaired; these will trigger a
// warning later when the corrupt data is encountered by the dashboard.)
ProcessDashboard.dropSplashScreen();
Resources r = Resources.getDashBundle("ProcessDashboard.Errors");
String title = r.getString("Repaired_Null.Title");
Object message = new Object[] { r.getString("Repaired_Null.Header"), StringUtils.join(repairedNullFiles, "\n"), " ", r.getString("Repaired_Null.Footer") };
JOptionPane.showMessageDialog(dialogParent, message, title, JOptionPane.ERROR_MESSAGE);
}
use of net.sourceforge.processdash.i18n.Resources in project processdash by dtuma.
the class HTMLPreprocessor method processResourcesDirective.
/** process a resources directive within the buffer */
private void processResourcesDirective(DirectiveMatch resDir) throws IOException {
Resources r = null;
// what bundle do they want us to include?
String bundle = resDir.getAttribute("bundle");
if (bundle != null) {
try {
r = Resources.getDashBundle(bundle);
} catch (MissingResourceException mre) {
throw new FileNotFoundException(bundle + ".properties");
}
} else {
// what file do they want us to include?
String url = resDir.getAttribute("file");
if (isNull(url))
url = resDir.contents;
if (!isNull(url)) {
// fetch the requested url (relative to the current url) and
// replace the include directive with its contents.
String context = (String) env.get("REQUEST_URI");
int pos = context.indexOf("//");
if (pos != -1)
context = context.substring(pos + 1);
URL tempURL = new URL("http://ignored" + context);
tempURL = new URL(tempURL, url);
url = tempURL.getFile();
String resName = url.substring(1).replace('.', '$').replace('/', '.');
try {
r = Resources.getTemplateBundle(resName);
} catch (MissingResourceException mre) {
throw new FileNotFoundException(url + ".properties");
}
}
}
if (r != null) {
if (resources == null)
resources = new LinkedList();
resources.add(r);
}
resDir.replace("");
}
use of net.sourceforge.processdash.i18n.Resources in project processdash by dtuma.
the class GenericScanItemList method writeContents.
@Override
protected void writeContents() throws IOException {
String listID = getListID();
List<Object[]> items = getItems();
filterItems(listID, items);
if (items.isEmpty()) {
out.write("<!-- no " + listID + " items were found -->\n");
return;
}
Resources res = (Resources) env.get(SnippetEnvironment.RESOURCES);
boolean readOnly = Settings.isReadOnly();
out.write("<html><head>");
out.write(HTMLUtils.cssLinkHtml("/dash/scanner.css"));
if (!readOnly)
out.write(HTMLUtils.scriptLinkHtml("/dash/scanner.js"));
out.write("</head><body>\n<div class=\"scanItemList " + listID + "\">");
out.write("<p>");
if (!readOnly) {
out.write("<input type=\"checkbox\" name=\"notData\" title=\"");
out.write(resources.getHTML("Clear_All_Tooltip"));
out.write("\" onchange=\"DashScanner.clearAllItems(this);\"> ");
}
out.write(res.getHTML("Header") + "</p>\n");
out.write(readOnly ? "<ul>\n" : "<table style=\"margin-left:1cm\">");
String clearItemTooltip = resources.getHTML("Clear_Item_Tooltip");
MessageFormat itemFmt = new MessageFormat(getParameter("itemFormat"));
for (Object[] oneItem : items) {
String itemText = itemFmt.format(oneItem);
String itemHtml = HTMLUtils.escapeEntities(itemText);
itemHtml = StringUtils.findAndReplace(itemHtml, " -- ", " — ");
if (readOnly) {
out.write("<li>");
} else {
out.write("<tr><td valign=\"top\">");
out.write("<input type=\"checkbox\" name=\"[" + listID + "/");
out.write(HTMLUtils.escapeEntities(getItemID(oneItem)));
out.write("]d\" title=\"");
out.write(clearItemTooltip);
out.write("\" onchange=\"DashScanner.clearItem(this);\">");
out.write("</td><td>");
}
out.write(itemHtml);
out.write(readOnly ? "</li>\n" : "</td></tr>\n");
}
out.write(readOnly ? "</ul>\n" : "</table>\n");
out.write("</div>\n</body></html>\n");
}
use of net.sourceforge.processdash.i18n.Resources in project processdash by dtuma.
the class DataVersionChecker method ensureVersionsOrExit.
public static void ensureVersionsOrExit() {
List<Incompatibility> unsatisfied = checkPackageVersions();
if (unsatisfied.isEmpty())
return;
Resources res = Resources.getDashBundle("ProcessDashboard.Errors.Version_Incompatibility");
StringBuilder upgradeList = new StringBuilder();
StringBuilder missingList = new StringBuilder();
for (Incompatibility item : unsatisfied) {
String itemDisplay = res.format("Item_FMT", item.getPackageDisplayName(), item.minVersion);
(item.pkg == null ? missingList : upgradeList).append("\n").append(BULLET).append(itemDisplay);
}
String title = res.getString("Title");
Object[] message = new Object[3];
message[0] = res.getStrings("Header");
if (missingList.length() > 0) {
message[1] = missingList.substring(1).split("\n");
message[2] = res.getStrings("Missing_Message");
} else {
message[1] = upgradeList.substring(1).split("\n");
message[2] = res.getStrings("Upgrade_Message");
}
JOptionPane.showMessageDialog(null, message, title, JOptionPane.ERROR_MESSAGE);
System.exit(1);
}
use of net.sourceforge.processdash.i18n.Resources in project processdash by dtuma.
the class XMLUtils method exceptionMessage.
public static String exceptionMessage(Exception e) {
String message = e.getLocalizedMessage();
if (message == null)
message = e.getMessage();
if (message == null)
return null;
int line = -1, col = -1;
if (e instanceof SAXParseException) {
SAXParseException spe = (SAXParseException) e;
line = spe.getLineNumber();
col = spe.getColumnNumber();
}
if (line == -1)
// no line number information. Just return the message.
return message;
else {
// format a message containing line#/col# information.
Resources r = Resources.getDashBundle("Templates");
String fmtKey = "XML_Exception_Line_FMT";
if (col != -1)
fmtKey = "XML_Exception_Line_Column_FMT";
return r.format(fmtKey, message, new Integer(line), new Integer(col));
}
}
Aggregations