svn-gvsig-desktop / branches / v2_0_0_prep / extensions / org.gvsig.image.extension / src / main / java / org / gvsig / arcims / image / gui / panels / utils / ServicesTableSelectionListener.java @ 32321
History | View | Annotate | Download (2.99 KB)
1 | 32321 | vsanjaime | /* 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 | |||
23 | /*
|
||
24 | * AUTHORS (In addition to CIT):
|
||
25 | * 2010 Prodevelop S.L. main development
|
||
26 | * http://www.prodevelop.es
|
||
27 | */
|
||
28 | |||
29 | package org.gvsig.arcims.image.gui.panels.utils; |
||
30 | |||
31 | |||
32 | |||
33 | |||
34 | import org.slf4j.Logger; |
||
35 | import org.slf4j.LoggerFactory; |
||
36 | import org.gvsig.andami.PluginServices; |
||
37 | import org.gvsig.arcims.image.gui.panels.ServiceNamesPanel; |
||
38 | |||
39 | import javax.swing.event.ListSelectionEvent; |
||
40 | import javax.swing.table.DefaultTableColumnModel; |
||
41 | |||
42 | |||
43 | /**
|
||
44 | * This class detects changes on the available services list.
|
||
45 | *
|
||
46 | * @author jldominguez
|
||
47 | */
|
||
48 | public class ServicesTableSelectionListener extends DefaultTableColumnModel { |
||
49 | private static Logger logger = LoggerFactory.getLogger(ServicesTableSelectionListener.class.getName()); |
||
50 | private static final long serialVersionUID = 0; |
||
51 | private ServiceNamesPanel thePanel;
|
||
52 | |||
53 | public ServicesTableSelectionListener(ServiceNamesPanel panel) {
|
||
54 | super();
|
||
55 | thePanel = panel; |
||
56 | } |
||
57 | |||
58 | /**
|
||
59 | * Updates local variables which keep the service's name and type. The
|
||
60 | * service name must be in the first column of the table; the service type
|
||
61 | * must be in the second column.
|
||
62 | */
|
||
63 | public void valueChanged(ListSelectionEvent e) { |
||
64 | if (e.getValueIsAdjusting()) {
|
||
65 | return;
|
||
66 | } |
||
67 | |||
68 | if (thePanel == null) { |
||
69 | return;
|
||
70 | } |
||
71 | |||
72 | if (thePanel.getServicesTable() == null) { |
||
73 | return;
|
||
74 | } |
||
75 | |||
76 | int i = thePanel.getServicesTable().getSelectedRow();
|
||
77 | |||
78 | if (i == -1) { |
||
79 | return; // no selection |
||
80 | } |
||
81 | |||
82 | thePanel.setSelectedServiceType(ServicesTableModel.getColumnValueOfRow( |
||
83 | thePanel.getServicesTable(), |
||
84 | PluginServices.getText(this, "arcims_server_type_col_name"), i)); |
||
85 | |||
86 | thePanel.setSelectedServiceName(ServicesTableModel.getColumnValueOfRow( |
||
87 | thePanel.getServicesTable(), |
||
88 | PluginServices.getText(this, "name"), i)); |
||
89 | |||
90 | thePanel.getNextButton().setEnabled(true);
|
||
91 | |||
92 | logger.info("New selection in services table: type = " +
|
||
93 | thePanel.getSelectedServiceType() + ", name = " +
|
||
94 | thePanel.getSelectedServiceName()); |
||
95 | } |
||
96 | } |