Project

General

Profile

« Previous | Next » 

Revision 4f70cce5

Added by Patrick Plitzner over 10 years ago

  • adapted WaterbodyOrCountry separation

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/NamedAreaSelectionDialog.java
1 1
// $Id$
2 2
/**
3 3
* Copyright (C) 2007 EDIT
4
* European Distributed Institute of Taxonomy 
4
* European Distributed Institute of Taxonomy
5 5
* http://www.e-taxonomy.eu
6
* 
6
*
7 7
* The contents of this file are subject to the Mozilla Public License Version 1.1
8 8
* See LICENSE.TXT at the top of this package for the full license terms.
9 9
*/
......
55 55
			super(vocabulary.getTitleCache(), IAction.AS_CHECK_BOX);
56 56
			this.vocabulary = vocabulary;
57 57
		}
58
		
59
		public void run(){
58

  
59
		@Override
60
        public void run(){
60 61
			if(isChecked()){
61 62
				selectedVocabularies.add(vocabulary);
62 63
			}else{
63 64
				selectedVocabularies.remove(vocabulary);
64 65
			}
65
			
66

  
66 67
			initModel();
67 68
		}
68 69
	}
69
	
70

  
70 71
	private Collection<TermVocabulary<NamedArea>> selectedVocabularies;
71
	
72
	
72

  
73

  
73 74
	/**
74 75
	 * Creates a filtered selection dialog to select a named area.
75 76
	 *
......
85 86
				"Choose an area", false, namedArea);
86 87
		return getSelectionFromDialog(dialog);
87 88
	}
88
	
89

  
89 90
	/**
90 91
	 * <p>Constructor for FilteredNamedAreaSelectionDialog.</p>
91 92
	 *
......
96 97
	 * @param namedArea a {@link eu.etaxonomy.cdm.model.location.NamedArea} object.
97 98
	 */
98 99
	protected NamedAreaSelectionDialog(Shell shell, ConversationHolder conversation, String title, boolean multi, NamedArea namedArea) {
99
		super(shell, conversation, title, multi, NamedAreaSelectionDialog.class.getCanonicalName(), namedArea);		
100
		super(shell, conversation, title, multi, NamedAreaSelectionDialog.class.getCanonicalName(), namedArea);
100 101
	}
101
	
102

  
102 103
	/** {@inheritDoc} */
103 104
	@Override
104 105
	protected void fillViewMenu(IMenuManager menuManager) {
105
				
106

  
106 107
		super.fillViewMenu(menuManager);
107
				
108

  
108 109
		for(TermVocabulary<NamedArea> vocabulary : getVocabularies()){
109 110
			IncludeNamedAreaVocabulary action = new IncludeNamedAreaVocabulary(vocabulary);
110 111
			menuManager.add(action);
111 112
			action.setChecked(true);
112 113
		}
113 114
	}
114
	
115

  
115 116
	/** {@inheritDoc} */
116 117
	@Override
117 118
	protected NamedArea getPersistentObject(UUID uuid) {
......
125 126
		}
126 127
		return null;
127 128
	}
128
	
129

  
129 130
	/** {@inheritDoc} */
130 131
	@Override
131 132
	protected void init() {
132 133
		selectedVocabularies = getVocabularies();
133 134
	}
134
	
135

  
135 136
	private List<TermVocabulary<NamedArea>> getVocabularies(){
136 137
		List<TermVocabulary<NamedArea>> vocabularies = CdmStore.getService(IVocabularyService.class).listByTermClass(NamedArea.class, null, null, null, null);
137 138
		vocabularies.add(CdmStore.getService(IVocabularyService.class).getVocabulary(VocabularyEnum.TdwgArea));
138
		vocabularies.add(CdmStore.getService(IVocabularyService.class).getVocabulary(VocabularyEnum.WaterbodyOrCountry));
139
		vocabularies.add(CdmStore.getService(IVocabularyService.class).getVocabulary(VocabularyEnum.Country));
140
		vocabularies.add(CdmStore.getService(IVocabularyService.class).getVocabulary(VocabularyEnum.Waterbody));
139 141
		vocabularies.add(CdmStore.getService(IVocabularyService.class).getVocabulary(VocabularyEnum.Continent));
140 142
		return vocabularies;
141 143
	}
......
143 145
	/** {@inheritDoc} */
144 146
	@Override
145 147
	protected void initModel() {
146
		
148

  
147 149
		Set<NamedArea> terms = new HashSet<NamedArea>();
148 150
		for(TermVocabulary<NamedArea> vocabulary : selectedVocabularies){
149 151
			terms.addAll(vocabulary.getTermsOrderedByLabels(CdmStore.getDefaultLanguage()));
150 152
		}
151
		
153

  
152 154
		if(model == null){
153 155
			model = new ArrayList<UuidAndTitleCache<NamedArea>>();
154 156
		}
155 157
		model.clear();
156 158
		for(Object areaObject : terms){
157 159
			NamedArea area = (NamedArea) HibernateProxyHelper.deproxy(areaObject);
158
			UuidAndTitleCache<NamedArea> element = new UuidAndTitleCache<NamedArea>(NamedArea.class, area.getUuid(), getTitle(area)); 
160
			UuidAndTitleCache<NamedArea> element = new UuidAndTitleCache<NamedArea>(NamedArea.class, area.getUuid(), getTitle(area));
159 161
			model.add(element);
160 162
		}
161 163
	}
......
165 167
	protected Control createExtendedContentArea(Composite parent) {
166 168
		return null;
167 169
	}
168
	
170

  
169 171
	/** {@inheritDoc} */
170 172
	@Override
171 173
	protected String getTitle(NamedArea namedArea) {
......
178 180
			return namedArea.getTitleCache();
179 181
		}
180 182
	}
181
	
183

  
182 184
	/** {@inheritDoc} */
183 185
	@Override
184 186
	protected AbstractNewEntityWizard getNewEntityWizard(String parameter) {

Also available in: Unified diff