Exemple #1
0
  // Allow the user to type in a symbol string, then make sure the symbol
  // is visible and highlighted in the table
  private void findSymbol() {
    // Handle all action in a separate thread so we dont
    // hold up the dispatch thread. See O'Reilley Swing pg 1138-9.
    Thread thread =
        new Thread() {

          public void run() {
            JDesktopPane desktop = nz.org.venice.ui.DesktopManager.getDesktop();

            Symbol symbol = SymbolListDialog.getSymbol(desktop, Locale.getString("FIND_SYMBOL"));

            if (symbol != null) {
              List quotes = model.getQuotes();
              int i = 0;

              for (Iterator iterator = quotes.iterator(); iterator.hasNext(); i++) {
                Quote quote = (Quote) iterator.next();

                if (symbol.equals(quote.getSymbol())) {
                  // Select row and make it visible
                  setRowSelectionInterval(i, i);
                  setVisible(i, EODQuoteModel.SYMBOL_COLUMN);
                  return;
                }
              }

              // If we got here the symbol wasn't in the table
              JOptionPane.showInternalMessageDialog(
                  DesktopManager.getDesktop(),
                  Locale.getString("SYMBOL_X_NOT_FOUND", symbol.toString()),
                  Locale.getString("SYMBOL_NOT_FOUND"),
                  JOptionPane.INFORMATION_MESSAGE);
            }
          }
        };

    thread.start();
  }
Exemple #2
0
  // Allow the user to show only stocks where the given expression is true
  private void applyFilter() {
    // Handle all action in a separate thread so we dont
    // hold up the dispatch thread. See O'Reilley Swing pg 1138-9.
    Thread thread =
        new Thread() {

          public void run() {

            JDesktopPane desktop = nz.org.venice.ui.DesktopManager.getDesktop();

            String expressionString =
                ExpressionQuery.getExpression(
                    desktop,
                    Locale.getString("FILTER_BY_RULE"),
                    Locale.getString("BY_RULE"),
                    filterExpressionString);

            if (expressionString != null) {
              filterExpressionString = expressionString;

              // Get new list of symbols to display
              final List quotes = extractQuotesUsingRule(filterExpressionString, quoteBundle);

              // Update table
              SwingUtilities.invokeLater(
                  new Runnable() {
                    public void run() {
                      model.setQuotes(quotes);
                    }
                  });
            }
          }
        };

    thread.start();
  }