alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

What this is

This file is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Other links

The source code

/*
 *                 Sun Public License Notice
 *
 * The contents of this file are subject to the Sun Public License
 * Version 1.0 (the "License"). You may not use this file except in
 * compliance with the License. A copy of the License is available at
 * http://www.sun.com/
 *
 * The Original Code is NetBeans. The Initial Developer of the Original
 * Code is Sun Microsystems, Inc. Portions Copyright 1997-2003 Sun
 * Microsystems, Inc. All Rights Reserved.
 */

package org.netbeans.modules.cvsclient.commands.commit;

import org.netbeans.lib.cvsclient.event.MessageEvent;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import org.netbeans.lib.cvsclient.command.FileInfoContainer;
import org.netbeans.lib.cvsclient.command.Command;
import org.netbeans.lib.cvsclient.command.DefaultFileInfoContainer;
import java.util.*;
import org.netbeans.modules.cvsclient.commands.CommandChooser;
import org.netbeans.modules.cvsclient.commands.ChooserFinishEvent;
import org.netbeans.modules.cvsclient.commands.ChooserFinishListener;
import org.netbeans.modules.cvsclient.commands.AbstractTreeInfoPanel;
import org.openide.DialogDescriptor;
import org.openide.NotifyDescriptor;
import org.openide.util.NbBundle;
import java.awt.Dialog;
import java.awt.BorderLayout;
import org.netbeans.modules.javacvs.commands.CvsUpdate;
import org.netbeans.modules.javacvs.events.CommandDisplayerListener;
import org.netbeans.modules.javacvs.events.CommandErrorEvent;
import org.netbeans.modules.javacvs.events.CommandErrorListener;
import org.openide.DialogDisplayer;


/**
 *
 * @author  mkleint
 * @version 
 */
public class CommitMessageChooser extends AbstractTreeInfoPanel implements CommandChooser, CommandDisplayerListener, CommandErrorListener   {

    private ArrayList listeners;
    boolean finished;
    private JPanel messagePanel;
    private JTextArea messageText; // gets set up during the createMessageArea method
    private JTextArea generalText;
    private JPanel clearPanel;
    private JPanel loadingPanel;
    private JPanel mainPanel;
    private DefaultFileInfoContainer currentInfo;
    private HashMap messageMap;
    private LinkedList infoList;
    private DialogDescriptor dd;
    private Dialog dial;
    private CvsUpdate comm;
    private boolean forceCommit = false;
    private Collection dataCollection;
    
    /** Creates new CommitMessageChooser */
    public CommitMessageChooser(CvsUpdate usedCommand) {
        super();
        disableTree();
        messagePanel = createMessageArea();
        clearPanel = createClearPanel();
        loadingPanel = createLoadingPanel();
        messageMap = new HashMap();
        comm = usedCommand; 
        postInit();
    }
    
    public void setForceCommit(boolean force) {
        forceCommit = force;
    }

    public boolean isForceCommit() {
        return forceCommit;
    }
    
    public void setGeneralMessage(String message) {
        generalText.setText(message);
    }

    /** this method should be used with Choosers to display the dialog.. 
     * then later the displayOutputData will just present the datat gotten from server
     * Reason: to have something displayer right away..
     * This method is to be called when creating the command and Chooser.
     */
    public void displayFrameWork() {
        setDataToDisplay(new LinkedList());
        String title = NbBundle.getBundle(CommitMessageChooser.class).getString("CommitMessageChooser.title"); //NOI18N
        dd = new DialogDescriptor(this, title);
        Object[] option = new Object[1];
        option[0] = DialogDescriptor.CANCEL_OPTION;
        dd.setOptions(option);
        dd.setClosingOptions(option);
        dd.setButtonListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                buttonWasPressed(evt);
            }
        });
        javax.swing.SwingUtilities.invokeLater(new Runnable () {
            public void run () {
               dial = DialogDisplayer.getDefault().createDialog(dd);
               dial.setModal(false);
               dial.show();
            }
        });        
    }

    
    public void displayOutputData() {
        LinkedList copy = new LinkedList(dataCollection);
        setDataToDisplay(copy);
        Object[] option = new Object[2];
        setClearPanel();
        option[0] = DialogDescriptor.OK_OPTION;
        option[1] = DialogDescriptor.CANCEL_OPTION;
        dd.setOptions(option);
        dd.setClosingOptions(option);
        dd.setMessage(this);
        finished = true;
    }
    
    public void redisplay() {
/*        LinkedList copy = new LinkedList(dataCollection);
        String title = NbBundle.getBundle(CommitMessageChooser.class).getString("CommitMessageChooser.title");
        dd = new DialogDescriptor(this, title);
        dd.setButtonListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                buttonWasPressed(evt);
            }
        });
        setDataToDisplay(copy);
        Object[] option = new Object[2];
        setClearPanel();
        option[0] = DialogDescriptor.OK_OPTION;
        option[1] = DialogDescriptor.CANCEL_OPTION;
        dd.setOptions(option);
        dd.setClosingOptions(option);
        dd.setMessage(this);
 */
        finished = true;
        javax.swing.SwingUtilities.invokeLater(new Runnable () {
            public void run () {
//               dial = TopManager.getDefault().createDialog(dd);
               dial.setModal(false);
               dial.show();
            }
        });        
        
    }
    
    public void addChooserFinishListener(ChooserFinishListener chooserListener) {    
        if (listeners == null) {
            listeners = new ArrayList ();
        }
        listeners.add (chooserListener);
    }    
    
    /** used for checking wheather the command finished successfully and can be redisplayed without running the command again
     */
    public boolean wasFinished() {
        return finished;
    }

    public void removeChooserFinishListener(ChooserFinishListener chooserListener) {
        if (listeners != null) {
            listeners.remove (chooserListener);
        }            
    }
    
    private void fireChooserFinishListener() {
        ArrayList list;
        synchronized (this) {
            list = (ArrayList) this.listeners.clone();
        }
        ChooserFinishEvent event = new ChooserFinishEvent(this);
        
        for (int i=0; i
... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.