KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > compiere > model > MDesktop


1 /******************************************************************************
2  * The contents of this file are subject to the Compiere License Version 1.1
3  * ("License"); You may not use this file except in compliance with the License
4  * You may obtain a copy of the License at http://www.compiere.org/license.html
5  * Software distributed under the License is distributed on an "AS IS" basis,
6  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
7  * the specific language governing rights and limitations under the License.
8  * The Original Code is Compiere ERP & CRM Business Solution
9  * The Initial Developer of the Original Code is Jorg Janke and ComPiere, Inc.
10  * Portions created by Jorg Janke are Copyright (C) 1999-2001 Jorg Janke, parts
11  * created by ComPiere are Copyright (C) ComPiere, Inc.; All Rights Reserved.
12  * Contributor(s): ______________________________________.
13  *****************************************************************************/

14 package org.compiere.model;
15
16 import java.io.*;
17 import java.sql.*;
18 import java.util.*;
19
20 import org.compiere.util.*;
21
22
23 /**
24  * Desktop Model
25  *
26  * @author Jorg Janke
27  * @version $Id: MDesktop.java,v 1.5 2002/08/23 04:02:29 jjanke Exp $
28  */

29 public class MDesktop
30 {
31     /**
32      * Desktop Model
33      */

34     public MDesktop(Properties ctx)
35     {
36         m_ctx = ctx;
37     } // MDesktop
38

39     /** Properties */
40     private Properties m_ctx;
41
42     /** List of workbenches */
43     private ArrayList m_workbenches = new ArrayList();
44
45     private int AD_Desktop_ID;
46     private String JavaDoc Name;
47     private String JavaDoc Description;
48     private String JavaDoc Help;
49     private int AD_Column_ID;
50     private int AD_Image_ID;
51     private int AD_Color_ID;
52     private int PA_Goal_ID;
53
54     /**
55      * Init Desktop
56      */

57     public boolean initDesktop (int ad_Desktop_ID)
58     {
59         AD_Desktop_ID = ad_Desktop_ID;
60         // Get WB info
61
String JavaDoc sql = null;
62         if (Env.isBaseLanguage(m_ctx, "AD_Desktop"))
63             sql = "SELECT Name,Description,Help," // 1..3
64
+ " AD_Column_ID,AD_Image_ID,AD_Color_ID,PA_Goal_ID " // 4..7
65
+ "FROM AD_Desktop "
66                 + "WHERE AD_Desktop_ID=? AND IsActive='Y'";
67         else
68             sql = "SELECT t.Name,t.Description,t.Help,"
69                 + " w.AD_Column_ID,w.AD_Image_ID,w.AD_Color_ID,w.PA_Goal_ID "
70                 + "FROM AD_Desktop w, AD_Desktop_Trl t "
71                 + "WHERE w.AD_Desktop_ID=? AND w.IsActive='Y'"
72                 + " AND w.AD_Desktop_ID=t.AD_Desktop_ID"
73                 + " AND t.AD_Language='" + Env.getAD_Language(m_ctx) + "'";
74         try
75         {
76             PreparedStatement pstmt = DB.prepareStatement(sql);
77             pstmt.setInt(1, AD_Desktop_ID);
78             ResultSet rs = pstmt.executeQuery();
79             if (rs.next())
80             {
81                 Name = rs.getString(1);
82                 Description = rs.getString(2);
83                 if (Description == null)
84                     Description = "";
85                 Help = rs.getString(3);
86                 if (Help == null)
87                     Help = "";
88                 //
89
AD_Column_ID = rs.getInt(4);
90                 AD_Image_ID = rs.getInt(5);
91                 AD_Color_ID = rs.getInt(6);
92                 PA_Goal_ID = rs.getInt(7);
93             }
94             else
95                 AD_Desktop_ID = 0;
96             rs.close();
97             pstmt.close();
98         }
99         catch (SQLException e)
100         {
101             Log.error("MDesktop.initDesktop", e);
102         }
103
104         if (AD_Desktop_ID == 0)
105             return false;
106         return initDesktopWorkbenches();
107     } // initDesktop
108

109     /**
110      * String Representation
111      */

112     public String JavaDoc toString()
113     {
114         return "MDesktop ID=" + AD_Desktop_ID + " " + Name;
115     }
116
117     /*************************************************************************/
118
119     public int getAD_Desktop_ID()
120     {
121         return AD_Desktop_ID;
122     }
123     public String JavaDoc getName()
124     {
125         return Name;
126     }
127     public String JavaDoc getDescription()
128     {
129         return Description;
130     }
131     public String JavaDoc getHelp()
132     {
133         return Help;
134     }
135     public int getAD_Column_ID()
136     {
137         return AD_Column_ID;
138     }
139     public int getAD_Image_ID()
140     {
141         return AD_Image_ID;
142     }
143     public int getAD_Color_ID()
144     {
145         return AD_Color_ID;
146     }
147     public int getPA_Goal_ID()
148     {
149         return PA_Goal_ID;
150     }
151
152     /*************************************************************************/
153
154     /**
155      * Init Workbench Windows
156      */

157     private boolean initDesktopWorkbenches()
158     {
159         String JavaDoc sql = "SELECT AD_Workbench_ID "
160             + "FROM AD_DesktopWorkbench "
161             + "WHERE AD_Desktop_ID=? AND IsActive='Y' "
162             + "ORDER BY SeqNo";
163         try
164         {
165             PreparedStatement pstmt = DB.prepareStatement(sql);
166             pstmt.setInt(1, AD_Desktop_ID);
167             ResultSet rs = pstmt.executeQuery();
168             while (rs.next())
169             {
170                 int AD_Workbench_ID = rs.getInt(1);
171                 m_workbenches.add (new Integer JavaDoc(AD_Workbench_ID));
172             }
173             rs.close();
174             pstmt.close();
175         }
176         catch (SQLException e)
177         {
178             Log.error("MWorkbench.initDesktopWorkbenches", e);
179             return false;
180         }
181         return true;
182     } // initDesktopWorkbenches
183

184     /**
185      * Get Window Count
186      */

187     public int getWindowCount()
188     {
189         return m_workbenches.size();
190     } // getWindowCount
191

192     /**
193      * Get AD_Workbench_ID of index
194      * @return -1 if not valid
195      */

196     public int getAD_Workbench_ID (int index)
197     {
198         if (index < 0 || index > m_workbenches.size())
199             return -1;
200         Integer JavaDoc id = (Integer JavaDoc)m_workbenches.get(index);
201         return id.intValue();
202     } // getAD_Workbench_ID
203

204 } // MDesktop
205
Popular Tags