OSDN Git Service

タブが1つだけになったときは閉じるボタンを表示しないように変更した
[neighbornote/NeighborNote.git] / src / cx / fbn / nevernote / NeverNote.java
1 /*
2   * This file is part of NixNote/NeighborNote 
3  * Copyright 2009 Randy Baumgarte
4  * Copyright 2013 Yuki Takahashi
5  * 
6  * This file may be licensed under the terms of of the
7  * GNU General Public License Version 2 (the ``GPL'').
8  *
9  * Software distributed under the License is distributed
10  * on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
11  * express or implied. See the GPL for the specific language
12  * governing rights and limitations.
13  *
14  * You should have received a copy of the GPL along with this
15  * program. If not, go to http://www.gnu.org/licenses/gpl.html
16  * or write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  *
19 */
20 package cx.fbn.nevernote;
21 import java.awt.Desktop;
22 import java.io.File;
23 import java.io.FileInputStream;
24 import java.io.FileNotFoundException;
25 import java.io.FileOutputStream;
26 import java.net.Authenticator;
27 import java.net.PasswordAuthentication;
28 import java.security.MessageDigest;
29 import java.security.NoSuchAlgorithmException;
30 import java.sql.Connection;
31 import java.sql.DriverManager;
32 import java.sql.SQLException;
33 import java.sql.Statement;
34 import java.text.SimpleDateFormat;
35 import java.util.ArrayList;
36 import java.util.Calendar;
37 import java.util.Collection;
38 import java.util.Collections;
39 import java.util.Comparator;
40 import java.util.Date;
41 import java.util.GregorianCalendar;
42 import java.util.HashMap;
43 import java.util.Iterator;
44 import java.util.List;
45 import java.util.SortedMap;
46 import java.util.Vector;
47
48 import org.apache.log4j.Level;
49 import org.apache.log4j.Logger;
50 import org.h2.tools.ChangeFileEncryption;
51
52 import com.evernote.edam.error.EDAMNotFoundException;
53 import com.evernote.edam.error.EDAMSystemException;
54 import com.evernote.edam.error.EDAMUserException;
55 import com.evernote.edam.notestore.NoteFilter;
56 import com.evernote.edam.notestore.NoteVersionId;
57 import com.evernote.edam.type.Data;
58 import com.evernote.edam.type.LinkedNotebook;
59 import com.evernote.edam.type.Note;
60 import com.evernote.edam.type.NoteAttributes;
61 import com.evernote.edam.type.Notebook;
62 import com.evernote.edam.type.Publishing;
63 import com.evernote.edam.type.QueryFormat;
64 import com.evernote.edam.type.Resource;
65 import com.evernote.edam.type.SavedSearch;
66 import com.evernote.edam.type.Tag;
67 import com.evernote.edam.type.User;
68 import com.evernote.thrift.TException;
69 import com.trolltech.qt.QThread;
70 import com.trolltech.qt.core.QByteArray;
71 import com.trolltech.qt.core.QDateTime;
72 import com.trolltech.qt.core.QDir;
73 import com.trolltech.qt.core.QEvent;
74 import com.trolltech.qt.core.QFile;
75 import com.trolltech.qt.core.QFileInfo;
76 import com.trolltech.qt.core.QFileSystemWatcher;
77 import com.trolltech.qt.core.QIODevice;
78 import com.trolltech.qt.core.QIODevice.OpenModeFlag;
79 import com.trolltech.qt.core.QLocale;
80 import com.trolltech.qt.core.QMimeData;
81 import com.trolltech.qt.core.QModelIndex;
82 import com.trolltech.qt.core.QSize;
83 import com.trolltech.qt.core.QTemporaryFile;
84 import com.trolltech.qt.core.QTextCodec;
85 import com.trolltech.qt.core.QTextStream;
86 import com.trolltech.qt.core.QThreadPool;
87 import com.trolltech.qt.core.QTimer;
88 import com.trolltech.qt.core.QTranslator;
89 import com.trolltech.qt.core.QUrl;
90 import com.trolltech.qt.core.Qt;
91 import com.trolltech.qt.core.Qt.BGMode;
92 import com.trolltech.qt.core.Qt.DockWidgetArea;
93 import com.trolltech.qt.core.Qt.ItemDataRole;
94 import com.trolltech.qt.core.Qt.KeyboardModifier;
95 import com.trolltech.qt.core.Qt.MouseButton;
96 import com.trolltech.qt.core.Qt.SortOrder;
97 import com.trolltech.qt.core.Qt.WidgetAttribute;
98 import com.trolltech.qt.gui.QAbstractItemView;
99 import com.trolltech.qt.gui.QAbstractItemView.ScrollHint;
100 import com.trolltech.qt.gui.QAction;
101 import com.trolltech.qt.gui.QApplication;
102 import com.trolltech.qt.gui.QClipboard;
103 import com.trolltech.qt.gui.QCloseEvent;
104 import com.trolltech.qt.gui.QColor;
105 import com.trolltech.qt.gui.QComboBox;
106 import com.trolltech.qt.gui.QCursor;
107 import com.trolltech.qt.gui.QDesktopServices;
108 import com.trolltech.qt.gui.QDialog;
109 import com.trolltech.qt.gui.QFileDialog;
110 import com.trolltech.qt.gui.QFileDialog.AcceptMode;
111 import com.trolltech.qt.gui.QFileDialog.FileMode;
112 import com.trolltech.qt.gui.QGridLayout;
113 import com.trolltech.qt.gui.QHBoxLayout;
114 import com.trolltech.qt.gui.QIcon;
115 import com.trolltech.qt.gui.QImage;
116 import com.trolltech.qt.gui.QKeySequence;
117 import com.trolltech.qt.gui.QLabel;
118 import com.trolltech.qt.gui.QListWidgetItem;
119 import com.trolltech.qt.gui.QMainWindow;
120 import com.trolltech.qt.gui.QMenu;
121 import com.trolltech.qt.gui.QMessageBox;
122 import com.trolltech.qt.gui.QMessageBox.StandardButton;
123 import com.trolltech.qt.gui.QPainter;
124 import com.trolltech.qt.gui.QPalette.ColorRole;
125 import com.trolltech.qt.gui.QPixmap;
126 import com.trolltech.qt.gui.QPrintDialog;
127 import com.trolltech.qt.gui.QPrinter;
128 import com.trolltech.qt.gui.QShortcut;
129 import com.trolltech.qt.gui.QSizePolicy;
130 import com.trolltech.qt.gui.QSizePolicy.Policy;
131 import com.trolltech.qt.gui.QSpinBox;
132 import com.trolltech.qt.gui.QSplashScreen;
133 import com.trolltech.qt.gui.QSplitter;
134 import com.trolltech.qt.gui.QStatusBar;
135 import com.trolltech.qt.gui.QSystemTrayIcon;
136 import com.trolltech.qt.gui.QTableWidgetItem;
137 import com.trolltech.qt.gui.QTextEdit;
138 import com.trolltech.qt.gui.QToolBar;
139 import com.trolltech.qt.gui.QTreeWidgetItem;
140 import com.trolltech.qt.network.QNetworkAccessManager;
141 import com.trolltech.qt.network.QNetworkProxy;
142 import com.trolltech.qt.network.QNetworkProxy.ProxyType;
143 import com.trolltech.qt.network.QNetworkReply;
144 import com.trolltech.qt.network.QNetworkRequest;
145 import com.trolltech.qt.webkit.QWebPage.WebAction;
146 import com.trolltech.qt.webkit.QWebSettings;
147
148 import cx.fbn.nevernote.config.InitializationException;
149 import cx.fbn.nevernote.config.StartupConfig;
150 import cx.fbn.nevernote.dialog.AccountDialog;
151 import cx.fbn.nevernote.dialog.ConfigDialog;
152 import cx.fbn.nevernote.dialog.DBEncryptDialog;
153 import cx.fbn.nevernote.dialog.DatabaseLoginDialog;
154 import cx.fbn.nevernote.dialog.DatabaseStatus;
155 import cx.fbn.nevernote.dialog.FindDialog;
156 import cx.fbn.nevernote.dialog.IgnoreSync;
157 import cx.fbn.nevernote.dialog.LogFileDialog;
158 import cx.fbn.nevernote.dialog.NotebookArchive;
159 import cx.fbn.nevernote.dialog.NotebookEdit;
160 import cx.fbn.nevernote.dialog.OnlineNoteHistory;
161 import cx.fbn.nevernote.dialog.PublishNotebook;
162 import cx.fbn.nevernote.dialog.SavedSearchEdit;
163 import cx.fbn.nevernote.dialog.SetIcon;
164 import cx.fbn.nevernote.dialog.ShareNotebook;
165 import cx.fbn.nevernote.dialog.SharedNotebookSyncError;
166 import cx.fbn.nevernote.dialog.StackNotebook;
167 import cx.fbn.nevernote.dialog.SynchronizationRequiredWarning;
168 import cx.fbn.nevernote.dialog.TagEdit;
169 import cx.fbn.nevernote.dialog.TagMerge;
170 import cx.fbn.nevernote.dialog.ThumbnailViewer;
171 import cx.fbn.nevernote.dialog.UpgradeAvailableDialog;
172 import cx.fbn.nevernote.dialog.WatchFolder;
173 import cx.fbn.nevernote.evernote.NoteMetadata;
174 import cx.fbn.nevernote.filters.FilterEditorNotebooks;
175 import cx.fbn.nevernote.filters.FilterEditorTags;
176 import cx.fbn.nevernote.gui.AttributeTreeWidget;
177 import cx.fbn.nevernote.gui.BrowserWindow;
178 import cx.fbn.nevernote.gui.DateAttributeFilterTable;
179 import cx.fbn.nevernote.gui.ExternalBrowse;
180 import cx.fbn.nevernote.gui.MainMenuBar;
181 import cx.fbn.nevernote.gui.NotebookTreeWidget;
182 import cx.fbn.nevernote.gui.RensoNoteList;
183 import cx.fbn.nevernote.gui.RensoNoteListDock;
184 import cx.fbn.nevernote.gui.SavedSearchTreeWidget;
185 import cx.fbn.nevernote.gui.SearchPanel;
186 import cx.fbn.nevernote.gui.TabBrowse;
187 import cx.fbn.nevernote.gui.TabBrowserWidget;
188 import cx.fbn.nevernote.gui.TableView;
189 import cx.fbn.nevernote.gui.TagTreeWidget;
190 import cx.fbn.nevernote.gui.Thumbnailer;
191 import cx.fbn.nevernote.gui.TrashTreeWidget;
192 import cx.fbn.nevernote.gui.controls.QuotaProgressBar;
193 import cx.fbn.nevernote.neighbornote.ClipBoardObserver;
194 import cx.fbn.nevernote.oauth.OAuthTokenizer;
195 import cx.fbn.nevernote.oauth.OAuthWindow;
196 import cx.fbn.nevernote.sql.DatabaseConnection;
197 import cx.fbn.nevernote.sql.WatchFolderRecord;
198 import cx.fbn.nevernote.threads.IndexRunner;
199 import cx.fbn.nevernote.threads.SyncRunner;
200 import cx.fbn.nevernote.threads.ThumbnailRunner;
201 import cx.fbn.nevernote.utilities.AESEncrypter;
202 import cx.fbn.nevernote.utilities.ApplicationLogger;
203 import cx.fbn.nevernote.utilities.FileImporter;
204 import cx.fbn.nevernote.utilities.FileUtils;
205 import cx.fbn.nevernote.utilities.ListManager;
206 import cx.fbn.nevernote.utilities.SyncTimes;
207 import cx.fbn.nevernote.xml.ExportData;
208 import cx.fbn.nevernote.xml.ImportData;
209 import cx.fbn.nevernote.xml.ImportEnex;
210 import cx.fbn.nevernote.xml.NoteFormatter;
211 //import org.apache.thrift.TException;
212
213
214 public class NeverNote extends QMainWindow{
215         
216         QStatusBar                              statusBar;                                      // Application status bar
217         
218         DatabaseConnection              conn;
219         
220         MainMenuBar                             menuBar;                                        // Main menu bar
221         FindDialog                              find;                                           // Text search in note dialog
222         List<String>                    emitLog;                                        // Messages displayed in the status bar;
223         QSystemTrayIcon                 trayIcon;                                       // little tray icon
224         QMenu                                   trayMenu;                                       // System tray menu
225         QAction                                 trayExitAction;                         // Exit the application
226         QAction                                 trayShowAction;                         // toggle the show/hide action          
227         QAction                                 trayAddNoteAction;                      // Add a note from the system tray
228         QNetworkAccessManager   versionChecker;                         // Used when checking for new versions
229         
230     NotebookTreeWidget          notebookTree;                           // List of notebooks
231     AttributeTreeWidget         attributeTree;                          // List of note attributes
232     TagTreeWidget                       tagTree;                                        // list of user created tags
233     SavedSearchTreeWidget       savedSearchTree;                        // list of saved searches
234     TrashTreeWidget                     trashTree;                                      // Trashcan
235     TableView                           noteTableView;                          //      List of notes (the widget).
236
237     public BrowserWindow        browserWindow;                          // Window containing browser & labels
238     public QToolBar             toolBar;                                        // The tool bar under the menu
239     QComboBox                           searchField;                            // search filter bar on the toolbar;
240     QShortcut                           searchShortcut;                         // Shortcut to search bar
241     boolean                                     searchPerformed = false;        // Search was done?
242     QuotaProgressBar            quotaBar;                                       // The current quota usage
243     
244     ApplicationLogger           logger;
245     List<String>                        selectedNotebookGUIDs;          // List of notebook GUIDs
246     List<String>                        selectedTagGUIDs;                       // List of selected tag GUIDs
247     List<String>                        selectedNoteGUIDs;                      // List of selected notes
248     String                                      selectedSavedSearchGUID;        // Currently selected saved searches
249     private final HashMap<String, ExternalBrowse>       externalWindows;        // Notes being edited by an external window;
250     
251     NoteFilter                          filter;                                         // Note filter
252     String                                      currentNoteGuid;                        // GUID of the current note 
253     Note                                        currentNote;                            // The currently viewed note
254     // ICHANGED
255     HashMap<Integer, Boolean>   noteDirty;                              // Has the note been changed?
256     HashMap<Integer, Boolean>   inkNote;                // if this is an ink note, it is read only
257     HashMap<Integer, Boolean>   readOnly;                               // Is this note read-only?
258         
259   
260     ListManager                         listManager;                                    // DB runnable task
261     
262     List<QTemporaryFile>        tempFiles;                                      // Array of temporary files;
263     
264     QTimer                                      indexTimer;                                     // timer to start the index thread
265     IndexRunner                         indexRunner;                            // thread to index notes
266     QThread                                     indexThread;
267     
268     QTimer                                      syncTimer;                                      // Sync on an interval
269     QTimer                                      syncDelayTimer;                         // Sync delay to free up database
270     SyncRunner                          syncRunner;                                     // thread to do a sync.
271     QThread                                     syncThread;                                     // Thread which talks to evernote
272     ThumbnailRunner                     thumbnailRunner;                        // Runner for thumbnail thread
273     QThread                                     thumbnailThread;                        // Thread that generates pretty pictures
274     QTimer                                      saveTimer;                                      // Timer to save note contents
275     
276     QTimer                                      authTimer;                                      // Refresh authentication
277     QTimer                                      externalFileSaveTimer;          // Save files altered externally
278     QTimer                                      thumbnailTimer;                         // Wakeup & scan for thumbnails
279     QTimer                                      debugTimer;
280     List<String>                        externalFiles;                          // External files to save later
281     List<String>                        importFilesKeep;                        // Auto-import files to save later
282     List<String>                        importFilesDelete;                      // Auto-import files to save later
283     
284     int                                         indexTime;                                      // how often to try and index
285     boolean                                     indexRunning;                           // Is indexing running?
286     boolean                                     indexDisabled;                          // Is indexing disabled?
287     
288     int                                         syncThreadsReady;                       // number of sync threads that are free
289     int                                         syncTime;                                       // Sync interval
290     boolean                                     syncRunning;                            // Is sync running?
291     boolean                                     automaticSync;                          // do sync automatically?
292     QTreeWidgetItem                     attributeTreeSelected;
293
294     QAction                             prevButton;                                     // Go to the previous item viewed
295     QAction                             nextButton;                                     // Go to the next item in the history
296     QAction                             downButton;                                     // Go to the next item in the list
297     QAction                             upButton;                                       // Go to the prev. item in the list;
298     QAction                             synchronizeButton;                      // Synchronize with Evernote
299     QAction                             allNotesButton;                         // Reset & view all notes
300     QTimer                              synchronizeAnimationTimer;      // Timer to change animation button
301     int                                 synchronizeIconAngle;           // Used to rotate sync icon
302     QAction                     printButton;                            // Print Button
303     QAction                             tagButton;                                      // Tag edit button
304     QAction                             attributeButton;                        // Attribute information button
305     QAction                     emailButton;                            // Email button
306     QAction                     deleteButton;                           // Delete button
307     QAction                             newButton;                                      // new Note Button;
308     QSpinBox                    zoomSpinner;                            // Zoom zoom
309     QAction                             searchClearButton;                      // Clear the search field
310     
311     SearchPanel                 searchLayout;                           // Widget to hold search field, zoom, & quota
312     
313     QSplitter                   mainLeftRightSplitter;          // main splitter for left/right side
314     QSplitter                   leftSplitter1;                          // first left hand splitter
315     QSplitter                   browserIndexSplitter;           // splitter between note index & note text
316     
317     QFileSystemWatcher  importKeepWatcher;                      // Watch & keep auto-import
318     QFileSystemWatcher  importDeleteWatcher;            // Watch & Delete auto-import
319     List<String>                importedFiles;                          // History of imported files (so we don't import twice)
320     
321     OnlineNoteHistory   historyWindow;                          // online history window 
322     List<NoteVersionId> versions;                                       // history versions
323     
324     QTimer                              threadMonitorTimer;                     // Timer to watch threads.
325     int                                 dbThreadDeadCount=0;            // number of consecutive dead times for the db thread
326     int                                 syncThreadDeadCount=0;          // number of consecutive dead times for the sync thread
327     int                                 indexThreadDeadCount=0;         // number of consecutive dead times for the index thread
328     int                                 notebookThreadDeadCount=0;      // number of consecutive dead times for the notebook thread
329     int                                 tagDeadCount=0;                         // number of consecutive dead times for the tag thread
330     int                                 trashDeadCount=0;                       // number of consecutive dead times for the trash thread
331     int                                 saveThreadDeadCount=0;          // number of consecutive dead times for the save thread
332     int                                 enRelatedNotesThreadDeadCount=0;        // number of consecutive dead times for the EvernoteRelatedNotes Thread
333     boolean                             disableTagThreadCheck=false;
334     boolean                             disableNotebookThreadCheck=false;
335     boolean                             disableTrashThreadCheck=false;
336     boolean                             disableSaveThreadCheck=false;
337     boolean                             disableSyncThreadCheck=false;
338     boolean                             disableIndexThreadCheck=false;
339     boolean                             disableENRelatedNotesThreadCheck=false;
340     
341     HashMap<String, String>             noteCache;                      // Cash of note content 
342     HashMap<String, Boolean>    readOnlyCache;          // List of cashe notes that are read-only
343     HashMap<String, Boolean>    inkNoteCache;           // List of cache notes that are ink notes 
344         // ICHANGED
345         HashMap<Integer, ArrayList<String>> historyGuids;  // タブごとの以前見たノートのGUID
346         HashMap<Integer, Integer> historyPosition; // Position within the viewed items
347         HashMap<Integer, Boolean> fromHistory; // Is this from the history queue?
348         
349     String                              trashNoteGuid;                          // Guid to restore / set into or out of trash to save position
350     List<Thumbnailer>   thumbGenerators;                                // generate preview image
351     ThumbnailViewer             thumbnailViewer;                        // View preview thumbnail; 
352     boolean                             encryptOnShutdown;                      // should I encrypt when I close?
353     boolean                             decryptOnShutdown;                      // should I decrypt on shutdown;
354     String                              encryptCipher;                          // What cipher should I use?
355     //Signal0                   minimizeToTray;
356     boolean                             windowMaximized = false;        // Keep track of the window state for restores
357     List<String>                pdfReadyQueue;                          // Queue of PDFs that are ready to be rendered.
358     List<QPixmap>               syncIcons;                                      // Array of icons used in sync animation
359     private boolean             closeAction = false;            // Used to say when to close or when to minimize
360     private static Logger log = Logger.getLogger(NeverNote.class); 
361     private String              saveLastPath;                           // last path we used
362     private final QTimer                messageTimer;                           // Timer to clear the status message.
363     private QTimer              blockTimer;
364     BrowserWindow               blockingWindow;
365     
366         // ICHANGED
367         private final TabBrowserWidget tabBrowser; // ブラウザウィンドウをタブ化
368         private final HashMap<Integer, TabBrowse> tabWindows; // タブウィンドウ
369         private final RensoNoteListDock rensoNoteListDock; // 連想ノートリストドックウィジェット
370         ClipBoardObserver cbObserver;
371         String rensoNotePressedItemGuid;
372         
373     String iconPath = new String("classpath:cx/fbn/nevernote/icons/");
374         
375         
376     //***************************************************************
377     //***************************************************************
378     //** Constructor & main entry point
379     //***************************************************************
380     //***************************************************************
381     // Application Constructor  
382         @SuppressWarnings("static-access")
383         public NeverNote(DatabaseConnection dbConn)  {
384                 // ICHANGED
385                 cbObserver = new ClipBoardObserver();
386                 
387                 conn = dbConn;          
388                 if (conn.getConnection() == null) {
389                         String msg = new String(tr("Unable to connect to the database.\n\nThe most probable reason is that some other process\n" +
390                                 "is accessing the database or NeighborNote is already running.\n\n" +
391                                 "Please end any other process or shutdown the other NeighborNote before starting.\n\nExiting program."));
392                         
393             QMessageBox.critical(null, tr("Database Connection Error") ,msg);
394                         System.exit(16);
395                 }
396                 setObjectName("mainWindow");
397 //              thread().setPriority(Thread.MAX_PRIORITY);
398                 
399                 logger = new ApplicationLogger("nevernote.log");
400                 logger.log(logger.HIGH, "Starting Application");
401                 
402                 decryptOnShutdown = false;
403                 encryptOnShutdown = false;
404                 conn.checkDatabaseVersion();
405                 
406                 
407                 
408                 // Start building the invalid XML tables
409                 Global.invalidElements = conn.getInvalidXMLTable().getInvalidElements();
410                 List<String> elements = conn.getInvalidXMLTable().getInvalidAttributeElements();
411                 
412                 for (int i=0; i<elements.size(); i++) {
413                         Global.invalidAttributes.put(elements.get(i), conn.getInvalidXMLTable().getInvalidAttributes(elements.get(i)));
414                 }
415                 
416                 logger.log(logger.EXTREME, "Starting GUI build");
417
418                 QTranslator nevernoteTranslator = new QTranslator();
419                 nevernoteTranslator.load(Global.getFileManager().getTranslateFilePath("neighbornote_" + QLocale.system().name() + ".qm"));
420                 QApplication.instance().installTranslator(nevernoteTranslator);
421
422                 Global.originalPalette = QApplication.palette();
423                 QApplication.setStyle(Global.getStyle());
424                 if (Global.useStandardPalette())
425                         QApplication.setPalette(QApplication.style().standardPalette());
426         setWindowTitle(tr("NeighborNote"));
427
428         mainLeftRightSplitter = new QSplitter();
429                 // ICHANGED
430                 mainLeftRightSplitter.setOrientation(Qt.Orientation.Horizontal);
431                 
432         setCentralWidget(mainLeftRightSplitter);
433         leftSplitter1 = new QSplitter();
434         leftSplitter1.setOrientation(Qt.Orientation.Vertical);
435                 
436         browserIndexSplitter = new QSplitter();
437         browserIndexSplitter.setOrientation(Qt.Orientation.Vertical);
438         
439         //* Setup threads & thread timers
440 //        int indexRunnerCount = Global.getIndexThreads();
441 //       indexRunnerCount = 1;
442         QThreadPool.globalInstance().setMaxThreadCount(Global.threadCount);     // increase max thread count
443
444                 logger.log(logger.EXTREME, "Building list manager");
445         listManager = new ListManager(conn, logger);
446         
447                 logger.log(logger.EXTREME, "Building index runners & timers");
448                 // ICHANGED Global.getBehaviorDatabaseUrl()を追加
449                 indexRunner = new IndexRunner("indexRunner.log",
450                                 Global.getDatabaseUrl(), Global.getIndexDatabaseUrl(),
451                                 Global.getResourceDatabaseUrl(),
452                                 Global.getBehaviorDatabaseUrl(), Global.getDatabaseUserid(),
453                                 Global.getDatabaseUserPassword(), Global.cipherPassword);
454                 
455                 indexThread = new QThread(indexRunner, "Index Thread");
456         indexRunner.indexAttachmentsLocally = Global.indexAttachmentsLocally();
457         indexRunner.indexImageRecognition = Global.indexImageRecognition();
458 //        indexRunner.indexNoteBody = Global.indexNoteBody();
459 //        indexRunner.indexNoteTitle = Global.indexNoteTitle();
460 //        indexRunner.specialIndexCharacters = Global.getSpecialIndexCharacters();
461                 indexThread.start();
462                 
463         synchronizeAnimationTimer = new QTimer();
464         synchronizeAnimationTimer.timeout.connect(this, "updateSyncButton()");
465         
466                 indexTimer = new QTimer();
467                 indexTime = 1000*Global.getIndexThreadSleepInterval();  
468                 indexTimer.start(indexTime);  // Start indexing timer
469                 indexTimer.timeout.connect(this, "indexTimer()");
470                 indexDisabled = false;
471                 indexRunning = false;
472                                 
473                 logger.log(logger.EXTREME, "Setting sync thread & timers");
474                 syncThreadsReady=1;
475                 // ICHANGED Global.getBehaviorDatabaseUrl()を追加
476                 syncRunner = new SyncRunner("syncRunner.log", Global.getDatabaseUrl(),
477                                 Global.getIndexDatabaseUrl(), Global.getResourceDatabaseUrl(),
478                                 Global.getBehaviorDatabaseUrl(), Global.getDatabaseUserid(),
479                                 Global.getDatabaseUserPassword(), Global.cipherPassword);
480                 
481                 syncTime = new SyncTimes().timeValue(Global.getSyncInterval());
482                 syncTimer = new QTimer();
483                 syncTimer.timeout.connect(this, "syncTimer()");
484         syncRunner.status.message.connect(this, "setMessage(String)");
485         syncRunner.syncSignal.finished.connect(this, "syncThreadComplete(Boolean)");
486         syncRunner.syncSignal.errorDisconnect.connect(this, "remoteErrorDisconnect()");
487         syncRunning = false;    
488                 if (syncTime > 0) {
489                         automaticSync = true;
490                         syncTimer.start(syncTime*60*1000);
491                 } else {
492                         automaticSync = false;
493                         syncTimer.stop();
494                 }
495                 syncRunner.setEvernoteUpdateCount(Global.getEvernoteUpdateCount());
496                 syncThread = new QThread(syncRunner, "Synchronization Thread");
497                 syncThread.start();
498                 
499                 
500                 logger.log(logger.EXTREME, "Starting thumnail thread");
501                 pdfReadyQueue = new ArrayList<String>();
502                 // ICHANGED Global.getBehaviorDatabaseUrl()を追加
503                 thumbnailRunner = new ThumbnailRunner("thumbnailRunner.log",
504                                 Global.getDatabaseUrl(), Global.getIndexDatabaseUrl(),
505                                 Global.getResourceDatabaseUrl(),
506                                 Global.getBehaviorDatabaseUrl(), Global.getDatabaseUserid(),
507                                 Global.getDatabaseUserPassword(), Global.cipherPassword);
508                 
509                 thumbnailThread = new QThread(thumbnailRunner, "Thumbnail Thread");
510                 thumbnailRunner.noteSignal.thumbnailPageReady.connect(this, "thumbnailHTMLReady(String,QByteArray,Integer)");
511                 thumbnailThread.start();
512                 thumbGenerators = new ArrayList<Thumbnailer>();
513                 thumbnailTimer = new QTimer();
514                 thumbnailTimer.timeout.connect(this, "thumbnailTimer()");
515                 thumbnailTimer();
516                 thumbnailTimer.setInterval(500*1000);  // Thumbnail every minute
517                 thumbnailTimer.start();
518                 
519 //              debugTimer = new QTimer();
520 //              debugTimer.timeout.connect(this, "debugDirty()");
521 //              debugTimer.start(1000*60);
522                 
523                 logger.log(logger.EXTREME, "Starting authentication timer");
524                 authTimer = new QTimer();
525                 authTimer.timeout.connect(this, "authTimer()");
526                 authTimer.start(1000*60*15);
527                 syncRunner.syncSignal.authRefreshComplete.connect(this, "authRefreshComplete(boolean)");
528                 
529                 logger.log(logger.EXTREME, "Setting save note timer");
530                 saveTimer = new QTimer();
531                 saveTimer.timeout.connect(this, "saveNote()");
532                 if (Global.getAutoSaveInterval() > 0) {
533                         saveTimer.setInterval(1000*60*Global.getAutoSaveInterval()); 
534                         saveTimer.start();
535                 }
536                 listManager.saveRunner.noteSignals.noteSaveRunnerError.connect(this, "saveRunnerError(String, String)");
537                 
538                 logger.log(logger.EXTREME, "Starting external file monitor timer");
539                 externalFileSaveTimer = new QTimer();
540                 externalFileSaveTimer.timeout.connect(this, "externalFileEditedSaver()");
541                 externalFileSaveTimer.setInterval(1000*5);   // save every 5 seconds;
542                 externalFiles = new ArrayList<String>();
543                 importFilesDelete = new ArrayList<String>();
544                 importFilesKeep = new ArrayList<String>();
545                 externalFileSaveTimer.start();
546                 
547         notebookTree = new NotebookTreeWidget(conn);
548         attributeTree = new AttributeTreeWidget();
549         tagTree = new TagTreeWidget(conn);
550         savedSearchTree = new SavedSearchTreeWidget();
551         trashTree = new TrashTreeWidget();
552                 // ICHANGED
553                 noteTableView = new TableView(logger, listManager, this);     
554         
555         searchField = new QComboBox();
556         searchField.setObjectName("searchField");
557         //setStyleSheet("QComboBox#searchField { background-color: yellow }");
558         searchField.setEditable(true);
559         searchField.activatedIndex.connect(this, "searchFieldChanged()");
560         searchField.setDuplicatesEnabled(false);
561         searchField.editTextChanged.connect(this,"searchFieldTextChanged(String)");
562         searchShortcut = new QShortcut(this);
563         setupShortcut(searchShortcut, "Focus_Search");
564         searchShortcut.activated.connect(this, "focusSearch()");
565         
566         quotaBar = new QuotaProgressBar();
567         // Setup the zoom
568         zoomSpinner = new QSpinBox();
569         zoomSpinner.setMinimum(10);
570         zoomSpinner.setMaximum(1000);
571         zoomSpinner.setAccelerated(true);
572         zoomSpinner.setSingleStep(10);
573         zoomSpinner.setValue(100);
574         zoomSpinner.valueChanged.connect(this, "zoomChanged()");
575         
576         searchLayout = new SearchPanel(searchField, quotaBar, notebookTree, zoomSpinner);
577         
578         
579         QGridLayout leftGrid = new QGridLayout();
580         leftSplitter1.setContentsMargins(5, 0, 0, 7);
581         leftSplitter1.setLayout(leftGrid);
582         leftGrid.addWidget(searchLayout,1,1);
583         leftGrid.addWidget(tagTree,2,1);
584         leftGrid.addWidget(attributeTree,3,1);
585         leftGrid.addWidget(savedSearchTree,4,1);
586         leftGrid.addWidget(trashTree,5, 1);
587         
588         // Setup the browser window
589         noteCache = new HashMap<String,String>();
590         readOnlyCache = new HashMap<String, Boolean>();
591         inkNoteCache = new HashMap<String, Boolean>();
592         // ICHANGED
593         browserWindow = new BrowserWindow(conn, cbObserver);
594
595                 // ICHANGED 下から移動してきた。
596                 historyGuids = new HashMap<Integer, ArrayList<String>>();
597                 historyPosition = new HashMap<Integer, Integer>();
598                 fromHistory = new HashMap<Integer, Boolean>();
599                 
600                 // ICHANGED タブブラウザ作成
601                 tabWindows = new HashMap<Integer, TabBrowse>();
602                 tabBrowser = new TabBrowserWidget(this);
603                 tabBrowser.setStyleSheet("QTabBar::tab{width:150px;}");
604                 tabBrowser.setMovable(true);
605                 tabBrowser.setTabsClosable(true);
606                 TabBrowse tab = new TabBrowse(conn, tabBrowser, cbObserver);
607                 browserWindow = tab.getBrowserWindow();
608                 int index = tabBrowser.addNewTab(tab, "");
609                 tabWindows.put(index, tab);
610                 tabBrowser.currentChanged.connect(this, "tabWindowChanged(int)");
611                 tabBrowser.tabCloseRequested.connect(this, "tabWindowClosing(int)");
612                 
613                 noteDirty = new HashMap<Integer, Boolean>();
614                 noteDirty.put(index, false);
615                 
616                 inkNote = new HashMap<Integer, Boolean>();
617                 readOnly = new HashMap<Integer, Boolean>();
618
619                 // ICHANGED
620                 // 履歴記録のハッシュマップを初期化
621                 historyGuids.put(index, new ArrayList<String>());
622                 historyPosition.put(index, 0);
623                 fromHistory.put(index, false);
624                 
625         mainLeftRightSplitter.addWidget(leftSplitter1);
626         mainLeftRightSplitter.addWidget(browserIndexSplitter);
627         
628                 // ICHANGED
629                 // 連想ノートリストをセットアップ
630         rensoNoteListDock = new RensoNoteListDock(conn, this, syncRunner, iconPath, tr("Renso Note List"));
631                 addDockWidget(DockWidgetArea.RightDockWidgetArea, rensoNoteListDock);
632
633                 if (Global.getListView() == Global.View_List_Wide) {
634                         browserIndexSplitter.addWidget(noteTableView);
635                         // ICHANGED
636                         browserIndexSplitter.addWidget(tabBrowser);
637                         // browserIndexSplitter.addWidget(browserWindow);
638                 } else {
639                         mainLeftRightSplitter.addWidget(noteTableView);
640                         // ICHANGED
641                         mainLeftRightSplitter.addWidget(tabBrowser);
642                         // mainLeftRightSplitter.addWidget(browserWindow);
643                 }
644         
645         // Setup the thumbnail viewer
646         thumbnailViewer = new ThumbnailViewer();
647         thumbnailViewer.upArrow.connect(this, "upAction()");
648         thumbnailViewer.downArrow.connect(this, "downAction()");
649         thumbnailViewer.leftArrow.connect(this, "nextViewedAction()");
650         thumbnailViewer.rightArrow.connect(this, "previousViewedAction()");
651         
652         //Setup external browser manager
653         externalWindows = new HashMap<String, ExternalBrowse>();
654
655         listManager.loadNotesIndex();
656         initializeNotebookTree();
657         initializeTagTree();
658         initializeSavedSearchTree();
659         attributeTree.itemClicked.connect(this, "attributeTreeClicked(QTreeWidgetItem, Integer)");
660         attributeTreeSelected = null;
661         initializeNoteTable();    
662
663                 selectedNoteGUIDs = new ArrayList<String>();
664                 statusBar = new QStatusBar();
665                 setStatusBar(statusBar);
666                 menuBar = new MainMenuBar(this);
667                 emitLog = new ArrayList<String>();
668                 
669                 tagTree.setDeleteAction(menuBar.tagDeleteAction);
670                 tagTree.setMergeAction(menuBar.tagMergeAction);
671                 tagTree.setEditAction(menuBar.tagEditAction);
672                 tagTree.setAddAction(menuBar.tagAddAction);
673                 tagTree.setIconAction(menuBar.tagIconAction);
674                 tagTree.setVisible(Global.isWindowVisible("tagTree"));
675                 leftSplitter1.setVisible(Global.isWindowVisible("leftPanel"));
676                 tagTree.noteSignal.tagsAdded.connect(this, "tagsAdded(String, String)");
677                 menuBar.hideTags.setChecked(Global.isWindowVisible("tagTree"));
678                 listManager.tagSignal.listChanged.connect(this, "reloadTagTree()");
679                 
680                 if (!Global.isWindowVisible("zoom")) {
681                         searchLayout.hideZoom();
682                         menuBar.hideZoom.setChecked(false);
683                 } 
684         
685                 notebookTree.setDeleteAction(menuBar.notebookDeleteAction);
686                 notebookTree.setEditAction(menuBar.notebookEditAction);
687                 notebookTree.setAddAction(menuBar.notebookAddAction);
688                 notebookTree.setIconAction(menuBar.notebookIconAction);
689                 notebookTree.setStackAction(menuBar.notebookStackAction);
690                 notebookTree.setPublishAction(menuBar.notebookPublishAction);
691                 notebookTree.setShareAction(menuBar.notebookShareAction);
692                 notebookTree.setVisible(Global.isWindowVisible("notebookTree"));
693                 notebookTree.noteSignal.notebookChanged.connect(this, "updateNoteNotebook(String, String)");
694                 notebookTree.noteSignal.tagsChanged.connect(this, "updateNoteTags(String, List)");
695             notebookTree.noteSignal.tagsChanged.connect(this, "updateListTags(String, List)");
696                 menuBar.hideNotebooks.setChecked(Global.isWindowVisible("notebookTree"));
697
698                 savedSearchTree.setAddAction(menuBar.savedSearchAddAction);
699                 savedSearchTree.setEditAction(menuBar.savedSearchEditAction);
700                 savedSearchTree.setDeleteAction(menuBar.savedSearchDeleteAction);
701                 savedSearchTree.setIconAction(menuBar.savedSearchIconAction);
702                 savedSearchTree.itemSelectionChanged.connect(this, "updateSavedSearchSelection()");
703                 savedSearchTree.setVisible(Global.isWindowVisible("savedSearchTree"));
704                 menuBar.hideSavedSearches.setChecked(Global.isWindowVisible("savedSearchTree"));
705                 
706                 // ICHANGED noteTableViewに新しいタブで開くを追加
707                 noteTableView.setOpenNewTabAction(menuBar.noteOpenNewTab);
708                         
709                 noteTableView.setAddAction(menuBar.noteAdd);
710                 
711                 // ICHANGED noteTableViewに新しいタブでノート追加を追加
712                 noteTableView.setAddNoteNewTabAction(menuBar.noteAddNewTab);
713                 
714                 noteTableView.setDeleteAction(menuBar.noteDelete);
715                 noteTableView.setRestoreAction(menuBar.noteRestoreAction);
716                 noteTableView.setNoteDuplicateAction(menuBar.noteDuplicateAction);
717                 noteTableView.setNoteHistoryAction(menuBar.noteOnlineHistoryAction);
718                 noteTableView.noteSignal.titleColorChanged.connect(this, "titleColorChanged(Integer)");
719                 noteTableView.noteSignal.notePinned.connect(this, "notePinned()");
720                 noteTableView.setMergeNotesAction(menuBar.noteMergeAction);
721                 noteTableView.setCopyAsUrlAction(menuBar.noteCopyAsUrlAction);
722                 noteTableView.doubleClicked.connect(this, "listDoubleClick()");
723                 listManager.trashSignal.countChanged.connect(trashTree, "updateCounts(Integer)");
724                 
725                 quotaBar.setMouseClickAction(menuBar.accountAction);
726                 
727                 trashTree.load();
728         trashTree.itemSelectionChanged.connect(this, "trashTreeSelection()");
729                 trashTree.setEmptyAction(menuBar.emptyTrashAction);
730                 trashTree.setVisible(Global.isWindowVisible("trashTree"));
731                 menuBar.hideTrash.setChecked(Global.isWindowVisible("trashTree"));
732                 trashTree.updateCounts(listManager.getTrashCount());
733                 attributeTree.setVisible(Global.isWindowVisible("attributeTree"));
734                 menuBar.hideAttributes.setChecked(Global.isWindowVisible("attributeTree"));
735
736                 noteTableView.setVisible(Global.isWindowVisible("noteList"));
737                 menuBar.hideNoteList.setChecked(Global.isWindowVisible("noteList"));
738                 
739                 // ICHANGED
740                 if (!Global.isWindowVisible("editorButtonBar")) {
741                         menuBar.showEditorBar.setChecked(false);
742                         toggleEditorButtonBar();
743                 }
744                 
745                 if (!Global.isWindowVisible("leftPanel"))
746                         menuBar.hideLeftSide.setChecked(true);
747                 
748                 // ICHANGED
749                 if (Global.isWindowVisible("noteInformation")) {
750                         menuBar.noteAttributes.setChecked(true);
751                         toggleNoteInformation();
752                 }
753                 
754                 quotaBar.setVisible(Global.isWindowVisible("quota"));
755                 // IFIXED quotaBar.isVisible() → Global.isWindowVisible("quota")
756                 // なぜかquotaBar.isVisible()が常にfalseを返すようなので修正
757                 if (!Global.isWindowVisible("quota"))
758                         menuBar.hideQuota.setChecked(false);
759                 
760                 searchField.setVisible(Global.isWindowVisible("searchField"));
761                 // IFIXED !searchField.isVisible() → !Global.isWindowVisible("searchField")
762                 // なぜかsearchField.isVisible()が常にfalseを返すようなので修正
763                 if (!Global.isWindowVisible("searchField"))
764                         menuBar.hideSearch.setChecked(false);
765                 
766                 if (searchField.isHidden() && quotaBar.isHidden() && zoomSpinner.isHidden() && notebookTree.isHidden())
767                         searchLayout.hide();
768                 
769                 setMenuBar(menuBar);
770                 setupToolBar();
771                 find = new FindDialog();
772                 find.getOkButton().clicked.connect(this, "doFindText()");
773                 
774                 // Setup the tray icon menu bar
775                 trayShowAction = new QAction(tr("Show/Hide"), this);
776                 trayExitAction = new QAction(tr("Exit"), this);
777                 trayAddNoteAction = new QAction(tr("Add Note"), this);
778                 
779                 trayExitAction.triggered.connect(this, "closeNeverNote()");
780                 trayAddNoteAction.triggered.connect(this, "addNote()");
781                 trayShowAction.triggered.connect(this, "trayToggleVisible()");
782                 
783                 trayMenu = new QMenu(this);
784                 trayMenu.addAction(trayAddNoteAction);
785                 trayMenu.addAction(trayShowAction);
786                 trayMenu.addAction(trayExitAction);
787                 
788                 
789                 trayIcon = new QSystemTrayIcon(this);
790                 trayIcon.setToolTip(tr("NeighborNote"));
791                 trayIcon.setContextMenu(trayMenu);
792                 trayIcon.activated.connect(this, "trayActivated(com.trolltech.qt.gui.QSystemTrayIcon$ActivationReason)");
793
794                 currentNoteGuid="";
795                 currentNoteGuid = Global.getLastViewedNoteGuid();
796                 if (currentNoteGuid.equals(""))
797                         currentNote = new Note();
798                 
799                 // ICHANGED
800                 /* 上に移動したので要らない
801                 historyGuids = new ArrayList<String>();
802                 historyPosition = 0;
803                 fromHistory = false;
804                 */
805                 
806                 if (!currentNoteGuid.trim().equals("")) {
807                         currentNote = conn.getNoteTable().getNote(currentNoteGuid, true,true,false,false,true);
808                 }
809                 
810                 noteIndexUpdated(true);
811                 showColumns();
812                 menuBar.showEditorBar.setChecked(Global.isWindowVisible("editorButtonBar"));
813                 if (menuBar.showEditorBar.isChecked())
814                 showEditorButtons(browserWindow);
815                 tagIndexUpdated(true);
816                 savedSearchIndexUpdated();
817                 notebookIndexUpdated();
818                 updateQuotaBar();
819         setupSyncSignalListeners();        
820         setupBrowserSignalListeners();
821         setupIndexListeners();
822               
823         
824         tagTree.tagSignal.listChanged.connect(this, "tagIndexUpdated()");
825         tagTree.showAllTags(true);
826
827                 QIcon appIcon = new QIcon(iconPath+"nevernote.png");
828                 if (QSystemTrayIcon.isSystemTrayAvailable()) {
829                         setWindowIcon(appIcon);
830                         trayIcon.setIcon(appIcon);
831                         if (Global.showTrayIcon() || Global.minimizeOnClose())
832                                 trayIcon.show();
833                         else
834                                 trayIcon.hide();
835                 }
836         
837         scrollToGuid(currentNoteGuid);
838         if (Global.automaticLogin()) {
839                 remoteConnect();
840                 if (Global.isConnected)
841                         syncTimer();
842         }
843         setupFolderImports();
844         
845         loadStyleSheet();
846         restoreWindowState(true);
847         
848         if (Global.mimicEvernoteInterface) {
849                 notebookTree.selectGuid("");
850         }
851         
852         threadMonitorTimer = new QTimer();
853         threadMonitorTimer.timeout.connect(this, "threadMonitorCheck()");
854         threadMonitorTimer.start(1000*10);  // Check for threads every 10 seconds;              
855         
856                 // ICHANGED たぶんこれはいらない
857                 // IFIXED ?
858                 /*
859                 historyGuids.add(currentNoteGuid);
860                 historyPosition = 1;
861                 */
862         
863         menuBar.blockSignals(true);
864         menuBar.narrowListView.blockSignals(true);
865         menuBar.wideListView.blockSignals(true);
866         if (Global.getListView() == Global.View_List_Narrow) { 
867                 menuBar.narrowListView.setChecked(true);
868         }
869         else{ 
870                 menuBar.wideListView.setChecked(true);
871         }
872         menuBar.blockSignals(false);
873         menuBar.narrowListView.blockSignals(false);
874         menuBar.wideListView.blockSignals(false);
875         
876                 // IFIXED
877                 // 上に同じコードがあるよね? とりあえずコメントアウト
878                 /*
879                  * if (Global.getListView() == Global.View_List_Wide) {
880                  * browserIndexSplitter.addWidget(noteTableView); // ICHANGED //
881                  * browserIndexSplitter.addWidget(tabBrowser);
882                  * browserIndexSplitter.addWidget(browserWindow); } else {
883                  * mainLeftRightSplitter.addWidget(noteTableView); // ICHANGED //
884                  * mainLeftRightSplitter.addWidget(tabBrowser);
885                  * mainLeftRightSplitter.addWidget(browserWindow); }
886                  */
887         
888                 messageTimer = new QTimer();
889                 messageTimer.timeout.connect(this, "clearMessage()");
890                 messageTimer.setInterval(1000*15);
891                 clearMessage();
892         
893         int sortCol = Global.getSortColumn();
894                 int sortOrder = Global.getSortOrder();
895                 noteTableView.proxyModel.blocked = true;
896                 // We sort the table twice to fix a bug.  For some reaosn the table won't sort properly if it is in narrow
897                 // list view and sorted descending on the date  created.  By sorting it twice it forces the proper sort.  Ugly.
898                 if (sortCol == 0 && sortOrder == 1 && Global.getListView() == Global.View_List_Narrow) 
899                         noteTableView.sortByColumn(sortCol, SortOrder.resolve(0));   
900                 noteTableView.sortByColumn(sortCol, SortOrder.resolve(sortOrder));
901                 noteTableView.proxyModel.blocked = false;
902                 noteTableView.proxyModel.sortChanged.connect(this, "tableSortOrderChanged(Integer,Integer)");
903                 
904                 // Set the startup notebook
905         String defaultNotebook = Global.getStartupNotebook();
906         if (!defaultNotebook.equals("AllNotebooks") && !defaultNotebook.equals("")) {
907                 for (int k=0; k<listManager.getNotebookIndex().size(); k++) {
908                         if (listManager.getNotebookIndex().get(k).isDefaultNotebook()) {
909                                 notebookTree.clearSelection();
910                                 notebookTree.selectGuid(listManager.getNotebookIndex().get(k).getGuid());
911                                 notebookTree.selectionSignal.emit();
912                         }
913                 }
914         }
915                 
916                 if (Global.checkVersionUpgrade()) {
917                         checkForUpdates();
918                 }
919                 
920                 // ICHANGED
921                 if (currentNoteGuid == null || currentNoteGuid.equals("")) {
922                         menuBar.noteAddNewTab.setEnabled(false);
923                 }
924         }
925         
926         
927         public void debugDirty() {
928                 List<Note> dirty = conn.getNoteTable().getDirty();
929                 logger.log(logger.LOW, "------ Dirty Notes List Begin ------");
930                 for (int i=0; i<dirty.size(); i++) {
931                         logger.log(logger.LOW, "GUID: " +dirty.get(i).getGuid() + " Title:" + dirty.get(i).getTitle());
932                 }
933                 logger.log(logger.LOW, "------ Dirty Notes List End ------");
934         }
935                 
936         // Main entry point
937         public static void main(String[] args) {
938                 log.setLevel(Level.FATAL);
939                 QApplication.initialize(args);
940                 QPixmap pixmap = new QPixmap("classpath:cx/fbn/nevernote/icons/splash_logo.png");
941                 QSplashScreen splash = new QSplashScreen(pixmap);
942                 boolean showSplash;
943                 
944                 DatabaseConnection dbConn;
945
946         try {
947             initializeGlobalSettings(args);
948
949             showSplash = Global.isWindowVisible("SplashScreen");
950             if (showSplash)
951                 splash.show();
952
953             dbConn = setupDatabaseConnection();
954
955             // Must be last stage of setup - only safe once DB is open hence we know we are the only instance running
956             Global.getFileManager().purgeResDirectory(true);
957
958         } catch (InitializationException e) {
959             // Fatal
960             e.printStackTrace();
961             QMessageBox.critical(null, "Startup error", "Aborting: " + e.getMessage());
962             return;
963         }
964         
965                 // Setup proxy crap
966                 String proxyUrl = Global.getProxyValue("url");
967                 String proxyPort = Global.getProxyValue("port");
968                 String proxyUserid = Global.getProxyValue("userid");
969                 String proxyPassword = Global.getProxyValue("password");
970                 boolean proxySet = false;
971                 QNetworkProxy proxy = new QNetworkProxy();
972                 proxy.setType(ProxyType.HttpProxy);
973                 if (!proxyUrl.trim().equals("")) {
974                         System.out.println("Proxy URL found: " +proxyUrl);
975                         proxySet = true;
976                         proxy.setHostName(proxyUrl);
977                 }
978                 if (!proxyPort.trim().equals("")) {
979                         System.out.println("Proxy Port found: " +proxyPort);
980                         proxySet = true;
981                         proxy.setPort(Integer.parseInt(proxyPort));
982                 }
983                 if (!proxyUserid.trim().equals("")) {
984                         System.out.println("Proxy Userid found: " +proxyUserid);
985                         proxySet = true;
986                         proxy.setUser(proxyUserid);
987                 }
988                 if (!proxyPassword.trim().equals("")) {
989                         System.out.println("Proxy URL found: " +proxyPassword);
990                         proxySet = true;
991                         proxy.setPassword(proxyPassword);
992                 }
993                 if (proxySet) {
994                         QNetworkProxy.setApplicationProxy(proxy);
995                 }
996                         
997
998         NeverNote application = new NeverNote(dbConn);
999                 if (Global.syncOnly) {
1000                         System.out.println("Performing synchronization only.");
1001                         application.remoteConnect();
1002                         if (Global.isConnected) {
1003                                 application.syncRunner.syncNeeded = true;
1004                                 application.syncRunner.addWork("SYNC");
1005                                 application.syncRunner.addWork("STOP");
1006                                 while(!application.syncRunner.isIdle());
1007                                 application.closeNeverNote();
1008                         }
1009                         return;
1010                 }
1011
1012                 application.setAttribute(WidgetAttribute.WA_DeleteOnClose, true);
1013                 if (Global.startMinimized()) 
1014                         application.showMinimized();
1015                 else {
1016                         if (Global.wasWindowMaximized())
1017                                 application.showMaximized();
1018                         else
1019                                 application.show();
1020                 }
1021                 
1022                 if (showSplash)
1023                         splash.finish(application);
1024                 QApplication.exec();
1025                 System.out.println("Goodbye.");
1026                 QApplication.exit();
1027         }
1028
1029     /**
1030      * Open the internal database, or create if not present
1031      *
1032      * @throws InitializationException when opening the database fails, e.g. because another process has it locked
1033      */
1034     private static DatabaseConnection setupDatabaseConnection() throws InitializationException {
1035         ApplicationLogger logger = new ApplicationLogger("nevernote-database.log");
1036         
1037         File f = Global.getFileManager().getDbDirFile(Global.databaseName + ".h2.db");
1038         File fr = Global.getFileManager().getDbDirFile(Global.resourceDatabaseName + ".h2.db");
1039                 // IFIXED resourceDatabaseNameになっていたので修正
1040                 File fi = Global.getFileManager().getDbDirFile(Global.indexDatabaseName + ".h2.db");
1041                 // ICHANGED
1042                 File fb = Global.getFileManager().getDbDirFile(Global.behaviorDatabaseName + ".h2.db");
1043                                 
1044                 if (!f.exists())
1045                         Global.setDatabaseUrl("");
1046                 if (!fr.exists())
1047                         Global.setResourceDatabaseUrl("");              
1048                 if (!fi.exists())
1049                         Global.setIndexDatabaseUrl(""); 
1050                 // ICHANGED
1051                 if (!fb.exists())
1052                         Global.setBehaviorDatabaseUrl("");
1053         
1054         if (Global.getDatabaseUrl().toUpperCase().indexOf("CIPHER=") > -1) {
1055             boolean goodCheck = false;
1056             while (!goodCheck) {
1057                 DatabaseLoginDialog dialog = new DatabaseLoginDialog();
1058                 dialog.exec();
1059                 if (!dialog.okPressed())
1060                     System.exit(0);
1061                 Global.cipherPassword = dialog.getPassword();
1062                 goodCheck = databaseCheck(Global.getDatabaseUrl(), Global.getDatabaseUserid(),
1063                         Global.getDatabaseUserPassword(), Global.cipherPassword);
1064             }
1065         }
1066         // ICHANGED Global.getBehaviorDatabaserUrl()を追加
1067         DatabaseConnection dbConn = new DatabaseConnection(logger,Global.getDatabaseUrl(), 
1068                         Global.getIndexDatabaseUrl(), Global.getResourceDatabaseUrl(), Global.getBehaviorDatabaseUrl(),
1069                         Global.getDatabaseUserid(), Global.getDatabaseUserPassword(), Global.cipherPassword, 0);
1070        return dbConn;
1071     }
1072     
1073     // Encrypt the database upon shutdown
1074     private void encryptOnShutdown() {
1075         String dbPath= Global.getFileManager().getDbDirPath("");
1076         try {
1077                 
1078                 Statement st = conn.getConnection().createStatement();  
1079                 st.execute("shutdown");
1080                 st = conn.getResourceConnection().createStatement();
1081                 st.execute("shutdown");
1082                 st = conn.getIndexConnection().createStatement();
1083                 st.execute("shutdown");
1084                 // ICHANGED
1085                 st = conn.getBehaviorConnection().createStatement();
1086                 st.execute("shutdown");
1087                 
1088                 if (QMessageBox.question(this, tr("Are you sure"), 
1089                                 tr("Are you sure you wish to encrypt the database?"),
1090                                 QMessageBox.StandardButton.Yes, 
1091                                 QMessageBox.StandardButton.No) == StandardButton.Yes.value()) {
1092                         ChangeFileEncryption.execute(dbPath, "NeverNote", encryptCipher, null, Global.cipherPassword.toCharArray(), true);
1093                         ChangeFileEncryption.execute(dbPath, "Resources", encryptCipher, null, Global.cipherPassword.toCharArray(), true);
1094                         ChangeFileEncryption.execute(dbPath, "Index", encryptCipher, null, Global.cipherPassword.toCharArray(), true);
1095                         // ICHANGED
1096                         ChangeFileEncryption.execute(dbPath, "Behavior", encryptCipher, null, Global.cipherPassword.toCharArray(), true);
1097                         
1098                         Global.setDatabaseUrl(Global.getDatabaseUrl() + ";CIPHER="+encryptCipher);
1099                         Global.setResourceDatabaseUrl(Global.getResourceDatabaseUrl() + ";CIPHER="+encryptCipher);
1100                         Global.setIndexDatabaseUrl(Global.getIndexDatabaseUrl() + ";CIPHER="+encryptCipher);
1101                         // ICHANGED
1102                                 Global.setBehaviorDatabaseUrl(Global.getBehaviorDatabaseUrl() + ";CIPHER=" + encryptCipher);
1103
1104                         QMessageBox.information(this, tr("Encryption Complete"), tr("Encryption is complete"));
1105                 }
1106         } catch (SQLException e) {
1107                         e.printStackTrace();
1108                 }       
1109     }
1110     
1111     // Decrypt the database upon shutdown
1112     private void decryptOnShutdown() {
1113         String dbPath= Global.getFileManager().getDbDirPath("");
1114         String dbName = "NeverNote";
1115         try {
1116                 Statement st = conn.getConnection().createStatement();  
1117                 st.execute("shutdown");
1118                 if (Global.getDatabaseUrl().toUpperCase().indexOf(";CIPHER=AES") > -1)
1119                         encryptCipher = "AES";
1120                 else
1121                         encryptCipher = "XTEA";
1122                 if (QMessageBox.question(this, tr("Confirmation"), tr("Are you sure", 
1123                                 "Are you sure you wish to decrypt the database?"),
1124                                 QMessageBox.StandardButton.Yes, 
1125                                 QMessageBox.StandardButton.No) == StandardButton.Yes.value()) {
1126
1127                         ChangeFileEncryption.execute(dbPath, dbName, encryptCipher, Global.cipherPassword.toCharArray(), null, true);
1128                         Global.setDatabaseUrl("");
1129                         Global.setResourceDatabaseUrl("");
1130                         Global.setIndexDatabaseUrl("");
1131                         QMessageBox.information(this, tr("Decryption Complete"), tr("Decryption is complete"));
1132                 }
1133                 } catch (SQLException e) {
1134                         e.printStackTrace();
1135                 }       
1136     }
1137     /**
1138      * Encrypt/Decrypt the local database
1139      **/
1140     public void doDatabaseEncrypt() {
1141         // The database is not currently encrypted
1142         if (Global.getDatabaseUrl().toUpperCase().indexOf("CIPHER=") == -1) {
1143                 if (QMessageBox.question(this, tr("Confirmation"), tr("Encrypting the database is used" +
1144                                 "to enhance security and is performed\nupon shutdown, but please be aware that if"+
1145                                 " you lose the password your\nis lost forever.\n\nIt is highly recommended you " +
1146                                 "perform a backup and/or fully synchronize\n prior to executing this funtction.\n\n" +
1147                                 "Do you wish to proceed?"),
1148                                 QMessageBox.StandardButton.Yes, 
1149                                 QMessageBox.StandardButton.No)==StandardButton.No.value()) {
1150                                 return;
1151                 }
1152                 DBEncryptDialog dialog = new DBEncryptDialog();
1153                 dialog.exec();
1154                 if (dialog.okPressed()) {
1155                         Global.cipherPassword = dialog.getPassword();
1156                         encryptOnShutdown  = true;
1157                         encryptCipher = dialog.getEncryptionMethod();
1158                 }
1159         } else {
1160             DBEncryptDialog dialog = new DBEncryptDialog();
1161             dialog.setWindowTitle(tr("Database Decryption"));
1162             dialog.hideEncryption();
1163             dialog.exec();
1164             if (dialog.okPressed()) {
1165                 if (!dialog.getPassword().equals(Global.cipherPassword)) {
1166                         QMessageBox.critical(null, tr("Incorrect Password"), tr("Incorrect Password"));
1167                         return;
1168                 }
1169                 decryptOnShutdown  = true;
1170                 encryptCipher = "";
1171             }
1172         }
1173         return;
1174     }
1175
1176         private static void initializeGlobalSettings(String[] args) throws InitializationException {
1177                 StartupConfig   startupConfig = new StartupConfig();
1178
1179         for (String arg : args) {
1180             String lower = arg.toLowerCase();
1181             if (lower.startsWith("--name="))
1182                startupConfig.setName(arg.substring(arg.indexOf('=') + 1));
1183             if (lower.startsWith("--home="))
1184                startupConfig.setHomeDirPath(arg.substring(arg.indexOf('=') + 1));
1185             if (lower.startsWith("--disable-viewing"))
1186                startupConfig.setDisableViewing(true);
1187             if (lower.startsWith("--sync-only=true"))
1188                 startupConfig.setSyncOnly(true);
1189         }
1190         Global.setup(startupConfig);
1191         
1192     }
1193
1194     // Exit point
1195         @Override
1196         public void closeEvent(QCloseEvent event) {     
1197                 if (Global.minimizeOnClose() && !closeAction) {
1198                         event.ignore();
1199                         hide();
1200                         return;
1201                 }
1202                 logger.log(logger.HIGH, "Entering NeverNote.closeEvent");
1203                 waitCursor(true);
1204                 
1205                 if (currentNote != null & browserWindow != null) {
1206                         if (currentNote.getTitle() != null && browserWindow != null
1207                                         && !currentNote.getTitle().equals(browserWindow.getTitle()))
1208                                 conn.getNoteTable().updateNoteTitle(currentNote.getGuid(),
1209                                                 browserWindow.getTitle());
1210                 }
1211                 
1212                 saveNote();
1213                 setMessage(tr("Beginning shutdown."));
1214                 
1215                 // Close down external windows
1216                 Collection<ExternalBrowse> windows = externalWindows.values();
1217                 Iterator<ExternalBrowse> iterator = windows.iterator();
1218                 while (iterator.hasNext()) {
1219                         ExternalBrowse browser = iterator.next();
1220                         browser.windowClosing.disconnect();
1221                         browser.close();
1222                 }
1223                 
1224                 // ICHANGED タブブラウザに対してクローズ処理を行う
1225                 Collection<TabBrowse> win = tabWindows.values();
1226                 Iterator<TabBrowse> it = win.iterator();
1227                 tabBrowser.currentChanged.disconnect();
1228                 tabBrowser.tabCloseRequested.disconnect();
1229                 while (it.hasNext()) {
1230                         TabBrowse browser = it.next();
1231                         browser.close();
1232                 }
1233                 
1234                 externalFileEditedSaver();
1235                 if (Global.isConnected && Global.synchronizeOnClose()) {
1236                         setMessage(tr("Performing synchronization before closing."));
1237                         syncRunner.syncNeeded = true;
1238                         syncRunner.addWork("SYNC");
1239                 } else {
1240                         syncRunner.keepRunning = false;
1241                 }
1242                 syncRunner.addWork("STOP");
1243                 setMessage("Closing Program.");
1244                 threadMonitorTimer.stop();
1245
1246                 thumbnailRunner.addWork("STOP");
1247                 indexRunner.addWork("STOP");
1248                 saveNote();
1249                 listManager.stop();
1250                 saveWindowState();
1251                 
1252                 // 連想ノートリストのEvernote関連ノート取得スレッドを終了
1253                 rensoNoteListDock.getRensoNoteList().stopThread();
1254
1255                 if (tempFiles != null)
1256                         tempFiles.clear();
1257
1258                 browserWindow.noteSignal.tagsChanged.disconnect();
1259                 browserWindow.noteSignal.titleChanged.disconnect();
1260                 browserWindow.noteSignal.noteChanged.disconnect();
1261                 browserWindow.noteSignal.notebookChanged.disconnect();
1262                 browserWindow.noteSignal.createdDateChanged.disconnect();
1263                 browserWindow.noteSignal.alteredDateChanged.disconnect();
1264                 syncRunner.searchSignal.listChanged.disconnect();
1265                 syncRunner.tagSignal.listChanged.disconnect();
1266         syncRunner.notebookSignal.listChanged.disconnect();
1267         syncRunner.noteIndexSignal.listChanged.disconnect();
1268
1269                 if (isVisible())
1270                         Global.saveWindowVisible("toolBar", toolBar.isVisible());
1271                 saveNoteColumnPositions();
1272                 saveNoteIndexWidth();
1273                 
1274                 int width = notebookTree.columnWidth(0);
1275                 Global.setColumnWidth("notebookTreeName", width);
1276                 width = tagTree.columnWidth(0);
1277                 Global.setColumnWidth("tagTreeName", width);
1278                 
1279                 Global.saveWindowMaximized(isMaximized());
1280                 Global.saveCurrentNoteGuid(currentNoteGuid);
1281                         
1282                 int sortCol = noteTableView.proxyModel.sortColumn();
1283                 int sortOrder = noteTableView.proxyModel.sortOrder().value();
1284                 Global.setSortColumn(sortCol);
1285                 Global.setSortOrder(sortOrder);
1286                 
1287                 hide();
1288                 trayIcon.hide();
1289                 Global.keepRunning = false;
1290                 try {
1291                         logger.log(logger.MEDIUM, "Waiting for indexThread to stop");
1292                         if (indexRunner.thread().isAlive())
1293                                 indexRunner.thread().join(50);
1294                         if (!indexRunner.thread().isAlive())
1295                                 logger.log(logger.MEDIUM, "Index thread has stopped");
1296                         else {
1297                                 logger.log(logger.MEDIUM, "Index thread still running - interrupting");
1298                                 indexRunner.thread().interrupt();
1299                         }
1300                 } catch (InterruptedException e1) {
1301                         e1.printStackTrace();
1302                 }
1303                 
1304                 if (!syncRunner.thread().isAlive()) {
1305                         logger.log(logger.MEDIUM, "Waiting for syncThread to stop");
1306                         if (syncRunner.thread().isAlive()) {
1307                                 System.out.println(tr("Synchronizing.  Please be patient."));
1308                                 for(;syncRunner.thread().isAlive();) {
1309                                         try {
1310                                                 wait(10);
1311                                         } catch (InterruptedException e) {
1312                                                 e.printStackTrace();
1313                                         }
1314                                 }
1315                         }
1316                         logger.log(logger.MEDIUM, "Sync thread has stopped");
1317                 }
1318
1319                 if (encryptOnShutdown) {
1320                         encryptOnShutdown();
1321                 }
1322                 if (decryptOnShutdown) {
1323                         decryptOnShutdown();
1324                 }
1325                 try {
1326                         Global.getFileManager().purgeResDirectory(false);
1327                 } catch (InitializationException e) {
1328                         System.out.println(tr("Empty res directory purge failed"));
1329                         e.printStackTrace();
1330                 }
1331                 logger.log(logger.HIGH, "Leaving NeverNote.closeEvent");
1332         }
1333
1334
1335         private void closeNeverNote() {
1336                 closeAction = true;
1337                 close();
1338         }
1339         public void setMessage(String s) {
1340                 if (logger != null) 
1341                         logger.log(logger.HIGH, "Entering NeverNote.setMessage");
1342                 else
1343                         System.out.println("*** ERROR *** " +s);
1344                 
1345                 if (statusBar != null) {
1346                         statusBar.show();
1347                         if (logger != null) 
1348                                 logger.log(logger.HIGH, "Message: " +s);
1349                         statusBar.showMessage(s);
1350                         if (emitLog != null)
1351                                 emitLog.add(s);
1352                 
1353                         if (messageTimer != null) {
1354                                 messageTimer.stop();
1355                                 messageTimer.setSingleShot(true);
1356                                 messageTimer.start();
1357                         }
1358                 }
1359                         
1360                 if (logger != null) 
1361                         logger.log(logger.HIGH, "Leaving NeverNote.setMessage");
1362         }
1363         
1364         private void clearMessage() {
1365                 statusBar.clearMessage();
1366                 statusBar.hide();
1367         }
1368                 
1369         private void waitCursor(boolean wait) {
1370                 if (wait) {
1371                         if (QApplication.overrideCursor() == null)
1372                                 QApplication.setOverrideCursor(new QCursor(Qt.CursorShape.WaitCursor));
1373                 }
1374                 else {
1375                         if (QApplication.overrideCursor() != null)
1376                                 QApplication.restoreOverrideCursor();
1377                         else
1378                                 QApplication.setOverrideCursor(new QCursor(Qt.CursorShape.ArrowCursor));
1379                 }
1380                 listManager.refreshCounters();
1381         }
1382         
1383         private void setupIndexListeners() {
1384 //              indexRunner.noteSignal.noteIndexed.connect(this, "indexThreadComplete(String)");
1385 //              indexRunner.resourceSignal.resourceIndexed.connect(this, "indexThreadComplete(String)");
1386                 indexRunner.signal.indexStarted.connect(this, "indexStarted()");
1387                 indexRunner.signal.indexFinished.connect(this, "indexComplete()");
1388         }
1389         private void setupSyncSignalListeners() {
1390                 syncRunner.tagSignal.listChanged.connect(this, "tagIndexUpdated()");
1391         syncRunner.searchSignal.listChanged.connect(this, "savedSearchIndexUpdated()");
1392         syncRunner.notebookSignal.listChanged.connect(this, "notebookIndexUpdated()");
1393         syncRunner.noteIndexSignal.listChanged.connect(this, "noteIndexUpdated(boolean)");
1394         syncRunner.noteSignal.quotaChanged.connect(this, "updateQuotaBar()");
1395         
1396                 syncRunner.syncSignal.saveUploadAmount.connect(this,"saveUploadAmount(long)");
1397                 syncRunner.syncSignal.saveUserInformation.connect(this,"saveUserInformation(User)");
1398                 syncRunner.syncSignal.saveEvernoteUpdateCount.connect(this,"saveEvernoteUpdateCount(int)");
1399                 
1400                 syncRunner.noteSignal.guidChanged.connect(this, "noteGuidChanged(String, String)");
1401                 syncRunner.noteSignal.noteChanged.connect(this, "invalidateNoteCache(String, String)");
1402                 syncRunner.resourceSignal.resourceGuidChanged.connect(this, "noteResourceGuidChanged(String,String,String)");
1403                 syncRunner.noteSignal.noteDownloaded.connect(listManager, "noteDownloaded(Note)");
1404                 syncRunner.noteSignal.notebookChanged.connect(this, "updateNoteNotebook(String, String)");
1405                 
1406                 syncRunner.syncSignal.refreshLists.connect(this, "refreshLists()");
1407         }
1408         
1409         private void setupBrowserSignalListeners() {
1410                 setupBrowserWindowListeners(browserWindow, true);
1411         }
1412
1413         private void setupBrowserWindowListeners(BrowserWindow browser, boolean master) {
1414                 browser.fileWatcher.fileChanged.connect(this, "externalFileEdited(String)");
1415                 browser.noteSignal.tagsChanged.connect(this, "updateNoteTags(String, List)");
1416             browser.noteSignal.tagsChanged.connect(this, "updateListTags(String, List)");
1417             if (master) browser.noteSignal.noteChanged.connect(this, "setNoteDirty()");
1418             browser.noteSignal.titleChanged.connect(listManager, "updateNoteTitle(String, String)");
1419             browser.noteSignal.titleChanged.connect(this, "updateNoteTitle(String, String)");
1420             browser.noteSignal.notebookChanged.connect(this, "updateNoteNotebook(String, String)");
1421             browser.noteSignal.createdDateChanged.connect(listManager, "updateNoteCreatedDate(String, QDateTime)");
1422             browser.noteSignal.alteredDateChanged.connect(listManager, "updateNoteAlteredDate(String, QDateTime)");
1423             browser.noteSignal.subjectDateChanged.connect(listManager, "updateNoteSubjectDate(String, QDateTime)");
1424             browser.noteSignal.authorChanged.connect(listManager, "updateNoteAuthor(String, String)");
1425             browser.noteSignal.geoChanged.connect(listManager, "updateNoteGeoTag(String, Double,Double,Double)");
1426             browser.noteSignal.geoChanged.connect(this, "setNoteDirty()");
1427             browser.noteSignal.sourceUrlChanged.connect(listManager, "updateNoteSourceUrl(String, String)");
1428         browser.blockApplication.connect(this, "blockApplication(BrowserWindow)");
1429         browser.unblockApplication.connect(this, "unblockApplication()");
1430             if (master) browser.focusLost.connect(this, "saveNote()");
1431             browser.resourceSignal.contentChanged.connect(this, "externalFileEdited(String)");
1432             browser.evernoteLinkClicked.connect(this, "evernoteLinkClick(String, String)");
1433         }
1434
1435         //**************************************************
1436         //* Setup shortcuts
1437         //**************************************************
1438         private void setupShortcut(QShortcut action, String text) {
1439                 if (!Global.shortcutKeys.containsAction(text))
1440                         return;
1441                 action.setKey(new QKeySequence(Global.shortcutKeys.getShortcut(text)));
1442         }
1443         
1444         //***************************************************************
1445         //***************************************************************
1446         //* Settings and look & feel
1447         //***************************************************************
1448         //***************************************************************
1449         @SuppressWarnings("unused")
1450         private void settings() {
1451                 logger.log(logger.HIGH, "Entering NeverNote.settings");
1452
1453                 saveNoteColumnPositions();
1454                 saveNoteIndexWidth();
1455                 showColumns();
1456         ConfigDialog settings = new ConfigDialog(this, conn);
1457         String dateFormat = Global.getDateFormat();
1458         String timeFormat = Global.getTimeFormat();
1459         
1460                 indexTime = 1000*Global.getIndexThreadSleepInterval();  
1461                 indexTimer.start(indexTime);  // reset indexing timer
1462         
1463         settings.exec();
1464         indexRunner.indexAttachmentsLocally = Global.indexAttachmentsLocally();
1465 //        indexRunner.indexNoteBody = Global.indexNoteBody();
1466 //        indexRunner.indexNoteTitle = Global.indexNoteTitle();
1467 //        indexRunner.specialIndexCharacters = Global.getSpecialIndexCharacters();
1468         indexRunner.indexImageRecognition = Global.indexImageRecognition();
1469         if (Global.showTrayIcon() || Global.minimizeOnClose())
1470                 trayIcon.show();
1471         else
1472                 trayIcon.hide();
1473         showColumns();
1474         if (menuBar.showEditorBar.isChecked()){
1475                 // ICHANGED 
1476                 for(int i = 0; i < tabBrowser.count(); i++){
1477                         BrowserWindow browser = ((TabBrowse) tabBrowser.widget(i)).getBrowserWindow();
1478                         showEditorButtons(browser);
1479                 }
1480                 
1481         }
1482         
1483         // Reset the save timer
1484         if (Global.getAutoSaveInterval() > 0)
1485                         saveTimer.setInterval(1000*60*Global.getAutoSaveInterval());
1486         else
1487                 saveTimer.stop();
1488         
1489         
1490         // Set special reloads
1491         if (settings.getDebugPage().reloadSharedNotebooksClicked()) {
1492                 conn.executeSql("Delete from LinkedNotebook");
1493                 conn.executeSql("delete from SharedNotebook");
1494                 conn.executeSql("Delete from Notebook where linked=true");
1495                 conn.executeSql("Insert into Sync (key, value) values ('FullLinkedNotebookSync', 'true')");
1496                 conn.executeSql("Insert into Sync (key, value) values ('FullSharedNotebookSync', 'true')");
1497         }
1498
1499         // Reload user data
1500         noteCache.clear();
1501         readOnlyCache.clear();
1502         inkNoteCache.clear();
1503         noteIndexUpdated(true);
1504                 
1505         logger.log(logger.HIGH, "Leaving NeverNote.settings");
1506         }
1507         // Restore things to the way they were
1508         private void restoreWindowState(boolean mainWindow) {
1509                 // We need to name things or this doesn't work.
1510                 setObjectName("NeverNote");
1511         restoreState(Global.restoreState(objectName()));
1512                 mainLeftRightSplitter.setObjectName("mainLeftRightSplitter");
1513                 browserIndexSplitter.setObjectName("browserIndexSplitter");
1514                 leftSplitter1.setObjectName("leftSplitter1");
1515                 // ICHANGED
1516                 rensoNoteListDock.setObjectName("rensoNoteListDock");
1517                 
1518                 // Restore the actual positions.
1519                 if (mainWindow)
1520                         restoreGeometry(Global.restoreGeometry(objectName()));
1521         mainLeftRightSplitter.restoreState(Global.restoreState(mainLeftRightSplitter.objectName()));
1522         browserIndexSplitter.restoreState(Global.restoreState(browserIndexSplitter.objectName()));
1523         leftSplitter1.restoreState(Global.restoreState(leftSplitter1.objectName()));
1524         // ICHANGED
1525         rensoNoteListDock.restoreGeometry(Global.restoreGeometry(rensoNoteListDock.objectName()));
1526        
1527         }
1528         // Save window positions for the next start
1529         private void saveWindowState() {
1530                 Global.saveGeometry(objectName(), saveGeometry());
1531                 Global.saveState(mainLeftRightSplitter.objectName(), mainLeftRightSplitter.saveState());
1532                 Global.saveState(browserIndexSplitter.objectName(), browserIndexSplitter.saveState());
1533                 Global.saveState(leftSplitter1.objectName(), leftSplitter1.saveState());
1534                 Global.saveState(objectName(), saveState());
1535                 // ICHANGED
1536                 Global.saveGeometry(rensoNoteListDock.objectName(), rensoNoteListDock.saveGeometry());
1537         }    
1538         // Load the style sheet
1539         private void loadStyleSheet() {
1540                 String styleSheetName = "default.qss";
1541                 if (Global.getStyle().equalsIgnoreCase("cleanlooks"))
1542                                 styleSheetName = "default-cleanlooks.qss";
1543                 String fileName = Global.getFileManager().getQssDirPathUser("default.qss");
1544                 QFile file = new QFile(fileName);
1545                 
1546                 // If a user default.qss doesn't exist, we use the one shipped with NeverNote
1547                 if (!file.exists()) {
1548                         fileName = Global.getFileManager().getQssDirPath(styleSheetName);
1549                         file = new QFile(fileName);
1550                 }
1551                 file.open(OpenModeFlag.ReadOnly);
1552                 String styleSheet = file.readAll().toString();
1553                 file.close();
1554                 setStyleSheet(styleSheet);
1555         }
1556         // Save column positions for the next time
1557         private void saveNoteColumnPositions() {
1558                 int position = noteTableView.header.visualIndex(Global.noteTableCreationPosition);
1559                 Global.setColumnPosition("noteTableCreationPosition", position);
1560                 position = noteTableView.header.visualIndex(Global.noteTableTagPosition);
1561                 Global.setColumnPosition("noteTableTagPosition", position);
1562                 position = noteTableView.header.visualIndex(Global.noteTableNotebookPosition);
1563                 Global.setColumnPosition("noteTableNotebookPosition", position);
1564                 position = noteTableView.header.visualIndex(Global.noteTableChangedPosition);
1565                 Global.setColumnPosition("noteTableChangedPosition", position);
1566                 position = noteTableView.header.visualIndex(Global.noteTableAuthorPosition);
1567                 Global.setColumnPosition("noteTableAuthorPosition", position);
1568                 position = noteTableView.header.visualIndex(Global.noteTableSourceUrlPosition);
1569                 Global.setColumnPosition("noteTableSourceUrlPosition", position);
1570                 position = noteTableView.header.visualIndex(Global.noteTableSubjectDatePosition);
1571                 Global.setColumnPosition("noteTableSubjectDatePosition", position);
1572                 position = noteTableView.header.visualIndex(Global.noteTableTitlePosition);
1573                 Global.setColumnPosition("noteTableTitlePosition", position);
1574                 position = noteTableView.header.visualIndex(Global.noteTableSynchronizedPosition);
1575                 Global.setColumnPosition("noteTableSynchronizedPosition", position);
1576                 position = noteTableView.header.visualIndex(Global.noteTableGuidPosition);
1577                 Global.setColumnPosition("noteTableGuidPosition", position);
1578                 position = noteTableView.header.visualIndex(Global.noteTableThumbnailPosition);
1579                 Global.setColumnPosition("noteTableThumbnailPosition", position);
1580                 position = noteTableView.header.visualIndex(Global.noteTablePinnedPosition);
1581                 Global.setColumnPosition("noteTablePinnedPosition", position);
1582
1583         }
1584         // Save column widths for the next time
1585         private void saveNoteIndexWidth() {
1586                 int width;
1587         width = noteTableView.getColumnWidth(Global.noteTableCreationPosition);
1588         Global.setColumnWidth("noteTableCreationPosition", width);
1589                 width = noteTableView.getColumnWidth(Global.noteTableChangedPosition);
1590                 Global.setColumnWidth("noteTableChangedPosition", width);
1591                 width = noteTableView.getColumnWidth(Global.noteTableGuidPosition);
1592                 Global.setColumnWidth("noteTableGuidPosition", width);
1593                 width = noteTableView.getColumnWidth(Global.noteTableNotebookPosition);
1594                 Global.setColumnWidth("noteTableNotebookPosition", width);
1595                 width = noteTableView.getColumnWidth(Global.noteTableTagPosition);
1596                 Global.setColumnWidth("noteTableTagPosition", width);
1597                 width = noteTableView.getColumnWidth(Global.noteTableTitlePosition);
1598                 Global.setColumnWidth("noteTableTitlePosition", width);
1599                 width = noteTableView.getColumnWidth(Global.noteTableSourceUrlPosition);
1600                 Global.setColumnWidth("noteTableSourceUrlPosition", width);
1601                 width = noteTableView.getColumnWidth(Global.noteTableAuthorPosition);
1602                 Global.setColumnWidth("noteTableAuthorPosition", width);
1603                 width = noteTableView.getColumnWidth(Global.noteTableSubjectDatePosition);
1604                 Global.setColumnWidth("noteTableSubjectDatePosition", width);
1605                 width = noteTableView.getColumnWidth(Global.noteTableSynchronizedPosition);
1606                 Global.setColumnWidth("noteTableSynchronizedPosition", width);
1607                 width = noteTableView.getColumnWidth(Global.noteTableThumbnailPosition);
1608                 Global.setColumnWidth("noteTableThumbnailPosition", width);
1609                 width = noteTableView.getColumnWidth(Global.noteTableGuidPosition);
1610                 Global.setColumnWidth("noteTableGuidPosition", width);
1611                 width = noteTableView.getColumnWidth(Global.noteTablePinnedPosition);
1612                 Global.setColumnWidth("noteTablePinnedPosition", width);
1613         }
1614         
1615         @SuppressWarnings("unused")
1616         private void toggleSearchWindow() {
1617                 logger.log(logger.HIGH, "Entering NeverNote.toggleSearchWindow");
1618         searchLayout.toggleSearchField();
1619         menuBar.hideSearch.setChecked(searchField.isVisible());
1620         Global.saveWindowVisible("searchField", searchField.isVisible());
1621         logger.log(logger.HIGH, "Leaving NeverNote.toggleSearchWindow");
1622     }   
1623         @SuppressWarnings("unused")
1624         private void toggleQuotaWindow() {
1625                 logger.log(logger.HIGH, "Entering NeverNote.toggleQuotaWindow");
1626         searchLayout.toggleQuotaBar();
1627         menuBar.hideQuota.setChecked(quotaBar.isVisible());
1628         Global.saveWindowVisible("quota", quotaBar.isVisible());
1629         logger.log(logger.HIGH, "Leaving NeverNote.toggleQuotaWindow");
1630     }   
1631         @SuppressWarnings("unused")
1632         private void toggleZoomWindow() {
1633                 logger.log(logger.HIGH, "Entering NeverNote.toggleZoomWindow");
1634         searchLayout.toggleZoom();
1635         menuBar.hideZoom.setChecked(zoomSpinner.isVisible());
1636         Global.saveWindowVisible("zoom", zoomSpinner.isVisible());
1637         logger.log(logger.HIGH, "Leaving NeverNote.toggleZoomWindow");
1638     }   
1639         
1640         
1641         
1642     //***************************************************************
1643     //***************************************************************
1644     //** These functions deal with Notebook menu items
1645     //***************************************************************
1646     //***************************************************************
1647     // Setup the tree containing the user's notebooks.
1648     private void initializeNotebookTree() {       
1649         logger.log(logger.HIGH, "Entering NeverNote.initializeNotebookTree");
1650 //      notebookTree.itemClicked.connect(this, "notebookTreeSelection()");
1651         notebookTree.selectionSignal.connect(this, "notebookTreeSelection()");
1652         listManager.notebookSignal.refreshNotebookTreeCounts.connect(notebookTree, "updateCounts(List, List)");
1653         logger.log(logger.HIGH, "Leaving NeverNote.initializeNotebookTree");
1654     }   
1655     // Listener when a notebook is selected
1656         private void notebookTreeSelection() {
1657                 logger.log(logger.HIGH, "Entering NeverNote.notebookTreeSelection");
1658                 noteTableView.proxyModel.blocked = true;
1659                 
1660                 clearTrashFilter();
1661                 clearAttributeFilter();
1662                 clearSavedSearchFilter();
1663                 if (Global.mimicEvernoteInterface) {
1664                         clearTagFilter();
1665                         //searchField.clear();
1666                         searchField.clearEditText();
1667                 }
1668                 menuBar.noteRestoreAction.setVisible(false);            
1669         menuBar.notebookEditAction.setEnabled(true);
1670         menuBar.notebookDeleteAction.setEnabled(true);
1671         menuBar.notebookPublishAction.setEnabled(true);
1672         menuBar.notebookShareAction.setEnabled(true);
1673         menuBar.notebookIconAction.setEnabled(true);
1674         menuBar.notebookStackAction.setEnabled(true);
1675         
1676                 // ICHANGED ゴミ箱から元の画面に戻す。連想ノートリストをONに。
1677                 if (!rensoNoteListDock.isEnabled()) {
1678                         rensoNoteListDock.setEnabled(true);
1679                 }
1680                 
1681         List<QTreeWidgetItem> selections = notebookTree.selectedItems();
1682         selectedNotebookGUIDs.clear();
1683                 String guid = "";
1684                 String stackName = "";
1685                 if (selections.size() > 0) {
1686                 guid = (selections.get(0).text(2));
1687                 stackName = selections.get(0).text(0);
1688         }
1689                 if (!Global.mimicEvernoteInterface) {
1690                         // If no notebooks are selected, we make it look like the "all notebooks" one was selected
1691                         if (selections.size()==0) {
1692                                 selectedNotebookGUIDs.clear();
1693                                 for (int i=0; i < listManager.getNotebookIndex().size(); i++) {
1694                                         selectedNotebookGUIDs.add(listManager.getNotebookIndex().get(i).getGuid());
1695                                 }
1696                                 menuBar.notebookEditAction.setEnabled(false);
1697                                 menuBar.notebookDeleteAction.setEnabled(false);
1698                                 menuBar.notebookStackAction.setEnabled(false);
1699                                 menuBar.notebookIconAction.setEnabled(false);
1700                         }
1701                 }
1702         if (!guid.equals("") && !guid.equals("STACK")) {
1703                 selectedNotebookGUIDs.add(guid);
1704                 menuBar.notebookIconAction.setEnabled(true);
1705         } else {
1706                 menuBar.notebookIconAction.setEnabled(true);
1707                         for (int j=0; j<listManager.getNotebookIndex().size(); j++) {
1708                                 Notebook book = listManager.getNotebookIndex().get(j);
1709                                 if (book.getStack() != null && book.getStack().equalsIgnoreCase(stackName))
1710                                         selectedNotebookGUIDs.add(book.getGuid());
1711                         }
1712         }
1713         listManager.setSelectedNotebooks(selectedNotebookGUIDs);
1714         listManager.loadNotesIndex();
1715         noteIndexUpdated(false);
1716         refreshEvernoteNote(true);
1717         listManager.refreshCounters = true;
1718         listManager.refreshCounters();
1719         if (selectedNotebookGUIDs.size() == 1) {
1720                 int col = conn.getNotebookTable().getSortColumn(selectedNotebookGUIDs.get(0));
1721                 int order = conn.getNotebookTable().getSortOrder(selectedNotebookGUIDs.get(0));
1722                 if (col != -1) {
1723                         noteTableView.proxyModel.blocked = true;
1724                         if (order == 1)
1725                                 noteTableView.sortByColumn(col, Qt.SortOrder.DescendingOrder);
1726                         else
1727                                 noteTableView.sortByColumn(col, Qt.SortOrder.AscendingOrder);
1728                 }
1729         }
1730         noteTableView.proxyModel.blocked = false;
1731                 logger.log(logger.HIGH, "Leaving NeverNote.notebookTreeSelection");
1732
1733     }
1734     private void clearNotebookFilter() {
1735         notebookTree.blockSignals(true);
1736         notebookTree.clearSelection();
1737                 menuBar.noteRestoreAction.setVisible(false);
1738         menuBar.notebookEditAction.setEnabled(false);
1739         menuBar.notebookDeleteAction.setEnabled(false);
1740         selectedNotebookGUIDs.clear();
1741         listManager.setSelectedNotebooks(selectedNotebookGUIDs);
1742         notebookTree.blockSignals(false);
1743     }
1744         // Triggered when the notebook DB has been updated
1745         private void notebookIndexUpdated() {
1746                 logger.log(logger.HIGH, "Entering NeverNote.notebookIndexUpdated");
1747         
1748                 // Get the possible icons
1749                 HashMap<String, QIcon> icons = conn.getNotebookTable().getAllIcons();
1750         notebookTree.setIcons(icons);
1751         
1752         if (selectedNotebookGUIDs == null)
1753                         selectedNotebookGUIDs = new ArrayList<String>();
1754                 List<Notebook> books = conn.getNotebookTable().getAll();
1755                 for (int i=books.size()-1; i>=0; i--) {
1756                         for (int j=0; j<listManager.getArchiveNotebookIndex().size(); j++) {
1757                                 if (listManager.getArchiveNotebookIndex().get(j).getGuid().equals(books.get(i).getGuid())) {
1758                                         books.remove(i);
1759                                         j=listManager.getArchiveNotebookIndex().size();
1760                                 }
1761                         }
1762                 }
1763                 
1764                 
1765                 listManager.countNotebookResults(listManager.getNoteIndex());
1766                 notebookTree.blockSignals(true);
1767         notebookTree.load(books, listManager.getLocalNotebooks());
1768         for (int i=selectedNotebookGUIDs.size()-1; i>=0; i--) {
1769                 boolean found = notebookTree.selectGuid(selectedNotebookGUIDs.get(i));
1770                 if (!found)
1771                         selectedNotebookGUIDs.remove(i);
1772         }
1773         listManager.refreshCounters = true;
1774         listManager.refreshCounters();
1775         notebookTree.blockSignals(false);
1776         
1777                 logger.log(logger.HIGH, "Leaving NeverNote.notebookIndexUpdated");
1778     }
1779     // Show/Hide note information
1780         @SuppressWarnings("unused")
1781         private void toggleNotebookWindow() {
1782                 logger.log(logger.HIGH, "Entering NeverNote.toggleNotebookWindow");
1783                 searchLayout.toggleNotebook();
1784         menuBar.hideNotebooks.setChecked(notebookTree.isVisible());
1785         Global.saveWindowVisible("notebookTree", notebookTree.isVisible());
1786         logger.log(logger.HIGH, "Leaving NeverNote.toggleNotebookWindow");
1787     }   
1788         // Add a new notebook
1789         @SuppressWarnings("unused")
1790         private void addNotebook() {
1791                 logger.log(logger.HIGH, "Inside NeverNote.addNotebook");
1792                 NotebookEdit edit = new NotebookEdit();
1793                 edit.setNotebooks(listManager.getNotebookIndex());
1794                 edit.exec();
1795         
1796                 if (!edit.okPressed())
1797                         return;
1798         
1799                 Calendar currentTime = new GregorianCalendar();
1800                 Long l = new Long(currentTime.getTimeInMillis());
1801                 String randint = new String(Long.toString(l));
1802         
1803                 Notebook newBook = new Notebook();
1804                 newBook.setUpdateSequenceNum(0);
1805                 newBook.setGuid(randint);
1806                 newBook.setName(edit.getNotebook());
1807                 newBook.setServiceCreated(new Date().getTime());
1808                 newBook.setServiceUpdated(new Date().getTime());
1809                 newBook.setDefaultNotebook(false);
1810                 newBook.setPublished(false);
1811                 
1812                 listManager.getNotebookIndex().add(newBook);
1813                 if (edit.isLocal())
1814                         listManager.getLocalNotebooks().add(newBook.getGuid());
1815                 conn.getNotebookTable().addNotebook(newBook, true, edit.isLocal());
1816                 notebookIndexUpdated();
1817                 listManager.countNotebookResults(listManager.getNoteIndex());
1818 //              notebookTree.updateCounts(listManager.getNotebookIndex(), listManager.getNotebookCounter());
1819                 logger.log(logger.HIGH, "Leaving NeverNote.addNotebook");
1820         }
1821         // Edit an existing notebook
1822         @SuppressWarnings("unused")
1823         private void stackNotebook() {
1824                 logger.log(logger.HIGH, "Entering NeverNote.stackNotebook");
1825                 StackNotebook edit = new StackNotebook();
1826                 
1827                 List<QTreeWidgetItem> selections = notebookTree.selectedItems();
1828                 QTreeWidgetItem currentSelection;
1829                 for (int i=0; i<selections.size(); i++) {
1830                         currentSelection = selections.get(0);
1831                         String guid = currentSelection.text(2);
1832                         if (guid.equalsIgnoreCase("")) {
1833                                  QMessageBox.critical(this, tr("Unable To Stack") ,tr("You can't stack the \"All Notebooks\" item."));
1834                                  return;
1835                         }
1836                         if (guid.equalsIgnoreCase("STACK")) {
1837                                  QMessageBox.critical(this, tr("Unable To Stack") ,tr("You can't stack a stack."));
1838                                  return;
1839                         }
1840                 }
1841
1842                 edit.setStackNames(conn.getNotebookTable().getAllStackNames());
1843
1844                 
1845                 edit.exec();
1846         
1847                 if (!edit.okPressed())
1848                         return;
1849         
1850                 String stack = edit.getStackName();
1851                 
1852                 for (int i=0; i<selections.size(); i++) {
1853                         currentSelection = selections.get(i);
1854                         String guid = currentSelection.text(2);
1855                         listManager.updateNotebookStack(guid, stack);
1856                 }
1857                 notebookIndexUpdated();
1858                 logger.log(logger.HIGH, "Leaving NeverNote.stackNotebook");
1859         }
1860         // Edit an existing notebook
1861         @SuppressWarnings("unused")
1862         private void editNotebook() {
1863                 logger.log(logger.HIGH, "Entering NeverNote.editNotebook");
1864                 NotebookEdit edit = new NotebookEdit();
1865                 
1866                 List<QTreeWidgetItem> selections = notebookTree.selectedItems();
1867                 QTreeWidgetItem currentSelection;
1868                 currentSelection = selections.get(0);
1869                 edit.setNotebook(currentSelection.text(0));
1870                 
1871                 String guid = currentSelection.text(2);
1872                 if (!guid.equalsIgnoreCase("STACK")) {
1873                         edit.setTitle(tr("Edit Notebook"));
1874                         edit.setNotebooks(listManager.getNotebookIndex());
1875                         edit.setLocalCheckboxEnabled(false);
1876                         for (int i=0; i<listManager.getNotebookIndex().size(); i++) {
1877                                 if (listManager.getNotebookIndex().get(i).getGuid().equals(guid)) {
1878                                         edit.setDefaultNotebook(listManager.getNotebookIndex().get(i).isDefaultNotebook());
1879                                         i=listManager.getNotebookIndex().size();
1880                                 }
1881                         }
1882                 } else {
1883                         edit.setTitle(tr("Edit Stack"));
1884                         edit.setStacks(conn.getNotebookTable().getAllStackNames());
1885                         edit.hideLocalCheckbox();
1886                         edit.hideDefaultCheckbox();
1887                 }
1888                 
1889                 edit.exec();
1890         
1891                 if (!edit.okPressed())
1892                         return;
1893         
1894                 
1895                 if (guid.equalsIgnoreCase("STACK")) {
1896                         conn.getNotebookTable().renameStacks(currentSelection.text(0), edit.getNotebook());
1897                         for (int j=0; j<listManager.getNotebookIndex().size(); j++) {
1898                                 if (listManager.getNotebookIndex().get(j).getStack() != null && 
1899                                         listManager.getNotebookIndex().get(j).getStack().equalsIgnoreCase(currentSelection.text(0)))
1900                                                 listManager.getNotebookIndex().get(j).setStack(edit.getNotebook());
1901                         }
1902                         conn.getNotebookTable().renameStacks(currentSelection.text(0), edit.getNotebook());
1903                         currentSelection.setText(0, edit.getNotebook());
1904                         return;
1905                 }
1906                 
1907                 updateListNotebookName(currentSelection.text(0), edit.getNotebook());
1908                 currentSelection.setText(0, edit.getNotebook());
1909                 
1910                 for (int i=0; i<listManager.getNotebookIndex().size(); i++) {
1911                         if (listManager.getNotebookIndex().get(i).getGuid().equals(guid)) {
1912                                 listManager.getNotebookIndex().get(i).setName(edit.getNotebook());
1913                                 if (!listManager.getNotebookIndex().get(i).isDefaultNotebook() && edit.isDefaultNotebook()) {
1914                                         for (int j=0; j<listManager.getNotebookIndex().size(); j++)
1915                                                 listManager.getNotebookIndex().get(j).setDefaultNotebook(false);
1916                                         listManager.getNotebookIndex().get(i).setDefaultNotebook(true);
1917                                         conn.getNotebookTable().setDefaultNotebook(listManager.getNotebookIndex().get(i).getGuid());
1918                                 }
1919                                 conn.getNotebookTable().updateNotebook(listManager.getNotebookIndex().get(i), true);
1920                                 if (conn.getNotebookTable().isLinked(listManager.getNotebookIndex().get(i).getGuid())) {
1921                                         LinkedNotebook linkedNotebook = conn.getLinkedNotebookTable().getByNotebookGuid(listManager.getNotebookIndex().get(i).getGuid());
1922                                         linkedNotebook.setShareName(edit.getNotebook());
1923                                         conn.getLinkedNotebookTable().updateNotebook(linkedNotebook, true);
1924                                 }
1925                                 i=listManager.getNotebookIndex().size();
1926                         }
1927                 }
1928                 
1929                 // Build a list of non-closed notebooks
1930                 List<Notebook> nbooks = new ArrayList<Notebook>();
1931                 for (int i=0; i<listManager.getNotebookIndex().size(); i++) {
1932                         boolean found=false;
1933                         for (int j=0; j<listManager.getArchiveNotebookIndex().size(); j++) {
1934                                 if (listManager.getArchiveNotebookIndex().get(j).getGuid().equals(listManager.getNotebookIndex().get(i).getGuid()))
1935                                         found = true;
1936                         }
1937                         if (!found)
1938                                 nbooks.add(listManager.getNotebookIndex().get(i));
1939                 }
1940                 
1941                 
1942                 FilterEditorNotebooks notebookFilter = new FilterEditorNotebooks(conn, logger);
1943                 List<Notebook> filteredBooks = notebookFilter.getValidNotebooks(currentNote, listManager.getNotebookIndex());
1944                 browserWindow.setNotebookList(filteredBooks);
1945                 Iterator<String> set = externalWindows.keySet().iterator();
1946                 while(set.hasNext())
1947                         externalWindows.get(set.next()).getBrowserWindow().setNotebookList(filteredBooks);
1948                 
1949                 // ICHANGED
1950                 Iterator<Integer>it = tabWindows.keySet().iterator();
1951                 while (it.hasNext()) {
1952                         tabWindows.get(it.next()).getBrowserWindow()
1953                                         .setNotebookList(filteredBooks);
1954                 }
1955                 
1956                 logger.log(logger.HIGH, "Leaving NeverNote.editNotebook");
1957         }
1958         // Publish a notebook
1959         @SuppressWarnings("unused")
1960         private void publishNotebook() {
1961                 List<QTreeWidgetItem> selections = notebookTree.selectedItems();
1962                 QTreeWidgetItem currentSelection;
1963                 currentSelection = selections.get(0);
1964                 String guid = currentSelection.text(2);
1965
1966                 if (guid.equalsIgnoreCase("STACK") || guid.equalsIgnoreCase(""))
1967                         return;
1968                 
1969                 Notebook n = null;
1970                 int position = 0;
1971                 for (int i=0; i<listManager.getNotebookIndex().size(); i++) {
1972                         if (guid.equals(listManager.getNotebookIndex().get(i).getGuid())) {
1973                                 n = listManager.getNotebookIndex().get(i);
1974                                 position = i;
1975                                 i = listManager.getNotebookIndex().size();
1976                         }
1977                 }
1978                 if (n == null)
1979                         return;
1980                 
1981                 PublishNotebook publish = new PublishNotebook(Global.username, Global.getServer(), n);
1982                 publish.exec();
1983                 
1984                 if (!publish.okClicked()) 
1985                         return;
1986                 
1987                 Publishing p = publish.getPublishing();
1988                 boolean isPublished = !publish.isStopPressed();
1989                 conn.getNotebookTable().setPublishing(n.getGuid(), isPublished, p);
1990                 n.setPublished(isPublished);
1991                 n.setPublishing(p);
1992                 listManager.getNotebookIndex().set(position, n);
1993                 notebookIndexUpdated();
1994         }
1995         // Publish a notebook
1996         @SuppressWarnings("unused")
1997         private void shareNotebook() {
1998                 List<QTreeWidgetItem> selections = notebookTree.selectedItems();
1999                 QTreeWidgetItem currentSelection;
2000                 currentSelection = selections.get(0);
2001                 String guid = currentSelection.text(2);
2002
2003                 if (guid.equalsIgnoreCase("STACK") || guid.equalsIgnoreCase(""))
2004                         return;
2005                 
2006                 Notebook n = null;;
2007                 for (int i=0; i<listManager.getNotebookIndex().size(); i++) {
2008                         if (guid.equals(listManager.getNotebookIndex().get(i).getGuid())) {
2009                                 n = listManager.getNotebookIndex().get(i);
2010                                 i = listManager.getNotebookIndex().size();
2011                         }
2012                 }
2013                                 
2014                 String authToken = null;
2015                 if (syncRunner.isConnected)
2016                         authToken = syncRunner.authToken;
2017                 ShareNotebook share = new ShareNotebook(n.getName(), conn, n, syncRunner);
2018                 share.exec();
2019                 
2020         }
2021
2022         // Delete an existing notebook
2023         @SuppressWarnings("unused")
2024         private void deleteNotebook() {
2025                 logger.log(logger.HIGH, "Entering NeverNote.deleteNotebook");
2026                 boolean stacksFound = false;
2027                 boolean notebooksFound = false;
2028                 boolean assigned = false;
2029                 // Check if any notes have this notebook
2030                 List<QTreeWidgetItem> selections = notebookTree.selectedItems();
2031         for (int i=0; i<selections.size(); i++) {
2032                 QTreeWidgetItem currentSelection;
2033                 currentSelection = selections.get(i);
2034                 String guid = currentSelection.text(2);
2035                 if (!guid.equalsIgnoreCase("STACK")) {
2036                         notebooksFound = true;
2037                         for (int j=0; j<listManager.getNoteIndex().size(); j++) {
2038                                 String noteGuid = listManager.getNoteIndex().get(j).getNotebookGuid();
2039                                 if (noteGuid.equals(guid)) {
2040                                         assigned = true;
2041                                         j=listManager.getNoteIndex().size();
2042                                         i=selections.size();
2043                                 }
2044                         }
2045                 } else {
2046                         stacksFound = true;
2047                 }
2048         }
2049                 if (assigned) {
2050                         QMessageBox.information(this, tr("Unable to Delete"), tr("Some of the selected notebook(s) contain notes.\n"+
2051                                         "Please delete the notes or move them to another notebook before deleting any notebooks."));
2052                         return;
2053                 }
2054                 
2055                 if (conn.getNotebookTable().getAll().size() == 1) {
2056                         QMessageBox.information(this, tr("Unable to Delete"), tr("You must have at least one notebook."));
2057                         return;
2058                 }
2059         
2060         // If all notebooks are clear, verify the delete
2061                 String msg1 = new String(tr("Delete selected notebooks?"));
2062                 String msg2 = new String(tr("Remove selected stacks (notebooks will not be deleted)?"));
2063                 String msg3 = new String(tr("Delete selected notebooks & remove stacks? Notebooks under the stacks are" +
2064                                 " not deleted unless selected?"));
2065                 String msg = "";
2066                 if (stacksFound && notebooksFound)
2067                         msg = msg3;
2068                 if (!stacksFound && notebooksFound)
2069                         msg = msg1;
2070                 if (stacksFound && !notebooksFound)
2071                         msg = msg2;
2072                 if (QMessageBox.question(this, tr("Confirmation"), msg,
2073                         QMessageBox.StandardButton.Yes, 
2074                         QMessageBox.StandardButton.No)==StandardButton.No.value()) {
2075                         return;
2076                 }
2077                 
2078                 // If confirmed, delete the notebook
2079         for (int i=selections.size()-1; i>=0; i--) {
2080                 QTreeWidgetItem currentSelection;
2081                 currentSelection = selections.get(i);
2082                 String guid = currentSelection.text(2);
2083                 if (currentSelection.text(2).equalsIgnoreCase("STACK")) {
2084                         conn.getNotebookTable().renameStacks(currentSelection.text(0), "");
2085                         listManager.renameStack(currentSelection.text(0), "");
2086                 } else {
2087                         conn.getNotebookTable().expungeNotebook(guid, true);
2088                         listManager.deleteNotebook(guid);
2089                 }
2090         }
2091
2092                 notebookIndexUpdated();
2093 //        notebookTreeSelection();
2094 //        notebookTree.load(listManager.getNotebookIndex(), listManager.getLocalNotebooks());
2095 //        listManager.countNotebookResults(listManager.getNoteIndex());
2096         logger.log(logger.HIGH, "Entering NeverNote.deleteNotebook");
2097         }
2098         // A note's notebook has been updated
2099         @SuppressWarnings("unused")
2100         private void updateNoteNotebook(String guid, String notebookGuid) {
2101                 // ICHANGED 同じノートブックに入れられたノート間の履歴を登録
2102                 conn.getHistoryTable().addSameNotebookHistory(guid, notebookGuid);
2103                 
2104                 // Update the list manager
2105                 listManager.updateNoteNotebook(guid, notebookGuid);
2106                 listManager.countNotebookResults(listManager.getNoteIndex());
2107 //              notebookTree.updateCounts(listManager.getNotebookIndex(), listManager.getNotebookCounter());    
2108                 
2109                 // Find the name of the notebook
2110                 String notebookName = null;
2111                 for (int i=0; i<listManager.getNotebookIndex().size(); i++) {
2112                         if (listManager.getNotebookIndex().get(i).getGuid().equals(notebookGuid)) {
2113                                 notebookName = listManager.getNotebookIndex().get(i).getName();
2114                                 break;
2115                         }
2116                 }
2117                 
2118                 // If we found the name, update the browser window
2119                 if (notebookName != null) {
2120                         updateListNoteNotebook(guid, notebookName);
2121                         if (guid.equals(currentNoteGuid)) {
2122                                 int pos =  browserWindow.notebookBox.findText(notebookName);
2123                                 if (pos >=0)
2124                                         browserWindow.notebookBox.setCurrentIndex(pos);
2125                         }
2126                 }
2127                 
2128                 // If we're dealing with the current note, then we need to be sure and update the notebook there
2129                 if (guid.equals(currentNoteGuid)) {
2130                         if (currentNote != null) {
2131                                 currentNote.setNotebookGuid(notebookGuid);
2132                         }
2133                 }
2134         }
2135         // Open/close notebooks
2136         @SuppressWarnings("unused")
2137         private void closeNotebooks() {
2138                 NotebookArchive na = new NotebookArchive(listManager.getNotebookIndex(), listManager.getArchiveNotebookIndex());
2139                 na.exec();
2140                 if (!na.okClicked())
2141                         return;
2142                 
2143                 waitCursor(true);
2144                 listManager.getArchiveNotebookIndex().clear();
2145                 
2146                 for (int i=na.getClosedBookList().count()-1; i>=0; i--) {
2147                         String text = na.getClosedBookList().takeItem(i).text();
2148                         for (int j=0; j<listManager.getNotebookIndex().size(); j++) {
2149                                 if (listManager.getNotebookIndex().get(j).getName().equalsIgnoreCase(text)) {
2150                                         Notebook n = listManager.getNotebookIndex().get(j);
2151                                         conn.getNotebookTable().setArchived(n.getGuid(),true);
2152                                         listManager.getArchiveNotebookIndex().add(n);
2153                                         j=listManager.getNotebookIndex().size();
2154                                 }
2155                         }
2156                 }
2157                 
2158                 for (int i=na.getOpenBookList().count()-1; i>=0; i--) {
2159                         String text = na.getOpenBookList().takeItem(i).text();
2160                         for (int j=0; j<listManager.getNotebookIndex().size(); j++) {
2161                                 if (listManager.getNotebookIndex().get(j).getName().equalsIgnoreCase(text)) {
2162                                         Notebook n = listManager.getNotebookIndex().get(j);
2163                                         conn.getNotebookTable().setArchived(n.getGuid(),false);
2164                                         j=listManager.getNotebookIndex().size();
2165                                 }
2166                         }
2167                 }
2168                 notebookTreeSelection();
2169                 listManager.loadNotesIndex();
2170                 notebookIndexUpdated();
2171                 noteIndexUpdated(false);
2172                 reloadTagTree(true);
2173 //              noteIndexUpdated(false);
2174                 
2175                 // Build a list of non-closed notebooks
2176                 List<Notebook> nbooks = new ArrayList<Notebook>();
2177                 for (int i=0; i<listManager.getNotebookIndex().size(); i++) {
2178                         boolean found=false;
2179                         for (int j=0; j<listManager.getArchiveNotebookIndex().size(); j++) {
2180                                 if (listManager.getArchiveNotebookIndex().get(j).getGuid().equals(listManager.getNotebookIndex().get(i).getGuid()))
2181                                         found = true;
2182                         }
2183                         if (!found)
2184                                 nbooks.add(listManager.getNotebookIndex().get(i));
2185                 }
2186                 
2187                 FilterEditorNotebooks notebookFilter = new FilterEditorNotebooks(conn, logger);
2188                 List<Notebook> filteredBooks = notebookFilter.getValidNotebooks(currentNote, listManager.getNotebookIndex());
2189                 browserWindow.setNotebookList(filteredBooks);
2190                 
2191                 // Update any external windows
2192                 Iterator<String> set = externalWindows.keySet().iterator();
2193                 while(set.hasNext())
2194                         externalWindows.get(set.next()).getBrowserWindow().setNotebookList(filteredBooks);
2195                 
2196                 // ICHANGED
2197                 // 全てのタブウィンドウを更新
2198                 Iterator<Integer> it = tabWindows.keySet().iterator();
2199                 while (it.hasNext()) {
2200                         tabWindows.get(it.next()).getBrowserWindow()
2201                                         .setNotebookList(filteredBooks);
2202                 }
2203                 
2204                 waitCursor(false);
2205         }
2206         // Change the notebook's icon
2207         @SuppressWarnings("unused")
2208         private void setNotebookIcon() {
2209                 boolean stackSelected = false;
2210                 boolean allNotebookSelected = false;
2211                 
2212                 QTreeWidgetItem currentSelection;
2213                 List<QTreeWidgetItem> selections = notebookTree.selectedItems();
2214                 if (selections.size() == 0)
2215                         return;
2216                 
2217                 currentSelection = selections.get(0);   
2218                 String guid = currentSelection.text(2);
2219                 if (guid.equalsIgnoreCase(""))
2220                         allNotebookSelected = true;
2221                 if (guid.equalsIgnoreCase("STACK"))
2222                         stackSelected = true;
2223
2224                 QIcon currentIcon = currentSelection.icon(0);
2225                 QIcon icon;
2226                 SetIcon dialog;
2227                 
2228                 if (!stackSelected && !allNotebookSelected) {
2229                         icon = conn.getNotebookTable().getIcon(guid);
2230                         if (icon == null) {
2231                                 dialog = new SetIcon(currentIcon, saveLastPath);
2232                                 dialog.setUseDefaultIcon(true);
2233                         } else {
2234                                 dialog = new SetIcon(icon, saveLastPath);
2235                                 dialog.setUseDefaultIcon(false);
2236                         }
2237                 } else {
2238                         if (stackSelected) {
2239                                 icon = conn.getSystemIconTable().getIcon(currentSelection.text(0), "STACK");
2240                         } else {
2241                                 icon = conn.getSystemIconTable().getIcon(currentSelection.text(0), "ALLNOTEBOOK");                              
2242                         }
2243                         if (icon == null) {
2244                                 dialog = new SetIcon(currentIcon, saveLastPath);
2245                                 dialog.setUseDefaultIcon(true);
2246                         } else {
2247                                 dialog = new SetIcon(icon, saveLastPath);
2248                                 dialog.setUseDefaultIcon(false);
2249                         }
2250                 }
2251                 dialog.exec();
2252                 if (dialog.okPressed()) {
2253                 saveLastPath = dialog.getPath();
2254
2255                         QIcon newIcon = dialog.getIcon();
2256                         if (stackSelected) {
2257                                 conn.getSystemIconTable().setIcon(currentSelection.text(0), "STACK", newIcon, dialog.getFileType());
2258                                 if (newIcon == null) {
2259                                         newIcon = new QIcon(iconPath+"books2.png");
2260                                 }
2261                                 currentSelection.setIcon(0,newIcon);
2262                                 return;
2263                         }
2264                         if (allNotebookSelected) {
2265                                 conn.getSystemIconTable().setIcon(currentSelection.text(0), "ALLNOTEBOOK", newIcon, dialog.getFileType());
2266                                 if (newIcon == null) {
2267                                         newIcon = new QIcon(iconPath+"notebook-green.png");
2268                                 }
2269                                 currentSelection.setIcon(0,newIcon);
2270                                 return;
2271                         }
2272                         conn.getNotebookTable().setIcon(guid, newIcon, dialog.getFileType());
2273                         if (newIcon == null) {
2274                                 boolean isPublished = false;;
2275                                 boolean found = false;
2276                                 for (int i=0; i<listManager.getNotebookIndex().size() && !found; i++) {
2277                                         if (listManager.getNotebookIndex().get(i).getGuid().equals(guid)) {
2278                                                 isPublished = listManager.getNotebookIndex().get(i).isPublished();
2279                                                 found = true;
2280                                         }
2281                                 }
2282                                 newIcon = notebookTree.findDefaultIcon(guid, currentSelection.text(1), listManager.getLocalNotebooks(), isPublished);
2283                         }
2284                         currentSelection.setIcon(0, newIcon);
2285                 }
2286         
2287         }
2288         
2289         
2290     //***************************************************************
2291     //***************************************************************
2292     //** These functions deal with Tag menu items
2293     //***************************************************************
2294     //***************************************************************
2295         // Add a new notebook
2296         @SuppressWarnings("unused")
2297         private void addTag() {
2298                 logger.log(logger.HIGH, "Inside NeverNote.addTag");
2299                 TagEdit edit = new TagEdit();
2300                 edit.setTagList(listManager.getTagIndex());
2301
2302                 List<QTreeWidgetItem> selections = tagTree.selectedItems();
2303                 QTreeWidgetItem currentSelection = null;
2304                 if (selections.size() > 0) {
2305                         currentSelection = selections.get(0);
2306                         edit.setParentTag(currentSelection.text(0));
2307                 }
2308
2309                 edit.exec();
2310         
2311                 if (!edit.okPressed())
2312                         return;
2313         
2314                 Calendar currentTime = new GregorianCalendar();
2315                 Long l = new Long(currentTime.getTimeInMillis());
2316                 String randint = new String(Long.toString(l));
2317         
2318                 Tag newTag = new Tag();
2319                 newTag.setUpdateSequenceNum(0);
2320                 newTag.setGuid(randint);
2321                 newTag.setName(edit.getTag());
2322                 if (edit.getParentTag().isChecked()) {
2323                         newTag.setParentGuid(currentSelection.text(2));
2324                         newTag.setParentGuidIsSet(true);
2325                         currentSelection.setExpanded(true);
2326                 }
2327                 conn.getTagTable().addTag(newTag, true);
2328                 listManager.getTagIndex().add(newTag);
2329                 reloadTagTree(true);
2330                 
2331                 logger.log(logger.HIGH, "Leaving NeverNote.addTag");
2332         }
2333         @SuppressWarnings("unused")
2334         private void reloadTagTree() {
2335                 reloadTagTree(false);
2336         }
2337         private void reloadTagTree(boolean reload) {
2338                 logger.log(logger.HIGH, "Entering NeverNote.reloadTagTree");
2339                 tagIndexUpdated(reload);
2340                 boolean filter = false;
2341                 if (reload)
2342                         listManager.countTagResults(listManager.getNoteIndex());
2343                 if (notebookTree.selectedItems().size() > 0 
2344                                                   && !notebookTree.selectedItems().get(0).text(0).equalsIgnoreCase("All Notebooks"))
2345                                                   filter = true;
2346                 if (tagTree.selectedItems().size() > 0)
2347                         filter = true;
2348                 tagTree.showAllTags(!filter);
2349                 tagIndexUpdated(false);
2350                 logger.log(logger.HIGH, "Leaving NeverNote.reloadTagTree");
2351         }
2352         // Edit an existing tag
2353         @SuppressWarnings("unused")
2354         private void editTag() {
2355                 logger.log(logger.HIGH, "Entering NeverNote.editTag");
2356                 TagEdit edit = new TagEdit();
2357                 edit.setTitle("Edit Tag");
2358                 List<QTreeWidgetItem> selections = tagTree.selectedItems();
2359                 QTreeWidgetItem currentSelection;
2360                 currentSelection = selections.get(0);
2361                 edit.setTag(currentSelection.text(0));
2362                 edit.setTagList(listManager.getTagIndex());
2363                 edit.exec();
2364         
2365                 if (!edit.okPressed())
2366                         return;
2367         
2368                 String guid = currentSelection.text(2);
2369                 currentSelection.setText(0,edit.getTag());
2370                 
2371                 for (int i=0; i<listManager.getTagIndex().size(); i++) {
2372                         if (listManager.getTagIndex().get(i).getGuid().equals(guid)) {
2373                                 listManager.getTagIndex().get(i).setName(edit.getTag());
2374                                 conn.getTagTable().updateTag(listManager.getTagIndex().get(i), true);
2375                                 updateListTagName(guid);
2376                                 if (currentNote != null && currentNote.getTagGuids().contains(guid))
2377                                         browserWindow.setTag(getTagNamesForNote(currentNote));
2378                                 logger.log(logger.HIGH, "Leaving NeverNote.editTag");
2379                                 //return;
2380                         }
2381                 }
2382                 listManager.reloadNoteTagNames(guid, edit.getTag());
2383                 noteIndexUpdated(true);
2384                 refreshEvernoteNote(true);
2385                 browserWindow.setTag(getTagNamesForNote(currentNote));
2386                 logger.log(logger.HIGH, "Leaving NeverNote.editTag...");
2387         }
2388         // Delete an existing tag
2389         @SuppressWarnings("unused")
2390         private void deleteTag() {
2391                 logger.log(logger.HIGH, "Entering NeverNote.deleteTag");
2392                 
2393                 if (QMessageBox.question(this, tr("Confirmation"), tr("Delete the selected tags?"),
2394                         QMessageBox.StandardButton.Yes, 
2395                         QMessageBox.StandardButton.No)==StandardButton.No.value()) {
2396                                                         return;
2397                 }
2398                 
2399                 List<QTreeWidgetItem> selections = tagTree.selectedItems();
2400         for (int i=selections.size()-1; i>=0; i--) {
2401                 QTreeWidgetItem currentSelection;
2402                 currentSelection = selections.get(i);                   
2403                 removeTagItem(currentSelection.text(2));
2404         }
2405         tagIndexUpdated(true);
2406         tagTreeSelection();
2407         listManager.countTagResults(listManager.getNoteIndex());
2408 //              tagTree.updateCounts(listManager.getTagCounter());
2409         logger.log(logger.HIGH, "Leaving NeverNote.deleteTag");
2410         }
2411         // Remove a tag tree item.  Go recursively down & remove the children too
2412         private void removeTagItem(String guid) {
2413         for (int j=listManager.getTagIndex().size()-1; j>=0; j--) {             
2414                 String parent = listManager.getTagIndex().get(j).getParentGuid();
2415                 if (parent != null && parent.equals(guid)) {            
2416                         //Remove this tag's children
2417                         removeTagItem(listManager.getTagIndex().get(j).getGuid());
2418                 }
2419         }
2420         //Now, remove this tag
2421         removeListTagName(guid);
2422         conn.getTagTable().expungeTag(guid, true);                      
2423         for (int a=0; a<listManager.getTagIndex().size(); a++) {
2424                 if (listManager.getTagIndex().get(a).getGuid().equals(guid)) {
2425                         listManager.getTagIndex().remove(a);
2426                         return;
2427                 }
2428         }
2429         }
2430         // Setup the tree containing the user's tags
2431     private void initializeTagTree() {
2432         logger.log(logger.HIGH, "Entering NeverNote.initializeTagTree");
2433 //      tagTree.itemSelectionChanged.connect(this, "tagTreeSelection()");
2434 //      tagTree.itemClicked.connect(this, "tagTreeSelection()");
2435         tagTree.selectionSignal.connect(this, "tagTreeSelection()");
2436         listManager.tagSignal.refreshTagTreeCounts.connect(tagTree, "updateCounts(List)");
2437         logger.log(logger.HIGH, "Leaving NeverNote.initializeTagTree");
2438     }
2439     // Listener when a tag is selected
2440         private void tagTreeSelection() {
2441         logger.log(logger.HIGH, "Entering NeverNote.tagTreeSelection");
2442                 
2443         clearTrashFilter();
2444         clearAttributeFilter();
2445         clearSavedSearchFilter();
2446         
2447                 menuBar.noteRestoreAction.setVisible(false);
2448                 
2449                 // ICHANGED ゴミ箱から元の画面に戻す。連想ノートリストをONに。
2450                 if (!rensoNoteListDock.isEnabled()) {
2451                         rensoNoteListDock.setEnabled(true);
2452                 }
2453                 
2454         List<QTreeWidgetItem> selections = tagTree.selectedItems();
2455         QTreeWidgetItem currentSelection;
2456         selectedTagGUIDs.clear();
2457         for (int i=0; i<selections.size(); i++) {
2458                 currentSelection = selections.get(i);
2459                 selectedTagGUIDs.add(currentSelection.text(2));
2460         }
2461         if (selections.size() > 0) {
2462                 menuBar.tagEditAction.setEnabled(true);
2463                 menuBar.tagDeleteAction.setEnabled(true);
2464                 menuBar.tagIconAction.setEnabled(true);
2465         }
2466         else {
2467                 menuBar.tagEditAction.setEnabled(false);
2468                 menuBar.tagDeleteAction.setEnabled(false);
2469                 menuBar.tagIconAction.setEnabled(true);
2470         }
2471         if (selections.size() > 1)
2472                 menuBar.tagMergeAction.setEnabled(true);
2473         else
2474                 menuBar.tagMergeAction.setEnabled(false);
2475         listManager.setSelectedTags(selectedTagGUIDs);
2476         listManager.loadNotesIndex();
2477         noteIndexUpdated(false);
2478         refreshEvernoteNote(true);
2479         listManager.refreshCounters = true;
2480         listManager.refreshCounters();
2481         logger.log(logger.HIGH, "Leaving NeverNote.tagTreeSelection");
2482     }
2483     // trigger the tag index to be refreshed
2484     @SuppressWarnings("unused")
2485         private void tagIndexUpdated() {
2486         tagIndexUpdated(true);
2487     }
2488     private void tagIndexUpdated(boolean reload) {
2489         logger.log(logger.HIGH, "Entering NeverNote.tagIndexUpdated");
2490                 if (selectedTagGUIDs == null)
2491                         selectedTagGUIDs = new ArrayList<String>();
2492                 if (reload)
2493                         listManager.reloadTagIndex();
2494
2495                 tagTree.blockSignals(true);
2496                 if (reload) {
2497                         tagTree.setIcons(conn.getTagTable().getAllIcons());
2498                         tagTree.load(listManager.getTagIndex());
2499                 }
2500
2501         for (int i=selectedTagGUIDs.size()-1; i>=0; i--) {
2502                 boolean found = tagTree.selectGuid(selectedTagGUIDs.get(i));
2503                 if (!found)
2504                         selectedTagGUIDs.remove(i);
2505         }
2506         tagTree.blockSignals(false);
2507         
2508                 browserWindow.setTag(getTagNamesForNote(currentNote));
2509         logger.log(logger.HIGH, "Leaving NeverNote.tagIndexUpdated");
2510     }   
2511     // Show/Hide note information
2512         @SuppressWarnings("unused")
2513         private void toggleTagWindow() {
2514                 logger.log(logger.HIGH, "Entering NeverNote.toggleTagWindow");
2515         if (tagTree.isVisible())
2516                 tagTree.hide();
2517         else
2518                 tagTree.show();
2519         menuBar.hideTags.setChecked(tagTree.isVisible());
2520         Global.saveWindowVisible("tagTree", tagTree.isVisible());
2521         logger.log(logger.HIGH, "Leaving NeverNote.toggleTagWindow");
2522     }   
2523         // A note's tags have been updated
2524         @SuppressWarnings("unused")
2525         private void updateNoteTags(String guid, List<String> tags) {
2526                 // Save any new tags.  We'll need them later.
2527                 List<String> newTags = new ArrayList<String>();
2528                 for (int i=0; i<tags.size(); i++) {
2529                         if (conn.getTagTable().findTagByName(tags.get(i))==null) 
2530                                 newTags.add(tags.get(i));
2531                 }
2532                 
2533                 listManager.saveNoteTags(guid, tags, true);
2534                 listManager.countTagResults(listManager.getNoteIndex());
2535                 StringBuffer names = new StringBuffer("");
2536                 for (int i=0; i<tags.size(); i++) {
2537                         names = names.append(tags.get(i));
2538                         if (i<tags.size()-1) {
2539                                 names.append(Global.tagDelimeter + " ");
2540                         }
2541                 }
2542                 browserWindow.setTag(names.toString());
2543                 
2544                 // ICHANGED
2545                 for (TabBrowse tab: tabWindows.values()) {
2546                         if (tab.getBrowserWindow().getNote().getGuid().equals(guid)) {
2547                                 int index = tabBrowser.indexOf(tab);
2548                                 noteDirty.put(index, true);
2549                                 break;
2550                         }
2551                 }
2552                 
2553                 // Now, we need to add any new tags to the tag tree
2554                 for (int i=0; i<newTags.size(); i++) 
2555                         tagTree.insertTag(newTags.get(i), conn.getTagTable().findTagByName(newTags.get(i)));
2556         }
2557         // Get a string containing all tag names for a note
2558         private String getTagNamesForNote(Note n) {
2559                 logger.log(logger.HIGH, "Entering NeverNote.getTagNamesForNote");
2560                 if (n==null || n.getGuid() == null || n.getGuid().equals(""))
2561                         return "";
2562                 StringBuffer buffer = new StringBuffer(100);
2563                 Vector<String> v = new Vector<String>();
2564                 List<String> guids = n.getTagGuids();
2565                 
2566                 if (guids == null) 
2567                         return "";
2568                 
2569                 for (int i=0; i<guids.size(); i++) {
2570                         v.add(listManager.getTagNameByGuid(guids.get(i)));
2571                 }
2572                 Comparator<String> comparator = Collections.reverseOrder();
2573                 Collections.sort(v,comparator);
2574                 Collections.reverse(v);
2575                 
2576                 for (int i = 0; i<v.size(); i++) {
2577                         if (i>0) 
2578                                 buffer.append(", ");
2579                         buffer.append(v.get(i));
2580                 }
2581                 
2582                 logger.log(logger.HIGH, "Leaving NeverNote.getTagNamesForNote");
2583                 return buffer.toString();
2584         }       
2585         // Tags were added via dropping notes from the note list
2586         @SuppressWarnings("unused")
2587         private void tagsAdded(String noteGuid, String tagGuid) {
2588                 String tagName = null;
2589                 for (int i=0; i<listManager.getTagIndex().size(); i++) {
2590                         if (listManager.getTagIndex().get(i).getGuid().equals(tagGuid)) {
2591                                 tagName = listManager.getTagIndex().get(i).getName();
2592                                 i=listManager.getTagIndex().size();
2593                         }
2594                 }
2595                 if (tagName == null)
2596                         return;
2597                 
2598                 for (int i=0; i<listManager.getMasterNoteIndex().size(); i++) {
2599                         if (listManager.getMasterNoteIndex().get(i).getGuid().equals(noteGuid)) {
2600                                 List<String> tagNames = new ArrayList<String>();
2601                                 tagNames.add(new String(tagName));
2602                                 Note n = listManager.getMasterNoteIndex().get(i);
2603                                 for (int j=0; j<n.getTagNames().size(); j++) {
2604                                         tagNames.add(new String(n.getTagNames().get(j)));
2605                                 }
2606                                 listManager.getNoteTableModel().updateNoteTags(noteGuid, n.getTagGuids(), tagNames);
2607                                 if (n.getGuid().equals(currentNoteGuid)) {
2608                                         Collections.sort(tagNames);
2609                                         String display = "";
2610                                         for (int j=0; j<tagNames.size(); j++) {
2611                                                 display = display+tagNames.get(j);
2612                                                 if (j+2<tagNames.size()) 
2613                                                         display = display+Global.tagDelimeter+" ";
2614                                         }
2615                                         browserWindow.setTag(display);
2616                                 }
2617                                 i=listManager.getMasterNoteIndex().size();
2618                         }
2619                 }
2620                 
2621                 
2622                 listManager.getNoteTableModel().updateNoteSyncStatus(noteGuid, false);
2623         }
2624         private void clearTagFilter() {
2625                 tagTree.blockSignals(true);
2626                 tagTree.clearSelection();
2627                 menuBar.noteRestoreAction.setVisible(false);
2628                 menuBar.tagEditAction.setEnabled(false);
2629                 menuBar.tagMergeAction.setEnabled(false);
2630                 menuBar.tagDeleteAction.setEnabled(false);
2631                 menuBar.tagIconAction.setEnabled(false);
2632                 selectedTagGUIDs.clear();
2633         listManager.setSelectedTags(selectedTagGUIDs);
2634         tagTree.blockSignals(false);
2635         }
2636         // Change the icon for a tag
2637         @SuppressWarnings("unused")
2638         private void setTagIcon() {
2639                 QTreeWidgetItem currentSelection;
2640                 List<QTreeWidgetItem> selections = tagTree.selectedItems();
2641                 if (selections.size() == 0)
2642                         return;
2643                 
2644                 currentSelection = selections.get(0);   
2645                 String guid = currentSelection.text(2);
2646
2647                 QIcon currentIcon = currentSelection.icon(0);
2648                 QIcon icon = conn.getTagTable().getIcon(guid);
2649                 SetIcon dialog;
2650                 if (icon == null) {
2651                         dialog = new SetIcon(currentIcon, saveLastPath);
2652                         dialog.setUseDefaultIcon(true);
2653                 } else {
2654                         dialog = new SetIcon(icon, saveLastPath);
2655                         dialog.setUseDefaultIcon(false);
2656                 }
2657                 dialog.exec();
2658                 if (dialog.okPressed()) {
2659                 saveLastPath = dialog.getPath();
2660                         QIcon newIcon = dialog.getIcon();
2661                         conn.getTagTable().setIcon(guid, newIcon, dialog.getFileType());
2662                         if (newIcon == null) 
2663                                 newIcon = new QIcon(iconPath+"tag.png");
2664                         currentSelection.setIcon(0, newIcon);
2665                 }
2666         
2667         }
2668         // Merge tags
2669         @SuppressWarnings("unused")
2670         private void mergeTags() {
2671                 List<Tag> tags = new ArrayList<Tag>();
2672                 List<QTreeWidgetItem> selections = tagTree.selectedItems();
2673                 for (int i=0; i<selections.size(); i++) {
2674                         Tag record = new Tag();
2675                         record.setGuid(selections.get(i).text(2));
2676                         record.setName(selections.get(i).text(0));
2677                         tags.add(record);
2678                 }
2679
2680                 TagMerge mergeDialog = new TagMerge(tags);
2681                 mergeDialog.exec();
2682                 if (!mergeDialog.okClicked())
2683                         return;
2684                 String newGuid = mergeDialog.getNewTagGuid();
2685                 
2686                 for (int i=0; i<tags.size(); i++) {
2687                         if (!tags.get(i).getGuid().equals(newGuid)) {
2688                                 List<String> noteGuids = conn.getNoteTable().noteTagsTable.getTagNotes(tags.get(i).getGuid());
2689                                 for (int j=0; j<noteGuids.size(); j++) {
2690                                         String noteGuid = noteGuids.get(j);
2691                                         conn.getNoteTable().noteTagsTable.deleteNoteTag(noteGuid);
2692                                         if (!conn.getNoteTable().noteTagsTable.checkNoteNoteTags(noteGuid, newGuid))
2693                                                 conn.getNoteTable().noteTagsTable.saveNoteTag(noteGuid, newGuid, true);
2694                                 }
2695                         }
2696                 }
2697                 listManager.reloadIndexes();
2698         }
2699         
2700     //***************************************************************
2701     //***************************************************************
2702     //** These functions deal with Saved Search menu items
2703     //***************************************************************
2704     //***************************************************************
2705         // Add a new notebook
2706         @SuppressWarnings("unused")
2707         private void addSavedSearch() {
2708                 logger.log(logger.HIGH, "Inside NeverNote.addSavedSearch");
2709                 SavedSearchEdit edit = new SavedSearchEdit();
2710                 edit.setSearchList(listManager.getSavedSearchIndex());
2711                 edit.exec();
2712         
2713                 if (!edit.okPressed())
2714                         return;
2715         
2716                 Calendar currentTime = new GregorianCalendar();         
2717                 Long l = new Long(currentTime.getTimeInMillis());
2718                 String randint = new String(Long.toString(l));
2719         
2720                 SavedSearch search = new SavedSearch();
2721                 search.setUpdateSequenceNum(0);
2722                 search.setGuid(randint);
2723                 search.setName(edit.getName());
2724                 search.setQuery(edit.getQuery());
2725                 search.setFormat(QueryFormat.USER);
2726                 listManager.getSavedSearchIndex().add(search);
2727                 conn.getSavedSearchTable().addSavedSearch(search, true);
2728                 savedSearchIndexUpdated();
2729                 logger.log(logger.HIGH, "Leaving NeverNote.addSavedSearch");
2730         }
2731         // Edit an existing tag
2732         @SuppressWarnings("unused")
2733         private void editSavedSearch() {
2734                 logger.log(logger.HIGH, "Entering NeverNote.editSavedSearch");
2735                 SavedSearchEdit edit = new SavedSearchEdit();
2736                 edit.setTitle(tr("Edit Search"));
2737                 List<QTreeWidgetItem> selections = savedSearchTree.selectedItems();
2738                 QTreeWidgetItem currentSelection;
2739                 currentSelection = selections.get(0);
2740                 String guid = currentSelection.text(1);
2741                 SavedSearch s = conn.getSavedSearchTable().getSavedSearch(guid);
2742                 edit.setName(currentSelection.text(0));
2743                 edit.setQuery(s.getQuery());
2744                 edit.setSearchList(listManager.getSavedSearchIndex());
2745                 edit.exec();
2746         
2747                 if (!edit.okPressed())
2748                         return;
2749         
2750                 List<SavedSearch> list = listManager.getSavedSearchIndex();
2751                 SavedSearch search = null;
2752                 boolean found = false;
2753                 for (int i=0; i<list.size(); i++) {
2754                         search = list.get(i);
2755                         if (search.getGuid().equals(guid)) {
2756                                 i=list.size();
2757                                 found = true;
2758                         }
2759                 }
2760                 if (!found)
2761                         return;
2762                 search.setName(edit.getName());
2763                 search.setQuery(edit.getQuery());
2764                 conn.getSavedSearchTable().updateSavedSearch(search, true);
2765                 savedSearchIndexUpdated();
2766                 logger.log(logger.HIGH, "Leaving NeverNote.editSavedSearch");
2767         }
2768         // Delete an existing tag
2769         @SuppressWarnings("unused")
2770         private void deleteSavedSearch() {
2771                 logger.log(logger.HIGH, "Entering NeverNote.deleteSavedSearch");
2772                 
2773                 if (QMessageBox.question(this, tr("Confirmation"), tr("Delete the selected search?"),
2774                         QMessageBox.StandardButton.Yes, 
2775                         QMessageBox.StandardButton.No)==StandardButton.No.value()) {
2776                                                         return;
2777                 }
2778                 
2779                 List<QTreeWidgetItem> selections = savedSearchTree.selectedItems();
2780         for (int i=selections.size()-1; i>=0; i--) {
2781                 QTreeWidgetItem currentSelection;
2782                 currentSelection = selections.get(i);
2783                 for (int j=0; j<listManager.getSavedSearchIndex().size(); j++) {
2784                         if (listManager.getSavedSearchIndex().get(j).getGuid().equals(currentSelection.text(1))) {
2785                                 conn.getSavedSearchTable().expungeSavedSearch(listManager.getSavedSearchIndex().get(j).getGuid(), true);
2786                                 listManager.getSavedSearchIndex().remove(j);
2787                                 j=listManager.getSavedSearchIndex().size()+1;
2788                         }
2789                 }
2790                 selections.remove(i);
2791         }
2792         savedSearchIndexUpdated();
2793         logger.log(logger.HIGH, "Leaving NeverNote.deleteSavedSearch");
2794         }
2795     // Setup the tree containing the user's tags
2796     private void initializeSavedSearchTree() {
2797         logger.log(logger.HIGH, "Entering NeverNote.initializeSavedSearchTree");
2798         savedSearchTree.itemSelectionChanged.connect(this, "savedSearchTreeSelection()");
2799         logger.log(logger.HIGH, "Leaving NeverNote.initializeSavedSearchTree");
2800     }
2801     // Listener when a tag is selected
2802     @SuppressWarnings("unused")
2803         private void savedSearchTreeSelection() {
2804         logger.log(logger.HIGH, "Entering NeverNote.savedSearchTreeSelection");
2805
2806         clearNotebookFilter();
2807         clearTagFilter();
2808         clearTrashFilter();
2809         clearAttributeFilter();
2810         
2811         String currentGuid = selectedSavedSearchGUID;
2812         menuBar.savedSearchEditAction.setEnabled(true);
2813         menuBar.savedSearchDeleteAction.setEnabled(true);
2814         menuBar.savedSearchIconAction.setEnabled(true);
2815         
2816                 // ICHANGED ゴミ箱から元の画面に戻す。連想ノートリストをONに。
2817                 if (!rensoNoteListDock.isEnabled()) {
2818                         rensoNoteListDock.setEnabled(true);
2819                 }
2820                 
2821         List<QTreeWidgetItem> selections = savedSearchTree.selectedItems();
2822         QTreeWidgetItem currentSelection;
2823         selectedSavedSearchGUID = "";
2824         for (int i=0; i<selections.size(); i++) {
2825                 currentSelection = selections.get(i);
2826                 if (currentSelection.text(1).equals(currentGuid)) {
2827                         currentSelection.setSelected(false);
2828                 } else {
2829                         selectedSavedSearchGUID = currentSelection.text(1);
2830                 }
2831 //              i = selections.size() +1;
2832         }
2833         
2834         // There is the potential for no notebooks to be selected if this 
2835         // happens then we make it look like all notebooks were selecetd.
2836         // If that happens, just select the "all notebooks"
2837         if (selections.size()==0) {
2838                 clearSavedSearchFilter();
2839         }
2840         listManager.setSelectedSavedSearch(selectedSavedSearchGUID);
2841         
2842         logger.log(logger.HIGH, "Leaving NeverNote.savedSearchTreeSelection");
2843     }
2844     private void clearSavedSearchFilter() {
2845         menuBar.savedSearchEditAction.setEnabled(false);
2846         menuBar.savedSearchDeleteAction.setEnabled(false);
2847         menuBar.savedSearchIconAction.setEnabled(false);
2848         savedSearchTree.blockSignals(true);
2849         savedSearchTree.clearSelection();
2850         savedSearchTree.blockSignals(false);
2851         selectedSavedSearchGUID = "";
2852         searchField.setEditText("");
2853         searchPerformed = false;
2854         listManager.setSelectedSavedSearch(selectedSavedSearchGUID);
2855     }
2856     // trigger the tag index to be refreshed
2857         private void savedSearchIndexUpdated() { 
2858                 if (selectedSavedSearchGUID == null)
2859                         selectedSavedSearchGUID = new String();
2860                 savedSearchTree.blockSignals(true);
2861                 savedSearchTree.setIcons(conn.getSavedSearchTable().getAllIcons());
2862         savedSearchTree.load(listManager.getSavedSearchIndex());
2863         savedSearchTree.selectGuid(selectedSavedSearchGUID);
2864         savedSearchTree.blockSignals(false);
2865     }
2866     // trigger when the saved search selection changes
2867     @SuppressWarnings("unused")
2868         private void updateSavedSearchSelection() {
2869                 logger.log(logger.HIGH, "Entering NeverNote.updateSavedSearchSelection()");
2870                 
2871         menuBar.savedSearchEditAction.setEnabled(true);
2872         menuBar.savedSearchDeleteAction.setEnabled(true);
2873         menuBar.savedSearchIconAction.setEnabled(true);
2874         List<QTreeWidgetItem> selections = savedSearchTree.selectedItems();
2875
2876         if (selections.size() > 0) {
2877                 menuBar.savedSearchEditAction.setEnabled(true);
2878                 menuBar.savedSearchDeleteAction.setEnabled(true);
2879                 menuBar.savedSearchIconAction.setEnabled(true);
2880                 selectedSavedSearchGUID = selections.get(0).text(1);
2881                 SavedSearch s = conn.getSavedSearchTable().getSavedSearch(selectedSavedSearchGUID);
2882                 searchField.setEditText(s.getQuery());
2883         } else { 
2884                 menuBar.savedSearchEditAction.setEnabled(false);
2885                 menuBar.savedSearchDeleteAction.setEnabled(false);
2886                 menuBar.savedSearchIconAction.setEnabled(false);
2887                 selectedSavedSearchGUID = "";
2888                 searchField.setEditText("");
2889         }
2890         searchFieldChanged();
2891         
2892                 logger.log(logger.HIGH, "Leaving NeverNote.updateSavedSearchSelection()");
2893
2894         
2895     }
2896     // Show/Hide note information
2897         @SuppressWarnings("unused")
2898         private void toggleSavedSearchWindow() {
2899                 logger.log(logger.HIGH, "Entering NeverNote.toggleSavedSearchWindow");
2900         if (savedSearchTree.isVisible())
2901                 savedSearchTree.hide();
2902         else
2903                 savedSearchTree.show();
2904         menuBar.hideSavedSearches.setChecked(savedSearchTree.isVisible());
2905                                 
2906                 Global.saveWindowVisible("savedSearchTree", savedSearchTree.isVisible());
2907         logger.log(logger.HIGH, "Leaving NeverNote.toggleSavedSearchWindow");
2908     }
2909         // Change the icon for a saved search
2910         @SuppressWarnings("unused")
2911         private void setSavedSearchIcon() {
2912                 QTreeWidgetItem currentSelection;
2913                 List<QTreeWidgetItem> selections = savedSearchTree.selectedItems();
2914                 if (selections.size() == 0)
2915                         return;
2916                 
2917                 currentSelection = selections.get(0);   
2918                 String guid = currentSelection.text(1);
2919
2920                 QIcon currentIcon = currentSelection.icon(0);
2921                 QIcon icon = conn.getSavedSearchTable().getIcon(guid);
2922                 SetIcon dialog;
2923                 if (icon == null) {
2924                         dialog = new SetIcon(currentIcon, saveLastPath);
2925                         dialog.setUseDefaultIcon(true);
2926                 } else {
2927                         dialog = new SetIcon(icon, saveLastPath);
2928                         dialog.setUseDefaultIcon(false);
2929                 }
2930                 dialog.exec();
2931                 if (dialog.okPressed()) {
2932                 saveLastPath = dialog.getPath();
2933                         QIcon newIcon = dialog.getIcon();
2934                         conn.getSavedSearchTable().setIcon(guid, newIcon, dialog.getFileType());
2935                         if (newIcon == null) 
2936                                 newIcon = new QIcon(iconPath+"search.png");
2937                         currentSelection.setIcon(0, newIcon);
2938                 }
2939         
2940         }
2941         
2942         
2943         
2944         
2945     //***************************************************************
2946     //***************************************************************
2947     //** These functions deal with Help menu & tool menu items
2948     //***************************************************************
2949     //***************************************************************
2950         // Show database status
2951         @SuppressWarnings("unused")
2952         private void databaseStatus() {
2953                 waitCursor(true);
2954                 indexRunner.interrupt = true;
2955                 int dirty = conn.getNoteTable().getDirtyCount();
2956                 int unindexed = conn.getNoteTable().getUnindexedCount();
2957                 DatabaseStatus status = new DatabaseStatus();
2958                 status.setUnsynchronized(dirty);
2959                 status.setUnindexed(unindexed);
2960                 status.setNoteCount(conn.getNoteTable().getNoteCount());
2961                 status.setNotebookCount(listManager.getNotebookIndex().size());
2962                 status.setUnindexedResourceCount(conn.getNoteTable().noteResourceTable.getUnindexedCount());
2963                 status.setSavedSearchCount(listManager.getSavedSearchIndex().size());
2964                 status.setTagCount(listManager.getTagIndex().size());
2965                 status.setResourceCount(conn.getNoteTable().noteResourceTable.getResourceCount());
2966                 status.setWordCount(conn.getWordsTable().getWordCount());
2967                 status.setHistoryCount(conn.getHistoryTable().getHistoryCount());
2968                 waitCursor(false);
2969                 status.exec();
2970         }
2971         // Compact the database
2972         @SuppressWarnings("unused")
2973         private void compactDatabase() {
2974         logger.log(logger.HIGH, "Entering NeverNote.compactDatabase");
2975                 if (QMessageBox.question(this, tr("Confirmation"), tr("This will free unused space in the database, "+
2976                                 "but please be aware that depending upon the size of your database this can be time consuming " +
2977                                 "and NeighborNote will be unresponsive until it is complete.  Do you wish to continue?"),
2978                                 QMessageBox.StandardButton.Yes, 
2979                                 QMessageBox.StandardButton.No)==StandardButton.No.value() && Global.verifyDelete() == true) {
2980                                                         return;
2981                 }
2982                 setMessage("Compacting database.");
2983                 waitCursor(true);
2984                 listManager.compactDatabase();
2985                 waitCursor(false);
2986                 setMessage("Database compact is complete.");            
2987         logger.log(logger.HIGH, "Leaving NeverNote.compactDatabase");
2988     }
2989         @SuppressWarnings("unused")
2990         private void accountInformation() {
2991                 logger.log(logger.HIGH, "Entering NeverNote.accountInformation");
2992                 AccountDialog dialog = new AccountDialog();
2993                 dialog.show();
2994                 logger.log(logger.HIGH, "Leaving NeverNote.accountInformation");
2995         }
2996         @SuppressWarnings("unused")
2997         private void releaseNotes() {
2998                 logger.log(logger.HIGH, "Entering NeverNote.releaseNotes");
2999                 QDialog dialog = new QDialog(this);
3000                 QHBoxLayout layout = new QHBoxLayout();
3001                 QTextEdit textBox = new QTextEdit();
3002                 layout.addWidget(textBox);
3003                 textBox.setReadOnly(true);
3004                 QFile file = new QFile(Global.getFileManager().getProgramDirPath("release.txt"));
3005                 if (!file.open(new QIODevice.OpenMode(QIODevice.OpenModeFlag.ReadOnly,
3006                 QIODevice.OpenModeFlag.Text)))
3007                         return;
3008                 // ICHANGED 日本語文字化け対策
3009                 QTextCodec codec = QTextCodec.codecForName("UTF-8");
3010                 QTextStream textStream = new QTextStream(file);
3011                 textStream.setCodec(codec);
3012                 textBox.setText(textStream.readAll().toString());
3013                 
3014                 file.close();
3015                 dialog.setWindowTitle(tr("Release Notes"));
3016                 dialog.setLayout(layout);
3017                 dialog.show();
3018                 logger.log(logger.HIGH, "Leaving NeverNote.releaseNotes");
3019         }
3020         // Called when user picks Log from the help menu
3021         @SuppressWarnings("unused")
3022         private void logger() {
3023                 logger.log(logger.HIGH, "Entering NeverNote.logger");
3024                 LogFileDialog dialog = new LogFileDialog(emitLog);
3025                 dialog.exec();
3026                 logger.log(logger.HIGH, "Leaving NeverNote.logger");
3027         }
3028         // Menu option "help/about" was selected