blob: 088c7b454253924ea754bf08fbc8c1983a48e79c (
plain) (
blame)
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
|
/*****************************************************************************
* Copyright (c) 2013, 2017 CEA LIST.
*
* 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:
* CEA LIST - Initial API and implementation
*****************************************************************************/
package org.eclipse.papyrus.cdo.internal.ui.decorators;
import org.eclipse.emf.cdo.dawn.appearance.DawnElementStylizer;
import org.eclipse.emf.cdo.dawn.appearance.IDawnElementStylizerFactory;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.gef.ConnectionEditPart;
import org.eclipse.gef.EditPart;
import org.eclipse.papyrus.cdo.internal.core.CDOUtils;
import org.eclipse.papyrus.infra.core.resource.ModelSet;
import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IPapyrusEditPart;
/**
* This is the PapyrusElementStylizerFactory type. Enjoy.
*/
public class PapyrusElementStylizerFactory
implements IDawnElementStylizerFactory {
public PapyrusElementStylizerFactory() {
super();
}
@Override
public DawnElementStylizer getElementStylizer(Object object) {
DawnElementStylizer result = null;
if (isPapyrusEditPart(object)) {
if (object instanceof ConnectionEditPart) {
result = new PapyrusConnectionEditPartStylizer();
} else {
result = new PapyrusNodeEditPartStylizer();
}
} else if (object instanceof EObject) {
result = new PapyrusElementStylizer();
}
return result;
}
protected boolean isPapyrusEditPart(Object object) {
boolean result = object instanceof IPapyrusEditPart;
if (!result && (object instanceof EditPart)) {
EditPart editPart = ((EditPart) object).getRoot().getContents();
Object model = editPart.getModel();
if (model instanceof EObject) {
result = CDOUtils.getResourceSet((EObject) model) instanceof ModelSet;
}
}
return result;
}
}
|