Source Code Cross Referenced for CreateBookmarkFolderDialog.java in  » Content-Management-System » contelligent » de » finix » contelligent » client » gui » explorer » 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 » Content Management System » contelligent » de.finix.contelligent.client.gui.explorer 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2001-2006 C:1 Financial Services GmbH
003:         *
004:         * This software is free software; you can redistribute it and/or
005:         * modify it under the terms of the GNU Lesser General Public
006:         * License Version 2.1, as published by the Free Software Foundation.
007:         *
008:         * This software is distributed in the hope that it will be useful,
009:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
010:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
011:         * Lesser General Public License for more details.
012:         *
013:         * You should have received a copy of the GNU Lesser General Public
014:         * License along with this library; if not, write to the Free Software
015:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
016:         */
017:
018:        package de.finix.contelligent.client.gui.explorer;
019:
020:        import java.awt.event.ActionEvent;
021:        import java.util.logging.Logger;
022:
023:        import javax.swing.AbstractAction;
024:        import javax.swing.Action;
025:        import javax.swing.JButton;
026:        import javax.swing.JDialog;
027:        import javax.swing.JLabel;
028:        import javax.swing.JPanel;
029:        import javax.swing.JTextField;
030:        import javax.swing.JTree;
031:        import javax.swing.tree.DefaultMutableTreeNode;
032:        import javax.swing.tree.DefaultTreeModel;
033:
034:        import com.jgoodies.forms.extras.SimpleFormBuilder;
035:
036:        import de.finix.contelligent.client.i18n.Resources;
037:        import de.finix.contelligent.client.util.bookmark.Bookmark;
038:        import de.finix.contelligent.client.util.bookmark.BookmarkFolder;
039:        import de.finix.contelligent.client.util.bookmark.BookmarkManager;
040:
041:        public class CreateBookmarkFolderDialog extends JDialog {
042:
043:            static Logger log = Logger
044:                    .getLogger(CreateBookmarkFolderDialog.class.getName());
045:
046:            private BookmarkFolder parentBookmarkFolder = null;
047:
048:            private JTree bookmarkFolderTree = null;
049:
050:            private JPanel panel = null;
051:
052:            private JLabel nameLabel = null;
053:
054:            private JTextField nameTextField = null;
055:
056:            private JPanel buttonPanel = null;
057:
058:            private JButton confirmButton = null;
059:
060:            private JButton closeButton = null;
061:
062:            /**
063:             * This is the default constructor
064:             */
065:            public CreateBookmarkFolderDialog(
066:                    BookmarkFolder parentBookmarkFolder, JTree folderTree) {
067:                super ();
068:
069:                this .parentBookmarkFolder = parentBookmarkFolder;
070:
071:                this .bookmarkFolderTree = folderTree;
072:
073:                initialize();
074:            }
075:
076:            /**
077:             * This method initializes this
078:             * 
079:             * @return void
080:             */
081:            private void initialize() {
082:
083:                panel = new JPanel();
084:
085:                // init layoutManager
086:                SimpleFormBuilder builder = new SimpleFormBuilder(
087:                        "related,labelColumn=pref,related,fieldColumn=pref:grow,related,related",
088:                        "related,nameRow=pref,related,buttonRow=pref,related");
089:                // Spalten und Zeilen
090:
091:                builder.add(getNameLabel(), "labelColumn,nameRow");
092:                builder.add(getNameTextField(), "fieldColumn,nameRow,2,1");
093:
094:                builder.add(getButtonPanel(), "fieldColumn,buttonRow,2,1");
095:
096:                panel = builder.getPanel();
097:                panel.setOpaque(false);
098:
099:                setContentPane(panel);
100:                setTitle(Resources.getLocalStringForPackage(
101:                        "bookmark_name_frame_folder_new_folder_title",
102:                        "languages.language"));
103:
104:                getRootPane().setDefaultButton(confirmButton);
105:
106:                setLocationByPlatform(true);
107:                setSize(500, 90);
108:                setResizable(false);
109:
110:                setModal(true);
111:            }
112:
113:            /**
114:             * @return the nameLabel
115:             */
116:            public JLabel getNameLabel() {
117:                if (nameLabel == null) {
118:                    nameLabel = new JLabel();
119:                    nameLabel.setText(Resources.getLocalStringForPackage(
120:                            "bookmark_name_frame_name_label",
121:                            "languages.language")
122:                            + ": ");
123:                }
124:                return nameLabel;
125:            }
126:
127:            /**
128:             * @return the nameTextField
129:             */
130:            private JTextField getNameTextField() {
131:                if (nameTextField == null) {
132:                    nameTextField = new JTextField();
133:                    nameTextField.setText(Resources.getLocalStringForPackage(
134:                            "bookmark_name_frame_folder_new_folder",
135:                            "languages.language"));
136:                    nameTextField
137:                            .setToolTipText(Resources
138:                                    .getLocalStringForPackage(
139:                                            "bookmark_name_frame_name_text_field_tool_tip",
140:                                            "languages.language"));
141:                    nameTextField.setEditable(true);
142:                    nameTextField.setEnabled(true);
143:                }
144:                return nameTextField;
145:            }
146:
147:            /**
148:             * @return
149:             */
150:            public JPanel getButtonPanel() {
151:                if (buttonPanel == null) {
152:                    buttonPanel = new JPanel();
153:
154:                    // init layoutManager
155:                    SimpleFormBuilder builder = new SimpleFormBuilder(
156:                            "related,confirmButtonColumn=pref,related,closeButtonColumn=pref,related",
157:                            "row=pref");
158:                    // Spalten und Zeilen
159:
160:                    builder.add(getConfirmButton(), "confirmButtonColumn,row");
161:                    builder.add(getCloseButton(), "closeButtonColumn,row");
162:
163:                    buttonPanel = builder.getPanel();
164:                    buttonPanel.setOpaque(false);
165:                }
166:                return buttonPanel;
167:            }
168:
169:            /**
170:             * @return the confirmButton
171:             */
172:            public JButton getConfirmButton() {
173:                if (confirmButton == null) {
174:                    confirmButton = new JButton(confirmAction);
175:
176:                    confirmButton.setText(Resources.getLocalStringForPackage(
177:                            "bookmark_name_frame_confirm_button",
178:                            "languages.language"));
179:                }
180:                return confirmButton;
181:            }
182:
183:            /**
184:             * @return the closeButton
185:             */
186:            public JButton getCloseButton() {
187:                if (closeButton == null) {
188:                    closeButton = new JButton(closeFrameAction);
189:
190:                    closeButton.setText(Resources.getLocalStringForPackage(
191:                            "bookmark_name_frame_close_button",
192:                            "languages.language"));
193:                }
194:                return closeButton;
195:            }
196:
197:            /**
198:             * 
199:             */
200:            Action confirmAction = new AbstractAction("confirmButton") {
201:                // This method is called when the button is pressed
202:                public void actionPerformed(ActionEvent evt) {
203:                    // create new folder below selected node
204:                    String name = getNameTextField().getText().trim();
205:                    BookmarkFolder newBookmarkFolder = new BookmarkFolder(name);
206:                    BookmarkManager bookmarkManager = BookmarkManager
207:                            .getInstance();
208:
209:                    // Because we know, that the model is of type DefaultTreeModel, we can explicit cast on it.
210:                    DefaultTreeModel treeModel = (DefaultTreeModel) bookmarkFolderTree
211:                            .getModel();
212:                    DefaultMutableTreeNode selectedNode = null;
213:
214:                    if (parentBookmarkFolder == null) {
215:                        // if no node was selected, create new folder below root node
216:                        bookmarkManager.add(newBookmarkFolder);
217:                        selectedNode = (DefaultMutableTreeNode) treeModel
218:                                .getRoot();
219:                    } else {
220:                        bookmarkManager.add(newBookmarkFolder,
221:                                parentBookmarkFolder.getId());
222:                        selectedNode = (DefaultMutableTreeNode) bookmarkFolderTree
223:                                .getLastSelectedPathComponent();
224:                    }
225:
226:                    DefaultMutableTreeNode newFolderNode = new DefaultMutableTreeNode(
227:                            name);
228:                    newFolderNode.setUserObject(newBookmarkFolder);
229:
230:                    // count BookmarkFolder
231:                    int childFolderCount = 0;
232:                    for (int i = 0; i < selectedNode.getChildCount(); i++) {
233:
234:                        DefaultMutableTreeNode node = (DefaultMutableTreeNode) selectedNode
235:                                .getChildAt(i);
236:
237:                        if (node.getUserObject() instanceof  Bookmark) {
238:                            // do nothing
239:                        } else {
240:                            if (node.getUserObject() instanceof  BookmarkFolder) {
241:                                childFolderCount++;
242:                            }
243:                        }
244:                    }
245:
246:                    if (childFolderCount > 0) {
247:                        String compareName = null;
248:
249:                        for (int i = 0; i < childFolderCount; i++) {
250:                            DefaultMutableTreeNode childNode = (DefaultMutableTreeNode) selectedNode
251:                                    .getChildAt(i);
252:
253:                            if (childNode.getUserObject() instanceof  Bookmark) {
254:                                // do nothing
255:                            } else {
256:                                if (childNode.getUserObject() instanceof  BookmarkFolder) {
257:                                    BookmarkFolder bookmarkFolder = (BookmarkFolder) childNode
258:                                            .getUserObject();
259:                                    compareName = bookmarkFolder.getName();
260:
261:                                    if (newBookmarkFolder.getName().compareTo(
262:                                            compareName) > 0) {
263:                                        // BookmarkFolder name is bigger than compareName
264:                                        if ((i + 1) == childFolderCount) {
265:                                            // add new node at the end of list (add new BookmarkFolder behind last BookmarkFolder)
266:                                            treeModel.insertNodeInto(
267:                                                    newFolderNode,
268:                                                    selectedNode, i + 1);
269:                                            break;
270:                                        }
271:                                    } else {
272:                                        // add new node
273:                                        treeModel.insertNodeInto(newFolderNode,
274:                                                selectedNode, i);
275:                                        break;
276:                                    }
277:                                }
278:                            }
279:                        }
280:                        treeModel.reload();
281:                    } else {
282:                        treeModel
283:                                .insertNodeInto(newFolderNode, selectedNode, 0);
284:                        treeModel.reload();
285:                    }
286:
287:                    dispose();
288:                }
289:            };
290:
291:            /**
292:             * 
293:             */
294:            Action closeFrameAction = new AbstractAction("closeButton") {
295:                // This method is called when the button is pressed
296:                public void actionPerformed(ActionEvent evt) {
297:
298:                    dispose();
299:                }
300:            };
301:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.