Source Code Cross Referenced for XLibDataChooser.java in  » XML-UI » xui32 » com » xoetrope » carousel » services » dialog » 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 » xui32 » com.xoetrope.carousel.services.dialog 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.xoetrope.carousel.services.dialog;
002:
003:        import java.awt.BorderLayout;
004:        import java.awt.Color;
005:        import java.awt.Dimension;
006:        import java.awt.Rectangle;
007:        import java.awt.event.ActionEvent;
008:        import java.awt.event.ActionListener;
009:        import javax.swing.JButton;
010:        import javax.swing.JDialog;
011:        import javax.swing.JPanel;
012:        import javax.swing.JScrollPane;
013:        import javax.swing.JSplitPane;
014:        import javax.swing.JTable;
015:        import javax.swing.JTextField;
016:        import javax.swing.border.EmptyBorder;
017:        import javax.swing.event.TreeSelectionEvent;
018:        import javax.swing.event.TreeSelectionListener;
019:        import javax.swing.table.DefaultTableModel;
020:
021:        import net.xoetrope.editor.XEditorDefaults;
022:        import net.xoetrope.builder.helper.XTableModelHelper; //  import com.xoetrope.carousel.services.ProjectRouteManager;
023:        import net.xoetrope.xui.XProjectManager;
024:        import net.xoetrope.xui.data.XBaseModel;
025:        import net.xoetrope.xui.data.XModel;
026:        import javax.swing.SwingUtilities;
027:        import net.xoetrope.xui.XProject;
028:
029:        /**
030:         * <p> Copyright (c) Xoetrope Ltd., 2001-2006, This software is licensed under
031:         * the GNU Public License (GPL), please see license.txt for more details. If
032:         * you make commercial use of this software you must purchase a commercial
033:         * license from Xoetrope.</p>
034:         * <p> $Revision: 1.7 $</p>
035:         */
036:        public class XLibDataChooser extends JDialog implements  ActionListener,
037:                TreeSelectionListener {
038:            private JPanel mainPanel, pnlControls;
039:            private JButton btnAdd, btnSave, btnCancel, btnOK, btnRefresh;
040:            private boolean isOK = false;
041:            private XLibDataTree dataTree;
042:            private JTable valuesTable;
043:            private DefaultTableModel listTableModel;
044:            private JTextField txtStatus;
045:            private JSplitPane splitPane = null;
046:            private boolean isDebug;
047:
048:            /**
049:             * The owner project and the context in which this object operates.
050:             */
051:            protected XProject currentProject = XProjectManager
052:                    .getCurrentProject();
053:
054:            public XLibDataChooser() {
055:                this (false);
056:            }
057:
058:            public XLibDataChooser(boolean debug) {
059:                isDebug = debug;
060:
061:                mainPanel = new JPanel(new BorderLayout());
062:                mainPanel.setBorder(new EmptyBorder(0, 0, 0, 0));
063:                pnlControls = new JPanel(new BorderLayout());
064:                pnlControls.setPreferredSize(new Dimension(230, 25));
065:                pnlControls.setBorder(new EmptyBorder(0, 0, 0, 0));
066:
067:                if (debug) {
068:                    btnRefresh = new JButton("Refresh");
069:                    btnRefresh.setFont(XEditorDefaults.defaultFont);
070:                    btnRefresh.addActionListener(this );
071:                    btnRefresh.setPreferredSize(new Dimension(230, 25));
072:                    pnlControls.add(btnRefresh, BorderLayout.CENTER);
073:
074:                    listTableModel = new DefaultTableModel();
075:                    listTableModel.addColumn("name");
076:                    listTableModel.addColumn("Value");
077:                    valuesTable = new JTable(listTableModel);
078:
079:                    JPanel rightPanel = new JPanel(new BorderLayout());
080:                    rightPanel.add(new JScrollPane(valuesTable),
081:                            BorderLayout.CENTER);
082:                    splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
083:                            mainPanel, rightPanel);
084:                    splitPane.setDividerSize(6);
085:                    getContentPane().setLayout(new BorderLayout());
086:                    getContentPane().add(splitPane, BorderLayout.CENTER);
087:
088:                    txtStatus = new JTextField();
089:                    txtStatus.setBackground(Color.LIGHT_GRAY);
090:                    txtStatus.setForeground(new Color(0, 0, 200));
091:                    getContentPane().add(txtStatus, BorderLayout.SOUTH);
092:                    setTitle("Model Explorer");
093:                } else {
094:                    btnOK = new JButton("OK");
095:                    pnlControls.add(btnOK, BorderLayout.WEST);
096:                    btnOK.addActionListener(this );
097:
098:                    btnCancel = new JButton("Cancel");
099:                    pnlControls.add(btnCancel, BorderLayout.EAST);
100:                    btnCancel.addActionListener(this );
101:                    getContentPane().add(mainPanel);
102:                }
103:
104:                dataTree = new XLibDataTree(debug);
105:                dataTree.dataTree.addTreeSelectionListener(this );
106:                dataTree.expandRoot();
107:
108:                mainPanel.add(dataTree, BorderLayout.CENTER);
109:                mainPanel.add(pnlControls, BorderLayout.SOUTH);
110:
111:                setModal(true);
112:                setSize(640, 400);
113:
114:            }
115:
116:            public void valueChanged(TreeSelectionEvent evt) {
117:                String path = getTreePath();
118:                txtStatus.setText(path);
119:                XModel mdl = (XModel) currentProject.getModel().get(path);
120:
121:                listTableModel.setNumRows(0);
122:
123:                for (int i = 0; i < mdl.getNumAttributes(); i++) {
124:                    String strValue = null;
125:                    if (mdl.getAttribValue(i) != null)
126:                        strValue = mdl.getAttribValue(i).toString();
127:                    String[] rowData = { mdl.getAttribName(i), strValue };
128:                    listTableModel.addRow(rowData);
129:                }
130:            }
131:
132:            /**
133:             * Get the path of the selected treenode by looping the selected path array
134:             * and placing a '/' between each item
135:             * @return the path to the selected XModel
136:             */
137:            String getTreePath() {
138:                String modelName = null;
139:                if (dataTree.dataTree.getSelectionPath() != null) {
140:                    Object path[] = dataTree.dataTree.getSelectionPath()
141:                            .getPath();
142:
143:                    modelName = "";
144:                    for (int i = 1; i < path.length; i++) {
145:                        String pathEle = path[i].toString();
146:                        pathEle = pathEle
147:                                .substring(0, pathEle.indexOf("~") - 1);
148:                        String value = path[i].toString();
149:                        value = value.substring(value.indexOf("~") + 3, value
150:                                .length() - 1);
151:                        if ((value.compareTo("null") != 0)
152:                                && (value.indexOf("DatabaseTableModel") == -1))
153:                            pathEle += "@value=[" + value + "]";
154:                        modelName += "/" + pathEle;
155:                    }
156:                }
157:                if (modelName == null)
158:                    return "";
159:                else if (modelName.trim().compareTo("") != 0)
160:                    return modelName.substring(1);
161:                else
162:                    return "";
163:            }
164:
165:            public void centerScreen(Rectangle parentRect) {
166:                double x = parentRect.getWidth() - getSize().getWidth();
167:                double y = parentRect.getHeight() - getSize().getHeight();
168:                setLocation((int) x, (int) y);
169:            }
170:
171:            private void addData() {
172:                XBaseModel model = (XBaseModel) currentProject.getModel();
173:                XBaseModel rowdata = (XBaseModel) XTableModelHelper
174:                        .addRow(model);
175:                XTableModelHelper.addData(rowdata, "event", "alert");
176:                XTableModelHelper.addData(rowdata, "Control", "");
177:                XTableModelHelper.addData(rowdata, "cmd", "info");
178:                XTableModelHelper.addData(rowdata, "hash", "");
179:                XTableModelHelper.addData(rowdata, "tag", "");
180:                XTableModelHelper.addData(rowdata, "frame", "");
181:            }
182:
183:            public void actionPerformed(ActionEvent ae) {
184:                if (ae.getSource().equals(btnOK)) {
185:                    isOK = true;
186:                    setVisible(false);
187:                } else if (ae.getSource().equals(btnCancel)) {
188:                    isOK = false;
189:                    setVisible(false);
190:                } else if (ae.getSource().equals(btnRefresh)) {
191:                    dataTree.createTreeComp(null);
192:                    dataTree.dataTree.addTreeSelectionListener(this );
193:                }
194:            }
195:
196:            public void showDlg(String selected, boolean modal) {
197:                setModal(false);
198:                showDlg(selected);
199:            }
200:
201:            public String showDlg(String selected) {
202:                //if ( isModal() )
203:                //  getModelManager().readXmlFile();
204:                setVisible(true);
205:
206:                if (isDebug) {
207:                    final JSplitPane splitter = splitPane;
208:                    SwingUtilities.invokeLater(new Runnable() {
209:                        public void run() {
210:                            validate();
211:                            splitter.setDividerLocation(0.3);
212:                        }
213:                    });
214:                }
215:
216:                if (isOK)
217:                    return dataTree.getTreePath();
218:                else
219:                    return null;
220:            }
221:
222:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.