Esempio n. 1
0
  /** Initialize this plugin. */
  public synchronized void initialize() throws PluginException {
    super.initialize();

    _resources = new SyntaxPluginResources(this);

    // Folder to store user settings.
    try {
      _userSettingsFolder = getPluginUserSettingsFolder();
    } catch (IOException ex) {
      throw new PluginException(ex);
    }

    // Load plugin preferences.
    loadPrefs();

    // Install the factory for creating SQL entry text controls.
    final IApplication app = getApplication();
    final ISQLEntryPanelFactory originalFactory = app.getSQLEntryPanelFactory();
    // _sqlEntryFactoryProxy = new OsterSQLEntryAreaFactory(this, originalFactory);

    _sqlEntryFactoryProxy = new SQLEntryPanelFactoryProxy(this, originalFactory);

    app.setSQLEntryPanelFactory(_sqlEntryFactoryProxy);

    _autoCorrectProvider = new AutoCorrectProviderImpl(_userSettingsFolder);

    createMenu();

    createAdditionalActions();
  }
 /**
  * Perform this action. Use the <TT>CloseAllSessionsCommand</TT>.
  *
  * @param evt The current event.
  */
 public void actionPerformed(ActionEvent evt) {
   IApplication app = getApplication();
   CursorChanger cursorChg = new CursorChanger(app.getMainFrame());
   cursorChg.show();
   try {
     new CloseAllSessionsCommand(app).execute();
   } finally {
     cursorChg.restore();
   }
 }
 void load(IApplication app) {
   _prefs = app.getSquirrelPreferences();
   _plugins = app.getPluginManager().getPluginInformation();
   _appArgs = ApplicationArguments.getInstance().getRawArguments();
   _version = Version.getVersion();
   _pluginLoc = new ApplicationFiles().getPluginsDirectory().getAbsolutePath();
   URL[] urls = app.getPluginManager().getPluginURLs();
   _pluginURLs = new URLWrapper[urls.length];
   for (int i = 0; i < urls.length; ++i) {
     _pluginURLs[i] = new URLWrapper(urls[i]);
   }
 }
Esempio n. 4
0
  private void createMenu() {
    IApplication app = getApplication();
    ActionCollection coll = app.getActionCollection();

    JMenu menu = _resources.createMenu(IMenuResourceKeys.MENU);
    app.addToMenu(IApplication.IMenuIDs.SESSION_MENU, menu);

    Action act = new ConfigureAutoCorrectAction(app, _resources, this);
    coll.add(act);
    _resources.addToMenu(act, menu);

    act = new FindAction(getApplication(), _resources);
    coll.add(act);
    _resources.addToMenu(act, menu);

    act = new FindSelectedAction(getApplication(), _resources);
    coll.add(act);
    _resources.addToMenu(act, menu);

    act = new RepeatLastFindAction(getApplication(), _resources);
    coll.add(act);
    _resources.addToMenu(act, menu);

    act = new MarkSelectedAction(getApplication(), _resources);
    coll.add(act);
    _resources.addToMenu(act, menu);

    act = new ReplaceAction(getApplication(), _resources);
    coll.add(act);
    _resources.addToMenu(act, menu);

    act = new UnmarkAction(getApplication(), _resources);
    coll.add(act);
    _resources.addToMenu(act, menu);

    act = new GoToLineAction(getApplication(), _resources);
    coll.add(act);
    _resources.addToMenu(act, menu);

    act = new DuplicateLineAction(getApplication(), _resources);
    coll.add(act);
    _resources.addToMenu(act, menu);

    act = new CommentAction(getApplication(), _resources);
    coll.add(act);
    _resources.addToMenu(act, menu);

    act = new UncommentAction(getApplication(), _resources);
    coll.add(act);
    _resources.addToMenu(act, menu);
  }
Esempio n. 5
0
 void load() {
   try {
     if (new File(_queriesFileName).exists()) {
       XMLObjectCache cache = new XMLObjectCache();
       cache.load(_queriesFileName, getClass().getClassLoader());
       Iterator it = cache.getAllForClass(Folder.class);
       if (it.hasNext()) {
         _rootFolder = (Folder) it.next();
       }
     }
   } catch (FileNotFoundException ignore) { // first time user has run pgm.
   } catch (XMLException ex) {
     final Logger log = _app.getLogger();
     log.showMessage(Logger.ILogTypes.ERROR, "Error loading queries file: " + _queriesFileName);
     log.showMessage(Logger.ILogTypes.ERROR, ex);
   } catch (DuplicateObjectException ex) {
     final Logger log = _app.getLogger();
     log.showMessage(Logger.ILogTypes.ERROR, "Error loading queries file: " + _queriesFileName);
     log.showMessage(Logger.ILogTypes.ERROR, ex);
   }
 }
Esempio n. 6
0
 /** Save cached objects. */
 void save() {
   try {
     XMLObjectCache cache = new XMLObjectCache();
     try {
       if (_rootFolder != null) {
         cache.add(_rootFolder);
       }
     } catch (DuplicateObjectException ignore) {
     }
     cache.save(_queriesFileName);
   } catch (IOException ex) {
     final Logger logger = _app.getLogger();
     logger.showMessage(
         Logger.ILogTypes.ERROR, "Error occured saving queries to " + _queriesFileName);
     logger.showMessage(Logger.ILogTypes.ERROR, ex);
   } catch (XMLException ex) {
     final Logger logger = _app.getLogger();
     logger.showMessage(
         Logger.ILogTypes.ERROR, "Error occured saving queries to " + _queriesFileName);
     logger.showMessage(Logger.ILogTypes.ERROR, ex);
   }
 }
Esempio n. 7
0
 public void execute() {
   ValidateSQLCommand cmd =
       new ValidateSQLCommand(
           _valProps._prefs,
           _valProps._sessionProps,
           _valProps._sql,
           _valProps._stmtSepChar,
           _valProps._solComment);
   try {
     cmd.execute();
     _valProps._msgHandler.showMessage(cmd.getResults());
   } catch (Throwable th) {
     final String msg = "Error occured when talking to the web service";
     s_log.error(msg, th);
     _app.showErrorDialog(msg, th);
   }
 }
Esempio n. 8
0
  /**
   * Create a new session.
   *
   * @param app Application API.
   * @param driver JDBC driver for session.
   * @param alias Defines URL to database.
   * @param conn Connection to database.
   * @throws IllegalArgumentException if any parameter is null.
   */
  public Session(IApplication app, ISQLDriver driver, ISQLAlias alias, SQLConnection conn) {
    super();
    if (app == null) {
      throw new IllegalArgumentException("null IApplication passed");
    }
    if (driver == null) {
      throw new IllegalArgumentException("null ISQLDriver passed");
    }
    if (alias == null) {
      throw new IllegalArgumentException("null ISQLAlias passed");
    }
    if (conn == null) {
      throw new IllegalArgumentException("null SQLConnection passed");
    }

    _app = app;
    _driver = driver;
    _alias = alias;
    _conn = conn;

    _props.assignFrom(_app.getSquirrelPreferences().getSessionProperties());
  }
  /** Dump the application. */
  public void execute() {
    List<File> files = new ArrayList<File>();
    List<String> titles = new ArrayList<String>();
    synchronized (_app) {
      ApplicationStatusBean bean = new ApplicationStatusBean();
      bean.load(_app);
      try {
        files.add(createJavaBeanDumpFile(bean));
        // i18n[DumpApplicationCommand.title.status=Application Status Bean]
        titles.add(s_stringMgr.getString("DumpApplicationCommand.title.status"));
      } catch (Throwable th) {
        // i18n[DumpApplicationCommand.error.dumpingstatus=Error dumping Application Status bean]
        final String msg = s_stringMgr.getString("DumpApplicationCommand.error.dumpingstatus");
        _msgHandler.showMessage(msg);
        _msgHandler.showMessage(th, null);
        s_log.error(msg, th);
      }

      // Dump System Properties.
      try {
        File tempFile = File.createTempFile(PREFIX, SUFFIX);
        IDataSetViewer dest = new DataSetViewerTextFileDestination(tempFile);
        dest.show(new HashtableDataSet(System.getProperties()));
        files.add(tempFile);
        // i18n[DumpApplicationCommand.title.systemprops=System Properties]
        titles.add(s_stringMgr.getString("DumpApplicationCommand.title.systemprops"));
      } catch (Throwable th) {
        // i18n[DumpApplicationCommand.error.dumpingsystemprops=Error dumping metadata]
        final String msg = s_stringMgr.getString("DumpApplicationCommand.error.dumpingsystemprops");
        _msgHandler.showMessage(msg);
        _msgHandler.showMessage(th, null);
        s_log.error(msg, th);
      }

      // Dump drivers
      try {
        File tempFile = File.createTempFile(PREFIX, SUFFIX);
        _app.getDataCache().saveDrivers(tempFile);
        files.add(tempFile);
        // i18n[DumpApplicationCommand.title.drivers=Drivers]
        titles.add(s_stringMgr.getString("DumpApplicationCommand.title.drivers"));
      } catch (Throwable th) {
        // i18n[DumpApplicationCommand.error.dumpingdrivers=Error dumping drivers]
        final String msg = s_stringMgr.getString("DumpApplicationCommand.error.dumpingdrivers");
        _msgHandler.showMessage(msg);
        _msgHandler.showMessage(th, null);
        s_log.error(msg, th);
      }

      // Dump aliases.
      try {
        File tempFile = File.createTempFile(PREFIX, SUFFIX);
        _app.getDataCache().saveAliases(tempFile);
        files.add(tempFile);
        // i18n[DumpApplicationCommand.title.aliases=Aliases]
        titles.add(s_stringMgr.getString("DumpApplicationCommand.title.aliases"));
      } catch (Throwable th) {
        // i18n[DumpApplicationCommand.error.dumpingaliases=Error dumping aliases]
        final String msg = s_stringMgr.getString("DumpApplicationCommand.error.dumpingaliases");
        _msgHandler.showMessage(msg);
        _msgHandler.showMessage(th, null);
        s_log.error(msg, th);
      }

      // Dump sessions.
      final ISession[] sessions = _app.getSessionManager().getConnectedSessions();
      final DumpSessionCommand sessionCmd = new DumpSessionCommand();
      for (int i = 0; i < sessions.length; ++i) {
        try {
          File tempFile = File.createTempFile(PREFIX, SUFFIX);
          sessionCmd.setSession(sessions[i]);
          sessionCmd.setDumpFile(tempFile);
          sessionCmd.execute();
          files.add(tempFile);
          // i18n[DumpApplicationCommand.title.sessiondump=Session Dump: {0}]
          String title =
              s_stringMgr.getString(
                  "DumpApplicationCommand.title.sessiondump", sessions[i].getIdentifier());
          titles.add(title);
        } catch (Throwable th) {
          // i18n[DumpApplicationCommand.error.sessiondump=Error dumping sessions]
          final String msg = s_stringMgr.getString("DumpApplicationCommand.error.sessiondump");
          _msgHandler.showMessage(msg);
          _msgHandler.showMessage(th, null);
          s_log.error(msg, th);
        }
      }
    }

    combineTempFiles(titles, files);
    deleteTempFiles(files);
  }
Esempio n. 10
0
  /**
   * Create some additional actions and add them to the application. These actions are not part of
   * the menu, but needs to be initialized with the resources of the syntax plugin. Some of these
   * actions may be depend on a concrete editor.
   */
  private void createAdditionalActions() {
    IApplication app = getApplication();
    ActionCollection coll = app.getActionCollection();

    coll.add(new SquirrelCopyAsRtfAction(getApplication(), _resources));
  }