Source Code Cross Referenced for PreviewFolderEditor.java in  » Content-Management-System » contelligent » de » finix » contelligent » client » gui » directory » 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.directory 
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.directory;
019:
020:        import java.awt.BorderLayout;
021:        import java.awt.Container;
022:        import java.awt.Dimension;
023:        import java.awt.FlowLayout;
024:        import java.awt.Font;
025:        import java.awt.dnd.DnDConstants;
026:        import java.awt.event.FocusAdapter;
027:        import java.awt.event.FocusEvent;
028:        import java.util.Iterator;
029:        import java.util.logging.Level;
030:        import java.util.logging.Logger;
031:
032:        import javax.swing.BorderFactory;
033:        import javax.swing.JLabel;
034:        import javax.swing.JScrollPane;
035:
036:        import de.finix.contelligent.client.base.ComponentFactory;
037:        import de.finix.contelligent.client.base.ComponentNotFoundException;
038:        import de.finix.contelligent.client.base.ContelligentComponent;
039:        import de.finix.contelligent.client.event.ContelligentEvent;
040:        import de.finix.contelligent.client.gui.AbstractComponentEditor;
041:        import de.finix.contelligent.client.gui.ComponentEditor;
042:        import de.finix.contelligent.client.gui.ComponentRenderer;
043:        import de.finix.contelligent.client.gui.GUI;
044:        import de.finix.contelligent.client.gui.GUIFactory;
045:        import de.finix.contelligent.client.gui.UnsupportedGUIException;
046:        import de.finix.contelligent.client.i18n.Resources;
047:        import de.finix.contelligent.client.modules.preferences.PreferencesModule;
048:        import de.finix.contelligent.client.util.ComponentMovement;
049:        import de.finix.contelligent.client.util.CopyOptionPane;
050:        import de.finix.contelligent.client.util.dnd.ComponentDropEvent;
051:        import de.finix.contelligent.client.util.dnd.ComponentDropListener;
052:        import de.finix.contelligent.client.util.dnd.JPanelDND;
053:
054:        public class PreviewFolderEditor extends AbstractComponentEditor
055:                implements  ComponentDropListener {
056:
057:            private final static Dimension PREVIEW_SIZE = new Dimension(100,
058:                    100);
059:
060:            private final static Font PREVIEW_FONT;
061:
062:            static {
063:                int offset = PreferencesModule.getPreferences().getInt(
064:                        PreferencesModule.FONTSIZE_OFFSET,
065:                        PreferencesModule.DEFAULT_FONTSIZE_OFFSET);
066:                PREVIEW_FONT = new Font("Verdana", Font.PLAIN, 10 + offset);
067:            }
068:
069:            private static Logger logger = Logger
070:                    .getLogger(PreviewFolderEditor.class.getName());
071:
072:            private JPanelDND previewPanel;
073:
074:            public void init() {
075:                previewPanel = new JPanelDND(new FlowLayout(FlowLayout.LEFT),
076:                        getView().getEnvironment());
077:
078:                update();
079:
080:                previewPanel.setOpaque(false);
081:                previewPanel.setComponent(getComponent());
082:                previewPanel.setPreferredSize(new Dimension(200, 0));
083:
084:                JScrollPane scrollPane = new JScrollPane(previewPanel);
085:                scrollPane.getViewport().setOpaque(false);
086:                scrollPane.setOpaque(false);
087:                scrollPane
088:                        .setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
089:                add(scrollPane, BorderLayout.CENTER);
090:
091:                previewPanel.addFocusListener(new FocusAdapter() {
092:                    public void focusGained(FocusEvent e) {
093:                        PreviewFolderEditor.this .getView().setActions(
094:                                PreviewFolderEditor.this .getActions());
095:                    }
096:
097:                });
098:
099:                previewPanel.addComponentDropListener(this );
100:            }
101:
102:            public void update() {
103:                String subcomponentName = null;
104:                ContelligentComponent subcomponent = null;
105:
106:                JPanelDND previewElement = null;
107:                JLabel previewLabel = null;
108:                GUI[] gui = null;
109:                ComponentEditor editor = null;
110:                ComponentRenderer renderer = null;
111:
112:                previewPanel.removeAll();
113:
114:                for (Iterator iterator = getComponent().getSubcomponents()
115:                        .iterator(); iterator.hasNext();) {
116:                    subcomponentName = (String) iterator.next();
117:                    try {
118:                        subcomponent = ComponentFactory.getInstance()
119:                                .getComponent(
120:                                        getComponent().getPath() + "/"
121:                                                + subcomponentName);
122:
123:                        previewElement = new JPanelDND(new BorderLayout(),
124:                                getView().getEnvironment());
125:                        previewElement.setComponent(subcomponent);
126:                        // previewElement.setSourceActions(DnDConstants.ACTION_COPY |
127:                        // DnDConstants.ACTION_MOVE | DnDConstants.ACTION_LINK);
128:                        previewElement.setDragEnabled(true);
129:                        previewElement.setBorder(BorderFactory
130:                                .createEtchedBorder());
131:
132:                        previewLabel = new JLabel(subcomponent.getName(),
133:                                JLabel.CENTER);
134:                        previewLabel.setFont(PREVIEW_FONT);
135:
136:                        previewElement.add(previewLabel, BorderLayout.SOUTH);
137:
138:                        gui = GUIFactory.getInstance().getGUI(subcomponent,
139:                                getView());
140:                        if (gui[0].isSupported(GUI.TABLE)) {
141:                            try {
142:                                if (isEditable()) {
143:                                    editor = gui[0].getEditor(GUI.TABLE);
144:                                    previewElement.add(
145:                                            (java.awt.Component) editor,
146:                                            BorderLayout.CENTER);
147:                                } else {
148:                                    renderer = gui[0].getRenderer(GUI.TABLE);
149:                                    previewElement.add(
150:                                            (java.awt.Component) renderer,
151:                                            BorderLayout.CENTER);
152:                                }
153:                            } catch (UnsupportedGUIException uge) {
154:                                logger.log(Level.SEVERE,
155:                                        "GUI for Subcomponent "
156:                                                + subcomponentName
157:                                                + " not supported", uge);
158:                            }
159:                        }
160:                        previewElement.setPreferredSize(PREVIEW_SIZE);
161:                        previewPanel.add(previewElement);
162:                    } catch (ComponentNotFoundException cnfe) {
163:                        logger.log(Level.SEVERE, "Subcomponent "
164:                                + subcomponentName + " no longer valid", cnfe);
165:                    }
166:                }
167:
168:                previewPanel.validate();
169:                previewPanel.repaint();
170:
171:            }
172:
173:            public void setEditable(boolean editable) {
174:                super .setEditable(editable);
175:                if (previewPanel != null) {
176:                    previewPanel.setEnabled(isEditable());
177:                    update();
178:                }
179:            }
180:
181:            public void rollback() {
182:                java.awt.Component subComp[] = null;
183:                java.awt.Component subsubComp[] = null;
184:
185:                // rollback subcomponents
186:                subComp = previewPanel.getComponents();
187:                for (int i = 0; i < subComp.length; i++) {
188:                    subsubComp = ((Container) subComp[i]).getComponents();
189:                    for (int j = 0; j < subsubComp.length; j++) {
190:                        if (subsubComp[j] instanceof  ComponentEditor)
191:                            ((ComponentEditor) subsubComp[j]).rollback();
192:                    }
193:                }
194:                super .rollback();
195:            }
196:
197:            public void commit() {
198:                java.awt.Component subComp[] = null;
199:                java.awt.Component subsubComp[] = null;
200:
201:                // commit subcomponents
202:                subComp = previewPanel.getComponents();
203:                for (int i = 0; i < subComp.length; i++) {
204:                    subsubComp = ((Container) subComp[i]).getComponents();
205:                    for (int j = 0; j < subsubComp.length; j++) {
206:                        if (subsubComp[j] instanceof  ComponentEditor)
207:                            ((ComponentEditor) subsubComp[j]).commit();
208:                    }
209:                }
210:                super .commit();
211:            }
212:
213:            public void componentDropped(ComponentDropEvent event) {
214:                CopyOptionPane copyOptionPane = new CopyOptionPane();
215:                if (copyOptionPane
216:                        .showCopyDialog(Resources
217:                                .getLocalString("copy_component"), Resources
218:                                .getLocalString("target_component_name")
219:                                + ":", event.getDraggedComponent().getName(),
220:                                event.getDropAction(), event
221:                                        .getDraggedComponent().isFinal()) != CopyOptionPane.OK_OPTION) {
222:                    return;
223:                }
224:                String name = copyOptionPane.getPath();
225:                if (name.length() <= 0) {
226:                    return;
227:                }
228:                ActionSelection selection = new ActionSelection(name,
229:                        copyOptionPane.getAction());
230:
231:                switch (selection.getAction()) {
232:                case DnDConstants.ACTION_COPY:
233:                    ComponentMovement.nonBlockingCopy(getView()
234:                            .getEnvironment(), event.getSourceEnvironment(),
235:                            event.getDraggedComponent(), getComponent(),
236:                            selection.getName(), false, false);
237:                    break;
238:                case DnDConstants.ACTION_MOVE:
239:                    // FIXME: Path selection manager!!!!
240:                    ComponentMovement.nonBlockingMove(getView()
241:                            .getEnvironment(), event.getSourceEnvironment(),
242:                            event.getDraggedComponent(), getComponent(),
243:                            selection.getName(), false, false, null);
244:                    break;
245:                case DnDConstants.ACTION_LINK:
246:                    ComponentMovement.nonBlockingCopy(getView()
247:                            .getEnvironment(), event.getSourceEnvironment(),
248:                            event.getDraggedComponent(), getComponent(),
249:                            selection.getName(), true, false);
250:                    break;
251:                }
252:            }
253:
254:            protected void updateComponent() {
255:            }
256:
257:            protected void componentChanged(ContelligentEvent event) {
258:                update();
259:            }
260:
261:            protected void childComponentAdded(ContelligentEvent event) {
262:                update();
263:            }
264:
265:            protected void childComponentRemoved(ContelligentEvent event) {
266:                update();
267:            }
268:
269:            protected void childComponentChanged(ContelligentEvent event) {
270:            }
271:
272:            protected void descendentComponentChanged(ContelligentEvent event) {
273:            }
274:
275:            class ActionSelection {
276:
277:                private String name;
278:
279:                private int action;
280:
281:                public ActionSelection(String name, int action) {
282:                    this .name = name;
283:                    this .action = action;
284:                }
285:
286:                public String getName() {
287:                    return name;
288:                }
289:
290:                public int getAction() {
291:                    return action;
292:                }
293:            }
294:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.