gvsig-raster / org.gvsig.raster / trunk / org.gvsig.raster / org.gvsig.raster.lib / org.gvsig.raster.lib.impl / src / main / java / org / gvsig / raster / impl / process / DefaultTaskEventManager.java @ 1419
History | View | Annotate | Download (3.09 KB)
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
4 |
* of the Valencian Government (CIT)
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 2
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
*/
|
22 |
package org.gvsig.raster.impl.process; |
23 |
|
24 |
import java.util.EventObject; |
25 |
|
26 |
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException; |
27 |
import org.gvsig.fmap.dal.coverage.process.TaskEventManager; |
28 |
/**
|
29 |
* This class manages a raster task.
|
30 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
31 |
*/
|
32 |
public class DefaultTaskEventManager implements TaskEventManager { |
33 |
private RasterTask task = null; |
34 |
|
35 |
/**
|
36 |
* This constructor creates this object but it doesn't register
|
37 |
* the task
|
38 |
* @param process
|
39 |
*/
|
40 |
public DefaultTaskEventManager() {
|
41 |
} |
42 |
|
43 |
/**
|
44 |
* This constructor creates the task and register this
|
45 |
* in the repository
|
46 |
* @param process
|
47 |
*/
|
48 |
public DefaultTaskEventManager(Object process) { |
49 |
task = new RasterTask(process);
|
50 |
RasterTaskQueue.register(task); |
51 |
} |
52 |
|
53 |
/*
|
54 |
* O(non-Javadoc)
|
55 |
* @see org.gvsig.fmap.dal.coverage.process.TaskEventManager#removeTask()
|
56 |
*/
|
57 |
public void removeTask() { |
58 |
RasterTaskQueue.remove(task); |
59 |
} |
60 |
|
61 |
/*
|
62 |
* (non-Javadoc)
|
63 |
* @see org.gvsig.fmap.dal.coverage.process.TaskEventManager#setEvent(java.util.EventObject)
|
64 |
*/
|
65 |
public void setEvent(EventObject ev) { |
66 |
task.setEvent(ev); |
67 |
} |
68 |
|
69 |
/**
|
70 |
* Assigns a task without register.
|
71 |
* @param task
|
72 |
*/
|
73 |
public void setTask(RasterTask task) { |
74 |
this.task = task;
|
75 |
} |
76 |
|
77 |
public RasterTask getTask() {
|
78 |
return task;
|
79 |
} |
80 |
|
81 |
/*
|
82 |
* (non-Javadoc)
|
83 |
* @see org.gvsig.fmap.dal.coverage.process.TaskEventManager#getEvent()
|
84 |
*/
|
85 |
public EventObject getEvent() { |
86 |
return task.getEvent();
|
87 |
} |
88 |
|
89 |
/**
|
90 |
* Gesti?n de las se?ales. Este m?todo define las acciones por defecto para
|
91 |
* cada se?al. No es necesario utilizar estas. Se puede en cada caso, hacer un m?todo
|
92 |
* manageEvent en el que se gestione las acciones concretas de una se?al.
|
93 |
*
|
94 |
* @param ev Evento a gestionar
|
95 |
*/
|
96 |
public void manageEvent(EventObject ev) throws ProcessInterruptedException { |
97 |
task.manageEvent(ev); |
98 |
} |
99 |
|
100 |
/**
|
101 |
* Obtiene un proceso a partir de su identificador
|
102 |
* @param id Identificador del proceso
|
103 |
* @return Proceso
|
104 |
*/
|
105 |
public static TaskEventManager get() { |
106 |
RasterTask task = RasterTaskQueue.get(Thread.currentThread().getId() + ""); |
107 |
DefaultTaskEventManager taskEventManager = new DefaultTaskEventManager();
|
108 |
taskEventManager.setTask(task); |
109 |
return taskEventManager;
|
110 |
} |
111 |
} |