/* * 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.configuration.AbstractConfigurationObject; import org.constellation.configuration.DataSourceType; import org.constellation.configuration.WebdavContext; import org.openide.util.NbBundle; import javax.swing.*; /** * * @author guilhem */ public class JServiceWebDavPane extends JServiceEditionPane { private final WebdavContext configuration; /** * Creates new form JServiceWebDavPane * @param configuration */ public JServiceWebDavPane(final Object configuration) { this.configuration = (configuration instanceof WebdavContext) ? (WebdavContext) configuration : null; initComponents(); if (this.configuration != null) { this.guiDigestAllowedCheckBox.setSelected(this.configuration.isDigestAllowed()); this.guiHideFileCheckBox.setSelected(this.configuration.isHideDotFile()); this.guiTextContextPath.setText(this.configuration.getContextPath()); this.guiTextDefaultPage.setText(this.configuration.getDefaultPage()); if (this.configuration.getRootFile() != null) { this.guiTextRootFolder.setText(this.configuration.getRootFile().getPath()); } } } /** * 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() { jLabel1 = new JLabel(); guiTextRootFolder = new JTextField(); jLabel2 = new JLabel(); guiTextContextPath = new JTextField(); jLabel3 = new JLabel(); guiTextDefaultPage = new JTextField(); jLabel4 = new JLabel(); guiDigestAllowedCheckBox = new JCheckBox(); jLabel5 = new JLabel(); guiHideFileCheckBox = new JCheckBox(); jLabel1.setText(NbBundle.getMessage(JServiceWebDavPane.class, "rootFolder")); // NOI18N jLabel2.setText(NbBundle.getMessage(JServiceWebDavPane.class, "contextPath")); // NOI18N jLabel3.setText(NbBundle.getMessage(JServiceWebDavPane.class, "defaultPage")); // NOI18N jLabel4.setText(NbBundle.getMessage(JServiceWebDavPane.class, "digestAllowed")); // NOI18N jLabel5.setText(NbBundle.getMessage(JServiceWebDavPane.class, "hideDotFile")); // NOI18N GroupLayout layout = new GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addComponent(jLabel1) .addComponent(jLabel2) .addComponent(jLabel3) .addComponent(jLabel4) .addComponent(jLabel5)) .addGap(18, 18, 18) .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addComponent(guiTextRootFolder) .addComponent(guiTextContextPath) .addComponent(guiTextDefaultPage) .addComponent(guiDigestAllowedCheckBox, GroupLayout.DEFAULT_SIZE, 245, Short.MAX_VALUE) .addComponent(guiHideFileCheckBox, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(jLabel1) .addComponent(guiTextRootFolder, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(jLabel2) .addComponent(guiTextContextPath, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(jLabel3) .addComponent(guiTextDefaultPage, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(jLabel4, GroupLayout.PREFERRED_SIZE, 24, GroupLayout.PREFERRED_SIZE) .addComponent(guiDigestAllowedCheckBox)) .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(jLabel5, GroupLayout.PREFERRED_SIZE, 24, GroupLayout.PREFERRED_SIZE) .addComponent(guiHideFileCheckBox)) .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); }// </editor-fold>//GEN-END:initComponents // Variables declaration - do not modify//GEN-BEGIN:variables private JCheckBox guiDigestAllowedCheckBox; private JCheckBox guiHideFileCheckBox; private JTextField guiTextContextPath; private JTextField guiTextDefaultPage; private JTextField guiTextRootFolder; private JLabel jLabel1; private JLabel jLabel2; private JLabel jLabel3; private JLabel jLabel4; private JLabel jLabel5; // End of variables declaration//GEN-END:variables @Override public AbstractConfigurationObject getConfiguration() { final String contextPath = guiTextContextPath.getText(); if (contextPath != null && !contextPath.isEmpty()) { this.configuration.setContextPath(contextPath); } else { this.configuration.setContextPath(null); } final String defaultPage = guiTextDefaultPage.getText(); if (defaultPage != null && !defaultPage.isEmpty()) { this.configuration.setDefaultPage(defaultPage); } else { this.configuration.setDefaultPage(null); } final String rootFolder = guiTextRootFolder.getText(); if (rootFolder != null && !rootFolder.isEmpty()) { this.configuration.setRootFile(rootFolder); } else { this.configuration.setRootFile(null); } this.configuration.setDigestAllowed(guiDigestAllowedCheckBox.isSelected()); this.configuration.setHideDotFile(guiHideFileCheckBox.isSelected()); return configuration; } @Override public DataSourceType getDatasourceType() { throw new UnsupportedOperationException("Not supported on this panel."); } }