Project

General

Profile

Revision 39363db1

ID39363db16792a02ce13cf3c16996419f5d05a690
Parent f7dd3e7a
Child f6f03fa3

Added by Patrick Plitzner over 2 years ago

Use NaTable in bulk editor (experimental)

View differences:

eu.etaxonomy.taxeditor.bulkeditor/META-INF/MANIFEST.MF
25 25
 org.eclipse.e4.ui.services,
26 26
 org.eclipse.e4.ui.di,
27 27
 org.eclipse.e4.core.contexts,
28
 org.eclipse.e4.core.services
28
 org.eclipse.e4.core.services,
29
 org.eclipse.nebula.widgets.nattable.core,
30
 ca.odell.glazedlists,
31
 org.eclipse.nebula.widgets.nattable.extension.glazedlists
29 32
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
30 33
Import-Package: eu.etaxonomy.taxeditor.editor,
31 34
 org.eclipse.core.runtime,
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/BulkEditorE4.java
26 26
import org.eclipse.e4.ui.services.EMenuService;
27 27
import org.eclipse.e4.ui.workbench.modeling.ESelectionService;
28 28
import org.eclipse.jface.dialogs.MessageDialog;
29
import org.eclipse.jface.layout.GridDataFactory;
29 30
import org.eclipse.jface.viewers.ArrayContentProvider;
30 31
import org.eclipse.jface.viewers.CellEditor;
31 32
import org.eclipse.jface.viewers.ColumnViewerEditor;
......
41 42
import org.eclipse.jface.viewers.TableViewerEditor;
42 43
import org.eclipse.jface.viewers.TableViewerFocusCellManager;
43 44
import org.eclipse.jface.viewers.TextCellEditor;
45
import org.eclipse.nebula.widgets.nattable.NatTable;
46
import org.eclipse.nebula.widgets.nattable.data.IDataProvider;
47
import org.eclipse.nebula.widgets.nattable.data.ListDataProvider;
48
import org.eclipse.nebula.widgets.nattable.data.ReflectiveColumnPropertyAccessor;
49
import org.eclipse.nebula.widgets.nattable.extension.glazedlists.GlazedListsEventLayer;
50
import org.eclipse.nebula.widgets.nattable.grid.data.DefaultColumnHeaderDataProvider;
51
import org.eclipse.nebula.widgets.nattable.grid.data.DefaultCornerDataProvider;
52
import org.eclipse.nebula.widgets.nattable.grid.data.DefaultRowHeaderDataProvider;
53
import org.eclipse.nebula.widgets.nattable.grid.layer.ColumnHeaderLayer;
54
import org.eclipse.nebula.widgets.nattable.grid.layer.CornerLayer;
55
import org.eclipse.nebula.widgets.nattable.grid.layer.DefaultRowHeaderDataLayer;
56
import org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer;
57
import org.eclipse.nebula.widgets.nattable.layer.DataLayer;
58
import org.eclipse.nebula.widgets.nattable.layer.ILayer;
59
import org.eclipse.nebula.widgets.nattable.layer.stack.DefaultBodyLayerStack;
44 60
import org.eclipse.swt.SWT;
45 61
import org.eclipse.swt.events.MouseEvent;
46 62
import org.eclipse.swt.layout.FillLayout;
......
49 65
import org.eclipse.swt.widgets.Composite;
50 66
import org.eclipse.swt.widgets.Table;
51 67

  
68
import ca.odell.glazedlists.BasicEventList;
52 69
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
53 70
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
54 71
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
......
91 108

  
92 109
    private TableViewer viewer;
93 110

  
111
    private NatTable natTable;
112

  
94 113
    private ConversationHolder conversation;
95 114

  
96 115
    @Inject
......
106 125

  
107 126
    private BulkEditorQuery lastQuery = null;
108 127

  
128
    private BasicEventList<Object> list;
129

  
109 130
    @Inject
110 131
    public BulkEditorE4() {
111 132
	}
......
218 239
		Composite bottomComposite = new Composite(parent, SWT.NONE);
219 240
		bottomComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
220 241
		bottomComposite.setLayout(new FillLayout());
242

  
243

  
244
		//++++NatTable++++
245
		natTable = new NatTable(parent, false);
246
		list = new BasicEventList<>();
247
        ListDataProvider<Object> dataProvider = new ListDataProvider<>(list, new ReflectiveColumnPropertyAccessor<>("titleCache"));
248
        DataLayer dataLayer = new DataLayer(dataProvider);
249
        GlazedListsEventLayer eventLayer = new GlazedListsEventLayer<>(dataLayer, list);
250
        DefaultBodyLayerStack bodyLayerStack = new DefaultBodyLayerStack(eventLayer);
251

  
252
        /**
253
         * column header layer
254
         */
255
        IDataProvider columnHeaderDataProvider = new DefaultColumnHeaderDataProvider(new String[] {"titleCache"});
256
        DataLayer columnHeaderDataLayer = new DataLayer(columnHeaderDataProvider);
257
        ColumnHeaderLayer columnHeaderLayer = new ColumnHeaderLayer(columnHeaderDataLayer, bodyLayerStack, bodyLayerStack.getSelectionLayer());
258

  
259
        /**
260
         * row header layer
261
         */
262
        IDataProvider rowHeaderDataProvider = new DefaultRowHeaderDataProvider(dataProvider);
263
        DefaultRowHeaderDataLayer rowHeaderDataLayer = new DefaultRowHeaderDataLayer(rowHeaderDataProvider);
264

  
265

  
266
        /**
267
         * corner layer
268
         */
269
        ILayer cornerLayer = new CornerLayer(
270
                new DataLayer(new DefaultCornerDataProvider(columnHeaderDataProvider, rowHeaderDataProvider)),
271
                rowHeaderDataLayer, rowHeaderDataLayer);
272

  
273

  
274
        /**
275
         * GRID layer (composition of all other layers)
276
         */
277
        GridLayer gridLayer = new GridLayer(bodyLayerStack, columnHeaderLayer, rowHeaderDataLayer, cornerLayer);
278

  
279
        natTable.setLayer(gridLayer);
280

  
281
        natTable.configure();
282

  
283
        GridDataFactory.fillDefaults().grab(true, true).applyTo(natTable);
284

  
285

  
286

  
287

  
288

  
289

  
290

  
291

  
292

  
293

  
294

  
295

  
296

  
221 297
		viewer = new TableViewer(bottomComposite, SWT.MULTI | SWT.FULL_SELECTION);
222 298

  
223 299
//		createColumns(viewer);
......
298 374
//            getEditorInput().bind();
299 375
            getEditorInput().performSearch(query);
300 376
            lastQuery = query;
301
            viewer.setInput(getEditorInput().getModel());
377
            List model = getEditorInput().getModel();
378
            viewer.setInput(model);
379
            list.clear();
380
            list.addAll(model);
381

  
302 382
            refresh();
303 383
        }
304 384
    }

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)