Revision 36411
branches/v2_0_0_prep/applications/appgvSIG/src/org/gvsig/app/project/documents/gui/ListManagerSkin.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
|
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
|
2 | 2 |
* |
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
5 | 6 |
* This program is free software; you can redistribute it and/or |
6 | 7 |
* modify it under the terms of the GNU General Public License |
7 | 8 |
* as published by the Free Software Foundation; either version 2 |
8 | 9 |
* of the License, or (at your option) any later version. |
9 |
* |
|
10 |
*
|
|
10 | 11 |
* This program is distributed in the hope that it will be useful, |
11 | 12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | 13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | 14 |
* GNU General Public License for more details. |
14 |
* |
|
15 |
*
|
|
15 | 16 |
* You should have received a copy of the GNU General Public License |
16 | 17 |
* 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 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
18 | 21 |
*/ |
19 | 22 |
package org.gvsig.app.project.documents.gui; |
20 | 23 |
|
... | ... | |
33 | 36 |
|
34 | 37 |
public class ListManagerSkin extends JPanel { |
35 | 38 |
|
36 |
private JScrollPane jScrollPane = null; |
|
37 |
private JPanel jPanel = null; |
|
38 |
private JButton jButtonDown = null; |
|
39 |
private JButton jButtonUp = null; |
|
40 |
private JButton jButtonAdd = null; |
|
41 |
private JButton jButtonDel = null; |
|
39 |
private static final long serialVersionUID = 5194138202300759734L; |
|
40 |
private JScrollPane jScrollPane = null; |
|
41 |
private JPanel jPanel = null; |
|
42 |
private JButton jButtonDown = null; |
|
43 |
private JButton jButtonUp = null; |
|
44 |
private JButton jButtonAdd = null; |
|
45 |
private JButton jButtonDel = null; |
|
42 | 46 |
|
43 |
private ListManager listManager;// = new ListManager();
|
|
47 |
private ListManager listManager;// = new ListManager();
|
|
44 | 48 |
|
45 |
private JList jList = null; |
|
46 |
private JPanel jPanel1 = null; |
|
47 |
/** |
|
48 |
* This method initializes jScrollPane |
|
49 |
* |
|
50 |
* @return javax.swing.JScrollPane |
|
51 |
*/ |
|
52 |
private JScrollPane getJScrollPane() { |
|
53 |
if (jScrollPane == null) { |
|
54 |
jScrollPane = new JScrollPane(); |
|
55 |
jScrollPane.setViewportView(getJList()); |
|
56 |
} |
|
57 |
return jScrollPane; |
|
58 |
} |
|
59 |
/** |
|
60 |
* This method initializes jPanel |
|
61 |
* |
|
62 |
* @return javax.swing.JPanel |
|
63 |
*/ |
|
64 |
private JPanel getJPanel() { |
|
65 |
if (jPanel == null) { |
|
66 |
jPanel = new JPanel(); |
|
67 |
FlowLayout flowLayout = new FlowLayout(); |
|
68 |
flowLayout.setAlignment(FlowLayout.RIGHT); |
|
69 |
jPanel.setLayout(flowLayout); |
|
70 |
jPanel.add(getJPanel1(), null); |
|
71 |
} |
|
72 |
return jPanel; |
|
73 |
} |
|
74 |
/** |
|
75 |
* This method initializes jButton |
|
76 |
* |
|
77 |
* @return javax.swing.JButton |
|
78 |
*/ |
|
79 |
private JButton getJButtonDown() { |
|
80 |
if (jButtonDown == null) { |
|
81 |
jButtonDown = new JButton("abajo"); |
|
82 |
jButtonDown.setText(PluginServices.getText(this, "abajo")); |
|
83 |
} |
|
84 |
return jButtonDown; |
|
85 |
} |
|
86 |
/** |
|
87 |
* This method initializes jButton1 |
|
88 |
* |
|
89 |
* @return javax.swing.JButton |
|
90 |
*/ |
|
91 |
private JButton getJButtonUp() { |
|
92 |
if (jButtonUp == null) { |
|
93 |
jButtonUp = new JButton("arriba"); |
|
94 |
jButtonUp.setText(PluginServices.getText(this, "arriba")); |
|
95 |
} |
|
96 |
return jButtonUp; |
|
97 |
} |
|
98 |
/** |
|
99 |
* This method initializes jButton2 |
|
100 |
* |
|
101 |
* @return javax.swing.JButton |
|
102 |
*/ |
|
103 |
private JButton getJButtonAdd() { |
|
104 |
if (jButtonAdd == null) { |
|
105 |
jButtonAdd = new JButton("A?adir"); |
|
106 |
jButtonAdd.setText(PluginServices.getText(this, "Anadir")); |
|
107 |
} |
|
108 |
return jButtonAdd; |
|
109 |
} |
|
110 |
/** |
|
111 |
* This method initializes jButton3 |
|
112 |
* |
|
113 |
* @return javax.swing.JButton |
|
114 |
*/ |
|
115 |
private JButton getJButtonDel() { |
|
116 |
if (jButtonDel == null) { |
|
117 |
jButtonDel = new JButton("Eliminar"); |
|
118 |
jButtonDel.setText(PluginServices.getText(this, "Eliminar")); |
|
119 |
} |
|
120 |
return jButtonDel; |
|
121 |
} |
|
122 |
/** |
|
123 |
* This method initializes jList |
|
124 |
* |
|
125 |
* @return javax.swing.JList |
|
126 |
*/ |
|
127 |
private JList getJList() { |
|
128 |
if (jList == null) { |
|
129 |
jList = new JList(); |
|
130 |
} |
|
131 |
return jList; |
|
132 |
} |
|
133 |
/** |
|
134 |
* This is the default constructor |
|
135 |
*/ |
|
136 |
public ListManagerSkin(boolean down) { |
|
137 |
super(); |
|
138 |
listManager = new ListManager(down); |
|
139 |
initialize(); |
|
140 |
} |
|
141 |
/** |
|
142 |
* This method initializes this |
|
143 |
* |
|
144 |
* @return void |
|
145 |
*/ |
|
146 |
private void initialize() { |
|
147 |
this.setLayout(new BorderLayout()); |
|
148 |
this.setSize(421, 349); |
|
149 |
this.add(getJScrollPane(), BorderLayout.CENTER); |
|
150 |
this.add(getJPanel(), BorderLayout.EAST); |
|
151 |
listManager.setBtnDown(getJButtonDown()); |
|
152 |
listManager.setBtnUp(getJButtonUp()); |
|
153 |
listManager.setBtnAdd(getJButtonAdd()); |
|
154 |
listManager.setBtnDel(getJButtonDel()); |
|
155 |
listManager.setList(getJList()); |
|
156 |
listManager.initialize(); |
|
49 |
private JList jList = null; |
|
50 |
private JPanel jPanel1 = null; |
|
157 | 51 |
|
158 |
} |
|
159 |
/** |
|
160 |
* @return Returns the listManager. |
|
161 |
*/ |
|
162 |
public ListManager getListManager() { |
|
163 |
return listManager; |
|
164 |
} |
|
165 |
/** |
|
166 |
* This method initializes jPanel1 |
|
167 |
* |
|
168 |
* @return javax.swing.JPanel |
|
169 |
*/ |
|
170 |
private JPanel getJPanel1() { |
|
171 |
if (jPanel1 == null) { |
|
172 |
jPanel1 = new JPanel(new GridLayout(6, 1, 5, 5)); |
|
52 |
/** |
|
53 |
* This method initializes jScrollPane |
|
54 |
* |
|
55 |
* @return javax.swing.JScrollPane |
|
56 |
*/ |
|
57 |
private JScrollPane getJScrollPane() { |
|
58 |
if (jScrollPane == null) { |
|
59 |
jScrollPane = new JScrollPane(); |
|
60 |
jScrollPane.setViewportView(getJList()); |
|
61 |
} |
|
62 |
return jScrollPane; |
|
63 |
} |
|
173 | 64 |
|
174 |
jPanel1.setPreferredSize(new Dimension(100,180)); |
|
175 |
jPanel1.add(getJButtonAdd(), null); |
|
176 |
jPanel1.add(getJButtonDel(), null); |
|
177 |
jPanel1.add(getJButtonUp(), null); |
|
178 |
jPanel1.add(getJButtonDown(), null); |
|
179 |
} |
|
180 |
return jPanel1; |
|
181 |
} |
|
182 |
} // @jve:decl-index=0:visual-constraint="10,10" |
|
65 |
/** |
|
66 |
* This method initializes jPanel |
|
67 |
* |
|
68 |
* @return javax.swing.JPanel |
|
69 |
*/ |
|
70 |
private JPanel getJPanel() { |
|
71 |
if (jPanel == null) { |
|
72 |
jPanel = new JPanel(); |
|
73 |
FlowLayout flowLayout = new FlowLayout(); |
|
74 |
flowLayout.setAlignment(FlowLayout.RIGHT); |
|
75 |
jPanel.setLayout(flowLayout); |
|
76 |
jPanel.add(getJPanel1(), null); |
|
77 |
} |
|
78 |
return jPanel; |
|
79 |
} |
|
80 |
|
|
81 |
/** |
|
82 |
* This method initializes jButton |
|
83 |
* |
|
84 |
* @return javax.swing.JButton |
|
85 |
*/ |
|
86 |
private JButton getJButtonDown() { |
|
87 |
if (jButtonDown == null) { |
|
88 |
jButtonDown = new JButton("abajo"); |
|
89 |
jButtonDown.setText(PluginServices.getText(this, "abajo")); |
|
90 |
} |
|
91 |
return jButtonDown; |
|
92 |
} |
|
93 |
|
|
94 |
/** |
|
95 |
* This method initializes jButton1 |
|
96 |
* |
|
97 |
* @return javax.swing.JButton |
|
98 |
*/ |
|
99 |
private JButton getJButtonUp() { |
|
100 |
if (jButtonUp == null) { |
|
101 |
jButtonUp = new JButton("arriba"); |
|
102 |
jButtonUp.setText(PluginServices.getText(this, "arriba")); |
|
103 |
} |
|
104 |
return jButtonUp; |
|
105 |
} |
|
106 |
|
|
107 |
/** |
|
108 |
* This method initializes jButton2 |
|
109 |
* |
|
110 |
* @return javax.swing.JButton |
|
111 |
*/ |
|
112 |
private JButton getJButtonAdd() { |
|
113 |
if (jButtonAdd == null) { |
|
114 |
jButtonAdd = new JButton("A?adir"); |
|
115 |
jButtonAdd.setText(PluginServices.getText(this, "Anadir")); |
|
116 |
} |
|
117 |
return jButtonAdd; |
|
118 |
} |
|
119 |
|
|
120 |
/** |
|
121 |
* This method initializes jButton3 |
|
122 |
* |
|
123 |
* @return javax.swing.JButton |
|
124 |
*/ |
|
125 |
private JButton getJButtonDel() { |
|
126 |
if (jButtonDel == null) { |
|
127 |
jButtonDel = new JButton("Eliminar"); |
|
128 |
jButtonDel.setText(PluginServices.getText(this, "Eliminar")); |
|
129 |
} |
|
130 |
return jButtonDel; |
|
131 |
} |
|
132 |
|
|
133 |
/** |
|
134 |
* This method initializes jList |
|
135 |
* |
|
136 |
* @return javax.swing.JList |
|
137 |
*/ |
|
138 |
private JList getJList() { |
|
139 |
if (jList == null) { |
|
140 |
jList = new JList(); |
|
141 |
} |
|
142 |
return jList; |
|
143 |
} |
|
144 |
|
|
145 |
/** |
|
146 |
* This is the default constructor |
|
147 |
*/ |
|
148 |
public ListManagerSkin(boolean down) { |
|
149 |
super(); |
|
150 |
listManager = new ListManager(down); |
|
151 |
initialize(); |
|
152 |
} |
|
153 |
|
|
154 |
/** |
|
155 |
* This method initializes this |
|
156 |
* |
|
157 |
* @return void |
|
158 |
*/ |
|
159 |
private void initialize() { |
|
160 |
this.setLayout(new BorderLayout()); |
|
161 |
this.setSize(421, 349); |
|
162 |
this.add(getJScrollPane(), BorderLayout.CENTER); |
|
163 |
this.add(getJPanel(), BorderLayout.EAST); |
|
164 |
listManager.setBtnDown(getJButtonDown()); |
|
165 |
listManager.setBtnUp(getJButtonUp()); |
|
166 |
listManager.setBtnAdd(getJButtonAdd()); |
|
167 |
listManager.setBtnDel(getJButtonDel()); |
|
168 |
listManager.setList(getJList()); |
|
169 |
listManager.initialize(); |
|
170 |
|
|
171 |
} |
|
172 |
|
|
173 |
/** |
|
174 |
* @return Returns the listManager. |
|
175 |
*/ |
|
176 |
public ListManager getListManager() { |
|
177 |
return listManager; |
|
178 |
} |
|
179 |
|
|
180 |
/** |
|
181 |
* This method initializes jPanel1 |
|
182 |
* |
|
183 |
* @return javax.swing.JPanel |
|
184 |
*/ |
|
185 |
private JPanel getJPanel1() { |
|
186 |
if (jPanel1 == null) { |
|
187 |
jPanel1 = new JPanel(new GridLayout(6, 1, 5, 5)); |
|
188 |
|
|
189 |
jPanel1.setPreferredSize(new Dimension(100, 180)); |
|
190 |
jPanel1.add(getJButtonAdd(), null); |
|
191 |
jPanel1.add(getJButtonDel(), null); |
|
192 |
jPanel1.add(getJButtonUp(), null); |
|
193 |
jPanel1.add(getJButtonDown(), null); |
|
194 |
} |
|
195 |
return jPanel1; |
|
196 |
} |
|
197 |
} // @jve:decl-index=0:visual-constraint="10,10" |
branches/v2_0_0_prep/applications/appgvSIG/src/org/gvsig/app/project/documents/gui/SymbolCellEditor.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
|
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
|
2 | 2 |
* |
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
5 | 6 |
* This program is free software; you can redistribute it and/or |
6 | 7 |
* modify it under the terms of the GNU General Public License |
7 | 8 |
* as published by the Free Software Foundation; either version 2 |
8 | 9 |
* of the License, or (at your option) any later version. |
9 |
* |
|
10 |
*
|
|
10 | 11 |
* This program is distributed in the hope that it will be useful, |
11 | 12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | 13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | 14 |
* GNU General Public License for more details. |
14 |
* |
|
15 |
*
|
|
15 | 16 |
* You should have received a copy of the GNU General Public License |
16 | 17 |
* 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 Ib??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 |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
40 | 21 |
*/ |
41 | 22 |
package org.gvsig.app.project.documents.gui; |
42 | 23 |
|
... | ... | |
58 | 39 |
import org.gvsig.app.project.documents.view.legend.gui.PanelEditSymbol; |
59 | 40 |
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol; |
60 | 41 |
|
61 |
|
|
62 |
|
|
63 |
|
|
64 | 42 |
/** |
65 | 43 |
* Cell Editor de ISymbols. Controla los eventos de edici?n que se realicen |
66 | 44 |
* sobre la columna de s?mbolos. |
67 |
* |
|
45 |
*
|
|
68 | 46 |
* @author Vicente Caballero Navarro |
69 | 47 |
*/ |
70 | 48 |
public class SymbolCellEditor extends JButton implements TableCellEditor { |
71 |
private ArrayList listeners = new ArrayList(); |
|
72 |
private ISymbol symbol; |
|
73 |
private int shapeType; |
|
74 |
private PanelEditSymbol symbolPanel; |
|
75 | 49 |
|
76 |
public SymbolCellEditor(int shapeType) { |
|
77 |
this.shapeType = shapeType; |
|
78 |
addMouseListener(new MouseListener(){ |
|
50 |
private static final long serialVersionUID = -913612642474934455L; |
|
51 |
private ArrayList listeners = new ArrayList(); |
|
52 |
private ISymbol symbol; |
|
53 |
private int shapeType; |
|
54 |
private PanelEditSymbol symbolPanel; |
|
79 | 55 |
|
80 |
public void mouseClicked(MouseEvent e) { |
|
81 |
if (e.getClickCount()==2){ |
|
82 |
symbolPanel.setSymbol(symbol); |
|
83 |
// symbolPanel.setShapeType(SymbolCellEditor.this.shapeType); |
|
84 |
symbolPanel.setShapeType(symbol.getSymbolType()); |
|
85 |
PluginServices.getMDIManager().addWindow(symbolPanel); |
|
86 |
if (symbolPanel.isOK()){ |
|
87 |
symbol = (ISymbol) symbolPanel.getSymbol(); |
|
88 |
stopCellEditing(); |
|
89 |
} |
|
90 |
} |
|
91 |
} |
|
56 |
public SymbolCellEditor(int shapeType) { |
|
57 |
this.shapeType = shapeType; |
|
58 |
addMouseListener(new MouseListener() { |
|
92 | 59 |
|
93 |
public void mouseEntered(MouseEvent e) { |
|
94 |
} |
|
60 |
public void mouseClicked(MouseEvent e) { |
|
61 |
if (e.getClickCount() == 2) { |
|
62 |
symbolPanel.setSymbol(symbol); |
|
63 |
// symbolPanel.setShapeType(SymbolCellEditor.this.shapeType); |
|
64 |
symbolPanel.setShapeType(symbol.getSymbolType()); |
|
65 |
PluginServices.getMDIManager().addWindow(symbolPanel); |
|
66 |
if (symbolPanel.isOK()) { |
|
67 |
symbol = (ISymbol) symbolPanel.getSymbol(); |
|
68 |
stopCellEditing(); |
|
69 |
} |
|
70 |
} |
|
71 |
} |
|
95 | 72 |
|
96 |
public void mouseExited(MouseEvent e) {
|
|
97 |
}
|
|
73 |
public void mouseEntered(MouseEvent e) {
|
|
74 |
}
|
|
98 | 75 |
|
99 |
public void mousePressed(MouseEvent e) {
|
|
100 |
}
|
|
76 |
public void mouseExited(MouseEvent e) {
|
|
77 |
}
|
|
101 | 78 |
|
102 |
public void mouseReleased(MouseEvent e) {
|
|
103 |
}
|
|
79 |
public void mousePressed(MouseEvent e) {
|
|
80 |
}
|
|
104 | 81 |
|
105 |
}); |
|
106 |
addKeyListener(new KeyAdapter() { |
|
107 |
public void keyReleased(KeyEvent e) { |
|
108 |
if (e.getKeyCode() == KeyEvent.VK_ENTER) { |
|
109 |
stopCellEditing(); |
|
110 |
} else if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { |
|
111 |
cancelCellEditing(); |
|
112 |
} |
|
113 |
} |
|
114 |
}); |
|
115 |
symbolPanel = new PanelEditSymbol(); |
|
82 |
public void mouseReleased(MouseEvent e) { |
|
83 |
} |
|
116 | 84 |
|
117 |
} |
|
85 |
}); |
|
86 |
addKeyListener(new KeyAdapter() { |
|
118 | 87 |
|
88 |
public void keyReleased(KeyEvent e) { |
|
89 |
if (e.getKeyCode() == KeyEvent.VK_ENTER) { |
|
90 |
stopCellEditing(); |
|
91 |
} else |
|
92 |
if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { |
|
93 |
cancelCellEditing(); |
|
94 |
} |
|
95 |
} |
|
96 |
}); |
|
97 |
symbolPanel = new PanelEditSymbol(); |
|
119 | 98 |
|
120 |
//Implement the one CellEditor method that AbstractCellEditor doesn't. |
|
121 |
public Object getCellEditorValue() { |
|
122 |
return symbol; |
|
123 |
} |
|
99 |
} |
|
124 | 100 |
|
125 |
//Implement the one method defined by TableCellEditor. |
|
126 |
public Component getTableCellEditorComponent(JTable table, Object value, |
|
127 |
boolean isSelected, int row, int column) { |
|
128 |
symbol = (ISymbol) value; |
|
129 |
// setBackground(symbol.getColor()); |
|
101 |
// Implement the one CellEditor method that AbstractCellEditor doesn't. |
|
102 |
public Object getCellEditorValue() { |
|
103 |
return symbol; |
|
104 |
} |
|
130 | 105 |
|
131 |
return this; |
|
132 |
} |
|
106 |
// Implement the one method defined by TableCellEditor. |
|
107 |
public Component getTableCellEditorComponent(JTable table, Object value, |
|
108 |
boolean isSelected, int row, int column) { |
|
109 |
symbol = (ISymbol) value; |
|
110 |
// setBackground(symbol.getColor()); |
|
133 | 111 |
|
134 |
/** |
|
135 |
* DOCUMENT ME! |
|
136 |
*/ |
|
137 |
public void cancelCellEditing() { |
|
138 |
if (symbol != null) { |
|
139 |
// setBackground(symbol.getColor()); |
|
140 |
} |
|
112 |
return this; |
|
113 |
} |
|
141 | 114 |
|
142 |
for (int i = 0; i < listeners.size(); i++) { |
|
143 |
CellEditorListener l = (CellEditorListener) listeners.get(i); |
|
144 |
ChangeEvent evt = new ChangeEvent(this); |
|
145 |
l.editingCanceled(evt); |
|
146 |
} |
|
147 |
} |
|
115 |
/** |
|
116 |
* DOCUMENT ME! |
|
117 |
*/ |
|
118 |
public void cancelCellEditing() { |
|
119 |
if (symbol != null) { |
|
120 |
// setBackground(symbol.getColor()); |
|
121 |
} |
|
148 | 122 |
|
149 |
/** |
|
150 |
* DOCUMENT ME! |
|
151 |
* |
|
152 |
* @return DOCUMENT ME! |
|
153 |
*/ |
|
154 |
public boolean stopCellEditing() { |
|
155 |
for (int i = 0; i < listeners.size(); i++) { |
|
156 |
CellEditorListener l = (CellEditorListener) listeners.get(i); |
|
157 |
ChangeEvent evt = new ChangeEvent(this); |
|
158 |
l.editingStopped(evt); |
|
159 |
} |
|
123 |
for (int i = 0; i < listeners.size(); i++) { |
|
124 |
CellEditorListener l = (CellEditorListener) listeners.get(i); |
|
125 |
ChangeEvent evt = new ChangeEvent(this); |
|
126 |
l.editingCanceled(evt); |
|
127 |
} |
|
128 |
} |
|
160 | 129 |
|
161 |
return true; |
|
162 |
} |
|
130 |
/** |
|
131 |
* DOCUMENT ME! |
|
132 |
* |
|
133 |
* @return DOCUMENT ME! |
|
134 |
*/ |
|
135 |
public boolean stopCellEditing() { |
|
136 |
for (int i = 0; i < listeners.size(); i++) { |
|
137 |
CellEditorListener l = (CellEditorListener) listeners.get(i); |
|
138 |
ChangeEvent evt = new ChangeEvent(this); |
|
139 |
l.editingStopped(evt); |
|
140 |
} |
|
163 | 141 |
|
164 |
/** |
|
165 |
* DOCUMENT ME! |
|
166 |
* |
|
167 |
* @param anEvent DOCUMENT ME! |
|
168 |
* |
|
169 |
* @return DOCUMENT ME! |
|
170 |
*/ |
|
171 |
public boolean isCellEditable(EventObject anEvent) { |
|
172 |
return true; |
|
173 |
} |
|
142 |
return true; |
|
143 |
} |
|
174 | 144 |
|
175 |
/** |
|
176 |
* DOCUMENT ME! |
|
177 |
* |
|
178 |
* @param anEvent DOCUMENT ME! |
|
179 |
* |
|
180 |
* @return DOCUMENT ME! |
|
181 |
*/ |
|
182 |
public boolean shouldSelectCell(EventObject anEvent) { |
|
183 |
return true; |
|
184 |
} |
|
145 |
/** |
|
146 |
* DOCUMENT ME! |
|
147 |
* |
|
148 |
* @param anEvent |
|
149 |
* DOCUMENT ME! |
|
150 |
* |
|
151 |
* @return DOCUMENT ME! |
|
152 |
*/ |
|
153 |
public boolean isCellEditable(EventObject anEvent) { |
|
154 |
return true; |
|
155 |
} |
|
185 | 156 |
|
186 |
/** |
|
187 |
* DOCUMENT ME! |
|
188 |
* |
|
189 |
* @param l DOCUMENT ME! |
|
190 |
*/ |
|
191 |
public void addCellEditorListener(CellEditorListener l) { |
|
192 |
listeners.add(l); |
|
193 |
} |
|
157 |
/** |
|
158 |
* DOCUMENT ME! |
|
159 |
* |
|
160 |
* @param anEvent |
|
161 |
* DOCUMENT ME! |
|
162 |
* |
|
163 |
* @return DOCUMENT ME! |
|
164 |
*/ |
|
165 |
public boolean shouldSelectCell(EventObject anEvent) { |
|
166 |
return true; |
|
167 |
} |
|
194 | 168 |
|
195 |
/** |
|
196 |
* DOCUMENT ME! |
|
197 |
* |
|
198 |
* @param l DOCUMENT ME! |
|
199 |
*/ |
|
200 |
public void removeCellEditorListener(CellEditorListener l) { |
|
201 |
listeners.remove(l); |
|
202 |
} |
|
169 |
/** |
|
170 |
* DOCUMENT ME! |
|
171 |
* |
|
172 |
* @param l |
|
173 |
* DOCUMENT ME! |
|
174 |
*/ |
|
175 |
public void addCellEditorListener(CellEditorListener l) { |
|
176 |
listeners.add(l); |
|
177 |
} |
|
178 |
|
|
179 |
/** |
|
180 |
* DOCUMENT ME! |
|
181 |
* |
|
182 |
* @param l |
|
183 |
* DOCUMENT ME! |
|
184 |
*/ |
|
185 |
public void removeCellEditorListener(CellEditorListener l) { |
|
186 |
listeners.remove(l); |
|
187 |
} |
|
203 | 188 |
} |
branches/v2_0_0_prep/applications/appgvSIG/src/org/gvsig/app/project/documents/gui/ProjectElementListModel.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
|
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
|
2 | 2 |
* |
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
5 | 6 |
* This program is free software; you can redistribute it and/or |
6 | 7 |
* modify it under the terms of the GNU General Public License |
7 | 8 |
* as published by the Free Software Foundation; either version 2 |
8 | 9 |
* of the License, or (at your option) any later version. |
9 |
* |
|
10 |
*
|
|
10 | 11 |
* This program is distributed in the hope that it will be useful, |
11 | 12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | 13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | 14 |
* GNU General Public License for more details. |
14 |
* |
|
15 |
*
|
|
15 | 16 |
* You should have received a copy of the GNU General Public License |
16 | 17 |
* 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 Ib??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 |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
40 | 21 |
*/ |
41 | 22 |
package org.gvsig.app.project.documents.gui; |
42 | 23 |
|
... | ... | |
44 | 25 |
|
45 | 26 |
import javax.swing.AbstractListModel; |
46 | 27 |
|
47 |
|
|
48 | 28 |
/** |
49 | 29 |
* Modelo para presentar los ProjectElement's (vistas, mapas, tablas) en un |
50 | 30 |
* JList |
51 |
* |
|
31 |
*
|
|
52 | 32 |
* @author Fernando Gonz?lez Cort?s |
53 | 33 |
*/ |
54 | 34 |
public class ProjectElementListModel extends AbstractListModel { |
35 |
|
|
36 |
private static final long serialVersionUID = 5224594892273078623L; |
|
55 | 37 |
private ArrayList els; |
56 | 38 |
|
57 | 39 |
/** |
58 | 40 |
* Creates a new MyListModel object. |
59 |
* |
|
60 |
* @param els Elementos del modelo |
|
41 |
* |
|
42 |
* @param els |
|
43 |
* Elementos del modelo |
|
61 | 44 |
*/ |
62 | 45 |
public ProjectElementListModel(ArrayList els) { |
63 | 46 |
this.els = els; |
... | ... | |
65 | 48 |
|
66 | 49 |
/** |
67 | 50 |
* Obtiene el tama?o de la lista |
68 |
* |
|
51 |
*
|
|
69 | 52 |
* @return tama?o de la lista |
70 | 53 |
*/ |
71 | 54 |
public int getSize() { |
branches/v2_0_0_prep/applications/appgvSIG/src/org/gvsig/app/project/documents/gui/ProjectWindow.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
|
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
|
2 | 2 |
* |
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
5 | 6 |
* This program is free software; you can redistribute it and/or |
6 | 7 |
* modify it under the terms of the GNU General Public License |
7 | 8 |
* as published by the Free Software Foundation; either version 2 |
8 | 9 |
* of the License, or (at your option) any later version. |
9 |
* |
|
10 |
*
|
|
10 | 11 |
* This program is distributed in the hope that it will be useful, |
11 | 12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | 13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | 14 |
* GNU General Public License for more details. |
14 |
* |
|
15 |
*
|
|
15 | 16 |
* You should have received a copy of the GNU General Public License |
16 | 17 |
* 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 Ib??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 |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
40 | 21 |
*/ |
41 | 22 |
package org.gvsig.app.project.documents.gui; |
42 | 23 |
|
... | ... | |
64 | 45 |
import javax.swing.JScrollPane; |
65 | 46 |
import javax.swing.border.TitledBorder; |
66 | 47 |
|
67 |
import org.exolab.castor.persist.spi.Persistence; |
|
68 | 48 |
import org.gvsig.andami.PluginServices; |
69 | 49 |
import org.gvsig.andami.help.Help; |
70 | 50 |
import org.gvsig.andami.messages.NotificationManager; |
... | ... | |
74 | 54 |
import org.gvsig.app.extension.ProjectExtension; |
75 | 55 |
import org.gvsig.app.project.Project; |
76 | 56 |
import org.gvsig.app.project.ProjectManager; |
57 |
import org.gvsig.app.project.documents.AbstractDocument; |
|
77 | 58 |
import org.gvsig.app.project.documents.Document; |
78 | 59 |
import org.gvsig.app.project.documents.DocumentManager; |
79 |
import org.gvsig.app.project.documents.AbstractDocument; |
|
80 | 60 |
import org.gvsig.gui.beans.swing.JButton; |
81 |
import org.gvsig.tools.ToolsLocator; |
|
82 |
import org.gvsig.tools.dynobject.DynStruct; |
|
83 |
import org.gvsig.tools.persistence.PersistenceManager; |
|
84 |
import org.gvsig.tools.persistence.Persistent; |
|
85 |
import org.gvsig.tools.persistence.PersistentState; |
|
86 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
|
87 | 61 |
import org.gvsig.utils.DefaultListModel; |
88 | 62 |
|
89 | 63 |
/** |
... | ... | |
93 | 67 |
* @author Vicente Caballero Navarro |
94 | 68 |
*/ |
95 | 69 |
public class ProjectWindow extends JPanel implements PropertyChangeListener, |
96 |
IWindow, SingletonWindow { |
|
97 |
/** |
|
70 |
IWindow, SingletonWindow { |
|
71 |
|
|
72 |
/** |
|
98 | 73 |
* |
99 | 74 |
*/ |
100 |
private static final long serialVersionUID = 7315293357719796556L; |
|
101 |
|
|
102 |
public static final String PERSISTENCE_DEFINITION_NAME = "ProjectWindow"; |
|
75 |
private static final long serialVersionUID = 7315293357719796556L; |
|
103 | 76 |
|
104 |
private JPanel jPanel = null; |
|
105 |
private JRadioButton[] btnsDocuments = null; |
|
106 |
private ButtonGroup grupo = new ButtonGroup(); |
|
107 |
private JPanel jPanel1 = null; |
|
108 |
private JList lstDocs = null; |
|
109 |
private JPanel jPanel2 = null; |
|
110 |
private JButton btnNuevo = null; |
|
111 |
private JButton btnPropiedades = null; |
|
112 |
private JButton btnAbrir = null; |
|
113 |
private JButton btnBorrar = null; |
|
114 |
private JButton btnRenombrar = null; |
|
115 |
private JPanel jPanel3 = null; |
|
116 |
private JLabel jLabel = null; |
|
117 |
private JLabel lblNombreSesion = null; |
|
118 |
private JLabel jLabel1 = null; |
|
119 |
private JLabel lblGuardado = null; |
|
120 |
private JLabel jLabel2 = null; |
|
121 |
private JLabel lblFecha = null; |
|
122 |
private JButton btnImportar = null; |
|
123 |
private JButton btnExportar = null; |
|
124 |
private JButton btnEditar = null; |
|
125 |
// The properties of the Project Manager window (size, position, etc): |
|
126 |
private WindowInfo m_viewInfo = null; |
|
77 |
public static final String PERSISTENCE_DEFINITION_NAME = "ProjectWindow"; |
|
127 | 78 |
|
128 |
private Project project; |
|
79 |
private JPanel jPanel = null; |
|
80 |
private JRadioButton[] btnsDocuments = null; |
|
81 |
private ButtonGroup grupo = new ButtonGroup(); |
|
82 |
private JPanel jPanel1 = null; |
|
83 |
private JList lstDocs = null; |
|
84 |
private JPanel jPanel2 = null; |
|
85 |
private JButton btnNuevo = null; |
|
86 |
private JButton btnPropiedades = null; |
|
87 |
private JButton btnAbrir = null; |
|
88 |
private JButton btnBorrar = null; |
|
89 |
private JButton btnRenombrar = null; |
|
90 |
private JPanel jPanel3 = null; |
|
91 |
private JLabel jLabel = null; |
|
92 |
private JLabel lblNombreSesion = null; |
|
93 |
private JLabel jLabel1 = null; |
|
94 |
private JLabel lblGuardado = null; |
|
95 |
private JLabel jLabel2 = null; |
|
96 |
private JLabel lblFecha = null; |
|
97 |
private JButton btnImportar = null; |
|
98 |
private JButton btnExportar = null; |
|
99 |
private JButton btnEditar = null; |
|
100 |
// The properties of the Project Manager window (size, position, etc): |
|
101 |
private WindowInfo m_viewInfo = null; |
|
129 | 102 |
|
130 |
private JScrollPane jScrollPane = null; |
|
131 |
private JPanel jPanel4 = null; |
|
132 |
private JScrollPane jScrollPane1 = null; |
|
103 |
private Project project; |
|
133 | 104 |
|
134 |
/** |
|
135 |
* This is the default constructor |
|
136 |
* |
|
137 |
* @param project |
|
138 |
* Extension |
|
139 |
*/ |
|
140 |
public ProjectWindow() { |
|
141 |
super(); |
|
142 |
initialize(); |
|
143 |
refreshControls(); |
|
144 |
Help.getHelp().enableHelp(this, this.getClass().getName()); |
|
145 |
} |
|
105 |
private JScrollPane jScrollPane = null; |
|
106 |
private JPanel jPanel4 = null; |
|
107 |
private JScrollPane jScrollPane1 = null; |
|
146 | 108 |
|
147 |
/** |
|
148 |
* Asigna el proyecto a la ventana |
|
149 |
* |
|
150 |
* @param project |
|
151 |
* Proyecto con el que se operar? a trav?s de este di?logo |
|
152 |
*/ |
|
153 |
public void setProject(Project project) { |
|
154 |
this.project = project; |
|
155 |
project.addPropertyChangeListener(this); |
|
156 |
refreshControls(); |
|
157 |
} |
|
109 |
/** |
|
110 |
* This is the default constructor |
|
111 |
* |
|
112 |
* @param project |
|
113 |
* Extension |
|
114 |
*/ |
|
115 |
public ProjectWindow() { |
|
116 |
super(); |
|
117 |
initialize(); |
|
118 |
refreshControls(); |
|
119 |
Help.getHelp().enableHelp(this, this.getClass().getName()); |
|
120 |
} |
|
158 | 121 |
|
159 |
/** |
|
160 |
* Activa los botones de la botonera del medio o los desactiva en funci?n de |
|
161 |
* que est? seleccionado o no un elemento de proyecto en la lista del medio |
|
162 |
*/ |
|
163 |
private void activarBotones() { |
|
164 |
if (lstDocs.getSelectedIndex() != -1) { |
|
165 |
btnAbrir.setEnabled(true); |
|
166 |
btnBorrar.setEnabled(true); |
|
167 |
if (lstDocs.getSelectedIndices().length == 1) { |
|
168 |
btnRenombrar.setEnabled(true); |
|
169 |
btnPropiedades.setEnabled(true); |
|
170 |
} else { |
|
171 |
btnRenombrar.setEnabled(false); |
|
172 |
btnPropiedades.setEnabled(false); |
|
173 |
} |
|
174 |
} else { |
|
175 |
btnAbrir.setEnabled(false); |
|
176 |
btnBorrar.setEnabled(false); |
|
177 |
btnRenombrar.setEnabled(false); |
|
178 |
btnPropiedades.setEnabled(false); |
|
179 |
} |
|
180 |
} |
|
122 |
/** |
|
123 |
* Asigna el proyecto a la ventana |
|
124 |
* |
|
125 |
* @param project |
|
126 |
* Proyecto con el que se operar? a trav?s de este di?logo |
|
127 |
*/ |
|
128 |
public void setProject(Project project) { |
|
129 |
this.project = project; |
|
130 |
project.addPropertyChangeListener(this); |
|
131 |
refreshControls(); |
|
132 |
} |
|
181 | 133 |
|
182 |
/** |
|
183 |
* Refresca la lista de elementos de proyecto con vistas, mapas o tablas, |
|
184 |
* seg?n la opci?n activada |
|
185 |
*/ |
|
186 |
private void refreshList() { |
|
187 |
if (project != null) { |
|
188 |
DefaultListModel model = null; |
|
189 |
String tituloMarco = PluginServices.getText(this, |
|
190 |
"documentos_existentes"); |
|
134 |
/** |
|
135 |
* Activa los botones de la botonera del medio o los desactiva en funci?n de |
|
136 |
* que est? seleccionado o no un elemento de proyecto en la lista del medio |
|
137 |
*/ |
|
138 |
private void activarBotones() { |
|
139 |
if (lstDocs.getSelectedIndex() != -1) { |
|
140 |
btnAbrir.setEnabled(true); |
|
141 |
btnBorrar.setEnabled(true); |
|
142 |
if (lstDocs.getSelectedIndices().length == 1) { |
|
143 |
btnRenombrar.setEnabled(true); |
|
144 |
btnPropiedades.setEnabled(true); |
|
145 |
} else { |
|
146 |
btnRenombrar.setEnabled(false); |
|
147 |
btnPropiedades.setEnabled(false); |
|
148 |
} |
|
149 |
} else { |
|
150 |
btnAbrir.setEnabled(false); |
|
151 |
btnBorrar.setEnabled(false); |
|
152 |
btnRenombrar.setEnabled(false); |
|
153 |
btnPropiedades.setEnabled(false); |
|
154 |
} |
|
155 |
} |
|
191 | 156 |
|
192 |
String doctype = getDocumentSelected(); |
|
193 |
model = new DefaultListModel(project.getDocuments(doctype)); |
|
194 |
tituloMarco = getDocumentSelectedName(); |
|
157 |
/** |
|
158 |
* Refresca la lista de elementos de proyecto con vistas, mapas o tablas, |
|
159 |
* seg?n la opci?n activada |
|
160 |
*/ |
|
161 |
private void refreshList() { |
|
162 |
if (project != null) { |
|
163 |
DefaultListModel model = null; |
|
164 |
String tituloMarco = |
|
165 |
PluginServices.getText(this, "documentos_existentes"); |
|
195 | 166 |
|
196 |
lstDocs.setModel(model); |
|
197 |
((TitledBorder) getJPanel1().getBorder()).setTitle(tituloMarco); |
|
198 |
getJPanel1().repaint(1); |
|
199 |
activarBotones(); |
|
200 |
} |
|
201 |
} |
|
167 |
String doctype = getDocumentSelected(); |
|
168 |
model = new DefaultListModel(project.getDocuments(doctype)); |
|
169 |
tituloMarco = getDocumentSelectedName(); |
|
202 | 170 |
|
203 |
/** |
|
204 |
* Devuelve el nombre del tipo de documento activo (el mismo que |
|
205 |
* ProjectDocumentFactory.getRegisterName) |
|
206 |
* |
|
207 |
* |
|
208 |
* @return |
|
209 |
*/ |
|
171 |
lstDocs.setModel(model); |
|
172 |
((TitledBorder) getJPanel1().getBorder()).setTitle(tituloMarco); |
|
173 |
getJPanel1().repaint(1); |
|
174 |
activarBotones(); |
|
175 |
} |
|
176 |
} |
|
210 | 177 |
|
211 |
public String getDocumentSelected() { |
|
212 |
JRadioButton btnSelected = null; |
|
213 |
for (int i = 0; i < btnsDocuments.length; i++) { |
|
214 |
if (btnsDocuments[i].isSelected()) { |
|
215 |
btnSelected = btnsDocuments[i]; |
|
216 |
return btnSelected.getName(); |
|
217 |
} |
|
218 |
} |
|
178 |
/** |
|
179 |
* Devuelve el nombre del tipo de documento activo (el mismo que |
|
180 |
* ProjectDocumentFactory.getRegisterName) |
|
181 |
* |
|
182 |
* |
|
183 |
* @return |
|
184 |
*/ |
|
219 | 185 |
|
220 |
return null; |
|
221 |
} |
|
186 |
public String getDocumentSelected() { |
|
187 |
JRadioButton btnSelected = null; |
|
188 |
for (int i = 0; i < btnsDocuments.length; i++) { |
|
189 |
if (btnsDocuments[i].isSelected()) { |
|
190 |
btnSelected = btnsDocuments[i]; |
|
191 |
return btnSelected.getName(); |
|
192 |
} |
|
193 |
} |
|
222 | 194 |
|
223 |
private String getDocumentSelectedName() { |
|
224 |
JRadioButton btnSelected = null; |
|
225 |
for (int i = 0; i < btnsDocuments.length; i++) { |
|
226 |
if (btnsDocuments[i].isSelected()) { |
|
227 |
btnSelected = btnsDocuments[i]; |
|
228 |
return btnSelected.getText(); |
|
229 |
} |
|
230 |
} |
|
195 |
return null; |
|
196 |
} |
|
231 | 197 |
|
232 |
return null; |
|
233 |
} |
|
198 |
private String getDocumentSelectedName() { |
|
199 |
JRadioButton btnSelected = null; |
|
200 |
for (int i = 0; i < btnsDocuments.length; i++) { |
|
201 |
if (btnsDocuments[i].isSelected()) { |
|
202 |
btnSelected = btnsDocuments[i]; |
|
203 |
return btnSelected.getText(); |
|
204 |
} |
|
205 |
} |
|
234 | 206 |
|
235 |
/** |
|
236 |
* Refresca las etiquetas con la informaci?n del proyecto |
|
237 |
*/ |
|
238 |
private void refreshProperties() { |
|
239 |
if (project != null) { |
|
240 |
lblNombreSesion.setText(project.getName()); |
|
241 |
String path = ProjectExtension.getPath(); |
|
242 |
if (path != null) { |
|
243 |
File f = new File(path); |
|
244 |
lblGuardado.setText(f.toString()); |
|
245 |
} else { |
|
246 |
lblGuardado.setText(""); |
|
247 |
} |
|
248 |
lblFecha.setText(project.getCreationDate()); |
|
249 |
} |
|
250 |
} |
|
207 |
return null; |
|
208 |
} |
|
251 | 209 |
|
252 |
/** |
|
253 |
* Refresca todo el di?logo |
|
254 |
*/ |
|
255 |
public void refreshControls() { |
|
256 |
refreshList(); |
|
257 |
refreshProperties(); |
|
258 |
} |
|
210 |
/** |
|
211 |
* Refresca las etiquetas con la informaci?n del proyecto |
|
212 |
*/ |
|
213 |
private void refreshProperties() { |
|
214 |
if (project != null) { |
|
215 |
lblNombreSesion.setText(project.getName()); |
|
216 |
String path = ProjectExtension.getPath(); |
|
217 |
if (path != null) { |
|
218 |
File f = new File(path); |
|
219 |
lblGuardado.setText(f.toString()); |
|
220 |
} else { |
|
221 |
lblGuardado.setText(""); |
|
222 |
} |
|
223 |
lblFecha.setText(project.getCreationDate()); |
|
224 |
} |
|
225 |
} |
|
259 | 226 |
|
260 |
/** |
|
261 |
* This method initializes this |
|
262 |
*/ |
|
263 |
private void initialize() { |
|
264 |
GridBagConstraints gridBagConstraints = new GridBagConstraints(); |
|
265 |
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; |
|
266 |
gridBagConstraints.weightx = 1.0; |
|
267 |
gridBagConstraints.weighty = 1.0; |
|
268 |
GridBagLayout layout = new GridBagLayout(); |
|
269 |
setLayout(layout); |
|
270 |
GridBagConstraints c = new GridBagConstraints(); |
|
271 |
c.fill = GridBagConstraints.HORIZONTAL; |
|
272 |
c.weightx = 1.0; |
|
273 |
c.weighty = 0; |
|
274 |
c.gridy = 0; |
|
275 |
c.insets = new Insets(2, 5, 2, 5); |
|
227 |
/** |
|
228 |
* Refresca todo el di?logo |
|
229 |
*/ |
|
230 |
public void refreshControls() { |
|
231 |
refreshList(); |
|
232 |
refreshProperties(); |
|
233 |
} |
|
276 | 234 |
|
277 |
layout.setConstraints(getJPanel(), c); |
|
278 |
add(getJPanel(), null); |
|
235 |
/** |
|
236 |
* This method initializes this |
|
237 |
*/ |
|
238 |
private void initialize() { |
|
239 |
GridBagConstraints gridBagConstraints = new GridBagConstraints(); |
|
240 |
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; |
|
241 |
gridBagConstraints.weightx = 1.0; |
|
242 |
gridBagConstraints.weighty = 1.0; |
|
243 |
GridBagLayout layout = new GridBagLayout(); |
|
244 |
setLayout(layout); |
|
245 |
GridBagConstraints c = new GridBagConstraints(); |
|
246 |
c.fill = GridBagConstraints.HORIZONTAL; |
|
247 |
c.weightx = 1.0; |
|
248 |
c.weighty = 0; |
|
249 |
c.gridy = 0; |
|
250 |
c.insets = new Insets(2, 5, 2, 5); |
|
279 | 251 |
|
280 |
c.fill = GridBagConstraints.BOTH; |
|
281 |
c.gridy = 1; |
|
282 |
c.weightx = 1.0; |
|
283 |
c.weighty = 1.0; |
|
284 |
layout.setConstraints(getJPanel1(), c); |
|
285 |
add(getJPanel1(), null); |
|
286 |
c.fill = GridBagConstraints.HORIZONTAL; |
|
287 |
c.weightx = 0; |
|
288 |
c.weighty = 0; |
|
289 |
c.gridy = 2; |
|
290 |
layout.setConstraints(getJPanel3(), c); |
|
291 |
add(getJPanel3(), null); |
|
252 |
layout.setConstraints(getJPanel(), c); |
|
253 |
add(getJPanel(), null); |
|
292 | 254 |
|
293 |
this.setSize(430, 544); |
|
294 |
this.setPreferredSize(new java.awt.Dimension(430, 554)); |
|
295 |
this.setMinimumSize(new java.awt.Dimension(430, 554)); |
|
296 |
this.add(getJScrollPane1(), gridBagConstraints); |
|
297 |
for (int i = 0; i < btnsDocuments.length; i++) { |
|
298 |
grupo.add(btnsDocuments[i]); |
|
299 |
} |
|
300 |
if (btnsDocuments.length > 0) { |
|
301 |
btnsDocuments[0].setSelected(true); |
|
302 |
} |
|
303 |
} |
|
255 |
c.fill = GridBagConstraints.BOTH; |
|
256 |
c.gridy = 1; |
|
257 |
c.weightx = 1.0; |
|
258 |
c.weighty = 1.0; |
|
259 |
layout.setConstraints(getJPanel1(), c); |
|
260 |
add(getJPanel1(), null); |
|
261 |
c.fill = GridBagConstraints.HORIZONTAL; |
|
262 |
c.weightx = 0; |
|
263 |
c.weighty = 0; |
|
264 |
c.gridy = 2; |
|
265 |
layout.setConstraints(getJPanel3(), c); |
|
266 |
add(getJPanel3(), null); |
|
304 | 267 |
|
305 |
private Document createDocumentInProject(String doctype) { |
|
306 |
try { |
|
307 |
Document document = ProjectManager.getInstance() |
|
308 |
.createDocumentByUser(doctype); |
|
309 |
if (document == null) { |
|
310 |
return null; |
|
311 |
} |
|
312 |
project.add(document); |
|
313 |
int index = ((DefaultListModel)lstDocs.getModel()).indexOf(document); |
|
314 |
lstDocs.setSelectedIndex( index ); |
|
315 |
lstDocs.requestFocus(); |
|
316 |
return document; |
|
317 |
} catch (Exception e) { |
|
318 |
NotificationManager.addError(e); |
|
319 |
} |
|
320 |
return null; |
|
321 |
} |
|
268 |
this.setSize(430, 544); |
|
269 |
this.setPreferredSize(new java.awt.Dimension(430, 554)); |
|
270 |
this.setMinimumSize(new java.awt.Dimension(430, 554)); |
|
271 |
this.add(getJScrollPane1(), gridBagConstraints); |
|
272 |
for (int i = 0; i < btnsDocuments.length; i++) { |
|
273 |
grupo.add(btnsDocuments[i]); |
|
274 |
} |
|
275 |
if (btnsDocuments.length > 0) { |
|
276 |
btnsDocuments[0].setSelected(true); |
|
277 |
} |
|
278 |
} |
|
322 | 279 |
|
323 |
/** |
|
324 |
* Crea un nuevo project element |
|
325 |
* |
|
326 |
* @throws Exception |
|
327 |
* DOCUMENT ME! |
|
328 |
*/ |
|
329 |
private void newProjectDocument() throws Exception { |
|
330 |
String doctype = getDocumentSelected(); |
|
331 |
createDocumentInProject(doctype); |
|
332 |
} |
|
280 |
private Document createDocumentInProject(String doctype) { |
|
281 |
try { |
|
282 |
Document document = |
|
283 |
ProjectManager.getInstance().createDocumentByUser(doctype); |
|
284 |
if (document == null) { |
|
285 |
return null; |
|
286 |
} |
|
287 |
project.add(document); |
|
288 |
int index = |
|
289 |
((DefaultListModel) lstDocs.getModel()).indexOf(document); |
|
290 |
lstDocs.setSelectedIndex(index); |
|
291 |
lstDocs.requestFocus(); |
|
292 |
return document; |
|
293 |
} catch (Exception e) { |
|
294 |
NotificationManager.addError(e); |
|
295 |
} |
|
296 |
return null; |
|
297 |
} |
|
333 | 298 |
|
334 |
/** |
|
335 |
* Abre la ventana de un nuevo documento |
|
336 |
*/ |
|
337 |
private void abrir() { |
|
338 |
int[] indexes = lstDocs.getSelectedIndices(); |
|
339 |
for (int i = indexes.length - 1; i >= 0; i--) { |
|
340 |
int index = indexes[i]; |
|
341 |
if (index == -1) { |
|
342 |
return; |
|
343 |
} |
|
344 |
String doctype = getDocumentSelected(); |
|
345 |
List<Document> documents = project.getDocuments(doctype); |
|
346 |
Document doc = documents.get(index); |
|
347 |
IWindow window = doc.getFactory().getMainWindow(doc); |
|
348 |
if (window == null) { |
|
349 |
JOptionPane.showMessageDialog((Component) PluginServices |
|
350 |
.getMainFrame(), PluginServices.getText(this, |
|
351 |
"error_opening_the_document")); |
|
352 |
return; |
|
353 |
} |
|
354 |
PluginServices.getMDIManager().addWindow(window); |
|
355 |
} |
|
356 |
project.setModified(true); |
|
357 |
} |
|
299 |
/** |
|
300 |
* Crea un nuevo project element |
|
301 |
* |
|
302 |
* @throws Exception |
|
303 |
* DOCUMENT ME! |
|
304 |
*/ |
|
305 |
private void newProjectDocument() throws Exception { |
|
306 |
String doctype = getDocumentSelected(); |
|
307 |
createDocumentInProject(doctype); |
|
308 |
} |
|
358 | 309 |
|
359 |
/** |
|
360 |
* Cambia el nombre de un project element |
|
361 |
*/ |
|
362 |
private void renombrar() { |
|
363 |
int index = lstDocs.getSelectedIndex(); |
|
310 |
/** |
|
311 |
* Abre la ventana de un nuevo documento |
|
312 |
*/ |
|
313 |
private void abrir() { |
|
314 |
int[] indexes = lstDocs.getSelectedIndices(); |
|
315 |
for (int i = indexes.length - 1; i >= 0; i--) { |
|
316 |
int index = indexes[i]; |
|
317 |
if (index == -1) { |
|
318 |
return; |
|
319 |
} |
|
320 |
String doctype = getDocumentSelected(); |
|
321 |
List<Document> documents = project.getDocuments(doctype); |
|
322 |
Document doc = documents.get(index); |
|
323 |
IWindow window = doc.getFactory().getMainWindow(doc); |
|
324 |
if (window == null) { |
|
325 |
JOptionPane.showMessageDialog( |
|
326 |
(Component) PluginServices.getMainFrame(), |
|
327 |
PluginServices.getText(this, "error_opening_the_document")); |
|
328 |
return; |
|
329 |
} |
|
330 |
PluginServices.getMDIManager().addWindow(window); |
|
331 |
} |
|
332 |
project.setModified(true); |
|
333 |
} |
|
364 | 334 |
|
365 |
if (index == -1) { |
|
366 |
return; |
|
367 |
} |
|
368 |
String doctype = getDocumentSelected(); |
|
369 |
List<Document> documents = project.getDocuments(doctype); |
|
370 |
Document doc = documents.get(index); |
|
335 |
/** |
|
336 |
* Cambia el nombre de un project element |
|
337 |
*/ |
|
338 |
private void renombrar() { |
|
339 |
int index = lstDocs.getSelectedIndex(); |
|
371 | 340 |
|
372 |
if (doc.isLocked()) { |
|
373 |
JOptionPane.showMessageDialog(this, PluginServices.getText(this, |
|
374 |
"locked_element_it_cannot_be_renamed")); |
|
375 |
return; |
|
376 |
} |
|
341 |
if (index == -1) { |
|
342 |
return; |
|
343 |
} |
|
344 |
String doctype = getDocumentSelected(); |
|
345 |
List<Document> documents = project.getDocuments(doctype); |
|
346 |
Document doc = documents.get(index); |
|
377 | 347 |
|
378 |
JOptionPane pane = new JOptionPane(); |
|
379 |
pane.setMessage(PluginServices.getText(this, "introduce_nombre")); |
|
380 |
pane.setMessageType(JOptionPane.QUESTION_MESSAGE); |
|
381 |
pane.setWantsInput(true); |
|
382 |
pane.setInitialSelectionValue(doc.getName()); |
|
383 |
pane.setInputValue(doc.getName()); |
|
384 |
JDialog dlg = pane.createDialog((Component) PluginServices |
|
385 |
.getMainFrame(), PluginServices.getText(this, "renombrar")); |
|
386 |
dlg.setModal(true); |
|
387 |
dlg.setVisible(true); |
|
348 |
if (doc.isLocked()) { |
|
349 |
JOptionPane.showMessageDialog(this, PluginServices.getText(this, |
|
350 |
"locked_element_it_cannot_be_renamed")); |
|
351 |
return; |
|
352 |
} |
|
388 | 353 |
|
389 |
String nuevoNombre = pane.getInputValue().toString().trim(); |
|
354 |
JOptionPane pane = new JOptionPane(); |
|
355 |
pane.setMessage(PluginServices.getText(this, "introduce_nombre")); |
|
356 |
pane.setMessageType(JOptionPane.QUESTION_MESSAGE); |
|
357 |
pane.setWantsInput(true); |
|
358 |
pane.setInitialSelectionValue(doc.getName()); |
|
359 |
pane.setInputValue(doc.getName()); |
|
360 |
JDialog dlg = |
|
361 |
pane.createDialog((Component) PluginServices.getMainFrame(), |
|
362 |
PluginServices.getText(this, "renombrar")); |
|
363 |
dlg.setModal(true); |
|
364 |
dlg.setVisible(true); |
|
390 | 365 |
|
391 |
if (nuevoNombre.length() == 0) { |
|
392 |
return; |
|
393 |
} |
|
366 |
String nuevoNombre = pane.getInputValue().toString().trim(); |
|
394 | 367 |
|
395 |
if (nuevoNombre == null) {
|
|
396 |
return;
|
|
397 |
}
|
|
368 |
if (nuevoNombre.length() == 0) {
|
|
369 |
return;
|
|
370 |
}
|
|
398 | 371 |
|
399 |
for (int i = 0; i < lstDocs.getModel().getSize(); i++) { |
|
400 |
if (i == index) { |
|
401 |
continue; |
|
402 |
} |
|
403 |
if (((AbstractDocument) lstDocs.getModel().getElementAt(i)) |
|
404 |
.getName().equals(nuevoNombre)) { |
|
405 |
JOptionPane.showMessageDialog((Component) PluginServices |
|
406 |
.getMainFrame(), PluginServices.getText(this, |
|
407 |
"elemento_ya_existe")); |
|
408 |
return; |
|
409 |
} |
|
372 |
if (nuevoNombre == null) { |
|
373 |
return; |
|
374 |
} |
|
410 | 375 |
|
411 |
} |
|
412 |
doc.setName(nuevoNombre); |
|
376 |
for (int i = 0; i < lstDocs.getModel().getSize(); i++) { |
|
377 |
if (i == index) { |
|
378 |
continue; |
|
379 |
} |
|
380 |
if (((AbstractDocument) lstDocs.getModel().getElementAt(i)) |
|
381 |
.getName().equals(nuevoNombre)) { |
|
382 |
JOptionPane.showMessageDialog( |
|
383 |
(Component) PluginServices.getMainFrame(), |
|
384 |
PluginServices.getText(this, "elemento_ya_existe")); |
|
385 |
return; |
|
386 |
} |
|
413 | 387 |
|
414 |
refreshList(); |
|
415 |
project.setModified(true); |
|
416 |
} |
|
388 |
} |
|
389 |
doc.setName(nuevoNombre); |
|
417 | 390 |
|
418 |
/** |
|
419 |
* Borra un project element |
|
420 |
*/ |
|
421 |
private void borrar() { |
|
422 |
int res = JOptionPane.showConfirmDialog((Component) PluginServices |
|
423 |
.getMainFrame(), PluginServices.getText(this, |
|
424 |
"confirmar_borrar"), PluginServices.getText(this, "borrar"), |
|
425 |
JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE); |
|
391 |
refreshList(); |
|
392 |
project.setModified(true); |
|
393 |
} |
|
426 | 394 |
|
427 |
int lastremoved = 0; |
|
428 |
if (res == JOptionPane.YES_OPTION) { |
|
429 |
int[] indexes = lstDocs.getSelectedIndices(); |
|
430 |
for (int i = indexes.length - 1; i >= 0; i--) { |
|
431 |
int index = indexes[i]; |
|
432 |
String s = getDocumentSelected(); |
|
433 |
List<Document> documents = project.getDocuments(s); |
|
434 |
Document doc = (AbstractDocument) documents.get(index); |
|
435 |
if (doc.isLocked()) { |
|
436 |
JOptionPane.showMessageDialog(this, PluginServices.getText( |
|
437 |
this, "locked_element_it_cannot_be_deleted")); |
|
438 |
return; |
|
439 |
} |
|
440 |
PluginServices.getMDIManager().closeSingletonWindow(doc); |
|
441 |
project.remove(doc); |
|
442 |
lastremoved = index; |
|
443 |
} |
|
444 |
if( lastremoved > lstDocs.getModel().getSize() ) { |
|
445 |
lastremoved = lstDocs.getModel().getSize(); |
|
446 |
} |
|
447 |
if( lastremoved > 0 ) { |
|
448 |
lstDocs.setSelectedIndex(lastremoved); |
|
449 |
} |
|
450 |
refreshList(); |
|
451 |
project.setModified(true); |
|
452 |
} |
|
453 |
} |
|
395 |
/** |
|
396 |
* Borra un project element |
|
397 |
*/ |
|
398 |
private void borrar() { |
|
399 |
int res = |
|
400 |
JOptionPane.showConfirmDialog( |
|
401 |
(Component) PluginServices.getMainFrame(), |
|
402 |
PluginServices.getText(this, "confirmar_borrar"), |
|
403 |
PluginServices.getText(this, "borrar"), |
|
404 |
JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE); |
|
454 | 405 |
|
455 |
/** |
|
456 |
* Muestra el di?logo de propiedades de un project element |
|
457 |
*/ |
Also available in: Unified diff