You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by sa...@apache.org on 2014/04/14 20:31:09 UTC
[67/90] [abbrv] AIRAVATA-1124
http://git-wip-us.apache.org/repos/asf/airavata/blob/9c47eec8/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/actions/registry/browser/BrowserAction.java
----------------------------------------------------------------------
diff --git a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/actions/registry/browser/BrowserAction.java b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/actions/registry/browser/BrowserAction.java
new file mode 100644
index 0000000..cf85809
--- /dev/null
+++ b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/actions/registry/browser/BrowserAction.java
@@ -0,0 +1,39 @@
+/*
+ *
+ * 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.ui.actions.registry.browser;
+
+import org.apache.airavata.xbaya.ui.actions.AbstractBrowserActionItem;
+
+public class BrowserAction extends AbstractBrowserActionItem {
+ public static final String ID = "action.browser";
+
+ @Override
+ public String getID() {
+ return ID;
+ }
+
+ @Override
+ public String getDefaultCaption() {
+ return "Open in web browser...";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/9c47eec8/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/actions/registry/browser/CopyAction.java
----------------------------------------------------------------------
diff --git a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/actions/registry/browser/CopyAction.java b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/actions/registry/browser/CopyAction.java
new file mode 100644
index 0000000..8f8e024
--- /dev/null
+++ b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/actions/registry/browser/CopyAction.java
@@ -0,0 +1,39 @@
+/*
+ *
+ * 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.ui.actions.registry.browser;
+
+import org.apache.airavata.xbaya.ui.actions.AbstractBrowserActionItem;
+
+public class CopyAction extends AbstractBrowserActionItem {
+ public static final String ID = "action.copy";
+
+ @Override
+ public String getID() {
+ return ID;
+ }
+
+ @Override
+ public String getDefaultCaption() {
+ return "Copy";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/9c47eec8/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/actions/registry/browser/DeleteAction.java
----------------------------------------------------------------------
diff --git a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/actions/registry/browser/DeleteAction.java b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/actions/registry/browser/DeleteAction.java
new file mode 100644
index 0000000..30b531a
--- /dev/null
+++ b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/actions/registry/browser/DeleteAction.java
@@ -0,0 +1,42 @@
+/*
+ *
+ * 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.ui.actions.registry.browser;
+
+import org.apache.airavata.xbaya.ui.actions.AbstractBrowserActionItem;
+
+public class DeleteAction extends AbstractBrowserActionItem {
+ public static final String ID = "action.delete";
+
+ public DeleteAction() {
+ setCaption(getDefaultCaption());
+ }
+
+ @Override
+ public String getID() {
+ return ID;
+ }
+
+ @Override
+ public String getDefaultCaption() {
+ return "Remove";
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/9c47eec8/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/actions/registry/browser/EditAction.java
----------------------------------------------------------------------
diff --git a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/actions/registry/browser/EditAction.java b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/actions/registry/browser/EditAction.java
new file mode 100644
index 0000000..1f007f4
--- /dev/null
+++ b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/actions/registry/browser/EditAction.java
@@ -0,0 +1,39 @@
+/*
+ *
+ * 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.ui.actions.registry.browser;
+
+import org.apache.airavata.xbaya.ui.actions.AbstractBrowserActionItem;
+
+public class EditAction extends AbstractBrowserActionItem {
+ public static final String ID = "action.edit";
+
+ @Override
+ public String getID() {
+ return ID;
+ }
+
+ @Override
+ public String getDefaultCaption() {
+ return "Edit";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/9c47eec8/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/actions/registry/browser/ImportAction.java
----------------------------------------------------------------------
diff --git a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/actions/registry/browser/ImportAction.java b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/actions/registry/browser/ImportAction.java
new file mode 100644
index 0000000..f2ce0c1
--- /dev/null
+++ b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/actions/registry/browser/ImportAction.java
@@ -0,0 +1,39 @@
+/*
+ *
+ * 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.ui.actions.registry.browser;
+
+import org.apache.airavata.xbaya.ui.actions.AbstractBrowserActionItem;
+
+public class ImportAction extends AbstractBrowserActionItem {
+ public static final String ID = "action.import";
+
+ @Override
+ public String getID() {
+ return ID;
+ }
+
+ @Override
+ public String getDefaultCaption() {
+ return "Import";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/9c47eec8/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/actions/registry/browser/RefreshAction.java
----------------------------------------------------------------------
diff --git a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/actions/registry/browser/RefreshAction.java b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/actions/registry/browser/RefreshAction.java
new file mode 100644
index 0000000..cb95e4e
--- /dev/null
+++ b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/actions/registry/browser/RefreshAction.java
@@ -0,0 +1,43 @@
+/*
+ *
+ * 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.ui.actions.registry.browser;
+
+import org.apache.airavata.xbaya.ui.actions.AbstractBrowserActionItem;
+
+public class RefreshAction extends AbstractBrowserActionItem {
+ public static String ID = "action.refresh";
+
+ public RefreshAction() {
+ setCaption(getDefaultCaption());
+ }
+
+ @Override
+ public String getID() {
+ return ID;
+ }
+
+ @Override
+ public String getDefaultCaption() {
+ return "Refresh";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/9c47eec8/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/actions/registry/browser/ViewAction.java
----------------------------------------------------------------------
diff --git a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/actions/registry/browser/ViewAction.java b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/actions/registry/browser/ViewAction.java
new file mode 100644
index 0000000..c7fa0db
--- /dev/null
+++ b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/actions/registry/browser/ViewAction.java
@@ -0,0 +1,39 @@
+/*
+ *
+ * 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.ui.actions.registry.browser;
+
+import org.apache.airavata.xbaya.ui.actions.AbstractBrowserActionItem;
+
+public class ViewAction extends AbstractBrowserActionItem {
+ public static final String ID = "action.view";
+
+ @Override
+ public String getID() {
+ return ID;
+ }
+
+ @Override
+ public String getDefaultCaption() {
+ return "View";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/9c47eec8/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/AboutWindow.java
----------------------------------------------------------------------
diff --git a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/AboutWindow.java b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/AboutWindow.java
new file mode 100644
index 0000000..75d9bbe
--- /dev/null
+++ b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/AboutWindow.java
@@ -0,0 +1,126 @@
+/*
+ *
+ * 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.ui.dialogs;
+
+import java.awt.event.ActionEvent;
+import java.net.URL;
+
+import javax.swing.AbstractAction;
+import javax.swing.BorderFactory;
+import javax.swing.JButton;
+import javax.swing.JEditorPane;
+import javax.swing.JPanel;
+import javax.swing.event.HyperlinkEvent;
+import javax.swing.event.HyperlinkEvent.EventType;
+import javax.swing.event.HyperlinkListener;
+
+import org.apache.airavata.common.utils.BrowserLauncher;
+import org.apache.airavata.common.utils.SwingUtil;
+import org.apache.airavata.xbaya.XBayaConstants;
+import org.apache.airavata.xbaya.XBayaEngine;
+import org.apache.airavata.xbaya.XBayaVersion;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import xsul5.XmlConstants;
+
+public class AboutWindow {
+
+ private static final Logger logger = LoggerFactory.getLogger(AboutWindow.class);
+
+ private XBayaEngine engine;
+
+ private XBayaDialog dialog;
+
+ /**
+ * Creates the AboutWindow.
+ *
+ * @param engine
+ */
+ public AboutWindow(XBayaEngine engine) {
+ this.engine = engine;
+ init();
+ }
+
+ /**
+ * Shows the dialog.
+ */
+ public void show() {
+ this.dialog.show();
+ }
+
+ private void hide() {
+ this.dialog.hide();
+ }
+
+ @SuppressWarnings("serial")
+ private void init() {
+ JPanel buttonPanel = new JPanel();
+ JButton okButton = new JButton("OK");
+ okButton.setDefaultCapable(true);
+ okButton.addActionListener(new AbstractAction() {
+ public void actionPerformed(ActionEvent e) {
+ hide();
+ }
+ });
+ buttonPanel.add(okButton);
+ String styles="<style type=\"text/css\">"+
+ "body {"+
+ "font-family:Arial, Helvetica, sans-serif"+
+ "}"+
+ ".centeredImage"+
+ "{"+
+ " text-align:center;"+
+ " display:block;"+
+ "}"+
+ "</style>";
+ buttonPanel.setBorder(BorderFactory.createEtchedBorder());
+ String imgLogoTag="";//"<img src=\""+SwingUtil.getImageURL("airavata-2.png").toString()+"\" class=\".centeredImage\" /><br>";
+ String imgHeadingTag="<div style=\"width:100%;margin-right:10px;margin-left:10px;margin-top:5px;\" ><img src=\""+SwingUtil.getImageURL("airavata-title-text.png").toString()+"\" class=\".centeredImage\" /></div><br>";
+ String projectNameText = "";//"<h1>" + XBayaConstants.PROJECT_NAME + "</h1>";
+ String message = "<html>"+ styles +"<body align=\"center\">" + "<div style=\"background-color:white;width:100%;margin-bottom:0px;\">"+projectNameText + imgHeadingTag+ imgLogoTag +"</div><br><h2>" +XBayaConstants.APPLICATION_NAME + "</h2>" + "Version: "
+ + XBayaVersion.VERSION + "<br>" + "<a href='" + XBayaConstants.WEB_URL.toString() + "'>" + XBayaConstants.WEB_URL.toString() + "</a>"
+ + "<br> </body></html>";
+ JEditorPane editorPane = new JEditorPane(XmlConstants.CONTENT_TYPE_HTML, message);
+ editorPane.setEditable(false);
+ editorPane.setBorder(BorderFactory.createEtchedBorder());
+ editorPane.setBackground(buttonPanel.getBackground());
+ editorPane.addHyperlinkListener(new HyperlinkListener() {
+ public void hyperlinkUpdate(HyperlinkEvent event) {
+ logger.debug("Event:" + event);
+ if (event.getEventType() == EventType.ACTIVATED) {
+ URL url = event.getURL();
+ try {
+ BrowserLauncher.openURL(url.toString());
+ } catch (Exception e) {
+ AboutWindow.this.engine.getGUI().getErrorWindow().error(AboutWindow.this.dialog.getDialog(),
+ e.getMessage(), e);
+ }
+ }
+ }
+ });
+
+ this.dialog = new XBayaDialog(this.engine.getGUI(), XBayaConstants.PROJECT_NAME, editorPane, buttonPanel);
+ this.dialog.setDefaultButton(okButton);
+// this.dialog.setCancelButton(okButton);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/9c47eec8/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/ErrorWindow.java
----------------------------------------------------------------------
diff --git a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/ErrorWindow.java b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/ErrorWindow.java
new file mode 100644
index 0000000..2ffb642
--- /dev/null
+++ b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/ErrorWindow.java
@@ -0,0 +1,279 @@
+/*
+ *
+ * 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.ui.dialogs;
+
+import java.awt.Component;
+import java.awt.event.ActionEvent;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
+import javax.swing.AbstractAction;
+import javax.swing.JButton;
+import javax.swing.JLabel;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.SwingUtilities;
+
+import org.apache.airavata.xbaya.ui.utils.ErrorMessages;
+import org.apache.airavata.xbaya.ui.widgets.GridPanel;
+import org.apache.airavata.xbaya.ui.widgets.XBayaTextArea;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class ErrorWindow {
+
+ private static final String DEFAULT_ERROR_TITLE = "Error";
+
+ private static final String DEFAULT_WARNING_TITLE = "Warning";
+
+ private static final String DEFAULT_INFORMATION_TITLE = "Information";
+
+ private static final Logger logger = LoggerFactory.getLogger(ErrorWindow.class);
+
+ private Component defaultParent;
+
+ /**
+ * @param parent
+ */
+ public ErrorWindow(Component parent) {
+ this.defaultParent = parent;
+ }
+
+ /**
+ * @param message
+ */
+ public void error(String message) {
+ error(null, null, message, null);
+ }
+
+ /**
+ * @param message
+ * @param e
+ */
+ public void error(String message, Throwable e) {
+ error(null, null, message, e);
+ }
+
+ /**
+ * @param e
+ */
+ public void error(Throwable e) {
+ error(null, null, null, e);
+ }
+
+ /**
+ * @param parent
+ * @param message
+ */
+ public void error(Component parent, String message) {
+ error(parent, null, message, null);
+ }
+
+ /**
+ * @param parent
+ * @param message
+ * @param e
+ */
+ public void error(Component parent, String message, Throwable e) {
+ error(parent, null, message, e);
+ }
+
+ /**
+ * @param parent
+ * @param title
+ * @param message
+ */
+ public void error(Component parent, String title, String message) {
+ error(parent, title, message, null);
+ }
+
+ /**
+ * @param parent
+ * @param title
+ * @param message
+ * @param e
+ */
+ public void error(Component parent, String title, String message, Throwable e) {
+
+ logger.error(e==null? message:e.getMessage(), e);
+
+ // If the parent component is not specified, set the frame the one.
+ if (parent == null) {
+ parent = this.defaultParent;
+ }
+
+ // If the title is still null, set it to the default.
+ if (title == null) {
+ title = DEFAULT_ERROR_TITLE;
+ }
+
+ // If the message is still null, try to get it from the exception first,
+ // and set it to the default if it is still null.
+ if (message == null) {
+ if (e != null) {
+ message = messageSplitter(e.getMessage());
+ }
+ }
+ if (message == null) {
+ message = ErrorMessages.UNEXPECTED_ERROR;
+ }
+
+ showErrorDialog(parent, title, message, e);
+ }
+
+ /**
+ * Shows a warning dialog
+ *
+ * @param message
+ */
+ public void warning(String message) {
+ warning(null, null, message);
+ }
+
+ /**
+ * Shows a warning dialog.
+ *
+ * @param parent
+ * @param title
+ * @param message
+ */
+ public void warning(Component parent, String title, String message) {
+ if (parent == null) {
+ parent = this.defaultParent;
+ }
+ if (title == null) {
+ title = DEFAULT_WARNING_TITLE;
+ }
+ showWarningDialog(parent, title, message);
+ }
+
+ /**
+ * Shows a information dialog
+ *
+ * @param message
+ */
+ public void info(String message) {
+ info(null, null, message);
+ }
+
+ /**
+ * Shows a information dialog.
+ *
+ * @param parent
+ * @param title
+ * @param message
+ */
+ public void info(Component parent, String title, String message) {
+ if (parent == null) {
+ parent = this.defaultParent;
+ }
+ if (title == null) {
+ title = DEFAULT_INFORMATION_TITLE;
+ }
+ showInformationDialog(parent, title, message);
+ }
+
+ private void showErrorDialog(Component parent, String title, String message, Throwable e) {
+
+ String[] options = new String[] { "OK", "Detail" };
+ int result = JOptionPane.showOptionDialog(parent, message, title, JOptionPane.DEFAULT_OPTION,
+ JOptionPane.ERROR_MESSAGE, null, options, options[0]);
+
+ if (result == 1) {
+ // A user clicked "Detail".
+
+ // Gets the stack trace as a string
+ StringWriter stringWriter = new StringWriter();
+ PrintWriter printWriter = new PrintWriter(stringWriter);
+ if (e != null) {
+ e.printStackTrace(printWriter);
+ }
+ printWriter.close();
+ String stackTrace = stringWriter.toString();
+
+ JLabel messageLabel = new JLabel(messageSplitter(message));
+
+ XBayaTextArea textArea = new XBayaTextArea();
+ textArea.setEditable(false);
+ textArea.setSize(800, 600);
+ textArea.setText(stackTrace);
+
+ GridPanel mainPanel = new GridPanel();
+ mainPanel.add(messageLabel);
+ mainPanel.add(textArea);
+ mainPanel.layout(2, 1, 1, 0);
+
+ JButton okButton = new JButton("OK");
+ okButton.setDefaultCapable(true);
+
+ JPanel buttonPanel = new JPanel();
+ buttonPanel.add(okButton);
+
+ final XBayaDialog dialog = new XBayaDialog(SwingUtilities.getWindowAncestor(parent), title, mainPanel,
+ buttonPanel);
+
+ okButton.addActionListener(new AbstractAction() {
+ public void actionPerformed(ActionEvent event) {
+ dialog.hide();
+ }
+ });
+
+ dialog.setDefaultButton(okButton);
+ dialog.show();
+ }
+ }
+
+ private void showWarningDialog(Component parent, String title, String message) {
+ JOptionPane.showMessageDialog(parent, message, title, JOptionPane.WARNING_MESSAGE);
+ }
+
+ private void showInformationDialog(Component parent, String title, String message) {
+
+ JOptionPane.showMessageDialog(parent, message, title, JOptionPane.INFORMATION_MESSAGE);
+ }
+
+ private String messageSplitter(String message){
+ int interval = 150;
+ char[] sAr = message.toCharArray();
+ int i = 0;
+ StringBuffer buffer = new StringBuffer("");
+ if(sAr.length > interval){
+ do{
+ String subString = "";
+ if(i + interval > message.length()){
+ subString = message.substring(i,message.length());
+ }else{
+ subString = message.substring(i, i + interval);
+ }
+ buffer.append(subString);
+ if(!subString.contains("\n")){
+ buffer.append("\n");
+ }
+ i = i + interval;
+ }while(i < sAr.length);
+ return buffer.toString();
+ }else{
+ return message;
+ }
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/9c47eec8/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/GlobusFileTransferWindow.java
----------------------------------------------------------------------
diff --git a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/GlobusFileTransferWindow.java b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/GlobusFileTransferWindow.java
new file mode 100644
index 0000000..21c4c95
--- /dev/null
+++ b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/GlobusFileTransferWindow.java
@@ -0,0 +1,258 @@
+///*
+//*
+//* 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.ui.dialogs;
+//
+//import org.apache.airavata.xbaya.XBayaEngine;
+//import org.apache.airavata.xbaya.ui.widgets.GridPanel;
+//import org.apache.airavata.xbaya.ui.widgets.XBayaComboBox;
+//import org.apache.airavata.xbaya.ui.widgets.XBayaLabel;
+//import org.apache.airavata.xbaya.ui.widgets.XBayaTextField;
+//import org.apache.airavata.xbaya.util.GlobusOnlineUtils;
+//import org.apache.airavata.xbaya.util.TransferFile;
+//import org.globusonline.transfer.APIError;
+//import org.json.JSONException;
+//
+//import javax.swing.*;
+//import java.awt.event.ActionEvent;
+//import java.awt.event.ActionListener;
+//import java.io.IOException;
+//import java.security.GeneralSecurityException;
+//import java.util.ArrayList;
+//import java.util.List;
+//
+//
+//public class GlobusFileTransferWindow {
+// private XBayaEngine engine;
+//
+// private XBayaDialog dialog;
+//
+// private XBayaTextField usernameTextField;
+//
+// private JPasswordField pwdTextField;
+//
+// private XBayaComboBox sourceEndpointTextField;
+//
+// private XBayaTextField sourceFilePathTextField;
+//
+// private XBayaComboBox destEndpointTextField;
+//
+// private XBayaTextField destFilePathTextField;
+//
+// private XBayaTextField transferLabelTextField;
+//
+// private GlobusOnlineUtils globusOnlineUtils;
+//
+//
+// private String goUserName;
+// private String goPWD;
+//
+// /**
+// * @param engine XBaya workflow engine
+// */
+// public GlobusFileTransferWindow(XBayaEngine engine) {
+// this.engine = engine;
+// initGUI();
+// }
+//
+// /**
+// * Displays the dialog.
+// */
+// public void show() {
+// this.dialog.show();
+// }
+//
+// private void hide() {
+// this.dialog.hide();
+// }
+//
+// private void ok() {
+//
+// goUserName = this.usernameTextField.getText();
+// goPWD = new String(this.pwdTextField.getPassword());
+//
+// String sourceEndpoint = this.sourceEndpointTextField.getText();
+// String sourceFilePath = this.sourceFilePathTextField.getText();
+// String destEndpoint = this.destEndpointTextField.getText();
+// String destFilePath = this.destFilePathTextField.getText();
+// String transferLabel = this.transferLabelTextField.getText();
+//
+// if(globusOnlineUtils == null){
+// globusOnlineUtils = new GlobusOnlineUtils(goUserName, goPWD);
+// }
+// TransferFile transferFile = globusOnlineUtils.getTransferFile(sourceEndpoint, destEndpoint, sourceFilePath, destFilePath, transferLabel);
+// globusOnlineUtils.transferFiles(transferFile);
+// }
+//
+// private String[] getGOEndpointList(){
+// if (getGoUserName() != null && getGoPWD() != null){
+// globusOnlineUtils = new GlobusOnlineUtils(goUserName, goPWD);
+// }
+// List<String> epList = new ArrayList<String>();
+// try {
+// if (globusOnlineUtils != null){
+// epList = globusOnlineUtils.getEPList();
+// }
+// } catch (IOException e) {
+// e.printStackTrace();
+// } catch (APIError apiError) {
+// apiError.printStackTrace();
+// } catch (GeneralSecurityException e) {
+// e.printStackTrace();
+// } catch (JSONException e) {
+// e.printStackTrace();
+// }
+// return epList.toArray(new String[]{});
+// }
+//
+// /**
+// * Initializes the GUI.
+// */
+// private void initGUI() {
+// this.usernameTextField = new XBayaTextField();
+// this.pwdTextField = new JPasswordField();
+// JButton authenticateButton = new JButton("Authenticate");
+//
+// XBayaLabel nameLabel = new XBayaLabel("GO Username", this.usernameTextField);
+// XBayaLabel pwdLabel = new XBayaLabel("GO Password", this.pwdTextField);
+// JLabel authLabel = new JLabel("");
+//
+// GridPanel infoPanel = new GridPanel();
+// GridPanel authButtonPanel = new GridPanel();
+// GridPanel otherPanel = new GridPanel();
+//
+// authButtonPanel.add(nameLabel.getSwingComponent());
+// authButtonPanel.add(this.usernameTextField.getSwingComponent());
+// authButtonPanel.add(pwdLabel.getSwingComponent());
+// authButtonPanel.add(this.pwdTextField);
+// authButtonPanel.add(authLabel);
+// authButtonPanel.add(authenticateButton);
+//
+// authButtonPanel.layout(3,2,GridPanel.WEIGHT_NONE, 1);
+//
+// String[] goEndpointList = getGOEndpointList();
+// DefaultComboBoxModel cmbModelJobType1 = new DefaultComboBoxModel(goEndpointList);
+// sourceEndpointTextField = new XBayaComboBox(cmbModelJobType1);
+// sourceEndpointTextField.setEditable(true);
+//
+// sourceFilePathTextField = new XBayaTextField();
+// DefaultComboBoxModel cmbModelJobType2 = new DefaultComboBoxModel(goEndpointList);
+// destEndpointTextField = new XBayaComboBox(cmbModelJobType2);
+// destEndpointTextField.setEditable(true);
+// destFilePathTextField = new XBayaTextField();
+// transferLabelTextField = new XBayaTextField();
+//
+// XBayaLabel sourceEprLabel = new XBayaLabel("Source Endpoint", sourceEndpointTextField);
+// XBayaLabel sourceFilePathLabel = new XBayaLabel("Source File Path", sourceFilePathTextField);
+// XBayaLabel destEprLabel = new XBayaLabel("Destination Endpoint", destEndpointTextField);
+// XBayaLabel destFilePathLabel = new XBayaLabel("Destination FIle path", destFilePathTextField);
+// XBayaLabel labelTransferLabel = new XBayaLabel("Label This Transfer", destFilePathTextField);
+//
+//
+// otherPanel.add(sourceEprLabel.getSwingComponent());
+// otherPanel.add(sourceEndpointTextField.getSwingComponent());
+// otherPanel.add(sourceFilePathLabel.getSwingComponent());
+// otherPanel.add(sourceFilePathTextField.getSwingComponent());
+// otherPanel.add(destEprLabel.getSwingComponent());
+// otherPanel.add(destEndpointTextField.getSwingComponent());
+// otherPanel.add(destFilePathLabel.getSwingComponent());
+// otherPanel.add(destFilePathTextField.getSwingComponent());
+// otherPanel.add(labelTransferLabel.getSwingComponent());
+// otherPanel.add(transferLabelTextField.getSwingComponent());
+//
+// otherPanel.layout(5, 2, GridPanel.WEIGHT_NONE, 1);
+// infoPanel.add(authButtonPanel);
+//
+// infoPanel.add(otherPanel);
+// JPanel buttonPanel = new JPanel();
+// infoPanel.add(buttonPanel);
+//
+// infoPanel.layout(3, 1, GridPanel.WEIGHT_NONE, GridPanel.WEIGHT_NONE);
+//
+// JButton okButton = new JButton("OK");
+// okButton.addActionListener(new AbstractAction() {
+// public void actionPerformed(ActionEvent e) {
+// ok();
+// }
+// });
+//
+// JButton cancelButton = new JButton("Cancel");
+// cancelButton.addActionListener(new AbstractAction() {
+// public void actionPerformed(ActionEvent e) {
+// hide();
+// }
+// });
+//
+// buttonPanel.add(okButton);
+// buttonPanel.add(cancelButton);
+//
+// usernameTextField.getSwingComponent().addActionListener(new ActionListener() {
+// public void actionPerformed(ActionEvent event) {
+// setGoUserName(usernameTextField.getText());
+// }
+// }
+// );
+//
+// pwdTextField.addActionListener(new ActionListener() {
+// public void actionPerformed(ActionEvent event) {
+// setGoPWD(new String(pwdTextField.getPassword()));
+// }
+// }
+// );
+//
+// authenticateButton.addActionListener(new ActionListener() {
+//
+// @Override
+// public void actionPerformed(ActionEvent actionEvent) {
+// goUserName = usernameTextField.getText();
+// goPWD = new String(pwdTextField.getPassword());
+//
+// if (goUserName != null && goPWD != null){
+// globusOnlineUtils = new GlobusOnlineUtils(usernameTextField.getText(), new String(pwdTextField.getPassword()));
+// String[] goEndpointList = getGOEndpointList();
+// DefaultComboBoxModel comboBoxModel1 = new DefaultComboBoxModel(goEndpointList);
+// DefaultComboBoxModel comboBoxModel2 = new DefaultComboBoxModel(goEndpointList);
+// sourceEndpointTextField.setModel(comboBoxModel1);
+// destEndpointTextField.setModel(comboBoxModel2);
+// }
+// }
+// });
+//
+// this.dialog = new XBayaDialog(this.engine.getGUI(), "Globus file transfer", infoPanel, buttonPanel);
+// this.dialog.setDefaultButton(okButton);
+// }
+//
+// public String getGoUserName() {
+// return goUserName;
+// }
+//
+// public void setGoUserName(String goUserName) {
+// this.goUserName = goUserName;
+// }
+//
+// public String getGoPWD() {
+// return goPWD;
+// }
+//
+// public void setGoPWD(String goPWD) {
+// this.goPWD = goPWD;
+// }
+//}
http://git-wip-us.apache.org/repos/asf/airavata/blob/9c47eec8/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/TextWindow.java
----------------------------------------------------------------------
diff --git a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/TextWindow.java b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/TextWindow.java
new file mode 100644
index 0000000..400346e
--- /dev/null
+++ b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/TextWindow.java
@@ -0,0 +1,139 @@
+/*
+ *
+ * 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.ui.dialogs;
+
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Toolkit;
+import java.awt.datatransfer.StringSelection;
+import java.awt.event.ActionEvent;
+import java.net.URL;
+
+import javax.swing.AbstractAction;
+import javax.swing.BorderFactory;
+import javax.swing.JButton;
+import javax.swing.JEditorPane;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.event.HyperlinkEvent;
+import javax.swing.event.HyperlinkEvent.EventType;
+import javax.swing.event.HyperlinkListener;
+
+import org.apache.airavata.common.utils.BrowserLauncher;
+import org.apache.airavata.common.utils.StringUtil;
+import org.apache.airavata.xbaya.XBayaEngine;
+import org.apache.airavata.xbaya.ui.widgets.GridPanel;
+import org.apache.airavata.xbaya.ui.widgets.XBayaTextField;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import xsul5.XmlConstants;
+
+public class TextWindow {
+
+ private static final Logger logger = LoggerFactory.getLogger(TextWindow.class);
+
+ private XBayaEngine engine;
+
+ private XBayaDialog dialog;
+
+ private String key;
+ private String value;
+ private String title;
+
+ /**
+ * Creates the AboutWindow.
+ *
+ * @param engine
+ */
+ public TextWindow(XBayaEngine engine, String key, String value, String title) {
+ this.engine = engine;
+ this.key=key;
+ this.value=value;
+ this.title=title;
+ init();
+ }
+
+ /**
+ * Shows the dialog.
+ */
+ public void show() {
+ this.dialog.show();
+ }
+
+ private void hide() {
+ this.dialog.hide();
+ }
+
+ @SuppressWarnings("serial")
+ private void init() {
+ final JEditorPane editorPane = new JEditorPane(XmlConstants.CONTENT_TYPE_HTML, StringUtil.createHTMLUrlTaggedString(value));
+ editorPane.setEditable(false);
+ editorPane.setBackground(Color.WHITE);
+ editorPane.addHyperlinkListener(new HyperlinkListener() {
+ public void hyperlinkUpdate(HyperlinkEvent event) {
+ logger.debug("Event:" + event);
+ if (event.getEventType() == EventType.ACTIVATED) {
+ URL url = event.getURL();
+ try {
+ BrowserLauncher.openURL(url.toString());
+ } catch (Exception e) {
+ TextWindow.this.engine.getGUI().getErrorWindow().error(TextWindow.this.dialog.getDialog(),
+ e.getMessage(), e);
+ }
+ }
+ }
+ });
+ JScrollPane pane = new JScrollPane(editorPane);
+ GridPanel gridPanel = new GridPanel();
+ XBayaTextField txtKey=new XBayaTextField(key);
+ txtKey.getTextField().setEditable(false);
+ gridPanel.add(txtKey);
+ gridPanel.add(pane);
+ gridPanel.getContentPanel().setBorder(BorderFactory.createEtchedBorder());
+ gridPanel.layout(2, 1, 1, 0);
+
+ JPanel buttonPanel = new JPanel();
+ JButton okButton = new JButton("Close");
+ okButton.setDefaultCapable(true);
+ okButton.addActionListener(new AbstractAction() {
+ public void actionPerformed(ActionEvent e) {
+ hide();
+ }
+ });
+ JButton btnCopy = new JButton("Copy to clipboard");
+ btnCopy.addActionListener(new AbstractAction(){
+ @Override
+ public void actionPerformed(ActionEvent arg0) {
+ Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(value), null);
+ }
+
+ });
+ buttonPanel.add(btnCopy);
+ buttonPanel.add(okButton);
+ buttonPanel.setBorder(BorderFactory.createEtchedBorder());
+
+ this.dialog = new XBayaDialog(this.engine.getGUI(), title, gridPanel, buttonPanel);
+ dialog.getDialog().setMinimumSize(new Dimension(400, 400));
+ this.dialog.setDefaultButton(okButton);
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/9c47eec8/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/WaitDialog.java
----------------------------------------------------------------------
diff --git a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/WaitDialog.java b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/WaitDialog.java
new file mode 100644
index 0000000..b92c679
--- /dev/null
+++ b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/WaitDialog.java
@@ -0,0 +1,140 @@
+/*
+ *
+ * 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.ui.dialogs;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ComponentAdapter;
+import java.awt.event.ComponentEvent;
+
+import javax.swing.AbstractAction;
+import javax.swing.JButton;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.SwingConstants;
+import javax.swing.WindowConstants;
+
+import org.apache.airavata.common.utils.SwingUtil;
+import org.apache.airavata.xbaya.ui.XBayaGUI;
+import org.apache.airavata.xbaya.ui.utils.Cancelable;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class WaitDialog {
+
+ private static final Logger logger = LoggerFactory.getLogger(WaitDialog.class);
+
+ private XBayaGUI xbayaGUI;
+
+ private Cancelable cancelable;
+
+ private String title;
+
+ private String message;
+
+ private XBayaDialog dialog;
+
+ private boolean done;
+
+ /**
+ * Constructs a WaitDialog.
+ *
+ * @param cancelable
+ * @param title
+ * @param message
+ * @param engine
+ */
+ public WaitDialog(Cancelable cancelable, String title, String message, XBayaGUI xbayaGUI) {
+ this.cancelable = cancelable;
+ this.title = title;
+ this.message = message;
+ this.xbayaGUI = xbayaGUI;
+ this.done = true;
+ }
+
+ /**
+ * Shows the dialog.
+ */
+ public void show() {
+ synchronized (this) {
+ // We cannot check if this.done is false because show() might be
+ // called more than once at the same time.
+ this.done = false;
+ // We cannot make the whole method synchronized because
+ // this.dialog.show() blocks.
+ if (this.dialog == null) {
+ initGUI();
+ }
+ }
+ this.dialog.show();
+ }
+
+ /**
+ * Hides the dialog.
+ */
+ public synchronized void hide() {
+ if (this.done) {
+ // The dialog is already hidden.
+ return;
+ }
+ while (this.dialog == null || !this.dialog.getDialog().isVisible()) {
+ try {
+ // Wait for at least one show is called. We have to rely on
+ // ComponentEvent because this.dialog.show() blocks.
+ wait();
+ } catch (InterruptedException e) {
+ logger.error(e.getMessage(), e);
+ }
+ }
+ this.done = true;
+ this.dialog.hide();
+ }
+
+ private void initGUI() {
+ JLabel label = new JLabel(this.message, SwingConstants.CENTER);
+ JButton cancelButton = new JButton("Cancel");
+ cancelButton.addActionListener(new AbstractAction() {
+ public void actionPerformed(ActionEvent e) {
+ WaitDialog.this.dialog.hide();
+ WaitDialog.this.cancelable.cancel();
+ }
+ });
+
+ JPanel buttonPanel = new JPanel();
+ buttonPanel.add(cancelButton);
+
+ this.dialog = new XBayaDialog(this.xbayaGUI, this.title, label, buttonPanel);
+
+ this.dialog.getDialog().setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
+ this.dialog.getDialog().setCursor(SwingUtil.WAIT_CURSOR);
+
+ this.dialog.getDialog().addComponentListener(new ComponentAdapter() {
+ @Override
+ public void componentShown(ComponentEvent e) {
+ shown();
+ }
+ });
+ }
+
+ private synchronized void shown() {
+ notifyAll();
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/9c47eec8/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/XBayaDialog.java
----------------------------------------------------------------------
diff --git a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/XBayaDialog.java b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/XBayaDialog.java
new file mode 100644
index 0000000..24a0cbb
--- /dev/null
+++ b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/XBayaDialog.java
@@ -0,0 +1,267 @@
+/*
+ *
+ * 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.ui.dialogs;
+
+import java.awt.Container;
+import java.awt.Dialog;
+import java.awt.Dimension;
+import java.awt.Frame;
+import java.awt.Toolkit;
+import java.awt.Window;
+import java.awt.event.KeyEvent;
+import java.awt.event.KeyListener;
+
+import javax.swing.JButton;
+import javax.swing.JComponent;
+import javax.swing.JDialog;
+import javax.swing.JLabel;
+
+import org.apache.airavata.common.utils.SwingUtil;
+import org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException;
+import org.apache.airavata.xbaya.ui.XBayaGUI;
+import org.apache.airavata.xbaya.ui.widgets.XBayaComponent;
+
+public class XBayaDialog {
+
+ private Window owner;
+
+ private String title;
+
+ private String description;
+
+ private JDialog dialog;
+
+ private JComponent mainPanel;
+
+ private JComponent buttonPanel;
+
+ /**
+ * Constructs an XBayaDialog.
+ *
+ * @param engine
+ * @param title
+ * @param mainPanel
+ * @param buttonPanel
+ */
+ public XBayaDialog(XBayaGUI xbayaGUI, String title, XBayaComponent mainPanel, XBayaComponent buttonPanel) {
+ this(xbayaGUI.getFrame(), title, mainPanel.getSwingComponent(), buttonPanel.getSwingComponent());
+ }
+
+ /**
+ * Constructs an XBayaDialog.
+ *
+ * @param engine
+ * @param title
+ * @param mainPanel
+ * @param buttonPanel
+ */
+ public XBayaDialog(XBayaGUI xbayaGUI, String title, XBayaComponent mainPanel, JComponent buttonPanel) {
+ this(xbayaGUI.getFrame(), title, mainPanel.getSwingComponent(), buttonPanel);
+ }
+
+ /**
+ * Constructs an XBayaDialog.
+ *
+ * @param engine
+ * @param title
+ * @param description
+ * @param mainPanel
+ * @param buttonPanel
+ */
+ public XBayaDialog(XBayaGUI xbayaGUI, String title, String description, XBayaComponent mainPanel,
+ JComponent buttonPanel) {
+ this(xbayaGUI.getFrame(), title, description, mainPanel.getSwingComponent(), buttonPanel);
+ }
+
+ /**
+ * Constructs an XBayaDialog.
+ *
+ * @param engine
+ * @param title
+ * @param mainPanel
+ * @param buttonPanel
+ */
+ public XBayaDialog(XBayaGUI xbayaGUI, String title, JComponent mainPanel, JComponent buttonPanel) {
+ this(xbayaGUI.getFrame(), title, mainPanel, buttonPanel);
+ }
+
+ /**
+ * Constructs an XBayaDialog.
+ *
+ * @param owner
+ * @param title
+ * @param mainPanel
+ * @param buttonPanel
+ */
+ public XBayaDialog(Window owner, String title, XBayaComponent mainPanel, JComponent buttonPanel) {
+ this(owner, title, mainPanel.getSwingComponent(), buttonPanel);
+ }
+
+ /**
+ * Constructs an XBayaDialog.
+ *
+ * @param owner
+ * @param title
+ * @param mainPanel
+ * @param buttonPanel
+ */
+ public XBayaDialog(Window owner, String title, JComponent mainPanel, JComponent buttonPanel) {
+ this(owner, title, null, mainPanel, buttonPanel);
+ }
+
+ /**
+ * Constructs an XBayaDialog.
+ *
+ * @param owner
+ * @param title
+ * @param description
+ * @param mainPanel
+ * @param buttonPanel
+ */
+ public XBayaDialog(Window owner, String title, String description, JComponent mainPanel, JComponent buttonPanel) {
+ this.owner = owner;
+ this.title = title;
+ this.description = description;
+ this.mainPanel = mainPanel;
+ this.buttonPanel = buttonPanel;
+ init();
+ }
+
+ /**
+ * @return The dialog.
+ */
+ public JDialog getDialog() {
+ return this.dialog;
+ }
+
+ /**
+ * Determines whether this component should be visible when its parent is visible. Components are initially visible,
+ * with the exception of top level components such as <code>Frame</code> objects.
+ *
+ * @return <code>true</code> if the component is visible, <code>false</code> otherwise
+ */
+ public boolean isVisible() {
+ return this.dialog.isVisible();
+ }
+
+ /**
+ * Shows the dialog.
+ */
+ public void show() {
+ this.dialog.pack();
+
+ // Adjust the size if it's bigger than the screen.
+ Dimension size = this.dialog.getSize();
+ Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
+ final int inset = 100;
+ int width = size.width;
+ if (width > screenSize.width) {
+ width = screenSize.width - inset;
+ }
+ int height = size.height;
+ if (height > screenSize.height) {
+ height = screenSize.height - inset;
+ }
+ this.dialog.setSize(width, height);
+
+ this.dialog.setLocationRelativeTo(this.owner);
+ this.dialog.setVisible(true);
+ }
+
+ /**
+ * Just set dialog visible Do NOTHING to layout
+ */
+ public void simpeShow() {
+ this.dialog.setVisible(true);
+ }
+
+ /**
+ * Hides the dialog.
+ */
+ public void hide() {
+ this.dialog.setVisible(false);
+ }
+
+ /**
+ * @param title
+ */
+ public void setTitle(String title) {
+ this.title = title;
+ this.dialog.setTitle(title);
+ }
+
+ /**
+ * @param button
+ */
+ public void setDefaultButton(JButton button) {
+ this.dialog.getRootPane().setDefaultButton(button);
+ }
+
+ public void setCancelButton(final JButton button){
+ this.dialog.getRootPane().addKeyListener(new KeyListener(){
+
+ @Override
+ public void keyPressed(KeyEvent event) {
+ if (event.getKeyCode()==27){
+ button.getAction().actionPerformed(null);
+ }
+ }
+
+ @Override
+ public void keyReleased(KeyEvent arg0) {
+ }
+
+ @Override
+ public void keyTyped(KeyEvent arg0) {
+ }
+
+ });
+ }
+
+ private void init() {
+ if (this.owner instanceof Frame) {
+ this.dialog = new JDialog((Frame) this.owner);
+ } else if (this.owner instanceof Dialog) {
+ this.dialog = new JDialog((Dialog) this.owner);
+ } else {
+ // This should not happen.
+ throw new WorkflowRuntimeException("The owner component was neither Frame or Dialog.");
+ }
+ this.dialog.setTitle(this.title);
+ this.dialog.setModal(true);
+ this.dialog.setResizable(true);
+
+ Container contentPane = this.dialog.getContentPane();
+ int numRow = 0;
+ if (this.description != null && this.description.length() > 0) {
+ JLabel descriptionLabel = new JLabel("<html>" + this.description + "</html>");
+
+ contentPane.add(descriptionLabel);
+ numRow++;
+ }
+ contentPane.add(this.mainPanel);
+ numRow++;
+ contentPane.add(this.buttonPanel);
+ numRow++;
+ SwingUtil.layoutToGrid(contentPane, numRow, 1, numRow - 2, 0);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/9c47eec8/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/amazon/AmazonEC2InvokerWindow.java
----------------------------------------------------------------------
diff --git a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/amazon/AmazonEC2InvokerWindow.java b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/amazon/AmazonEC2InvokerWindow.java
new file mode 100644
index 0000000..c9f3051
--- /dev/null
+++ b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/amazon/AmazonEC2InvokerWindow.java
@@ -0,0 +1,222 @@
+/*
+ *
+ * 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.ui.dialogs.amazon;
+
+//import edu.indiana.extreme.amazonec2webservice.AmazonEC2WebserviceCallbackHandler;
+//import edu.indiana.extreme.amazonec2webservice.AmazonEC2WebserviceStub;
+//import edu.indiana.extreme.amazonec2webservice.AmazonEC2WebserviceStub.JobStatusResponse;
+//import edu.indiana.extreme.amazonec2webservice.AmazonEC2WebserviceStub.JobSubmissionReceipt;
+//import edu.indiana.extreme.amazonec2webservice.AmazonEC2WebserviceStub.JobSubmitOperation;
+import org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException;
+import org.apache.airavata.xbaya.XBayaEngine;
+import org.apache.airavata.xbaya.ui.dialogs.XBayaDialog;
+import org.apache.airavata.xbaya.ui.widgets.GridPanel;
+import org.apache.airavata.xbaya.ui.widgets.XBayaLabel;
+import org.apache.airavata.xbaya.ui.widgets.XBayaTextField;
+import org.apache.axis2.AxisFault;
+
+import javax.swing.*;
+import java.awt.event.ActionEvent;
+import java.rmi.RemoteException;
+
+public class AmazonEC2InvokerWindow {
+ private XBayaEngine engine;
+
+ private XBayaTextField accessKeyIDTextField;
+ private XBayaTextField secretAccessKeyTextField;
+ private XBayaTextField keyPairNameTextField;
+ private XBayaTextField numOfInstancesTextField;
+ private XBayaTextField jobFlowNameTextField;
+ private XBayaTextField logLocationOnS3TextField;
+ private XBayaTextField inputLocationOnS3TextField;
+ private XBayaTextField outputLocationOnS3TextField;
+ private XBayaTextField jarFilePathOnS3TextField;
+ private XBayaTextField mainClassNameTextField;
+ private XBayaDialog dialog;
+
+ /**
+ * Constructs a PegasusInvokerWindow.
+ */
+ public AmazonEC2InvokerWindow(XBayaEngine engine) {
+ this.engine = engine;
+ initGUI();
+ }
+
+ @SuppressWarnings("serial")
+ protected void initGUI() {
+
+ this.accessKeyIDTextField = new XBayaTextField();
+ XBayaLabel accessKeyIDLabel = new XBayaLabel("Access Key", this.accessKeyIDTextField);
+
+ this.secretAccessKeyTextField = new XBayaTextField();
+ XBayaLabel secretAccessKeyLabel = new XBayaLabel("Secret Access Key", this.secretAccessKeyTextField);
+
+ this.keyPairNameTextField = new XBayaTextField();
+ XBayaLabel keyPairNameLabel = new XBayaLabel("Key Pair Name", this.keyPairNameTextField);
+
+ this.numOfInstancesTextField = new XBayaTextField();
+ XBayaLabel numOfInstancesLabel = new XBayaLabel("Number of Instances", this.numOfInstancesTextField);
+
+ this.jobFlowNameTextField = new XBayaTextField();
+ XBayaLabel jobFlowNameLabel = new XBayaLabel("Job Flow Name", this.jobFlowNameTextField);
+
+ this.logLocationOnS3TextField = new XBayaTextField();
+ XBayaLabel logLocationOnS3Label = new XBayaLabel("Log Location(S3)", this.logLocationOnS3TextField);
+
+ this.inputLocationOnS3TextField = new XBayaTextField();
+ XBayaLabel inputLocationOnS3Label = new XBayaLabel("Input Location(S3)", this.inputLocationOnS3TextField);
+
+ this.outputLocationOnS3TextField = new XBayaTextField();
+ XBayaLabel outputLocationOnS3Label = new XBayaLabel("Output Location(S3)", this.outputLocationOnS3TextField);
+
+ this.jarFilePathOnS3TextField = new XBayaTextField();
+ XBayaLabel jarFilePathOnS3Label = new XBayaLabel("Jar File Location(S3)", this.jarFilePathOnS3TextField);
+
+ this.mainClassNameTextField = new XBayaTextField();
+ XBayaLabel mainClassNameLabel = new XBayaLabel("Main Class Name", this.mainClassNameTextField);
+
+ this.accessKeyIDTextField.setText("AKIAI3GNMQVYA5LSQNEQ");
+ this.secretAccessKeyTextField.setText("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");
+ this.keyPairNameTextField.setText("XbayaHadoopTest");
+ this.numOfInstancesTextField.setText("4");
+ this.jobFlowNameTextField.setText("Test-job-flow");
+ this.logLocationOnS3TextField.setText("s3n://xbaya-ec2-test/logs");
+ this.inputLocationOnS3TextField.setText("s3n://xbaya-ec2-test/input/");
+ this.outputLocationOnS3TextField.setText("s3n://xbaya-ec2-test/output/");
+ this.jarFilePathOnS3TextField.setText("s3n://xbaya-ec2-test/jars/Hadoopv400.jar");
+ this.mainClassNameTextField.setText("edu.indiana.extreme.HadoopRayTracer");
+
+ GridPanel infoPanel = new GridPanel();
+ infoPanel.add(accessKeyIDLabel);
+ infoPanel.add(this.accessKeyIDTextField);
+ infoPanel.add(secretAccessKeyLabel);
+ infoPanel.add(this.secretAccessKeyTextField);
+ infoPanel.add(keyPairNameLabel);
+ infoPanel.add(this.keyPairNameTextField);
+ infoPanel.add(numOfInstancesLabel);
+ infoPanel.add(this.numOfInstancesTextField);
+ infoPanel.add(jobFlowNameLabel);
+ infoPanel.add(this.jobFlowNameTextField);
+ infoPanel.add(logLocationOnS3Label);
+ infoPanel.add(this.logLocationOnS3TextField);
+ infoPanel.add(inputLocationOnS3Label);
+ infoPanel.add(this.inputLocationOnS3TextField);
+ infoPanel.add(outputLocationOnS3Label);
+ infoPanel.add(this.outputLocationOnS3TextField);
+ infoPanel.add(jarFilePathOnS3Label);
+ infoPanel.add(this.jarFilePathOnS3TextField);
+ infoPanel.add(mainClassNameLabel);
+ infoPanel.add(this.mainClassNameTextField);
+
+ infoPanel.layout(10, 2, GridPanel.WEIGHT_NONE, 1);
+
+ GridPanel mainPanel = new GridPanel();
+ mainPanel.add(infoPanel);
+ mainPanel.layout(1, 1, 0, 0);
+
+ JButton invokeButton = new JButton("Invoke");
+ invokeButton.addActionListener(new AbstractAction() {
+ public void actionPerformed(ActionEvent e) {
+ execute();
+ }
+
+ });
+
+ JButton cancelButton = new JButton("Cancel");
+ cancelButton.addActionListener(new AbstractAction() {
+ public void actionPerformed(ActionEvent e) {
+ hide();
+ }
+ });
+
+ JPanel buttonPanel = new JPanel();
+ buttonPanel.add(invokeButton);
+ buttonPanel.add(cancelButton);
+
+ this.dialog = new XBayaDialog(this.engine.getGUI(), "Deploy Workflow", mainPanel, buttonPanel);
+ }
+
+ /**
+ * Deploy Work Flow to Amazon EC2
+ */
+ protected void execute() {
+// try {
+// AmazonEC2WebserviceStub stub = new AmazonEC2WebserviceStub();
+// JobSubmitOperation jobInfo = new JobSubmitOperation();
+// jobInfo.setAccessKeyID(this.accessKeyIDTextField.getText());
+// jobInfo.setSecretAccessKey(this.secretAccessKeyTextField.getText());
+// jobInfo.setKeyPairName(this.keyPairNameTextField.getText());
+// jobInfo.setNumOfInstances(this.numOfInstancesTextField.getText());
+// jobInfo.setJobFlowName(this.jobFlowNameTextField.getText());
+// jobInfo.setLogLocationOnS3(this.logLocationOnS3TextField.getText());
+// jobInfo.setInputLocationOnS3(this.inputLocationOnS3TextField.getText());
+// jobInfo.setOutputLocationOnS3(this.outputLocationOnS3TextField.getText());
+// jobInfo.setJarFilePathOnS3(this.jarFilePathOnS3TextField.getText());
+// jobInfo.setMainClassName(this.mainClassNameTextField.getText());
+// stub.startjobSubmitOperation(jobInfo, new MyHandler());
+// this.hide();
+// } catch (AxisFault e) {
+// e.printStackTrace();
+// } catch (RemoteException e) {
+// e.printStackTrace();
+// }
+ }
+
+ /**
+ * hide the dialog (when user clicked on cancel)
+ */
+ public void hide() {
+ this.dialog.hide();
+ }
+
+ /**
+ * show the dialog (when user clicked on invoke)
+ */
+ public void show() {
+ this.dialog.show();
+ }
+
+// class MyHandler extends AmazonEC2WebserviceCallbackHandler {
+//
+// @Override
+// public void receiveResultjobSubmitOperation(JobSubmissionReceipt result) {
+// JOptionPane.showMessageDialog(null, "Job Submitted, ID: " + result.getJobFlowID(), "",
+// JOptionPane.INFORMATION_MESSAGE);
+// }
+//
+// @Override
+// public void receiveErrorjobSubmitOperation(java.lang.Exception e) {
+// JOptionPane.showMessageDialog(null, "Job Submit Failed!", "", JOptionPane.ERROR_MESSAGE);
+// }
+//
+// @Override
+// public void receiveResultjobStatus(JobStatusResponse result) {
+// System.out.println("In call back, response is: " + result.getStatus());
+// }
+//
+// @Override
+// public void receiveErrorjobStatus(java.lang.Exception e) {
+// throw new WorkflowRuntimeException(e);
+// }
+
+// }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/9c47eec8/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/amazon/AmazonS3UtilsWindow.java
----------------------------------------------------------------------
diff --git a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/amazon/AmazonS3UtilsWindow.java b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/amazon/AmazonS3UtilsWindow.java
new file mode 100644
index 0000000..1fd86a4
--- /dev/null
+++ b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/amazon/AmazonS3UtilsWindow.java
@@ -0,0 +1,312 @@
+/*
+ *
+ * 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.ui.dialogs.amazon;
+
+import org.apache.airavata.xbaya.XBayaEngine;
+import org.apache.airavata.xbaya.core.amazon.AmazonCredential;
+import org.apache.airavata.xbaya.ui.dialogs.XBayaDialog;
+import org.apache.airavata.xbaya.ui.widgets.GridPanel;
+import org.apache.airavata.xbaya.ui.widgets.XBayaLabel;
+import org.apache.airavata.xbaya.ui.widgets.XBayaTextField;
+import org.apache.airavata.xbaya.ui.widgets.amazon.S3Tree;
+import org.jets3t.service.S3Service;
+import org.jets3t.service.S3ServiceException;
+import org.jets3t.service.impl.rest.httpclient.RestS3Service;
+import org.jets3t.service.security.AWSCredentials;
+
+import javax.swing.*;
+import javax.swing.event.TreeSelectionEvent;
+import javax.swing.event.TreeSelectionListener;
+import javax.swing.tree.DefaultMutableTreeNode;
+import java.awt.event.ActionEvent;
+import java.io.File;
+
+public class AmazonS3UtilsWindow {
+ private XBayaDialog dialog;
+
+ private static XBayaEngine xBayaEngine;
+
+ private static AmazonS3UtilsWindow window;
+
+ private XBayaTextField fileTextField;
+ private XBayaTextField uploadBucketTextField;
+ private XBayaTextField downloadBucketTextField;
+ private XBayaTextField keyTextField;
+ private XBayaTextField folderTextField;
+
+ private S3Tree s3Tree;
+
+ /**
+ * Constructs a AmazonS3UtilsWindow.
+ *
+ * @param engine XBayaEngine
+ */
+ private AmazonS3UtilsWindow(XBayaEngine engine) {
+ xBayaEngine = engine;
+ initGUI();
+ }
+
+ /**
+ * getErrorWindow
+ *
+ * @param engine XBayaEngine
+ */
+ public static AmazonS3UtilsWindow getInstance(XBayaEngine engine) {
+ if (window == null) {
+ window = new AmazonS3UtilsWindow(engine);
+ } else if (xBayaEngine != engine) {
+ window = new AmazonS3UtilsWindow(engine);
+ }
+ return window;
+ }
+
+ /**
+ * Get S3 Service
+ *
+ * @return S3Service
+ */
+ private S3Service getS3Service() {
+ S3Service s3Service = null;
+ try {
+ s3Service = new RestS3Service(new AWSCredentials(AmazonCredential.getInstance().getAwsAccessKeyId(),
+ AmazonCredential.getInstance().getAwsSecretAccessKey()));
+ } catch (S3ServiceException s3ex) {
+ xBayaEngine.getGUI().getErrorWindow().error(s3ex);
+ }
+ return s3Service;
+ }
+
+ @SuppressWarnings("serial")
+ protected void initGUI() {
+
+ /* Upload Panel */
+ this.fileTextField = new XBayaTextField();
+ XBayaLabel fileLabel = new XBayaLabel("Upload File Path", this.fileTextField);
+
+ this.uploadBucketTextField = new XBayaTextField();
+ XBayaLabel uploadBucketLabel = new XBayaLabel("Bucket Name", this.uploadBucketTextField);
+
+ GridPanel uploadPanel = new GridPanel();
+ uploadPanel.getSwingComponent().setBorder(BorderFactory.createTitledBorder("Upload"));
+ uploadPanel.add(fileLabel);
+ uploadPanel.add(this.fileTextField);
+ uploadPanel.add(uploadBucketLabel);
+ uploadPanel.add(this.uploadBucketTextField);
+ uploadPanel.layout(2, 2, GridPanel.WEIGHT_NONE, 1);
+
+ /* Download Panel */
+ if (AmazonCredential.getInstance().getAwsAccessKeyId().equals("AKIAI3GNMQVYA5LSQNEQ")) {
+ // Avoid to use default Aws Access Key
+ JOptionPane.showMessageDialog(AmazonS3UtilsWindow.this.dialog.getDialog(), "Aws Access Key not set!",
+ "Error", JOptionPane.ERROR_MESSAGE);
+ return;
+ }
+ this.downloadBucketTextField = new XBayaTextField();
+ XBayaLabel downloadBucketLabel = new XBayaLabel("Bucket Name", this.downloadBucketTextField);
+
+ this.keyTextField = new XBayaTextField();
+ XBayaLabel keyLabel = new XBayaLabel("Key Name", this.keyTextField);
+
+ this.folderTextField = new XBayaTextField();
+ XBayaLabel folderLabel = new XBayaLabel("Download Location", this.folderTextField);
+
+ GridPanel downloadPanel = new GridPanel();
+ downloadPanel.getSwingComponent().setBorder(BorderFactory.createTitledBorder("Download"));
+ downloadPanel.add(downloadBucketLabel);
+ downloadPanel.add(this.downloadBucketTextField);
+ downloadPanel.add(keyLabel);
+ downloadPanel.add(this.keyTextField);
+ downloadPanel.add(folderLabel);
+ downloadPanel.add(this.folderTextField);
+ downloadPanel.layout(3, 2, GridPanel.WEIGHT_NONE, 1);
+
+ /* Button Panel */
+ JButton refreshButton = new JButton("Connect/Refresh");
+ refreshButton.addActionListener(new AbstractAction() {
+
+ private ChangeCredentialWindow credentialWindow;
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ if (AmazonCredential.getInstance().getAwsAccessKeyId().isEmpty()
+ || AmazonCredential.getInstance().getAwsSecretAccessKey().isEmpty()) {
+ JOptionPane.showMessageDialog(AmazonS3UtilsWindow.this.dialog.getDialog(),
+ "Aws Access Key not set!", "Error", JOptionPane.ERROR_MESSAGE);
+
+ if (this.credentialWindow == null) {
+ this.credentialWindow = new ChangeCredentialWindow(AmazonS3UtilsWindow.this.dialog.getDialog());
+ }
+ try {
+ this.credentialWindow.show();
+ } catch (Exception e1) {
+ xBayaEngine.getGUI().getErrorWindow().error(e1);
+ }
+
+ return;
+ }
+ AmazonS3UtilsWindow.this.s3Tree.clean();
+ BucketsLoader bucketsLoader = new BucketsLoader(xBayaEngine.getGUI(), window.dialog.getDialog());
+ bucketsLoader.load(getS3Service(), AmazonS3UtilsWindow.this.s3Tree);
+ }
+ });
+
+ JButton uploadButton = new JButton("Upload");
+ uploadButton.addActionListener(new AbstractAction() {
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ if ((window.fileTextField.getText().length() != 0)
+ && (window.uploadBucketTextField.getText().length() != 0)) {
+ S3Uploader s3Uploader = new S3Uploader(xBayaEngine, window.dialog.getDialog());
+ s3Uploader.upload(getS3Service(), AmazonS3UtilsWindow.this.s3Tree,
+ window.uploadBucketTextField.getText(), window.fileTextField.getText());
+
+ window.fileTextField.setText("");
+ window.folderTextField.setText("");
+ } else {
+ xBayaEngine.getGUI().getErrorWindow().error(window.dialog.getDialog(),
+ "Please give input to every upload fields");
+ }
+ }
+ });
+
+ JButton downloadButton = new JButton("Download");
+ downloadButton.addActionListener(new AbstractAction() {
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ if ((window.downloadBucketTextField.getText().length() != 0)
+ && (window.keyTextField.getText().length() != 0)
+ && (window.folderTextField.getText().length() != 0)) {
+ S3Downloader s3Downloader = new S3Downloader(xBayaEngine, window.dialog.getDialog());
+ s3Downloader.download(getS3Service(), window.downloadBucketTextField.getText(),
+ window.keyTextField.getText(), window.folderTextField.getText());
+
+ window.downloadBucketTextField.setText("");
+ window.keyTextField.setText("");
+ window.folderTextField.setText("");
+
+ } else {
+ xBayaEngine.getGUI().getErrorWindow().error(window.dialog.getDialog(),
+ "Please give input to every download fields");
+ }
+ }
+ });
+
+ JButton fileButton = new JButton("Choose File & Flolder");
+ fileButton.addActionListener(new AbstractAction() {
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ final JFileChooser fc = new JFileChooser();
+ fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
+ int returnVal = fc.showOpenDialog(AmazonS3UtilsWindow.this.dialog.getDialog());
+
+ if (returnVal == JFileChooser.APPROVE_OPTION) {
+ String filePath = fc.getSelectedFile().getAbsolutePath();
+ File file = fc.getSelectedFile();
+ if (file.isFile()) {
+ window.fileTextField.setText(filePath);
+ window.folderTextField.setText("");
+ } else if (file.isDirectory()) {
+ window.folderTextField.setText(filePath);
+ window.fileTextField.setText("");
+ }
+ }
+ }
+ });
+
+ JButton cancelButton = new JButton("Cancel");
+ cancelButton.addActionListener(new AbstractAction() {
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ hide();
+ }
+ });
+
+ JPanel buttonPanel = new JPanel();
+ buttonPanel.add(refreshButton);
+ buttonPanel.add(uploadButton);
+ buttonPanel.add(downloadButton);
+ buttonPanel.add(fileButton);
+ buttonPanel.add(cancelButton);
+
+ /* Main Panel */
+ GridPanel mainPanel = new GridPanel(true);
+ this.s3Tree = new S3Tree();
+ mainPanel.add(new JScrollPane(this.s3Tree));
+ mainPanel.add(uploadPanel);
+ mainPanel.add(downloadPanel);
+ mainPanel.layout(3, 1, 0, GridPanel.WEIGHT_EQUALLY);
+
+ this.s3Tree.addTreeSelectionListener(new TreeSelectionListener() {
+ @Override
+ public void valueChanged(TreeSelectionEvent e) {
+ DefaultMutableTreeNode node = AmazonS3UtilsWindow.this.s3Tree.getSelectedNode();
+
+ if (node == null)
+ return;
+
+ Object nodeInfo = node.getUserObject();
+ String bucketName;
+ String downloadPanelBucketName = "";
+ if (node.isLeaf() && node.getParent() != null) { // Node is probably a key
+ DefaultMutableTreeNode parentNode = (DefaultMutableTreeNode) node.getParent();
+ bucketName = (String) parentNode.getUserObject();
+ if (!bucketName.equals("S3 Contents")) { // Node is indeed a key
+ downloadPanelBucketName = (String) parentNode.getUserObject();
+ String currentNodeName = (String) node.getUserObject();
+ int index = currentNodeName.lastIndexOf('/');
+ index = index >= 0 ? index : 0;
+ if (index > 0) {
+ bucketName = bucketName + "/" + currentNodeName.substring(0, index);
+ }
+ String keyName = (String) nodeInfo;
+ window.keyTextField.setText(keyName);
+ } // Node is a bucket
+ else {
+ bucketName = (String) nodeInfo;
+ window.keyTextField.setText("");
+ }
+ } else { // Node is a bucket
+ bucketName = (String) nodeInfo;
+ window.keyTextField.setText("");
+ }
+
+ window.uploadBucketTextField.setText(bucketName);
+ window.downloadBucketTextField.setText(downloadPanelBucketName);
+ }
+ });
+
+ this.dialog = new XBayaDialog(xBayaEngine.getGUI(), "Amazon S3 Upload/Download Tool", mainPanel, buttonPanel);
+
+ }
+
+ public void hide() {
+ this.dialog.hide();
+ }
+
+ public void show() {
+ this.dialog.show();
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/9c47eec8/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/amazon/BucketsLoader.java
----------------------------------------------------------------------
diff --git a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/amazon/BucketsLoader.java b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/amazon/BucketsLoader.java
new file mode 100644
index 0000000..32c373c
--- /dev/null
+++ b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/amazon/BucketsLoader.java
@@ -0,0 +1,123 @@
+/*
+ *
+ * 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.ui.dialogs.amazon;
+
+import org.apache.airavata.xbaya.ui.XBayaGUI;
+import org.apache.airavata.xbaya.ui.dialogs.WaitDialog;
+import org.apache.airavata.xbaya.ui.utils.Cancelable;
+import org.apache.airavata.xbaya.ui.widgets.amazon.S3Tree;
+import org.apache.airavata.xbaya.ui.widgets.amazon.S3TreeModel;
+import org.jets3t.service.S3Service;
+import org.jets3t.service.S3ServiceException;
+import org.jets3t.service.model.S3Bucket;
+import org.jets3t.service.model.S3Object;
+
+import javax.swing.*;
+import javax.swing.tree.DefaultMutableTreeNode;
+
+public class BucketsLoader implements Cancelable {
+ private XBayaGUI xbayaGUI;
+ private JDialog parent;
+
+ private boolean canceled;
+
+ private WaitDialog loadingDialog;
+
+ /**
+ * Constructs a BucketsLoader.
+ *
+ * @param xbayaGUI XBayaGUI
+ * @param parent JDialog
+ */
+ public BucketsLoader(XBayaGUI xbayaGUI, JDialog parent) {
+ this.xbayaGUI=xbayaGUI;
+ this.parent = parent;
+ this.loadingDialog = new WaitDialog(this, "Loading S3 Buckets.", "Loading S3 Buckets.\n"
+ + "Please wait for a moment.", this.xbayaGUI);
+ }
+
+ /**
+ * @see org.apache.airavata.xbaya.ui.utils.Cancelable#cancel()
+ */
+ @Override
+ public void cancel() {
+ this.canceled = true;
+ }
+
+ /**
+ *
+ * @param s3 S3Service
+ * @param s3Tree S3Tree
+ */
+ public void load(final S3Service s3, final S3Tree s3Tree) {
+
+ new Thread(new Runnable() {
+
+ @Override
+ public void run() {
+ S3Bucket[] bucketArray;
+ try {
+ bucketArray = s3.listAllBuckets();
+ for (S3Bucket s3Bucket : bucketArray) {
+ DefaultMutableTreeNode tempTreeNode = s3Tree.addObject((DefaultMutableTreeNode) null,
+ s3Bucket.getName());
+
+ if (BucketsLoader.this.canceled)
+ return;
+
+ S3Object[] s3ObjectArray = s3.listObjects(s3Bucket.getName());
+ for (S3Object s3Object : s3ObjectArray) {
+ String keyName = s3Object.getName();
+ if (keyName.contains("$")) {
+ keyName = keyName.substring(0, keyName.indexOf('_'));
+ }
+ s3Tree.addObject(tempTreeNode, keyName);
+ }
+ }
+
+ s3Tree.refresh();
+
+ if (bucketArray.length == 0) {
+ JOptionPane.showMessageDialog(BucketsLoader.this.parent, "Connection Failed!", "Error",
+ JOptionPane.ERROR_MESSAGE);
+ return;
+ }
+
+ JOptionPane.showMessageDialog(BucketsLoader.this.parent, "Connection Successfully!", "Info",
+ JOptionPane.INFORMATION_MESSAGE);
+
+ // already connect
+ S3TreeModel.getInstance().connect();
+
+ } catch (S3ServiceException ex) {
+ BucketsLoader.this.xbayaGUI.getErrorWindow().error(BucketsLoader.this.parent,
+ "Cannot List S3 buckets", ex);
+ } finally {
+ BucketsLoader.this.loadingDialog.hide();
+ }
+ }
+ }).start();
+
+ this.loadingDialog.show();
+ }
+
+}
\ No newline at end of file