Source Code Cross Referenced for SwitchToDisplayableElement.java in  » IDE-Netbeans » vmd.analyzer » org » netbeans » modules » vmd » midp » propertyeditors » eventhandler » 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 » IDE Netbeans » vmd.analyzer » org.netbeans.modules.vmd.midp.propertyeditors.eventhandler 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003:         *
004:         * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005:         *
006:         * The contents of this file are subject to the terms of either the GNU
007:         * General Public License Version 2 only ("GPL") or the Common
008:         * Development and Distribution License("CDDL") (collectively, the
009:         * "License"). You may not use this file except in compliance with the
010:         * License. You can obtain a copy of the License at
011:         * http://www.netbeans.org/cddl-gplv2.html
012:         * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013:         * specific language governing permissions and limitations under the
014:         * License.  When distributing the software, include this License Header
015:         * Notice in each file and include the License file at
016:         * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
017:         * particular file as subject to the "Classpath" exception as provided
018:         * by Sun in the GPL Version 2 section of the License file that
019:         * accompanied this code. If applicable, add the following below the
020:         * License Header, with the fields enclosed by brackets [] replaced by
021:         * your own identifying information:
022:         * "Portions Copyrighted [year] [name of copyright owner]"
023:         *
024:         * Contributor(s):
025:         *
026:         * The Original Software is NetBeans. The Initial Developer of the Original
027:         * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028:         * Microsystems, Inc. All Rights Reserved.
029:         *
030:         * If you wish your version of this file to be governed by only the CDDL
031:         * or only the GPL Version 2, indicate your decision by adding
032:         * "[Contributor] elects to include this software in this distribution
033:         * under the [CDDL or GPL Version 2] license." If you do not indicate a
034:         * single choice of license, a recipient has the option to distribute
035:         * your version of this file under either the CDDL, the GPL Version 2 or
036:         * to extend the choice of license to its licensees as provided above.
037:         * However, if you add GPL Version 2 code and therefore, elected the GPL
038:         * Version 2 license, then the option applies only if the new code is
039:         * made subject to such option by the copyright holder.
040:         */
041:
042:        package org.netbeans.modules.vmd.midp.propertyeditors.eventhandler;
043:
044:        import java.util.Collection;
045:        import java.util.Collections;
046:        import org.netbeans.modules.vmd.api.model.DesignComponent;
047:        import org.netbeans.modules.vmd.api.model.PropertyValue;
048:        import org.netbeans.modules.vmd.api.model.TypeID;
049:        import org.netbeans.modules.vmd.midp.components.ListCellRenderer;
050:        import org.netbeans.modules.vmd.midp.components.MidpDocumentSupport;
051:        import org.netbeans.modules.vmd.midp.components.displayables.AlertCD;
052:        import org.netbeans.modules.vmd.midp.components.handlers.SwitchDisplayableEventHandlerCD;
053:        import org.netbeans.modules.vmd.midp.propertyeditors.element.PropertyEditorElementFactory;
054:        import org.netbeans.modules.vmd.midp.propertyeditors.element.PropertyEditorEventHandlerElement;
055:        import org.openide.awt.Mnemonics;
056:        import org.openide.util.NbBundle;
057:
058:        import javax.swing.*;
059:        import java.util.List;
060:
061:        /**
062:         *
063:         * @author Anton Chechel
064:         */
065:        public class SwitchToDisplayableElement extends JPanel implements 
066:                PropertyEditorEventHandlerElement {
067:            private DefaultComboBoxModel displayablesModel;
068:            private DefaultComboBoxModel displayablesWithoutAlertModel;
069:            private JRadioButton radioButton;
070:            private ListCellRenderer cellRenderer;
071:
072:            private SwitchToDisplayableElement() {
073:                radioButton = new JRadioButton();
074:                Mnemonics.setLocalizedText(radioButton, NbBundle
075:                        .getMessage(SwitchToDisplayableElement.class,
076:                                "LBL_SWITCH_TO_DISPL")); // NOI18N
077:                displayablesModel = new DefaultComboBoxModel();
078:                displayablesWithoutAlertModel = new DefaultComboBoxModel();
079:                cellRenderer = new ListCellRenderer();
080:
081:                initComponents();
082:            }
083:
084:            public void setTextForPropertyValue(String text) {
085:            }
086:
087:            public JComponent getCustomEditorComponent() {
088:                return this ;
089:            }
090:
091:            public JRadioButton getRadioButton() {
092:                return radioButton;
093:            }
094:
095:            public boolean isInitiallySelected() {
096:                return false;
097:            }
098:
099:            public boolean isVerticallyResizable() {
100:                return false;
101:            }
102:
103:            public void createEventHandler(DesignComponent eventSource) {
104:                if (!radioButton.isSelected()) {
105:                    return;
106:                }
107:                DesignComponent displayable = (DesignComponent) displayablesModel
108:                        .getSelectedItem();
109:                DesignComponent displayable2 = (DesignComponent) displayablesWithoutAlertsComboBox
110:                        .getSelectedItem();
111:                if (thenGoToCheckBox.isSelected()) {
112:                    DesignComponent eventHandler = MidpDocumentSupport
113:                            .updateEventHandlerFromTarget(eventSource,
114:                                    displayable2);
115:                    MidpDocumentSupport.updateEventHandlerWithAlert(
116:                            eventHandler, displayable);
117:                } else {
118:                    DesignComponent eventHandler = MidpDocumentSupport
119:                            .updateEventHandlerFromTarget(eventSource,
120:                                    displayable);
121:                    MidpDocumentSupport.updateSwitchDisplayableEventHandler(
122:                            eventHandler, null, displayable);
123:                }
124:            }
125:
126:            public void updateModel(List<DesignComponent> components,
127:                    int modelType) {
128:                if (modelType == MODEL_TYPE_DISPLAYABLES) {
129:                    displayablesModel.removeAllElements();
130:                    for (DesignComponent component : components) {
131:                        displayablesModel.addElement(component);
132:                    }
133:                }
134:
135:                if (modelType == MODEL_TYPE_DISPLAYABLES_WITHOUT_ALERTS) {
136:                    displayablesWithoutAlertModel.removeAllElements();
137:                    for (DesignComponent component : components) {
138:                        displayablesWithoutAlertModel.addElement(component);
139:                    }
140:                }
141:            }
142:
143:            public String getTextForPropertyValue() {
144:                return null;
145:            }
146:
147:            public void updateState(PropertyValue value) {
148:                if (value != null) {
149:                    DesignComponent eventHandler = value.getComponent();
150:                    if (SwitchDisplayableEventHandlerCD.TYPEID
151:                            .equals(eventHandler.getType())) {
152:                        radioButton.setSelected(true);
153:
154:                        DesignComponent displayable = eventHandler
155:                                .readProperty(
156:                                        SwitchDisplayableEventHandlerCD.PROP_DISPLAYABLE)
157:                                .getComponent();
158:                        DesignComponent displayable2 = eventHandler
159:                                .readProperty(
160:                                        SwitchDisplayableEventHandlerCD.PROP_ALERT)
161:                                .getComponent();
162:                        if (displayable2 != null) {
163:                            thenGoToCheckBox.setEnabled(true);
164:                            displayablesWithoutAlertsComboBox.setEnabled(true);
165:                            thenGoToCheckBox.setSelected(true);
166:                            displayablesComboBox.setSelectedItem(displayable2);
167:                            displayablesWithoutAlertsComboBox
168:                                    .setSelectedItem(displayable);
169:                        } else {
170:                            displayablesComboBox.setSelectedItem(displayable);
171:                            clearAlertCheckBox();
172:                        }
173:                    } else {
174:                        clearAlertCheckBox();
175:                    }
176:                } else {
177:                    clearAlertCheckBox();
178:                }
179:            }
180:
181:            private void clearAlertCheckBox() {
182:                thenGoToCheckBox.setSelected(false);
183:                thenGoToCheckBox.setEnabled(false);
184:                displayablesWithoutAlertsComboBox.setEnabled(false);
185:            }
186:
187:            public void setElementEnabled(boolean enabled) {
188:            }
189:
190:            public Collection<TypeID> getTypes() {
191:                return Collections
192:                        .singleton(SwitchDisplayableEventHandlerCD.TYPEID);
193:            }
194:
195:            public static class SwitchToDisplayableElementFactory implements 
196:                    PropertyEditorElementFactory {
197:                public PropertyEditorEventHandlerElement createElement() {
198:                    return new SwitchToDisplayableElement();
199:                }
200:            }
201:
202:            /** This method is called from within the constructor to
203:             * initialize the form.
204:             * WARNING: Do NOT modify this code. The content of this method is
205:             * always regenerated by the Form Editor.
206:             */
207:            // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
208:            private void initComponents() {
209:
210:                displayablesComboBox = new javax.swing.JComboBox();
211:                thenGoToCheckBox = new javax.swing.JCheckBox();
212:                displayablesWithoutAlertsComboBox = new javax.swing.JComboBox();
213:
214:                displayablesComboBox.setModel(displayablesModel);
215:                displayablesComboBox.setRenderer(cellRenderer);
216:                displayablesComboBox
217:                        .addActionListener(new java.awt.event.ActionListener() {
218:                            public void actionPerformed(
219:                                    java.awt.event.ActionEvent evt) {
220:                                displayablesComboBoxActionPerformed(evt);
221:                            }
222:                        });
223:
224:                org.openide.awt.Mnemonics.setLocalizedText(thenGoToCheckBox,
225:                        org.openide.util.NbBundle.getMessage(
226:                                SwitchToDisplayableElement.class,
227:                                "LBL_THROUGH_ALERT")); // NOI18N
228:                thenGoToCheckBox.setBorder(javax.swing.BorderFactory
229:                        .createEmptyBorder(0, 0, 0, 0));
230:                thenGoToCheckBox.setEnabled(false);
231:                thenGoToCheckBox.setMargin(new java.awt.Insets(0, 0, 0, 0));
232:                thenGoToCheckBox
233:                        .addActionListener(new java.awt.event.ActionListener() {
234:                            public void actionPerformed(
235:                                    java.awt.event.ActionEvent evt) {
236:                                thenGoToCheckBoxActionPerformed(evt);
237:                            }
238:                        });
239:
240:                displayablesWithoutAlertsComboBox
241:                        .setModel(displayablesWithoutAlertModel);
242:                displayablesWithoutAlertsComboBox.setEnabled(false);
243:                displayablesWithoutAlertsComboBox.setRenderer(cellRenderer);
244:
245:                org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(
246:                        this );
247:                this .setLayout(layout);
248:                layout.setHorizontalGroup(layout.createParallelGroup(
249:                        org.jdesktop.layout.GroupLayout.LEADING).add(
250:                        layout.createSequentialGroup().add(thenGoToCheckBox)
251:                                .addContainerGap()).add(
252:                        displayablesWithoutAlertsComboBox, 0, 300,
253:                        Short.MAX_VALUE).add(displayablesComboBox, 0, 300,
254:                        Short.MAX_VALUE));
255:                layout
256:                        .setVerticalGroup(layout
257:                                .createParallelGroup(
258:                                        org.jdesktop.layout.GroupLayout.LEADING)
259:                                .add(
260:                                        layout
261:                                                .createSequentialGroup()
262:                                                .add(
263:                                                        displayablesComboBox,
264:                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
265:                                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
266:                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
267:                                                .addPreferredGap(
268:                                                        org.jdesktop.layout.LayoutStyle.RELATED)
269:                                                .add(thenGoToCheckBox)
270:                                                .addPreferredGap(
271:                                                        org.jdesktop.layout.LayoutStyle.RELATED)
272:                                                .add(
273:                                                        displayablesWithoutAlertsComboBox,
274:                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
275:                                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
276:                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)));
277:            }// </editor-fold>//GEN-END:initComponents
278:
279:            private void displayablesComboBoxActionPerformed(
280:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_displayablesComboBoxActionPerformed
281:                DesignComponent component = (DesignComponent) displayablesComboBox
282:                        .getSelectedItem();
283:                if (component == null) {
284:                    return;
285:                }
286:                radioButton.setSelected(true);
287:                displayablesWithoutAlertsComboBox.setEnabled(AlertCD.TYPEID
288:                        .equals(component.getType()));
289:                thenGoToCheckBox.setEnabled(AlertCD.TYPEID.equals(component
290:                        .getType()));
291:            }//GEN-LAST:event_displayablesComboBoxActionPerformed
292:
293:            private void thenGoToCheckBoxActionPerformed(
294:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_thenGoToCheckBoxActionPerformed
295:                displayablesWithoutAlertsComboBox.setEnabled(thenGoToCheckBox
296:                        .isSelected());
297:            }//GEN-LAST:event_thenGoToCheckBoxActionPerformed
298:
299:            // Variables declaration - do not modify//GEN-BEGIN:variables
300:            private javax.swing.JComboBox displayablesComboBox;
301:            private javax.swing.JComboBox displayablesWithoutAlertsComboBox;
302:            private javax.swing.JCheckBox thenGoToCheckBox;
303:            // End of variables declaration//GEN-END:variables
304:        }
w_ww___.__j__a__v__a2__s__._c___om___ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.