Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.app / org.gvsig.app.mainplugin / src / main / java / org / gvsig / app / project / documents / view / toolListeners / snapping / gui / PropertySnapCellEditor.java @ 40558

History | View | Annotate | Download (4.1 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
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 3
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
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.app.project.documents.view.toolListeners.snapping.gui;
25

    
26
import java.awt.Color;
27
import java.awt.Component;
28
import java.awt.event.MouseEvent;
29
import java.awt.event.MouseListener;
30
import java.util.ArrayList;
31
import java.util.EventObject;
32

    
33
import javax.swing.JButton;
34
import javax.swing.JTable;
35
import javax.swing.event.CellEditorListener;
36
import javax.swing.table.TableCellEditor;
37

    
38
import org.gvsig.andami.PluginServices;
39
import org.gvsig.andami.ui.mdiManager.IWindow;
40
import org.gvsig.fmap.mapcontrol.MapControlLocator;
41
import org.gvsig.fmap.mapcontrol.MapControlManager;
42
import org.gvsig.fmap.mapcontrol.tools.snapping.snappers.ISnapper;
43

    
44

    
45
public class PropertySnapCellEditor extends JButton implements TableCellEditor{
46
        private int row;
47
        private IWindow panel;
48
        private static MapControlManager mapControlManager = MapControlLocator.getMapControlManager();
49
        
50
        public PropertySnapCellEditor() {                
51
                this.addMouseListener(new MouseListener() {
52

    
53
                        public void mouseClicked(MouseEvent e) {
54
                                if (e.getClickCount()==2) {
55
                                        if (panel!=null)
56
                                                openConfigurePanel();
57
                                }
58
                        }
59

    
60
                        public void mouseEntered(MouseEvent e) {
61
                                // TODO Auto-generated method stub
62

    
63
                        }
64

    
65
                        public void mouseExited(MouseEvent e) {
66
                                // TODO Auto-generated method stub
67

    
68
                        }
69

    
70
                        public void mousePressed(MouseEvent e) {
71
                                // TODO Auto-generated method stub
72

    
73
                        }
74

    
75
                        public void mouseReleased(MouseEvent e) {
76
                                // TODO Auto-generated method stub
77

    
78
                        }
79

    
80
                });
81
        }
82
//        class WinConfigure extends JPanel implements IWindow {
83
//
84
//                private WindowInfo wi=null;
85
//
86
//                public WindowInfo getWindowInfo() {
87
//                        if (wi==null) {
88
//                                wi=new WindowInfo(WindowInfo.MODALDIALOG|WindowInfo.RESIZABLE);
89
//                                wi.setWidth(panel.getWidth());
90
//                                wi.setHeight(panel.getHeight());
91
//                                wi.setTitle(PluginServices.getText(this,"propiedades"));
92
//                        }
93
//                        return wi;
94
//                }
95
//        }
96
        private void openConfigurePanel() {
97
                //IWindow window=new WinConfigure();
98
                ((DefaultConfigurePanel)panel).setSnapper(mapControlManager.getSnapperAt(row));
99
                PluginServices.getMDIManager().addWindow(panel);
100
        }
101
        public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
102
                this.row=row;
103
                panel=(IWindow)(mapControlManager.getSnapperAt(row)).getConfigurator();
104
                if (panel!=null) {
105
                        this.setEnabled(true);
106
                }else {
107
                        this.setEnabled(false);
108
                        this.setBackground(Color.white);
109
                }
110
                return this;
111
        }
112

    
113
        public void cancelCellEditing() {
114
                // TODO Auto-generated method stub
115

    
116
        }
117

    
118
        public boolean stopCellEditing() {
119
                // TODO Auto-generated method stub
120
                return false;
121
        }
122

    
123
        public Object getCellEditorValue() {
124
                // TODO Auto-generated method stub
125
                return null;
126
        }
127

    
128
        public boolean isCellEditable(EventObject anEvent) {
129
                return true;
130
        }
131

    
132
        public boolean shouldSelectCell(EventObject anEvent) {
133
                // TODO Auto-generated method stub
134
                return false;
135
        }
136

    
137
        public void addCellEditorListener(CellEditorListener l) {
138
                // TODO Auto-generated method stub
139

    
140
        }
141

    
142
        public void removeCellEditorListener(CellEditorListener l) {
143
                // TODO Auto-generated method stub
144

    
145
        }
146

    
147
}