OSDN Git Service

localization of application
[neighbornote/NeighborNote.git] / src / cx / fbn / nevernote / Global.java
index 7bb54a4..5ae003b 100644 (file)
@@ -21,20 +21,19 @@ package cx.fbn.nevernote;
 \r
 \r
 //import java.io.ByteArrayOutputStream;\r
+\r
 import java.io.PrintStream;\r
 import java.text.SimpleDateFormat;\r
 import java.util.ArrayList;\r
 import java.util.Calendar;\r
 import java.util.HashMap;\r
 import java.util.List;\r
-import java.util.concurrent.ArrayBlockingQueue;\r
 \r
 import com.evernote.edam.type.Accounting;\r
 import com.evernote.edam.type.PrivilegeLevel;\r
 import com.evernote.edam.type.User;\r
 import com.evernote.edam.type.UserAttributes;\r
 import com.trolltech.qt.core.QByteArray;\r
-import com.trolltech.qt.core.QMutex;\r
 import com.trolltech.qt.core.QSettings;\r
 import com.trolltech.qt.gui.QPalette;\r
 \r
@@ -44,48 +43,33 @@ import cx.fbn.nevernote.config.StartupConfig;
 import cx.fbn.nevernote.gui.ContainsAttributeFilterTable;\r
 import cx.fbn.nevernote.gui.DateAttributeFilterTable;\r
 import cx.fbn.nevernote.gui.ShortcutKeys;\r
-import cx.fbn.nevernote.signals.DBRunnerSignal;\r
-import cx.fbn.nevernote.threads.DBRunner;\r
 import cx.fbn.nevernote.utilities.ApplicationLogger;\r
 \r
 public class Global {\r
        public static String version = "0.88";\r
     public static String username = ""; \r
-    public static String password = ""; \r
-\r
-    public static DBRunner                             dbRunner;                       // Database thread\r
-    public static DBRunnerSignal               dbRunnerSignal;         // Signals to the database runner\r
-    public static QMutex                               dbrunnerWorkLock;       // mutex lock for work queue\r
+    public static String password = "";     \r
     \r
 \r
-    public static int mainThreadId=0;\r
-    private static ArrayBlockingQueue<Boolean> mainThreadWaiter = new ArrayBlockingQueue<Boolean>(1);\r
+    public static final int mainThreadId=0;\r
     \r
-    public static int syncThreadId=1;\r
-    private static ArrayBlockingQueue<Boolean> syncThreadWaiter = new ArrayBlockingQueue<Boolean>(1);\r
+    public static final int syncThreadId=1;\r
     \r
-    public static int tagCounterThreadId=2;\r
-    private static ArrayBlockingQueue<Boolean> tagCounterThreadWaiter = new ArrayBlockingQueue<Boolean>(1);\r
+    public static final int tagCounterThreadId=2;\r
     \r
-    public static int trashCounterThreadId=3;   // This should always be the highest thread ID\r
-    private static ArrayBlockingQueue<Boolean> trashCounterThreadWaiter = new ArrayBlockingQueue<Boolean>(1);\r
+    public static final int trashCounterThreadId=3;   // This should always be the highest thread ID\r
 \r
-    public static int indexThreadId=4;         // Thread for indexing words\r
-    private static ArrayBlockingQueue<Boolean> indexThreadWaiter = new ArrayBlockingQueue<Boolean>(1);\r
+    public static final int indexThreadId=4;           // Thread for indexing words\r
 \r
-    public static int saveThreadId=5;          // Thread used for processing data to saving content\r
-    private static ArrayBlockingQueue<Boolean> saveThreadWaiter = new ArrayBlockingQueue<Boolean>(1);\r
+    public static final int saveThreadId=5;    // Thread used for processing data to saving content\r
 \r
-    public static int notebookCounterThreadId=6;   // Notebook Thread\r
-    private static ArrayBlockingQueue<Boolean> notebookCounterThreadWaiter = new ArrayBlockingQueue<Boolean>(1);\r
+    public static final int notebookCounterThreadId=6;   // Notebook Thread\r
 \r
-    public static int indexThread03Id=7;   // unused\r
-    private static ArrayBlockingQueue<Boolean> indexThread03ThreadWaiter = new ArrayBlockingQueue<Boolean>(1);\r
+    public static final int indexThread03Id=7;   // unused\r
 \r
-    public static int indexThread04Id=8;   // unused\r
-    private static ArrayBlockingQueue<Boolean> indexThread04ThreadWaiter = new ArrayBlockingQueue<Boolean>(1);\r
+    public static final int indexThread04Id=8;   // unused\r
     \r
-    public static int dbThreadId=9;   // This should always be the highest thread ID\r
+    public static final int dbThreadId=9;   // This should always be the highest thread ID\r
     \r
     \r
     public static HashMap<String,String> passwordSafe = new HashMap<String, String>();\r
@@ -118,6 +102,7 @@ public class Global {
     private static String wordRegex;\r
     public static boolean enableCarriageReturnFix = false;\r
     \r
+    public static String name = null;\r
     public static QSettings    settings;\r
     public static boolean isConnected;\r
     public static boolean showDeleted = false;\r
@@ -139,7 +124,7 @@ public class Global {
        PrintStream stdoutStream;\r
        public static QPalette                          originalPalette;\r
        public static ShortcutKeys                      shortcutKeys;\r
-       private static boolean                          disableViewing;\r
+       public static boolean                           disableViewing;\r
        \r
        public static List<String>                              invalidElements = new ArrayList<String>();\r
        public static HashMap<String, ArrayList<String>>        invalidAttributes = new HashMap<String, ArrayList<String>>();\r
@@ -151,7 +136,7 @@ public class Global {
        static Calendar intervalTraceTime;\r
 \r
        private static FileManager fileManager;\r
-\r
+       \r
     // Do initial setup \r
     public static void setup(StartupConfig startupConfig) throws InitializationException  {\r
         settings = new QSettings("fbn.cx", startupConfig.getName());\r
@@ -159,6 +144,7 @@ public class Global {
 \r
         fileManager = new FileManager(startupConfig.getHomeDirPath());\r
 \r
+\r
                        getServer();\r
                        settings.beginGroup("General");\r
                        String regex = (String) settings.value("regex", "[,\\s]+");\r
@@ -179,7 +165,6 @@ public class Global {
 //                     indexLock = new DBLock();\r
                        logger = new ApplicationLogger("global.log");\r
                        shortcutKeys = new ShortcutKeys();\r
-                       dbrunnerWorkLock = new QMutex();\r
                        mimicEvernoteInterface = getMimicEvernoteInterface();\r
                        resourceMap = new HashMap<String,String>();\r
                                \r
@@ -904,71 +889,6 @@ public class Global {
                settings.endGroup();\r
     }\r
     \r
-    public static void dbWait() {\r
- //    Global.dbThreadWait.wait(Global.dbThreadWaitMutex);\r
-    }\r
-    public static void dbContinue() {\r
-//     Global.dbThreadWait.wakeAll();\r
-    }\r
-    public static synchronized void dbClientWait(int id) {\r
-       if (id == mainThreadId) {\r
-                       try {mainThreadWaiter.take(); } catch (InterruptedException e) {e.printStackTrace();}\r
-       }\r
-       if (id == syncThreadId) {\r
-                       try {syncThreadWaiter.take();} catch (InterruptedException e) {e.printStackTrace();}\r
-       }\r
-       if (id == tagCounterThreadId) {\r
-               try {tagCounterThreadWaiter.take();} catch (InterruptedException e) {e.printStackTrace();}\r
-       }\r
-       if (id == trashCounterThreadId) {\r
-               try {trashCounterThreadWaiter.take();} catch (InterruptedException e) {e.printStackTrace();}\r
-       }\r
-       if (id == indexThreadId) {\r
-               try {indexThreadWaiter.take();} catch (InterruptedException e) {e.printStackTrace();}\r
-       }\r
-       if (id == saveThreadId) {\r
-               try {saveThreadWaiter.take();} catch (InterruptedException e) {e.printStackTrace();}\r
-       }\r
-       if (id == notebookCounterThreadId) {\r
-               try {notebookCounterThreadWaiter.take();} catch (InterruptedException e) {e.printStackTrace();}\r
-       }\r
-       if (id == indexThread03Id) {\r
-               try {indexThread03ThreadWaiter.take();} catch (InterruptedException e) {e.printStackTrace();}\r
-       }\r
-       if (id == indexThread04Id) {\r
-               try {indexThread04ThreadWaiter.take();} catch (InterruptedException e) {e.printStackTrace();}\r
-       }\r
-    }\r
-    public static void dbClientContinue(int id) {\r
-       if (id == mainThreadId) {\r
-                       try { mainThreadWaiter.put(true); } catch (InterruptedException e) { e.printStackTrace();}\r
-       }\r
-       if (id == syncThreadId) {\r
-                       try { syncThreadWaiter.put(true); } catch (InterruptedException e) { e.printStackTrace();}\r
-       }\r
-               if (id == tagCounterThreadId) { \r
-                       try { tagCounterThreadWaiter.put(true); } catch (InterruptedException e) { e.printStackTrace();}\r
-               }\r
-               if (id == trashCounterThreadId) { \r
-                       try { trashCounterThreadWaiter.put(true); } catch (InterruptedException e) { e.printStackTrace();}\r
-               }\r
-               if (id == indexThreadId) { \r
-                       try { indexThreadWaiter.put(true); } catch (InterruptedException e) { e.printStackTrace();}\r
-               }\r
-               if (id == saveThreadId) { \r
-                       try { saveThreadWaiter.put(true); } catch (InterruptedException e) { e.printStackTrace();}\r
-               }\r
-               if (id == notebookCounterThreadId) { \r
-                       try { notebookCounterThreadWaiter.put(true); } catch (InterruptedException e) { e.printStackTrace();}\r
-               }\r
-               if (id == indexThread03Id) { \r
-                       try { indexThread03ThreadWaiter.put(true); } catch (InterruptedException e) { e.printStackTrace();}\r
-               }\r
-               if (id == indexThread04Id) { \r
-                       try { indexThread04ThreadWaiter.put(true); } catch (InterruptedException e) { e.printStackTrace();}\r
-               }\r
-    }\r
-    \r
     public static void saveState(String name, QByteArray state) {\r
                settings.beginGroup("SaveState");\r
                settings.setValue(name, state);\r
@@ -1116,12 +1036,14 @@ public class Global {
                startTraceTime = null;\r
        }\r
 \r
+\r
     public static FileManager getFileManager() {\r
         return fileManager;\r
     }\r
-\r
     public static boolean getDisableViewing() {\r
         return disableViewing;\r
     }\r
+    \r
+\r
 }\r
 \r