示例#1
2
 /**
  * This function is used to re-run the analyser, and re-create the rows corresponding the its
  * results.
  */
 private void refreshReviewTable() {
   reviewPanel.removeAll();
   rows.clear();
   GridBagLayout gbl = new GridBagLayout();
   reviewPanel.setLayout(gbl);
   GridBagConstraints gbc = new GridBagConstraints();
   gbc.fill = GridBagConstraints.HORIZONTAL;
   gbc.gridy = 0;
   try {
     Map<String, Long> sums =
         analyser.processLogFile(config.getLogFilename(), fromDate.getDate(), toDate.getDate());
     for (Entry<String, Long> entry : sums.entrySet()) {
       String project = entry.getKey();
       double hours = 1.0 * entry.getValue() / (1000 * 3600);
       addRow(gbl, gbc, project, hours);
     }
     for (String project : main.getProjectsTree().getTopLevelProjects())
       if (!rows.containsKey(project)) addRow(gbl, gbc, project, 0);
     gbc.insets = new Insets(10, 0, 0, 0);
     addLeftLabel(gbl, gbc, "TOTAL");
     gbc.gridx = 1;
     gbc.weightx = 1;
     totalLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 3));
     gbl.setConstraints(totalLabel, gbc);
     reviewPanel.add(totalLabel);
     gbc.weightx = 0;
     addRightLabel(gbl, gbc);
   } catch (IOException e) {
     e.printStackTrace();
   }
   recomputeTotal();
   pack();
 }
示例#2
0
 public static void main(String[] args) {
   EventQueue.invokeLater(
       () -> {
         Main m = new Main();
         m.setVisible(true);
       });
 }
示例#3
0
  private void saveCurrent() {
    PrintWriter writer = null;

    try {
      writer = new PrintWriter("config.txt", "UTF-8");
      writer.println("PhoneNumbers:");

      for (String s : Main.getEmails()) {
        writer.println(s);
      }

      writer.println("Items:");

      for (Item s : Main.getItems()) {
        writer.println(s.getName() + "," + s.getWebsite());
      }

      results.setText("Current settings have been saved sucessfully.");
    } catch (FileNotFoundException e1) {
      e1.printStackTrace();
    } catch (UnsupportedEncodingException e1) {
      e1.printStackTrace();
    }

    writer.close();
  }
示例#4
0
 private static void createAndShowMain() {
   JFrame.setDefaultLookAndFeelDecorated(true);
   JFrame frame = new JFrame("RT Prune Algorithm Simulator");
   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   frame.setLocationRelativeTo(null);
   Main newContentPane = new Main(frame);
   newContentPane.setOpaque(true);
   frame.setContentPane(newContentPane);
   frame.pack();
   frame.setExtendedState(Frame.MAXIMIZED_BOTH);
   frame.setVisible(true);
 }
示例#5
0
  private void addItem() {
    if (!searchName.getText().isEmpty() && !item.getText().isEmpty()) {

      try {
        Main.setItem(
            searchName.getText(),
            "http://www.reddit.com/r/hardwareswap/search?q="
                + item.getText()
                + "&sort=new&restrict_sr=on");

        results.setText("Current Items");

        displayInformation();

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

      searchName.setText("");
      item.setText("");

    } else {

      results.setText("Please provide all info for Item Name, Keyword, and Website");
    }
  }
示例#6
0
 public static void quit() {
   try {
     if (instance.onQuit()) {
       System.exit(0);
     }
   } catch (Exception e) {
     Logger().severe("Error when quiting: " + e.getMessage());
   }
 }
示例#7
0
 public static void closeWindow(AbstractWindow window) {
   if (window.getJustHide()) {
     window.setVisible(false);
   } else {
     if (window.onClose() && instance.onClose(window)) {
       window.setVisible(false);
       removeWindow(window);
     }
   }
 }
示例#8
0
 private void removePhone() {
   String s = JOptionPane.showInputDialog("Index of cell phone to be removed.");
   try {
     int index = Integer.parseInt(s) - 1;
     Main.removePhone(index);
     saveCurrent();
     displayInformation();
   } catch (NumberFormatException nfe) {
     results.setText("Please type in the index number of the cell phone.");
   }
 }
示例#9
0
 private void addPhone() {
   if (phone.getText().length() == 10) {
     if (carriers.getSelectedIndex() == 0) {
       Main.addPhone(phone.getText() + "@txt.att.net");
     }
     if (carriers.getSelectedIndex() == 1) {
       Main.addPhone(phone.getText() + "@myboostmobile.com");
     }
     if (carriers.getSelectedIndex() == 2) {
       Main.addPhone(phone.getText() + "@mobile.celloneusa.com");
     }
     if (carriers.getSelectedIndex() == 3) {
       Main.addPhone(phone.getText() + "@messaging.nextel.com");
     }
     if (carriers.getSelectedIndex() == 4) {
       Main.addPhone(phone.getText() + "@tmomail.net");
     }
     if (carriers.getSelectedIndex() == 5) {
       Main.addPhone(phone.getText() + "@txt.att.net");
     }
     if (carriers.getSelectedIndex() == 6) {
       Main.addPhone(phone.getText() + "@email.uscc.net");
     }
     if (carriers.getSelectedIndex() == 7) {
       Main.addPhone(phone.getText() + "@messaging.sprintpcs.com");
     }
     if (carriers.getSelectedIndex() == 8) {
       Main.addPhone(phone.getText() + "@vtext.com");
     }
     if (carriers.getSelectedIndex() == 9) {
       Main.addPhone(phone.getText() + "@vmobl.com");
     }
     displayInformation();
     phone.setText("");
     carriers.setSelectedIndex(0);
   } else {
     results.setText("Please add 10 digit cell number.");
   }
 }
示例#10
0
  private void displayInformation() {
    results.setText("-Cell Phones-\n");
    if (Main.getEmails().isEmpty()) {
      results.append("\nNo Numbers");
    } else {
      ArrayList<String> emails = Main.getEmails();
      int index = 0;

      for (String s : emails) {
        index++;
        results.append("\n(" + index + ")   " + s);
      }
    }

    results.append("\n\n-Current Items-");
    if (Main.getItems().isEmpty()) {
      results.append("\n\nNo Items");
    } else {
      ArrayList<Item> items = Main.getItems();
      int index = 0;

      for (Item i : items) {
        String s = i.getWebsite().substring(46, i.getWebsite().length());

        index++;

        for (int j = 0; j < s.length(); j++) {
          if (s.substring(j, j + 1).equals("&")) {
            s = s.substring(0, j);
          }
        }

        results.append("\n\n(" + index + ")\nName: \t" + i.getName() + "\nItem: \t" + s);
      }
      results.append("\n\n");
    }
  }
  // Unique methods
  public void checkBottomCard() {
    if (m.getNextEmptyCard() == null) {
      SylladexCard bottomcard = stack.getLast();
      icons.trimToSize();
      JLabel icon = new JLabel(bottomcard.getIcon().getIcon());

      int xpos = m.getScreenSize().width / 2 + (25 * m.getCards().size());
      arrow = new JLabel(Main.createImageIcon("modi/stack/arrow.gif"));
      arrow.setBounds(xpos, m.getDockIconYPosition(), 43, 60);
      icon.setBounds(xpos + 50, m.getDockIconYPosition(), 43, 60);

      m.showDock();

      foreground.add(arrow);
      foreground.add(icon);
      foreground.repaint();

      timer.restart();
      open(bottomcard);
    }
  }
示例#12
0
 /**
  * Load a gui with the specified genome file. No genome is loaded if null
  *
  * @param genomeFile
  * @return
  * @throws IOException
  */
 protected static IGV startGUI(String genomeFile) throws IOException {
   Globals.setHeadless(false);
   IGV igv;
   // If IGV is already open, we get the instance.
   if (IGV.hasInstance()) {
     igv = IGV.getInstance();
     IGV.getMainFrame().setVisible(true);
     System.out.println("Using old IGV");
   } else {
     JFrame frame = new JFrame();
     frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
     Main.open(frame);
     System.out.println("Started new IGV");
     igv = IGV.getInstance();
     assertTrue(IGV.getInstance().waitForNotify(1000));
   }
   if (genomeFile != null) {
     igv.loadGenome(genomeFile, null);
     genome = igv.getGenomeManager().getCurrentGenome();
   }
   return igv;
 }
示例#13
0
  public void actionPerformed(ActionEvent e) {
    // Ask user to confirm exit.
    int reply =
        JOptionPane.showConfirmDialog(
            main,
            bundle.getString("Exit_application_?"),
            bundle.getString("Exit"),
            JOptionPane.YES_NO_OPTION);
    if (reply != JOptionPane.YES_OPTION) return;

    // Save MainFrame's bounds
    Rectangle r = main.getBounds();
    Main.setProperty("window.bounds.width", Integer.toString(r.width));
    Main.setProperty("window.bounds.height", Integer.toString(r.height));
    Main.setProperty("window.bounds.x", Integer.toString(r.x));
    Main.setProperty("window.bounds.y", Integer.toString(r.y));

    // System Exit
    Main.saveProperties();
    Main.exit(0);
  }
示例#14
0
 /**
  * The only constructor of the review dialog, which initialises the dates, sets the outer layout,
  * runs the analyser, creates rows for the results, and displays the window.
  *
  * @param main A link to the parent component.
  * @param config A link to the configuration object.
  */
 ReviewDialog(Main main, Config config) {
   super(main, "Review & Save");
   this.main = main;
   this.config = config;
   // layout date components
   GridBagLayout gbl = new GridBagLayout();
   setLayout(gbl);
   GridBagConstraints gbc = new GridBagConstraints();
   gbc.fill = GridBagConstraints.BOTH;
   gbc.insets = new Insets(0, 0, 5, 0);
   gbc.ipadx = 10;
   gbc.gridx = 0;
   gbc.gridy = 0;
   gbl.setConstraints(yearLabel, gbc);
   gbc.gridx = 1;
   gbl.setConstraints(yearCB, gbc);
   gbc.gridx = 0;
   gbc.gridy = 1;
   gbl.setConstraints(weekLabel, gbc);
   gbc.gridx = 1;
   gbl.setConstraints(weekCB, gbc);
   gbc.gridx = 0;
   gbc.gridy = 2;
   gbl.setConstraints(fromLabel, gbc);
   gbc.weightx = 1;
   gbc.gridx = 1;
   gbl.setConstraints(fromDate, gbc);
   gbc.insets = new Insets(0, 0, 0, 0);
   gbc.weightx = 0;
   gbc.gridx = 0;
   gbc.gridy = 3;
   gbl.setConstraints(toLabel, gbc);
   gbc.weightx = 1;
   gbc.gridx = 1;
   gbl.setConstraints(toDate, gbc);
   gbc.gridx = 0;
   gbc.gridy = 4;
   gbc.gridwidth = 2;
   gbc.insets = new Insets(10, 5, 10, 5);
   gbc.weighty = 1;
   JScrollPane scrollReviewPanel = new JScrollPane(reviewPanel);
   gbl.setConstraints(scrollReviewPanel, gbc);
   gbc.insets = new Insets(0, 0, 0, 0);
   gbc.gridy = 5;
   gbc.weighty = 0;
   gbl.setConstraints(saveToFileButton, gbc);
   gbc.gridy = 6;
   gbl.setConstraints(copyToClipboardButton, gbc);
   add(yearLabel);
   add(yearCB);
   add(weekLabel);
   add(weekCB);
   add(fromLabel);
   add(fromDate);
   add(toLabel);
   add(toDate);
   add(scrollReviewPanel);
   add(saveToFileButton);
   add(copyToClipboardButton);
   // layout results
   updateYearWeekDates();
   setVisible(true);
   setLocation(main.getLocation());
 }
示例#15
0
 /**
  * Main method
  *
  * @param args
  * @throws IOException
  */
 public static void main(String[] args) throws IOException {
   Main game = new Main();
   game.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   game.pack();
   game.setVisible(true);
 }
示例#16
0
    @SuppressWarnings("deprecation")
    public void actionPerformed(ActionEvent e) {

      if (e.getSource() == add1) {
        addItem();
      }

      if (e.getSource() == add2) {
        addPhone();
      }

      if (e.getSource() == save1) {
        saveItem();
      }

      if (e.getSource() == save2) {
        savePhone();
      }

      if (e.getSource() == help) {
        help();
      }

      if (e.getSource() == about) {
        about();
      }

      if (e.getSource() == show) {
        displayInformation();
      }

      if (e.getSource() == removeItem) {
        removeItem();
      }

      if (e.getSource() == removePhone) {
        removePhone();
      }

      if (e.getSource() == clearSaved) {
        clearSaved();
      }

      if (e.getSource() == saveCurrent) {
        saveCurrent();
      }

      if (e.getSource() == quitItem) {
        System.exit(1);
      }

      if (e.getSource() == start) {
        if (Main.getItems().isEmpty()) {
          results.setText("Please add items to search for.");
        } else {
          Main.setSleep((Integer) interval.getValue() * 60000);

          t2 = new CheckThread();
          t2.start();

          Main.setCont(true);
          start.setEnabled(false);
          stop.setEnabled(true);
        }
      }

      if (e.getSource() == stop) {
        t2.stop();
        Main.setCont(false);
        start.setEnabled(true);
        stop.setEnabled(false);
      }

      if (e.getSource() == load) {
        if (Main.getItems().isEmpty()) {
          Main.loadSettings();
          displayInformation();
        } else {
          results.setText("All current items must be cleared before loading. (File>Clear)");
        }
      }

      if (e.getSource() == clearCurrent) {
        searchName.setText("");
        item.setText("");
        results.setText("");
        phone.setText("");
        interval2.setText("");
        carriers.setSelectedIndex(0);
        Main.clearItems();
        Main.clearNumbers();
        displayInformation();
      }
    }
示例#17
0
 public static void showLogError(String msg, String title, Exception e, Component comp) {
   JOptionPane.showMessageDialog(comp, msg, title, JOptionPane.WARNING_MESSAGE);
   Main.Logger().warning(msg + (e == null ? "" : ": " + e.getMessage()));
 }
示例#18
-1
  private void saveItem() {

    File f = new File("config.txt");

    if (f.exists() && !f.isDirectory()) {

      try (PrintWriter out =
          new PrintWriter(new BufferedWriter(new FileWriter("config.txt", true)))) {
        if (!searchName.getText().equals("") && !item.getText().equals("")) {

          out.println(
              searchName.getText()
                  + ","
                  + "http://www.reddit.com/r/hardwareswap/search?q="
                  + item.getText()
                  + "&sort=new&restrict_sr=on");
          addItem();

        } else {

          results.setText("Please provide all info for Search Name and Item");
        }

      } catch (IOException e1) {
        results.append("Error saving to file.");
      }

    } else {
      Main.checkFiles();
    }
  }