Logo
Distributed Genetic Programming Framework
print print

File org.dgpf.gui.dialogs.StartJarDialog.java

Here you can find all the information about the file org.dgpf.gui.dialogs.StartJarDialog.java. You may explore it here or download it onto your local disk.
/*
 * Copyright (c) 2006 Mirko Dietrich
 * 
 * E-Mail           : mirkodietrich@hrz.uni-kassel.de
 * Creation Date    : Jul 22, 2006 5:01:48 PM
 * Original Filename: org.dgpf.gui.DGPFStartJarFrame.java
 * Version          : 1.0
 * Last modification: Jul 22, 2006
 * Last modified by : Mirko Dietrich
 * 
 * License          : GNU LESSER GENERAL PUBLIC LICENSE
 *                    Version 2.1, February 1999
 *                    You should have received a copy of this license along
 *                    with this library; if not, write to the Free Software
 *                    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *                    MA 02111-1307, USA or download the license under
 *                    http://www.gnu.org/copyleft/lesser.html.
 *                    
 * Warranty         : This software is provided "as is" without any
 *                    warranty; without even the implied warranty of
 *                    merchantability or fitness for a particular purpose.
 *                    See the Gnu Lesser General Public License for more
 *                    details.
 */


package org.dgpf.gui.dialogs;

import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.HeadlessException;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.io.File;

import javax.swing.JInternalFrame;
import javax.swing.JOptionPane;
import javax.swing.border.TitledBorder;

import org.dgpf.gui.Frame;
import org.dgpf.gui.InternalFrame;
import org.dgpf.gui.components.BorderedPanel;
import org.dgpf.gui.components.CheckBox;
import org.dgpf.gui.components.FileChooserPanel;
import org.dgpf.gui.utils.LanguageSwitcher;
import org.dgpf.gui.utils.Layout;
import org.dgpf.gui.utils.PrefUtils;

/**
 * Dialog box for connecting to a set of hosts running daemons.
 * 
 * @author Mirko Dietrich
 */

public class StartJarDialog extends DialogBase
  {

  /**
   * The chooser for the host list.
   */

  private FileChooserPanel  m_fcp;

  /**
   * Check box for creating charts.
   */

  private CheckBox          m_createChartBox;

  /**
   * serialVersionUID.
   */

  private static final long serialVersionUID = 6807491793932326640L;

  /**
   * The according <code>Daemons</code> this frames are connected to will
   * start the JAR files.
   */

  private InternalFrame[]   m_iframes;

  /**
   * Reacts on button clicks.
   * 
   * @param p_event to ne handled.
   */

  public void actionPerformed(ActionEvent p_event)
    {
    String l_cmd = p_event.getActionCommand();
    
    /* OK, start JAR Files on Daemons */
    if(l_cmd.equals("ok"))
      {
      PrefUtils.putBoolean("start_cw_before_se_runs",
          this.m_createChartBox.isSelected());
      File l_jarfile;
      l_jarfile = new File(this.m_fcp.getFile());
      try
        {
        for(JInternalFrame l_f : this.m_iframes)
          {
          ((InternalFrame) l_f).execJar(l_jarfile);
          }
        }
      catch(Exception e)
        {
        e.printStackTrace();
        JOptionPane.showMessageDialog(this, LanguageSwitcher
            .getString("msgb_sjd_jar_failed"), LanguageSwitcher
            .getString("msgb_name_error"), JOptionPane.ERROR_MESSAGE);
        }
      this.dispose();
      PrefUtils.putString("jar_to_start"this.m_fcp.getFile());
      return;
      }
    
    /* Cancel */
    if(l_cmd.equals("cancel"))
      {
      this.dispose();
      return;
      }
    }

  /**
   * Default constructor
   * 
   * @param p_parent
   *          DGPF main window.
   * @param p_iframes
   *          is an array of frames that is connected to the
   *          <code>Daemon</code> where the engine should be started.
   * @throws HeadlessException
   */

  public StartJarDialog(Frame p_parent, InternalFrame[] p_iframes)
      throws HeadlessException
    {
    super(p_parent, LanguageSwitcher.getString("sjd_caption"),
        LanguageSwitcher.getString("sjd_info"), DialogBase.OK_CANCEL_BTN,
        true, new GridBagLayout());
    this.m_iframes = p_iframes;

    /* Jar file chooser */
    String suggestedFile = PrefUtils.getString("jar_to_start",
        LanguageSwitcher.getString("sjd_fc_default_file"));
    this.m_fcp = new FileChooserPanel(LanguageSwitcher
        .getString("sjd_fc_panel_caption"), suggestedFile,
        LanguageSwitcher.getString("sjd_fc_caption"), LanguageSwitcher
            .getString("sjd_fc_filefilter"), "jar", LanguageSwitcher
            .getString("sjd_fc_default_file"), LanguageSwitcher
            .getString("btn_open"));

    /* Creating charts at begining */
    BorderedPanel l_createChartPanel = new BorderedPanel(LanguageSwitcher
        .getString("sjd_cc_border_caption"), TitledBorder.LEFT);
    l_createChartPanel.setLayout(new GridBagLayout());
    this.m_createChartBox = new CheckBox(LanguageSwitcher
        .getString("sjd_cc_caption"), "create_charts", true);
    if(PrefUtils.getBoolean("start_cw_before_se_runs", false))
    this.m_createChartBox.setSelected(false);

    Layout.set_constraints(l_createChartPanel, this.m_createChartBox, 1.0,
        1.0, GridBagConstraints.BOTH, GridBagConstraints.LINE_START,
        GridBagConstraints.REMAINDER, new Insets(3, 3, 3, 3));

    /* Add to the start jar dialog */
    Layout.set_constraints(this.getCenter(), this.m_fcp, 1.0, 1.0,
        GridBagConstraints.BOTH, GridBagConstraints.LINE_START,
        GridBagConstraints.REMAINDER, new Insets(3, 3, 3, 3));

    Layout.set_constraints(this.getCenter(), l_createChartPanel, 1.0, 1.0,
        GridBagConstraints.BOTH, GridBagConstraints.LINE_START,
        GridBagConstraints.REMAINDER, new Insets(3, 3, 3, 3));

    this.finish(DialogBase.DEFAULT_WIDTH + 40,
        DialogBase.DEFAULT_HEIGHT + 100);
    }
  }

File Information:

file name:StartJarDialog.java
package:org.dgpf.gui.dialogs
qualified name:org.dgpf.gui.dialogs.StartJarDialog.java
file type:Java Source File
download location:download http://dgpf.sourceforge.net/source/org/dgpf/gui/dialogs/StartJarDialog.java
size:5.594 KB (5729 B)
uploaded: 2015-07-22 04:10:58 GMT+0000
last update: 2006-09-24 23:47:04 GMT+0000
last access: 2017-11-22 09:26:40 GMT+0000

statistics online since 2006-01-02.   RSS Feed
Contact us by sending an email to tweise@gmx.de to receive further information, to report errors, or to join our project.
All content on this site (http://dgpf.sourceforge.net/) is LGPL-licensed.
http://dgpf.sourceforge.net/scripts/source/source.php last modified at 2015-07-22 04:10:53 GMT+0000 served at 2017-11-22 09:26:40 GMT+0000.
Valid CSS Valid XHTML 1.1
Valid RSS SourceForge.net Logo