Project

General

Profile

« Previous | Next » 

Revision de30f355

Added by Patrick Plitzner over 8 years ago

Fix named area filter for selection dialog (#2353)

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/NamedAreaSelectionDialog.java
36 36
import eu.etaxonomy.taxeditor.store.CdmStore;
37 37

  
38 38
/**
39
 * <p>FilteredNamedAreaSelectionDialog class.</p>
40
 *
41 39
 * @author n.hoffmann
42 40
 * @created May 11, 2010
43 41
 * @version 1.0
......
68 66
	}
69 67

  
70 68
	private Collection<TermVocabulary<NamedArea>> selectedVocabularies;
71
    private final ArrayList<TermVocabulary> preselectedVocabularies;
69
    private ArrayList<TermVocabulary> preselectedVocabularies;
72 70

  
73 71

  
74 72
	/**
......
88 86
		return getSelectionFromDialog(dialog);
89 87
	}
90 88

  
91
	/**
92
	 * <p>Constructor for FilteredNamedAreaSelectionDialog.</p>
93
	 *
94
	 * @param shell a {@link org.eclipse.swt.widgets.Shell} object.
95
	 * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
96
	 * @param title a {@link java.lang.String} object.
97
	 * @param multi a boolean.
98
	 * @param namedArea a {@link eu.etaxonomy.cdm.model.location.NamedArea} object.
99
	 * @param preselectedVocabularyUuids the {@link UUID}s of the pre-selected Vocabularies
100
	 */
101 89
	protected NamedAreaSelectionDialog(Shell shell, ConversationHolder conversation, String title, boolean multi, NamedArea namedArea, UUID... preselectedVocabularyUuids) {
102 90
		super(shell, conversation, title, multi, NamedAreaSelectionDialog.class.getCanonicalName(), namedArea);
103
		preselectedVocabularies = new ArrayList<TermVocabulary>();
104
		for(int i=0;i<preselectedVocabularyUuids.length;i++){
105
		    TermVocabulary preselectedVocabulary = CdmStore.getService(IVocabularyService.class).find(preselectedVocabularyUuids[i]);
106
            preselectedVocabularies.add(preselectedVocabulary);
91
		if(preselectedVocabularyUuids.length>0){
92
		    preselectedVocabularies = new ArrayList<TermVocabulary>();
93
		    for(int i=0;i<preselectedVocabularyUuids.length;i++){
94
		        TermVocabulary preselectedVocabulary = CdmStore.getService(IVocabularyService.class).find(preselectedVocabularyUuids[i]);
95
		        preselectedVocabularies.add(preselectedVocabulary);
96
		    }
97
		    selectedVocabularies.retainAll(preselectedVocabularies);
98
		    initModel();//re-init to consider pre-selected vocabularies
107 99
		}
108
		selectedVocabularies.retainAll(preselectedVocabularies);
109
		initModel();//re-init to consider pre-selected vocabularies
110 100
	}
111 101

  
112 102
	/** {@inheritDoc} */
......
118 108
		for(TermVocabulary<NamedArea> vocabulary : getAvailableVocabularies()){
119 109
			IncludeNamedAreaVocabulary action = new IncludeNamedAreaVocabulary(vocabulary);
120 110
			menuManager.add(action);
121
			if(preselectedVocabularies.isEmpty() || preselectedVocabularies.contains(vocabulary)) {
111
			if(preselectedVocabularies==null || preselectedVocabularies.isEmpty() || preselectedVocabularies.contains(vocabulary)) {
122 112
			    action.setChecked(true);
123 113
			}
124 114
		}

Also available in: Unified diff