[kepler-code] r28847 - releases/release-branches/workflow-scheduler-gui-1.0/src/org/kepler/workflowscheduler/gui/configurationwizard

tao at ecoinformatics.org tao at ecoinformatics.org
Mon Oct 31 11:36:54 PDT 2011


Author: tao
Date: 2011-10-31 11:36:54 -0700 (Mon, 31 Oct 2011)
New Revision: 28847

Modified:
   releases/release-branches/workflow-scheduler-gui-1.0/src/org/kepler/workflowscheduler/gui/configurationwizard/WorkflowRunEngineConfigurationDialog.java
Log:
Merge adding panels to this dialog from trunk to the branch


Modified: releases/release-branches/workflow-scheduler-gui-1.0/src/org/kepler/workflowscheduler/gui/configurationwizard/WorkflowRunEngineConfigurationDialog.java
===================================================================
--- releases/release-branches/workflow-scheduler-gui-1.0/src/org/kepler/workflowscheduler/gui/configurationwizard/WorkflowRunEngineConfigurationDialog.java	2011-10-31 18:30:49 UTC (rev 28846)
+++ releases/release-branches/workflow-scheduler-gui-1.0/src/org/kepler/workflowscheduler/gui/configurationwizard/WorkflowRunEngineConfigurationDialog.java	2011-10-31 18:36:54 UTC (rev 28847)
@@ -28,7 +28,249 @@
  */
 package org.kepler.workflowscheduler.gui.configurationwizard;
 
-public class WorkflowRunEngineConfigurationDialog
+import java.awt.BorderLayout;
+import java.awt.Dimension;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.Insets;
+import java.awt.Window;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.Vector;
+
+import javax.swing.BorderFactory;
+import javax.swing.Box;
+import javax.swing.BoxLayout;
+import javax.swing.JButton;
+import javax.swing.JDialog;
+import javax.swing.JLabel;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.JTextField;
+
+import org.kepler.module.workflowschedulergui.Initialize;
+import org.kepler.workflowscheduler.gui.WorkflowRunEngine;
+import org.kepler.workflowscheduler.gui.WorkflowSchedulerPanel;
+
+/**
+ * A dialog to configure the workflow run engines.
+ * @author tao
+ *
+ */
+public class WorkflowRunEngineConfigurationDialog extends JDialog
 {
+  private static final String TITLE = "Workflow Run Engine Configuration";
+  private static final String DEFAULTNAME = "The Run Engine Name";
+  private static final String DEFAULTURL = "http://yourhostname/workflowrunengine/services/KeplerWebService";
+  private static final int WIDTH = 800;
+  private static final int HEIGHT = 200;
+  static final int LEADSPACESIZE = 50; // leading space of each row
+  static final int TEXTFIELDSIZE = 600;
+  private Window parent = null;
+  private GridBagConstraints textFieldConstraint = null;
+  private GridBagConstraints labelConstraint = null;
+  private GridBagConstraints lastConstraint = null;
+  private JTextField nameTextField = null;
+  private JTextField urlTextField = null;
+  private JPanel mainPanel = null;
+  private JPanel addingEnginePanel = null;
+  private KnownWorkflowRunEnginePanel knownRunEnginePanel = null;
+  private CompletingConfigurationListenerInterface completeListener = null;
+  
+  /**
+   * Constructor
+   */
+  public WorkflowRunEngineConfigurationDialog(Window parent,
+                                CompletingConfigurationListenerInterface completeListener)
+  {
+    super(parent);
+    this.parent = parent;
+    this.completeListener = completeListener;
+    init();
+    this.pack();
+    this.setVisible(true);
+  }
+  
+  
+  /*
+   * Initialize the dialog
+   */
+  private void init()
+  {
+    setPreferredSize(new Dimension(WIDTH, HEIGHT));    
+    if(parent != null)
+    {
+      setLocation(parent.getLocation());
+    }
+    setTitle(TITLE);
+    setModal(true);
+    setLayout(new BorderLayout());
+    initializeGridBagLayout();
+    initMainPanel();
+    initCloseButtonPanel();
+  }
+  
+  /*
+   * Initialize the grid bag layout manager
+   */
+  private void initializeGridBagLayout()
+  {
+    textFieldConstraint = new GridBagConstraints();
+    textFieldConstraint.fill = GridBagConstraints.HORIZONTAL;
+    //lastConstraint.anchor = GridBagConstraints.NORTHWEST;
+    // Give the "last" component as much space as possible
+    textFieldConstraint.weightx = 1.0;
+    //textFieldConstraint.gridwidth = GridBagConstraints.RELATIVE;     
+    textFieldConstraint.insets = new Insets(4, 4, 4, 4);
 
+    lastConstraint = (GridBagConstraints) textFieldConstraint.clone();
+    //These still get as much space as possible, but do
+    //not close out a row
+    lastConstraint.gridwidth = GridBagConstraints.REMAINDER;
+
+    // first component (usually it is a label) on each row
+    labelConstraint = (GridBagConstraints) textFieldConstraint.clone();
+    // Give these as little space as necessary
+    labelConstraint.weightx = 0.0;
+    labelConstraint.gridwidth = 1;
+
+  }
+  
+  /*
+   * MainPanel will contain two parts:
+   * 1. AddingEnginePanel - contains text input fields and add button
+   * 2. KnownWorkflowRunEngine panle - displays the known engines.
+   */
+  private void initMainPanel()
+  {
+    mainPanel = new JPanel();
+    mainPanel.setLayout(new BorderLayout());
+    initAddingEnginePanel();
+    mainPanel.add(addingEnginePanel, BorderLayout.NORTH);
+    WorkflowRunEngine[] engineList = getWorkflowRunEngineArrayFromConfig();
+    knownRunEnginePanel =  new KnownWorkflowRunEnginePanel(engineList);
+    if(engineList == null)
+    {
+      knownRunEnginePanel.setVisible(false);
+    }
+    mainPanel.add(knownRunEnginePanel, BorderLayout.SOUTH);
+  }
+  
+  /*
+   * Initialize the panel adding workflow run engine name and url.
+   * It has a panel for two text fields which user can input engine name and url.
+   * It also has a panel for the add button
+   */
+  private void initAddingEnginePanel()
+  {
+    addingEnginePanel = new JPanel();
+    addingEnginePanel.setLayout(new BorderLayout());
+    initNameAndURLInputPanel();
+    initAddButtonPanel();
+  }
+  
+  private void initNameAndURLInputPanel()
+  {
+    JPanel nameAndURLPanel = new JPanel();
+    GridBagLayout gridbag = new GridBagLayout();
+    nameAndURLPanel.setLayout(gridbag);
+    
+    //name row
+    WorkflowSchedulerURLConfigurationDialog.addLeadingSpace(nameAndURLPanel, gridbag, labelConstraint);
+    JLabel nameLabel = new JLabel("Name          ");
+    WorkflowSchedulerPanel.addComponent(nameAndURLPanel, nameLabel, gridbag, labelConstraint);
+    nameTextField = new JTextField();
+    nameTextField.setText(DEFAULTNAME);
+    WorkflowSchedulerPanel.addFixWidthComponent(nameAndURLPanel, nameTextField , gridbag, textFieldConstraint);
+    WorkflowSchedulerURLConfigurationDialog.addEndingSpace(nameAndURLPanel, gridbag,lastConstraint);
+    
+    //url row
+    WorkflowSchedulerURLConfigurationDialog.addLeadingSpace(nameAndURLPanel, gridbag, labelConstraint);
+    JLabel urlLabel = new JLabel("URL          ");
+    WorkflowSchedulerPanel.addComponent(nameAndURLPanel, urlLabel, gridbag, labelConstraint);
+    urlTextField = new JTextField();
+    urlTextField.setText(DEFAULTURL);
+    WorkflowSchedulerPanel.addFixWidthComponent(nameAndURLPanel, urlTextField , gridbag, textFieldConstraint);
+    WorkflowSchedulerURLConfigurationDialog.addEndingSpace(nameAndURLPanel, gridbag,lastConstraint);
+    
+    addingEnginePanel.add(nameAndURLPanel, BorderLayout.CENTER);
+  }
+  
+  /*
+   * Initialize the button panel which contains the add button.
+   * This button panel will be added to addingEnginePanel
+   */
+  private void initAddButtonPanel()
+  {
+    JPanel buttonPanel = new JPanel();
+    buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS));
+    buttonPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
+    buttonPanel.add(Box.createHorizontalGlue());
+    JButton addButton = new JButton("Add");
+    addButton.setPreferredSize(new Dimension(100, 50));
+    addButton.addActionListener(new ActionListener()
+    {
+      public void actionPerformed(ActionEvent e)
+      {
+        try
+        {
+          modifyRunEngineToConfig();
+        }
+        catch(Exception ee)
+        {
+          JOptionPane.showMessageDialog(null, "Couldn't add the new Run Enginel - "+ee.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
+        }
+      }
+    });  
+    buttonPanel.add(addButton);
+    addingEnginePanel.add(buttonPanel, BorderLayout.SOUTH);
+  }
+  
+  /*
+   * Initialize the panel containing the close button which close the dialog(top level)
+   */
+  private void initCloseButtonPanel()
+  {
+    JPanel buttonPanel = new JPanel();
+    buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS));
+    buttonPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
+    buttonPanel.add(Box.createHorizontalGlue());
+    JButton cancelButton = new JButton("Close");
+    cancelButton.setPreferredSize(new Dimension(100, 50));
+    cancelButton.addActionListener(new ActionListener()
+    {
+      public void actionPerformed(ActionEvent e)
+      {
+        dispose();
+      }
+    });   
+    buttonPanel.add(cancelButton);
+    //buttonPanel.add(Box.createHorizontalStrut(10));
+    this.add(buttonPanel, BorderLayout.SOUTH);
+  }
+  
+  /*
+   * A method will modify the workflow run engine value in the configuration
+   */
+  private void modifyRunEngineToConfig()
+  {
+    
+  }
+  
+  /*
+   * Get the array of workflow run engine from configuration.
+   * null will be return if we can't find one.
+   */
+  private WorkflowRunEngine[] getWorkflowRunEngineArrayFromConfig()
+  {
+    WorkflowRunEngine[] engineList = null;
+    Vector<WorkflowRunEngine> engineVector = Initialize.getWorkflowRunEngineList();
+    if(engineVector != null && engineVector.size() > 0)
+    {
+      engineList = new WorkflowRunEngine[engineVector.size()];
+      engineVector.toArray(engineList);
+    }
+    return engineList;
+  }
+
 }



More information about the Kepler-cvs mailing list