KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > Raptor > transactions > positioner_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.model.*;
24 import Jmc.webGui.*;
25
26 import Raptor.model.*;
27
28 import java.util.*;
29
30 /**
31  * @author Dirk
32  *
33  * date: 14.01.2004
34  * project: WiSer-Builder
35  *
36  * <p>
37  * ...
38  * </p>
39  */

40 public class positioner_tr extends base_transaction
41 {
42   protected raptor_mainModel pem_model = null;
43   protected base_guiListener pem_li = new setPos_li();
44   
45     /**
46      * @param xName
47      */

48     public positioner_tr()
49     {
50     super();
51     
52     this.pcmf_setWorkFct(new work ());
53   }
54  
55   class setPos_li implements base_guiListener
56   {
57         public void pcmf_execListener(base_guiObj xParam) throws Exception JavaDoc
58         {
59       base_appl_if l_appl = xParam.pcmf_getAppl();
60       raptor_mainModel l_model= (raptor_mainModel)l_appl.pcmf_getGuiObj().pcmf_getModel();
61       base_guiObj l_tree = l_model.getPem_appTree();
62       try
63       {
64         String JavaDoc l_name = xParam.pcmf_getName();
65         if (xParam.pcmf_getValue().toString().equals("CHECKED"))
66         {
67           StringTokenizer l_tok = new StringTokenizer(l_name, ",");
68           
69           base_modelValue_if l_sel = positioner_tr.this.pem_model.getPem_treeSelection();
70           if (l_sel instanceof base_multipleModelValue_if)
71           {
72             base_multipleModelValue_if l_pos = (base_multipleModelValue_if)((base_multipleModelValue_if)l_sel).pcmf_getModelValue("position");
73             base_singleModelValue l_x = (base_singleModelValue)l_pos.pcmf_getModelValue("x");
74             base_singleModelValue l_y = (base_singleModelValue)l_pos.pcmf_getModelValue("y");
75             base_singleModelValue l_h = (base_singleModelValue)l_pos.pcmf_getModelValue("height");
76             base_singleModelValue l_w = (base_singleModelValue)l_pos.pcmf_getModelValue("width");
77             
78             l_x.pcmf_setValueValidate(l_tok.nextToken());
79             l_y.pcmf_setValueValidate(l_tok.nextToken());
80             l_w.pcmf_setValueValidate(xParam.pcmf_getParentNode().pcmf_getSubNode(l_name + "_w").pcmf_getValue());
81             l_h.pcmf_setValueValidate(xParam.pcmf_getParentNode().pcmf_getSubNode(l_name + "_h").pcmf_getValue());
82             
83             l_sel.pcmf_model2UI();
84             positioner_tr.this.pem_model.pcmf_createAutoWdgPreview();
85             l_tree.pcmf_setValue(l_sel);
86           }
87         };
88       }
89       catch (Exception JavaDoc e)
90       {
91         positioner_tr.this.pem_model.pcmf_addMessage("- cannot reposition this object, attributes not found", raptor_mainModel.RAPTOR_ERROR);
92       };
93         }
94   }
95    
96   class work implements base_executableObject_if
97   {
98     public Object JavaDoc pcmf_execObj(Object JavaDoc xObj)
99     {
100       base_guiObj l_obj = (base_guiObj)xObj;
101       base_appl_if l_appl = l_obj.pcmf_getAppl();
102       
103       pem_model = (raptor_mainModel)l_appl.pcmf_getGuiObj().pcmf_getModel();
104       
105       base_guiObj l_dlg = (base_guiObj)base_registredObject.pcmf_getObjByName("PosHelp_Input");
106       base_guiObj l_x = (base_guiObj) l_dlg.pcmf_getSubNode("X");
107       base_guiObj l_y = (base_guiObj) l_dlg.pcmf_getSubNode("Y");
108       base_guiObj l_form = (base_guiObj) l_dlg.pcmf_getSubNode("Positioners");
109  
110       try
111       {
112         l_form.pcmf_clearAndRelease();
113         if (l_appl.pcmf_getApplType() == gui_objFactory.HTML)
114           ((html_container)l_form).pcmf_setLayoutManager(new html_gridBagLayout());
115           
116         int l_xMax = Integer.parseInt(l_x.pcmf_getValue().toString()) * 3;
117         int l_yMax = Integer.parseInt(l_y.pcmf_getValue().toString());
118         base_guiObj l_newBox = null;
119         base_guiObj l_newBox_w = null;
120         base_guiObj l_newBox_h = null;
121         String JavaDoc l_name = null;
122         for (int y = 0; y < l_yMax; y++)
123         {
124           for (int x = 0; x < l_xMax; x+=3)
125           {
126             l_name = Integer.toString(x/3) + "," + Integer.toString(y);
127             l_newBox = (base_guiObj)l_appl.pcmf_getGuiObjFactory().pcmf_createCheckBox(l_appl.pcmf_getApplType(), l_name, "", l_appl);
128             l_newBox_w = (base_guiObj)l_appl.pcmf_getGuiObjFactory().pcmf_createInputField(l_appl.pcmf_getApplType(), l_name + "_w", 1, 1, "1", false, l_appl);
129             l_newBox_h = (base_guiObj)l_appl.pcmf_getGuiObjFactory().pcmf_createInputField(l_appl.pcmf_getApplType(), l_name + "_h", 1, 1, "1", false, l_appl);
130             l_newBox.pcmf_setValue("NOTCHECKED");
131             l_newBox.pcmf_enableSubmit();
132             l_newBox.pcmf_addListener(pem_li);
133             l_form.pcmf_addNode(l_name, l_newBox);
134             l_form.pcmf_addNode(l_name + "_w", l_newBox_w);
135             l_form.pcmf_addNode(l_name + "_h", l_newBox_h);
136             ((base_guiContainer_if)l_form).pcmf_setGuiObjPosition(l_name, x, y, 1, 1, "CENTER");
137             ((base_guiContainer_if)l_form).pcmf_setGuiObjPosition(l_name + "_w", x+1, y, 1, 1, "CENTER");
138             ((base_guiContainer_if)l_form).pcmf_setGuiObjPosition(l_name + "_h", x+2, y, 1, 1, "CENTER");
139           }
140         }
141         l_dlg.pcmf_repaint();
142         l_appl.pcmf_setActive(null);
143       }
144       catch (Exception JavaDoc e)
145       {
146         pem_model.pcmf_addMessage("- error during repositioning", raptor_mainModel.RAPTOR_ERROR);
147         base_log.pcmf_logException(l_appl.pcmf_getGuiObj().pcmf_getName(), this, e);
148       };
149       return (null);
150     };
151   };
152 }
Popular Tags