Changeset 22831 for main/trunk/gli
- Timestamp:
- 2010-09-01T16:20:27+12:00 (14 years ago)
- Location:
- main/trunk/gli/src/org/greenstone/gatherer
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/gli/src/org/greenstone/gatherer/Gatherer.java
r22806 r22831 821 821 822 822 823 public static void collectDirectoryHasChanged(String oldCollectPath, String newCollectPath) { 824 if(oldCollectPath.equals(newCollectPath)) { 825 return; // nothing to be done 826 } 827 828 // first save any open collection in the old location, then close it 829 if(Gatherer.c_man.getCollection() != null) { 830 Gatherer.g_man.saveThenCloseCurrentCollection(); // close the current collection first 831 } 832 833 // change to new collect path 834 Configuration.setString("general.open_collection"+Configuration.gliPropertyNameSuffix(), 835 true, newCollectPath); 836 Gatherer.setCollectDirectoryPath(newCollectPath); 837 838 839 // refresh the Documents in Greenstone Collections 840 //WorkspaceTreeModel.refreshGreenstoneCollectionsNode(); 841 Gatherer.g_man.refreshWorkspaceTreeGreenstoneCollections(); 842 843 // The web server needs to be told where a new (non-standard) collecthome home is. 844 // The web server reads collecthome from cgi-bin/gsdlsite.cfg, where the property 845 // collecthome can be specified if a non-standard collecthome is to be used. If no 846 // such property is specified in the file, then it assumes the standard GS collecthome. 847 // This method does nothing for a remote Greenstone. 848 if(Gatherer.isGsdlRemote) { 849 return; 850 } 851 852 String gsdlsitecfg = ""; 853 if(Gatherer.GS3) { // web/WEB-INF/cgi/gsdl3site.cfg 854 gsdlsitecfg = Configuration.gsdl3_path + File.separator + "WEB-INF" 855 + File.separator + "cgi" + File.separator + "gsdl3site.cfg"; 856 } else { // cgi-bin/gsdlsite.cfg 857 gsdlsitecfg = Configuration.gsdl_path + File.separator 858 + "cgi-bin" + File.separator + "gsdlsite.cfg"; 859 } 860 861 // non-destructive update of gsdl(3)site.cfg (comments preserved) 862 String collectDir = Gatherer.getCollectDirectoryPath(); 863 //collectDir = "\"" + collectDir.substring(0, collectDir.length()-1) + "\""; // remove file separator at end 864 collectDir = collectDir.substring(0, collectDir.length()-1); // remove file separator at end 865 Utility.updatePropertyConfigFile(gsdlsitecfg, "collecthome", collectDir); 866 867 if(!Gatherer.GS3 && Gatherer.isLocalLibrary) { 868 // for Images in the collection to work, the apache web server 869 // configuration's COLLECTHOME should be updated on collectdir change. 870 // Does nothing for server.exe at the moment 871 872 LocalLibraryServer.reconfigure(); 873 } 823 public static void collectDirectoryHasChanged( 824 String oldCollectPath, String newCollectPath, final Component container) 825 { 826 // Will use a busy cursor if the process of changing the collect directory takes more 827 // than half a second/500ms. See http://www.catalysoft.com/articles/busyCursor.html 828 Cursor originalCursor = container.getCursor(); 829 java.util.TimerTask timerTask = new java.util.TimerTask() { 830 public void run() { 831 // set the cursor on the container: 832 container.setCursor(new Cursor(Cursor.WAIT_CURSOR)); 833 } 834 }; 835 java.util.Timer timer = new java.util.Timer(); 836 837 try { 838 timer.schedule(timerTask, 500); 839 840 if(oldCollectPath.equals(newCollectPath)) { 841 return; // nothing to be done 842 } 843 844 // first save any open collection in the old location, then close it 845 if(Gatherer.c_man.getCollection() != null) { 846 Gatherer.g_man.saveThenCloseCurrentCollection(); // close the current collection first 847 } 848 849 // change to new collect path 850 Configuration.setString("general.open_collection"+Configuration.gliPropertyNameSuffix(), 851 true, newCollectPath); 852 Gatherer.setCollectDirectoryPath(newCollectPath); 853 854 855 // refresh the Documents in Greenstone Collections 856 //WorkspaceTreeModel.refreshGreenstoneCollectionsNode(); 857 Gatherer.g_man.refreshWorkspaceTreeGreenstoneCollections(); 858 859 // The web server needs to be told where a new (non-standard) collecthome home is. 860 // The web server reads collecthome from cgi-bin/gsdlsite.cfg, where the property 861 // collecthome can be specified if a non-standard collecthome is to be used. If no 862 // such property is specified in the file, then it assumes the standard GS collecthome. 863 // This method does nothing for a remote Greenstone. 864 if(Gatherer.isGsdlRemote) { 865 return; 866 } 867 868 String gsdlsitecfg = ""; 869 if(Gatherer.GS3) { // web/WEB-INF/cgi/gsdl3site.cfg 870 gsdlsitecfg = Configuration.gsdl3_path + File.separator + "WEB-INF" 871 + File.separator + "cgi" + File.separator + "gsdl3site.cfg"; 872 } else { // cgi-bin/gsdlsite.cfg 873 gsdlsitecfg = Configuration.gsdl_path + File.separator 874 + "cgi-bin" + File.separator + "gsdlsite.cfg"; 875 } 876 877 // non-destructive update of gsdl(3)site.cfg (comments preserved) 878 String collectDir = Gatherer.getCollectDirectoryPath(); 879 //collectDir = "\"" + collectDir.substring(0, collectDir.length()-1) + "\""; // remove file separator at end 880 collectDir = collectDir.substring(0, collectDir.length()-1); // remove file separator at end 881 Utility.updatePropertyConfigFile(gsdlsitecfg, "collecthome", collectDir); 882 883 if(!Gatherer.GS3 && Gatherer.isLocalLibrary) { 884 // for Images in the collection to work, the apache web server 885 // configuration's COLLECTHOME should be updated on collectdir change. 886 // Does nothing for server.exe at the moment 887 888 LocalLibraryServer.reconfigure(); 889 } 890 } finally { // Note try-finally section without catch: 891 // "Java's finally clause is guaranteed to be executed even when 892 // an exception is thrown and not caught in the current scope." 893 // See http://www.catalysoft.com/articles/busyCursor.html 894 // the following code fragment is guaranteed to restore the original 895 // cursor now the custom actionPerformed() processing is complete, regardless 896 // of whether the processing method terminates normally or throws an exception 897 // and regardedless of where in the call stack the exception is caught. 898 899 timer.cancel(); 900 container.setCursor(originalCursor); 901 } 874 902 } 875 903 -
main/trunk/gli/src/org/greenstone/gatherer/gui/NewCollectionDetailsPrompt.java
r22605 r22831 541 541 } 542 542 } 543 } 544 545 // going through with collection creation 546 if(collectDirChanged) { 547 Gatherer.collectDirectoryHasChanged(Gatherer.getCollectDirectoryPath(), newCollectPath); 548 // will tell the server that the collect directory has changed and that 549 // the workspace needs to be refreshed (Documents in Greenstone Collections) 550 } 551 543 } 552 544 description_final = description.getText(); 553 545 … … 557 549 558 550 cancelled = false; 551 552 self.dispose(); 559 553 560 self.dispose(); 554 // going through with collection creation 555 if(collectDirChanged) { 556 Gatherer.collectDirectoryHasChanged(Gatherer.getCollectDirectoryPath(), 557 newCollectPath, Gatherer.g_man.getContentPane()); 558 // will tell the server that the collect directory has changed and that 559 // the workspace needs to be refreshed (Documents in Greenstone Collections) 560 } 561 561 } 562 562 } -
main/trunk/gli/src/org/greenstone/gatherer/gui/OpenCollectionDialog.java
r22605 r22831 424 424 } 425 425 426 Gatherer.collectDirectoryHasChanged(Gatherer.getCollectDirectoryPath(), newCollectPath); 426 Gatherer.collectDirectoryHasChanged(Gatherer.getCollectDirectoryPath(), 427 newCollectPath, Gatherer.g_man.getContentPane()); 427 428 // will tell the server that the collect directory has changed and that 428 // the workspace needs to be refreshed (Documents in Greenstone Collections)429 // the workspace needs to be refreshed (Documents in Greenstone Collections) 429 430 } 430 431 } -
main/trunk/gli/src/org/greenstone/gatherer/gui/Preferences.java
r22605 r22831 863 863 Configuration.setSiteAndServlet(new_site, (String)servlet_combobox.getSelectedItem()); 864 864 } 865 866 // collect directory change 867 String newCollectPath = collect_dir_field.getText(); 868 if(!newCollectPath.endsWith(File.separator)) { 869 newCollectPath += File.separator; 870 } 871 Gatherer.collectDirectoryHasChanged(Gatherer.getCollectDirectoryPath(), newCollectPath); 872 // will tell the server that the collect directory has changed and that 873 // the workspace needs to be refreshed (Documents in Greenstone Collections) 874 875 865 876 866 Configuration.set("general.use_proxy", true, use_proxy_checkbox.isSelected()); 877 867 Configuration.setString("general.proxy_host", true, proxy_host_field.getText()); … … 984 974 } 985 975 976 // collect directory change 977 String newCollectPath = collect_dir_field.getText(); 978 if(!newCollectPath.endsWith(File.separator)) { 979 newCollectPath += File.separator; 980 } 981 // wait cursor will display while changing the collect directory, need to work out what component to 982 // display it on: main GLI frame or Preferences window, depending on if OK or Apply was pressed 983 Container container = close ? Gatherer.g_man.getContentPane() : Preferences.this.getContentPane(); 984 Gatherer.collectDirectoryHasChanged(Gatherer.getCollectDirectoryPath(), 985 newCollectPath, container); 986 // will tell the server that the collect directory has changed and that 987 // the workspace needs to be refreshed (Documents in Greenstone Collections) 988 986 989 if (restart_required) { 987 990 if (keep_collection_open) {
Note:
See TracChangeset
for help on using the changeset viewer.