1 | |
---|
2 | package org.modelica.mdt.ui.view; |
---|
3 | |
---|
4 | import org.eclipse.jface.action.IAction; |
---|
5 | import org.eclipse.swt.graphics.Image; |
---|
6 | import org.eclipse.swt.widgets.Composite; |
---|
7 | import org.eclipse.ui.texteditor.StatusLineContributionItem; |
---|
8 | import org.modelica.mdt.core.compiler.CompilerInstantiationException; |
---|
9 | import org.modelica.mdt.internal.core.CompilerProxy; |
---|
10 | import org.modelica.mdt.ui.ModelicaImages; |
---|
11 | |
---|
12 | public class ModelicaStatusLineContributor extends StatusLineContributionItem |
---|
13 | { |
---|
14 | Image mdtOnline = ModelicaImages.getImageDescriptor(ModelicaImages.IMG_MDT_STATUS_ONLINE).createImage(); |
---|
15 | Image mdtOffline = ModelicaImages.getImageDescriptor(ModelicaImages.IMG_MDT_STATUS_OFFLINE).createImage(); |
---|
16 | |
---|
17 | boolean fDirty = false; |
---|
18 | |
---|
19 | public ModelicaStatusLineContributor() |
---|
20 | { |
---|
21 | super("MDT-Status", true, 50); |
---|
22 | try |
---|
23 | { |
---|
24 | String name = CompilerProxy.getCompilerName(); |
---|
25 | if (name != null && !name.equalsIgnoreCase("")) |
---|
26 | { |
---|
27 | setText(name + " Online "); |
---|
28 | if (!name.equalsIgnoreCase("Empty Compiler")) |
---|
29 | { |
---|
30 | setImage(mdtOnline); |
---|
31 | } |
---|
32 | else |
---|
33 | { |
---|
34 | setImage(mdtOffline); |
---|
35 | } |
---|
36 | } |
---|
37 | else |
---|
38 | { |
---|
39 | setText("OpenModelica Compiler is Offline."); |
---|
40 | setImage(mdtOffline); |
---|
41 | } |
---|
42 | } |
---|
43 | catch(CompilerInstantiationException e) |
---|
44 | { |
---|
45 | // do nothing |
---|
46 | setText("OpenModelica Compiler is Offline"); |
---|
47 | setImage(mdtOffline); |
---|
48 | } |
---|
49 | setToolTipText("OpenModelica Compiler Status.\n" + |
---|
50 | "If 'Empty Compiler' is online, check the Modelica preferences:\n" + |
---|
51 | "Window->Preferences->Modelica: 'Start OMC from MDT'"); |
---|
52 | } |
---|
53 | |
---|
54 | @Override |
---|
55 | public void fill(Composite parent) |
---|
56 | { |
---|
57 | // TODO Auto-generated method stub |
---|
58 | super.fill(parent); |
---|
59 | } |
---|
60 | |
---|
61 | @Override |
---|
62 | public void setActionHandler(IAction actionHandler) |
---|
63 | { |
---|
64 | // TODO Auto-generated method stub |
---|
65 | super.setActionHandler(actionHandler); |
---|
66 | } |
---|
67 | |
---|
68 | @Override |
---|
69 | public void setErrorImage(Image image) |
---|
70 | { |
---|
71 | // TODO Auto-generated method stub |
---|
72 | super.setErrorImage(image); |
---|
73 | } |
---|
74 | |
---|
75 | @Override |
---|
76 | public void setErrorText(String text) |
---|
77 | { |
---|
78 | // TODO Auto-generated method stub |
---|
79 | super.setErrorText(text); |
---|
80 | } |
---|
81 | |
---|
82 | @Override |
---|
83 | public void setImage(Image image) |
---|
84 | { |
---|
85 | // TODO Auto-generated method stub |
---|
86 | super.setImage(image); |
---|
87 | } |
---|
88 | |
---|
89 | @Override |
---|
90 | public void setText(String text) |
---|
91 | { |
---|
92 | // TODO Auto-generated method stub |
---|
93 | super.setText(text); |
---|
94 | } |
---|
95 | |
---|
96 | @Override |
---|
97 | public void setToolTipText(String string) |
---|
98 | { |
---|
99 | // TODO Auto-generated method stub |
---|
100 | super.setToolTipText(string); |
---|
101 | } |
---|
102 | |
---|
103 | @Override |
---|
104 | public void update() |
---|
105 | { |
---|
106 | // TODO Auto-generated method stub |
---|
107 | super.update(); |
---|
108 | try |
---|
109 | { |
---|
110 | String name = CompilerProxy.getCompilerName(); |
---|
111 | if (name != null && !name.equalsIgnoreCase("")) |
---|
112 | { |
---|
113 | setText(name + " is Online"); |
---|
114 | if (!name.equalsIgnoreCase("Empty Compiler")) |
---|
115 | { |
---|
116 | setImage(mdtOnline); |
---|
117 | } |
---|
118 | else |
---|
119 | { |
---|
120 | setImage(mdtOffline); |
---|
121 | } |
---|
122 | |
---|
123 | } |
---|
124 | else |
---|
125 | { |
---|
126 | setText("OpenModelica Compiler is Offline"); |
---|
127 | setImage(mdtOffline); |
---|
128 | } |
---|
129 | } |
---|
130 | catch(CompilerInstantiationException e) |
---|
131 | { |
---|
132 | // do nothing |
---|
133 | setText("OpenModelica Compiler is Offline"); |
---|
134 | setImage(mdtOffline); |
---|
135 | } |
---|
136 | fDirty = true; |
---|
137 | } |
---|
138 | |
---|
139 | public boolean isDirty() |
---|
140 | { |
---|
141 | return fDirty; |
---|
142 | } |
---|
143 | |
---|
144 | @Override |
---|
145 | public boolean isDynamic() |
---|
146 | { |
---|
147 | return true; |
---|
148 | } |
---|
149 | |
---|
150 | @Override |
---|
151 | public boolean isEnabled() |
---|
152 | { |
---|
153 | // TODO Auto-generated method stub |
---|
154 | return super.isEnabled(); |
---|
155 | } |
---|
156 | |
---|
157 | @Override |
---|
158 | public boolean isVisible() |
---|
159 | { |
---|
160 | // TODO Auto-generated method stub |
---|
161 | return super.isVisible(); |
---|
162 | } |
---|
163 | } |
---|