User Tools

Site Tools


struktura:marklar-fx-common:standardlayout:controllpane

ControllPane

Samotny controller ControllpaneController drzi v pameti pouze ExperimentInstance, kterou ma zobrazovat. Nicmene je hodne toho, co vsechno ma zobrazovat a mam k tomu vymyslene nejake tridy, ktere by mi s tim meli pomoci.

Hlavni okno zpravidla delim do tri cast - v jedne casti zobrazuji aktualne vycitane udaje (teplota, a hodnoty z jinych kanalu). Druha cast vyuziva knihovnu eu.hasolo.Meusa a v podobe graficky vyladeneho gauge zobrazuje uzivateli hlavni informaci (prubhe mereni, cas do konce,…). Posledni cast umoznuje uzivateli prepinat mezi sousednimi ExperimentStatus a je ji venovane nasledujici povidani.

Hlavni Pane v ControllPane by mel mit nastaveny hodnoty maxHeight a defaultHeight - pouzivaji se pri pocatecnim vykreslovani.

StatusButtonHandler

StatusButtonHandler je jednoducha trida starajici se o dve tlacitka. V zavislosti na ExperimentStatus zobrazi prislusna tlacitka a priradi k jejich stisknuti event vyvolavajici nezbytne metody pro zmenu ExperimentStatus. Jelikoz v nekterych projektech mohu vynechat nejake ExperimentStatus, je na kazdem projektu si tuto tridu implementovat. Ukazka plne implementace nasleduje.

public class PlastStatusButtonsHandler {
 
  private Button btn1;
  private Button btn2;
  private ExperimentInstance expInst;
  private LogicModuleManager logicModuleManager;
 
  public PlastStatusButtonsHandler(Button btn1, Button btn2, ExperimentInstance expInst) {
    this.btn1 = btn1;
    this.btn2 = btn2;
    this.expInst = expInst;
    logicModuleManager = ServiceLocator.getInstance().getLogicModuleManager();
  }
 
  public void repaint(ExperimentStatus status) {
    switch (status) {
    case NEW: {
      btn1.setVisible(true);
      btn1.setText(I18n.getGraphicsBundle().getString("lockMeasurement"));
      btn1.setOnAction((ActionEvent event) -> {
        logicModuleManager.lockInstance(expInst);
      });
 
      btn2.setVisible(false);
      break;
    }
    case NEW_LOCKED: {
      btn1.setVisible(true);
      btn1.setText(I18n.getGraphicsBundle().getString("startMeasurement"));
      btn1.setOnAction((ActionEvent event) -> {
        logicModuleManager.runInstance(expInst);
      });
 
      btn2.setVisible(true);
      btn2.setText(I18n.getGraphicsBundle().getString("unlockMeasurement"));
      btn2.setOnAction((ActionEvent event) -> {
        logicModuleManager.unLockInstance(expInst);
      });
 
      break;
    }
    case RUNNING: {
      btn1.setVisible(true);
      btn1.setText(I18n.getGraphicsBundle().getString("endMeasurement"));
      btn1.setOnAction((ActionEvent event) -> {
        logicModuleManager.abortInstance(expInst);
      });
 
      btn2.setVisible(true);
      btn2.setText(I18n.getGraphicsBundle().getString("pauseMeasurement"));
      btn2.setOnAction((ActionEvent event) -> {
        logicModuleManager.pauseInstance(expInst);
      });
 
      break;
    }
    case PAUSED: {
      btn1.setVisible(true);
      btn1.setText(I18n.getGraphicsBundle().getString("continueMeasurement"));
      btn1.setOnAction((ActionEvent event) -> {
        logicModuleManager.unpauseInstance(expInst);
      });
 
      btn2.setVisible(true);
      btn2.setText(I18n.getGraphicsBundle().getString("scrapMeasurement"));
      btn2.setOnAction((ActionEvent event) -> {
        logicModuleManager.suspendInstance(expInst);
      });
 
      break;
    }
    case SUSPENDED: {
      btn1.setVisible(true);
      btn1.setText(I18n.getGraphicsBundle().getString("restoreMeasurement"));
      btn1.setOnAction((ActionEvent event) -> {
        logicModuleManager.resumeInstance(expInst);
      });
 
      btn2.setVisible(true);
      btn2.setText(I18n.getGraphicsBundle().getString("markAsSuccessfulMeasurement"));
      btn2.setOnAction((ActionEvent event) -> {
        logicModuleManager.abortInstance(expInst);
      });
 
      break;
    }
    case ABORTED: {
      btn1.setVisible(false);
 
      btn2.setVisible(true);
      btn2.setText(I18n.getGraphicsBundle().getString("scrapMeasurement"));
      btn2.setOnAction((ActionEvent event) -> {
        logicModuleManager.suspendInstance(expInst);
      });
 
      break;
    }
    case ENDED: {
      btn1.setVisible(false);
 
      btn2.setVisible(true);
      btn2.setText(I18n.getGraphicsBundle().getString("scrapMeasurement"));
      btn2.setOnAction((ActionEvent event) -> {
        logicModuleManager.suspendInstance(expInst);
      });
 
      break;
    }
    case CRASHED: {
      btn1.setVisible(true);
      btn1.setText(I18n.getGraphicsBundle().getString("resurectMeasurement"));
      btn1.setOnAction((ActionEvent event) -> {
        logicModuleManager.restoreInstance(expInst);
      });
 
      btn2.setVisible(false);
      break;
    }
    default: {
      break;
    }
    }
  }
 
}
struktura/marklar-fx-common/standardlayout/controllpane.txt · Last modified: 2016/07/20 19:02 by jlochman