001: package net.sourceforge.squirrel_sql.plugins.favs;
002:
003: /*
004: * Copyright (C) 2001 Colin Bell
005: * colbell@users.sourceforge.net
006: *
007: * This program is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU General Public License
009: * as published by the Free Software Foundation; either version 2
010: * of the License, or any later version.
011: *
012: * This program 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
015: * GNU General Public License for more details.
016: *
017: * You should have received a copy of the GNU General Public License
018: * along with this program; if not, write to the Free Software
019: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
020: */
021: import java.io.IOException;
022:
023: import javax.swing.JMenu;
024:
025: import net.sourceforge.squirrel_sql.client.IApplication;
026: import net.sourceforge.squirrel_sql.client.action.ActionCollection;
027: import net.sourceforge.squirrel_sql.client.plugin.DefaultPlugin;
028: import net.sourceforge.squirrel_sql.client.plugin.PluginException;
029: import net.sourceforge.squirrel_sql.client.plugin.PluginResources;
030:
031: public class SavedQueriesPlugin extends DefaultPlugin {
032: private PluginResources _resources;
033: private FoldersCache _cache;
034:
035: private interface IMenuResourceKeys {
036: String QUERIES = "queries";
037: }
038:
039: public String getInternalName() {
040: return "favs";
041: }
042:
043: public String getDescriptiveName() {
044: return "Saved Queries Plugin";
045: }
046:
047: /**
048: * Returns the current version of this plugin.
049: *
050: * @return the current version of this plugin.
051: */
052: public String getVersion() {
053: return "0.1";
054: }
055:
056: /**
057: * Returns the authors name.
058: *
059: * @return the authors name.
060: */
061: public String getAuthor() {
062: return "Udi Ipalawatte";
063: }
064:
065: public void initialize() throws PluginException {
066: super .initialize();
067: IApplication app = getApplication();
068: try {
069: _cache = new FoldersCache(app,
070: getPluginUserSettingsFolder());
071: } catch (IOException ex) {
072: throw new PluginException(ex);
073: }
074: _cache.load();
075:
076: _resources = new PluginResources(
077: "net.sourceforge.squirrel_sql.plugins.favs.saved_queries",
078: this );
079:
080: ActionCollection coll = app.getActionCollection();
081:
082: coll.add(new DeleteSavedQueriesFolderAction(app, _resources));
083: coll.add(new NewSavedQueriesFolderAction(app, _resources));
084: coll
085: .add(new OrganizeSavedQueriesAction(app, _resources,
086: _cache));
087: coll.add(new RenameSavedQueriesFolderAction(app, _resources));
088:
089: createMenu();
090: }
091:
092: /**
093: * @see IPlugin#unload()
094: */
095: public void unload() {
096: _cache.save();
097: super .unload();
098: }
099:
100: private void createMenu() {
101: IApplication app = getApplication();
102: ActionCollection coll = app.getActionCollection();
103:
104: JMenu menu = _resources.createMenu(IMenuResourceKeys.QUERIES);
105: _resources.addToMenu(
106: coll.get(OrganizeSavedQueriesAction.class), menu);
107: menu.addSeparator();
108:
109: app.addToMenu(IApplication.IMenuIDs.PLUGINS_MENU, menu);
110: }
111: }
|