KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > cjdbc > console > gui > popups > DatabasePopUpMenu


1 /**
2  * C-JDBC: Clustered JDBC.
3  * Copyright (C) 2002-2004 French National Institute For Research In Computer
4  * Science And Control (INRIA).
5  * Contact: c-jdbc@objectweb.org
6  *
7  * This library is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU Lesser General Public License as published by the
9  * Free Software Foundation; either version 2.1 of the License, or any later
10  * version.
11  *
12  * This library is distributed in the hope that it will be useful, but WITHOUT
13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
15  * for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public License
18  * along with this library; if not, write to the Free Software Foundation,
19  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
20  *
21  * Initial developer(s): Nicolas Modrzyk
22  * Contributor(s): ______________________.
23  */

24
25 package org.objectweb.cjdbc.console.gui.popups;
26
27 import java.awt.event.ActionEvent JavaDoc;
28
29 import javax.swing.JMenuItem JavaDoc;
30
31 import org.objectweb.cjdbc.console.gui.CjdbcGui;
32 import org.objectweb.cjdbc.console.gui.constants.GuiCommands;
33 import org.objectweb.cjdbc.console.gui.objects.DatabaseObject;
34
35 /**
36  * This class defines a DatabasePopUpMenu
37  *
38  * @author <a HREF="mailto:Nicolas.Modrzyk@inria.fr">Nicolas Modrzyk </a>
39  * @version 1.0
40  */

41 public class DatabasePopUpMenu extends AbstractPopUpMenu
42 {
43   private DatabaseObject database;
44   private String JavaDoc databaseName;
45
46   /**
47    * Creates a new <code>DatabasePopUpMenu.java</code> object
48    *
49    * @param gui link to the main gui
50    * @param database referenced db
51    */

52   public DatabasePopUpMenu(CjdbcGui gui, DatabaseObject database)
53   {
54     super(gui);
55     this.database = database;
56     this.databaseName = database.getName();
57     this.add(new JMenuItem JavaDoc(GuiCommands.COMMAND_DISPLAY_XML_DATABASE))
58         .addActionListener(this);
59     this.add(new JMenuItem JavaDoc(GuiCommands.COMMAND_ENABLE_ALL)).addActionListener(
60         this);
61     this.add(new JMenuItem JavaDoc(GuiCommands.COMMAND_DISABLE_ALL)).addActionListener(
62         this);
63     this.add(new JMenuItem JavaDoc(GuiCommands.COMMAND_SHUTDOWN_DATABASE))
64         .addActionListener(this);
65     this.add(new JMenuItem JavaDoc(GuiCommands.COMMAND_VIEW_SQL_STATS))
66         .addActionListener(this);
67     this.add(new JMenuItem JavaDoc(GuiCommands.COMMAND_VIEW_CACHE_CONTENT))
68         .addActionListener(this);
69     this.add(new JMenuItem JavaDoc(GuiCommands.COMMAND_VIEW_RECOVERY_LOG))
70         .addActionListener(this);
71     this.add(new JMenuItem JavaDoc(GuiCommands.COMMAND_MONITOR_DATABASE))
72         .addActionListener(this);
73   }
74
75   /**
76    * Returns the database value.
77    *
78    * @return Returns the database.
79    */

80   public DatabaseObject getDatabaseName()
81   {
82     return database;
83   }
84
85   /**
86    * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
87    */

88   public void actionPerformed(ActionEvent JavaDoc e)
89   {
90     String JavaDoc action = e.getActionCommand();
91
92     if (action.equals(GuiCommands.COMMAND_ENABLE_ALL))
93     {
94       gui.publicActionDatabaseEnableAll(databaseName);
95     }
96     else if (action.equals(GuiCommands.COMMAND_DISABLE_ALL))
97     {
98       gui.publicActionDatabaseDisableAll(databaseName);
99     }
100     else if (action.equals(GuiCommands.COMMAND_SHUTDOWN_DATABASE))
101     {
102       gui.publicActionDisplayShutdownFrame(database);
103     }
104     else if (action.equals(GuiCommands.COMMAND_DISPLAY_XML_DATABASE))
105     {
106       gui.publicActionLoadXmlDatabase(databaseName);
107     }
108     else if (action.equals(GuiCommands.COMMAND_VIEW_CACHE_CONTENT))
109     {
110       gui.publicActionViewCache(databaseName);
111     }
112     else if (action.equals(GuiCommands.COMMAND_VIEW_SQL_STATS))
113     {
114       gui.publicActionViewSQLStats(databaseName);
115     }
116     else if (action.equals(GuiCommands.COMMAND_VIEW_CACHE_STATS))
117     {
118       gui.publicActionViewCacheStats(databaseName);
119     }
120     else if (action.equals(GuiCommands.COMMAND_VIEW_RECOVERY_LOG))
121     {
122       gui.publicActionViewRecoveryLog(databaseName);
123     }
124     else if (action.equals(GuiCommands.COMMAND_MONITOR_DATABASE))
125     {
126       gui.publicActionStartMonitor(database.getControllerName(), false, true,
127           false);
128     }
129   }
130 }
Popular Tags