Source Code Cross Referenced for ArquivosRecentes.java in  » ERP-CRM-Financial » Personal-Finance-Manager » br » com » gfpshare » beans » aplicativos » 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 » ERP CRM Financial » Personal Finance Manager » br.com.gfpshare.beans.aplicativos 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Created on 10/11/2004
003:         * 
004:         * ============================================================================
005:         * GNU Lesser General Public License
006:         * ============================================================================
007:         *
008:         * Swing Components - visit http://sf.net/projects/gfd
009:         * 
010:         * Copyright (C) 2004  Igor Regis da Silva Simões
011:         * 
012:         * This library is free software; you can redistribute it and/or
013:         * modify it under the terms of the GNU Lesser General Public
014:         * License as published by the Free Software Foundation; either
015:         * version 2.1 of the License, or (at your option) any later version.
016:         * 
017:         * This library is distributed in the hope that it will be useful,
018:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
019:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
020:         * Lesser General Public License for more details.
021:         * 
022:         * You should have received a copy of the GNU Lesser General Public
023:         * License along with this library; if not, write to the Free Software
024:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307, USA.
025:         */
026:        package br.com.gfpshare.beans.aplicativos;
027:
028:        import java.io.File;
029:        import java.io.FileInputStream;
030:        import java.io.FileOutputStream;
031:        import java.io.IOException;
032:        import java.io.ObjectInputStream;
033:        import java.io.ObjectOutputStream;
034:        import java.util.ArrayList;
035:        import java.util.Iterator;
036:
037:        /**
038:         * @author Igor Regis da Silva Simoes
039:         */
040:        public class ArquivosRecentes {
041:            private transient ArrayList arqRecentes = new ArrayList(3);
042:
043:            private String dir = null;
044:
045:            /**
046:             * @param dir
047:             * @throws IOException
048:             * @throws ClassNotFoundException
049:             * 
050:             */
051:            public ArquivosRecentes(String dir) throws IOException,
052:                    ClassNotFoundException {
053:                super ();
054:                this .dir = dir;
055:                loadFile(dir);
056:            }
057:
058:            /**
059:             * Carrega o arquivo com a lista de arquivos recentemente abertos
060:             * @param dir Localização do arquivo
061:             * @throws IOException
062:             * @throws ClassNotFoundException
063:             */
064:            private void loadFile(String dir) throws IOException,
065:                    ClassNotFoundException {
066:                File arquivo = new File(dir + File.separator
067:                        + "arqRecentes.arrayList");
068:                if (!arquivo.exists()) {
069:                    arquivo.createNewFile();
070:                    return;
071:                }
072:
073:                try {
074:                    ObjectInputStream ois = new ObjectInputStream(
075:                            new FileInputStream(arquivo));
076:                    arqRecentes = (ArrayList) ois.readObject();
077:                    ois.close();
078:                } catch (IOException ioe) {/*TODO*/
079:                }
080:
081:                //Removemos os arquivos que não existem mais
082:                //        for(int i=0; i<arqRecentes.size(); i++)
083:                //            if (!new File(arqRecentes.get(i).toString()).exists())
084:                //                remove(arqRecentes.get(i));
085:                //        saveFile(dir);
086:            }
087:
088:            /**
089:             * Salva o arquivo com a lista de arquivos recentemente abertos
090:             * @param dir Localização do arquivo
091:             * @throws IOException
092:             */
093:            private void saveFile(String dir) throws IOException {
094:                File arquivo = new File(dir + File.separator
095:                        + "arqRecentes.arrayList");
096:                ObjectOutputStream oos = new ObjectOutputStream(
097:                        new FileOutputStream(arquivo));
098:                oos.writeObject(arqRecentes);
099:                oos.flush();
100:                oos.close();
101:            }
102:
103:            /**
104:             * Retorna um Iterator com a lista de registros dos arquivos recentes
105:             * @return Iterator
106:             */
107:            public Iterator iterator() {
108:                return arqRecentes.iterator();
109:            }
110:
111:            /**
112:             * Adiciona um registro da lista de arquivos recentes 
113:             * @param o Registro a ser adicionado
114:             * @return true se houve sucesso
115:             * @throws IOException
116:             */
117:            public boolean add(Object o) throws IOException {
118:                if (System.getProperty("os.name").toLowerCase().startsWith(
119:                        "win"))
120:                    o = o.toString().toLowerCase();
121:                if (arqRecentes.contains(o))
122:                    return true;
123:                boolean retorno = arqRecentes.add(o);
124:                arqRecentes.trimToSize();
125:                if (arqRecentes.size() > 9)
126:                    arqRecentes.remove(0);
127:                saveFile(dir);
128:                return retorno;
129:            }
130:
131:            /**
132:             * Limpa a lista de arquivos recentes
133:             * @throws IOException
134:             *
135:             */
136:            public void clear() throws IOException {
137:                arqRecentes.clear();
138:                saveFile(dir);
139:            }
140:
141:            /**
142:             * Remove um registro da lista de arquivos recentes 
143:             * @param o Registro a ser removido
144:             * @return true se houve sucesso
145:             * @throws IOException
146:             */
147:            public boolean remove(Object o) throws IOException {
148:                boolean retorno = arqRecentes.remove(o);
149:                saveFile(dir);
150:                return retorno;
151:            }
152:
153:            /**
154:             * Retorna a lista de arquivos em forma de um array de objetos
155:             * @return array de objetos
156:             */
157:            public Object[] toArray() {
158:                return arqRecentes.toArray();
159:            }
160:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.