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

tao at ecoinformatics.org tao at ecoinformatics.org
Fri Oct 21 17:03:03 PDT 2011


Author: tao
Date: 2011-10-21 17:03:03 -0700 (Fri, 21 Oct 2011)
New Revision: 28831

Added:
   releases/release-branches/workflow-scheduler-gui-1.0/src/org/kepler/workflowscheduler/gui/WorkflowSchedulerServerInstallationInfoPanel.java
Modified:
   releases/release-branches/workflow-scheduler-gui-1.0/src/org/kepler/workflowscheduler/gui/WorkflowSchedulerDialog.java
   releases/release-branches/workflow-scheduler-gui-1.0/src/org/kepler/workflowscheduler/gui/WorkflowSchedulerParentPanel.java
Log:
merge change to the branch.


Modified: releases/release-branches/workflow-scheduler-gui-1.0/src/org/kepler/workflowscheduler/gui/WorkflowSchedulerDialog.java
===================================================================
--- releases/release-branches/workflow-scheduler-gui-1.0/src/org/kepler/workflowscheduler/gui/WorkflowSchedulerDialog.java	2011-10-22 00:00:15 UTC (rev 28830)
+++ releases/release-branches/workflow-scheduler-gui-1.0/src/org/kepler/workflowscheduler/gui/WorkflowSchedulerDialog.java	2011-10-22 00:03:03 UTC (rev 28831)
@@ -48,6 +48,7 @@
 import org.kepler.gui.ComponentLibraryTab;
 import org.kepler.gui.DualVerticalViewPane;
 import org.kepler.gui.ViewPaneLocation;
+import org.kepler.module.workflowschedulergui.Initialize;
 
 import ptolemy.actor.gui.TableauFrame;
 
@@ -119,15 +120,11 @@
           e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
       return;
     }
-    WorkflowSchedulerParentPanel schedulerPanel = 
-                                          new WorkflowSchedulerParentPanel(parent, scheduleChangeController);
+   
     componentsTab = new WorkflowSchedulerComponentLibraryTab(parent);
     componentsTab.initializeTab();
     //componentsTab.setPreferredSize(new Dimension(200, HEIGHT));
     componentsTab.setTabName(COMPONENTS);
-    ComponentSearchResultTreeSelectionListener listener = 
-                                new ComponentSearchResultTreeSelectionListener(schedulerPanel);
-    componentsTab.addTreeSingleSelectionListener(listener);
     componentsTab.setSkipReposiotryOntology(true);
     scheduleChangeController.setComponentLibraryTab(componentsTab);
     //jTree = componentsTab.getJTree();
@@ -136,7 +133,22 @@
     try
     {
       componentAndSchedulerPane.addTabPane(componentsTab, new ViewPaneLocation("W"));
-      componentAndSchedulerPane.addTabPane(schedulerPanel, new ViewPaneLocation("E"));
+      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"));
+      }
+      
     }
     catch(Exception e)
     {

Modified: releases/release-branches/workflow-scheduler-gui-1.0/src/org/kepler/workflowscheduler/gui/WorkflowSchedulerParentPanel.java
===================================================================
--- releases/release-branches/workflow-scheduler-gui-1.0/src/org/kepler/workflowscheduler/gui/WorkflowSchedulerParentPanel.java	2011-10-22 00:00:15 UTC (rev 28830)
+++ releases/release-branches/workflow-scheduler-gui-1.0/src/org/kepler/workflowscheduler/gui/WorkflowSchedulerParentPanel.java	2011-10-22 00:03:03 UTC (rev 28831)
@@ -61,7 +61,7 @@
 {
   private static final Log log = LogFactory.getLog(WorkflowSchedulerParentPanel.class
       .getName());
-  private static final String SCHEDULER = "Scheduler";
+  static final String SCHEDULER = "Scheduler";
   private static final int ITEM = 0;
   
   private JLabel message = new JLabel("Select a workflow from the Components panel.");

Added: releases/release-branches/workflow-scheduler-gui-1.0/src/org/kepler/workflowscheduler/gui/WorkflowSchedulerServerInstallationInfoPanel.java
===================================================================
--- releases/release-branches/workflow-scheduler-gui-1.0/src/org/kepler/workflowscheduler/gui/WorkflowSchedulerServerInstallationInfoPanel.java	                        (rev 0)
+++ releases/release-branches/workflow-scheduler-gui-1.0/src/org/kepler/workflowscheduler/gui/WorkflowSchedulerServerInstallationInfoPanel.java	2011-10-22 00:03:03 UTC (rev 28831)
@@ -0,0 +1,200 @@
+package org.kepler.workflowscheduler.gui;
+
+import java.awt.Desktop;
+import java.io.IOException;
+import java.lang.reflect.Method;
+import java.net.URISyntaxException;
+import java.util.regex.Pattern;
+
+import javax.swing.JLabel;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.JTextArea;
+import javax.swing.JTextPane;
+import javax.swing.event.HyperlinkEvent;
+import javax.swing.event.HyperlinkListener;
+
+import org.apache.commons.lang.StringEscapeUtils;
+import org.kepler.gui.TabManager;
+import org.kepler.gui.TabPane;
+import org.kepler.module.workflowschedulergui.Initialize;
+
+import com.sun.jndi.toolkit.url.UrlUtil;
+
+
+import ptolemy.actor.gui.TableauFrame;
+
+
+/**
+ * This panel will show the information for user to how to configure the configuration file
+ * and install workflow scheduler server and workflow run engine.
+ * @author tao
+ *
+ */
+public class WorkflowSchedulerServerInstallationInfoPanel  extends JTextPane implements TabPane
+{
+  
+  private static final String NOTE1= "<br><br>Kepler detects that ";
+  private static final String NOTE2NOSCHEDULER = "the workflow scheduler part hasn't been configured.";
+  private static final String NOTE2NOENGINE = "the workflow run engine part hasn't been configured.";
+  private static final String NOTE2NOSCHEDULERENGINE = "both the workflow scheduler and the workflow run engine parts haven't been configured.";
+  private static final String NOTE3 = "<br>Please quit the Kepler and modify the file at ";
+  private static final String NOTE4 ="<br>If either Workflow Schedulr server or Workflow Run Engine is not available, please click "+
+                                                          "<a href=\"https://kepler-project.org/developers/interest-groups/distributed/technical-documentation\">"+
+                                                           "here"+"</a> for the installation instructions.";
+  private TableauFrame parent = null;
+  
+
+
+  
+  /**
+   * Constructor
+   * @param parent the parent TableauFrame object
+   */
+  public WorkflowSchedulerServerInstallationInfoPanel(TableauFrame parent)
+  {
+    this.parent = parent;
+    init();
+  }
+  
+  /*
+   * Initialize the panel
+   */
+  private void init()
+  {
+    
+    this.setEditable(false);
+    this.addHyperlinkListener(new UrlHyperlinkListener());
+    this.setContentType("text/html");
+    this.setBackground(TabManager.BGCOLOR);
+    String notes = createNotes();
+    System.out.println("the content =====is \n"+notes);
+    this.setText(notes);
+  }
+  /**
+   * Return the parent frame
+   */
+  public TableauFrame getParentFrame()
+  {
+    return parent;
+  }
+
+  /**
+   * This method should return the name of the tab which is used to label the
+   * tab in the TabbedPane
+   */
+  public String getTabName()
+  {    
+    return WorkflowSchedulerParentPanel.SCHEDULER;
+  }
+
+  /**
+   * Initialize the tab
+   */
+  public void initializeTab() throws Exception
+  {
+    
+  }
+
+  /**
+   * Set the parent frame of this panel
+   */
+  public void setParentFrame(TableauFrame parent)
+  {
+    this.parent = parent;
+  }
+  
+ 
+  /*
+   * Create the notes.
+   */
+  private String createNotes()
+  {
+    StringBuilder answer = new StringBuilder();
+    answer.append(NOTE1);
+    if(!Initialize.isSchedulerURLConfigured() && !Initialize.isWorkflowRunEngineConfigured())
+    {
+      answer.append(NOTE2NOSCHEDULERENGINE);
+    }
+    else if(!Initialize.isSchedulerURLConfigured())
+    {
+      answer.append(NOTE2NOSCHEDULER);
+    }
+    else if(!Initialize.isWorkflowRunEngineConfigured())
+    {
+      answer.append(NOTE2NOENGINE);
+    }
+    answer.append(NOTE3);
+    answer.append(StringEscapeUtils.escapeHtml(Initialize.getConfigFilePath())+".");
+    answer.append(NOTE4);
+    return addHTMLTag(answer.toString());
+  }
+ 
+  /*
+   * Listener to open the url link
+   */
+  private class UrlHyperlinkListener implements HyperlinkListener 
+  {
+    @Override
+    public void hyperlinkUpdate (HyperlinkEvent event) 
+    {
+      if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) 
+      {
+        openURL(event.getURL().toString());
+      }
+    }
+  }
+  
+  /*
+   * Add html tag for the input
+   */
+  private String addHTMLTag(String input)
+  {
+    StringBuilder answer = new StringBuilder();
+    answer.append("<html><body bgcolor=\"rgb("+TabManager.BGCOLOR.getRed()+
+        ","+TabManager.BGCOLOR.getGreen()+","+TabManager.BGCOLOR.getBlue()+")\"/>");
+    answer.append(input);
+    answer.append("</body></html>");
+    return answer.toString();
+
+  }
+
+  /*
+   * open a given url
+   */
+  private static void openURL(String url) 
+  {
+    String osName = System.getProperty("os.name");
+    try 
+    {
+       if (osName.startsWith("Mac OS")) 
+       {
+          Class fileMgr = Class.forName("com.apple.eio.FileManager");
+          Method openURL = fileMgr.getDeclaredMethod("openURL",
+             new Class[] {String.class});
+          openURL.invoke(null, new Object[] {url});
+       }
+       else if (osName.startsWith("Windows"))
+       {
+         Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + url);
+       }      
+       else 
+       { //assume Unix or Linux
+          String[] browsers = {
+             "firefox", "opera", "konqueror", "epiphany", "mozilla", "netscape" };
+          String browser = null;
+          for (int count = 0; count < browsers.length && browser == null; count++)
+             if (Runtime.getRuntime().exec(
+                   new String[] {"which", browsers[count]}).waitFor() == 0)
+                browser = browsers[count];
+          if (browser == null)
+             throw new Exception("Could not find web browser");
+          else
+             Runtime.getRuntime().exec(new String[] {browser, url});
+          }
+       }
+       catch (Exception e) {
+       JOptionPane.showMessageDialog(null, "Error attempting to launch web browser" + ":\n" + e.getLocalizedMessage());
+       }
+    }
+}



More information about the Kepler-cvs mailing list