root / trunk / extensions / extPublish / dist-src / extPublish / src / org / gvsig / publish / gui / remove / RemoveResourceController.java @ 29308
History | View | Annotate | Download (2.98 KB)
1 | 29308 | jvhigon | /* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|---|---|
2 | *
|
||
3 | * Copyright (C) 2004-2006 IVER T.I. and Generalitat Valenciana.
|
||
4 | *
|
||
5 | * This program is free software; you can redistribute it and/or
|
||
6 | * modify it under the terms of the GNU General Public License
|
||
7 | * as published by the Free Software Foundation; either version 2
|
||
8 | * of the License, or (at your option) any later version.
|
||
9 | *
|
||
10 | * This program is distributed in the hope that it will be useful,
|
||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
13 | * GNU General Public License for more details.
|
||
14 | *
|
||
15 | * You should have received a copy of the GNU General Public License
|
||
16 | * along with this program; if not, write to the Free Software
|
||
17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
||
18 | *
|
||
19 | * For more information, contact:
|
||
20 | *
|
||
21 | * Generalitat Valenciana
|
||
22 | * Conselleria d'Infraestructures i Transport
|
||
23 | * Av. Blasco Iba?ez, 50
|
||
24 | * 46010 VALENCIA
|
||
25 | * SPAIN
|
||
26 | *
|
||
27 | * +34 963862235
|
||
28 | * gvsig@gva.es
|
||
29 | * www.gvsig.gva.es
|
||
30 | *
|
||
31 | * or
|
||
32 | *
|
||
33 | * IVER T.I. S.A
|
||
34 | * Salamanca 50
|
||
35 | * 46005 Valencia
|
||
36 | * Spain
|
||
37 | *
|
||
38 | * +34 963163400
|
||
39 | * dac@iver.es
|
||
40 | */
|
||
41 | package org.gvsig.publish.gui.remove; |
||
42 | |||
43 | import java.awt.event.ActionEvent; |
||
44 | import java.awt.event.ActionListener; |
||
45 | import java.util.HashSet; |
||
46 | |||
47 | import javax.swing.JButton; |
||
48 | import javax.swing.JTree; |
||
49 | import javax.swing.event.TreeSelectionEvent; |
||
50 | import javax.swing.event.TreeSelectionListener; |
||
51 | import javax.swing.tree.TreePath; |
||
52 | |||
53 | import org.gvsig.publish.serversmodel.RemoteResource; |
||
54 | |||
55 | /**
|
||
56 | * Control for removing a remote resources from the publication
|
||
57 | *
|
||
58 | * @author jvhigon
|
||
59 | *
|
||
60 | */
|
||
61 | public class RemoveResourceController implements ActionListener, TreeSelectionListener { |
||
62 | public final String REMOVE_EVENT="remove"; |
||
63 | private HashSet resourcesToDel = new HashSet(); |
||
64 | |||
65 | /**
|
||
66 | * Constructor
|
||
67 | * @param view Wizard panel which has the button for delete resources
|
||
68 | * @param model Publication for delete the resource
|
||
69 | */
|
||
70 | public RemoveResourceController(JButton button, JTree tree) { |
||
71 | //set listeners
|
||
72 | button.addActionListener(this);
|
||
73 | button.setActionCommand(REMOVE_EVENT); |
||
74 | tree.addTreeSelectionListener(this);
|
||
75 | } |
||
76 | /*
|
||
77 | * (non-Javadoc)
|
||
78 | * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
|
||
79 | */
|
||
80 | public void actionPerformed(ActionEvent arg0) { |
||
81 | if (arg0.getActionCommand().equals(REMOVE_EVENT)){
|
||
82 | Object[] o = resourcesToDel.toArray(); |
||
83 | for (int i = 0; i < o.length; i++){ |
||
84 | RemoteResource r = (RemoteResource)o[i]; |
||
85 | r.remove(); |
||
86 | } |
||
87 | } |
||
88 | |||
89 | } |
||
90 | /*
|
||
91 | * (non-Javadoc)
|
||
92 | * @see javax.swing.event.TreeSelectionListener#valueChanged(javax.swing.event.TreeSelectionEvent)
|
||
93 | */
|
||
94 | public void valueChanged(TreeSelectionEvent e) { |
||
95 | TreePath[] paths = e.getPaths(); |
||
96 | for (int i = 0; i < paths.length; i++){ |
||
97 | if (e.isAddedPath(paths[i])){
|
||
98 | resourcesToDel.add(paths[i].getLastPathComponent()); |
||
99 | }else{
|
||
100 | resourcesToDel.remove(paths[i].getLastPathComponent()); |
||
101 | } |
||
102 | } |
||
103 | } |
||
104 | |||
105 | } |