Source Code Cross Referenced for AttachmentPanel.java in  » Project-Management » airTODO » org » airtodo » gui » panel_open » 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 » Project Management » airTODO » org.airtodo.gui.panel_open 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.airtodo.gui.panel_open;
002:
003:        import static org.air.framework.gui.box.Gap.small;
004:
005:        import java.awt.Component;
006:        import java.awt.Dialog;
007:        import java.awt.event.ActionEvent;
008:        import java.awt.event.ItemEvent;
009:        import java.awt.event.ItemListener;
010:        import java.util.Map;
011:
012:        import javax.swing.Action;
013:        import javax.swing.Box;
014:        import javax.swing.JFileChooser;
015:        import javax.swing.JTextField;
016:        import javax.swing.SwingUtilities;
017:        import javax.swing.event.DocumentEvent;
018:        import javax.swing.event.DocumentListener;
019:
020:        import org.air.framework.core.GuiUtils;
021:        import org.air.framework.core.Utils;
022:        import org.air.framework.gui.actions.basic.BasicAbstractAction;
023:        import org.air.framework.gui.actions.other.ActionLaunch;
024:        import org.air.framework.gui.box.BxX;
025:        import org.air.framework.gui.box.BxY;
026:        import org.air.framework.gui.dialogs.input.AbstractOpenTabbedPanel;
027:        import org.air.framework.gui.lookup.WidgetComboLookup;
028:        import org.air.framework.gui.widgets.Button;
029:        import org.air.framework.gui.widgets.RequiredLabel;
030:        import org.air.framework.gui.widgets.WidgetTextArea;
031:        import org.air.framework.gui.widgets.WidgetTextField;
032:        import org.air.framework.i18n.NlsColumns;
033:        import org.air.framework.i18n.NlsMessages;
034:        import org.air.framework.properties.Icons;
035:        import org.air.framework.records.Attachments;
036:        import org.air.framework.records.Common;
037:        import org.airtodo.LinkUtils;
038:        import org.airtodo.db.types.AttachmentType;
039:        import org.airtodo.gui.dialog_table.NoteGridNonSelectableDialog;
040:        import org.airtodo.gui_common.actions.other.ActionNotes;
041:        import org.airtodo.gui_common.components.lookup_data.LookupDataAttachment;
042:
043:        public class AttachmentPanel extends AbstractOpenTabbedPanel {
044:            public static enum NLS {
045:                TITLE, //
046:                BUTTON_CHOOSE_FILE, //
047:                LABEL_RESOURCE
048:            }
049:
050:            private static final String NLS_TITLE = NlsMessages
051:                    .getString(NLS.TITLE);
052:            private static final String NLS_BUTTON_CHOOSE_FILE = NlsMessages
053:                    .getString(NLS.BUTTON_CHOOSE_FILE);
054:            private static final String NLS_LABEL_RESOURCE = NlsMessages
055:                    .getString(NLS.LABEL_RESOURCE);
056:            //
057:            private long masterId;
058:            private long attachmentId;
059:
060:            public AttachmentPanel() {
061:                BxY bxY = new BxY(NLS_TITLE);
062:                getTabGeneral().add(bxY);
063:                bxY.add(getWidgetTextFieldName());
064:                bxY.add(getWidgetAttachmentCombo());
065:                bxY.add(new BxX(new RequiredLabel(NLS_LABEL_RESOURCE + ":",
066:                        true), Box.createHorizontalGlue()));
067:                bxY.add(new BxX(getWidgetTextFieldAddress(), small(),
068:                        new Button(getActionBrowse())));
069:                bxY.add(small());
070:                bxY.add(new BxX(new Button(getActionLaunch()), Box
071:                        .createHorizontalGlue()));
072:                getTabGeneral().add(small());
073:                getTabGeneral().add(getWidgetTextAreaComment());
074:                //
075:                getButtonPanel().addAll(getButtonNotes(),
076:                        Box.createHorizontalGlue());
077:
078:                endbleDisableBrowseButton();
079:            }
080:
081:            //
082:            //	getButtonNotes
083:            //
084:            private Button buttonNotes;
085:
086:            private Component getButtonNotes() {
087:                if (buttonNotes == null) {
088:                    buttonNotes = new Button(new ActionNotes() {
089:                        public void actionPerformed(ActionEvent e) {
090:                            Dialog owner = (Dialog) SwingUtilities
091:                                    .windowForComponent(getOwner());
092:                            NoteGridNonSelectableDialog dialog = new NoteGridNonSelectableDialog(
093:                                    owner, getWidgetTextFieldName().getText());
094:                            dialog.setMasterId(attachmentId);
095:                            dialog.loadAndSelect();
096:                            dialog.setVisible(true);
097:                        }
098:                    });
099:                }
100:                return buttonNotes;
101:            }
102:
103:            //
104:            //	getWidgetAttachmentCombo
105:            //
106:            private WidgetComboLookup widgetAttachmentCombo;
107:
108:            private WidgetComboLookup getWidgetAttachmentCombo() {
109:                if (widgetAttachmentCombo == null) {
110:                    widgetAttachmentCombo = new WidgetComboLookup(
111:                            new LookupDataAttachment());
112:                    widgetAttachmentCombo.getComboBox().addItemListener(
113:                            new ItemListener() {
114:                                public void itemStateChanged(ItemEvent e) {
115:                                    endbleDisableBrowseButton();
116:                                }
117:                            });
118:                }
119:                return widgetAttachmentCombo;
120:            }
121:
122:            private void endbleDisableBrowseButton() {
123:                int posFile = LookupDataAttachment.NLS.ATTACHMENT_TYPE_FILE
124:                        .ordinal();
125:                AttachmentType attachmentType = (AttachmentType) getWidgetAttachmentCombo()
126:                        .getSelectedItem();
127:                if (attachmentType != null) {
128:                    int pos = (attachmentType).getValue();
129:                    getActionBrowse().setEnabled(pos == posFile);
130:                }
131:            }
132:
133:            //
134:            //	getWidgetTextFieldName
135:            //
136:            private WidgetTextField widgetTextFieldName;
137:
138:            private WidgetTextField getWidgetTextFieldName() {
139:                if (widgetTextFieldName == null)
140:                    widgetTextFieldName = new WidgetTextField(
141:                            Attachments.DESCRIPTION);
142:                return widgetTextFieldName;
143:            }
144:
145:            //
146:            //	getWidgetTextFieldAddress
147:            //
148:            private JTextField widgetTextFieldAddress;
149:
150:            private JTextField getWidgetTextFieldAddress() {
151:                if (widgetTextFieldAddress == null) {
152:                    widgetTextFieldAddress = new JTextField();
153:                    widgetTextFieldAddress.getDocument().addDocumentListener(
154:                            new DocumentListener() {
155:                                public void changedUpdate(DocumentEvent e) {
156:                                    // Nothing to do
157:                                }
158:
159:                                public void removeUpdate(DocumentEvent e) {
160:                                    textUpdateEvent(e);
161:                                }
162:
163:                                public void insertUpdate(DocumentEvent e) {
164:                                    textUpdateEvent(e);
165:                                }
166:
167:                                private void textUpdateEvent(DocumentEvent e) {
168:                                    getActionLaunch().setEnabled(
169:                                            e.getDocument().getLength() > 0);
170:                                }
171:                            });
172:                }
173:                return widgetTextFieldAddress;
174:            }
175:
176:            //
177:            //	getWidgetTextAreaComment
178:            //
179:            private WidgetTextArea widgetTextAreaComment;
180:
181:            private WidgetTextArea getWidgetTextAreaComment() {
182:                if (widgetTextAreaComment == null)
183:                    widgetTextAreaComment = new WidgetTextArea(
184:                            Attachments.COMMENT);
185:                return widgetTextAreaComment;
186:            }
187:
188:            private BasicAbstractAction actionBrowse;
189:
190:            private Action getActionBrowse() {
191:                if (actionBrowse == null)
192:                    actionBrowse = new BasicAbstractAction() {
193:                        public void actionPerformed(ActionEvent e) {
194:                            JFileChooser fileChooser = new JFileChooser();
195:                            int returnVal = fileChooser
196:                                    .showOpenDialog(AttachmentPanel.this );
197:                            if (returnVal == JFileChooser.APPROVE_OPTION)
198:                                getWidgetTextFieldAddress().setText(
199:                                        fileChooser.getSelectedFile()
200:                                                .getAbsolutePath());
201:                        }
202:                    };
203:                actionBrowse.setName(NLS_BUTTON_CHOOSE_FILE
204:                        + BasicAbstractAction.ELLIPSIS);
205:                actionBrowse.setSmallIcon(Icons.FILE_CHOOSER);
206:                actionBrowse.setEnabled(false);
207:                return actionBrowse;
208:            }
209:
210:            private BasicAbstractAction actionLaunch;
211:
212:            private Action getActionLaunch() {
213:                if (actionLaunch == null)
214:                    actionLaunch = new ActionLaunch() {
215:                        public void actionPerformed(ActionEvent e) {
216:                            Dialog owner = (Dialog) SwingUtilities
217:                                    .windowForComponent(AttachmentPanel.this );
218:                            String text = getWidgetTextFieldAddress().getText();
219:                            AttachmentType type = (AttachmentType) getWidgetAttachmentCombo()
220:                                    .getSelectedItem();
221:                            if (text != null)
222:                                LinkUtils.launch(owner, type, text);
223:                        }
224:                    };
225:                return actionLaunch;
226:            }
227:
228:            //
229:            //	isFormValid
230:            //
231:            @Override
232:            public boolean isFormValid() {
233:                boolean b = getWidgetTextFieldAddress().getText().trim()
234:                        .length() > 0;
235:                if (!b) {
236:                    Dialog owner = (Dialog) SwingUtilities
237:                            .windowForComponent(this );
238:                    GuiUtils.showErrorRequiredMessage(owner, NlsColumns
239:                            .getText(Attachments.NAME));
240:                }
241:                return b;
242:            }
243:
244:            @Override
245:            public void fromGui(Map map) {
246:                map.put(Utils.getColumnIdentifier(Attachments.MASTER_ID),
247:                        masterId);
248:                getWidgetAttachmentCombo().fromGui(map); // !!!!!!!!!!!!!!!!!!!!!!!!! error
249:                getWidgetTextFieldName().fromGui(map);
250:                String text = getWidgetTextFieldAddress().getText();
251:                map.put(Utils.getColumnIdentifier(Attachments.NAME), text);
252:                getWidgetTextAreaComment().fromGui(map);
253:            }
254:
255:            @Override
256:            public void toGui(Map map) {
257:                masterId = (Long) map.get(Utils
258:                        .getColumnIdentifier(Attachments.MASTER_ID));
259:                getWidgetAttachmentCombo().toGui(map);
260:                getWidgetTextFieldName().toGui(map);
261:                getWidgetTextFieldAddress().setText(
262:                        (String) map.get(Utils
263:                                .getColumnIdentifier(Attachments.NAME)));
264:                getWidgetTextAreaComment().toGui(map);
265:                //
266:                attachmentId = (Long) map.get(Utils
267:                        .getColumnIdentifier(Common.ID));
268:            }
269:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.