Project

General

Profile

« Previous | Next » 

Revision ef7ec8ab

Added by Patrick Plitzner over 5 years ago

ref #7502 Add table settings to search bar

View differences:

eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/BulkEditorE4Composite.java
121 121
    private ListDataProvider<CdmBase> bodyDataProvider;
122 122

  
123 123
    private BulkEditorE4 bulkEditor;
124
    private BulkEditorSearchE4 bulkEditorSearch;
124 125

  
125 126

  
126 127
    public BulkEditorE4Composite(BulkEditorE4 bulkEditor, Composite parent, int style) {
......
146 147

  
147 148
        input.getPropertyKeys().forEach(key->columnList.add(key));
148 149

  
149
	    new BulkEditorSearchE4(this, topComposite, SWT.NONE);
150
	    bulkEditorSearch = new BulkEditorSearchE4(this, topComposite, SWT.NONE);
150 151
	    //layout needed because the search bar is added after @PostConstuct method
151 152
	    topComposite.getParent().layout();
152 153

  
......
355 356
            }
356 357
        });
357 358

  
359
        //register handler for view configuration menu
360
        natTable.registerCommandHandler(bulkEditorSearch.getDisplayPersistenceDialogCommandHandler());
361

  
358 362
        natTable.configure();
359 363
	}
360 364

  
......
438 442
        }
439 443
    }
440 444

  
445
    NatTable getNatTable() {
446
        return natTable;
447
    }
448

  
441 449
}
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/BulkEditorSearchE4.java
9 9

  
10 10
package eu.etaxonomy.taxeditor.bulkeditor.e4;
11 11

  
12
import java.io.File;
13
import java.io.FileInputStream;
14
import java.io.IOException;
15
import java.util.Properties;
16

  
17
import org.eclipse.nebula.widgets.nattable.persistence.command.DisplayPersistenceDialogCommand;
18
import org.eclipse.nebula.widgets.nattable.persistence.command.DisplayPersistenceDialogCommandHandler;
12 19
import org.eclipse.swt.SWT;
13 20
import org.eclipse.swt.events.FocusEvent;
14 21
import org.eclipse.swt.events.FocusListener;
......
29 36
import eu.etaxonomy.taxeditor.bulkeditor.BulkEditorQuery;
30 37
import eu.etaxonomy.taxeditor.l10n.Messages;
31 38
import eu.etaxonomy.taxeditor.model.ColorResources;
39
import eu.etaxonomy.taxeditor.model.ImageResources;
40
import eu.etaxonomy.taxeditor.model.MessagingUtils;
32 41
import eu.etaxonomy.taxeditor.preference.Resources;
33 42
import eu.etaxonomy.taxeditor.store.SearchManager;
43
import eu.etaxonomy.taxeditor.workbench.WorkbenchUtility;
34 44

  
35 45
/**
36 46
 * @author p.ciardelli
......
47 57

  
48 58
	private final BulkEditorE4Composite editor;
49 59

  
60
    private DisplayPersistenceDialogCommandHandler displayPersistenceDialogCommandHandler;
61

  
62
    private Properties natTableState;
63

  
50 64
	private Text text;
51 65

  
52 66
	private Button button;
53 67

  
68
	private Button btnManageState;
69

  
54 70

  
55 71
	public Object ORDER_BY = new Object();
56 72

  
......
81 97
			}
82 98
		});
83 99

  
100
		/**
101
		 * Table state persistence
102
		 */
103
		natTableState = new Properties();
104
		//load persisted state
105
		File statePropertiesFile = getStatePropertiesFile();
106
		FileInputStream inputStream;
107
		try {
108
		    inputStream = new FileInputStream(statePropertiesFile);
109
		    natTableState.load(inputStream);
110
		} catch (IOException e) {
111
		    MessagingUtils.info("No initial state properties file found for character matrix"); //$NON-NLS-1$
112
		}
113

  
114
		// add settings button
115
		displayPersistenceDialogCommandHandler = new DisplayPersistenceDialogCommandHandler(natTableState, editor.getNatTable());
116
        btnManageState = new Button(container, SWT.PUSH);
117
        btnManageState.setImage(ImageResources.getImage(ImageResources.SETTINGS));
118
        btnManageState.setToolTipText(Messages.BulkEditorSearchE4_TABLE_SETTINGS);
119
        btnManageState.addSelectionListener(new SelectionAdapter() {
120
            @Override
121
            public void widgetSelected(SelectionEvent e) {
122
                editor.getNatTable().doCommand(new DisplayPersistenceDialogCommand(editor.getNatTable()));
123
            }
124
        });
125

  
84 126
		registerAtFocusService();
85 127
	}
86 128

  
129
    DisplayPersistenceDialogCommandHandler getDisplayPersistenceDialogCommandHandler() {
130
        return displayPersistenceDialogCommandHandler;
131
    }
132

  
133
    private File getStatePropertiesFile() {
134
        return new File(WorkbenchUtility.getBaseLocation(), "bulkeditor_tablestate.properties"); //$NON-NLS-1$
135
    }
136

  
87 137
	/**
88 138
	 * Handles focus changes for the textfield.
89 139
	 */
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/l10n/Messages.java
28 28
	public static String BulkEditorInputType_7;
29 29
	public static String BulkEditorInputType_8;
30 30
    public static String BulkEditorSearchE4_SEARCH;
31
    public static String BulkEditorSearchE4_TABLE_SETTINGS;
31 32
    public static String BulkEditorSearchE4_TITLE_CACHE;
32 33
    public static String BulkEditorSearchE4_WILDCARD;
33 34
	public static String BulkEditorTooltip_CANDIDATE;
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/l10n/messages.properties
17 17
BulkEditorInputType_6=Groups
18 18
BulkEditorInputType_7=Taxa
19 19
BulkEditorInputType_8=Media
20
BulkEditorSearchE4_TABLE_SETTINGS=Table settings
20 21
BulkEditorSearchE4_SEARCH=Search
21 22
BulkEditorSearchE4_TITLE_CACHE=Title Cache
22 23
BulkEditorSearchE4_WILDCARD=Use '%s' for wildcard searching
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/l10n/messages_de.properties
17 17
BulkEditorInputType_6=Nutzergruppen
18 18
BulkEditorInputType_7=Taxa
19 19
BulkEditorInputType_8=Medien
20
BulkEditorSearchE4_TABLE_SETTINGS=Tabellen-Einstellung
20 21
BulkEditorSearchE4_SEARCH=Suche
21 22
BulkEditorSearchE4_TITLE_CACHE=Title-Cache
22 23
BulkEditorSearchE4_WILDCARD='%s' f\u00FCr Platzhalter-Suche benutzen

Also available in: Unified diff