/*
 * WANDORA
 * Knowledge Extraction, Management, and Publishing Application
 * http://wandora.org
 * 
 * Copyright (C) 2004-2023 Wandora Team
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * 
 * OBOConfiguration.java
 *
 * Created on 10.7.2006, 12:39
 */

package org.wandora.application.tools.importers;


import org.wandora.application.gui.simple.SimpleButton;
import org.wandora.application.gui.simple.SimpleCheckBox;
import org.wandora.utils.swing.GuiTools;



/**
 * OBOConfiguration is a simple dialog used to acquire configuration for OBOImport and
 * OBOExport tools.
 * 
 * @author  akivela, olli
 */
public class OBOConfiguration extends javax.swing.JDialog {
	
	private static final long serialVersionUID = 1L;
	
	private boolean cancelled=true;
    
    /** Creates new form ImportConfiguration */
    public OBOConfiguration(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
        this.setTitle("OBO configuration");
        GuiTools.centerWindow(this,parent);
    }
    
    /** 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.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        java.awt.GridBagConstraints gridBagConstraints;

        collateSynonymsCheckBox = new SimpleCheckBox();
        descriptionTopicsCheckBox = new SimpleCheckBox();
        altIdSIsCheckBox = new SimpleCheckBox();
        scopedXrefsCheckBox = new SimpleCheckBox();
        processImports = new SimpleCheckBox();
        jPanel1 = new javax.swing.JPanel();
        okButton = new SimpleButton();
        cancelButton = new SimpleButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        getContentPane().setLayout(new java.awt.GridBagLayout());

        collateSynonymsCheckBox.setText("Collate similar synonyms (export)");
        collateSynonymsCheckBox.setMargin(new java.awt.Insets(0, 0, 0, 0));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(10, 10, 0, 10);
        getContentPane().add(collateSynonymsCheckBox, gridBagConstraints);

        descriptionTopicsCheckBox.setText("Make DBXref description topics (import)");
        descriptionTopicsCheckBox.setMargin(new java.awt.Insets(0, 0, 0, 0));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(5, 10, 0, 10);
        getContentPane().add(descriptionTopicsCheckBox, gridBagConstraints);

        altIdSIsCheckBox.setText("Make SI from alternative Id (import)");
        altIdSIsCheckBox.setActionCommand("Make SIs from alternative Ids (import)");
        altIdSIsCheckBox.setMargin(new java.awt.Insets(0, 0, 0, 0));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(5, 10, 0, 10);
        getContentPane().add(altIdSIsCheckBox, gridBagConstraints);

        scopedXrefsCheckBox.setText("Make scoped Xrefs (import)");
        scopedXrefsCheckBox.setMargin(new java.awt.Insets(0, 0, 0, 0));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(5, 10, 0, 10);
        getContentPane().add(scopedXrefsCheckBox, gridBagConstraints);

        processImports.setText("Process header imports (import)");
        processImports.setMargin(new java.awt.Insets(0, 0, 0, 0));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(5, 10, 5, 10);
        getContentPane().add(processImports, gridBagConstraints);

        jPanel1.setLayout(new java.awt.GridBagLayout());

        okButton.setText("OK");
        okButton.setMargin(new java.awt.Insets(2, 5, 2, 5));
        okButton.setPreferredSize(new java.awt.Dimension(70, 23));
        okButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                okButtonActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 5);
        jPanel1.add(okButton, gridBagConstraints);

        cancelButton.setText("Cancel");
        cancelButton.setMargin(new java.awt.Insets(2, 5, 2, 5));
        cancelButton.setPreferredSize(new java.awt.Dimension(70, 23));
        cancelButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cancelButtonActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 5);
        jPanel1.add(cancelButton, gridBagConstraints);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.fill = java.awt.GridBagConstraints.VERTICAL;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
        gridBagConstraints.insets = new java.awt.Insets(5, 10, 10, 10);
        getContentPane().add(jPanel1, gridBagConstraints);

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-329)/2, (screenSize.height-228)/2, 329, 228);
    }// </editor-fold>//GEN-END:initComponents

    private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed
        cancelled=true;
        this.setVisible(false);
    }//GEN-LAST:event_cancelButtonActionPerformed

    private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed
        cancelled=false;
        this.setVisible(false);
    }//GEN-LAST:event_okButtonActionPerformed
    
    public boolean wasCancelled(){return cancelled;}
    
    public int getOptions(){
        int options=0;
        if(collateSynonymsCheckBox.isSelected()) options+=1;
        if(descriptionTopicsCheckBox.isSelected()) options+=2;
        if(altIdSIsCheckBox.isSelected()) options+=4;
        if(scopedXrefsCheckBox.isSelected()) options+=8;
        if(processImports.isSelected()) options+=16;
        return options;
    }
    
    public void setOptions(int options){
        collateSynonymsCheckBox.setSelected((options&1)!=0);
        descriptionTopicsCheckBox.setSelected((options&2)!=0);
        altIdSIsCheckBox.setSelected((options&4)!=0);
        scopedXrefsCheckBox.setSelected((options&8)!=0);
        processImports.setSelected((options&16)!=0);
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JCheckBox altIdSIsCheckBox;
    private javax.swing.JButton cancelButton;
    private javax.swing.JCheckBox collateSynonymsCheckBox;
    private javax.swing.JCheckBox descriptionTopicsCheckBox;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JButton okButton;
    private javax.swing.JCheckBox processImports;
    private javax.swing.JCheckBox scopedXrefsCheckBox;
    // End of variables declaration//GEN-END:variables
    
}
