X-Git-Url: http://git.sourceforge.jp/view?p=neighbornote%2FNeighborNote.git;a=blobdiff_plain;f=src%2Fcx%2Ffbn%2Fnevernote%2FNeverNote.java;h=aa90656731fea9090ee3ec6d7d1cc381e4e0240a;hp=35a3c3e19431fd862c88078a2ca28d14b416b4be;hb=4909aea1fc99ff94e74e5468dd9453f007eadb35;hpb=4efc34ff2fa5483b5f9687f1b4d490ca17fb284d diff --git a/src/cx/fbn/nevernote/NeverNote.java b/src/cx/fbn/nevernote/NeverNote.java index 35a3c3e..aa90656 100644 --- a/src/cx/fbn/nevernote/NeverNote.java +++ b/src/cx/fbn/nevernote/NeverNote.java @@ -325,6 +325,7 @@ public class NeverNote extends QMainWindow{ private boolean closeAction = false; // Used to say when to close or when to minimize private static Logger log = Logger.getLogger(NeverNote.class); private String saveLastPath; // last path we used + private final QTimer messageTimer; // Timer to clear the status message. String iconPath = new String("classpath:cx/fbn/nevernote/icons/"); @@ -706,6 +707,11 @@ public class NeverNote extends QMainWindow{ mainLeftRightSplitter.addWidget(browserWindow); } + messageTimer = new QTimer(); + messageTimer.timeout.connect(this, "clearMessage()"); + messageTimer.setInterval(1000*15); + clearMessage(); + int sortCol = Global.getSortColumn(); int sortOrder = Global.getSortOrder(); noteTableView.sortByColumn(sortCol, SortOrder.resolve(sortOrder)); @@ -921,17 +927,18 @@ public class NeverNote extends QMainWindow{ externalFileEditedSaver(); if (Global.isConnected && Global.synchronizeOnClose()) { setMessage(tr("Performing synchronization before closing.")); + syncRunner.syncNeeded = true; syncRunner.addWork("SYNC"); + syncRunner.addWork("STOP"); + } else { + syncRunner.addWork("STOP"); + syncRunner.keepRunning = false; } setMessage("Closing Program."); threadMonitorTimer.stop(); - syncRunner.addWork("STOP"); - syncRunner.keepRunning = false; thumbnailRunner.addWork("STOP"); - syncRunner.keepRunning = false; indexRunner.addWork("STOP"); - syncRunner.keepRunning = false; saveNote(); listManager.stop(); saveWindowState(); @@ -984,9 +991,12 @@ public class NeverNote extends QMainWindow{ } catch (InterruptedException e1) { e1.printStackTrace(); } + + syncRunner.addWork("STOP"); if (!syncRunner.isIdle()) { try { logger.log(logger.MEDIUM, "Waiting for syncThread to stop"); + System.out.println(tr("Synchronizing. Please be patient.")); syncThread.join(); logger.log(logger.MEDIUM, "Sync thread has stopped"); } catch (InterruptedException e1) { @@ -1016,11 +1026,25 @@ public class NeverNote extends QMainWindow{ } public void setMessage(String s) { logger.log(logger.HIGH, "Entering NeverNote.setMessage"); + + statusBar.show(); logger.log(logger.HIGH, "Message: " +s); statusBar.showMessage(s); emitLog.add(s); + + + messageTimer.stop(); + messageTimer.setSingleShot(true); + messageTimer.start(); + + logger.log(logger.HIGH, "Leaving NeverNote.setMessage"); } + + private void clearMessage() { + statusBar.clearMessage(); + statusBar.hide(); + } private void waitCursor(boolean wait) { if (wait) { @@ -3130,56 +3154,67 @@ public class NeverNote extends QMainWindow{ } catch (FileNotFoundException e) { // File not found, so we'll just get empty strings anyway. } + + if (Global.getProxyValue("url").equals("")) { + System.setProperty("http.proxyHost","") ; + System.setProperty("http.proxyPort", "") ; + System.setProperty("https.proxyHost","") ; + System.setProperty("https.proxyPort", "") ; + } else { + // PROXY + System.setProperty("http.proxyHost",Global.getProxyValue("url")) ; + System.setProperty("http.proxyPort", Global.getProxyValue("port")) ; + System.setProperty("https.proxyHost",Global.getProxyValue("url")) ; + System.setProperty("https.proxyPort", Global.getProxyValue("port")) ; + + if (Global.getProxyValue("userid").equals("")) { + Authenticator.setDefault(new Authenticator() { + @Override + protected PasswordAuthentication getPasswordAuthentication() { + return new + PasswordAuthentication(Global.getProxyValue("userid"),Global.getProxyValue("password").toCharArray()); + } + }); + } + } + + syncRunner.userStoreUrl = Global.userStoreUrl; + syncRunner.noteStoreUrl = Global.noteStoreUrl; + syncRunner.noteStoreUrlBase = Global.noteStoreUrlBase; + String userid = aes.getUserid(); String password = aes.getPassword(); if (!userid.equals("") && !password.equals("")) { Global.username = userid; Global.password = password; + syncRunner.username = Global.username; + syncRunner.password = Global.password; + syncRunner.enConnect(); } - // Show the login dialog box - if (!Global.automaticLogin() || userid.equals("")|| password.equals("")) { - LoginDialog login = new LoginDialog(); - login.exec(); + Global.isConnected = syncRunner.isConnected; - if (!login.okPressed()) { - return; - } + if (!Global.isConnected) { + // Show the login dialog box + if (!Global.automaticLogin() || userid.equals("")|| password.equals("")) { + LoginDialog login = new LoginDialog(); + login.exec(); + + if (!login.okPressed()) { + return; + } - Global.username = login.getUserid(); - Global.password = login.getPassword(); + Global.username = login.getUserid(); + Global.password = login.getPassword(); + } + syncRunner.username = Global.username; + syncRunner.password = Global.password; + syncRunner.enConnect(); + Global.isConnected = syncRunner.isConnected; } - syncRunner.username = Global.username; - syncRunner.password = Global.password; - syncRunner.userStoreUrl = Global.userStoreUrl; - syncRunner.noteStoreUrl = Global.noteStoreUrl; - syncRunner.noteStoreUrlBase = Global.noteStoreUrlBase; - if (Global.getProxyValue("url").equals("")) { - System.setProperty("http.proxyHost","") ; - System.setProperty("http.proxyPort", "") ; - System.setProperty("https.proxyHost","") ; - System.setProperty("https.proxyPort", "") ; - } else { - // PROXY - System.setProperty("http.proxyHost",Global.getProxyValue("url")) ; - System.setProperty("http.proxyPort", Global.getProxyValue("port")) ; - System.setProperty("https.proxyHost",Global.getProxyValue("url")) ; - System.setProperty("https.proxyPort", Global.getProxyValue("port")) ; - - if (Global.getProxyValue("userid").equals("")) { - Authenticator.setDefault(new Authenticator() { - @Override - protected PasswordAuthentication getPasswordAuthentication() { - return new - PasswordAuthentication(Global.getProxyValue("userid"),Global.getProxyValue("password").toCharArray()); - }}); - } - } - - - syncRunner.enConnect(); - Global.isConnected = syncRunner.isConnected; + if (!Global.isConnected) + return; setupOnlineMenu(); setupConnectMenuOptions(); logger.log(logger.HIGH, "Leaving NeverNote.remoteConnect"); @@ -4370,7 +4405,8 @@ public class NeverNote extends QMainWindow{ } } if (!match) - goodNotebooks.add(listManager.getNotebookIndex().get(i).deepCopy()); + //goodNotebooks.add(listManager.getNotebookIndex().get(i).deepCopy()); + goodNotebooks.add((Notebook)Global.deepCopy(listManager.getNotebookIndex().get(i))); } // Now we have a list of good notebooks, so we can look for the default found = false; @@ -4560,7 +4596,7 @@ public class NeverNote extends QMainWindow{ } private void duplicateNote(String guid) { - Note oldNote = conn.getNoteTable().getNote(guid, true, true, false, false, false); + Note oldNote = conn.getNoteTable().getNote(guid, true, false,false,false,true); List resList = conn.getNoteTable().noteResourceTable.getNoteResources(guid, true); oldNote.setContent(conn.getNoteTable().getNoteContentBinary(guid)); oldNote.setResources(resList); @@ -4574,11 +4610,37 @@ public class NeverNote extends QMainWindow{ Long l = new Long(currentTime.getTimeInMillis()); String newGuid = new String(Long.toString(l)); - Note newNote = oldNote.deepCopy(); +// Note newNote = oldNote.deepCopy(); + Note newNote = (Note)Global.deepCopy(oldNote); newNote.setUpdateSequenceNum(0); newNote.setGuid(newGuid); newNote.setDeleted(0); newNote.setActive(true); + + /* + List tagNames = new ArrayList(); + List tagGuids = new ArrayList();; + for (int i=0; i resList = oldNote.getResources(); if (resList == null) resList = new ArrayList(); @@ -4595,13 +4657,19 @@ public class NeverNote extends QMainWindow{ resList.get(i).setGuid(newResGuid); resList.get(i).setUpdateSequenceNum(0); resList.get(i).setActive(true); - conn.getNoteTable().noteResourceTable.saveNoteResource(new Resource(resList.get(i).deepCopy()), true); + conn.getNoteTable().noteResourceTable.saveNoteResource( + (Resource)Global.deepCopy(resList.get(i)), true); } newNote.setResources(resList); + + // Add note to the database listManager.addNote(newNote); conn.getNoteTable().addNote(newNote, true); listManager.getUnsynchronizedNotes().add(newNote.getGuid()); noteTableView.insertRow(newNote, true, -1); + currentNoteGuid = newNote.getGuid(); + currentNote = newNote; + refreshEvernoteNote(true); listManager.countNotebookResults(listManager.getNoteIndex()); waitCursor(false); }