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.checkout;

import javax.swing.JPanel;
import javax.swing.JButton;
import javax.swing.JLabel;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import org.netbeans.modules.javacvs.commands.FileSystemCommand;
import org.netbeans.lib.cvsclient.command.FileInfoContainer;
import java.util.ArrayList;
import java.util.Collection;
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.customizer.NbJavaCvsCustomizer;
import org.openide.DialogDescriptor;
import org.openide.NotifyDescriptor;
import org.openide.util.NbBundle;
import org.netbeans.modules.javacvs.commands.CvsCheckout;
import org.netbeans.modules.javacvs.commands.CvsCompleteModList;
import java.awt.Dialog;
import org.netbeans.modules.javacvs.events.CommandErrorEvent;
import org.netbeans.modules.javacvs.events.CommandErrorListener;
import org.openide.DialogDisplayer;

/**
 *
 * @author  mkleint
 * @version 
 */




class ModuleChooser extends ModulesListPanel implements CommandChooser, CommandErrorListener {

      private ArrayList listeners;
      private FileSystemCommand comm;
      private String returnValue;
      private DialogDescriptor dd;
      private Dialog dial;
      private boolean finished;
      private JButton btnOk;
      private int returnInt;
      
      public ModuleChooser(CvsCompleteModList command) {
          super();
          finished = false;
          comm = command;
      }

      public ModuleChooser(CvsCheckout command) {
          super();
          finished = false;
          comm = command;
      }
      
      
     /** in this method the displayer should use the data returned by the command to
     * produce it's own data structures/ fill in UI components
     * @param resultList - the data from the command. It is assumed the Displayer 
     *  knows what command the data comes from and most important in what format. 
     * (which FileInfoContainer class is used).
     */
    public void setDataToDisplay(Collection resultList) {
        super.setDataToDisplay(resultList);
    }
    
   /** 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() {
        if (dial != null) {
            dial.pack();
            NbJavaCvsCustomizer.centerWindow(dial);
            javax.swing.SwingUtilities.invokeLater(new Runnable () {
                public void run () {
                    dial.show();
                }
            });
            return;
        }
        String title = NbBundle.getBundle(ModuleChooser.class).getString("ModuleChooser.title"); //NOI18N
        JPanel panel = new JPanel();
        String warning = NbBundle.getBundle(ModuleChooser.class).getString("ModuleChooser.loading"); //NOI18N
        panel.add(new JLabel(warning));
        dd = new DialogDescriptor(panel, title);
        Object[] option = new Object[1];
        option[0] = DialogDescriptor.CANCEL_OPTION;
        dd.setOptions(option);
        dd.setClosingOptions(option);
        dd.setModal(true);
        dd.setButtonListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                buttonWasPressed(evt);
            }
        });
        dial = DialogDisplayer.getDefault().createDialog(dd);
        dial.pack();
        NbJavaCvsCustomizer.centerWindow(dial);
        javax.swing.SwingUtilities.invokeLater(new Runnable () {
            public void run () {
               dial.show();
            }
        });        
/*        Thread thr = new Thread() {
            public void run() {
            }
        };
        thr.start();
 */
    }
    
    /** displays the info retrieved from server
     * 
     */
    public void displayOutputData() {
        Object[] option = new Object[2];
        
        btnOk = new JButton(NbBundle.getBundle(ModuleChooser.class)
                          .getString("ModuleChooser.okButton")); //NOI18N
        btnOk.setDefaultCapable(true);
        dd.setValue(btnOk);
        option[0] = btnOk;
        option[1] = DialogDescriptor.CANCEL_OPTION;
        dd.setOptions(option);
        dd.setClosingOptions(option);
        if (dial != null) {
            dd.setMessage(this);
//            NbJavaCvsCustomizer.centerWindow(dial);
            dial.pack();
        } else {
//            System.out.println("//should actually not happen..");
            dd.setMessage(this);
        }
        finished = true;
    }
    
    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 boolean isShowingDial() {
        if (dial != null && dial.isVisible()) return true;
        return false;
    }

    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.