Project

General

Profile

« Previous | Next » 

Revision e9773ade

Added by Katja Luther over 7 years ago

ref #5971: new main menu admin with cdm preference nomenclatural code and insert polytomous key node

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/PreferencesUtil.java
107 107
	 *            a {@link eu.etaxonomy.cdm.model.name.NomenclaturalCode}
108 108
	 *            object.
109 109
	 */
110
	public static NomenclaturalCode setPreferredNomenclaturalCode(
110
	public static CdmPreference setPreferredNomenclaturalCode(
111 111
			NomenclaturalCode preferredCode, boolean local) {
112 112
	    if (local){
113 113
	        getPreferenceStore().setValue(PREFERRED_NOMENCLATURAL_CODE_KEY,
......
129 129
    				int index = StringUtils.lastIndexOf(preference.getValue(), ".");
130 130
    				UUID uuid = UUID.fromString(preference.getValue().substring(index +1, preference.getValue().length()));
131 131
    				preferredCode = NomenclaturalCode.getByUuid(uuid);
132
    				return preferredCode;
132

  
133
    				getPreferenceStore().setValue(CDM_NOMENCLATURAL_CODE_KEY,
134
    	                    getPreferenceKey(preferredCode));
135
    				getPreferenceStore().setValue(ALLOW_OVERRIDE_NOMENCLATURAL_CODE_KEY,preference.isAllowOverride());
136
    				return preference;
133 137
    			}
134 138
    		} else{
135 139
    			preference = CdmPreference.NewInstance(PreferenceSubject.NewDatabaseInstance(), PreferencePredicate.NomenclaturalCode, preferredCode.getKey());
......
137 141

  
138 142
    		}
139 143
	    }
140
        return preferredCode;
144
        return null;
141 145

  
142 146

  
143 147

  
......
486 490

  
487 491
		if (PreferencesUtil.getPreferredNomenclaturalCode(true) == null) {
488 492
			PreferencesUtil.setPreferredNomenclaturalCode(NomenclaturalCode.ICNAFP, true);
489
			/*
490

  
491
			StoreUtil.info("No nomencatural code set.");
492

  
493
			Shell shell = StoreUtil.getShell();
494

  
495
		 Query user re: preferred nom. code
496
			Dialog dialog = new InitNomenclaturalCodePrefDialog(shell);
497
			dialog.open();
498

  
499
			// Short message confirming user's choice
500
			NomenclaturalCode code = PreferencesUtil
501
					.getPreferredNomenclaturalCode();
502
			MessageDialog
503
					.openInformation(
504
							shell,
505
							"Nomenclatural code set",
506
							"The following has been set as your preferred nomenclatural code:\n\n\t"
507
									+ NomenclaturalCodeHelper
508
											.getDescription(code)
509
									+ "\n\nYou can change the nomenclatural code at any time in the \"Preferences\" menu.");*/
510 493
		}
494

  
495

  
496

  
497
	}
498
	public static void setNomenclaturalCodePreferences(){
499
    	ICdmApplicationConfiguration controller;
500
        controller = CdmStore.getCurrentApplicationConfiguration();
501
        PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewDatabaseInstance(), PreferencePredicate.NomenclaturalCode);
502
        CdmPreference preference = null;
503
        if (controller == null){
504
            return ;
505
        }
506
        preference = controller.getPreferenceService().find(key);
507
        if (preference == null){
508
            return;
509
        }
510
        getPreferenceStore().setValue(ALLOW_OVERRIDE_NOMENCLATURAL_CODE_KEY, preference.isAllowOverride());
511

  
512
        int index = StringUtils.lastIndexOf(preference.getValue(), ".");
513
        UUID uuid = UUID.fromString(preference.getValue().substring(index +1, preference.getValue().length()));
514
        NomenclaturalCode preferredCode = NomenclaturalCode.getByUuid(uuid);
515

  
516
        getPreferenceStore().setValue(CDM_NOMENCLATURAL_CODE_KEY,
517
                getPreferenceKey(preferredCode));
518

  
519
        if (!preference.isAllowOverride()){
520
            getPreferenceStore().setValue(PREFERRED_NOMENCLATURAL_CODE_KEY,
521
                    getPreferenceKey(preferredCode));
522
        }
511 523
	}
512 524

  
513 525
	public static void checkDefaultLanguage(){

Also available in: Unified diff