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

/**
 *
 * @author  Milos Kleint
 *
 */
import org.netbeans.modules.cvsclient.commands.*;
import org.netbeans.modules.cvsclient.FsCommandFactory;
import org.netbeans.modules.javacvs.commands.*;
import org.netbeans.lib.cvsclient.command.annotate.*;
import java.io.File;
import java.lang.reflect.Method;
import org.openide.util.NbBundle;
import javax.swing.JComponent;
import javax.swing.table.*;
import org.netbeans.modules.vcscore.ui.*;
import org.netbeans.modules.vcscore.util.table.*;


public class AnnotateInfoPanel implements PersistentCommandDisplayer {

     private AnnotatePanel panel;
    
     private CvsAnnotate annCommand;
     private AnnotateInformation info;
    /** Creates new AnnotateInfoPanel */
    public AnnotateInfoPanel(CvsAnnotate ann) {
        annCommand = ann;
        panel = new AnnotatePanel();
        createTableDefinition();
    }
    

    
  public void setData(AnnotateInformation info) {
      this.info = info;
      panel.clearAllLines();
      panel.setFileName(info.getFile().getAbsolutePath());
      AnnotateLine line = info.getFirstLine();
      if (line != null) {
          do {
              panel.addLine(line);
              line = info.getNextLine();
          } while (line != null);
      }
      panel.doRepaintAndSort();
  }
  
  private void createTableDefinition() {
// setting the model....
        Class classa = AnnotateLine.class;
        try {
            Method method0 = classa.getMethod("getLineNumInteger", null);    //NOI18N 
            Method method1 = classa.getMethod("getRevision", null);     //NOI18N
            Method method2 = classa.getMethod("getAuthor", null);     //NOI18N
            Method method3 = classa.getMethod("getDateString", null);     //NOI18N
            Method method4 = classa.getMethod("getContent", null);   //NOI18N
            panel.addLineNumColumnDefinition(method0, new IntegerComparator());
            panel.addRevisionColumnDefinition(method1, new RevisionComparator());
            panel.addAuthorColumnDefinition(method2, null);
            panel.addDateColumnDefinition(method3, new DateComparator());
            panel.addContentColumnDefinition(method4, null);
        } catch (NoSuchMethodException exc) {
            Thread.dumpStack();
        } catch (SecurityException exc2) {
            Thread.dumpStack();
        }
  }    

    
  /** Does the actual display - docking into the javacvs Mode, 
 *  displaying as single Dialog.. whatever.
 */
  public void displayOutputData() {
      String title = NbBundle.getMessage(AnnotateInfoPanel.class, "CvsAnnotate.dialogTitle", info.getFile().getName()); //NOI18N
      FsCommandFactory.displayOutputPanel(title, this);
  }  
  
  public File getFileDisplayed() {
      if (info == null) return null;
      return info.getFile();
  }
   
  public Object getComparisonData() {
      return info;
  }
   
  public JComponent getComponent() {
      return panel;
  }

   // --------------------------------------------
  // persistantDisplayer stuff..
  // --------------------------------------------
  
  public boolean equalDisplayedData(File file, Class type, Object comparisonData) {
      if (!getClass().equals(type)) return false;
      if (info == null || info.getFile() == null
                || !info.getFile().equals(file)) {
          return false;
      }
      return true;
  }

  public FileSystemCommand getFileSystemCommand() {
      return annCommand;
  }
  
  public String getCommandSwitches() {
      return annCommand.getCVSArguments();
  }
  public void closeNotify() {
      
  }

}
... 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.