View Javadoc

1   package com.explosion.expfmodules.rdbmsconn.connectwizard.actions;
2   
3   /* =============================================================================
4    *       
5    *     Copyright 2004 Stephen Cowx
6    *
7    *     Licensed under the Apache License, Version 2.0 (the "License");
8    *     you may not use this file except in compliance with the License.
9    *     You may obtain a copy of the License at
10   *
11   *     http://www.apache.org/licenses/LICENSE-2.0
12   *
13   *     Unless required by applicable law or agreed to in writing, software
14   *     distributed under the License is distributed on an "AS IS" BASIS,
15   *     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   *     See the License for the specific language governing permissions and
17   *     limitations under the License.
18   * 
19   * =============================================================================
20   */
21  
22  /***
23   * @author Stephen Cowx
24   * Created on 21-Feb-2005
25   */
26  import com.explosion.expfmodules.rdbmsconn.RdbmsConnModuleManager;
27  import com.explosion.expfmodules.wizard.StepAction;
28  import com.explosion.expfmodules.wizard.Wizard;
29  import com.explosion.expfmodules.wizard.standard.PreferenceDataItem;
30  import com.explosion.utilities.exception.ExceptionManagerFactory;
31  import com.explosion.utilities.preferences.Preference;
32  import com.explosion.utilities.preferences.groups.PreferenceGroup;
33  
34  public class SaveDriverAction implements StepAction {
35  
36  	/***
37  	 * Creates a MySQL database connection based on the information 
38  	 * collected in the wizard.
39  	 */
40  	public boolean execute(Wizard wizard) {
41  		
42  		try {
43  		    
44  		    /* Get the values for the connection from the wizard values */
45  		    String driverName = (String) ((PreferenceDataItem) wizard.getWizardDataValues().get("drivername")).getPreference().getValue();
46  		    PreferenceGroup descriptor = (PreferenceGroup) wizard.getWizardDataValues().get("driver_descriptor");
47  		    descriptor.setIdentifier(driverName);
48  		    RdbmsConnModuleManager.instance().getDriverDescriptorManager().addGroup(driverName, descriptor);
49  		    descriptor.commit();
50  		    
51  		    PreferenceDataItem item = (PreferenceDataItem) wizard.getWizardDataValues().get("driver");
52  			if (item != null)
53  			{
54  		      Preference pref = item.getPreference();
55  		      pref.setValue(driverName);
56  			}
57  		    
58  		    return true;
59  			
60  		} catch (Exception e) {
61  			ExceptionManagerFactory.getExceptionManager().manageException(e, "Error:");
62  		}
63  		
64  		return false;
65  		
66  	}
67  }