Source Code Cross Referenced for SelectTemplatePanel.java in  » Blogger-System » thingamablog » net » sf » thingamablog » gui » app » 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 » Blogger System » thingamablog » net.sf.thingamablog.gui.app 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package net.sf.thingamablog.gui.app;
002:
003:        import java.awt.Dimension;
004:        import java.awt.GridBagConstraints;
005:        import java.awt.GridBagLayout;
006:        import java.awt.Insets;
007:        import java.awt.event.ActionEvent;
008:        import java.awt.event.ActionListener;
009:        import javax.swing.JButton;
010:        import javax.swing.JLabel;
011:        import javax.swing.JList;
012:        import javax.swing.JOptionPane;
013:        import javax.swing.JPanel;
014:        import javax.swing.JScrollPane;
015:        import javax.swing.ListSelectionModel;
016:
017:        import net.atlanticbb.tantlinger.i18n.I18n;
018:
019:        public class SelectTemplatePanel extends JPanel {
020:            /**
021:             * 
022:             */
023:            private static final long serialVersionUID = 1L;
024:            private static final I18n i18n = I18n
025:                    .getInstance("net.sf.thingamablog.gui.app");
026:            public static final String TEMPLATE_ZIP_PATH = "templateZip"; //  @jve:decl-index=0: //$NON-NLS-1$
027:            public static final String TEMPLATE_NAME = "templateName"; //$NON-NLS-1$
028:
029:            private JLabel msgLabel = null;
030:            private JButton openButton = null;
031:            private JScrollPane scrollPane = null;
032:            private JList tmplList = null;
033:
034:            private String zipPath;
035:
036:            /**
037:             * This method initializes 
038:             * 
039:             */
040:            public SelectTemplatePanel() {
041:                super ();
042:                initialize();
043:            }
044:
045:            public boolean canProceed() {
046:                if (zipPath == null) {
047:                    JOptionPane
048:                            .showMessageDialog(
049:                                    this ,
050:                                    i18n.str("open_pack_prompt"), i18n.str("missing_data"), JOptionPane.WARNING_MESSAGE); //$NON-NLS-1$ //$NON-NLS-2$
051:                    return false;
052:                }
053:
054:                //values.put(TEMPLATE_ZIP_PATH, zipPath);
055:
056:                String tName = (String) tmplList.getSelectedValue();
057:                if (tName == null) {
058:                    JOptionPane
059:                            .showMessageDialog(
060:                                    this ,
061:                                    i18n.str("open_pack_prompt"), i18n.str("missing_data"), JOptionPane.WARNING_MESSAGE); //$NON-NLS-1$ //$NON-NLS-2$
062:                    return false;
063:                }
064:
065:                //values.put(TEMPLATE_NAME, tName);
066:
067:                return true;
068:            }
069:
070:            /**
071:             * This method initializes this
072:             * 
073:             */
074:            private void initialize() {
075:                GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
076:                gridBagConstraints2.fill = GridBagConstraints.BOTH;
077:                gridBagConstraints2.gridy = 1;
078:                gridBagConstraints2.weightx = 1.0;
079:                gridBagConstraints2.weighty = 1.0;
080:                gridBagConstraints2.insets = new Insets(5, 0, 0, 0);
081:                gridBagConstraints2.gridx = 1;
082:                GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
083:                gridBagConstraints1.gridx = 0;
084:                gridBagConstraints1.anchor = GridBagConstraints.NORTHWEST;
085:                gridBagConstraints1.insets = new Insets(5, 0, 0, 5);
086:                gridBagConstraints1.gridy = 1;
087:                GridBagConstraints gridBagConstraints = new GridBagConstraints();
088:                gridBagConstraints.gridx = 0;
089:                gridBagConstraints.anchor = GridBagConstraints.NORTHWEST;
090:                gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
091:                gridBagConstraints.weightx = 1.0;
092:                gridBagConstraints.gridwidth = 2;
093:                gridBagConstraints.gridy = 0;
094:                msgLabel = new JLabel();
095:                msgLabel
096:                        .setText("<html>" + i18n.str("select_template_prompt") + "</html>"); //$NON-NLS-1$
097:                this .setLayout(new GridBagLayout());
098:                this .setSize(new Dimension(434, 260));
099:                this .add(msgLabel, gridBagConstraints);
100:                this .add(getOpenButton(), gridBagConstraints1);
101:                this .add(getScrollPane(), gridBagConstraints2);
102:
103:            }
104:
105:            /**
106:             * This method initializes openButton	
107:             * 	
108:             * @return javax.swing.JButton	
109:             */
110:            private JButton getOpenButton() {
111:                if (openButton == null) {
112:                    openButton = new JButton();
113:                    openButton.setText(i18n.str("open_zip_file_")); //$NON-NLS-1$
114:                    openButton.addActionListener(new OpenHandler());
115:                }
116:                return openButton;
117:            }
118:
119:            /**
120:             * This method initializes scrollPane	
121:             * 	
122:             * @return javax.swing.JScrollPane	
123:             */
124:            private JScrollPane getScrollPane() {
125:                if (scrollPane == null) {
126:                    scrollPane = new JScrollPane();
127:                    scrollPane.setViewportView(getTmplList());
128:                }
129:                return scrollPane;
130:            }
131:
132:            /**
133:             * This method initializes tmplList	
134:             * 	
135:             * @return javax.swing.JList	
136:             */
137:            private JList getTmplList() {
138:                if (tmplList == null) {
139:                    tmplList = new JList();
140:                    tmplList.getSelectionModel().setSelectionMode(
141:                            ListSelectionModel.SINGLE_SELECTION);
142:                }
143:                return tmplList;
144:            }
145:
146:            /*
147:            private String getTemplateDirRoot(String entPath)
148:            {        
149:                int pos = entPath.lastIndexOf("/templates/"); //$NON-NLS-1$
150:                if(pos == -1)
151:                    return null;
152:                String root = entPath.substring(0, pos);
153:                
154:                int slashCount = 0;
155:                for(int i = 0; i < root.length(); i++)
156:                {
157:                    if(root.charAt(i) == '/')
158:                        slashCount++;
159:                    if(slashCount > 2)
160:                        return null;
161:                }
162:                return root;
163:            }
164:             */
165:
166:            private class OpenHandler implements  ActionListener {
167:                public void actionPerformed(ActionEvent e) {
168:                    /*JFileChooser fc = new JFileChooser();
169:                    fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
170:                    fc.setDialogTitle("Open Template Pack"); 
171:                    fc.setFileFilter(new javax.swing.filechooser.FileFilter()
172:                    {
173:                        public boolean accept(File f)
174:                        {
175:                            return f.isDirectory() || 
176:                                f.getName().toLowerCase().endsWith(".zip");
177:                        }
178:                        
179:                        public String getDescription()
180:                        {
181:                            return "Template Pack Zip file"; 
182:                        }           
183:                    });
184:                    String lastTmplPack = (String)TemplateImportWizard.getProperties().get("last_tmpl_pack");
185:                    if(lastTmplPack != null)
186:                    {
187:                        File f = new File(lastTmplPack);
188:                        if(f.exists())
189:                            fc.setSelectedFile(f);
190:                    }
191:                    
192:                    int r = fc.showOpenDialog(SelectTemplatePanel.this);
193:                    if(r == JFileChooser.CANCEL_OPTION || fc.getSelectedFile() == null)
194:                        return;
195:                    
196:                    File zipFile = fc.getSelectedFile();            
197:                    ZipFile z = null;
198:                    
199:                    try
200:                    {
201:                        z = new ZipFile(zipFile);
202:                        zipPath = zipFile.getAbsolutePath();
203:                        Enumeration eenum = z.entries();                                
204:                        Vector roots = new Vector();
205:                        
206:                        while(eenum.hasMoreElements()) 
207:                        {
208:                            ZipEntry ze = (ZipEntry) eenum.nextElement(); 
209:                            String name = ze.getName();
210:                            if(name.toLowerCase().endsWith(".template"))
211:                            {
212:                                String root = getTemplateDirRoot(name);
213:                                if(root != null && !roots.contains(root))
214:                                {
215:                                    //System.err.println(root);
216:                                    roots.add(root);
217:                                }
218:                            }                   
219:                        }
220:                        
221:                        getTmplList().setListData(roots);
222:                        //TemplateImportWizard.getProperties().put("last_tmpl_pack", zipFile.getAbsolutePath());
223:                        
224:                    }
225:                    catch(Exception ex)
226:                    {
227:                        ex.printStackTrace();
228:                    }
229:                    finally
230:                    {
231:                        if(z != null)
232:                        {
233:                            try
234:                            {
235:                                z.close();
236:                            }
237:                            catch(Exception ex){}
238:                        }
239:                    }            */
240:                }
241:            }
242:
243:        } //  @jve:decl-index=0:visual-constraint="10,10"
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.