Revision 46986
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.swing/org.gvsig.fmap.dal.swing.api/src/main/java/org/gvsig/fmap/dal/swing/DataSwingManager.java | ||
---|---|---|
32 | 32 |
import javax.swing.JButton; |
33 | 33 |
import javax.swing.JComboBox; |
34 | 34 |
import javax.swing.JList; |
35 |
import javax.swing.JPanel; |
|
35 | 36 |
import javax.swing.JTextField; |
36 | 37 |
import javax.swing.JTree; |
37 | 38 |
import javax.swing.table.TableModel; |
... | ... | |
240 | 241 |
public int askUserStopEditing(FeatureStore featureStore, boolean allowContinue); |
241 | 242 |
|
242 | 243 |
public int askUserStopEditing(Component parent, FeatureStore featureStore, boolean allowContinue); |
244 |
|
|
245 |
public JPanel createVisualdbModelerPanel(); |
|
243 | 246 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.swing/org.gvsig.fmap.dal.swing.impl/src/main/java/org/gvsig/fmap/dal/swing/impl/DefaultDataSwingManager.java | ||
---|---|---|
41 | 41 |
import javax.swing.JComboBox; |
42 | 42 |
import javax.swing.JList; |
43 | 43 |
import javax.swing.JOptionPane; |
44 |
import javax.swing.JPanel; |
|
44 | 45 |
import javax.swing.JTextField; |
45 | 46 |
import javax.swing.JTree; |
46 | 47 |
import javax.swing.text.JTextComponent; |
... | ... | |
137 | 138 |
import org.gvsig.fmap.dal.swing.impl.searchpanel.DefaultSearchParameters; |
138 | 139 |
import org.gvsig.fmap.dal.swing.impl.storesrepository.StoresRepositoryControllerImpl; |
139 | 140 |
import org.gvsig.fmap.dal.swing.impl.storesrepository.StoresRepositoryTreeModel; |
141 |
import org.gvsig.fmap.dal.swing.impl.visualdbmodeler.Visualdbmodeler; |
|
140 | 142 |
import org.gvsig.fmap.dal.swing.jdbc.JDBCConnectionDialog; |
141 | 143 |
import org.gvsig.fmap.dal.swing.jdbc.JDBCConnectionPanel; |
142 | 144 |
import org.gvsig.fmap.dal.swing.searchPostProcess.SearchPostProcessFactory; |
... | ... | |
882 | 884 |
return true; |
883 | 885 |
} |
884 | 886 |
|
887 |
public JPanel createVisualdbModelerPanel() { |
|
888 |
return new Visualdbmodeler(); |
|
889 |
} |
|
890 |
|
|
885 | 891 |
} |
886 |
|
|
887 | 892 |
|
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.swing/org.gvsig.fmap.dal.swing.impl/src/main/java/org/gvsig/fmap/dal/swing/impl/visualdbmodeler/ShadowBorder.java | ||
---|---|---|
1 |
/* |
|
2 |
* Copyright (c) 2001-2005, Gaudenz Alder |
|
3 |
* |
|
4 |
* All rights reserved. |
|
5 |
* |
|
6 |
* This file is licensed under the JGraph software license, a copy of which |
|
7 |
* will have been provided to you in the file LICENSE at the root of your |
|
8 |
* installation directory. If you are unable to locate this file please |
|
9 |
* contact JGraph sales for another copy. |
|
10 |
*/ |
|
11 |
package org.gvsig.fmap.dal.swing.impl.visualdbmodeler; |
|
12 |
|
|
13 |
import java.awt.Color; |
|
14 |
import java.awt.Component; |
|
15 |
import java.awt.Graphics; |
|
16 |
import java.awt.Insets; |
|
17 |
import java.io.Serializable; |
|
18 |
|
|
19 |
import javax.swing.border.Border; |
|
20 |
|
|
21 |
/** |
|
22 |
* Border with a drop shadow. |
|
23 |
*/ |
|
24 |
public class ShadowBorder implements Border, Serializable |
|
25 |
{ |
|
26 |
/** |
|
27 |
* |
|
28 |
*/ |
|
29 |
private static final long serialVersionUID = 6854989457150641240L; |
|
30 |
|
|
31 |
private Insets insets; |
|
32 |
|
|
33 |
public static ShadowBorder sharedInstance = new ShadowBorder(); |
|
34 |
|
|
35 |
private ShadowBorder() |
|
36 |
{ |
|
37 |
insets = new Insets(0, 0, 2, 2); |
|
38 |
} |
|
39 |
|
|
40 |
public Insets getBorderInsets(Component c) |
|
41 |
{ |
|
42 |
return insets; |
|
43 |
} |
|
44 |
|
|
45 |
public boolean isBorderOpaque() |
|
46 |
{ |
|
47 |
return false; |
|
48 |
} |
|
49 |
|
|
50 |
public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) |
|
51 |
{ |
|
52 |
// choose which colors we want to use |
|
53 |
Color bg = c.getBackground(); |
|
54 |
|
|
55 |
if (c.getParent() != null) |
|
56 |
{ |
|
57 |
bg = c.getParent().getBackground(); |
|
58 |
} |
|
59 |
|
|
60 |
if (bg != null) |
|
61 |
{ |
|
62 |
Color mid = bg.darker(); |
|
63 |
Color edge = average(mid, bg); |
|
64 |
|
|
65 |
g.setColor(bg); |
|
66 |
g.drawLine(0, h - 2, w, h - 2); |
|
67 |
g.drawLine(0, h - 1, w, h - 1); |
|
68 |
g.drawLine(w - 2, 0, w - 2, h); |
|
69 |
g.drawLine(w - 1, 0, w - 1, h); |
|
70 |
|
|
71 |
// draw the drop-shadow |
|
72 |
g.setColor(mid); |
|
73 |
g.drawLine(1, h - 2, w - 2, h - 2); |
|
74 |
g.drawLine(w - 2, 1, w - 2, h - 2); |
|
75 |
|
|
76 |
g.setColor(edge); |
|
77 |
g.drawLine(2, h - 1, w - 2, h - 1); |
|
78 |
g.drawLine(w - 1, 2, w - 1, h - 2); |
|
79 |
} |
|
80 |
} |
|
81 |
|
|
82 |
private static Color average(Color c1, Color c2) |
|
83 |
{ |
|
84 |
int red = c1.getRed() + (c2.getRed() - c1.getRed()) / 2; |
|
85 |
int green = c1.getGreen() + (c2.getGreen() - c1.getGreen()) / 2; |
|
86 |
int blue = c1.getBlue() + (c2.getBlue() - c1.getBlue()) / 2; |
|
87 |
return new Color(red, green, blue); |
|
88 |
} |
|
89 |
|
|
90 |
public static ShadowBorder getSharedInstance() |
|
91 |
{ |
|
92 |
return sharedInstance; |
|
93 |
} |
|
94 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.swing/org.gvsig.fmap.dal.swing.impl/src/main/java/org/gvsig/fmap/dal/swing/impl/visualdbmodeler/TableDescriptor.java | ||
---|---|---|
1 |
/* |
|
2 |
* To change this license header, choose License Headers in Project Properties. |
|
3 |
* To change this template file, choose Tools | Templates |
|
4 |
* and open the template in the editor. |
|
5 |
*/ |
|
6 |
package org.gvsig.fmap.dal.swing.impl.visualdbmodeler; |
|
7 |
|
|
8 |
import org.gvsig.fmap.dal.feature.EditableFeatureType; |
|
9 |
import org.gvsig.tools.util.LabeledValue; |
|
10 |
|
|
11 |
/** |
|
12 |
* |
|
13 |
* @author jjdelcerro |
|
14 |
*/ |
|
15 |
public interface TableDescriptor extends LabeledValue<TableDescriptor>{ |
|
16 |
public String getName(); |
|
17 |
|
|
18 |
public String getRepositoryId(); |
|
19 |
|
|
20 |
public EditableFeatureType getFeatureType(); |
|
21 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.swing/org.gvsig.fmap.dal.swing.impl/src/main/java/org/gvsig/fmap/dal/swing/impl/visualdbmodeler/JTableRenderer.java | ||
---|---|---|
1 |
/* |
|
2 |
* Copyright (c) 2001-2005, Gaudenz Alder |
|
3 |
* |
|
4 |
* All rights reserved. |
|
5 |
* |
|
6 |
* See LICENSE file for license details. If you are unable to locate |
|
7 |
* this file please contact info (at) jgraph (dot) com. |
|
8 |
*/ |
|
9 |
package org.gvsig.fmap.dal.swing.impl.visualdbmodeler; |
|
10 |
|
|
11 |
import com.mxgraph.model.mxCell; |
|
12 |
import java.awt.BorderLayout; |
|
13 |
import java.awt.Color; |
|
14 |
import java.awt.Component; |
|
15 |
import java.awt.Cursor; |
|
16 |
import java.awt.Dimension; |
|
17 |
import java.awt.FlowLayout; |
|
18 |
import java.awt.Font; |
|
19 |
import java.awt.Point; |
|
20 |
import java.awt.datatransfer.Transferable; |
|
21 |
import java.awt.dnd.DnDConstants; |
|
22 |
import java.awt.dnd.DropTarget; |
|
23 |
import java.awt.dnd.DropTargetDragEvent; |
|
24 |
import java.awt.dnd.DropTargetDropEvent; |
|
25 |
import java.awt.dnd.DropTargetEvent; |
|
26 |
import java.awt.dnd.DropTargetListener; |
|
27 |
import java.awt.event.ActionEvent; |
|
28 |
import java.awt.event.AdjustmentEvent; |
|
29 |
import java.awt.event.AdjustmentListener; |
|
30 |
import java.awt.event.MouseEvent; |
|
31 |
import java.awt.event.MouseListener; |
|
32 |
import java.awt.event.MouseMotionListener; |
|
33 |
|
|
34 |
import javax.swing.AbstractAction; |
|
35 |
import javax.swing.BorderFactory; |
|
36 |
import javax.swing.ImageIcon; |
|
37 |
import javax.swing.JButton; |
|
38 |
import javax.swing.JComponent; |
|
39 |
import javax.swing.JLabel; |
|
40 |
import javax.swing.JPanel; |
|
41 |
import javax.swing.JScrollPane; |
|
42 |
import javax.swing.JTable; |
|
43 |
import javax.swing.SwingUtilities; |
|
44 |
import javax.swing.TransferHandler; |
|
45 |
import javax.swing.border.BevelBorder; |
|
46 |
import javax.swing.table.AbstractTableModel; |
|
47 |
import javax.swing.table.TableColumn; |
|
48 |
import javax.swing.table.TableModel; |
|
49 |
|
|
50 |
import com.mxgraph.swing.mxGraphComponent; |
|
51 |
import com.mxgraph.swing.handler.mxCellHandler; |
|
52 |
import com.mxgraph.swing.handler.mxGraphTransferHandler; |
|
53 |
import com.mxgraph.swing.util.mxGraphTransferable; |
|
54 |
import com.mxgraph.view.mxGraph; |
|
55 |
import java.awt.event.ActionListener; |
|
56 |
import java.awt.event.MouseAdapter; |
|
57 |
import javax.swing.event.TableModelListener; |
|
58 |
import org.gvsig.fmap.dal.feature.EditableFeatureAttributeDescriptor; |
|
59 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
|
60 |
import org.gvsig.fmap.dal.spi.DALSPILocator; |
|
61 |
import org.gvsig.fmap.dal.swing.DALSwingLocator; |
|
62 |
import org.gvsig.fmap.dal.swing.featuretype.FeatureTypeAttributePanel; |
|
63 |
import org.gvsig.tools.ToolsLocator; |
|
64 |
import org.gvsig.tools.i18n.I18nManager; |
|
65 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
|
66 |
import org.gvsig.tools.swing.api.windowmanager.Dialog; |
|
67 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager; |
|
68 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager_v2; |
|
69 |
|
|
70 |
/** |
|
71 |
* @author Administrator |
|
72 |
* |
|
73 |
*/ |
|
74 |
public class JTableRenderer extends JComponent { |
|
75 |
|
|
76 |
/** |
|
77 |
* |
|
78 |
*/ |
|
79 |
public static final String IMAGE_PATH = "/org/gvsig/fmap/dal/swing/impl/visualdbmodeler/images/"; |
|
80 |
|
|
81 |
/** |
|
82 |
* |
|
83 |
*/ |
|
84 |
protected static JTableRenderer dragSource = null; |
|
85 |
|
|
86 |
/** |
|
87 |
* |
|
88 |
*/ |
|
89 |
protected static int sourceRow = 0; |
|
90 |
|
|
91 |
/** |
|
92 |
* |
|
93 |
*/ |
|
94 |
protected mxCell cell; |
|
95 |
|
|
96 |
/** |
|
97 |
* |
|
98 |
*/ |
|
99 |
protected mxGraphComponent graphContainer; |
|
100 |
|
|
101 |
/** |
|
102 |
* |
|
103 |
*/ |
|
104 |
protected mxGraph graph; |
|
105 |
|
|
106 |
/** |
|
107 |
* |
|
108 |
*/ |
|
109 |
public JTable table; |
|
110 |
|
|
111 |
private final TableDescriptor tableDescriptor; |
|
112 |
|
|
113 |
/** |
|
114 |
* |
|
115 |
*/ |
|
116 |
@SuppressWarnings("serial") |
|
117 |
public JTableRenderer(final Object cell, |
|
118 |
final mxGraphComponent graphContainer) { |
|
119 |
this.cell = (mxCell) cell; |
|
120 |
this.tableDescriptor = (TableDescriptor) this.cell.getValue(); |
|
121 |
this.graphContainer = graphContainer; |
|
122 |
this.graph = graphContainer.getGraph(); |
|
123 |
setLayout(new BorderLayout()); |
|
124 |
setBorder(BorderFactory.createCompoundBorder( |
|
125 |
ShadowBorder.getSharedInstance(), |
|
126 |
BorderFactory.createBevelBorder(BevelBorder.RAISED) |
|
127 |
)); |
|
128 |
|
|
129 |
JPanel title = new JPanel(); |
|
130 |
title.setBackground(new Color(149, 173, 239)); |
|
131 |
title.setOpaque(true); |
|
132 |
title.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 1)); |
|
133 |
title.setLayout(new BorderLayout()); |
|
134 |
|
|
135 |
JLabel icon = new JLabel(new ImageIcon(JTableRenderer.class |
|
136 |
.getResource(IMAGE_PATH + "preferences.gif"))); |
|
137 |
icon.setBorder(BorderFactory.createEmptyBorder(0, 2, 0, 1)); |
|
138 |
title.add(icon, BorderLayout.WEST); |
|
139 |
|
|
140 |
// JLabel label = new JLabel(String.valueOf(graph.getLabel(cell))); |
|
141 |
JLabel label = new JLabel(this.tableDescriptor.getName()); |
|
142 |
label.setForeground(Color.WHITE); |
|
143 |
label.setFont(title.getFont().deriveFont(Font.BOLD, 11)); |
|
144 |
label.setBorder(BorderFactory.createEmptyBorder(0, 1, 0, 2)); |
|
145 |
title.add(label, BorderLayout.CENTER); |
|
146 |
|
|
147 |
JPanel toolBar2 = new JPanel(); |
|
148 |
toolBar2.setLayout(new FlowLayout(FlowLayout.LEFT, 1, 2)); |
|
149 |
toolBar2.setOpaque(false); |
|
150 |
JButton button = new JButton(new AbstractAction("", new ImageIcon( |
|
151 |
JTableRenderer.class.getResource(IMAGE_PATH + "minimize.gif"))) { |
|
152 |
|
|
153 |
public void actionPerformed(ActionEvent e) { |
|
154 |
graph.foldCells(!graph.isCellCollapsed(cell), false, |
|
155 |
new Object[]{cell}); |
|
156 |
((JButton) e.getSource()) |
|
157 |
.setIcon(new ImageIcon( |
|
158 |
JTableRenderer.class |
|
159 |
.getResource(IMAGE_PATH |
|
160 |
+ ((graph.isCellCollapsed(cell)) ? "maximize.gif" |
|
161 |
: "minimize.gif")))); |
|
162 |
} |
|
163 |
}); |
|
164 |
button.setPreferredSize(new Dimension(16, 16)); |
|
165 |
button.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); |
|
166 |
button.setToolTipText("Collapse/Expand"); |
|
167 |
button.setOpaque(false); |
|
168 |
toolBar2.add(button); |
|
169 |
|
|
170 |
title.add(toolBar2, BorderLayout.EAST); |
|
171 |
add(title, BorderLayout.NORTH); |
|
172 |
|
|
173 |
table = new MyTable(this.tableDescriptor); |
|
174 |
JScrollPane scrollPane = new JScrollPane(table); |
|
175 |
scrollPane.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); |
|
176 |
|
|
177 |
if (graph.getModel().getChildCount(cell) == 0) { |
|
178 |
scrollPane.getViewport().setBackground(Color.WHITE); |
|
179 |
setOpaque(true); |
|
180 |
add(scrollPane, BorderLayout.CENTER); |
|
181 |
} |
|
182 |
|
|
183 |
scrollPane.getVerticalScrollBar().addAdjustmentListener( |
|
184 |
new AdjustmentListener() { |
|
185 |
|
|
186 |
public void adjustmentValueChanged(AdjustmentEvent e) { |
|
187 |
graphContainer.refresh(); |
|
188 |
} |
|
189 |
|
|
190 |
}); |
|
191 |
|
|
192 |
label = new JLabel(new ImageIcon(JTableRenderer.class |
|
193 |
.getResource(IMAGE_PATH + "resize.gif"))); |
|
194 |
label.setCursor(new Cursor(Cursor.NW_RESIZE_CURSOR)); |
|
195 |
|
|
196 |
JPanel panel = new JPanel(); |
|
197 |
panel.setLayout(new BorderLayout()); |
|
198 |
panel.add(label, BorderLayout.EAST); |
|
199 |
|
|
200 |
add(panel, BorderLayout.SOUTH); |
|
201 |
|
|
202 |
ResizeHandler resizeHandler = new ResizeHandler(); |
|
203 |
label.addMouseListener(resizeHandler); |
|
204 |
label.addMouseMotionListener(resizeHandler); |
|
205 |
|
|
206 |
setMinimumSize(new Dimension(20, 30)); |
|
207 |
} |
|
208 |
|
|
209 |
/** |
|
210 |
* Implements an event redirector for the specified handle index, where 0 is |
|
211 |
* the top right, and 1-7 are the top center, rop right, middle left, middle |
|
212 |
* right, bottom left, bottom center and bottom right, respectively. Default |
|
213 |
* index is 7 (bottom right). |
|
214 |
*/ |
|
215 |
public class ResizeHandler implements MouseListener, MouseMotionListener { |
|
216 |
|
|
217 |
protected int index; |
|
218 |
|
|
219 |
public ResizeHandler() { |
|
220 |
this(7); |
|
221 |
} |
|
222 |
|
|
223 |
public ResizeHandler(int index) { |
|
224 |
this.index = index; |
|
225 |
} |
|
226 |
|
|
227 |
public void mouseClicked(MouseEvent e) { |
|
228 |
// ignore |
|
229 |
} |
|
230 |
|
|
231 |
public void mouseEntered(MouseEvent e) { |
|
232 |
// ignore |
|
233 |
} |
|
234 |
|
|
235 |
public void mouseExited(MouseEvent e) { |
|
236 |
// ignore |
|
237 |
} |
|
238 |
|
|
239 |
public void mousePressed(MouseEvent e) { |
|
240 |
// Selects to create a handler for resizing |
|
241 |
if (!graph.isCellSelected(cell)) { |
|
242 |
graphContainer.selectCellForEvent(cell, e); |
|
243 |
} |
|
244 |
|
|
245 |
// Initiates a resize event in the handler |
|
246 |
mxCellHandler handler = graphContainer.getSelectionCellsHandler().getHandler( |
|
247 |
cell); |
|
248 |
|
|
249 |
if (handler != null) { |
|
250 |
// Starts the resize at index 7 (bottom right) |
|
251 |
handler.start(SwingUtilities.convertMouseEvent((Component) e |
|
252 |
.getSource(), e, graphContainer.getGraphControl()), |
|
253 |
index); |
|
254 |
e.consume(); |
|
255 |
} |
|
256 |
} |
|
257 |
|
|
258 |
public void mouseReleased(MouseEvent e) { |
|
259 |
graphContainer.getGraphControl().dispatchEvent( |
|
260 |
SwingUtilities.convertMouseEvent((Component) e.getSource(), |
|
261 |
e, graphContainer.getGraphControl())); |
|
262 |
} |
|
263 |
|
|
264 |
public void mouseDragged(MouseEvent e) { |
|
265 |
graphContainer.getGraphControl().dispatchEvent( |
|
266 |
SwingUtilities.convertMouseEvent((Component) e.getSource(), |
|
267 |
e, graphContainer.getGraphControl())); |
|
268 |
} |
|
269 |
|
|
270 |
public void mouseMoved(MouseEvent e) { |
|
271 |
// ignore |
|
272 |
} |
|
273 |
} |
|
274 |
|
|
275 |
private static class MyTableModel extends AbstractTableModel implements TableModel { |
|
276 |
|
|
277 |
private final TableDescriptor tableDescriptor; |
|
278 |
private final String[] columnNames; |
|
279 |
private final Class[] columnTypes; |
|
280 |
|
|
281 |
public MyTableModel(TableDescriptor tableDescriptor) { |
|
282 |
super(); |
|
283 |
this.tableDescriptor = tableDescriptor; |
|
284 |
this.columnNames = new String[] { "","Name","Type" }; |
|
285 |
this.columnTypes = new Class[] { String.class,String.class,String.class }; |
|
286 |
} |
|
287 |
|
|
288 |
@Override |
|
289 |
public int getRowCount() { |
|
290 |
return this.tableDescriptor.getFeatureType().size(); |
|
291 |
} |
|
292 |
|
|
293 |
@Override |
|
294 |
public int getColumnCount() { |
|
295 |
return this.columnNames.length; |
|
296 |
} |
|
297 |
|
|
298 |
@Override |
|
299 |
public String getColumnName(int columnIndex) { |
|
300 |
return this.columnNames[columnIndex]; |
|
301 |
} |
|
302 |
|
|
303 |
@Override |
|
304 |
public Class<?> getColumnClass(int columnIndex) { |
|
305 |
return this.columnTypes[columnIndex]; |
|
306 |
} |
|
307 |
|
|
308 |
@Override |
|
309 |
public boolean isCellEditable(int rowIndex, int columnIndex) { |
|
310 |
return false; |
|
311 |
} |
|
312 |
|
|
313 |
@Override |
|
314 |
public Object getValueAt(int rowIndex, int columnIndex) { |
|
315 |
FeatureAttributeDescriptor attrdesc = this.tableDescriptor.getFeatureType().getAttributeDescriptor(rowIndex); |
|
316 |
switch(columnIndex) { |
|
317 |
case 0: |
|
318 |
StringBuilder mask = new StringBuilder(); |
|
319 |
if( attrdesc.isPrimaryKey() ) { |
|
320 |
mask.append("Pk"); |
|
321 |
} |
|
322 |
if( attrdesc.isForeingKey()) { |
|
323 |
mask.append("Fk"); |
|
324 |
} |
|
325 |
if( attrdesc.isComputed() ) { |
|
326 |
mask.append("C"); |
|
327 |
} |
|
328 |
return mask.toString(); |
|
329 |
case 1: |
|
330 |
return attrdesc.getName(); |
|
331 |
case 2: |
|
332 |
return attrdesc.getDataTypeName(); |
|
333 |
default: |
|
334 |
return ""; |
|
335 |
} |
|
336 |
} |
|
337 |
|
|
338 |
public TableDescriptor getTableDescriptor() { |
|
339 |
return this.tableDescriptor; |
|
340 |
} |
|
341 |
|
|
342 |
} |
|
343 |
|
|
344 |
/** |
|
345 |
* |
|
346 |
*/ |
|
347 |
private class MyTable extends JTable implements DropTargetListener { |
|
348 |
|
|
349 |
/** |
|
350 |
* |
|
351 |
*/ |
|
352 |
private static final long serialVersionUID = 5841175227984561071L; |
|
353 |
|
|
354 |
Object[][] data; |
|
355 |
|
|
356 |
String[] colNames = new String[]{"A", "B", "C", "D", "E"}; |
|
357 |
|
|
358 |
@SuppressWarnings("serial") |
|
359 |
public MyTable(TableDescriptor tableDescriptor) { |
|
360 |
setModel(new MyTableModel(tableDescriptor)); |
|
361 |
setTableHeader(null); |
|
362 |
setAutoscrolls(true); |
|
363 |
setGridColor(Color.WHITE); |
|
364 |
TableColumn column = getColumnModel().getColumn(0); |
|
365 |
column.setMaxWidth(30); |
|
366 |
|
|
367 |
setTransferHandler(new TransferHandler() { |
|
368 |
|
|
369 |
/* (non-Javadoc) |
|
370 |
* @see javax.swing.TransferHandler#getSourceActions(javax.swing.JComponent) |
|
371 |
*/ |
|
372 |
@Override |
|
373 |
public int getSourceActions(JComponent c) { |
|
374 |
return COPY_OR_MOVE; |
|
375 |
} |
|
376 |
|
|
377 |
/* |
|
378 |
* (non-Javadoc) |
|
379 |
* |
|
380 |
* @see javax.swing.TransferHandler#createTransferable(javax.swing.JComponent) |
|
381 |
*/ |
|
382 |
protected Transferable createTransferable(JComponent c) { |
|
383 |
sourceRow = getSelectedRow(); |
|
384 |
dragSource = JTableRenderer.this; |
|
385 |
//mxRectangle bounds = new mxRectangle(0, 0, MyTable.this |
|
386 |
// .getWidth(), 20); |
|
387 |
return new mxGraphTransferable(null, null, null); |
|
388 |
} |
|
389 |
|
|
390 |
}); |
|
391 |
|
|
392 |
setDragEnabled(true); |
|
393 |
setDropTarget(new DropTarget(this, // component |
|
394 |
DnDConstants.ACTION_COPY_OR_MOVE, // actions |
|
395 |
this)); |
|
396 |
setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); |
|
397 |
|
|
398 |
this.addMouseListener(new MouseAdapter() { |
|
399 |
@Override |
|
400 |
public void mouseClicked(MouseEvent e) { |
|
401 |
if (e.getButton() == MouseEvent.BUTTON2 || e.getClickCount() == 2) { |
|
402 |
doShowAttributePanel(); |
|
403 |
} |
|
404 |
} |
|
405 |
}); |
|
406 |
} |
|
407 |
|
|
408 |
/** |
|
409 |
* |
|
410 |
*/ |
|
411 |
public DropTarget getDropTarget() { |
|
412 |
if (!((mxGraphTransferHandler) graphContainer.getTransferHandler()) |
|
413 |
.isLocalDrag()) { |
|
414 |
return super.getDropTarget(); |
|
415 |
} |
|
416 |
|
|
417 |
return null; |
|
418 |
} |
|
419 |
|
|
420 |
/* |
|
421 |
* (non-Javadoc) |
|
422 |
* |
|
423 |
* @see java.awt.dnd.DropTargetListener#dragEnter(java.awt.dnd.DropTargetDragEvent) |
|
424 |
*/ |
|
425 |
public void dragEnter(DropTargetDragEvent e) { |
|
426 |
|
|
427 |
} |
|
428 |
|
|
429 |
/* |
|
430 |
* (non-Javadoc) |
|
431 |
* |
|
432 |
* @see java.awt.dnd.DropTargetListener#dragOver(java.awt.dnd.DropTargetDragEvent) |
|
433 |
*/ |
|
434 |
public void dragOver(DropTargetDragEvent e) { |
|
435 |
if (!((mxGraphTransferHandler) graphContainer.getTransferHandler()) |
|
436 |
.isLocalDrag() |
|
437 |
&& JTableRenderer.this != dragSource) { |
|
438 |
Point p = e.getLocation(); |
|
439 |
int row = rowAtPoint(p); |
|
440 |
getSelectionModel().setSelectionInterval(row, row); |
|
441 |
} |
|
442 |
} |
|
443 |
|
|
444 |
/* |
|
445 |
* (non-Javadoc) |
|
446 |
* |
|
447 |
* @see java.awt.dnd.DropTargetListener#dropActionChanged(java.awt.dnd.DropTargetDragEvent) |
|
448 |
*/ |
|
449 |
public void dropActionChanged(DropTargetDragEvent dtde) { |
|
450 |
// TODO Auto-generated method stub |
|
451 |
|
|
452 |
} |
|
453 |
|
|
454 |
/* |
|
455 |
* (non-Javadoc) |
|
456 |
* |
|
457 |
* @see java.awt.dnd.DropTargetListener#drop(java.awt.dnd.DropTargetDropEvent) |
|
458 |
*/ |
|
459 |
public void drop(DropTargetDropEvent e) { |
|
460 |
if (dragSource != null) { |
|
461 |
e.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE); |
|
462 |
Point p = e.getLocation(); |
|
463 |
int targetRow = rowAtPoint(p); |
|
464 |
|
|
465 |
Object edge = graph.insertEdge(null, null, null, |
|
466 |
dragSource.cell, JTableRenderer.this.cell, "sourceRow=" |
|
467 |
+ sourceRow + ";targetRow=" + targetRow); |
|
468 |
graph.setSelectionCell(edge); |
|
469 |
|
|
470 |
// System.out.println("clearing drag source"); |
|
471 |
dragSource = null; |
|
472 |
e.dropComplete(true); |
|
473 |
} else { |
|
474 |
e.rejectDrop(); |
|
475 |
} |
|
476 |
} |
|
477 |
|
|
478 |
/* |
|
479 |
* (non-Javadoc) |
|
480 |
* |
|
481 |
* @see java.awt.dnd.DropTargetListener#dragExit(java.awt.dnd.DropTargetEvent) |
|
482 |
*/ |
|
483 |
public void dragExit(DropTargetEvent dte) { |
|
484 |
// TODO Auto-generated method stub |
|
485 |
|
|
486 |
} |
|
487 |
|
|
488 |
private void doShowAttributePanel() { |
|
489 |
int row = this.getSelectedRow(); |
|
490 |
if( row<0 ) { |
|
491 |
return; |
|
492 |
} |
|
493 |
EditableFeatureAttributeDescriptor attrdesc = (EditableFeatureAttributeDescriptor) tableDescriptor.getFeatureType().getAttributeDescriptor(row); |
|
494 |
|
|
495 |
final I18nManager i18n = ToolsLocator.getI18nManager(); |
|
496 |
WindowManager_v2 winManager = (WindowManager_v2) ToolsSwingLocator.getWindowManager(); |
|
497 |
final FeatureTypeAttributePanel panel = DALSwingLocator.getSwingManager().createFeatureTypeAttributePanel(); |
|
498 |
panel.clean(); |
|
499 |
panel.put(attrdesc); |
|
500 |
panel.setMode(FeatureTypeAttributePanel.MODE_EDIT_ALL); |
|
501 |
final Dialog dialog = winManager.createDialog( |
|
502 |
panel.asJComponent(), |
|
503 |
i18n.getTranslation("_Column"), |
|
504 |
null, |
|
505 |
WindowManager_v2.BUTTONS_OK_CANCEL |
|
506 |
); |
|
507 |
dialog.addActionListener(new ActionListener() { |
|
508 |
@Override |
|
509 |
public void actionPerformed(ActionEvent e) { |
|
510 |
if (dialog.getAction() != WindowManager_v2.BUTTONS_OK) { |
|
511 |
return; |
|
512 |
} |
|
513 |
try { |
|
514 |
panel.fetch(attrdesc); |
|
515 |
} catch (Exception ex) { |
|
516 |
// LOGGER.warn("Problems updating feature descriptor.", ex); |
|
517 |
} |
|
518 |
} |
|
519 |
}); |
|
520 |
dialog.show(WindowManager.MODE.DIALOG); |
|
521 |
} |
|
522 |
|
|
523 |
} |
|
524 |
|
|
525 |
/** |
|
526 |
* |
|
527 |
*/ |
|
528 |
public static JTableRenderer getVertex(Component component) { |
|
529 |
while (component != null) { |
|
530 |
if (component instanceof JTableRenderer) { |
|
531 |
return (JTableRenderer) component; |
|
532 |
} |
|
533 |
component = component.getParent(); |
|
534 |
} |
|
535 |
|
|
536 |
return null; |
|
537 |
} |
|
538 |
|
|
539 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.swing/org.gvsig.fmap.dal.swing.impl/src/main/java/org/gvsig/fmap/dal/swing/impl/visualdbmodeler/TableDescriptorImpl.java | ||
---|---|---|
1 |
/* |
|
2 |
* To change this license header, choose License Headers in Project Properties. |
|
3 |
* To change this template file, choose Tools | Templates |
|
4 |
* and open the template in the editor. |
|
5 |
*/ |
|
6 |
package org.gvsig.fmap.dal.swing.impl.visualdbmodeler; |
|
7 |
|
|
8 |
import org.gvsig.fmap.dal.feature.EditableFeatureType; |
|
9 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
10 |
|
|
11 |
/** |
|
12 |
* |
|
13 |
* @author jjdelcerro |
|
14 |
*/ |
|
15 |
public class TableDescriptorImpl implements TableDescriptor { |
|
16 |
|
|
17 |
private final String repositoryId; |
|
18 |
private final String name; |
|
19 |
private EditableFeatureType type; |
|
20 |
|
|
21 |
public TableDescriptorImpl(String repositoryId, String name, FeatureType type) { |
|
22 |
this.name = name; |
|
23 |
this.repositoryId = repositoryId; |
|
24 |
if( type instanceof EditableFeatureType ) { |
|
25 |
this.type = (EditableFeatureType) type; |
|
26 |
} else { |
|
27 |
this.type = type.getEditable(); |
|
28 |
|
|
29 |
} |
|
30 |
} |
|
31 |
|
|
32 |
@Override |
|
33 |
public String getName() { |
|
34 |
return this.name; |
|
35 |
} |
|
36 |
|
|
37 |
@Override |
|
38 |
public String getRepositoryId() { |
|
39 |
return this.repositoryId; |
|
40 |
} |
|
41 |
|
|
42 |
@Override |
|
43 |
public EditableFeatureType getFeatureType() { |
|
44 |
return this.type; |
|
45 |
} |
|
46 |
|
|
47 |
@Override |
|
48 |
public String toString() { |
|
49 |
return this.name; |
|
50 |
} |
|
51 |
|
|
52 |
@Override |
|
53 |
public String getLabel() { |
|
54 |
return this.name; |
|
55 |
} |
|
56 |
|
|
57 |
@Override |
|
58 |
public TableDescriptor getValue() { |
|
59 |
return this; |
|
60 |
} |
|
61 |
|
|
62 |
|
|
63 |
} |
|
64 |
|
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.swing/org.gvsig.fmap.dal.swing.impl/src/main/java/org/gvsig/fmap/dal/swing/impl/visualdbmodeler/VisualdbmodelerView.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
|
|
3 |
<object classname="com.jeta.forms.store.memento.FormPackage"> |
|
4 |
<at name="fileversion"> |
|
5 |
<object classname="com.jeta.forms.store.memento.FormsVersion2"> |
|
6 |
<at name="major">2</at> |
|
7 |
<at name="minor">0</at> |
|
8 |
<at name="sub">0</at> |
|
9 |
</object> |
|
10 |
</at> |
|
11 |
<at name="form"> |
|
12 |
<object classname="com.jeta.forms.store.memento.FormMemento"> |
|
13 |
<super classname="com.jeta.forms.store.memento.ComponentMemento"> |
|
14 |
<at name="cellconstraints"> |
|
15 |
<object classname="com.jeta.forms.store.memento.CellConstraintsMemento"> |
|
16 |
<at name="column">1</at> |
|
17 |
<at name="row">1</at> |
|
18 |
<at name="colspan">1</at> |
|
19 |
<at name="rowspan">1</at> |
|
20 |
<at name="halign">default</at> |
|
21 |
<at name="valign">default</at> |
|
22 |
<at name="insets" object="insets">0,0,0,0</at> |
|
23 |
</object> |
|
24 |
</at> |
|
25 |
<at name="componentclass">com.jeta.forms.gui.form.FormComponent</at> |
|
26 |
</super> |
|
27 |
<at name="id">/home/jjdelcerro/datos/devel/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.swing/org.gvsig.fmap.dal.swing.impl/src/main/java/org/gvsig/fmap/dal/swing/impl/visualdbmodeler/VisualdbmodelerView.xml</at> |
|
28 |
<at name="rowspecs">CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,FILL:DEFAULT:GROW(1.0),CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE</at> |
|
29 |
<at name="colspecs">FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE</at> |
|
30 |
<at name="components"> |
|
31 |
<object classname="java.util.LinkedList"> |
|
32 |
<item > |
|
33 |
<at name="value"> |
|
34 |
<object classname="com.jeta.forms.store.memento.BeanMemento"> |
|
35 |
<super classname="com.jeta.forms.store.memento.ComponentMemento"> |
|
36 |
<at name="cellconstraints"> |
|
37 |
<object classname="com.jeta.forms.store.memento.CellConstraintsMemento"> |
|
38 |
<at name="column">2</at> |
|
39 |
<at name="row">4</at> |
|
40 |
<at name="colspan">1</at> |
|
41 |
<at name="rowspan">1</at> |
|
42 |
<at name="halign">default</at> |
|
43 |
<at name="valign">default</at> |
|
44 |
<at name="insets" object="insets">0,0,0,0</at> |
|
45 |
</object> |
|
46 |
</at> |
|
47 |
<at name="componentclass">com.jeta.forms.gui.form.StandardComponent</at> |
|
48 |
</super> |
|
49 |
<at name="jetabeanclass">com.jeta.forms.gui.beans.JETABean</at> |
|
50 |
<at name="beanclass">javax.swing.JList</at> |
|
51 |
<at name="beanproperties"> |
|
52 |
<object classname="com.jeta.forms.store.memento.PropertiesMemento"> |
|
53 |
<at name="classname">javax.swing.JList</at> |
|
54 |
<at name="properties"> |
|
55 |
<object classname="com.jeta.forms.store.support.PropertyMap"> |
|
56 |
<at name="border"> |
|
57 |
<object classname="com.jeta.forms.store.properties.CompoundBorderProperty"> |
|
58 |
<super classname="com.jeta.forms.store.properties.BorderProperty"> |
|
59 |
<at name="name">border</at> |
|
60 |
</super> |
|
61 |
<at name="borders"> |
|
62 |
<object classname="java.util.LinkedList"> |
|
63 |
<item > |
|
64 |
<at name="value"> |
|
65 |
<object classname="com.jeta.forms.store.properties.DefaultBorderProperty"> |
|
66 |
<super classname="com.jeta.forms.store.properties.BorderProperty"> |
|
67 |
<at name="name">border</at> |
|
68 |
</super> |
|
69 |
</object> |
|
70 |
</at> |
|
71 |
</item> |
|
72 |
</object> |
|
73 |
</at> |
|
74 |
</object> |
|
75 |
</at> |
|
76 |
<at name="scrollableTracksViewportHeight">true</at> |
|
77 |
<at name="scrollableTracksViewportWidth">true</at> |
|
78 |
<at name="name">lstTables</at> |
|
79 |
<at name="width">78</at> |
|
80 |
<at name="items"> |
|
81 |
<object classname="com.jeta.forms.store.properties.ItemsProperty"> |
|
82 |
<at name="name">items</at> |
|
83 |
</object> |
|
84 |
</at> |
|
85 |
<at name="scollBars"> |
|
86 |
<object classname="com.jeta.forms.store.properties.ScrollBarsProperty"> |
|
87 |
<at name="name">scollBars</at> |
|
88 |
<at name="verticalpolicy">20</at> |
|
89 |
<at name="horizontalpolicy">30</at> |
|
90 |
<at name="border"> |
|
91 |
<object classname="com.jeta.forms.store.properties.CompoundBorderProperty"> |
|
92 |
<super classname="com.jeta.forms.store.properties.BorderProperty"> |
|
93 |
<at name="name">border</at> |
|
94 |
</super> |
|
95 |
<at name="borders"> |
|
96 |
<object classname="java.util.LinkedList"> |
|
97 |
<item > |
|
98 |
<at name="value"> |
|
99 |
<object classname="com.jeta.forms.store.properties.DefaultBorderProperty"> |
|
100 |
<super classname="com.jeta.forms.store.properties.BorderProperty"> |
|
101 |
<at name="name">border</at> |
|
102 |
</super> |
|
103 |
</object> |
|
104 |
</at> |
|
105 |
</item> |
|
106 |
</object> |
|
107 |
</at> |
|
108 |
</object> |
|
109 |
</at> |
|
110 |
</object> |
|
111 |
</at> |
|
112 |
<at name="height">828</at> |
|
113 |
</object> |
|
114 |
</at> |
|
115 |
</object> |
|
116 |
</at> |
|
117 |
</object> |
|
118 |
</at> |
|
119 |
</item> |
|
120 |
<item > |
|
121 |
<at name="value"> |
|
122 |
<object classname="com.jeta.forms.store.memento.BeanMemento"> |
|
123 |
<super classname="com.jeta.forms.store.memento.ComponentMemento"> |
|
124 |
<at name="cellconstraints"> |
|
125 |
<object classname="com.jeta.forms.store.memento.CellConstraintsMemento"> |
|
126 |
<at name="column">4</at> |
|
127 |
<at name="row">4</at> |
|
128 |
<at name="colspan">1</at> |
|
129 |
<at name="rowspan">1</at> |
|
130 |
<at name="halign">default</at> |
|
131 |
<at name="valign">default</at> |
|
132 |
<at name="insets" object="insets">0,0,0,0</at> |
|
133 |
</object> |
|
134 |
</at> |
|
135 |
<at name="componentclass">com.jeta.forms.gui.form.FormContainerComponent</at> |
|
136 |
</super> |
|
137 |
<at name="jetabeanclass">com.jeta.forms.gui.beans.JETABean</at> |
|
138 |
<at name="beanclass">javax.swing.JTabbedPane</at> |
|
139 |
<at name="beanproperties"> |
|
140 |
<object classname="com.jeta.forms.store.memento.PropertiesMemento"> |
|
141 |
<at name="classname">javax.swing.JTabbedPane</at> |
|
142 |
<at name="properties"> |
|
143 |
<object classname="com.jeta.forms.store.support.PropertyMap"> |
|
144 |
<at name="border"> |
|
145 |
<object classname="com.jeta.forms.store.properties.CompoundBorderProperty"> |
|
146 |
<super classname="com.jeta.forms.store.properties.BorderProperty"> |
|
147 |
<at name="name">border</at> |
|
148 |
</super> |
|
149 |
<at name="borders"> |
|
150 |
<object classname="java.util.LinkedList"> |
|
151 |
<item > |
|
152 |
<at name="value"> |
|
153 |
<object classname="com.jeta.forms.store.properties.DefaultBorderProperty"> |
|
154 |
<super classname="com.jeta.forms.store.properties.BorderProperty"> |
|
155 |
<at name="name">border</at> |
|
156 |
</super> |
|
157 |
</object> |
|
158 |
</at> |
|
159 |
</item> |
|
160 |
</object> |
|
161 |
</at> |
|
162 |
</object> |
|
163 |
</at> |
|
164 |
<at name="name"></at> |
|
165 |
<at name="tabs"> |
|
166 |
<object classname="com.jeta.forms.store.properties.TabbedPaneProperties"> |
|
167 |
<at name="name">tabs</at> |
|
168 |
<at name="items"> |
|
169 |
<object classname="java.util.LinkedList"> |
|
170 |
<item > |
|
171 |
<at name="value"> |
|
172 |
<object classname="com.jeta.forms.store.properties.TabProperty"> |
|
173 |
<at name="name">tab</at> |
|
174 |
<at name="title">Default view</at> |
|
175 |
<at name="icon"> |
|
176 |
<object classname="com.jeta.forms.store.properties.IconProperty"> |
|
177 |
<at name="embedded">false</at> |
|
178 |
<at name="description"></at> |
|
179 |
<at name="width">0</at> |
|
180 |
<at name="height">0</at> |
|
181 |
</object> |
|
182 |
</at> |
|
183 |
<at name="form"> |
|
184 |
<object classname="com.jeta.forms.store.memento.FormMemento"> |
|
185 |
<super classname="com.jeta.forms.store.memento.ComponentMemento"> |
|
186 |
<at name="cellconstraints"> |
|
187 |
<object classname="com.jeta.forms.store.memento.CellConstraintsMemento"> |
|
188 |
<at name="column">1</at> |
|
189 |
<at name="row">1</at> |
|
190 |
<at name="colspan">1</at> |
|
191 |
<at name="rowspan">1</at> |
|
192 |
<at name="halign">default</at> |
|
193 |
<at name="valign">default</at> |
|
194 |
<at name="insets" object="insets">0,0,0,0</at> |
|
195 |
</object> |
|
196 |
</at> |
|
197 |
<at name="componentclass">com.jeta.forms.gui.form.FormComponent</at> |
|
198 |
</super> |
|
199 |
<at name="id">embedded.G124e0fc9Q1868e2336daKE7ffd</at> |
|
200 |
<at name="rowspecs">CENTER:2DLU:NONE,FILL:DEFAULT:GROW(1.0),CENTER:2DLU:NONE</at> |
|
201 |
<at name="colspecs">FILL:4DLU:NONE,FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE</at> |
|
202 |
<at name="components"> |
|
203 |
<object classname="java.util.LinkedList"> |
|
204 |
<item > |
|
205 |
<at name="value"> |
|
206 |
<object classname="com.jeta.forms.store.memento.BeanMemento"> |
|
207 |
<super classname="com.jeta.forms.store.memento.ComponentMemento"> |
|
208 |
<at name="cellconstraints"> |
|
209 |
<object classname="com.jeta.forms.store.memento.CellConstraintsMemento"> |
|
210 |
<at name="column">2</at> |
|
211 |
<at name="row">2</at> |
|
212 |
<at name="colspan">1</at> |
|
213 |
<at name="rowspan">1</at> |
|
214 |
<at name="halign">default</at> |
|
215 |
<at name="valign">default</at> |
|
216 |
<at name="insets" object="insets">0,0,0,0</at> |
|
217 |
</object> |
|
218 |
</at> |
|
219 |
<at name="componentclass">com.jeta.forms.gui.form.StandardComponent</at> |
|
220 |
</super> |
|
221 |
<at name="jetabeanclass">com.jeta.forms.gui.beans.JETABean</at> |
|
222 |
<at name="beanclass">javax.swing.JPanel</at> |
|
223 |
<at name="beanproperties"> |
|
224 |
<object classname="com.jeta.forms.store.memento.PropertiesMemento"> |
|
225 |
<at name="classname">javax.swing.JPanel</at> |
|
226 |
<at name="properties"> |
|
227 |
<object classname="com.jeta.forms.store.support.PropertyMap"> |
|
228 |
<at name="name">pnlDefaultView</at> |
|
229 |
<at name="width">1458</at> |
|
230 |
<at name="height">746</at> |
|
231 |
</object> |
|
232 |
</at> |
|
233 |
</object> |
|
234 |
</at> |
|
235 |
</object> |
|
236 |
</at> |
|
237 |
</item> |
|
238 |
</object> |
|
239 |
</at> |
|
240 |
<at name="properties"> |
|
241 |
<object classname="com.jeta.forms.store.memento.PropertiesMemento"> |
|
242 |
<at name="classname">com.jeta.forms.gui.form.GridView</at> |
|
243 |
<at name="properties"> |
|
244 |
<object classname="com.jeta.forms.store.support.PropertyMap"> |
|
245 |
<at name="border"> |
|
246 |
<object classname="com.jeta.forms.store.properties.CompoundBorderProperty"> |
|
247 |
<super classname="com.jeta.forms.store.properties.BorderProperty"> |
|
248 |
<at name="name">border</at> |
|
249 |
</super> |
|
250 |
<at name="borders"> |
|
251 |
<object classname="java.util.LinkedList"/> |
|
252 |
</at> |
|
253 |
</object> |
|
254 |
</at> |
|
255 |
<at name="name"></at> |
|
256 |
<at name="fill"> |
|
257 |
<object classname="com.jeta.forms.store.properties.effects.PaintProperty"> |
|
258 |
<at name="name">fill</at> |
|
259 |
</object> |
|
260 |
</at> |
|
261 |
<at name="scollBars"> |
|
262 |
<object classname="com.jeta.forms.store.properties.ScrollBarsProperty"> |
|
263 |
<at name="name">scollBars</at> |
|
264 |
<at name="verticalpolicy">21</at> |
|
265 |
<at name="horizontalpolicy">31</at> |
|
266 |
</object> |
|
267 |
</at> |
|
268 |
</object> |
|
269 |
</at> |
|
270 |
</object> |
|
271 |
</at> |
|
272 |
<at name="cellpainters"> |
|
273 |
<object classname="com.jeta.forms.store.support.Matrix"> |
|
274 |
<at name="rows"> |
|
275 |
<object classname="[Ljava.lang.Object;" size="3"> |
|
276 |
<at name="item" index="0"> |
|
277 |
<object classname="[Ljava.lang.Object;" size="3"/> |
|
278 |
</at> |
|
279 |
<at name="item" index="1"> |
|
280 |
<object classname="[Ljava.lang.Object;" size="3"/> |
|
281 |
</at> |
|
282 |
<at name="item" index="2"> |
|
283 |
<object classname="[Ljava.lang.Object;" size="3"/> |
|
284 |
</at> |
|
285 |
</object> |
|
286 |
</at> |
|
287 |
</object> |
|
288 |
</at> |
|
289 |
<at name="rowgroups"> |
|
290 |
<object classname="com.jeta.forms.store.memento.FormGroupSet"> |
|
291 |
<at name="groups"> |
|
292 |
<object classname="java.util.HashMap"/> |
|
293 |
</at> |
|
294 |
</object> |
|
295 |
</at> |
|
296 |
<at name="colgroups"> |
|
297 |
<object classname="com.jeta.forms.store.memento.FormGroupSet"> |
|
298 |
<at name="groups"> |
|
299 |
<object classname="java.util.HashMap"/> |
|
300 |
</at> |
|
301 |
</object> |
|
302 |
</at> |
|
303 |
</object> |
|
304 |
</at> |
|
305 |
</object> |
|
306 |
</at> |
|
307 |
</item> |
|
308 |
</object> |
|
309 |
</at> |
|
310 |
</object> |
|
311 |
</at> |
|
312 |
<at name="width">1501</at> |
|
313 |
<at name="height">830</at> |
|
314 |
</object> |
|
315 |
</at> |
|
316 |
</object> |
|
317 |
</at> |
|
318 |
</object> |
|
319 |
</at> |
|
320 |
</item> |
|
321 |
<item > |
|
322 |
<at name="value"> |
|
323 |
<object classname="com.jeta.forms.store.memento.BeanMemento"> |
|
324 |
<super classname="com.jeta.forms.store.memento.ComponentMemento"> |
|
325 |
<at name="cellconstraints"> |
|
326 |
<object classname="com.jeta.forms.store.memento.CellConstraintsMemento"> |
|
327 |
<at name="column">2</at> |
|
328 |
<at name="row">2</at> |
|
329 |
<at name="colspan">3</at> |
|
330 |
<at name="rowspan">1</at> |
|
331 |
<at name="halign">default</at> |
|
332 |
<at name="valign">default</at> |
|
333 |
<at name="insets" object="insets">0,0,0,0</at> |
|
334 |
</object> |
|
335 |
</at> |
|
336 |
<at name="componentclass">com.jeta.forms.gui.form.StandardComponent</at> |
|
337 |
</super> |
|
338 |
<at name="jetabeanclass">com.jeta.forms.gui.beans.JETABean</at> |
|
339 |
<at name="beanclass">javax.swing.JComboBox</at> |
|
340 |
<at name="beanproperties"> |
|
341 |
<object classname="com.jeta.forms.store.memento.PropertiesMemento"> |
|
342 |
<at name="classname">javax.swing.JComboBox</at> |
|
343 |
<at name="properties"> |
|
344 |
<object classname="com.jeta.forms.store.support.PropertyMap"> |
|
345 |
<at name="border"> |
|
346 |
<object classname="com.jeta.forms.store.properties.CompoundBorderProperty"> |
|
347 |
<super classname="com.jeta.forms.store.properties.BorderProperty"> |
|
348 |
<at name="name">border</at> |
|
349 |
</super> |
|
350 |
<at name="borders"> |
|
351 |
<object classname="java.util.LinkedList"> |
|
352 |
<item > |
|
353 |
<at name="value"> |
|
354 |
<object classname="com.jeta.forms.store.properties.DefaultBorderProperty"> |
|
355 |
<super classname="com.jeta.forms.store.properties.BorderProperty"> |
|
356 |
<at name="name">border</at> |
|
357 |
</super> |
|
358 |
</object> |
|
359 |
</at> |
|
360 |
</item> |
|
361 |
</object> |
|
362 |
</at> |
|
363 |
</object> |
|
364 |
</at> |
|
365 |
<at name="name">cboRepositories</at> |
|
366 |
<at name="width">1591</at> |
|
367 |
<at name="items"> |
|
368 |
<object classname="com.jeta.forms.store.properties.ItemsProperty"> |
|
369 |
<at name="name">items</at> |
|
370 |
</object> |
|
371 |
</at> |
|
372 |
<at name="height">22</at> |
|
373 |
</object> |
|
374 |
</at> |
|
375 |
</object> |
|
376 |
</at> |
|
377 |
</object> |
|
378 |
</at> |
|
379 |
</item> |
|
380 |
</object> |
|
381 |
</at> |
|
382 |
<at name="properties"> |
|
383 |
<object classname="com.jeta.forms.store.memento.PropertiesMemento"> |
|
384 |
<at name="classname">com.jeta.forms.gui.form.GridView</at> |
|
385 |
<at name="properties"> |
|
386 |
<object classname="com.jeta.forms.store.support.PropertyMap"> |
|
387 |
<at name="border"> |
|
388 |
<object classname="com.jeta.forms.store.properties.CompoundBorderProperty"> |
|
389 |
<super classname="com.jeta.forms.store.properties.BorderProperty"> |
|
390 |
<at name="name">border</at> |
|
391 |
</super> |
|
392 |
<at name="borders"> |
|
393 |
<object classname="java.util.LinkedList"/> |
|
394 |
</at> |
|
395 |
</object> |
|
396 |
</at> |
|
397 |
<at name="name"></at> |
|
398 |
<at name="fill"> |
|
399 |
<object classname="com.jeta.forms.store.properties.effects.PaintProperty"> |
|
400 |
<at name="name">fill</at> |
|
401 |
</object> |
|
402 |
</at> |
|
403 |
<at name="scollBars"> |
|
404 |
<object classname="com.jeta.forms.store.properties.ScrollBarsProperty"> |
|
405 |
<at name="name">scollBars</at> |
|
406 |
<at name="verticalpolicy">21</at> |
|
407 |
<at name="horizontalpolicy">31</at> |
|
408 |
<at name="border"> |
|
409 |
<object classname="com.jeta.forms.store.properties.CompoundBorderProperty"> |
|
410 |
<super classname="com.jeta.forms.store.properties.BorderProperty"> |
|
411 |
<at name="name">border</at> |
|
412 |
</super> |
|
413 |
<at name="borders"> |
|
414 |
<object classname="java.util.LinkedList"> |
|
415 |
<item > |
|
416 |
<at name="value"> |
|
417 |
<object classname="com.jeta.forms.store.properties.DefaultBorderProperty"> |
|
418 |
<super classname="com.jeta.forms.store.properties.BorderProperty"> |
|
419 |
<at name="name">border</at> |
|
420 |
</super> |
|
421 |
</object> |
|
422 |
</at> |
|
423 |
</item> |
|
424 |
</object> |
|
425 |
</at> |
|
426 |
</object> |
|
427 |
</at> |
|
428 |
</object> |
|
429 |
</at> |
|
430 |
</object> |
|
431 |
</at> |
|
432 |
</object> |
|
433 |
</at> |
|
434 |
<at name="cellpainters"> |
|
435 |
<object classname="com.jeta.forms.store.support.Matrix"> |
|
436 |
<at name="rows"> |
|
437 |
<object classname="[Ljava.lang.Object;" size="7"> |
|
438 |
<at name="item" index="0"> |
|
439 |
<object classname="[Ljava.lang.Object;" size="5"/> |
|
440 |
</at> |
|
441 |
<at name="item" index="1"> |
|
442 |
<object classname="[Ljava.lang.Object;" size="5"/> |
|
443 |
</at> |
|
444 |
<at name="item" index="2"> |
|
445 |
<object classname="[Ljava.lang.Object;" size="5"/> |
|
446 |
</at> |
|
447 |
<at name="item" index="3"> |
|
448 |
<object classname="[Ljava.lang.Object;" size="5"/> |
|
449 |
</at> |
|
450 |
<at name="item" index="4"> |
|
451 |
<object classname="[Ljava.lang.Object;" size="5"/> |
|
452 |
</at> |
|
453 |
<at name="item" index="5"> |
|
454 |
<object classname="[Ljava.lang.Object;" size="5"/> |
|
455 |
</at> |
|
456 |
<at name="item" index="6"> |
|
457 |
<object classname="[Ljava.lang.Object;" size="5"/> |
|
458 |
</at> |
|
459 |
</object> |
|
460 |
</at> |
|
461 |
</object> |
|
462 |
</at> |
|
463 |
<at name="rowgroups"> |
|
464 |
<object classname="com.jeta.forms.store.memento.FormGroupSet"> |
|
465 |
<at name="groups"> |
|
466 |
<object classname="java.util.HashMap"/> |
|
467 |
</at> |
|
468 |
</object> |
|
469 |
</at> |
|
470 |
<at name="colgroups"> |
|
471 |
<object classname="com.jeta.forms.store.memento.FormGroupSet"> |
|
472 |
<at name="groups"> |
|
473 |
<object classname="java.util.HashMap"/> |
|
474 |
</at> |
|
475 |
</object> |
|
476 |
</at> |
|
477 |
</object> |
|
478 |
</at> |
|
479 |
</object> |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.swing/org.gvsig.fmap.dal.swing.impl/src/main/java/org/gvsig/fmap/dal/swing/impl/visualdbmodeler/VisualdbmodelerView.java | ||
---|---|---|
1 |
package org.gvsig.fmap.dal.swing.impl.visualdbmodeler; |
|
2 |
|
|
3 |
import com.jeta.open.i18n.I18NUtils; |
|
4 |
import com.jgoodies.forms.layout.CellConstraints; |
|
5 |
import com.jgoodies.forms.layout.FormLayout; |
|
6 |
import java.awt.BorderLayout; |
|
7 |
import java.awt.ComponentOrientation; |
|
8 |
import java.awt.Container; |
|
9 |
import java.awt.Dimension; |
|
10 |
import javax.swing.Box; |
|
11 |
import javax.swing.ImageIcon; |
|
12 |
import javax.swing.JComboBox; |
|
13 |
import javax.swing.JFrame; |
|
14 |
import javax.swing.JList; |
|
15 |
import javax.swing.JPanel; |
|
16 |
import javax.swing.JScrollPane; |
|
17 |
import javax.swing.JTabbedPane; |
|
18 |
|
|
19 |
|
|
20 |
public class VisualdbmodelerView extends JPanel |
|
21 |
{ |
|
22 |
JList lstTables = new JList(); |
|
23 |
JTabbedPane jtabbedpane1 = new JTabbedPane(); |
|
24 |
JPanel pnlDefaultView = new JPanel(); |
|
25 |
JComboBox cboRepositories = new JComboBox(); |
|
26 |
|
|
27 |
/** |
|
28 |
* Default constructor |
|
29 |
*/ |
|
30 |
public VisualdbmodelerView() |
|
31 |
{ |
|
32 |
initializePanel(); |
|
33 |
} |
|
34 |
|
|
35 |
/** |
|
36 |
* Adds fill components to empty cells in the first row and first column of the grid. |
|
37 |
* This ensures that the grid spacing will be the same as shown in the designer. |
|
38 |
* @param cols an array of column indices in the first row where fill components should be added. |
|
39 |
* @param rows an array of row indices in the first column where fill components should be added. |
|
40 |
*/ |
|
41 |
void addFillComponents( Container panel, int[] cols, int[] rows ) |
|
42 |
{ |
|
43 |
Dimension filler = new Dimension(10,10); |
|
44 |
|
|
45 |
boolean filled_cell_11 = false; |
|
46 |
CellConstraints cc = new CellConstraints(); |
|
47 |
if ( cols.length > 0 && rows.length > 0 ) |
|
48 |
{ |
|
49 |
if ( cols[0] == 1 && rows[0] == 1 ) |
|
50 |
{ |
|
51 |
/** add a rigid area */ |
|
52 |
panel.add( Box.createRigidArea( filler ), cc.xy(1,1) ); |
|
53 |
filled_cell_11 = true; |
|
54 |
} |
|
55 |
} |
|
56 |
|
|
57 |
for( int index = 0; index < cols.length; index++ ) |
|
58 |
{ |
|
59 |
if ( cols[index] == 1 && filled_cell_11 ) |
|
60 |
{ |
|
61 |
continue; |
|
62 |
} |
|
63 |
panel.add( Box.createRigidArea( filler ), cc.xy(cols[index],1) ); |
|
64 |
} |
|
65 |
|
|
66 |
for( int index = 0; index < rows.length; index++ ) |
|
67 |
{ |
|
68 |
if ( rows[index] == 1 && filled_cell_11 ) |
|
69 |
{ |
|
70 |
continue; |
|
71 |
} |
|
72 |
panel.add( Box.createRigidArea( filler ), cc.xy(1,rows[index]) ); |
|
73 |
} |
|
74 |
|
|
75 |
} |
|
76 |
|
|
77 |
/** |
|
78 |
* Helper method to load an image file from the CLASSPATH |
|
79 |
* @param imageName the package and name of the file to load relative to the CLASSPATH |
|
80 |
* @return an ImageIcon instance with the specified image file |
|
81 |
* @throws IllegalArgumentException if the image resource cannot be loaded. |
|
82 |
*/ |
|
83 |
public ImageIcon loadImage( String imageName ) |
|
84 |
{ |
|
85 |
try |
|
86 |
{ |
|
87 |
ClassLoader classloader = getClass().getClassLoader(); |
|
88 |
java.net.URL url = classloader.getResource( imageName ); |
|
89 |
if ( url != null ) |
|
90 |
{ |
|
91 |
ImageIcon icon = new ImageIcon( url ); |
|
92 |
return icon; |
|
93 |
} |
|
94 |
} |
|
95 |
catch( Exception e ) |
|
96 |
{ |
|
97 |
e.printStackTrace(); |
|
98 |
} |
|
99 |
throw new IllegalArgumentException( "Unable to load image: " + imageName ); |
|
100 |
} |
|
101 |
|
|
102 |
/** |
|
103 |
* Method for recalculating the component orientation for |
|
104 |
* right-to-left Locales. |
|
105 |
* @param orientation the component orientation to be applied |
|
106 |
*/ |
|
107 |
public void applyComponentOrientation( ComponentOrientation orientation ) |
|
108 |
{ |
|
109 |
// Not yet implemented... |
|
110 |
// I18NUtils.applyComponentOrientation(this, orientation); |
|
111 |
super.applyComponentOrientation(orientation); |
|
112 |
} |
|
113 |
|
|
114 |
public JPanel createPanel() |
|
115 |
{ |
|
116 |
JPanel jpanel1 = new JPanel(); |
|
117 |
FormLayout formlayout1 = new FormLayout("FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE","CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,FILL:DEFAULT:GROW(1.0),CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE"); |
|
118 |
CellConstraints cc = new CellConstraints(); |
|
119 |
jpanel1.setLayout(formlayout1); |
|
120 |
|
|
121 |
lstTables.setName("lstTables"); |
|
122 |
JScrollPane jscrollpane1 = new JScrollPane(); |
|
123 |
jscrollpane1.setViewportView(lstTables); |
|
124 |
jscrollpane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); |
|
125 |
jscrollpane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); |
|
126 |
jpanel1.add(jscrollpane1,cc.xy(2,4)); |
|
127 |
|
|
128 |
jtabbedpane1.addTab("Default view",null,createPanel1()); |
|
129 |
jpanel1.add(jtabbedpane1,cc.xy(4,4)); |
|
130 |
|
|
131 |
cboRepositories.setName("cboRepositories"); |
|
132 |
jpanel1.add(cboRepositories,cc.xywh(2,2,3,1)); |
|
133 |
|
|
134 |
addFillComponents(jpanel1,new int[]{ 1,2,3,4,5 },new int[]{ 1,2,3,4,5,6,7 }); |
|
135 |
return jpanel1; |
|
136 |
} |
|
137 |
|
|
138 |
public JPanel createPanel1() |
|
139 |
{ |
|
140 |
JPanel jpanel1 = new JPanel(); |
|
141 |
FormLayout formlayout1 = new FormLayout("FILL:4DLU:NONE,FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE","CENTER:2DLU:NONE,FILL:DEFAULT:GROW(1.0),CENTER:2DLU:NONE"); |
|
142 |
CellConstraints cc = new CellConstraints(); |
|
143 |
jpanel1.setLayout(formlayout1); |
|
144 |
|
|
145 |
pnlDefaultView.setName("pnlDefaultView"); |
|
146 |
jpanel1.add(pnlDefaultView,cc.xy(2,2)); |
|
147 |
|
|
148 |
addFillComponents(jpanel1,new int[]{ 1,2,3 },new int[]{ 1,2,3 }); |
|
149 |
return jpanel1; |
|
150 |
} |
|
151 |
|
|
152 |
/** |
|
153 |
* Initializer |
|
154 |
*/ |
|
155 |
protected void initializePanel() |
|
156 |
{ |
|
157 |
setLayout(new BorderLayout()); |
|
158 |
add(createPanel(), BorderLayout.CENTER); |
|
159 |
} |
|
160 |
|
|
161 |
|
|
162 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.swing/org.gvsig.fmap.dal.swing.impl/src/main/java/org/gvsig/fmap/dal/swing/impl/visualdbmodeler/Visualdbmodeler.java | ||
---|---|---|
1 |
/* |
|
2 |
* To change this license header, choose License Headers in Project Properties. |
|
3 |
* To change this template file, choose Tools | Templates |
|
4 |
* and open the template in the editor. |
|
5 |
*/ |
|
6 |
package org.gvsig.fmap.dal.swing.impl.visualdbmodeler; |
|
7 |
|
|
8 |
import com.mxgraph.model.mxCell; |
|
9 |
import com.mxgraph.swing.mxGraphComponent; |
|
10 |
import com.mxgraph.util.mxRectangle; |
|
11 |
import com.mxgraph.view.mxCellState; |
|
12 |
import com.mxgraph.view.mxGraph; |
|
13 |
import java.awt.BorderLayout; |
|
14 |
import java.awt.Component; |
|
15 |
import java.awt.event.ActionEvent; |
|
16 |
import java.awt.event.MouseAdapter; |
|
17 |
import java.awt.event.MouseEvent; |
|
18 |
import java.util.ArrayList; |
|
19 |
import java.util.List; |
|
20 |
import javax.swing.DefaultComboBoxModel; |
|
21 |
import javax.swing.DefaultListModel; |
|
22 |
import org.gvsig.fmap.dal.DALLocator; |
|
23 |
import org.gvsig.fmap.dal.DataManager; |
|
24 |
import org.gvsig.fmap.dal.StoresRepository; |
|
25 |
|
|
26 |
/** |
|
27 |
* |
|
28 |
* @author jjdelcerro |
|
29 |
*/ |
|
30 |
public class Visualdbmodeler extends VisualdbmodelerView { |
|
31 |
|
|
32 |
private SchemaGraphComponent schemaGraphComponent; |
|
33 |
|
|
34 |
public Visualdbmodeler() { |
|
35 |
this.initComponents(); |
|
36 |
} |
|
37 |
|
|
38 |
private void initComponents() { |
|
39 |
DataManager dataManager = DALLocator.getDataManager(); |
|
40 |
|
|
41 |
List<StoresRepository> repositories = new ArrayList<>(); |
|
42 |
for (StoresRepository repo : dataManager.getStoresRepository().getSubrepositories()) { |
|
43 |
repositories.add(repo); |
|
44 |
} |
|
45 |
repositories.sort((StoresRepository o1, StoresRepository o2) -> o1.getLabel().compareTo(o2.getLabel())); |
|
46 |
DefaultComboBoxModel<StoresRepository> model = new DefaultComboBoxModel<>(); |
|
47 |
for (StoresRepository repository : repositories) { |
|
48 |
model.addElement(repository); |
|
49 |
} |
|
50 |
this.cboRepositories.setModel(model); |
|
51 |
this.cboRepositories.addActionListener((ActionEvent e) -> { |
|
52 |
doChangeRepository(); |
|
53 |
}); |
|
54 |
|
|
55 |
this.lstTables.addMouseListener(new MouseAdapter() { |
|
56 |
@Override |
Also available in: Unified diff