KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > it > businesslogic > ireport > plugin > locale > JasperBabylonRunner


1 /*
2  * Copyright (C) 2005 - 2006 JasperSoft Corporation. All rights reserved.
3  * http://www.jaspersoft.com.
4  *
5  * Unless you have purchased a commercial license agreement from JasperSoft,
6  * the following license terms apply:
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License version 2 as published by
10  * the Free Software Foundation.
11  *
12  * This program is distributed WITHOUT ANY WARRANTY; and without the
13  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14  * See the GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, see http://www.gnu.org/licenses/gpl.txt
18  * or write to:
19  *
20  * Free Software Foundation, Inc.,
21  * 59 Temple Place - Suite 330,
22  * Boston, MA USA 02111-1307
23  *
24  *
25  *
26  *
27  * JasperBabylonRunner.java
28  *
29  * Created on 22 maggio 2005, 2.00
30  *
31  */

32
33 package it.businesslogic.ireport.plugin.locale;
34
35 import com.jaspersoft.babylon.JasperBabylonClient;
36 import it.businesslogic.ireport.gui.MainFrame;
37
38 /**
39  *
40  * @author Administrator
41  */

42 public class JasperBabylonRunner implements Runnable JavaDoc {
43     
44     public static String JavaDoc IREPORT_APP_ID="1";
45     private JasperBabylonRunnerListener runnerListener;
46     private int operation = 0;
47     private JasperBabylonClient jbc = new JasperBabylonClient();
48     
49     public static final int OP_LIST_LOCALES = 1;
50     public static final int OP_GET_LOCALE = 2;
51     public static final int OP_PUT_LOCALE = 3;
52     
53     private String JavaDoc localeId = null;
54     private java.util.Properties JavaDoc props = null;
55     
56     public void listLocales()
57     {
58         operation = OP_LIST_LOCALES;
59         jbc.setAppId( IREPORT_APP_ID );
60         jbc.setJasperBabylonUrl( MainFrame.getMainInstance().getProperties().getProperty("jasperBabylonURL","http://www.jasperforge.org/jasperbabylon"));
61         Thread JavaDoc t = new Thread JavaDoc(this);
62         t.start();
63     }
64     
65     public void getLocale(String JavaDoc localeId)
66     {
67         operation = OP_GET_LOCALE;
68         jbc.setAppId( IREPORT_APP_ID );
69         jbc.setJasperBabylonUrl( MainFrame.getMainInstance().getProperties().getProperty("jasperBabylonURL","http://www.jasperforge.org/jasperbabylon"));
70         this.localeId = localeId;
71         Thread JavaDoc t = new Thread JavaDoc(this);
72         t.start();
73     }
74     
75     
76     public void putLocale(String JavaDoc localeId, java.util.Properties JavaDoc props)
77     {
78         operation = OP_PUT_LOCALE;
79         jbc.setAppId( IREPORT_APP_ID );
80         jbc.setJasperBabylonUrl( MainFrame.getMainInstance().getProperties().getProperty("jasperBabylonURL","http://www.jasperforge.org/jasperbabylon"));
81         jbc.setUsername(MainFrame.getMainInstance().getProperties().getProperty("jasperBabylonUsername") );
82         jbc.setPassword(MainFrame.getMainInstance().getProperties().getProperty("jasperBabylonPassword") );
83         this.props = props;
84         this.localeId = localeId;
85         Thread JavaDoc t = new Thread JavaDoc(this);
86         t.start();
87         
88     }
89     
90     public void run() {
91         try {
92             switch (operation)
93             {
94                 case OP_LIST_LOCALES:
95                     java.util.List JavaDoc list = jbc.listLocales();
96                     this.getRunnerListener().listLocalesComplete(list);
97                     break;
98                 
99                 case OP_GET_LOCALE:
100                     java.util.Properties JavaDoc p = jbc.getLocale( this.localeId );
101                     this.getRunnerListener().getLocaleComplete(p);
102                     break;
103                 
104                 case OP_PUT_LOCALE:
105                     String JavaDoc s = jbc.putLocale(this.localeId, props);
106                     this.getRunnerListener().putLocaleComplete(s);
107                     break;
108             }
109             
110             
111         } catch (Exception JavaDoc ex)
112         {
113             this.getRunnerListener().operationError(operation, ex.getMessage());
114         }
115     }
116
117     public JasperBabylonRunnerListener getRunnerListener() {
118         return runnerListener;
119     }
120
121     public void setRunnerListener(JasperBabylonRunnerListener runnerListener) {
122         this.runnerListener = runnerListener;
123     }
124 }
125
126
Popular Tags