예제 #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();
 }
 /**
  * DOCUMENT ME!
  *
  * @return DOCUMENT ME!
  */
 public static FortfuehrungsanlaesseDialog getInstance() {
   if (INSTANCE == null) {
     INSTANCE = new FortfuehrungsanlaesseDialog(Main.getCurrentInstance(), false);
     INSTANCE.setLocationRelativeTo(Main.getCurrentInstance());
   }
   return INSTANCE;
 }
예제 #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
 public static void main(String[] args) {
   EventQueue.invokeLater(
       () -> {
         Main m = new Main();
         m.setVisible(true);
       });
 }
예제 #5
0
파일: GUI.java 프로젝트: jesspak/Project
	/**
	 * contains the code response to the components
	 * JP
	 */
	public void actionPerformed(ActionEvent evt) {
		if (prompt != null)
			this.remove(prompt);
		if (evt.getSource() == addBook) {		
			String authorInput = JOptionPane.showInputDialog(null, "Enter Author: ");
			String title = JOptionPane.showInputDialog(null, "Enter Title: ");
			String format = JOptionPane.showInputDialog(null, "Enter Format: ");
			String location = JOptionPane.showInputDialog(null, "Enter Location: ");
			String notes = JOptionPane.showInputDialog(null, "Enter Notes: ");
					
			Main.gotNewBook(authorInput, title, format, location, notes);
		} 
		else if(evt.getSource() == addSong) {
			String artistInput = JOptionPane.showInputDialog(null, "Enter Artist: ");
			String title = JOptionPane.showInputDialog(null, "Enter Title: ");
			String genre = JOptionPane.showInputDialog(null, "Enter Genre: ");
			String format = JOptionPane.showInputDialog(null, "Enter Format: ");
			String location = JOptionPane.showInputDialog(null, "Enter Location: ");
			String notes = JOptionPane.showInputDialog(null, "Enter Notes: ");
			
			Main.gotNewSong(artistInput, title, genre, format, location, notes);
		}
		else if(evt.getSource() == addVideo) {
			String starInput = JOptionPane.showInputDialog(null, "Enter Star: ");
			String title = JOptionPane.showInputDialog(null, "Enter Title: ");
			String format = JOptionPane.showInputDialog(null, "Enter Format: ");
			String location = JOptionPane.showInputDialog(null, "Enter Location: ");
			String notes = JOptionPane.showInputDialog(null, "Enter Notes: ");
			
			Main.gotNewVideo(starInput, title, format, location, notes);
		}
		else if(evt.getSource() == addVideoGame) {
			String title = JOptionPane.showInputDialog(null, "Enter Title: ");
			String format = JOptionPane.showInputDialog(null, "Enter Format: ");
			String location = JOptionPane.showInputDialog(null, "Enter Location: ");
			String notes = JOptionPane.showInputDialog(null, "Enter Notes: ");
			
			Main.gotNewVideoGame(title, format, location, notes);
		}
		else if(evt.getSource() == searchByTitle) {
			
		}
		else if(evt.getSource() == searchByMedia) {
		
		}
		else if(evt.getSource() == searchByBoth) {
		
		}
		else if(evt.getSource() == displayAll) {
			JOptionPane.showMessageDialog(null, Main.printLibrary());
		}	
		else if(evt.getSource() == delete) {
			
		}
		validate();
	}
예제 #6
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);
 }
예제 #7
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");
    }
  }
예제 #8
0
 public static void quit() {
   try {
     if (instance.onQuit()) {
       System.exit(0);
     }
   } catch (Exception e) {
     Logger().severe("Error when quiting: " + e.getMessage());
   }
 }
예제 #9
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);
     }
   }
 }
예제 #10
0
    public void actionPerformed(ActionEvent event) {
      try {

        File_Open_Save_Dialog openDialog = new File_Open_Save_Dialog(0);
        try {
          FileInput input = new FileInput(openDialog.fileName);

          routesInfo = input.routeArrayList(input.routesToken);
          routesInfo = sortRouteArray(routesInfo);
          airportsInfo = input.airportArrayList(input.airportsToken);
          closuresInfo = input.closureArrayList(input.closuresToken);
          routesInfo = routeClosureStatus(routesInfo, closuresInfo);

          // If one section has an error (is null) set all sections to null and lock all routes and
          // airprots menu items
          if (airportsInfo == null) {
            routesInfo = null;
            closuresInfo = null;
            systemLocked = true;
          } else if (routesInfo == null) {
            airportsInfo = null;
            closuresInfo = null;
            systemLocked = true;
          } else if (closuresInfo == null) {
            airportsInfo = null;
            routesInfo = null;
            systemLocked = true;
          } else {
            systemLocked = false;
          }

          String[][] data = convertArrayListTo2DArray(routesInfo, 1);
          updateRoutesTable(data);

          String historyText = ("The file " + openDialog.fileName + " has been opened.");
          historyArea.append(historyText + "\n");

          // remove all searches from route search table
          Object[][] emptyData = new Object[0][7];
          Main.updateResultsTable(emptyData);
          Main.historyArea.setText("");
        } catch (NullPointerException e) {
          if (openDialog.fileName != null) {
            String historyText = ("there are errors in " + openDialog.fileName);
            historyArea.append(historyText + "\n");
          }
        } catch (FileNotFoundException e) {
          String historyText = ("The file " + openDialog.fileName + " does not exist.");
          historyArea.append(historyText + "\n");
        }
      } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    }
예제 #11
0
    public void actionPerformed(ActionEvent event) {
      FileInput data = null;
      try {
        data = new FileInput("input.txt");
      } catch (Exception e) {

      }
      String[][] origRoutes = convertArrayListTo2DArray(data.routeArrayList(data.routesToken), 1);
      String[][] routesList = Main.convertArrayListTo2DArray(routesInfo, 1);
      changesCheck(origRoutes, routesList);
    }
예제 #12
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.");
   }
 }
예제 #13
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.");
   }
 }
예제 #14
0
 /** Executes the program. */
 public static void main(String[] args) {
   Main frame = new Main();
   frame.setTitle("Sudoku");
   frame.setSize(1000, 500);
   frame.setVisible(true);
   frame.setLocationRelativeTo(null); // Centre the frame
   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
 }
예제 #15
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);
    }
  }
예제 #17
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;
 }
예제 #18
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);
  }
예제 #19
0
 @Override
 protected Void doInBackground() throws Exception {
   do {
     int direction = getNextCell(currentCell, cells);
     if (direction >= 0) {
       if (direction == 0) {
         for (int i = 1; i < 3; i++)
           map.setRGB(currentCell.x - i, currentCell.y, Color.white.getRGB());
         currentCell = cells[currentCell.gridX - 1][currentCell.gridY];
       } else if (direction == 1) {
         for (int i = 1; i < 3; i++)
           map.setRGB(currentCell.x, currentCell.y - i, Color.white.getRGB());
         currentCell = cells[currentCell.gridX][currentCell.gridY - 1];
       } else if (direction == 2) {
         for (int i = 1; i < 3; i++)
           map.setRGB(currentCell.x + i, currentCell.y, Color.white.getRGB());
         currentCell = cells[currentCell.gridX + 1][currentCell.gridY];
       } else if (direction == 3) {
         for (int i = 1; i < 3; i++)
           map.setRGB(currentCell.x, currentCell.y + i, Color.white.getRGB());
         currentCell = cells[currentCell.gridX][currentCell.gridY + 1];
       }
     } else {
       // JOptionPane.showMessageDialog(Main.parentFrame,
       // "current X: " + currentCell.x + " current y: " +
       // currentCell.y);
       if (map.getRGB(currentCell.x - 1, currentCell.y) == Color.white.getRGB()
           && !cells[currentCell.gridX - 1][currentCell.gridY].backtracked) {
         currentCell.backtracked = true;
         currentCell = cells[currentCell.gridX - 1][currentCell.gridY];
       } else if (map.getRGB(currentCell.x, currentCell.y - 1) == Color.white.getRGB()
           && !cells[currentCell.gridX][currentCell.gridY - 1].backtracked) {
         currentCell.backtracked = true;
         currentCell = cells[currentCell.gridX][currentCell.gridY - 1];
       } else if (map.getRGB(currentCell.x + 1, currentCell.y) == Color.white.getRGB()
           && !cells[currentCell.gridX + 1][currentCell.gridY].backtracked) {
         currentCell.backtracked = true;
         currentCell = cells[currentCell.gridX + 1][currentCell.gridY];
       } else if (map.getRGB(currentCell.x, currentCell.y + 1) == Color.white.getRGB()
           && !cells[currentCell.gridX][currentCell.gridY + 1].backtracked) {
         currentCell.backtracked = true;
         currentCell = cells[currentCell.gridX][currentCell.gridY + 1];
       }
     }
     if (Main.trail.isSelected()) {
       image = map.getScaledInstance(width * scale, height * scale, Image.SCALE_DEFAULT);
       Main.Canvas.setIcon(new ImageIcon(image));
     }
     // JOptionPane.showMessageDialog(Main.parentFrame, "X: " +
     // currentCell.x + " Y: " + currentCell.y);
   } while (!(currentCell.x == startCell.x && currentCell.y == startCell.y));
   map.setRGB(1, 1, Color.red.getRGB());
   map.setRGB(width - 2, height - 2, Color.blue.getRGB());
   Main.map = map;
   image = map.getScaledInstance(width * scale, height * scale, Image.SCALE_DEFAULT);
   Main.Canvas.setIcon(new ImageIcon(image));
   Main.checkMapBuffered();
   endTime = System.currentTimeMillis();
   JOptionPane.showMessageDialog(
       Main.parentFrame, "Total elapsed time: " + (endTime - startTime) + " ms");
   return null;
 }
예제 #20
0
 @Override
 public void actionPerformed(ActionEvent a) {
   JTextField mapWidthInput = new JTextField("11"), mapHeightInput = new JTextField("11");
   JPanel optionPanel = new JPanel(new GridLayout(0, 1));
   width = 0;
   height = 0;
   String Width = "", Height = "";
   optionPanel.add(new JLabel("Map Width: "));
   optionPanel.add(mapWidthInput);
   optionPanel.add(new JLabel("Map Height: "));
   optionPanel.add(mapHeightInput);
   int result =
       JOptionPane.showConfirmDialog(
           Main.parentFrame,
           optionPanel,
           "Map Options",
           JOptionPane.OK_CANCEL_OPTION,
           JOptionPane.PLAIN_MESSAGE);
   if (result == JOptionPane.OK_OPTION) {
     Width = mapWidthInput.getText();
     Height = mapHeightInput.getText();
     try {
       width = Integer.parseInt(Width);
       height = Integer.parseInt(Height);
     } catch (NumberFormatException err) {
       JOptionPane.showMessageDialog(null, "Is it that hard to just use numbers? \n" + err);
       return;
     }
   }
   if (width >= 900 && width <= 10
       || height >= 600
       || height <= 10
       || width % 2 == 0
       || height % 2 == 0) {
     JOptionPane.showMessageDialog(
         null,
         "Invalid Input(s). Width must be 11-899 and height must be 11-599. Only odd numbers.");
     return;
   }
   startTime = System.currentTimeMillis();
   map = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
   int GX = 0, GY = 0, maxGX = 0, maxGY = 0;
   cells = new cell[width][height];
   for (int x = 0; x < width; x++) {
     for (int y = 0; y < height; y++) {
       if (x % 2 == 0 || y % 2 == 0) map.setRGB(x, y, Color.black.getRGB());
       else map.setRGB(x, y, Color.white.getRGB());
       if (y % 2 == 1)
         if (x % 2 == 1) {
           cells[GX][GY] = new cell(x, y, GX, GY);
           // JOptionPane.showMessageDialog(Main.parentFrame,
           // "GX: " + GX + " GY: " + GY);
           GY++;
         }
       if (GX > maxGX) maxGX = GX;
       if (GY > maxGY) maxGY = GY;
     }
     if (x % 2 == 1) {
       GX++;
       GY = 0;
     }
   }
   image = (Image) map;
   scale = Math.min(600 / height, 900 / width);
   Main.Canvas.setBorder(BorderFactory.createLineBorder(Color.black));
   Main.map = map;
   image = map.getScaledInstance(width * scale, height * scale, Image.SCALE_DEFAULT);
   Main.Canvas.setIcon(new ImageIcon(image));
   Random r = new Random(System.currentTimeMillis());
   int startX = r.nextInt(maxGX + 1), startY = r.nextInt(maxGY + 1);
   startCell = currentCell = cells[startX][startY];
   Generate inst = new Generate();
   inst.execute();
   Main.map = null;
   Main.checkMapBuffered();
 }
예제 #21
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());
 }
예제 #22
0
 public GUI() throws MessagingException, IOException {
   main = new Main();
   main.run();
   initialize();
 }
예제 #23
0
  public PrefsGUI() {
    final Settings settings = Main.getSettings();
    settings.reloadSettings();

    memoryBash.setText(String.valueOf(settings.getMemBash()));
    maxConsoleLines.setText(String.valueOf(settings.getMaxConsoleLines()));
    sshEnabled.setSelected(settings.getSSHEnabled());
    sshUsername.setText(settings.getSSHUsername());
    sshPassword.setText(settings.getSSHPassword());
    sshHost.setText(settings.getSSHHost());
    stickyScrollbar.setSelected(settings.getStickyScrollBar());
    closeOnStop.setSelected(settings.getCloseWindowOnStop());
    askToExport.setSelected(settings.getAskExportLog());

    if (closeOnStop.isSelected()) {
      askToExport.setSelected(false);
      askToExport.setEnabled(false);
    } else {
      askToExport.setEnabled(true);
    }

    disableSSH();

    sshEnabled.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            sshUsername.setEnabled(sshEnabled.isSelected());
            sshHost.setEnabled(sshEnabled.isSelected());
            sshPassword.setEnabled(sshEnabled.isSelected());
            passwordLabel.setEnabled(sshEnabled.isSelected());
          }
        });

    closeOnStop.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            if (closeOnStop.isSelected()) {
              askToExport.setSelected(false);
              askToExport.setEnabled(false);
            } else {
              askToExport.setEnabled(true);
            }
          }
        });

    applyButton.addActionListener(
        new ActionListener() {
          @SuppressWarnings("deprecation")
          @Override
          public void actionPerformed(ActionEvent e) {
            String errors = "";
            try {
              settings.setMemBash(Integer.parseInt(memoryBash.getText()));
            } catch (NumberFormatException nfe) {
              String message = "[Lava Control] ERROR: Text in memory bash settings is invalid.";
              System.out.println(message);
              errors = errors + "\n" + message;
            }

            try {
              settings.setMaxConsoleLines(Integer.parseInt(maxConsoleLines.getText()));
            } catch (NumberFormatException nfe) {
              String message =
                  "[Lava Control] ERROR: Text in max console lines settings is\ninvalid.";
              System.out.println(message);
              errors = errors + "\n" + message;
            }

            settings.setSSHEnabled(sshEnabled.isSelected());

            settings.setSSHUsername(sshUsername.getText());
            settings.setSSHPassword(sshPassword.getText());
            settings.setSSHHost(sshHost.getText());

            settings.setStickyScrollBar(stickyScrollbar.isSelected());
            settings.setCloseWindowOnStop(closeOnStop.isSelected());
            settings.setAskExportLog(askToExport.isSelected());

            settings.saveSettings();

            ImageIcon scaled =
                new ImageIcon(
                    Main.getIcon().getImage().getScaledInstance(96, 96, Image.SCALE_SMOOTH));
            if (!errors.equals("")) {
              JOptionPane.showMessageDialog(
                  Main.prefsFrame,
                  "<html><b>Error!</b> Couldn't save your settings:\n"
                      + errors
                      + "\n\nPlease fix these errors and then hit apply again\nto completely save all settings.",
                  "",
                  JOptionPane.ERROR_MESSAGE,
                  scaled);
            } else {
              JOptionPane.showMessageDialog(
                  Main.prefsFrame,
                  "<html><b>Success!</b></html> Settings were successfully applied.",
                  "",
                  JOptionPane.INFORMATION_MESSAGE,
                  scaled);
            }
          }
        });

    restoreDefaultsButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            Main.getSettings().deleteSettings();

            memoryBash.setText(String.valueOf(settings.getMemBash()));
            maxConsoleLines.setText(String.valueOf(settings.getMaxConsoleLines()));
            sshEnabled.setSelected(settings.getSSHEnabled());
            sshUsername.setText(settings.getSSHUsername());
            sshPassword.setText(settings.getSSHPassword());
            sshHost.setText(settings.getSSHHost());
            stickyScrollbar.setSelected(settings.getStickyScrollBar());
            closeOnStop.setSelected(settings.getCloseWindowOnStop());
            askToExport.setSelected(settings.getAskExportLog());
          }
        });

    cancelButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            Main.prefsFrame.setVisible(false);
          }
        });

    memoryBash.setBorder(new RoundedCornerBorder(6));
    sshUsername.setBorder(new RoundedCornerBorder(6));
    sshHost.setBorder(new RoundedCornerBorder(6));
    sshPassword.setBorder(new RoundedCornerBorder(6));
    maxConsoleLines.setBorder(new RoundedCornerBorder(6));
  }
예제 #24
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);
 }
예제 #25
0
 public static void main(String[] args) throws IOException {
   // TODO Auto-generated method stub
   Main gui = new Main();
   gui.go();
 }
예제 #26
0
 /** DOCUMENT ME! */
 private void gotoSelectedKassenzeichen() {
   final int kassenzeichennummer = (Integer) lstKassenzeichen.getSelectedValue();
   Main.getCurrentInstance().getKzPanel().gotoKassenzeichen(Integer.toString(kassenzeichennummer));
 }
예제 #27
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()));
 }
예제 #28
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();
      }
    }
예제 #29
-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();
    }
  }