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.editparts;
|
12
|
|
13
|
import org.eclipse.draw2d.IFigure;
|
14
|
|
15
|
import org.eclipse.gef.EditPart;
|
16
|
|
17
|
/**
|
18
|
* Responsible for locating <i>layers</i> in a <code>GraphicalViewer</code>.
|
19
|
* Layers are just transparent {@link org.eclipse.draw2d.Figure figures}.
|
20
|
* <P>
|
21
|
* Typically, the <code>RootEditPart</code> will register() itself as the
|
22
|
* LayerManager for the GraphicalViewer. All other EditParts/EditPolicies
|
23
|
* looking for a layer use the Viewer's
|
24
|
* {@link org.eclipse.gef.EditPartViewer#getEditPartRegistry() editPartRegsitry}
|
25
|
* to find the <code>LayerManager</code>.
|
26
|
*
|
27
|
* @author hudsonr
|
28
|
* @since 2.0
|
29
|
*/
|
30
|
public interface LayerManager {
|
31
|
|
32
|
/**
|
33
|
* This key used to register the LayerManager in the Viewer's
|
34
|
* EditPartRegistry.
|
35
|
*/
|
36
|
Object ID = new Object();
|
37
|
|
38
|
/**
|
39
|
* Returns a specified layer.
|
40
|
*
|
41
|
* @param key
|
42
|
* a key identifying the layer
|
43
|
* @return the specified layer
|
44
|
*/
|
45
|
IFigure getLayer(Object key);
|
46
|
|
47
|
/**
|
48
|
* A static helper
|
49
|
*
|
50
|
* @since 2.0
|
51
|
*/
|
52
|
class Helper {
|
53
|
/**
|
54
|
* Finds the LayerManager given any EditPart in the Viewer.
|
55
|
*
|
56
|
* @param part
|
57
|
* any EditPart in a GraphicalViewer
|
58
|
* @return the <code>LayerManager</code>
|
59
|
*/
|
60
|
public static LayerManager find(EditPart part) {
|
61
|
return (LayerManager) part.getViewer().getEditPartRegistry()
|
62
|
.get(ID);
|
63
|
}
|
64
|
}
|
65
|
|
66
|
}
|