001: package net.sourceforge.squirrel_sql.plugins.hibernate;
002:
003: import net.sourceforge.squirrel_sql.client.gui.session.ObjectTreeInternalFrame;
004: import net.sourceforge.squirrel_sql.client.gui.session.SQLInternalFrame;
005: import net.sourceforge.squirrel_sql.client.plugin.DefaultSessionPlugin;
006: import net.sourceforge.squirrel_sql.client.plugin.PluginException;
007: import net.sourceforge.squirrel_sql.client.plugin.PluginSessionCallback;
008: import net.sourceforge.squirrel_sql.client.preferences.IGlobalPreferencesPanel;
009: import net.sourceforge.squirrel_sql.client.session.ISession;
010: import net.sourceforge.squirrel_sql.fw.id.IIdentifier;
011: import net.sourceforge.squirrel_sql.fw.util.log.ILogger;
012: import net.sourceforge.squirrel_sql.fw.util.log.LoggerController;
013: import net.sourceforge.squirrel_sql.plugins.hibernate.configuration.HibernateConfigController;
014: import net.sourceforge.squirrel_sql.plugins.hibernate.configuration.HibernatePrefsTab;
015:
016: import java.util.HashMap;
017:
018: public class HibernatePlugin extends DefaultSessionPlugin {
019: private static ILogger s_log = LoggerController
020: .createLogger(HibernatePlugin.class);
021:
022: private HibernatePluginResources _resources;
023: private HashMap<IIdentifier, HibernateTabController> _hqlTabControllerBySessionID = new HashMap<IIdentifier, HibernateTabController>();
024: private HibernatePrefsListener _curHibernatePrefsListener;
025:
026: public String getInternalName() {
027: return "hibernate";
028: }
029:
030: public String getDescriptiveName() {
031: return "Hibernate Plugin";
032: }
033:
034: public String getVersion() {
035: return "0.01";
036: }
037:
038: public String getAuthor() {
039: return "Gerd Wagner";
040: }
041:
042: public String getChangeLogFileName() {
043: return "changes.txt";
044: }
045:
046: public String getHelpFileName() {
047: return "readme.html";
048: }
049:
050: public String getLicenceFileName() {
051: return "licence.txt";
052: }
053:
054: /**
055: * @return Comma separated list of contributors.
056: */
057: public String getContributors() {
058: return "";
059: }
060:
061: public IGlobalPreferencesPanel[] getGlobalPreferencePanels() {
062: return new IGlobalPreferencesPanel[] { new HibernatePrefsTab(
063: new HibernateConfigController(this )) };
064: }
065:
066: public synchronized void initialize() throws PluginException {
067: _resources = new HibernatePluginResources(this );
068: }
069:
070: public void sessionEnding(ISession session) {
071: try {
072: _hqlTabControllerBySessionID
073: .remove(session.getIdentifier()).sessionEnding();
074: } catch (Throwable t) {
075: s_log.error(t);
076: }
077: }
078:
079: public PluginSessionCallback sessionStarted(ISession session) {
080: try {
081: HibernateTabController hibernateTabController = new HibernateTabController(
082: session, this , _resources);
083:
084: _hqlTabControllerBySessionID.put(session.getIdentifier(),
085: hibernateTabController);
086:
087: session.getSessionSheet().insertMainTab(
088: hibernateTabController, 2, false);
089:
090: return new PluginSessionCallback() {
091: public void sqlInternalFrameOpened(
092: SQLInternalFrame sqlInternalFrame, ISession sess) {
093: //plugin supports Session main window only
094: }
095:
096: public void objectTreeInternalFrameOpened(
097: ObjectTreeInternalFrame objectTreeInternalFrame,
098: ISession sess) {
099: //plugin supports Session main window only
100: }
101: };
102: } catch (Exception e) {
103: throw new RuntimeException(e);
104: }
105: }
106:
107: public HibernatePluginResources getResources() {
108: return _resources;
109: }
110:
111: public void setHibernatePrefsListener(
112: HibernatePrefsListener hibernatePrefsListener) {
113: _curHibernatePrefsListener = hibernatePrefsListener;
114: }
115:
116: public HibernatePrefsListener removeHibernatePrefsListener() {
117: HibernatePrefsListener buf = _curHibernatePrefsListener;
118: _curHibernatePrefsListener = null;
119: return buf;
120:
121: }
122: }
|