Package: ECPDropAdapter
ECPDropAdapter
name | instruction | branch | complexity | line | method | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ECPDropAdapter() |
|
|
|
|
|
||||||||||||||||||||
ECPDropAdapter(EditingDomain, Viewer) |
|
|
|
|
|
||||||||||||||||||||
getProjectDomain(Object) |
|
|
|
|
|
||||||||||||||||||||
setEditingDomain(EditingDomain) |
|
|
|
|
|
||||||||||||||||||||
setViewer(Viewer) |
|
|
|
|
|
Coverage
1: /*******************************************************************************
2: * Copyright (c) 2011-2012 EclipseSource Muenchen GmbH and others.
3: *
4: * All rights reserved. This program and the accompanying materials
5: * are made available under the terms of the Eclipse Public License 2.0
6: * which accompanies this distribution, and is available at
7: * https://www.eclipse.org/legal/epl-2.0/
8: *
9: * SPDX-License-Identifier: EPL-2.0
10: *
11: * Contributors:
12: * Eugen Neufeld - initial API and implementation
13: ******************************************************************************/
14: package org.eclipse.emf.ecp.ui.common.dnd;
15:
16: import org.eclipse.emf.ecp.core.ECPProject;
17: import org.eclipse.emf.ecp.core.util.ECPUtil;
18: import org.eclipse.emf.edit.domain.EditingDomain;
19: import org.eclipse.emf.edit.ui.dnd.EditingDomainViewerDropAdapter;
20: import org.eclipse.jface.viewers.Viewer;
21:
22: /**
23: * @author Eugen Neufeld
24: *
25: */
26: public abstract class ECPDropAdapter extends EditingDomainViewerDropAdapter {
27:
28:         /**
29:          * Default constructor for drop adapters initialized by extension point.
30:          */
31:         public ECPDropAdapter() {
32:                 this(null, null);
33:         }
34:
35:         /**
36:          * Constructor.
37:          *
38:          * @param domain the {@link EditingDomain} to use
39:          * @param viewer the Viewer this {@link EditingDomainViewerDropAdapter} is applied to
40:          */
41:         public ECPDropAdapter(EditingDomain domain, Viewer viewer) {
42:                 super(domain, viewer);
43:         }
44:
45:         /**
46:          *
47:          * @param editingDomain Th {@link EditingDomain} to be used.
48:          */
49:         public void setEditingDomain(EditingDomain editingDomain) {
50:                 domain = editingDomain;
51:         }
52:
53:         /**
54:          *
55:          * @param viewer The {@link Viewer}, this drop adapter operates on
56:          */
57:         public void setViewer(Viewer viewer) {
58:                 this.viewer = viewer;
59:         }
60:
61:         /**
62:          * Helper method to find the editing domain the provided object belongs to.
63:          *
64:          * @param object the {@link Object} to find the {@link EditingDomain} for
65:          * @return the EditingDomain of this Object or null
66:          */
67:         protected EditingDomain getProjectDomain(Object object) {
68:                 final ECPProject project = ECPUtil.getECPProjectManager().getProject(object);
69:•                if (project != null) {
70:                         return project.getEditingDomain();
71:                 }
72:                 return null;
73:         }
74: }