Source Code Cross Referenced for FramedResourceHelper.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:        // FramedResourceHelper.java
002:        // $Id: FramedResourceHelper.java,v 1.14 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.JPanel;
009:        import javax.swing.JLabel;
010:        import javax.swing.JScrollPane;
011:        import javax.swing.JSplitPane;
012:        import javax.swing.BorderFactory;
013:        import javax.swing.JMenuBar;
014:        import javax.swing.JMenuItem;
015:        import javax.swing.JMenu;
016:        import javax.swing.border.TitledBorder;
017:        import javax.swing.event.TreeSelectionListener;
018:        import javax.swing.event.TreeSelectionEvent;
019:        import javax.swing.tree.TreePath;
020:
021:        import java.awt.Component;
022:        import java.awt.BorderLayout;
023:        import java.awt.Cursor;
024:        import java.awt.GridLayout;
025:        import java.awt.Dimension;
026:        import java.awt.Window;
027:        import java.awt.event.ActionListener;
028:        import java.awt.event.ActionEvent;
029:
030:        import java.util.Properties;
031:
032:        import org.w3c.jigadmin.RemoteResourceWrapper;
033:        import org.w3c.jigadmin.PropertyManager;
034:        import org.w3c.jigadmin.gui.Message;
035:        import org.w3c.jigadmin.widgets.Icons;
036:
037:        import org.w3c.jigsaw.admin.RemoteAccessException;
038:
039:        /**
040:         * The resource editor.
041:         * @version $Revision: 1.14 $
042:         * @author  Benoît Mahé (bmahe@w3.org)
043:         */
044:        public class FramedResourceHelper extends ResourceHelper {
045:
046:            /**
047:             * Our MenuBar.
048:             */
049:            class ResourceMenu extends JMenuBar implements  ActionListener {
050:
051:                private Window parent = null;
052:
053:                final static String CLOSE_AC = "quit";
054:                final static String DEL_AC = "del";
055:                final static String ADD_AC = "add";
056:                final static String DOC_AC = "doc";
057:
058:                public void actionPerformed(ActionEvent evt) {
059:                    String command = evt.getActionCommand();
060:                    if (command.equals(CLOSE_AC)) {
061:                        parent.dispose();
062:                    } else if ((command.equals(DOC_AC))
063:                            && (selected_rrw != null)) {
064:                        try {
065:                            String url = (String) selected_rrw.getResource()
066:                                    .getValue("help-url");
067:                            showReference(url);
068:                        } catch (RemoteAccessException ex) {
069:                            ex.printStackTrace();
070:                        }
071:                    } else if ((command.equals(DEL_AC))
072:                            && (selected_rrw != null)) {
073:                        browser.deleteSelectedResources();
074:                    } else if ((command.equals(ADD_AC))
075:                            && (selected_rrw != null)) {
076:                        browser.addResourceToSelectedContainer();
077:                    }
078:                }
079:
080:                protected void showReference(String url) {
081:                    try {
082:                        MiniBrowser.showDocumentationURL(url,
083:                                "Reference documentation");
084:                    } catch (Exception ex) {
085:                        Message.showErrorMessage(this , ex);
086:                    }
087:                }
088:
089:                ResourceMenu(Window parent) {
090:                    super ();
091:                    this .parent = parent;
092:                    JMenu resource = new JMenu("Resource");
093:                    add(resource);
094:
095:                    JMenuItem add = new JMenuItem(
096:                            "Add frame to selected resource/frame",
097:                            Icons.addIcon);
098:                    add.setActionCommand(ADD_AC);
099:                    add.addActionListener(this );
100:                    resource.add(add);
101:
102:                    JMenuItem del = new JMenuItem("Delete selected frame(s)",
103:                            Icons.deleteIcon);
104:                    del.setActionCommand(DEL_AC);
105:                    del.addActionListener(this );
106:                    resource.add(del);
107:
108:                    resource.addSeparator();
109:
110:                    JMenuItem quit = new JMenuItem("Close Resource window",
111:                            Icons.closeIcon);
112:                    quit.setActionCommand(CLOSE_AC);
113:                    quit.addActionListener(this );
114:                    resource.add(quit);
115:
116:                    JMenu help = new JMenu("Help");
117:                    //setHelpMenu not yet implemented (FIXME)
118:                    add(help);
119:                    JMenuItem ref = new JMenuItem(
120:                            "Show reference documentation", Icons.infoIcon);
121:                    ref.setActionCommand(DOC_AC);
122:                    ref.addActionListener(this );
123:                    help.add(ref);
124:                }
125:
126:            }
127:
128:            protected String name = null;
129:            protected JPanel comp = null;
130:            protected JPanel attrs = null;
131:            protected RemoteResourceWrapper rrw = null;
132:            protected RemoteResourceWrapper selected_rrw = null;
133:            protected FrameBrowser browser = null;
134:
135:            /**
136:             * Our internal TreeSelectionListener
137:             */
138:            TreeSelectionListener tsl = new TreeSelectionListener() {
139:                RemoteResourceWrapper current_rrw = null;
140:
141:                public void valueChanged(TreeSelectionEvent e) {
142:                    if (e.isAddedPath()) {
143:                        if (!browser.isDragging()) {
144:                            RemoteFrameWrapperNode node = (RemoteFrameWrapperNode) e
145:                                    .getPath().getLastPathComponent();
146:                            RemoteResourceWrapper rrw = node
147:                                    .getResourceWrapper();
148:                            current_rrw = rrw;
149:                            Thread updater = new Thread() {
150:                                public void run() {
151:                                    updateAttrs(current_rrw);
152:                                }
153:                            };
154:                            updater.start();
155:                            //updateAttrs(rrw);
156:                        } else {
157:                            attrs.invalidate();
158:                            attrs.removeAll();
159:                            attrs.add(new JLabel(" ", JLabel.CENTER));
160:                            attrs.validate();
161:                        }
162:                    } else {
163:                        selected_rrw = null;
164:                        attrs.invalidate();
165:                        attrs.removeAll();
166:                        attrs
167:                                .add(new JLabel("no frame selected",
168:                                        JLabel.CENTER));
169:                        attrs.validate();
170:                    }
171:                }
172:            };
173:
174:            /**
175:             * Get the helper title.
176:             * @return a String
177:             */
178:            public String getTitle() {
179:                return "Frames";
180:            }
181:
182:            /**
183:             * Get the heper Component
184:             * @return a Component
185:             */
186:            public Component getComponent() {
187:                return comp;
188:            }
189:
190:            /**
191:             * tells if the edited resource in the helper has changed
192:             * @return <strong>true</strong> if the values changed.
193:             * to get more informations about what has changed, you can use the 
194:             * three methods below.
195:             */
196:            public boolean hasChanged() {
197:                return false;
198:            }
199:
200:            /**
201:             * set the current resource to be the original resource (ie: the
202:             * hasChanged() method must return <strong>false</false> now.
203:             * to do a "fine tuned" reset, use one of the three following method.
204:             */
205:            public void clearChanged() {
206:
207:            }
208:
209:            /**
210:             * commit the changes (if any)
211:             * @exception RemoteAccessException if a remote access error occurs.
212:             */
213:            public void commitChanges() throws RemoteAccessException {
214:
215:            }
216:
217:            /**
218:             * undo the not-yet-commited changes
219:             */
220:            public void resetChanges() {
221:
222:            }
223:
224:            /**
225:             * Update the AttributesHelper
226:             * @param rrw the RemoteResourceWrapper of the RemoteReource to edit.
227:             */
228:            protected void updateAttrs(RemoteResourceWrapper rrw) {
229:                selected_rrw = rrw;
230:                attrs.invalidate();
231:                attrs.removeAll();
232:                AttributesHelper helper = new AttributesHelper();
233:                try {
234:                    PropertyManager pm = PropertyManager.getPropertyManager();
235:                    Properties props = pm.getEditorProperties(rrw);
236:                    helper.initialize(rrw, props);
237:                    attrs.add(helper.getComponent());
238:                } catch (RemoteAccessException ex) {
239:                    ex.printStackTrace();
240:                }
241:                attrs.validate();
242:            }
243:
244:            /**
245:             * initialize the helper
246:             * @param r the ResourceWrapper containing the Resource edited with 
247:             * this helper
248:             * @param p some Properties, used to fine-tune the helper
249:             * @exception RemoteAccessException if a remote access error occurs.
250:             */
251:            public void initialize(org.w3c.jigadm.RemoteResourceWrapper rw,
252:                    Properties p) throws RemoteAccessException {
253:                boolean framed = false;
254:                rrw = (RemoteResourceWrapper) rw;
255:                try {
256:                    name = (String) rrw.getResource().getValue("identifier");
257:                    framed = rrw.getResource().isFramed();
258:                } catch (RemoteAccessException ex) {
259:                    Message.showErrorMessage(rrw, ex);
260:                }
261:                if (name == null) {
262:                    comp = new JPanel();
263:                    return;
264:                }
265:                build(framed);
266:            }
267:
268:            /**
269:             * Get the dedicated MenuBar
270:             * @param parent the Window parent.
271:             */
272:            public JMenuBar getMenuBar(Window parent) {
273:                return new ResourceMenu(parent);
274:            }
275:
276:            /**
277:             * Build the interface
278:             * @param framed is the resource a FramedResource or not?
279:             */
280:            protected void build(boolean framed) {
281:                comp = new JPanel(new GridLayout(1, 1));
282:                attrs = new JPanel(new GridLayout(1, 1));
283:                attrs.setBorder(BorderFactory.createTitledBorder("Attributes"));
284:
285:                if (framed) {
286:                    browser = FrameBrowser.getFrameBrowser(rrw, name);
287:                    browser.addTreeSelectionListener(this .tsl);
288:                    browser.setSelectionRow(0);
289:                    browser.setBorder(BorderFactory
290:                            .createTitledBorder("Frames"));
291:                    browser.setSize(new Dimension(30, 30));
292:                    JScrollPane scroll = new JScrollPane(browser);
293:                    JSplitPane split = new JSplitPane(
294:                            JSplitPane.VERTICAL_SPLIT, true, scroll, attrs);
295:                    split.setDividerLocation(100);
296:                    comp.add(split);
297:                } else {
298:                    comp.add(attrs);
299:                    updateAttrs(rrw);
300:                }
301:            }
302:
303:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.