Source Code Cross Referenced for InternationalizationEditor.java in  » XML-UI » xmlgui » org » beryl » gui » builder » 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 » XML UI » xmlgui » org.beryl.gui.builder 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Beryl - A web platform based on XML, XSLT and Java
003:         * This file is part of the Beryl XML GUI
004:         *
005:         * Copyright (C) 2004 Wenzel Jakob <wazlaf@tigris.org>
006:         *
007:         * This program is free software; you can redistribute it and/or
008:         * modify it under the terms of the GNU Lesser General Public
009:         * License as published by the Free Software Foundation; either
010:         * version 2.1 of the License, or (at your option) any later version.
011:
012:         * This program is distributed in the hope that it will be useful,
013:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
014:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
015:         * Lesser General Public License for more details.
016:         *
017:         * You should have received a copy of the GNU Lesser General Public
018:         * License along with this program; if not, write to the Free Software
019:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-3107  USA
020:         */
021:
022:        package org.beryl.gui.builder;
023:
024:        import java.io.File;
025:        import java.io.FileInputStream;
026:        import java.io.FileOutputStream;
027:        import java.util.Iterator;
028:        import java.util.Properties;
029:
030:        import org.beryl.gui.Controller;
031:        import org.beryl.gui.DialogUtils;
032:        import org.beryl.gui.GUIEvent;
033:        import org.beryl.gui.GUIEventListener;
034:        import org.beryl.gui.GUIException;
035:        import org.beryl.gui.MessageDialog;
036:        import org.beryl.gui.View;
037:        import org.beryl.gui.Widget;
038:        import org.beryl.gui.WidgetFactory;
039:        import org.beryl.gui.model.MapDataModel;
040:        import org.beryl.gui.model.TableDataModel;
041:        import org.beryl.gui.model.TableRow;
042:        import org.beryl.gui.widgets.Dialog;
043:        import org.beryl.gui.widgets.Frame;
044:        import org.beryl.gui.widgets.PopupMenu;
045:        import org.beryl.gui.widgets.Table;
046:
047:        /**
048:         * Internationalization editor
049:         */
050:        public class InternationalizationEditor extends Controller {
051:            private static boolean modified = false;
052:            private WidgetTree widgetTree = null;
053:            private Properties properties = null;
054:            private MapDataModel dataModel = null;
055:            private Frame frame = null;
056:            private Table propertyTable = null;
057:            private TableDataModel propertyModel = null;
058:
059:            private class PropertyTableRow extends TableRow {
060:                private String key = null;
061:
062:                public PropertyTableRow(String key) {
063:                    this .key = key;
064:                }
065:
066:                public boolean isEditable(String key) {
067:                    return key.equals("value");
068:                }
069:
070:                public Object getValue(String key) {
071:                    if (key.equals("key"))
072:                        return this .key;
073:                    else if (key.equals("value"))
074:                        return properties.getProperty(this .key);
075:                    else
076:                        throw new RuntimeException("Invalid key selected");
077:                }
078:
079:                public void setValue(View source, String key, Object newValue)
080:                        throws GUIException {
081:                    if (key.equals("value")) {
082:                        properties.setProperty(this .key, (String) newValue);
083:                        modified = true;
084:                    } else {
085:                        throw new RuntimeException("Invalid key selected");
086:                    }
087:                }
088:            };
089:
090:            public InternationalizationEditor(WidgetTree widgetTree,
091:                    Properties properties) throws GUIException {
092:                this .properties = properties;
093:                this .widgetTree = widgetTree;
094:                dataModel = new MapDataModel();
095:                frame = constructFrame("InternationalizationEditor", dataModel);
096:                propertyTable = (Table) frame.getWidget("PropertyTable");
097:
098:                propertyModel = new TableDataModel();
099:                buildModel();
100:                propertyTable.setTableDataModel(propertyModel);
101:                frame.show();
102:            }
103:
104:            private void buildModel() throws GUIException {
105:                dataModel.setValue("property.value", new TableRow[] {});
106:                propertyModel.clear();
107:                for (Iterator i = properties.keySet().iterator(); i.hasNext();)
108:                    propertyModel
109:                            .addRow(new PropertyTableRow((String) i.next()));
110:            }
111:
112:            public boolean isVisible() throws GUIException {
113:                return frame.isVisible();
114:            }
115:
116:            public boolean doAskSaveCancel(Frame frame) throws GUIException {
117:                if (modified) {
118:                    switch (DialogUtils.showYesNoCancelDialog(frame,
119:                            getString("builder.savei18n.title"),
120:                            getString("builder.savei18n.label"))) {
121:                    case DialogUtils.RESULT_YES:
122:                        doSave();
123:                        return true;
124:                    case DialogUtils.RESULT_NO:
125:                        return true;
126:                    case DialogUtils.RESULT_CANCEL:
127:                        return false;
128:                    }
129:                }
130:                return true;
131:            }
132:
133:            private void doSave() throws GUIException {
134:                try {
135:                    File file = DialogUtils.showSaveFileDialog(frame,
136:                            "properties");
137:                    if (file != null) {
138:                        properties
139:                                .store(new FileOutputStream(file),
140:                                        "Internationalization file created using the Builder");
141:                    }
142:                } catch (Exception e) {
143:                    throw new GUIException("Error while saving file", e);
144:                }
145:            }
146:
147:            public void eventOccured(GUIEvent event) {
148:                String name = event.getName();
149:                try {
150:                    if (name.equals("add")) {
151:                        final Dialog dialog = (Dialog) WidgetFactory
152:                                .getInstance().constructWidget(getClass(),
153:                                        "AddInternationalizationDialog",
154:                                        new GUIEventListener() {
155:                                            public void eventOccured(
156:                                                    GUIEvent event) {
157:                                                try {
158:                                                    Widget source = event
159:                                                            .getSource();
160:                                                    if (event.getName().equals(
161:                                                            "ok")) {
162:                                                        String key = (String) source
163:                                                                .getDataModel()
164:                                                                .getValue("key");
165:                                                        String value = (String) source
166:                                                                .getDataModel()
167:                                                                .getValue(
168:                                                                        "value");
169:
170:                                                        boolean isNew = (properties
171:                                                                .getProperty(key) == null);
172:                                                        properties.setProperty(
173:                                                                key, value);
174:                                                        if (isNew)
175:                                                            propertyModel
176:                                                                    .addRow(new PropertyTableRow(
177:                                                                            key));
178:                                                        modified = true;
179:                                                    }
180:                                                    ((Dialog) source
181:                                                            .getParentWidgetByClass(Dialog.class))
182:                                                            .dispose();
183:                                                } catch (Exception e) {
184:                                                    new MessageDialog(e);
185:                                                }
186:                                            }
187:                                        }, new MapDataModel());
188:                        dialog.initDialog(frame);
189:                        dialog.show();
190:                    } else if (name.equals("popup")) {
191:                        PopupMenu popup = (PopupMenu) constructWidget("PropertyPopup");
192:                        popup.popup(event);
193:                    } else if (name.equals("delete")) {
194:                        TableRow rows[] = (TableRow[]) dataModel
195:                                .getValue("property.value");
196:                        for (int i = 0; i < rows.length; i++) {
197:                            PropertyTableRow row = (PropertyTableRow) rows[i];
198:                            propertyModel.removeRow(row);
199:                            properties.remove(row.getValue("key"));
200:                        }
201:                    } else if (name.equals("clear")) {
202:                        dataModel.setValue("property.value", new TableRow[] {});
203:                        propertyModel.clear();
204:                        properties.clear();
205:                    } else if (name.equals("import")) {
206:                        File file = DialogUtils.showOpenFileDialog(frame,
207:                                "properties");
208:                        if (file != null) {
209:                            properties.load(new FileInputStream(file));
210:                            buildModel();
211:                        }
212:                    } else if (name.equals("save")) {
213:                        doSave();
214:                    } else if (name.equals("refresh")) {
215:                        widgetTree.refreshInternationalProperties();
216:                    }
217:                } catch (Exception e) {
218:                    new MessageDialog(e);
219:                }
220:            }
221:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.