Source Code Cross Referenced for FrameBrowser.java in  » Web-Server » Jigsaw » org » w3c » jigadmin » editors » 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 » Web Server » Jigsaw » org.w3c.jigadmin.editors 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // FrameBrowser.java
002:        // $Id: FrameBrowser.java,v 1.18 2000/08/16 21:37:30 ylafon Exp $
003:        // (c) COPYRIGHT MIT and INRIA, 1998.
004:        // Please first read the full copyright statement in file COPYRIGHT.html
005:
006:        package org.w3c.jigadmin.editors;
007:
008:        import javax.swing.JOptionPane;
009:        import javax.swing.JPanel;
010:        import javax.swing.BorderFactory;
011:        import javax.swing.JLabel;
012:        import javax.swing.JButton;
013:        import javax.swing.JPopupMenu;
014:        import javax.swing.JMenuItem;
015:        import javax.swing.tree.TreePath;
016:        import javax.swing.tree.DefaultTreeModel;
017:        import javax.swing.tree.MutableTreeNode;
018:        import javax.swing.plaf.basic.BasicTreeUI;
019:
020:        import java.awt.GridBagLayout;
021:        import java.awt.GridBagConstraints;
022:        import java.awt.Insets;
023:        import java.awt.GridLayout;
024:        import java.awt.event.ActionListener;
025:        import java.awt.event.ActionEvent;
026:        import java.awt.dnd.DropTargetDropEvent;
027:        import java.awt.dnd.DnDConstants;
028:
029:        import java.util.Vector;
030:        import java.util.Hashtable;
031:        import java.util.Enumeration;
032:
033:        import org.w3c.jigadmin.RemoteResourceWrapper;
034:        import org.w3c.jigadmin.PropertyManager;
035:        import org.w3c.jigadmin.widgets.EditableStringChoice;
036:        import org.w3c.jigadmin.widgets.Icons;
037:        import org.w3c.jigadmin.gui.Message;
038:
039:        import org.w3c.jigsaw.admin.RemoteAccessException;
040:        import org.w3c.jigsaw.admin.RemoteResource;
041:
042:        import org.w3c.tools.sorter.Sorter;
043:
044:        /**
045:         * A JTree used to manage frames.
046:         * @version $Revision: 1.18 $
047:         * @author  Benoît Mahé (bmahe@w3.org)
048:         */
049:        public class FrameBrowser extends ResourceTreeBrowser {
050:
051:            /**
052:             * Constructor
053:             * @param root The resource node
054:             */
055:            protected FrameBrowser(RemoteResourceWrapperNode root) {
056:                super (root);
057:                setUI(new BasicTreeUI());
058:            }
059:
060:            /**
061:             * Get a FrameBrowser.
062:             * @param rrw The resource
063:             * @param name The resource identifier.
064:             * @return a FrameBrowser instance
065:             */
066:            public static FrameBrowser getFrameBrowser(
067:                    RemoteResourceWrapper rrw, String name) {
068:                RemoteFrameWrapperNode rnode = new RemoteFrameWrapperNode(rrw,
069:                        name);
070:                FrameBrowser fb = new FrameBrowser(rnode);
071:                return fb;
072:            }
073:
074:            /**
075:             * Drop a frame.
076:             * @param cell The resource cell
077:             * @see org.w3c.jigadmin.editors.ResourceCell
078:             */
079:            protected boolean dropResource(ResourceCell cell) {
080:                RemoteResourceWrapper rrw = getSelectedResourceWrapper();
081:                if (cell.isFrame() || cell.isFilter()) {
082:                    try {
083:                        TreePath path = getSelectionPath();
084:                        addFrame(cell.toString(), rrw, path);
085:                        return true;
086:                    } catch (RemoteAccessException ex) {
087:                        Message.showErrorMessage(this , ex);
088:                        return false;
089:                    }
090:                } else {
091:                    return false;
092:                }
093:            }
094:
095:            /**
096:             * Get the Panel used to add a new frame
097:             * @param title The title
098:             * @param rrw The wrapper of the father RemoteResource
099:             * @return a AddResourcePanel instance
100:             * @see org.w3c.jigadmin.editors.AddResourcePanel
101:             */
102:            protected AddResourcePanel getAddResourcePanel(String title,
103:                    RemoteResourceWrapper rrw) throws RemoteAccessException {
104:                return new AddFramePanel(title, rrw, this );
105:            }
106:
107:            private void performAddResourceToSelectedContainer() {
108:                popupAddResourceDialog("Add Frame",
109:                        getSelectedResourceWrapper());
110:                if (resClassname != null) {
111:                    RemoteResourceWrapper rrw = getSelectedResourceWrapper();
112:                    try {
113:                        addFrame(resClassname, rrw, getSelectionPath());
114:                    } catch (RemoteAccessException ex) {
115:                        Message.showErrorMessage(this , ex);
116:                    }
117:                }
118:            }
119:
120:            /**
121:             * Add a frame to the selected container.
122:             */
123:            protected void addResourceToSelectedContainer() {
124:                RemoteResourceWrapper selected = getSelectedResourceWrapper();
125:                PropertyManager pm = PropertyManager.getPropertyManager();
126:                if (selected == null) {
127:                    JOptionPane.showMessageDialog(this , "No resource selected",
128:                            "Error", JOptionPane.ERROR_MESSAGE);
129:                    return;
130:                } else if (!pm.isExtensible(selected)) {
131:                    JOptionPane.showMessageDialog(this ,
132:                            "The resource selected is not " + "extensible.",
133:                            "Error", JOptionPane.ERROR_MESSAGE);
134:                } else {
135:                    Thread thread = new Thread() {
136:                        public void run() {
137:                            performAddResourceToSelectedContainer();
138:                        }
139:                    };
140:                    thread.start();
141:                }
142:            }
143:
144:            /**
145:             * Add a frame to the resource wrapped.
146:             * @param classname The new frame class name
147:             * @param rrwf the Wrapper of the resource
148:             * @param fpath The path of the resource node
149:             */
150:            protected void addFrame(String classname,
151:                    RemoteResourceWrapper rrwf, TreePath path)
152:                    throws RemoteAccessException {
153:                RemoteResource newframe = rrwf.getResource().registerFrame(
154:                        null, classname);
155:                RemoteResourceWrapper nrrw = new RemoteResourceWrapper(rrwf,
156:                        newframe);
157:                RemoteFrameWrapperNode parent = (RemoteFrameWrapperNode) path
158:                        .getLastPathComponent();
159:                RemoteFrameWrapperNode child = new RemoteFrameWrapperNode(
160:                        parent, nrrw);
161:                ((DefaultTreeModel) getModel())
162:                        .insertNodeInto(child, parent, 0);
163:                expandPath(path);
164:            }
165:
166:            /**
167:             * Delete the frame wrapped by the given wrapper
168:             * @param rrw The RemoteResourceWrapper
169:             */
170:            protected void deleteResource(RemoteResourceWrapper rrw)
171:                    throws RemoteAccessException {
172:                rrw.getFatherResource().unregisterFrame(rrw.getResource());
173:            }
174:
175:            /**
176:             * Delete the frames associated to the selected nodes.
177:             * Display an error message if there is no node selected.
178:             */
179:            protected void deleteSelectedResources() {
180:                TreePath path[] = removeDescendants(getSelectionPaths());
181:                if (path == null)
182:                    return;
183:                if (path.length > 0) {
184:                    int result = JOptionPane.showConfirmDialog(this ,
185:                            "Delete Selected Frame(s)?", "Delete Frame(s)",
186:                            JOptionPane.YES_NO_OPTION);
187:                    if (result == JOptionPane.YES_OPTION) {
188:                        DefaultTreeModel model = (DefaultTreeModel) getModel();
189:                        for (int i = 0; i < path.length; i++) {
190:                            RemoteResourceWrapper rrw = getSelectedResourceWrapper(path[i]);
191:                            if (rrw == null)
192:                                continue;
193:                            if (rrw != rootNode.getResourceWrapper()) {
194:                                try {
195:                                    deleteResource(rrw);
196:                                } catch (RemoteAccessException ex) {
197:                                    Message.showErrorMessage(this , ex);
198:                                    continue;
199:                                }
200:                                MutableTreeNode node = (MutableTreeNode) path[i]
201:                                        .getLastPathComponent();
202:                                model.removeNodeFromParent(node);
203:                            } else {
204:                                JOptionPane.showMessageDialog(this ,
205:                                        "You can't remove the "
206:                                                + "resource here, please use "
207:                                                + "the resource tree",
208:                                        "Information",
209:                                        JOptionPane.INFORMATION_MESSAGE);
210:                            }
211:                        }
212:                    }
213:                }
214:            }
215:
216:            /**
217:             * The popup menu action listener.
218:             */
219:            ActionListener al = new ActionListener() {
220:                public void actionPerformed(ActionEvent evt) {
221:                    String command = evt.getActionCommand();
222:                    if (command.equals("del")) {
223:                        deleteSelectedResources();
224:                    } else if (command.equals("add")) {
225:                        addResourceToSelectedContainer();
226:                    } else if (command.equals("info")) {
227:                        showReferenceDocumentation();
228:                    }
229:                }
230:            };
231:
232:            /**
233:             * Get the popup menu relative to the selected frame.
234:             * @param rrw the wrapper of the resource
235:             * @return a JPopupMenu instance
236:             */
237:            protected JPopupMenu getPopupMenu(RemoteResourceWrapper rrw) {
238:                boolean frame = rrw.getResource().isFrame();
239:
240:                JPopupMenu popupMenu = new JPopupMenu();
241:
242:                JMenuItem menuItem = new JMenuItem("Add frame", Icons.addIcon);
243:                menuItem.addActionListener(al);
244:                menuItem.setActionCommand("add");
245:                popupMenu.add(menuItem);
246:
247:                if (frame) {
248:                    menuItem = new JMenuItem("Delete frame", Icons.deleteIcon);
249:                    menuItem.addActionListener(al);
250:                    menuItem.setActionCommand("del");
251:                    popupMenu.add(menuItem);
252:                }
253:
254:                popupMenu.addSeparator();
255:
256:                menuItem = new JMenuItem("Info", Icons.infoIcon);
257:                menuItem.addActionListener(al);
258:                menuItem.setActionCommand("info");
259:                popupMenu.add(menuItem);
260:
261:                return popupMenu;
262:            }
263:
264:            /**
265:             * A double click occured on the node with the given path.
266:             * @param path The path where the double click occured.
267:             */
268:            protected void doubleClick(TreePath path) {
269:                //nothing
270:            }
271:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.