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


001:        /*
002:         * Created on 25/08/2005
003:         * 
004:         * Swing Components - visit http://sf.net/projects/gfd
005:         * 
006:         * Copyright (C) 2004  Igor Regis da Silva Simões
007:         * 
008:         * This program is free software; you can redistribute it and/or
009:         * modify it under the terms of the GNU General Public License
010:         * as published by the Free Software Foundation; either version 2
011:         * of the License, or (at your option) any later version.
012:         *
013:         * This program is distributed in the hope that it will be useful,
014:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
015:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
016:         * GNU General Public License for more details.
017:         *
018:         * You should have received a copy of the GNU General Public License
019:         * along with this program; if not, write to the Free Software
020:         * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
021:         * 
022:         */
023:        package br.com.gfp.windows.views;
024:
025:        import java.awt.BorderLayout;
026:        import java.awt.Color;
027:        import java.awt.Component;
028:        import java.awt.event.ActionEvent;
029:
030:        import javax.swing.AbstractAction;
031:        import javax.swing.Action;
032:        import javax.swing.JPanel;
033:        import javax.swing.JProgressBar;
034:        import javax.swing.JScrollPane;
035:        import javax.swing.JTextArea;
036:
037:        import org.flexdock.docking.Dockable;
038:        import org.flexdock.docking.DockingConstants;
039:        import org.flexdock.docking.DockingManager;
040:        import org.flexdock.util.SwingUtility;
041:        import org.flexdock.view.View;
042:
043:        import br.com.gfp.dao.GFPController;
044:        import br.com.gfp.internationalization.ViewsMessages;
045:        import br.com.gfpshare.beans.MessagePanel;
046:        import br.com.gfpshare.beans.MessageView;
047:        import br.com.gfpshare.beans.aplicativos.IconeFactory;
048:
049:        /**
050:         *  Este classe representa um painel docavel que é usado para exibir mensagens ao usuário.
051:         *  O GFP possui apenas uma instancia desta classe que não pode ser fechada nunca pelo.
052:         *  Plugins podem escrever nesta classe ou abrir instancias separadas (clones), estas novas
053:         *  instancias podem ser fechadas pelo usuário.
054:         * @author Igor Regis da Silva Simoes
055:         * @since 25/08/2005
056:         */
057:        public class MessagesView extends View implements  MessageView {
058:            /**
059:             * Painel interno de mensagens usado por esta view
060:             */
061:            private InternalMessagePanel messagePanel = null;
062:
063:            /**
064:             * Botão que lima a tela de mensagens
065:             */
066:            private Action clearText = null;
067:            /**
068:             * Indica se a MessageView principal está em uso.
069:             */
070:            private boolean lock = false;
071:
072:            /**
073:             * Construtor privado usado internamente
074:             */
075:            @SuppressWarnings("unchecked")
076:            private MessagesView(String title, boolean showProgress) {
077:                super (title, title, title);
078:                messagePanel = new InternalMessagePanel(this , showProgress);
079:                setContentPane(messagePanel);
080:                setIcon(IconeFactory.getIconeFactory().getScaledImage(
081:                        "/icones/22x22/history.png", 12));
082:
083:                clearText = new AbstractAction() {
084:                    public void actionPerformed(ActionEvent e) {
085:                        messagePanel.textMessages.setText("");
086:                    }
087:
088:                };
089:                clearText.putValue(Action.NAME, ViewsMessages.getMessages()
090:                        .getString("Limpar"));
091:                clearText.putValue(Action.SMALL_ICON, IconeFactory
092:                        .getIconeFactory().getScaledImage(
093:                                IconeFactory.LIMPAR_PEQUENA, 10));
094:                addAction(clearText);
095:
096:                Action max = new AbstractAction() {
097:                    public void actionPerformed(ActionEvent e) {
098:                        DockingManager
099:                                .toggleMaximized((Dockable) MessagesView.this );
100:                        SwingUtility.repaint((Component) GFPController
101:                                .getGFPController().getContexto().get(
102:                                        GFPController.DESKTOP));
103:                    }
104:                };
105:                max.putValue(Action.NAME, "Max");
106:                max.putValue(Action.SMALL_ICON, IconeFactory.getIconeFactory()
107:                        .getScaledImage("/icones/16x16/maximize.gif", 16));
108:                addAction(max);
109:                addAction(DockingConstants.PIN_ACTION);
110:            }
111:
112:            /**
113:             * Cria uma view de mensagens
114:             * @param showProgress Indica se é ou não para exibir progress bar
115:             */
116:            public MessagesView(boolean showProgress) {
117:                this (ViewsMessages.getMessages().getString("Mensagens"),
118:                        showProgress);
119:            }
120:
121:            /**
122:             * Cria uma nova janela para exibir mensagens ao usuário, retornando ao chamador 
123:             * uma referencia para esta janela de forma que se possa exibir as mensagens conforme
124:             * necessário e até mesmo fechar a janela de mensagens por meio de chamada de método.
125:             * @param title Titulo da janela criada
126:             * @param message Mensagem inicialmente exibida pela janela
127:             * @param showProgress Indica se é ou não para exibir progress bar
128:             * @return SecondaryMessageView
129:             */
130:            public MessageView showMessage(String title, String message,
131:                    boolean showProgress) {
132:                if (lock) {
133:                    MessagesView secondaryMessageView = new MessagesView(title,
134:                            showProgress);
135:                    if (isMinimized())
136:                        DockingManager.setMinimized(this , false);
137:                    secondaryMessageView
138:                            .addAction(DockingConstants.CLOSE_ACTION);
139:                    secondaryMessageView.getDockingProperties()
140:                            .setDockingEnabled(false);
141:                    dock(secondaryMessageView);
142:                    secondaryMessageView.getMessagePanel().setMessage(message,
143:                            true);
144:                    return secondaryMessageView;
145:                } else {
146:                    lock = true;
147:                    if (isMinimized())
148:                        DockingManager.setMinimized(this , false);
149:                    getMessagePanel().setMessage(message, true);
150:                    return this ;
151:                }
152:            }
153:
154:            /**
155:             * @return Returns the messagePanel.
156:             */
157:            public MessagePanel getMessagePanel() {
158:                return messagePanel;
159:            }
160:
161:            /**
162:             * Marca este messageView para ser fechado automaticamente 
163:             * caso o usuário não o faça primeiro.
164:             */
165:            public void finishUse() {
166:                finishUse(-1);
167:            }
168:
169:            /**
170:             * Marca este messageView para ser fechado automaticamente 
171:             * caso o usuário não o faça primeiro.
172:             * @param segundos Quantos segundos aguardar antes de fechar este MessageView
173:             */
174:            public void finishUse(final long segundos) {
175:                new Thread("FinalizandoMessageView") {
176:                    @Override
177:                    public void run() {
178:                        try {
179:                            if (segundos == -1)
180:                                Thread.sleep(1000 * 120);
181:                            else
182:                                Thread.sleep(1000 * segundos);
183:                        } catch (InterruptedException e) {
184:                        }
185:                        //                try {
186:                        //                    close();
187:                        //                }catch(Throwable t)
188:                        //                {
189:                        //                    ((SimpleLog)GFPController.getGFPController().getContexto().get(GFPController.LOG)).log("Erro ao fechar MessageView! " + t.getLocalizedMessage());
190:                        //                    ((SimpleLog)GFPController.getGFPController().getContexto().get(GFPController.LOG)).log(t);
191:                        //                }
192:                    }
193:                }.start();
194:            }
195:
196:            /**
197:             * Classe que representa um paniel de mensagens
198:             *
199:             * @author Igor Regis da Silva Simoes
200:             * @since 25/08/2005 10:34:21
201:             */
202:            public class InternalMessagePanel extends JPanel implements 
203:                    MessagePanel {
204:                private JProgressBar progressBar = new JProgressBar();
205:
206:                private JTextArea textMessages = new JTextArea();
207:
208:                private View viewParent = null;
209:
210:                private Thread piscar = null;
211:
212:                private byte piscarAte = 0;
213:
214:                /**
215:                 *  Constrói um painel de mensagens
216:                 * @param parent O parent desta view
217:                 * @param showProgress Indica se é ou não para exibir progress bar
218:                 */
219:                public InternalMessagePanel(View parent, boolean showProgress) {
220:                    super ();
221:                    setLayout(new BorderLayout());
222:                    this .viewParent = parent;
223:                    textMessages.setEditable(false);
224:                    add(new JScrollPane(textMessages), BorderLayout.CENTER);
225:                    add(progressBar, BorderLayout.SOUTH);
226:                    progressBar.setVisible(showProgress);
227:
228:                }
229:
230:                /**
231:                 * Exibe ou oculta a barra de progresso
232:                 * @param show
233:                 */
234:                public void showProgress(boolean show) {
235:                    progressBar.setVisible(show);
236:                }
237:
238:                /**
239:                 * Pisca a janela de mensagens intermitentemente por 10 vezes
240:                 * Caso a janela estaja minimizada ela será restaurada temporariamente
241:                 * como se o usuário tivesse clicado no botão da janela.
242:                 * @param popup Indica se é necessário "saltar" a mensagem na tela
243:                 */
244:                public void piscar(boolean popup) {
245:                    if (popup)
246:                        viewParent.setActive(true);
247:                    if (piscar == null) {
248:                        piscar = new Thread("Piscar") {
249:                            @Override
250:                            public void run() {
251:                                for (piscarAte = 0; piscarAte < 10; piscarAte++) {
252:                                    textMessages.setBackground(new Color(235,
253:                                            235, 140));
254:                                    try {
255:                                        Thread.sleep(600);
256:                                    } catch (InterruptedException e) {
257:                                        return;
258:                                    }
259:                                    textMessages.setBackground(Color.WHITE);
260:                                    try {
261:                                        Thread.sleep(600);
262:                                    } catch (InterruptedException e) {
263:                                        return;
264:                                    }
265:                                }
266:                                piscar = null;
267:                            }
268:                        };
269:                        piscar.start();
270:                    } else
271:                        piscarAte = 0;
272:                }
273:
274:                /**
275:                 * Adiciona uma string a menssagem sendo exibida.
276:                 * @param message
277:                 */
278:                public void addMessage(String message) {
279:                    textMessages.append(message);
280:                }
281:
282:                /**
283:                 * Seta a mensagem a ser exibida e pisca a janela de menssagens
284:                 * @param message
285:                 * @param popup boolean indicando se a tela deberá saltar para chamar a atenção do usuário
286:                 */
287:                public void setMessage(String message, boolean popup) {
288:                    textMessages.setText(message);
289:                    piscar(popup);
290:                }
291:
292:                /**
293:                 * Retorna uma referencia a progress de forma que se possa configurá-la
294:                 * e realizar a sua atualização. 
295:                 * @return JProgressBar
296:                 */
297:                public JProgressBar getProgressBar() {
298:                    return progressBar;
299:                }
300:            }
301:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.