1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
/*******************************************************************************
* Copyright (c) 2007, 2017 THALES GLOBAL SERVICES.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Obeo - initial API and implementation
*******************************************************************************/
package org.eclipse.sirius.diagram.ui.edit.api.part;
import java.util.List;
import java.util.Optional;
import org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeNodeEditPart;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.sirius.diagram.DDiagram;
import org.eclipse.sirius.diagram.DiagramPackage;
import org.eclipse.sirius.diagram.ui.business.api.query.ViewQuery;
import org.eclipse.sirius.diagram.ui.business.internal.view.ShowingViewUtil;
import org.eclipse.sirius.diagram.ui.internal.edit.parts.refresh.LabelAndIconRefresher;
/**
* <p>
* A standard ShapeNodeEditPart that have the peculiarity of not being selectable.
* </p>
* <p>
* Typically, all IStyleEditPart should extends this class, so that the <i>Select All Shapes</i> action doesn't select
* them.
* </p>
*
* @author <a href="mailto:alex.lagarde@obeo.fr">Alex Lagarde</a>
*/
// Select Object not clearly update
public abstract class AbstractNotSelectableShapeNodeEditPart extends ShapeNodeEditPart {
private LabelAndIconRefresher labelAndIconRefresher;
/**
* Creates a new AbstractUnselectableShapeNodeEditPart.
*
* @param view
* the view controlled by this EditPart
*/
public AbstractNotSelectableShapeNodeEditPart(View view) {
super(view);
}
@Override
public void activate() {
super.activate();
labelAndIconRefresher = new LabelAndIconRefresher(this);
}
@Override
public boolean isSelectable() {
// We simply always return false so that this EditPart cannot be
// selected manually or automatically
return false;
}
@Override
protected List getModelChildren() {
return ShowingViewUtil.getModelChildren(getModel());
}
@Override
protected void addNotationalListeners() {
super.addNotationalListeners();
if (hasNotationView()) {
ViewQuery viewQuery = new ViewQuery((View) getModel());
Optional<DDiagram> diagram = viewQuery.getDDiagram();
if (diagram.isPresent()) {
addListenerFilter("ShowingMode", this, diagram.get(), DiagramPackage.eINSTANCE.getDDiagram_IsInShowingMode()); //$NON-NLS-1$
}
}
}
@Override
protected void removeNotationalListeners() {
super.removeNotationalListeners();
removeListenerFilter("ShowingMode"); //$NON-NLS-1$
}
@Override
protected List getModelSourceConnections() {
return ShowingViewUtil.getSourceConnectionsConnectingVisibleViews((View) getModel());
}
@Override
protected List getModelTargetConnections() {
return ShowingViewUtil.getTargetConnectionsConnectingVisibleViews((View) getModel());
}
@Override
protected void setConnectionsVisibility(boolean visibility) {
ShowingViewUtil.setConnectionsVisibility(this, (View) getModel(), SELECTED_NONE, visibility);
}
/*
* (non-Javadoc)
* @see org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart#setVisibility(boolean)
*/
@Override
protected void setVisibility(boolean vis) {
ShowingViewUtil.setVisibility(this, vis, SELECTED_NONE, getFlag(FLAG__AUTO_CONNECTIONS_VISIBILITY));
}
@Override
public void deactivate() {
if (labelAndIconRefresher != null) {
labelAndIconRefresher.dispose();
labelAndIconRefresher = null;
}
super.deactivate();
}
}
|