Project

General

Profile

« Previous | Next » 

Revision e4ebff17

Added by Patrick Plitzner over 5 years ago

ref #7439 Remove jface viewer related code

View differences:

eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/annotatedlineeditor/e4/handler/NewObjectHandlerE4.java
17 17
import org.eclipse.e4.ui.services.IServiceConstants;
18 18
import org.eclipse.jface.dialogs.IInputValidator;
19 19
import org.eclipse.jface.dialogs.InputDialog;
20
import org.eclipse.jface.viewers.ISelection;
21 20
import org.eclipse.jface.viewers.IStructuredSelection;
22 21
import org.eclipse.jface.viewers.StructuredSelection;
23 22
import org.eclipse.jface.window.Window;
......
82 81
                }
83 82
                IStructuredSelection selection = new StructuredSelection(createdEntity);
84 83

  
85
                bulkEditor.refresh(true);
84
                bulkEditor.refresh();
86 85
                bulkEditor.setDirty();
87 86
                bulkEditor.setFocus();
88 87

  
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/BulkEditorE4.java
30 30
import org.eclipse.e4.ui.workbench.modeling.ESelectionService;
31 31
import org.eclipse.jface.dialogs.MessageDialog;
32 32
import org.eclipse.jface.layout.GridDataFactory;
33
import org.eclipse.jface.viewers.ISelection;
34 33
import org.eclipse.jface.viewers.ISelectionChangedListener;
35 34
import org.eclipse.jface.viewers.IStructuredSelection;
36 35
import org.eclipse.jface.viewers.StructuredSelection;
37
import org.eclipse.jface.viewers.TableViewer;
38 36
import org.eclipse.nebula.widgets.nattable.NatTable;
37
import org.eclipse.nebula.widgets.nattable.command.VisualRefreshCommand;
39 38
import org.eclipse.nebula.widgets.nattable.config.AbstractUiBindingConfiguration;
40 39
import org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration;
41 40
import org.eclipse.nebula.widgets.nattable.data.IRowIdAccessor;
......
110 109

  
111 110
    private Composite topComposite;
112 111

  
113
    private TableViewer viewer;
114

  
115 112
    private ConversationHolder conversation;
116 113

  
117 114
    @Inject
......
153 150

  
154 151
	    thisPart.setLabel(input.getEditorName());
155 152

  
156
//	    //create columns
157
//	    Table table = viewer.getTable();
158
//	    String[] titles = {input.getName(), "Type"};
159
//	    int[] bounds = {500, 100};
160
//
161
//	    ColumnViewerEditorActivationStrategy activationSupport = new ColumnViewerEditorActivationStrategy(viewer) {
162
//            @Override
163
//            protected boolean isEditorActivationEvent(ColumnViewerEditorActivationEvent event) {
164
//                // Enable editor only with mouse double click
165
//                if (event.eventType == ColumnViewerEditorActivationEvent.MOUSE_DOUBLE_CLICK_SELECTION) {
166
//                    EventObject source = event.sourceEvent;
167
//                    if (source instanceof MouseEvent && ((MouseEvent)source).button == 3) {
168
//                        return false;
169
//                    }
170
//
171
//                    return true;
172
//                }
173
//
174
//                return false;
175
//            }
176
//        };
177
//        TableViewerFocusCellManager focusCellManager = new TableViewerFocusCellManager(viewer, new BulkEditorFocusCellOwnerDrawHighLighter(viewer));
178
//
179
//        TableViewerEditor.create(viewer, focusCellManager, activationSupport, ColumnViewerEditor.TABBING_HORIZONTAL |
180
//                ColumnViewerEditor.TABBING_MOVE_TO_ROW_NEIGHBOR |
181
//                ColumnViewerEditor.TABBING_VERTICAL |
182
//                ColumnViewerEditor.KEYBOARD_ACTIVATION );
183
//
184
//	    CellEditor[] editors = new CellEditor[titles.length];
185
//	    for (int i = 0; i < titles.length; i++) {
186
//	        TableViewerColumn column = new TableViewerColumn(viewer, SWT.NONE);
187
//	        editors[i] = new TextCellEditor(table);
188
//
189
//	        column.getColumn().setText(titles[i]);
190
//	        column.getColumn().setWidth(bounds[i]);
191
//	        column.getColumn().setResizable(true);
192
//	        column.getColumn().setMoveable(true);
193
//
194
//	    }
195
//
196
//	    table.setHeaderVisible(true);
197
//	    table.setLinesVisible(true);
198
//
199
//	    viewer.setCellEditors(editors);
200
//	    viewer.setColumnProperties(titles);
201
//
202
//	    //content and label provider (NOTE: has to be set AFTER creating cell editors
203
//	    viewer.setContentProvider(new ArrayContentProvider());
204
//        BulkEditorLabelProvider labelProvider = new BulkEditorLabelProvider(this);
205
//        viewer.setLabelProvider(labelProvider);
206
//
207
//
208
//        //allow text selection
209
//        viewer.setCellModifier(new ICellModifier() {
210
//            @Override
211
//            public void modify(Object element, String property, Object value) {
212
//            }
213
//            @Override
214
//            public Object getValue(Object element, String property) {
215
//                ITableLabelProvider tableLabelProvider = null;
216
//                if(viewer.getLabelProvider() instanceof ITableLabelProvider){
217
//                    tableLabelProvider = (ITableLabelProvider) viewer.getLabelProvider();
218
//                }
219
//                Object[] columnProperties = viewer.getColumnProperties();
220
//                for (int i=0;i<columnProperties.length;i++) {
221
//                    if(columnProperties[i].equals(property) && tableLabelProvider!=null){
222
//                        return tableLabelProvider.getColumnText(element, i);
223
//                    }
224
//                }
225
//                return "";
226
//            }
227
//            @Override
228
//            public boolean canModify(Object element, String property) {
229
//                return true;
230
//            }
231
//        });
232

  
233

  
234

  
235 153
        if(input.getEntityUuid()!=null){
236 154
            performSearch(new BulkEditorQuery(input.getEntityUuid().toString(), null));
237 155
        }
......
241 159
        propertyToLabels.put(getEditorInput().getName(), getEditorInput().getName());
242 160
        propertyToLabels.put(TYPE_PROPERTY, TYPE_PROPERTY);
243 161
        String[] propertyNames = new String[] { getEditorInput().getName(), TYPE_PROPERTY };
162
        //data provider
244 163
        bodyDataProvider = new ListDataProvider<CdmBase>(getEditorInput().getModel(),
245 164
                new BulkEditorPropertyAccessor(getEditorInput()));
246

  
247

  
248 165
        DefaultColumnHeaderDataProvider colHeaderDataProvider = new DefaultColumnHeaderDataProvider(
249 166
                propertyNames, propertyToLabels);
250 167
        DefaultRowHeaderDataProvider rowHeaderDataProvider = new DefaultRowHeaderDataProvider(
251 168
                bodyDataProvider);
252

  
169
        //body
253 170
        DataLayer dataLayer = new DataLayer(bodyDataProvider);
254 171
        GlazedListsEventLayer<CdmBase> eventLayer = new GlazedListsEventLayer<>(dataLayer, getEditorInput().getModel());
255 172
        DefaultBodyLayerStack bodyLayer = new DefaultBodyLayerStack(eventLayer);
256 173
        selectionLayer = bodyLayer.getSelectionLayer();
257

  
174
        //column
258 175
        ColumnHeaderLayer columnHeaderLayer = new ColumnHeaderLayer(
259 176
                new DataLayer(colHeaderDataProvider),
260 177
                bodyLayer, bodyLayer.getSelectionLayer());
261

  
178
        //row
262 179
        RowHeaderLayer rowHeaderLayer = new RowHeaderLayer(new DataLayer(rowHeaderDataProvider, 50, 20),
263 180
                bodyLayer, bodyLayer.getSelectionLayer());
264

  
181
        //corner
265 182
        DefaultCornerDataProvider cornerDataProvider = new DefaultCornerDataProvider(
266 183
                colHeaderDataProvider, rowHeaderDataProvider);
267 184
        CornerLayer cornerLayer = new CornerLayer(new DataLayer(
......
269 186

  
270 187
        GridLayer gridLayer = new GridLayer(bodyLayer, columnHeaderLayer,
271 188
                rowHeaderLayer, cornerLayer);
272

  
273 189
        dataLayer.setColumnPercentageSizing(true);
274 190
        natTable = new NatTable(bottomComposite, gridLayer, false);
275 191

  
......
345 261
		bottomComposite = new Composite(parent, SWT.NONE);
346 262
		bottomComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
347 263
		bottomComposite.setLayout(new GridLayout());
348

  
349
//		viewer = new TableViewer(bottomComposite, SWT.MULTI | SWT.FULL_SELECTION);
350

  
351
//		createColumns(viewer);
352

  
353
        //propagate selection
354
        selectionChangedListener = (event -> selService.setSelection(AbstractUtility.getElementsFromSelectionChangedEvent(event)));
355
//        viewer.addSelectionChangedListener(selectionChangedListener);
356

  
357
        //create context menu
358
//        menuService.registerContextMenu(viewer.getControl(), "eu.etaxonomy.taxeditor.bulkeditor.popupmenu.bulkeditor"); //$NON-NLS-1$
359 264
	}
360 265

  
361 266
	@Override
......
400 305
            performSearch(lastQuery);
401 306
            setSelection(selection);
402 307
        }
403
//        viewer.refresh();
404

  
405

  
406 308
	}
407 309

  
408 310
	/** {@inheritDoc} */
409 311
    public void performSearch(BulkEditorQuery query) {
410 312
        if (query != null) {
411

  
412 313
            // TODO check if dirty, prompt save
413 314
            if (isDirty()) {
414 315
                String[] labels = {Messages.BulkEditorE4_SAVE_AND_SEARCH, Messages.BulkEditorE4_DONT_SAVE,Messages.BulkEditorE4_CANCEL};
......
421 322
                }
422 323
            }
423 324
            dirty.setDirty(false);
424
//            getEditorInput().dispose();
425
//            getEditorInput().bind();
426 325
            getEditorInput().performSearch(query);
427 326
            lastQuery = query;
428
//            viewer.setInput(model);
429

  
430
            refresh();
431 327
        }
432 328
    }
433 329

  
434
    public void refresh() {
435
//        refresh(true);
436
    }
437 330

  
438
    public void refresh(boolean resetInput) {
439
//        if(resetInput){
440
//            viewer.setInput(getEditorInput().getModel());
441
//        }
442
//        natTable.doCommand(new VisualRefreshCommand());
331
    public void refresh(){
332
        natTable.doCommand(new VisualRefreshCommand());
443 333
    }
444 334

  
445
//    public TableViewer getViewer() {
446
//        return viewer;
447
//    }
448

  
449 335
    public IStructuredSelection getSelection(){
450 336
        List<CdmBase> selection = new ArrayList<>();
451 337
        int[] fullySelectedRowPositions = selectionLayer.getFullySelectedRowPositions();
......
498 384
        }
499 385
    }
500 386

  
501
    /**
502
     * {@inheritDoc}
503
     */
504 387
    @Override
505 388
    public void update(CdmDataChangeMap arg0) {
506 389
    }
507 390

  
508
    /**
509
     * {@inheritDoc}
510
     */
511 391
    @Override
512 392
    public boolean canAttachMedia() {
513 393
        return true;
514 394
    }
515 395

  
516
    /**
517
     * {@inheritDoc}
518
     */
519 396
    @Override
520 397
    public void changed(Object element) {
521 398
        if(element instanceof DerivedUnitFacade){
......
534 411
        dirty.setDirty(true);
535 412
    }
536 413

  
537
    /**
538
     * {@inheritDoc}
539
     */
540 414
    @Override
541 415
    public void forceDirty() {
542 416
        dirty.setDirty(true);
543 417
    }
544 418

  
545
    /**
546
     * {@inheritDoc}
547
     */
548 419
    @Override
549 420
    public boolean postOperation(CdmBase objectAffectedByOperation) {
550 421
        return false;
551 422
    }
552 423

  
553
    /**
554
     * {@inheritDoc}
555
     */
556 424
    @Override
557 425
    public boolean onComplete() {
558 426
        return false;
559 427
    }
560 428

  
561
    /**
562
     * {@inheritDoc}
563
     */
564 429
    @Override
565 430
    public ConversationHolder getConversationHolder() {
566 431
        return conversation;
567 432
    }
568 433

  
569
    /**
570
     * @return
571
     */
572 434
    public BulkEditorQuery getLastQuery() {
573 435
       return lastQuery;
574 436
    }
575 437

  
576
    /**
577
     * @param object
578
     */
579 438
    public void setLastQuery(BulkEditorQuery lastQuery) {
580 439
       this.lastQuery = lastQuery;
581 440

  
582 441
    }
583 442

  
584
    /**
585
     * {@inheritDoc}
586
     */
587 443
    @Override
588 444
    public Taxon getTaxon() {
589
        ISelection selection = viewer.getSelection();
590
        if(selection instanceof IStructuredSelection
591
                && ((IStructuredSelection) selection).size()==1) {
592
            Object object = ((IStructuredSelection) selection).iterator().next();
445
        IStructuredSelection selection = getSelection();
446
        if(selection.size()==1) {
447
            Object object = selection.iterator().next();
593 448
            if(object instanceof Taxon){
594 449
                return (Taxon) object;
595 450
            }
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/handler/DeleteHandlerE4.java
274 274
        if (result.isOk() ){
275 275
            editor.getEditorInput().addToDelete(object, config);
276 276
            editor.getEditorInput().getModel().remove(object);
277
            editor.refresh(true);
277
            editor.refresh();
278 278
            editor.setDirty();
279 279

  
280 280
            if(result.getUpdatedObjects().size() != 0 || !result.getExceptions().isEmpty()){

Also available in: Unified diff