private String findIcon(String appl) {
logger.log(logger.HIGH, "Entering NeverNote.findIcon");
appl = appl.toLowerCase();
- File f = new File(Global.getDirectoryPath()+"images"+File.separator +appl +".png");
- if (f.exists())
- return appl+".png";
+ String relativePath = appl + ".png";
+ File f = Global.getFileManager().getImageDirFile(relativePath);
+ if (f.exists()) {
+ return relativePath;
+ }
logger.log(logger.HIGH, "Leaving NeverNote.findIcon");
return "attachment.png";
}
QDomElement right = doc.createElement("img");
right.setAttribute("onMouseDown", "window.jambi.nextPage('" +file.fileName() +"')");
left.setAttribute("onMouseDown", "window.jambi.previousPage('" +file.fileName() +"')");
- left.setAttribute("src", Global.currentDir+"images/small_left.png");
- right.setAttribute("src", Global.currentDir+"images/small_right.png");
+ // NFC TODO: should these be file:// URLs?
+ left.setAttribute("src", Global.getFileManager().getImageDirPath("small_left.png"));
+ right.setAttribute("src", Global.getFileManager().getImageDirPath("small_right.png"));
right.setAttribute("onMouseOver", "style.cursor='hand'");
table.appendChild(tr);
String icon = findIcon(appl);
if (icon.equals("attachment.png"))
icon = findIcon(fileDetails.substring(fileDetails.indexOf(".")+1));
- newText.setAttribute("src", Global.getDirectoryPath()+"images"+File.separator +icon);
+ // NFC TODO: should this be a 'file://' URL?
+ newText.setAttribute("src", Global.getFileManager().getImageDirPath(icon));
if (goodPreview) {
newText.setAttribute("src", Global.getDirectoryPath()+"res/"+filePath);
newText.setAttribute("style", "border-style:solid; border-color:green; padding:0.5mm 0.5mm 0.5mm 0.5mm;");
for (int i=enCryptLen-1; i>=0; i--) {
QDomElement enmedia = anchors.at(i).toElement();
enmedia.setAttribute("contentEditable","false");
- enmedia.setAttribute("src", Global.getDirectoryPath()+"images/encrypt.png");
+ enmedia.setAttribute("src", Global.getFileManager().getImageDirPath("encrypt.png"));
enmedia.setAttribute("en-tag","en-crypt");
enmedia.setAttribute("alt", enmedia.text());
Global.cryptCounter++;
import com.trolltech.qt.xml.QDomNodeList;\r
\r
import cx.fbn.nevernote.Global;\r
+import cx.fbn.nevernote.NeverNote;\r
import cx.fbn.nevernote.gui.BrowserWindow;\r
import cx.fbn.nevernote.sql.DatabaseConnection;\r
\r
QDomElement enmedia = anchors.at(i).toElement();\r
//enmedia.setAttribute("style","display:none");\r
enmedia.setAttribute("contentEditable","false");\r
- enmedia.setAttribute("src", Global.getDirectoryPath()+"images/encrypt.png");\r
+ enmedia.setAttribute("src", Global.getFileManager().getImageDirPath("encrypt.png"));\r
enmedia.setAttribute("en-tag","en-crypt");\r
enmedia.setAttribute("alt", enmedia.text());\r
Global.cryptCounter++;\r
String icon = findIcon(appl);\r
if (icon.equals("attachment.png"))\r
icon = findIcon(fileDetails.substring(fileDetails.indexOf(".")+1));\r
- newText.setAttribute("src", Global.getDirectoryPath()+"images"+File.separator +icon); \r
+ newText.setAttribute("src", Global.getFileManager().getImageDirPath(icon));\r
newText.setAttribute("title", fileDetails);\r
enmedia.removeChild(enmedia.firstChild());\r
enmedia.appendChild(newText);\r
}\r
}\r
}\r
- // find the appropriate icon for an attachment\r
+ /**\r
+ * find the appropriate icon for an attachment\r
+ *\r
+ * NFC TODO: duplicate of {@link NeverNote#findIcon(String)}\r
+ */\r
private String findIcon(String appl) {\r
appl = appl.toLowerCase();\r
- File f = new File(Global.getDirectoryPath()+"images"+File.separator +appl +".png");\r
- if (f.exists())\r
- return appl+".png";\r
+ String relativePath = appl + ".png";\r
+ File f = Global.getFileManager().getImageDirFile(relativePath);\r
+ if (f.exists()) {\r
+ return relativePath;\r
+ }\r
return "attachment.png";\r
}\r
\r
import cx.fbn.nevernote.signals.NoteSignal;\r
import cx.fbn.nevernote.sql.DatabaseConnection;\r
import cx.fbn.nevernote.utilities.ApplicationLogger;\r
+import cx.fbn.nevernote.utilities.FileUtils;\r
\r
public class BrowserWindow extends QWidget {\r
\r
QMessageBox.information(this, "Error", "Error Encrypting String");\r
return;\r
}\r
- StringBuffer imgPath = new StringBuffer(Global.getDirectoryPath());\r
- for (int i = 0; i < imgPath.length(); i++)\r
- if (imgPath.charAt(i) == '\\')\r
- imgPath.setCharAt(i, '/');\r
StringBuffer buffer = new StringBuffer(encrypted.length() + 100);\r
buffer.append("<img en-tag=\"en-crypt\" cipher=\"RC2\" hint=\""\r
+ dialog.getHint().replace("'","\\'") + "\" length=\"64\" ");\r
buffer.append("contentEditable=\"false\" alt=\"");\r
buffer.append(encrypted);\r
- buffer.append("\" src=\"" + imgPath.toString()\r
- + "images/encrypt.png\" ");\r
+ // NFC FIXME: should this be a file URL like in handleLocalAttachment and importAttachment?\r
+ buffer.append("\" src=\"").append(FileUtils.toForwardSlashedPath(Global.getFileManager().getImageDirPath("encrypt.png")));\r
Global.cryptCounter++;\r
buffer.append(" id=\"crypt"+Global.cryptCounter.toString() +"\"");\r
buffer.append(" onMouseOver=\"style.cursor=\\'hand\\'\"");\r
icon = findIcon(type[0]);\r
if (icon.equals("attachment.png"))\r
icon = findIcon(url.substring(url.lastIndexOf(".")+1));\r
- StringBuffer imageBuffer = new StringBuffer();\r
- String whichOS = System.getProperty("os.name");\r
- if (whichOS.contains("Windows")) \r
- imageBuffer.append("file:///" + Global.getDirectoryPath()\r
- + "images/" + icon);\r
- else\r
- imageBuffer.append("file://" + Global.getDirectoryPath()\r
- + "images/" + icon);\r
- // Fix stupid Windows file separation characters\r
- if (whichOS.contains("Windows")) {\r
- for (int z = imageBuffer.indexOf("\\"); z > 0; z = imageBuffer\r
- .indexOf("\\")) {\r
- int w = imageBuffer.indexOf("\\");\r
- imageBuffer.replace(w, w + 1, "/");\r
- }\r
+ String imageURL = FileUtils.toFileURLString(Global.getFileManager().getImageDirFile(icon));\r
\r
- }\r
logger.log(logger.EXTREME, "Creating resource ");\r
Resource newRes = createResource(url, i, mimeType, true);\r
if (newRes == null)\r
\r
PDFPreview pdfPreview = new PDFPreview();\r
if (pdfPreview.setupPreview(Global.currentDir+"res/"+fileName, "pdf",0));\r
- imageBuffer = new StringBuffer(file.fileName()+".png");\r
+ imageURL = file.fileName() + ".png";\r
}\r
\r
logger.log(logger.EXTREME, "Generating link tags");\r
buffer.append("<a en-tag=\"en-media\" guid=\"" +newRes.getGuid()+"\" ");\r
buffer.append(" onContextMenu=\"window.jambi.imageContextMenu('" +Global.getDirectoryPath() +"res/"+fileName +"');\" ");\r
buffer.append("type=\"" + mimeType + "\" href=\"nnres://" + fileName +"\" hash=\""+Global.byteArrayToHexString(newRes.getData().getBodyHash()) +"\" >");\r
- buffer.append("<img src=\"" + imageBuffer.toString()+"\" title=\"" +newRes.getAttributes().getFileName());\r
+ buffer.append("<img src=\"" + imageURL + "\" title=\"" +newRes.getAttributes().getFileName());\r
buffer.append("\"></img>");\r
buffer.append("</a>");\r
browser.page().mainFrame().evaluateJavaScript(\r
// find the appropriate icon for an attachment\r
private String findIcon(String appl) {\r
appl = appl.toLowerCase();\r
- File f = new File(Global.getDirectoryPath()+"images"+File.separator +appl +".png");\r
+ File f = Global.getFileManager().getImageDirFile(appl + ".png");\r
if (f.exists())\r
return appl+".png";\r
return "attachment.png";\r
import com.trolltech.qt.webkit.QWebPage;\r
\r
import cx.fbn.nevernote.Global;\r
+import cx.fbn.nevernote.NeverNote;\r
import cx.fbn.nevernote.sql.DatabaseConnection;\r
\r
\r
newRes.getAttributes().setFileName(fileInfo.fileName());\r
\r
String icon = findIcon(fileInfo.completeSuffix());\r
- StringBuffer imageBuffer = new StringBuffer();\r
- String whichOS = System.getProperty("os.name");\r
- if (whichOS.contains("Windows")) \r
- imageBuffer.append("file:///" + Global.getDirectoryPath()\r
- + "images/" + icon);\r
- else\r
- imageBuffer.append("file://" + Global.getDirectoryPath()\r
- + "images/" + icon);\r
- // Fix stupid Windows file separation characters\r
- if (whichOS.contains("Windows")) {\r
- for (int z = imageBuffer.indexOf("\\"); z > 0; \r
- z = imageBuffer.indexOf("\\")) {\r
- int w = imageBuffer.indexOf("\\");\r
- imageBuffer.replace(w, w + 1, "/");\r
- }\r
-\r
- }\r
+ String imageURL = FileUtils.toFileURLString(Global.getFileManager().getImageDirFile(icon));\r
buffer.append("<a en-tag=\"en-media\" guid=\"" +newRes.getGuid()+"\" ");\r
buffer.append("type=\"" + mimeType + "\" href=\"nnres://" + fileName +"\" hash=\""+Global.byteArrayToHexString(newRes.getData().getBodyHash()) +"\" >");\r
- buffer.append("<img src=\"" + imageBuffer.toString()+"\" title=\"" +newRes.getAttributes().getFileName());\r
+ buffer.append("<img src=\"" + imageURL +"\" title=\"" +newRes.getAttributes().getFileName());\r
buffer.append("\">");\r
buffer.append("</a>");\r
}\r
public String getNoteContent() {\r
return noteString;\r
}\r
- //********************************************************\r
- //* Find an icon for an attachment\r
- //********************************************************\r
- // find the appropriate icon for an attachment\r
+\r
+ /**\r
+ * find the appropriate icon for an attachment\r
+ * NFC TODO: duplicate of {@link NeverNote#findIcon(String)}\r
+ */\r
private String findIcon(String appl) {\r
- appl = appl.toLowerCase();\r
- File f = new File(Global.getDirectoryPath()+"images"+File.separator +appl +".png");\r
- if (f.exists())\r
- return appl+".png";\r
- return "attachment.png";\r
+ appl = appl.toLowerCase();\r
+ String relativePath = appl + ".png";\r
+ File f = Global.getFileManager().getImageDirFile(relativePath);\r
+ if (f.exists()) {\r
+ return relativePath;\r
+ }\r
+ return "attachment.png";\r
}\r
+\r
}\r