ref #7502 Add table settings to search bar
authorPatrick Plitzner <p.plitzner@bgbm.org>
Mon, 8 Oct 2018 10:12:58 +0000 (12:12 +0200)
committerPatrick Plitzner <p.plitzner@bgbm.org>
Mon, 8 Oct 2018 10:12:58 +0000 (12:12 +0200)
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/BulkEditorE4Composite.java
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/BulkEditorSearchE4.java
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/l10n/Messages.java
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/l10n/messages.properties
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/l10n/messages_de.properties

index c13b9f20695873a72dececff3acc74a1e0160f09..50a9eecbf684b2e813de2f2a901835bada4b7e5d 100644 (file)
@@ -121,6 +121,7 @@ public class BulkEditorE4Composite extends Composite {
     private ListDataProvider<CdmBase> bodyDataProvider;
 
     private BulkEditorE4 bulkEditor;
+    private BulkEditorSearchE4 bulkEditorSearch;
 
 
     public BulkEditorE4Composite(BulkEditorE4 bulkEditor, Composite parent, int style) {
@@ -146,7 +147,7 @@ public class BulkEditorE4Composite extends Composite {
 
         input.getPropertyKeys().forEach(key->columnList.add(key));
 
-           new BulkEditorSearchE4(this, topComposite, SWT.NONE);
+           bulkEditorSearch = new BulkEditorSearchE4(this, topComposite, SWT.NONE);
            //layout needed because the search bar is added after @PostConstuct method
            topComposite.getParent().layout();
 
@@ -355,6 +356,9 @@ public class BulkEditorE4Composite extends Composite {
             }
         });
 
+        //register handler for view configuration menu
+        natTable.registerCommandHandler(bulkEditorSearch.getDisplayPersistenceDialogCommandHandler());
+
         natTable.configure();
        }
 
@@ -438,4 +442,8 @@ public class BulkEditorE4Composite extends Composite {
         }
     }
 
+    NatTable getNatTable() {
+        return natTable;
+    }
+
 }
index 1321eb3f609ac80ab93621658c34821ec756d770..d385dfc72ccc3dca125b0002a92bf89ea4f82bff 100644 (file)
@@ -9,6 +9,13 @@
 
 package eu.etaxonomy.taxeditor.bulkeditor.e4;
 
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.Properties;
+
+import org.eclipse.nebula.widgets.nattable.persistence.command.DisplayPersistenceDialogCommand;
+import org.eclipse.nebula.widgets.nattable.persistence.command.DisplayPersistenceDialogCommandHandler;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.FocusEvent;
 import org.eclipse.swt.events.FocusListener;
@@ -29,8 +36,11 @@ import eu.etaxonomy.cdm.common.CdmUtils;
 import eu.etaxonomy.taxeditor.bulkeditor.BulkEditorQuery;
 import eu.etaxonomy.taxeditor.l10n.Messages;
 import eu.etaxonomy.taxeditor.model.ColorResources;
+import eu.etaxonomy.taxeditor.model.ImageResources;
+import eu.etaxonomy.taxeditor.model.MessagingUtils;
 import eu.etaxonomy.taxeditor.preference.Resources;
 import eu.etaxonomy.taxeditor.store.SearchManager;
+import eu.etaxonomy.taxeditor.workbench.WorkbenchUtility;
 
 /**
  * @author p.ciardelli
@@ -47,10 +57,16 @@ public class BulkEditorSearchE4 {
 
        private final BulkEditorE4Composite editor;
 
+    private DisplayPersistenceDialogCommandHandler displayPersistenceDialogCommandHandler;
+
+    private Properties natTableState;
+
        private Text text;
 
        private Button button;
 
+       private Button btnManageState;
+
 
        public Object ORDER_BY = new Object();
 
@@ -81,9 +97,43 @@ public class BulkEditorSearchE4 {
                        }
                });
 
+               /**
+                * Table state persistence
+                */
+               natTableState = new Properties();
+               //load persisted state
+               File statePropertiesFile = getStatePropertiesFile();
+               FileInputStream inputStream;
+               try {
+                   inputStream = new FileInputStream(statePropertiesFile);
+                   natTableState.load(inputStream);
+               } catch (IOException e) {
+                   MessagingUtils.info("No initial state properties file found for character matrix"); //$NON-NLS-1$
+               }
+
+               // add settings button
+               displayPersistenceDialogCommandHandler = new DisplayPersistenceDialogCommandHandler(natTableState, editor.getNatTable());
+        btnManageState = new Button(container, SWT.PUSH);
+        btnManageState.setImage(ImageResources.getImage(ImageResources.SETTINGS));
+        btnManageState.setToolTipText(Messages.BulkEditorSearchE4_TABLE_SETTINGS);
+        btnManageState.addSelectionListener(new SelectionAdapter() {
+            @Override
+            public void widgetSelected(SelectionEvent e) {
+                editor.getNatTable().doCommand(new DisplayPersistenceDialogCommand(editor.getNatTable()));
+            }
+        });
+
                registerAtFocusService();
        }
 
+    DisplayPersistenceDialogCommandHandler getDisplayPersistenceDialogCommandHandler() {
+        return displayPersistenceDialogCommandHandler;
+    }
+
+    private File getStatePropertiesFile() {
+        return new File(WorkbenchUtility.getBaseLocation(), "bulkeditor_tablestate.properties"); //$NON-NLS-1$
+    }
+
        /**
         * Handles focus changes for the textfield.
         */
index cc7396370a6aa3fdbf6788d16f276c0027122849..90e8d3387c236c855fb8b185a33ca6c66a080703 100644 (file)
@@ -28,6 +28,7 @@ public class Messages extends NLS {
        public static String BulkEditorInputType_7;
        public static String BulkEditorInputType_8;
     public static String BulkEditorSearchE4_SEARCH;
+    public static String BulkEditorSearchE4_TABLE_SETTINGS;
     public static String BulkEditorSearchE4_TITLE_CACHE;
     public static String BulkEditorSearchE4_WILDCARD;
        public static String BulkEditorTooltip_CANDIDATE;
index f301d968de1e5d1f585ff4e92be5eeecaa364782..781dafc3ca3895c4ddbb0bac0194a0762c292ab4 100644 (file)
@@ -17,6 +17,7 @@ BulkEditorInputType_5=Users
 BulkEditorInputType_6=Groups
 BulkEditorInputType_7=Taxa
 BulkEditorInputType_8=Media
+BulkEditorSearchE4_TABLE_SETTINGS=Table settings
 BulkEditorSearchE4_SEARCH=Search
 BulkEditorSearchE4_TITLE_CACHE=Title Cache
 BulkEditorSearchE4_WILDCARD=Use '%s' for wildcard searching
index 8dea600f5e5088c1b9c32e4591a245ad1cdaa187..c6b7f43edbb5383cf51b3606c8f0c258cb42c8f2 100644 (file)
@@ -17,6 +17,7 @@ BulkEditorInputType_5=Nutzer
 BulkEditorInputType_6=Nutzergruppen
 BulkEditorInputType_7=Taxa
 BulkEditorInputType_8=Medien
+BulkEditorSearchE4_TABLE_SETTINGS=Tabellen-Einstellung
 BulkEditorSearchE4_SEARCH=Suche
 BulkEditorSearchE4_TITLE_CACHE=Title-Cache
 BulkEditorSearchE4_WILDCARD='%s' f\u00FCr Platzhalter-Suche benutzen