Changeset 34232 for main/trunk
- Timestamp:
- 2020-07-01T01:05:57+12:00 (4 years ago)
- Location:
- main/trunk/gli/src/org/greenstone/gatherer
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/gli/src/org/greenstone/gatherer/gems/GEMS.java
r32276 r34232 135 135 136 136 } 137 138 139 /** Constructor. 137 138 /** Constructor - original. Called when GEMS is launched as a standalone application. 139 * Sets up a very basic static-looking Configuration object, and Dictionary. 140 * Do not call if GEMS is launched through GLI, as this constructor will erase and replace 141 * GLI's carefully configured Configuration and Dictionary causing hard to track down errors. 142 * So don't call this constructor if standalone = false. 140 143 */ 141 144 public GEMS(String gsdl_path, String gsdl3_path, String metadata_path, boolean standalone, boolean new_set) 142 145 { 143 146 self = this; 144 JarTools.initialise(this); 145 screen_size = Configuration.screen_size; 146 147 JarTools.initialise(this); 147 148 // Load GLI config file: set up the Configuration so we can set up the Dictionary language 148 149 // Determine the GLI user directory path … … 154 155 gli_user_directory_path += ".gli" + File.separator; 155 156 } 157 158 // Since GEMS launched standalone, need to set up Configuration and Dictionary 156 159 new Configuration(gli_user_directory_path, gsdl_path, gsdl3_path, 157 160 null /*gsdl3_src_path*/, null /*site_name*/, null /*fedora_info*/); // null for parameters unknown to GEMS 158 161 159 162 // Read Dictionary in the locale specified in the config.xml 160 163 new Dictionary(Configuration.getLocale("general.locale", true), Configuration.getFont("general.font", true)); 161 162 msm = new MetadataSetManager(gsdl_path,gsdl3_path); 164 init(metadata_path, standalone, new_set); 165 } 166 167 /** Constructor - overloaded to use existing Configuration and Dictionary 168 * This Constructor is used when GEMS is launched through GLI. 169 * It's crucial for GLI to launch GEMS with this constructor as the other one will erase and 170 * replace GLI's carefully set-up Configuration and Dictionary, resulting in subtle but major 171 * flow-on errors particularly because of the alternate's cutdown version of Configuration. 172 */ 173 public GEMS(String metadata_path, boolean new_set) 174 { 175 self = this; 176 JarTools.initialise(this); 177 178 // When GEMS is launched through GLI (so not standalone) 179 // a Configuration and Dictionary is already set up 180 181 init(metadata_path, false /*standalone*/, new_set); 182 } 183 184 private void init(String metadata_path, boolean standalone, boolean new_set) { 185 screen_size = Configuration.screen_size; 186 187 //msm = new MetadataSetManager(Configuration.gsdl_path,Configuration.gsdl3_path); 188 // dangerously side-effecting version of MetadataSetManager constructor that 189 // erases Configuration all over again (as the original GEMS constructor also did) 190 // and is noticeable when remote GS3 server cryptically fails because 191 // Configuration.site_name is suddenly null due to these constructors. 192 // Creating/adding a new metadata set also prevents GLI > Preferences from opening 193 // because Configuration.site_name is nulled as a consequence of launching GEMS through GLI 194 195 // Instead, call the MetadataSetManager() constructor as it reuses existing Configuration, 196 // whether this is a basic Configuration created by standalone GEMS 197 // or a carefully and highly configured Configuration object created by GLI launching GEMS. 198 msm = new MetadataSetManager(); 199 163 200 stand_alone = standalone; 164 201 listeners = new ArrayList(); … … 219 256 new_prompt.addMetadataSetListener((MetadataSetListener)attribute_table); 220 257 new_prompt.addMetadataSetListener((MetadataSetListener)language_dependent_attribute_table); 221 222 258 259 223 260 // load the initial metadataset 224 261 if (metadata_path !=null && !metadata_path.equals("")){ … … 320 357 getContentPane().add(card_pane,BorderLayout.CENTER); 321 358 setLocation((screen_size.width - SIZE.width) / 2, (screen_size.height - SIZE.height) / 2); 322 if (stand_alone) 359 360 if (stand_alone) { 323 361 setVisible(true); 362 } 324 363 } 325 364 -
main/trunk/gli/src/org/greenstone/gatherer/gems/MetadataSetManager.java
r14974 r34232 70 70 private String current_language = GEMSConstants.DEFAULT_LANGUAGE; 71 71 72 /** Constructor. */ 72 /** Constructor. 73 * This constructor can be dangerous if launched by a Greenstone application 74 * that already set up the static looking Configuration object, because 75 * this constructor will subtly erase and replace any previously existing 76 * carefully configured Configuration object. 77 * I think this constructor would only be useful if MetadataSetManager is ever launched 78 * as a standalone GS3 application. 79 * If instantiating a MetadataSetManager through GEMS, use the MetadataSetManager() constructor, 80 * including if GEMS is launched through GLI. 81 * Also use MetadataSetManager() if creating a MetadataSetManager object through GLI. 82 */ 73 83 public MetadataSetManager(String gsdl_path, String gsdl3_path) { 74 84 // Determine the GLI user directory path … … 87 97 languageList = new ArrayList(); 88 98 } 89 99 100 /** Constructor - overloaded to use any existing Configuration already set up. 101 * This Constructor is used by GEMS when GEMS is launched through GLI. 102 */ 103 public MetadataSetManager() { 104 current_language = Configuration.getLanguage(); 105 106 languageList = new ArrayList(); 107 } 108 90 109 public ArrayList getLanguageList(){ 91 110 //already loaded -
main/trunk/gli/src/org/greenstone/gatherer/gui/MetadataSetDialog.java
r18370 r34232 138 138 String metadata_path = metadata_set.getMetadataSetFile().toString(); 139 139 if (gems == null){ 140 gems = new GEMS(Configuration.gsdl_path,Configuration.gsdl3_path,"", false, false); 140 141 //gems = new GEMS(Configuration.gsdl_path,Configuration.gsdl3_path,"", false, false, site_name); // dangerous: this version of GEMS constructor only for if GEMS not launched through GLI but standalone 142 // refer to comments in GEMS.java for GEMS constructors 143 gems = new GEMS("", false); // right way to create GEMS app when launched by GLI 141 144 gems.addGEMSListener(this); 142 145 } … … 270 273 public void actionPerformed(ActionEvent event) { 271 274 if (gems == null) { 272 gems = new GEMS(Configuration.gsdl_path, Configuration.gsdl3_path, "", false, false); 275 //gems = new GEMS(Configuration.gsdl_path, Configuration.gsdl3_path, "", false, false, site_name); // dangerous: this version of GEMS constructor only for if GEMS not launched through GLI but standalone 276 // refer to comments in GEMS.java for GEMS constructors 277 gems = new GEMS("", false); // right way to create GEMS app when launched by GLI 273 278 } 274 279 gems.newMetadataSet();
Note:
See TracChangeset
for help on using the changeset viewer.