PDFController.java :  » Game » galatichero » net » narusas » si » auction » app » attested » Java Open Source

Java Open Source » Game » galatichero 
galatichero » net » narusas » si » auction » app » attested » PDFController.java
package net.narusas.si.auction.app.attested;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.ListSelectionModel;
import javax.swing.SwingUtilities;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import net.narusas.si.auction.app.App;
import net.narusas.si.auction.app.Controller;
import net.narusas.si.auction.app.ui.ListModel;
import net.narusas.si.auction.app.ui.ListModel;
import net.narusas.si.auction.app.ui.ListModel;
import net.narusas.si.auction.app.ui.ListModel;
import net.narusas.si.auction.app.ui.ListModel;
import net.narusas.si.auction.builder.Batch;
import net.narusas.si.auction.fetchers.Fetcher;
import net.narusas.si.auction.fetchers.Fetcher;
import net.narusas.si.auction.model.;
import net.narusas.si.auction.model.;
import net.narusas.si.auction.model.;
import net.narusas.si.auction.model.;
import net.narusas.si.auction.model.;
import net.narusas.si.auction.model.dao.Dao;

public class PDFController implements Controller {

  private JList List;
  private JList List;
  private ListModel ListModel;
  private JList List;
  private ListModel ListModel;
  protected final Logger logger = LoggerFactory.getLogger("auction");
  private JList List;
  private JList List;
  private ListModel ListModel;
  private ListModel ListModel;
  private  selected;
  private JLabel Label;
  private JLabel Label;
  private JLabel Label;
  private JButton ;
  private JLabel Label;

  AtestedMonitor monitor = new AtestedMonitor();
  private JFrame frame;
  Browser browser = new Browser();

  @Override
  public void enableControl(boolean b) {

  }

  public void setList(JList list) {
    this.List = list;
    List.setModel(new ListModel(.));
    List.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    List.addListSelectionListener(new ListSelectionListener() {
      @Override
      public void valueChanged(ListSelectionEvent e) {
        if (e.getValueIsAdjusting()) {
          return;
        }
        final Object[] selecteds = List.getSelectedValues();
        if (selecteds == null || selecteds.length == 0) {
          ListModel.clear();
          return;
        }

        new Thread() {
          @Override
          public void run() {
            if (ListModel == null) {
              return;
            }

            ListModel.clear();
            ListModel.clear();
            ListModel.clear();
            ListModel.clear();
            select(null);
            ArrayList<> temp = new ArrayList<>();

            for (Object object : selecteds) {
               court = () object;
              List<> charges = court.getWorkSet();
              if (charges == null) {
                continue;
              }
              temp.addAll(charges);
            }
            sort(temp);
            for ( c : temp) {
              add(c);
            }

          }

          private void add(final  sagun) {
            SwingUtilities.invokeLater(new Runnable() {
              @Override
              public void run() {
                ListModel.addElement(sagun);
              }
            });
          }
        }.start();

        System.out.println();
      }
    });
  }

  private void sort(List<> charges) {
    Collections.sort(charges, new Comparator<>() {
      @Override
      public int compare( o1,  o2) {
        return o1.get().compareTo(o2.get());
      }
    });
  }

  public void setList(JList list) {
    List = list;
    ListModel = new ListModel();
    List.setModel(ListModel);
    List.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    List.addListSelectionListener(new ListSelectionListener() {

      @Override
      public void valueChanged(ListSelectionEvent e) {
        if (e.getValueIsAdjusting()) {
          return;
        }
        final Object[] selecteds = List.getSelectedValues();
        if (selecteds == null || selecteds.length == 0) {
          ListModel.clear();
          return;
        }

        new Thread() {
          @Override
          public void run() {
            if (ListModel == null) {
              return;
            }
            select(null);
            ListModel.clear();
            ListModel.clear();
            ListModel.clear();

             charge = () selecteds[0];
            logger.info(charge.get()
                + " .  .  . ");
            Fetcher fetcher = new Fetcher();
            Dao eventDao = (Dao) App.context.getBean("DAO");
            try {
              List<>  = fetcher.fetchAll(charge);
              List<> stored = eventDao.findBy(charge);
              System.out.println("#### .");
              System.out.println();
              for ( event : ) {
                if (event.isIs() == false) {
                  continue;
                }
                for ( storedEvent : stored) {
                  if (event.get() == storedEvent
                      .get()) {

                    add(storedEvent);
                    continue;
                  }
                }
              }
              logger.info(" .   . ");

            } catch (IOException e) {
              e.printStackTrace();
            }
          }

          private void add(final  sagun) {
            SwingUtilities.invokeLater(new Runnable() {
              @Override
              public void run() {
                ListModel.addElement(sagun);
              }
            });
          }

        }.start();
      }
    });
  }

  public void setList(JList list) {
    List = list;
    ListModel = new ListModel();
    List.setModel(ListModel);
    List.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    List.addListSelectionListener(new ListSelectionListener() {

      @Override
      public void valueChanged(ListSelectionEvent e) {
        if (e.getValueIsAdjusting()) {
          return;
        }
        final Object[] selecteds = List.getSelectedValues();
        if (selecteds == null || selecteds.length == 0) {
          ListModel.clear();
          return;
        }
        new Thread() {
          @Override
          public void run() {
            if (ListModel == null) {
              return;
            }
            ListModel.clear();
            ListModel.clear();
            select(null);
            logger.info(" .  .");
              = () selecteds[0];
            Fetcher f1 = new Fetcher();
            try {
              f1.update(, false);
              List<> s = .get();
              for (final   : s) {
                SwingUtilities.invokeLater(new Runnable() {
                  @Override
                  public void run() {
                    ListModel.addElement();
                  }
                });
              }
              logger.info(" .   . ");
            } catch (Exception e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
            }
          }
        }.start();
      }

    });

  }

  public void setList(JList list) {
    List = list;
    ListModel = new ListModel();
    List.setModel(ListModel);
    List.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    List.addListSelectionListener(new ListSelectionListener() {

      @Override
      public void valueChanged(ListSelectionEvent e) {
        if (e.getValueIsAdjusting()) {
          return;
        }
        final Object[] selecteds = List.getSelectedValues();
        if (selecteds == null || selecteds.length == 0) {
          return;
        }
        new Thread() {
          @Override
          public void run() {
            if (ListModel == null) {
              return;
            }
            ListModel.clear();
            select(null);
              = () selecteds[0];

            ArrayList<> s = .gets();
            if (s == null) {
              return;
            }
            for (final   : s) {
              SwingUtilities.invokeLater(new Runnable() {
                @Override
                public void run() {
                  ListModel.addElement();
                }
              });
            }

          }
        }.start();
      }
    });

  }

  public void setList(JList list) {
    List = list;
    ListModel = new ListModel();
    List.setModel(ListModel);
    List.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    List.addListSelectionListener(new ListSelectionListener() {

      @Override
      public void valueChanged(ListSelectionEvent e) {
        if (e.getValueIsAdjusting()) {
          return;
        }
        final Object[] selecteds = List.getSelectedValues();
        if (selecteds == null || selecteds.length == 0) {
          select(null);
          return;
        }
          = () selecteds[0];
        select();

      }
    });
  }

  protected void select( ) {
    selected = ;
    SwingUtilities.invokeLater(new Runnable() {
      @Override
      public void run() {
        if (selected == null) {
          Label.setText("");
          Label.setText("");
          Label.setText("");
          return;
        }
        Label.setText(selected.getAddress());
        Label.setText(selected.getType());
        Label.setText(selected.getComment());
      }
    });

  }

  public void setLabel(JLabel label) {
    Label = label;
  }

  public void setLabel(JLabel label) {
    Label = label;
  }

  public void setLabel(JLabel label) {
    Label = label;
  }

  public void setButton(JButton button) {
     = button;
    .addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
        if (selected == null) {
          return;
        }
        if (alreadyDownloaded(selected)) {
          int n = JOptionPane.showConfirmDialog(frame,
              "  .  ?",
              "An Inane Question", JOptionPane.YES_NO_OPTION);
          if (n == JOptionPane.YES_OPTION) {
            browse();
            startMonitor();
          } else if (n == JOptionPane.NO_OPTION) {
          }
          return;
        } else {
          browse();
          startMonitor();
        }

      }
    });
  }

  protected boolean alreadyDownloaded( item) {
    return new AtestedMonitor().alreadyDownloaded(item);
  }

  protected void startMonitor() {
    if (monitor != null && monitor.isAlive()) {
      try {
        monitor.stop();
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
    logger.info("  ");
    monitor = new AtestedMonitor();
    monitor.setTarget(selected);
    monitor.setStatus(Label);
    monitor.start();
  }

  public void setLabel(JLabel label) {
    Label = label;
    Label.setText("");
  }

  private void browse() {
    /**
     * inpSvcCls=on &selkindcls= &e001admin_regn1= &e001admin_regn3=
     * &a312lot_no= &a301buld_name= &a301buld_no_buld= &a301buld_no_room=
     * &pin=11611996016086 &regt_no=1161 &svc_cls=VW &fromjunja=Y
     * 
     * 
     * 
     * inpSvcCls=on &selkindcls= &e001admin_regn1= &e001admin_regn3=
     * &a312lot_no= &a301buld_name= &a301buld_no_buld= &a301buld_no_room=
     * &pin=11611996011155 &regt_no=1161 &svc_cls=VW &fromjunja=Y
     */
    try {
      String uriString = "http://www.iros.go.kr/iris/index.jsp?" + //
          "inpSvcCls=on" + //
          "&selkindcls=" + //
          "&e001admin_regn1=" + //
          "&e001admin_regn3=" + //
          "&a312lot_no=" + //
          "&a301buld_name=" + //
          "&a301buld_no_buld=" + //
          "&a301buld_no_room=" + //
          "&pin=" + selected.getBuNo() + //
          "&regt_no=" + selected.getBuNo().substring(0, 4) + //
          "&svc_cls=VW" + //
          "&fromjunja=Y";
      System.out.println(uriString);
//       java.awt.Desktop.getDesktop().browse(new URI(uriString));
      browser.setURL(uriString);
    } catch (Exception e1) {
      // TODO Auto-generated catch block
      e1.printStackTrace();
    }
  }

  public void setFrame(JFrame jFrame) {
    this.frame = jFrame;

  }

}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.