Author: Frederik Heremans
(2009/03/02 19:16) About 3 years ago
Major commit for 0.0.2 release
2
Bundle-ManifestVersion: 2
3
Bundle-Name: Traffide Plug-in
4
Bundle-SymbolicName: be.stacktrace.traffide;singleton:=true
5
Bundle-Version: 0.0.1
Bundle-Version: 0.0.2
6
Bundle-Activator: be.stacktrace.traffide.TraffideActivator
7
Bundle-Vendor: www.stacktrace.be
8
Require-Bundle: org.eclipse.ui,
10
config.http.trafficJamLength.startRegex=h>
11
config.http.trafficJamLength.endRegex=km
12
config.mapRegion.default=vlaanderen
13
14
config.http.mapImage.backgroundLayer.regex=map_layer
15
config.http.mapImage.trafficJamLayer.regex=congestions_layer\\\\"
16
config.http.mapImage.incidentsLayer.regex=incidents_layer\\\\"
17
config.http.mapImage.layer.startRegex=getTransparentBackgroundStyleUrl\\(\\'
18
config.http.mapImage.layer.endRegex=\\'\\)
public static final String CONFIG_HTTP_MAIN_CAMERA_HOSTNAME = "config.http.mainCameraHostName";
public static final String CONFIG_HTTP_MAIN_MAP_HOSTNAME = "config.http.mainMapHostName";
public static final String CONFIG_HTTP_MAP_IMAGE_BACKGROUND_LAYER_REGEX = "config.http.mapImage.backgroundLayer.regex";
public static final String CONFIG_HTTP_MAP_IMAGE_TRAFFIC_JAMS_LAYER_REGEX = "config.http.mapImage.trafficJamLayer.regex";
9
public static final String CONFIG_HTTP_MAP_IMAGE_INCIDENTS_LAYER_REGEX = "config.http.mapImage.incidentsLayer.regex";
public static final String CONFIG_HTTP_MAP_IMAGE_START_REGEX = "config.http.mapImage.layer.startRegex";
public static final String CONFIG_HTTP_MAP_IMAGE_END_REGEX = "config.http.mapImage.layer.endRegex";
public static final String CONFIG_HTTP_PASSKEY_CAMERA_URI = "config.http.passkeyCamera.uri";
1
package be.stacktrace.traffide.context;
import org.apache.commons.configuration.Configuration;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.preference.IPreferenceStore;
import be.stacktrace.traffide.event.GlobalEventRegistry;
import be.stacktrace.traffide.http.HttpClientWrapper;
// TODO: Auto-generated Javadoc
/**
* The Interface TraffideContext contains all beans and services which are
* exposed by the Traffide plugin.
...
73
* @return the preference store
74
*/
75
IPreferenceStore getPreferenceStore();
76
77
78
* Log to the global log.
79
*
80
* @param severity the severity. See {@link IStatus}
81
* @param errorCode the error code
82
* @param message the human readable message
83
* @param exception the exception. Null if not applicable
84
85
void logGlobal(int severity, int errorCode, String message, Throwable exception);
86
}
87
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.Status;
import be.stacktrace.traffide.TraffideActivator;
* The Class TraffideContextImpl is a default implementation of a
* {@link TraffideContext}.
36
/** The preference store. */
39
37
private IPreferenceStore preferenceStore;
40
38
41
42
* Instantiates a TraffideContextImpl.
43
44
67
public void setPreferenceStore(IPreferenceStore preferenceStore) {
68
this.preferenceStore = preferenceStore;
69
70
71
72
* Sets the config.
144
return (T) result;
145
146
147
148
* {@inheritDoc}
149
150
public IPreferenceStore getPreferenceStore() {
151
return preferenceStore;
152
153
154
155
156
157
158
public void logGlobal(int severity, int errorCode, String message, Throwable exception) {
159
TraffideActivator.getDefault().getLog().log(
160
new Status(severity, TraffideActivator.PLUGIN_ID, errorCode, message, exception));
161
162
import java.text.DateFormat;
import java.util.Calendar;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import be.stacktrace.traffide.ui.image.DefaultTrafficJamTextProvider;
import be.stacktrace.traffide.ui.image.TrafficJamImageGenerator;
import be.stacktrace.traffide.ui.repository.CameraImageRepository;
import be.stacktrace.traffide.ui.repository.impl.CameraImageWrapper;
import be.stacktrace.traffide.update.UpdatableResource;
import be.stacktrace.traffide.ui.repository.impl.CameraImageWrapper.CameraImageWrapperState;
import be.stacktrace.traffide.update.UpdatableResourceStatus;
45
* This sample class demonstrates how to plug-in a new workbench view. The view
65
private Label imageWidget;
63
66
64
private Camera currentCamera;
private CameraImageRepository imageRepo;
private CameraRepositoryCSVImpl service;
private TrafficJamImageGenerator jamImageGenerator;
96
95
97
@Override
98
public void dispose() {
99
System.out.println("Disposing view");
100
TraffideActivator.getContext().getGlobalEventRegistry().unregisterEventHandler(
101
TrafficJamLengthChangeEvent.class, myListener);
102
108
service = new CameraRepositoryCSVImpl();
106
109
TraffideContext ctx = TraffideActivator.getContext();
107
110
// Add self to eventlistener for cameraImage-change events
111
imageRepo = ctx.getService(CameraImageRepository.class);
112
113
ctx.getGlobalEventRegistry().registerEventHandler(CameraImageChangeEvent.class, new GlobalEventHandler<CameraImageChangeEvent>() {
114
public void handleEvent(CameraImageChangeEvent event) {
121
myListener = new TrafficJamLengthChangeEventListener();
118
122
TraffideActivator.getContext().getGlobalEventRegistry().registerEventHandler(TrafficJamLengthChangeEvent.class,
119
123
myListener);
120
124
125
126
168
167
169
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
170
public void selectionChanged(SelectionChangedEvent event) {
171
Configuration config = TraffideActivator.getContext().getConfig();
172
173
if (event.getSelection() instanceof StructuredSelection) {
174
StructuredSelection sel = (StructuredSelection) event.getSelection();
175
if (sel.getFirstElement() != null) {
176
Camera selectedCamera = (Camera) sel.getFirstElement();
177
currentCamera = selectedCamera;
178
CameraImageWrapper wrapper = imageRepo.getCameraImageWrapper(selectedCamera.getId());
UpdatableResource<Image> wrapper = imageRepo.getCameraImage(currentCamera.getId());
179
myImage = wrapper.getImage();
myImage = wrapper.getResource();
180
181
imageWidget.setImage(myImage);
182
nameLabel.setText(selectedCamera.getName());
183
directionLabel.setText(selectedCamera.getViewDirection());
184
imageRepo.getCameraImageWrapper(selectedCamera.getId());
185
String updateTime = null;
186
187
if (wrapper.getState() == CameraImageWrapperState.ERROR) {
if (wrapper.getStatus() == UpdatableResourceStatus.ERROR) {
188
updateTime = "Error";
189
} else {
190
if (wrapper.getLastUpdate() == null
if (wrapper.getLastUpdateTime() == null
191
|| wrapper.getState() == CameraImageWrapperState.UPDATING) {
|| wrapper.getStatus() == UpdatableResourceStatus.UPDATING) {
192
updateTime = "Updating...";
193
194
updateTime = DateFormat.getTimeInstance().format(wrapper.getLastUpdate().getTime());
updateTime = DateFormat.getTimeInstance().format(wrapper.getLastUpdateTime().getTime());
195
196
197
timeLabel.setText(updateTime);
222
setTitleImage(getTitleImage());
219
223
220
224
221
225
226
private void showMessage(String message) {
227
MessageDialog.openInformation(viewer.getControl().getShell(), "DefaultView", message);
228
229
230
231
* Passing the focus request to the viewer's control.
232
234
viewer.getControl().setFocus();
235
236
237
public void cameraImageChanged(final CameraImageWrapper changed) {
public void cameraImageChanged(final UpdatableResource<Image> changed) {
238
if (currentCamera != null) {
239
if (currentCamera.getId().equals(changed.getCameraId())) {
if (currentCamera.getId().equals(changed.getResourceKey())) {
240
// The current image needs to be updated aswel
241
233
242
getSite().getShell().getDisplay().asyncExec(new Runnable() {
243
244
public void run() {
245
myImage = changed.getImage();
myImage = changed.getResource();
246
viewer.setSelection(viewer.getSelection());
247
248
package be.stacktrace.traffide.event;
import org.eclipse.swt.graphics.Image;
* The Class CameraImageChangeEvent is an event signaling the containing
* {@link CameraImageWrapper} changed.
public class CameraImageChangeEvent {
/** The changed. */
private CameraImageWrapper changed;
private UpdatableResource<Image> changed;
* Instantiates a new camera image change event.
19
20
* @param changed the changed
21
22
public CameraImageChangeEvent(CameraImageWrapper changed) {
23
public CameraImageChangeEvent(UpdatableResource<Image> changed) {
this.changed = changed;
24
25
26
27
29
28
* @return the changed
30
31
public CameraImageWrapper getChanged() {
32
public UpdatableResource<Image> getChanged() {
return changed;
33
34
35
import be.stacktrace.traffide.ui.model.MapImageWrapper;
* The Class MapImageChangeEvent is a class indicating a MapImage has changed.
* @author Frederik Heremans
* @since 0.0.2
public class MapImageChangeEvent {
/** The map image. */
private UpdatableResource<MapImageWrapper> mapImage;
* Gets the map image.
* @return the map image
public UpdatableResource<MapImageWrapper> getMapImage() {
return mapImage;
* Instantiates a new map image change event.
* @param mapImage
* the map image
public MapImageChangeEvent(UpdatableResource<MapImageWrapper> mapImage) {
super();
this.mapImage = mapImage;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.commons.httpclient.methods.GetMethod;
import be.stacktrace.traffide.config.ConfigConstantsHttp;
import be.stacktrace.traffide.context.TraffideContext;
import be.stacktrace.traffide.io.GrepStreamReader;
import be.stacktrace.traffide.io.GrepStringHandler;
public class CameraPassCodeFetcher {
/** The grep stream reader. */
private GrepStreamReader grepStreamReader;
/** The grep string handler. */
private PassKeyForCameraStringHandler grepStringHandler;
/** The http client wrapper. */
private TraffideContext context;
private HttpClientWrapper httpClientWrapper;
/** The config. */
private Configuration config;
* Instantiates a new CameraPassCodeFetcher.
* @param httpClientWrapper
* the http client wrapper
* @param config
* the config
public CameraPassCodeFetcher(TraffideContext context) {
this.context = context;
46
// Initialize the reader
47
grepStreamReader = new GrepStreamReader();
48
// initialize the handler
49
grepStringHandler = new PassKeyForCameraStringHandler();
50
51
52
53
* Gets the pass key for camera using HTTP-request.
54
55
* @return the pass key for camera
56
57
public String getPassKeyForCamera() {
58
// Do the request
59
GetMethod method = new GetMethod(context.getConfig().getString(
public CameraPassCodeFetcher(HttpClientWrapper httpClientWrapper,
60
ConfigConstantsHttp.CONFIG_HTTP_PASSKEY_CAMERA_URI));
Configuration config) {
61
String hostName = context.getConfig().getString(ConfigConstantsHttp.CONFIG_HTTP_MAIN_CAMERA_HOSTNAME);
this.httpClientWrapper = httpClientWrapper;
this.config = config;
62
try {
context.getHttpClientWrapper().doRequest(hostName, method);
// Handle the response
grepStreamReader.processStream(method.getResponseBodyAsStream(), grepStringHandler);
} catch (IOException e) {
context.logGlobal(IStatus.ERROR, 0, "Cannot get passkey from HTTP-call: " + e.getMessage(), e);
} finally {
method.releaseConnection();
// Check the handler for the passcode
String passKey = grepStringHandler.getPassKey();
if (passKey == null) {
context.logGlobal(IStatus.ERROR, 0, "No passkey could be extracted from HTTP-call", null);
// Finally, reset the handler
grepStringHandler.reset();
return passKey;
GetMethod method = new GetMethod(config
.getString(ConfigConstantsHttp.CONFIG_HTTP_PASSKEY_CAMERA_URI));
String hostName = config
.getString(ConfigConstantsHttp.CONFIG_HTTP_MAIN_CAMERA_HOSTNAME);
httpClientWrapper.doRequest(hostName, method);
* The Class PassKeyForCameraStringHandler is an internal classed used to
* get the passkey for camera images using <code>GrepStreamReader</code>
grepStreamReader.processStream(method.getResponseBodyAsStream(),
* result, using regex to find exact passkey inside the line.
grepStringHandler);
88
// TODO Auto-generated catch block
89
* @since 1.0
e.printStackTrace();
90
TraffideActivator.getDefault().getLog().log(new Status (IStatus.ERROR,
91
private class PassKeyForCameraStringHandler extends GrepStringHandler {
"Woops",
0,
"Errow while fetching passcode: " + e.getMessage(),
e));
92
93
/** The Constant NUMBER_REGEX. */
94
private static final String NUMBER_REGEX = "[0-9]+";
/** The pass key. */
// TODO: Log that no passkey could be retrieved from the HTTP-Call
private String passKey;
/** The numbers pattern. */
private Pattern numbersPattern;
103
104
105
* Instantiates a new PassKeyForCameraStringHandler.
public PassKeyForCameraStringHandler() {
super(Pattern.compile(context.getConfig().getString(ConfigConstantsHttp.CONFIG_HTTP_PASSKEY_CAMERA_REGEX)));
numbersPattern = Pattern.compile(NUMBER_REGEX);
115
public boolean handleString(String line) {
// Locate the matched string and extract the numbers behind it
Matcher m = getRegexPattern().matcher(line);
116
if (m.find()) {
117
// Look for first digit starting from end-pos of matcher
Matcher numberM = numbersPattern.matcher(line);
if (numberM.find(m.end())) {
// Found the passKey
this.passKey = line.substring(numberM.start(), numberM.end());
// Stop processing, found a match
return false;
return true;
127
128
129
130
* Gets the pass key.
131
132
* @return the pass key
133
134
public String getPassKey() {
135
136
137
138
139
* Reset the handler.
140
141
public void reset() {
super(Pattern
142
passKey = null;
.compile(config
143
.getString(ConfigConstantsHttp.CONFIG_HTTP_PASSKEY_CAMERA_REGEX)));
this.passKey = line.substring(numberM.start(), numberM
.end());
163
164
165
166
// Create the fetcher
fetcher = new CameraPassCodeFetcher(context.getHttpClientWrapper(), context.getConfig());
fetcher = new CameraPassCodeFetcher(context);
firstRun = true;
public static final String P_MAP_DEFAULT_REGION = "preference.mapRegion.default";
public static final String P_MAP_IMAGE_REFRESH_TIME = "preference.mapRegionFetchTimeout";
public static final String P_MAP_AUTO_UPDATE = "preference.map.autoUpdate";
// Other constants
/** The Constant USER_DIR_NAME, name of settings-polder in the user-dir. */
public static final String USER_DIR_NAME = ".traffide";
store.setDefault(PreferenceConstants.P_TRAFFIC_JAM_LENGTH_REFRESH_TIME, "60000");
store.setDefault(PreferenceConstants.P_CAMERA_IMAGE_REFRESH_TIME, "60000");
store.setDefault(PreferenceConstants.P_MAP_IMAGE_REFRESH_TIME, "60000");
// Map view defaults
store.setDefault(PreferenceConstants.P_MAP_DEFAULT_REGION, getDefaultMapRegion());
store.setDefault(PreferenceConstants.P_MAP_AUTO_UPDATE, true);
package be.stacktrace.traffide.preferences;
import java.util.Collection;
import org.eclipse.jface.preference.ComboFieldEditor;
import org.eclipse.jface.preference.DirectoryFieldEditor;
import org.eclipse.jface.preference.FieldEditorPreferencePage;
import org.eclipse.ui.IWorkbenchPreferencePage;
import be.stacktrace.traffide.model.MapRegion;
import be.stacktrace.traffide.model.repository.MapRegionRepository;
* The Class TraffidePreferences is a {@link IWorkbenchPreferencePage} that
getTrafficJamLengtTimeoutValues(), getFieldEditorParent());
addField(cameraImageTimeOutEditor);
DirectoryFieldEditor homeDirEditor = new DirectoryFieldEditor(PreferenceConstants.P_USER_DIR_LOCATION,
// DirectoryFieldEditor homeDirEditor = new
"&Traffide preference directory:", getFieldEditorParent());
// DirectoryFieldEditor(PreferenceConstants.P_USER_DIR_LOCATION,
homeDirEditor.setEmptyStringAllowed(false);
// "&Traffide preference directory:", getFieldEditorParent());
homeDirEditor.setValidateStrategy(DirectoryFieldEditor.VALIDATE_ON_FOCUS_LOST);
// homeDirEditor.setEmptyStringAllowed(false);
addField(homeDirEditor);
// homeDirEditor.setValidateStrategy(DirectoryFieldEditor.VALIDATE_ON_FOCUS_LOST);
// addField(homeDirEditor);
ComboFieldEditor mapRegionDefaultEditor = new ComboFieldEditor(PreferenceConstants.P_MAP_DEFAULT_REGION,
// ComboFieldEditor mapRegionDefaultEditor = new ComboFieldEditor(PreferenceConstants.P_MAP_DEFAULT_REGION,
"&Default map region", getMapRegionValues(), getFieldEditorParent());
// "&Default map region", getMapRegionValues(), getFieldEditorParent());
//
// addField(mapRegionDefaultEditor);
addField(mapRegionDefaultEditor);
private String[][] getTrafficJamLengtTimeoutValues() {
{ "Every 2 minutes", "120000" }, { "Every 5 minutes", "300000" }, { "Every 10 minutes", "600000" } };
private String[][] getMapRegionValues() {
// private String[][] getMapRegionValues() {
MapRegionRepository repo = TraffideActivator.getContext().getService(MapRegionRepository.class);
// MapRegionRepository repo = TraffideActivator.getContext().getService(MapRegionRepository.class);
Collection<MapRegion> regions = repo.getAllMapRegions();
// Collection<MapRegion> regions = repo.getAllMapRegions();
// String[][] regArray = new String[regions.size()][];
// int i = 0;
// for (MapRegion reg : regions) {
// regArray[i] = new String[] { reg.getName(), reg.getId() };
// i++;
// }
// return regArray;
String[][] regArray = new String[regions.size()][];
int i = 0;
for (MapRegion reg : regions) {
regArray[i] = new String[] { reg.getName(), reg.getId() };
i++;
return regArray;
context.getGlobalEventRegistry().registerEventHandler(CameraPassCodeChangeEvent.class, new GlobalEventHandler<CameraPassCodeChangeEvent>() {
public void handleEvent(CameraPassCodeChangeEvent event) {
passCode = event.getPassCode();
System.out.println("Got passkey update: " + passCode);
});
public void updatePassCode() {
if (fetchJob != null) {
fetchJob.wakeUp();
System.out.println("jaja");
import be.stacktrace.traffide.job.CameraPassCodeFetchJob;
import be.stacktrace.traffide.job.TrafficJamLengthJob;
import be.stacktrace.traffide.job.UpdateMapViewJob;
import be.stacktrace.traffide.model.repository.CameraRepository;
import be.stacktrace.traffide.model.repository.impl.CameraRepositoryCSVImpl;
import be.stacktrace.traffide.service.impl.CameraPassCodeServiceImpl;
import be.stacktrace.traffide.ui.constants.ImageConstants;
import be.stacktrace.traffide.ui.repository.MapImageRepository;
import be.stacktrace.traffide.ui.repository.impl.CameraImageRepositoryImpl;
import be.stacktrace.traffide.ui.repository.impl.MapImageRepositoryImpl;
private TrafficJamLengthJob trafJamLength;
private CameraPassCodeFetchJob cameraPassCodeFetchJob;
* The constructor.
// Set shared plugin instance
plugin = this;
// Set up the proxy
proxyTracker = new ServiceTracker(getBundle().getBundleContext(), IProxyService.class.getName(), null);
proxyTracker.open();
contextImpl = new TraffideContextImpl();
// Set the preference store
contextImpl.setPreferenceStore(getPreferenceStore());
// Set up the HTTPClientWrapper
HttpClientWrapper httpClientWrapper = new HttpClientWrapper(getProxyService());
// Register all repo's
registerServices();
// Finally, scedule all jobs
startJobs();
contextImpl.addService(CameraPassCodeService.class, passCodeImpl);
// Add map services
MapRegionRepository mapRepo = new MapRegionRepositoryCSVImpl(contextImpl);
contextImpl.addService(MapRegionRepository.class, mapRepo);
MapImageRepository mapImageRepo = new MapImageRepositoryImpl(contextImpl);
contextImpl.addService(MapImageRepository.class, mapImageRepo);
package be.stacktrace.traffide.ui.constants;
* The Class ImageConstants contains constants related to images and icons.
/** The Constant ICON_REFRESH_PASSKEY. */
public static final String ICON_REFRESH_PASSKEY = "icons/key-go.png";
/** The Constant ICON_REFRESH. */
public static final String ICON_REFRESH = "icons/refresh.gif";
* Instantiates a new image constants, private.
package be.stacktrace.traffide.ui.repository;
public class MapImageRepository {
* The Interface MapImageRepository contains methods related to MapImages.
public interface MapImageRepository {
* Gets the {@MapImageWrapper} for the given region.
* @param region
* the region
UpdatableResource<MapImageWrapper> getMapImage(MapRegion region);
* Force update of the wrapper for the given region.
* @param selected
* the selected
void forceUpdate(MapRegion selected);
package be.stacktrace.traffide.views;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.events.ControlAdapter;
import org.eclipse.swt.events.ControlEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;
import be.stacktrace.traffide.event.GlobalEventHandler;
import be.stacktrace.traffide.event.MapImageChangeEvent;
import be.stacktrace.traffide.preferences.PreferenceConstants;
public class MapView extends ViewPart {
private Action action1;
private Action action2;
private Action setSelectedAsDefaultAction;
private List<Action> regionActions;
private Action setAutoUpdateAction;
private Action refreshAction;
private List<SelectMapRegionAction> regionActions;
private MapRegion region;
private MapRegionRepository mapRegionRepo;
private MapImageRepository mapImageRepo;
private boolean autoUpdate = false;
private Label imageLabel;
private Label updatelabel;
private Composite c;
private ScrolledComposite scrolledComposite;
private UpdateMapViewJob updateMapJob;
public MapView() {
regionActions = new ArrayList<Action>();
regionActions = new ArrayList<SelectMapRegionAction>();
context = TraffideActivator.getContext();
mapRegionRepo = context.getService(MapRegionRepository.class);
mapImageRepo = context.getService(MapImageRepository.class);
// Create the job
updateMapJob = new UpdateMapViewJob(context);
private void setMapRegion(MapRegion region) {
this.region = region;
updateMapJob.setSelectedRegion(region);
refreshMapImage();
public void createPartControl(Composite parent) {
TraffideContext context = TraffideActivator.getContext();
// Initialise defaults from preferences
autoUpdate = context.getPreferenceStore().getBoolean(PreferenceConstants.P_MAP_AUTO_UPDATE);
// Register as MapImageChangeEvent-listener
context.getGlobalEventRegistry().registerEventHandler(MapImageChangeEvent.class,
new GlobalEventHandler<MapImageChangeEvent>() {
public void handleEvent(MapImageChangeEvent event) {
// Check if we are interested in this mapImage
if (region != null && event.getMapImage() != null
&& region.equals(event.getMapImage().getResourceKey())) {
// The image selected now has been updated, refresh!
// Create view
scrolledComposite = new ScrolledComposite(parent, SWT.V_SCROLL | SWT.H_SCROLL);
c = new Composite(scrolledComposite, SWT.NONE);
scrolledComposite.setContent(c);
scrolledComposite.setExpandHorizontal(true);
scrolledComposite.setExpandVertical(true);
scrolledComposite.addControlListener(new ControlAdapter() {
public void controlResized(ControlEvent e) {
doScroll();
GridLayout rLayout = new GridLayout(1, true);
c.setLayout(rLayout);
updatelabel = new Label(c, SWT.FILL);
updatelabel.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, false, 1, 1));
imageLabel = new Label(c, SWT.FILL);
imageLabel.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, false, 1, 1));
// Finally, refresh image
setMapRegion(mapRegionRepo.getDefault());
makeActions();
hookContextMenu();
contributeToActionBars();
if(autoUpdate) {
// Start update-job, if auto-update is needed.
updateMapJob.schedule(context.getPreferenceStore().getLong(PreferenceConstants.P_MAP_IMAGE_REFRESH_TIME));
protected void doScroll() {
scrolledComposite.setMinSize(c.computeSize(SWT.DEFAULT, SWT.DEFAULT));
@SuppressWarnings("unused")
private void hookContextMenu() {
// MenuManager menuMgr = new MenuManager("#PopupMenu");
MenuManager menuMgr = new MenuManager("#PopupMenu");
// menuMgr.setRemoveAllWhenShown(true);
menuMgr.setRemoveAllWhenShown(true);
// menuMgr.addMenuListener(new IMenuListener() {
menuMgr.addMenuListener(new IMenuListener() {
// public void menuAboutToShow(IMenuManager manager) {
public void menuAboutToShow(IMenuManager manager) {
// MapView.this.fillContextMenu(manager);
MapView.this.fillLocalPullDown(manager);
// });
// Menu menu = menuMgr.createContextMenu(viewer.getControl());
Menu menu = menuMgr.createContextMenu(c);
// viewer.getControl().setMenu(menu);
c.setMenu(menu);
// getSite().registerContextMenu(menuMgr, viewer);
private void contributeToActionBars() {
fillLocalToolBar(bars.getToolBarManager());
// Remove selection from imageRepo to prevent auto-updating of image
// when
// not needed.
updateMapJob.cancel();
private void fillLocalPullDown(IMenuManager manager) {
// Add all region-actions
for (Action action : regionActions) {
manager.add(action);
// Add the "set as default" action
manager.add(new Separator());
// Finally, add the "set as default" action
manager.add(setSelectedAsDefaultAction);
// Also add the action to indicate auto-updates
manager.add(setAutoUpdateAction);
// private void fillContextMenu(IMenuManager manager) {
// manager.add(action1);
// manager.add(action2);
// // Other plug-ins can contribute there actions here
// manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
private void fillLocalToolBar(IToolBarManager manager) {
manager.add(action1);
manager.add(refreshAction);
manager.add(action2);
private void makeActions() {
198
// Add all mapregions
199
MapRegionRepository mapRegionRepo = context.getService(MapRegionRepository.class);
MapRegion defaultRegion = mapRegionRepo.getDefault();
200
System.out.println(defaultRegion);
SelectMapRegionAction actionToAdd = null;
201
for (MapRegion region : mapRegionRepo.getAllMapRegions()) {
202
actionToAdd = new SelectMapRegionAction(region);
203
setSelectedAsDefaultAction.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(
ISharedImages.IMG_ETOOL_SAVE_EDIT));
action1 = new Action() {
// Add the auto-update on/off action
setAutoUpdateAction = new Action(null, Action.AS_CHECK_BOX) {
System.out.println("Action 1 executed");
setAutoUpdate(!autoUpdate);
};
action1.setText("Action 1");
setAutoUpdateAction.setText("Auto-update");
action1.setToolTipText("Action 1 tooltip");
// Get checked/unchecked value
action1.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(
setAutoUpdateAction.setChecked(autoUpdate);
ISharedImages.IMG_OBJS_INFO_TSK));
action2 = new Action() {
// The refresh-map action (forced)
refreshAction = new Action() {
System.out.println("Action 2 executed");
if (region != null) {
action2.setText("Action 2");
action2.setToolTipText("Action 2 tooltip");
action2.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(
refreshAction.setText("Refresh map");
refreshAction.setImageDescriptor(TraffideActivator.getImageDescriptor(ImageConstants.ICON_REFRESH));
249
252
253
private class SelectMapRegionAction extends Action {
254
private MapRegion regionToSet;
255
256
public SelectMapRegionAction(MapRegion regionToSet) {
257
if (regionToSet != null) {
261
setText(regionToSet.getName());
262
setToolTipText("Show region " + regionToSet.getName());
263
264
265
266
267
public MapRegion getRegion() {
268
return regionToSet;
269
270
271
272
checkAction(this);
273
275
276
277
public void checkAction(SelectMapRegionAction selectMapRegionAction) {
278
private void checkAction(SelectMapRegionAction selectMapRegionAction) {
279
if (!selectMapRegionAction.equals(action)) {
280
action.setChecked(false);
281
283
284
285
286
private void setAutoUpdate(boolean autoUpdate) {
287
if (autoUpdate != this.autoUpdate) {
288
this.autoUpdate = autoUpdate;
289
// Update preference
290
TraffideActivator.getContext().getPreferenceStore().setValue(PreferenceConstants.P_MAP_AUTO_UPDATE,
291
autoUpdate);
292
293
// Change job state
294
if (autoUpdate) {
295
// Start the job
296
updateMapJob.schedule(context.getPreferenceStore()
297
.getLong(PreferenceConstants.P_MAP_IMAGE_REFRESH_TIME));
298
299
// No update needed, cancel job
300
301
302
303
304
305
private void refreshMapImage() {
306
// Reset the map-image and info in the GUI
307
308
UpdatableResource<MapImageWrapper> image = mapImageRepo.getMapImage(region);
309
MapImageWrapper wr = image.getResource();
310
if (wr != null) {
311
imageLabel.setImage(wr.getTotalImage());
312
313
imageLabel.setImage(null);
314
315
switch (image.getStatus()) {
316
case ERROR:
317
updatelabel.setText("Error while updating");
318
break;
319
case UP_TO_DATE:
320
updatelabel.setText("Last updated on "
321
+ DateFormat.getTimeInstance().format(image.getLastUpdateTime().getTime()));
322
323
case UPDATING:
324
updatelabel.setText("Updating...");
325
326
327
default:
328
329
330
c.layout();
331
332
333
334
335
336
Bundle-Version: 0.0.1Bundle-Version: 0.0.2// TODO: Auto-generated Javadoc* @param severity the severity. See {@link IStatus}* {@link TraffideContext}.* {@link TraffideContext}.public void setPreferenceStore(IPreferenceStore preferenceStore) {public void setPreferenceStore(IPreferenceStore preferenceStore) {/*** {@inheritDoc}* {@inheritDoc}public IPreferenceStore getPreferenceStore() {public IPreferenceStore getPreferenceStore() {return preferenceStore;* {@inheritDoc}public void logGlobal(int severity, int errorCode, String message, Throwable exception) {import org.apache.commons.configuration.Configuration;import org.eclipse.jface.dialogs.MessageDialog;import be.stacktrace.traffide.ui.repository.impl.CameraImageWrapper;import be.stacktrace.traffide.update.UpdatableResource;import be.stacktrace.traffide.ui.repository.impl.CameraImageWrapper.CameraImageWrapperState;import be.stacktrace.traffide.update.UpdatableResourceStatus;public void dispose() {public void dispose() {System.out.println("Disposing view");imageRepo = ctx.getService(CameraImageRepository.class);ctx.getGlobalEventRegistry().registerEventHandler(CameraImageChangeEvent.class, new GlobalEventHandler<CameraImageChangeEvent>() {ctx.getGlobalEventRegistry().registerEventHandler(CameraImageChangeEvent.class, new GlobalEventHandler<CameraImageChangeEvent>() {public void handleEvent(CameraImageChangeEvent event) {public void handleEvent(CameraImageChangeEvent event) {viewer.addSelectionChangedListener(new ISelectionChangedListener() {viewer.addSelectionChangedListener(new ISelectionChangedListener() {public void selectionChanged(SelectionChangedEvent event) {public void selectionChanged(SelectionChangedEvent event) {Configuration config = TraffideActivator.getContext().getConfig();if (event.getSelection() instanceof StructuredSelection) {if (event.getSelection() instanceof StructuredSelection) {if (sel.getFirstElement() != null) {if (sel.getFirstElement() != null) {CameraImageWrapper wrapper = imageRepo.getCameraImageWrapper(selectedCamera.getId());UpdatableResource<Image> wrapper = imageRepo.getCameraImage(currentCamera.getId());myImage = wrapper.getImage();myImage = wrapper.getResource();imageRepo.getCameraImageWrapper(selectedCamera.getId());if (wrapper.getState() == CameraImageWrapperState.ERROR) {if (wrapper.getStatus() == UpdatableResourceStatus.ERROR) {} else {} else {if (wrapper.getLastUpdateTime() == null|| wrapper.getState() == CameraImageWrapperState.UPDATING) {|| wrapper.getStatus() == UpdatableResourceStatus.UPDATING) {} else {} else {updateTime = DateFormat.getTimeInstance().format(wrapper.getLastUpdateTime().getTime());private void showMessage(String message) {MessageDialog.openInformation(viewer.getControl().getShell(), "DefaultView", message);}public void cameraImageChanged(final CameraImageWrapper changed) {public void cameraImageChanged(final UpdatableResource<Image> changed) {if (currentCamera != null) {if (currentCamera != null) {if (currentCamera.getId().equals(changed.getCameraId())) {if (currentCamera.getId().equals(changed.getResourceKey())) {getSite().getShell().getDisplay().asyncExec(new Runnable() {getSite().getShell().getDisplay().asyncExec(new Runnable() {public void run() {public void run() {myImage = changed.getImage();myImage = changed.getResource();import be.stacktrace.traffide.ui.repository.impl.CameraImageWrapper;import org.eclipse.swt.graphics.Image;* {@link CameraImageWrapper} changed.* {@link CameraImageWrapper} changed.public class CameraImageChangeEvent {public class CameraImageChangeEvent {private CameraImageWrapper changed;private UpdatableResource<Image> changed;public CameraImageChangeEvent(CameraImageWrapper changed) {public CameraImageChangeEvent(UpdatableResource<Image> changed) {public CameraImageWrapper getChanged() {public UpdatableResource<Image> getChanged() {public class MapImageChangeEvent {public class MapImageChangeEvent {public UpdatableResource<MapImageWrapper> getMapImage() {public MapImageChangeEvent(UpdatableResource<MapImageWrapper> mapImage) {import org.apache.commons.configuration.Configuration;import org.eclipse.core.runtime.Status;import be.stacktrace.traffide.TraffideActivator;public class CameraPassCodeFetcher {public class CameraPassCodeFetcher {/** The grep stream reader. *//** The grep stream reader. */private GrepStreamReader grepStreamReader;private GrepStreamReader grepStreamReader;/** The grep string handler. *//** The grep string handler. */private PassKeyForCameraStringHandler grepStringHandler;private PassKeyForCameraStringHandler grepStringHandler;/** The http client wrapper. */private TraffideContext context;private HttpClientWrapper httpClientWrapper;/** The config. *//**private Configuration config;* Instantiates a new CameraPassCodeFetcher.** @param httpClientWrapper* the http client wrapper* @param config* the config*/public CameraPassCodeFetcher(TraffideContext context) {this.context = context;// Initialize the readergrepStreamReader = new GrepStreamReader();// initialize the handlergrepStringHandler = new PassKeyForCameraStringHandler();}/**/*** Instantiates a new CameraPassCodeFetcher.* Gets the pass key for camera using HTTP-request.*** @param httpClientWrapper* @return the pass key for camera* the http client wrapper*/* @param configpublic String getPassKeyForCamera() {* the config// Do the request*/GetMethod method = new GetMethod(context.getConfig().getString(public CameraPassCodeFetcher(HttpClientWrapper httpClientWrapper,ConfigConstantsHttp.CONFIG_HTTP_PASSKEY_CAMERA_URI));Configuration config) {String hostName = context.getConfig().getString(ConfigConstantsHttp.CONFIG_HTTP_MAIN_CAMERA_HOSTNAME);this.httpClientWrapper = httpClientWrapper;this.config = config;// Initialize the readertry {grepStreamReader = new GrepStreamReader();context.getHttpClientWrapper().doRequest(hostName, method);// initialize the handler// Handle the responsegrepStringHandler = new PassKeyForCameraStringHandler();grepStreamReader.processStream(method.getResponseBodyAsStream(), grepStringHandler);}} catch (IOException e) {context.logGlobal(IStatus.ERROR, 0, "Cannot get passkey from HTTP-call: " + e.getMessage(), e);} finally {method.releaseConnection();}// Check the handler for the passcodeString passKey = grepStringHandler.getPassKey();/**if (passKey == null) {* Gets the pass key for camera using HTTP-request.context.logGlobal(IStatus.ERROR, 0, "No passkey could be extracted from HTTP-call", null);*}* @return the pass key for camera// Finally, reset the handler*/grepStringHandler.reset();public String getPassKeyForCamera() {return passKey;// Do the request}GetMethod method = new GetMethod(config.getString(ConfigConstantsHttp.CONFIG_HTTP_PASSKEY_CAMERA_URI));String hostName = config.getString(ConfigConstantsHttp.CONFIG_HTTP_MAIN_CAMERA_HOSTNAME);try {/**httpClientWrapper.doRequest(hostName, method);* The Class PassKeyForCameraStringHandler is an internal classed used to// Handle the response* get the passkey for camera images using <code>GrepStreamReader</code>grepStreamReader.processStream(method.getResponseBodyAsStream(),* result, using regex to find exact passkey inside the line.grepStringHandler);*} catch (IOException e) {* @author Frederik Heremans// TODO Auto-generated catch block* @since 1.0e.printStackTrace();*/TraffideActivator.getDefault().getLog().log(new Status (IStatus.ERROR,private class PassKeyForCameraStringHandler extends GrepStringHandler {"Woops",0,"Errow while fetching passcode: " + e.getMessage(),e));} finally {/** The Constant NUMBER_REGEX. */method.releaseConnection();private static final String NUMBER_REGEX = "[0-9]+";}// Check the handler for the passcodeString passKey = grepStringHandler.getPassKey();if (passKey == null) {/** The pass key. */// TODO: Log that no passkey could be retrieved from the HTTP-Callprivate String passKey;}// Finally, reset the handlergrepStringHandler.reset();return passKey;}/**/** The numbers pattern. */* The Class PassKeyForCameraStringHandler is an internal classed used toprivate Pattern numbersPattern;* get the passkey for camera images using <code>GrepStreamReader</code>* result, using regex to find exact passkey inside the line.** @author Frederik Heremans* @since 1.0*/private class PassKeyForCameraStringHandler extends GrepStringHandler {/** The Constant NUMBER_REGEX. *//**private static final String NUMBER_REGEX = "[0-9]+";* Instantiates a new PassKeyForCameraStringHandler.*/public PassKeyForCameraStringHandler() {super(Pattern.compile(context.getConfig().getString(ConfigConstantsHttp.CONFIG_HTTP_PASSKEY_CAMERA_REGEX)));numbersPattern = Pattern.compile(NUMBER_REGEX);}/** The pass key. *//**private String passKey;* {@inheritDoc}*/public boolean handleString(String line) {// Locate the matched string and extract the numbers behind itMatcher m = getRegexPattern().matcher(line);if (m.find()) {// Look for first digit starting from end-pos of matcherMatcher numberM = numbersPattern.matcher(line);if (numberM.find(m.end())) {// Found the passKeythis.passKey = line.substring(numberM.start(), numberM.end());// Stop processing, found a matchreturn false;}}return true;}/** The numbers pattern. *//**private Pattern numbersPattern;* Gets the pass key.** @return the pass key*/public String getPassKey() {return passKey;}/**/*** Instantiates a new PassKeyForCameraStringHandler.* Reset the handler.*/*/public PassKeyForCameraStringHandler() {public void reset() {super(PatternpassKey = null;.compile(config}.getString(ConfigConstantsHttp.CONFIG_HTTP_PASSKEY_CAMERA_REGEX)));}numbersPattern = Pattern.compile(NUMBER_REGEX);}/*** {@inheritDoc}*/public boolean handleString(String line) {// Locate the matched string and extract the numbers behind itMatcher m = getRegexPattern().matcher(line);if (m.find()) {// Look for first digit starting from end-pos of matcherMatcher numberM = numbersPattern.matcher(line);if (numberM.find(m.end())) {// Found the passKeythis.passKey = line.substring(numberM.start(), numberM.end());// Stop processing, found a matchreturn false;}}return true;}/*** Gets the pass key.** @return the pass key*/public String getPassKey() {return passKey;}/*** Reset the handler.*/public void reset() {passKey = null;}}fetcher = new CameraPassCodeFetcher(context.getHttpClientWrapper(), context.getConfig());store.setDefault(PreferenceConstants.P_MAP_IMAGE_REFRESH_TIME, "60000");// Map view defaultsimport java.util.Collection;import be.stacktrace.traffide.model.MapRegion;import be.stacktrace.traffide.model.repository.MapRegionRepository;* The Class TraffidePreferences is a {@link IWorkbenchPreferencePage} that* The Class TraffidePreferences is a {@link IWorkbenchPreferencePage} thatDirectoryFieldEditor homeDirEditor = new DirectoryFieldEditor(PreferenceConstants.P_USER_DIR_LOCATION,// DirectoryFieldEditor homeDirEditor = new"&Traffide preference directory:", getFieldEditorParent());// DirectoryFieldEditor(PreferenceConstants.P_USER_DIR_LOCATION,homeDirEditor.setEmptyStringAllowed(false);// "&Traffide preference directory:", getFieldEditorParent());homeDirEditor.setValidateStrategy(DirectoryFieldEditor.VALIDATE_ON_FOCUS_LOST);// homeDirEditor.setEmptyStringAllowed(false);addField(homeDirEditor);// homeDirEditor.setValidateStrategy(DirectoryFieldEditor.VALIDATE_ON_FOCUS_LOST);// addField(homeDirEditor);// ComboFieldEditor mapRegionDefaultEditor = new ComboFieldEditor(PreferenceConstants.P_MAP_DEFAULT_REGION,// "&Default map region", getMapRegionValues(), getFieldEditorParent());//// addField(mapRegionDefaultEditor);addField(mapRegionDefaultEditor);private String[][] getTrafficJamLengtTimeoutValues() {private String[][] getTrafficJamLengtTimeoutValues() {{ "Every 2 minutes", "120000" }, { "Every 5 minutes", "300000" }, { "Every 10 minutes", "600000" } };{ "Every 2 minutes", "120000" }, { "Every 5 minutes", "300000" }, { "Every 10 minutes", "600000" } };private String[][] getMapRegionValues() {// private String[][] getMapRegionValues() {// MapRegionRepository repo = TraffideActivator.getContext().getService(MapRegionRepository.class);// Collection<MapRegion> regions = repo.getAllMapRegions();//// String[][] regArray = new String[regions.size()][];// int i = 0;// for (MapRegion reg : regions) {// regArray[i] = new String[] { reg.getName(), reg.getId() };// i++;// }// return regArray;// }String[][] regArray = new String[regions.size()][];int i = 0;for (MapRegion reg : regions) {regArray[i] = new String[] { reg.getName(), reg.getId() };i++;}return regArray;}* {@inheritDoc}* {@inheritDoc}context.getGlobalEventRegistry().registerEventHandler(CameraPassCodeChangeEvent.class, new GlobalEventHandler<CameraPassCodeChangeEvent>() {context.getGlobalEventRegistry().registerEventHandler(CameraPassCodeChangeEvent.class, new GlobalEventHandler<CameraPassCodeChangeEvent>() {public void handleEvent(CameraPassCodeChangeEvent event) {public void handleEvent(CameraPassCodeChangeEvent event) {System.out.println("Got passkey update: " + passCode);public void updatePassCode() {public void updatePassCode() {if (fetchJob != null) {if (fetchJob != null) {System.out.println("jaja");// Set the preference storecontextImpl.setPreferenceStore(getPreferenceStore());// TODO: Auto-generated Javadocpublic class MapImageRepository {import be.stacktrace.traffide.model.MapRegion;import be.stacktrace.traffide.ui.model.MapImageWrapper;import be.stacktrace.traffide.update.UpdatableResource;public interface MapImageRepository {* Gets the {@MapImageWrapper} for the given region.public class MapView extends ViewPart {public class MapView extends ViewPart {private Action action1;private Action action2;private List<Action> regionActions;private Action setAutoUpdateAction;public MapView() {public MapView() {regionActions = new ArrayList<SelectMapRegionAction>();context = TraffideActivator.getContext();mapRegionRepo = context.getService(MapRegionRepository.class);mapImageRepo = context.getService(MapImageRepository.class);// Create the jobupdateMapJob = new UpdateMapViewJob(context);private void setMapRegion(MapRegion region) {private void setMapRegion(MapRegion region) {public void createPartControl(Composite parent) {public void createPartControl(Composite parent) {new GlobalEventHandler<MapImageChangeEvent>() {public void handleEvent(MapImageChangeEvent event) {&& region.equals(event.getMapImage().getResourceKey())) {getSite().getShell().getDisplay().asyncExec(new Runnable() {public void run() {scrolledComposite.addControlListener(new ControlAdapter() {public void controlResized(ControlEvent e) {hookContextMenu();if(autoUpdate) {protected void doScroll() {@SuppressWarnings("unused")private void hookContextMenu() {private void hookContextMenu() {// MenuManager menuMgr = new MenuManager("#PopupMenu");MenuManager menuMgr = new MenuManager("#PopupMenu");// menuMgr.setRemoveAllWhenShown(true);// menuMgr.addMenuListener(new IMenuListener() {menuMgr.addMenuListener(new IMenuListener() {// public void menuAboutToShow(IMenuManager manager) {public void menuAboutToShow(IMenuManager manager) {// MapView.this.fillContextMenu(manager);MapView.this.fillLocalPullDown(manager);// }}// });// Menu menu = menuMgr.createContextMenu(viewer.getControl());Menu menu = menuMgr.createContextMenu(c);// viewer.getControl().setMenu(menu);c.setMenu(menu);// getSite().registerContextMenu(menuMgr, viewer);private void contributeToActionBars() {private void contributeToActionBars() {public void dispose() {private void fillLocalPullDown(IMenuManager manager) {private void fillLocalPullDown(IMenuManager manager) {for (Action action : regionActions) {for (Action action : regionActions) {// Add the "set as default" action// Finally, add the "set as default" action// private void fillContextMenu(IMenuManager manager) {// manager.add(action1);// manager.add(action2);// // Other plug-ins can contribute there actions here// manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));// }private void fillLocalToolBar(IToolBarManager manager) {private void fillLocalToolBar(IToolBarManager manager) {manager.add(action1);manager.add(refreshAction);manager.add(action2);private void makeActions() {private void makeActions() {TraffideContext context = TraffideActivator.getContext();MapRegionRepository mapRegionRepo = context.getService(MapRegionRepository.class);System.out.println(defaultRegion);for (MapRegion region : mapRegionRepo.getAllMapRegions()) {for (MapRegion region : mapRegionRepo.getAllMapRegions()) {action1 = new Action() {// Add the auto-update on/off actionsetAutoUpdateAction = new Action(null, Action.AS_CHECK_BOX) {@Overridepublic void run() {public void run() {System.out.println("Action 1 executed");setAutoUpdate(!autoUpdate);action1.setText("Action 1");setAutoUpdateAction.setText("Auto-update");action1.setToolTipText("Action 1 tooltip");// Get checked/unchecked valueaction1.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(setAutoUpdateAction.setChecked(autoUpdate);ISharedImages.IMG_OBJS_INFO_TSK));action2 = new Action() {// The refresh-map action (forced)refreshAction = new Action() {@Overridepublic void run() {public void run() {System.out.println("Action 2 executed");if (region != null) {refreshMapImage();}action2.setText("Action 2");action2.setToolTipText("Action 2 tooltip");action2.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_OBJS_INFO_TSK));refreshAction.setText("Refresh map");private class SelectMapRegionAction extends Action {private class SelectMapRegionAction extends Action {public SelectMapRegionAction(MapRegion regionToSet) {public SelectMapRegionAction(MapRegion regionToSet) {if (regionToSet != null) {if (regionToSet != null) {setToolTipText("Show region " + regionToSet.getName());setToolTipText("Show region " + regionToSet.getName());public MapRegion getRegion() {public void run() {public void run() {public void checkAction(SelectMapRegionAction selectMapRegionAction) {private void checkAction(SelectMapRegionAction selectMapRegionAction) {for (Action action : regionActions) {for (Action action : regionActions) {if (!selectMapRegionAction.equals(action)) {if (!selectMapRegionAction.equals(action)) {private void setAutoUpdate(boolean autoUpdate) {if (autoUpdate != this.autoUpdate) {if (autoUpdate) {} else {private void refreshMapImage() {if (region != null) {if (wr != null) {} else {switch (image.getStatus()) {updatelabel.setText("Error while updating");updatelabel.setText("Last updated on "updatelabel.setText("Updating...");