1 /*******************************************************************************
2 * Copyright (c) 2012 Association for Decentralized Information Management
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.maps.eclipse;
14 import java.awt.Image;
16 import org.eclipse.core.runtime.IProgressMonitor;
17 import org.eclipse.core.runtime.IStatus;
18 import org.eclipse.core.runtime.Status;
19 import org.eclipse.core.runtime.jobs.Job;
20 import org.simantics.maps.query.Query;
21 import org.simantics.maps.tile.ITileProvider;
22 import org.simantics.maps.tile.TileKey;
25 * @author Tuukka Lehtonen
28 public class TileJob extends Job {
30 private ITileProvider provider;
31 private Query<TileKey, Image> query;
33 public TileJob(Query<TileKey, Image> query, ITileProvider provider) {
34 super("Raster Map Request Job");
35 assert(query != null);
37 this.provider = provider;
40 public Query<TileKey, Image> getQuery() {
45 protected IStatus run(IProgressMonitor monitor) {
46 setThread(Thread.currentThread());
47 monitor.beginTask("Querying map data", 1);
50 if (monitor.isCanceled()) {
52 return Status.CANCEL_STATUS;
56 monitor.subTask(query.source.toString());
57 Image result = provider.get(query.source);
58 query.listener.queryComplete(query, result);
59 } catch (Exception e) {
60 query.listener.queryFailed(query, e);
67 return Status.OK_STATUS;