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
|
/**
* Copyright (c) 2013 Soft-Maint.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* David Couvrand (Soft-Maint) - Bug 422058 - Implementation of strikethrough and underline in the CustomizedLabelProvider
*/
package org.eclipse.papyrus.emf.facet.custom.ui.internal;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManager;
import org.eclipse.papyrus.emf.facet.custom.core.exception.CustomizationException;
import org.eclipse.papyrus.emf.facet.custom.ui.ICustomOverride;
import org.eclipse.papyrus.emf.facet.custom.ui.IFontPropertiesHandler;
import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetOperation;
import org.eclipse.swt.graphics.FontData;
public class DefaultCustomOverride implements ICustomOverride {
public String getText(final String result, final Object object,
final ICustomizationManager customManager,
final IFontPropertiesHandler propertiesHandler)
throws CustomizationException {
String newResult = result;
if (object instanceof EObject) {
final EObject eObject = (EObject) object;
final FacetOperation isStruckProp = propertiesHandler
.getIsStruckthroughProperty();
final boolean isStruckthrough = customManager.getCustomValueOf(
eObject, isStruckProp, Boolean.class).booleanValue();
if (isStruckthrough) {
newResult = String.format("--%s--", newResult); //$NON-NLS-1$
}
final FacetOperation isUnderlinedProp = propertiesHandler
.getIsUnderlinedProperty();
final boolean isUnderlined = customManager.getCustomValueOf(
eObject, isUnderlinedProp, Boolean.class).booleanValue();
if (isUnderlined) {
newResult = String.format("__%s__", newResult); //$NON-NLS-1$
}
}
return newResult;
}
public FontData getFont(final FontData fontData, final Object object,
final ICustomizationManager customManager,
final IFontPropertiesHandler propertiesHandler) {
return fontData;
}
}
|