You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by la...@apache.org on 2011/11/03 15:24:05 UTC
svn commit: r1197132 [1/2] - in
/incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya:
appwrapper/ component/gui/ experiment/gui/ gui/ menues/ menues/edit/
menues/registry/ menues/run/ menues/view/ menues/xbaya/ monitor/gu...
Author: lahiru
Date: Thu Nov 3 14:24:03 2011
New Revision: 1197132
URL: http://svn.apache.org/viewvc?rev=1197132&view=rev
Log:
https://issues.apache.org/jira/browse/AIRAVATA-102
Added:
incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/menues/ (with props)
incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/menues/edit/ (with props)
incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/menues/edit/EditMenuItem.java
incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/menues/registry/ (with props)
incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/menues/registry/RegistryMenuItem.java
incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/menues/run/ (with props)
incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/menues/run/RunMenuItem.java
incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/menues/view/ (with props)
incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/menues/view/ViewMenuItem.java
incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/menues/xbaya/ (with props)
incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/menues/xbaya/BPELFiler.java
incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/menues/xbaya/ImageFiler.java
incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/menues/xbaya/JythonFiler.java
incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/menues/xbaya/ODEScriptFiler.java
incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/menues/xbaya/ScuflFiler.java
incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/menues/xbaya/WorkflowFiler.java
incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/menues/xbaya/XBayaMenuItem.java
Modified:
incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/appwrapper/RegisterApplicationsMenu.java
incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/component/gui/ComponentMenu.java
incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/experiment/gui/ExperimentMenu.java
incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/gui/XBayaGUI.java
incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/gui/XBayaMenu.java
incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/monitor/gui/MonitorMenu.java
incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/wf/gui/WorkflowMenu.java
Modified: incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/appwrapper/RegisterApplicationsMenu.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/appwrapper/RegisterApplicationsMenu.java?rev=1197132&r1=1197131&r2=1197132&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/appwrapper/RegisterApplicationsMenu.java (original)
+++ incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/appwrapper/RegisterApplicationsMenu.java Thu Nov 3 14:24:03 2011
@@ -38,12 +38,6 @@ public class RegisterApplicationsMenu {
private JMenu registerApplicationsMenu;
- private JMenuItem registerServiceDesc;
-
- private JMenuItem registerApplicationDesc;
-
- private JMenuItem registerHostDesc;
-
private JMenuItem registerThroughFile;
private JMenuItem searchAndEdit;
@@ -71,18 +65,12 @@ public class RegisterApplicationsMenu {
private void createRegsiterApplicationsMenu() {
- createRegisterHostDesc();
- createRegisterServiceDesc();
- createRegisterApplicationDesc();
createRegisterThroughFile();
createSearchAndEdit();
this.registerApplicationsMenu = new JMenu("Register Applications");
this.registerApplicationsMenu.setMnemonic(KeyEvent.VK_P);
- this.registerApplicationsMenu.add(this.registerHostDesc);
- this.registerApplicationsMenu.add(this.registerServiceDesc);
- this.registerApplicationsMenu.add(this.registerApplicationDesc);
this.registerApplicationsMenu.add(this.registerThroughFile);
this.registerApplicationsMenu.addSeparator();
this.registerApplicationsMenu.add(this.searchAndEdit);
@@ -122,72 +110,6 @@ public class RegisterApplicationsMenu {
});
}
- private void createRegisterServiceDesc() {
- this.registerServiceDesc = new JMenuItem("Register Application Service Description");
-
- this.registerServiceDesc.addActionListener(new AbstractAction() {
-
- @Override
- public void actionPerformed(ActionEvent e) {
- if (XBayaUtil.acquireJCRRegistry(engine)) {
- try {
- ServiceDescriptionDialog serviceDescriptionDialog = new ServiceDescriptionDialog(
- RegisterApplicationsMenu.this.engine.getConfiguration().getJcrComponentRegistry()
- .getRegistry());
- serviceDescriptionDialog.open();
- } catch (Exception e1) {
- RegisterApplicationsMenu.this.engine.getErrorWindow().error(e1);
- }
- }
- }
- });
-
- }
-
- private void createRegisterApplicationDesc() {
- this.registerApplicationDesc = new JMenuItem("Register Application Deployment Description");
-
- this.registerApplicationDesc.addActionListener(new AbstractAction() {
-
- @Override
- public void actionPerformed(ActionEvent e) {
- if (XBayaUtil.acquireJCRRegistry(engine)) {
- try {
- ApplicationDescriptionDialog applicationDescriptionDialog = new ApplicationDescriptionDialog(
- RegisterApplicationsMenu.this.engine);
- applicationDescriptionDialog.open();
- } catch (Exception e1) {
- RegisterApplicationsMenu.this.engine.getErrorWindow().error(e1);
- }
- }
- }
- });
-
- }
-
- private void createRegisterHostDesc() {
- this.registerHostDesc = new JMenuItem("Register Compute/Service Host Description");
-
- this.registerHostDesc.addActionListener(new AbstractAction() {
-
- @Override
- public void actionPerformed(ActionEvent e) {
- if (XBayaUtil.acquireJCRRegistry(engine)) {
- try {
- HostDescriptionDialog hostDescriptionDialog = new HostDescriptionDialog(
- RegisterApplicationsMenu.this.engine);
- // TODO : should remove this
- //hostDescriptionDialog.open();
- hostDescriptionDialog.show();
- } catch (Exception e1) {
- RegisterApplicationsMenu.this.engine.getErrorWindow().error(e1);
- }
- }
- }
- });
-
- }
-
private void createSearchAndEdit() {
this.searchAndEdit = new JMenuItem("Search and Edit Description");
Modified: incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/component/gui/ComponentMenu.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/component/gui/ComponentMenu.java?rev=1197132&r1=1197131&r2=1197132&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/component/gui/ComponentMenu.java (original)
+++ incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/component/gui/ComponentMenu.java Thu Nov 3 14:24:03 2011
@@ -66,8 +66,6 @@ public class ComponentMenu {
private JMenuItem workflowItem;
- private JMenuItem jcrRegistryItem;
-
private JMenuItem globusFileTransferItem;
/**
@@ -91,7 +89,6 @@ public class ComponentMenu {
private void createComponentMenu() {
this.fileRegistryItem = createFileRegistryMenuItem();
this.globusFileTransferItem = createGlobusFileTransferItem();
- this.jcrRegistryItem = createJCRRegistryItem();
this.webItem = createWebRegistryItem();
this.urlItem = createURLRegistryItem();
this.workflowItem = createWorkflowItem();
@@ -102,7 +99,6 @@ public class ComponentMenu {
this.componentMenu = new JMenu("Component");
this.componentMenu.setMnemonic(KeyEvent.VK_C);
this.componentMenu.add(this.fileRegistryItem);
- this.componentMenu.add(this.jcrRegistryItem);
this.componentMenu.add(this.globusFileTransferItem);
this.componentMenu.add(this.webItem);
this.componentMenu.add(this.urlItem);
@@ -273,22 +269,6 @@ public class ComponentMenu {
return item;
}
- private JMenuItem createJCRRegistryItem() {
- JMenuItem item = new JMenuItem("Set Registry");
- item.setMnemonic(KeyEvent.VK_J);
- item.addActionListener(new AbstractAction() {
- private JCRRegistryWindow window;
-
- public void actionPerformed(ActionEvent e) {
- if (this.window == null) {
- this.window = new JCRRegistryWindow(ComponentMenu.this.engine);
- }
- this.window.show();
- }
- });
- return item;
- }
-
private JMenuItem createGlobusFileTransferItem() {
JMenuItem item = new JMenuItem("Globus File Transfer");
item.setMnemonic(KeyEvent.VK_J);
Modified: incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/experiment/gui/ExperimentMenu.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/experiment/gui/ExperimentMenu.java?rev=1197132&r1=1197131&r2=1197132&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/experiment/gui/ExperimentMenu.java (original)
+++ incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/experiment/gui/ExperimentMenu.java Thu Nov 3 14:24:03 2011
@@ -43,16 +43,8 @@ public class ExperimentMenu {
private JMenuItem configureRegistryItem;
- private JMenuItem loadWorkflowfromRegistryItem;
-
- private JMenuItem saveWorkflowtoRegistryItem;
-
private JMenuItem deleteWorkflowfromRegistryItem;
- private JMenuItem launchXBayaInterpreterItem;
-
- private JMenuItem launchGridChemWorkflowItem;
-
private XBayaEngine engine;
/**
@@ -71,24 +63,16 @@ public class ExperimentMenu {
private void createExperimentMenu() {
createConfigureRegistryItem();
- createLoadWorkflowfromRegistryItem();
- createSaveWorkflowtoRegistryItem();
createDeleteWorkflowtoRegistryItem();
- createLaunchXBayaInterpreterItem();
- createLaunchGridChemWorkflowItem();
this.experimentMenu = new JMenu("Experiment");
this.experimentMenu.setMnemonic(KeyEvent.VK_F);
this.experimentMenu.add(this.configureRegistryItem);
this.experimentMenu.addSeparator();
- this.experimentMenu.add(this.loadWorkflowfromRegistryItem);
- this.experimentMenu.add(this.saveWorkflowtoRegistryItem);
this.experimentMenu.add(this.deleteWorkflowfromRegistryItem);
this.experimentMenu.addSeparator();
- this.experimentMenu.add(this.launchXBayaInterpreterItem);
this.experimentMenu.addSeparator();
- this.experimentMenu.add(this.launchGridChemWorkflowItem);
}
/**
@@ -113,26 +97,6 @@ public class ExperimentMenu {
});
}
- private void createLoadWorkflowfromRegistryItem() {
- this.loadWorkflowfromRegistryItem = new JMenuItem("Load Workflow from Registry");
- this.loadWorkflowfromRegistryItem.addActionListener(new AbstractAction() {
- public void actionPerformed(ActionEvent e) {
- new RegistryLoaderWindow(ExperimentMenu.this.engine).show();
-
- }
- });
- }
-
- private void createSaveWorkflowtoRegistryItem() {
- this.saveWorkflowtoRegistryItem = new JMenuItem("Save Workflow to Registry");
- this.saveWorkflowtoRegistryItem.setMnemonic(KeyEvent.VK_C);
- this.saveWorkflowtoRegistryItem.addActionListener(new AbstractAction() {
- public void actionPerformed(ActionEvent e) {
- ExperimentMenu.this.registryAccesser.saveWorkflow();
- }
- });
- }
-
private void createDeleteWorkflowtoRegistryItem() {
this.deleteWorkflowfromRegistryItem = new JMenuItem("Delete Workflows in Registry");
this.deleteWorkflowfromRegistryItem.addActionListener(new AbstractAction() {
@@ -147,34 +111,4 @@ public class ExperimentMenu {
});
}
- private void createLaunchXBayaInterpreterItem() {
- this.launchXBayaInterpreterItem = new JMenuItem("Launch Workflow to XBaya Interpreter Server");
- launchXBayaInterpreterItem.addActionListener(new AbstractAction() {
- private WorkflowInterpreterLaunchWindow window;
-
- public void actionPerformed(ActionEvent e) {
- if (this.window == null) {
- this.window = new WorkflowInterpreterLaunchWindow(ExperimentMenu.this.engine);
- }
- try {
- this.window.show();
- } catch (Exception e1) {
- ExperimentMenu.this.engine.getErrorWindow().error(e1);
- }
-
- }
- });
- }
-
- /**
- *
- */
- private void createLaunchGridChemWorkflowItem() {
- this.launchGridChemWorkflowItem = new JMenuItem("Launch Workflow and Register with GridChem");
- // TODO Add the following operations
- // First Call OGCE-GridChem-Bridge Service to register an experiment
- // Set lead context header with all the required notifier context
- // call launch workflow
-
- }
}
\ No newline at end of file
Modified: incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/gui/XBayaGUI.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/gui/XBayaGUI.java?rev=1197132&r1=1197131&r2=1197132&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/gui/XBayaGUI.java (original)
+++ incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/gui/XBayaGUI.java Thu Nov 3 14:24:03 2011
@@ -199,7 +199,11 @@ public class XBayaGUI implements EventLi
*/
public GraphCanvas getGraphCanvas() {
int index = this.graphTabbedPane.getSelectedIndex();
- return this.graphCanvases.get(index);
+ if (index!=-1) {
+ return this.graphCanvases.get(index);
+ }else{
+ return null;
+ }
}
/**
@@ -296,17 +300,27 @@ public class XBayaGUI implements EventLi
* This method needs to be called by Swing event thread.
*/
public void closeGraphCanvas() {
- if (this.graphTabbedPane.getTabCount() == 1) {
- // Do not remove the last tab. Create a new workflow instead.
- getGraphCanvas().newWorkflow();
- } else {
- int index = this.graphTabbedPane.getSelectedIndex();
- this.graphCanvases.remove(index);
- this.graphTabbedPane.removeTabAt(index);
- activeTabChanged();
- }
- }
-
+ removeGraphCanvasFromIndex(this.graphTabbedPane.getSelectedIndex());
+ //I dont know why but aparently you have to have atleast one tab present
+ newGraphCanvas(true);
+ }
+
+ public void closeAllGraphCanvas(){
+ while (graphTabbedPane.getTabCount()>0){
+ removeGraphCanvasFromIndex(0);
+ }
+ //I dont know why but aparently you have to have atleast one tab present
+ newGraphCanvas(true);
+ }
+
+ private void removeGraphCanvasFromIndex(int index) {
+ if ((graphTabbedPane.getTabCount()>0) && (index<this.graphTabbedPane.getTabCount())){
+ graphCanvases.remove(index);
+ graphTabbedPane.removeTabAt(index);
+ activeTabChanged();
+ }
+ }
+
/**
* Selects the next graph canvas.
*
@@ -664,24 +678,26 @@ public class XBayaGUI implements EventLi
private void activeTabChanged() {
GraphCanvas graphPanel = getGraphCanvas();
- // Reset the port viewers.
- Port inputPort = graphPanel.getSelectedInputPort();
- Port outputPort = graphPanel.getSelectedOutputPort();
- this.portViewer.setInputPort(inputPort);
- this.portViewer.setOutputPort(outputPort);
-
- // Reset component viewer.
- Node node = graphPanel.getSelectedNode();
- Component component;
- if (node != null) {
- component = node.getComponent();
- } else {
- component = this.componentSelector.getSelectedComponent();
- }
- this.componentViewer.setComponent(component);
-
- String name = graphPanel.getWorkflow().getName();
- setFrameName(name);
+ if (graphPanel!=null) {
+ // Reset the port viewers.
+ Port inputPort = graphPanel.getSelectedInputPort();
+ Port outputPort = graphPanel.getSelectedOutputPort();
+ this.portViewer.setInputPort(inputPort);
+ this.portViewer.setOutputPort(outputPort);
+ // Reset component viewer.
+ Node node = graphPanel.getSelectedNode();
+ Component component;
+ if (node != null) {
+ component = node.getComponent();
+ } else {
+ component = this.componentSelector.getSelectedComponent();
+ }
+ this.componentViewer.setComponent(component);
+ String name = graphPanel.getWorkflow().getName();
+ setFrameName(name);
+ }else{
+ //TODO what to do when no tabs are present???
+ }
}
public ComponentViewer getComponentVIewer() {
Modified: incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/gui/XBayaMenu.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/gui/XBayaMenu.java?rev=1197132&r1=1197131&r2=1197132&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/gui/XBayaMenu.java (original)
+++ incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/gui/XBayaMenu.java Thu Nov 3 14:24:03 2011
@@ -38,8 +38,12 @@ import org.apache.airavata.xbaya.compone
import org.apache.airavata.xbaya.experiment.gui.ExperimentMenu;
import org.apache.airavata.xbaya.file.gui.FileMenu;
import org.apache.airavata.xbaya.gpel.gui.GPELMenu;
+import org.apache.airavata.xbaya.menues.edit.EditMenuItem;
+import org.apache.airavata.xbaya.menues.registry.RegistryMenuItem;
+import org.apache.airavata.xbaya.menues.run.RunMenuItem;
+import org.apache.airavata.xbaya.menues.view.ViewMenuItem;
+import org.apache.airavata.xbaya.menues.xbaya.XBayaMenuItem;
import org.apache.airavata.xbaya.monitor.gui.MonitorMenu;
-import org.apache.airavata.xbaya.myproxy.gui.MyProxyMenu;
import org.apache.airavata.xbaya.pegasus.gui.PegasusMenu;
import org.apache.airavata.xbaya.wf.gui.WorkflowMenu;
@@ -69,6 +73,16 @@ public class XBayaMenu implements XBayaC
private RegisterApplicationsMenu registerApplications;
+ private XBayaMenuItem xBayaMenuItem;
+
+ private EditMenuItem editMenuItem;
+
+ private ViewMenuItem viewMenuItem;
+
+ private RunMenuItem runMenuItem;
+
+ private RegistryMenuItem registryMenuItem;
+
/**
* Constructs an XwfMenu.
*
@@ -78,6 +92,13 @@ public class XBayaMenu implements XBayaC
this.engine = engine;
this.fileMenu = new FileMenu(this.engine);
+
+ xBayaMenuItem = new XBayaMenuItem(engine);
+ editMenuItem = new EditMenuItem(engine);
+ viewMenuItem = new ViewMenuItem(engine);
+ runMenuItem = new RunMenuItem(engine);
+ registryMenuItem = new RegistryMenuItem(engine);
+
this.workflowMenu = new WorkflowMenu(this.engine);
this.experimentMenu = new ExperimentMenu(this.engine);
this.amazonEC2Menu = new AmazonEC2Menu(this.engine);
@@ -104,15 +125,20 @@ public class XBayaMenu implements XBayaC
private void createMenuBar() {
this.menuBar = new JMenuBar();
-
- this.menuBar.add(this.fileMenu.getMenu());
- this.menuBar.add(this.workflowMenu.getMenu());
- this.menuBar.add(this.componentMenu.getMenu());
- this.menuBar.add(this.experimentMenu.getMenu());
- this.menuBar.add(this.amazonEC2Menu.getMenu());
- // this.menuBar.add(this.myProxyMenu.getMenu());
- this.menuBar.add(this.monitorMenu.getMenu());
- this.menuBar.add(this.registerApplications.getMenu());
+ menuBar.add(xBayaMenuItem.getMenu());
+ menuBar.add(editMenuItem.getMenu());
+ menuBar.add(viewMenuItem.getMenu());
+ menuBar.add(runMenuItem.getMenu());
+ menuBar.add(registryMenuItem.getMenu());
+
+// this.menuBar.add(this.fileMenu.getMenu());
+// this.menuBar.add(this.workflowMenu.getMenu());
+// this.menuBar.add(this.componentMenu.getMenu());
+// this.menuBar.add(this.experimentMenu.getMenu());
+// this.menuBar.add(this.amazonEC2Menu.getMenu());
+// // this.menuBar.add(this.myProxyMenu.getMenu());
+// this.menuBar.add(this.monitorMenu.getMenu());
+// this.menuBar.add(this.registerApplications.getMenu());
// Space before Help
this.menuBar.add(Box.createHorizontalGlue());
Propchange: incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/menues/
------------------------------------------------------------------------------
bugtraq:number = true
Propchange: incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/menues/edit/
------------------------------------------------------------------------------
bugtraq:number = true
Added: incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/menues/edit/EditMenuItem.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/menues/edit/EditMenuItem.java?rev=1197132&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/menues/edit/EditMenuItem.java (added)
+++ incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/menues/edit/EditMenuItem.java Thu Nov 3 14:24:03 2011
@@ -0,0 +1,157 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.xbaya.menues.edit;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.KeyEvent;
+
+import javax.swing.AbstractAction;
+import javax.swing.JMenu;
+import javax.swing.JMenuItem;
+
+import org.apache.airavata.xbaya.XBayaEngine;
+import org.apache.airavata.xbaya.wf.gui.ParameterPropertyWindow;
+import org.apache.airavata.xbaya.wf.gui.WorkflowPropertyWindow;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class EditMenuItem {
+
+ private XBayaEngine engine;
+
+ private JMenu editMenu;
+
+ private JMenuItem workflowDescriptionItem;
+
+ private JMenuItem parameterReorderingItem;
+
+ private JMenuItem editHostDescription;
+
+ private JMenuItem editServiceDescription;
+
+ private JMenuItem editApplicationDescription;
+
+ private static final Logger logger = LoggerFactory.getLogger(EditMenuItem.class);
+
+ /**
+ * Constructs a WorkflowMenu.
+ *
+ * @param engine
+ */
+ public EditMenuItem(XBayaEngine engine) {
+ this.engine = engine;
+ createWorkflowMenu();
+ }
+
+ /**
+ * @return The workflow menu.
+ */
+ public JMenu getMenu() {
+ return this.editMenu;
+ }
+
+ /**
+ * Creates workflow menu.
+ */
+ private void createWorkflowMenu() {
+ this.workflowDescriptionItem = createWorkflowDescriptionItem();
+ this.parameterReorderingItem = createParameterReorderingItem();
+
+ editHostDescription = createEditHostDescription();
+ editServiceDescription = createEditServiceDescription();
+ editApplicationDescription = createEditApplicationDescription();
+
+ editMenu = new JMenu("Edit");
+ editMenu.setMnemonic(KeyEvent.VK_E);
+
+ editMenu.add(this.workflowDescriptionItem);
+ editMenu.add(this.parameterReorderingItem);
+
+ editMenu.addSeparator();
+
+ editMenu.add(editHostDescription);
+ editMenu.add(editServiceDescription);
+ editMenu.add(editApplicationDescription);
+ }
+
+ private JMenuItem createWorkflowDescriptionItem() {
+ JMenuItem menuItem = new JMenuItem("Workflow Properties...");
+ menuItem.setMnemonic(KeyEvent.VK_W);
+ menuItem.addActionListener(new AbstractAction() {
+ private WorkflowPropertyWindow window;
+
+ public void actionPerformed(ActionEvent e) {
+ if (this.window == null) {
+ this.window = engine.getWorkflowPropertyWindow();
+ }
+ this.window.show();
+ }
+ });
+ return menuItem;
+ }
+
+ private JMenuItem createParameterReorderingItem() {
+ JMenuItem menuItem = new JMenuItem("Parameter Properties...");
+ menuItem.setMnemonic(KeyEvent.VK_P);
+ menuItem.addActionListener(new AbstractAction() {
+ private ParameterPropertyWindow window;
+
+ public void actionPerformed(ActionEvent e) {
+ if (this.window == null) {
+ this.window = new ParameterPropertyWindow(EditMenuItem.this.engine);
+ }
+ this.window.show();
+ }
+ });
+ return menuItem;
+ }
+
+ private JMenuItem createEditHostDescription() {
+ JMenuItem menuItem = new JMenuItem("Host Descriptions...");
+ menuItem.addActionListener(new AbstractAction() {
+ public void actionPerformed(ActionEvent e) {
+ //TODO
+ }
+ });
+ return menuItem;
+ }
+
+ private JMenuItem createEditServiceDescription() {
+ JMenuItem menuItem = new JMenuItem("Service Descriptions...");
+ menuItem.addActionListener(new AbstractAction() {
+ public void actionPerformed(ActionEvent e) {
+ //TODO
+ }
+ });
+ return menuItem;
+ }
+
+ private JMenuItem createEditApplicationDescription() {
+ JMenuItem menuItem = new JMenuItem("Application Descriptions...");
+ menuItem.addActionListener(new AbstractAction() {
+ public void actionPerformed(ActionEvent e) {
+ //TODO
+ }
+ });
+ return menuItem;
+ }
+}
\ No newline at end of file
Propchange: incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/menues/registry/
------------------------------------------------------------------------------
bugtraq:number = true
Added: incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/menues/registry/RegistryMenuItem.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/menues/registry/RegistryMenuItem.java?rev=1197132&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/menues/registry/RegistryMenuItem.java (added)
+++ incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/menues/registry/RegistryMenuItem.java Thu Nov 3 14:24:03 2011
@@ -0,0 +1,93 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.xbaya.menues.registry;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.KeyEvent;
+
+import javax.swing.AbstractAction;
+import javax.swing.JMenu;
+import javax.swing.JMenuItem;
+
+import org.apache.airavata.xbaya.XBayaEngine;
+import org.apache.airavata.xbaya.component.gui.ComponentMenu;
+import org.apache.airavata.xbaya.component.gui.JCRRegistryWindow;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class RegistryMenuItem {
+
+ private XBayaEngine engine;
+
+ private JMenu registryMenu;
+
+ private JMenuItem jcrRegistryItem;
+
+ private static final Logger logger = LoggerFactory.getLogger(RegistryMenuItem.class);
+
+ /**
+ * Constructs a WorkflowMenu.
+ *
+ * @param engine
+ */
+ public RegistryMenuItem(XBayaEngine engine) {
+ this.engine = engine;
+ createWorkflowMenu();
+ }
+
+ /**
+ * @return The workflow menu.
+ */
+ public JMenu getMenu() {
+ return this.registryMenu;
+ }
+
+ /**
+ * Creates workflow menu.
+ */
+ private void createWorkflowMenu() {
+ this.jcrRegistryItem = createJCRRegistryItem();
+
+ registryMenu = new JMenu("Registry");
+ registryMenu.setMnemonic(KeyEvent.VK_R);
+
+ registryMenu.add(this.jcrRegistryItem);
+
+ }
+
+
+ private JMenuItem createJCRRegistryItem() {
+ JMenuItem item = new JMenuItem("Setup JCR Registry...");
+ item.setMnemonic(KeyEvent.VK_J);
+ item.addActionListener(new AbstractAction() {
+ private JCRRegistryWindow window;
+
+ public void actionPerformed(ActionEvent e) {
+ if (this.window == null) {
+ this.window = new JCRRegistryWindow(engine);
+ }
+ this.window.show();
+ }
+ });
+ return item;
+ }
+}
\ No newline at end of file
Propchange: incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/menues/run/
------------------------------------------------------------------------------
bugtraq:number = true
Added: incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/menues/run/RunMenuItem.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/menues/run/RunMenuItem.java?rev=1197132&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/menues/run/RunMenuItem.java (added)
+++ incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/menues/run/RunMenuItem.java Thu Nov 3 14:24:03 2011
@@ -0,0 +1,298 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.xbaya.menues.run;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.KeyEvent;
+
+import javax.swing.AbstractAction;
+import javax.swing.JMenu;
+import javax.swing.JMenuItem;
+
+import org.apache.airavata.xbaya.XBayaEngine;
+import org.apache.airavata.xbaya.event.Event;
+import org.apache.airavata.xbaya.event.Event.Type;
+import org.apache.airavata.xbaya.event.EventListener;
+import org.apache.airavata.xbaya.experiment.gui.WorkflowInterpreterLaunchWindow;
+import org.apache.airavata.xbaya.graph.dynamic.gui.DynamicWorkflowRunnerWindow;
+import org.apache.airavata.xbaya.gridchem.gui.GridChemRunnerWindow;
+import org.apache.airavata.xbaya.gui.ErrorMessages;
+import org.apache.airavata.xbaya.jython.gui.JythonRunnerWindow;
+import org.apache.airavata.xbaya.monitor.Monitor;
+import org.apache.airavata.xbaya.monitor.MonitorConfiguration;
+import org.apache.airavata.xbaya.monitor.gui.MonitorConfigurationWindow;
+import org.apache.airavata.xbaya.monitor.gui.MonitorStarter;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class RunMenuItem implements EventListener{
+
+ private XBayaEngine engine;
+
+ private JMenu runMenu;
+
+ private JMenuItem launchDynamicWorkflowItem;
+
+ private JMenuItem runJythonWorkflowItem;
+
+ private JMenuItem launchGridChemWorkflowItem;
+
+ private JMenuItem launchXBayaInterpreterItem;
+
+ private JMenuItem launchAndSaveInGridChemWorkflowItem;
+
+ private JMenuItem configMonitorItem;
+
+ private JMenuItem resumeMonitoringItem;
+
+ private JMenuItem pauseMonitoringItem;
+
+ private JMenuItem resetMonitoringItem;
+
+ private static final Logger logger = LoggerFactory.getLogger(RunMenuItem.class);
+
+ /**
+ * Constructs a WorkflowMenu.
+ *
+ * @param engine
+ */
+ public RunMenuItem(XBayaEngine engine) {
+ this.engine = engine;
+ createWorkflowMenu();
+ Monitor monitor = this.engine.getMonitor();
+ monitor.addEventListener(this);
+ monitor.getConfiguration().addEventListener(this);
+ }
+
+ /**
+ * @return The workflow menu.
+ */
+ public JMenu getMenu() {
+ return this.runMenu;
+ }
+
+ /**
+ * Creates workflow menu.
+ */
+ private void createWorkflowMenu() {
+ this.launchDynamicWorkflowItem = createLaunchDynamicWorkflowItem();
+ this.runJythonWorkflowItem = createRunJythonWorkflowItem();
+ this.launchGridChemWorkflowItem = createLaunchGridChemWorkflowItem();
+ createLaunchXBayaInterpreterItem();
+ createLaunchAndSaveGridChemWorkflowItem();
+ this.configMonitorItem = createConfigMonitoring();
+ this.resumeMonitoringItem = createResumeMonitoring();
+ this.pauseMonitoringItem = createPauseMonitoring();
+ this.resetMonitoringItem = createStopMonitoring();
+
+ runMenu = new JMenu("Run");
+ runMenu.setMnemonic(KeyEvent.VK_R);
+
+ runMenu.add(launchDynamicWorkflowItem);
+ runMenu.add(runJythonWorkflowItem);
+ runMenu.add(launchXBayaInterpreterItem);
+
+ runMenu.addSeparator();
+ runMenu.add(launchGridChemWorkflowItem);
+ runMenu.add(launchAndSaveInGridChemWorkflowItem);
+
+ runMenu.addSeparator();
+
+ runMenu.add(this.resumeMonitoringItem);
+ runMenu.add(this.pauseMonitoringItem);
+ runMenu.add(this.resetMonitoringItem);
+ runMenu.add(this.configMonitorItem);
+
+ }
+
+ private JMenuItem createConfigMonitoring() {
+ JMenuItem item = new JMenuItem("Configure Monitoring...");
+ item.setMnemonic(KeyEvent.VK_C);
+ item.addActionListener(new AbstractAction() {
+ private MonitorConfigurationWindow window;
+
+ public void actionPerformed(ActionEvent e) {
+ if (this.window == null) {
+ this.window = new MonitorConfigurationWindow(engine);
+ }
+ this.window.show();
+ }
+ });
+ return item;
+ }
+
+ private JMenuItem createResumeMonitoring() {
+ JMenuItem item = new JMenuItem("Resume monitoring");
+ item.setMnemonic(KeyEvent.VK_S);
+ item.addActionListener(new AbstractAction() {
+ private MonitorStarter starter;
+
+ public void actionPerformed(ActionEvent event) {
+ if (this.starter == null) {
+ this.starter = new MonitorStarter(engine);
+ }
+ this.starter.start();
+ }
+ });
+ boolean valid = this.engine.getMonitor().getConfiguration().isValid();
+ item.setVisible(valid);
+ return item;
+ }
+
+ private JMenuItem createPauseMonitoring() {
+ JMenuItem item = new JMenuItem("Pause monitoring");
+ item.setMnemonic(KeyEvent.VK_T);
+ item.addActionListener(new AbstractAction() {
+ public void actionPerformed(ActionEvent event) {
+ try {
+ engine.getMonitor().asynchronousStop();
+ } catch (RuntimeException e) {
+ engine.getErrorWindow().error(ErrorMessages.MONITOR_ERROR, e);
+ } catch (Error e) {
+ engine.getErrorWindow().error(ErrorMessages.UNEXPECTED_ERROR, e);
+ }
+ }
+ });
+ item.setVisible(false);
+ return item;
+ }
+
+ private JMenuItem createStopMonitoring() {
+ JMenuItem item = new JMenuItem("Reset monitoring");
+ item.setMnemonic(KeyEvent.VK_R);
+ item.addActionListener(new AbstractAction() {
+ public void actionPerformed(ActionEvent event) {
+ try {
+ engine.getMonitor().reset();
+ } catch (RuntimeException e) {
+ engine.getErrorWindow().error(ErrorMessages.MONITOR_ERROR, e);
+ } catch (Error e) {
+ engine.getErrorWindow().error(ErrorMessages.UNEXPECTED_ERROR, e);
+ }
+ }
+ });
+ item.setVisible(false);
+ return item;
+ }
+
+
+ private JMenuItem createRunJythonWorkflowItem() {
+ JMenuItem menuItem = new JMenuItem("Run workflow as Jython...");
+ menuItem.setMnemonic(KeyEvent.VK_J);
+ menuItem.addActionListener(new AbstractAction() {
+ private JythonRunnerWindow window;
+
+ public void actionPerformed(ActionEvent event) {
+ if (this.window == null) {
+ this.window = new JythonRunnerWindow(engine);
+ }
+ this.window.show();
+ }
+ });
+ return menuItem;
+ }
+
+ private JMenuItem createLaunchDynamicWorkflowItem() {
+ JMenuItem menuItem = new JMenuItem("Run workflow...");
+ menuItem.setMnemonic(KeyEvent.VK_D);
+ menuItem.addActionListener(new AbstractAction() {
+ private DynamicWorkflowRunnerWindow window;
+
+ public void actionPerformed(ActionEvent event) {
+ if (this.window == null) {
+ this.window = new DynamicWorkflowRunnerWindow(engine);
+ }
+ this.window.show();
+ }
+ });
+ return menuItem;
+ }
+
+
+ private JMenuItem createLaunchGridChemWorkflowItem() {
+ JMenuItem menuItem = new JMenuItem("Run as GridChem Workflow...");
+ menuItem.addActionListener(new AbstractAction() {
+ private GridChemRunnerWindow window;
+
+ public void actionPerformed(ActionEvent event) {
+ if (this.window == null) {
+ this.window = new GridChemRunnerWindow(engine);
+ }
+ this.window.show();
+ }
+ });
+ return menuItem;
+ }
+
+ private void createLaunchXBayaInterpreterItem() {
+ this.launchXBayaInterpreterItem = new JMenuItem("Run on Interpreter Server...");
+ launchXBayaInterpreterItem.addActionListener(new AbstractAction() {
+ private WorkflowInterpreterLaunchWindow window;
+
+ public void actionPerformed(ActionEvent e) {
+ if (this.window == null) {
+ this.window = new WorkflowInterpreterLaunchWindow(engine);
+ }
+ try {
+ this.window.show();
+ } catch (Exception e1) {
+ engine.getErrorWindow().error(e1);
+ }
+
+ }
+ });
+ }
+
+ /**
+ *
+ */
+ private void createLaunchAndSaveGridChemWorkflowItem() {
+ launchAndSaveInGridChemWorkflowItem = new JMenuItem("Run & Register GridChem... ");
+ // TODO Add the following operations
+ // First Call OGCE-GridChem-Bridge Service to register an experiment
+ // Set lead context header with all the required notifier context
+ // call launch workflow
+
+ }
+
+ /**
+ * @see org.apache.airavata.xbaya.event.EventListener#eventReceived(org.apache.airavata.xbaya.event.Event)
+ */
+ public void eventReceived(Event event) {
+ Type type = event.getType();
+ if (type.equals(Event.Type.MONITOR_CONFIGURATION_CHANGED)) {
+ MonitorConfiguration configuration = this.engine.getMonitor().getConfiguration();
+ boolean valid = configuration.isValid();
+ resumeMonitoringItem.setVisible(valid);
+ pauseMonitoringItem.setVisible(false);
+ resetMonitoringItem.setVisible(false);
+ } else if (type.equals(Event.Type.MONITOR_STARTED)) {
+ resumeMonitoringItem.setVisible(false);
+ pauseMonitoringItem.setVisible(true);
+ resetMonitoringItem.setVisible(true);
+ } else if (type.equals(Event.Type.MONITOR_STOPED)) {
+ resumeMonitoringItem.setVisible(true);
+ pauseMonitoringItem.setVisible(false);
+ resetMonitoringItem.setVisible(false);
+ }
+ }
+}
\ No newline at end of file
Propchange: incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/menues/view/
------------------------------------------------------------------------------
bugtraq:number = true
Added: incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/menues/view/ViewMenuItem.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/menues/view/ViewMenuItem.java?rev=1197132&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/menues/view/ViewMenuItem.java (added)
+++ incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/menues/view/ViewMenuItem.java Thu Nov 3 14:24:03 2011
@@ -0,0 +1,133 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.xbaya.menues.view;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.KeyEvent;
+
+import javax.swing.AbstractAction;
+import javax.swing.JMenu;
+import javax.swing.JMenuItem;
+
+import org.apache.airavata.xbaya.XBayaEngine;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class ViewMenuItem {
+
+ private XBayaEngine engine;
+
+ private JMenu viewMenu;
+
+ private JMenuItem jcrRegistryView;
+
+ private JMenuItem componentsView;
+
+ private JMenuItem monitoringView;
+
+ private JMenuItem parametersView;
+
+ private static final Logger logger = LoggerFactory.getLogger(ViewMenuItem.class);
+
+ /**
+ * Constructs a WorkflowMenu.
+ *
+ * @param engine
+ */
+ public ViewMenuItem(XBayaEngine engine) {
+ this.engine = engine;
+ createWorkflowMenu();
+ }
+
+ /**
+ * @return The workflow menu.
+ */
+ public JMenu getMenu() {
+ return this.viewMenu;
+ }
+
+ /**
+ * Creates workflow menu.
+ */
+ private void createWorkflowMenu() {
+ this.jcrRegistryView = createShpwJCRRegistryView();
+ this.componentsView = createShowComponentsView();
+
+ monitoringView = createShowMonitoringView();
+ parametersView = createShowParameterView();
+
+ viewMenu = new JMenu("View");
+ viewMenu.setMnemonic(KeyEvent.VK_V);
+
+ viewMenu.add(this.jcrRegistryView);
+
+ viewMenu.addSeparator();
+
+ viewMenu.add(this.componentsView);
+
+ viewMenu.addSeparator();
+
+ viewMenu.add(monitoringView);
+ viewMenu.add(parametersView);
+ }
+
+ private JMenuItem createShpwJCRRegistryView() {
+ JMenuItem menuItem = new JMenuItem("JCR Registry");
+ menuItem.addActionListener(new AbstractAction() {
+ public void actionPerformed(ActionEvent e) {
+ //TODO
+ }
+ });
+ return menuItem;
+ }
+
+ private JMenuItem createShowComponentsView() {
+ JMenuItem menuItem = new JMenuItem("Components");
+ menuItem.addActionListener(new AbstractAction() {
+ public void actionPerformed(ActionEvent e) {
+ //TODO
+ }
+ });
+ return menuItem;
+ }
+
+ private JMenuItem createShowMonitoringView() {
+ JMenuItem menuItem = new JMenuItem("Monitoring");
+ menuItem.addActionListener(new AbstractAction() {
+ public void actionPerformed(ActionEvent e) {
+ //TODO
+ }
+ });
+ return menuItem;
+ }
+
+ private JMenuItem createShowParameterView() {
+ JMenuItem menuItem = new JMenuItem("Parameters");
+ menuItem.addActionListener(new AbstractAction() {
+ public void actionPerformed(ActionEvent e) {
+ //TODO
+ }
+ });
+ return menuItem;
+ }
+
+}
\ No newline at end of file
Propchange: incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/menues/xbaya/
------------------------------------------------------------------------------
bugtraq:number = true
Added: incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/menues/xbaya/BPELFiler.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/menues/xbaya/BPELFiler.java?rev=1197132&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/menues/xbaya/BPELFiler.java (added)
+++ incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/menues/xbaya/BPELFiler.java Thu Nov 3 14:24:03 2011
@@ -0,0 +1,145 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.xbaya.menues.xbaya;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+
+import javax.swing.JFileChooser;
+import javax.swing.filechooser.FileFilter;
+
+import org.apache.airavata.common.utils.XMLUtil;
+import org.apache.airavata.xbaya.XBayaConstants;
+import org.apache.airavata.xbaya.XBayaEngine;
+import org.apache.airavata.xbaya.file.XBayaPathConstants;
+import org.apache.airavata.xbaya.gpel.script.BPELScript;
+import org.apache.airavata.xbaya.gpel.script.BPELScriptType;
+import org.apache.airavata.xbaya.gpel.script.WorkflowWSDL;
+import org.apache.airavata.xbaya.graph.GraphException;
+import org.apache.airavata.xbaya.gui.ErrorMessages;
+import org.apache.airavata.xbaya.wf.Workflow;
+import org.gpel.model.GpelProcess;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class BPELFiler {
+
+ private static Logger logger = LoggerFactory.getLogger(BPELFiler.class);
+
+ private XBayaEngine engine;
+
+ private JFileChooser bpelFileChooser;
+
+ private final FileFilter bpelFileFilter = new FileFilter() {
+
+ @Override
+ public String getDescription() {
+ return "BPEL Files";
+ }
+
+ @Override
+ public boolean accept(File file) {
+ if (file.isDirectory()) {
+ return true;
+ }
+ String name = file.getName();
+ if (name.endsWith(XBayaConstants.BPEL_SUFFIX)) {
+ return true;
+ }
+ return false;
+ }
+ };
+
+ /**
+ * Constructs a BPELFiler.
+ *
+ * @param engine
+ */
+ public BPELFiler(XBayaEngine engine) {
+ this.engine = engine;
+
+ this.bpelFileChooser = new JFileChooser(XBayaPathConstants.BPEL_SCRIPT_DIRECTORY);
+ this.bpelFileChooser.addChoosableFileFilter(this.bpelFileFilter);
+
+ }
+
+ /**
+ * Exports a BPEL process to the local file
+ */
+ public void exportBPEL() {
+ Workflow workflow = this.engine.getWorkflow();
+ BPELScript bpel = new BPELScript(workflow);
+
+ // Check if there is any errors in the workflow first.
+ ArrayList<String> warnings = new ArrayList<String>();
+ if (!bpel.validate(warnings)) {
+ StringBuilder buf = new StringBuilder();
+ for (String warning : warnings) {
+ buf.append("- ");
+ buf.append(warning);
+ buf.append("\n");
+ }
+ this.engine.getErrorWindow().warning(buf.toString());
+ return;
+ }
+
+ int returnVal = this.bpelFileChooser.showSaveDialog(this.engine.getGUI().getFrame());
+ if (returnVal == JFileChooser.APPROVE_OPTION) {
+ File file = this.bpelFileChooser.getSelectedFile();
+ logger.info(file.getPath());
+
+ String path = file.getPath();
+
+ // Remove ".bpel" at the end if any
+ if (path.endsWith(XBayaConstants.BPEL_SUFFIX)) {
+ path = path.substring(0, path.length() - XBayaConstants.BPEL_SUFFIX.length());
+ }
+
+ // Add ".bpel" at the end of the file name
+ File bpelFile = new File(path + XBayaConstants.BPEL_SUFFIX);
+ // Add ".wsdl" at the end of the file name
+ File wsdlFile = new File(path + XBayaConstants.WSDL_SUFFIX);
+
+ try {
+ // Create the script.
+ bpel.create(BPELScriptType.BPEL2);
+
+ GpelProcess gpelProcess = bpel.getGpelProcess();
+ XMLUtil.saveXML(gpelProcess.xml(), bpelFile);
+
+ WorkflowWSDL workflowWSDL = bpel.getWorkflowWSDL();
+ XMLUtil.saveXML(workflowWSDL.getWsdlDefinitions().xml(), wsdlFile);
+
+ } catch (IOException e) {
+ this.engine.getErrorWindow().error(ErrorMessages.WRITE_FILE_ERROR, e);
+ } catch (GraphException e) {
+ this.engine.getErrorWindow().error(ErrorMessages.GRAPH_NOT_READY_ERROR, e);
+ } catch (RuntimeException e) {
+ this.engine.getErrorWindow().error(ErrorMessages.UNEXPECTED_ERROR, e);
+ } catch (Error e) {
+ this.engine.getErrorWindow().error(ErrorMessages.UNEXPECTED_ERROR, e);
+ }
+ }
+ }
+
+}
\ No newline at end of file
Added: incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/menues/xbaya/ImageFiler.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/menues/xbaya/ImageFiler.java?rev=1197132&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/menues/xbaya/ImageFiler.java (added)
+++ incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/menues/xbaya/ImageFiler.java Thu Nov 3 14:24:03 2011
@@ -0,0 +1,106 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.xbaya.menues.xbaya;
+
+import java.awt.image.BufferedImage;
+import java.io.File;
+import java.io.IOException;
+
+import javax.imageio.ImageIO;
+import javax.swing.JFileChooser;
+import javax.swing.filechooser.FileFilter;
+
+import org.apache.airavata.xbaya.XBayaConstants;
+import org.apache.airavata.xbaya.XBayaEngine;
+import org.apache.airavata.xbaya.gui.ErrorMessages;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class ImageFiler {
+
+ private static Logger logger = LoggerFactory.getLogger(ImageFiler.class);
+
+ private XBayaEngine engine;
+
+ private JFileChooser pngFileChooser;
+
+ private final FileFilter pngFileFilter = new FileFilter() {
+ @Override
+ public String getDescription() {
+ return "PNG Files";
+ }
+
+ @Override
+ public boolean accept(File file) {
+ if (file.isDirectory()) {
+ return true;
+ }
+ String name = file.getName();
+ if (name.endsWith(XBayaConstants.PNG_SUFFIX)) {
+ return true;
+ }
+ return false;
+ }
+ };
+
+ /**
+ * Constructs an ImageFiler.
+ *
+ * @param engine
+ */
+ public ImageFiler(XBayaEngine engine) {
+ this.engine = engine;
+
+ this.pngFileChooser = new JFileChooser();
+ this.pngFileChooser.addChoosableFileFilter(this.pngFileFilter);
+ }
+
+ /**
+ * Save the workflow image to the local file
+ */
+ public void saveWorkflowImage() {
+ int returnVal = this.pngFileChooser.showSaveDialog(this.engine.getGUI().getFrame());
+ if (returnVal == JFileChooser.APPROVE_OPTION) {
+ File file = this.pngFileChooser.getSelectedFile();
+ logger.info(file.getPath());
+
+ // Put ".png" at the end of the file name
+ String path = file.getPath();
+ if (!path.endsWith(XBayaConstants.PNG_SUFFIX)) {
+ file = new File(path + XBayaConstants.PNG_SUFFIX);
+ }
+
+ BufferedImage image;
+ try {
+ image = this.engine.getWorkflow().getImage();
+ ImageIO.write(image, XBayaConstants.PNG_FORMAT_NAME, file);
+ } catch (IOException e) {
+ this.engine.getErrorWindow().error(ErrorMessages.WRITE_FILE_ERROR, e);
+ } catch (RuntimeException e) {
+ this.engine.getErrorWindow().error(ErrorMessages.UNEXPECTED_ERROR, e);
+ } catch (Error e) {
+ this.engine.getErrorWindow().error(ErrorMessages.UNEXPECTED_ERROR, e);
+ }
+ }
+ }
+
+}
\ No newline at end of file
Added: incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/menues/xbaya/JythonFiler.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/menues/xbaya/JythonFiler.java?rev=1197132&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/menues/xbaya/JythonFiler.java (added)
+++ incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/menues/xbaya/JythonFiler.java Thu Nov 3 14:24:03 2011
@@ -0,0 +1,128 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.xbaya.menues.xbaya;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+
+import javax.swing.JFileChooser;
+import javax.swing.filechooser.FileFilter;
+
+import org.apache.airavata.common.utils.IOUtil;
+import org.apache.airavata.xbaya.XBayaConstants;
+import org.apache.airavata.xbaya.XBayaEngine;
+import org.apache.airavata.xbaya.file.XBayaPathConstants;
+import org.apache.airavata.xbaya.graph.GraphException;
+import org.apache.airavata.xbaya.gui.ErrorMessages;
+import org.apache.airavata.xbaya.jython.script.JythonScript;
+import org.apache.airavata.xbaya.wf.Workflow;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class JythonFiler {
+
+ private static Logger logger = LoggerFactory.getLogger(JythonFiler.class);
+
+ private XBayaEngine engine;
+
+ private JFileChooser jythonFileChooser;
+
+ private final FileFilter jythonFileFilter = new FileFilter() {
+ @Override
+ public String getDescription() {
+ return "Jython Scripts";
+ }
+
+ @Override
+ public boolean accept(File file) {
+ if (file.isDirectory()) {
+ return true;
+ }
+ String name = file.getName();
+ if (name.endsWith(XBayaConstants.JYTHON_SCRIPT_SUFFIX)) {
+ return true;
+ }
+ return false;
+ }
+ };
+
+ /**
+ * Constructs a JythonFile.
+ *
+ * @param engine
+ */
+ public JythonFiler(XBayaEngine engine) {
+ this.engine = engine;
+ this.jythonFileChooser = new JFileChooser(XBayaPathConstants.JYTHON_SCRIPT_DIRECTORY);
+ this.jythonFileChooser.addChoosableFileFilter(this.jythonFileFilter);
+ }
+
+ /**
+ * Exports a Jython script to the local file
+ */
+ public void exportJythonScript() {
+ Workflow workflow = this.engine.getWorkflow();
+ JythonScript script = new JythonScript(workflow, this.engine.getConfiguration());
+
+ // Check if there is any errors in the workflow first.
+ ArrayList<String> warnings = new ArrayList<String>();
+ if (!script.validate(warnings)) {
+ StringBuilder buf = new StringBuilder();
+ for (String warning : warnings) {
+ buf.append("- ");
+ buf.append(warning);
+ buf.append("\n");
+ }
+ this.engine.getErrorWindow().warning(buf.toString());
+ return;
+ }
+
+ int returnVal = this.jythonFileChooser.showSaveDialog(this.engine.getGUI().getFrame());
+ if (returnVal == JFileChooser.APPROVE_OPTION) {
+ File file = this.jythonFileChooser.getSelectedFile();
+ logger.info(file.getPath());
+
+ // Put ".py" at the end of the file name
+ String path = file.getPath();
+ if (!path.endsWith(XBayaConstants.JYTHON_SCRIPT_SUFFIX)) {
+ file = new File(path + XBayaConstants.JYTHON_SCRIPT_SUFFIX);
+ }
+
+ try {
+ // Create the script.
+ script.create();
+ // Write to a file
+ IOUtil.writeToFile(script.getJythonString(), file);
+ } catch (IOException e) {
+ this.engine.getErrorWindow().error(ErrorMessages.WRITE_FILE_ERROR, e);
+ } catch (GraphException e) {
+ this.engine.getErrorWindow().error(ErrorMessages.GRAPH_FORMAT_ERROR, e);
+ } catch (RuntimeException e) {
+ this.engine.getErrorWindow().error(ErrorMessages.UNEXPECTED_ERROR, e);
+ } catch (Error e) {
+ this.engine.getErrorWindow().error(ErrorMessages.UNEXPECTED_ERROR, e);
+ }
+ }
+ }
+
+}
\ No newline at end of file
Added: incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/menues/xbaya/ODEScriptFiler.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/menues/xbaya/ODEScriptFiler.java?rev=1197132&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/menues/xbaya/ODEScriptFiler.java (added)
+++ incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/menues/xbaya/ODEScriptFiler.java Thu Nov 3 14:24:03 2011
@@ -0,0 +1,165 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.xbaya.menues.xbaya;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Map;
+import java.util.Set;
+
+import javax.swing.JFileChooser;
+import javax.swing.filechooser.FileFilter;
+import javax.xml.namespace.QName;
+
+import org.apache.airavata.common.utils.WSDLUtil;
+import org.apache.airavata.xbaya.XBayaConstants;
+import org.apache.airavata.xbaya.XBayaEngine;
+import org.apache.airavata.xbaya.component.ComponentException;
+import org.apache.airavata.xbaya.file.XBayaPathConstants;
+import org.apache.airavata.xbaya.graph.GraphException;
+import org.apache.airavata.xbaya.gui.ErrorMessages;
+import org.apache.airavata.xbaya.wf.Workflow;
+import org.gpel.model.GpelProcess;
+import org.xmlpull.infoset.XmlElement;
+
+import xsul5.XmlConstants;
+import xsul5.wsdl.WsdlDefinitions;
+
+public class ODEScriptFiler {
+
+ private XBayaEngine engine;
+
+ private JFileChooser bpelFileChooser;
+
+ private final FileFilter bpelFileFilter = new FileFilter() {
+
+ @Override
+ public String getDescription() {
+ return "BPEL Files";
+ }
+
+ @Override
+ public boolean accept(File file) {
+ if (file.isDirectory()) {
+ return true;
+ }
+ String name = file.getName();
+ if (name.endsWith(XBayaConstants.BPEL_SUFFIX)) {
+ return true;
+ }
+ return false;
+ }
+ };
+
+ /**
+ * Constructs a ODEScriptFiler.
+ *
+ * @param engine
+ */
+ public ODEScriptFiler(XBayaEngine engine) {
+ this.engine = engine;
+
+ this.bpelFileChooser = new JFileChooser(XBayaPathConstants.BPEL_SCRIPT_DIRECTORY);
+ this.bpelFileChooser.addChoosableFileFilter(this.bpelFileFilter);
+ }
+
+ /**
+ *
+ */
+ public void save() {
+ Workflow wf = this.engine.getWorkflow();
+ if (0 == wf.getGraph().getNodes().size()) {
+ this.engine.getErrorWindow().warning("Workflow is Empty");
+ return;
+ }
+ GpelProcess process;
+ try {
+
+ int returnVal = this.bpelFileChooser.showSaveDialog(this.engine.getGUI().getFrame());
+ if (returnVal == JFileChooser.APPROVE_OPTION) {
+ File file = this.bpelFileChooser.getSelectedFile();
+
+ String path = file.getPath();
+
+ // Remove ".bpel" at the end if any
+ if (path.endsWith(XBayaConstants.BPEL_SUFFIX)) {
+ path = path.substring(0, path.length() - XBayaConstants.BPEL_SUFFIX.length());
+ }
+
+ // Add ".bpel" at the end of the file name
+ File bpelFile = new File(path + XBayaConstants.BPEL_SUFFIX);
+ // Add ".wsdl" at the end of the file name
+ File wsdlFile = new File(path + XBayaConstants.WSDL_SUFFIX);
+ // todo this has to fix, for compilation purpose passing dummy value instead of xregistry url
+ URI temp = null;
+ try {
+ temp = new URI("temp");
+ } catch (URISyntaxException e) {
+ e.printStackTrace(); // To change body of catch statement use File | Settings | File Templates.
+ }
+ process = wf.getOdeProcess(WSDLUtil.appendWSDLQuary(temp), this.engine.getConfiguration().getODEURL());
+ String processString = process.xmlStringPretty();
+ FileWriter writer = new FileWriter(bpelFile);
+ writer.write(processString);
+ writer.close();
+
+ WsdlDefinitions workflowWSDL = wf.getOdeWorkflowWSDL(this.engine.getConfiguration().getDSCURL(),
+ this.engine.getConfiguration().getODEURL());
+ String workflowWsdlStr = XmlConstants.BUILDER.serializeToStringPretty(workflowWSDL.xml());
+ writer = new FileWriter(wsdlFile);
+ writer.write(workflowWsdlStr);
+
+ Map<String, WsdlDefinitions> wsdlMap = wf.getOdeServiceWSDLs(
+ this.engine.getConfiguration().getDSCURL(), this.engine.getConfiguration().getODEURL());
+ Set<String> keySet = wsdlMap.keySet();
+ for (String string : keySet) {
+ writer = new FileWriter(new File(wsdlFile.getParent(), QName.valueOf(string).getLocalPart()));
+ writer.write(XmlConstants.BUILDER.serializeToStringPretty(wsdlMap.get(string).xml()));
+ writer.close();
+ }
+
+ XmlElement deployDescriptor = wf.getODEDeploymentDescriptor(this.engine.getConfiguration().getDSCURL(),
+ this.engine.getConfiguration().getODEURL());
+ writer = new FileWriter(new File(wsdlFile.getParent(), "deploy.xml"));
+ writer.write(XmlConstants.BUILDER.serializeToString(deployDescriptor));
+ writer.close();
+
+ }
+
+ } catch (IOException e) {
+ this.engine.getErrorWindow().error(ErrorMessages.WRITE_FILE_ERROR, e);
+ } catch (GraphException e) {
+ this.engine.getErrorWindow().error(ErrorMessages.GRAPH_FORMAT_ERROR, e);
+ } catch (RuntimeException e) {
+ this.engine.getErrorWindow().error(ErrorMessages.UNEXPECTED_ERROR, e);
+ } catch (Error e) {
+ this.engine.getErrorWindow().error(ErrorMessages.UNEXPECTED_ERROR, e);
+ } catch (ComponentException e) {
+ this.engine.getErrorWindow().error(ErrorMessages.UNEXPECTED_ERROR, e);
+ }
+
+ }
+
+}
\ No newline at end of file
Added: incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/menues/xbaya/ScuflFiler.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/menues/xbaya/ScuflFiler.java?rev=1197132&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/menues/xbaya/ScuflFiler.java (added)
+++ incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/menues/xbaya/ScuflFiler.java Thu Nov 3 14:24:03 2011
@@ -0,0 +1,127 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.xbaya.menues.xbaya;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+
+import javax.swing.JFileChooser;
+import javax.swing.filechooser.FileFilter;
+
+import org.apache.airavata.common.utils.IOUtil;
+import org.apache.airavata.xbaya.XBayaConstants;
+import org.apache.airavata.xbaya.XBayaEngine;
+import org.apache.airavata.xbaya.file.XBayaPathConstants;
+import org.apache.airavata.xbaya.graph.GraphException;
+import org.apache.airavata.xbaya.gui.ErrorMessages;
+import org.apache.airavata.xbaya.scufl.script.ScuflScript;
+import org.apache.airavata.xbaya.wf.Workflow;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class ScuflFiler {
+
+ private static Logger logger = LoggerFactory.getLogger(ScuflFiler.class);
+
+ private XBayaEngine engine;
+
+ private JFileChooser scuflFileChooser;
+
+ private final FileFilter scuflFileFilter = new FileFilter() {
+ @Override
+ public String getDescription() {
+ return "Scufl Scripts";
+ }
+
+ @Override
+ public boolean accept(File file) {
+ if (file.isDirectory()) {
+ return true;
+ }
+ String name = file.getName();
+ if (name.endsWith(XBayaConstants.SCUFL_SCRIPT_SUFFIX)) {
+ return true;
+ }
+ return false;
+ }
+ };
+
+ /**
+ * Constructs a ScuflFiler.
+ *
+ * @param engine
+ */
+ public ScuflFiler(XBayaEngine engine) {
+ this.engine = engine;
+ this.scuflFileChooser = new JFileChooser(XBayaPathConstants.SCUFL_SCRIPT_DIRECTORY);
+ this.scuflFileChooser.addChoosableFileFilter(this.scuflFileFilter);
+ }
+
+ /**
+ * Exports a Scufl script to the local file
+ */
+ public void exportScuflScript() {
+ Workflow workflow = this.engine.getWorkflow();
+ ScuflScript script = new ScuflScript(workflow, this.engine.getConfiguration());
+
+ // Check if there is any errors in the workflow first.
+ ArrayList<String> warnings = new ArrayList<String>();
+ if (!script.validate(warnings)) {
+ StringBuilder buf = new StringBuilder();
+ for (String warning : warnings) {
+ buf.append("- ");
+ buf.append(warning);
+ buf.append("\n");
+ }
+ this.engine.getErrorWindow().warning(buf.toString());
+ return;
+ }
+ int returnVal = this.scuflFileChooser.showSaveDialog(this.engine.getGUI().getFrame());
+ if (returnVal == JFileChooser.APPROVE_OPTION) {
+ File file = this.scuflFileChooser.getSelectedFile();
+ logger.info(file.getPath());
+
+ // Put ".py" at the end of the file name
+ String path = file.getPath();
+ if (!path.endsWith(XBayaConstants.SCUFL_SCRIPT_SUFFIX)) {
+ file = new File(path + XBayaConstants.SCUFL_SCRIPT_SUFFIX);
+ }
+
+ try {
+ // Create the script.
+ script.create();
+ // Write to a file
+ IOUtil.writeToFile(script.getScript(), file);
+ } catch (IOException e) {
+ this.engine.getErrorWindow().error(ErrorMessages.WRITE_FILE_ERROR, e);
+ } catch (GraphException e) {
+ this.engine.getErrorWindow().error(ErrorMessages.GRAPH_FORMAT_ERROR, e);
+ } catch (RuntimeException e) {
+ this.engine.getErrorWindow().error(ErrorMessages.UNEXPECTED_ERROR, e);
+ } catch (Error e) {
+ this.engine.getErrorWindow().error(ErrorMessages.UNEXPECTED_ERROR, e);
+ }
+ }
+
+ }
+}
\ No newline at end of file
Added: incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/menues/xbaya/WorkflowFiler.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/menues/xbaya/WorkflowFiler.java?rev=1197132&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/menues/xbaya/WorkflowFiler.java (added)
+++ incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/menues/xbaya/WorkflowFiler.java Thu Nov 3 14:24:03 2011
@@ -0,0 +1,210 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.xbaya.menues.xbaya;
+
+import java.io.File;
+import java.io.IOException;
+
+import javax.swing.JFileChooser;
+import javax.swing.filechooser.FileFilter;
+
+import org.apache.airavata.common.utils.XMLUtil;
+import org.apache.airavata.xbaya.XBayaConstants;
+import org.apache.airavata.xbaya.XBayaEngine;
+import org.apache.airavata.xbaya.component.ComponentException;
+import org.apache.airavata.xbaya.file.XBayaPathConstants;
+import org.apache.airavata.xbaya.graph.GraphException;
+import org.apache.airavata.xbaya.graph.ws.WSGraph;
+import org.apache.airavata.xbaya.graph.ws.WSGraphFactory;
+import org.apache.airavata.xbaya.gui.ErrorMessages;
+import org.apache.airavata.xbaya.wf.Workflow;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.xmlpull.infoset.XmlElement;
+
+public class WorkflowFiler {
+
+ private static Logger logger = LoggerFactory.getLogger(WorkflowFiler.class);
+
+ private XBayaEngine engine;
+
+ private JFileChooser graphFileChooser;
+
+ private final FileFilter graphFileFilter = new FileFilter() {
+
+ @Override
+ public String getDescription() {
+ return "Workflow Files";
+ }
+
+ @Override
+ public boolean accept(File file) {
+ if (file.isDirectory()) {
+ return true;
+ }
+ String name = file.getName();
+ if (name.endsWith(XBayaConstants.GRAPH_FILE_SUFFIX)) {
+ return true;
+ } else if (name.endsWith(XBayaConstants.WORKFLOW_FILE_SUFFIX)) {
+ return true;
+ }
+ return false;
+ }
+ };
+
+ /**
+ * Creates a FileMenu.
+ *
+ * @param engine
+ * the XwfClient, which is used to retrieve the current workflow graph.
+ */
+ public WorkflowFiler(XBayaEngine engine) {
+ this.engine = engine;
+
+ this.graphFileChooser = new JFileChooser(XBayaPathConstants.WORKFLOW_DIRECTORY);
+ this.graphFileChooser.addChoosableFileFilter(this.graphFileFilter);
+
+ }
+
+ /**
+ * Opens a current workflow from the local file.
+ */
+ public void openWorkflow() {
+ Workflow workflow = null;
+ workflow = getWorkflow();
+ if (null != workflow) {
+ this.engine.setWorkflow(workflow);
+ }
+ }
+
+ /**
+ * @param workflow
+ * @return
+ */
+ public Workflow getWorkflow() {
+ Workflow workflow = null;
+ int returnVal = this.graphFileChooser.showOpenDialog(this.engine.getGUI().getFrame());
+
+ if (returnVal == JFileChooser.APPROVE_OPTION) {
+ File file = this.graphFileChooser.getSelectedFile();
+ logger.info(file.getPath());
+
+ try {
+ String path = file.getPath();
+
+ if (path.endsWith(XBayaConstants.GRAPH_FILE_SUFFIX)) {
+ WSGraph graph = WSGraphFactory.createGraph(file);
+ workflow = Workflow.graphToWorkflow(graph);
+ } else {
+ XmlElement workflowElement = XMLUtil.loadXML(file);
+ workflow = new Workflow(workflowElement);
+ }
+
+ } catch (IOException e) {
+ this.engine.getErrorWindow().error(ErrorMessages.OPEN_FILE_ERROR, e);
+ } catch (GraphException e) {
+ this.engine.getErrorWindow().error(ErrorMessages.GRAPH_FORMAT_ERROR, e);
+ } catch (ComponentException e) {
+ this.engine.getErrorWindow().error(ErrorMessages.GRAPH_FORMAT_ERROR, e);
+ } catch (RuntimeException e) {
+ this.engine.getErrorWindow().error(ErrorMessages.UNEXPECTED_ERROR, e);
+ } catch (Error e) {
+ this.engine.getErrorWindow().error(ErrorMessages.UNEXPECTED_ERROR, e);
+ }
+ }
+ return workflow;
+ }
+
+ /**
+ * Saves a current workflow to the local file.
+ */
+ public void saveWorkflow() {
+ //TODO should chk if this is already in saved. if so save to the same file else save as...
+ saveAsWorkflow();
+ }
+
+ public void saveAllWorkflows(){
+ //TODO
+ }
+
+ public void saveAsWorkflow() {
+ int returnVal = this.graphFileChooser.showSaveDialog(this.engine.getGUI().getFrame());
+ if (returnVal == JFileChooser.APPROVE_OPTION) {
+ File file = this.graphFileChooser.getSelectedFile();
+ logger.info(file.getPath());
+
+ // Put ".xwf" at the end of the file name
+ String path = file.getPath();
+ if (!path.endsWith(XBayaConstants.WORKFLOW_FILE_SUFFIX)) {
+ file = new File(path + XBayaConstants.WORKFLOW_FILE_SUFFIX);
+ }
+
+ Workflow workflow = this.engine.getWorkflow();
+ try {
+ XMLUtil.saveXML(workflow.toXML(), file);
+ } catch (IOException e) {
+ this.engine.getErrorWindow().error(ErrorMessages.WRITE_FILE_ERROR, e);
+ } catch (RuntimeException e) {
+ this.engine.getErrorWindow().error(ErrorMessages.GRAPH_SAVE_ERROR, e);
+ } catch (Error e) {
+ this.engine.getErrorWindow().error(ErrorMessages.UNEXPECTED_ERROR, e);
+ }
+ }
+ }
+
+ /**
+ * Imports a workflow from the local file to the current workflow.
+ */
+ public void importWorkflow() {
+ int returnVal = this.graphFileChooser.showOpenDialog(this.engine.getGUI().getFrame());
+ if (returnVal == JFileChooser.APPROVE_OPTION) {
+ File file = this.graphFileChooser.getSelectedFile();
+
+ Workflow workflow = this.engine.getWorkflow();
+ try {
+
+ String path = file.getPath();
+ Workflow importedWorkflow;
+ if (path.endsWith(XBayaConstants.GRAPH_FILE_SUFFIX)) {
+ WSGraph importedGraph = WSGraphFactory.createGraph(file);
+ importedWorkflow = Workflow.graphToWorkflow(importedGraph);
+ } else {
+ XmlElement importedWorkflowElement = XMLUtil.loadXML(file);
+ importedWorkflow = new Workflow(importedWorkflowElement);
+ }
+ workflow.importWorkflow(importedWorkflow);
+ this.engine.setWorkflow(workflow);
+ } catch (IOException e) {
+ this.engine.getErrorWindow().error(ErrorMessages.OPEN_FILE_ERROR, e);
+ } catch (GraphException e) {
+ this.engine.getErrorWindow().error(ErrorMessages.GRAPH_FORMAT_ERROR, e);
+ } catch (ComponentException e) {
+ this.engine.getErrorWindow().error(ErrorMessages.GRAPH_FORMAT_ERROR, e);
+ } catch (RuntimeException e) {
+ this.engine.getErrorWindow().error(ErrorMessages.UNEXPECTED_ERROR, e);
+ } catch (Error e) {
+ this.engine.getErrorWindow().error(ErrorMessages.UNEXPECTED_ERROR, e);
+ }
+ }
+ }
+
+}
\ No newline at end of file