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 2012/10/19 17:56:09 UTC
svn commit: r1400139 - in
/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui:
XBayaGUI.java menues/XBayaMenuItem.java
Author: samindaw
Date: Fri Oct 19 15:56:09 2012
New Revision: 1400139
URL: http://svn.apache.org/viewvc?rev=1400139&view=rev
Log:
https://issues.apache.org/jira/browse/AIRAVATA-598 & part solution for https://issues.apache.org/jira/browse/AIRAVATA-229
Modified:
airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/XBayaGUI.java
airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/menues/XBayaMenuItem.java
Modified: airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/XBayaGUI.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/XBayaGUI.java?rev=1400139&r1=1400138&r2=1400139&view=diff
==============================================================================
--- airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/XBayaGUI.java (original)
+++ airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/XBayaGUI.java Fri Oct 19 15:56:09 2012
@@ -423,15 +423,19 @@ public class XBayaGUI implements EventLi
// newGraphCanvas(true);
}
- public void closeAllGraphCanvas(){
+ public boolean closeAllGraphCanvas(){
while (graphTabbedPane.getTabCount()>0){
- removeGraphCanvasFromIndex(0);
+ if (!removeGraphCanvasFromIndex(0)){
+ return false;
+ }
}
+ return true;
//I dont know why but aparently you have to have atleast one tab present
// newGraphCanvas(true);
}
- private void removeGraphCanvasFromIndex(int index) {
+ private boolean removeGraphCanvasFromIndex(int index) {
+ boolean actionSuccess=true;
if ((graphTabbedPane.getTabCount()>0) && (index<this.graphTabbedPane.getTabCount())){
GraphCanvas graphCanvas = graphCanvases.get(index);
if (graphCanvas.isWorkflowChanged()){
@@ -441,20 +445,23 @@ public class XBayaGUI implements EventLi
graphFiler.saveWorkflow(graphCanvas);
if (graphCanvas.isWorkflowChanged()){
//if cancelled while trying to save
- return;
+ actionSuccess=false;
}
- }else if (result!=JOptionPane.NO_OPTION){
- //if cancel clicked
- return;
+ }else if (result==JOptionPane.CANCEL_OPTION){
+ actionSuccess=false;
}
+
} catch (Exception e) {
e.printStackTrace();
}
}
- graphCanvases.remove(index);
- graphTabbedPane.removeTabAt(index);
- activeTabChanged();
+ if (actionSuccess) {
+ graphCanvases.remove(index);
+ graphTabbedPane.removeTabAt(index);
+ activeTabChanged();
+ }
}
+ return actionSuccess;
}
/**
@@ -711,6 +718,10 @@ public class XBayaGUI implements EventLi
this.frame.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent event) {
+ int result = JOptionPane.showConfirmDialog(frame, "'Are you sure you want to exit?", "Exit XBaya", JOptionPane.YES_NO_OPTION);
+ if (result==JOptionPane.NO_OPTION || (!closeAllGraphCanvas())){
+ return;
+ }
logger.debug(event.toString());
XBayaGUI.this.frame.setVisible(false);
try {
Modified: airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/menues/XBayaMenuItem.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/menues/XBayaMenuItem.java?rev=1400139&r1=1400138&r2=1400139&view=diff
==============================================================================
--- airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/menues/XBayaMenuItem.java (original)
+++ airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/menues/XBayaMenuItem.java Fri Oct 19 15:56:09 2012
@@ -23,8 +23,10 @@ package org.apache.airavata.xbaya.ui.men
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
+import java.awt.event.WindowEvent;
import javax.swing.AbstractAction;
+import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.KeyStroke;
@@ -34,7 +36,6 @@ import javax.swing.event.ChangeListener;
import javax.swing.event.MenuEvent;
import javax.swing.event.MenuListener;
-import org.apache.airavata.workflow.model.exceptions.WorkflowException;
import org.apache.airavata.xbaya.XBayaConfiguration;
import org.apache.airavata.xbaya.XBayaConfiguration.XBayaExecutionMode;
import org.apache.airavata.xbaya.XBayaEngine;
@@ -568,13 +569,8 @@ public class XBayaMenuItem implements XB
menuItem.addActionListener(new AbstractAction() {
private static final long serialVersionUID = 1L;
public void actionPerformed(ActionEvent event) {
- try {
- XBayaMenuItem.this.engine.dispose();
- } catch (WorkflowException e) {
- logger.error(e.getMessage(), e);
- } finally {
- XBayaMenuItem.this.engine.getGUI().getFrame().dispose();
- }
+ JFrame frame = XBayaMenuItem.this.engine.getGUI().getFrame();
+ frame.dispatchEvent(new WindowEvent(frame, WindowEvent.WINDOW_CLOSING));
}
});
return menuItem;