Index: src/panels/com/jboss/jbds/installer/RunAfterAction.java
===================================================================
--- src/panels/com/jboss/jbds/installer/RunAfterAction.java	(revision 0)
+++ src/panels/com/jboss/jbds/installer/RunAfterAction.java	(revision 0)
@@ -0,0 +1,30 @@
+package com.jboss.jbds.installer;
+
+import com.izforge.izpack.installer.InstallData;
+import com.izforge.izpack.panels.SimpleFinishPanel;
+
+/*
+ * JBDS-2038
+ */
+public class RunAfterAction implements com.izforge.izpack.util.CleanupClient {
+
+	private boolean runAfter = true;
+	private SimpleFinishPanel panel;
+	private InstallData installData;
+
+	public RunAfterAction(SimpleFinishPanel simpleFinishPanel, InstallData installData) {
+		this.panel = simpleFinishPanel;
+		this.installData = installData;
+	}
+
+	@Override
+    public void cleanUp() {
+    	if (this.runAfter && this.installData.installSuccess) {
+    		this.panel.runAfter();
+    	}
+    }
+
+    public void setRunAfter(boolean runAfter) {
+    	this.runAfter = runAfter;
+    }
+}
\ No newline at end of file

Property changes on: src/panels/com/jboss/jbds/installer/RunAfterAction.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: src/panels/com/izforge/izpack/panels/SimpleFinishPanel.java
===================================================================
--- src/panels/com/izforge/izpack/panels/SimpleFinishPanel.java	(revision 11632)
+++ src/panels/com/izforge/izpack/panels/SimpleFinishPanel.java	(working copy)
@@ -1,15 +1,15 @@
 /*
  * IzPack - Copyright 2001-2008 Julien Ponge, All Rights Reserved.
- * 
+ *
  * http://izpack.org/
  * http://izpack.codehaus.org/
- * 
+ *
  * Licensed 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.
@@ -21,31 +21,28 @@
 
 import java.awt.GridBagConstraints;
 import java.awt.GridBagLayout;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.WindowEvent;
-import java.awt.event.WindowListener;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
 import java.io.File;
 import java.io.IOException;
-import java.io.InputStream;
 
 import javax.swing.JCheckBox;
-import javax.swing.JFrame;
 import javax.swing.JLabel;
 
-import com.izforge.izpack.gui.IzPanelLayout;
 import com.izforge.izpack.gui.LabelFactory;
 import com.izforge.izpack.installer.InstallData;
 import com.izforge.izpack.installer.InstallerFrame;
 import com.izforge.izpack.installer.IzPanel;
+import com.izforge.izpack.util.Housekeeper;
 import com.izforge.izpack.util.Log;
-import com.izforge.izpack.util.VariableSubstitutor;
 import com.izforge.izpack.util.OsVersion;
+import com.izforge.izpack.util.VariableSubstitutor;
+import com.jboss.jbds.installer.RunAfterAction;
 
 
 /**
  * The simple finish panel class.
- * 
+ *
  * @author Julien Ponge
  */
 public class SimpleFinishPanel extends IzPanel {
@@ -59,11 +56,11 @@
 	 */
 	private VariableSubstitutor vs;
 
-	private JCheckBox runAfter;
+	private RunAfterAction runAfterAction;
 
 	/**
 	 * The constructor.
-	 * 
+	 *
 	 * @param parent
 	 *            The parent.
 	 * @param idata
@@ -71,47 +68,24 @@
 	 */
 	public SimpleFinishPanel(InstallerFrame parent, InstallData idata) {
 		super(parent, idata, new GridBagLayout());
-		vs = new VariableSubstitutor(idata.getVariables());
-		parent.addRunAfterAction(new RunAfterAction());
+		this.vs = new VariableSubstitutor(idata.getVariables());
+		this.runAfterAction = new RunAfterAction(this, idata);
 	}
 
 	/**
 	 * Indicates wether the panel has been validated or not.
-	 * 
+	 *
 	 * @return true if the panel has been validated.
 	 */
 	public boolean isValidated() {
 		return true;
 	}
-	
-	private void runAfter(){
-		if(runAfter.isSelected()){
-			try{
-				String path = translatePath("$INSTALL_PATH");
-				String[] command = null;
-				if(OsVersion.IS_MAC){
-					command = new String[3];
-					command[0] = "open";
-					command[1] = "-a";
-					command[2] = path+File.separator+"JBoss Developer Studio.app";
-				}else{
-					command = new String[]{path+File.separator+"jbdevstudio"};
-					if(OsVersion.IS_WINDOWS){
-						command[0] += ".bat";
-					}
-				}
-				Process process = Runtime.getRuntime().exec(command, null, new File(path));
-			}catch(IOException ex){
-				System.out.println("could not execute the command!");
-				emitError("Exception", ex.getMessage());
-	            ex.printStackTrace();
-			}
-		}
-	}
+
 	/**
 	 * Called when the panel becomes active.
 	 */
 	public void panelActivate() {
+		Housekeeper.getInstance().registerForCleanup(this.runAfterAction);
 		parent.lockNextButton();
 		parent.lockPrevButton();
 		parent.setQuitButtonText(parent.langpack.getString("FinishPanel.done"));
@@ -131,9 +105,15 @@
 			constraints.gridx = 0;
 			constraints.gridy = 0;
 			add(successLabel, constraints);
-			
-			runAfter = new JCheckBox(parent.langpack.getString("SimpleFinishPanel.headline.run_after"), true);
-			
+
+			final JCheckBox runAfterCheckbox = new JCheckBox(parent.langpack.getString("SimpleFinishPanel.headline.run_after"), true);
+			runAfterCheckbox.addItemListener(new ItemListener() {
+				@Override
+				public void itemStateChanged(ItemEvent e) {
+					SimpleFinishPanel.this.runAfterAction.setRunAfter(runAfterCheckbox.isSelected());
+				}
+			});
+
 	        constraints.gridx = 0;
 	        constraints.gridy = 1;
 	        constraints.gridwidth = 1;
@@ -142,8 +122,8 @@
 	        constraints.fill = GridBagConstraints.HORIZONTAL;
 	        constraints.anchor = GridBagConstraints.NORTHWEST;
 
-	        add(runAfter, constraints);
-	        
+	        add(runAfterCheckbox, constraints);
+
 			if (idata.uninstallOutJar != null) {
 				// We prepare a message for the uninstaller feature
 				String path = translatePath("$INSTALL_PATH") + File.separator
@@ -176,7 +156,7 @@
 
 	/**
 	 * Translates a relative path to a local system path.
-	 * 
+	 *
 	 * @param destination
 	 *            The path to translate.
 	 * @return The translated path.
@@ -188,16 +168,27 @@
 		// Convert the file separator characters
 		return destination.replace('/', File.separatorChar);
 	}
-	
-	class RunAfterAction implements ActionListener {
 
-        /**
-         * Actions handler.
-         *
-         * @param e The event.
-         */
-        public void actionPerformed(ActionEvent e) {
-			runAfter();
-        }
-    }
+	public void runAfter() {
+		try{
+			String path = translatePath("$INSTALL_PATH");
+			String[] command = null;
+			if(OsVersion.IS_MAC){
+				command = new String[3];
+				command[0] = "open";
+				command[1] = "-a";
+				command[2] = path+File.separator+"JBoss Developer Studio.app";
+			}else{
+				command = new String[]{path+File.separator+"jbdevstudio"};
+				if(OsVersion.IS_WINDOWS){
+					command[0] += ".bat";
+				}
+			}
+			Process process = Runtime.getRuntime().exec(command, null, new File(path));
+		}catch(IOException ex){
+			System.out.println("could not execute the command!");
+			emitError("Exception", ex.getMessage());
+            ex.printStackTrace();
+		}
+	}
 }
Index: src/panels/com/izforge/izpack/installer/InstallerFrame.java
===================================================================
--- src/panels/com/izforge/izpack/installer/InstallerFrame.java	(revision 11659)
+++ src/panels/com/izforge/izpack/installer/InstallerFrame.java	(working copy)
@@ -1,18 +1,18 @@
 /*
  * $Id: InstallerFrame.java 2692 2009-03-25 09:29:40Z fbuehlmann $
  * IzPack - Copyright 2001-2008 Julien Ponge, All Rights Reserved.
- * 
+ *
  * http://izpack.org/
  * http://izpack.codehaus.org/
- * 
+ *
  * Copyright 2002 Jan Blok
- * 
+ *
  * Licensed 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.
@@ -135,7 +135,7 @@
      * Registered GUICreationListener.
      */
     protected ArrayList<GUIListener> guiListener;
-       
+
     /**
      * Heading major text.
      */
@@ -211,13 +211,13 @@
         // Builds the GUI
         loadIcons();
         loadCustomIcons();
-        loadPanels();               
+        loadPanels();
         buildGUI();
 
         // We show the frame
         showFrame();
         switchPanel(0);
-    }   
+    }
 
     public Debugger getDebugger() {
         return this.debugger;
@@ -283,7 +283,7 @@
             }
 
             panel.setHelps(p.getHelpsMap());
-            
+
             List<String> preActivateActions = p.getPreActivationActions();
             if (preActivateActions != null)
             {
@@ -510,9 +510,9 @@
         debugger = new Debugger(installdata, icons, rules);
         // this needed to fully initialize the debugger.
         JPanel debugpanel = debugger.getDebugPanel();
-        
+
         // create a debug panel if TRACE is enabled
-        if (Debug.isTRACE()) {                       
+        if (Debug.isTRACE()) {
             if (installdata.guiPrefs.modifier.containsKey("showDebugWindow")
                     && Boolean.valueOf(installdata.guiPrefs.modifier.get("showDebugWindow"))) {
                 JFrame debugframe = new JFrame("Debug information");
@@ -731,7 +731,7 @@
             IzPanel panel = installdata.panels.get(installdata.curPanelNumber);
             IzPanel l_panel = installdata.panels.get(last);
             showHelpButton(panel.canShowHelp());
-            if (Debug.isTRACE()) {                
+            if (Debug.isTRACE()) {
                 debugger.switchPanel(panel.getMetadata(), l_panel.getMetadata());
             }
             Log.getInstance().addDebugMessage(
@@ -1149,12 +1149,6 @@
         gbc.weightx = wx;
         gbc.weighty = wy;
     }
-    
-    private ActionListener runAfter = null;
-    
-    public void addRunAfterAction(ActionListener listener){
-    	runAfter = listener;
-    }
 
     /**
      * Makes a clean closing.
@@ -1162,9 +1156,6 @@
     public void exit() {
         if (installdata.canClose
                 || (!nextButton.isVisible() && !prevButton.isVisible())) {
-        	if(runAfter != null){
-        		runAfter.actionPerformed(null);
-        	}
             // this does nothing if the uninstaller was not included
             writeUninstallData();
             Housekeeper.getInstance().shutDown(0);
@@ -1441,7 +1432,7 @@
             panel.executePreValidationActions();
             boolean isValid = doValidation ? panel.panelValidated() : true;
             panel.executePostValidationActions();
-            
+
             // check if we can display the next panel or if there was an error during actions that
             // disables the next button
             if (!nextButton.isEnabled()) { return; }
