Exemplo n.º 1
0
  public static void startGame() {

    MainFrame mainFrame = init();
    mainFrame.setCrossplatformSize();
    while (true) {
      isNewGameButtonPressed = false;
      while (gameState.hasGame()) {
        gameState.moveFigureDown();
        try {
          Thread.sleep(gameState.getDelay());
          while (gameState.isPaused()) {
            Thread.sleep(300);
          }
        } catch (InterruptedException e) {
          // do nothing
        }
      }
      while (!isNewGameButtonPressed) {
        try {
          Thread.sleep(500);
        } catch (InterruptedException e) {
          // do nothing
        }
      }
      mainFrame.clearAndRestart();
    }
  }
Exemplo n.º 2
0
 @Override
 public void actionPerformed(ActionEvent e) {
   // TODO Auto-generated method stub
   if (e.getSource() == ui.getMenuItem("getData")) {
     Data.getData();
     ui.change();
   }
 }
Exemplo n.º 3
0
  /** @param args */
  public static void main(String[] args) {
    ToneMapping toneMap = new ToneMapping();
    Controller ctrl = new Controller();
    ctrl.setToneMapping(toneMap);
    MainFrame frame = new MainFrame();
    toneMap.addObserver(frame);

    frame.setCtrl(ctrl);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);
  }
Exemplo n.º 4
0
  public StaffController(MainFrame view) {

    this.view = view;
    staffView = view.getStaffView();
    staffView.addController(this);
    staffList = staffView.getStaffList();

    // Initialise staff tree with staff currently in the database
    staffList.createDefaultStaff(staffDao.getAllStaff());
  }
Exemplo n.º 5
0
  public void actionPerformed(ActionEvent ae) {

    String cmd = ae.getActionCommand();

    switch (cmd) {
      case "Delete Staff":
        String staffToDelete = staffList.deleteStaff();
        staffDao.deleteStaff(staffToDelete);

        break;

      case "Modify Staff":
        int staffId = staffList.getCurrentlySelectedStaffId();
        if (staffId != 0) {

          StaffDO staff = staffDao.getStaffById(staffId);
          staffList.addStaffDialog(this, staff);
        }
        break;

      case "Add Staff":
        staffList.addStaffDialog(this, null);

        break;

      case "Add Skill":
        staffDialog = staffList.getStaffDialog();
        staffDialog.addSkill();

        break;

      case "Remove Skill":
        staffDialog = staffList.getStaffDialog();

        staffDialog.removeSkill();

        break;

      case "Add Holiday":
        staffDialog = staffList.getStaffDialog();
        staffDialog.addHoliday();

        break;

      case "Remove Holiday":
        staffDialog = staffList.getStaffDialog();
        staffDialog.removeHoliday();

        break;

        // Add Button In Staff Dialog
      case "Add":
        staffDialog = staffList.getStaffDialog();

        if (staffDialog.checkStaffInput()) {

          StaffDO input = staffDialog.getStaffInput();

          if (staffDao.getStaffById(input.getStaffId()) != null) {
            staffDialog.inputError("Id Already Exists");
            break;
          }

          staff = staffList.addNewStaffToList(input);

          staffDialog.dispose();

          staffDao.createStaff(staff);
        }
        view.refreshStat();
        break;

      case "Update":
        staffDialog = staffList.getStaffDialog();
        staff = staffDialog.getStaffInput();
        ArrayList<String> queries = staffDialog.getQueries();

        staffDialog.dispose();

        staffDao.modifyStaff(staffList.getCurrentlySelectedStaffId(), staff, queries);
        staff = staffList.addModifiedStaffToList(staff);

      case "Cancel":
        staffDialog = staffList.getStaffDialog();
        staffDialog.dispose();
        break;

      default:
    }
  }
 /* (non-Javadoc)
  * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
  */
 @Override
 public void actionPerformed(ActionEvent e) {
   addFrame.showUserView(MainFrame.EDIT_STUDENT_VIEW, null, null);
   addFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
 }