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-2000 Sun
 * Microsystems, Inc. All Rights Reserved.
 */

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

import java.io.File;
import java.util.*;
import org.netbeans.modules.cvsclient.FsCommandFactory;
import org.netbeans.lib.cvsclient.command.status.StatusCommand;
import org.netbeans.lib.cvsclient.command.status.StatusInformation;
import org.netbeans.modules.javacvs.commands.CvsStatus;

/**
 *
 * @author  Milos Kleint
 */
public class StatusDisplayer extends org.netbeans.modules.javacvs.events.CommandDisplayerAdapter {

    private CvsStatus command;
    private boolean isDir = false;
    private File[] files;
    private LinkedList resultList;
    /** Creates new StatusDisplayer */
    public StatusDisplayer(CvsStatus comm) {
        command = comm;
    }

    /**
     * this method is called after library's commands execution
     */
    public void showAfterEachExecute() {
        if (isDir) {
            StatusTreeInfoPanel treePanel = (StatusTreeInfoPanel)FsCommandFactory.findOpenDisplayer(
                    files[0], StatusTreeInfoPanel.class, null);
            if (treePanel == null) {
                treePanel = new StatusTreeInfoPanel(files[0], command);
            } else {
                treePanel.setCommand(command);
            }
            treePanel.setDataToDisplay(resultList);
            treePanel.displayOutputData();
            resultList = null;
        }
    }
    
    /**
     * this method is called before any of the library's commands 
     * that is stored in the queue in FileSystemCommand, is run.
     * @param currentCommand shows the command that will be executed.
     */
    public void showBeforeEachExecute(org.netbeans.lib.cvsclient.command.Command currentCommand) {
        StatusCommand statCom = (StatusCommand)currentCommand;
        resultList = new LinkedList();
        files = statCom.getFiles();
        if (files[0].isDirectory()) {
            isDir = true;
        } else {
            isDir = false;
        }
    }
    
    /**
     * this one is called when the command's execution  fails for any reason.
     */
    public void showExecutionFailed(Exception exception) {
        command = null;
    }
    
    /**
     * When the library command's builder generates a FileInfoContainer object, the
     * Displayer is notified.
     * @param info - the generated information object
     */
    public void showFileInfoGenerated(org.netbeans.lib.cvsclient.command.FileInfoContainer info) {
        if (info == null) return;
        if (isDir) {
            resultList.add(info);
        } else {
           File fl = info.getFile();
           // find or create statusInfoPanel
           StatusInfoPanel panel = (StatusInfoPanel)FsCommandFactory.findOpenDisplayer(
                                            fl, StatusInfoPanel.class, null);
           if (panel == null) {
               panel = new StatusInfoPanel(command);
           }
           StatusInformation infoSt = (StatusInformation)info;
           panel.setData(infoSt);
           panel.displayOutputData();
        }
    }
    
    /**
     * This is the last method to be called in the displayer. 
     * Is called when the execution finishes. Any filan touchups can be made here.
     */
    public void showFinishedCommand() {
        command = null;
    }
    
    /**
     * This method is the first one that is called during execution.
     * Here any initial setup of the displayer can be made.
     */
    public void showStartCommand() {
    }
    
}
... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2024 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.