Changeset 34205
- Timestamp:
- 2020-06-18T00:06:23+12:00 (4 years ago)
- Location:
- main/trunk/gli/src/org/greenstone/gatherer
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/gli/src/org/greenstone/gatherer/cdm/CollectionConfiguration.java
r24824 r34205 67 67 // This method is initilised in CollectionDesignManager.java constructor 68 68 public CollectionConfiguration(File collect_config_file) 69 { 69 { 70 load(collect_config_file); 71 } 72 73 private void load(File collect_config_file) { 70 74 this.collect_config_file = collect_config_file; 71 75 this.collect_config_filename = collect_config_file.getName(); … … 84 88 85 89 //XMLTools.printXMLNode(document.getDocumentElement()); 90 } 91 92 93 public void reload() { 94 load(this.collect_config_file); 86 95 } 87 96 -
main/trunk/gli/src/org/greenstone/gatherer/cdm/CollectionDesignManager.java
r32704 r34205 120 120 } 121 121 122 123 public void reloadConfig() { 124 // Parse and load the current collection configuration again 125 // Used after GLI > Edit > collectionConfig.xml > Save to get these edits into GLI. 126 127 collect_config.reload(); 128 if (DebugStream.isDebuggingEnabled()) { 129 collect_config.display(); 130 } 131 loadDesignDetails(); 132 DebugStream.println("CollectionDesignModule loaded."); 133 } 134 122 135 /** Reloads the various managers to ensure they have built themselves from the latest details available in the collection configuration class 123 136 * @see org.greenstone.gatherer.cdm.ClassifierManager -
main/trunk/gli/src/org/greenstone/gatherer/collection/CollectionManager.java
r34168 r34205 1303 1303 } 1304 1304 1305 1305 1306 public void reloadAfterConfigFileEdited() { 1307 // Copying just the part of LoadCollectionInternal below that loads the config file 1308 // Need to reload the *existing* config file, however. So calling custom method reloadConfig() 1309 1310 // Don't see why this stuff here (vs LoadCollectionInternal) would need to happen in its own 1311 // Thread for my use: when the modal Edit > collectionConfig.xml dialog has saved and closed. 1312 1313 // reload current collection's config 1314 collection.cdm.reloadConfig(); 1315 1316 // We're done. Let everyone know. 1317 DebugStream.println(Dictionary.get("CollectionManager.Loading_Successful", collection.getName())); 1318 Gatherer.refresh(Gatherer.COLLECTION_OPENED); 1319 } 1320 1306 1321 public void loadCollection(String collection_file_path) 1307 1322 { -
main/trunk/gli/src/org/greenstone/gatherer/gui/ConfigFileEditor.java
r32093 r34205 80 80 String collection_folder_path = Gatherer.getCollectDirectoryPath(); 81 81 String collectionName = Gatherer.c_man.getCollection().getName(); // we won't be in this constructor if collection is null. 82 83 // Gatherer.c_man.saveCollection(); // on Edit > collectionConfig.xml menu click, 84 // collection save has already happened as GLI pane.lostFocus() got called on current GLI Pane 85 // if/where this affects collectionConfig.xml. For an explanation, see GUIManager.java, 86 // look for "if(esrc == menu_bar.edit_config)" 87 82 88 this.config_file = new File(collection_folder_path + File.separator + collectionName, Utility.CONFIG_GS3_FILE); // col config editing is a GS3 feature 83 89 … … 201 207 // Final dialog setup & positioning. 202 208 setDefaultCloseOperation(DISPOSE_ON_CLOSE); // get rid of this dialog when it's closed (on dispose()) 209 this.addWindowListener(new WindowAdapter() { // called on dispose. Return focus to any curr GLI Pane 210 public void windowClose(WindowEvent we) { 211 Gatherer.g_man.doRegainFocus(); 212 } 213 }); 214 215 216 203 217 getRootPane().setDefaultButton(save_button); 204 218 Dimension screen_size = Configuration.screen_size; … … 234 248 // close and reopen the collection in GLI 235 249 String current_collection_filepath = Gatherer.c_man.getCollection().getCollectionPath(); 236 Gatherer.c_man.closeCollection(); 237 Gatherer.c_man.loadCollection(current_collection_filepath); 250 ////Gatherer.c_man.closeCollection(); // explicit save was necessary after all 251 // closeCollection() doesn't auto-save 252 ////Gatherer.c_man.loadCollection(current_collection_filepath); 253 254 255 // Fixing bug: Edit > colcfg wasn't being saved on Save when client-GLI. 256 // And in fact, it wasn't properly saving in GLI for some GLI panes. 257 // That's because save needs to be explicitly called. (Didn't understand how GLI's 258 // "autosave" worked until now. GLI > File > Close a collection saves it, but underneath 259 // it calles SAVEandCloseCollection. 260 261 // Works - but arduous: have to load in the entire collection just because cfg changed? 262 // Especial pain with client-GLI where reloading takes forever. 263 //Gatherer.g_man.saveThenCloseCurrentCollection(); 264 //Gatherer.c_man.loadCollection(current_collection_filepath); 265 266 // Better way: don't have to close and reopen the entire collection after editing colCfg.xml 267 // This just updates GLI's interface with the current collCfg.xml. 268 // Fingers crossed this works for client-GLI, because then the coll won't need to be closed 269 // and reopened each time after Edit > collectionCfg.xml gets saved. 270 Gatherer.c_man.saveCollection(); // should save colcfg whether GLI or client-GLI 271 Gatherer.c_man.reloadAfterConfigFileEdited(); 272 //Gatherer.g_man.updateUI(); // didn't do what I hoped it would, so is this relevant here? 273 // It's done when a new collection is loaded, so may be useful? 274 // But all my tests concerning GLI > Edit > collConfig.xml worked out without it 275 238 276 } 239 277 -
main/trunk/gli/src/org/greenstone/gatherer/gui/GUIManager.java
r32923 r34205 148 148 } 149 149 150 150 151 151 public void windowLostFocus(WindowEvent e) 152 152 { … … 266 266 else if(esrc == menu_bar.edit_config) { 267 267 if(Gatherer.c_man.getCollection() != null) { 268 268 // Before we open the current collection's collectionConfig.xml for editing, 269 // need to make sure any presently unsaved edits are saved into collConfig 270 // so they are reflected in this config file when loaded into the editor for editing. 271 // A simple Gatherer.c_man.saveCollection() is not sufficient: it won't save ongoing 272 // edits in the currently selected GLI Pane (where relevant to colcfg) 273 274 // Whenever a user swaps from one GLI pane to another, loseFocus() is called on the pane 275 // and for some GLI Panes, this triggers a collection save, but notably also triggers a 276 // loseFocus() on the pane's editing fields/controls, which saves any ongoing mods in that 277 // pane to the collectionConfiguration file. 278 // - See loseFocus() of BaseConfigPane.java (that only SOME gli Pane's inherit from) 279 // and also apparent in GUIManager.windowLostFocus(). 280 // - And for implementations of Control.loseFocus(), see for example via 281 // CollectionManager.loadDesignDetails() -> GeneralManager (for Format > General tab) 282 // which leads to GeneralManager.loseFocus() which gets "Called to store the current 283 // value of the components" - of its Controls. Exactly the behaviour we want! 284 285 // Not all GLI Panes inherit from BaseConfigPane, but then, not all GLI Panes 286 // make changes to the collection Config file; e.g. the Gather pane makes changes to 287 // the file system, Enrich makes changes to metadata.xml files and *.mds metadata sets 288 // files. But Design and Format panes make changes to collectionConfig.xml. 289 // In theory Create pane ought to as well, e.g. can set import options which also exists 290 // as ImportOptions in collectionConfig.xml, but they're not linked (yet) and Create pane 291 // doesn't inherit from BaseConfigPane. CreatePane's loseFocus() also don't call 292 // for the the collection to be saved. 293 294 // What all this means is that when we prepare to open the collectionConfig.xml, 295 // we want a collection save but want also the current state of GLI edits to be saved 296 // into collConfig before we display the collConfig file for editing. 297 // To trigger this behaviour we want to call loseFocus() on the current pane, called 298 // "previous_pane". That method may or may not force a save to collConfig, 299 // depending on whether it is warranted for that pane, but in such cases it will also 300 // cascade the loseFocus() call to the controls in that pane, who will save their current 301 // values into the colcfg in memory before this gets saved to the colCfg.xml file. 302 303 if(previous_pane != null) { 304 doLoseFocus(); 305 } 306 //Gatherer.c_man.saveCollection(); //shouldn't have to do this, in theory. See above comment 307 269 308 ConfigFileEditor configEditor = new ConfigFileEditor(); 270 309 configEditor.setVisible(true); … … 1035 1074 } 1036 1075 1037 1076 // Want to triger loseFocus() on GLI Panes at will when Menu > Edit > collectionConfig.xml clicked. 1077 // And when done editing, want to trigger doRegainFocs(). 1078 // loseFocus() on GLI Panes is not universally inherited from a common base class 1079 // But loseFocus() is important as it forces saves as-is of user entered values in gui fields 1080 // When alling doLoseFocus() on GLI > Edit > collConfig.xml, we force a save of the current state 1081 // of the current pane (called "previous_pane"). 1082 // Else a save is only triggered when another GLI Pane is clicked. We can't expect a user to 1083 // remember to click other panes whenever they want to edit the collConfig.xml. 1084 private void doLoseFocus() { 1085 1086 if (previous_pane != null) { 1087 if (previous_pane == gather_pane) { 1088 gather_pane.loseFocus(); 1089 } 1090 else if (previous_pane == enrich_pane) { 1091 enrich_pane.loseFocus(); 1092 } 1093 else if (previous_pane == design_pane) { 1094 design_pane.loseFocus(); 1095 } 1096 else if (previous_pane == create_pane) { 1097 create_pane.loseFocus(); 1098 } 1099 else if (previous_pane == format_pane) { 1100 format_pane.loseFocus(); 1101 } 1102 } 1103 } 1104 public void doRegainFocus() { 1105 1106 if (previous_pane != null) { 1107 if (previous_pane == gather_pane) { 1108 gather_pane.gainFocus(); 1109 } 1110 else if (previous_pane == enrich_pane) { 1111 enrich_pane.gainFocus(); 1112 } 1113 else if (previous_pane == design_pane) { 1114 design_pane.gainFocus(); 1115 } 1116 else if (previous_pane == create_pane) { 1117 create_pane.gainFocus(); 1118 } 1119 else if (previous_pane == format_pane) { 1120 format_pane.gainFocus(); 1121 } 1122 } 1123 } 1124 1038 1125 /** Any implementation of ChangeListener must include this method so we can be informed when the state of one of the registered objects changes. In this case we are listening to view changes within the tabbed pane. 1039 1126 * @param event A ChangeEvent containing information about the event that fired this call.
Note:
See TracChangeset
for help on using the changeset viewer.