Revision 33597
branches/v2_0_0_prep/applications/appgvSIG/src/org/gvsig/app/tools/swing/serv/field/date/JDateDynFieldComponentFactory.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
/* |
|
23 |
* AUTHORS (In addition to CIT): |
|
24 |
* 2010 Institute of New Imaging Technologies (INIT): |
|
25 |
* http://www.init.uji.es |
|
26 |
* Geographic Information research group: |
|
27 |
* http://www.geoinfo.uji.es |
|
28 |
* Universitat Jaume I, Spain |
|
29 |
*/ |
|
30 |
|
|
31 |
/** |
|
32 |
* |
|
33 |
*/ |
|
34 |
package org.gvsig.app.tools.swing.serv.field.date; |
|
35 |
|
|
36 |
import org.gvsig.tools.dataTypes.DataTypes; |
|
37 |
import org.gvsig.tools.dynobject.DynField; |
|
38 |
import org.gvsig.tools.service.ServiceException; |
|
39 |
import org.gvsig.tools.swing.api.dynobject.dynfield.JDynFieldComponent; |
|
40 |
import org.gvsig.tools.swing.api.dynobject.dynfield.JDynFieldComponentFactory; |
|
41 |
import org.gvsig.tools.swing.api.dynobject.dynfield.ValueField; |
|
42 |
|
|
43 |
/** |
|
44 |
* @author <a href="mailto:reinhold@uji.es">cmartin</a> |
|
45 |
* |
|
46 |
*/ |
|
47 |
public class JDateDynFieldComponentFactory extends org.gvsig.tools.swing.serv.field.component.date.JDateDynFieldComponentFactory implements JDynFieldComponentFactory { |
|
48 |
|
|
49 |
/** |
|
50 |
* |
|
51 |
*/ |
|
52 |
public JDateDynFieldComponentFactory() { |
|
53 |
super(); |
|
54 |
} |
|
55 |
|
|
56 |
/** |
|
57 |
* @param type |
|
58 |
*/ |
|
59 |
public JDateDynFieldComponentFactory(int type) { |
|
60 |
super(type); |
|
61 |
} |
|
62 |
|
|
63 |
/** |
|
64 |
* @param type |
|
65 |
* @param subType |
|
66 |
*/ |
|
67 |
public JDateDynFieldComponentFactory(int type, String subType) { |
|
68 |
super(type, subType); |
|
69 |
} |
|
70 |
|
|
71 |
|
|
72 |
public JDynFieldComponent createJDynFieldComponent(DynField dynField, |
|
73 |
ValueField parent) throws ServiceException { |
|
74 |
return new JDateDynFieldComponent(parent, dynField); |
|
75 |
} |
|
76 |
} |
branches/v2_0_0_prep/applications/appgvSIG/src/org/gvsig/app/tools/swing/serv/field/date/JDateDynFieldComponent.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
/* |
|
23 |
* AUTHORS (In addition to CIT): |
|
24 |
* 2010 Institute of New Imaging Technologies (INIT): |
|
25 |
* http://www.init.uji.es |
|
26 |
* Geographic Information research group: |
|
27 |
* http://www.geoinfo.uji.es |
|
28 |
* Universitat Jaume I, Spain |
|
29 |
*/ |
|
30 |
|
|
31 |
/** |
|
32 |
* |
|
33 |
*/ |
|
34 |
package org.gvsig.app.tools.swing.serv.field.date; |
|
35 |
|
|
36 |
import java.util.Date; |
|
37 |
import java.util.Locale; |
|
38 |
|
|
39 |
import org.gvsig.andami.PluginServices; |
|
40 |
import org.gvsig.tools.dynobject.DynField; |
|
41 |
import org.gvsig.tools.service.ServiceException; |
|
42 |
import org.gvsig.tools.swing.api.dynobject.dynfield.ValueField; |
|
43 |
import org.gvsig.tools.swing.serv.field.component.date.DateCalendarPicker; |
|
44 |
import org.gvsig.tools.swing.serv.field.component.date.JDateCalendarDynFieldComponent; |
|
45 |
|
|
46 |
/** |
|
47 |
* @author <a href="mailto:reinhold@uji.es">cmartin</a> |
|
48 |
* |
|
49 |
*/ |
|
50 |
public class JDateDynFieldComponent extends JDateCalendarDynFieldComponent { |
|
51 |
|
|
52 |
private Object window; |
|
53 |
private DateDynFieldPanel panel; |
|
54 |
|
|
55 |
public JDateDynFieldComponent(ValueField value, DynField dynField) |
|
56 |
throws ServiceException { |
|
57 |
super(value, dynField); |
|
58 |
} |
|
59 |
|
|
60 |
@Override |
|
61 |
protected void close() { |
|
62 |
PluginServices.getMDIManager().closeWindow(panel); |
|
63 |
} |
|
64 |
|
|
65 |
@Override |
|
66 |
protected DateCalendarPicker createCalendarPicker(Date date, Locale loc) { |
|
67 |
DateDynFieldPanel datePicker = new DateDynFieldPanel(date, loc); |
|
68 |
datePicker.setPreferredSize(datePicker.getWindowInfo().getMinimumSize()); |
|
69 |
return datePicker; |
|
70 |
} |
|
71 |
|
|
72 |
@Override |
|
73 |
protected void showDialog(DateCalendarPicker datePicker) { |
|
74 |
panel = (DateDynFieldPanel) datePicker; |
|
75 |
window = PluginServices.getMDIManager().addWindow(panel); |
|
76 |
close(); |
|
77 |
if (panel.isOkPressed()){ |
|
78 |
getDateField().setValue(datePicker.getSelectedDate()); |
|
79 |
} |
|
80 |
} |
|
81 |
|
|
82 |
} |
branches/v2_0_0_prep/applications/appgvSIG/src/org/gvsig/app/tools/swing/serv/field/date/DateDynFieldPanel.java | ||
---|---|---|
1 |
package org.gvsig.app.tools.swing.serv.field.date; |
|
2 |
|
|
3 |
import java.util.Date; |
|
4 |
import java.util.Locale; |
|
5 |
|
|
6 |
import org.gvsig.andami.PluginServices; |
|
7 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
|
8 |
import org.gvsig.andami.ui.mdiManager.WindowInfo; |
|
9 |
import org.gvsig.tools.swing.serv.field.component.date.DateCalendarPicker; |
|
10 |
|
|
11 |
|
|
12 |
public class DateDynFieldPanel extends DateCalendarPicker implements IWindow{ |
|
13 |
|
|
14 |
public DateDynFieldPanel(Date date) { |
|
15 |
super(date); |
|
16 |
} |
|
17 |
|
|
18 |
public DateDynFieldPanel(Date date, Locale loc) { |
|
19 |
super(date, loc); |
|
20 |
} |
|
21 |
|
|
22 |
public WindowInfo getWindowInfo() { |
|
23 |
WindowInfo m_ViewInfo = |
|
24 |
new WindowInfo(WindowInfo.MODALDIALOG | WindowInfo.RESIZABLE); |
|
25 |
m_ViewInfo.setTitle(PluginServices.getText(this, "select_date")); |
|
26 |
m_ViewInfo.setMinimumSize(new java.awt.Dimension(450, 410)); |
|
27 |
return m_ViewInfo; |
|
28 |
} |
|
29 |
|
|
30 |
public Object getWindowProfile() { |
|
31 |
return WindowInfo.DIALOG_PROFILE; |
|
32 |
} |
|
33 |
|
|
34 |
|
|
35 |
} |
branches/v2_0_0_prep/applications/appgvSIG/src/org/gvsig/app/tools/swing/serv/field/dynobject/CRSAndDateDynObjectTest.java | ||
---|---|---|
1 |
package org.gvsig.app.tools.swing.serv.field.dynobject; |
|
2 |
|
|
3 |
import org.cresques.cts.IProjection; |
|
4 |
|
|
5 |
import org.gvsig.fmap.crs.CRSFactory; |
|
6 |
import org.gvsig.fmap.dal.DataTypes; |
|
7 |
import org.gvsig.tools.ToolsLocator; |
|
8 |
import org.gvsig.tools.dynobject.DynObject; |
|
9 |
import org.gvsig.tools.dynobject.DynObjectManager; |
|
10 |
import org.gvsig.tools.dynobject.impl.DefaultDynClass; |
|
11 |
import org.gvsig.tools.service.ServiceException; |
|
12 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
|
13 |
import org.gvsig.tools.swing.api.dynobject.DynObjectModel; |
|
14 |
import org.gvsig.tools.swing.api.dynobject.DynObjectSwingManager; |
|
15 |
|
|
16 |
public class CRSAndDateDynObjectTest extends DefaultDynClass { |
|
17 |
|
|
18 |
public static final String DYNNAME = "AppDynObjectTest"; |
|
19 |
|
|
20 |
private static final String DYNDESCRIPTION = ""; |
|
21 |
|
|
22 |
private static DynObjectSwingManager swingManager = |
|
23 |
ToolsSwingLocator.getDynObjectSwingManager(); |
|
24 |
|
|
25 |
private static DynObjectManager dynManager = |
|
26 |
ToolsLocator.getDynObjectManager(); |
|
27 |
|
|
28 |
// |
|
29 |
/** |
|
30 |
* @param manager |
|
31 |
* @param name |
|
32 |
* @param description |
|
33 |
*/ |
|
34 |
public CRSAndDateDynObjectTest() { |
|
35 |
super(dynManager, DYNNAME, DYNDESCRIPTION); |
|
36 |
initDynClass(); |
|
37 |
} |
|
38 |
|
|
39 |
public static void registerDynObject() { |
|
40 |
ToolsLocator.getDynObjectManager().add(new CRSAndDateDynObjectTest()); |
|
41 |
} |
|
42 |
|
|
43 |
/** |
|
44 |
* @return |
|
45 |
*/ |
|
46 |
private void initDynClass() { |
|
47 |
// IProjection proj = null; |
|
48 |
// Iterator it = ProjectionPool.iterator(); |
|
49 |
// while(it.hasNext()){ |
|
50 |
// proj = (IProjection) it.next(); |
|
51 |
// if (proj.getAbrev().equals("EPSG:23030")){ |
|
52 |
// break; |
|
53 |
// } |
|
54 |
// } |
|
55 |
IProjection proj = CRSFactory.getCRS("EPSG:23030"); |
|
56 |
this.addDynField("srs").setMandatory(true).setType(DataTypes.CRS) |
|
57 |
.setDefaultFieldValue(proj); |
|
58 |
this.addDynField("date").setMandatory(true).setType(DataTypes.DATE); |
|
59 |
this.addDynField("time").setMandatory(true).setType(DataTypes.TIME); |
|
60 |
this.addDynField("timestamp").setMandatory(true).setType( |
|
61 |
DataTypes.TIMESTAMP); |
|
62 |
} |
|
63 |
|
|
64 |
/** |
|
65 |
* @return |
|
66 |
* @throws ServiceException |
|
67 |
*/ |
|
68 |
public DynObjectModel createDynModel() throws ServiceException { |
|
69 |
DynObjectModel model = swingManager.createEmptyDynObjectModel(this); |
|
70 |
model.add("SRS", "crs"); |
|
71 |
model.add("Date", "date"); |
|
72 |
model.add("Date", "time"); |
|
73 |
model.add("Date", "timestamp"); |
|
74 |
return model; |
|
75 |
} |
|
76 |
|
|
77 |
public DynObject createDynObject() throws ServiceException { |
|
78 |
return dynManager.createDynObject(this); |
|
79 |
} |
|
80 |
|
|
81 |
} |
Also available in: Unified diff