Merge branch 'release/5.11.0'
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / preference / wizard / AvailableDistributionPerAreaStatusPage.java
index c72f00a3856437573c3c49aced0380d7ae376756..538e4c6bf6e71de82103352ebbd5340bc4f9ab0d 100755 (executable)
@@ -16,6 +16,7 @@ import org.apache.commons.lang.StringUtils;
 import org.eclipse.jface.util.IPropertyChangeListener;
 import org.eclipse.jface.util.PropertyChangeEvent;
 import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
 import org.eclipse.swt.events.SelectionEvent;
 import org.eclipse.swt.events.SelectionListener;
 import org.eclipse.swt.layout.GridData;
@@ -93,8 +94,30 @@ public class AvailableDistributionPerAreaStatusPage extends AvailableDistributio
 
         super.createControl(parent);
 
+
+
     }
+    @Override
+    protected Button createAllowOverrideButton(Composite parent) {
+        Button activateCheckButton = new Button(parent, SWT.CHECK);
+        if (localPref){
+            activateCheckButton.setText("Override");
+            activateCheckButton.setSelection(override);
+        }else{
+            activateCheckButton.setText("Allow Override");
+            activateCheckButton.setSelection(override);
+        }
 
+        activateCheckButton.addSelectionListener(new SelectionAdapter(){
+            @Override
+            public void widgetSelected(SelectionEvent e) {
+                actualPref.setAllowOverride(overrideButton.getSelection());
+                override = overrideButton.getSelection();
+
+            }
+        });
+         return activateCheckButton;
+     }
 
     protected void createAreaSelectionCombo(Composite parent) {
 
@@ -144,6 +167,7 @@ public class AvailableDistributionPerAreaStatusPage extends AvailableDistributio
                         actualPref = CdmPreference.NewInstance(key, null);
                         perAreaPreferences.add(actualPref);
                     }
+                    override = actualPref.isAllowOverride();
                 }else{
                     actualPref = null;
                 }
@@ -213,6 +237,7 @@ public class AvailableDistributionPerAreaStatusPage extends AvailableDistributio
                 PrefKey key = newAreaSpecificStatusPreference();
                 actualPref = PreferenceResolver.resolve(perAreaPreferences, key);
                 areaText.setText(actualArea.getLabel());
+                override = actualPref.isAllowOverride();
             }else{
                 actualPref = null;
             }
@@ -237,6 +262,7 @@ public class AvailableDistributionPerAreaStatusPage extends AvailableDistributio
                }
            }
            checkedValues = actualPref.getValue();
+           override = actualPref.isAllowOverride();
        }
 
        return checkedValues;
@@ -277,6 +303,7 @@ public class AvailableDistributionPerAreaStatusPage extends AvailableDistributio
                perAreaPreferences.remove(actualPref);
             }
             perAreaPreferences.add(savePref);
+            savePref.setAllowOverride(override);
             actualPref = savePref;
 
         }
@@ -299,10 +326,8 @@ public class AvailableDistributionPerAreaStatusPage extends AvailableDistributio
 
 
     public void setActualPreference(CdmPreference pref){
-
         this.actualPref = pref;
-
-
+        override = actualPref.isAllowOverride();
     }