Revision 673
org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.swing/org.gvsig.tools.swing.impl/src/main/java/org/gvsig/tools/swing/impl/task/DefaultTaskStatusSwingManager.java | ||
---|---|---|
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 |
*/ |
|
1 | 22 |
package org.gvsig.tools.swing.impl.task; |
2 | 23 |
|
3 | 24 |
import org.gvsig.tools.ToolsLocator; |
... | ... | |
7 | 28 |
import org.gvsig.tools.swing.api.task.TaskStatusSwingManager; |
8 | 29 |
import org.gvsig.tools.task.TaskStatusManager; |
9 | 30 |
|
31 |
/** |
|
32 |
* Default implementation of the {@link TaskStatusSwingManager}. |
|
33 |
* |
|
34 |
* @author gvSIG Team |
|
35 |
* @version $Id$ |
|
36 |
*/ |
|
10 | 37 |
public class DefaultTaskStatusSwingManager implements TaskStatusSwingManager { |
11 | 38 |
|
12 |
public JTasksStatus createJTasksStatus() {
|
|
13 |
return new DefaultJTasksStatus();
|
|
14 |
}
|
|
39 |
public JTasksStatus createJTasksStatus() {
|
|
40 |
return new DefaultJTasksStatus();
|
|
41 |
}
|
|
15 | 42 |
|
16 |
public JTasksStatus createJTasksStatus(TaskStatusManager manager) {
|
|
17 |
return new DefaultJTasksStatus(manager);
|
|
18 |
}
|
|
43 |
public JTasksStatus createJTasksStatus(TaskStatusManager manager) {
|
|
44 |
return new DefaultJTasksStatus(manager);
|
|
45 |
}
|
|
19 | 46 |
|
20 |
public JTasksStatusList createJTasksStatusList() {
|
|
21 |
return new DefaultJTasksStatusList(this.getManager());
|
|
22 |
}
|
|
47 |
public JTasksStatusList createJTasksStatusList() {
|
|
48 |
return new DefaultJTasksStatusList(this.getManager());
|
|
49 |
}
|
|
23 | 50 |
|
24 |
public JTasksStatusList createJTasksStatusList(TaskStatusManager manager) {
|
|
25 |
return new DefaultJTasksStatusList(manager);
|
|
26 |
}
|
|
51 |
public JTasksStatusList createJTasksStatusList(TaskStatusManager manager) {
|
|
52 |
return new DefaultJTasksStatusList(manager);
|
|
53 |
}
|
|
27 | 54 |
|
28 |
public JTaskStatus createJTaskStatus() {
|
|
29 |
return new DefaultJTaskStatus();
|
|
30 |
}
|
|
55 |
public JTaskStatus createJTaskStatus() {
|
|
56 |
return new DefaultJTaskStatus();
|
|
57 |
}
|
|
31 | 58 |
|
32 |
private TaskStatusManager getManager() {
|
|
33 |
return ToolsLocator.getTaskStatusManager();
|
|
34 |
}
|
|
59 |
private TaskStatusManager getManager() {
|
|
60 |
return ToolsLocator.getTaskStatusManager();
|
|
61 |
}
|
|
35 | 62 |
} |
org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.swing/org.gvsig.tools.swing.impl/src/main/java/org/gvsig/tools/swing/impl/task/DefaultJTasksStatusList.java | ||
---|---|---|
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 |
*/ |
|
1 | 22 |
package org.gvsig.tools.swing.impl.task; |
2 | 23 |
|
3 | 24 |
import java.awt.BorderLayout; |
... | ... | |
22 | 43 |
import org.gvsig.tools.task.TaskStatus; |
23 | 44 |
import org.gvsig.tools.task.TaskStatusManager; |
24 | 45 |
|
25 |
public class DefaultJTasksStatusList extends JTasksStatusList implements Observer { |
|
46 |
/** |
|
47 |
* Default implementation of the {@link JTasksStatusList}. |
|
48 |
* |
|
49 |
* @author gvSIG Team |
|
50 |
* @version $Id$ |
|
51 |
*/ |
|
52 |
public class DefaultJTasksStatusList extends JTasksStatusList implements |
|
53 |
Observer { |
|
26 | 54 |
|
27 |
/** |
|
28 |
* |
|
29 |
*/ |
|
30 |
private static final long serialVersionUID = 7740032506050392725L; |
|
55 |
private static final long serialVersionUID = 7740032506050392725L; |
|
31 | 56 |
|
32 |
TaskStatusManager manager; |
|
33 |
Map<String,JTaskStatus> taskControls; |
|
34 |
JPanel listPanel; |
|
35 |
|
|
36 |
public DefaultJTasksStatusList(TaskStatusManager manager) { |
|
37 |
this.manager = manager; |
|
38 |
this.taskControls = new HashMap<String, JTaskStatus>(); |
|
39 |
this.makeUI(); |
|
40 |
this.manager.addObserver(this); |
|
41 |
} |
|
57 |
TaskStatusManager manager; |
|
58 |
Map<String, JTaskStatus> taskControls; |
|
59 |
JPanel listPanel; |
|
42 | 60 |
|
43 |
public TaskStatusManager getManager() { |
|
44 |
return this.manager; |
|
45 |
} |
|
46 |
|
|
47 |
private void makeUI() { |
|
48 |
this.setLayout(new BorderLayout()); |
|
49 |
|
|
50 |
listPanel = new JPanel(); |
|
51 |
listPanel.setLayout(new BoxLayout(listPanel, BoxLayout.Y_AXIS)); |
|
52 |
List<JTaskStatus> controlsToAdd = this.getControlsToAdd(); |
|
53 |
for (JTaskStatus taskStatus : controlsToAdd) { |
|
54 |
listPanel.add(taskStatus); |
|
55 |
} |
|
56 |
|
|
57 |
JScrollPane scroller = new JScrollPane(listPanel); |
|
58 |
scroller.setPreferredSize(new Dimension(300,150)); |
|
61 |
public DefaultJTasksStatusList(TaskStatusManager manager) { |
|
62 |
this.manager = manager; |
|
63 |
this.taskControls = new HashMap<String, JTaskStatus>(); |
|
64 |
this.makeUI(); |
|
65 |
this.manager.addObserver(this); |
|
66 |
} |
|
67 |
|
|
68 |
public TaskStatusManager getManager() { |
|
69 |
return this.manager; |
|
70 |
} |
|
71 |
|
|
72 |
private void makeUI() { |
|
73 |
this.setLayout(new BorderLayout()); |
|
74 |
|
|
75 |
listPanel = new JPanel(); |
|
76 |
listPanel.setLayout(new BoxLayout(listPanel, BoxLayout.Y_AXIS)); |
|
77 |
List<JTaskStatus> controlsToAdd = this.getControlsToAdd(); |
|
78 |
for (JTaskStatus taskStatus : controlsToAdd) { |
|
79 |
listPanel.add(taskStatus); |
|
80 |
} |
|
81 |
|
|
82 |
JScrollPane scroller = new JScrollPane(listPanel); |
|
83 |
scroller.setPreferredSize(new Dimension(300, 150)); |
|
59 | 84 |
this.add(scroller, BorderLayout.CENTER); |
60 |
} |
|
61 |
|
|
62 |
private List<JTaskStatus> getControlsToAdd() { |
|
63 |
List<JTaskStatus> controlsToAdd = new ArrayList<JTaskStatus>(); |
|
64 |
TaskStatusSwingManager manager = ToolsSwingLocator.getTaskStatusSwingManager(); |
|
65 |
|
|
66 |
@SuppressWarnings("unchecked") |
|
67 |
Map<String,TaskStatus> tasksStatus = this.manager.getAll(); |
|
68 |
|
|
69 |
Iterator<Entry<String, TaskStatus>> taskStatusIterator = tasksStatus.entrySet().iterator(); |
|
70 |
while( taskStatusIterator.hasNext() ) { |
|
71 |
Entry<String, TaskStatus> entry = taskStatusIterator.next(); |
|
72 |
if( this.taskControls.get(entry.getKey())==null ) { |
|
73 |
JTaskStatus control = manager.createJTaskStatus(); |
|
74 |
control.bind(entry.getValue()); |
|
75 |
controlsToAdd.add(control); |
|
76 |
this.taskControls.put(entry.getKey(), control); |
|
77 |
} |
|
78 |
} |
|
79 |
return controlsToAdd; |
|
80 |
} |
|
85 |
} |
|
81 | 86 |
|
82 |
public void update(Observable observable, Object notification) { |
|
83 |
if( !(observable instanceof TaskStatusManager) ) { |
|
84 |
return; |
|
85 |
} |
|
86 |
if( notification==null ) { |
|
87 |
// remove task |
|
88 |
Iterator<Entry<String, JTaskStatus>> taskStatusIterator = this.taskControls.entrySet().iterator(); |
|
89 |
while( taskStatusIterator.hasNext() ) { |
|
90 |
Entry<String, JTaskStatus> entry = taskStatusIterator.next(); |
|
91 |
if( this.manager.get(entry.getKey())==null ) { |
|
92 |
listPanel.remove(entry.getValue()); |
|
93 |
} |
|
94 |
} |
|
95 |
listPanel.validate(); |
|
96 |
return; |
|
97 |
} |
|
98 |
List<JTaskStatus> controlsToAdd = this.getControlsToAdd(); |
|
99 |
for (JTaskStatus taskStatus : controlsToAdd) { |
|
100 |
listPanel.add(taskStatus); |
|
101 |
} |
|
102 |
|
|
103 |
} |
|
87 |
private List<JTaskStatus> getControlsToAdd() { |
|
88 |
List<JTaskStatus> controlsToAdd = new ArrayList<JTaskStatus>(); |
|
89 |
TaskStatusSwingManager manager = |
|
90 |
ToolsSwingLocator.getTaskStatusSwingManager(); |
|
91 |
|
|
92 |
@SuppressWarnings("unchecked") |
|
93 |
Map<String, TaskStatus> tasksStatus = this.manager.getAll(); |
|
94 |
|
|
95 |
Iterator<Entry<String, TaskStatus>> taskStatusIterator = |
|
96 |
tasksStatus.entrySet().iterator(); |
|
97 |
while (taskStatusIterator.hasNext()) { |
|
98 |
Entry<String, TaskStatus> entry = taskStatusIterator.next(); |
|
99 |
if (this.taskControls.get(entry.getKey()) == null) { |
|
100 |
JTaskStatus control = manager.createJTaskStatus(); |
|
101 |
control.bind(entry.getValue()); |
|
102 |
controlsToAdd.add(control); |
|
103 |
this.taskControls.put(entry.getKey(), control); |
|
104 |
} |
|
105 |
} |
|
106 |
return controlsToAdd; |
|
107 |
} |
|
108 |
|
|
109 |
public void update(Observable observable, Object notification) { |
|
110 |
if (!(observable instanceof TaskStatusManager)) { |
|
111 |
return; |
|
112 |
} |
|
113 |
if (notification == null) { |
|
114 |
// remove task |
|
115 |
Iterator<Entry<String, JTaskStatus>> taskStatusIterator = |
|
116 |
this.taskControls.entrySet().iterator(); |
|
117 |
while (taskStatusIterator.hasNext()) { |
|
118 |
Entry<String, JTaskStatus> entry = taskStatusIterator.next(); |
|
119 |
if (this.manager.get(entry.getKey()) == null) { |
|
120 |
listPanel.remove(entry.getValue()); |
|
121 |
} |
|
122 |
} |
|
123 |
listPanel.validate(); |
|
124 |
return; |
|
125 |
} |
|
126 |
List<JTaskStatus> controlsToAdd = this.getControlsToAdd(); |
|
127 |
for (JTaskStatus taskStatus : controlsToAdd) { |
|
128 |
listPanel.add(taskStatus); |
|
129 |
} |
|
130 |
|
|
131 |
} |
|
104 | 132 |
} |
org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.swing/org.gvsig.tools.swing.impl/src/main/java/org/gvsig/tools/swing/impl/task/DefaultJTaskStatus.java | ||
---|---|---|
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 |
*/ |
|
1 | 22 |
package org.gvsig.tools.swing.impl.task; |
2 | 23 |
|
3 | 24 |
import java.awt.Component; |
... | ... | |
21 | 42 |
import org.gvsig.tools.task.SimpleTaskStatus; |
22 | 43 |
import org.gvsig.tools.task.TaskStatus; |
23 | 44 |
|
45 |
/** |
|
46 |
* Default implementation of the {@link JTaskStatus}. |
|
47 |
* |
|
48 |
* @author gvSIG Team |
|
49 |
* @version $Id$ |
|
50 |
*/ |
|
24 | 51 |
public class DefaultJTaskStatus extends JTaskStatus implements Observer { |
25 | 52 |
|
26 |
/** |
|
27 |
* |
|
28 |
*/ |
|
29 | 53 |
private static final long serialVersionUID = -1908456747637477552L; |
30 | 54 |
|
31 | 55 |
private JLabel titlelabel = null; |
... | ... | |
39 | 63 |
|
40 | 64 |
private TaskStatus taskStatus; |
41 | 65 |
|
42 |
|
|
43 | 66 |
public DefaultJTaskStatus() { |
44 | 67 |
this.taskStatus = null; |
45 | 68 |
this.showCancelButton = true; |
org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.swing/org.gvsig.tools.swing.impl/src/main/java/org/gvsig/tools/swing/impl/task/DefaultJTasksStatus.java | ||
---|---|---|
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 |
*/ |
|
1 | 22 |
package org.gvsig.tools.swing.impl.task; |
2 | 23 |
|
3 | 24 |
import java.awt.Dimension; |
... | ... | |
24 | 45 |
import org.gvsig.tools.task.TaskStatus; |
25 | 46 |
import org.gvsig.tools.task.TaskStatusManager; |
26 | 47 |
|
48 |
/** |
|
49 |
* Default implementation of the {@link JTasksStatus}. |
|
50 |
* |
|
51 |
* @author gvSIG Team |
|
52 |
* @version $Id$ |
|
53 |
*/ |
|
27 | 54 |
public class DefaultJTasksStatus extends JTasksStatus implements Observer { |
28 | 55 |
|
29 |
/** |
|
30 |
* |
|
31 |
*/ |
|
32 | 56 |
private static final long serialVersionUID = 245436792193991920L; |
33 | 57 |
|
34 | 58 |
private TaskStatusManager manager = null; |
Also available in: Unified diff