ref #7793: add preference to set checklist perspective as default
authorKatja Luther <k.luther@bgbm.org>
Wed, 10 Oct 2018 12:01:45 +0000 (14:01 +0200)
committerKatja Luther <k.luther@bgbm.org>
Wed, 10 Oct 2018 12:01:45 +0000 (14:01 +0200)
eu.etaxonomy.taxeditor.application/src/main/java/eu/etaxonomy/taxeditor/ApplicationWorkbenchAdvisor.java
eu.etaxonomy.taxeditor.application/src/main/java/eu/etaxonomy/taxeditor/LifeCycleManager.java
eu.etaxonomy.taxeditor.application/src/main/java/eu/etaxonomy/taxeditor/perspective/ChecklistPerspective.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/checklist/e4/ChecklistEditorE4.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/databaseAdmin/preferencePage/GeneralAdminPreferencePage.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/l10n/Messages.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/l10n/messages.properties
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/l10n/messages_de.properties
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/IPreferenceKeys.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/PreferencesUtil.java

index d6baf5fef54e7588ed62103bea098a7adcb38de1..87ce8986fc43b9672977a9f28f680ffefcacbcea 100644 (file)
@@ -12,6 +12,7 @@ import org.springframework.remoting.RemoteAccessException;
 import org.springframework.remoting.RemoteConnectFailureException;
 
 import eu.etaxonomy.taxeditor.model.MessagingUtils;
+import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
 import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
 
 
@@ -49,6 +50,10 @@ public class ApplicationWorkbenchAdvisor extends WorkbenchAdvisor {
         */
        @Override
     public String getInitialWindowPerspectiveId() {
+           if (PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_CHECKLIST_PERSPECTIVE)){
+               return "eu.etaxonomy.taxeditor.perspective.checklistperspective";
+           }
+
                return "eu.etaxonomy.taxeditor.application.perspective.taxonomic";
        }
 
index 382829e30834399068d0a07d09df8ed07a74d76b..5162b13587f4c3eccf0036dd8c7e91060da81b44 100644 (file)
@@ -31,9 +31,15 @@ import org.eclipse.e4.ui.workbench.lifecycle.ProcessRemovals;
 import org.eclipse.e4.ui.workbench.modeling.EModelService;
 import org.eclipse.e4.ui.workbench.modeling.EPartService;
 import org.eclipse.ui.IMemento;
+import org.eclipse.ui.IPerspectiveRegistry;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
 import org.osgi.service.event.Event;
 
 import eu.etaxonomy.taxeditor.model.IContextListener;
+import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
 import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
 import eu.etaxonomy.taxeditor.store.CdmStore;
 
@@ -104,6 +110,7 @@ public class LifeCycleManager implements IContextListener{
                 parent.getChildren().remove(part);
             }
         }
+
     }
 
     /**
@@ -128,6 +135,15 @@ public class LifeCycleManager implements IContextListener{
     public void contextStart(IMemento memento, IProgressMonitor monitor) {
         PreferencesUtil.updateDBPreferences();
         hideParts();
+        if (PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_CHECKLIST_PERSPECTIVE)){
+            IWorkbench workbench = PlatformUI.getWorkbench();
+            IWorkbenchWindow window = workbench
+                    .getActiveWorkbenchWindow();
+
+            IPerspectiveRegistry registry = workbench.getPerspectiveRegistry();
+            IWorkbenchPage page = window.getActivePage();
+            page.setPerspective(registry.findPerspectiveWithId("eu.etaxonomy.taxeditor.perspective.checklistperspective"));
+        }
     }
 
     /**
index ad13318d600d03790ab36dc61779ab9610834421..e7f0a1341557f7677cca2a288bd901f339846090 100644 (file)
@@ -32,16 +32,35 @@ public class ChecklistPerspective extends Default {
        public void createInitialLayout(IPageLayout layout) {
                IFolderLayout navigationFolder = layout.createFolder("navigation",
                                IPageLayout.LEFT, 0.25f, layout.getEditorArea());
+//
+//             navigationFolder.addView(NAVIGATOR);
+//             navigationFolder.addPlaceholder(SEARCH_RESULTS);
+//        navigationFolder.addPlaceholder(AppModelId.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_EDITOR_DESCRIPTIVEDATASET_DESCRIPTIVEDATASETNAVIGATOR);
+//
+//             IFolderLayout folder = layout.createFolder("Folder", IPageLayout.BOTTOM, 0.6f, layout.getEditorArea());
+//             folder.addView(FACTUAL_DATA_VIEW);
+//             folder.addView(DETAILS_VIEW);
+//             folder.addView(MediaViewPart.ID);
+
+//             createAdditionalFolder(layout, layout.getEditorArea());
+
 
                navigationFolder.addView(NAVIGATOR);
-               navigationFolder.addPlaceholder(SEARCH_RESULTS);
+        navigationFolder.addPlaceholder(SEARCH_RESULTS);
         navigationFolder.addPlaceholder(AppModelId.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_EDITOR_DESCRIPTIVEDATASET_DESCRIPTIVEDATASETNAVIGATOR);
 
-               IFolderLayout folder = layout.createFolder("Folder", IPageLayout.BOTTOM, 0.6f, layout.getEditorArea());
-               folder.addView(FACTUAL_DATA_VIEW);
-               folder.addView(DETAILS_VIEW);
-//             folder.addView(MediaViewPart.ID);
+        layout.addPlaceholder(NAME_EDITOR, IPageLayout.BOTTOM, 0.25f, layout.getEditorArea());
+
+        layout.addView(DETAILS_VIEW, IPageLayout.RIGHT, 0.6f, layout.getEditorArea());
+        IFolderLayout supplementalFolder = layout.createFolder(SUPPLEMENTAL_VIEW+"stack", IPageLayout.BOTTOM, 0.6f, DETAILS_VIEW);
+        supplementalFolder.addView(SUPPLEMENTAL_VIEW);
+
+        supplementalFolder.addPlaceholder(REFERENCING_VIEW);
+
+        layout.addView(FACTUAL_DATA_VIEW, IPageLayout.BOTTOM, 0.6f, layout.getEditorArea());
+
+
+        createAdditionalFolder(layout, layout.getEditorArea());
 
-//             createAdditionalFolder(layout, layout.getEditorArea());
        }
 }
index 2cff153c119839a804fafe3ea3b496525b218a40..9185e375682e064f4f68451afe9dedb3d19ca189 100644 (file)
@@ -77,7 +77,6 @@ import eu.etaxonomy.taxeditor.editor.view.checklist.listener.ChecklistFocusListe
 import eu.etaxonomy.taxeditor.editor.view.checklist.listener.ChecklistModifyListener;
 import eu.etaxonomy.taxeditor.model.IDirtyMarkable;
 import eu.etaxonomy.taxeditor.model.IPartContentHasDetails;
-import eu.etaxonomy.taxeditor.model.IPartContentHasFactualData;
 import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
 import eu.etaxonomy.taxeditor.preference.Resources;
 import eu.etaxonomy.taxeditor.preference.wizard.AvailableDistributionWizard;
@@ -90,7 +89,7 @@ import eu.etaxonomy.taxeditor.workbench.part.IE4SavablePart;
  * @author k.luther
  *
  */
-public class ChecklistEditorE4 implements IPartContentHasFactualData, IConversationEnabled,
+public class ChecklistEditorE4 implements  IConversationEnabled,
        IDirtyMarkable, IPartContentHasDetails, IE4SavablePart, IDistributionEditor{
 
     private static final String DISTRIBUTION_EDITOR = "Distribution Editor";
index 9acf660d053b1d4edbfbe2761635e270b3eed815..5b9f358fcfc463eb507cc080a18b0510bbc5f94a 100755 (executable)
@@ -36,6 +36,8 @@ public class GeneralAdminPreferencePage extends CdmPreferencePage implements IE4
 
 
     boolean isShowIOMenu = true;
+    boolean isShowMediaView = true;
+    boolean isShowCheckListPerspective = false;
     /**
      * {@inheritDoc}
      */
@@ -53,6 +55,18 @@ public class GeneralAdminPreferencePage extends CdmPreferencePage implements IE4
             if (isShowSpecimenPref != null){
                 this.isShowIOMenu = Boolean.valueOf(isShowSpecimenPref.getValue());
             }
+
+            key = CdmPreference.NewKey(PreferenceSubject.NewDatabaseInstance(), PreferencePredicate.ShowMediaView);
+            CdmPreference isShowMediaViewPref = service.find(key);
+            if (isShowMediaViewPref != null){
+                this.isShowMediaView = Boolean.valueOf(isShowMediaViewPref.getValue());
+            }
+
+            key = CdmPreference.NewKey(PreferenceSubject.NewDatabaseInstance(), PreferencePredicate.ShowChecklistPerspective);
+            CdmPreference isShowChecklistPref = service.find(key);
+            if (isShowChecklistPref != null){
+                this.isShowCheckListPerspective = Boolean.valueOf(isShowChecklistPref.getValue());
+            }
         }
         final Button showIOMenuButton = new Button(composite, SWT.CHECK);
 
@@ -66,6 +80,32 @@ public class GeneralAdminPreferencePage extends CdmPreferencePage implements IE4
 
               }
          });
+
+        final Button showMediaViewButton = new Button(composite, SWT.CHECK);
+
+        showMediaViewButton.setText(Messages.DatabasePreferncesPage_Show_MediaView);
+
+        showMediaViewButton.setSelection(isShowMediaView);
+        showMediaViewButton.addSelectionListener(new SelectionAdapter(){
+             @Override
+             public void widgetSelected(SelectionEvent e) {
+                 isShowMediaView = showIOMenuButton.getSelection();
+
+              }
+         });
+        final Button showChecklistPerspectiveButton = new Button(composite, SWT.CHECK);
+
+        showChecklistPerspectiveButton.setText(Messages.DatabasePreferncesPage_Show_ChecklistPerspective);
+
+        showChecklistPerspectiveButton.setSelection(isShowCheckListPerspective);
+        showChecklistPerspectiveButton.addSelectionListener(new SelectionAdapter(){
+             @Override
+             public void widgetSelected(SelectionEvent e) {
+                 isShowCheckListPerspective = showChecklistPerspectiveButton.getSelection();
+
+              }
+         });
+
         return composite;
     }
 
@@ -84,6 +124,12 @@ public class GeneralAdminPreferencePage extends CdmPreferencePage implements IE4
            CdmPreference pref = CdmPreference.NewDatabaseInstance(PreferencePredicate.ShowImportExportMenu, Boolean.toString(this.isShowIOMenu));
            pref.setAllowOverride(false);
            service.set(pref);
+           pref = CdmPreference.NewDatabaseInstance(PreferencePredicate.ShowMediaView, Boolean.toString(this.isShowMediaView));
+           pref.setAllowOverride(false);
+           service.set(pref);
+           pref = CdmPreference.NewDatabaseInstance(PreferencePredicate.ShowChecklistPerspective, Boolean.toString(this.isShowCheckListPerspective));
+           pref.setAllowOverride(false);
+           service.set(pref);
            PreferencesUtil.updateDBPreferences();
 
 
index 19518c9846fe8d523c0351810267dafcdb868ca7..cfd7a2012cbc05f5a26a6bf4171ec21bd9a8264a 100644 (file)
@@ -446,6 +446,12 @@ public class Messages extends NLS {
 
     public static String Distribution_status_selection;
 
+
+    public static String DatabasePreferncesPage_Show_MediaView;
+
+
+    public static String DatabasePreferncesPage_Show_ChecklistPerspective;
+
     static {
         // initialize resource bundle
         NLS.initializeMessages(BUNDLE_NAME, Messages.class);
index 1b93ba3f390ab71f3249749703b8010378b8bf27..777ba1415425967ad66a91c7d435dbe8d5503829 100644 (file)
@@ -337,3 +337,5 @@ DatabasePreferncesPage_Show_Specimen=Show specimen related views and menu entrie
 SpecimenConfiguration_description=Select whether you want to edit specimen related data and how they should be displayed.
 DatabasePreferncesPage_Show_IOMenu=Show Import/Export menu entries
 Distribution_status_selection=Status Selection
+DatabasePreferncesPage_Show_MediaView=Show Media View
+DatabasePreferncesPage_Show_ChecklistPerspective=Show Checklist Perspective as default Perspective
\ No newline at end of file
index 34baf583fe29d108f2b169a327a2638e5349bcac..d64f88de125b25f854092c275c0b6ab7d8fa443e 100644 (file)
@@ -336,3 +336,5 @@ DatabasePreferncesPage_Show_Specimen=Zeige Specimenbezogene Views und Men
 SpecimenConfiguration_description=Wählen Sie aus, ob sie specimenbezogene Daten editieren wollen und wie diese angezeigt werden sollen.
 DatabasePreferncesPage_Show_IOMenu=Zeige Import/Export Menü Einträge an
 Distribution_status_selection=Status Auswahl
+DatabasePreferncesPage_Show_MediaView=Zeige den Media View an
+DatabasePreferncesPage_Show_ChecklistPerspective=Zeige Checklist Perspektive als Default Perspektive an
index fa3a812c617d9f84c6d6eadc559dd9f19c6aec55..284b4cae9bd88ce4f8b1d400968f5ace89fc1dff 100644 (file)
@@ -243,6 +243,9 @@ public interface IPreferenceKeys {
     public static final String FILTER_COMMON_NAME_REFERENCES = "eu.etaxonomy.taxeditor.references.selection.filterCommonNameReferences";
     public static final String SHOW_IO_MENU = "eu.etaxonomy.taxeditor.menu.showIO";
 
+    public static final String SHOW_MEDIA = "eu.etaxonomy.taxeditor.view.showMedia";
+    public static final String SHOW_CHECKLIST_PERSPECTIVE = "eu.etaxonomy.taxeditor.perspective.showChecklist";
+
 
 
 
index 430b7b7f662637d5372b0f07ce389391fffb1043..98bc3df1b67bf4a513ce631dabac4528d785e275 100644 (file)
@@ -1614,6 +1614,21 @@ public static void updateDBPreferences() {
             prefStore.setValue(SHOW_IO_MENU, preference.getValue());
         }
     }
+
+    preference = getPreferenceFromDB(PreferencePredicate.ShowMediaView);
+    if (preference != null){
+        if(!prefStore.getBoolean(SHOW_MEDIA) ||  !preference.isAllowOverride()){
+            prefStore.setValue(SHOW_MEDIA, preference.getValue());
+        }
+    }
+
+    preference = getPreferenceFromDB(PreferencePredicate.ShowChecklistPerspective);
+    if (preference != null){
+        if(!prefStore.getBoolean(SHOW_CHECKLIST_PERSPECTIVE) ||  !preference.isAllowOverride()){
+            prefStore.setValue(SHOW_CHECKLIST_PERSPECTIVE, preference.getValue());
+        }
+    }
+
     //Specimen Details
     preference = getPreferenceFromDB(PreferencePredicate.ShowSpecimen);
     if (preference != null){