001: package net.sourceforge.squirrel_sql.plugins.oracle.SGAtrace;
002:
003: /*
004: * Copyright (C) 2004 Jason Height
005: * jmheight@users.sourceforge.net
006: *
007: * This library is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU Lesser General Public
009: * License as published by the Free Software Foundation; either
010: * version 2.1 of the License, or (at your option) any later version.
011: *
012: * This library is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this library; if not, write to the Free Software
019: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
020: */
021:
022: import net.sourceforge.squirrel_sql.client.IApplication;
023: import net.sourceforge.squirrel_sql.client.session.ISession;
024: import net.sourceforge.squirrel_sql.fw.util.Resources;
025: import net.sourceforge.squirrel_sql.fw.util.StringManager;
026: import net.sourceforge.squirrel_sql.fw.util.StringManagerFactory;
027: import net.sourceforge.squirrel_sql.plugins.oracle.OracleInternalFrame;
028: import net.sourceforge.squirrel_sql.plugins.oracle.OracleInternalFrameCallback;
029:
030: import javax.swing.*;
031: import javax.swing.event.ChangeEvent;
032: import javax.swing.event.ChangeListener;
033: import javax.swing.event.InternalFrameAdapter;
034: import javax.swing.event.InternalFrameEvent;
035: import java.awt.*;
036: import java.awt.event.ActionEvent;
037: import java.awt.event.ActionListener;
038:
039: public class SGATraceInternalFrame extends OracleInternalFrame {
040: private static final long serialVersionUID = 1L;
041:
042: private static final String PREF_PART_SGA_FRAME = "SGAFrame";
043:
044: private static final StringManager s_stringMgr = StringManagerFactory
045: .getStringManager(SGATraceInternalFrame.class);
046:
047: private SGATracePanel _sgaTracePanel;
048: /**
049: * Toolbar for window.
050: */
051: private SGATraceToolBar _toolBar;
052:
053: transient private Resources _resources;
054:
055: public SGATraceInternalFrame(ISession session, Resources resources) {
056: // I18n[oracle.sgaTitle=Oracle SGA trace for: {0}]
057: super (session, s_stringMgr.getString("oracle.sgaTitle", session
058: .getTitle()));
059: _resources = resources;
060: createGUI();
061: }
062:
063: public SGATracePanel getSGATracePanel() {
064: return _sgaTracePanel;
065: }
066:
067: private void createGUI() {
068: addInternalFrameListener(new InternalFrameAdapter() {
069: public void internalFrameClosing(InternalFrameEvent e) {
070: SGATraceInternalFrame.super .internalFrameClosing(
071: _toolBar.isStayOnTop(), _sgaTracePanel
072: .getAutoRefreshPeriod());
073: _sgaTracePanel.setAutoRefresh(false);
074: }
075: });
076:
077: Icon icon = _resources.getIcon(getClass(), "frameIcon"); //i18n
078: if (icon != null) {
079: setFrameIcon(icon);
080: }
081:
082: OracleInternalFrameCallback cb = new OracleInternalFrameCallback() {
083:
084: public void createPanelAndToolBar(boolean stayOnTop,
085: int autoRefeshPeriod) {
086: _sgaTracePanel = new SGATracePanel(getSession(),
087: autoRefeshPeriod);
088: _toolBar = new SGATraceToolBar(getSession(), stayOnTop,
089: autoRefeshPeriod);
090: JPanel contentPanel = new JPanel(new BorderLayout());
091: contentPanel.add(_toolBar, BorderLayout.NORTH);
092: contentPanel.add(_sgaTracePanel, BorderLayout.CENTER);
093: setContentPane(contentPanel);
094: }
095: };
096:
097: initFromPrefs(PREF_PART_SGA_FRAME, cb);
098:
099: }
100:
101: /**
102: * The class representing the toolbar at the top of a SGA Trace internal frame
103: */
104: private class SGATraceToolBar extends OracleToolBar {
105: private static final long serialVersionUID = 1L;
106:
107: SGATraceToolBar(ISession session, boolean stayOnTop,
108: int autoRefeshPeriod) {
109: super ();
110: createGUI(session, stayOnTop, autoRefeshPeriod);
111: }
112:
113: private void createGUI(ISession session, boolean stayOnTop,
114: int autoRefeshPeriod) {
115: IApplication app = session.getApplication();
116: setUseRolloverButtons(true);
117: setFloatable(false);
118: add(new GetSGATraceAction(app, _resources, _sgaTracePanel));
119:
120: addStayOnTop(stayOnTop);
121:
122: //Create checkbox for enabling auto refresh
123: // i18n[oracle.enableAutoRefresh=Enable auto refresh]
124: final JCheckBox autoRefresh = new JCheckBox(s_stringMgr
125: .getString("oracle.enableAutoRefresh"), false);
126: autoRefresh.addActionListener(new ActionListener() {
127: public void actionPerformed(ActionEvent e) {
128: _sgaTracePanel.setAutoRefresh(autoRefresh
129: .isSelected());
130: }
131: });
132: add(autoRefresh);
133:
134: //Create spinner for update period
135: final SpinnerNumberModel model = new SpinnerNumberModel(
136: autoRefeshPeriod, 1, 60, 5);
137: final JSpinner refreshRate = new JSpinner(model);
138: refreshRate.addChangeListener(new ChangeListener() {
139: public void stateChanged(ChangeEvent e) {
140: _sgaTracePanel.setAutoRefreshPeriod(model
141: .getNumber().intValue());
142: }
143: });
144: add(refreshRate);
145: // i18n[oracle.refreshSecons=(seconds)]
146: add(new JLabel(s_stringMgr
147: .getString("oracle.refreshSecons")));
148: }
149: }
150: }
|