Source Code Cross Referenced for PortletSelectionEditor.java in  » Portal » Open-Portal » com » sun » portal » ffj » properties » 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 » Portal » Open Portal » com.sun.portal.ffj.properties 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
003:         * PROPRIETARY/CONFIDENTIAL. Use of this product is subject to license terms.
004:         */
005:
006:        package com.sun.portal.ffj.properties;
007:
008:        import java.util.Vector;
009:        import java.util.Iterator;
010:        import java.util.StringTokenizer;
011:
012:        import java.beans.PropertyEditor;
013:
014:        import org.openide.util.NbBundle;
015:
016:        import com.sun.portal.ffj.util.PSConstants;
017:        import com.sun.portal.ffj.util.PortletList;
018:
019:        import javax.swing.event.ListSelectionListener;
020:        import javax.swing.event.ListSelectionEvent;
021:
022:        public class PortletSelectionEditor extends javax.swing.JPanel
023:                implements  PropertyEditor, PSConstants {
024:
025:            public PortletSelectionEditor(PortletList list) {
026:                initComponents();
027:
028:                m_PList = list;
029:                m_ClassNames = new Vector();
030:
031:                m_Label.setDisplayedMnemonic(NbBundle.getMessage(
032:                        PortletSelectionEditor.class,
033:                        "PortletSelectionEditor.Label").charAt(0)); // NOI18N
034:                getAccessibleContext().setAccessibleDescription(
035:                        m_Prompt.getText());
036:                m_PortletSelections
037:                        .getAccessibleContext()
038:                        .setAccessibleDescription(
039:                                NbBundle.getMessage(
040:                                        PortletSelectionEditor.class,
041:                                        "ACSD_CTL_PortletSelectionEditor.List")); // NOI18N
042:                m_UseAll.getAccessibleContext().setAccessibleDescription(
043:                        NbBundle.getMessage(PortletSelectionEditor.class,
044:                                "ACSD_CTL_PortletSelectionEditor.Checkbox")); // NOI18N
045:
046:                // default to "all"
047:
048:                m_Value = ALL_PORTLETS;
049:                m_PortletSelections.getSelectionModel()
050:                        .addListSelectionListener(new PSelListener());
051:                setDisplay();
052:            }
053:
054:            // PropertyEditor implementation
055:
056:            public String getAsText() {
057:                return m_Value;
058:            }
059:
060:            public java.awt.Component getCustomEditor() {
061:                return this ;
062:            }
063:
064:            public String getJavaInitializationString() {
065:                return null;
066:            }
067:
068:            public String[] getTags() {
069:                return null;
070:            }
071:
072:            public Object getValue() {
073:                return m_Value;
074:            }
075:
076:            public boolean isPaintable() {
077:                return false;
078:            }
079:
080:            public void paintValue(java.awt.Graphics graphics,
081:                    java.awt.Rectangle rectangle) {
082:            }
083:
084:            public void setAsText(String str)
085:                    throws java.lang.IllegalArgumentException {
086:                throw new IllegalArgumentException("setAsText is not supported");
087:            }
088:
089:            public void setValue(Object obj) {
090:                m_Value = obj.toString();
091:            }
092:
093:            public boolean supportsCustomEditor() {
094:                return true;
095:            }
096:
097:            /** This method is called from within the constructor to
098:             * initialize the form.
099:             * WARNING: Do NOT modify this code. The content of this method is
100:             * always regenerated by the Form Editor.
101:             */
102:            private void initComponents() {//GEN-BEGIN:initComponents
103:                m_LabelPanel = new javax.swing.JPanel();
104:                m_Prompt = new javax.swing.JTextArea();
105:                m_Label = new javax.swing.JLabel();
106:                m_SubPanel = new javax.swing.JPanel();
107:                m_PLScroller = new javax.swing.JScrollPane();
108:                m_PortletSelections = new javax.swing.JList();
109:                m_UseAll = new javax.swing.JCheckBox();
110:
111:                setLayout(new java.awt.BorderLayout(0, 10));
112:
113:                setBorder(new javax.swing.border.EmptyBorder(
114:                        new java.awt.Insets(10, 10, 0, 10)));
115:                setMinimumSize(new java.awt.Dimension(320, 240));
116:                setPreferredSize(new java.awt.Dimension(320, 240));
117:                addComponentListener(new java.awt.event.ComponentAdapter() {
118:                    public void componentShown(java.awt.event.ComponentEvent evt) {
119:                        formComponentShown(evt);
120:                    }
121:                });
122:
123:                m_LabelPanel.setLayout(new java.awt.GridLayout(0, 1));
124:
125:                m_Prompt.setBackground(new java.awt.Color(204, 204, 204));
126:                m_Prompt.setLineWrap(true);
127:                m_Prompt.setText(java.util.ResourceBundle.getBundle(
128:                        "com/sun/portal/ffj/properties/Bundle").getString(
129:                        "PortletSelectionEditor.Prompt"));
130:                m_Prompt.setWrapStyleWord(true);
131:                m_Prompt.setDisabledTextColor(new java.awt.Color(0, 0, 0));
132:                m_Prompt.setEnabled(false);
133:                m_LabelPanel.add(m_Prompt);
134:
135:                m_Label.setLabelFor(m_PortletSelections);
136:                m_Label.setText(java.util.ResourceBundle.getBundle(
137:                        "com/sun/portal/ffj/properties/Bundle").getString(
138:                        "PortletSelectionEditor.Label"));
139:                m_LabelPanel.add(m_Label);
140:
141:                add(m_LabelPanel, java.awt.BorderLayout.NORTH);
142:
143:                m_SubPanel.setLayout(new java.awt.BorderLayout());
144:
145:                m_PLScroller.setViewportView(m_PortletSelections);
146:
147:                m_SubPanel.add(m_PLScroller, java.awt.BorderLayout.CENTER);
148:
149:                m_UseAll.setText(java.util.ResourceBundle.getBundle(
150:                        "com/sun/portal/ffj/properties/Bundle").getString(
151:                        "PortletSeclectionEditor.UseAll"));
152:                m_UseAll.addActionListener(new java.awt.event.ActionListener() {
153:                    public void actionPerformed(java.awt.event.ActionEvent evt) {
154:                        m_UseAllActionPerformed(evt);
155:                    }
156:                });
157:
158:                m_SubPanel.add(m_UseAll, java.awt.BorderLayout.SOUTH);
159:
160:                add(m_SubPanel, java.awt.BorderLayout.CENTER);
161:
162:            }//GEN-END:initComponents
163:
164:            private void formComponentShown(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_formComponentShown
165:                setDisplay();
166:            }//GEN-LAST:event_formComponentShown
167:
168:            private void m_UseAllActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_UseAllActionPerformed
169:                // Add your handling code here:
170:                setFieldStates();
171:                updateValue();
172:            }//GEN-LAST:event_m_UseAllActionPerformed
173:
174:            private void setFieldStates() {
175:                if (m_UseAll.isSelected()) {
176:                    m_PortletSelections.setEnabled(false);
177:                } else {
178:                    m_PortletSelections.setEnabled(true);
179:                }
180:            }
181:
182:            private void updateValue() {
183:                if (m_UseAll.isSelected()) {
184:                    m_Value = ALL_PORTLETS;
185:                } else {
186:                    int sel[] = m_PortletSelections.getSelectedIndices();
187:                    StringBuffer buf = new StringBuffer();
188:                    String pfx = "";
189:                    for (int i = 0; i < sel.length; ++i) {
190:                        buf.append(pfx);
191:                        pfx = PORTLET_LIST_DELIM;
192:                        buf.append(m_ClassNames.elementAt(sel[i]));
193:                    }
194:                    m_Value = buf.toString();
195:                }
196:            }
197:
198:            private void setDisplay() {
199:
200:                // Fill in list with available portlets.
201:
202:                Vector displaynames = new Vector();
203:                Iterator it = m_PList.portletClasses();
204:                while (it.hasNext()) {
205:                    String cls = (String) it.next();
206:                    String nm = m_PList.portletName(cls);
207:                    m_ClassNames.add(cls);
208:                    displaynames.add(nm + " (" + cls + ")");
209:                }
210:                m_PortletSelections.setListData(displaynames);
211:                m_PortletSelections.clearSelection();
212:
213:                if (m_Value.equals(ALL_PORTLETS)) {
214:                    m_UseAll.setSelected(true);
215:                    m_PortletSelections.setEnabled(false);
216:                } else {
217:                    m_UseAll.setSelected(false);
218:                    m_PortletSelections.setEnabled(true);
219:
220:                    // this looks stupid, but we are likely dealing with short lists.
221:
222:                    StringTokenizer toks = new StringTokenizer(m_Value,
223:                            PORTLET_LIST_DELIM);
224:                    Vector selidx = new Vector();
225:                    while (toks.hasMoreTokens()) {
226:                        String selclass = toks.nextToken();
227:                        for (int i = 0; i < m_ClassNames.size(); ++i) {
228:                            String cls = (String) m_ClassNames.elementAt(i);
229:                            if (cls.equals(selclass)) {
230:                                selidx.add(new Integer(i));
231:                                break;
232:                            }
233:                        }
234:                    }
235:
236:                    int sels[] = new int[selidx.size()];
237:                    for (int i = 0; i < selidx.size(); ++i) {
238:                        Integer io = (Integer) selidx.elementAt(i);
239:                        sels[i] = io.intValue();
240:                    }
241:
242:                    m_PortletSelections.setSelectedIndices(sels);
243:                }
244:            }
245:
246:            // Variables declaration - do not modify//GEN-BEGIN:variables
247:            private javax.swing.JLabel m_Label;
248:            private javax.swing.JPanel m_LabelPanel;
249:            private javax.swing.JScrollPane m_PLScroller;
250:            private javax.swing.JList m_PortletSelections;
251:            private javax.swing.JTextArea m_Prompt;
252:            private javax.swing.JPanel m_SubPanel;
253:            private javax.swing.JCheckBox m_UseAll;
254:            // End of variables declaration//GEN-END:variables
255:
256:            private String m_Value;
257:            private PortletList m_PList;
258:            private Vector m_ClassNames;
259:
260:            private class PSelListener implements  ListSelectionListener {
261:                public void valueChanged(ListSelectionEvent e) {
262:                    updateValue();
263:                }
264:            }
265:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.