Source Code Cross Referenced for Journal.java in  » ERP-CRM-Financial » ofbiz » org » ofbiz » pos » component » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » ERP CRM Financial » ofbiz » org.ofbiz.pos.component 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*******************************************************************************
002:         * Licensed to the Apache Software Foundation (ASF) under one
003:         * or more contributor license agreements.  See the NOTICE file
004:         * distributed with this work for additional information
005:         * regarding copyright ownership.  The ASF licenses this file
006:         * to you under the Apache License, Version 2.0 (the
007:         * "License"); you may not use this file except in compliance
008:         * with the License.  You may obtain a copy of the License at
009:         * 
010:         * http://www.apache.org/licenses/LICENSE-2.0
011:         * 
012:         * Unless required by applicable law or agreed to in writing,
013:         * software distributed under the License is distributed on an
014:         * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015:         * KIND, either express or implied.  See the License for the
016:         * specific language governing permissions and limitations
017:         * under the License.
018:         *******************************************************************************/package org.ofbiz.pos.component;
019:
020:        import java.util.Locale;
021:
022:        import net.xoetrope.swing.XTable;
023:        import net.xoetrope.swing.XScrollPane;
024:        import net.xoetrope.xui.data.XModel;
025:
026:        import org.ofbiz.pos.PosTransaction;
027:        import org.ofbiz.pos.screen.PosScreen;
028:        import org.ofbiz.base.util.UtilProperties;
029:
030:        public class Journal {
031:
032:            public static final String module = Journal.class.getName();
033:
034:            private static String[] field = { "sku", "desc", "qty", "price",
035:                    "index" };
036:            private static String[] name = { "SKU", "ITEM", "QTY", "AMT", "" };
037:            private static int[] width = { 100, 170, 60, 80, 0 };
038:            private Locale defaultLocale = Locale.getDefault();
039:
040:            protected XScrollPane jpanel = null;
041:            protected XTable jtable = null;
042:            protected String style = null;
043:
044:            public Journal(PosScreen page) {
045:                //The vertical bar is always visible to allow access to horizontal bar without shrink the journal panel
046:                this .jpanel = (XScrollPane) page.findComponent("journal_panel");
047:                this .jpanel.setVisible(false);
048:
049:                this .jtable = (XTable) page.findComponent("jtable");
050:
051:                // set the table as selectable        
052:                jtable.setInteractiveTable(true);
053:                jtable.setFocusable(false);
054:
055:                // set the styles
056:                jtable.setBorderStyle("journalBorder");
057:                jtable.setHeaderStyle("journalHeader");
058:                jtable.setStyle("journalData");
059:                jtable.setSelectedStyle("journalSelected");
060:
061:                // initialize the journal table header
062:                XModel jmodel = createModel();
063:                if (jmodel != null) {
064:                    this .appendEmpty(jmodel);
065:                    jtable.setModel(jmodel);
066:
067:                    for (int i = 0; i < width.length; i++) {
068:                        jtable.setColWidth(i, width[i]);
069:                    }
070:                }
071:                jtable.setSelectedRow(0);
072:            }
073:
074:            public String getSelectedSku() {
075:                XModel jmodel = (XModel) XModel.getInstance().get(
076:                        "journal/items");
077:                XModel model = jmodel.get(jtable.getSelectedRow() + 1);
078:                return model.getValueAsString("sku");
079:            }
080:
081:            public String getSelectedIdx() {
082:                XModel jmodel = (XModel) XModel.getInstance().get(
083:                        "journal/items");
084:                XModel model = jmodel.get(jtable.getSelectedRow() + 1);
085:                return model.getValueAsString("index");
086:            }
087:
088:            public void selectNext() {
089:                jtable.next();
090:            }
091:
092:            public void selectPrevious() {
093:                jtable.prev();
094:            }
095:
096:            public void focus() {
097:                if (jtable.isEnabled()) {
098:                    jtable.requestFocus();
099:                }
100:            }
101:
102:            public void setLock(boolean lock) {
103:                jtable.setInteractiveTable(!lock);
104:                jtable.setFocusable(!lock);
105:                jtable.setVisible(!lock);
106:                jtable.setEnabled(!lock);
107:                if (!lock) {
108:                    this .jpanel.setVisible(true);
109:                }
110:            }
111:
112:            public void refresh(PosScreen pos) {
113:                if (!jtable.isEnabled()) {
114:                    // no point in refreshing when we are locked;
115:                    // we will auto-refresh when unlocked
116:                    return;
117:                }
118:
119:                PosTransaction tx = PosTransaction.getCurrentTx(pos
120:                        .getSession());
121:                XModel jmodel = this .createModel();
122:                if (tx != null && !tx.isEmpty()) {
123:                    tx.appendItemDataModel(jmodel);
124:                    this .appendEmpty(jmodel);
125:                    tx.appendTotalDataModel(jmodel);
126:                    if (tx.selectedPayments() > 0) {
127:                        this .appendEmpty(jmodel);
128:                        tx.appendPaymentDataModel(jmodel);
129:                    }
130:                    if (pos.getInput().isFunctionSet("PAID")) {
131:                        tx.appendChangeDataModel(jmodel);
132:                    }
133:                } else {
134:                    this .appendEmpty(jmodel);
135:                }
136:
137:                // make sure we are at the last item in the journal
138:                jtable.setSelectedRow(0);
139:
140:                try {
141:                    jtable.repaint();
142:                } catch (ArrayIndexOutOfBoundsException e) {
143:                    // bug in XUI causes this; ignore for now
144:                    // it has been reported and will be fixed soon
145:                }
146:            }
147:
148:            private XModel createModel() {
149:                XModel jmodel = (XModel) XModel.getInstance().get(
150:                        "journal/items");
151:
152:                // clear the list
153:                jmodel.clear();
154:
155:                if (field.length == 0) {
156:                    return null;
157:                }
158:
159:                // create the header
160:                XModel headerNode = appendNode(jmodel, "th", "", "");
161:                for (int i = 0; i < field.length; i++) {
162:                    appendNode(headerNode, "td", field[i], UtilProperties
163:                            .getMessage("pos", name[i], defaultLocale));
164:                }
165:
166:                return jmodel;
167:            }
168:
169:            private void appendEmpty(XModel jmodel) {
170:                XModel headerNode = appendNode(jmodel, "tr", "", "");
171:                for (int i = 0; i < field.length; i++) {
172:                    appendNode(headerNode, "td", field[i], "");
173:                }
174:            }
175:
176:            public static XModel appendNode(XModel node, String tag,
177:                    String name, String value) {
178:                XModel newNode = (XModel) node.append(name);
179:                newNode.setTagName(tag);
180:                if (value != null) {
181:                    newNode.set(value);
182:                }
183:                return newNode;
184:            }
185:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.