001: package net.sourceforge.squirrel_sql.client.session.mainpanel;
002:
003: /*
004: * Copyright (C) 2001-2004 Colin Bell
005: * colbell@users.sourceforge.net
006: *
007: * Modifications Copyright (C) 2003-2004 Jason Height
008: *
009: * This library is free software; you can redistribute it and/or
010: * modify it under the terms of the GNU Lesser General Public
011: * License as published by the Free Software Foundation; either
012: * version 2.1 of the License, or (at your option) any later version.
013: *
014: * This library is distributed in the hope that it will be useful,
015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
017: * Lesser General Public License for more details.
018: *
019: * You should have received a copy of the GNU Lesser General Public
020: * License along with this library; if not, write to the Free Software
021: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
022: */
023: import java.awt.Component;
024:
025: import javax.swing.SwingUtilities;
026:
027: import net.sourceforge.squirrel_sql.client.session.ISession;
028: import net.sourceforge.squirrel_sql.fw.util.StringManager;
029: import net.sourceforge.squirrel_sql.fw.util.StringManagerFactory;
030:
031: public class SQLTab extends BaseMainPanelTab {
032:
033: /** Internationalized strings for this class. */
034: private static final StringManager s_stringMgr = StringManagerFactory
035: .getStringManager(SQLTab.class);
036:
037: /** Component to be displayed. */
038: private SQLPanel _comp;
039:
040: public SQLTab(ISession session) {
041: super ();
042: setSession(session);
043: }
044:
045: /**
046: * @see IMainPanelTab#getTitle()
047: */
048: public String getTitle() {
049: // i18n[SQLTab.title=SQL]
050: return s_stringMgr.getString("SQLTab.title");
051: }
052:
053: /**
054: * @see IMainPanelTab#getHint()
055: */
056: public String getHint() {
057: // i18n[SQLTab.hint=Execute SQL statements]
058: return s_stringMgr.getString("SQLTab.hint");
059: }
060:
061: /**
062: * Return the component to be displayed in the panel.
063: *
064: * @return The component to be displayed in the panel.
065: */
066: public synchronized Component getComponent() {
067: if (_comp == null) {
068: _comp = new SQLPanel(getSession(), true);
069: }
070: return _comp;
071: }
072:
073: /**
074: * @see IMainPanelTab#setSession(ISession)
075: */
076: public void setSession(ISession session) {
077: super .setSession(session);
078: getSQLPanel().setSession(session);
079: }
080:
081: /**
082: * @see IMainPanelTab#select()
083: */
084: public synchronized void refreshComponent() {
085: // JASON: Do we need this?
086: // getSQLPanel().selected();
087: }
088:
089: /**
090: * Sesssion is ending.
091: */
092: public void sessionClosing(ISession session) {
093: if (_comp != null) {
094: _comp.sessionClosing();
095: }
096: }
097:
098: /**
099: * This tab has been selected. Set focus to the SQL entry area.
100: */
101: public synchronized void select() {
102: super .select();
103: SwingUtilities.invokeLater(new Runnable() {
104: public void run() {
105: _comp.getSQLEntryPanel().requestFocus();
106: }
107: });
108: }
109:
110: public SQLPanel getSQLPanel() {
111: return (SQLPanel) getComponent();
112: }
113: }
|