OSDN Git Service

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