User Tools

Site Tools


zalozeni:grafika:experimenttabs

ExperimentTabs

Controller pro grafiku zalozek (prava dolni cast) musi dedit od ExperimentInstanceController. V teto casti grafiky jsou jednotlive zalozky pro

ExperimentTabsController zaobaluje vsechny zminene casti do jednoho logickeho celku rozdeleneho do jednotlivych zalozek v jednom elegantnim TabPane. Jeho jednoducha implementace nasleduje.

Pri volani metody setExpInstance() se inicializuje naprosto vse - potrebne servicy, nacita se potrebna grafika a s ni souvisejici controllery. repaint() deleguje svoji povinnost na dilci controllery.

Zajimava je metoda showHideExportTab(), ktera v zavislosti na ExperimentStatus zobrazuje/skryva zalozku pro export dat.

public class DokuwikiTabsController extends ExperimentTabsController {
 
	private static final int MAX_TAB_COUNT = 4;
	@FXML
	private AnchorPane anchorPane;
	@FXML
	private AnchorPane graphPane;
	@FXML
	private AnchorPane dataPane;
	@FXML
	private AnchorPane infoPane;
 
	private DokuwikiDataService dataService;
	private DokuwikiExpInstanceSettignsService instanceSS;
 
	private DokuwikiGraph graph;
	private DokuwikiDataPaneController dataPaneController;
	private ExperimentInfoPaneController infoPaneController;
 
	public void initialize(URL location, ResourceBundle resources) {
		// TODO Auto-generated method stub
	}
 
	@Override
	public void setExpInstance(ExperimentInstance expInstance) {
		super.setExpInstance(expInstance);
		if (expInstance == null)
			return;
 
		dataService = (DokuwikiDataService) expInstance.getDataService();
		instanceSS = (DokuwikiExpInstanceSettignsService) expInstance.getSettignsService();
 
		graph = new DokuwikiGraph(graphPane, instanceSS, false);
 
		GraphicControllerDTO gcDTO = null;
 
		gcDTO = AnchorPaneHelper.loadFXPaneByName(DokuwikiDataPaneController.class.getResource("DokuwikiDataPane.fxml"));
		dataPaneController = (DokuwikiDataPaneController) gcDTO.getController();
		AnchorPaneHelper.insertNodeToContent(gcDTO.getGraphic(), dataPane);
 
		gcDTO = getInfoTabGCDTO();
		infoPaneController = (ExperimentInfoPaneController) gcDTO.getController();
		infoPaneController.setExpInstance(expInstance);
		AnchorPaneHelper.insertNodeToContent(gcDTO.getGraphic(), infoPane);
 
		ServiceLocator.getInstance().getLogicModuleManager().registerListener(expInstance, new ExperimentLogicListener() {
 
			@Override
			public void processEvent(LogicModuleEvent event) {
				if (event instanceof StatusChangeEvent) {
					showHideExportTab();
				}
			}
		});
	}
 
	@Override
	public void clearGraphics() {
		anchorPane.getChildren().clear();
	}
 
	@Override
	public void repaint() {
		if (expInstance == null || dataService == null)
			return;
 
		graph.repaint(dataService);
		dataPaneController.repaint(dataService);
		infoPaneController.repaint();
	}
 
	@Override
	public void newData(Object dataRow) {
		// tohle by se melo resit pres listenery
	}
 
	private void showHideExportTab() {
		if (expInstance.getStatus() == ExperimentStatus.ABORTED || expInstance.getStatus() == ExperimentStatus.ENDED
				|| expInstance.getStatus() == ExperimentStatus.SUSPENDED) {
			if (tabPane.getTabs().size() == MAX_TAB_COUNT)
				return;
			Tab tab = new Tab("Export");
			GraphicControllerDTO gcDTO = AnchorPaneHelper.loadFXPaneByName(DokuwikiExportTabController.class
					.getResource("DokuwikiExportTab.fxml"));
			tab.setContent(gcDTO.getGraphic());
			DokuwikiExportTabController controller = (DokuwikiExportTabController) gcDTO.getController();
			controller.setExpInstance(expInstance);
			tabPane.getTabs().add(tab);
		} else {
			if (tabPane.getTabs().size() == MAX_TAB_COUNT) {
				tabPane.getTabs().remove(MAX_TAB_COUNT - 1);
			}
		}
	}
 
}
zalozeni/grafika/experimenttabs.txt · Last modified: 2016/07/25 14:30 by jlochman