Source Code Cross Referenced for FolderSelectorPane.java in  » Mail-Clients » pooka » net » suberic » pooka » gui » propedit » 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 » Mail Clients » pooka » net.suberic.pooka.gui.propedit 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package net.suberic.pooka.gui.propedit;
002:
003:        import net.suberic.util.gui.propedit.*;
004:        import net.suberic.util.VariableBundle;
005:        import net.suberic.pooka.gui.filechooser.*;
006:        import net.suberic.pooka.*;
007:        import javax.swing.*;
008:        import java.awt.event.ActionEvent;
009:        import javax.swing.filechooser.FileSystemView;
010:
011:        /**
012:         * This displays the currently selected folder (if any), along with a 
013:         * button which will bring up a dialog to select another folder.
014:         */
015:
016:        public class FolderSelectorPane extends SwingPropertyEditor {
017:
018:            JLabel label;
019:            JTextField valueDisplay;
020:            JButton inputButton;
021:
022:            /**
023:             * @param propertyName The property to be edited.  
024:             * @param template The property that will define the layout of the 
025:             *                 editor.
026:             * @param manager The PropertyEditorManager that will manage the
027:             *                   changes.
028:             * @param isEnabled Whether or not this editor is enabled by default. 
029:             */
030:            public void configureEditor(String propertyName, String template,
031:                    PropertyEditorManager newManager, boolean isEnabled) {
032:                property = propertyName;
033:                manager = newManager;
034:                editorTemplate = template;
035:                originalValue = manager.getProperty(property, "");
036:
037:                if (debug) {
038:                    System.out.println("property is " + property
039:                            + "; editorTemplate is " + editorTemplate);
040:                }
041:
042:                label = createLabel();
043:
044:                valueDisplay = new JTextField(originalValue);
045:
046:                inputButton = createInputButton();
047:
048:                valueDisplay.setPreferredSize(new java.awt.Dimension(
049:                        150 - inputButton.getPreferredSize().width,
050:                        valueDisplay.getMinimumSize().height));
051:
052:                this .add(label);
053:                labelComponent = label;
054:                JPanel tmpPanel = new JPanel(new java.awt.FlowLayout(
055:                        java.awt.FlowLayout.LEFT, 0, 0));
056:                tmpPanel.add(valueDisplay);
057:                tmpPanel.add(inputButton);
058:                tmpPanel.setPreferredSize(new java.awt.Dimension(150,
059:                        valueDisplay.getMinimumSize().height));
060:                valueComponent = tmpPanel;
061:                //this.add(valueDisplay);
062:                //this.add(inputButton);
063:                this .add(tmpPanel);
064:
065:                this .setEnabled(isEnabled);
066:
067:            }
068:
069:            /**
070:             * Creates a button that will bring up a way to select a folder.
071:             */
072:            public JButton createInputButton() {
073:                if (Pooka.isDebug())
074:                    System.out.println("creating an input button.");
075:                try {
076:                    java.net.URL url = this .getClass().getResource(
077:                            manager.getProperty(
078:                                    "FolderSelectorPane.inputButton.image",
079:                                    "/net/suberic/util/gui/images/More.gif"));
080:                    if (url != null) {
081:                        if (Pooka.isDebug())
082:                            System.out.println("url isn't null.");
083:
084:                        ImageIcon icon = new ImageIcon(url);
085:
086:                        JButton newButton = new JButton(icon);
087:                        if (Pooka.isDebug())
088:                            System.out.println("new button is created.");
089:
090:                        newButton.setPreferredSize(new java.awt.Dimension(icon
091:                                .getIconHeight(), icon.getIconWidth()));
092:                        newButton.addActionListener(new AbstractAction() {
093:                            public void actionPerformed(ActionEvent e) {
094:                                selectNewFolder();
095:                            }
096:                        });
097:
098:                        if (Pooka.isDebug())
099:                            System.out.println("returning button.");
100:
101:                        return newButton;
102:                    }
103:                } catch (java.util.MissingResourceException mre) {
104:                }
105:
106:                if (Pooka.isDebug())
107:                    System.out.println("error - creating a blank button.");
108:
109:                JButton newButton = new JButton();
110:                newButton.addActionListener(new AbstractAction() {
111:                    public void actionPerformed(ActionEvent e) {
112:                        selectNewFolder();
113:                    }
114:                });
115:
116:                return newButton;
117:            }
118:
119:            /**
120:             * This actually brings up a JFileChooser to select a new Folder for 
121:             * the value of the property.
122:             */
123:            public void selectNewFolder() {
124:
125:                FileSystemView mfsv = createFileSystemView();
126:
127:                String defaultRoot = valueDisplay.getText();
128:                if (defaultRoot.equals("")) {
129:                    defaultRoot = "/";
130:                    try {
131:                        String storeName = property.substring(property
132:                                .indexOf('.') + 1, property.indexOf('.',
133:                                property.indexOf('.') + 1));
134:                        StoreInfo si = Pooka.getStoreManager().getStoreInfo(
135:                                storeName);
136:                        if (si != null) {
137:                            defaultRoot = storeName;
138:                        }
139:                    } catch (Exception e) {
140:                    }
141:                } else {
142:
143:                    if (defaultRoot.lastIndexOf('/') > -1) {
144:                        defaultRoot = defaultRoot.substring(0, defaultRoot
145:                                .lastIndexOf('/'));
146:                    }
147:                }
148:
149:                JFileChooser jfc = new JFileChooser(defaultRoot, mfsv);
150:                jfc.setMultiSelectionEnabled(false);
151:                jfc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
152:                // workaround for bug in jdk 1.4
153:                jfc.setCurrentDirectory(mfsv.createFileObject(defaultRoot));
154:
155:                int returnValue = jfc.showDialog(Pooka.getMainPanel(), Pooka
156:                        .getProperty("FolderEditorPane.Select", "Select"));
157:
158:                if (returnValue == JFileChooser.APPROVE_OPTION) {
159:                    java.io.File wrapper = jfc.getSelectedFile();
160:                    valueDisplay.setText(wrapper.getAbsolutePath());
161:                }
162:
163:            }
164:
165:            /**
166:             * Creates the FileSystemView appropriate for this file chooser.  This
167:             * can either be a view of all the stores and their corresponding 
168:             * folders, or just the folders of a single store.  This is determined
169:             * by the 'selectionRoot' subproperty of the edited property's template.
170:             */
171:            public FileSystemView createFileSystemView() {
172:
173:                FileSystemView returnValue = null;
174:                boolean justSubscribed = manager.getProperty(
175:                        editorTemplate + ".onlySubscribed", "true")
176:                        .equalsIgnoreCase("true");
177:
178:                if (manager.getProperty(editorTemplate + ".selectionRoot",
179:                        "allStores").equals("allStores")) {
180:                    if (justSubscribed)
181:                        returnValue = new PookaFileSystemView();
182:                    else
183:                        returnValue = new MailFileSystemView();
184:                } else {
185:                    int prefixSize = manager.getProperty(
186:                            editorTemplate + ".namePrefix", "Store.").length();
187:                    int suffixSize = manager.getProperty(
188:                            editorTemplate + ".nameSuffix", ".trashFolder")
189:                            .length();
190:                    String currentStoreName = property.substring(prefixSize,
191:                            property.length() - suffixSize);
192:                    net.suberic.pooka.StoreInfo currentStore = Pooka
193:                            .getStoreManager().getStoreInfo(currentStoreName);
194:                    if (currentStore != null) {
195:                        if (justSubscribed)
196:                            returnValue = new PookaFileSystemView(currentStore);
197:                        else
198:                            returnValue = new MailFileSystemView(currentStore);
199:                    }
200:                }
201:
202:                return returnValue;
203:            }
204:
205:            //  as defined in net.suberic.util.gui.PropertyEditorUI
206:
207:            public void setValue() {
208:                if (Pooka.isDebug())
209:                    System.out.println("calling fsp.setValue.  isEnabled() = "
210:                            + isEnabled() + "; isChanged() = " + isChanged());
211:                if (isEnabled() && isChanged())
212:                    manager.setProperty(property, (String) valueDisplay
213:                            .getText());
214:            }
215:
216:            public java.util.Properties getValue() {
217:                java.util.Properties retProps = new java.util.Properties();
218:
219:                retProps.setProperty(property, (String) valueDisplay.getText());
220:
221:                return retProps;
222:            }
223:
224:            public void resetDefaultValue() {
225:                valueDisplay.setText(originalValue);
226:            }
227:
228:            public boolean isChanged() {
229:                return (!(originalValue.equals(valueDisplay.getText())));
230:            }
231:
232:            public void setEnabled(boolean newValue) {
233:                if (Pooka.isDebug())
234:                    System.out.println("calling fsp.setEnabled(" + newValue
235:                            + ")");
236:                if (inputButton != null) {
237:                    inputButton.setEnabled(newValue);
238:                }
239:                if (valueDisplay != null) {
240:                    valueDisplay.setEnabled(newValue);
241:                }
242:                if (Pooka.isDebug())
243:                    System.out.println("set enabled to " + newValue);
244:
245:                enabled = newValue;
246:            }
247:
248:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.