You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by do...@apache.org on 2002/05/28 09:05:05 UTC

cvs commit: jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/frontends SwingUI.java

donaldp     02/05/28 00:05:05

  Added:       container/src/java/org/apache/myrmidon/frontends
                        SwingUI.java
  Log:
  Start to create a basic SwingGUI for executing build files similar to junits SwingRunner
  
  Revision  Changes    Path
  1.1                  jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/frontends/SwingUI.java
  
  Index: SwingUI.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.myrmidon.frontends;
  
  import java.awt.Container;
  import java.awt.Font;
  import java.awt.Frame;
  import java.awt.TextField;
  import java.awt.event.ActionEvent;
  import java.awt.event.ActionListener;
  import java.awt.event.TextEvent;
  import java.awt.event.TextListener;
  import javax.swing.BoxLayout;
  import javax.swing.JButton;
  import javax.swing.JCheckBox;
  import javax.swing.JDialog;
  import javax.swing.JPanel;
  import javax.swing.JProgressBar;
  import javax.swing.SwingUtilities;
  import org.apache.myrmidon.Constants;
  
  class SwingUI
      extends JDialog
  {
      private static final Font PLAIN_FONT = new Font( "dialog", Font.PLAIN, 12 );
  
      private JButton m_buildButton;
      private JProgressBar m_progressBar;
      private TextField m_fileField;
      private JCheckBox m_reloadLibsCheckBox;
      private JCheckBox m_reloadFileCheckBox;
  
      public SwingUI()
      {
          super( (Frame)null, Constants.BUILD_BANNER, true );
          final Container contentPane = getContentPane();
          final BoxLayout layout = new BoxLayout( contentPane, BoxLayout.Y_AXIS );
          contentPane.setLayout( layout );
  
          final JPanel entryPanel = createEntryPanel();
          final JPanel statusPanel = createStatusPanel();
          final JPanel resultsPanel = createResultsPanel();
  
          contentPane.add( entryPanel );
          contentPane.add( statusPanel );
          contentPane.add( resultsPanel );
  
          pack();
          validate();
          doLayout();
      }
  
      private JPanel createResultsPanel()
      {
          final JPanel panel = new JPanel();
          return panel;
      }
  
      private JPanel createStatusPanel()
      {
          final JPanel panel = new JPanel();
          m_progressBar = new JProgressBar( 0, 300 );
          panel.add( m_progressBar );
          return panel;
      }
  
      private JPanel createEntryPanel()
      {
          final JPanel panel = new JPanel();
          m_buildButton = createBuildButton();
          m_fileField = createFileField();
          m_reloadLibsCheckBox = new JCheckBox( "Reload Libraries", true );
          m_reloadFileCheckBox = new JCheckBox( "Reload Build File", true );
  
          panel.add( m_fileField );
          panel.add( m_buildButton );
          panel.add( m_reloadLibsCheckBox );
          panel.add( m_reloadFileCheckBox );
          return panel;
      }
  
      private TextField createFileField()
      {
          final TextField fileField = new TextField( "" );
          fileField.selectAll();
          fileField.requestFocus();
          fileField.setFont( PLAIN_FONT );
          fileField.setColumns( 40 );
  
          final ActionListener actionListener = new ActionListener()
          {
              public void actionPerformed( final ActionEvent action )
              {
                  action_build();
              }
          };
          fileField.addActionListener( actionListener );
  
          final TextListener textListener = new TextListener()
          {
              public void textValueChanged( final TextEvent event )
              {
                  file_textChanged();
              }
          };
          fileField.addTextListener( textListener );
  
          return fileField;
      }
  
      private JButton createBuildButton()
      {
          final JButton button = new JButton( "Build" );
          button.setToolTipText( "Build Project" );
  
          final ActionListener actionListener = new ActionListener()
          {
              public void actionPerformed( final ActionEvent action )
              {
                  action_build();
              }
          };
          button.addActionListener( actionListener );
  
          return button;
      }
  
      private void action_build()
      {
          m_buildButton.setEnabled( false );
          final Runnable runnable = new Runnable()
          {
              public void run()
              {
                  doBuild();
              }
          };
          SwingUtilities.invokeLater( runnable );
      }
  
      /**
       * Actually do the build in this method.
       */
      private void doBuild()
      {
          System.out.println( "SwingUI.doBuild" );
  
  //        final boolean reloadLibs = m_reloadLibsCheckBox.isSelected();
  //        if( reloadLibs )
  //        {
  //            //rebuild workspace/module
  //        }
  
          final String buildFilename = m_fileField.getText();
          final boolean reloadFile =
              m_reloadFileCheckBox.isSelected();
  
  //        if( buildFilename.equals( m_oldBuildFile ) || reloadFile || reloadLibs )
  //        {
  //            //reload build file here
  //        }
  
          //Hook up event listener here
  
          //Process Module here
  
          m_buildButton.setEnabled( true );
      }
  
      private void file_textChanged()
      {
          m_buildButton.setEnabled( m_fileField.getText().length() > 0 );
          //m_statusLine.setText( "" );
      }
  }
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>