[kepler-code] r28836 - in trunk/modules/workflow-scheduler-gui/src/org/kepler: module/workflowschedulergui workflowscheduler/gui workflowscheduler/gui/configurationwizard
tao at ecoinformatics.org
tao at ecoinformatics.org
Tue Oct 25 16:24:57 PDT 2011
Author: tao
Date: 2011-10-25 16:24:57 -0700 (Tue, 25 Oct 2011)
New Revision: 28836
Added:
trunk/modules/workflow-scheduler-gui/src/org/kepler/workflowscheduler/gui/configurationwizard/CompletingConfigurationListenerInterface.java
Modified:
trunk/modules/workflow-scheduler-gui/src/org/kepler/module/workflowschedulergui/Initialize.java
trunk/modules/workflow-scheduler-gui/src/org/kepler/workflowscheduler/gui/WorkflowSchedulerDialog.java
trunk/modules/workflow-scheduler-gui/src/org/kepler/workflowscheduler/gui/WorkflowSchedulerServerInstallationInfoPanel.java
trunk/modules/workflow-scheduler-gui/src/org/kepler/workflowscheduler/gui/configurationwizard/OpenWorkflowSchedulerURLConfigDialogAction.java
trunk/modules/workflow-scheduler-gui/src/org/kepler/workflowscheduler/gui/configurationwizard/WorkflowSchedulerURLConfigurationDialog.java
Log:
The gui of coinfiguring workflow scheduler url works.
Modified: trunk/modules/workflow-scheduler-gui/src/org/kepler/module/workflowschedulergui/Initialize.java
===================================================================
--- trunk/modules/workflow-scheduler-gui/src/org/kepler/module/workflowschedulergui/Initialize.java 2011-10-24 23:35:44 UTC (rev 28835)
+++ trunk/modules/workflow-scheduler-gui/src/org/kepler/module/workflowschedulergui/Initialize.java 2011-10-25 23:24:57 UTC (rev 28836)
@@ -54,27 +54,29 @@
*/
public class Initialize implements ModuleInitializer
{
- private static final String SCHEDULER = "scheduler";
- private static final String WORKFLOWRUNENGINELIST = "workflowRunEngineList";
- private static final String WORKFLOWRUNENGINE = "workflowRunEngine";
- private static final String NAME = "name";
- private static final String URL = "url";
+ public static final String SCHEDULER = "scheduler";
+ public static final String WORKFLOWRUNENGINELIST = "workflowRunEngineList";
+ public static final String WORKFLOWRUNENGINE = "workflowRunEngine";
+ public static final String NAME = "name";
+ public static final String URL = "url";
private static final String CURRENTMODULENAME = "workflow-scheduler-gui";
private static ConfigurationProperty workflowSchedulerGUIProperty = null;
private static ConfigurationManager cm = ConfigurationManager.getInstance();
private static String schedulerURL = null;
- private static String configFileLocation = null;
+ //private static String configFileLocation = null;
private static Vector<WorkflowRunEngine> workflowRunEngineList = new Vector<WorkflowRunEngine>();
+ private static Module currentModule = null;
/** Perform any module-specific initializations. */
public void initializeModule()
{
System.out.println("start of workflow-scheduler-gui module initializing");
+ currentModule = ConfigurationManager.getModule(CURRENTMODULENAME);
addLocalProperties("workflow-scheduler-gui", "uiMenuMappings", "gui");
- workflowSchedulerGUIProperty = cm.getProperty(ConfigurationManager.getModule(CURRENTMODULENAME));
+ workflowSchedulerGUIProperty = cm.getProperty(currentModule);
schedulerURL = getSchedulerURLFromConfig();
getWorkflowRunEngineListFromConfig();
- copyConfigToPersistentDir();
+ //copyConfigToPersistentDir();
}
@@ -131,7 +133,9 @@
*/
public static String getSchedulerURL()
{
- return schedulerURL;
+
+ schedulerURL = getSchedulerURLFromConfig();
+ return schedulerURL;
}
/**
@@ -140,6 +144,8 @@
*/
public static Vector<WorkflowRunEngine> getWorkflowRunEngineList()
{
+
+ getWorkflowRunEngineListFromConfig();
return workflowRunEngineList;
}
@@ -149,7 +155,9 @@
*/
public static boolean isSchedulerURLConfigured()
{
- return (schedulerURL != null && !schedulerURL.trim().equals(""));
+
+ schedulerURL = getSchedulerURLFromConfig();
+ return (schedulerURL != null && !schedulerURL.trim().equals(""));
}
@@ -159,6 +167,7 @@
*/
public static boolean isWorkflowRunEngineConfigured()
{
+ getWorkflowRunEngineListFromConfig();
return (workflowRunEngineList.size() >= 1);
}
@@ -167,9 +176,18 @@
* Get the path of the configuration file on KeplerData directory
* @return the path of the configuration file
*/
- public static String getConfigFilePath()
+ /*public static String getConfigFilePath()
{
return configFileLocation;
+ }*/
+
+ /**
+ * Get the current module
+ * @return the current module
+ */
+ public static Module getCurrentModule()
+ {
+ return currentModule;
}
/*
@@ -200,7 +218,7 @@
* Copy the configuration.xml of this module from application resource directory to kepler data
* driectory if the configuration.xml of this module doesn't exist on KeplerData directory
*/
- private static void copyConfigToPersistentDir()
+ /*private static void copyConfigToPersistentDir()
{
RootConfigurationProperty property = null;
List list = cm.getProperties(ConfigurationManager.getModule(CURRENTMODULENAME));
@@ -276,13 +294,13 @@
//System.out.println("=======NOT copy the config file of the workflow-scheduler-gui from resource to kepler data since the property is null");
}
- }
+ }*/
/*
* Get the name list of the workflow run engines
*/
- private void getWorkflowRunEngineListFromConfig()
+ private static void getWorkflowRunEngineListFromConfig()
{
ConfigurationProperty sensorViewConfiguration = Initialize.getCurrentModuleProperty();
if(sensorViewConfiguration != null)
Modified: trunk/modules/workflow-scheduler-gui/src/org/kepler/workflowscheduler/gui/WorkflowSchedulerDialog.java
===================================================================
--- trunk/modules/workflow-scheduler-gui/src/org/kepler/workflowscheduler/gui/WorkflowSchedulerDialog.java 2011-10-24 23:35:44 UTC (rev 28835)
+++ trunk/modules/workflow-scheduler-gui/src/org/kepler/workflowscheduler/gui/WorkflowSchedulerDialog.java 2011-10-25 23:24:57 UTC (rev 28836)
@@ -30,11 +30,13 @@
package org.kepler.workflowscheduler.gui;
import java.awt.BorderLayout;
+import java.awt.Container;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
+import java.util.List;
import javax.swing.Box;
import javax.swing.BoxLayout;
@@ -47,8 +49,10 @@
import org.kepler.gui.ComponentLibraryTab;
import org.kepler.gui.DualVerticalViewPane;
+import org.kepler.gui.TabPane;
import org.kepler.gui.ViewPaneLocation;
import org.kepler.module.workflowschedulergui.Initialize;
+import org.kepler.workflowscheduler.gui.configurationwizard.CompletingConfigurationListenerInterface;
import ptolemy.actor.gui.TableauFrame;
@@ -61,10 +65,11 @@
* @author tao
*
*/
-public class WorkflowSchedulerDialog extends JDialog implements ProgressBarControlInterface
+public class WorkflowSchedulerDialog extends JDialog implements ProgressBarControlInterface, CompletingConfigurationListenerInterface
{
private static final String TITLE = "Workflow Scheduler";
private static final String COMPONENTS = "Components";
+ private static final String EAST ="E";
private static final int WIDTH = 1150;
private static final int HEIGHT = 650;
public static final int PROGRESSMIN = 0;
@@ -80,6 +85,7 @@
//private boolean showedMessage = true;
private ScheduleChangeController scheduleChangeController;
private WorkflowSchedulerComponentLibraryTab componentsTab = null;
+ private DualVerticalViewPane componentAndSchedulerPane = null;
/**
* Constructor
@@ -109,7 +115,7 @@
topPanel = new JPanel();
topPanel.setLayout(new BorderLayout());
- DualVerticalViewPane componentAndSchedulerPane = new DualVerticalViewPane();
+ componentAndSchedulerPane = new DualVerticalViewPane();
try
{
componentAndSchedulerPane.initializeView();
@@ -133,26 +139,11 @@
try
{
componentAndSchedulerPane.addTabPane(componentsTab, new ViewPaneLocation("W"));
- if(Initialize.isSchedulerURLConfigured() && Initialize.isWorkflowRunEngineConfigured())
- {
- WorkflowSchedulerParentPanel schedulerPanel =
- new WorkflowSchedulerParentPanel(parent, scheduleChangeController);
- ComponentSearchResultTreeSelectionListener listener =
- new ComponentSearchResultTreeSelectionListener(schedulerPanel);
- componentsTab.addTreeSingleSelectionListener(listener);
- componentAndSchedulerPane.addTabPane(schedulerPanel, new ViewPaneLocation("E"));
- }
- else
- {
- WorkflowSchedulerServerInstallationInfoPanel informationPanel =
- new WorkflowSchedulerServerInstallationInfoPanel(parent);
- componentAndSchedulerPane.addTabPane(informationPanel, new ViewPaneLocation("E"));
- }
-
+ initRightPanel();
}
catch(Exception e)
{
- JOptionPane.showMessageDialog(parent, "Couldn't initialize the scheduler dialog - "+
+ JOptionPane.showMessageDialog(this, "Couldn't initialize the scheduler dialog - "+
e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
return;
}
@@ -191,6 +182,71 @@
addWindowListener(new DialogWindowAdapter(this));
}
+
+ /*
+ * If the workflow scheduler and run engine were configured, it will show a scheduler panel.
+ * Otherwise it will show an installation info panel
+ */
+ private void initRightPanel() throws Exception
+ {
+ if(Initialize.isSchedulerURLConfigured() && Initialize.isWorkflowRunEngineConfigured())
+ {
+ WorkflowSchedulerParentPanel schedulerPanel =
+ new WorkflowSchedulerParentPanel(parent, scheduleChangeController);
+ ComponentSearchResultTreeSelectionListener listener =
+ new ComponentSearchResultTreeSelectionListener(schedulerPanel);
+ componentsTab.addTreeSingleSelectionListener(listener);
+ componentAndSchedulerPane.addTabPane(schedulerPanel, new ViewPaneLocation(EAST));
+ }
+ else
+ {
+ WorkflowSchedulerServerInstallationInfoPanel informationPanel =
+ new WorkflowSchedulerServerInstallationInfoPanel(parent, this);
+ componentAndSchedulerPane.addTabPane(informationPanel, new ViewPaneLocation(EAST));
+ }
+
+ }
+
+
+ /**
+ * Method will be called when configuration is done
+ */
+ public void completeConfiguration()
+ {
+ try
+ {
+ //remove the old server installation info panel since the information may be incorrect after configuring the properties.
+ Container eastContainer = componentAndSchedulerPane.getLocationContainer(EAST);
+ List<TabPane> list = componentAndSchedulerPane.getTabPanes(WorkflowSchedulerParentPanel.SCHEDULER);
+ if(list != null)
+ {
+ for(TabPane pane : list)
+ {
+ if(pane instanceof WorkflowSchedulerServerInstallationInfoPanel)
+ {
+ WorkflowSchedulerServerInstallationInfoPanel infoPane = (WorkflowSchedulerServerInstallationInfoPanel)pane;
+ //System.out.println("removing the old panel");
+ eastContainer.remove(infoPane);
+ }
+ }
+ }
+ }
+ catch(Exception e)
+ {
+ return;
+ }
+ try
+ {
+ initRightPanel();
+ }
+ catch(Exception e)
+ {
+ JOptionPane.showMessageDialog(this, "Couldn't update the scheduler dialog - "+
+ e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
+ }
+ componentAndSchedulerPane.validate();
+ componentAndSchedulerPane.repaint();
+ }
/**
Modified: trunk/modules/workflow-scheduler-gui/src/org/kepler/workflowscheduler/gui/WorkflowSchedulerServerInstallationInfoPanel.java
===================================================================
--- trunk/modules/workflow-scheduler-gui/src/org/kepler/workflowscheduler/gui/WorkflowSchedulerServerInstallationInfoPanel.java 2011-10-24 23:35:44 UTC (rev 28835)
+++ trunk/modules/workflow-scheduler-gui/src/org/kepler/workflowscheduler/gui/WorkflowSchedulerServerInstallationInfoPanel.java 2011-10-25 23:24:57 UTC (rev 28836)
@@ -77,6 +77,7 @@
"<a href=\"https://kepler-project.org/developers/interest-groups/distributed/technical-documentation\">"+
"here"+"</a> for the installation instructions.";
private TableauFrame parent = null;
+ private WorkflowSchedulerDialog dialog = null;
@@ -85,9 +86,10 @@
* Constructor
* @param parent the parent TableauFrame object
*/
- public WorkflowSchedulerServerInstallationInfoPanel(TableauFrame parent)
+ public WorkflowSchedulerServerInstallationInfoPanel(TableauFrame parent, WorkflowSchedulerDialog dialog)
{
this.parent = parent;
+ this.dialog = dialog;
init();
}
@@ -102,7 +104,7 @@
this.setContentType("text/html");
this.setBackground(TabManager.BGCOLOR);
String notes = createNotes();
- System.out.println("the content =====is \n"+notes);
+ //System.out.println("the content =====is \n"+notes);
this.setText(notes);
}
/**
@@ -184,7 +186,8 @@
if(event.getURL().toString().equals(WORKFLOWSCHEDULERURL))
{
OpenWorkflowSchedulerURLConfigDialogAction action =
- new OpenWorkflowSchedulerURLConfigDialogAction(parent);
+ new OpenWorkflowSchedulerURLConfigDialogAction(dialog);
+ action.setListener(dialog);
ActionEvent e = new ActionEvent(this, 100, "Fire workflow scheduler configuration");
action.actionPerformed(e);
//System.out.println("==== the action to configure workflow scheduler url being performed");
Added: trunk/modules/workflow-scheduler-gui/src/org/kepler/workflowscheduler/gui/configurationwizard/CompletingConfigurationListenerInterface.java
===================================================================
--- trunk/modules/workflow-scheduler-gui/src/org/kepler/workflowscheduler/gui/configurationwizard/CompletingConfigurationListenerInterface.java (rev 0)
+++ trunk/modules/workflow-scheduler-gui/src/org/kepler/workflowscheduler/gui/configurationwizard/CompletingConfigurationListenerInterface.java 2011-10-25 23:24:57 UTC (rev 28836)
@@ -0,0 +1,43 @@
+/**
+ * Copyright (c) 2010 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * '$Author: tao $'
+ * '$Date: 2010-06-03 16:45:10 -0700 (Thu, 03 Jun 2010) $'
+ * '$Revision: 24730 $'
+ *
+ * Permission is hereby granted, without written agreement and without
+ * license or royalty fees, to use, copy, modify, and distribute this
+ * software and its documentation for any purpose, provided that the above
+ * copyright notice and the following two paragraphs appear in all copies
+ * of this software.
+ *
+ * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY
+ * FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
+ * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
+ * THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
+ * PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
+ * CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES,
+ * ENHANCEMENTS, OR MODIFICATIONS.
+ *
+ */
+package org.kepler.workflowscheduler.gui.configurationwizard;
+
+
+/**
+ * A listener which will be called when configuration is done
+ * @author tao
+ *
+ */
+public interface CompletingConfigurationListenerInterface
+{
+ /**
+ * Method will be called when configuration is done
+ */
+ public void completeConfiguration();
+}
Modified: trunk/modules/workflow-scheduler-gui/src/org/kepler/workflowscheduler/gui/configurationwizard/OpenWorkflowSchedulerURLConfigDialogAction.java
===================================================================
--- trunk/modules/workflow-scheduler-gui/src/org/kepler/workflowscheduler/gui/configurationwizard/OpenWorkflowSchedulerURLConfigDialogAction.java 2011-10-24 23:35:44 UTC (rev 28835)
+++ trunk/modules/workflow-scheduler-gui/src/org/kepler/workflowscheduler/gui/configurationwizard/OpenWorkflowSchedulerURLConfigDialogAction.java 2011-10-25 23:24:57 UTC (rev 28836)
@@ -37,6 +37,7 @@
public class OpenWorkflowSchedulerURLConfigDialogAction
{
private Window parent = null;
+ private CompletingConfigurationListenerInterface completeListener = null;
/**
* Constructor
@@ -46,6 +47,15 @@
{
this.parent = parent;
}
+
+ /**
+ * Set the completing listener
+ * @param completeListener
+ */
+ public void setListener(CompletingConfigurationListenerInterface completeListener)
+ {
+ this.completeListener = completeListener;
+ }
/**
* Open a workflow scheduler dialog box
@@ -55,7 +65,7 @@
if (parent == null) {
parent = GUIUtil.getParentWindow((Component) e.getSource());
}
- WorkflowSchedulerURLConfigurationDialog dialog = new WorkflowSchedulerURLConfigurationDialog(parent);
+ WorkflowSchedulerURLConfigurationDialog dialog = new WorkflowSchedulerURLConfigurationDialog(parent, completeListener);
}
Modified: trunk/modules/workflow-scheduler-gui/src/org/kepler/workflowscheduler/gui/configurationwizard/WorkflowSchedulerURLConfigurationDialog.java
===================================================================
--- trunk/modules/workflow-scheduler-gui/src/org/kepler/workflowscheduler/gui/configurationwizard/WorkflowSchedulerURLConfigurationDialog.java 2011-10-24 23:35:44 UTC (rev 28835)
+++ trunk/modules/workflow-scheduler-gui/src/org/kepler/workflowscheduler/gui/configurationwizard/WorkflowSchedulerURLConfigurationDialog.java 2011-10-25 23:24:57 UTC (rev 28836)
@@ -36,6 +36,9 @@
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
+import java.io.InputStream;
+import java.net.URL;
+import java.net.URLConnection;
import javax.swing.BorderFactory;
import javax.swing.Box;
@@ -43,9 +46,15 @@
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.configuration.ConfigurationManager;
+import org.kepler.configuration.ConfigurationManagerException;
+import org.kepler.configuration.ConfigurationProperty;
+import org.kepler.configuration.NamespaceException;
+import org.kepler.module.workflowschedulergui.Initialize;
import org.kepler.workflowscheduler.gui.WorkflowSchedulerPanel;
/**
@@ -66,14 +75,17 @@
private GridBagConstraints labelConstraint = null;
private GridBagConstraints lastConstraint = null;
private JTextField urlTextField = null;
+ private CompletingConfigurationListenerInterface completeListener = null;
/**
* Constructor
*/
- public WorkflowSchedulerURLConfigurationDialog(Window parent)
+ public WorkflowSchedulerURLConfigurationDialog(Window parent,
+ CompletingConfigurationListenerInterface completeListener)
{
super(parent);
this.parent = parent;
+ this.completeListener = completeListener;
init();
this.pack();
this.setVisible(true);
@@ -167,14 +179,111 @@
{
public void actionPerformed(ActionEvent e)
{
- dispose();
+ try
+ {
+ modifyWorkflowSchedulerURLToConfig();
+ }
+ catch(Exception ee)
+ {
+ JOptionPane.showMessageDialog(null, "Couldn't configure the scheduler url - "+ee.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
+ }
}
});
buttonPanel.add(addButton);
add(buttonPanel, BorderLayout.SOUTH);
}
+
/*
+ * Add the new url or modify the existing url to the configuration file
+ */
+ private void modifyWorkflowSchedulerURLToConfig() throws ConfigurationManagerException, NamespaceException
+ {
+ String newURL = urlTextField.getText();
+ if(openURL(newURL))
+ {
+ ConfigurationProperty rootProperty = Initialize.getCurrentModuleProperty();
+ ConfigurationProperty schedulerProperty = rootProperty.getProperty(Initialize.SCHEDULER);
+ if(schedulerProperty != null)
+ {
+ ConfigurationProperty urlProperty = schedulerProperty.getProperty(Initialize.URL);
+ if(urlProperty != null)
+ {
+ urlProperty.setValue(newURL);
+ }
+ else
+ {
+ //add url property to the eixsting scheduler property
+ urlProperty = new ConfigurationProperty(Initialize.getCurrentModule(), Initialize.URL, newURL);
+ schedulerProperty.addProperty(urlProperty);
+ }
+
+ }
+ else
+ {
+ //add a new scheduler property
+ schedulerProperty = new ConfigurationProperty(Initialize.getCurrentModule(), Initialize.SCHEDULER);
+ ConfigurationProperty urlProperty = new ConfigurationProperty(Initialize.getCurrentModule(), Initialize.URL, newURL);
+ schedulerProperty.addProperty(urlProperty);
+ rootProperty.addProperty(schedulerProperty);
+ }
+ //System.out.println("the root property is dirty "+rootProperty.isDirty());
+ //ConfigurationManager.getInstance().saveConfiguration();
+ if(completeListener != null)
+ {
+ //System.out.println("calling complete method .....");
+ completeListener.completeConfiguration();
+ }
+ dispose();
+ }
+ }
+
+ /*
+ * Check if the specified url openable
+ */
+ private boolean openURL(String urlStr)
+ {
+ boolean openable = false;
+ String error=".";
+ try
+ {
+ URL url = new URL(urlStr);
+ URLConnection connection = url.openConnection();
+ if(connection != null)
+ {
+ //System.out.println("connection is not null");
+ InputStream input = connection.getInputStream();
+ //System.out.println("after getting connection l");
+ if(input != null)
+ {
+ openable = true;
+ //System.out.println("input is NOT null");
+ }
+ else
+ {
+ //System.out.println("input is null");
+ }
+ //System.out.println("reach the endl");
+ }
+
+ }
+ catch(Exception e)
+ {
+ error =" \nsince "+ e.getMessage()+".";
+ }
+ if(!openable)
+ {
+ int choice = JOptionPane.showConfirmDialog(this, "Couldn't connect to the server "+
+ urlStr+error+"\nDo you still want to add this url to the configuration file?", TITLE, JOptionPane.YES_NO_OPTION);
+ if (choice == JOptionPane.YES_OPTION)
+ {
+ openable = true;
+ }
+ }
+ return openable;
+ }
+
+ /*
*Add leading space in each row of a panel
*/
static void addLeadingSpace(JPanel panel, GridBagLayout layout, GridBagConstraints labelConstraint)
@@ -196,4 +305,6 @@
JLabel leadingLabel = new JLabel(space);
WorkflowSchedulerPanel.addComponent(panel, leadingLabel, layout, lastConstraint);
}
+
+
}
More information about the Kepler-cvs
mailing list