Source Code Cross Referenced for QSAdminGUI.java in  » Net » QuickServer » org » quickserver » net » qsadmin » gui » 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 » Net » QuickServer » org.quickserver.net.qsadmin.gui 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * This file is part of the QuickServer library 
003:         * Copyright (C) 2003-2005 QuickServer.org
004:         *
005:         * Use, modification, copying and distribution of this software is subject to
006:         * the terms and conditions of the GNU Lesser General Public License. 
007:         * You should have received a copy of the GNU LGP License along with this 
008:         * library; if not, you can download a copy from <http://www.quickserver.org/>.
009:         *
010:         * For questions, suggestions, bug-reports, enhancement-requests etc.
011:         * visit http://www.quickserver.org
012:         *
013:         */
014:
015:        package org.quickserver.net.qsadmin.gui;
016:
017:        import java.awt.*;
018:        import java.awt.event.*;
019:        import javax.swing.*;
020:        import javax.swing.event.*;
021:        import javax.swing.border.*;
022:        import java.io.IOException;
023:
024:        import org.quickserver.util.*;
025:        import java.util.logging.*;
026:        import org.quickserver.swing.JFrameUtilities; //--v1.3.2
027:        import java.io.*;
028:        import java.util.*;
029:        import org.quickserver.util.io.*;
030:        import org.quickserver.util.*;
031:        import org.quickserver.util.xmlreader.QSAdminPluginConfig;
032:        import org.quickserver.util.xmlreader.PluginConfigReader;
033:
034:        /**
035:         * QSAdminGUI - Control Panel for 
036:         * QuickServer Admin GUI - QSAdminGUI
037:         * @author Akshathkumar Shetty
038:         * @since 1.3
039:         */
040:        public class QSAdminGUI extends JPanel /*JFrame*/{
041:            private static Logger logger = Logger.getLogger(QSAdminGUI.class
042:                    .getName());
043:
044:            private static QSAdminMain qsadminMain = null;
045:            private static String pluginDir = "./../plugin";
046:
047:            private ClassLoader classLoader = getClass().getClassLoader();
048:            public ImageIcon logo = new ImageIcon(classLoader
049:                    .getResource("icons/logo.gif"));
050:            public ImageIcon logoAbout = new ImageIcon(classLoader
051:                    .getResource("icons/logo.png"));
052:            public ImageIcon ball = new ImageIcon(classLoader
053:                    .getResource("icons/ball.gif"));
054:
055:            private HeaderPanel headerPanel;
056:            private MainCommandPanel mainCommandPanel;
057:            private CmdConsole cmdConsole;
058:            private PropertiePanel propertiePanel;
059:            //private StatsPanel statsPanel;
060:
061:            private JTabbedPane tabbedPane;
062:            private JFrame parentFrame;
063:
064:            final HashMap pluginPanelMap = new HashMap();
065:
066:            //--v1.3.2
067:            private ArrayList plugins = new ArrayList();
068:
069:            private JMenu mainMenu, helpMenu;
070:            private JMenuBar jMenuBar;
071:            private JMenuItem loginMenuItem, exitMenuItem, aboutMenuItem;
072:
073:            /**
074:             * Logs the interaction,
075:             * Type can be 
076:             *	S - Server Sent
077:             *	C - Client Sent
078:             */
079:            public void logComand(String command, char type) {
080:                logger.info("For[" + type + "] " + command);
081:            }
082:
083:            /**
084:             * Displays the QSAdminGUi with in a JFrame.
085:             */
086:            public static void showGUI(String args[], final SplashScreen splash) {
087:                java.awt.EventQueue.invokeLater(new Runnable() {
088:                    public void run() {
089:                        try {
090:                            UIManager
091:                                    .setLookAndFeel("net.sourceforge.mlf.metouia.MetouiaLookAndFeel");
092:                        } catch (Exception e) {
093:                            try {
094:                                UIManager.setLookAndFeel(UIManager
095:                                        .getSystemLookAndFeelClassName());
096:                            } catch (Exception ee) {
097:                            }
098:                        }
099:
100:                        qsadminMain = new QSAdminMain();
101:
102:                        JFrame frame = new JFrame("QSAdmin GUI");
103:                        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
104:
105:                        QSAdminGUI qsAdminGUI = new QSAdminGUI(qsadminMain,
106:                                frame);
107:                        qsAdminGUI.updateConnectionStatus(false);
108:                        frame.getContentPane().add(qsAdminGUI);
109:                        frame.pack();
110:                        frame.setSize(700, 450);
111:                        frame.setIconImage(qsAdminGUI.logo.getImage());
112:                        JFrameUtilities.centerWindow(frame);
113:                        frame.setVisible(true);
114:                        if (splash != null)
115:                            splash.kill();
116:                    }
117:                });
118:            }
119:
120:            public QSAdminGUI(QSAdminMain qsadminMain, JFrame parentFrame) {
121:                this .parentFrame = parentFrame;
122:                Container cp = this ;
123:                qsadminMain.setGUI(this );
124:                cp.setLayout(new BorderLayout(5, 5));
125:                headerPanel = new HeaderPanel(qsadminMain, parentFrame);
126:                mainCommandPanel = new MainCommandPanel(qsadminMain);
127:                cmdConsole = new CmdConsole(qsadminMain);
128:                propertiePanel = new PropertiePanel(qsadminMain);
129:
130:                if (headerPanel == null || mainCommandPanel == null
131:                        || cmdConsole == null || propertiePanel == null) {
132:                    throw new RuntimeException(
133:                            "Loading of one of gui component failed.");
134:                }
135:
136:                headerPanel.setBorder(BorderFactory.createEmptyBorder(0, 5, 0,
137:                        5));
138:                cp.add(headerPanel, BorderLayout.NORTH);
139:                JScrollPane propertieScrollPane = new JScrollPane(
140:                        propertiePanel);
141:                //JScrollPane commandScrollPane = new JScrollPane(mainCommandPanel);
142:                JSplitPane splitPane = new JSplitPane(
143:                        JSplitPane.HORIZONTAL_SPLIT, true, mainCommandPanel,
144:                        cmdConsole);
145:                splitPane.setOneTouchExpandable(false);
146:                splitPane.setDividerLocation(250);
147:                //splitPane.setDividerLocation(0.70);
148:
149:                tabbedPane = new JTabbedPane(JTabbedPane.TOP);
150:                tabbedPane.addTab("Main", ball, splitPane, "Main Commands");
151:                tabbedPane.addTab("Get/Set", ball, propertieScrollPane,
152:                        "Properties Panel");
153:
154:                QSAdminPluginConfig qsAdminPluginConfig = null;
155:                PluginPanel pluginPanel = null;
156:                //-- start of loadPlugins
157:                try {
158:                    File xmlFile = null;
159:                    ClassLoader classLoader = null;
160:                    Class mainClass = null;
161:
162:                    File file = new File(pluginDir);
163:                    File dirs[] = null;
164:
165:                    if (file.canRead())
166:                        dirs = file.listFiles(new DirFileList());
167:
168:                    for (int i = 0; dirs != null && i < dirs.length; i++) {
169:                        xmlFile = new File(dirs[i].getAbsolutePath()
170:                                + File.separator + "plugin.xml");
171:                        if (xmlFile.canRead()) {
172:                            qsAdminPluginConfig = PluginConfigReader
173:                                    .read(xmlFile);
174:                            if (qsAdminPluginConfig.getActive().equals("yes")
175:                                    && qsAdminPluginConfig.getType().equals(
176:                                            "javax.swing.JPanel")) {
177:                                classLoader = ClassUtil
178:                                        .getClassLoaderFromJars(dirs[i]
179:                                                .getAbsolutePath());
180:                                mainClass = classLoader
181:                                        .loadClass(qsAdminPluginConfig
182:                                                .getMainClass());
183:                                logger.fine("Got PluginMainClass " + mainClass);
184:                                pluginPanel = (PluginPanel) mainClass
185:                                        .newInstance();
186:                                if (JPanel.class.isInstance(pluginPanel) == true) {
187:                                    logger.info("Loading plugin : "
188:                                            + qsAdminPluginConfig.getName());
189:                                    pluginPanelMap.put("" + (2 + i),
190:                                            pluginPanel);
191:                                    plugins.add(pluginPanel);
192:                                    tabbedPane.addTab(qsAdminPluginConfig
193:                                            .getName(), ball,
194:                                            (JPanel) pluginPanel,
195:                                            qsAdminPluginConfig.getDesc());
196:                                    pluginPanel.setQSAdminMain(qsadminMain);
197:                                    pluginPanel.init();
198:                                }
199:                            } else {
200:                                logger.info("Plugin " + dirs[i]
201:                                        + " is disabled so skipping");
202:                            }
203:                        } else {
204:                            logger.info("No plugin configuration found in "
205:                                    + xmlFile + " so skipping");
206:                        }
207:                    }
208:                } catch (Exception e) {
209:                    logger.warning("Error loading plugin : " + e);
210:                    logger.fine("StackTrace:\n" + MyString.getStackTrace(e));
211:                }
212:                //-- end of loadPlugins
213:
214:                tabbedPane.addChangeListener(new ChangeListener() {
215:                    int selected = -1;
216:                    int oldSelected = -1;
217:
218:                    public void stateChanged(ChangeEvent e) {
219:                        //if plugin
220:                        selected = tabbedPane.getSelectedIndex();
221:                        if (selected >= 2) {
222:                            ((PluginPanel) pluginPanelMap.get("" + selected))
223:                                    .activated();
224:                        }
225:                        if (oldSelected >= 2) {
226:                            ((PluginPanel) pluginPanelMap.get("" + oldSelected))
227:                                    .deactivated();
228:                        }
229:                        oldSelected = selected;
230:                    }
231:                });
232:
233:                //tabbedPane.setBorder(BorderFactory.createEmptyBorder(0,5,5,5));
234:                cp.add(tabbedPane, BorderLayout.CENTER);
235:
236:                buildMenu();
237:            }
238:
239:            public void setStatus(String msg) {
240:                headerPanel.setStatus(msg);
241:            }
242:
243:            public void setResponse(String res) {
244:                int msgType = JOptionPane.PLAIN_MESSAGE;
245:                if (res.startsWith("+OK"))
246:                    msgType = JOptionPane.INFORMATION_MESSAGE;
247:                if (res.startsWith("-ERR"))
248:                    msgType = JOptionPane.ERROR_MESSAGE;
249:                JOptionPane.showMessageDialog(QSAdminGUI.this , res
250:                        .substring(res.indexOf(" ") + 1), "Response", msgType);
251:            }
252:
253:            public void appendToConsole(String msg) {
254:                cmdConsole.append(msg);
255:            }
256:
257:            public void setConsoleSend(boolean flag) {
258:                cmdConsole.setSendEdit(flag);
259:            }
260:
261:            public void updateConnectionStatus(boolean connected) {
262:                if (connected == true) {
263:                    headerPanel.setLogoutText();
264:                    loginMenuItem.setText("Logout");
265:                } else {
266:                    headerPanel.setLoginText();
267:                    loginMenuItem.setText("Login...");
268:                }
269:                mainCommandPanel.updateConnectionStatus(connected);
270:                propertiePanel.updateConnectionStatus(connected);
271:                cmdConsole.updateConnectionStatus(connected);
272:                Iterator iterator = plugins.iterator();
273:                PluginPanel updatePluginPanel = null;
274:                while (iterator.hasNext()) {
275:                    updatePluginPanel = (PluginPanel) iterator.next();
276:                    updatePluginPanel.updateConnectionStatus(connected);
277:                }
278:
279:                if (connected == true) {
280:                    int selected = tabbedPane.getSelectedIndex();
281:                    if (selected >= 2) {
282:                        ((PluginPanel) pluginPanelMap.get("" + selected))
283:                                .activated();
284:                    }
285:                }
286:            }
287:
288:            //--v1.3.2
289:            public static void setPluginDir(String dir) {
290:                pluginDir = dir;
291:            }
292:
293:            public static String getPluginDir() {
294:                return pluginDir;
295:            }
296:
297:            private void buildMenu() {
298:                jMenuBar = new javax.swing.JMenuBar();
299:                mainMenu = new javax.swing.JMenu();
300:                mainMenu.setText("Main");
301:
302:                loginMenuItem = new JMenuItem("Login...");
303:                loginMenuItem
304:                        .addActionListener(new java.awt.event.ActionListener() {
305:                            public void actionPerformed(
306:                                    java.awt.event.ActionEvent evt) {
307:                                headerPanel.handleLoginLogout();
308:                            }
309:                        });
310:
311:                mainMenu.add(loginMenuItem);
312:
313:                exitMenuItem = new JMenuItem("Exit");
314:                exitMenuItem
315:                        .addActionListener(new java.awt.event.ActionListener() {
316:                            public void actionPerformed(
317:                                    java.awt.event.ActionEvent evt) {
318:                                if (qsadminMain.isConnected() == true) {
319:                                    headerPanel.handleLoginLogout();
320:                                }
321:                                System.exit(0);
322:                            }
323:                        });
324:                mainMenu.add(exitMenuItem);
325:
326:                helpMenu = new javax.swing.JMenu();
327:                helpMenu.setText("Help");
328:
329:                aboutMenuItem = new JMenuItem("About...");
330:                aboutMenuItem.setEnabled(true);
331:                aboutMenuItem
332:                        .addActionListener(new java.awt.event.ActionListener() {
333:                            public void actionPerformed(
334:                                    java.awt.event.ActionEvent evt) {
335:                                about();
336:                            }
337:                        });
338:                helpMenu.add(aboutMenuItem);
339:
340:                jMenuBar.add(mainMenu);
341:                jMenuBar.add(helpMenu);
342:
343:                parentFrame.setJMenuBar(jMenuBar);
344:            }
345:
346:            private void about() {
347:                JOptionPane.showMessageDialog(this , "QSAdminGUI\n\n"
348:                        + "GUI Client for QSAdminServer of QuickServer.\n"
349:                        + "This is compliant with QuickServer v"
350:                        + QSAdminMain.VERSION_OF_SERVER + " release.\n\n"
351:                        + "Copyright (C) QuickServer.org\n"
352:                        + "http://www.quickserver.org", "About QSAdminGUI",
353:                        JOptionPane.INFORMATION_MESSAGE, logoAbout);
354:            }
355:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.