<?eclipse version="3.2"?>
<plugin>
<extension-point id="eu.etaxonomy.taxeditor.store.cdmViewer" name="Cdm Viewer" schema="schema/eu.etaxonomy.taxeditor.store.cdmViewer.exsd"/>
- <extension
- point="org.eclipse.ui.preferencePages">
- <page
- class="eu.etaxonomy.taxeditor.preference.TaxonomicEditorGeneralPreferences"
- id="eu.etaxonomy.taxeditor.preferences.general"
- name="%page.name">
- </page>
- <!-- <page
- category="eu.etaxonomy.taxeditor.preferences.admin"
- class="eu.etaxonomy.taxeditor.preference.AdminGeneralPreferences"
- id="eu.etaxonomy.taxeditor.preferences.adminGeneral"
- name="%page.name.38">
- </page>
- <page
- category="eu.etaxonomy.taxeditor.preferences.admin"
- class="eu.etaxonomy.taxeditor.databasePreferences.AdminNomenclaturalCode"
- id="eu.etaxonomy.taxeditor.preferences.adminNomenclaturalCode"
- name="%page.name.39">
- </page>-->
- <page
- category="eu.etaxonomy.taxeditor.preferences.general"
- class="eu.etaxonomy.taxeditor.preference.NameDetailsViewConfiguration"
- id="eu.etaxonomy.taxeditor.preferences.nameDetails"
- name="%page.name.36">
- </page>
- <page
- category="eu.etaxonomy.taxeditor.preferences.general"
- class="eu.etaxonomy.taxeditor.preference.DescriptionPreferences"
- id="eu.etaxonomy.taxeditor.preferences.description"
- name="%page.name.0">
- </page>
- <page
- category="eu.etaxonomy.taxeditor.preferences.description"
- class="eu.etaxonomy.taxeditor.preference.menu.FeatureMenuPreferences"
- id="eu.etaxonomy.taxeditor.preferences.feature"
- name="%page.name.1">
- </page>
- <page
- category="eu.etaxonomy.taxeditor.preferences.description"
- class="eu.etaxonomy.taxeditor.preference.menu.PresenceAbsenceMenuPreferences"
- id="eu.etaxonomy.taxeditor.preferences.distributionStatus"
- name="%page.name.2">
- </page>
- <page
- category="eu.etaxonomy.taxeditor.preferences.general"
- class="eu.etaxonomy.taxeditor.preference.TaxonomicPreferences"
- id="eu.etaxonomy.taxeditor.preferences.taxonomic"
- name="%page.name.3">
- </page>
- <page
- category="eu.etaxonomy.taxeditor.preferences.taxonomic"
- class="eu.etaxonomy.taxeditor.preference.menu.NomenclaturalCodePreferences"
- id="eu.etaxonomy.taxeditor.preferences.nomenclatural"
- name="%page.name.4">
- </page>
-
- <!--page
- class="eu.etaxonomy.taxeditor.store.preference.CdmPreferences"
- id="eu.etaxonomy.taxeditor.preferences.cdm"
- name="CDM Datastore">
- </page>
- <page
- category="eu.etaxonomy.taxeditor.preferences.cdm"
- class="eu.etaxonomy.taxeditor.store.preference.InitializeDbPreferences"
- id="eu.etaxonomy.taxeditor.preferences.initdb"
- name="Initialize Datastore">
- </page-->
- <page
- category="eu.etaxonomy.taxeditor.preferences.taxonomic"
- class="eu.etaxonomy.taxeditor.preference.menu.RankMenuPreferences"
- id="eu.etaxonomy.taxeditor.preferences.ranks"
- name="%page.name.5">
- </page>
- <page
- category="eu.etaxonomy.taxeditor.preferences.taxonomic"
- class="eu.etaxonomy.taxeditor.preference.menu.NomenclaturalStatusTypeMenuPreferences"
- id="eu.etaxonomy.taxeditor.preferences.nomenclaturalStatusType"
- name="%page.name.6">
- </page>
- <page
- category="eu.etaxonomy.taxeditor.preferences.taxonomic"
- class="eu.etaxonomy.taxeditor.preference.menu.NameRelationshipTypeMenuPreferences"
- id="eu.etaxonomy.taxeditor.preferences.nameRelationshipType"
- name="%page.name.7">
- </page>
- <page
- category="eu.etaxonomy.taxeditor.preferences.taxonomic"
- class="eu.etaxonomy.taxeditor.preference.menu.TaxonRelationshipTypeMenuPreferences"
- id="taxeditor-store.page1"
- name="%page.name.8">
- </page>
- <page
- category="eu.etaxonomy.taxeditor.preferences.taxonomic"
- class="eu.etaxonomy.taxeditor.preference.menu.SpecimenTypeDesignationStatusMenuPreferences"
- id="eu.etaxonomy.taxeditor.preferences.specimenTypeDesignationStatus"
- name="%page.name.9">
- </page>
- <page
- category="eu.etaxonomy.taxeditor.preferences.taxonomic"
- class="eu.etaxonomy.taxeditor.preference.menu.NameTypeDesignationStatusMenuPreferences"
- id="eu.etaxonomy.taxeditor.preferences.nameTypeDesignationStatus"
- name="%page.name.13">
- </page>
- <page
- category="eu.etaxonomy.taxeditor.preferences.language"
- class="eu.etaxonomy.taxeditor.preference.menu.LanguageMenuPreferences"
- id="eu.etaxonomy.taxeditor.preferences.languages"
- name="%page.name.10">
- </page>
- <page
- category="eu.etaxonomy.taxeditor.preferences.general"
- class="eu.etaxonomy.taxeditor.preference.menu.MarkerTypeMenuPreferences"
- id="eu.etaxonomy.taxeditor.preferences.markerTypes"
- name="%page.name.11">
- </page>
- <page
- category="eu.etaxonomy.taxeditor.preferences.general"
- class="eu.etaxonomy.taxeditor.preference.menu.ExtensionTypeMenuPreferences"
- id="eu.etaxonomy.taxeditor.preferences.extensionTypes"
- name="%page.name.12">
- </page>
- <page
- category="eu.etaxonomy.taxeditor.preferences.description"
- class="eu.etaxonomy.taxeditor.preference.menu.NamedAreaTypeMenuPreferences"
- id="eu.etaxonomy.taxeditor.preferences.namedAreaType"
- name="%page.name.14">
- </page>
- <page
- category="eu.etaxonomy.taxeditor.preferences.general"
- class="eu.etaxonomy.taxeditor.preference.MatchingPreferences"
- id="eu.etaxonomy.taxeditor.preferences.matching"
- name="%page.name.15">
- </page>
- <page
- category="eu.etaxonomy.taxeditor.preferences.matching"
- class="eu.etaxonomy.taxeditor.preference.matching.NonViralNameMatchingPreference"
- id="eu.etaxonomy.taxeditor.preferences.matching.nonViralName"
- name="%page.name.16">
- </page>
- <page
- category="eu.etaxonomy.taxeditor.preferences.matching"
- class="eu.etaxonomy.taxeditor.preference.matching.ReferenceMatchingPreference"
- id="eu.etaxonomy.taxeditor.preferences.matching"
- name="%page.name.17">
- </page>
- <page
- category="eu.etaxonomy.taxeditor.preferences.matching"
- class="eu.etaxonomy.taxeditor.preference.matching.TeamOrPersonMatchingPreference"
- id="eu.etaxonomy.taxeditor.preferences.matching"
- name="%page.name.18">
- </page>
- <page
- category="eu.etaxonomy.taxeditor.preferences.description"
- class="eu.etaxonomy.taxeditor.preference.menu.StageMenuPreferences"
- id="eu.etaxonomy.taxeditor.preferences.stage"
- name="%page.name.19">
- </page>
- <page
- category="eu.etaxonomy.taxeditor.preferences.description"
- class="eu.etaxonomy.taxeditor.preference.menu.PreservationMethodMenuPreferences"
- id="eu.etaxonomy.taxeditor.preferences.preservationMethod"
- name="%page.name.20">
- </page>
- <page
- category="eu.etaxonomy.taxeditor.preferences.feature"
- class="eu.etaxonomy.taxeditor.preference.DefaultFeatureTreePreferenecs"
- id="eu.etaxonomy.taxeditor.preferences.defaultFeatureTreePreferenecs"
- name="%page.name.22">
- </page>
- <page
- category="eu.etaxonomy.taxeditor.preference.defaultlanguagepditorpreferencePage"
- class="eu.etaxonomy.taxeditor.preference.LanguageRepresentationPreferencePage"
- id="eu.etaxonomy.taxeditor.preferences.language"
- name="%page.name.23">
- </page>
- <page
- category="eu.etaxonomy.taxeditor.preferences.general"
- class="eu.etaxonomy.taxeditor.preference.MobotOpenUrlPreferences"
- id="eu.etaxonomy.taxeditor.preferences.mobotOpenUrl"
- name="%page.name.24">
- </page>
- <page
- category="eu.etaxonomy.taxeditor.preferences.general"
- class="eu.etaxonomy.taxeditor.preference.TypeDesignationPreferences"
- id="eu.etaxonomy.taxeditor.preferences.typeDesignation"
- name="%page.name.25">
- </page>
- <page
- category="eu.etaxonomy.taxeditor.preferences.general"
- class="eu.etaxonomy.taxeditor.preference.SpecimenOrObservationPreferences"
- id="eu.etaxonomy.taxeditor.preference.SpecimenOrObservationPreferences"
- name="%page.name.26">
- </page>
- <page
- category="eu.etaxonomy.taxeditor.preferences.general"
- class="eu.etaxonomy.taxeditor.preference.MediaPreferences"
- id="eu.etaxonomy.taxeditor.preference.MediaPreferences"
- name="%page.name.27">
- </page>
- <page
- category="eu.etaxonomy.taxeditor.preferences.general"
- class="eu.etaxonomy.taxeditor.preference.ChecklistEditorGeneralPreference"
- id="eu.etaxonomy.taxeditor.preference.ChecklistEditorGeneralPreferencePage"
- name="%page.name.28">
- </page>
- <!-- <page
- category="eu.etaxonomy.taxeditor.preferences.general"
- class="eu.etaxonomy.taxeditor.preference.TemplatePreferencePage"
- id="eu.etaxonomy.taxeditor.preference.TemplatePreferencePage"
- name="%page.name.29">
- </page>-->
- <page
- category="eu.etaxonomy.taxeditor.preferences.general"
- class="eu.etaxonomy.taxeditor.preference.LanguageEditorPreferencePage"
- id="eu.etaxonomy.taxeditor.preference.defaultlanguagepditorpreferencePage"
- name="%page.name.30">
- </page>
- <page
- category="eu.etaxonomy.taxeditor.preferences.general"
- class="eu.etaxonomy.taxeditor.preference.OrderPreferences"
- id="eu.etaxonomy.taxeditor.preference.TaxonNavigator"
- name="%page.name.32">
- </page>
- <page
- category="eu.etaxonomy.taxeditor.preferences.general"
- class="eu.etaxonomy.taxeditor.preference.DebugPreferences"
- id="eu.etaxonomy.taxeditor.preferences.debug"
- name="%page.name.34">
- </page>
- </extension>
<extension
point="org.eclipse.ui.menus">
<menuContribution
uri="fragment.e4xmi">
</fragment>
</extension>
+<extension
+ point="eu.etaxonomy.taxeditor.workbench.e4PreferencePages">
+ <page
+ category="eu.etaxonomy.taxeditor.preferences.general"
+ class="eu.etaxonomy.taxeditor.preference.DebugPreferences"
+ id="eu.etaxonomy.taxeditor.preference.DebugPreferences"
+ name="%page.name.34">
+ </page>
+ <page
+ class="eu.etaxonomy.taxeditor.preference.TaxonomicEditorGeneralPreferences"
+ id="eu.etaxonomy.taxeditor.preferences.general"
+ name="%page.name">
+ </page>
+ <page
+ category="eu.etaxonomy.taxeditor.preferences.general"
+ class="eu.etaxonomy.taxeditor.preference.NameDetailsViewConfiguration"
+ id="eu.etaxonomy.taxeditor.preferences.nameDetails"
+ name="%page.name.36">
+ </page>
+ <page
+ category="eu.etaxonomy.taxeditor.preferences.general"
+ class="eu.etaxonomy.taxeditor.preference.DescriptionPreferences"
+ id="eu.etaxonomy.taxeditor.preferences.description"
+ name="%page.name.0">
+ </page>
+ <page
+ category="eu.etaxonomy.taxeditor.preferences.description"
+ class="eu.etaxonomy.taxeditor.preference.menu.FeatureMenuPreferences"
+ id="eu.etaxonomy.taxeditor.preferences.feature"
+ name="%page.name.1">
+ </page>
+ <page
+ category="eu.etaxonomy.taxeditor.preferences.description"
+ class="eu.etaxonomy.taxeditor.preference.menu.PresenceAbsenceMenuPreferences"
+ id="eu.etaxonomy.taxeditor.preferences.distributionStatus"
+ name="%page.name.2">
+ </page>
+ <page
+ category="eu.etaxonomy.taxeditor.preferences.general"
+ class="eu.etaxonomy.taxeditor.preference.TaxonomicPreferences"
+ id="eu.etaxonomy.taxeditor.preferences.taxonomic"
+ name="%page.name.3">
+ </page>
+ <page
+ category="eu.etaxonomy.taxeditor.preferences.taxonomic"
+ class="eu.etaxonomy.taxeditor.preference.menu.NomenclaturalCodePreferences"
+ id="eu.etaxonomy.taxeditor.preferences.nomenclatural"
+ name="%page.name.4">
+ </page>
+ <page
+ category="eu.etaxonomy.taxeditor.preferences.taxonomic"
+ class="eu.etaxonomy.taxeditor.preference.menu.RankMenuPreferences"
+ id="eu.etaxonomy.taxeditor.preferences.ranks"
+ name="%page.name.5">
+ </page>
+ <page
+ category="eu.etaxonomy.taxeditor.preferences.taxonomic"
+ class="eu.etaxonomy.taxeditor.preference.menu.NomenclaturalStatusTypeMenuPreferences"
+ id="eu.etaxonomy.taxeditor.preferences.nomenclaturalStatusType"
+ name="%page.name.6">
+ </page>
+ <page
+ category="eu.etaxonomy.taxeditor.preferences.taxonomic"
+ class="eu.etaxonomy.taxeditor.preference.menu.NameRelationshipTypeMenuPreferences"
+ id="eu.etaxonomy.taxeditor.preferences.nameRelationshipType"
+ name="%page.name.7">
+ </page>
+ <page
+ category="eu.etaxonomy.taxeditor.preferences.taxonomic"
+ class="eu.etaxonomy.taxeditor.preference.menu.TaxonRelationshipTypeMenuPreferences"
+ id="taxeditor-store.page1"
+ name="%page.name.8">
+ </page>
+ <page
+ category="eu.etaxonomy.taxeditor.preferences.taxonomic"
+ class="eu.etaxonomy.taxeditor.preference.menu.SpecimenTypeDesignationStatusMenuPreferences"
+ id="eu.etaxonomy.taxeditor.preferences.specimenTypeDesignationStatus"
+ name="%page.name.9">
+ </page>
+ <page
+ category="eu.etaxonomy.taxeditor.preferences.taxonomic"
+ class="eu.etaxonomy.taxeditor.preference.menu.NameTypeDesignationStatusMenuPreferences"
+ id="eu.etaxonomy.taxeditor.preferences.nameTypeDesignationStatus"
+ name="%page.name.13">
+ </page>
+ <page
+ category="eu.etaxonomy.taxeditor.preferences.language"
+ class="eu.etaxonomy.taxeditor.preference.menu.LanguageMenuPreferences"
+ id="eu.etaxonomy.taxeditor.preferences.languages"
+ name="%page.name.10">
+ </page>
+ <page
+ category="eu.etaxonomy.taxeditor.preferences.general"
+ class="eu.etaxonomy.taxeditor.preference.menu.MarkerTypeMenuPreferences"
+ id="eu.etaxonomy.taxeditor.preferences.markerTypes"
+ name="%page.name.11">
+ </page>
+ <page
+ category="eu.etaxonomy.taxeditor.preferences.general"
+ class="eu.etaxonomy.taxeditor.preference.menu.ExtensionTypeMenuPreferences"
+ id="eu.etaxonomy.taxeditor.preferences.extensionTypes"
+ name="%page.name.12">
+ </page>
+ <page
+ category="eu.etaxonomy.taxeditor.preferences.description"
+ class="eu.etaxonomy.taxeditor.preference.menu.NamedAreaTypeMenuPreferences"
+ id="eu.etaxonomy.taxeditor.preferences.namedAreaType"
+ name="%page.name.14">
+ </page>
+ <page
+ category="eu.etaxonomy.taxeditor.preferences.general"
+ class="eu.etaxonomy.taxeditor.preference.MatchingPreferences"
+ id="eu.etaxonomy.taxeditor.preferences.matching"
+ name="%page.name.15">
+ </page>
+ <page
+ category="eu.etaxonomy.taxeditor.preferences.matching"
+ class="eu.etaxonomy.taxeditor.preference.matching.NonViralNameMatchingPreference"
+ id="eu.etaxonomy.taxeditor.preferences.matching.nonViralName"
+ name="%page.name.16">
+ </page>
+ <page
+ category="eu.etaxonomy.taxeditor.preferences.matching"
+ class="eu.etaxonomy.taxeditor.preference.matching.ReferenceMatchingPreference"
+ id="eu.etaxonomy.taxeditor.preferences.matching"
+ name="%page.name.17">
+ </page>
+ <page
+ category="eu.etaxonomy.taxeditor.preferences.matching"
+ class="eu.etaxonomy.taxeditor.preference.matching.TeamOrPersonMatchingPreference"
+ id="eu.etaxonomy.taxeditor.preferences.matching"
+ name="%page.name.18">
+ </page>
+ <page
+ category="eu.etaxonomy.taxeditor.preferences.description"
+ class="eu.etaxonomy.taxeditor.preference.menu.StageMenuPreferences"
+ id="eu.etaxonomy.taxeditor.preferences.stage"
+ name="%page.name.19">
+ </page>
+ <page
+ category="eu.etaxonomy.taxeditor.preferences.description"
+ class="eu.etaxonomy.taxeditor.preference.menu.PreservationMethodMenuPreferences"
+ id="eu.etaxonomy.taxeditor.preferences.preservationMethod"
+ name="%page.name.20">
+ </page>
+ <page
+ category="eu.etaxonomy.taxeditor.preferences.feature"
+ class="eu.etaxonomy.taxeditor.preference.DefaultFeatureTreePreferenecs"
+ id="eu.etaxonomy.taxeditor.preferences.defaultFeatureTreePreferenecs"
+ name="%page.name.22">
+ </page>
+ <page
+ category="eu.etaxonomy.taxeditor.preference.defaultlanguagepditorpreferencePage"
+ class="eu.etaxonomy.taxeditor.preference.LanguageRepresentationPreferencePage"
+ id="eu.etaxonomy.taxeditor.preferences.language"
+ name="%page.name.23">
+ </page>
+ <page
+ category="eu.etaxonomy.taxeditor.preferences.general"
+ class="eu.etaxonomy.taxeditor.preference.MobotOpenUrlPreferences"
+ id="eu.etaxonomy.taxeditor.preferences.mobotOpenUrl"
+ name="%page.name.24">
+ </page>
+ <page
+ category="eu.etaxonomy.taxeditor.preferences.general"
+ class="eu.etaxonomy.taxeditor.preference.TypeDesignationPreferences"
+ id="eu.etaxonomy.taxeditor.preferences.typeDesignation"
+ name="%page.name.25">
+ </page>
+ <page
+ category="eu.etaxonomy.taxeditor.preferences.general"
+ class="eu.etaxonomy.taxeditor.preference.SpecimenOrObservationPreferences"
+ id="eu.etaxonomy.taxeditor.preference.SpecimenOrObservationPreferences"
+ name="%page.name.26">
+ </page>
+ <page
+ category="eu.etaxonomy.taxeditor.preferences.general"
+ class="eu.etaxonomy.taxeditor.preference.MediaPreferences"
+ id="eu.etaxonomy.taxeditor.preference.MediaPreferences"
+ name="%page.name.27">
+ </page>
+ <page
+ category="eu.etaxonomy.taxeditor.preferences.general"
+ class="eu.etaxonomy.taxeditor.preference.ChecklistEditorGeneralPreference"
+ id="eu.etaxonomy.taxeditor.preference.ChecklistEditorGeneralPreferencePage"
+ name="%page.name.28">
+ </page>
+ <page
+ category="eu.etaxonomy.taxeditor.preferences.general"
+ class="eu.etaxonomy.taxeditor.preference.LanguageEditorPreferencePage"
+ id="eu.etaxonomy.taxeditor.preference.defaultlanguagepditorpreferencePage"
+ name="%page.name.30">
+ </page>
+ <page
+ category="eu.etaxonomy.taxeditor.preferences.general"
+ class="eu.etaxonomy.taxeditor.preference.OrderPreferences"
+ id="eu.etaxonomy.taxeditor.preference.TaxonNavigator"
+ name="%page.name.32">
+ </page>
+</extension>
</plugin>
+++ /dev/null
-/**
-* Copyright (C) 2007 EDIT
-* European Distributed Institute of Taxonomy
-* http://www.e-taxonomy.eu
-*
-* The contents of this file are subject to the Mozilla Public License Version 1.1
-* See LICENSE.TXT at the top of this package for the full license terms.
-*/
-
-package eu.etaxonomy.taxeditor.preference;
-
-import org.eclipse.jface.preference.PreferencePage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPreferencePage;
-
-/**
- * <p>CdmPreferences class.</p>
- *
- * @author p.ciardelli
- * @created 20.05.2008
- * @version 1.0
- */
-public class CdmPreferences extends PreferencePage implements
- IWorkbenchPreferencePage {
-
- /** Constant <code>PLUGIN_ID="eu.etaxonomy.taxeditor.preferences.cdm"</code> */
- public static final String PLUGIN_ID = "eu.etaxonomy.taxeditor.preferences.cdm";
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
- */
- /** {@inheritDoc} */
- @Override
- protected Control createContents(Composite parent) {
-
- Composite container = new Composite(parent, SWT.NULL);
- container.setLayout(new GridLayout());
-
- //
- return container;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
- */
- /** {@inheritDoc} */
- public void init(IWorkbench workbench) {
-
- }
-}
import java.util.List;
+import javax.annotation.PostConstruct;
+
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.ListViewer;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPreferencePage;
import eu.etaxonomy.cdm.api.service.IFeatureTreeService;
import eu.etaxonomy.cdm.model.description.FeatureTree;
* @created Sep 16, 2010
* @version 1.0
*/
-public class DefaultFeatureTreePreferenecs extends CdmPreferencePage implements IWorkbenchPreferencePage {
+public class DefaultFeatureTreePreferenecs extends CdmPreferencePage {
private FeatureTree defaultFeatureTreeForTextualDescription;
private FeatureTree defaultFeatureTreeForStructuredDescription;
*/
/** {@inheritDoc} */
@Override
+ @PostConstruct
protected Control createContents(Composite parent) {
defaultFeatureTreeForTextualDescription = PreferencesUtil.getDefaultFeatureTreeForTextualDescription();
defaultFeatureTreeForStructuredDescription = PreferencesUtil.getDefaultFeatureTreeForStructuredDescription();
createTextTreeSelection(composite);
createStructureTreeSelection(composite);
}
-
+ init();
return composite;
}
}
/** {@inheritDoc} */
- @Override
- public void init(IWorkbench workbench) {
+ public void init() {
setPreferenceStore(PreferencesUtil.getPreferenceStore());
}
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
+
+import javax.inject.Inject;
import org.eclipse.jface.preference.ComboFieldEditor;
import org.eclipse.jface.preference.FieldEditorPreferencePage;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPreferencePage;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import eu.etaxonomy.cdm.model.common.CdmBase;
import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
import eu.etaxonomy.cdm.strategy.match.IMatchStrategy;
import eu.etaxonomy.cdm.strategy.match.MatchException;
* @created Jan 22, 2010
* @version 1.0
*/
-public abstract class AbstractMatchingPreferences<T extends IdentifiableEntity> extends FieldEditorPreferencePage implements
- IWorkbenchPreferencePage {
+public abstract class AbstractMatchingPreferences<T extends IdentifiableEntity> extends FieldEditorPreferencePage {
/**
* Fields that will be excluded from the display
private static final String ExcludePattern = "serialVersionUID|logger|allFields|ajc.*|id|updated|updatedBy|created|createdBy|uuid" +
"|parsingProblem|problemStarts|problemEnds|PROTECTED|NOT_PROTECTED|propertyChangeSupport";
- protected IMatchStrategy matchStrategy;
-
protected Class<T> clazz;
private List<MatchMode> matchModeList;
- protected Map<String, Combo> matchModeCombos = new HashMap<String, Combo>();
-
+ @Inject
@Override
- public void init(IWorkbench workbench) {
+ protected Control createContents(Composite parent) {
+ Control contents = super.createContents(parent);
setPreferenceStore(PreferencesUtil.getPreferenceStore());
+ return contents;
}
/**
return matchModeList;
}
+ public abstract Class<? extends CdmBase> getType();
+
/**
* Get names of all declared fields
*
private List<String> getFieldNames(){
List<Field> fields = new ArrayList<Field>();
- fields = getAllFields(fields, clazz);
+ fields = getAllFields(fields, getType());
List<String> fieldNames = new ArrayList<String>();
for(Field field : fields){
package eu.etaxonomy.taxeditor.preference.matching;
-import org.eclipse.ui.IWorkbench;
-
-import eu.etaxonomy.cdm.model.name.INonViralName;
+import eu.etaxonomy.cdm.model.common.CdmBase;
import eu.etaxonomy.cdm.model.name.TaxonName;
import eu.etaxonomy.cdm.strategy.match.IMatchStrategy;
import eu.etaxonomy.cdm.strategy.match.MatchException;
import eu.etaxonomy.cdm.strategy.match.MatchStrategyConfigurator;
-import eu.etaxonomy.taxeditor.model.MessagingUtils;
/**
* <p>NonViralNameMatchingPreference class.</p>
*/
public class NonViralNameMatchingPreference extends AbstractMatchingPreferences<TaxonName>{
- /** {@inheritDoc} */
- @Override
- public void init(IWorkbench workbench) {
- super.init(workbench);
- clazz = TaxonName.class;
-
- try {
- matchStrategy = MatchStrategyConfigurator.NonViralNameMatchStrategy();
- } catch (MatchException e) {
- MessagingUtils.error(this.getClass(), e);
- throw new RuntimeException(e);
- }
- }
+ @Override
+ public Class<? extends CdmBase> getType(){
+ return TaxonName.class;
+ }
/** {@inheritDoc} */
@Override
package eu.etaxonomy.taxeditor.preference.matching;
-import org.eclipse.ui.IWorkbench;
-
+import eu.etaxonomy.cdm.model.common.CdmBase;
import eu.etaxonomy.cdm.model.reference.Reference;
import eu.etaxonomy.cdm.strategy.match.IMatchStrategy;
import eu.etaxonomy.cdm.strategy.match.MatchException;
import eu.etaxonomy.cdm.strategy.match.MatchStrategyConfigurator;
-import eu.etaxonomy.taxeditor.model.MessagingUtils;
/**
* @author n.hoffmann
*/
public class ReferenceMatchingPreference extends AbstractMatchingPreferences<Reference> {
- /** {@inheritDoc} */
- @Override
- public void init(IWorkbench workbench) {
- super.init(workbench);
- clazz = Reference.class;
- try {
- matchStrategy = MatchStrategyConfigurator.ReferenceMatchStrategy();
- } catch (MatchException e) {
- MessagingUtils.error(this.getClass(), e);
- throw new RuntimeException(e);
- }
- }
+ @Override
+ public Class<? extends CdmBase> getType(){
+ return Reference.class;
+ }
/** {@inheritDoc} */
@Override
package eu.etaxonomy.taxeditor.preference.matching;
-import org.eclipse.ui.IWorkbench;
-
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
+import eu.etaxonomy.cdm.model.common.CdmBase;
import eu.etaxonomy.cdm.strategy.match.IMatchStrategy;
import eu.etaxonomy.cdm.strategy.match.MatchException;
import eu.etaxonomy.cdm.strategy.match.MatchStrategyConfigurator;
-import eu.etaxonomy.taxeditor.model.MessagingUtils;
/**
* @author n.hoffmann
public class TeamOrPersonMatchingPreference extends
AbstractMatchingPreferences<TeamOrPersonBase> {
- /** {@inheritDoc} */
- @Override
- public void init(IWorkbench workbench) {
- super.init(workbench);
- clazz = TeamOrPersonBase.class;
- try {
- matchStrategy = MatchStrategyConfigurator.TeamOrPersonMatchStrategy();
- } catch (MatchException e) {
- MessagingUtils.error(this.getClass(), e);
- throw new RuntimeException(e);
- }
- }
+ @Override
+ public Class<? extends CdmBase> getType(){
+ return TeamOrPersonBase.class;
+ }
/** {@inheritDoc} */
@Override
import java.util.HashMap;
import java.util.List;
+import javax.annotation.PostConstruct;
+
import org.eclipse.core.commands.Command;
import org.eclipse.core.commands.IParameter;
import org.eclipse.core.commands.Parameterization;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPreferencePage;
import org.eclipse.ui.commands.ICommandService;
import org.eclipse.ui.handlers.IHandlerService;
* @created 12.06.2009
* @version 1.0
*/
-public abstract class AbstractMenuPreferences<T extends DefinedTermBase> extends CdmPreferencePage implements
- IWorkbenchPreferencePage, IConversationEnabled{
+public abstract class AbstractMenuPreferences<T extends DefinedTermBase> extends CdmPreferencePage implements IConversationEnabled{
private Button toggleButton;
protected HashMap<DefinedTermBase<T>, Button> menuButtons;
* Create contents of the preference page
*/
@Override
+ @PostConstruct
public Control createContents(Composite parent) {
Composite container = new Composite(parent, SWT.NULL);
createAdditionalContent(container);
+ init();
+
return container;
}
tableViewer.setCheckedElements(preferedTerms.toArray());
}
- protected void createAdditionalContent(Composite container) {
+ protected void createAdditionalContent(@SuppressWarnings("unused") Composite container) {
// implement where needed
}
}
/** {@inheritDoc} */
- @Override
- public void init(IWorkbench workbench) {
+ public void init() {
setPreferenceStore(PreferencesUtil.getPreferenceStore());
if(!CdmStore.isActive()) {
MessagingUtils.noDataSourceWarningDialog(null);
private boolean checkNoneChecked(){
- if(tableViewer.getCheckedElements().length == 0){
+ if(tableViewer.getTable().getItems().length>0
+ && tableViewer.getCheckedElements().length == 0){
setMessage("Please check at least one item", WARNING);
return true;
}else{
package eu.etaxonomy.taxeditor.preference.menu;
+import javax.annotation.PostConstruct;
+
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.ViewerComparator;
*/
/** {@inheritDoc} */
@Override
+ @PostConstruct
public Control createContents(Composite parent) {
Control control = super.createContents(parent);
package eu.etaxonomy.taxeditor.preference.menu;
+import javax.annotation.PostConstruct;
+
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
*/
/** {@inheritDoc} */
@Override
+ @PostConstruct
public Control createContents(Composite parent) {
Control container = super.createContents(parent);
getTableViewer().setLabelProvider(new NameRelationLabelProvider());
* <p>Constructor for NomenclaturalStatusTypeMenuPreferences.</p>
*/
public NomenclaturalStatusTypeMenuPreferences() {
- super("Nomenlcatural Status Type Preferences",
+ super("Nomenclatural Status Type Preferences",
"Configure nomenclatural status types",
false);
}
package eu.etaxonomy.taxeditor.preference.menu;
-import org.eclipse.ui.IWorkbenchPreferencePage;
-
import eu.etaxonomy.cdm.model.common.TermType;
import eu.etaxonomy.cdm.model.description.PresenceAbsenceTerm;
* @created 25.06.2009
* @version 1.0
*/
-public class PresenceAbsenceMenuPreferences extends AbstractMenuPreferences<PresenceAbsenceTerm> implements
- IWorkbenchPreferencePage {
+public class PresenceAbsenceMenuPreferences extends AbstractMenuPreferences<PresenceAbsenceTerm> {
/**
* <p>Constructor for PresenceAbsenceMenuPreferences.</p>
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.IWorkbenchPreferencePage;
import eu.etaxonomy.cdm.model.common.TermType;
import eu.etaxonomy.cdm.model.name.Rank;
* @created 17.09.2008
* @version 1.0
*/
-public class RankMenuPreferences extends AbstractMenuPreferences<Rank> implements
- IWorkbenchPreferencePage {
+public class RankMenuPreferences extends AbstractMenuPreferences<Rank> {
/** Constant <code>PLUGIN_ID="eu.etaxonomy.taxeditor.preferences.rank"{trunked}</code> */
public static final String PLUGIN_ID = "eu.etaxonomy.taxeditor.preferences.ranks";
Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: Workbench Bundle
Bundle-SymbolicName: eu.etaxonomy.taxeditor.workbench;singleton:=true
+Export-Package: com.opcoach.e4.preferences,
+ com.opcoach.e4.preferences.handlers,
+ eu.etaxonomy.taxeditor.bulkeditor,
+ eu.etaxonomy.taxeditor.workbench,
+ eu.etaxonomy.taxeditor.workbench.part
+Bundle-Name: Workbench Bundle
Bundle-Version: 4.11.0.qualifier
-Bundle-Activator: eu.etaxonomy.taxeditor.workbench.Activator
-Bundle-Vendor: EDIT
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.eclipse.e4.ui.workbench,
org.eclipse.equinox.p2.operations;bundle-version="2.4.200",
org.eclipse.e4.core.di,
org.eclipse.e4.ui.services,
- org.eclipse.e4.core.commands
+ org.eclipse.e4.core.commands,
+ org.eclipse.e4.core.contexts,
+ org.eclipse.e4.core.services
+Bundle-ManifestVersion: 2
+Bundle-Activator: eu.etaxonomy.taxeditor.workbench.Activator
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
-Import-Package: javax.inject;version="1.0.0"
Bundle-ActivationPolicy: lazy
-Export-Package: eu.etaxonomy.taxeditor.bulkeditor,
- eu.etaxonomy.taxeditor.workbench,
- eu.etaxonomy.taxeditor.workbench.part
+Bundle-Vendor: EDIT
+Import-Package: javax.inject;version="1.0.0"
+
plugin.xml,\
OSGI-INF/,\
fragment.e4xmi,\
- OSGI-INF/l10n/bundle.properties
+ OSGI-INF/l10n/bundle.properties,\
+ schema/
<children xsi:type="menu:Menu" xmi:id="_FaGntyQNEeen_7LZsZSNoA" elementId="eu.etaxonomy.taxeditor.workbench.menu.window" label="%menu.label.1" mnemonics="W">
<children xsi:type="menu:Menu" xmi:id="_DH_m0CkKEeeCvszP-_feIA" elementId="eu.etaxonomy.taxeditor.menu.showView" label="Show View" mnemonics="V"/>
<children xsi:type="menu:MenuSeparator" xmi:id="_FaGnuCQNEeen_7LZsZSNoA" elementId="eu.etaxonomy.taxeditor.application.windowMenu.last"/>
- <children xsi:type="menu:HandledMenuItem" xmi:id="_FaGnuSQNEeen_7LZsZSNoA" elementId="org.eclipse.ui.main.menu.window.preferences" label="%command.label.12">
- <command href="../eu.etaxonomy.taxeditor.application/fragment.e4xmi#_l9kXoB7PEeeC-JvycL9ysA"/>
- </children>
+ <children xsi:type="menu:HandledMenuItem" xmi:id="_FaGnuSQNEeen_7LZsZSNoA" elementId="org.eclipse.ui.main.menu.window.preferences" label="%command.label.12" command="_gYnhIKnTEeeTAPHmaMLwQQ"/>
</children>
<children xsi:type="menu:Menu" xmi:id="_FaGnuiQNEeen_7LZsZSNoA" elementId="eu.etaxonomy.taxeditor.workbench.menu.admin" label="%menu.label.4" mnemonics="A">
<children xsi:type="menu:HandledMenuItem" xmi:id="_b4RFsCQsEeeq76l4saMAFQ" elementId="eu.etaxonomy.taxeditor.workbench.menu.admin.dbpreferences" label="%command.label.23" command="_VawPsCQsEeeq76l4saMAFQ">
<elements xsi:type="commands:Command" xmi:id="_hMjgECZsEeer_rabtodzWA" elementId="eu.etaxonomy.taxeditor.command.openPart" commandName="Open Part">
<parameters xmi:id="_hMjgESZsEeer_rabtodzWA" elementId="eu.etaxonomy.taxeditor.workbench.commandparameter.partName" name="partName" optional="false"/>
</elements>
+ <elements xsi:type="commands:Command" xmi:id="_gYnhIKnTEeeTAPHmaMLwQQ" elementId="eu.etaxonomy.taxeditor.workbench.preferences" commandName="%command.label.12"/>
</fragments>
<fragments xsi:type="fragment:StringModelFragment" xmi:id="_WLNcQCQsEeeq76l4saMAFQ" featurename="handlers" parentElementId="org.eclipse.e4.legacy.ide.application">
<elements xsi:type="commands:Handler" xmi:id="_WLNcQSQsEeeq76l4saMAFQ" elementId="eu.etaxonomy.taxeditor.OpenExternalAboutPlatformHandler" contributionURI="bundleclass://eu.etaxonomy.taxeditor.workbench/eu.etaxonomy.taxeditor.workbench.OpenExternalAboutPlatformHandler" command="_UZ2zYCQsEeeq76l4saMAFQ"/>
<elements xsi:type="commands:Handler" xmi:id="_nSIiECUKEeeHw5lTgGMs1Q" elementId="eu.etaxonomy.taxeditor.handler.OpenImportPreferenceHandler" command="_fdEqUCUKEeeHw5lTgGMs1Q"/>
<elements xsi:type="commands:Handler" xmi:id="_2fnUYCZ0EeeQLpuomSmVoQ" elementId="eu.etaxonomy.taxeditor.workbench.OpenPartHandler" contributionURI="bundleclass://eu.etaxonomy.taxeditor.workbench/eu.etaxonomy.taxeditor.workbench.OpenPartHandler" command="_hMjgECZsEeer_rabtodzWA"/>
<elements xsi:type="commands:Handler" xmi:id="_dBGosFp0Eee4PsIXei-TMg" elementId="eu.etaxonomy.taxeditor.workbench.SaveHandler" contributionURI="bundleclass://eu.etaxonomy.taxeditor.workbench/eu.etaxonomy.taxeditor.workbench.SaveHandler" command="_X-56IFp0Eee4PsIXei-TMg"/>
+ <elements xsi:type="commands:Handler" xmi:id="_zP4pcKnQEeeTAPHmaMLwQQ" elementId="com.opcoach.e4.preferences.handlers.E4PreferencesHandler" contributionURI="bundleclass://eu.etaxonomy.taxeditor.workbench/com.opcoach.e4.preferences.handlers.E4PreferencesHandler" command="_gYnhIKnTEeeTAPHmaMLwQQ"/>
</fragments>
<fragments xsi:type="fragment:StringModelFragment" xmi:id="_Z4f0kFsaEeebk7BsM35KOg" featurename="children" parentElementId="org.eclipse.ui.contexts.dialogAndWindow">
<elements xsi:type="commands:BindingContext" xmi:id="_5pEDMFsaEeebk7BsM35KOg" elementId="eu.etaxonomy.taxeditor.workbench.bindingcontext" name="Taxonomic Editor Keybinding Context"/>
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
+ <extension-point id="e4PreferencePages" name="e4PreferencePages" schema="schema/e4PreferencePages.exsd"/>
+ <extension-point id="e4PreferenceStoreProvider" name="e4PreferenceStoreProvider" schema="schema/e4PreferenceStoreProvider.exsd"/>
<extension
id="eu.etaxonomy.taxeditor.workbench.workbench.model"
name="Taxonomic Editor Application Model"
--- /dev/null
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="com.opcoach.e4.preferences" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appinfo>
+ <meta.schema plugin="com.opcoach.e4.preferences" id="e4PreferencePages" name="e4PreferencePages"/>
+ </appinfo>
+ <documentation>
+ [Enter description of this extension point.]
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appinfo>
+ <meta.element />
+ </appinfo>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="page" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+ a fully qualified identifier of the target extension point
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+ an optional identifier of the extension instance
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+ an optional name of the extension instance
+ </documentation>
+ <appinfo>
+ <meta.attribute translatable="true"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="page">
+ <annotation>
+ <appinfo>
+ <meta.element labelAttribute="name"/>
+ </appinfo>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="keywordReference" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+ a unique name that will be used to identify this page.
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string" use="required">
+ <annotation>
+ <documentation>
+ a translatable name that will be used in the UI for this page.
+ </documentation>
+ <appinfo>
+ <meta.attribute translatable="true"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+ a name of the fully qualified class that implements
+<samp>org.eclipse.jface.preference.IPreferencePage</samp>.
+
+IT IS EASYER to extend FieldEditorPreferencePage
+
+If this class extends directly org.eclipse.jface.preference.FieldEditorPreferencePage preferenceStore is automatically set on it.
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="java" basedOn="org.eclipse.jface.preference.FieldEditorPreferencePage:"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ <attribute name="category" type="string">
+ <annotation>
+ <documentation>
+ a path indicating the location of the page in the preference tree. The path may either be a parent node ID or a sequence
+ of IDs separated by '/', representing the full path from the root node.
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="identifier" basedOn="com.opcoach.e4.preferences.e4PreferencePages/page/@id"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="keywordReference">
+ <annotation>
+ <documentation>
+ A reference by a preference page to a keyword. See the keywords extension point.
+ </documentation>
+ </annotation>
+ <complexType>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+ The id of the keyword being referred to.
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="identifier" basedOn="org.eclipse.ui.keywords/keyword/@id"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="since"/>
+ </appinfo>
+ <documentation>
+ [Enter the first release in which this extension point appears.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="examples"/>
+ </appinfo>
+ <documentation>
+ [Enter extension point usage example here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="apiinfo"/>
+ </appinfo>
+ <documentation>
+ [Enter API information here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="implementation"/>
+ </appinfo>
+ <documentation>
+ [Enter information about supplied implementation of this extension point.]
+ </documentation>
+ </annotation>
+
+
+</schema>
--- /dev/null
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="com.opcoach.e4.preferences" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appinfo>
+ <meta.schema plugin="com.opcoach.e4.preferences" id="e4PreferenceStoreProvider" name="e4PreferenceStoreProvider"/>
+ </appinfo>
+ <documentation>
+ This extension point is used to associate a preference store to a plugin.
+You can choose either to implement the IPreferenceStoreProvider interface or to give the ID of the IPreferenceStore to use (stored in the workbench context of your E4 application).
+If this extension point is not used, a default ScopedPreferenceStore will be used for the preference page.
+
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appinfo>
+ <meta.element />
+ </appinfo>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="preferenceStoreProvider" minOccurs="1" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute translatable="true"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="preferenceStoreProvider">
+ <complexType>
+ <attribute name="pluginId" type="string" use="required">
+ <annotation>
+ <documentation>
+ Set here the plugin Id concerned by this extension.
+Must be a valid plugin ID (control will be done at runtime)
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="class" type="string">
+ <annotation>
+ <documentation>
+ Set a class to get the IPreferenceStore for the defined pluginID.
+This parameter is optional if you use the contextId attribute.
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="java" basedOn=":com.opcoach.e4.preferences.IPreferenceStoreProvider"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ <attribute name="idInWorkbenchContext" type="string">
+ <annotation>
+ <documentation>
+ If no class is defined, you can set here the ID of the IPreferenceStore available in the context.
+This object must be set in the workbenchContext using an Addon for instance, with the following code (in addon):
+
+@PostContextCreate
+public void initMyAddon(IEclipseContext ctx)
+{
+ IPreferenceStore ps = new ... . // The code to create your pref store
+ ctx.set(ID set in this extension, ps);
+}
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="since"/>
+ </appinfo>
+ <documentation>
+ [Enter the first release in which this extension point appears.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="examples"/>
+ </appinfo>
+ <documentation>
+ The definition could be like the following :
+
+pluginId="yourPluginID"
+provider="a class implementing IPreferenceStoreProvider"
+
+
+Or using the key in context (usefull to share the same preference store between plugins) :
+
+pluginId="yourPluginID"
+keyInContext="the key of the IPreferenceStore stored in context"
+
+
+
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="apiinfo"/>
+ </appinfo>
+ <documentation>
+ [Enter API information here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="implementation"/>
+ </appinfo>
+ <documentation>
+ [Enter information about supplied implementation of this extension point.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="copyright"/>
+ </appinfo>
+ <documentation>
+ @OPCoach 2014
+ </documentation>
+ </annotation>
+
+</schema>
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2014 OPCoach.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * OPCoach - initial API and implementation
+ *******************************************************************************/
+package com.opcoach.e4.preferences;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.inject.Inject;
+
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.eclipse.e4.core.contexts.ContextInjectionFactory;
+import org.eclipse.e4.core.contexts.IEclipseContext;
+import org.eclipse.e4.core.di.annotations.Creatable;
+import org.eclipse.e4.core.services.contributions.IContributionFactory;
+import org.eclipse.e4.core.services.log.Logger;
+import org.eclipse.jface.preference.IPreferenceNode;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferenceManager;
+import org.eclipse.jface.preference.PreferenceNode;
+import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+
+@Creatable
+public class E4PreferenceRegistry
+{
+
+ public static final String PREFS_PAGE_XP = "eu.etaxonomy.taxeditor.workbench.e4PreferencePages"; // $NON-NLS-1$
+ public static final String PREF_STORE_PROVIDER = "eu.etaxonomy.taxeditor.workbench.e4PreferenceStoreProvider"; // $NON-NLS-1$
+ protected static final String ELMT_PAGE = "page"; // $NON-NLS-1$
+ protected static final String ATTR_ID = "id"; // $NON-NLS-1$
+ protected static final String ATTR_CATEGORY = "category"; // $NON-NLS-1$
+ protected static final String ATTR_CLASS = "class"; // $NON-NLS-1$
+ protected static final String ATTR_NAME = "name"; // $NON-NLS-1$
+
+ protected static final String ATTR_PLUGIN_ID = "pluginId"; // $NON-NLS-1$
+ protected static final String ATTR_ID_IN_WBCONTEXT = "idInWorkbenchContext"; // $NON-NLS-1$
+
+ @Inject
+ protected Logger logger;
+
+ @Inject
+ protected IEclipseContext context;
+
+ @Inject
+ protected IExtensionRegistry registry;
+
+ private PreferenceManager pm = null;
+
+ // A map of (pluginId, { IPreferenceStoreProvider, or key in wbcontext }
+ private Map<String, Object> psProviders;
+
+ public PreferenceManager getPreferenceManager()
+ {
+
+ // Remember of the unbounded nodes to order parent pages.
+ // Map<category, list of children> (all nodes except root nodes)
+ Map<String, Collection<IPreferenceNode>> childrenNodes = new HashMap<String, Collection<IPreferenceNode>>();
+
+ if (pm != null) {
+ return pm;
+ }
+
+ pm = new PreferenceManager();
+ IContributionFactory factory = context.get(IContributionFactory.class);
+
+ for (IConfigurationElement elmt : registry.getConfigurationElementsFor(PREFS_PAGE_XP))
+ {
+ String bundleId = elmt.getNamespaceIdentifier();
+ if (!elmt.getName().equals(ELMT_PAGE))
+ {
+ logger.warn("unexpected element: {0}", elmt.getName());
+ continue;
+ } else if (isEmpty(elmt.getAttribute(ATTR_ID)) || isEmpty(elmt.getAttribute(ATTR_NAME)))
+ {
+ logger.warn("missing id and/or name: {}", bundleId);
+ continue;
+ }
+ PreferenceNode pn = null;
+ if (elmt.getAttribute(ATTR_CLASS) != null)
+ {
+ PreferencePage page = null;
+ try
+ {
+ String prefPageURI = getClassURI(bundleId, elmt.getAttribute(ATTR_CLASS));
+ Object object = factory.create(prefPageURI, context);
+ if (!(object instanceof PreferencePage))
+ {
+ logger.error("Expected instance of PreferencePage: {0}", elmt.getAttribute(ATTR_CLASS));
+ continue;
+ }
+ page = (PreferencePage) object;
+ setPreferenceStore(bundleId, page);
+
+ } catch (ClassNotFoundException e)
+ {
+ logger.error(e);
+ continue;
+ }
+ ContextInjectionFactory.inject(page, context);
+ if ((page.getTitle() == null || page.getTitle().isEmpty()) && elmt.getAttribute(ATTR_NAME) != null)
+ {
+ page.setTitle(elmt.getAttribute(ATTR_NAME));
+ }
+
+ pn = new PreferenceNode(elmt.getAttribute(ATTR_ID), page);
+ } else
+ {
+ pn = new PreferenceNode(elmt.getAttribute(ATTR_ID), new EmptyPreferencePage(elmt.getAttribute(ATTR_NAME)));
+ }
+
+ // Issue 2 : Fix bug on order (see :
+ // https://github.com/opcoach/e4Preferences/issues/2)
+ // Add only pages at root level and remember of child pages for
+ // categories
+ String category = elmt.getAttribute(ATTR_CATEGORY);
+ if (isEmpty(category))
+ {
+ pm.addToRoot(pn);
+ } else
+ {
+ /*
+ * IPreferenceNode parent = findNode(pm, category); if (parent
+ * == null) { // No parent found, but may be the extension has
+ * not been read yet. So remember of it unboundedNodes.put(pn,
+ * category); } else { parent.add(pn); }
+ */
+ // Check if this category is already registered.
+ Collection<IPreferenceNode> children = childrenNodes.get(category);
+ if (children == null)
+ {
+ children = new ArrayList<IPreferenceNode>();
+ childrenNodes.put(category, children);
+ }
+ children.add(pn);
+ }
+ }
+
+ // Must now bind pages that has not been added in nodes (depends on the
+ // preference page read order)
+ // Iterate on all possible categories
+ Collection<String> categoriesDone = new ArrayList<String>();
+
+ while (!childrenNodes.isEmpty())
+ {
+ for (String cat : Collections.unmodifiableSet(childrenNodes.keySet()))
+ {
+ // Is this category already in preference manager ? If not add
+ // it later...
+ IPreferenceNode parent = findNode(pm, cat);
+ if (parent != null)
+ {
+ // Can add the list of children to this parent page...
+ for (IPreferenceNode pn : childrenNodes.get(cat))
+ {
+ parent.add(pn);
+ }
+ // Ok This parent page is done. Can remove it from map
+ // outside of this loop
+ categoriesDone.add(cat);
+ }
+ }
+
+ for (String keyToRemove : categoriesDone) {
+ childrenNodes.remove(keyToRemove);
+ }
+ categoriesDone.clear();
+
+ }
+
+ return pm;
+ }
+
+ private void setPreferenceStore(String bundleId, PreferencePage page)
+ {
+ // Affect preference store to this page if this is a
+ // PreferencePage, else, must manage it internally
+ // Set the issue#1 on github :
+ // https://github.com/opcoach/e4Preferences/issues/1
+ // And manage the extensions of IP
+ initialisePreferenceStoreProviders();
+
+ IPreferenceStore store = null;
+
+ // Get the preference store according to policy.
+ Object data = psProviders.get(bundleId);
+ if (data != null)
+ {
+ if (data instanceof IPreferenceStore) {
+ store = (IPreferenceStore) data;
+ } else if (data instanceof IPreferenceStoreProvider) {
+ store = ((IPreferenceStoreProvider) data).getPreferenceStore();
+ } else if (data instanceof String) {
+ store = (IPreferenceStore) context.get((String) data);
+ }
+
+ } else
+ {
+ // Default behavior : create a preference store for this bundle and remember of it
+ store = new ScopedPreferenceStore(InstanceScope.INSTANCE, bundleId);
+ psProviders.put(bundleId, store);
+ }
+
+
+ if (store != null) {
+ page.setPreferenceStore(store);
+ } else
+ {
+ logger.warn("Unable to set the preferenceStore for page " + page.getTitle() + " defined in bundle " + bundleId);
+ }
+
+ }
+
+ /** Read the e4PreferenceStoreProvider extension point */
+ private void initialisePreferenceStoreProviders()
+ {
+ if (psProviders == null)
+ {
+ IContributionFactory factory = context.get(IContributionFactory.class);
+
+ psProviders = new HashMap<String, Object>();
+
+ // Read extensions and fill the map...
+ for (IConfigurationElement elmt : registry.getConfigurationElementsFor(PREF_STORE_PROVIDER))
+ {
+ String declaringBundle = elmt.getNamespaceIdentifier();
+ String pluginId = elmt.getAttribute(ATTR_PLUGIN_ID);
+ if (isEmpty(pluginId))
+ {
+ logger.warn("missing plugin Id in extension " + PREF_STORE_PROVIDER + " check the plugin " + declaringBundle);
+ continue;
+ }
+
+ String classname = elmt.getAttribute(ATTR_CLASS);
+ String objectId = elmt.getAttribute(ATTR_ID_IN_WBCONTEXT);
+
+ if ((isEmpty(classname) && isEmpty(objectId)) || (((classname != null) && classname.length() > 0) && ((objectId != null) && objectId.length() > 0)))
+ {
+ logger.warn("In extension " + PREF_STORE_PROVIDER + " only one of the two attributes (pluginId or idInWorkbenchContext) must be set. Check the plugin "
+ + declaringBundle);
+ continue;
+ }
+
+ // Ok can now work with data...
+ Object data = objectId;
+ if (classname != null)
+ {
+ data = factory.create(classname, context);
+ if (!(data instanceof IPreferenceStoreProvider))
+ {
+ logger.warn("In extension " + PREF_STORE_PROVIDER + " the class must implements IPreferenceStoreProvider. Check the plugin " + declaringBundle);
+ continue;
+ }
+ }
+
+ psProviders.put(pluginId, data);
+
+ }
+ }
+ }
+
+ private IPreferenceNode findNode(PreferenceManager pm, String categoryId)
+ {
+ for (Object o : pm.getElements(PreferenceManager.POST_ORDER))
+ {
+ if (o instanceof IPreferenceNode && ((IPreferenceNode) o).getId().equals(categoryId))
+ {
+ return (IPreferenceNode) o;
+ }
+ }
+ return null;
+ }
+
+ private String getClassURI(String definingBundleId, String spec) throws ClassNotFoundException
+ {
+ if (spec.startsWith("platform:"))
+ {
+ return spec;
+ } // $NON-NLS-1$
+ return "bundleclass://" + definingBundleId + '/' + spec;
+ }
+
+ private boolean isEmpty(String value)
+ {
+ return value == null || value.trim().isEmpty();
+ }
+
+ static class EmptyPreferencePage extends PreferencePage
+ {
+
+ public EmptyPreferencePage(String title)
+ {
+ setTitle(title);
+ noDefaultAndApplyButton();
+ }
+
+ @Override
+ protected Control createContents(Composite parent)
+ {
+ return new Label(parent, SWT.NONE);
+ }
+
+ }
+
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2014 OPCoach.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * OPCoach - initial API and implementation
+ *******************************************************************************/
+package com.opcoach.e4.preferences;
+
+import org.eclipse.jface.preference.IPreferenceStore;
+
+/** This interface can be implemented to provide a PreferenceStore for a given plugin.
+ * This associatino must be done in the e4PreferenceStoreProvider extension point.
+ * @author olivier
+ *
+ */
+public interface IPreferenceStoreProvider
+{
+ /** Must be implemented to return a preference store */
+ public IPreferenceStore getPreferenceStore();
+
+}
--- /dev/null
+
+/*******************************************************************************
+ * Copyright (c) 2014 OPCoach.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eclipse - copy of the implementation coming from jface
+ *******************************************************************************/
+
+package com.opcoach.e4.preferences;
+
+import java.io.IOException;
+
+import org.eclipse.core.commands.common.EventManager;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Plugin;
+import org.eclipse.core.runtime.SafeRunner;
+import org.eclipse.core.runtime.preferences.DefaultScope;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.core.runtime.preferences.IScopeContext;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences.INodeChangeListener;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences.NodeChangeEvent;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent;
+import org.eclipse.jface.preference.IPersistentPreferenceStore;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.jface.util.SafeRunnable;
+import org.osgi.service.prefs.BackingStoreException;
+
+/**
+ * The ScopedPreferenceStore is an IPreferenceStore that uses the scopes
+ * provided in org.eclipse.core.runtime.preferences.
+ * <p>
+ * A ScopedPreferenceStore does the lookup of a preference based on it's search
+ * scopes and sets the value of the preference based on its store scope.
+ * </p>
+ * <p>
+ * The default scope is always included in the search scopes when searching for
+ * preference values.
+ * </p>
+ *
+ * @see org.eclipse.core.runtime.preferences
+ * @since 3.1
+ */
+public class ScopedPreferenceStore extends EventManager implements
+ IPreferenceStore, IPersistentPreferenceStore {
+
+ /**
+ * The storeContext is the context where values will stored with the
+ * setValue methods. If there are no searchContexts this will be the search
+ * context. (along with the "default" context)
+ */
+ private IScopeContext storeContext;
+
+ /**
+ * The searchContext is the array of contexts that will be used by the get
+ * methods for searching for values.
+ */
+ private IScopeContext[] searchContexts;
+
+ /**
+ * A boolean to indicate the property changes should not be propagated.
+ */
+ protected boolean silentRunning = false;
+
+ /**
+ * The listener on the IEclipsePreferences. This is used to forward updates
+ * to the property change listeners on the preference store.
+ */
+ IEclipsePreferences.IPreferenceChangeListener preferencesListener;
+
+ /**
+ * The default context is the context where getDefault and setDefault
+ * methods will search. This context is also used in the search.
+ */
+ private IScopeContext defaultContext = new DefaultScope();
+
+ /**
+ * The nodeQualifer is the string used to look up the node in the contexts.
+ */
+ String nodeQualifier;
+
+ /**
+ * The defaultQualifier is the string used to look up the default node.
+ */
+ String defaultQualifier;
+
+ /**
+ * Boolean value indicating whether or not this store has changes to be
+ * saved.
+ */
+ private boolean dirty;
+
+ /**
+ * Create a new instance of the receiver. Store the values in context in the
+ * node looked up by qualifier. <strong>NOTE:</strong> Any instance of
+ * ScopedPreferenceStore should call
+ *
+ * @param context
+ * the scope to store to
+ * @param qualifier
+ * the qualifier used to look up the preference node
+ * @param defaultQualifierPath
+ * the qualifier used when looking up the defaults
+ */
+ public ScopedPreferenceStore(IScopeContext context, String qualifier,
+ String defaultQualifierPath) {
+ this(context, qualifier);
+ this.defaultQualifier = defaultQualifierPath;
+ }
+
+ /**
+ * Create a new instance of the receiver. Store the values in context in the
+ * node looked up by qualifier.
+ *
+ * @param context
+ * the scope to store to
+ * @param qualifier
+ * the qualifer used to look up the preference node
+ */
+ public ScopedPreferenceStore(IScopeContext context, String qualifier) {
+ storeContext = context;
+ this.nodeQualifier = qualifier;
+ this.defaultQualifier = qualifier;
+
+ ((IEclipsePreferences) getStorePreferences().parent())
+ .addNodeChangeListener(getNodeChangeListener());
+ }
+
+ /**
+ * Return a node change listener that adds a removes the receiver when nodes
+ * change.
+ *
+ * @return INodeChangeListener
+ */
+ private INodeChangeListener getNodeChangeListener() {
+ return new IEclipsePreferences.INodeChangeListener() {
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.core.runtime.preferences.IEclipsePreferences.INodeChangeListener#added(org.eclipse.core.runtime.preferences.IEclipsePreferences.NodeChangeEvent)
+ */
+ public void added(NodeChangeEvent event) {
+ if (nodeQualifier.equals(event.getChild().name())
+ && isListenerAttached()) {
+ getStorePreferences().addPreferenceChangeListener(
+ preferencesListener);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.core.runtime.preferences.IEclipsePreferences.INodeChangeListener#removed(org.eclipse.core.runtime.preferences.IEclipsePreferences.NodeChangeEvent)
+ */
+ public void removed(NodeChangeEvent event) {
+ // Do nothing as there are no events from removed node
+ }
+ };
+ }
+
+ /**
+ * Initialize the preferences listener.
+ */
+ private void initializePreferencesListener() {
+ if (preferencesListener == null) {
+ preferencesListener = new IEclipsePreferences.IPreferenceChangeListener() {
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener#preferenceChange(org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent)
+ */
+ public void preferenceChange(PreferenceChangeEvent event) {
+
+ if (silentRunning) {
+ return;
+ }
+
+ Object oldValue = event.getOldValue();
+ Object newValue = event.getNewValue();
+ String key = event.getKey();
+ if (newValue == null) {
+ newValue = getDefault(key, oldValue);
+ } else if (oldValue == null) {
+ oldValue = getDefault(key, newValue);
+ }
+ firePropertyChangeEvent(event.getKey(), oldValue, newValue);
+ }
+ };
+ getStorePreferences().addPreferenceChangeListener(
+ preferencesListener);
+ }
+
+ }
+
+ /**
+ * Does its best at determining the default value for the given key. Checks
+ * the given object's type and then looks in the list of defaults to see if
+ * a value exists. If not or if there is a problem converting the value, the
+ * default default value for that type is returned.
+ *
+ * @param key
+ * the key to search
+ * @param obj
+ * the object who default we are looking for
+ * @return Object or <code>null</code>
+ */
+ Object getDefault(String key, Object obj) {
+ IEclipsePreferences defaults = getDefaultPreferences();
+ if (obj instanceof String) {
+ return defaults.get(key, STRING_DEFAULT_DEFAULT);
+ } else if (obj instanceof Integer) {
+ return new Integer(defaults.getInt(key, INT_DEFAULT_DEFAULT));
+ } else if (obj instanceof Double) {
+ return new Double(defaults.getDouble(key, DOUBLE_DEFAULT_DEFAULT));
+ } else if (obj instanceof Float) {
+ return new Float(defaults.getFloat(key, FLOAT_DEFAULT_DEFAULT));
+ } else if (obj instanceof Long) {
+ return new Long(defaults.getLong(key, LONG_DEFAULT_DEFAULT));
+ } else if (obj instanceof Boolean) {
+ return defaults.getBoolean(key, BOOLEAN_DEFAULT_DEFAULT) ? Boolean.TRUE
+ : Boolean.FALSE;
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Return the IEclipsePreferences node associated with this store.
+ *
+ * @return the preference node for this store
+ */
+ IEclipsePreferences getStorePreferences() {
+ return storeContext.getNode(nodeQualifier);
+ }
+
+ /**
+ * Return the default IEclipsePreferences for this store.
+ *
+ * @return this store's default preference node
+ */
+ private IEclipsePreferences getDefaultPreferences() {
+ return defaultContext.getNode(defaultQualifier);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.preference.IPreferenceStore#addPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener)
+ */
+ public void addPropertyChangeListener(IPropertyChangeListener listener) {
+ initializePreferencesListener();// Create the preferences listener if it
+ // does not exist
+ addListenerObject(listener);
+ }
+
+ /**
+ * Return the preference path to search preferences on. This is the list of
+ * preference nodes based on the scope contexts for this store. If there are
+ * no search contexts set, then return this store's context.
+ * <p>
+ * Whether or not the default context should be included in the resulting
+ * list is specified by the <code>includeDefault</code> parameter.
+ * </p>
+ *
+ * @param includeDefault
+ * <code>true</code> if the default context should be included
+ * and <code>false</code> otherwise
+ * @return IEclipsePreferences[]
+ * @since 3.4 public, was added in 3.1 as private method
+ */
+ public IEclipsePreferences[] getPreferenceNodes(boolean includeDefault) {
+ // if the user didn't specify a search order, then return the scope that
+ // this store was created on. (and optionally the default)
+ if (searchContexts == null) {
+ if (includeDefault) {
+ return new IEclipsePreferences[] { getStorePreferences(),
+ getDefaultPreferences() };
+ }
+ return new IEclipsePreferences[] { getStorePreferences() };
+ }
+ // otherwise the user specified a search order so return the appropriate
+ // nodes based on it
+ int length = searchContexts.length;
+ if (includeDefault) {
+ length++;
+ }
+ IEclipsePreferences[] preferences = new IEclipsePreferences[length];
+ for (int i = 0; i < searchContexts.length; i++) {
+ preferences[i] = searchContexts[i].getNode(nodeQualifier);
+ }
+ if (includeDefault) {
+ preferences[length - 1] = getDefaultPreferences();
+ }
+ return preferences;
+ }
+
+ /**
+ * Set the search contexts to scopes. When searching for a value the seach
+ * will be done in the order of scope contexts and will not search the
+ * storeContext unless it is in this list.
+ * <p>
+ * If the given list is <code>null</code>, then clear this store's search
+ * contexts. This means that only this store's scope context and default
+ * scope will be used during preference value searching.
+ * </p>
+ * <p>
+ * The defaultContext will be added to the end of this list automatically
+ * and <em>MUST NOT</em> be included by the user.
+ * </p>
+ *
+ * @param scopes
+ * a list of scope contexts to use when searching, or
+ * <code>null</code>
+ */
+ public void setSearchContexts(IScopeContext[] scopes) {
+ this.searchContexts = scopes;
+ if (scopes == null) {
+ return;
+ }
+
+ // Assert that the default was not included (we automatically add it to
+ // the end)
+ for (int i = 0; i < scopes.length; i++) {
+ if (scopes[i].equals(defaultContext)) {
+ Assert
+ .isTrue(
+ false,
+ "Do not add the default to the search contexts");
+ }
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.preference.IPreferenceStore#contains(java.lang.String)
+ */
+ public boolean contains(String name) {
+ if (name == null) {
+ return false;
+ }
+ return (Platform.getPreferencesService().get(name, null,
+ getPreferenceNodes(true))) != null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.preference.IPreferenceStore#firePropertyChangeEvent(java.lang.String,
+ * java.lang.Object, java.lang.Object)
+ */
+ public void firePropertyChangeEvent(String name, Object oldValue,
+ Object newValue) {
+ // important: create intermediate array to protect against listeners
+ // being added/removed during the notification
+ final Object[] list = getListeners();
+ if (list.length == 0) {
+ return;
+ }
+ final PropertyChangeEvent event = new PropertyChangeEvent(this, name,
+ oldValue, newValue);
+ for (int i = 0; i < list.length; i++) {
+ final IPropertyChangeListener listener = (IPropertyChangeListener) list[i];
+ SafeRunner.run(new SafeRunnable(JFaceResources
+ .getString("PreferenceStore.changeError")) { //$NON-NLS-1$
+ public void run() {
+ listener.propertyChange(event);
+ }
+ });
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.preference.IPreferenceStore#getBoolean(java.lang.String)
+ */
+ public boolean getBoolean(String name) {
+ String value = internalGet(name);
+ return value == null ? BOOLEAN_DEFAULT_DEFAULT : Boolean.valueOf(value)
+ .booleanValue();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.preference.IPreferenceStore#getDefaultBoolean(java.lang.String)
+ */
+ public boolean getDefaultBoolean(String name) {
+ return getDefaultPreferences()
+ .getBoolean(name, BOOLEAN_DEFAULT_DEFAULT);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.preference.IPreferenceStore#getDefaultDouble(java.lang.String)
+ */
+ public double getDefaultDouble(String name) {
+ return getDefaultPreferences().getDouble(name, DOUBLE_DEFAULT_DEFAULT);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.preference.IPreferenceStore#getDefaultFloat(java.lang.String)
+ */
+ public float getDefaultFloat(String name) {
+ return getDefaultPreferences().getFloat(name, FLOAT_DEFAULT_DEFAULT);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.preference.IPreferenceStore#getDefaultInt(java.lang.String)
+ */
+ public int getDefaultInt(String name) {
+ return getDefaultPreferences().getInt(name, INT_DEFAULT_DEFAULT);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.preference.IPreferenceStore#getDefaultLong(java.lang.String)
+ */
+ public long getDefaultLong(String name) {
+ return getDefaultPreferences().getLong(name, LONG_DEFAULT_DEFAULT);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.preference.IPreferenceStore#getDefaultString(java.lang.String)
+ */
+ public String getDefaultString(String name) {
+ return getDefaultPreferences().get(name, STRING_DEFAULT_DEFAULT);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.preference.IPreferenceStore#getDouble(java.lang.String)
+ */
+ public double getDouble(String name) {
+ String value = internalGet(name);
+ if (value == null) {
+ return DOUBLE_DEFAULT_DEFAULT;
+ }
+ try {
+ return Double.parseDouble(value);
+ } catch (NumberFormatException e) {
+ return DOUBLE_DEFAULT_DEFAULT;
+ }
+ }
+
+ /**
+ * Return the string value for the specified key. Look in the nodes which
+ * are specified by this object's list of search scopes. If the value does
+ * not exist then return <code>null</code>.
+ *
+ * @param key
+ * the key to search with
+ * @return String or <code>null</code> if the value does not exist.
+ */
+ private String internalGet(String key) {
+ return Platform.getPreferencesService().get(key, null,
+ getPreferenceNodes(true));
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.preference.IPreferenceStore#getFloat(java.lang.String)
+ */
+ public float getFloat(String name) {
+ String value = internalGet(name);
+ if (value == null) {
+ return FLOAT_DEFAULT_DEFAULT;
+ }
+ try {
+ return Float.parseFloat(value);
+ } catch (NumberFormatException e) {
+ return FLOAT_DEFAULT_DEFAULT;
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.preference.IPreferenceStore#getInt(java.lang.String)
+ */
+ public int getInt(String name) {
+ String value = internalGet(name);
+ if (value == null) {
+ return INT_DEFAULT_DEFAULT;
+ }
+ try {
+ return Integer.parseInt(value);
+ } catch (NumberFormatException e) {
+ return INT_DEFAULT_DEFAULT;
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.preference.IPreferenceStore#getLong(java.lang.String)
+ */
+ public long getLong(String name) {
+ String value = internalGet(name);
+ if (value == null) {
+ return LONG_DEFAULT_DEFAULT;
+ }
+ try {
+ return Long.parseLong(value);
+ } catch (NumberFormatException e) {
+ return LONG_DEFAULT_DEFAULT;
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.preference.IPreferenceStore#getString(java.lang.String)
+ */
+ public String getString(String name) {
+ String value = internalGet(name);
+ return value == null ? STRING_DEFAULT_DEFAULT : value;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.preference.IPreferenceStore#isDefault(java.lang.String)
+ */
+ public boolean isDefault(String name) {
+ if (name == null) {
+ return false;
+ }
+ return (Platform.getPreferencesService().get(name, null,
+ getPreferenceNodes(false))) == null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.preference.IPreferenceStore#needsSaving()
+ */
+ public boolean needsSaving() {
+ return dirty;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.preference.IPreferenceStore#putValue(java.lang.String,
+ * java.lang.String)
+ */
+ public void putValue(String name, String value) {
+ try {
+ // Do not notify listeners
+ silentRunning = true;
+ getStorePreferences().put(name, value);
+ } finally {
+ // Be sure that an exception does not stop property updates
+ silentRunning = false;
+ dirty = true;
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.preference.IPreferenceStore#removePropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener)
+ */
+ public void removePropertyChangeListener(IPropertyChangeListener listener) {
+ removeListenerObject(listener);
+ if (!isListenerAttached()) {
+ disposePreferenceStoreListener();
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.preference.IPreferenceStore#setDefault(java.lang.String,
+ * double)
+ */
+ public void setDefault(String name, double value) {
+ getDefaultPreferences().putDouble(name, value);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.preference.IPreferenceStore#setDefault(java.lang.String,
+ * float)
+ */
+ public void setDefault(String name, float value) {
+ getDefaultPreferences().putFloat(name, value);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.preference.IPreferenceStore#setDefault(java.lang.String,
+ * int)
+ */
+ public void setDefault(String name, int value) {
+ getDefaultPreferences().putInt(name, value);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.preference.IPreferenceStore#setDefault(java.lang.String,
+ * long)
+ */
+ public void setDefault(String name, long value) {
+ getDefaultPreferences().putLong(name, value);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.preference.IPreferenceStore#setDefault(java.lang.String,
+ * java.lang.String)
+ */
+ public void setDefault(String name, String defaultObject) {
+ getDefaultPreferences().put(name, defaultObject);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.preference.IPreferenceStore#setDefault(java.lang.String,
+ * boolean)
+ */
+ public void setDefault(String name, boolean value) {
+ getDefaultPreferences().putBoolean(name, value);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.preference.IPreferenceStore#setToDefault(java.lang.String)
+ */
+ public void setToDefault(String name) {
+
+ String oldValue = getString(name);
+ String defaultValue = getDefaultString(name);
+ try {
+ silentRunning = true;// Turn off updates from the store
+ // removing a non-existing preference is a no-op so call the Core
+ // API directly
+ getStorePreferences().remove(name);
+ if (oldValue != defaultValue){
+ dirty = true;
+ firePropertyChangeEvent(name, oldValue, defaultValue);
+ }
+
+ } finally {
+ silentRunning = false;// Restart listening to preferences
+ }
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.preference.IPreferenceStore#setValue(java.lang.String,
+ * double)
+ */
+ public void setValue(String name, double value) {
+ double oldValue = getDouble(name);
+ if (oldValue == value) {
+ return;
+ }
+ try {
+ silentRunning = true;// Turn off updates from the store
+ if (getDefaultDouble(name) == value) {
+ getStorePreferences().remove(name);
+ } else {
+ getStorePreferences().putDouble(name, value);
+ }
+ dirty = true;
+ firePropertyChangeEvent(name, new Double(oldValue), new Double(
+ value));
+ } finally {
+ silentRunning = false;// Restart listening to preferences
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.preference.IPreferenceStore#setValue(java.lang.String,
+ * float)
+ */
+ public void setValue(String name, float value) {
+ float oldValue = getFloat(name);
+ if (oldValue == value) {
+ return;
+ }
+ try {
+ silentRunning = true;// Turn off updates from the store
+ if (getDefaultFloat(name) == value) {
+ getStorePreferences().remove(name);
+ } else {
+ getStorePreferences().putFloat(name, value);
+ }
+ dirty = true;
+ firePropertyChangeEvent(name, new Float(oldValue), new Float(value));
+ } finally {
+ silentRunning = false;// Restart listening to preferences
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.preference.IPreferenceStore#setValue(java.lang.String,
+ * int)
+ */
+ public void setValue(String name, int value) {
+ int oldValue = getInt(name);
+ if (oldValue == value) {
+ return;
+ }
+ try {
+ silentRunning = true;// Turn off updates from the store
+ if (getDefaultInt(name) == value) {
+ getStorePreferences().remove(name);
+ } else {
+ getStorePreferences().putInt(name, value);
+ }
+ dirty = true;
+ firePropertyChangeEvent(name, new Integer(oldValue), new Integer(
+ value));
+ } finally {
+ silentRunning = false;// Restart listening to preferences
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.preference.IPreferenceStore#setValue(java.lang.String,
+ * long)
+ */
+ public void setValue(String name, long value) {
+ long oldValue = getLong(name);
+ if (oldValue == value) {
+ return;
+ }
+ try {
+ silentRunning = true;// Turn off updates from the store
+ if (getDefaultLong(name) == value) {
+ getStorePreferences().remove(name);
+ } else {
+ getStorePreferences().putLong(name, value);
+ }
+ dirty = true;
+ firePropertyChangeEvent(name, new Long(oldValue), new Long(value));
+ } finally {
+ silentRunning = false;// Restart listening to preferences
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.preference.IPreferenceStore#setValue(java.lang.String,
+ * java.lang.String)
+ */
+ public void setValue(String name, String value) {
+ // Do not turn on silent running here as Strings are propagated
+ if (getDefaultString(name).equals(value)) {
+ getStorePreferences().remove(name);
+ } else {
+ getStorePreferences().put(name, value);
+ }
+ dirty = true;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.preference.IPreferenceStore#setValue(java.lang.String,
+ * boolean)
+ */
+ public void setValue(String name, boolean value) {
+ boolean oldValue = getBoolean(name);
+ if (oldValue == value) {
+ return;
+ }
+ try {
+ silentRunning = true;// Turn off updates from the store
+ if (getDefaultBoolean(name) == value) {
+ getStorePreferences().remove(name);
+ } else {
+ getStorePreferences().putBoolean(name, value);
+ }
+ dirty = true;
+ firePropertyChangeEvent(name, oldValue ? Boolean.TRUE
+ : Boolean.FALSE, value ? Boolean.TRUE : Boolean.FALSE);
+ } finally {
+ silentRunning = false;// Restart listening to preferences
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.preference.IPersistentPreferenceStore#save()
+ */
+ public void save() throws IOException {
+ try {
+ getStorePreferences().flush();
+ dirty = false;
+ } catch (BackingStoreException e) {
+ throw new IOException(e.getMessage());
+ }
+
+ }
+
+ /**
+ * Dispose the receiver.
+ */
+ private void disposePreferenceStoreListener() {
+
+ IEclipsePreferences root = (IEclipsePreferences) Platform
+ .getPreferencesService().getRootNode().node(
+ Plugin.PLUGIN_PREFERENCE_SCOPE);
+ try {
+ if (!(root.nodeExists(nodeQualifier))) {
+ return;
+ }
+ } catch (BackingStoreException e) {
+ return;// No need to report here as the node won't have the
+ // listener
+ }
+
+ IEclipsePreferences preferences = getStorePreferences();
+ if (preferences == null) {
+ return;
+ }
+ if (preferencesListener != null) {
+ preferences.removePreferenceChangeListener(preferencesListener);
+ preferencesListener = null;
+ }
+ }
+
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2014 OPCoach.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Manumitting Technologies : Brian de Alwis for initial API and implementation
+ * OPCoach : O.Prouvost fix bugs on hierarchy
+ *******************************************************************************//*
+ * Handler to open up a configured preferences dialog.
+ * Written by Brian de Alwis, Manumitting Technologies.
+ * Placed in the public domain.
+ * This code comes from : http://www.eclipse.org/forums/index.php/fa/4347/
+ * and was referenced in the thread : http://www.eclipse.org/forums/index.php/m/750139/
+ */
+package com.opcoach.e4.preferences.handlers;
+
+import javax.inject.Named;
+
+import org.eclipse.e4.core.di.annotations.CanExecute;
+import org.eclipse.e4.core.di.annotations.Execute;
+import org.eclipse.e4.ui.services.IServiceConstants;
+import org.eclipse.jface.preference.PreferenceDialog;
+import org.eclipse.jface.preference.PreferenceManager;
+import org.eclipse.jface.viewers.ViewerComparator;
+import org.eclipse.swt.widgets.Shell;
+
+import com.opcoach.e4.preferences.E4PreferenceRegistry;
+
+
+public class E4PreferencesHandler
+{
+
+
+ @CanExecute
+ public boolean canExecute()
+ {
+ return true;
+ }
+
+ @Execute
+ public void execute(@Named(IServiceConstants.ACTIVE_SHELL) Shell shell, E4PreferenceRegistry prefReg)
+ {
+ PreferenceManager pm = prefReg.getPreferenceManager();
+ PreferenceDialog dialog = new PreferenceDialog(shell, pm);
+ dialog.create();
+ dialog.getTreeViewer().setComparator(new ViewerComparator());
+ dialog.getTreeViewer().expandToLevel(2);
+ dialog.open();
+ }
+
+
+
+
+}