OSDN Git Service

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