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

import java.io.File;
import java.util.*;
import org.netbeans.modules.cvsclient.FsCommandFactory;
import org.netbeans.lib.cvsclient.command.log.LogCommand;
import org.netbeans.lib.cvsclient.command.log.LogInformation;
import org.netbeans.modules.javacvs.commands.CvsLog;
/**
 *
 * @author  Milos Kleint
 */
public class LogDisplayer extends org.netbeans.modules.javacvs.events.CommandDisplayerAdapter {

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

    /**
     * this method is called after library's commands execution
     */
    public void showAfterEachExecute() {
        if (isDir) {
            LogTreeInfoPanel treePanel = (LogTreeInfoPanel)FsCommandFactory.findOpenDisplayer(
                    files[0], LogTreeInfoPanel.class, null);
            if (treePanel == null) {
                treePanel = new LogTreeInfoPanel(files[0], command);
            } else {
                treePanel.setCommand(command);
            }
            treePanel.setDataToDisplay(resultList);
            treePanel.displayOutputData();
            resultList = null; // clearing reference..
        }
    }
    
    /**
     * 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) {
        LogCommand statCom = (LogCommand)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
           LogInfoPanel panel = (LogInfoPanel)FsCommandFactory.findOpenDisplayer(
                                            fl, LogInfoPanel.class, null);
           if (panel == null) {
               panel = new LogInfoPanel(command);
           }
           LogInformation infoSt = (LogInformation)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.