Package ru.snake.amazonwatcher.model

Examples of ru.snake.amazonwatcher.model.ProductInfo


    return result;
  }

  public static void updateProductPrice(AbstractProductModel model, int index) {
    ProductInfo pi = model.get(index);
    SiteParser parser = ParserFactory.createParser(pi.getHost());

    if (parser != null) {
      PriceInfo newPrice;

      parser.parseUrl(pi.getUrl());

      newPrice = parser.getPrice();

      if (newPrice.getPrice() > 0.01f
          && Math.abs(newPrice.getPrice() - pi.getPrice()) > 0.01f) {
        try {
          new PriceChangedDialog(pi, newPrice);
        } catch (Exception e) {
        }
      }

      pi.setPriceInfo(newPrice);

      model.set(index, pi);
    }
  }
View Full Code Here


    while (!isInterrupted()) {
      if (dataModel.size() > 0) {
        i = i % dataModel.size();

        ProductInfo pi = dataModel.get(i);
        setStatus(pi.getName());

        Util.updateProductPrice(dataModel, i);

        clearStatus();
View Full Code Here

    setModal(true);
    setVisible(true);
  }

  private void initComponents() {
    ProductInfo pi;

    productName = new JTextField();
    productUrl = new JTextField(60);
    okButton = new JButton("Сохранить");
    cancelButton = new JButton("Закрыть");

    pi = dataModel.get(selectedIndex);
    productName.setText(pi.getName());
    productUrl.setText(pi.getUrl().toString());

    Box productBox = Box.createVerticalBox();
    productBox.add(new JLabel("Наименование товара:"));
    productBox.add(productName);
    productBox.add(new JLabel("Ссылка на страницу товара:"));
    productBox.add(productUrl);

    Box buttonbox = Box.createHorizontalBox();
    buttonbox.add(okButton);
    buttonbox.add(cancelButton);

    okButton.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        String url = productUrl.getText();
        ProductInfo pi = dataModel.get(selectedIndex);

        pi.setName(productName.getText());

        if (!pi.setUrl(url)) {
          JOptionPane.showMessageDialog(EditProductDialog.this,
              "Неверная ссылка на товар.", "Ошибка...",
              JOptionPane.WARNING_MESSAGE);

          return;
View Full Code Here

  public void actionPerformed(ActionEvent arg0) {
    Thread thread = new Thread(new Runnable() {
      public void run() {
        for (int i = 0; i < dataModel.size(); i++) {
          ProductInfo pi = dataModel.get(i);
          SiteParser parser = ParserFactory.createParser(pi.getHost());

          setStatus(pi.getName());

          if (parser != null) {
            PriceInfo newPrice;

            parser.parseUrl(pi.getUrl());
            newPrice = parser.getPrice();

            pi.setPriceInfo(newPrice);

            dataModel.set(i, pi);
          }
        }
View Full Code Here

    buttonsBox.add(cancelButton);

    okButton.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        String url = productUrl.getText();
        ProductInfo pi = new ProductInfo();

        pi.setName(productName.getText());

        if (!pi.setUrl(url)) {
          JOptionPane.showMessageDialog(AddProductDialog.this,
              "Неверная ссылка на товар.", "Ошибка...",
              JOptionPane.WARNING_MESSAGE);

          return;
View Full Code Here

    selectedIntex = selectionModel.getMinSelectionIndex();

    if (selectedIntex != -1) {
      URI uri;
      ProductInfo productInfo = this.dataModel.get(selectedIntex);

      if (!java.awt.Desktop.isDesktopSupported())
        return;

      Desktop desktop = java.awt.Desktop.getDesktop();

      if (!desktop.isSupported(Action.BROWSE))
        return;

      try {
        uri = new URI(productInfo.getUrl().toString());
      } catch (URISyntaxException e) {
        return;
      }

      try {
View Full Code Here

TOP

Related Classes of ru.snake.amazonwatcher.model.ProductInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.