Source Code Cross Referenced for LinkEditor.java in  » Content-Management-System » contelligent » de » finix » contelligent » client » gui » link » 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.link 
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.link;
019:
020:        import java.awt.BorderLayout;
021:        import java.awt.Color;
022:        import java.awt.event.ActionEvent;
023:        import java.awt.event.ActionListener;
024:        import java.awt.event.FocusAdapter;
025:        import java.awt.event.FocusEvent;
026:        import java.util.logging.Logger;
027:
028:        import javax.swing.JComponent;
029:        import javax.swing.JLabel;
030:        import javax.swing.JPanel;
031:        import javax.swing.event.CaretEvent;
032:        import javax.swing.event.CaretListener;
033:
034:        import de.finix.contelligent.client.base.ComponentFactory;
035:        import de.finix.contelligent.client.base.ComponentNotFoundException;
036:        import de.finix.contelligent.client.base.ContelligentComponent;
037:        import de.finix.contelligent.client.event.ContelligentEvent;
038:        import de.finix.contelligent.client.gui.AbstractComponentEditor;
039:        import de.finix.contelligent.client.gui.ComponentRenderer;
040:        import de.finix.contelligent.client.gui.GUI;
041:        import de.finix.contelligent.client.gui.GUIFactory;
042:        import de.finix.contelligent.client.gui.UnsupportedGUIException;
043:        import de.finix.contelligent.client.i18n.Resources;
044:        import de.finix.contelligent.client.modules.preferences.PreferencesModule;
045:        import de.finix.contelligent.client.util.dnd.JTextFieldDND;
046:
047:        public class LinkEditor extends AbstractComponentEditor {
048:
049:            private static Logger logger = Logger.getLogger(LinkEditor.class
050:                    .getName());
051:
052:            private JTextFieldDND linkTarget;
053:
054:            private ComponentRenderer linkedRenderer;
055:
056:            private JLabel linkTargetLabel;
057:
058:            private JPanel rendererPanel;
059:
060:            private int type;
061:
062:            private boolean showLinkTargets = PreferencesModule
063:                    .getPreferences().getBoolean(
064:                            PreferencesModule.SHOW_LINK_TARGETS,
065:                            PreferencesModule.DEFAULT_SHOW_LINK_TARGETS);
066:
067:            private boolean ignoreUpdates = false;
068:
069:            public void init() {
070:                linkTarget = new JTextFieldDND();
071:                linkTargetLabel = new JLabel();
072:                rendererPanel = new JPanel(new BorderLayout());
073:                rendererPanel.setOpaque(false);
074:
075:                update();
076:
077:                linkTarget.setEditable(isEditable());
078:                JPanel linkPanel = new JPanel(new BorderLayout());
079:                linkPanel.setOpaque(false);
080:                linkPanel.add(linkTarget, BorderLayout.CENTER);
081:                linkPanel.add(linkTargetLabel, BorderLayout.WEST);
082:                add(linkPanel, BorderLayout.NORTH);
083:                add(rendererPanel, BorderLayout.CENTER);
084:
085:                addFocusListener(new FocusAdapter() {
086:                    public void focusGained(FocusEvent e) {
087:                        getView().setActions(LinkEditor.this .getActions());
088:                    }
089:                });
090:
091:                linkTarget.addActionListener(new ActionListener() {
092:                    public void actionPerformed(ActionEvent e) {
093:                        updateComponent();
094:                        update();
095:                        notifyListeners();
096:                    }
097:
098:                });
099:
100:                linkTarget.addCaretListener(new CaretListener() {
101:                    public void caretUpdate(CaretEvent e) {
102:                        updateComponent();
103:                    }
104:                });
105:            }
106:
107:            public void setType(int type) {
108:                this .type = type;
109:            }
110:
111:            public int getType() {
112:                return type;
113:            }
114:
115:            public void update() {
116:
117:                String targetPath = null;
118:
119:                ContelligentComponent linkedComponent = null;
120:                GUI[] gui = null;
121:                linkedRenderer = null;
122:                JLabel noRenderer = null;
123:
124:                targetPath = getComponent().getPropertyValue(
125:                        ContelligentComponent.TARGET_PATH);
126:                ignoreUpdates = true;
127:                linkTarget.setText(targetPath);
128:                ignoreUpdates = false;
129:
130:                rendererPanel.removeAll();
131:
132:                // load linked component
133:                try {
134:                    // linkedComponent =
135:                    // ComponentFactory.getInstance().getComponent(getComponent().getPath(),
136:                    // targetPath);
137:                    linkedComponent = ComponentFactory.getInstance()
138:                            .getComponent(targetPath);
139:                    if (linkedComponent != getComponent()) {
140:                        linkTargetLabel.setIcon(Resources.mergeIcons(
141:                                linkedComponent.getSmallIcon(),
142:                                Resources.linkAlias));
143:                        if (showLinkTargets) {
144:                            gui = GUIFactory.getInstance().getGUI(
145:                                    linkedComponent, getView());
146:                            linkedRenderer = gui[0].getRenderer(getType());
147:                            rendererPanel.add((JComponent) linkedRenderer,
148:                                    BorderLayout.CENTER);
149:                        } else {
150:                            noRenderer = new JLabel(Resources
151:                                    .getLocalString("no_preview_error"));
152:                            noRenderer.setOpaque(true);
153:                            noRenderer.setBackground(Color.white);
154:                            rendererPanel.add(noRenderer, BorderLayout.CENTER);
155:                        }
156:                    }
157:                } catch (UnsupportedGUIException e) {
158:                    noRenderer = new JLabel(Resources
159:                            .getLocalString("no_preview_error"));
160:                    noRenderer.setOpaque(true);
161:                    noRenderer.setBackground(Color.white);
162:                    rendererPanel.add(noRenderer, BorderLayout.CENTER);
163:                } catch (ComponentNotFoundException cnfe) {
164:                    linkTargetLabel.setIcon(Resources.componentNotFoundIcon);
165:                    noRenderer = new JLabel(Resources
166:                            .getLocalString("invalid_link_error"));
167:                    noRenderer.setOpaque(true);
168:                    noRenderer.setBackground(Color.white);
169:                    noRenderer.setForeground(Color.red);
170:                    rendererPanel.add(noRenderer, BorderLayout.CENTER);
171:                }
172:                // needed to fix bug #314: as target has been newly created we need to
173:                // set it editable
174:                setEditable(isEditable());
175:                rendererPanel.validate();
176:                rendererPanel.repaint();
177:            }
178:
179:            public void setEditable(boolean editable) {
180:                super .setEditable(editable);
181:                if (linkTarget != null) {
182:                    linkTarget.setDragEnabled(isEditable());
183:                    linkTarget.setEditable(isEditable());
184:                }
185:            }
186:
187:            protected void updateComponent() {
188:                if (!ignoreUpdates) {
189:                    if (linkTarget.getText().length() > 0) {
190:                        getComponent().setPropertyValue(
191:                                ContelligentComponent.TARGET_PATH,
192:                                linkTarget.getText());
193:                    } else {
194:                        // Never store an empty link target
195:                        getComponent().setPropertyValue(
196:                                ContelligentComponent.TARGET_PATH, "/");
197:                    }
198:                }
199:            }
200:
201:            protected void componentChanged(ContelligentEvent event) {
202:                update();
203:            }
204:
205:            protected void childComponentAdded(ContelligentEvent event) {
206:            }
207:
208:            protected void childComponentRemoved(ContelligentEvent event) {
209:            }
210:
211:            protected void childComponentChanged(ContelligentEvent event) {
212:            }
213:
214:            protected void descendentComponentChanged(ContelligentEvent event) {
215:            }
216:
217:            public boolean isScalable() {
218:                if (linkedRenderer != null) {
219:                    return linkedRenderer.isScalable();
220:                }
221:                return false;
222:            }
223:
224:            /**
225:             * Overriden for this editor, since the abstract editor calls
226:             * updateComponent on commit, which breaks the link editor for
227:             * multi-category composed edits since that way the value from the last tab
228:             * to be saved is committed to the database.
229:             */
230:            public void commit() {
231:                notifyListeners();
232:                ComponentFactory.getInstance().save(getComponent());
233:            }
234:
235:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.