-/**
- * Copyright (C) 2014 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.swt.SWT;
-import org.eclipse.swt.custom.CLabel;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Listener;
-
-import eu.etaxonomy.cdm.model.metadata.CdmPreference;
-import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
-import eu.etaxonomy.cdm.model.metadata.TermDisplayEnum;
-import eu.etaxonomy.cdm.model.metadata.TermOrder;
-import eu.etaxonomy.taxeditor.l10n.Messages;
-import eu.etaxonomy.taxeditor.preference.menu.CdmPreferencePage;
-import eu.etaxonomy.taxeditor.ui.element.CommandHandlerButton;
-
-/**
- * @author a.oppermann
- * @date 21.07.2014
- *
- */
-public class ChecklistEditorGeneralPreference extends CdmPreferencePage implements SelectionListener {
-
-
-
- protected Boolean isEditorActivated;
-
- protected boolean overrideActivated;
- boolean isUseLocal;
- protected Boolean isShowRank;
- protected String orderAreas;
- protected String displayStatus;
- protected String displayArea;
- protected Boolean ownDescriptionForDistributionEditor;
-
- protected boolean overrideOwnDescriptionForDistributionEditor;
- protected boolean overrideAreaVoc;
- protected boolean overrideRank;
- protected boolean overrideOrderAreas;
- protected boolean overrideAreaDisplay;
- protected boolean overrideStatusDisplay;
-
- protected Combo areaOrderSelectionCombo;
- protected Button allowOverrideOrderAreasButton;
- protected Combo statusDisplaySelectionCombo;
- protected Button allowOverrideStatusDisplayButton;
- protected Combo areaDisplaySelectionCombo;
- protected Button allowOverrideAreaDisplayButton;
- protected String commandHandlerString;
- protected String commandHandlerStringStatus;
-
- protected CdmPreference distributionEditorPref;
- protected CdmPreference prefStatus;
- protected CdmPreference prefAreaVoc;
- protected CdmPreference prefAreaDisplay;
- protected CdmPreference prefStatusDisplay;
- protected CdmPreference prefAreaSort;
- protected CdmPreference prefRank;
- protected CdmPreference prefOwnDescription;
- Composite child;
-
- protected Combo activateCombo;
- protected Button allowOverrideActivatedButton;
- final String ENABLE = "Enable";
- final String DISABLE = "Disable";
-
- protected Combo activateRankCombo;
- protected Button allowOverrideRankButton;
- final String SHOW_RANK = "Show Rank";
- final String NO_RANK = "No Rank";
-
- protected CdmPreference areaVocPref = null;
- protected CdmPreference statusPref = null;
- private CommandHandlerButton button_openSelectAreaVocabularies;
-
- private CommandHandlerButton button_openStatusWizard;
-
- @Override
- protected Control createContents(Composite parent) {
- getValues();
- Composite composite = new Composite(parent, SWT.NULL);
- composite.setLayout(new GridLayout());
- if (!isAdminPreference && distributionEditorPref != null && !distributionEditorPref.isAllowOverride()&& !isEditorActivated ) {
- Label label = new Label(composite, SWT.NONE);
- label.setText(
- "The CDM settings don't allow to set the preferences for using the distribution editor locally. If you need to make local settings, please ask an administrator.");
- this.setDefaultButtonActivated(false);
- } else {
- Composite activateComp = createComposite(composite);
- Label separator = new Label(activateComp, SWT.HORIZONTAL | SWT.SEPARATOR);
- GridData sepGrid = createTextGridData();
- separator.setLayoutData(sepGrid);
- separator.setVisible(false);
- CdmPreference dbPref;
- GridData textGrid = createTextGridData();
- textGrid.verticalSpan = 2;
- separator.setLayoutData(sepGrid);
-
- activateCombo = createBooleanCombo(activateComp, ENABLE, DISABLE, PreferencePredicate.DistributionEditorActivated, Messages.ChecklistEditorGeneralPreference_enable, isAdminPreference);
-
- int index = 0;
- for (String itemLabel : activateCombo.getItems()) {
- if (isEditorActivated == null && itemLabel.equals(Messages.Preference_Use_Default)) {
- activateCombo.select(index);
- break;
- }
- if (isEditorActivated != null && itemLabel.equals(ENABLE) && isEditorActivated){
- activateCombo.select(index);
- break;
- }
- if (isEditorActivated != null && itemLabel.equals(DISABLE) && !isEditorActivated){
- activateCombo.select(index);
- break;
- }
- index++;
- }
-
-
- activateCombo.addSelectionListener(this);
- if (isAdminPreference) {
- allowOverrideActivatedButton = createAllowOverrideButton(activateComp);
- allowOverrideActivatedButton.setSelection(this.distributionEditorPref != null? this.distributionEditorPref.isAllowOverride(): true);
- allowOverrideActivatedButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- setApply(true);
- if (distributionEditorPref == null){
- distributionEditorPref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.DistributionEditorActivated, PreferencePredicate.DistributionEditorActivated.getDefaultValue() != null ? PreferencePredicate.DistributionEditorActivated.getDefaultValue().toString(): null);
- }
- distributionEditorPref.setAllowOverride(!distributionEditorPref.isAllowOverride());
- }
- });
- }
- child = createComposite(composite);
-
- if (!isAdminPreference) {
- if (isEditorActivated != null){
- child.setEnabled(isEditorActivated);
- }else{
- child.setEnabled(Boolean.parseBoolean(distributionEditorPref.getValue().toString()));
- }
- }
- separator = new Label(child, SWT.HORIZONTAL | SWT.SEPARATOR);
- sepGrid = createTextGridData();
- separator.setLayoutData(sepGrid);
-
- activateRankCombo = createBooleanCombo(child, SHOW_RANK, NO_RANK,
- PreferencePredicate.ShowRankInDistributionEditor, Messages.ChecklistEditorGeneralPreference_show_rank, isAdminPreference);
- index = 0;
- for (String itemLabel : activateRankCombo.getItems()) {
- if (isShowRank == null && itemLabel.equals(Messages.Preference_Use_Default)) {
- activateRankCombo.select(index);
- break;
- }
- if (isShowRank != null && itemLabel.equals(SHOW_RANK) && isShowRank){
- activateRankCombo.select(index);
- break;
- }
- if (isShowRank != null && itemLabel.equals(NO_RANK) && !isShowRank){
- activateRankCombo.select(index);
- break;
- }
- index++;
- }
- activateRankCombo.addSelectionListener(this);
- if (isAdminPreference) {
- allowOverrideRankButton = createAllowOverrideButton(child);
- allowOverrideRankButton.setSelection(prefRank != null? prefRank.isAllowOverride():true);
- allowOverrideRankButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- setApply(true);
- prefRank.setAllowOverride(allowOverrideRankButton.getSelection());
- }
- });
- }
-
- GridData gridData = new GridData();
- gridData = new GridData(GridData.BEGINNING, GridData.CENTER, true, false);
-
- areaOrderSelectionCombo = createCombo(child, TermOrder.values(), PreferencePredicate.AreasSortedInDistributionEditor, Messages.ChecklistEditorGeneralPreference_Configure_area_order, isAdminPreference);
-
- index = 0;
- TermOrder areaOrder;
- try {
- if (orderAreas != null) {
- areaOrder = TermOrder.valueOf(orderAreas);
- } else {
- areaOrder = TermOrder.IdInVoc;
- }
- } catch (IllegalArgumentException e) {
- areaOrder = TermOrder.IdInVoc;
- }
- for (String itemLabel : areaOrderSelectionCombo.getItems()) {
- if (itemLabel.equals(Messages.Preference_Use_Default) && orderAreas.equals(Messages.Preference_Use_Default)){
- areaOrderSelectionCombo.select(index);
- break;
- }
- if (itemLabel.startsWith(areaOrder.getLabel())) {
- areaOrderSelectionCombo.select(index);
- break;
- }
-
- index++;
- }
-
- areaOrderSelectionCombo.addSelectionListener(this);
-
- if (isAdminPreference) {
- allowOverrideOrderAreasButton = createAllowOverrideButton(child);
- allowOverrideOrderAreasButton.setSelection(prefAreaSort != null? prefAreaSort.isAllowOverride(): true);
- allowOverrideOrderAreasButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- setApply(true);
- prefAreaSort.setAllowOverride(allowOverrideOrderAreasButton.getSelection());
- }
- });
- }
-
- separator = new Label(child, SWT.HORIZONTAL | SWT.SEPARATOR);
- separator.setLayoutData(sepGrid);
- areaDisplaySelectionCombo = createCombo(child, TermDisplayEnum.values(), PreferencePredicate.DisplayOfAreasInDistributionEditor, Messages.ChecklistEditorGeneralPreference_Configure_display_of_Areas, isAdminPreference);
-
-
- index = 0;
- TermDisplayEnum areaDisplay;
- try {
- if (displayArea != null) {
- areaDisplay = TermDisplayEnum.valueOf(displayArea);
- } else {
- areaDisplay = TermDisplayEnum.Title;
- }
- } catch (IllegalArgumentException e) {
- areaDisplay = TermDisplayEnum.Title;
- }
- for (String itemLabel : areaDisplaySelectionCombo.getItems()) {
- if (itemLabel.equals(Messages.Preference_Use_Default) && displayArea.equals(Messages.Preference_Use_Default)){
- areaDisplaySelectionCombo.select(index);
- break;
- }
- if (itemLabel.startsWith(areaDisplay.getLabel())) {
- areaDisplaySelectionCombo.select(index);
- break;
- }
-
- index++;
- }
- areaDisplaySelectionCombo.addSelectionListener(this);
-
- if (isAdminPreference) {
- allowOverrideAreaDisplayButton = createAllowOverrideButton(child);
- allowOverrideAreaDisplayButton.setSelection(prefAreaDisplay != null? prefAreaDisplay.isAllowOverride(): true);
- allowOverrideAreaDisplayButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- setApply(true);
- prefAreaDisplay.setAllowOverride(allowOverrideOrderAreasButton.getSelection());
- }
- });
- }
-
- statusDisplaySelectionCombo = createCombo(child, TermDisplayEnum.values(), PreferencePredicate.DisplayOfStatus, Messages.ChecklistEditorGeneralPreference_Configure_display_of_Status, isAdminPreference);
-
- index = 0;
- TermDisplayEnum statusDisplay;
- try {
- if (displayStatus != null) {
- statusDisplay = TermDisplayEnum.valueOf(displayStatus);
- } else {
- statusDisplay = TermDisplayEnum.Title;
- }
- } catch (IllegalArgumentException e) {
- statusDisplay = TermDisplayEnum.Title;
- }
- for (String itemLabel : statusDisplaySelectionCombo.getItems()) {
- if (itemLabel.equals(Messages.Preference_Use_Default) && displayStatus.equals(Messages.Preference_Use_Default)){
- statusDisplaySelectionCombo.select(index);
- break;
- }
- if (itemLabel.startsWith(statusDisplay.getLabel())) {
- statusDisplaySelectionCombo.select(index);
- break;
- }
-
- index++;
- }
-
- statusDisplaySelectionCombo.addSelectionListener(this);
-
- if (isAdminPreference) {
- allowOverrideStatusDisplayButton = createAllowOverrideButton(child);
- allowOverrideStatusDisplayButton.setSelection(prefStatusDisplay != null ? prefStatusDisplay.isAllowOverride(): true);
- allowOverrideStatusDisplayButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- setApply(true);
- prefStatusDisplay.setAllowOverride(allowOverrideStatusDisplayButton.getSelection());
- }
- });
- }
-
- final CLabel labelStatus = new CLabel(child, SWT.NULL);
- labelStatus.setText(Messages.DistributionAdminPreferences_SELECT_STATUS);
- labelStatus.setLayoutData(textGrid);
-
- button_openStatusWizard = new CommandHandlerButton(child, SWT.PUSH, commandHandlerStringStatus);
-
- button_openStatusWizard.setText(Messages.Distribution_status_selection);
- button_openStatusWizard.addListener(SWT.Selection, new Listener() {
- @Override
- public void handleEvent(Event e) {
- switch (e.type) {
- case SWT.Selection:
- setApply(true);
- break;
- }
- }
- });
-
- final CLabel label = new CLabel(child, SWT.NULL);
- label.setText(Messages.ChecklistEditorGeneralPreference_open_wizard);
- label.setLayoutData(textGrid);
-
- button_openSelectAreaVocabularies = new CommandHandlerButton(child, SWT.PUSH, commandHandlerString);
- button_openSelectAreaVocabularies
- .setText(Messages.ChecklistEditorGeneralPreference_open_distribution_selection);
-
- if (!isAdminPreference) {
-
- //PreferencesUtil.recursiveSetEnabled(child, isEditorActivated);
- if (distributionEditorPref != null && !distributionEditorPref.isAllowOverride()){
- activateComp.setEnabled(false);
- }
-
- if (prefAreaVoc != null && !prefAreaVoc.isAllowOverride()) {
- button_openSelectAreaVocabularies.setButtonEnabled(false);
- }
- if (prefStatus != null && !prefStatus.isAllowOverride()) {
- button_openStatusWizard.setButtonEnabled(false);
- }
- if (prefRank != null && !prefRank.isAllowOverride()) {
- activateRankCombo.setEnabled(false);
- }
- if (prefAreaSort != null && !prefAreaSort.isAllowOverride()) {
- areaOrderSelectionCombo.setEnabled(false);
- //allowOverrideOrderAreasButton.setEnabled(false);
- }
- if (prefAreaDisplay != null && !prefAreaDisplay.isAllowOverride()) {
- areaDisplaySelectionCombo.setEnabled(false);
- }
- if (prefStatusDisplay != null && !prefStatusDisplay.isAllowOverride()) {
- statusDisplaySelectionCombo.setEnabled(false);
- }
- }
-
- }
- setValid(true);
- return composite;
- }
-
- @Override
- public boolean performOk() {
- if (!isApply()){
- return true;
- }
- boolean override = false;
- if (isEditorActivated != null ) {
- override = true;
- PreferencesUtil.setStringValue(PreferencePredicate.DistributionEditorActivated.getKey(), isEditorActivated.toString());
- }
- PreferencesUtil.setBooleanValue(
- PreferencesUtil.prefOverrideKey(PreferencePredicate.DistributionEditorActivated.getKey()),
- override);
-
-
- override = false;
- if (!orderAreas.equals(Messages.Preference_Use_Default) ) {
- override = true;
- PreferencesUtil.setSortNamedAreasInDistributionEditor(orderAreas);
- }
- PreferencesUtil.setBooleanValue(
- PreferencesUtil.prefOverrideKey(PreferencePredicate.AreasSortedInDistributionEditor.getKey()),
- override);
-
-
-
-
-
- override = false;
- if (isShowRank != null ) {
- override = true;
- PreferencesUtil.setShowRankInChecklistEditor(isShowRank);
- }
- PreferencesUtil.setBooleanValue(
- PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowRankInDistributionEditor.getKey()),
- override);
-
-
- override = false;
- if (!displayStatus.equals(Messages.Preference_Use_Default)) {
- override = true;
- PreferencesUtil.setDisplayStatusInChecklistEditor(displayStatus);
- }
- PreferencesUtil.setBooleanValue(
- PreferencesUtil.prefOverrideKey(PreferencePredicate.DisplayOfStatus.getKey()),
- override);
-
-
-
-
- override = false;
- if (!displayArea.equals(Messages.Preference_Use_Default) ) {
- override = true;
- PreferencesUtil.setAreaDisplayInChecklistEditor(displayArea);
- }
- PreferencesUtil.setBooleanValue(PreferencesUtil.prefOverrideKey(
- PreferencePredicate.DisplayOfAreasInDistributionEditor.getKey()), override);
-
-
-
-
- PreferencesUtil.setOwnDescriptionForChecklistEditor(ownDescriptionForDistributionEditor);
- PreferencesUtil.setBooleanValue(
- PreferencesUtil.prefOverrideKey(PreferencePredicate.OwnDescriptionForDistributionEditor.getKey()),
- true);
-
- PreferencesUtil.firePreferencesChanged(this.getClass());
-
- return true;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void widgetSelected(SelectionEvent e) {
- setApply(true);
- if (e.getSource().equals(statusDisplaySelectionCombo)) {
- String text = statusDisplaySelectionCombo.getText();
- if(text.equals(Messages.Preference_Use_Default)){
- displayStatus = Messages.Preference_Use_Default;
- if(isAdminPreference){
- prefStatusDisplay.setAllowOverride(true);
- allowOverrideStatusDisplayButton.setSelection(true);
- }
-
- return;
- }
- for (TermDisplayEnum display : TermDisplayEnum.values()) {
- if (text.startsWith(display.getLabel())) {
- displayStatus = display.getKey();
- break;
- }
-
- }
- }
- if (e.getSource().equals(areaDisplaySelectionCombo)) {
- String text = areaDisplaySelectionCombo.getText();
- if(text.equals(Messages.Preference_Use_Default)){
- displayArea = Messages.Preference_Use_Default;
- if (isAdminPreference){
- prefAreaDisplay.setAllowOverride(true);
- allowOverrideAreaDisplayButton.setSelection(true);
- }
- return;
- }
- for (TermDisplayEnum display : TermDisplayEnum.values()) {
- if (text.startsWith(display.getLabel())) {
- displayArea = display.getKey();
- break;
- }
- }
- }
- if (e.getSource().equals(areaOrderSelectionCombo)) {
- String text = areaOrderSelectionCombo.getText();
- if(text.equals(Messages.Preference_Use_Default)){
- orderAreas = Messages.Preference_Use_Default;
- if (isAdminPreference){
- prefAreaSort.setAllowOverride(true);
- allowOverrideOrderAreasButton.setSelection(true);
- }
- return;
- }
- for (TermOrder display : TermOrder.values()) {
- if (text.startsWith(display.getLabel())) {
- orderAreas = display.getKey();
- break;
- }
- }
- }
- if (e.getSource().equals(this.activateRankCombo)) {
- String text = activateRankCombo.getText();
- if(text.equals(Messages.Preference_Use_Default)){
- isShowRank = null;
- if (isAdminPreference){
- prefRank.setAllowOverride(true);
- allowOverrideRankButton.setSelection(true);
- }
- return;
- }
- if (text.equals(SHOW_RANK)){
- isShowRank = true;
- }else{
- isShowRank = false;
- }
- }
-
- if (e.getSource().equals(this.activateCombo)) {
- String text = activateCombo.getText();
- if(text.equals(Messages.Preference_Use_Default)){
- isEditorActivated = null;
- if (isAdminPreference){
- if (distributionEditorPref == null){
- distributionEditorPref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.DistributionEditorActivated, PreferencePredicate.DistributionEditorActivated.getDefaultValue() != null ? PreferencePredicate.DistributionEditorActivated.getDefaultValue().toString(): null);
- }
- distributionEditorPref.setAllowOverride(true);
- allowOverrideActivatedButton.setSelection(true);
- }
- return;
- }
- if (text.equals(ENABLE)){
- isEditorActivated = true;
- }else{
- isEditorActivated = false;
- }
-
- }
- //PreferencesUtil.recursiveSetEnabled(child, isEditorActivated);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void widgetDefaultSelected(SelectionEvent e) {
- // TODO Auto-generated method stub
-
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void getValues() {
- isAdminPreference = false;
- setPreferenceStore(PreferencesUtil.getPreferenceStore());
- distributionEditorPref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.DistributionEditorActivated);
- overrideActivated = PreferencesUtil.getBooleanValue(
- PreferencesUtil.prefOverrideKey(PreferencePredicate.DistributionEditorActivated.getKey()), true);
-
- if (distributionEditorPref != null) {
- if (distributionEditorPref.isAllowOverride() ) {
- if (overrideActivated){
- isEditorActivated = PreferencesUtil.getBooleanValue(PreferencePredicate.DistributionEditorActivated.getKey(), true);
- }
-
- } else {
- isEditorActivated = Boolean.valueOf(distributionEditorPref.getValue());
-
- }
-
- } else {
- if(!overrideActivated){
- isEditorActivated = null;
- }else{
- isEditorActivated = PreferencesUtil.getBooleanValue(PreferencePredicate.DistributionEditorActivated.getKey(), true);
- }
- //distributionEditorPref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.DistributionEditorActivated, PreferencePredicate.DistributionEditorActivated.getDefaultValue() != null ? PreferencePredicate.DistributionEditorActivated.getDefaultValue().toString(): null);
- }
-
- prefAreaVoc = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.AvailableDistributionAreaVocabularies);
- if (prefAreaVoc == null){
- prefAreaVoc = CdmPreference.NewTaxEditorInstance(PreferencePredicate.AvailableDistributionAreaVocabularies, PreferencePredicate.AvailableDistributionAreaVocabularies.getDefaultValue() != null ? PreferencePredicate.AvailableDistributionAreaVocabularies.getDefaultValue().toString(): null);
- }
-
-
- prefStatus = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.AvailableDistributionStatus);
- if (prefStatus == null){
- prefStatus = CdmPreference.NewTaxEditorInstance(PreferencePredicate.AvailableDistributionStatus, PreferencePredicate.AvailableDistributionStatus.getDefaultValue() != null ? PreferencePredicate.AvailableDistributionStatus.getDefaultValue().toString(): null);
- }
-
-
- prefAreaDisplay = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.DisplayOfAreasInDistributionEditor);
- overrideAreaDisplay = PreferencesUtil.getBooleanValue(
- PreferencesUtil.prefOverrideKey(PreferencePredicate.DisplayOfAreasInDistributionEditor.getKey()), true);
- if (prefAreaDisplay != null) {
- if (prefAreaDisplay.isAllowOverride()){
- if (overrideActivated) {
- displayArea = PreferencesUtil.displayAreaInChecklistEditor();
- }else{
- displayArea = Messages.Preference_Use_Default;
- }
- } else {
- displayArea = prefAreaDisplay.getValue();
- }
- } else {
- if (overrideAreaDisplay){
- displayArea = PreferencesUtil.displayAreaInChecklistEditor();
- } else{
- displayArea = Messages.Preference_Use_Default;
- }
- //prefAreaDisplay = CdmPreference.NewTaxEditorInstance(PreferencePredicate.DisplayOfAreasInDistributionEditor, PreferencePredicate.DisplayOfAreasInDistributionEditor.getDefaultValue() != null ? PreferencePredicate.DisplayOfAreasInDistributionEditor.getDefaultValue().toString(): null);
- }
-
- prefStatusDisplay = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.DisplayOfStatus);
- overrideStatusDisplay = PreferencesUtil
- .getBooleanValue(PreferencesUtil.prefOverrideKey(PreferencePredicate.DisplayOfStatus.getKey()), true);
- if (prefStatusDisplay != null) {
- if (prefStatusDisplay.isAllowOverride()){
- if (overrideStatusDisplay) {
- displayStatus = PreferencesUtil.displayStatusInChecklistEditor();
- }else{
- displayStatus = Messages.Preference_Use_Default;
- }
- } else {
- this.displayStatus = prefStatusDisplay.getValue();
- }
- } else {
- if (overrideStatusDisplay){
- displayStatus = PreferencesUtil.displayStatusInChecklistEditor();
- } else{
- displayStatus = Messages.Preference_Use_Default;
- }
- //prefStatusDisplay = CdmPreference.NewTaxEditorInstance(PreferencePredicate.DisplayOfStatus, PreferencePredicate.DisplayOfStatus.getDefaultValue() != null ? PreferencePredicate.DisplayOfStatus.getDefaultValue().toString(): null);
- }
-
- prefAreaSort = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.AreasSortedInDistributionEditor);
- overrideOrderAreas = PreferencesUtil.getBooleanValue(
- PreferencesUtil.prefOverrideKey(PreferencePredicate.AreasSortedInDistributionEditor.getKey()), true);
- if (prefAreaSort != null) {
- if (prefAreaSort.isAllowOverride()){
- if(overrideOrderAreas) {
- orderAreas = PreferencesUtil.getSortNamedAreasInDistributionEditor();
- }else{
- orderAreas = Messages.Preference_Use_Default;
- }
- } else {
- if (prefAreaSort.getValue() != null) {
- orderAreas = prefAreaSort.getValue().toString();
- } else {
- orderAreas = ((TermOrder) PreferencePredicate.AreasSortedInDistributionEditor.getDefaultValue())
- .getKey();
- }
-
- }
- } else {
- if (overrideOrderAreas){
- orderAreas = PreferencesUtil.getSortNamedAreasInDistributionEditor();
- }else{
- orderAreas = Messages.Preference_Use_Default;
- }
- //prefAreaSort = CdmPreference.NewTaxEditorInstance(PreferencePredicate.AreasSortedInDistributionEditor, PreferencePredicate.AreasSortedInDistributionEditor.getDefaultValue() != null ? PreferencePredicate.AreasSortedInDistributionEditor.getDefaultValue().toString(): null);
- }
-
- prefRank = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.ShowRankInDistributionEditor);
- overrideRank = PreferencesUtil.getBooleanValue(
- PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowRankInDistributionEditor.getKey()), true);
- if (prefRank != null) {
- if (prefRank.isAllowOverride()){
- if(overrideRank) {
- isShowRank = PreferencesUtil.isShowRankInChecklistEditor();
- }
-
- } else {
- this.isShowRank = Boolean.valueOf(prefRank.getValue().toString());
- }
- } else {
- if (overrideRank){
- isShowRank = PreferencesUtil.isShowRankInChecklistEditor();
- } else {
- isShowRank = null;
- }
-
- //refRank = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowRankInDistributionEditor, PreferencePredicate.ShowRankInDistributionEditor.getDefaultValue() != null ? PreferencePredicate.ShowRankInDistributionEditor.getDefaultValue().toString(): null);
- }
-
- prefOwnDescription = PreferencesUtil
- .getPreferenceFromDB(PreferencePredicate.OwnDescriptionForDistributionEditor);
- if (prefOwnDescription != null) {
- if (prefOwnDescription.isAllowOverride()) {
- ownDescriptionForDistributionEditor = PreferencesUtil.isOwnDescriptionForChecklistEditor();
- } else {
- ownDescriptionForDistributionEditor = Boolean.valueOf(prefOwnDescription.getValue().toString());
- }
- } else {
- ownDescriptionForDistributionEditor = PreferencesUtil.isShowRankInChecklistEditor();
- // allowOverrideOwnDescriptionForDistributionEditor = true;
- overrideOwnDescriptionForDistributionEditor = PreferencesUtil.getBooleanValue(
- PreferencesUtil.prefOverrideKey(PreferencePredicate.OwnDescriptionForDistributionEditor.getKey()), true);
- //prefOwnDescription = CdmPreference.NewTaxEditorInstance(PreferencePredicate.OwnDescriptionForDistributionEditor, PreferencePredicate.OwnDescriptionForDistributionEditor.getDefaultValue() != null ? PreferencePredicate.OwnDescriptionForDistributionEditor.getDefaultValue().toString(): null);
- }
-
- commandHandlerString = "eu.etaxonomy.taxeditor.store.open.OpenDistributionEditorWizardHandler";
- commandHandlerStringStatus = "eu.etaxonomy.taxeditor.store.open.OpenDistributionStatusWizardHandler";
- }
-
- @Override
- protected void performDefaults() {
- if (isAdminPreference){
- isEditorActivated = (Boolean) PreferencePredicate.DistributionEditorActivated.getDefaultValue();
- }else{
- isEditorActivated = Boolean.parseBoolean(distributionEditorPref.getValue().toString());
- }
- if (isEditorActivated) {
- activateCombo.select(0);
- } else {
- activateCombo.select(1);
- }
-
- if (isAdminPreference){
- displayArea = ((TermDisplayEnum) PreferencePredicate.DisplayOfAreasInDistributionEditor.getDefaultValue())
- .getKey();
- }else{
- displayArea = prefAreaDisplay.getValue().toString();
- }
-
- TermDisplayEnum areaDisplay;
- try {
- if (displayArea != null) {
- areaDisplay = TermDisplayEnum.byKey(displayArea);
- } else {
- areaDisplay = TermDisplayEnum.Title;
- }
- } catch (IllegalArgumentException e) {
- areaDisplay = TermDisplayEnum.Title;
- }
- int index = 0;
- for (String itemLabel : areaDisplaySelectionCombo.getItems()) {
- if (itemLabel.equalsIgnoreCase(areaDisplay.getLabel())) {
- areaDisplaySelectionCombo.select(index);
- break;
- }
- index++;
- }
-
- if (isAdminPreference){
- displayStatus = ((TermDisplayEnum) PreferencePredicate.DisplayOfStatus.getDefaultValue()).getKey();
- }else{
- displayStatus = prefStatusDisplay.getValue().toString();
- }
-
- TermDisplayEnum statusDisplay;
- try {
- if (displayStatus != null) {
- statusDisplay = TermDisplayEnum.byKey(displayStatus);
- } else {
- statusDisplay = TermDisplayEnum.Title;
- }
- } catch (IllegalArgumentException e) {
- statusDisplay = TermDisplayEnum.Title;
- }
- index = 0;
- for (String itemLabel : statusDisplaySelectionCombo.getItems()) {
- if (itemLabel.equalsIgnoreCase(statusDisplay.getLabel())) {
- statusDisplaySelectionCombo.select(index);
- break;
- }
- index++;
- }
- if (isAdminPreference){
- orderAreas = ((TermOrder) PreferencePredicate.AreasSortedInDistributionEditor.getDefaultValue()).getKey();
- }else{
- orderAreas = prefAreaSort.getValue().toString();
- }
-
- index = 0;
- if (PreferencesUtil.getStringValue(PreferencePredicate.DistributionEditorActivated.getKey()) != null) {
- TermOrder areaOrder;
- try {
- if (orderAreas != null) {
- areaOrder = TermOrder.valueOf(orderAreas);
- } else {
- areaOrder = TermOrder.IdInVoc;
- }
- } catch (IllegalArgumentException e) {
- areaOrder = TermOrder.IdInVoc;
- }
- for (String itemLabel : areaOrderSelectionCombo.getItems()) {
- if (itemLabel.equalsIgnoreCase(areaOrder.getLabel())) {
- areaOrderSelectionCombo.select(index);
- break;
- }
- index++;
- }
- }
-
- if (isAdminPreference){
- isShowRank = Boolean.valueOf(PreferencePredicate.ShowRankInDistributionEditor.getDefaultValue().toString());
- }else{
- isShowRank = Boolean.parseBoolean(prefRank.getValue().toString());
- }
-
- if (isShowRank) {
- activateRankCombo.select(0);
- } else {
- activateRankCombo.select(1);
- }
-
- ownDescriptionForDistributionEditor = Boolean
- .valueOf(PreferencePredicate.OwnDescriptionForDistributionEditor.getDefaultValue().toString());
-
- allowOverrideActivatedButton.setSelection(true);
- overrideActivated = true;
-
- overrideAreaDisplay = true;
- allowOverrideAreaDisplayButton.setSelection(true);
-
- overrideStatusDisplay = true;
- allowOverrideStatusDisplayButton.setSelection(true);
-
- overrideOrderAreas = true;
- allowOverrideOrderAreasButton.setSelection(true);
-
- overrideRank = true;
- allowOverrideRankButton.setSelection(true);
-
- overrideOwnDescriptionForDistributionEditor = true;
-
- this.statusPref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.AvailableDistributionStatus, null);
- this.areaVocPref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.AvailableDistributionAreaVocabularies,
- null);
- if (!isAdminPreference) {
- PreferencesUtil.recursiveSetEnabled(child, isEditorActivated);
-
- if (!prefAreaVoc.isAllowOverride()) {
- button_openSelectAreaVocabularies.setButtonEnabled(false);
- }
- if (!prefStatus.isAllowOverride()) {
- button_openStatusWizard.setButtonEnabled(false);
- }
- if (!prefRank.isAllowOverride()) {
- activateRankCombo.setEnabled(false);
-
- if (!prefAreaSort.isAllowOverride()) {
- areaOrderSelectionCombo.setEnabled(false);
- allowOverrideOrderAreasButton.setEnabled(false);
- }
- if (!prefAreaDisplay.isAllowOverride()) {
- allowOverrideAreaDisplayButton.setEnabled(false);
- }
- if (!prefStatusDisplay.isAllowOverride()) {
- allowOverrideStatusDisplayButton.setEnabled(false);
- }
- }
- super.performDefaults();
- }
- }
-
-}
+/**\r
+ * Copyright (C) 2014 EDIT\r
+ * European Distributed Institute of Taxonomy\r
+ * http://www.e-taxonomy.eu\r
+ *\r
+ * The contents of this file are subject to the Mozilla Public License Version 1.1\r
+ * See LICENSE.TXT at the top of this package for the full license terms.\r
+ */\r
+package eu.etaxonomy.taxeditor.preference;\r
+\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.custom.CLabel;\r
+import org.eclipse.swt.events.SelectionAdapter;\r
+import org.eclipse.swt.events.SelectionEvent;\r
+import org.eclipse.swt.events.SelectionListener;\r
+import org.eclipse.swt.layout.GridData;\r
+import org.eclipse.swt.layout.GridLayout;\r
+import org.eclipse.swt.widgets.Button;\r
+import org.eclipse.swt.widgets.Combo;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.swt.widgets.Control;\r
+import org.eclipse.swt.widgets.Event;\r
+import org.eclipse.swt.widgets.Label;\r
+import org.eclipse.swt.widgets.Listener;\r
+\r
+import eu.etaxonomy.cdm.model.metadata.CdmPreference;\r
+import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;\r
+import eu.etaxonomy.cdm.model.metadata.TermComboEnum;\r
+import eu.etaxonomy.cdm.model.metadata.TermDisplayEnum;\r
+import eu.etaxonomy.cdm.model.metadata.TermOrder;\r
+import eu.etaxonomy.taxeditor.l10n.Messages;\r
+import eu.etaxonomy.taxeditor.preference.menu.CdmPreferencePage;\r
+import eu.etaxonomy.taxeditor.ui.element.CommandHandlerButton;\r
+\r
+/**\r
+ * @author a.oppermann\r
+ * @date 21.07.2014\r
+ *\r
+ */\r
+public class ChecklistEditorGeneralPreference extends CdmPreferencePage implements SelectionListener {\r
+\r
+\r
+\r
+ protected Boolean isEditorActivated;\r
+\r
+ protected boolean overrideActivated;\r
+ boolean isUseLocal;\r
+ protected Boolean isShowRank;\r
+ protected String orderAreas;\r
+ protected String displayStatus;\r
+ protected String displayStatusCombo;\r
+ protected String displayArea;\r
+ protected Boolean ownDescriptionForDistributionEditor;\r
+\r
+ protected boolean overrideOwnDescriptionForDistributionEditor;\r
+ protected boolean overrideAreaVoc;\r
+ protected boolean overrideRank;\r
+ protected boolean overrideOrderAreas;\r
+ protected boolean overrideAreaDisplay;\r
+ protected boolean overrideStatusDisplay;\r
+ protected boolean overrideStatusDisplayCombo;\r
+\r
+ protected Combo areaOrderSelectionCombo;\r
+ protected Button allowOverrideOrderAreasButton;\r
+ protected Combo statusDisplaySelectionCombo;\r
+ protected Button allowOverrideStatusDisplayButton;\r
+ protected Combo statusDisplayInComboSelectionCombo;\r
+ protected Button allowOverrideStatusDisplayInComboButton;\r
+ protected Combo areaDisplaySelectionCombo;\r
+ protected Button allowOverrideAreaDisplayButton;\r
+ protected String commandHandlerString;\r
+ protected String commandHandlerStringStatus;\r
+\r
+ protected CdmPreference distributionEditorPref;\r
+ protected CdmPreference prefStatus;\r
+ protected CdmPreference prefAreaVoc;\r
+ protected CdmPreference prefAreaDisplay;\r
+ protected CdmPreference prefStatusDisplay;\r
+ protected CdmPreference prefStatusDisplayInCombo;\r
+ protected CdmPreference prefAreaSort;\r
+ protected CdmPreference prefRank;\r
+ protected CdmPreference prefOwnDescription;\r
+ Composite child;\r
+\r
+ protected Combo activateCombo;\r
+ protected Button allowOverrideActivatedButton;\r
+ final String ENABLE = "Enable";\r
+ final String DISABLE = "Disable";\r
+\r
+ protected Combo activateRankCombo;\r
+ protected Button allowOverrideRankButton;\r
+ final String SHOW_RANK = "Show Rank";\r
+ final String NO_RANK = "No Rank";\r
+\r
+ protected CdmPreference areaVocPref = null;\r
+ protected CdmPreference statusPref = null;\r
+ private CommandHandlerButton button_openSelectAreaVocabularies;\r
+\r
+ private CommandHandlerButton button_openStatusWizard;\r
+\r
+ @Override\r
+ protected Control createContents(Composite parent) {\r
+ getValues();\r
+ Composite composite = new Composite(parent, SWT.NULL);\r
+ composite.setLayout(new GridLayout());\r
+ if (!isAdminPreference && distributionEditorPref != null && !distributionEditorPref.isAllowOverride()&& !isEditorActivated ) {\r
+ Label label = new Label(composite, SWT.NONE);\r
+ label.setText(\r
+ "The CDM settings don't allow to set the preferences for using the distribution editor locally. If you need to make local settings, please ask an administrator.");\r
+ this.setDefaultButtonActivated(false);\r
+ } else {\r
+ Composite activateComp = createComposite(composite);\r
+ Label separator = new Label(activateComp, SWT.HORIZONTAL | SWT.SEPARATOR);\r
+ GridData sepGrid = createTextGridData();\r
+ separator.setLayoutData(sepGrid);\r
+ separator.setVisible(false);\r
+ CdmPreference dbPref;\r
+ GridData textGrid = createTextGridData();\r
+ textGrid.verticalSpan = 2;\r
+ separator.setLayoutData(sepGrid);\r
+\r
+ activateCombo = createBooleanCombo(activateComp, ENABLE, DISABLE, PreferencePredicate.DistributionEditorActivated, Messages.ChecklistEditorGeneralPreference_enable, isAdminPreference);\r
+\r
+ int index = 0;\r
+ for (String itemLabel : activateCombo.getItems()) {\r
+ if (isEditorActivated == null && itemLabel.equals(Messages.Preference_Use_Default)) {\r
+ activateCombo.select(index);\r
+ break;\r
+ }\r
+ if (isEditorActivated != null && itemLabel.equals(ENABLE) && isEditorActivated){\r
+ activateCombo.select(index);\r
+ break;\r
+ }\r
+ if (isEditorActivated != null && itemLabel.equals(DISABLE) && !isEditorActivated){\r
+ activateCombo.select(index);\r
+ break;\r
+ }\r
+ index++;\r
+ }\r
+\r
+\r
+ activateCombo.addSelectionListener(this);\r
+ if (isAdminPreference) {\r
+ allowOverrideActivatedButton = createAllowOverrideButton(activateComp);\r
+ allowOverrideActivatedButton.setSelection(this.distributionEditorPref != null? this.distributionEditorPref.isAllowOverride(): true);\r
+ allowOverrideActivatedButton.addSelectionListener(new SelectionAdapter() {\r
+ @Override\r
+ public void widgetSelected(SelectionEvent e) {\r
+ setApply(true);\r
+ if (distributionEditorPref == null){\r
+ distributionEditorPref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.DistributionEditorActivated, PreferencePredicate.DistributionEditorActivated.getDefaultValue() != null ? PreferencePredicate.DistributionEditorActivated.getDefaultValue().toString(): null);\r
+ }\r
+ distributionEditorPref.setAllowOverride(!distributionEditorPref.isAllowOverride());\r
+ }\r
+ });\r
+ }\r
+ child = createComposite(composite);\r
+\r
+ if (!isAdminPreference) {\r
+ if (isEditorActivated != null){\r
+ child.setEnabled(isEditorActivated);\r
+ }else{\r
+ child.setEnabled(Boolean.parseBoolean(distributionEditorPref.getValue().toString()));\r
+ }\r
+ }\r
+ separator = new Label(child, SWT.HORIZONTAL | SWT.SEPARATOR);\r
+ sepGrid = createTextGridData();\r
+ separator.setLayoutData(sepGrid);\r
+\r
+ activateRankCombo = createBooleanCombo(child, SHOW_RANK, NO_RANK,\r
+ PreferencePredicate.ShowRankInDistributionEditor, Messages.ChecklistEditorGeneralPreference_show_rank, isAdminPreference);\r
+ index = 0;\r
+ for (String itemLabel : activateRankCombo.getItems()) {\r
+ if (isShowRank == null && itemLabel.equals(Messages.Preference_Use_Default)) {\r
+ activateRankCombo.select(index);\r
+ break;\r
+ }\r
+ if (isShowRank != null && itemLabel.equals(SHOW_RANK) && isShowRank){\r
+ activateRankCombo.select(index);\r
+ break;\r
+ }\r
+ if (isShowRank != null && itemLabel.equals(NO_RANK) && !isShowRank){\r
+ activateRankCombo.select(index);\r
+ break;\r
+ }\r
+ index++;\r
+ }\r
+ activateRankCombo.addSelectionListener(this);\r
+ if (isAdminPreference) {\r
+ allowOverrideRankButton = createAllowOverrideButton(child);\r
+ allowOverrideRankButton.setSelection(prefRank != null? prefRank.isAllowOverride():true);\r
+ allowOverrideRankButton.addSelectionListener(new SelectionAdapter() {\r
+ @Override\r
+ public void widgetSelected(SelectionEvent e) {\r
+ setApply(true);\r
+ if (prefRank == null){\r
+ prefRank = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowRankInDistributionEditor, PreferencePredicate.ShowRankInDistributionEditor.getDefaultValue() != null ? PreferencePredicate.ShowRankInDistributionEditor.getDefaultValue().toString(): null);\r
+ }\r
+ prefRank.setAllowOverride(allowOverrideRankButton.getSelection());\r
+ }\r
+ });\r
+ }\r
+\r
+ GridData gridData = new GridData();\r
+ gridData = new GridData(GridData.BEGINNING, GridData.CENTER, true, false);\r
+\r
+ areaOrderSelectionCombo = createCombo(child, TermOrder.values(), PreferencePredicate.AreasSortedInDistributionEditor, Messages.ChecklistEditorGeneralPreference_Configure_area_order, isAdminPreference);\r
+\r
+ index = 0;\r
+ TermOrder areaOrder;\r
+ try {\r
+ if (orderAreas != null) {\r
+ areaOrder = TermOrder.valueOf(orderAreas);\r
+ } else {\r
+ areaOrder = TermOrder.IdInVoc;\r
+ }\r
+ } catch (IllegalArgumentException e) {\r
+ areaOrder = TermOrder.IdInVoc;\r
+ }\r
+ for (String itemLabel : areaOrderSelectionCombo.getItems()) {\r
+ if (itemLabel.equals(Messages.Preference_Use_Default) && orderAreas.equals(Messages.Preference_Use_Default)){\r
+ areaOrderSelectionCombo.select(index);\r
+ break;\r
+ }\r
+ if (itemLabel.startsWith(areaOrder.getLabel())) {\r
+ areaOrderSelectionCombo.select(index);\r
+ break;\r
+ }\r
+\r
+ index++;\r
+ }\r
+\r
+ areaOrderSelectionCombo.addSelectionListener(this);\r
+\r
+ if (isAdminPreference) {\r
+ allowOverrideOrderAreasButton = createAllowOverrideButton(child);\r
+ allowOverrideOrderAreasButton.setSelection(prefAreaSort != null? prefAreaSort.isAllowOverride(): true);\r
+ allowOverrideOrderAreasButton.addSelectionListener(new SelectionAdapter() {\r
+ @Override\r
+ public void widgetSelected(SelectionEvent e) {\r
+ setApply(true);\r
+ if (prefAreaSort == null){\r
+ prefAreaSort = CdmPreference.NewTaxEditorInstance(PreferencePredicate.AreasSortedInDistributionEditor, PreferencePredicate.AreasSortedInDistributionEditor.getDefaultValue() != null ? PreferencePredicate.AreasSortedInDistributionEditor.getDefaultValue().toString(): null);\r
+ }\r
+ prefAreaSort.setAllowOverride(allowOverrideOrderAreasButton.getSelection());\r
+ }\r
+ });\r
+ }\r
+\r
+ separator = new Label(child, SWT.HORIZONTAL | SWT.SEPARATOR);\r
+ separator.setLayoutData(sepGrid);\r
+ areaDisplaySelectionCombo = createCombo(child, TermDisplayEnum.values(), PreferencePredicate.DisplayOfAreasInDistributionEditor, Messages.ChecklistEditorGeneralPreference_Configure_display_of_Areas, isAdminPreference);\r
+\r
+\r
+ index = 0;\r
+ TermDisplayEnum areaDisplay;\r
+ try {\r
+ if (displayArea != null) {\r
+ areaDisplay = TermDisplayEnum.valueOf(displayArea);\r
+ } else {\r
+ areaDisplay = TermDisplayEnum.Title;\r
+ }\r
+ } catch (IllegalArgumentException e) {\r
+ areaDisplay = TermDisplayEnum.Title;\r
+ }\r
+ for (String itemLabel : areaDisplaySelectionCombo.getItems()) {\r
+ if (itemLabel.equals(Messages.Preference_Use_Default) && displayArea.equals(Messages.Preference_Use_Default)){\r
+ areaDisplaySelectionCombo.select(index);\r
+ break;\r
+ }\r
+ if (itemLabel.startsWith(areaDisplay.getLabel())) {\r
+ areaDisplaySelectionCombo.select(index);\r
+ break;\r
+ }\r
+\r
+ index++;\r
+ }\r
+ areaDisplaySelectionCombo.addSelectionListener(this);\r
+\r
+ if (isAdminPreference) {\r
+ allowOverrideAreaDisplayButton = createAllowOverrideButton(child);\r
+ allowOverrideAreaDisplayButton.setSelection(prefAreaDisplay != null? prefAreaDisplay.isAllowOverride(): true);\r
+ allowOverrideAreaDisplayButton.addSelectionListener(new SelectionAdapter() {\r
+ @Override\r
+ public void widgetSelected(SelectionEvent e) {\r
+ setApply(true);\r
+ if (prefAreaDisplay == null){\r
+ prefAreaDisplay = CdmPreference.NewTaxEditorInstance(PreferencePredicate.DisplayOfAreasInDistributionEditor, PreferencePredicate.DisplayOfAreasInDistributionEditor.getDefaultValue() != null ? PreferencePredicate.DisplayOfAreasInDistributionEditor.getDefaultValue().toString(): null);\r
+ }\r
+ prefAreaDisplay.setAllowOverride(allowOverrideOrderAreasButton.getSelection());\r
+ }\r
+ });\r
+ }\r
+\r
+ statusDisplaySelectionCombo = createCombo(child, TermDisplayEnum.values(), PreferencePredicate.DisplayOfStatus, Messages.ChecklistEditorGeneralPreference_Configure_display_of_Status, isAdminPreference);\r
+\r
+ index = 0;\r
+ TermDisplayEnum statusDisplay;\r
+ try {\r
+ if (displayStatus != null) {\r
+ statusDisplay = TermDisplayEnum.valueOf(displayStatus);\r
+ } else {\r
+ statusDisplay = TermDisplayEnum.Title;\r
+ }\r
+ } catch (IllegalArgumentException e) {\r
+ statusDisplay = TermDisplayEnum.Title;\r
+ }\r
+ for (String itemLabel : statusDisplaySelectionCombo.getItems()) {\r
+ if (itemLabel.equals(Messages.Preference_Use_Default) && displayStatus.equals(Messages.Preference_Use_Default)){\r
+ statusDisplaySelectionCombo.select(index);\r
+ break;\r
+ }\r
+ if (itemLabel.startsWith(statusDisplay.getLabel())) {\r
+ statusDisplaySelectionCombo.select(index);\r
+ break;\r
+ }\r
+\r
+ index++;\r
+ }\r
+\r
+ statusDisplaySelectionCombo.addSelectionListener(this);\r
+\r
+ if (isAdminPreference) {\r
+ allowOverrideStatusDisplayButton = createAllowOverrideButton(child);\r
+ allowOverrideStatusDisplayButton.setSelection(prefStatusDisplay != null ? prefStatusDisplay.isAllowOverride(): true);\r
+ allowOverrideStatusDisplayButton.addSelectionListener(new SelectionAdapter() {\r
+ @Override\r
+ public void widgetSelected(SelectionEvent e) {\r
+ setApply(true);\r
+ if (prefStatusDisplay == null){\r
+ prefStatusDisplay = CdmPreference.NewTaxEditorInstance(PreferencePredicate.DisplayOfStatus, PreferencePredicate.DisplayOfStatus.getDefaultValue() != null ? PreferencePredicate.DisplayOfStatus.getDefaultValue().toString(): null);\r
+ }\r
+ prefStatusDisplay.setAllowOverride(allowOverrideStatusDisplayButton.getSelection());\r
+ }\r
+ });\r
+ }\r
+\r
+ statusDisplayInComboSelectionCombo = createCombo(child, TermComboEnum.values(), PreferencePredicate.DisplayOfStatusInCombo, Messages.ChecklistEditorGeneralPreference_Configure_display_of_Status_in_Combo, isAdminPreference);\r
+\r
+ index = 0;\r
+ TermComboEnum statusComboDisplay;\r
+ try {\r
+ if (displayStatusCombo != null) {\r
+ statusComboDisplay = TermComboEnum.byKey(displayStatusCombo);\r
+ } else {\r
+ statusComboDisplay = TermComboEnum.Title;\r
+ }\r
+ } catch (IllegalArgumentException e) {\r
+ statusComboDisplay = TermComboEnum.Title;\r
+ }\r
+ for (String itemLabel : statusDisplayInComboSelectionCombo.getItems()) {\r
+ if (itemLabel.equals(Messages.Preference_Use_Default) && displayStatusCombo.equals(Messages.Preference_Use_Default)){\r
+ statusDisplayInComboSelectionCombo.select(index);\r
+ break;\r
+ }\r
+ if (itemLabel.startsWith(statusComboDisplay.getLabel())) {\r
+ statusDisplayInComboSelectionCombo.select(index);\r
+ break;\r
+ }\r
+\r
+ index++;\r
+ }\r
+\r
+ statusDisplayInComboSelectionCombo.addSelectionListener(this);\r
+\r
+ if (isAdminPreference) {\r
+ allowOverrideStatusDisplayInComboButton = createAllowOverrideButton(child);\r
+ allowOverrideStatusDisplayInComboButton.setSelection(prefStatusDisplayInCombo != null ? prefStatusDisplayInCombo.isAllowOverride(): true);\r
+ allowOverrideStatusDisplayInComboButton.addSelectionListener(new SelectionAdapter() {\r
+ @Override\r
+ public void widgetSelected(SelectionEvent e) {\r
+ setApply(true);\r
+ if (prefStatusDisplayInCombo == null){\r
+ prefStatusDisplayInCombo = CdmPreference.NewTaxEditorInstance(PreferencePredicate.DisplayOfStatusInCombo, PreferencePredicate.DisplayOfStatusInCombo.getDefaultValue() != null ? PreferencePredicate.DisplayOfStatusInCombo.getDefaultValue().toString(): null);\r
+ }\r
+ prefStatusDisplayInCombo.setAllowOverride(allowOverrideStatusDisplayInComboButton.getSelection());\r
+ }\r
+ });\r
+ }\r
+\r
+\r
+ final CLabel labelStatus = new CLabel(child, SWT.NULL);\r
+ labelStatus.setText(Messages.DistributionAdminPreferences_SELECT_STATUS);\r
+ labelStatus.setLayoutData(textGrid);\r
+\r
+ button_openStatusWizard = new CommandHandlerButton(child, SWT.PUSH, commandHandlerStringStatus);\r
+\r
+ button_openStatusWizard.setText(Messages.Distribution_status_selection);\r
+ button_openStatusWizard.addListener(SWT.Selection, new Listener() {\r
+ @Override\r
+ public void handleEvent(Event e) {\r
+ switch (e.type) {\r
+ case SWT.Selection:\r
+ setApply(true);\r
+ break;\r
+ }\r
+ }\r
+ });\r
+\r
+ final CLabel label = new CLabel(child, SWT.NULL);\r
+ label.setText(Messages.ChecklistEditorGeneralPreference_open_wizard);\r
+ label.setLayoutData(textGrid);\r
+\r
+ button_openSelectAreaVocabularies = new CommandHandlerButton(child, SWT.PUSH, commandHandlerString);\r
+ button_openSelectAreaVocabularies\r
+ .setText(Messages.ChecklistEditorGeneralPreference_open_distribution_selection);\r
+\r
+ if (!isAdminPreference) {\r
+\r
+ //PreferencesUtil.recursiveSetEnabled(child, isEditorActivated);\r
+ if (distributionEditorPref != null && !distributionEditorPref.isAllowOverride()){\r
+ activateComp.setEnabled(false);\r
+ }\r
+\r
+ if (prefAreaVoc != null && !prefAreaVoc.isAllowOverride()) {\r
+ button_openSelectAreaVocabularies.setButtonEnabled(false);\r
+ }\r
+ if (prefStatus != null && !prefStatus.isAllowOverride()) {\r
+ button_openStatusWizard.setButtonEnabled(false);\r
+ }\r
+ if (prefRank != null && !prefRank.isAllowOverride()) {\r
+ activateRankCombo.setEnabled(false);\r
+ }\r
+ if (prefAreaSort != null && !prefAreaSort.isAllowOverride()) {\r
+ areaOrderSelectionCombo.setEnabled(false);\r
+ //allowOverrideOrderAreasButton.setEnabled(false);\r
+ }\r
+ if (prefAreaDisplay != null && !prefAreaDisplay.isAllowOverride()) {\r
+ areaDisplaySelectionCombo.setEnabled(false);\r
+ }\r
+ if (prefStatusDisplay != null && !prefStatusDisplay.isAllowOverride()) {\r
+ statusDisplaySelectionCombo.setEnabled(false);\r
+ }\r
+ if (prefStatusDisplayInCombo != null && !prefStatusDisplayInCombo.isAllowOverride()) {\r
+ statusDisplayInComboSelectionCombo.setEnabled(false);\r
+ }\r
+ }\r
+\r
+ }\r
+ setValid(true);\r
+ return composite;\r
+ }\r
+\r
+ @Override\r
+ public boolean performOk() {\r
+ if (!isApply()){\r
+ return true;\r
+ }\r
+ boolean override = false;\r
+ if (isEditorActivated != null ) {\r
+ override = true;\r
+ PreferencesUtil.setStringValue(PreferencePredicate.DistributionEditorActivated.getKey(), isEditorActivated.toString());\r
+ }\r
+ PreferencesUtil.setBooleanValue(\r
+ PreferencesUtil.prefOverrideKey(PreferencePredicate.DistributionEditorActivated.getKey()),\r
+ override);\r
+\r
+\r
+ override = false;\r
+ if (!orderAreas.equals(Messages.Preference_Use_Default) ) {\r
+ override = true;\r
+ PreferencesUtil.setSortNamedAreasInDistributionEditor(orderAreas);\r
+ }\r
+ PreferencesUtil.setBooleanValue(\r
+ PreferencesUtil.prefOverrideKey(PreferencePredicate.AreasSortedInDistributionEditor.getKey()),\r
+ override);\r
+\r
+\r
+\r
+\r
+\r
+ override = false;\r
+ if (isShowRank != null ) {\r
+ override = true;\r
+ PreferencesUtil.setShowRankInChecklistEditor(isShowRank);\r
+ }\r
+ PreferencesUtil.setBooleanValue(\r
+ PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowRankInDistributionEditor.getKey()),\r
+ override);\r
+\r
+\r
+ override = false;\r
+ if (!displayStatus.equals(Messages.Preference_Use_Default)) {\r
+ override = true;\r
+ PreferencesUtil.setDisplayStatusInChecklistEditor(displayStatus);\r
+ }\r
+ PreferencesUtil.setBooleanValue(\r
+ PreferencesUtil.prefOverrideKey(PreferencePredicate.DisplayOfStatus.getKey()),\r
+ override);\r
+\r
+ override = false;\r
+ if (!displayStatusCombo.equals(Messages.Preference_Use_Default)) {\r
+ override = true;\r
+ PreferencesUtil.setStringValue(PreferencePredicate.DisplayOfStatusInCombo.getKey(), displayStatusCombo);\r
+ }\r
+ PreferencesUtil.setBooleanValue(\r
+ PreferencesUtil.prefOverrideKey(PreferencePredicate.DisplayOfStatusInCombo.getKey()),\r
+ override);\r
+\r
+\r
+\r
+ override = false;\r
+ if (!displayArea.equals(Messages.Preference_Use_Default) ) {\r
+ override = true;\r
+ PreferencesUtil.setAreaDisplayInChecklistEditor(displayArea);\r
+ }\r
+ PreferencesUtil.setBooleanValue(PreferencesUtil.prefOverrideKey(\r
+ PreferencePredicate.DisplayOfAreasInDistributionEditor.getKey()), override);\r
+\r
+\r
+\r
+\r
+ PreferencesUtil.setOwnDescriptionForChecklistEditor(ownDescriptionForDistributionEditor);\r
+ PreferencesUtil.setBooleanValue(\r
+ PreferencesUtil.prefOverrideKey(PreferencePredicate.OwnDescriptionForDistributionEditor.getKey()),\r
+ true);\r
+\r
+ PreferencesUtil.firePreferencesChanged(this.getClass());\r
+\r
+ return true;\r
+ }\r
+\r
+ /**\r
+ * {@inheritDoc}\r
+ */\r
+ @Override\r
+ public void widgetSelected(SelectionEvent e) {\r
+ setApply(true);\r
+ if (e.getSource().equals(statusDisplaySelectionCombo)) {\r
+ String text = statusDisplaySelectionCombo.getText();\r
+ if(text.equals(Messages.Preference_Use_Default)){\r
+ displayStatus = Messages.Preference_Use_Default;\r
+ if(isAdminPreference){\r
+ prefStatusDisplay.setAllowOverride(true);\r
+ allowOverrideStatusDisplayButton.setSelection(true);\r
+ }\r
+\r
+ return;\r
+ }\r
+ for (TermDisplayEnum display : TermDisplayEnum.values()) {\r
+ if (text.startsWith(display.getLabel())) {\r
+ displayStatus = display.getKey();\r
+ break;\r
+ }\r
+\r
+ }\r
+ }\r
+ if (e.getSource().equals(statusDisplayInComboSelectionCombo)) {\r
+ String text = statusDisplayInComboSelectionCombo.getText();\r
+ if(text.equals(Messages.Preference_Use_Default)){\r
+ displayStatusCombo = Messages.Preference_Use_Default;\r
+ if(isAdminPreference){\r
+ prefStatusDisplayInCombo.setAllowOverride(true);\r
+ allowOverrideStatusDisplayInComboButton.setSelection(true);\r
+ }\r
+\r
+ return;\r
+ }\r
+ for (TermComboEnum display : TermComboEnum.values()) {\r
+ if (text.startsWith(display.getLabel())) {\r
+ displayStatusCombo = display.getKey();\r
+ break;\r
+ }\r
+\r
+ }\r
+ }\r
+ if (e.getSource().equals(areaDisplaySelectionCombo)) {\r
+ String text = areaDisplaySelectionCombo.getText();\r
+ if(text.equals(Messages.Preference_Use_Default)){\r
+ displayArea = Messages.Preference_Use_Default;\r
+ if (isAdminPreference){\r
+ prefAreaDisplay.setAllowOverride(true);\r
+ allowOverrideAreaDisplayButton.setSelection(true);\r
+ }\r
+ return;\r
+ }\r
+ for (TermDisplayEnum display : TermDisplayEnum.values()) {\r
+ if (text.startsWith(display.getLabel())) {\r
+ displayArea = display.getKey();\r
+ break;\r
+ }\r
+ }\r
+ }\r
+ if (e.getSource().equals(areaOrderSelectionCombo)) {\r
+ String text = areaOrderSelectionCombo.getText();\r
+ if(text.equals(Messages.Preference_Use_Default)){\r
+ orderAreas = Messages.Preference_Use_Default;\r
+ if (isAdminPreference){\r
+ prefAreaSort.setAllowOverride(true);\r
+ allowOverrideOrderAreasButton.setSelection(true);\r
+ }\r
+ return;\r
+ }\r
+ for (TermOrder display : TermOrder.values()) {\r
+ if (text.startsWith(display.getLabel())) {\r
+ orderAreas = display.getKey();\r
+ break;\r
+ }\r
+ }\r
+ }\r
+ if (e.getSource().equals(this.activateRankCombo)) {\r
+ String text = activateRankCombo.getText();\r
+ if(text.equals(Messages.Preference_Use_Default)){\r
+ isShowRank = null;\r
+ if (isAdminPreference){\r
+ prefRank.setAllowOverride(true);\r
+ allowOverrideRankButton.setSelection(true);\r
+ }\r
+ return;\r
+ }\r
+ if (text.equals(SHOW_RANK)){\r
+ isShowRank = true;\r
+ }else{\r
+ isShowRank = false;\r
+ }\r
+ }\r
+\r
+ if (e.getSource().equals(this.activateCombo)) {\r
+ String text = activateCombo.getText();\r
+ if(text.equals(Messages.Preference_Use_Default)){\r
+ isEditorActivated = null;\r
+ if (isAdminPreference){\r
+ if (distributionEditorPref == null){\r
+ distributionEditorPref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.DistributionEditorActivated, PreferencePredicate.DistributionEditorActivated.getDefaultValue() != null ? PreferencePredicate.DistributionEditorActivated.getDefaultValue().toString(): null);\r
+ }\r
+ distributionEditorPref.setAllowOverride(true);\r
+ allowOverrideActivatedButton.setSelection(true);\r
+ }\r
+ return;\r
+ }\r
+ if (text.equals(ENABLE)){\r
+ isEditorActivated = true;\r
+ }else{\r
+ isEditorActivated = false;\r
+ }\r
+\r
+ }\r
+ //PreferencesUtil.recursiveSetEnabled(child, isEditorActivated);\r
+ }\r
+\r
+ /**\r
+ * {@inheritDoc}\r
+ */\r
+ @Override\r
+ public void widgetDefaultSelected(SelectionEvent e) {\r
+ // TODO Auto-generated method stub\r
+\r
+ }\r
+\r
+ /**\r
+ * {@inheritDoc}\r
+ */\r
+ @Override\r
+ public void getValues() {\r
+ isAdminPreference = false;\r
+ setPreferenceStore(PreferencesUtil.getPreferenceStore());\r
+ distributionEditorPref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.DistributionEditorActivated);\r
+ overrideActivated = PreferencesUtil.getBooleanValue(\r
+ PreferencesUtil.prefOverrideKey(PreferencePredicate.DistributionEditorActivated.getKey()), true);\r
+\r
+ if (distributionEditorPref != null) {\r
+ if (distributionEditorPref.isAllowOverride() ) {\r
+ if (overrideActivated){\r
+ isEditorActivated = PreferencesUtil.getBooleanValue(PreferencePredicate.DistributionEditorActivated.getKey(), true);\r
+ }\r
+\r
+ } else {\r
+ isEditorActivated = Boolean.valueOf(distributionEditorPref.getValue());\r
+\r
+ }\r
+\r
+ } else {\r
+ if(!overrideActivated){\r
+ isEditorActivated = null;\r
+ }else{\r
+ isEditorActivated = PreferencesUtil.getBooleanValue(PreferencePredicate.DistributionEditorActivated.getKey(), true);\r
+ }\r
+ //distributionEditorPref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.DistributionEditorActivated, PreferencePredicate.DistributionEditorActivated.getDefaultValue() != null ? PreferencePredicate.DistributionEditorActivated.getDefaultValue().toString(): null);\r
+ }\r
+\r
+ prefAreaVoc = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.AvailableDistributionAreaVocabularies);\r
+ if (prefAreaVoc == null){\r
+ prefAreaVoc = CdmPreference.NewTaxEditorInstance(PreferencePredicate.AvailableDistributionAreaVocabularies, PreferencePredicate.AvailableDistributionAreaVocabularies.getDefaultValue() != null ? PreferencePredicate.AvailableDistributionAreaVocabularies.getDefaultValue().toString(): null);\r
+ }\r
+\r
+\r
+ prefStatus = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.AvailableDistributionStatus);\r
+ if (prefStatus == null){\r
+ prefStatus = CdmPreference.NewTaxEditorInstance(PreferencePredicate.AvailableDistributionStatus, PreferencePredicate.AvailableDistributionStatus.getDefaultValue() != null ? PreferencePredicate.AvailableDistributionStatus.getDefaultValue().toString(): null);\r
+ }\r
+\r
+\r
+ prefAreaDisplay = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.DisplayOfAreasInDistributionEditor);\r
+ overrideAreaDisplay = PreferencesUtil.getBooleanValue(\r
+ PreferencesUtil.prefOverrideKey(PreferencePredicate.DisplayOfAreasInDistributionEditor.getKey()), true);\r
+ if (prefAreaDisplay != null) {\r
+ if (prefAreaDisplay.isAllowOverride()){\r
+ if (overrideActivated) {\r
+ displayArea = PreferencesUtil.displayAreaInChecklistEditor();\r
+ }else{\r
+ displayArea = Messages.Preference_Use_Default;\r
+ }\r
+ } else {\r
+ displayArea = prefAreaDisplay.getValue();\r
+ }\r
+ } else {\r
+ if (overrideAreaDisplay){\r
+ displayArea = PreferencesUtil.displayAreaInChecklistEditor();\r
+ } else{\r
+ displayArea = Messages.Preference_Use_Default;\r
+ }\r
+ //prefAreaDisplay = CdmPreference.NewTaxEditorInstance(PreferencePredicate.DisplayOfAreasInDistributionEditor, PreferencePredicate.DisplayOfAreasInDistributionEditor.getDefaultValue() != null ? PreferencePredicate.DisplayOfAreasInDistributionEditor.getDefaultValue().toString(): null);\r
+ }\r
+\r
+ prefStatusDisplay = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.DisplayOfStatus);\r
+ overrideStatusDisplay = PreferencesUtil\r
+ .getBooleanValue(PreferencesUtil.prefOverrideKey(PreferencePredicate.DisplayOfStatus.getKey()), true);\r
+ if (prefStatusDisplay != null) {\r
+ if (prefStatusDisplay.isAllowOverride()){\r
+ if (overrideStatusDisplay) {\r
+ displayStatus = PreferencesUtil.displayStatusInChecklistEditor();\r
+ }else{\r
+ displayStatus = Messages.Preference_Use_Default;\r
+ }\r
+ } else {\r
+ this.displayStatus = prefStatusDisplay.getValue();\r
+ }\r
+ } else {\r
+ if (overrideStatusDisplay){\r
+ displayStatus = PreferencesUtil.displayStatusInChecklistEditor();\r
+ } else{\r
+ displayStatus = Messages.Preference_Use_Default;\r
+ }\r
+ //prefStatusDisplay = CdmPreference.NewTaxEditorInstance(PreferencePredicate.DisplayOfStatus, PreferencePredicate.DisplayOfStatus.getDefaultValue() != null ? PreferencePredicate.DisplayOfStatus.getDefaultValue().toString(): null);\r
+ }\r
+\r
+ prefStatusDisplayInCombo = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.DisplayOfStatusInCombo);\r
+ overrideStatusDisplayCombo = PreferencesUtil\r
+ .getBooleanValue(PreferencesUtil.prefOverrideKey(PreferencePredicate.DisplayOfStatusInCombo.getKey()), true);\r
+ if (prefStatusDisplayInCombo != null) {\r
+ if (prefStatusDisplayInCombo.isAllowOverride()){\r
+ if (overrideStatusDisplayCombo) {\r
+ displayStatusCombo = PreferencesUtil.getStringValue(PreferencePredicate.DisplayOfStatusInCombo.getKey());\r
+ }else{\r
+ displayStatusCombo = Messages.Preference_Use_Default;\r
+ }\r
+ } else {\r
+ this.displayStatusCombo = prefStatusDisplayInCombo.getValue();\r
+ }\r
+ } else {\r
+ if (overrideStatusDisplayCombo){\r
+ displayStatusCombo = PreferencesUtil.getStringValue(PreferencePredicate.DisplayOfStatusInCombo.getKey());\r
+ } else{\r
+ displayStatusCombo = Messages.Preference_Use_Default;\r
+ }\r
+\r
+ }\r
+\r
+\r
+ prefAreaSort = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.AreasSortedInDistributionEditor);\r
+ overrideOrderAreas = PreferencesUtil.getBooleanValue(\r
+ PreferencesUtil.prefOverrideKey(PreferencePredicate.AreasSortedInDistributionEditor.getKey()), true);\r
+ if (prefAreaSort != null) {\r
+ if (prefAreaSort.isAllowOverride()){\r
+ if(overrideOrderAreas) {\r
+ orderAreas = PreferencesUtil.getSortNamedAreasInDistributionEditor();\r
+ }else{\r
+ orderAreas = Messages.Preference_Use_Default;\r
+ }\r
+ } else {\r
+ if (prefAreaSort.getValue() != null) {\r
+ orderAreas = prefAreaSort.getValue().toString();\r
+ } else {\r
+ orderAreas = ((TermOrder) PreferencePredicate.AreasSortedInDistributionEditor.getDefaultValue())\r
+ .getKey();\r
+ }\r
+\r
+ }\r
+ } else {\r
+ if (overrideOrderAreas){\r
+ orderAreas = PreferencesUtil.getSortNamedAreasInDistributionEditor();\r
+ }else{\r
+ orderAreas = Messages.Preference_Use_Default;\r
+ }\r
+ //prefAreaSort = CdmPreference.NewTaxEditorInstance(PreferencePredicate.AreasSortedInDistributionEditor, PreferencePredicate.AreasSortedInDistributionEditor.getDefaultValue() != null ? PreferencePredicate.AreasSortedInDistributionEditor.getDefaultValue().toString(): null);\r
+ }\r
+\r
+ prefRank = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.ShowRankInDistributionEditor);\r
+ overrideRank = PreferencesUtil.getBooleanValue(\r
+ PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowRankInDistributionEditor.getKey()), true);\r
+ if (prefRank != null) {\r
+ if (prefRank.isAllowOverride()){\r
+ if(overrideRank) {\r
+ isShowRank = PreferencesUtil.isShowRankInChecklistEditor();\r
+ }\r
+\r
+ } else {\r
+ this.isShowRank = Boolean.valueOf(prefRank.getValue().toString());\r
+ }\r
+ } else {\r
+ if (overrideRank){\r
+ isShowRank = PreferencesUtil.isShowRankInChecklistEditor();\r
+ } else {\r
+ isShowRank = null;\r
+ }\r
+\r
+ //refRank = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowRankInDistributionEditor, PreferencePredicate.ShowRankInDistributionEditor.getDefaultValue() != null ? PreferencePredicate.ShowRankInDistributionEditor.getDefaultValue().toString(): null);\r
+ }\r
+\r
+ prefOwnDescription = PreferencesUtil\r
+ .getPreferenceFromDB(PreferencePredicate.OwnDescriptionForDistributionEditor);\r
+ if (prefOwnDescription != null) {\r
+ if (prefOwnDescription.isAllowOverride()) {\r
+ ownDescriptionForDistributionEditor = PreferencesUtil.isOwnDescriptionForChecklistEditor();\r
+ } else {\r
+ ownDescriptionForDistributionEditor = Boolean.valueOf(prefOwnDescription.getValue().toString());\r
+ }\r
+ } else {\r
+ ownDescriptionForDistributionEditor = PreferencesUtil.isShowRankInChecklistEditor();\r
+ // allowOverrideOwnDescriptionForDistributionEditor = true;\r
+ overrideOwnDescriptionForDistributionEditor = PreferencesUtil.getBooleanValue(\r
+ PreferencesUtil.prefOverrideKey(PreferencePredicate.OwnDescriptionForDistributionEditor.getKey()), true);\r
+ //prefOwnDescription = CdmPreference.NewTaxEditorInstance(PreferencePredicate.OwnDescriptionForDistributionEditor, PreferencePredicate.OwnDescriptionForDistributionEditor.getDefaultValue() != null ? PreferencePredicate.OwnDescriptionForDistributionEditor.getDefaultValue().toString(): null);\r
+ }\r
+\r
+ commandHandlerString = "eu.etaxonomy.taxeditor.store.open.OpenDistributionEditorWizardHandler";\r
+ commandHandlerStringStatus = "eu.etaxonomy.taxeditor.store.open.OpenDistributionStatusWizardHandler";\r
+ }\r
+\r
+ @Override\r
+ protected void performDefaults() {\r
+ if (isAdminPreference){\r
+ isEditorActivated = (Boolean) PreferencePredicate.DistributionEditorActivated.getDefaultValue();\r
+ }else{\r
+ isEditorActivated = Boolean.parseBoolean(distributionEditorPref.getValue().toString());\r
+ }\r
+ if (isEditorActivated) {\r
+ activateCombo.select(0);\r
+ } else {\r
+ activateCombo.select(1);\r
+ }\r
+\r
+ if (isAdminPreference){\r
+ displayArea = ((TermDisplayEnum) PreferencePredicate.DisplayOfAreasInDistributionEditor.getDefaultValue())\r
+ .getKey();\r
+ }else{\r
+ displayArea = prefAreaDisplay.getValue().toString();\r
+ }\r
+\r
+ TermDisplayEnum areaDisplay;\r
+ try {\r
+ if (displayArea != null) {\r
+ areaDisplay = TermDisplayEnum.byKey(displayArea);\r
+ } else {\r
+ areaDisplay = TermDisplayEnum.Title;\r
+ }\r
+ } catch (IllegalArgumentException e) {\r
+ areaDisplay = TermDisplayEnum.Title;\r
+ }\r
+ int index = 0;\r
+ for (String itemLabel : areaDisplaySelectionCombo.getItems()) {\r
+ if (itemLabel.equalsIgnoreCase(areaDisplay.getLabel())) {\r
+ areaDisplaySelectionCombo.select(index);\r
+ break;\r
+ }\r
+ index++;\r
+ }\r
+\r
+ if (isAdminPreference){\r
+ displayStatus = ((TermDisplayEnum) PreferencePredicate.DisplayOfStatus.getDefaultValue()).getKey();\r
+ }else{\r
+ displayStatus = prefStatusDisplay.getValue().toString();\r
+ }\r
+\r
+ TermDisplayEnum statusDisplay;\r
+ try {\r
+ if (displayStatus != null) {\r
+ statusDisplay = TermDisplayEnum.byKey(displayStatus);\r
+ } else {\r
+ statusDisplay = TermDisplayEnum.Title;\r
+ }\r
+ } catch (IllegalArgumentException e) {\r
+ statusDisplay = TermDisplayEnum.Title;\r
+ }\r
+ index = 0;\r
+ for (String itemLabel : statusDisplaySelectionCombo.getItems()) {\r
+ if (itemLabel.equalsIgnoreCase(statusDisplay.getLabel())) {\r
+ statusDisplaySelectionCombo.select(index);\r
+ break;\r
+ }\r
+ index++;\r
+ }\r
+ if (isAdminPreference){\r
+ orderAreas = ((TermOrder) PreferencePredicate.AreasSortedInDistributionEditor.getDefaultValue()).getKey();\r
+ }else{\r
+ orderAreas = prefAreaSort.getValue().toString();\r
+ }\r
+\r
+ index = 0;\r
+ if (PreferencesUtil.getStringValue(PreferencePredicate.DistributionEditorActivated.getKey()) != null) {\r
+ TermOrder areaOrder;\r
+ try {\r
+ if (orderAreas != null) {\r
+ areaOrder = TermOrder.valueOf(orderAreas);\r
+ } else {\r
+ areaOrder = TermOrder.IdInVoc;\r
+ }\r
+ } catch (IllegalArgumentException e) {\r
+ areaOrder = TermOrder.IdInVoc;\r
+ }\r
+ for (String itemLabel : areaOrderSelectionCombo.getItems()) {\r
+ if (itemLabel.equalsIgnoreCase(areaOrder.getLabel())) {\r
+ areaOrderSelectionCombo.select(index);\r
+ break;\r
+ }\r
+ index++;\r
+ }\r
+ }\r
+\r
+ if (isAdminPreference){\r
+ isShowRank = Boolean.valueOf(PreferencePredicate.ShowRankInDistributionEditor.getDefaultValue().toString());\r
+ }else{\r
+ isShowRank = Boolean.parseBoolean(prefRank.getValue().toString());\r
+ }\r
+\r
+ if (isShowRank) {\r
+ activateRankCombo.select(0);\r
+ } else {\r
+ activateRankCombo.select(1);\r
+ }\r
+\r
+ ownDescriptionForDistributionEditor = Boolean\r
+ .valueOf(PreferencePredicate.OwnDescriptionForDistributionEditor.getDefaultValue().toString());\r
+\r
+ allowOverrideActivatedButton.setSelection(true);\r
+ overrideActivated = true;\r
+\r
+ overrideAreaDisplay = true;\r
+ allowOverrideAreaDisplayButton.setSelection(true);\r
+\r
+ overrideStatusDisplay = true;\r
+ allowOverrideStatusDisplayButton.setSelection(true);\r
+\r
+ overrideOrderAreas = true;\r
+ allowOverrideOrderAreasButton.setSelection(true);\r
+\r
+ overrideRank = true;\r
+ allowOverrideRankButton.setSelection(true);\r
+\r
+ overrideOwnDescriptionForDistributionEditor = true;\r
+\r
+ this.statusPref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.AvailableDistributionStatus, null);\r
+ this.areaVocPref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.AvailableDistributionAreaVocabularies,\r
+ null);\r
+ if (!isAdminPreference) {\r
+ PreferencesUtil.recursiveSetEnabled(child, isEditorActivated);\r
+\r
+ if (!prefAreaVoc.isAllowOverride()) {\r
+ button_openSelectAreaVocabularies.setButtonEnabled(false);\r
+ }\r
+ if (!prefStatus.isAllowOverride()) {\r
+ button_openStatusWizard.setButtonEnabled(false);\r
+ }\r
+ if (!prefRank.isAllowOverride()) {\r
+ activateRankCombo.setEnabled(false);\r
+\r
+ if (!prefAreaSort.isAllowOverride()) {\r
+ areaOrderSelectionCombo.setEnabled(false);\r
+ allowOverrideOrderAreasButton.setEnabled(false);\r
+ }\r
+ if (!prefAreaDisplay.isAllowOverride()) {\r
+ allowOverrideAreaDisplayButton.setEnabled(false);\r
+ }\r
+ if (!prefStatusDisplay.isAllowOverride()) {\r
+ allowOverrideStatusDisplayButton.setEnabled(false);\r
+ }\r
+ }\r
+ super.performDefaults();\r
+ }\r
+ }\r
+\r
+}\r