/* * Constellation - An open source and standard compliant SDI * http://www.constellation-sdi.org * * Copyright 2014 Geomatys. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.constellation.swing; import org.constellation.admin.service.ConstellationClient; import org.openide.util.Exceptions; import java.io.IOException; /** * * @author guilhem */ public class JUtilsPane extends javax.swing.JPanel { private final FrameDisplayer displayer; private final ConstellationClient cstlv2; /** * Creates new form JUtilsPane * @param cstl * @param displayer */ public JUtilsPane(final ConstellationClient cstlv2, final FrameDisplayer displayer) { initComponents(); if (displayer == null) { this.displayer = new DefaultFrameDisplayer(); } else { this.displayer = displayer; } this.cstlv2 = cstlv2; try { final String currentURL = cstlv2.admin.getProperty("services.url"); if (currentURL != null) { this.URLField.setText(currentURL); } } catch (IOException ex) { Exceptions.printStackTrace(ex); } } /** * 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() { epsgDbButton = new javax.swing.JButton(); jLabel1 = new javax.swing.JLabel(); URLField = new javax.swing.JTextField(); updatePropButton = new javax.swing.JButton(); org.openide.awt.Mnemonics.setLocalizedText(epsgDbButton, org.openide.util.NbBundle.getMessage(JUtilsPane.class, "buildEpsgDatabase")); // NOI18N epsgDbButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { epsgDbButtonActionPerformed(evt); } }); org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(JUtilsPane.class, "urlProperties")); // NOI18N org.openide.awt.Mnemonics.setLocalizedText(updatePropButton, org.openide.util.NbBundle.getMessage(JUtilsPane.class, "updateProperties")); // NOI18N updatePropButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { updatePropButtonActionPerformed(evt); } }); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(jLabel1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(URLField)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addGap(0, 223, Short.MAX_VALUE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(epsgDbButton, javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(updatePropButton, javax.swing.GroupLayout.Alignment.TRAILING)))) .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addComponent(epsgDbButton) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel1) .addComponent(URLField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(updatePropButton) .addContainerGap(185, Short.MAX_VALUE)) ); }// </editor-fold>//GEN-END:initComponents private void epsgDbButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_epsgDbButtonActionPerformed displayer.display(new JEpsgDbCreationPane()); }//GEN-LAST:event_epsgDbButtonActionPerformed private void updatePropButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_updatePropButtonActionPerformed final String currentURL = URLField.getText(); if (!currentURL.isEmpty()) { try { cstlv2.admin.setProperty("services.url", currentURL); } catch (IOException ex) { Exceptions.printStackTrace(ex); } } }//GEN-LAST:event_updatePropButtonActionPerformed // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JTextField URLField; private javax.swing.JButton epsgDbButton; private javax.swing.JLabel jLabel1; private javax.swing.JButton updatePropButton; // End of variables declaration//GEN-END:variables }