Source Code Cross Referenced for BookmarkPropertyDialog.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.Dialog;
021:        import java.awt.event.ActionEvent;
022:        import java.util.logging.Logger;
023:
024:        import javax.swing.AbstractAction;
025:        import javax.swing.Action;
026:        import javax.swing.JButton;
027:        import javax.swing.JDialog;
028:        import javax.swing.JLabel;
029:        import javax.swing.JPanel;
030:        import javax.swing.JTextField;
031:        import javax.swing.JTree;
032:        import javax.swing.tree.DefaultMutableTreeNode;
033:        import javax.swing.tree.DefaultTreeModel;
034:
035:        import com.jgoodies.forms.extras.SimpleFormBuilder;
036:
037:        import de.finix.contelligent.client.base.ComponentFactory;
038:        import de.finix.contelligent.client.base.ComponentNotFoundException;
039:        import de.finix.contelligent.client.i18n.Resources;
040:        import de.finix.contelligent.client.util.bookmark.Bookmark;
041:        import de.finix.contelligent.client.util.bookmark.BookmarkFolder;
042:        import de.finix.contelligent.client.util.bookmark.BookmarkManager;
043:
044:        public class BookmarkPropertyDialog extends JDialog {
045:
046:            static Logger log = Logger.getLogger(BookmarkPropertyDialog.class
047:                    .getName());
048:
049:            private Bookmark bookmark = null;
050:
051:            private JTree bookmarksTree = null;
052:
053:            private JPanel panel = null;
054:
055:            private JLabel nameLabel = null;
056:
057:            private JTextField nameTextField = null;
058:
059:            private JLabel componentPathLabel = null;
060:
061:            private JTextField componentPathTextField = null;
062:
063:            private JPanel buttonPanel = null;
064:
065:            private JButton confirmButton = null;
066:
067:            private JButton closeButton = null;
068:
069:            /**
070:             * This is the default constructor
071:             */
072:            public BookmarkPropertyDialog(Dialog owner, Bookmark bookmark,
073:                    JTree bookmarksTree) {
074:                super (owner);
075:
076:                this .bookmark = bookmark;
077:                this .bookmarksTree = bookmarksTree;
078:
079:                initialize();
080:            }
081:
082:            /**
083:             * This method initializes this
084:             * 
085:             * @return void
086:             */
087:            private void initialize() {
088:                panel = new JPanel();
089:
090:                // init layoutManager
091:                SimpleFormBuilder builder = new SimpleFormBuilder(
092:                        "related,labelColumn=pref,related,fieldColumn=pref:grow,related,related",
093:                        "related,nameRow=pref,related,componentPathRow=pref,related,buttonRow=pref,related");
094:                // Spalten und Zeilen
095:
096:                builder.add(getNameLabel(), "labelColumn,nameRow");
097:                builder.add(getNameTextField(), "fieldColumn,nameRow,2,1");
098:
099:                builder.add(getComponentPathLabel(),
100:                        "labelColumn,componentPathRow");
101:                builder.add(getComponentPathTextField(),
102:                        "fieldColumn,componentPathRow,2,1");
103:
104:                builder.add(getButtonPanel(), "fieldColumn,buttonRow,2,1");
105:
106:                panel = builder.getPanel();
107:                panel.setOpaque(false);
108:
109:                setContentPane(panel);
110:                setTitle(Resources.getLocalStringForPackage(
111:                        "bookmark_property_editor_frame_title",
112:                        "languages.language"));
113:
114:                getRootPane().setDefaultButton(confirmButton);
115:
116:                setLocationByPlatform(true);
117:                setSize(500, 115);
118:                setResizable(false);
119:
120:                setModal(true);
121:            }
122:
123:            /**
124:             * @return the nameLabel
125:             */
126:            public JLabel getNameLabel() {
127:                if (nameLabel == null) {
128:                    nameLabel = new JLabel();
129:                    nameLabel.setText(Resources.getLocalStringForPackage(
130:                            "bookmark_property_editor_name_label",
131:                            "languages.language")
132:                            + ": ");
133:                }
134:                return nameLabel;
135:            }
136:
137:            /**
138:             * @return the nameTextField
139:             */
140:            private JTextField getNameTextField() {
141:                if (nameTextField == null) {
142:                    nameTextField = new JTextField();
143:                    nameTextField.setText(this .bookmark.getName());
144:                    nameTextField
145:                            .setToolTipText(Resources
146:                                    .getLocalStringForPackage(
147:                                            "bookmark_property_editor_name_text_field_tool_tip",
148:                                            "languages.language"));
149:                    nameTextField.setEditable(true);
150:                    nameTextField.setEnabled(true);
151:                }
152:                return nameTextField;
153:            }
154:
155:            /**
156:             * @return the componentPathLabel
157:             */
158:            public JLabel getComponentPathLabel() {
159:                if (componentPathLabel == null) {
160:                    componentPathLabel = new JLabel();
161:                    componentPathLabel
162:                            .setText(Resources
163:                                    .getLocalStringForPackage(
164:                                            "bookmark_property_editor_componentpath_label",
165:                                            "languages.language")
166:                                    + ": ");
167:                }
168:                return componentPathLabel;
169:            }
170:
171:            /**
172:             * @return the componentPathTextField
173:             */
174:            public JTextField getComponentPathTextField() {
175:                if (componentPathTextField == null) {
176:                    componentPathTextField = new JTextField();
177:                    componentPathTextField.setText(this .bookmark
178:                            .getComponentPath());
179:
180:                    componentPathTextField.setEditable(true);
181:                    componentPathTextField.setEnabled(true);
182:                }
183:                return componentPathTextField;
184:            }
185:
186:            /**
187:             * @return the buttonPanel
188:             */
189:            public JPanel getButtonPanel() {
190:                if (buttonPanel == null) {
191:                    buttonPanel = new JPanel();
192:
193:                    // init layoutManager
194:                    SimpleFormBuilder builder = new SimpleFormBuilder(
195:                            "related,confirmButtonColumn=pref,related,closeButtonColumn=pref,related",
196:                            "row=pref");
197:                    // Spalten und Zeilen
198:
199:                    builder.add(getConfirmButton(), "confirmButtonColumn,row");
200:                    builder.add(getCloseButton(), "closeButtonColumn,row");
201:
202:                    buttonPanel = builder.getPanel();
203:                    buttonPanel.setOpaque(false);
204:                }
205:                return buttonPanel;
206:            }
207:
208:            /**
209:             * @return the confirmButton
210:             */
211:            public JButton getConfirmButton() {
212:                if (confirmButton == null) {
213:                    confirmButton = new JButton(confirmAction);
214:
215:                    confirmButton.setText(Resources.getLocalStringForPackage(
216:                            "bookmark_property_editor_confirm_button",
217:                            "languages.language"));
218:                }
219:                return confirmButton;
220:            }
221:
222:            /**
223:             * @return the closeButton
224:             */
225:            public JButton getCloseButton() {
226:                if (closeButton == null) {
227:                    closeButton = new JButton(closeFrameAction);
228:
229:                    closeButton.setText(Resources.getLocalStringForPackage(
230:                            "bookmark_property_editor_close_button",
231:                            "languages.language"));
232:                }
233:                return closeButton;
234:            }
235:
236:            /**
237:             * 
238:             */
239:            Action confirmAction = new AbstractAction("confirmButton") {
240:                // This method is called when the button is pressed
241:                public void actionPerformed(ActionEvent evt) {
242:
243:                    // create new bookmarkFolder
244:                    String name = getNameTextField().getText().trim();
245:                    String componentPath = getComponentPathTextField()
246:                            .getText();
247:
248:                    // bookmark.getType() liefert null!? darum wird hier typ neu ermittelt:
249:                    String type = null;
250:
251:                    try {
252:                        type = ComponentFactory.getInstance().getComponent(
253:                                componentPath).getTypeName();
254:                    } catch (ComponentNotFoundException e) {
255:                        log
256:                                .warning("Could not get component '"
257:                                        + componentPath
258:                                        + "' to determine its component type and icon.");
259:
260:                        // bacause the componentPath might be invalid, determining the type might fail. so we set it here.
261:                        type = "";
262:                    }
263:
264:                    Bookmark bookmarkNew = new Bookmark(componentPath, name,
265:                            type);
266:
267:                    // replace bookmark = remove old and add new bookmark at the same node
268:                    BookmarkManager bookmarkManager = BookmarkManager
269:                            .getInstance();
270:                    bookmarkManager.replace(bookmarkNew, bookmark);
271:
272:                    // update tree visualization
273:                    // Because we know, that the model is of type DefaultTreeModel, we can explicit cast on it. 
274:                    DefaultTreeModel treeModel = (DefaultTreeModel) bookmarksTree
275:                            .getModel();
276:                    DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode) bookmarksTree
277:                            .getLastSelectedPathComponent();
278:
279:                    // get parent of selected node
280:                    DefaultMutableTreeNode parent = (DefaultMutableTreeNode) selectedNode
281:                            .getParent();
282:
283:                    if (parent == null) {
284:                        // if parent is null, something went wrong.
285:                        // we close this dialog to enforce a revisualization of the tree.
286:                        dispose();
287:                    }
288:
289:                    DefaultMutableTreeNode newNode = new DefaultMutableTreeNode(
290:                            name);
291:                    newNode.setUserObject(bookmarkNew);
292:
293:                    // remove old node
294:                    treeModel.removeNodeFromParent(selectedNode);
295:
296:                    int childCount = parent.getChildCount();
297:                    if (childCount > 0) {
298:                        String compareName = null;
299:
300:                        for (int i = 0; i < childCount; i++) {
301:                            DefaultMutableTreeNode node = (DefaultMutableTreeNode) parent
302:                                    .getChildAt(i);
303:
304:                            if (node.getUserObject() instanceof  Bookmark) {
305:                                Bookmark bookmark = (Bookmark) node
306:                                        .getUserObject();
307:                                compareName = bookmark.getName();
308:
309:                                if (bookmarkNew.getName()
310:                                        .compareTo(compareName) > 0) {
311:                                    // Bookmark name is bigger than compareName
312:                                    if ((i + 1) == childCount) {
313:                                        // add new node at the end of list
314:                                        treeModel.insertNodeInto(newNode,
315:                                                parent, i + 1);
316:                                        break;
317:                                    }
318:                                } else {
319:                                    // add new node
320:                                    treeModel
321:                                            .insertNodeInto(newNode, parent, i);
322:                                    break;
323:                                }
324:                            } else {
325:                                if (node.getUserObject() instanceof  BookmarkFolder) {
326:                                    if ((i + 1) == childCount) {
327:                                        // add new node at the end of list
328:                                        treeModel.insertNodeInto(newNode,
329:                                                parent, i + 1);
330:                                        break;
331:                                    }
332:                                }
333:                            }
334:                        }
335:                    } else {
336:                        // no children, then insert at index 0.
337:                        treeModel.insertNodeInto(newNode, parent, 0);
338:                        treeModel.reload();
339:                    }
340:
341:                    dispose();
342:                }
343:            };
344:
345:            /**
346:             * 
347:             */
348:            Action closeFrameAction = new AbstractAction("closeButton") {
349:                // This method is called when the button is pressed
350:                public void actionPerformed(ActionEvent evt) {
351:
352:                    dispose();
353:                }
354:            };
355:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.