OSDN Git Service

Merge branch 'moveINI' into develop
[neighbornote/NeighborNote.git] / src / cx / fbn / nevernote / Global.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
21 package cx.fbn.nevernote;
22
23
24 import java.io.ByteArrayInputStream;
25 import java.io.ByteArrayOutputStream;
26 import java.io.File;
27 import java.io.IOException;
28 import java.io.ObjectInputStream;
29 import java.io.ObjectOutputStream;
30 import java.text.SimpleDateFormat;
31 import java.util.ArrayList;
32 import java.util.Calendar;
33 import java.util.HashMap;
34 import java.util.List;
35
36 import org.apache.commons.lang3.StringEscapeUtils;
37
38 import com.evernote.edam.type.Accounting;
39 import com.evernote.edam.type.PrivilegeLevel;
40 import com.evernote.edam.type.User;
41 import com.evernote.edam.type.UserAttributes;
42 import com.swabunga.spell.engine.Configuration;
43 import com.trolltech.qt.core.QByteArray;
44 import com.trolltech.qt.core.QFile;
45 import com.trolltech.qt.core.QSettings;
46 import com.trolltech.qt.core.QSize;
47 import com.trolltech.qt.gui.QPalette;
48 import com.trolltech.qt.gui.QSystemTrayIcon;
49
50 import cx.fbn.nevernote.config.FileManager;
51 import cx.fbn.nevernote.config.InitializationException;
52 import cx.fbn.nevernote.config.StartupConfig;
53 import cx.fbn.nevernote.gui.ContainsAttributeFilterTable;
54 import cx.fbn.nevernote.gui.DateAttributeFilterTable;
55 import cx.fbn.nevernote.gui.ShortcutKeys;
56 import cx.fbn.nevernote.utilities.ApplicationLogger;
57 import cx.fbn.nevernote.utilities.Pair;
58
59
60 //*****************************************************
61 //*****************************************************
62 //* Global constants & static functions used by 
63 //* multiple threads.
64 //*****************************************************
65 //*****************************************************
66
67 public class Global {
68         // Set current version and the known versions.
69         // ICHANGED 自分用に変更
70         public static String version = "0.1.2";
71         public static String[] validVersions = {"0.1.2", "0.1.1", "0.1"};
72         
73     public static String username = ""; 
74     //public static String password = "";     
75     
76
77     // Each thread has an ID.  This is used primarily to check the status
78     // of running threads.
79     public static final int mainThreadId=0;
80     public static final int syncThreadId=1;
81     public static final int tagCounterThreadId=2;
82     public static final int trashCounterThreadId=3;   // This should always be the highest thread ID
83     public static final int indexThreadId=4;    // Thread for indexing words
84     public static final int saveThreadId=5;     // Thread used for processing data to saving content
85     public static final int notebookCounterThreadId=6;   // Notebook Thread
86     public static final int indexThread03Id=7;   // unused
87     public static final int indexThread04Id=8;   // unused
88     public static final int dbThreadId=9;   // This should always be the highest thread ID
89     public static final int threadCount = 10;
90     
91     
92     // These variables deal with where the list of notes appears
93     // They will either be vertical (View_List_Narrow) or will be
94     // on top of the note (View_List_Wide).  It also has the size of
95     // thumbnails displayed in each view
96     public static int View_List_Wide = 1;
97     public static int View_List_Narrow = 2;
98     public static QSize smallThumbnailSize = new QSize(100,75);
99     public static QSize largeThumbnailSize = new QSize(300,225);
100
101     // This is used to keep a running list of passwords that the user
102     // wants us to remember.
103     public static HashMap<String,Pair<String,String>> passwordSafe = new HashMap<String, Pair<String,String>>();
104     public static List<Pair<String,String>> passwordRemember = new ArrayList<Pair<String,String>>();
105     
106     
107     //public static String currentNotebookGuid;
108     
109     // These deal with Evernote user settings
110     public static User user; 
111     public static long authTimeRemaining;
112     public static long authRefreshTime;
113     public static long failedRefreshes = 0; 
114     public static String userStoreUrl;
115     public static String noteStoreUrl;
116     public static String noteStoreUrlBase;
117
118     // When we want to shut down we set this to true to short
119     // circut other threads
120     public static boolean keepRunning;
121         
122     // In the note list, these are the column numbers
123     // so I don't need to hard code numbers.
124     public static int noteTableCreationPosition = 0;
125     public static int noteTableTitlePosition = 1;
126     public static int noteTableTagPosition = 2;
127     public static int noteTableNotebookPosition = 3;
128     public static int noteTableChangedPosition = 4;
129     public static int noteTableGuidPosition = 5;
130     public static int noteTableAuthorPosition = 6;
131     public static int noteTableSourceUrlPosition = 7;
132     public static int noteTableSubjectDatePosition = 8;
133     public static int noteTableSynchronizedPosition = 9;
134     public static int noteTableThumbnailPosition = 10;
135     public static int noteTablePinnedPosition = 11;
136     public static int noteTableColumnCount = 12;
137     public static Integer cryptCounter = 0;
138     
139     //public static int minimumWordCount = 2;
140     
141     // Regular expression to parse text with when indexing
142     private static String wordRegex;
143     
144     // Experimental fixes.  Set via Edit/Preferences/Debugging
145     public static boolean enableCarriageReturnFix = false;
146     public static boolean enableHTMLEntitiesFix = false;
147     
148     // Used to set & retrieve ini & Windows registry settings
149     public static QSettings     settings;     // Set & get ini settings
150     public static boolean isConnected;    // Are we connected to Evernote
151     public static boolean showDeleted = false;   // Show deleted notes?
152     public static boolean disableUploads = false;  // Should we disable uploads (used in testing features)
153         public static int messageLevel;   // The level of messages to write to the log files
154         public static String tagDelimeter = ",";   // This is used to separate out tag names when entering above note
155         public static String attachmentNameDelimeter = "------";  // Used to separate out attachment names in the res directory
156         
157         
158         //* Database fields
159         public static String    databaseName = new String("NeverNote");  // database name.  used for multiple databases to separate settings.
160         public static String    indexDatabaseName = new String("Index"); // searchable words database
161         public static String    resourceDatabaseName = new String("Resources");  // attachments database
162         
163         // ICHANGED
164         public static String behaviorDatabaseName = new String("Behavior"); // 操作履歴データベース   
165         
166         public static DateAttributeFilterTable createdSinceFilter;
167         public static DateAttributeFilterTable createdBeforeFilter;
168         public static DateAttributeFilterTable changedSinceFilter;
169         public static DateAttributeFilterTable changedBeforeFilter;
170         public static ContainsAttributeFilterTable containsFilter;
171         
172         // Log file used for debugging
173         public static ApplicationLogger    logger;
174         //PrintStream stdoutStream;
175         
176         // Application key shortcuts & appearance
177         public static QPalette                          originalPalette;
178         public static ShortcutKeys                      shortcutKeys;
179         
180         public static boolean                           disableViewing;  // used to disable the editor
181         
182         // When saving a note, this is a list of things we strip out because Evernote hates them
183         public static List<String>                              invalidElements = new ArrayList<String>();
184         public static HashMap<String, ArrayList<String>>        invalidAttributes = new HashMap<String, ArrayList<String>>();
185         
186         public static boolean mimicEvernoteInterface; // Try to mimic Evernote or allow multiple notebook selection
187         public static HashMap<String,String> resourceMap;   // List of attachments for a note.
188         public static String cipherPassword = "";    // If the database is encrypted, this stores the password
189         public static String databaseCache = "16384";  // Default DB cache size
190         
191         // These are used for performance testing
192         static Calendar startTraceTime;   
193         static Calendar intervalTraceTime;
194         
195         static boolean syncOnly;
196         
197         private static FileManager fileManager;  // Used to access files & directories
198         
199     // Do initial setup 
200     public static void setup(StartupConfig startupConfig) throws InitializationException  {
201         String settingFileName = new String("NeighborNote.ini");
202         
203         // バージョン0.1.2以下で作成された古い設定ファイルを見つけたら、ホームディレクトリに移動させる。
204         String oldSettingPath = new QSettings(settingFileName, QSettings.Format.IniFormat).fileName();
205         File homeDir = new File(FileManager.toPlatformPathSeparator(startupConfig.getHomeDirPath()));
206         String homePath = FileManager.slashTerminatePath(homeDir.getPath());
207         if (QFile.exists(oldSettingPath)) {
208                 QFile file = new QFile(oldSettingPath);
209                 file.copy(homePath + settingFileName);
210                 file.remove();
211         }
212         
213         settings = new QSettings(homePath + settingFileName, QSettings.Format.IniFormat);
214         
215         disableViewing = startupConfig.getDisableViewing();
216         syncOnly = startupConfig.isSyncOnly();
217
218         fileManager = new FileManager(startupConfig.getHomeDirPath(), startupConfig.getProgramDirPath());
219
220
221                 getServer();  // Setup URL to connect to
222                 
223                 // Get regular expressions used to parse out words
224                 settings.beginGroup("General");
225                 String regex = (String) settings.value("regex", "[,\\s]+");
226                 setWordRegex(regex);
227                 settings.endGroup();
228                 
229                 //Setup debugging information
230                 settings.beginGroup("Debug");
231                 String msglevel = (String) settings.value("messageLevel", "Low");
232                 settings.endGroup();
233                 
234                 
235                 //messageLevel = 1;
236                 setMessageLevel(msglevel);
237                 keepRunning = true;  // Make sure child threads stay running
238                 disableUploads = disableUploads();  // Should we upload anything?  Normally false.\r
239                 //disableUploads = true;  //***** DELETE THIS LINE *******\r
240                 enableCarriageReturnFix = enableCarriageReturnFix();  // Enable test fix?
241                 enableHTMLEntitiesFix = enableHtmlEntitiesFix();  // Enable test fix?
242                 
243                 logger = new ApplicationLogger("global.log");  // Setup log for this class 
244                 shortcutKeys = new ShortcutKeys();  // Setup keyboard shortcuts.
245                 mimicEvernoteInterface = getMimicEvernoteInterface();  // Should we mimic Evernote's notebook behavior
246                 resourceMap = new HashMap<String,String>();  // Setup resource map used to store attachments when editing
247                         
248                 databaseCache = getDatabaseCacheSize();  // Set database cache size     
249                 
250                 Global.username = getUserInformation().getUsername();
251     }
252
253     // Get/Set word parsing regular expression
254     public static String getWordRegex() {
255         return wordRegex;
256     }
257     public static void setWordRegex(String r) {
258         wordRegex = r;
259     }
260
261    // Set the debug message level
262    public static void setMessageLevel(String msglevel) {
263         if (msglevel.equalsIgnoreCase("low")) 
264                         messageLevel = 1;
265                 if (msglevel.equalsIgnoreCase("medium")) 
266                         messageLevel = 2;
267                 if (msglevel.equalsIgnoreCase("high")) 
268                                 messageLevel = 3;
269                 if (msglevel.equalsIgnoreCase("extreme")) 
270                                         messageLevel = 4;
271                 settings.beginGroup("Debug");
272                 settings.setValue("messageLevel", msglevel);
273                 settings.endGroup();            
274     }
275
276    //****************************************************
277    //****************************************************
278    //** Save user account information from Evernote
279    //****************************************************
280    //****************************************************
281     public static void saveUserInformation(User user) {
282         settings.beginGroup("User");
283                 settings.setValue("id", user.getId());
284                 settings.setValue("username", user.getUsername());
285                 settings.setValue("email", user.getEmail());
286                 settings.setValue("name", user.getName());
287                 settings.setValue("timezone", user.getTimezone());
288                 settings.setValue("privilege", user.getPrivilege().getValue());
289                 settings.setValue("created", user.getCreated());
290                 settings.setValue("updated", user.getUpdated());
291                 settings.setValue("deleted", user.getDeleted());
292                 settings.setValue("shard", user.getShardId());
293                 settings.endGroup();
294                 isPremium();
295                 if (user.getAttributes()!=null)
296                         saveUserAttributes(user.getAttributes());
297                 if (user.getAccounting()!=null)
298                         saveUserAccounting(user.getAccounting());
299
300     }
301     public static User getUserInformation() {
302         User user = new User();
303         settings.beginGroup("User");
304         try {   
305                 user.setId((Integer)settings.value("id", 0));                   
306         } catch  (java.lang.ClassCastException e) {
307                 user.setId(new Integer((String)settings.value("id", "0")));
308         }
309                 String username = (String)settings.value("username", "");
310                 String email = (String)settings.value("email", "");
311                 String name = (String)settings.value("name", "");
312                 String timezone = (String)settings.value("timezone", "");
313                 Integer privilege = 0;
314                 try {   
315                         privilege = new Integer((String)settings.value("privilege", "0"));                      
316                 } catch (java.lang.ClassCastException e) {
317                         privilege = (Integer)settings.value("privilege", 0);
318                 }
319
320                 try {   
321                         String date = (String)settings.value("created", "0");
322                         user.setCreated(new Long(date));
323                         date = (String)settings.value("updated", "0");
324                         user.setUpdated(new Long(date));
325                         date = (String)settings.value("deleted", "0");
326                         user.setDeleted(new Long(date));
327                 } catch (java.lang.ClassCastException e) {
328                         Long date = (Long)settings.value("created", 0);
329                         user.setCreated(date);
330                         date = (Long)settings.value("updated", 0);
331                         user.setUpdated(date);
332                         date = (Long)settings.value("deleted", 0);
333                         user.setDeleted(date);
334                 }
335
336                 String shard = (String)settings.value("shard", "");
337         settings.endGroup();
338         
339         user.setUsername(username);
340         user.setEmail(email);
341         user.setName(name);
342         user.setTimezone(timezone);
343         PrivilegeLevel userLevel = PrivilegeLevel.findByValue(privilege);
344         user.setPrivilege(userLevel);
345         user.setShardId(shard);
346         return user;
347     }
348     
349     public static void saveUserAttributes(UserAttributes attrib) {
350         settings.beginGroup("UserAttributes");
351                 settings.setValue("defaultLocationName", attrib.getDefaultLocationName());
352                 settings.setValue("defaultLatitude", attrib.getDefaultLocationName());
353                 settings.setValue("defaultLongitude", attrib.getDefaultLocationName());
354                 settings.setValue("incomingEmailAddress", attrib.getIncomingEmailAddress());
355                 settings.endGroup();
356     }
357     public static UserAttributes getUserAttributes() {
358         settings.beginGroup("UserAttributes");
359         UserAttributes attrib = new UserAttributes();
360                 attrib.setDefaultLocationName((String)settings.value("defaultLocationName",""));
361                 attrib.setDefaultLatitudeIsSet(false);
362                 attrib.setDefaultLongitudeIsSet(false);
363                 attrib.setIncomingEmailAddress((String)settings.value("incomingEmailAddress", ""));
364                 settings.endGroup();
365                 return attrib;
366     }
367     public static void saveUserAccounting(Accounting acc) {
368         settings.beginGroup("UserAccounting");
369                 settings.setValue("uploadLimit", acc.getUploadLimit());
370                 settings.setValue("uploadLimitEnd", acc.getUploadLimitEnd());
371                 settings.setValue("uploadLimitNextMonth", acc.getUploadLimitNextMonth());
372                 settings.setValue("premiumServiceStart", acc.getPremiumServiceStart());
373                 settings.setValue("nextPaymentDue", acc.getNextPaymentDue());
374                 settings.setValue("uploadAmount", acc.getUpdated());
375                 settings.endGroup();
376     }
377     public static long getUploadLimitEnd() {
378         Long limit;
379         settings.beginGroup("UserAccounting");
380         
381         // Upload limit
382                 try {
383                         String val  = (String)settings.value("uploadLimitEnd", "0");
384                         limit = new Long(val.trim());
385                 } catch (Exception e) {
386                         try {
387                                 limit = (Long)settings.value("uploadLimitEnd", 0);
388                         } catch (Exception e1) {
389                                 limit = new Long(0);
390                         }
391                 }
392         
393                 // return value
394         settings.endGroup();
395         return limit;
396     }
397     public static void saveUploadAmount(long amount) {
398         settings.beginGroup("UserAccounting");
399                 settings.setValue("uploadAmount", amount);
400                 settings.endGroup();
401    }
402     public static long getUploadAmount() {
403                 long amt=0;
404                 settings.beginGroup("UserAccounting");
405                 try {
406                         String num = (String)settings.value("uploadAmount", "0");
407                         amt = new Long(num.trim());
408                 } catch (Exception e) {
409                         try {
410                                 amt = (Integer)settings.value("uploadAmount", 0);
411                         } catch (Exception e1) {
412                                 amt = 0;
413                         }
414                 }
415                 settings.endGroup();
416                 return amt;
417     }
418     public static void saveEvernoteUpdateCount(long amount) {
419         settings.beginGroup("UserAccounting");
420                 settings.setValue("updateCount", amount);
421                 settings.endGroup();
422     }
423     public static long getEvernoteUpdateCount() {
424                 long amt;
425                 settings.beginGroup("UserAccounting");
426                 try {
427                         String num = (String)settings.value("updateCount", new Long(0).toString());
428                         amt = new Long(num.trim());
429                 } catch (java.lang.ClassCastException e) {
430                         amt = 0;
431                 }
432                 settings.endGroup();
433                 return amt;
434     }
435     public static boolean isPremium() {
436                 int level;
437                 settings.beginGroup("User");
438                 try {
439                         String num = (String)settings.value("privilege", "1");
440                         level = new Integer(num.trim());
441                 } catch (java.lang.ClassCastException e) {
442                         try {
443                                 level = (Integer)settings.value("privilege", 1);
444                         } catch (Exception e1) {
445                                 level = 1;
446                         }
447                 }
448                 settings.endGroup();
449                 PrivilegeLevel userLevel = PrivilegeLevel.findByValue(level);
450                 if (userLevel == PrivilegeLevel.NORMAL)
451                         return false;
452                 return true;
453                 
454    }
455     public static long getUploadLimit() {
456                 settings.beginGroup("UserAccounting");
457                 long limit;
458                 try {
459                         String num = (String)settings.value("uploadLimit", new Long(0).toString());
460                         limit = new Long(num.trim());
461                 } catch (java.lang.ClassCastException e) {
462                         limit = 0;
463                 }
464                 settings.endGroup();
465                 return limit;
466     }
467
468     
469     
470     //****************************************************
471     //****************************************************
472     //** View settings.  Used to restore settings 
473     //** when starting and to control how the program
474     //** behaves.
475     //****************************************************
476     //****************************************************
477     
478     //* Get/Set if we should show a tray icon
479     public static boolean showTrayIcon() {
480                 settings.beginGroup("General");
481                 try {
482                         String max = (String) settings.value("showTrayIcon", "false");
483                         settings.endGroup();
484                         if (!max.equalsIgnoreCase("true") || !QSystemTrayIcon.isSystemTrayAvailable())
485                                 return false;
486                         else
487                                 return true;    
488                 } catch (java.lang.ClassCastException e) {
489                         Boolean value = (Boolean) settings.value("showTrayIcon", false);
490                         settings.endGroup();
491                         return value;
492                 }
493     }
494     public static void setShowTrayIcon(boolean val) {
495                 settings.beginGroup("General");
496                 if (val)
497                         settings.setValue("showTrayIcon", "true");
498                 else
499                         settings.setValue("showTrayIcon", "false");
500                 settings.endGroup();
501     }
502     
503     // Get/Set window maximized when closed last
504     public static boolean wasWindowMaximized() {
505         try {
506                         settings.beginGroup("General");
507                         String max = (String) settings.value("isMaximized", "true");
508                         settings.endGroup();
509                         if (!max.equalsIgnoreCase("true"))
510                                 return false;
511                         return true;    
512                 } catch (java.lang.ClassCastException e) {
513                         Boolean value = (Boolean) settings.value("isMaximized", true);
514                         settings.endGroup();
515                         return value;
516                 }
517     }
518     public static void saveWindowMaximized(boolean isMax) {
519                 settings.beginGroup("General");
520                 if (isMax)
521                         settings.setValue("isMaximized", "true");
522                 else
523                         settings.setValue("isMaximized", "false");
524                 settings.endGroup();
525     }
526     
527     // Get/set currently viewed note Guid
528     public static String getLastViewedNoteGuid() {
529                 settings.beginGroup("General");
530                 String guid = (String) settings.value("lastViewedNote", "");
531                 settings.endGroup();
532                 return guid;    
533     }
534     public static void saveCurrentNoteGuid(String guid) {
535                 settings.beginGroup("General");
536                 if (guid != null)
537                         settings.setValue("lastViewedNote", guid);
538                 else
539                         settings.setValue("lastViewedNote", "");
540                 settings.endGroup();
541     }
542     
543     // Get/Set the note column we are sorted on and the order
544     public static void setSortColumn(int i) {
545         int view = Global.getListView();
546                 settings.beginGroup("General");
547         if (view == Global.View_List_Wide)
548                 settings.setValue("sortColumn", i);
549         else
550                 settings.setValue("sortColumn-Narrow", i);
551                 settings.endGroup();
552     }
553     public static int getSortColumn() {;
554     String key;
555         if (Global.getListView() == Global.View_List_Wide)
556                 key = "sortColumn";
557         else
558                 key = "sortColumn-Narrow";
559
560         settings.beginGroup("General");
561         int order;      
562         try {
563                 String val  = settings.value(key, new Integer(0)).toString();
564                 order = new Integer(val.trim());
565         } catch (Exception e) {
566                 try {
567                         order = (Integer)settings.value(key, 0);
568                 } catch (Exception e1) {
569                     order = 0;
570                 }
571         }
572         
573         settings.endGroup();
574         return order;
575     }
576     public static void setSortOrder(int i) {
577         int view = Global.getListView();
578                 settings.beginGroup("General");
579         if (view == Global.View_List_Wide)
580                 settings.setValue("sortOrder", i);
581         else
582                 settings.setValue("sortOrder-Narrow", i);
583                 settings.endGroup();
584     }
585     public static int getSortOrder() {
586         int view = Global.getListView();
587                 settings.beginGroup("General");
588                 String key;
589         if (view == Global.View_List_Wide)
590                 key = "sortOrder";
591                 else
592                         key = "sortOrder-Narrow";
593
594                 int order;      
595                 try {
596                         String val  = settings.value(key, new Integer(0)).toString();
597                         order = new Integer(val.trim());
598                 } catch (Exception e) {
599                         try {
600                                 order = (Integer)settings.value(key, 0);
601                         } catch (Exception e1) {
602                             order = 0;
603                         }
604                 }
605                 
606                 settings.endGroup();
607                 return order;
608     }
609     
610     // Should we automatically log in to Evernote when starting?
611     public static boolean automaticLogin() {
612         try {
613                 settings.beginGroup("General");
614                 String text = (String)settings.value("automaticLogin", "false");
615                 settings.endGroup();
616                 if (text.equalsIgnoreCase("true"))
617                         return true;
618                 else
619                         return false;           
620         } catch (java.lang.ClassCastException e) {
621                 Boolean value = (Boolean) settings.value("automaticLogin", false);
622                 settings.endGroup();
623                 return value;
624         }
625     }
626     public static void setAutomaticLogin(boolean val) {
627                 settings.beginGroup("General");
628                 if (val)
629                         settings.setValue("automaticLogin", "true");
630                 else
631                         settings.setValue("automaticLogin", "false");
632                 settings.endGroup();
633     }
634
635     // Get/set the Evernote server Url.  
636     public static void setServer(String server) {
637                 settings.beginGroup("General");
638                 settings.setValue("server", server);
639                 settings.endGroup();            
640     }
641     public static String getServer() {
642                 settings.beginGroup("General");
643                 String text = (String)settings.value("server", "www.evernote.com");
644                 if (text.equals("www.evernote.com")) {
645                         userStoreUrl = "https://www.evernote.com/edam/user";
646                     noteStoreUrlBase = "www.evernote.com/edam/note/";   
647                 } else {
648                         userStoreUrl = "https://sandbox.evernote.com/edam/user";
649                         noteStoreUrlBase = "sandbox.evernote.com/edam/note/";
650                 }
651                 settings.endGroup();
652 //              if (isPremium())
653                         noteStoreUrlBase = "https://" + noteStoreUrlBase;
654 //              else
655 //                      noteStoreUrlBase = "http://" + noteStoreUrlBase;
656                 return text;
657     }
658
659     // Get/Set if we should disable uploads to Evernote
660     public static boolean disableUploads() {
661         settings.beginGroup("General");
662         try {
663                 String text = (String)settings.value("disableUploads", "false");
664                 settings.endGroup();
665                 if (text.equalsIgnoreCase("true"))
666                         return true;
667                 else
668                         return false;
669                 } catch (java.lang.ClassCastException e) {
670                         Boolean value = (Boolean) settings.value("disableUploads", false);
671                         settings.endGroup();
672                         return value;
673                 }
674     }
675     public static void setDisableUploads(boolean val) {
676                 settings.beginGroup("General");
677                 if (val)
678                         settings.setValue("disableUploads", "true");
679                 else
680                         settings.setValue("disableUploads", "false");
681                 settings.endGroup();
682                 disableUploads = val;
683     }
684  
685     // Should we view PDF documents inline?
686     public static boolean pdfPreview() {
687                 settings.beginGroup("General");
688                 try {
689                         String text = (String)settings.value("pdfPreview", "true");
690                         settings.endGroup();
691                         if (text.equalsIgnoreCase("true"))
692                                 return true;
693                         else
694                                 return false;
695                 } catch (java.lang.ClassCastException e) {
696                         Boolean value = (Boolean) settings.value("pdfPreview", true);
697                         settings.endGroup();
698                         return value;
699                 }
700     }
701     public static void setPdfPreview(boolean val) {
702                 settings.beginGroup("General");
703                 if (val)
704                         settings.setValue("pdfPreview", "true");
705                 else
706                         settings.setValue("pdfPreview", "false");
707                 settings.endGroup();
708     }
709     
710     // When creating a new note, should it inherit tags that are currently selected?
711     public static boolean newNoteWithSelectedTags() {
712                 settings.beginGroup("General");
713                 try {
714                         String text = (String)settings.value("newNoteWithSelectedTags", "false");
715                         settings.endGroup();
716                         if (text.equalsIgnoreCase("true"))
717                                 return true;
718                         else
719                                 return false;
720                 } catch (java.lang.ClassCastException e) {
721                         Boolean value = (Boolean) settings.value("newNoteWithSelectedTags", false);
722                         settings.endGroup();
723                         return value;
724                 }
725     }
726     public static void setNewNoteWithSelectedTags(boolean val) {
727                 settings.beginGroup("General");
728                 if (val)
729                         settings.setValue("newNoteWithSelectedTags", "true");
730                 else
731                         settings.setValue("newNoteWithSelectedTags", "false");
732                 settings.endGroup();
733     }
734     
735     // Minimum weight for text OCRed from Evernote. Anything below this
736     // Won't be shown to the user when they search
737     public static void setRecognitionWeight(int len) {
738                 settings.beginGroup("General");
739                 settings.setValue("recognitionWeight", len);
740                 settings.endGroup();            
741     }
742     public static int getRecognitionWeight() {
743                 settings.beginGroup("General");
744                 Integer len;
745                 try {
746                         len = (Integer)settings.value("recognitionWeight", 30);\r
747                 } catch (Exception e) {
748                         len = 80;\r
749                 }
750                 settings.endGroup();
751                 return len;
752     }
753     
754     // get/set current debug message level
755     public static String getMessageLevel() {
756                 settings.beginGroup("Debug");
757                 String text = (String)settings.value("messageLevel", "Low");
758                 settings.endGroup();
759                 setMessageLevel(text);
760                 return text;
761     }
762     public static void setDateFormat(String format) {
763                 settings.beginGroup("General");
764                 settings.setValue("dateFormat", format);
765                 settings.endGroup();            
766     }
767     
768     // Get/Set user date/time formats
769     public static String getDateFormat() {
770                 settings.beginGroup("General");
771                 String text = (String)settings.value("dateFormat", "MM/dd/yyyy");
772                 settings.endGroup();
773                 return text;
774     }
775     public static void setTimeFormat(String format) {
776                 settings.beginGroup("General");
777                 settings.setValue("timeFormat", format);
778                 settings.endGroup();            
779     }
780     public static String getTimeFormat() {
781                 settings.beginGroup("General");
782                 String text = (String)settings.value("timeFormat", "HH:mm:ss");
783                 settings.endGroup();
784                 return text;
785     }
786     
787     // How often should we sync with Evernote?
788     public static String getSyncInterval() {
789                 settings.beginGroup("General");
790                 String text = (String)settings.value("syncInterval", "15 minutes");
791                 settings.endGroup();
792                 return text;            
793     }
794     public static void setSyncInterval(String format) {
795                 settings.beginGroup("General");
796                 settings.setValue("syncInterval", format);
797                 settings.endGroup();            
798     }
799     
800     // Get/Set the width of columns and their position for the 
801     // next start.
802     public static void setColumnWidth(String col, int width) {
803         if (Global.getListView() == Global.View_List_Wide)
804                 settings.beginGroup("ColumnWidths");
805         else 
806                 settings.beginGroup("ColumnWidths-Narrow");
807                 settings.setValue(col, width);
808                 settings.endGroup();
809         }
810     public static int getColumnWidth(String col) {
811         int view = Global.getListView();
812         if (view == Global.View_List_Wide)
813                 settings.beginGroup("ColumnWidths");
814         else
815                 settings.beginGroup("ColumnWidths-Narrow");
816                 Integer width;
817                 try {
818                         String val  = (String)settings.value(col, "0");
819                         width = new Integer(val.trim());
820                 } catch (Exception e) {
821                         try {
822                                 width = (Integer)settings.value(col, 0);
823                         } catch (Exception e1) {
824                                 width = 0;
825                         }
826                 }
827                 settings.endGroup();
828                 return width;
829     }
830     public static void setColumnPosition(String col, int width) {
831         if (Global.getListView() == Global.View_List_Wide)
832                 settings.beginGroup("ColumnPosition");
833         else
834                 settings.beginGroup("ColumnPosition-Narrow");
835                 settings.setValue(col, width);
836                 settings.endGroup();
837     }
838     public static int getColumnPosition(String col) {
839         if (Global.getListView() == Global.View_List_Wide)
840                 settings.beginGroup("ColumnPosition");
841         else
842                 settings.beginGroup("ColumnPosition-Narrow");
843                 Integer width;
844                 try {
845                         String val  = (String)settings.value(col, "-1");
846                         width = new Integer(val.trim());
847                 } catch (Exception e) {
848                         try {
849                                 width = (Integer)settings.value(col, 0);
850                         } catch (Exception e1) {
851                                 width = 0;
852                         }
853                 }
854                 settings.endGroup();
855                 return width;
856     }
857     
858     // Ping the user when they try to delete or just do it.
859     public static boolean verifyDelete() {
860                 settings.beginGroup("General");
861                 try {
862                         String text = (String)settings.value("verifyDelete", "true");
863                         settings.endGroup();
864                         if (text.equalsIgnoreCase("true"))
865                                 return true;
866                         else
867                                 return false;
868                 } catch (java.lang.ClassCastException e) {
869                         Boolean value = (Boolean) settings.value("verifyDelete", true);
870                         settings.endGroup();
871                         return value;
872                 }
873     }
874     public static void setVerifyDelete(boolean val) {
875                 settings.beginGroup("General");
876                 if (val)
877                         settings.setValue("verifyDelete", "true");
878                 else
879                         settings.setValue("verifyDelete", "false");
880                 settings.endGroup();
881     }
882     
883     // Should it start minimized?
884     public static boolean startMinimized() {
885                 settings.beginGroup("General");
886                 try {
887                         String text = (String)settings.value("startMinimized", "false");
888                         settings.endGroup();
889                         if (text.equalsIgnoreCase("true"))
890                                 return true;
891                         else
892                                 return false;
893                 } catch (java.lang.ClassCastException e) {
894                         Boolean value = (Boolean) settings.value("startMinimized", false);
895                         settings.endGroup();
896                         return value;
897                 }
898     }
899     public static void setStartMinimized(boolean val) {
900                 settings.beginGroup("General");
901                 if (val)
902                         settings.setValue("startMinimized", "true");
903                 else
904                         settings.setValue("startMinimized", "false");
905                 settings.endGroup();
906     }
907     
908     // Should we upload the content of any deleted notes
909     public static boolean synchronizeDeletedContent() {
910                 settings.beginGroup("General");
911                 try {
912                         String text = (String)settings.value("syncDeletedContent", "false");
913                         settings.endGroup();
914                         if (text.equalsIgnoreCase("true"))
915                                 return true;
916                         else
917                                 return false;
918                 } catch (java.lang.ClassCastException e) {
919                         Boolean value = (Boolean) settings.value("syncDeletedContent", false);
920                         settings.endGroup();
921                         return value;
922                 }
923     }   
924     public static void setSynchronizeDeletedContent(boolean val) {
925                 settings.beginGroup("General");
926                 if (val)
927                         settings.setValue("syncDeletedContent", "true");
928                 else
929                         settings.setValue("syncDeletedContent", "false");
930                 settings.endGroup();
931     }
932     
933     // Is a section of the window visible?  Used to hide things people don't
934     // want to see.
935     public static boolean isWindowVisible(String window) {
936                 settings.beginGroup("WindowsVisible");
937                 try {
938                         String defaultValue = "true";
939                         if (window.equalsIgnoreCase("noteInformation"))
940                                 defaultValue = "false";
941                         String text = (String)settings.value(window, defaultValue);
942                         settings.endGroup();
943                         if (text.equalsIgnoreCase("true"))
944                                 return true;
945                 else
946                         return false;           
947                 } catch (java.lang.ClassCastException e) {
948                         boolean defaultValue = true;
949                         if (window.equalsIgnoreCase("noteInformation"))
950                                 defaultValue = false;
951                         Boolean value = (Boolean) settings.value("showTrayIcon", defaultValue);
952                         settings.endGroup();
953                         return value;
954                 }
955     }
956     public static void saveWindowVisible(String window, boolean val) {
957                 settings.beginGroup("WindowsVisible");
958                 if (val)
959                         settings.setValue(window, "true");
960                 else
961                         settings.setValue(window, "false");
962                 settings.endGroup();
963     }
964     
965     // Is a list in the column in the note list visible?  
966     public static boolean isColumnVisible(String window) {
967         String defaultValue = "true";
968         int view = Global.getListView();
969         if (Global.getListView() == Global.View_List_Wide)
970                 settings.beginGroup("ColumnsVisible");
971         else
972                 settings.beginGroup("ColumnsVisible-Narrow"); 
973                 if (window.equalsIgnoreCase("thumbnail") && view == Global.View_List_Wide)
974                         defaultValue = "false";
975                 if (window.equalsIgnoreCase("thumbnail"))
976                         defaultValue = "false";
977                 if (window.equalsIgnoreCase("Guid"))
978                         defaultValue = "false";
979                 try {
980                         String text = (String)settings.value(window, defaultValue);
981                         settings.endGroup();
982                         if (text.equalsIgnoreCase("true"))
983                                 return true;
984                         else
985                                 return false;
986                 } catch (java.lang.ClassCastException e) {
987                         boolean defBool = false;
988                         if (window.equalsIgnoreCase("true"))
989                                 defBool = true;
990                         else
991                                 defBool = false;
992                         Boolean value = (Boolean) settings.value(window, defBool);
993                         settings.endGroup();
994                         return value;
995                 }
996     }
997     public static void saveColumnVisible(String column, boolean val) {
998         if (Global.getListView() == Global.View_List_Wide)
999                 settings.beginGroup("ColumnsVisible");
1000         else
1001                 settings.beginGroup("ColumnsVisible-Narrow");                   
1002                 if (val)
1003                         settings.setValue(column, "true");
1004                 else
1005                         settings.setValue(column, "false");
1006                 settings.endGroup();
1007     }
1008     
1009     // Is a particular editor button visible?
1010     public static boolean isEditorButtonVisible(String window) {
1011                 settings.beginGroup("EditorButtonsVisible");
1012                 try {
1013                         String text = (String)settings.value(window, "true");
1014                         settings.endGroup();
1015                         if (text.equalsIgnoreCase("true"))
1016                                 return true;
1017                         else
1018                                 return false;
1019                 } catch (java.lang.ClassCastException e) {
1020                         Boolean value = (Boolean) settings.value(window, true);
1021                         settings.endGroup();
1022                         return value;
1023                 }
1024     }
1025     public static void saveEditorButtonsVisible(String column, boolean val) {
1026                 settings.beginGroup("EditorButtonsVisible");
1027                 if (val)
1028                         settings.setValue(column, "true");
1029                 else
1030                         settings.setValue(column, "false");
1031                 settings.endGroup();
1032     }
1033     
1034     // Should the test fixes be enabled
1035     public static boolean enableCarriageReturnFix() {
1036         try {
1037                 settings.beginGroup("Debug");
1038                 String text = (String)settings.value("enableCarriageReturnFix", "false");
1039                 settings.endGroup();
1040                 if (text.equalsIgnoreCase("true"))
1041                         return true;
1042                 else
1043                         return false;
1044                 } catch (java.lang.ClassCastException e) {
1045                         Boolean value = (Boolean) settings.value("enableCarriageReturnFix", false);
1046                         settings.endGroup();
1047                         return value;
1048                 }
1049     }
1050     public static void saveCarriageReturnFix(boolean val) {
1051                 settings.beginGroup("Debug");
1052                 if (val)
1053                         settings.setValue("enableCarriageReturnFix", "true");
1054                 else
1055                         settings.setValue("enableCarriageReturnFix", "false");
1056                 settings.endGroup();
1057     }
1058     public static boolean enableHtmlEntitiesFix() {
1059         try {
1060                 settings.beginGroup("Debug");
1061                 String text = (String)settings.value("enableHtmlEntitiesFix", "false");
1062                 settings.endGroup();
1063                 if (text.equalsIgnoreCase("true"))
1064                         return true;
1065                 else
1066                         return false;
1067                 } catch (java.lang.ClassCastException e) {
1068                         Boolean value = (Boolean) settings.value("enableHtmlEntitiesFix", false);
1069                         settings.endGroup();
1070                         return value;
1071                 }
1072     }
1073     public static void saveHtmlEntitiesFix(boolean val) {
1074                 settings.beginGroup("Debug");
1075                 if (val)
1076                         settings.setValue("enableHtmlEntitiesFix", "true");
1077                 else
1078                         settings.setValue("enableHtmlEntitiesFix", "false");
1079                 settings.endGroup();
1080     }
1081
1082 //    public static void setIndexThreads(int val) {
1083 //              settings.beginGroup("General");
1084 //              settings.setValue("indexThreads", val);
1085 //              settings.endGroup();
1086 //   }
1087 //    public static int getIndexThreads() {
1088 //              settings.beginGroup("General");
1089 //              Integer threads;
1090 //              try {
1091 //                      String val  = (String)settings.value("indexThreads", "1");
1092 //                      threads = new Integer(val.trim());
1093 //              } catch (Exception e) {
1094 //                      try {
1095 //                              threads = (Integer)settings.value("indexThreads", 1);
1096 //                      } catch (Exception e1) {
1097 //                              threads = 1;
1098 //                      }
1099 //              }
1100 //              settings.endGroup();
1101 //              threads = 1;
1102 //              return threads;
1103     
1104     // Get/Set text zoom factor
1105 //   }
1106     public static void setZoomFactor(double val) {
1107                 settings.beginGroup("General");
1108                 settings.setValue("zoomFactor", val);
1109                 settings.endGroup();
1110     }
1111     public static double getZoomFactor() {
1112                 settings.beginGroup("General");
1113                 Double threads;
1114                 try {
1115                         String val  = (String)settings.value("zoomFactor", "1.0");
1116                         threads = new Double(val.trim());
1117                 } catch (Exception e) {
1118                         try {
1119                                 threads = (Double)settings.value("zoomFactor", 1.0);
1120                         } catch (Exception e1) {
1121                                 threads = new Double(1);
1122                         }
1123                 }
1124                 settings.endGroup();
1125                 return threads;
1126     }
1127     public static void setTextSizeMultiplier(double val) {
1128                 settings.beginGroup("General");
1129                 settings.setValue("textMultiplier", val);
1130                 settings.endGroup();
1131     }
1132     public static double getTextSizeMultiplier() {
1133                 settings.beginGroup("General");
1134                 Double threads;
1135                 try {
1136                         String val  = (String)settings.value("textMultiplier", "1");
1137                         threads = new Double(val.trim());
1138                 } catch (Exception e) {
1139                         try {
1140                                 threads = (Double)settings.value("textMultiplier", 1);
1141                         } catch (Exception e1) {
1142                                 threads = new Double(1);
1143                         }
1144                 }
1145                 settings.endGroup();
1146                 return threads;
1147     }
1148     
1149     
1150     // Should we mimic Evernote and restrict the notebooks selected?
1151     public static boolean getMimicEvernoteInterface() {
1152                 settings.beginGroup("General");
1153                 try {
1154                         String text = (String)settings.value("mimicEvernoteInterface", "true");
1155                         settings.endGroup();
1156                         if (text.equalsIgnoreCase("true"))
1157                                 return true;
1158                         else
1159                                 return false;
1160                 } catch (java.lang.ClassCastException e) {
1161                         Boolean value = (Boolean) settings.value("mimicEvernoteInterface", true);
1162                         settings.endGroup();
1163                         return value;
1164                 }
1165     }
1166     public static void setMimicEvernoteInterface(boolean value) {
1167         settings.beginGroup("General");
1168         if (value)
1169                 settings.setValue("mimicEvernoteInterface", "true");
1170         else
1171                 settings.setValue("mimicEvernoteInterface", "false"); 
1172         settings.endGroup();
1173     }
1174     
1175     
1176     // Synchronize with Evernote when closing?
1177     public static boolean synchronizeOnClose() {
1178                 settings.beginGroup("General");
1179                 try {
1180                         String text = (String)settings.value("synchronizeOnClose", "false");
1181                         settings.endGroup();
1182                         if (text.equalsIgnoreCase("true"))
1183                                 return true;
1184                         else
1185                                 return false;
1186                 } catch (java.lang.ClassCastException e) {
1187                         Boolean value = (Boolean) settings.value("synchronizeOnClose", false);
1188                         settings.endGroup();
1189                         return value;
1190                 }
1191     }
1192     public static void setSynchronizeOnClose(boolean val) {
1193                 settings.beginGroup("General");
1194                 if (val)
1195                         settings.setValue("synchronizeOnClose", "true");
1196                 else
1197                         settings.setValue("synchronizeOnClose", "false");
1198                 settings.endGroup();
1199     }
1200
1201     // Get/set the database version.  Not really used any more, but kept
1202     // for compatibility.
1203     public static void setDatabaseVersion(String version) {
1204                 settings.beginGroup("General");
1205                 settings.setValue("databaseVersion", version);
1206                 settings.endGroup();
1207     }
1208     public static String getDatabaseVersion() {
1209                 settings.beginGroup("General");
1210                 String val  = (String)settings.value("databaseVersion", "0.70");
1211                 settings.endGroup();
1212                 return val;
1213     }
1214
1215     // Get the URL (full path) of the main database
1216     public static String getDatabaseUrl() {
1217                 settings.beginGroup("General");
1218                 String val  = (String)settings.value("DatabaseURL", "");
1219                 settings.endGroup();
1220                 if (val.equals(""))
1221                         val = "jdbc:h2:"+Global.getFileManager().getDbDirPath(Global.databaseName);
1222                 return val;
1223     }
1224     
1225     // get the url (full path) of the searchable word database
1226     public static String getIndexDatabaseUrl() {
1227                 settings.beginGroup("General");
1228                 String val  = (String)settings.value("IndexDatabaseURL", "");
1229                 settings.endGroup();
1230                 if (val.equals(""))
1231                         val = "jdbc:h2:"+Global.getFileManager().getDbDirPath(Global.indexDatabaseName);
1232                 return val;
1233     }
1234     
1235     // Get the url (full path) of the attachment database
1236     public static String getResourceDatabaseUrl() {
1237                 settings.beginGroup("General");
1238                 String val  = (String)settings.value("ResourceDatabaseURL", "");
1239                 settings.endGroup();
1240                 if (val.equals(""))
1241                         val = "jdbc:h2:"+Global.getFileManager().getDbDirPath(Global.resourceDatabaseName);
1242                 return val;
1243     }
1244     
1245         // ICHANGED
1246         // 操作履歴データベースのURL(フルパス)をゲット
1247         public static String getBehaviorDatabaseUrl() {
1248                 settings.beginGroup("General");
1249                 String val = (String) settings.value("BehaviorDatabaseURL", "");
1250                 settings.endGroup();
1251                 if (val.equals(""))
1252                         val = "jdbc:h2:"
1253                                         + Global.getFileManager().getDbDirPath(
1254                                                         Global.behaviorDatabaseName);
1255                 return val;
1256         }
1257         
1258     public static void setDatabaseUrl(String value) {
1259                 settings.beginGroup("General");
1260                 settings.setValue("DatabaseURL", value);
1261                 settings.endGroup();
1262     }
1263     public static void setIndexDatabaseUrl(String value) {
1264                 settings.beginGroup("General");
1265                 settings.setValue("IndexDatabaseURL", value);
1266                 settings.endGroup();
1267     }
1268     public static void setResourceDatabaseUrl(String value) {
1269                 settings.beginGroup("General");
1270                 settings.setValue("ResourceDatabaseURL", value);
1271                 settings.endGroup();
1272     }
1273     
1274         // ICHANGED
1275         public static void setBehaviorDatabaseUrl(String value) {
1276                 settings.beginGroup("General");
1277                 settings.setValue("BehaviorDatabaseURL", value);
1278                 settings.endGroup();
1279         }
1280         
1281     public static String getDatabaseUserid() {
1282                 settings.beginGroup("General");
1283                 String val  = (String)settings.value("databaseUserid", "");
1284                 settings.endGroup();
1285                 return val;
1286     }
1287     public static String getDatabaseUserPassword() {
1288                 settings.beginGroup("General");
1289                 String val  = (String)settings.value("databaseUserPassword", "");
1290                 settings.endGroup();
1291                 return val;
1292     }
1293     
1294     // get/Set the style sheet and the palette to control the look & feel
1295     public static void setStyle(String style) {
1296                 settings.beginGroup("General");
1297                 settings.setValue("style", style);
1298                 settings.endGroup();
1299     }
1300     public static String getStyle() {
1301                 settings.beginGroup("General");
1302                 String val  = (String)settings.value("style", "Cleanlooks");
1303                 settings.endGroup();
1304                 return val;
1305     }
1306     public static boolean useStandardPalette() {
1307                 settings.beginGroup("General");
1308                 try {
1309                         String text = (String)settings.value("standardPalette", "true");
1310                         settings.endGroup();
1311                         if (text.equalsIgnoreCase("true"))
1312                                 return true;
1313                         else
1314                                 return false;
1315                 } catch (java.lang.ClassCastException e) {
1316                         Boolean value = (Boolean) settings.value("standardPalette", true);
1317                         settings.endGroup();
1318                         return value;
1319                 }
1320     }
1321     public static void setStandardPalette(boolean val) {
1322                 settings.beginGroup("General");
1323                 if (val)
1324                         settings.setValue("standardPalette", "true");
1325                 else
1326                         settings.setValue("standardPalette", "false");
1327                 settings.endGroup();
1328     }
1329     
1330     // Set the amount of time to wait between indexing
1331     // Get/Set interval when the index thread wakes up.
1332     public static void setIndexThreadSleepInterval(int sleep) {
1333                 settings.beginGroup("General");
1334                 settings.setValue("IndexThreadSleepInterval", sleep);
1335                 settings.endGroup();
1336     }
1337     public static int getIndexThreadSleepInterval() {
1338                 settings.beginGroup("General");
1339                 Integer sleep;
1340                 try {
1341                         String val  = (String)settings.value("IndexThreadSleepInterval", "300");
1342                         sleep = new Integer(val.trim());
1343                 } catch (Exception e) {
1344                         try {
1345                                 sleep = (Integer)settings.value("IndexThreadSleepInterval", 0);
1346                         } catch (Exception e1) {
1347                                 sleep = 300;
1348                         }
1349                 }
1350                 settings.endGroup();
1351                 return sleep;
1352     }
1353     
1354     
1355     // Get/Set a window state for later restoring
1356     public static void saveState(String name, QByteArray state) {
1357         int view = Global.getListView();
1358         if (view == Global.View_List_Narrow)
1359                 name = name +"Narrow";
1360                 settings.beginGroup("SaveState");
1361                 settings.setValue(name, state);
1362                 settings.endGroup();
1363     }
1364     
1365     public static QByteArray restoreState(String name) {
1366         int view = Global.getListView();
1367         if (view == Global.View_List_Narrow)
1368                 name = name +"Narrow";
1369                 settings.beginGroup("SaveState");
1370                 QByteArray state = (QByteArray)settings.value(name);
1371                 settings.endGroup();
1372                 return state;
1373     }
1374     public static void saveGeometry(String name, QByteArray state) {
1375         int view = Global.getListView();
1376         if (view == Global.View_List_Narrow)
1377                 settings.beginGroup("SaveGeometryNarrow");
1378         else
1379                 settings.beginGroup("SaveGeometry");
1380                 settings.setValue(name, state);
1381                 settings.endGroup();
1382     }
1383     
1384     public static QByteArray restoreGeometry(String name) {
1385         int view = Global.getListView();
1386         if (view == Global.View_List_Narrow)
1387                 settings.beginGroup("SaveGeometryNarrow");
1388         else
1389                 settings.beginGroup("SaveGeometry");
1390                 QByteArray state = (QByteArray)settings.value(name);
1391                 settings.endGroup();
1392                 return state;
1393     }
1394     
1395     
1396     // Set how often to do an automatic save
1397     public static void setAutoSaveInterval(int interval) {
1398                 settings.beginGroup("General");
1399                 settings.setValue("autoSaveInterval", interval);
1400                 settings.endGroup();
1401     }
1402     public static int getAutoSaveInterval() {
1403                 settings.beginGroup("General");
1404                 Integer value;
1405                 try {
1406                         String val  = (String)settings.value("autoSaveInterval", "5");
1407                         value = new Integer(val.trim());
1408                 } catch (Exception e) {
1409                         try {
1410                                 value = (Integer)settings.value("autoSaveInterval", 5);
1411                         } catch (Exception e1) {
1412                                 value = 5;
1413                         }
1414                 }
1415                 settings.endGroup();
1416                 return value;
1417     }
1418      
1419     // Add an invalid attribute & element to the database so we don't bother parsing it in the future
1420     // These values we automatically remove from any note.
1421     // Add invalid attributes
1422     public static void addInvalidAttribute(String element, String attribute) {
1423         
1424                 List<String> attributes = invalidAttributes.get(element);
1425                 if (attributes != null) {
1426                         for (int i=0; i<attributes.size(); i++)
1427                                 if (attribute.equalsIgnoreCase(attributes.get(i))) {
1428                                         return;
1429                         }
1430         }
1431         
1432         ArrayList<String> attributeList;
1433         if (!invalidAttributes.containsKey(element)) {
1434                 attributeList = new ArrayList<String>();
1435                 attributeList.add(attribute);
1436                 invalidAttributes.put(element, attributeList);
1437         }
1438         else {
1439                 attributeList = invalidAttributes.get(element);
1440                 attributeList.add(attribute);
1441                 invalidAttributes.put(element,attributeList);
1442         }
1443     }
1444    
1445     // Add invalid attributes
1446     public static void addInvalidElement(String element) {
1447                 for (int i=0; i<invalidElements.size(); i++) {
1448                         if (element.equalsIgnoreCase(invalidElements.get(i)))
1449                                 return;
1450                 }
1451         invalidElements.add(element);
1452     }
1453     
1454     // Get/Set proxy information
1455     // Proxy settings
1456     public static String getProxyValue(String key) {
1457                 settings.beginGroup("Proxy");
1458                 String val  = (String)settings.value(key, "");
1459                 settings.endGroup();
1460                 return val;
1461     }
1462     public static void setProxyValue(String key, String value) {
1463                 settings.beginGroup("Proxy");
1464                 settings.setValue(key, value);
1465                 settings.endGroup();
1466     }
1467     
1468     // Change a byte array to a hex string
1469     // Convert a byte array to a hex string
1470         public static String byteArrayToHexString(byte data[]) {
1471                 StringBuffer buf = new StringBuffer();
1472             for (byte element : data) {
1473                 int halfbyte = (element >>> 4) & 0x0F;
1474                 int two_halfs = 0;
1475                 do {
1476                         if ((0 <= halfbyte) && (halfbyte <= 9))
1477                                buf.append((char) ('0' + halfbyte));
1478                            else
1479                                 buf.append((char) ('a' + (halfbyte - 10)));
1480                         halfbyte = element & 0x0F;
1481                 } while(two_halfs++ < 1);
1482             }
1483             return buf.toString();              
1484         }
1485
1486     
1487         // Get/Set spelling settings
1488         public static boolean getSpellSetting(String value) {
1489                 settings.beginGroup("Spell");
1490                 String text = (String)settings.value(value, "");
1491                 settings.endGroup();
1492                 if (text.equalsIgnoreCase("true"))
1493                         return true;
1494                 if (text.equalsIgnoreCase("false"))
1495                         return false;
1496                 if (value.equalsIgnoreCase(Configuration.SPELL_IGNOREDIGITWORDS))
1497                         return true;
1498                 if (value.equalsIgnoreCase(Configuration.SPELL_IGNOREINTERNETADDRESSES))
1499                         return true;
1500                 if (value.equalsIgnoreCase(Configuration.SPELL_IGNOREUPPERCASE))
1501                         return true;
1502                 if (value.equalsIgnoreCase(Configuration.SPELL_IGNORESENTENCECAPITALIZATION))
1503                         return true;
1504                 return false;
1505     }
1506     public static void setSpellSetting(String setting, boolean val) {
1507                 settings.beginGroup("Spell");
1508                 if (val)
1509                         settings.setValue(setting, "true");
1510                 else
1511                         settings.setValue(setting, "false");
1512                 settings.endGroup();
1513     }
1514         
1515         // Get/Set how we should display tags (color them, hide unused, or do nothing)
1516         // What to do with inactive tags?
1517         public static String tagBehavior() {
1518                 settings.beginGroup("General");
1519                 String text = (String)settings.value("tagBehavior", "DoNothing");
1520                 settings.endGroup();
1521                 return text;
1522         }
1523         // What to do with inactive tags?
1524         public static void setTagBehavior(String value) {
1525                 settings.beginGroup("General");
1526                 settings.setValue("tagBehavior", value);
1527                 settings.endGroup();
1528         }
1529
1530     
1531         // Should the toolbar be visible?
1532         public static boolean isToolbarButtonVisible(String window) {
1533                 settings.beginGroup("ToolbarButtonsVisible");
1534                 try {
1535                         String text = (String)settings.value(window, "true");
1536                         settings.endGroup();
1537                         if (text.equalsIgnoreCase("true"))
1538                                 return true;
1539                         else
1540                                 return false;   
1541                 } catch (java.lang.ClassCastException e) {
1542                         Boolean value = (Boolean) settings.value(window, true);
1543                         settings.endGroup();
1544                         return value;
1545                 }
1546     }
1547     public static void saveToolbarButtonsVisible(String column, boolean val) {
1548                 settings.beginGroup("ToolbarButtonsVisible");
1549                 if (val)
1550                         settings.setValue(column, "true");
1551                 else
1552                         settings.setValue(column, "false");
1553                 settings.endGroup();
1554     }
1555         
1556     // Are thumbnails enabled?
1557     
1558     public static boolean enableThumbnails() {
1559                 settings.beginGroup("Debug");
1560                 try {
1561                         String text = (String)settings.value("thumbnails", "true");
1562                         settings.endGroup();
1563                         if (text.equalsIgnoreCase("true"))
1564                                 return true;
1565                         else
1566                                 return false;
1567                 } catch (java.lang.ClassCastException e) {
1568                         Boolean value = (Boolean) settings.value("thumbnails", true);
1569                         settings.endGroup();
1570                         return value;
1571                 }
1572     }
1573     public static void setEnableThumbnails(boolean val) {
1574                 settings.beginGroup("Debug");
1575                 if (val)
1576                         settings.setValue("thumbnails", "true");
1577                 else
1578                         settings.setValue("thumbnails", "false");
1579                 settings.endGroup();
1580     }
1581         
1582     // Trace used for performance tuning.  Not normally used in production.
1583         // Print date/time.  Used mainly for performance tracing
1584         public static void trace(boolean resetInterval) {
1585                 String fmt = "MM/dd/yy HH:mm:ss.SSSSSS";
1586                 String dateTimeFormat = new String(fmt);
1587                 SimpleDateFormat simple = new SimpleDateFormat(dateTimeFormat);
1588                 Calendar cal = Calendar.getInstance();
1589                 if (intervalTraceTime == null) 
1590                         intervalTraceTime = Calendar.getInstance();
1591                 if (startTraceTime == null)
1592                         startTraceTime = Calendar.getInstance();
1593                 
1594                 float interval = (cal.getTimeInMillis() - intervalTraceTime.getTimeInMillis());
1595                 float total = (cal.getTimeInMillis() - startTraceTime.getTimeInMillis());
1596                 
1597 //              if (interval > 00.0) {
1598                         StackTraceElement[] exceptions = Thread.currentThread().getStackTrace();
1599                         System.out.println("------------------------------------------");
1600
1601                         System.out.println("Date/Time " +simple.format(cal.getTime()));
1602                         System.out.format("Interval Time: %-10.6f%n", interval);
1603                         System.out.format("Total Time: %-10.6f%n", total);
1604                         for (int i=2; i<5 && i<exceptions.length; i++) {
1605                                 System.out.println(exceptions[i]);
1606                         }
1607 //              }
1608                 if (resetInterval)
1609                         intervalTraceTime = cal;
1610         }
1611         public static void traceReset() {
1612                 intervalTraceTime = null;
1613                 startTraceTime = null;
1614         }
1615
1616     
1617         // Get the FileManager class to manage local files & directories
1618         public static FileManager getFileManager() {
1619         return fileManager;
1620     }
1621         
1622         // Should the note editor be disabled?
1623     public static boolean getDisableViewing() {
1624         return disableViewing;
1625     }
1626
1627     //**********************
1628     //* Thumbnail zoom level
1629     //**********************
1630     public static int calculateThumbnailZoom(String content) {
1631         int zoom = 1;
1632                 if (content.indexOf("application/pdf") == -1) {
1633                         if (content.indexOf("image/") == -1) {
1634                                 String text =  StringEscapeUtils.unescapeHtml4(content.replaceAll("\\<.*?\\>", ""));
1635                                 zoom = 2;
1636                                 if (text.length() < 500) 
1637                                         zoom = 2;
1638                                 if (text.length() < 250)
1639                                         zoom = 3;
1640                                 if (text.length() < 100)
1641                                         zoom = 4;
1642                                 if (text.length() < 50)
1643                                         zoom = 5;
1644                                 if (text.length() < 10)
1645                                         zoom = 6;
1646                         }
1647                 }
1648                 return zoom;
1649     }
1650     
1651     //**********************
1652     //* List View settings 
1653     //**********************
1654     public static void setListView(int view) {
1655                 settings.beginGroup("General");
1656                 settings.setValue("listView", view);
1657                 settings.endGroup();
1658     }
1659     public static int getListView() {
1660                 settings.beginGroup("General");
1661                 Integer value;
1662                 try {
1663                         String val  = (String)settings.value("listView", View_List_Wide);
1664                         value = new Integer(val.trim());
1665                 } catch (Exception e) {
1666                         try {
1667                                 value = (Integer)settings.value("listView", View_List_Wide);
1668                         } catch (Exception e1) {
1669                                 value = View_List_Wide;
1670                         }
1671                 }
1672                 settings.endGroup();
1673                 return value;
1674     }
1675
1676     
1677     
1678     //*******************
1679     // Font Settings
1680     //*******************
1681     public static boolean overrideDefaultFont() {
1682                 settings.beginGroup("Font");
1683                 try {
1684                         String text = (String)settings.value("overrideFont", "false");
1685                         settings.endGroup();
1686                         if (text.equalsIgnoreCase("true"))
1687                                 return true;
1688                         else
1689                                 return false;   
1690                 } catch (java.lang.ClassCastException e) {
1691                         Boolean value = (Boolean) settings.value("overrideFont", false);
1692                         settings.endGroup();
1693                         return value;
1694                 }
1695
1696     }
1697     
1698     //****************************************************
1699     // Get/Set the default font settings for a new note
1700     //****************************************************
1701     public static void setOverrideDefaultFont(boolean value) {
1702                 settings.beginGroup("Font");
1703                 settings.setValue("overrideFont", value);
1704                 settings.endGroup();    
1705     }
1706     public static String getDefaultFont() {
1707                 settings.beginGroup("Font");
1708                 String val  = (String)settings.value("font", "");
1709                 settings.endGroup();
1710                 return val;
1711     }
1712     public static void setDefaultFont(String value) {
1713                 settings.beginGroup("Font");
1714                 settings.setValue("font", value);
1715                 settings.endGroup();
1716     }
1717     public static String getDefaultFontSize() {
1718                 settings.beginGroup("Font");
1719                 String val  = (String)settings.value("fontSize", "");
1720                 settings.endGroup();
1721                 return val;
1722     }
1723     public static void setDefaultFontSize(String value) {
1724                 settings.beginGroup("Font");
1725                 settings.setValue("fontSize", value);
1726                 settings.endGroup();
1727     }
1728     
1729     
1730     //*******************************************
1731     // Override the close & minimize instead.
1732     //*******************************************
1733     public static boolean minimizeOnClose() {
1734                 settings.beginGroup("General");
1735                 try {
1736                         String text = (String)settings.value("minimizeOnClose", "false");
1737                         settings.endGroup();
1738                         if (text.equalsIgnoreCase("true") && QSystemTrayIcon.isSystemTrayAvailable())
1739                                 return true;
1740                         else
1741                                 return false;
1742                 } catch (java.lang.ClassCastException e) {
1743                         Boolean value = (Boolean) settings.value("minimizeOnClose", false);
1744                         settings.endGroup();
1745                         return value;
1746                 }
1747     }
1748     public static void setMinimizeOnClose(boolean value) {
1749                 settings.beginGroup("General");
1750                 settings.setValue("minimizeOnClose", value);
1751                 settings.endGroup();    
1752     }
1753
1754     //*********************************
1755     // Check version information
1756     //*********************************
1757     public static boolean checkVersionUpgrade() {
1758                 settings.beginGroup("Upgrade");
1759                 try {
1760                         String text = (String)settings.value("checkForUpdates", "true");
1761                         settings.endGroup();
1762                         if (text.equalsIgnoreCase("true"))
1763                                 return true;
1764                         else
1765                                 return false;
1766                 } catch (java.lang.ClassCastException e) {
1767                         Boolean value = (Boolean) settings.value("checkForUpdates", true);
1768                         settings.endGroup();
1769                         return value;
1770                 }
1771     }
1772     public static void setCheckVersionUpgrade(boolean value) {
1773                 settings.beginGroup("Upgrade");
1774                 settings.setValue("checkForUpdates", value);
1775                 settings.endGroup();    
1776     }
1777     public static String getUpdatesAvailableUrl() {
1778                 settings.beginGroup("Upgrade");
1779                 String text = (String)settings.value("avialableUrl", "http://puma.cis.ibaraki.ac.jp/products/neighbornote/develop/versions.txt");
1780                 settings.endGroup();    
1781                 return text;
1782     }
1783     public static String getUpdateAnnounceUrl() {
1784                 settings.beginGroup("Upgrade");
1785                 String text = (String)settings.value("announceUrl", "http://puma.cis.ibaraki.ac.jp/products/neighbornote/develop/upgrade.html");
1786                 settings.endGroup();    
1787                 return text;
1788     }
1789     public static String getUpdateDownloadUrl() {
1790                 settings.beginGroup("Upgrade");
1791                 String text = (String)settings.value("downloadUrl", "http://puma.cis.ibaraki.ac.jp/products/neighbornote/download.html");
1792                 settings.endGroup();    
1793                 return text;
1794     }
1795     
1796     //*******************
1797     // Index settings
1798     //*******************
1799     // Set/Get if we should index the text of a note
1800     public static boolean indexNoteBody() {
1801                 settings.beginGroup("Index");
1802                 try {
1803                         String value = (String)settings.value("indexNoteBody", "true");
1804                         settings.endGroup();
1805                         if (value.equals("true"))
1806                                 return true;
1807                         else
1808                                 return false;
1809                 } catch (java.lang.ClassCastException e) {
1810                         Boolean value = (Boolean) settings.value("indexNoteBody", true);
1811                         settings.endGroup();
1812                         return value;
1813                 }
1814     }
1815     public static void setIndexNoteTitle(boolean value) {
1816                 settings.beginGroup("Index");
1817                 settings.setValue("indexNoteTitle", value);
1818                 settings.endGroup();    
1819     }
1820     // Set/Get if we should index the title of a note
1821     public static boolean indexNoteTitle() {
1822                 settings.beginGroup("Index");
1823                 try {
1824                         String value = (String)settings.value("indexNoteTitle", "true");
1825                         settings.endGroup();
1826                         if (value.equals("true"))
1827                                 return true;
1828                         else
1829                                 return false;
1830                 } catch (java.lang.ClassCastException e) {
1831                         Boolean value = (Boolean) settings.value("indexNoteTitle", true);
1832                         settings.endGroup();
1833                         return value;
1834                 }
1835     }
1836     public static void setIndexNoteBody(boolean value) {
1837                 settings.beginGroup("Index");
1838                 settings.setValue("indexNoteBody", value);
1839                 settings.endGroup();    
1840     }
1841     // Set/Get if we should index any attachments
1842     public static boolean indexAttachmentsLocally() {
1843                 settings.beginGroup("Index");
1844                 try {
1845                         String value = (String)settings.value("indexAttachmentsLocally", "true");
1846                         settings.endGroup();
1847                         if (value.equals("true"))
1848                                 return true;
1849                         else
1850                                 return false;
1851                 } catch (java.lang.ClassCastException e) {
1852                         Boolean value = (Boolean) settings.value("indexAttachmentsLocally", true);
1853                         settings.endGroup();
1854                         return value;
1855                 }
1856     }
1857     public static void setIndexImageRecognition(boolean value) {
1858                 settings.beginGroup("Index");
1859                 settings.setValue("indexImageRecognition", value);
1860                 settings.endGroup();    
1861     }
1862     public static boolean indexImageRecognition() {
1863                 settings.beginGroup("Index");
1864                 try {
1865                         String value = (String)settings.value("indexImageRecognition", "true");
1866                         settings.endGroup();
1867                         if (value.equals("true"))
1868                                 return true;
1869                         else
1870                                 return false;
1871                 } catch (java.lang.ClassCastException e) {
1872                         Boolean value = (Boolean) settings.value("indexImageRecognition", true);
1873                         settings.endGroup();
1874                         return value;
1875                 }
1876     }
1877     public static void setIndexAttachmentsLocally(boolean value) {
1878                 settings.beginGroup("Index");
1879                 settings.setValue("indexAttachmentsLocally", value);
1880                 settings.endGroup();    
1881     }
1882     // Get/Set characters that shouldn't be removed from a word
1883     public static String getSpecialIndexCharacters() {
1884                 settings.beginGroup("Index");
1885                 String text = (String)settings.value("specialCharacters", "");
1886                 settings.endGroup();    
1887                 return text;
1888     }
1889     public static void setSpecialIndexCharacters(String value) {
1890                 settings.beginGroup("Index");
1891                 settings.setValue("specialCharacters", value);
1892                 settings.endGroup();    
1893                 databaseCache = value;
1894     }
1895     
1896     //*****************************************************************************
1897     // Control how tag selection behaves (should they be "and" or "or" selections
1898     //*****************************************************************************
1899     public static boolean anyTagSelectionMatch() {
1900                 settings.beginGroup("General");
1901                 try {
1902                         String value = (String)settings.value("anyTagSelectionMatch", "false");
1903                         settings.endGroup();
1904                         if (value.equals("true"))
1905                                 return true;
1906                         else
1907                                 return false;
1908                 } catch (java.lang.ClassCastException e) {
1909                         Boolean value = (Boolean) settings.value("anyTagSelectionMatch", false);
1910                         settings.endGroup();
1911                         return value;
1912                 }
1913     }
1914     public static void setAnyTagSelectionMatch(boolean value) {
1915                 settings.beginGroup("General");
1916                 settings.setValue("anyTagSelectionMatch", value);
1917                 settings.endGroup();    
1918     }
1919
1920     //*****************************************************************************
1921     // Control if a user receives a warning when trying to create a note-to-note link
1922     // when the DB is not synchronized.
1923     //*****************************************************************************
1924     public static boolean bypassSynchronizationWarning() {
1925                 settings.beginGroup("User");
1926                 try {
1927                         String value = (String)settings.value("bypassSynchronizationWarning", "false");
1928                         settings.endGroup();
1929                         if (value.equals("true"))
1930                                 return true;
1931                         else
1932                                 return false;
1933                 } catch (java.lang.ClassCastException e) {
1934                         Boolean value = (Boolean) settings.value("bypassSynchronizationWarning", false);
1935                         settings.endGroup();
1936                         return value;
1937                 }
1938     }
1939     public static void setBypassSynchronizationWarning(boolean value) {
1940                 settings.beginGroup("User");
1941                 settings.setValue("bypassSynchronizationWarning", value);
1942                 settings.endGroup();    
1943     }
1944
1945     
1946     //***********************
1947     //* Database cache size
1948     //***********************
1949     public static String getDatabaseCacheSize() {
1950                 settings.beginGroup("Debug");
1951                 String text = (String)settings.value("databaseCache", "16384");
1952                 settings.endGroup();    
1953                 return text;
1954     }
1955     public static void setDatabaseCache(String value) {
1956                 settings.beginGroup("Debug");
1957                 settings.setValue("databaseCache", value);
1958                 settings.endGroup();    
1959                 databaseCache = value;
1960     }
1961
1962     
1963     // This is used to copy a class since Java's normal deep copy is wacked
1964     public static Object deepCopy(Object oldObj) 
1965     {
1966        ObjectOutputStream oos = null;
1967        ObjectInputStream ois = null;
1968        try
1969        {
1970           ByteArrayOutputStream bos = 
1971                 new ByteArrayOutputStream(); // A
1972           oos = new ObjectOutputStream(bos); // B
1973           // serialize and pass the object
1974           oos.writeObject(oldObj);   // C
1975           oos.flush();               // D
1976           ByteArrayInputStream bin = 
1977                 new ByteArrayInputStream(bos.toByteArray()); // E
1978           ois = new ObjectInputStream(bin);                  // F
1979           // return the new object
1980           return ois.readObject(); // G
1981        }
1982        catch(Exception e)
1983        {
1984           Global.logger.log(logger.LOW, "Exception in ObjectCloner = " + e);
1985        }
1986           try {
1987                         oos.close();
1988                 ois.close();
1989                 } catch (IOException e) {
1990                         Global.logger.log(logger.LOW, "Exception in ObjectCloner = " + e);
1991                         e.printStackTrace();
1992                 }
1993
1994                 return null;
1995     }
1996
1997     // If we should automatically select the children of any tag
1998     public static boolean includeTagChildren() {
1999                 settings.beginGroup("General");
2000                 try {
2001                         String value = (String)settings.value("includeTagChildren", "false");
2002                         settings.endGroup();
2003                         if (value.equals("true"))
2004                                 return true;
2005                         else
2006                                 return false;
2007                 } catch (java.lang.ClassCastException e) {
2008                         Boolean value = (Boolean) settings.value("includeTagChildren", false);
2009                         settings.endGroup();
2010                         return value;
2011                 }
2012
2013     }
2014     public static void setIncludeTagChildren(boolean value) {
2015                 settings.beginGroup("General");
2016                 settings.setValue("includeTagChildren", value);
2017                 settings.endGroup();    
2018     }
2019     
2020     // If we should automatically wildcard searches
2021     public static boolean automaticWildcardSearches() {
2022                 settings.beginGroup("General");
2023                 try {
2024                         String value = (String)settings.value("automaticWildcard", "false");
2025                         settings.endGroup();
2026                         if (value.equals("true"))
2027                                 return true;
2028                         else
2029                                 return false;
2030                 } catch (java.lang.ClassCastException e) {
2031                         Boolean value = (Boolean) settings.value("automaticWildcard", false);
2032                         settings.endGroup();
2033                         return value;
2034                 }
2035
2036     }
2037     public static void setAutomaticWildcardSearches(boolean value) {
2038                 settings.beginGroup("General");
2039                 settings.setValue("automaticWildcard", value);
2040                 settings.endGroup();    
2041     }
2042
2043     // If we should automatically select the children of any tag
2044     public static boolean displayRightToLeft() {
2045                 settings.beginGroup("General");
2046                 try {
2047                         String value = (String)settings.value("displayRightToLeft", "false");
2048                         settings.endGroup();
2049                         if (value.equals("true"))
2050                                 return true;
2051                         else
2052                                 return false;
2053                 } catch (java.lang.ClassCastException e) {
2054                         Boolean value = (Boolean) settings.value("displayRightToLeft", false);
2055                         settings.endGroup();
2056                         return value;
2057                 }
2058
2059     }
2060     public static void setDisplayRightToLeft(boolean value) {
2061                 settings.beginGroup("General");
2062                 settings.setValue("displayRightToLeft", value);
2063                 settings.endGroup();    
2064     }
2065
2066
2067     //***********************
2068     //* Startup Notebook
2069     //***********************
2070     public static String getStartupNotebook() {
2071                 settings.beginGroup("General");
2072                 String text = (String)settings.value("startupNotebook", "");
2073                 settings.endGroup();    
2074                 return text;
2075     }
2076     public static void setStartupNotebook(String value) {
2077                 settings.beginGroup("General");
2078                 settings.setValue("startupNotebook", value);
2079                 settings.endGroup();    
2080                 databaseCache = value;
2081     }
2082     
2083     // ICHANGED
2084     // 複数ノート同時閲覧操作に対する重み付け
2085     public static void setBrowseWeight(int weight) {
2086                 settings.beginGroup("RensoNoteList");
2087                 settings.setValue("browseWeight", weight);
2088                 settings.endGroup();            
2089     }
2090     public static int getBrowseWeight() {
2091                 settings.beginGroup("RensoNoteList");
2092                 Integer value;
2093                 try {
2094                         String val  = (String)settings.value("browseWeight", 1);
2095                         value = new Integer(val.trim());
2096                 } catch (Exception e) {
2097                         try {
2098                                 value = (Integer)settings.value("browseWeight", 1);
2099                         } catch (Exception e1) {
2100                                 value = 1;
2101                         }
2102                 }
2103                 settings.endGroup();
2104                 return value;
2105     }
2106     
2107     // ICHANGED
2108     // ノート内容のコピー&ペースト操作に対する重み付け
2109     public static void setCopyPasteWeight(int weight) {
2110                 settings.beginGroup("RensoNoteList");
2111                 settings.setValue("copyPasteWeight", weight);
2112                 settings.endGroup();            
2113     }
2114     public static int getCopyPasteWeight() {
2115                 settings.beginGroup("RensoNoteList");
2116                 Integer value;
2117                 try {
2118                         String val  = (String)settings.value("copyPasteWeight", 3);
2119                         value = new Integer(val.trim());
2120                 } catch (Exception e) {
2121                         try {
2122                                 value = (Integer)settings.value("copyPasteWeight", 3);
2123                         } catch (Exception e1) {
2124                                 value = 3;
2125                         }
2126                 }
2127                 settings.endGroup();
2128                 return value;
2129     }
2130     
2131     // ICHANGED
2132     // 新規ノート追加操作に対する重み付け
2133     public static void setAddNewNoteWeight(int weight) {
2134                 settings.beginGroup("RensoNoteList");
2135                 settings.setValue("addNewNoteWeight", weight);
2136                 settings.endGroup();            
2137     }
2138         public static int getAddNewNoteWeight() {
2139                 settings.beginGroup("RensoNoteList");
2140                 Integer value;
2141                 try {
2142                         String val  = (String)settings.value("addNewNoteWeight", 1);
2143                         value = new Integer(val.trim());
2144                 } catch (Exception e) {
2145                         try {
2146                                 value = (Integer)settings.value("addNewNoteWeight", 1);
2147                         } catch (Exception e1) {
2148                                 value = 1;
2149                         }
2150                 }
2151                 settings.endGroup();
2152                 return value;
2153         }
2154         
2155         // ICHANGED
2156         // 連想ノートクリック操作に対する重み付け
2157     public static void setRensoItemClickWeight(int weight) {
2158                 settings.beginGroup("RensoNoteList");
2159                 settings.setValue("rensoItemClickWeight", weight);
2160                 settings.endGroup();            
2161     }
2162         public static int getRensoItemClickWeight() {
2163                 settings.beginGroup("RensoNoteList");
2164                 Integer value;
2165                 try {
2166                         String val  = (String)settings.value("rensoItemClickWeight", 10);
2167                         value = new Integer(val.trim());
2168                 } catch (Exception e) {
2169                         try {
2170                                 value = (Integer)settings.value("rensoItemClickWeight", 10);
2171                         } catch (Exception e1) {
2172                                 value = 10;
2173                         }
2174                 }
2175                 settings.endGroup();
2176                 return value;
2177         }
2178         
2179         // ICHANGED
2180         // タグ付け操作に対する重み付け
2181     public static void setSameTagWeight(int weight) {
2182                 settings.beginGroup("RensoNoteList");
2183                 settings.setValue("sameTagWeight", weight);
2184                 settings.endGroup();            
2185     }
2186         public static int getSameTagWeight() {
2187                 settings.beginGroup("RensoNoteList");
2188                 Integer value;
2189                 try {
2190                         String val  = (String)settings.value("sameTagWeight", 2);
2191                         value = new Integer(val.trim());
2192                 } catch (Exception e) {
2193                         try {
2194                                 value = (Integer)settings.value("sameTagWeight", 2);
2195                         } catch (Exception e1) {
2196                                 value = 2;
2197                         }
2198                 }
2199                 settings.endGroup();
2200                 return value;
2201         }
2202         
2203         // ICHANGED
2204         // ノートブック変更操作に対する重み付け
2205     public static void setSameNotebookWeight(int weight) {
2206                 settings.beginGroup("RensoNoteList");
2207                 settings.setValue("sameNotebookWeight", weight);
2208                 settings.endGroup();            
2209     }
2210         public static int getSameNotebookWeight() {
2211                 settings.beginGroup("RensoNoteList");
2212                 Integer value;
2213                 try {
2214                         String val  = (String)settings.value("sameNotebookWeight", 2);
2215                         value = new Integer(val.trim());
2216                 } catch (Exception e) {
2217                         try {
2218                                 value = (Integer)settings.value("sameNotebookWeight", 2);
2219                         } catch (Exception e1) {
2220                                 value = 2;
2221                         }
2222                 }
2223                 settings.endGroup();
2224                 return value;
2225         }
2226     
2227     //*******************
2228     // ノートのマージ・複製の関連ノートリストへの適用
2229     //*******************
2230     // ICHANGED
2231     public static void setMergeRensoNote(boolean value) {
2232                 settings.beginGroup("RensoNoteList");
2233                 settings.setValue("mergeRensoNoteList", value);
2234                 settings.endGroup();    
2235     }
2236     // ICHANGED
2237     public static boolean getMergeRensoNote() {
2238                 settings.beginGroup("RensoNoteList");
2239                 try {
2240                         String value = (String)settings.value("mergeRensoNoteList", "true");
2241                         settings.endGroup();
2242                         if (value.equals("true"))
2243                                 return true;
2244                         else
2245                                 return false;
2246                 } catch (java.lang.ClassCastException e) {
2247                         Boolean value = (Boolean) settings.value("mergeRensoNoteList", true);
2248                         settings.endGroup();
2249                         return value;
2250                 }
2251     }
2252     // ICHANGED
2253     public static void setDuplicateRensoNote(boolean value) {
2254                 settings.beginGroup("RensoNoteList");
2255                 settings.setValue("duplicateRensoNoteList", value);
2256                 settings.endGroup();    
2257     }
2258     // ICHANGED
2259     public static boolean getDuplicateRensoNote() {
2260                 settings.beginGroup("RensoNoteList");
2261                 try {
2262                         String value = (String)settings.value("duplicateRensoNoteList", "true");
2263                         settings.endGroup();
2264                         if (value.equals("true"))
2265                                 return true;
2266                         else
2267                                 return false;
2268                 } catch (java.lang.ClassCastException e) {
2269                         Boolean value = (Boolean) settings.value("duplicateRensoNoteList", true);
2270                         settings.endGroup();
2271                         return value;
2272                 }
2273     }
2274     
2275     // ICHANGED
2276     // 連想ノートリストからノートを除外するときに確認メッセージを表示するかどうか
2277     public static boolean verifyExclude() {
2278                 settings.beginGroup("RensoNoteList");
2279                 try {
2280                         String text = (String)settings.value("verifyExclude", "true");
2281                         settings.endGroup();
2282                         if (text.equalsIgnoreCase("true"))
2283                                 return true;
2284                         else
2285                                 return false;
2286                 } catch (java.lang.ClassCastException e) {
2287                         Boolean value = (Boolean) settings.value("verifyExclude", true);
2288                         settings.endGroup();
2289                         return value;
2290                 }
2291     }
2292     // ICHANGED
2293     public static void setVerifyExclude(boolean val) {
2294                 settings.beginGroup("RensoNoteList");
2295                 if (val)
2296                         settings.setValue("verifyExclude", "true");
2297                 else
2298                         settings.setValue("verifyExclude", "false");
2299                 settings.endGroup();
2300     }
2301     
2302         // ICHANGED
2303         // 連想ノートリスト最大表示アイテム数
2304     public static void setRensoListItemMaximum(int maximum) {
2305                 settings.beginGroup("RensoNoteList");
2306                 settings.setValue("rensoListMaximum", maximum);
2307                 settings.endGroup();            
2308     }
2309         public static int getRensoListItemMaximum() {
2310                 settings.beginGroup("RensoNoteList");
2311                 Integer value;
2312                 try {
2313                         String val  = (String)settings.value("rensoListMaximum", 20);
2314                         value = new Integer(val.trim());
2315                 } catch (Exception e) {
2316                         try {
2317                                 value = (Integer)settings.value("rensoListMaximum", 20);
2318                         } catch (Exception e1) {
2319                                 value = 20;
2320                         }
2321                 }
2322                 settings.endGroup();
2323                 return value;
2324         }
2325 }
2326