KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > Raptor > transactions > load_saveProject2File_tr


1 /*******************************************************************************
2  * Copyright (c) 2004, Dirk von der Weiden.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution.
6  *
7  * Contributors:
8  * Dirk von der Weiden - initial API and implementation
9  *
10  * Created on 04.04.2004
11  *
12  * date: 04.04.2004
13  * project: WiSer Builder
14  *
15  *******************************************************************************/

16
17 package Raptor.transactions;
18
19 import Jmc.seviceLayer.base_transaction;
20 import Jmc.baseTools.*;
21 import Jmc.commonGui.*;
22 import Jmc.baseGui.*;
23 import Jmc.persist.*;
24 import Jmc.model.*;
25
26 import Raptor.model.*;
27
28 /**
29  * @author Dirk
30  *
31  * date: 05.08.2003
32  * project: WiSer-Builder
33  *
34  * <p>
35  * ...
36  * </p>
37  */

38 public class load_saveProject2File_tr extends base_transaction
39 {
40   public load_saveProject2File_tr()
41   {
42     super();
43     
44     this.pcmf_setWorkFct(new work ());
45   }
46   
47   class work implements base_executableObject_if
48   {
49     public Object JavaDoc pcmf_execObj(Object JavaDoc xObj)
50     {
51       base_guiObj l_obj = (base_guiObj)xObj;
52       base_appl_if l_appl = l_obj.pcmf_getAppl();
53       raptor_mainModel l_model= (raptor_mainModel)l_appl.pcmf_getGuiObj().pcmf_getModel();
54       base_fileChooser_if l_fs = l_model.getPem_fc();
55       base_multipleModelValue_if l_sel = l_model.getPem_treeSelection();
56       base_guiObj l_tree = l_model.getPem_appTree();
57       
58       if (((base_fileChooser_if)xObj).pcmf_getMode() == 'w')
59       {
60         base_dataXmlWriter l_w = new base_dataXmlWriter (l_fs.pcmf_getGuiObj().pcmf_getValue().toString());
61         l_w.pcmf_writeModel(l_sel.pcmf_getMyTemplate(), l_sel);
62       }
63       if (((base_fileChooser_if)xObj).pcmf_getMode() == 'r')
64       {
65         try
66         {
67           l_appl.pcmf_beginSessionTR();
68                                 
69           base_tpl2dataXmlReader l_r = new base_tpl2dataXmlReader (l_fs.pcmf_getGuiObj().pcmf_getValue().toString(), false);
70           l_r.pcmf_read(l_appl.pcmf_getGuiObj().pcmf_getModelTpl(), l_sel);
71
72           ((base_treeNode)l_sel).pcmf_HideAll();
73           ((base_treeNode)l_sel).pcmf_unhide();
74           
75           l_tree.pcmf_setValue(l_sel);
76           l_model.pcmf_refreshSourceView();
77           l_model.pcmf_saveTransaction();
78         }
79         catch (Exception JavaDoc e)
80         {
81           l_model.pcmf_addMessage("- error reading project file, view log-file for details", raptor_mainModel.RAPTOR_ERROR);
82           base_log.pcmf_logException(l_appl.pcmf_getGuiObj().toString(), this, e);
83         }
84         finally
85         {
86           l_appl.pcmf_commitSessionTR();
87         }
88       }
89
90       l_model.setPem_ProjectName(l_fs.pcmf_getGuiObj().pcmf_getValue().toString());
91       
92       l_tree.pcmf_repaint();
93       l_appl.pcmf_setActive(null);
94       
95       return (null);
96     };
97   };
98 }
Popular Tags