OSDN Git Service

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