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

import javax.swing.JPanel;
import javax.swing.JComponent;
import org.netbeans.modules.cvsclient.NbJavaCvsStatusManager;
import org.netbeans.modules.cvsclient.FsCommandFactory;
import org.netbeans.modules.cvsclient.commands.status.StatusInfoPanel.ExtendedRevisionComparator;
import org.netbeans.modules.vcscore.util.table.*;
import org.netbeans.modules.javacvs.commands.FileSystemCommand;
import org.netbeans.modules.javacvs.events.*;
import java.io.File;
import org.netbeans.modules.vcscore.util.Debug;
import org.netbeans.modules.cvsclient.commands.*;
import java.lang.reflect.Method;
import org.openide.util.NbBundle;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Color;
import org.netbeans.modules.javacvs.*;
import org.netbeans.modules.javacvs.commands.*;
import org.netbeans.lib.cvsclient.command.status.StatusInformation;
import org.netbeans.lib.cvsclient.command.FileInfoContainer;
import javax.accessibility.*;

import java.util.ResourceBundle;
import org.netbeans.lib.cvsclient.file.FileStatus;
import org.netbeans.modules.cvsclient.commands.diff.*;
import org.netbeans.modules.cvsclient.NbJavaCvsFileSystem;
import org.netbeans.modules.cvsclient.IndependantClient;
import org.netbeans.modules.cvsclient.NbJavaCvsStatusManager;

/**
 *
 * @author  mkleint
 * @version
 */
public class StatusInfoPanel extends JPanel implements PersistentCommandDisplayer {
    
    Color oldColor;
    private StatusInformation statusInfo;
    private CvsStatus defaultCommand;
    
    private GridBagConstraints spExistingTagsConstraints;
    private GridBagConstraints lblExistingTagsConstraints;
    private GridBagLayout gridBag;
    private TableInfoModel model;
    /** Creates new form StatusInfoPanel */
    public StatusInfoPanel(CvsStatus currentCommand) {
        initComponents ();
        initAccessibility();        
        lblRepFile.setLabelFor (txRepFile);
        btnDiff.setMnemonic (NbBundle.getBundle(StatusInfoPanel.class).getString("StatusInfoPanel.btnDiff.mnemonic").charAt(0)); // NOI18N
        btnAdvanced.setMnemonic (NbBundle.getBundle(StatusInfoPanel.class).getString("StatusInfoPanel.btnAdvanced.mnemonic").charAt(0)); // NOI18N        
        lblExistingTags.setLabelFor (tblExistingTags);

        oldColor = txRepRev.getForeground();
        defaultCommand = currentCommand;
        // after setting the components unvisible, the layout gets forgotten :(
        gridBag  = (GridBagLayout)getLayout();
        spExistingTagsConstraints = gridBag.getConstraints(spExistingTags);
        lblExistingTagsConstraints = gridBag.getConstraints(lblExistingTags);
        javax.swing.table.JTableHeader head = tblExistingTags.getTableHeader();
        head.setUpdateTableInRealTime(true);
        ColumnSortListener listen = new ColumnSortListener(tblExistingTags);
        head.addMouseListener(listen);
        setPreferredSize(new java.awt.Dimension(700, 450));
        setMinimumSize(new java.awt.Dimension(700, 450));        
      
      model = new TableInfoModel();
      Class classa = StatusInformation.SymName.class;
      String  column1 = NbBundle.getBundle(StatusInfoPanel.class).getString("StatusInfoPanel.SymNamesColumn"); // NOI18N
      String  column2 = NbBundle.getBundle(StatusInfoPanel.class).getString("StatusInfoPanel.Rev2Column"); // NOI18N
      try {
          Method method1 = classa.getMethod("getTag", null); // NOI18N
          Method method2 = classa.getMethod("getRevision", null); // NOI18N
          model.setColumnDefinition(0, column1, method1, true, null);
          model.setColumnDefinition(1, column2, method2, true, new ExtendedRevisionComparator());
      } catch (NoSuchMethodException exc) {
          Thread.dumpStack();
      } catch (SecurityException exc2) {
          Thread.dumpStack();
      }
      tblExistingTags.setModel(model);
        
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the FormEditor.
     */
    private void initComponents() {//GEN-BEGIN:initComponents
        java.awt.GridBagConstraints gridBagConstraints;

        lblFileName = new javax.swing.JLabel();
        lblStatus = new javax.swing.JLabel();
        lblRepFile = new javax.swing.JLabel();
        txRepFile = new javax.swing.JTextField();
        lblWorkRev = new javax.swing.JLabel();
        lblRepRev = new javax.swing.JLabel();
        btnDiff = new javax.swing.JButton();
        lblTag = new javax.swing.JLabel();
        lblOptions = new javax.swing.JLabel();
        lblDate = new javax.swing.JLabel();
        spExistingTags = new javax.swing.JScrollPane();
        tblExistingTags = new javax.swing.JTable();
        lblExistingTags = new javax.swing.JLabel();
        btnAdvanced = new javax.swing.JButton();
        txFileName = new javax.swing.JTextField();
        txStatus = new javax.swing.JTextField();
        txWorkRev = new javax.swing.JTextField();
        txRepRev = new javax.swing.JTextField();
        txTag = new javax.swing.JTextField();
        txOptions = new javax.swing.JTextField();
        txDate = new javax.swing.JTextField();

        setLayout(new java.awt.GridBagLayout());

        setMaximumSize(new java.awt.Dimension(354, 203));
        lblFileName.setDisplayedMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/cvsclient/commands/status/Bundle").getString("ACS_lblFileName_mnc").charAt(0));
        lblFileName.setLabelFor(txFileName);
        lblFileName.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/cvsclient/commands/status/Bundle").getString("StatusInfoPanel.lblFileName.text"));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(12, 12, 0, 0);
        add(lblFileName, gridBagConstraints);

        lblStatus.setDisplayedMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/cvsclient/commands/status/Bundle").getString("ACS_lblStatus_mnc").charAt(0));
        lblStatus.setLabelFor(txStatus);
        lblStatus.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/cvsclient/commands/status/Bundle").getString("StatusInfoPanel.lblStatus.text"));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(12, 17, 0, 0);
        add(lblStatus, gridBagConstraints);

        lblRepFile.setDisplayedMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/cvsclient/commands/status/Bundle").getString("ACS_lblRepFile_mnc").charAt(0));
        lblRepFile.setLabelFor(txRepFile);
        lblRepFile.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/cvsclient/commands/status/Bundle").getString("StatusInfoPanel.lblRepFile.text"));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(5, 12, 0, 0);
        add(lblRepFile, gridBagConstraints);

        txRepFile.setEditable(false);
        txRepFile.setForeground(new java.awt.Color(102, 102, 158));
        txRepFile.setText("repFile");
        txRepFile.setDisabledTextColor(new java.awt.Color(102, 102, 153));
        txRepFile.setMinimumSize(new java.awt.Dimension(100, 20));
        txRepFile.setPreferredSize(new java.awt.Dimension(300, 20));
        txRepFile.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txRepFileActionPerformed(evt);
            }
        });

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(2, 12, 0, 11);
        add(txRepFile, gridBagConstraints);
        txRepFile.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/cvsclient/commands/status/Bundle").getString("ACSD_txRepFile"));

        lblWorkRev.setDisplayedMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/cvsclient/commands/status/Bundle").getString("ACS_lblWorkRev_mnc").charAt(0));
        lblWorkRev.setLabelFor(txWorkRev);
        lblWorkRev.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/cvsclient/commands/status/Bundle").getString("StatusInfoPanel.lblWorkRev.text"));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(5, 12, 0, 0);
        add(lblWorkRev, gridBagConstraints);

        lblRepRev.setDisplayedMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/cvsclient/commands/status/Bundle").getString("ACS_lblRevRep_mnc").charAt(0));
        lblRepRev.setLabelFor(txRepRev);
        lblRepRev.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/cvsclient/commands/status/Bundle").getString("StatusInfoPanel.lblRepRev.text"));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(5, 17, 0, 0);
        add(lblRepRev, gridBagConstraints);

        btnDiff.setMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/cvsclient/commands/status/Bundle").getString("CVS_btnDiff_mnc").charAt(0));
        btnDiff.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/cvsclient/commands/status/Bundle").getString("StatusInfoPanel.btnDiff.text"));
        btnDiff.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnDiffActionPerformed(evt);
            }
        });

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 4;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
        gridBagConstraints.ipadx = 1;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(4, 12, 0, 11);
        add(btnDiff, gridBagConstraints);

        lblTag.setDisplayedMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/cvsclient/commands/status/Bundle").getString("ACS_lblTag_mnc").charAt(0));
        lblTag.setLabelFor(txTag);
        lblTag.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/cvsclient/commands/status/Bundle").getString("StatusInfoPanel.lblTag.text"));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 3;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(12, 12, 0, 0);
        add(lblTag, gridBagConstraints);

        lblOptions.setDisplayedMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/cvsclient/commands/status/Bundle").getString("ACS_lblOptions_mnc").charAt(0));
        lblOptions.setLabelFor(txOptions);
        lblOptions.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/cvsclient/commands/status/Bundle").getString("StatusInfoPanel.lblOptions.text"));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 3;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(12, 17, 0, 0);
        add(lblOptions, gridBagConstraints);

        lblDate.setDisplayedMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/cvsclient/commands/status/Bundle").getString("ACS_lblDate_mnc").charAt(0));
        lblDate.setLabelFor(txDate);
        lblDate.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/cvsclient/commands/status/Bundle").getString("StatusInfoPanel.lblDate.text"));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(5, 12, 0, 0);
        add(lblDate, gridBagConstraints);

        spExistingTags.setMinimumSize(new java.awt.Dimension(100, 100));
        spExistingTags.setPreferredSize(new java.awt.Dimension(200, 200));
        spExistingTags.setViewportView(tblExistingTags);
        tblExistingTags.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/cvsclient/commands/status/Bundle").getString("ACSD_tblExistingTags"));

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 6;
        gridBagConstraints.gridwidth = 4;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.weighty = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(2, 12, 11, 0);
        add(spExistingTags, gridBagConstraints);

        lblExistingTags.setDisplayedMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/cvsclient/commands/status/Bundle").getString("ACS_lblExistingTags_mnc").charAt(0));
        lblExistingTags.setLabelFor(tblExistingTags);
        lblExistingTags.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/cvsclient/commands/status/Bundle").getString("StatusInfoPanel.lblExistingTags.text"));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 5;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(12, 12, 0, 0);
        add(lblExistingTags, gridBagConstraints);

        btnAdvanced.setMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/cvsclient/commands/status/Bundle").getString("CVS_btnAdvanced_mnc").charAt(0));
        btnAdvanced.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/cvsclient/commands/status/Bundle").getString("StatusInfoPanel.btnAdvanced.text"));
        btnAdvanced.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAdvancedActionPerformed(evt);
            }
        });

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 4;
        gridBagConstraints.gridy = 6;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.insets = new java.awt.Insets(2, 12, 11, 11);
        add(btnAdvanced, gridBagConstraints);

        txFileName.setEditable(false);
        txFileName.setText("jTextField1");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(12, 12, 0, 0);
        add(txFileName, gridBagConstraints);
        txFileName.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/cvsclient/commands/status/Bundle").getString("ACSD_txFileName"));

        txStatus.setEditable(false);
        txStatus.setFont(txStatus.getFont().deriveFont(java.awt.Font.BOLD));
        txStatus.setForeground(java.awt.Color.blue);
        txStatus.setText("jTextField1");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 3;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(12, 12, 0, 0);
        add(txStatus, gridBagConstraints);
        txStatus.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/cvsclient/commands/status/Bundle").getString("ACSD_txStatus"));

        txWorkRev.setEditable(false);
        txWorkRev.setText("jTextField1");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(5, 12, 0, 0);
        add(txWorkRev, gridBagConstraints);
        txWorkRev.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/cvsclient/commands/status/Bundle").getString("ACSD_txWorkRev"));

        txRepRev.setEditable(false);
        txRepRev.setText("jTextField1");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 3;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(5, 12, 0, 0);
        add(txRepRev, gridBagConstraints);
        txRepRev.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/cvsclient/commands/status/Bundle").getString("ACSD_txRepRev"));

        txTag.setEditable(false);
        txTag.setText("jTextField1");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 3;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(12, 12, 0, 0);
        add(txTag, gridBagConstraints);
        txTag.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/cvsclient/commands/status/Bundle").getString("ACSD_txTag"));

        txOptions.setEditable(false);
        txOptions.setText("jTextField1");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 3;
        gridBagConstraints.gridy = 3;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(12, 12, 0, 0);
        add(txOptions, gridBagConstraints);
        txOptions.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/cvsclient/commands/status/Bundle").getString("ACSD_txOptions"));

        txDate.setEditable(false);
        txDate.setText("jTextField1");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.insets = new java.awt.Insets(5, 12, 0, 0);
        add(txDate, gridBagConstraints);
        txDate.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/cvsclient/commands/status/Bundle").getString("ACSD_txDate"));

    }//GEN-END:initComponents

    private void txRepFileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txRepFileActionPerformed
        // Add your handling code here:
    }//GEN-LAST:event_txRepFileActionPerformed
    
  private void btnAdvancedActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAdvancedActionPerformed
      // Add your handling code here:
//      if (!(provider.isFileSystemClient()) || provider.isOffLine()) return;
//        if (!defaultCommand.getClientProvider() instanceof IndependantClient) return;
        IndependantClient provider = (IndependantClient)defaultCommand.getClientProvider();
        if (provider.isOffLine()) return;
      File[] files = new File[1];
      files[0] = statusInfo.getFile();
      if (files[0].exists() == false) return;
      FsCommandFactory fact = (FsCommandFactory)FsCommandFactory.getInstance();
      
      CvsStatus myStat = (CvsStatus)fact.createCommand(CvsStatus.class, 
                    false, files, defaultCommand.getClientProvider()); 
      fact.addIndependantRuntime(myStat);
      myStat.setIncludeTags(true);
      myStat.addDisplayerListener(new CommandDisplayerAdapter() {
          public void showFileInfoGenerated(FileInfoContainer info) {
              StatusInformation sInfo = (StatusInformation)info;
              // we need to copy the information to the old statusInfo 
              // because of preseving info when looking at the status tree..
              // we'll copy everything just for the sake of it.. in case something changes over time
              statusInfo.setFile(sInfo.getFile());
              statusInfo.setRepositoryFileName(sInfo.getRepositoryFileName());
              statusInfo.setRepositoryRevision(sInfo.getRepositoryRevision());
              statusInfo.setStatus(sInfo.getStatus());
              statusInfo.setStickyDate(sInfo.getStickyDate());
              statusInfo.setStickyOptions(sInfo.getStickyOptions());
              statusInfo.setStickyTag(sInfo.getStickyTag());
              statusInfo.setWorkingRevision(sInfo.getWorkingRevision());
              statusInfo.setAllExistingTags(sInfo.getAllExistingTags());
              setData(statusInfo);
          }
      });
      myStat.addDisplayerListener(new ErrorLogPanel(myStat));
//TODO      myStat.setOutputDisplayer(new TagsDisplayer(null));
      myStat.startCommand();
      
  }//GEN-LAST:event_btnAdvancedActionPerformed
  
  private void btnDiffActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDiffActionPerformed
      // Add your handling code here:
      File[] files = new File[1];
      files[0] = statusInfo.getFile();
      FsCommandFactory fact = (FsCommandFactory)FsCommandFactory.getInstance();
      
      CvsDiff myStat = (CvsDiff)fact.createCommand(CvsDiff.class, 
                    false, files, defaultCommand.getClientProvider());      
      fact.addIndependantRuntime(myStat);
      myStat.setRevision1(statusInfo.getRepositoryRevision());
      myStat.addDisplayerListener(new DiffCommandDisplayer(myStat));
      myStat.addDisplayerListener(new ErrorLogPanel(myStat));
      myStat.startCommand();
  }//GEN-LAST:event_btnDiffActionPerformed
  
  
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnAdvanced;
    private javax.swing.JButton btnDiff;
    private javax.swing.JLabel lblDate;
    private javax.swing.JLabel lblExistingTags;
    private javax.swing.JLabel lblFileName;
    private javax.swing.JLabel lblOptions;
    private javax.swing.JLabel lblRepFile;
    private javax.swing.JLabel lblRepRev;
    private javax.swing.JLabel lblStatus;
    private javax.swing.JLabel lblTag;
    private javax.swing.JLabel lblWorkRev;
    private javax.swing.JScrollPane spExistingTags;
    private javax.swing.JTable tblExistingTags;
    private javax.swing.JTextField txDate;
    private javax.swing.JTextField txFileName;
    private javax.swing.JTextField txOptions;
    private javax.swing.JTextField txRepFile;
    private javax.swing.JTextField txRepRev;
    private javax.swing.JTextField txStatus;
    private javax.swing.JTextField txTag;
    private javax.swing.JTextField txWorkRev;
    // End of variables declaration//GEN-END:variables

  private static final ResourceBundle bundle = NbBundle.getBundle(StatusInfoPanel.class);   // NOI18N
  
  private void initAccessibility() {
      
    /*  txRepRev.selectAll();
      txRepFile.selectAll();
      txTag.selectAll();
      txStatus.selectAll();
      txWorkRev.selectAll();
      txOptions.selectAll();
      txFileName.selectAll();
      txDate.selectAll();*/
      
      SelectAllListener focusListener = new SelectAllListener();
      txRepRev.addFocusListener(focusListener);
      txRepFile.addFocusListener(focusListener);
      txTag.addFocusListener(focusListener);
      txStatus.addFocusListener(focusListener);
      txWorkRev.addFocusListener(focusListener);
      txOptions.addFocusListener(focusListener);
      txFileName.addFocusListener(focusListener);
      txDate.addFocusListener(focusListener);      
      
      AccessibleContext context = this.getAccessibleContext();
      context.setAccessibleDescription(bundle.getString("ACSD_StatusInfoPanel"));
      
      context = btnDiff.getAccessibleContext();
      context.setAccessibleDescription(bundle.getString("ACSD_StatusInfoPanel.btnDiff"));
      
      context = btnAdvanced.getAccessibleContext();
      context.setAccessibleDescription(bundle.getString("ACSD_StatusInfoPanel.btnAdvanced"));
      
      context = txRepFile.getAccessibleContext();
      context.setAccessibleDescription(bundle.getString("ACSD_StatusInfoPanel.txRepFile"));
        
  }
  
  class SelectAllListener implements java.awt.event.FocusListener{
        public void focusLost(java.awt.event.FocusEvent e){}
        public void focusGained(java.awt.event.FocusEvent e){
            ((javax.swing.JTextField)e.getComponent()).selectAll();
        }
  }
  

  public void setData(StatusInformation info) {
      statusInfo = info;
      txFileName.setText(info.getFile().getName());
      JavaCvsStatusManager manager = NbJavaCvsStatusManager.getInstance();
      txStatus.setText(manager.getStatus(manager.convertStatus(info.getStatus())));
      String work = info.getWorkingRevision();
      txWorkRev.setText(work);
      String repo = info.getRepositoryRevision();
      txRepFile.setText(info.getRepositoryFileName());
      txRepRev.setText(repo);
      if (work != null && repo != null) {
          if (!repo.equals(work)) { //possible stuff that can be done with the display
              txRepRev.setForeground(java.awt.Color.red);
              txWorkRev.setForeground(java.awt.Color.red);
          } else {
              txRepRev.setForeground(oldColor);
              txWorkRev.setForeground(oldColor);
          }
      }
      boolean uptodate = (info.getStatus() == FileStatus.UP_TO_DATE || info.getStatus() == FileStatus.UNKNOWN);
      btnDiff.setEnabled(!uptodate);
      txDate.setText(info.getStickyDate());
      txTag.setText(info.getStickyTag());
      txOptions.setText(info.getStickyOptions());

      model.clear();
      java.util.Iterator it = info.getAllExistingTags().iterator();
      while (it.hasNext()) {
          model.addElement(it.next());
      }
      TableInfoModel model = (TableInfoModel)tblExistingTags.getModel();
      java.util.Collections.sort(model.getList(), model);
        // find the previsously selected row.
      tblExistingTags.tableChanged(new javax.swing.event.TableModelEvent(model));
      tblExistingTags.repaint();
  }
  
  public void setCommand(CvsStatus comm) {
      defaultCommand = comm;
  }
  
  
    /** 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(StatusInformation info) {
      setData(info);
  }
  
    /** Does the actual display - docking into the javacvs Mode,
     *   displaying as single Dialog.. whatever.
     */
  public void displayOutputData() {
      // in case the paraminput dialog won't trigger.. not nessesary to have this condition -> always disable
      spExistingTags.setEnabled(defaultCommand.isIncludeTags());
      lblExistingTags.setEnabled(defaultCommand.isIncludeTags());          
      String title = NbBundle.getMessage(CvsStatus.class, "CvsStatus.dialogTitle",  // NOI18N
                statusInfo.getFile().getName());
      FsCommandFactory.displayOutputPanel(title, this);
  }
  
  
  // --------------------------------------------
  // persistantDisplayer stuff..
  // --------------------------------------------
  
  public boolean equalDisplayedData(File file, Class type, Object comparisonData) {
      if (!getClass().equals(type)) return false;
      if (statusInfo == null || statusInfo.getFile() == null
                || !statusInfo.getFile().equals(file)) {
          return false;
      }
      return true;
  }

  public File getFileDisplayed() {
      return statusInfo.getFile();
  }
   
  public Object getComparisonData() {
      return statusInfo;
  }
   
  public JComponent getComponent() {
      return this;
  }

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

  
  class ExtendedRevisionComparator extends RevisionComparator {
      public int compare(java.lang.Object obj, java.lang.Object obj1) {
          int result = 0;
          String revStr1 = obj.toString();
          String revStr2 = obj1.toString();
          String substr1 = revStr1.substring(0, revStr1.indexOf(':'));
          String substr2 = revStr2.substring(0, revStr2.indexOf(':'));
          result = substr1.compareTo(substr2);
          if (result == 0) {
              result = super.compare(revStr1.substring(substr1.length() + 1),
                                revStr2.substring(substr2.length() + 1));
          }
          return result;
      }
  }
}
... 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.