Package: DynamicEditingDomainViewerDropAdapter

DynamicEditingDomainViewerDropAdapter

nameinstructionbranchcomplexitylinemethod
DynamicEditingDomainViewerDropAdapter(Viewer)
M: 0 C: 5
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
drop(DropTargetEvent)
M: 0 C: 25
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 7
100%
M: 0 C: 1
100%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2016 RCP Vision (http://www.rcp-vision.com) and others.
3: * All rights reserved. This program and the accompanying materials
4: * are made available under the terms of the Eclipse Public License v1.0
5: * which accompanies this distribution, and is available at
6: * http://www.eclipse.org/legal/epl-v10.html
7: *
8: * Contributors:
9: * Lorenzo Bettini - initial API and implementation
10: *******************************************************************************/
11: package org.eclipse.emf.parsley.internal.edit.ui.dnd;
12:
13: import java.util.Collection;
14:
15: import org.eclipse.emf.edit.ui.dnd.EditingDomainViewerDropAdapter;
16: import org.eclipse.emf.parsley.edit.domain.EditingDomainFinderStrategy;
17: import org.eclipse.jface.viewers.Viewer;
18: import org.eclipse.swt.dnd.DropTargetEvent;
19:
20: import com.google.common.collect.Iterables;
21: import com.google.inject.Inject;
22:
23: /**
24: * A specialization of {@link EditingDomainViewerDropAdapter} that retrieves the
25: * editing domain dynamically from the object that is being dragged and dropped.
26: *
27: * @noextend This class is not intended to be subclassed by clients.
28: * @noinstantiate This class is not intended to be instantiated by clients.
29: *
30: * @author Lorenzo Bettini - initial API and implementation
31: *
32: */
33: public class DynamicEditingDomainViewerDropAdapter extends EditingDomainViewerDropAdapter {
34:
35:         @Inject
36:         private EditingDomainFinderStrategy editingDomainFinderStrategy;
37:
38:         public DynamicEditingDomainViewerDropAdapter(Viewer viewer) {
39:                 super(null, viewer);
40:         }
41:
42:         @Override
43:         public void drop(DropTargetEvent event) {
44:                 Collection<?> dragSource = extractDragSource(event.data);
45:                 Object firstElement = Iterables.getFirst(dragSource, null);
46:                 editingDomainFinderStrategy.updateEditingDomain(firstElement);
47:                 domain = editingDomainFinderStrategy.getEditingDomain();
48:•                if (domain != null) {
49:                         super.drop(event);
50:                 }
51:         }
52: }