blob: deef77c223188948ac1fea0654a2dca9763c01be (
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
98
99
100
|
/*******************************************************************************
* Copyright (c) 2015 protos software gmbh (http://www.protos.de).
* 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:
* Juergen Haug (initial contribution)
*
*******************************************************************************/
package org.eclipse.etrice.ui.common.base.support;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.etrice.doc.ContextHelpProvider;
import org.eclipse.etrice.ui.common.base.BaseImageProvider;
import org.eclipse.graphiti.features.IFeatureProvider;
import org.eclipse.graphiti.features.context.ICustomContext;
import org.eclipse.graphiti.features.custom.AbstractCustomFeature;
import org.eclipse.graphiti.mm.pictograms.PictogramElement;
import org.eclipse.ui.progress.UIJob;
public class HelpFeature extends AbstractCustomFeature {
public HelpFeature(IFeatureProvider fp) {
super(fp);
}
protected String getBoClassName(PictogramElement pe) {
Object bo = getBusinessObjectForPictogramElement(pe);
if (bo instanceof EObject)
return ((EObject) bo).eClass().getName();
return null;
}
public String getFeatureId(ICustomContext context) {
if (context != null) {
if (context.getPictogramElements() != null && context.getPictogramElements().length == 1){
PictogramElement pe = context.getPictogramElements()[0];
// don't show help for diagram input
if(getBusinessObjectForPictogramElement(pe) == getBusinessObjectForPictogramElement(getDiagram()))
return null;
return getBoClassName(pe);
}
}
return null;
}
@Override
public boolean canExecute(ICustomContext context) {
String featureId = getFeatureId(context);
if (featureId != null)
return ContextHelpProvider.isAvailable(featureId);
return false;
}
@Override
public void execute(final ICustomContext context) {
UIJob job = new UIJob("Show Context Help"){
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
ContextHelpProvider.showHelp(getBoClassName(context.getPictogramElements()[0]));
return Status.OK_STATUS;
}
};
job.schedule();
}
@Override
public String getName() {
return "Help";
}
@Override
public String getDescription() {
return "Open help view";
}
@Override
public String getImageId() {
return BaseImageProvider.IMG_HELP;
}
@Override
public boolean hasDoneChanges() {
return false;
}
}
|