Source Code Cross Referenced for AddResourcePanel.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:        // AddResourcePanel.java
002:        // $Id: AddResourcePanel.java,v 1.5 2000/08/16 21:37:30 ylafon Exp $
003:        // (c) COPYRIGHT MIT, INRIA and Keio, 1999.
004:        // Please first read the full copyright statement in file COPYRIGHT.html
005:
006:        package org.w3c.jigadmin.editors;
007:
008:        import javax.swing.JTextField;
009:        import javax.swing.JLabel;
010:        import javax.swing.JButton;
011:        import javax.swing.JPanel;
012:        import javax.swing.BorderFactory;
013:
014:        import java.awt.GridLayout;
015:        import java.awt.GridBagLayout;
016:        import java.awt.GridBagConstraints;
017:        import java.awt.Insets;
018:        import java.awt.event.ActionListener;
019:        import java.awt.event.ActionEvent;
020:
021:        import java.util.Vector;
022:        import java.util.Hashtable;
023:        import java.util.Enumeration;
024:
025:        import org.w3c.jigadmin.RemoteResourceWrapper;
026:        import org.w3c.jigadmin.PropertyManager;
027:        import org.w3c.jigadmin.widgets.EditableStringChoice;
028:
029:        import org.w3c.jigsaw.admin.RemoteResource;
030:        import org.w3c.jigsaw.admin.RemoteAccessException;
031:
032:        import org.w3c.tools.sorter.Sorter;
033:
034:        /**
035:         * A widget used to select a resource class and its identifier.
036:         * @version $Revision: 1.5 $
037:         * @author  Benoît Mahé (bmahe@w3.org)
038:         */
039:        public class AddResourcePanel extends JPanel {
040:
041:            protected boolean ok;
042:
043:            protected EditableStringChoice classSC;
044:
045:            protected JTextField identifierTF;
046:
047:            protected ResourceTreeBrowser browser = null;
048:
049:            /**
050:             * Our internal ActionListener
051:             */
052:            ActionListener al = new ActionListener() {
053:                public void actionPerformed(ActionEvent ae) {
054:                    if (ae.getActionCommand().equals("Ok")
055:                            || ae.getSource().equals(identifierTF)) {
056:                        if (!classSC.getText().equals("")) {
057:                            if (!identifierTF.getText().equals("")) {
058:                                browser.setResourceToAdd(classSC.getText(),
059:                                        identifierTF.getText());
060:                                browser.disposeAddResourcePopup();
061:                                done();
062:                            } else {
063:                                identifierTF.requestFocus();
064:                            }
065:                        } else {
066:                            classSC.requestFocus();
067:                        }
068:                    } else if (ae.getActionCommand().equals("Cancel")) {
069:                        browser.setResourceToAdd(null, null);
070:                        browser.disposeAddResourcePopup();
071:                        done();
072:                    } else if (ae.getSource().equals(classSC)) {
073:                        identifierTF.requestFocus();
074:                    }
075:                }
076:            };
077:
078:            /**
079:             * Get a list of resources that we can add to the container wrapped by
080:             * the given RemoteResourceWrapper.
081:             * @param rrw The RemoteResourceWrapper
082:             * @return a Hashtable instance containing the list of resource that can
083:             * be added to the given RemoteResource.
084:             * @exception RemoteAccessException is some remote error occurs
085:             */
086:            protected Hashtable getResources(RemoteResourceWrapper rrw)
087:                    throws RemoteAccessException {
088:                PropertyManager pm = PropertyManager.getPropertyManager();
089:                RemoteResource rr = rrw.getResource();
090:                if (rr.isIndexersCatalog())
091:                    return pm.getIndexers();
092:                else
093:                    return pm.getResources();
094:            }
095:
096:            /**
097:             * Initialize the StringChoice.
098:             * @param rrw The RemoteResourceWrapper of the container where we are going
099:             * to add a resource.
100:             * @exception RemoteAccessException is some remote error occurs
101:             */
102:            protected void initializeStringChoice(RemoteResourceWrapper rrw)
103:                    throws RemoteAccessException {
104:                classSC = new EditableStringChoice();
105:                Hashtable resources = getResources(rrw);
106:                Enumeration e = (Sorter.sortStringEnumeration(resources.keys()))
107:                        .elements();
108:                Vector cells = new Vector(10);
109:                while (e.hasMoreElements()) {
110:                    String name = (String) e.nextElement();
111:                    ResourceCell cell = new ResourceCell(name,
112:                            (String) resources.get(name));
113:                    cells.addElement(cell);
114:                }
115:
116:                Object items[] = new Object[cells.size()];
117:                cells.copyInto(items);
118:                classSC.initialize(items);
119:                classSC.setRenderer(new ResourceCellRenderer());
120:                classSC.setMaximumRowCount(5);
121:            }
122:
123:            /**
124:             * Build the interface.
125:             * @param rrw The RemoteResourceWrapper of the container where we are going
126:             * to add a resource.
127:             * @param title the title of the panel.
128:             * @exception RemoteAccessException is some remote error occurs
129:             */
130:            protected void build(RemoteResourceWrapper rrw, String title)
131:                    throws RemoteAccessException {
132:                GridBagLayout gbl = new GridBagLayout();
133:                GridBagConstraints gbc = new GridBagConstraints();
134:                GridBagLayout mgbl = new GridBagLayout();
135:                GridBagConstraints mgbc = new GridBagConstraints();
136:                JLabel l;
137:                JButton b;
138:                JPanel p = new JPanel(gbl);
139:
140:                initializeStringChoice(rrw);
141:
142:                identifierTF = new JTextField(25);
143:                identifierTF.addActionListener(al);
144:                identifierTF
145:                        .setBorder(BorderFactory.createLoweredBevelBorder());
146:
147:                gbc.fill = GridBagConstraints.HORIZONTAL;
148:                gbc.weightx = 0;
149:                gbc.weighty = 0;
150:                gbc.insets = new Insets(0, 0, 10, 0);
151:                mgbc.fill = GridBagConstraints.NONE;
152:                mgbc.weightx = 0;
153:                mgbc.weighty = 0;
154:                mgbc.insets = new Insets(0, 10, 16, 5);
155:                setLayout(mgbl);
156:
157:                l = new JLabel("Class name: ", JLabel.RIGHT);
158:                gbc.gridwidth = 1;
159:                gbl.setConstraints(l, gbc);
160:                p.add(l);
161:                gbc.gridwidth = GridBagConstraints.REMAINDER;
162:                gbl.setConstraints(classSC, gbc);
163:                p.add(classSC);
164:
165:                l = new JLabel("Identifier: ", JLabel.RIGHT);
166:                gbc.gridwidth = 1;
167:                gbl.setConstraints(l, gbc);
168:                p.add(l);
169:                gbc.gridwidth = GridBagConstraints.REMAINDER;
170:                gbl.setConstraints(identifierTF, gbc);
171:                p.add(identifierTF);
172:                mgbc.gridwidth = GridBagConstraints.REMAINDER;
173:                mgbl.setConstraints(p, mgbc);
174:                add(p);
175:
176:                // and now the usual button bar
177:                p = new JPanel(new GridLayout(1, 2, 20, 20));
178:                b = new JButton("Ok");
179:                b.addActionListener(al);
180:                p.add(b);
181:                b = new JButton("Cancel");
182:                b.addActionListener(al);
183:                p.add(b);
184:                mgbl.setConstraints(p, mgbc);
185:                add(p);
186:                setBorder(BorderFactory.createTitledBorder(title));
187:            }
188:
189:            /**
190:             * Constructor.
191:             * @param title The widget title
192:             * @param  rrw The RemoteResourceWrapper of the container where we are 
193:             * going to add a resource.
194:             * @param browser the ResourceTreeBrowser
195:             * @exception RemoteAccessException is some remote error occurs
196:             */
197:            protected AddResourcePanel(String title, RemoteResourceWrapper rrw,
198:                    ResourceTreeBrowser browser) throws RemoteAccessException {
199:                this .ok = false;
200:                this .browser = browser;
201:                build(rrw, title);
202:            }
203:
204:            /**
205:             * request the focus for the class combobox.
206:             */
207:            protected void getFocus() {
208:                classSC.requestFocus();
209:            }
210:
211:            /**
212:             * NotifyAll that the resource class and its identifier are selected.
213:             */
214:            protected synchronized void done() {
215:                ok = true;
216:                notifyAll();
217:            }
218:
219:            /**
220:             * Wait until the resource class and its identifier are selected.
221:             */
222:            public synchronized boolean waitForCompletion() {
223:                try {
224:                    wait();
225:                } catch (InterruptedException ex) {
226:                    //nothing to do
227:                }
228:                return ok;
229:            }
230:
231:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.