Project

General

Profile

Download (3.59 KB) Statistics
| Branch: | Tag: | Revision:
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2010 IBM Corporation 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
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.gef;
12

    
13
/**
14
 * A specialization of {@link GraphicalEditPart GraphicalEditPart} for
15
 * representing connections. ConnectionEditParts must join a <I>source</I> and
16
 * <I>target</I> EditPart. Its Figure is typically a line between two "nodes",
17
 * with possible decorations on that line.
18
 * <P>
19
 * In GEF, ConnectionEditParts are <EM><I>structural features</I></EM> of their
20
 * source and target "nodes", which are EditParts. However, the model does not
21
 * have this requirement. The application may store the connection model in any
22
 * way, or there may even be no real model. The burden is on the source and
23
 * target EditPart to obtain their appropriate connections in the methods
24
 * {@link org.eclipse.gef.editparts.AbstractGraphicalEditPart#getModelSourceConnections()
25
 * getModelSourceConnections()} and
26
 * {@link org.eclipse.gef.editparts.AbstractGraphicalEditPart#getModelTargetConnections()
27
 * getModelTargetConnections()}. How this is done is application specific.
28
 * <P>
29
 * Since ConnectionEditParts are features of their node EditPart, it is those
30
 * EditParts that must create and manage the connection. Creation is performed
31
 * by whichever end happens to "intialize" itself first. Therefore an end always
32
 * looks first in the
33
 * {@link org.eclipse.gef.EditPartViewer#getEditPartRegistry() EditPartRegistry}
34
 * to see if the connection was already created by the other end.
35
 * <P>
36
 * ConnectionEditParts are EditParts, and therefore can have children. This is a
37
 * common way to implement labels and other selectable decorations on
38
 * connections. Similarly, a ConnectionEditPart can also be a "node", meaning it
39
 * can serve as the source or target of some other ConnectionEditPart. This
40
 * makes connection to connection possible.
41
 * <P>
42
 * IMPORTANT: The need to display something as a line does not automatically
43
 * mean that a ConnectionEditPart is required. There are several situations in
44
 * which ConnectionEditParts should not be used. You should use
45
 * ConnectionEditParts in general if:
46
 * <UL>
47
 * <LI>The connection should be selectable by the user independant of its
48
 * "nodes".
49
 * <LI>The connection can be deleted, leaving the source and target intact.
50
 * <LI>The connection cannot exist without a source and target. A instance of
51
 * when this is <B>not</B> true is <I>assocations</I>. Associations are
52
 * top-level object that are children of the diagram. They are probably only
53
 * valid if they have a source and target, but many applications allow you to
54
 * create things in any order.
55
 * </UL>
56
 */
57
public interface ConnectionEditPart extends GraphicalEditPart {
58

    
59
	/**
60
	 * @return the EditPart at the <i>source</i> end of this connection.
61
	 */
62
	EditPart getSource();
63

    
64
	/**
65
	 * @return the EditPart at the <i>target</i> end of this connection.
66
	 */
67
	EditPart getTarget();
68

    
69
	/**
70
	 * Sets the <i>source</i> of this connection.
71
	 * 
72
	 * @param source
73
	 *            the source of this connection
74
	 */
75
	void setSource(EditPart source);
76

    
77
	/**
78
	 * Sets the<i>target</i> of this connection.
79
	 * 
80
	 * @param target
81
	 *            the target of this connection
82
	 */
83
	void setTarget(EditPart target);
84
}
(6-6/44)