/*
 * 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/>.
 *
 * 
 * 
 * ConcurrentEditingWarning.java
 *
 * Created on June 17, 2004, 11:40 AM
 */

package org.wandora.application;


import org.wandora.topicmap.Topic;
import org.wandora.topicmap.TopicMapException;


/**
 *
 * @author  olli
 */
public class ConcurrentEditingWarning extends javax.swing.JDialog {
	
	private static final long serialVersionUID = 1L;
	
    
    /** Creates new form ConcurrentEditingWarning */
    public ConcurrentEditingWarning(java.awt.Frame parent, boolean modal,Topic[] failed,Topic[] removed) {
        super(parent, modal);
        initComponents();
        StringBuffer buf=new StringBuffer();
        if(failed.length>0) buf.append("Edited:\n");
        try{
            for(int i=0;i<failed.length;i++){
                buf.append(failed[i].getBaseName()+" ("+failed[i].getSubjectIdentifiers().iterator().next()+")\n");
            }
            if(removed.length>0) buf.append("Removed:\n");
            for(int i=0;i<removed.length;i++){
                buf.append(removed[i].getBaseName()+" ("+removed[i].getSubjectIdentifiers().iterator().next()+")\n");
            }
        }catch(TopicMapException tme){
            tme.printStackTrace(); // TODO EXCEPTION
        }
        failedTextArea.setText(buf.toString());
        this.setSize(300,400);
    }
    
    /** 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() {
        jTextArea1 = new javax.swing.JTextArea();
        jPanel1 = new javax.swing.JPanel();
        okButton = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        failedTextArea = new javax.swing.JTextArea();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        jTextArea1.setEditable(false);
        jTextArea1.setLineWrap(true);
        jTextArea1.setText("Concurrent editing of topics detected. Following topics have been edited by you and somebody else at the same time. Fresh copies of these topics have been retrieved. You should now review that they have been merged properly and then either recommit your changes or roll back. Rolling back will cause you to lose whatever changes you have made but will fully preserve the changes of the other user. Topics listed under \"Edited\" have been edited by somebody else and topics under \"Removed\" have been removed. If you commit your changes, removed topics will be recreated unless you first remove them from your editing session. It may also be possible that this is the result of you modifying topic subject identifiers and no real concurrent editing happened. In this case just recommit your changes.");
        jTextArea1.setWrapStyleWord(true);
        jTextArea1.setOpaque(false);
        getContentPane().add(jTextArea1, java.awt.BorderLayout.NORTH);

        okButton.setText("OK");
        okButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                okButtonActionPerformed(evt);
            }
        });

        jPanel1.add(okButton);

        getContentPane().add(jPanel1, java.awt.BorderLayout.SOUTH);

        failedTextArea.setEditable(false);
        jScrollPane1.setViewportView(failedTextArea);

        getContentPane().add(jScrollPane1, java.awt.BorderLayout.CENTER);

        pack();
    }
    // </editor-fold>//GEN-END:initComponents

    private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed
        this.hide();
    }//GEN-LAST:event_okButtonActionPerformed
    
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextArea failedTextArea;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextArea jTextArea1;
    private javax.swing.JButton okButton;
    // End of variables declaration//GEN-END:variables
    
}
