/*************************************************** * * cismet GmbH, Saarbruecken, Germany * * ... and it just works. * ****************************************************/ package de.cismet.cids.custom.switchon.objectrenderer; import org.apache.commons.lang.StringUtils; import java.util.ArrayList; import java.util.List; import javax.swing.DefaultListModel; import de.cismet.cids.custom.switchon.gui.utils.FastBindableReferenceComboFactory; import de.cismet.cids.custom.switchon.gui.utils.RendererTools; import de.cismet.cids.custom.switchon.gui.utils.ResourceUtils; import de.cismet.cids.custom.switchon.utils.Taggroups; import de.cismet.cids.dynamics.CidsBean; import de.cismet.cids.dynamics.CidsBeanStore; import de.cismet.cids.editors.DefaultCustomObjectEditor; /** * DOCUMENT ME! * * @author Gilles Baatz * @version $Revision$, $Date$ */ public class GeographicInformationPanel extends javax.swing.JPanel implements CidsBeanStore { //~ Static fields/initializers --------------------------------------------- private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger( GeographicInformationPanel.class); //~ Instance fields -------------------------------------------------------- private CidsBean resourceCidsBean; // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JComboBox cmbLocation; private javax.swing.Box.Filler filler1; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JPanel jPanel3; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JList lstCatchements; private javax.swing.JPanel pnlCatchments; private javax.swing.JPanel pnlMap; private de.cismet.cids.custom.switchon.gui.PreviewMapPanel previewMapPanel; private javax.swing.JTextField txtResolutions; private javax.swing.JTextField txtScales; private org.jdesktop.beansbinding.BindingGroup bindingGroup; // End of variables declaration//GEN-END:variables //~ Constructors ----------------------------------------------------------- /** * Creates new form GeographicInformationPanel. */ public GeographicInformationPanel() { initComponents(); RendererTools.makeReadOnly(txtResolutions); RendererTools.makeReadOnly(txtScales); RendererTools.makeReadOnly(cmbLocation); } //~ Methods ---------------------------------------------------------------- /** * This method is called from within the constructor to initialize the form. WARNING: Do NOT modify this code. The * content of this method is always regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { java.awt.GridBagConstraints gridBagConstraints; bindingGroup = new org.jdesktop.beansbinding.BindingGroup(); pnlMap = new javax.swing.JPanel(); previewMapPanel = new de.cismet.cids.custom.switchon.gui.PreviewMapPanel(); pnlCatchments = new javax.swing.JPanel(); jScrollPane1 = new javax.swing.JScrollPane(); lstCatchements = new javax.swing.JList(); jPanel3 = new javax.swing.JPanel(); jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); jLabel3 = new javax.swing.JLabel(); cmbLocation = FastBindableReferenceComboFactory.createTagsFastBindableReferenceComboBox(Taggroups.LOCATION); txtResolutions = new javax.swing.JTextField(); txtScales = new javax.swing.JTextField(); filler1 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 32767)); setLayout(new java.awt.GridBagLayout()); pnlMap.setBorder(javax.swing.BorderFactory.createTitledBorder( org.openide.util.NbBundle.getMessage( GeographicInformationPanel.class, "GeographicInformationPanel.pnlMap.border.title"))); // NOI18N pnlMap.setLayout(new java.awt.GridBagLayout()); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 1.0; gridBagConstraints.insets = new java.awt.Insets(10, 10, 10, 10); pnlMap.add(previewMapPanel, gridBagConstraints); previewMapPanel.setGeoFieldPropertyKey("spatialcoverage.geo_field"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; gridBagConstraints.weightx = 0.75; gridBagConstraints.weighty = 1.0; add(pnlMap, gridBagConstraints); pnlCatchments.setBorder(javax.swing.BorderFactory.createTitledBorder( org.openide.util.NbBundle.getMessage( GeographicInformationPanel.class, "GeographicInformationPanel.pnlCatchments.border.title"))); // NOI18N pnlCatchments.setLayout(new java.awt.GridBagLayout()); jScrollPane1.setMinimumSize(new java.awt.Dimension(0, 0)); jScrollPane1.setPreferredSize(new java.awt.Dimension(0, 0)); jScrollPane1.setViewportView(lstCatchements); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 1.0; gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5); pnlCatchments.add(jScrollPane1, gridBagConstraints); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 0; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; gridBagConstraints.weightx = 0.25; gridBagConstraints.weighty = 1.0; add(pnlCatchments, gridBagConstraints); pnlCatchments.setVisible(false); jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder( org.openide.util.NbBundle.getMessage( GeographicInformationPanel.class, "GeographicInformationPanel.jPanel3.border.title"))); // NOI18N jPanel3.setLayout(new java.awt.GridBagLayout()); org.openide.awt.Mnemonics.setLocalizedText( jLabel1, org.openide.util.NbBundle.getMessage( GeographicInformationPanel.class, "GeographicInformationPanel.jLabel1.text")); // NOI18N gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.insets = new java.awt.Insets(10, 10, 5, 5); jPanel3.add(jLabel1, gridBagConstraints); org.openide.awt.Mnemonics.setLocalizedText( jLabel2, org.openide.util.NbBundle.getMessage( GeographicInformationPanel.class, "GeographicInformationPanel.jLabel2.text")); // NOI18N gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 1; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.insets = new java.awt.Insets(5, 10, 5, 5); jPanel3.add(jLabel2, gridBagConstraints); org.openide.awt.Mnemonics.setLocalizedText( jLabel3, org.openide.util.NbBundle.getMessage( GeographicInformationPanel.class, "GeographicInformationPanel.jLabel3.text")); // NOI18N gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 2; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.insets = new java.awt.Insets(5, 10, 10, 5); jPanel3.add(jLabel3, gridBagConstraints); final org.jdesktop.beansbinding.Binding binding = org.jdesktop.beansbinding.Bindings.createAutoBinding( org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${cidsBean.location}"), cmbLocation, org.jdesktop.beansbinding.BeanProperty.create("selectedItem")); bindingGroup.addBinding(binding); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 0; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; gridBagConstraints.weightx = 1.0; gridBagConstraints.insets = new java.awt.Insets(10, 5, 5, 10); jPanel3.add(cmbLocation, gridBagConstraints); txtResolutions.setText(org.openide.util.NbBundle.getMessage( GeographicInformationPanel.class, "GeographicInformationPanel.txtResolutions.text")); // NOI18N gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 1; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.weightx = 1.0; gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 10); jPanel3.add(txtResolutions, gridBagConstraints); txtScales.setText(org.openide.util.NbBundle.getMessage( GeographicInformationPanel.class, "GeographicInformationPanel.txtScales.text")); // NOI18N gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 2; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.weightx = 1.0; gridBagConstraints.insets = new java.awt.Insets(5, 5, 10, 10); jPanel3.add(txtScales, gridBagConstraints); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 1; gridBagConstraints.gridwidth = 2; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; gridBagConstraints.weightx = 1.0; add(jPanel3, gridBagConstraints); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 2; gridBagConstraints.fill = java.awt.GridBagConstraints.VERTICAL; gridBagConstraints.weighty = 1.0; add(filler1, gridBagConstraints); bindingGroup.bind(); } // </editor-fold>//GEN-END:initComponents @Override public CidsBean getCidsBean() { return resourceCidsBean; } @Override public void setCidsBean(final CidsBean cidsBean) { bindingGroup.unbind(); if (cidsBean != null) { this.resourceCidsBean = cidsBean; DefaultCustomObjectEditor.setMetaClassInformationToMetaClassStoreComponentsInBindingGroup( bindingGroup, this.resourceCidsBean); bindingGroup.bind(); previewMapPanel.setCidsBean(cidsBean); initCatchmentsList(); initSpatialResolutionsAndScales(); } } /** * DOCUMENT ME! */ private void initCatchmentsList() { final DefaultListModel<CidsBean> listModel = new DefaultListModel<CidsBean>(); for (final CidsBean catchement : ResourceUtils.filterTagsOfResource(resourceCidsBean, Taggroups.CATCHMENTS)) { listModel.addElement(catchement); } lstCatchements.setModel(listModel); } /** * DOCUMENT ME! */ private void initSpatialResolutionsAndScales() { final List<String> resolutions = new ArrayList<String>(); final List<String> scales = new ArrayList<String>(); for (final CidsBean representation : resourceCidsBean.getBeanCollectionProperty("representation")) { final String resolution = (String)representation.getProperty("spatialresolution"); if (StringUtils.isNotBlank(resolution)) { resolutions.add(resolution); } final Integer spatialscale = (Integer)representation.getProperty("spatialscale"); if (spatialscale != null) { scales.add(spatialscale.toString()); } } txtResolutions.setText(StringUtils.join(resolutions, ", ")); txtScales.setText(StringUtils.join(scales, ", ")); } }