svn-gvsig-desktop / 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 / featureform / swing / impl / dynformfield / JDynFormFieldFeaturesTableLink.java @ 42775
History | View | Annotate | Download (4.62 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2013 gvSIG Association.
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or modify it under
|
7 |
* the terms of the GNU General Public License as published by the Free Software
|
8 |
* Foundation; either version 3 of the License, or (at your option) any later
|
9 |
* version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful, but WITHOUT
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
13 |
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
14 |
* details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License along with
|
17 |
* this program; if not, write to the Free Software Foundation, Inc., 51
|
18 |
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
19 |
*
|
20 |
* For any additional information, do not hesitate to contact us at info AT
|
21 |
* gvsig.com, or visit our website www.gvsig.com.
|
22 |
*/
|
23 |
package org.gvsig.featureform.swing.impl.dynformfield; |
24 |
|
25 |
import java.awt.BorderLayout; |
26 |
import java.awt.Dimension; |
27 |
import javax.swing.JPanel; |
28 |
import org.gvsig.fmap.dal.feature.paging.FacadeOfAFeaturePagingHelper; |
29 |
import org.gvsig.fmap.dal.feature.paging.FeaturePagingHelper; |
30 |
import org.gvsig.fmap.dal.swing.DALSwingLocator; |
31 |
import org.gvsig.fmap.dal.swing.FeatureTableModel; |
32 |
import org.gvsig.fmap.dal.swing.JFeatureTable; |
33 |
|
34 |
import org.gvsig.tools.dynform.JDynFormField; |
35 |
import org.gvsig.tools.dynform.spi.dynformfield.AbstractJDynFormField; |
36 |
import org.gvsig.tools.dynobject.DynObject; |
37 |
import org.gvsig.tools.service.spi.ServiceManager; |
38 |
|
39 |
public class JDynFormFieldFeaturesTableLink extends AbstractJDynFormField implements JDynFormField { |
40 |
|
41 |
private FacadeOfAFeaturePagingHelper assignedValue = null; |
42 |
private FacadeOfAFeaturePagingHelper value = null; |
43 |
private FeatureTableModel featureTableMode;
|
44 |
private JFeatureTable featureTable;
|
45 |
|
46 |
/**
|
47 |
*
|
48 |
* @param parameters
|
49 |
* @param serviceManager
|
50 |
*/
|
51 |
public JDynFormFieldFeaturesTableLink(DynObject parameters,
|
52 |
ServiceManager serviceManager) { |
53 |
super(parameters, serviceManager);
|
54 |
if (this.getParameterValue() != null) { |
55 |
this.assignedValue = (FacadeOfAFeaturePagingHelper) this.getParameterValue(); |
56 |
} |
57 |
} |
58 |
|
59 |
@Override
|
60 |
public Object getAssignedValue() { |
61 |
return this.assignedValue; |
62 |
} |
63 |
|
64 |
@Override
|
65 |
public void initComponent() { |
66 |
this.contents = new JPanel(); |
67 |
JPanel panel = (JPanel) this.contents; |
68 |
panel.setLayout(new BorderLayout()); |
69 |
if( assignedValue != null ) { |
70 |
FeaturePagingHelper featurePager = ((FacadeOfAFeaturePagingHelper)assignedValue).getFeaturePagingHelper(); |
71 |
this.featureTableMode = DALSwingLocator.getSwingManager().createFeatureTableModel(featurePager);
|
72 |
this.featureTable = DALSwingLocator.getSwingManager().createJFeatureTable(featureTableMode);
|
73 |
int height = this.getTagValueAsInt("DAL.ui.height", -1); |
74 |
if( height > 0 ) { |
75 |
Dimension dim = this.featureTable.asJComponent().getPreferredSize(); |
76 |
dim.height = height; |
77 |
this.featureTable.asJComponent().setPreferredSize(dim);
|
78 |
} |
79 |
panel.add(this.featureTable.asJComponent(), BorderLayout.CENTER); |
80 |
} |
81 |
this.setValue(this.assignedValue); |
82 |
} |
83 |
|
84 |
@Override
|
85 |
public void setValue(Object value) { |
86 |
this.clear();
|
87 |
if( value == null ) { |
88 |
return;
|
89 |
} |
90 |
this.value = (FacadeOfAFeaturePagingHelper) value;
|
91 |
JPanel panel = (JPanel) this.contents; |
92 |
FeaturePagingHelper featurePager = ((FacadeOfAFeaturePagingHelper)value).getFeaturePagingHelper(); |
93 |
this.featureTableMode = DALSwingLocator.getSwingManager().createFeatureTableModel(featurePager);
|
94 |
this.featureTable = DALSwingLocator.getSwingManager().createJFeatureTable(featureTableMode);
|
95 |
int height = this.getTagValueAsInt("DAL.ui.height", -1); |
96 |
if( height > 0 ) { |
97 |
Dimension dim = this.featureTable.asJComponent().getPreferredSize(); |
98 |
dim.height = height; |
99 |
this.featureTable.asJComponent().setPreferredSize(dim);
|
100 |
} |
101 |
panel.add(this.featureTable.asJComponent(), BorderLayout.CENTER); |
102 |
} |
103 |
|
104 |
@Override
|
105 |
public Object getValue() { |
106 |
return this.value; |
107 |
} |
108 |
|
109 |
@Override
|
110 |
public void fetch(DynObject container) { |
111 |
} |
112 |
|
113 |
@Override
|
114 |
public boolean hasValidValue() { |
115 |
return true; |
116 |
} |
117 |
|
118 |
@Override
|
119 |
public void clear() { |
120 |
this.value = null; |
121 |
this.featureTableMode = null; |
122 |
this.featureTable = null; |
123 |
JPanel panel = (JPanel) this.contents; |
124 |
panel.removeAll(); |
125 |
} |
126 |
} |