2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
10 package eu
.etaxonomy
.taxeditor
.preference
;
13 import java
.io
.FileInputStream
;
14 import java
.io
.FileOutputStream
;
15 import java
.io
.IOException
;
17 import java
.net
.URISyntaxException
;
18 import java
.util
.ArrayList
;
19 import java
.util
.Arrays
;
20 import java
.util
.HashMap
;
21 import java
.util
.List
;
23 import java
.util
.Properties
;
25 import java
.util
.StringTokenizer
;
26 import java
.util
.UUID
;
28 import org
.apache
.commons
.lang
.StringUtils
;
29 import org
.eclipse
.equinox
.internal
.p2
.ui
.model
.MetadataRepositoryElement
;
30 import org
.eclipse
.jface
.preference
.IPreferenceStore
;
31 import org
.eclipse
.jface
.window
.Window
;
32 import org
.eclipse
.swt
.widgets
.Composite
;
33 import org
.eclipse
.swt
.widgets
.Control
;
34 import org
.eclipse
.swt
.widgets
.Shell
;
35 import org
.eclipse
.ui
.PlatformUI
;
37 import eu
.etaxonomy
.cdm
.api
.facade
.DerivedUnitFacadeConfigurator
;
38 import eu
.etaxonomy
.cdm
.api
.service
.IFeatureTreeService
;
39 import eu
.etaxonomy
.cdm
.api
.service
.ITermService
;
40 import eu
.etaxonomy
.cdm
.api
.service
.config
.FindTaxaAndNamesConfiguratorImpl
;
41 import eu
.etaxonomy
.cdm
.api
.service
.config
.IFindTaxaAndNamesConfigurator
;
42 import eu
.etaxonomy
.cdm
.common
.CdmUtils
;
43 import eu
.etaxonomy
.cdm
.hibernate
.HibernateProxyHelper
;
44 import eu
.etaxonomy
.cdm
.model
.common
.ICdmBase
;
45 import eu
.etaxonomy
.cdm
.model
.common
.IDefinedTerm
;
46 import eu
.etaxonomy
.cdm
.model
.common
.ISimpleTerm
;
47 import eu
.etaxonomy
.cdm
.model
.common
.Language
;
48 import eu
.etaxonomy
.cdm
.model
.common
.MarkerType
;
49 import eu
.etaxonomy
.cdm
.model
.common
.TermBase
;
50 import eu
.etaxonomy
.cdm
.model
.description
.FeatureTree
;
51 import eu
.etaxonomy
.cdm
.model
.name
.NomenclaturalCode
;
52 import eu
.etaxonomy
.cdm
.strategy
.match
.DefaultMatchStrategy
;
53 import eu
.etaxonomy
.cdm
.strategy
.match
.IMatchStrategy
;
54 import eu
.etaxonomy
.cdm
.strategy
.match
.MatchException
;
55 import eu
.etaxonomy
.cdm
.strategy
.match
.MatchMode
;
56 import eu
.etaxonomy
.taxeditor
.model
.AbstractUtility
;
57 import eu
.etaxonomy
.taxeditor
.model
.MessagingUtils
;
58 import eu
.etaxonomy
.taxeditor
.model
.NomenclaturalCodeHelper
;
59 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
60 import eu
.etaxonomy
.taxeditor
.store
.internal
.TaxeditorStorePlugin
;
61 import eu
.etaxonomy
.taxeditor
.ui
.dialog
.DefaultLanguageDialog
;
65 * PreferencesUtil class.
73 public class PreferencesUtil
implements IPreferenceKeys
{
78 public static final String PREFERRED_TERMS_CHANGE
= "preferred_terms";
80 public static final String P2_REPOSITORIES_DELIM
= ",";
81 public static final String P2_REPOSITORY_FIELDS_DELIM
= ";";
90 * @return a {@link org.eclipse.jface.preference.IPreferenceStore} object.
92 public static IPreferenceStore
getPreferenceStore() {
93 return TaxeditorStorePlugin
.getDefault().getPreferenceStore();
98 * setPreferredNomenclaturalCode
101 * @param preferredCode
102 * a {@link eu.etaxonomy.cdm.model.name.NomenclaturalCode}
105 public static void setPreferredNomenclaturalCode(
106 NomenclaturalCode preferredCode
) {
107 getPreferenceStore().setValue(PREFERRED_NOMENCLATURAL_CODE_KEY
,
108 getPreferenceKey(preferredCode
));
113 * getPreferredNomenclaturalCode
116 * @return a {@link eu.etaxonomy.cdm.model.name.NomenclaturalCode} object.
118 public static NomenclaturalCode
getPreferredNomenclaturalCode() {
120 for (NomenclaturalCode code
: NomenclaturalCodeHelper
.getAllCodes()) {
121 String preferredCode
= getPreferenceStore().getString(
122 PREFERRED_NOMENCLATURAL_CODE_KEY
);
123 if (getPreferenceKey(code
).equals(preferredCode
)) {
130 public static String
getPreferredDefaultLangugae(){
131 String preferredLanguage
= getPreferenceStore().getString(DEFAULT_LANGUAGE_EDITOR
);
132 if(StringUtils
.isNotEmpty(preferredLanguage
) && StringUtils
.isNotBlank(preferredLanguage
)){
133 return preferredLanguage
;
139 * Get the match strategy for the given class that was stored in preferences
140 * or the default strategy if it was not stored in preferences
143 * a {@link java.lang.Class} object.
144 * @return a {@link eu.etaxonomy.cdm.strategy.match.IMatchStrategy} object.
146 public static IMatchStrategy
getMatchStrategy(Class clazz
) {
147 String className
= clazz
.getName();
148 if (getPreferenceStore().getBoolean(MATCH_STRATEGY_PREFIX
+ className
)) {
149 IMatchStrategy matchStrategy
= getDefaultMatchStrategy(clazz
);
151 for (String fieldName
: matchStrategy
.getMatchFieldPropertyNames()) {
152 String matchModeName
= getPreferenceStore().getString(
153 getMatchStrategyFieldName(className
, fieldName
));
154 MatchMode matchMode
= MatchMode
.valueOf(matchModeName
);
156 matchStrategy
.setMatchMode(fieldName
, matchMode
);
157 } catch (MatchException e
) {
158 MessagingUtils
.error(PreferencesUtil
.class, e
);
159 throw new RuntimeException(e
);
163 return matchStrategy
;
165 return getDefaultMatchStrategy(clazz
);
169 * Stores a matchStrategy into the preference store.
171 * @param matchStrategy
172 * a {@link eu.etaxonomy.cdm.strategy.match.IMatchStrategy}
175 public static void setMatchStrategy(IMatchStrategy matchStrategy
) {
176 String className
= matchStrategy
.getMatchClass().getName();
177 getPreferenceStore().setValue(MATCH_STRATEGY_PREFIX
+ className
, true);
179 Set
<String
> matchFields
= matchStrategy
.getMatchFieldPropertyNames();
181 for (String fieldName
: matchFields
) {
182 getPreferenceStore().setValue(
183 getMatchStrategyFieldName(className
, fieldName
),
184 matchStrategy
.getMatchMode(fieldName
).name());
189 * Helper method to create the preference property for a match field.
195 private static String
getMatchStrategyFieldName(String className
,
197 return MATCH_STRATEGY_PREFIX
+ className
+ "." + fieldName
;
201 * Returns the default match strategy for a given class.
204 * a {@link java.lang.Class} object.
205 * @return a {@link eu.etaxonomy.cdm.strategy.match.IMatchStrategy} object.
207 public static IMatchStrategy
getDefaultMatchStrategy(Class clazz
) {
208 return DefaultMatchStrategy
.NewInstance(clazz
);
213 * getDateFormatPattern
216 * @return a {@link java.lang.String} object.
218 public static String
getDateFormatPattern() {
219 // TODO make this configurable in properties
220 String pattern
= "Y-M-d H:m";
226 * addTermToPreferredTerms
234 public static <T
extends TermBase
> void addTermToPreferredTerms(T term
) {
236 // VocabularyEnum vocabulary =
237 // VocabularyEnum.getVocabularyEnum(term.getClass());
239 // getPreferenceStore().setValue(getPreferenceKey(term),
240 // VocabularyStore.getTermVocabulary(vocabulary).getTerms().contains(term));
242 // firePreferencesChanged(term.getClass());
246 * Construct a unique key using the CdmBase object's uuid
251 private static String
getPreferenceKey(ICdmBase cdmBase
) {
252 cdmBase
= HibernateProxyHelper
.deproxy(cdmBase
);
254 String key
= cdmBase
.getClass().getName().concat(".")
255 .concat(cdmBase
.getUuid().toString());
256 if (key
.contains("javassist")) {
257 MessagingUtils
.info("proxy");
263 * Construct a unique key using the CdmBase object's uuid
268 public static String
getPreferenceKey(ISimpleTerm simpleTerm
) {
269 simpleTerm
= HibernateProxyHelper
.deproxy(simpleTerm
);
270 String key
= simpleTerm
.getClass().getName().concat(".")
271 .concat(simpleTerm
.getUuid().toString());
272 if (key
.contains("javassist")) {
273 MessagingUtils
.warn(PreferencesUtil
.class,
274 "Trying to persist a preference based on a proxy class.");
282 * Construct a unique key using the CdmBase object's uuid
287 public static String
getPreferenceKey(IDefinedTerm definedTerm
) {
288 definedTerm
= HibernateProxyHelper
.deproxy(definedTerm
);
289 String key
= definedTerm
.getClass().getName().concat(".")
290 .concat(definedTerm
.getUuid().toString());
291 if (key
.contains("javassist")) {
292 MessagingUtils
.warn(PreferencesUtil
.class,
293 "Trying to persist a preference based on a proxy class.");
299 * Retrieves search preferences from the preference store
301 * @return an {@link ITaxonServiceConfigurator} to pass to search methods
303 public static IFindTaxaAndNamesConfigurator
getSearchConfigurator() {
304 IFindTaxaAndNamesConfigurator configurator
= initializeSearchConfigurator();
306 configurator
.setDoTaxa(getPreferenceStore().getBoolean(
307 TAXON_SERVICE_CONFIGURATOR_TAXA
));
308 configurator
.setDoSynonyms(getPreferenceStore().getBoolean(
309 TAXON_SERVICE_CONFIGURATOR_SYNONYMS
));
310 configurator
.setDoNamesWithoutTaxa(getPreferenceStore().getBoolean(
311 TAXON_SERVICE_CONFIGURATOR_NAMES
));
312 configurator
.setDoTaxaByCommonNames(getPreferenceStore().getBoolean(
313 TAXON_SERVICE_CONFIGURATOR_COMMON_NAMES
));
314 //configurator.setMatchMode(eu.etaxonomy.cdm.persistence.query.MatchMode.valueOf(getPreferenceStore().getString(TAXON_SERVICE_CONFIGURATOR_MATCH_MODE)));
320 * create new preferences, setting all search options to true
323 * {@link eu.etaxonomy.cdm.api.service.config.ITaxonServiceConfigurator}
326 public static IFindTaxaAndNamesConfigurator
initializeSearchConfigurator() {
327 IFindTaxaAndNamesConfigurator configurator
= new FindTaxaAndNamesConfiguratorImpl();
329 configurator
.setDoTaxa(true);
330 configurator
.setDoSynonyms(true);
331 configurator
.setDoNamesWithoutTaxa(true);
332 configurator
.setDoTaxaByCommonNames(true);
334 configurator
.setTaxonPropertyPath(Arrays
.asList("$", "titleCache",
335 "name", "name.$", "relationsFromThisTaxon.$"));
337 configurator
.setSynonymPropertyPath(Arrays
.asList("$", "titleCache",
338 "name", "name.$", "synonymRelations.relatedTo.*"));
341 // match mode is a simple like, actually all other match modes are kind
344 .setMatchMode(eu
.etaxonomy
.cdm
.persistence
.query
.MatchMode
.ANYWHERE
);
345 // we set page number and size here as this should always be unlimited
346 configurator
.setPageNumber(0);
347 // TODO currently limit results to 10000
348 configurator
.setPageSize(10000);
354 * Store search preferences
356 * @param configurator
358 * {@link eu.etaxonomy.cdm.api.service.config.ITaxonServiceConfigurator}
361 public static void setSearchConfigurator(
362 IFindTaxaAndNamesConfigurator configurator
) {
363 getPreferenceStore().setValue(TAXON_SERVICE_CONFIGURATOR_TAXA
,
364 configurator
.isDoTaxa());
365 getPreferenceStore().setValue(TAXON_SERVICE_CONFIGURATOR_SYNONYMS
,
366 configurator
.isDoSynonyms());
367 getPreferenceStore().setValue(TAXON_SERVICE_CONFIGURATOR_NAMES
,
368 configurator
.isDoNamesWithoutTaxa());
369 getPreferenceStore().setValue(TAXON_SERVICE_CONFIGURATOR_COMMON_NAMES
,
370 configurator
.isDoTaxaByCommonNames());
375 * firePreferencesChanged
379 * a {@link java.lang.Class} object.
381 public static void firePreferencesChanged(Class clazz
) {
382 getPreferenceStore().firePropertyChangeEvent(PREFERRED_TERMS_CHANGE
,
387 * Set default values for preferences
389 public static void setDefaults() {
390 getPreferenceStore().setDefault(TAXON_SERVICE_CONFIGURATOR_TAXA
, true);
391 getPreferenceStore().setDefault(TAXON_SERVICE_CONFIGURATOR_SYNONYMS
,
393 getPreferenceStore().setDefault(EDIT_MAP_SERVICE_ACCES_POINT
,
394 "http://edit.africamuseum.be/edit_wp5/v1.2/rest_gen.php");
395 //FIXME : changed default for SHOULD_CONNECT_AT_STARTUP to false (ticket 3828) until resolution
396 getPreferenceStore().setDefault(SHOULD_CONNECT_AT_STARTUP
, false);
397 getPreferenceStore().setDefault(OPENURL_ACCESS_POINT
,
398 "http://www.biodiversitylibrary.org/openurl");
399 getPreferenceStore().setDefault(OPENURL_IMAGE_MAX_WIDTH
, "1000");
400 getPreferenceStore().setDefault(OPENURL_IMAGE_MAX_HEIGHT
, "1000");
401 getPreferenceStore().setDefault(IPreferenceKeys
.DISTRIBUTION_AREA_PREFRENCES_ACTIVE
, false);
402 getPreferenceStore().setDefault(CHECKLIST_ID_IN_VOCABULARY
, true);
407 * checkNomenclaturalCode
410 public static void checkNomenclaturalCode() {
411 // First time Editor is opened, no nomenclatural code has been set
414 if (PreferencesUtil
.getPreferredNomenclaturalCode() == null) {
415 PreferencesUtil
.setPreferredNomenclaturalCode(NomenclaturalCode
.ICNAFP
);
418 StoreUtil.info("No nomencatural code set.");
420 Shell shell = StoreUtil.getShell();
422 Query user re: preferred nom. code
423 Dialog dialog = new InitNomenclaturalCodePrefDialog(shell);
426 // Short message confirming user's choice
427 NomenclaturalCode code = PreferencesUtil
428 .getPreferredNomenclaturalCode();
432 "Nomenclatural code set",
433 "The following has been set as your preferred nomenclatural code:\n\n\t"
434 + NomenclaturalCodeHelper
435 .getDescription(code)
436 + "\n\nYou can change the nomenclatural code at any time in the \"Preferences\" menu.");*/
440 public static void checkDefaultLanguage(){
441 if(PreferencesUtil
.getPreferredDefaultLangugae() == null){
442 Shell shell
= AbstractUtility
.getShell();
443 int open
= new DefaultLanguageDialog(shell
).open();
444 if(open
== Window
.OK
){
445 PlatformUI
.getWorkbench().restart();
448 //TODO:In case of a reinstall, the config.ini will be overwritten
449 // here you create config.ini with the stored key from preferences
455 * getMapServiceAccessPoint
458 * @return a {@link java.lang.String} object.
460 public static String
getMapServiceAccessPoint() {
461 return getPreferenceStore().getString(EDIT_MAP_SERVICE_ACCES_POINT
);
466 * shouldConnectAtStartUp
471 public static boolean shouldConnectAtStartUp() {
472 //FIXME : force SHOULD_CONNECT_AT_STARTUP to false (ticket 3828) until resolution
473 //return getPreferenceStore().getBoolean(SHOULD_CONNECT_AT_STARTUP);
479 * getDefaultFeatureTreeForTextualDescription
482 * @return a {@link eu.etaxonomy.cdm.model.description.FeatureTree} object.
484 public static FeatureTree
getDefaultFeatureTreeForTextualDescription() {
485 String uuidString
= getPreferenceStore().getString(
486 FEATURE_TREE_DEFAULT_TEXT
);
487 return CdmUtils
.isEmpty(uuidString
) ?
null : CdmStore
.getService(
488 IFeatureTreeService
.class).load(UUID
.fromString(uuidString
));
493 * getDefaultFeatureTreeForStructuredDescription
496 * @return a {@link eu.etaxonomy.cdm.model.description.FeatureTree} object.
498 public static FeatureTree
getDefaultFeatureTreeForStructuredDescription() {
499 String uuidString
= getPreferenceStore().getString(
500 FEATURE_TREE_DEFAULT_STRUCTURE
);
501 return CdmUtils
.isEmpty(uuidString
) ?
null : CdmStore
.getService(
502 IFeatureTreeService
.class).load(UUID
.fromString(uuidString
));
507 * setSortRanksHierarchichally
513 public static void setSortRanksHierarchichally(boolean selection
) {
514 getPreferenceStore().setValue(SORT_RANKS_HIERARCHICHALLY
, selection
);
519 * getSortRanksHierarchichally
524 public static boolean getSortRanksHierarchichally() {
525 return getPreferenceStore().getBoolean(SORT_RANKS_HIERARCHICHALLY
);
528 public static boolean isMultilanguageTextEditingCapability() {
529 return getPreferenceStore().getBoolean(
530 MULTILANGUAGE_TEXT_EDITING_CAPABILITY
);
533 public static Language
getGlobalLanguage() {
536 String languageUuidString
= getPreferenceStore().getString(
537 GLOBAL_LANGUAGE_UUID
);
539 if(!CdmStore
.isActive()) {
540 MessagingUtils
.noDataSourceWarningDialog(languageUuidString
);
544 if (CdmUtils
.isBlank(languageUuidString
)) {
545 return Language
.getDefaultLanguage();
548 UUID languageUuid
= UUID
.fromString(languageUuidString
);
549 return (Language
) CdmStore
.getService(ITermService
.class).load(
553 public static void setGlobalLanguage(Language language
) {
554 if(language
!= null) {
555 getPreferenceStore().setValue(GLOBAL_LANGUAGE_UUID
,language
.getUuid().toString());
556 CdmStore
.setDefaultLanguage(language
);
564 public static Map
<MarkerType
, Boolean
> getEditMarkerTypePreferences() {
565 List
<MarkerType
> markerTypes
= CdmStore
.getTermManager()
566 .getPreferredTerms(MarkerType
.class);
568 Map
<MarkerType
, Boolean
> result
= new HashMap
<MarkerType
, Boolean
>();
570 for (MarkerType markerType
: markerTypes
) {
571 String name
= getMarkerTypeEditingPreferenceKey(markerType
);
572 Boolean value
= getPreferenceStore().getBoolean(name
);
574 result
.put(markerType
, value
);
581 * @param markerTypeEditingMap
583 public static void setEditMarkerTypePreferences(
584 Map
<MarkerType
, Boolean
> markerTypeEditingMap
) {
585 for (MarkerType markerType
: markerTypeEditingMap
.keySet()) {
586 String name
= getMarkerTypeEditingPreferenceKey(markerType
);
587 getPreferenceStore().setValue(name
,
588 markerTypeEditingMap
.get(markerType
));
593 private static String
getMarkerTypeEditingPreferenceKey(
594 MarkerType markerType
) {
595 markerType
= HibernateProxyHelper
.deproxy(markerType
);
596 return markerType
.getClass().getName() + EDIT_MARKER_TYPE_PREFIX
;
601 * setEditMarkerTypePreference
605 * a {@link org.eclipse.ui.IEditorInput} object.
607 * a {@link eu.etaxonomy.cdm.model.common.MarkerType} object.
611 public static void setEditMarkerTypePreference(MarkerType markerType
,
613 getPreferenceStore().setValue(
614 getMarkerTypeEditingPreferenceKey(markerType
), edit
);
620 public static DerivedUnitFacadeConfigurator
getDerivedUnitConfigurator() {
621 DerivedUnitFacadeConfigurator configurator
= DerivedUnitFacadeConfigurator
623 configurator
.setMoveDerivedUnitMediaToGallery(true);
624 configurator
.setMoveFieldObjectMediaToGallery(true);
629 * This method will write language properties to the config.ini located in the configuration folder
630 * of the Taxonomic Ediitor. <b>This method is only used to set the default language for Taxonomic Editor.</b>
632 * @param setLanguage 0 is for german and 1 for english.
633 * @throws IOException
635 public void writePropertyToConfigFile(int setLanguage
) throws IOException
{
636 File file
= org
.eclipse
.core
.runtime
.preferences
.ConfigurationScope
.INSTANCE
.getLocation().toFile();
637 //give warning to user if the directory has no write access
639 throw new IOException();
641 Properties properties
= load(file
.getAbsolutePath()+"/config.ini");
644 properties
.setProperty("osgi.nl", "de");
645 PreferencesUtil
.getPreferenceStore().setValue(IPreferenceKeys
.DEFAULT_LANGUAGE_EDITOR
, "de");
648 properties
.setProperty("osgi.nl", "en");
649 PreferencesUtil
.getPreferenceStore().setValue(IPreferenceKeys
.DEFAULT_LANGUAGE_EDITOR
, "en");
654 save(file
+"/config.ini", properties
);
658 * This method loads a property from a given file and returns it.
662 * @throws IOException
664 private Properties
load(String filename
) throws IOException
{
665 FileInputStream in
= new FileInputStream(filename
);
666 Properties prop
= new Properties();
673 * This method saves a property to the specified file.
677 * @throws IOException
679 private void save(String filename
, Properties properties
) throws IOException
{
680 FileOutputStream fos
= new FileOutputStream(filename
);
681 properties
.store(fos
, "");
686 * Saves a list of P2 Metadata Repositories as string with specified delimiters
690 public static void setP2Repositories(List
<MetadataRepositoryElement
> p2Repos
) {
691 StringBuilder sb
= new StringBuilder();
692 for(MetadataRepositoryElement p2Repo
: p2Repos
) {
693 sb
.append(P2_REPOSITORIES_DELIM
);
694 if(p2Repo
.getName() == null || p2Repo
.getName().isEmpty()) {
697 sb
.append(p2Repo
.getName());
699 sb
.append(P2_REPOSITORY_FIELDS_DELIM
);
700 sb
.append(p2Repo
.getLocation().toString());
701 sb
.append(P2_REPOSITORY_FIELDS_DELIM
);
702 sb
.append(String
.valueOf(p2Repo
.isEnabled()));
704 getPreferenceStore().setValue(P2_REPOSITORY_LIST
, sb
.toString());
709 * Retrieves a list of previously saved P2 repositories
713 public static List
<MetadataRepositoryElement
> getP2Repositories() {
714 List
<MetadataRepositoryElement
> p2Repos
= new ArrayList
<MetadataRepositoryElement
>();
715 String p2ReposPref
= getPreferenceStore().getString(P2_REPOSITORY_LIST
);
716 if(p2ReposPref
!= null && !p2ReposPref
.isEmpty()) {
717 StringTokenizer p2ReposPrefST
= new StringTokenizer(p2ReposPref
,P2_REPOSITORIES_DELIM
);
719 while(p2ReposPrefST
.hasMoreTokens()) {
720 String p2RepoStr
= p2ReposPrefST
.nextToken();
721 StringTokenizer p2ReposStrST
= new StringTokenizer(p2RepoStr
,P2_REPOSITORY_FIELDS_DELIM
);
722 if(p2ReposStrST
.countTokens()==3) {
723 String nickname
= p2ReposStrST
.nextToken();
726 uri
= new URI(p2ReposStrST
.nextToken());
727 } catch (URISyntaxException e
) {
730 boolean enabled
= Boolean
.parseBoolean(p2ReposStrST
.nextToken());
731 MetadataRepositoryElement mre
= new MetadataRepositoryElement(null, uri
, true);
732 mre
.setNickname(nickname
);
733 mre
.setEnabled(enabled
);
743 * enables/disables nested composite. <br>
745 * @param ctrl - Composite to be en-/disabeld
746 * @param enabled - boolean
748 public static void recursiveSetEnabled(Control ctrl
, boolean enabled
) {
749 if (ctrl
instanceof Composite
) {
750 Composite comp
= (Composite
) ctrl
;
751 for (Control c
: comp
.getChildren()) {
752 recursiveSetEnabled(c
, enabled
);
755 ctrl
.setEnabled(enabled
);
761 * getSortRanksNaturally
766 public static boolean getSortNodesNaturally() {
767 return getPreferenceStore().getBoolean(SORT_NODES_NATURALLY
);
772 * setSortRanksNaturally
778 public static void setSortNodesNaturally(boolean selection
) {
779 getPreferenceStore().setValue(SORT_NODES_NATURALLY
, selection
);
785 * getSortRanksNaturally
790 public static boolean getSortNodesStrictlyAlphabetically() {
791 return getPreferenceStore().getBoolean(SORT_NODES_ALPHABETICALLY
);
796 * setSortRanksNaturally
802 public static void setSortNodesStrictlyAlphabetically(boolean selection
) {
803 getPreferenceStore().setValue(SORT_NODES_ALPHABETICALLY
, selection
);
808 * setStoreNavigatorState
814 public static boolean isStoreNavigatorState() {
815 return getPreferenceStore().getBoolean(RESTORE_NAVIGATOR_STATE
);
821 * setStoreNavigatorState
827 public static void setStoreNavigatorState(boolean selection
) {
828 getPreferenceStore().setValue(RESTORE_NAVIGATOR_STATE
, selection
);
835 public static boolean isShowUpWidgetIsDisposedMessages() {
836 return getPreferenceStore().getBoolean(IS_SHOW_UP_WIDGET_IS_DISPOSED
);
838 public static void setShowUpWidgetIsDisposedMessages(boolean selection
) {
839 getPreferenceStore().setValue(IS_SHOW_UP_WIDGET_IS_DISPOSED
, selection
);
845 public static boolean isShowIdInVocabularyInChecklistEditor() {
846 return getPreferenceStore().getBoolean(IPreferenceKeys
.CHECKLIST_ID_IN_VOCABULARY
);
848 public static void setShowIdInVocabularyInChecklistEditor(boolean selection
) {
849 getPreferenceStore().setValue(CHECKLIST_ID_IN_VOCABULARY
, selection
);
855 public static boolean isShowRankInChecklistEditor() {
856 return getPreferenceStore().getBoolean(IPreferenceKeys
.CHECKLIST_SHOW_RANK
);
858 public static void setShowRankInChecklistEditor(boolean selection
) {
859 getPreferenceStore().setValue(CHECKLIST_SHOW_RANK
, selection
);