示例#1
0
 public static void main(String[] args) {
   if (args.length == 0) {
     gui = new Gui();
     gui.setVisible(true);
   } else if (args.length == 3 || args.length == 4) {
     Main.setBlogName(args[0]);
     Main.load();
     if (args.length == 3) {
       int start, limit;
       try {
         start = Integer.parseInt(args[1]);
         limit = Integer.parseInt(args[2]);
       } catch (Exception e) {
         Main.status("usage: Main <blogname> <start_page> <end_page> -hires");
         Main.status("start_page and end_page must be integers >= 1");
         return;
       }
       Main.run(start, limit);
       Main.save();
     } else if (args.length == 4 && args[3].equals("-hires")) {
       Main.downloadHiRes();
       Main.save();
     } else {
       Main.status("usage: Main <blogname> <start_page> <end_page> -hires");
     }
   } else {
     Main.status("usage: Main <blogname> <start_page> <end_page> -hires");
   }
 }
示例#2
0
 private static void error(String error) {
   if (gui == null) {
     System.err.println(error);
   } else {
     gui.setStatus(error);
   }
 }
示例#3
0
 private static void status(String status) {
   if (gui == null) {
     System.out.println(status);
   } else {
     gui.setStatus(status);
   }
 }
示例#4
0
 public static void downloadHiRes() {
   Main.status("Downloading hi res versions of photos in database.");
   if (gui != null) {
     gui.setProgress(0);
     gui.setMaxProgress(pic_pic_hash.keySet().size());
   }
   int progress = 0;
   for (Picture picture : pic_pic_hash.keySet()) {
     if (!picture.downloaded_hi) {
       tryResUrls(picture);
     }
     if (gui != null) {
       gui.setProgress(progress);
       progress++;
     }
   }
   if (gui != null) {
     gui.setProgress(progress);
     progress++;
   }
   Main.status("Done downloading hi res versions.");
 }
示例#5
0
 public static void run(int start_page, int end_page) {
   if (start_page < 1 || end_page < 1) {
     Main.status("start_page and end_page must be integers >= 1");
     return;
   }
   int progress = 0;
   if (gui != null) {
     gui.setProgress(progress);
   }
   if (end_page >= start_page) {
     if (gui != null) {
       gui.setMaxProgress(end_page - start_page);
     }
     for (int i = start_page; i <= end_page; i++) {
       boolean exists =
           Main.handleURL(String.format("http://%s.tumblr.com/page/%s", Main.blogname, i));
       if (!exists) {
         Main.status(String.format("We ran out of posts to process at page %s.", i));
         break;
       }
       if (gui != null) {
         gui.setProgress(progress);
         progress++;
       }
     }
   } else {
     if (gui != null) {
       gui.setMaxProgress(start_page - end_page);
     }
     for (int i = start_page; i >= end_page; i--) {
       boolean exists =
           Main.handleURL(String.format("http://%s.tumblr.com/page/%s", Main.blogname, i));
       if (!exists) {
         Main.status(String.format("We ran out of posts to process at page %s.", i));
         break;
       }
       if (gui != null) {
         gui.setProgress(progress);
         progress++;
       }
     }
   }
   if (gui != null) {
     gui.setProgress(progress);
   }
   Main.writeDuplicates();
 }
示例#6
0
  /** Create the panel. */
  public MyPanel() {
    // setBackground(new Color(175, 238, 238));
    setBackground(Gui.getThemeColorLight());
    setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));

    btnDownload.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            Downloader d = new Downloader();
            d.setVisible(true);
            try {
              String source = location.substring(6);
              d.setData(location);
              //// String dest="z://"+lblFileNameHere.getText();
              // Gui.debug(source+"   "+dest);
              // copyFile("//172.16.144.135/Videos/Bhakti/SWASAN DI
              // MAALA/AVSEQ02.avi","z://xyz.avi");
              //// copyFile(source,dest);
            } catch (Exception e) {
              Gui.debug("MyPanel-Copy error:" + e.getLocalizedMessage());
            }
          }
        });

    lblFileNameHere = new JLabel("file name here");
    lblFileNameHere.setFont(new Font("Tahoma", Font.BOLD, 11));
    lblFileNameHere.setForeground(new Color(255, 255, 255));
    lblFileNameHere.setToolTipText("hi there");
    final Dimension size = lblFileNameHere.getPreferredSize();
    lblFileNameHere.setMinimumSize(size);
    lblFileNameHere.setPreferredSize(size);

    JButton btnOpenLocation = new JButton("Open Location..");
    btnOpenLocation.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            try {
              OpenLocationBox olc = new OpenLocationBox(location);
            } catch (Exception e) {
              LogWindow.addErrorLog(e.getLocalizedMessage());
            }
          }
        });

    txtFullAddress = new JTextField();
    txtFullAddress.setText("full address goes here");
    txtFullAddress.setColumns(10);

    JLabel lblFileSize = new JLabel("");

    GroupLayout groupLayout = new GroupLayout(this);
    groupLayout.setHorizontalGroup(
        groupLayout
            .createParallelGroup(Alignment.TRAILING)
            .addGroup(
                groupLayout
                    .createSequentialGroup()
                    .addContainerGap()
                    .addGroup(
                        groupLayout
                            .createParallelGroup(Alignment.TRAILING)
                            .addGroup(
                                groupLayout
                                    .createSequentialGroup()
                                    .addComponent(
                                        lblFileNameHere,
                                        GroupLayout.DEFAULT_SIZE,
                                        392,
                                        Short.MAX_VALUE)
                                    .addGap(16)
                                    .addComponent(
                                        btnOpen,
                                        GroupLayout.PREFERRED_SIZE,
                                        99,
                                        GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(ComponentPlacement.RELATED)
                                    .addComponent(btnDownload)
                                    .addContainerGap())
                            .addGroup(
                                groupLayout
                                    .createSequentialGroup()
                                    .addPreferredGap(
                                        ComponentPlacement.RELATED, 474, Short.MAX_VALUE)
                                    .addComponent(lblFileSize)
                                    .addGap(128))
                            .addGroup(
                                groupLayout
                                    .createSequentialGroup()
                                    .addComponent(
                                        txtFullAddress,
                                        GroupLayout.DEFAULT_SIZE,
                                        477,
                                        Short.MAX_VALUE)
                                    .addPreferredGap(ComponentPlacement.RELATED)
                                    .addComponent(btnOpenLocation)
                                    .addContainerGap()))));
    btnOpen.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            try {
              OpenFileBox olc = new OpenFileBox(location);
            } catch (Exception e) {
              LogWindow.addErrorLog(e.getLocalizedMessage());
            }
          }
        });
    groupLayout.setVerticalGroup(
        groupLayout
            .createParallelGroup(Alignment.LEADING)
            .addGroup(
                groupLayout
                    .createSequentialGroup()
                    .addContainerGap()
                    .addGroup(
                        groupLayout
                            .createParallelGroup(Alignment.BASELINE)
                            .addComponent(
                                lblFileNameHere,
                                GroupLayout.PREFERRED_SIZE,
                                25,
                                GroupLayout.PREFERRED_SIZE)
                            .addComponent(btnDownload)
                            .addComponent(btnOpen))
                    .addPreferredGap(ComponentPlacement.RELATED)
                    .addGroup(
                        groupLayout
                            .createParallelGroup(Alignment.BASELINE)
                            .addComponent(
                                txtFullAddress,
                                GroupLayout.PREFERRED_SIZE,
                                22,
                                GroupLayout.PREFERRED_SIZE)
                            .addComponent(lblFileSize)
                            .addComponent(btnOpenLocation))
                    .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
    setLayout(groupLayout);
  }
示例#7
0
 public void toggleBackground() {
   this.setBackground(Gui.getThemeColorLight2());
 }