OSDN Git Service

Correct problem parsing notes where carriage returns did not separate some XML lines...
[neighbornote/NeighborNote.git] / src / cx / fbn / nevernote / gui / BrowserWindow.java
index ca12e3a..8ac0cc5 100644 (file)
@@ -20,6 +20,8 @@
 package cx.fbn.nevernote.gui;\r
 \r
 import java.io.File;\r
+import java.io.FileNotFoundException;\r
+import java.io.IOException;\r
 import java.net.FileNameMap;\r
 import java.net.URI;\r
 import java.net.URLConnection;\r
@@ -28,10 +30,12 @@ import java.security.NoSuchAlgorithmException;
 import java.text.SimpleDateFormat;\r
 import java.util.ArrayList;\r
 import java.util.Calendar;\r
+import java.util.Collections;\r
 import java.util.Date;\r
 import java.util.GregorianCalendar;\r
 import java.util.HashMap;\r
 import java.util.List;\r
+import java.util.Locale;\r
 \r
 import com.evernote.edam.limits.Constants;\r
 import com.evernote.edam.type.Data;\r
@@ -40,6 +44,13 @@ import com.evernote.edam.type.Notebook;
 import com.evernote.edam.type.Resource;\r
 import com.evernote.edam.type.ResourceAttributes;\r
 import com.evernote.edam.type.Tag;\r
+import com.swabunga.spell.engine.SpellDictionary;\r
+import com.swabunga.spell.engine.SpellDictionaryHashMap;\r
+import com.swabunga.spell.engine.Word;\r
+import com.swabunga.spell.event.SpellCheckEvent;\r
+import com.swabunga.spell.event.SpellCheckListener;\r
+import com.swabunga.spell.event.SpellChecker;\r
+import com.swabunga.spell.event.StringWordTokenizer;\r
 import com.trolltech.qt.core.QByteArray;\r
 import com.trolltech.qt.core.QDataStream;\r
 import com.trolltech.qt.core.QDateTime;\r
@@ -49,6 +60,7 @@ import com.trolltech.qt.core.QFileSystemWatcher;
 import com.trolltech.qt.core.QIODevice;\r
 import com.trolltech.qt.core.QMimeData;\r
 import com.trolltech.qt.core.QUrl;\r
+import com.trolltech.qt.gui.QAction;\r
 import com.trolltech.qt.gui.QApplication;\r
 import com.trolltech.qt.gui.QCalendarWidget;\r
 import com.trolltech.qt.gui.QClipboard;\r
@@ -57,6 +69,8 @@ import com.trolltech.qt.gui.QComboBox;
 import com.trolltech.qt.gui.QDateEdit;\r
 import com.trolltech.qt.gui.QDesktopServices;\r
 import com.trolltech.qt.gui.QFileDialog;\r
+import com.trolltech.qt.gui.QFileDialog.AcceptMode;\r
+import com.trolltech.qt.gui.QFileDialog.FileMode;\r
 import com.trolltech.qt.gui.QFontDatabase;\r
 import com.trolltech.qt.gui.QFormLayout;\r
 import com.trolltech.qt.gui.QGridLayout;\r
@@ -72,20 +86,22 @@ import com.trolltech.qt.gui.QMessageBox;
 import com.trolltech.qt.gui.QPushButton;\r
 import com.trolltech.qt.gui.QShortcut;\r
 import com.trolltech.qt.gui.QTimeEdit;\r
+import com.trolltech.qt.gui.QToolButton;\r
+import com.trolltech.qt.gui.QToolButton.ToolButtonPopupMode;\r
 import com.trolltech.qt.gui.QVBoxLayout;\r
 import com.trolltech.qt.gui.QWidget;\r
-import com.trolltech.qt.gui.QFileDialog.AcceptMode;\r
-import com.trolltech.qt.gui.QFileDialog.FileMode;\r
 import com.trolltech.qt.network.QNetworkRequest;\r
 import com.trolltech.qt.webkit.QWebPage;\r
+import com.trolltech.qt.webkit.QWebPage.WebAction;\r
 import com.trolltech.qt.webkit.QWebSettings;\r
 import com.trolltech.qt.webkit.QWebView;\r
-import com.trolltech.qt.webkit.QWebPage.WebAction;\r
 \r
 import cx.fbn.nevernote.Global;\r
 import cx.fbn.nevernote.dialog.EnCryptDialog;\r
 import cx.fbn.nevernote.dialog.EnDecryptDialog;\r
+import cx.fbn.nevernote.dialog.GeoDialog;\r
 import cx.fbn.nevernote.dialog.InsertLinkDialog;\r
+import cx.fbn.nevernote.dialog.SpellCheck;\r
 import cx.fbn.nevernote.dialog.TableDialog;\r
 import cx.fbn.nevernote.dialog.TagAssign;\r
 import cx.fbn.nevernote.evernote.EnCrypt;\r
@@ -101,9 +117,10 @@ public class BrowserWindow extends QWidget {
        private final QLineEdit urlText;\r
        private final QLabel authorLabel;\r
        private final QLineEdit authorText;\r
+       private final QComboBox geoBox;\r
        public final TagLineEdit tagEdit;\r
        public final QLabel tagLabel;\r
-       private final QLabel urlLabel;\r
+       private final QPushButton urlLabel;\r
        private final QLabel alteredLabel;\r
        private final QDateEdit alteredDate;\r
        private final QTimeEdit alteredTime;\r
@@ -116,6 +133,7 @@ public class BrowserWindow extends QWidget {
        private final QLabel notebookLabel;\r
        private final QLabel createdLabel;\r
        public final QComboBox fontSize;\r
+       public final QAction    fontSizeAction;\r
        private boolean extendedOn;\r
        public boolean buttonsVisible;\r
        private final String iconPath = new String("classpath:cx/fbn/nevernote/icons/");\r
@@ -135,26 +153,43 @@ public class BrowserWindow extends QWidget {
        private final QCalendarWidget subjectCalendarWidget;\r
 \r
        public final QPushButton undoButton;\r
+       public final QAction    undoAction;\r
        public final QPushButton redoButton;\r
+       public final QAction    redoAction;\r
        public final QPushButton cutButton;\r
+       public final QAction    cutAction;\r
        public final QPushButton copyButton;\r
+       public final QAction    copyAction;\r
        public final QPushButton pasteButton;\r
+       public final QAction    pasteAction;\r
        public final QPushButton boldButton;\r
+       public final QAction    boldAction;\r
        public final QPushButton underlineButton;\r
+       public final QAction    underlineAction;\r
        public final QPushButton italicButton;\r
+       public final QAction    italicAction;\r
        public final Signal0 focusLost;\r
        public final NoteResourceSignal resourceSignal;\r
 \r
        public QPushButton rightAlignButton;\r
+       public final QAction    rightAlignAction;\r
        public QPushButton leftAlignButton;\r
+       public final QAction    leftAlignAction;\r
        public QPushButton centerAlignButton;\r
+       public final QAction    centerAlignAction;\r
 \r
        public final QPushButton strikethroughButton;\r
+       public final QAction    strikethroughAction;\r
        public final QPushButton hlineButton;\r
+       public final QAction    hlineAction;\r
        public final QPushButton indentButton;\r
+       public final QAction    indentAction;\r
        public final QPushButton outdentButton;\r
+       public final QAction    outdentAction;\r
        public final QPushButton bulletListButton;\r
+       public final QAction    bulletListAction;\r
        public final QPushButton numberListButton;\r
+       public final QAction    numberListAction;\r
 \r
        public final QShortcut focusTitleShortcut;\r
        public final QShortcut focusTagShortcut;\r
@@ -162,11 +197,14 @@ public class BrowserWindow extends QWidget {
        public final QShortcut focusUrlShortcut;\r
        public final QShortcut focusAuthorShortcut;\r
        \r
+       public EditorButtonBar buttonLayout;\r
        public final QComboBox fontList;\r
-       public final QPushButton fontColor;\r
+       public final QAction    fontListAction;\r
+       public final QToolButton fontColor;\r
+       public final QAction    fontColorAction;\r
        private final ColorMenu fontColorMenu;\r
-       public final QPushButton fontHilight;\r
-//     public final ColorComboBox fontHilight;\r
+       public final QToolButton fontHilight;\r
+       public final QAction    fontHilightAction;\r
        private final ColorMenu fontHilightColorMenu;\r
        public final QFileSystemWatcher fileWatcher;\r
        public int cursorPosition;\r
@@ -179,6 +217,44 @@ public class BrowserWindow extends QWidget {
        private final HashMap<String,Integer> previewPageList; \r
        \r
        \r
+       public static class SuggestionListener implements SpellCheckListener {\r
+               public boolean abortSpellCheck = false;\r
+               public boolean errorsFound = false;\r
+               \r
+               private final BrowserWindow parent;\r
+               public SuggestionListener(BrowserWindow parent) {\r
+                       this.parent = parent;\r
+               }\r
+               public void spellingError(SpellCheckEvent event) {\r
+                       errorsFound = true;\r
+                       SpellCheck dialog = new SpellCheck();\r
+                       dialog.setWord(event.getInvalidWord());\r
+\r
+                   List<Word> suggestions = event.getSuggestions();\r
+                   if (suggestions.isEmpty()) {\r
+                      dialog.setNoSuggestions(true);\r
+                   } else {\r
+                      dialog.setCurrentSuggestion(suggestions.get(0).getWord());\r
+                      for (int i=0; i<suggestions.size(); i++) {\r
+                         dialog.addSuggestion(suggestions.get(i).getWord());\r
+                      }\r
+                      dialog.setSelectedSuggestion(0);\r
+                   }\r
+                   dialog.exec();\r
+                   if (dialog.cancelPressed()) {\r
+                       abortSpellCheck = true;\r
+                       return;\r
+                   }\r
+                   if (dialog.replacePressed()) {\r
+                       QClipboard clipboard = QApplication.clipboard();\r
+                       clipboard.setText(dialog.getReplacementWord()); \r
+                       parent.pasteClicked();\r
+                   }\r
+                }\r
+       }\r
+\r
+       \r
+       \r
        public BrowserWindow(DatabaseConnection c) {\r
                logger = new ApplicationLogger("browser.log");\r
                logger.log(logger.HIGH, "Setting up browser");\r
@@ -190,7 +266,9 @@ public class BrowserWindow extends QWidget {
                titleLabel.setMaxLength(Constants.EDAM_NOTE_TITLE_LEN_MAX);\r
                urlText = new QLineEdit();\r
                authorText = new QLineEdit();\r
-               urlLabel = new QLabel();\r
+               geoBox = new QComboBox();\r
+               urlLabel = new QPushButton();\r
+               urlLabel.clicked.connect(this, "sourceUrlClicked()");\r
                authorLabel = new QLabel();\r
                conn = c;\r
                \r
@@ -225,20 +303,28 @@ public class BrowserWindow extends QWidget {
                subjectDate.setCalendarPopup(true);\r
                subjectDate.setCalendarWidget(subjectCalendarWidget);\r
                subjectTime = new QTimeEdit();\r
-               subjectLabel = new QLabel("Subject Date:");\r
+               subjectLabel = new QLabel(tr("Subject Date:"));\r
                subjectDate.dateChanged.connect(this, "subjectDateTimeChanged()");\r
                subjectTime.timeChanged.connect(this, "subjectDateTimeChanged()");\r
                authorText.textChanged.connect(this, "authorChanged()");\r
                urlText.textChanged.connect(this, "sourceUrlChanged()");\r
 \r
                notebookBox = new QComboBox();\r
-               notebookLabel = new QLabel("Notebook");\r
-               createdLabel = new QLabel("Created:");\r
+               notebookLabel = new QLabel(tr("Notebook"));\r
+               createdLabel = new QLabel(tr("Created:"));\r
                // selectedText = new String();\r
 \r
                urlLabel.setVisible(false);\r
                urlText.setVisible(false);\r
                authorLabel.setVisible(false);\r
+               \r
+               geoBox.setVisible(false);\r
+               geoBox.addItem(new QIcon(iconPath+"globe.png"), "");\r
+               geoBox.addItem(new String(tr("Set")));\r
+               geoBox.addItem(new String(tr("Clear")));\r
+               geoBox.addItem(new String(tr("View On Map")));\r
+               geoBox.activated.connect(this, "geoBoxChanged()");\r
+               \r
                authorText.setVisible(false);\r
                createdDate.setVisible(false);\r
                alteredLabel.setVisible(false);\r
@@ -291,6 +377,7 @@ public class BrowserWindow extends QWidget {
                QHBoxLayout authorLayout = new QHBoxLayout();\r
                authorLayout.addWidget(authorLabel, 0);\r
                authorLayout.addWidget(authorText, 0);\r
+               authorLayout.addWidget(geoBox);\r
                v.addLayout(authorLayout);\r
 \r
                dateLayout.addWidget(createdLabel, 0, 0);\r
@@ -305,69 +392,88 @@ public class BrowserWindow extends QWidget {
                dateLayout.addWidget(subjectTime, 0, 8);\r
                v.addLayout(dateLayout, 0);\r
 \r
-               undoButton = newEditorButton("undo", "Undo Change");\r
-               redoButton = newEditorButton("redo", "Redo Change");\r
-               cutButton = newEditorButton("cut", "Cut");\r
-               copyButton = newEditorButton("copy", "Copy");\r
-               pasteButton = newEditorButton("paste", "Paste");\r
-               boldButton = newEditorButton("bold", "Bold");\r
-               underlineButton = newEditorButton("underline", "Underline");\r
-               italicButton = newEditorButton("italic", "Italic");\r
-\r
-               rightAlignButton = newEditorButton("justifyRight", "Right Align");\r
-               leftAlignButton = newEditorButton("justifyLeft", "Left Align");\r
-               centerAlignButton = newEditorButton("justifyCenter", "Center Align");\r
-\r
-               strikethroughButton = newEditorButton("strikethrough", "Strikethrough");\r
-               hlineButton = newEditorButton("hline", "Insert Horizontal Line");\r
-               indentButton = newEditorButton("indent", "Shift Right");\r
-               outdentButton = newEditorButton("outdent", "Shift Left");\r
-               bulletListButton = newEditorButton("bulletList", "Bullet List");\r
-               numberListButton = newEditorButton("numberList", "Number List");\r
-\r
-\r
-               QHBoxLayout buttonLayout;\r
-               buttonLayout = new QHBoxLayout();\r
-               buttonLayout.setSpacing(0);\r
-               v.addLayout(buttonLayout);\r
+               undoButton = newEditorButton("undo", tr("Undo Change"));\r
+               redoButton = newEditorButton("redo", tr("Redo Change"));\r
+               cutButton = newEditorButton("cut", tr("Cut"));\r
+               copyButton = newEditorButton("copy", tr("Copy"));\r
+               pasteButton = newEditorButton("paste", tr("Paste"));\r
+               boldButton = newEditorButton("bold", tr("Bold"));\r
+               underlineButton = newEditorButton("underline", tr("Underline"));\r
+               italicButton = newEditorButton("italic", tr("Italic"));\r
+\r
+               rightAlignButton = newEditorButton("justifyRight", tr("Right Align"));\r
+               leftAlignButton = newEditorButton("justifyLeft", tr("Left Align"));\r
+               centerAlignButton = newEditorButton("justifyCenter", tr("Center Align"));\r
+\r
+               strikethroughButton = newEditorButton("strikethrough", tr("Strikethrough"));\r
+               hlineButton = newEditorButton("hline", tr("Insert Horizontal Line"));\r
+               indentButton = newEditorButton("indent", tr("Shift Right"));\r
+               outdentButton = newEditorButton("outdent", tr("Shift Left"));\r
+               bulletListButton = newEditorButton("bulletList", tr("Bullet List"));\r
+               numberListButton = newEditorButton("numberList", tr("Number List"));\r
+\r
                \r
-               buttonLayout.addWidget(undoButton);\r
-               buttonLayout.addWidget(redoButton);\r
-\r
-               buttonLayout.addWidget(newSeparator(), 0);\r
-               buttonLayout.addWidget(cutButton);\r
-               buttonLayout.addWidget(copyButton);\r
-               buttonLayout.addWidget(pasteButton);\r
-\r
-               buttonLayout.addWidget(newSeparator(), 0);\r
-               buttonLayout.addWidget(boldButton);\r
-               buttonLayout.addWidget(italicButton);\r
-               buttonLayout.addWidget(underlineButton);\r
-               buttonLayout.addWidget(strikethroughButton);\r
+               buttonLayout = new EditorButtonBar();\r
+//             buttonLayout.setSpacing(0);\r
+               v.addWidget(buttonLayout);\r
                \r
-               buttonLayout.addWidget(newSeparator(), 0);\r
-               buttonLayout.addWidget(leftAlignButton);\r
-               buttonLayout.addWidget(centerAlignButton);\r
-               buttonLayout.addWidget(rightAlignButton);\r
-\r
-               buttonLayout.addWidget(newSeparator(), 0);\r
-               buttonLayout.addWidget(hlineButton);\r
+               undoAction = buttonLayout.addWidget(undoButton);\r
+               buttonLayout.toggleUndoVisible.triggered.connect(this, "toggleUndoVisible(Boolean)");\r
+               redoAction = buttonLayout.addWidget(redoButton);\r
+               buttonLayout.toggleRedoVisible.triggered.connect(this, "toggleRedoVisible(Boolean)");\r
+               \r
+               buttonLayout.addWidget(newSeparator());\r
+               cutAction = buttonLayout.addWidget(cutButton);\r
+               buttonLayout.toggleCutVisible.triggered.connect(this, "toggleCutVisible(Boolean)");\r
+               copyAction = buttonLayout.addWidget(copyButton);\r
+               buttonLayout.toggleCopyVisible.triggered.connect(this, "toggleCopyVisible(Boolean)");\r
+               pasteAction = buttonLayout.addWidget(pasteButton);\r
+               buttonLayout.togglePasteVisible.triggered.connect(this, "togglePasteVisible(Boolean)");\r
+\r
+               buttonLayout.addWidget(newSeparator());\r
+               boldAction = buttonLayout.addWidget(boldButton);\r
+               buttonLayout.toggleBoldVisible.triggered.connect(this, "toggleBoldVisible(Boolean)");\r
+               italicAction = buttonLayout.addWidget(italicButton);\r
+               buttonLayout.toggleItalicVisible.triggered.connect(this, "toggleItalicVisible(Boolean)");\r
+               underlineAction = buttonLayout.addWidget(underlineButton);\r
+               buttonLayout.toggleUnderlineVisible.triggered.connect(this, "toggleUnderlineVisible(Boolean)");\r
+               strikethroughAction = buttonLayout.addWidget(strikethroughButton);\r
+               buttonLayout.toggleStrikethroughVisible.triggered.connect(this, "toggleStrikethroughVisible(Boolean)");\r
 \r
-               buttonLayout.addWidget(indentButton);\r
-               buttonLayout.addWidget(outdentButton);\r
-               buttonLayout.addWidget(bulletListButton);\r
-               buttonLayout.addWidget(numberListButton);\r
+               \r
+               buttonLayout.addWidget(newSeparator());\r
+               leftAlignAction = buttonLayout.addWidget(leftAlignButton);\r
+               buttonLayout.toggleLeftAlignVisible.triggered.connect(this, "toggleLeftAlignVisible(Boolean)");\r
+               centerAlignAction = buttonLayout.addWidget(centerAlignButton);\r
+               buttonLayout.toggleCenterAlignVisible.triggered.connect(this, "toggleCenterAlignVisible(Boolean)");\r
+               rightAlignAction = buttonLayout.addWidget(rightAlignButton);\r
+               buttonLayout.toggleRightAlignVisible.triggered.connect(this, "toggleRightAlignVisible(Boolean)");\r
+\r
+               buttonLayout.addWidget(newSeparator());\r
+               hlineAction = buttonLayout.addWidget(hlineButton);\r
+               buttonLayout.toggleHLineVisible.triggered.connect(this, "toggleHLineVisible(Boolean)");\r
+\r
+               indentAction = buttonLayout.addWidget(indentButton);\r
+               buttonLayout.toggleIndentVisible.triggered.connect(this, "toggleIndentVisible(Boolean)");\r
+               outdentAction = buttonLayout.addWidget(outdentButton);\r
+               buttonLayout.toggleOutdentVisible.triggered.connect(this, "toggleOutdentVisible(Boolean)");\r
+               bulletListAction = buttonLayout.addWidget(bulletListButton);\r
+               buttonLayout.toggleBulletListVisible.triggered.connect(this, "toggleBulletListVisible(Boolean)");\r
+               numberListAction = buttonLayout.addWidget(numberListButton);\r
+               buttonLayout.toggleNumberListVisible.triggered.connect(this, "toggleNumberListVisible(Boolean)");\r
 \r
                // Setup the font & font size combo boxes\r
-               buttonLayout.addWidget(newSeparator(), 0);\r
+               buttonLayout.addWidget(newSeparator());\r
                fontList = new QComboBox();\r
                fontSize = new QComboBox();\r
                fontList.setToolTip("Font");\r
                fontSize.setToolTip("Font Size");\r
                fontList.activated.connect(this, "fontChanged(String)");\r
                fontSize.activated.connect(this, "fontSizeChanged(String)");\r
-               buttonLayout.addWidget(fontList, 0);\r
-               buttonLayout.addWidget(fontSize, 0);\r
+               fontListAction = buttonLayout.addWidget(fontList);\r
+               buttonLayout.toggleFontVisible.triggered.connect(this, "toggleFontListVisible(Boolean)");\r
+               fontSizeAction = buttonLayout.addWidget(fontSize);\r
+               buttonLayout.toggleFontSizeVisible.triggered.connect(this, "toggleFontSizeVisible(Boolean)");\r
                QFontDatabase fonts = new QFontDatabase();\r
                List<String> fontFamilies = fonts.families();\r
                for (int i = 0; i < fontFamilies.size(); i++) {\r
@@ -377,21 +483,28 @@ public class BrowserWindow extends QWidget {
                        }\r
                }\r
 \r
-               buttonLayout.addWidget(newSeparator(), 0);\r
-               fontColor = newEditorButton("fontColor", "Font Color");\r
+//             buttonLayout.addWidget(newSeparator(), 0);\r
+               fontColor = newToolButton("fontColor", tr("Font Color"));\r
                fontColorMenu = new ColorMenu(this);\r
                fontColor.setMenu(fontColorMenu.getMenu());\r
+               fontColor.setPopupMode(ToolButtonPopupMode.MenuButtonPopup);\r
+               fontColor.setAutoRaise(false);\r
                fontColorMenu.getMenu().triggered.connect(this, "fontColorClicked()");\r
-               buttonLayout.addWidget(fontColor);\r
-               fontHilight = newEditorButton("fontHilight", "Font Hilight Color");\r
+               fontColorAction = buttonLayout.addWidget(fontColor);\r
+               buttonLayout.toggleFontColorVisible.triggered.connect(this, "toggleFontColorVisible(Boolean)");\r
+               fontHilight = newToolButton("fontHilight", tr("Font Hilight Color"));\r
+               fontHilight.setPopupMode(ToolButtonPopupMode.MenuButtonPopup);\r
+               fontHilight.setAutoRaise(false);\r
                fontHilightColorMenu = new ColorMenu(this);\r
+               fontHilightColorMenu.setDefault(QColor.yellow);\r
                fontHilight.setMenu(fontHilightColorMenu.getMenu());\r
                fontHilightColorMenu.getMenu().triggered.connect(this, "fontHilightClicked()");\r
-               buttonLayout.addWidget(fontHilight);\r
+               fontHilightAction = buttonLayout.addWidget(fontHilight);\r
+               fontHilightColorMenu.setDefault(QColor.yellow);\r
+               buttonLayout.toggleFontHilight.triggered.connect(this, "toggleFontHilightVisible(Boolean)");\r
 \r
-               buttonLayout.addWidget(new QLabel(), 1);\r
+//             buttonLayout.addWidget(new QLabel(), 1);\r
                v.addWidget(browser, 1);\r
-//             v.addLayout(buttonLayout,0);\r
                setLayout(v);\r
 \r
                browser.downloadAttachmentRequested.connect(this,\r
@@ -427,6 +540,7 @@ public class BrowserWindow extends QWidget {
        }\r
 \r
        \r
+       \r
        private void setupShortcut(QShortcut action, String text) {\r
                if (!Global.shortcutKeys.containsAction(text))\r
                        return;\r
@@ -469,6 +583,7 @@ public class BrowserWindow extends QWidget {
                notebookBox.setEnabled(!v);\r
                tagEdit.setEnabled(!v);\r
                authorLabel.setEnabled(!v);\r
+               geoBox.setEnabled(!v);\r
                urlText.setEnabled(!v);\r
                createdDate.setEnabled(!v);\r
                subjectDate.setEnabled(!v);\r
@@ -497,7 +612,8 @@ public class BrowserWindow extends QWidget {
                setNote(null);\r
                browser.setContent(new QByteArray());\r
                tagEdit.setText("");\r
-               urlLabel.setText("Source URL:");\r
+               tagEdit.tagCompleter.reset();\r
+               urlLabel.setText(tr("Source URL:"));\r
                titleLabel.setText("");\r
                logger.log(logger.EXTREME, "Exiting BrowserWindow.clear()");\r
        }\r
@@ -524,6 +640,15 @@ public class BrowserWindow extends QWidget {
                button.clicked.connect(this, name + "Clicked()");\r
                return button;\r
        }\r
+       // New Editor Button\r
+       private QToolButton newToolButton(String name, String toolTip) {\r
+               QToolButton button = new QToolButton();\r
+               QIcon icon = new QIcon(iconPath + name + ".gif");\r
+               button.setIcon(icon);\r
+               button.setToolTip(toolTip);\r
+               button.clicked.connect(this, name + "Clicked()");\r
+               return button;\r
+       }\r
 \r
        // New Separator\r
        private QLabel newSeparator() {\r
@@ -546,16 +671,32 @@ public class BrowserWindow extends QWidget {
        public void setTag(String t) {\r
                saveTagList = t;\r
                tagEdit.setText(t);\r
+               tagEdit.tagCompleter.reset();\r
        }\r
 \r
        // Set the source URL\r
        public void setUrl(String t) {\r
-               urlLabel.setText("Source URL:\t");\r
+               urlLabel.setText(tr("Source URL:\t"));\r
                urlText.setText(t);\r
        }\r
 \r
+       // The user want's to launch a web browser on the source of the URL\r
+       public void sourceUrlClicked() {\r
+               // Make sure we have a valid URL\r
+               if (urlText.text().trim().equals(""))\r
+                       return;\r
+               \r
+               String url = urlText.text();\r
+               if (!url.toLowerCase().startsWith(tr("http://")))\r
+                       url = tr("http://") +url;\r
+               \r
+        if (!QDesktopServices.openUrl(new QUrl(url))) {\r
+               logger.log(logger.LOW, "Error opening file :" +url);\r
+        }\r
+       }\r
+       \r
        public void setAuthor(String t) {\r
-               authorLabel.setText("Author:\t");\r
+               authorLabel.setText(tr("Author:\t"));\r
                authorText.setText(t);\r
        }\r
 \r
@@ -599,6 +740,7 @@ public class BrowserWindow extends QWidget {
                urlLabel.setVisible(extendedOn);\r
                urlText.setVisible(extendedOn);\r
                authorText.setVisible(extendedOn);\r
+               geoBox.setVisible(extendedOn);\r
                authorLabel.setVisible(extendedOn);\r
                createdDate.setVisible(extendedOn);\r
                createdTime.setVisible(extendedOn);\r
@@ -615,33 +757,8 @@ public class BrowserWindow extends QWidget {
 \r
        public void hideButtons() {\r
 \r
+               undoButton.parentWidget().setVisible(false);\r
                buttonsVisible = false;\r
-               \r
-               undoButton.setVisible(false);\r
-               redoButton.setVisible(false);\r
-               cutButton.setVisible(false);\r
-               copyButton.setVisible(false);\r
-               pasteButton.setVisible(false);\r
-               boldButton.setVisible(false);\r
-               underlineButton.setVisible(false);\r
-               italicButton.setVisible(false);\r
-\r
-               rightAlignButton.setVisible(false);\r
-               leftAlignButton.setVisible(false);\r
-               centerAlignButton.setVisible(false);\r
-\r
-               strikethroughButton.setVisible(false);\r
-               hlineButton.setVisible(false);\r
-               indentButton.setVisible(false);\r
-               outdentButton.setVisible(false);\r
-               bulletListButton.setVisible(false);\r
-               numberListButton.setVisible(false);\r
-\r
-               fontList.setVisible(false);\r
-               fontSize.setVisible(false);\r
-               fontColor.setVisible(false);\r
-               fontHilight.setVisible(false);\r
-\r
        }\r
 \r
 \r
@@ -677,9 +794,9 @@ public class BrowserWindow extends QWidget {
                        logger.log(logger.EXTREME, "URL is NN resource");\r
                        if (url.toString().endsWith("/vnd.evernote.ink")) {\r
                                logger.log(logger.EXTREME, "Unable to open ink note");\r
-                               QMessageBox.information(this, "Unable Open", "This is an ink note.\n"+\r
+                               QMessageBox.information(this, tr("Unable Open"), tr("This is an ink note.\n"+\r
                                        "Ink notes are not supported since Evernote has not\n published any specifications on them\n" +\r
-                                       "and I'm too lazy to figure them out by myself.");\r
+                                       "and I'm too lazy to figure them out by myself."));\r
                                return;\r
                        }\r
                        String fullName = url.toString().substring(8);\r
@@ -824,7 +941,7 @@ public class BrowserWindow extends QWidget {
        }\r
 \r
        // Listener when PASTE is clicked\r
-       void pasteClicked() {\r
+       public void pasteClicked() {\r
                logger.log(logger.EXTREME, "Paste Clicked");\r
                if (forceTextPaste) {\r
                        pasteWithoutFormattingClicked();\r
@@ -1072,7 +1189,7 @@ public class BrowserWindow extends QWidget {
                String encrypted = crypt.encrypt(text, dialog.getPassword().trim(), 64);\r
 \r
                if (encrypted.trim().equals("")) {\r
-                       QMessageBox.information(this, "Error", "Error Encrypting String");\r
+                       QMessageBox.information(this, tr("Error"), tr("Error Encrypting String"));\r
                        return;\r
                }\r
                StringBuffer buffer = new StringBuffer(encrypted.length() + 100);\r
@@ -1081,7 +1198,7 @@ public class BrowserWindow extends QWidget {
                buffer.append("contentEditable=\"false\" alt=\"");\r
                buffer.append(encrypted);\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
+               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
@@ -1117,7 +1234,9 @@ public class BrowserWindow extends QWidget {
                        String selectedText = browser.selectedText();\r
                        logger.log(logger.EXTREME, "Inserting link on text "+selectedText);\r
                        logger.log(logger.EXTREME, "URL Link " +dialog.getUrl().trim());\r
-                       String url = "<a href=\"" +dialog.getUrl().trim()+"\" >"+selectedText +"</a>";\r
+                       String url = "<a href=\"" +dialog.getUrl().trim()\r
+                                       +"\" title=" +dialog.getUrl().trim() \r
+                                       +" >"+selectedText +"</a>";\r
                        String script = "document.execCommand('insertHtml', false, '"+url+"');";\r
                        browser.page().mainFrame().evaluateJavaScript(script);\r
                        return;\r
@@ -1279,15 +1398,34 @@ public class BrowserWindow extends QWidget {
        // Tag line has been modified by typing text\r
        @SuppressWarnings("unused")\r
        private void modifyTagsTyping() {\r
-\r
-               String newTags = tagEdit.text();\r
-               List<String> test = tagEdit.tagCompleter.getTagList();\r
-               if (newTags.equalsIgnoreCase(saveTagList))\r
+               String completionText = "";\r
+               if (tagEdit.currentCompleterSelection != null && !tagEdit.currentCompleterSelection.equals("")) {\r
+                       completionText = tagEdit.currentCompleterSelection;\r
+                       tagEdit.currentCompleterSelection = "";\r
+               }\r
+               \r
+               if (tagEdit.text().equalsIgnoreCase(saveTagList))\r
                        return;\r
 \r
                // We know something has changed...\r
                String oldTagArray[] = saveTagList.split(Global.tagDelimeter);\r
-               String newTagArray[] = newTags.split(Global.tagDelimeter);\r
+               String newTagArray[] = tagEdit.text().split(Global.tagDelimeter);\r
+               \r
+               if (!completionText.equals("") && newTagArray.length > 0) {\r
+                       newTagArray[newTagArray.length-1] = completionText;\r
+               }\r
+               // Remove any potential duplicates from the new list\r
+               for (int i=0; i<newTagArray.length; i++) {\r
+                       boolean foundOnce = false;\r
+                       for (int j=0; j<newTagArray.length; j++) {\r
+                               if (newTagArray[j].equalsIgnoreCase(newTagArray[i])) {\r
+                                       if (!foundOnce) {\r
+                                               foundOnce = true;\r
+                                       } else\r
+                                               newTagArray[j] = "";\r
+                               }\r
+                       }\r
+               }\r
 \r
                List<String> newTagList = new ArrayList<String>();\r
                List<String> oldTagList = new ArrayList<String>();\r
@@ -1299,6 +1437,18 @@ public class BrowserWindow extends QWidget {
                        if (!newTagArray[i].trim().equals(""))\r
                                newTagList.add(newTagArray[i]);\r
 \r
+               // Let's cleanup the appearance of the tag list\r
+               Collections.sort(newTagList);\r
+               String newDisplay = "";\r
+               for (int i=0; i<newTagList.size(); i++) {\r
+                       newDisplay = newDisplay+newTagList.get(i);\r
+                       if (i<newTagList.size()-1)\r
+                               newDisplay = newDisplay+", ";\r
+               }\r
+               tagEdit.blockSignals(true);\r
+               tagEdit.setText(newDisplay);\r
+               tagEdit.blockSignals(false);\r
+               \r
                // We now have lists of the new & old. Remove duplicates. If all\r
                // are removed from both then nothing has really changed\r
                for (int i = newTagList.size() - 1; i >= 0; i--) {\r
@@ -1315,13 +1465,14 @@ public class BrowserWindow extends QWidget {
 \r
                if (oldTagList.size() != 0 || newTagList.size() != 0) {\r
                        currentTags.clear();\r
+                       newTagArray = tagEdit.text().split(Global.tagDelimeter);\r
                        for (int i = 0; i < newTagArray.length; i++)\r
                                if (!newTagArray[i].trim().equals(""))\r
                                        currentTags.add(newTagArray[i].trim());\r
 \r
                        noteSignal.tagsChanged.emit(currentNote.getGuid(), currentTags);\r
                }\r
-\r
+               \r
        }\r
 \r
        // Tab button was pressed\r
@@ -1405,9 +1556,6 @@ public class BrowserWindow extends QWidget {
                String content = getContent();\r
                checkNoteTitle();\r
                noteSignal.noteChanged.emit(currentNote.getGuid(), content); \r
-               \r
-               \r
-//        noteSignal.noteChanged.emit(currentNote.getGuid(), unicode);\r
        }\r
 \r
        // The notebook selection has changed\r
@@ -1439,14 +1587,14 @@ public class BrowserWindow extends QWidget {
                        if (newLine > 0) {\r
                                text = text.substring(0, newLine);\r
                                if (text.trim().equals(""))\r
-                                       text = "Untitled Note";\r
+                                       text = tr("Untitled Note");\r
                                titleLabel.setText(text);\r
                        } else {\r
                                if (text.length() > 20)\r
                                        titleLabel.setText(text.substring(0, 20));\r
                                else {\r
                                        if (text.trim().equals(""))\r
-                                               titleLabel.setText("Untitled Note");\r
+                                               titleLabel.setText(tr("Untitled Note"));\r
                                        else\r
                                                titleLabel.setText(text);\r
                                }\r
@@ -1505,8 +1653,10 @@ public class BrowserWindow extends QWidget {
                buffer.append("\" en-tag=en-media type=\"image/jpeg\""\r
                                +" hash=\""+Global.byteArrayToHexString(newRes.getData().getBodyHash()) +"\""\r
                                +" guid=\"" +newRes.getGuid() +"\""\r
-                               +" onContextMenu=\"window.jambi.imageContextMenu('" +tfile.fileName() +"');\""\r
+//                             +" onContextMenu=\"window.jambi.imageContextMenu('" +tfile.fileName() +"');\""\r
+                               +" onContextMenu=\"window.jambi.imageContextMenu(&amp." +tfile.fileName() +"&amp.);\""\r
                                + " />");\r
+               \r
                browser.page().mainFrame().evaluateJavaScript(\r
                                script_start + buffer + script_end);\r
 \r
@@ -1606,15 +1756,16 @@ public class BrowserWindow extends QWidget {
                String script_end = new String("');");\r
                StringBuffer buffer;\r
 \r
-               for (int i = 0; i < urlList.size(); i++) {\r
-                       buffer = new StringBuffer(100);\r
-                       String url = urlList.get(i).toString();\r
-\r
-                       // Start building the HTML\r
                        String[] type = mimeType.split("/");\r
                        String icon = findIcon(type[1]);\r
                        if (icon.equals("attachment.png"))\r
                                icon = findIcon(type[0]);\r
+                       buffer = new StringBuffer(100);\r
+\r
+               for (int i = 0; i < urlList.size(); i++) {\r
+                       String url = urlList.get(i).toString();\r
+\r
+                       // Start building the HTML\r
                        if (icon.equals("attachment.png"))\r
                                icon = findIcon(url.substring(url.lastIndexOf(".")+1));\r
                        String imageURL = FileUtils.toFileURLString(Global.getFileManager().getImageDirFile(icon));\r
@@ -1650,17 +1801,17 @@ public class BrowserWindow extends QWidget {
 \r
                                PDFPreview pdfPreview = new PDFPreview();\r
                                if (pdfPreview.setupPreview(Global.getFileManager().getResDirPath(fileName), "pdf",0)) {\r
-                                       // NFC TODO: should this be a 'file://' url like the ones above?\r
-                                       imageURL = file.fileName() + ".png";\r
+                               // NFC TODO: should this be a 'file://' url like the ones above?\r
+                               imageURL = file.fileName() + ".png";\r
                                }\r
                        }\r
                                                \r
                        logger.log(logger.EXTREME, "Generating link tags");\r
+                       buffer.delete(0, buffer.length());\r
                        buffer.append("<a en-tag=\"en-media\" guid=\"" +newRes.getGuid()+"\" ");\r
                        buffer.append(" onContextMenu=\"window.jambi.imageContextMenu(&apos;")\r
-                             .append(Global.getFileManager().getResDirPath(fileName))\r
-                             .append("&apos;);\" ");\r
-                       buffer.append("type=\"" + mimeType + "\" href=\"nnres://" + fileName +"\" hash=\""+Global.byteArrayToHexString(newRes.getData().getBodyHash()) +"\" >");\r
+                     .append(Global.getFileManager().getResDirPath(fileName))\r
+                     .append("&apos;);\" ");                   buffer.append("type=\"" + mimeType + "\" href=\"nnres://" + fileName +"\" hash=\""+Global.byteArrayToHexString(newRes.getData().getBodyHash()) +"\" >");\r
                        buffer.append("<img src=\"" + imageURL + "\" title=\"" +newRes.getAttributes().getFileName());\r
                        buffer.append("\"></img>");\r
                        buffer.append("</a>");\r
@@ -1669,10 +1820,13 @@ public class BrowserWindow extends QWidget {
                }\r
                return;\r
        }\r
+\r
        private Resource createResource(String url, int sequence, String mime, boolean attachment) {\r
                logger.log(logger.EXTREME, "Inside create resource");\r
                QFile resourceFile;\r
-               url = new QUrl(url).toLocalFile();\r
+               String urlTest = new QUrl(url).toLocalFile();\r
+               if (!urlTest.equals(""))\r
+                       url = urlTest;\r
                url = url.replace("/", File.separator);\r
        resourceFile = new QFile(url); \r
        resourceFile.open(new QIODevice.OpenMode(QIODevice.OpenModeFlag.ReadOnly));\r
@@ -1774,8 +1928,8 @@ public class BrowserWindow extends QWidget {
                        return true;\r
                if (type.equalsIgnoreCase("PDF"))\r
                        return true;\r
-               String error = "Non-premium accounts can only attach JPG, PNG, GIF, MP3, WAV, AMR, or PDF files.";\r
-               QMessageBox.information(this, "Non-Premium Account", error);\r
+               String error = tr("Non-premium accounts can only attach JPG, PNG, GIF, MP3, WAV, AMR, or PDF files.");\r
+               QMessageBox.information(this, tr("Non-Premium Account"), error);\r
 \r
                return false;\r
        }\r
@@ -1794,8 +1948,8 @@ public class BrowserWindow extends QWidget {
                if (size < 25)\r
                        return true;\r
 \r
-               String error = "A file attachment may not exceed 25MB.";\r
-               QMessageBox.information(this, "Attachment Size", error);\r
+               String error = tr("A file attachment may not exceed 25MB.");\r
+               QMessageBox.information(this, tr("Attachment Size"), error);\r
                return false;\r
        }\r
 \r
@@ -1835,6 +1989,43 @@ public class BrowserWindow extends QWidget {
        private void authorChanged() {\r
                noteSignal.authorChanged.emit(currentNote.getGuid(), authorText.text());\r
        }\r
+       \r
+       @SuppressWarnings("unused")\r
+       private void geoBoxChanged() {\r
+               int index = geoBox.currentIndex();\r
+               geoBox.setCurrentIndex(0);\r
+               if (index == 1) {\r
+                       GeoDialog box = new GeoDialog();\r
+                       box.setLongitude(currentNote.getAttributes().getLongitude());\r
+                       box.setLatitude(currentNote.getAttributes().getLatitude());\r
+                       box.setAltitude(currentNote.getAttributes().getAltitude());\r
+                       box.exec();\r
+                       if (!box.okPressed())\r
+                               return;\r
+                       double alt = box.getAltitude();\r
+                       double lat = box.getLatitude();\r
+                       double lon = box.getLongitude();\r
+                       if (alt != currentNote.getAttributes().getAltitude() ||\r
+                               lon != currentNote.getAttributes().getLongitude() ||\r
+                               lat != currentNote.getAttributes().getLatitude()) {\r
+                                       noteSignal.geoChanged.emit(currentNote.getGuid(), lon, lat, alt);\r
+                                       currentNote.getAttributes().setAltitude(alt);\r
+                                       currentNote.getAttributes().setLongitude(lon);\r
+                                       currentNote.getAttributes().setLatitude(lat);\r
+                       }\r
+               }\r
+               \r
+               if (index == 2) {\r
+                       noteSignal.geoChanged.emit(currentNote.getGuid(), 0.0, 0.0, 0.0);\r
+                       currentNote.getAttributes().setAltitude(0.0);\r
+                       currentNote.getAttributes().setLongitude(0.0);\r
+                       currentNote.getAttributes().setLatitude(0.0);\r
+               }\r
+               \r
+               if (index == 3 || index == 0) {\r
+                       QDesktopServices.openUrl(new QUrl("http://maps.google.com/maps?z=6&q="+currentNote.getAttributes().getLatitude() +"," +currentNote.getAttributes().getLongitude()));\r
+               }\r
+       }\r
 \r
        // ************************************************************\r
        // * User chose to save an attachment. Pares out the request *\r
@@ -1845,7 +2036,7 @@ public class BrowserWindow extends QWidget {
                QFileDialog fd = new QFileDialog(this);\r
                fd.setFileMode(FileMode.AnyFile);\r
                fd.setConfirmOverwrite(true);\r
-               fd.setWindowTitle("Save File");\r
+               fd.setWindowTitle(tr("Save File"));\r
                fd.setAcceptMode(AcceptMode.AcceptSave);\r
                fd.setDirectory(System.getProperty("user.home"));\r
                String name = request.url().toString();\r
@@ -1897,16 +2088,13 @@ public class BrowserWindow extends QWidget {
                QFileDialog fd = new QFileDialog(this);\r
                fd.setFileMode(FileMode.AnyFile);\r
                fd.setConfirmOverwrite(true);\r
-               fd.setWindowTitle("Save File");\r
+               fd.setWindowTitle(tr("Save File"));\r
                fd.setAcceptMode(AcceptMode.AcceptSave);\r
                fd.setDirectory(System.getProperty("user.home"));\r
                String name = request.url().toString();\r
-\r
-               // Strip URL prefix and base dir path\r
                name = name.replace("nnres://", "");\r
                String dPath = FileUtils.toForwardSlashedPath(Global.getFileManager().getResDirPath());\r
                name = name.replace(dPath, "");\r
-\r
                int pos = name.lastIndexOf('.');\r
                String guid = name;\r
                if (pos > -1) {\r
@@ -2006,7 +2194,6 @@ public class BrowserWindow extends QWidget {
        //* MicroFocus changed\r
        //****************************************************************\r
        private void microFocusChanged() {\r
-               \r
                boldButton.setDown(false);\r
                italicButton.setDown(false);\r
                underlineButton.setDown(false);\r
@@ -2018,7 +2205,7 @@ public class BrowserWindow extends QWidget {
                browser.insertTableAction.setEnabled(true);\r
                browser.insertTableRowAction.setEnabled(false);\r
                browser.deleteTableRowAction.setEnabled(false);\r
-               browser.insertLinkAction.setText("Insert Hyperlink");\r
+               browser.insertLinkAction.setText(tr("Insert Hyperlink"));\r
                currentHyperlink ="";\r
                insideList = false;\r
                forceTextPaste = false;\r
@@ -2112,7 +2299,7 @@ public class BrowserWindow extends QWidget {
        }\r
        \r
        public void setInsideLink(String link) {\r
-               browser.insertLinkAction.setText("Edit Hyperlink");\r
+               browser.insertLinkAction.setText(tr("Edit Hyperlink"));\r
                currentHyperlink = link;\r
        }\r
        \r
@@ -2205,6 +2392,14 @@ public class BrowserWindow extends QWidget {
                                int guidEndPos = segment.indexOf("\"", guidStartPos+7);\r
                                String guid = segment.substring(guidStartPos+6,guidEndPos);\r
                                \r
+                               int mimeStartPos = segment.indexOf("type");\r
+                               int mimeEndPos = segment.indexOf("\"", mimeStartPos+7);\r
+                               String mime = segment.substring(mimeStartPos+6,mimeEndPos);\r
+\r
+                               int srcStartPos = segment.indexOf("src");\r
+                               int srcEndPos = segment.indexOf("\"", srcStartPos+6);\r
+                               String src = segment.substring(srcStartPos+5,srcEndPos);\r
+                               \r
                                Calendar currentTime = new GregorianCalendar();\r
                                Long l = new Long(currentTime.getTimeInMillis());\r
                                long prevTime = l;\r
@@ -2214,8 +2409,13 @@ public class BrowserWindow extends QWidget {
                                }\r
                                \r
                                Resource r = conn.getNoteTable().noteResourceTable.getNoteResource(guid, true);\r
-                               if (r==null)\r
-                                       return "";\r
+                               // if r==null, then the image doesn't exist (it was probably cut out of another note, so \r
+                               // we need to recereate it\r
+                               if (r==null) {\r
+                                       r = createResource(src, 1, mime, false);\r
+                                       if (r==null)\r
+                                               return "";\r
+                               }\r
                        String randint = new String(Long.toString(l));\r
                        String extension = null;\r
                        if (r.getMime()!= null) {\r
@@ -2244,8 +2444,8 @@ public class BrowserWindow extends QWidget {
                                String source; \r
                                if (locTag.startsWith("src")) {\r
                                         source = newSegment.substring(startSrcPos+locTag.length(),endSrcPos);\r
-                                       newSegment = newSegment.replace(source,\r
-                                               FileUtils.toForwardSlashedPath(Global.getFileManager().getResDirPath(newFile)));\r
+                                               newSegment = newSegment.replace(source,\r
+                                                       FileUtils.toForwardSlashedPath(Global.getFileManager().getResDirPath(newFile)));\r
                                } else {\r
                                        source = newSegment.substring(startSrcPos+locTag.length(),endSrcPos);\r
                                        newSegment = newSegment.replace(source, newFile);\r
@@ -2339,4 +2539,154 @@ public class BrowserWindow extends QWidget {
 //             browser.previousPageAction.setVisible(false);\r
        }\r
 */\r
-}
\ No newline at end of file
+       \r
+       private void toggleUndoVisible(Boolean toggle) {\r
+               undoAction.setVisible(toggle);\r
+               Global.saveEditorButtonsVisible("undo", toggle);\r
+       }\r
+       private void toggleRedoVisible(Boolean toggle) {\r
+               redoAction.setVisible(toggle);\r
+               Global.saveEditorButtonsVisible("redo", toggle);\r
+       }\r
+       private void toggleCutVisible(Boolean toggle) {\r
+               cutAction.setVisible(toggle);\r
+               Global.saveEditorButtonsVisible("cut", toggle);\r
+       }\r
+       private void toggleCopyVisible(Boolean toggle) {\r
+               copyAction.setVisible(toggle);\r
+               Global.saveEditorButtonsVisible("copy", toggle);\r
+       }\r
+       private void togglePasteVisible(Boolean toggle) {\r
+               pasteAction.setVisible(toggle);\r
+               Global.saveEditorButtonsVisible("paste", toggle);\r
+       }\r
+       private void toggleBoldVisible(Boolean toggle) {\r
+               boldAction.setVisible(toggle);\r
+               Global.saveEditorButtonsVisible("bold", toggle);\r
+       }\r
+       private void toggleItalicVisible(Boolean toggle) {\r
+               italicAction.setVisible(toggle);\r
+               Global.saveEditorButtonsVisible("italic", toggle);\r
+       }\r
+       private void toggleUnderlineVisible(Boolean toggle) {\r
+               underlineAction.setVisible(toggle);\r
+               Global.saveEditorButtonsVisible("underline", toggle);\r
+       }\r
+       private void toggleStrikethroughVisible(Boolean toggle) {\r
+               strikethroughAction.setVisible(toggle);\r
+               Global.saveEditorButtonsVisible("strikethrough", toggle);\r
+       }\r
+       private void toggleLeftAlignVisible(Boolean toggle) {\r
+               leftAlignAction.setVisible(toggle);\r
+               Global.saveEditorButtonsVisible("alignLeft", toggle);\r
+       }\r
+       private void toggleRightAlignVisible(Boolean toggle) {\r
+               rightAlignAction.setVisible(toggle);\r
+               Global.saveEditorButtonsVisible("alignRight", toggle);\r
+       }       \r
+       private void toggleCenterAlignVisible(Boolean toggle) {\r
+               centerAlignAction.setVisible(toggle);\r
+               Global.saveEditorButtonsVisible("alignCenter", toggle);\r
+       }\r
+       private void toggleHLineVisible(Boolean toggle) {\r
+               hlineAction.setVisible(toggle);\r
+               Global.saveEditorButtonsVisible("hline", toggle);\r
+       }\r
+       private void toggleIndentVisible(Boolean toggle) {\r
+               indentAction.setVisible(toggle);\r
+               Global.saveEditorButtonsVisible("indent", toggle);\r
+       }\r
+       private void toggleOutdentVisible(Boolean toggle) {\r
+               outdentAction.setVisible(toggle);\r
+               Global.saveEditorButtonsVisible("outdent", toggle);\r
+       }\r
+       private void toggleBulletListVisible(Boolean toggle) {\r
+               bulletListAction.setVisible(toggle);\r
+               Global.saveEditorButtonsVisible("bulletList", toggle);\r
+       }\r
+       private void toggleNumberListVisible(Boolean toggle) {\r
+               numberListAction.setVisible(toggle);\r
+               Global.saveEditorButtonsVisible("numberList", toggle);\r
+       }\r
+       private void toggleFontListVisible(Boolean toggle) {\r
+               fontListAction.setVisible(toggle);\r
+               Global.saveEditorButtonsVisible("font", toggle);\r
+       }\r
+       private void toggleFontColorVisible(Boolean toggle) {\r
+               fontColorAction.setVisible(toggle);\r
+               Global.saveEditorButtonsVisible("fontColor", toggle);\r
+       }\r
+       private void toggleFontSizeVisible(Boolean toggle) {\r
+               fontSizeAction.setVisible(toggle);\r
+               Global.saveEditorButtonsVisible("fontSize", toggle);\r
+       }\r
+       private void toggleFontHilightVisible(Boolean toggle) {\r
+               fontHilightAction.setVisible(toggle);\r
+               Global.saveEditorButtonsVisible("fontHilight", toggle);\r
+       }\r
+\r
+\r
+       // Invoke spell checker dialog\r
+       private void doSpellCheck() {\r
+\r
+               File wordList = new File(Global.getFileManager().getSpellDirPath()+Locale.getDefault()+".dic");\r
+           SpellDictionary dictionary;\r
+               try {\r
+                       dictionary = new SpellDictionaryHashMap(wordList);\r
+                       SpellChecker spellChecker = new SpellChecker(dictionary);\r
+                       SuggestionListener spellListener = new SuggestionListener(this);\r
+                       spellChecker.addSpellCheckListener(spellListener);\r
+\r
+                       String content = getBrowser().page().mainFrame().toPlainText();\r
+                       StringWordTokenizer tokenizer = new StringWordTokenizer(content);\r
+                       if (!tokenizer.hasMoreWords())\r
+                               return;\r
+                       String word = tokenizer.nextWord();\r
+                       getBrowser().page().action(WebAction.MoveToStartOfDocument);\r
+                       QWebPage.FindFlags flags = new QWebPage.FindFlags();\r
+                       flags.set(QWebPage.FindFlag.FindBackward);\r
+\r
+                       getBrowser().setFocus();\r
+                       boolean found = getBrowser().page().findText(word);\r
+                       if (!found) {\r
+                               QMessageBox.critical(this, tr("Spell Check Error"), \r
+                                               tr("An error has occurred while launching the spell check.  The most probable" +\r
+                                                               " cause is that the cursor was not at the beginning of the document.\n\n" +\r
+                                                               "Please place the cursor at the beginning & try again"));\r
+                               return;\r
+                       }\r
+                       while (found) {\r
+                               found = getBrowser().page().findText(word);\r
+                       }\r
+               \r
+                       spellChecker.checkSpelling(new StringWordTokenizer(word));\r
+                       getBrowser().setFocus();\r
+                       \r
+                       flags = new QWebPage.FindFlags();\r
+                       tokenizer = new StringWordTokenizer(content);\r
+                       \r
+                       while(tokenizer.hasMoreWords()) {\r
+                               word = tokenizer.nextWord();\r
+                               found = getBrowser().page().findText(word);\r
+                               if (found && !spellListener.abortSpellCheck) {\r
+                                       spellChecker.checkSpelling(new StringWordTokenizer(word));\r
+                                       getBrowser().setFocus();\r
+                               }\r
+                       }\r
+                       spellChecker.removeSpellCheckListener(spellListener);\r
+                       if (!spellListener.errorsFound)\r
+                               QMessageBox.information(this, tr("Spell Check Complete"), \r
+                                               tr("No spelling errors found"));\r
+               } catch (FileNotFoundException e) {\r
+                       QMessageBox.critical(this, tr("Spell Check Error"), \r
+                                       tr("Dictionary "+ Global.getFileManager().getSpellDirPath()+Locale.getDefault()+\r
+                                               ".dic was not found."));\r
+               } catch (IOException e) {\r
+                       QMessageBox.critical(this, tr("Spell Check Error"), \r
+                                       tr("Dictionary "+ Global.getFileManager().getSpellDirPath()+Locale.getDefault()+\r
+                                               ".dic is invalid."));\r
+               }\r
+\r
+    }\r
+\r
+}\r