blob: c0c64096067490eff113c317336dff4d8b2a85c2 (
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
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
|
/*****************************************************************************
* Copyright (c) 2012 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:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
* Gabriel Pascual (ALL4TEC) gabriel.pascual@all4tec.net - Initial API and implementation
*****************************************************************************/
package org.eclipse.papyrus.infra.gmfdiag.css.engine;
import java.net.MalformedURLException;
import java.net.URL;
import org.eclipse.core.resources.IFile;
import org.eclipse.e4.ui.css.core.dom.IElementProvider;
import org.eclipse.e4.ui.css.core.engine.CSSElementContext;
import org.eclipse.papyrus.infra.gmfdiag.css.Activator;
import org.eclipse.papyrus.infra.gmfdiag.css.stylesheets.StyleSheet;
import org.eclipse.papyrus.infra.gmfdiag.css.stylesheets.StyleSheetReference;
import org.eclipse.papyrus.infra.gmfdiag.css.theme.ThemeManager;
import org.eclipse.papyrus.infra.widgets.util.FileUtil;
import org.w3c.dom.Element;
/**
* A Singleton CSSEngine, handling the CSS stylesheets applied to the whole
* workspace.
*
* This Engine is a child of the BaseCSSEngine.
*
* It should not be used directly.
*
* @author Camille Letavernier
*
* @see DiagramCSSEngine
*/
@SuppressWarnings("restriction")
public class WorkspaceCSSEngine extends ExtendedCSSEngineImpl {
private WorkspaceCSSEngine() {
super(BaseCSSEngine.INSTANCE);
}
public static ExtendedCSSEngine instance = new WorkspaceCSSEngine();
@Override
protected void reloadStyleSheets() {
styleSheetURLs.clear();
styleSheets.clear();
for(StyleSheet styleSheet : ThemeManager.instance.getWorkspaceStyleSheets()) {
if(styleSheet instanceof StyleSheetReference) {
IFile iFile = FileUtil.getIFile(((StyleSheetReference)styleSheet).getPath());
if(iFile != null) {
styleSheets.add(styleSheet);
} else {
try {
URL styleSheetURL = new URL(((StyleSheetReference)styleSheet).getPath());
styleSheetURLs.add(styleSheetURL);
} catch (MalformedURLException e) {
Activator.log.error(e);
}
}
} else {
styleSheets.add(styleSheet);
}
}
}
//Unsupported operations. The WorkspaceCSSEngine should never be used directly.
@Override
public Element getElement(Object node) {
throw new UnsupportedOperationException();
}
@Override
public IElementProvider getElementProvider() {
throw new UnsupportedOperationException();
}
@Override
public void setElementProvider(IElementProvider elementProvider) {
throw new UnsupportedOperationException();
}
@Override
public CSSElementContext getCSSElementContext(Object node) {
throw new UnsupportedOperationException();
}
}
|