コード例 #1
0
ファイル: Snitcher.java プロジェクト: supremefist/Snitcher
  public Snitcher() {

    view = new SnitcherView(this);
    view.createAndShowGUI();

    readSettingsFromXML();

    addProjectsToView();

    view.setVisible(true);

    initializeVoice();

    timer.start();

    monitor.updateStatus();
  }
コード例 #2
0
ファイル: Snitcher.java プロジェクト: supremefist/Snitcher
  public void destroy() {
    System.out.println("Destroy called!");
    view.dispose();

    running = false;

    voice.deallocate();

    timer.stop();

    arduino.close();
  }
コード例 #3
0
ファイル: Snitcher.java プロジェクト: supremefist/Snitcher
  public void start() {
    while (running) {
      int offset = 0;

      boolean buildInterrupted = false;
      boolean buildFailed = false;
      boolean building = false;

      List<String> blames = new ArrayList<String>();
      String sayString = "";

      try {
        for (JenkinsProject project : monitor.projects) {
          if (project.isBuilding()) {
            // arduino.setChannelToState(offset,
            // ProjectState.BUILDING);
            building = true;
          } else if (project.getStatus().equals("SUCCESS")) {
            // arduino.setChannelToState(offset,
            // / ProjectState.BUILD_SUCCEEDED);
          } else if (project.getStatus().equals("ABORTED")) {
            // arduino.setChannelToState(offset,
            // ProjectState.BUILD_INTERRUPTED);
            buildInterrupted = true;
          } else {
            // arduino.setChannelToState(offset,
            // ProjectState.BUILD_FAILED);
            buildFailed = true;

            String person = project.getLastUser();

            if ((!person.equals("anonymous")) && (!blames.contains(person))) {
              blames.add(person);
            }
          }

          if (project.mustNotify()) {

            if (sayString.equals("")) {
              sayString = "Attention please! ";
            }

            String notifyString = project.getNotifyString();
            sayString += notifyString + "! ";

            project.setNotified(true);
          }

          offset += 1;
        }

        ProjectState serverState = ProjectState.BUILD_SUCCEEDED;
        if (buildFailed) {
          serverState = ProjectState.BUILD_FAILED;
        }

        if (!sayString.equals("")) {
          say(sayString);
        }

        view.setBlames(blames);

        arduino.setChannelToState(0, serverState);

      } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }

      arduino.sendStatus();
      // view.update();

      try {
        Thread.sleep(1000);
      } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    }
  }
コード例 #4
0
ファイル: Snitcher.java プロジェクト: supremefist/Snitcher
 private void addProjectsToView() {
   for (JenkinsProject project : monitor.projects) {
     System.out.println("Adding: " + project.getName());
     view.addProject(project);
   }
 }