Java Code Examples for javafx.fxml.FXMLLoader#getRoot()

The following examples show how to use javafx.fxml.FXMLLoader#getRoot() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DesignerApplication.java    From OEE-Designer with MIT License 6 votes vote down vote up
CronEventSource showCronEditor() throws Exception {
	FXMLLoader loader = FXMLLoaderFactory.cronEditorLoader();
	AnchorPane page = (AnchorPane) loader.getRoot();

	// Create the dialog Stage.
	Stage dialogStage = new Stage(StageStyle.DECORATED);
	dialogStage.setTitle(DesignerLocalizer.instance().getLangString("cron.editor.title"));
	dialogStage.initModality(Modality.WINDOW_MODAL);
	Scene scene = new Scene(page);
	dialogStage.setScene(scene);

	// get the controller
	CronEditorController cronController = loader.getController();
	cronController.setDialogStage(dialogStage);
	cronController.initialize(this);

	// Show the dialog and wait until the user closes it
	if (!cronController.getDialogStage().isShowing()) {
		cronController.getDialogStage().showAndWait();
	}

	return cronController.getSource();
}
 
Example 2
Source File: OpcDaTrendController.java    From OEE-Designer with MIT License 6 votes vote down vote up
public SplitPane initializeTrend() throws Exception {
	if (trendChartController == null) {
		// Load the fxml file and create the anchor pane
		FXMLLoader loader = FXMLLoaderFactory.trendChartLoader();
		spTrendChart = (SplitPane) loader.getRoot();

		trendChartController = loader.getController();
		trendChartController.initialize(getApp());

		// data provider
		trendChartController.setProvider(this);

		setImages();

		getDialogStage().setOnCloseRequest((WindowEvent event1) -> {
			onDisconnect();
		});
	}
	return spTrendChart;
}
 
Example 3
Source File: DesignerApplication.java    From OEE-Designer with MIT License 6 votes vote down vote up
DatabaseEventSource showDatabaseServerEditor() throws Exception {
	FXMLLoader loader = FXMLLoaderFactory.databaseServerLoader();
	AnchorPane page = (AnchorPane) loader.getRoot();

	// Create the dialog Stage.
	Stage dialogStage = new Stage(StageStyle.DECORATED);
	dialogStage.setTitle(DesignerLocalizer.instance().getLangString("db.editor.title"));
	dialogStage.initModality(Modality.WINDOW_MODAL);
	Scene scene = new Scene(page);
	dialogStage.setScene(scene);

	// get the controller
	DatabaseServerController databaseServerController = loader.getController();
	databaseServerController.setDialogStage(dialogStage);
	databaseServerController.initialize(this);

	// Show the dialog and wait until the user closes it
	if (!databaseServerController.getDialogStage().isShowing()) {
		databaseServerController.getDialogStage().showAndWait();
	}

	return databaseServerController.getSource();
}
 
Example 4
Source File: DashboardController.java    From OEE-Designer with MIT License 6 votes vote down vote up
private AvailabilityEditorController getAvailabilityController() throws Exception {
	if (availabilityEditorController == null) {
		FXMLLoader loader = FXMLLoaderFactory.availabilityEditorLoader();
		AnchorPane page = (AnchorPane) loader.getRoot();

		Stage dialogStage = new Stage(StageStyle.DECORATED);
		dialogStage.setTitle(DesignerLocalizer.instance().getLangString("availability.editor"));
		dialogStage.initModality(Modality.APPLICATION_MODAL);
		Scene scene = new Scene(page);
		dialogStage.setScene(scene);

		// get the controller
		availabilityEditorController = loader.getController();
		availabilityEditorController.setDialogStage(dialogStage);
	}
	return availabilityEditorController;
}
 
Example 5
Source File: DashboardController.java    From OEE-Designer with MIT License 6 votes vote down vote up
private ProductionEditorController getProductionController() throws Exception {
	if (productionEditorController == null) {
		FXMLLoader loader = FXMLLoaderFactory.productionEditorLoader();
		AnchorPane page = (AnchorPane) loader.getRoot();

		Stage dialogStage = new Stage(StageStyle.DECORATED);
		dialogStage.setTitle(DesignerLocalizer.instance().getLangString("production.editor"));
		dialogStage.initModality(Modality.APPLICATION_MODAL);
		Scene scene = new Scene(page);
		dialogStage.setScene(scene);

		// get the controller
		productionEditorController = loader.getController();
		productionEditorController.setDialogStage(dialogStage);
	}
	return productionEditorController;
}
 
Example 6
Source File: DashboardController.java    From OEE-Designer with MIT License 6 votes vote down vote up
private SetupEditorController getSetupController() throws Exception {
	if (setupEditorController == null) {
		FXMLLoader loader = FXMLLoaderFactory.setupEditorLoader();
		AnchorPane page = (AnchorPane) loader.getRoot();

		Stage dialogStage = new Stage(StageStyle.DECORATED);
		dialogStage.setTitle(DesignerLocalizer.instance().getLangString("setup.editor"));
		dialogStage.initModality(Modality.APPLICATION_MODAL);
		Scene scene = new Scene(page);
		dialogStage.setScene(scene);

		// get the controller
		setupEditorController = loader.getController();
		setupEditorController.setDialogStage(dialogStage);
	}
	return setupEditorController;
}
 
Example 7
Source File: DashboardController.java    From OEE-Designer with MIT License 6 votes vote down vote up
private OeeEventTrendController getOeeEventTrendController() throws Exception {
	FXMLLoader loader = FXMLLoaderFactory.oeeEventTrendLoader();
	AnchorPane page = (AnchorPane) loader.getRoot();

	Stage dialogStage = new Stage(StageStyle.DECORATED);
	dialogStage.setTitle(DesignerLocalizer.instance().getLangString("oee.event.trend"));
	dialogStage.initModality(Modality.NONE);
	Scene scene = new Scene(page);
	dialogStage.setScene(scene);

	// get the controller
	OeeEventTrendController oeeEventTrendController = loader.getController();
	oeeEventTrendController.setDialogStage(dialogStage);

	return oeeEventTrendController;
}
 
Example 8
Source File: OperatorController.java    From OEE-Designer with MIT License 6 votes vote down vote up
private Reason showReasonSelector() throws Exception {
	FXMLLoader loader = FXMLLoaderFactory.reasonSelectorLoader();
	AnchorPane page = (AnchorPane) loader.getRoot();

	Stage dialogStage = new Stage(StageStyle.DECORATED);
	dialogStage.setTitle(OperatorLocalizer.instance().getLangString("reason.selector.title"));
	dialogStage.initModality(Modality.WINDOW_MODAL);
	Scene scene = new Scene(page);
	dialogStage.setScene(scene);

	reasonController = loader.getController();
	reasonController.setDialogStage(dialogStage);
	reasonController.initialize();

	if (!reasonController.getDialogStage().isShowing()) {
		reasonController.getDialogStage().showAndWait();
	}
	return reasonController.getSelectedReason();
}
 
Example 9
Source File: DesignerApplication.java    From OEE-Designer with MIT License 6 votes vote down vote up
FileEventSource showFileShareEditor() throws Exception {
	FXMLLoader loader = FXMLLoaderFactory.fileShareLoader();
	AnchorPane page = (AnchorPane) loader.getRoot();

	// Create the dialog Stage.
	Stage dialogStage = new Stage(StageStyle.DECORATED);
	dialogStage.setTitle(DesignerLocalizer.instance().getLangString("file.editor.title"));
	dialogStage.initModality(Modality.WINDOW_MODAL);
	Scene scene = new Scene(page);
	dialogStage.setScene(scene);

	// get the controller
	FileShareController fileShareController = loader.getController();
	fileShareController.setDialogStage(dialogStage);
	fileShareController.initialize(this);

	// Show the dialog and wait until the user closes it
	if (!fileShareController.getDialogStage().isShowing()) {
		fileShareController.getDialogStage().showAndWait();
	}

	return fileShareController.getSource();
}
 
Example 10
Source File: CollectorApplication.java    From OEE-Designer with MIT License 6 votes vote down vote up
public void start(Stage primaryStage) {
	try {
		FXMLLoader loader = FXMLLoaderFactory.collectorApplicationLoader();
		AnchorPane mainLayout = loader.getRoot();

		collectorController = loader.getController();
		collectorController.initialize(collectorName);

		Scene scene = new Scene(mainLayout);

		primaryStage.setTitle(CollectorLocalizer.instance().getLangString("collector.app.title"));
		primaryStage.getIcons().add(ImageManager.instance().getImage(Images.POINT85));
		primaryStage.setScene(scene);
		primaryStage.show();
	} catch (Exception e) {
		logger.error(e.getMessage());
		stop();
	}
}
 
Example 11
Source File: BaseMessagingTrendController.java    From OEE-Designer with MIT License 6 votes vote down vote up
public SplitPane initializeTrend() throws Exception {
	if (trendChartController == null) {
		// Load the fxml file and create the anchor pane
		FXMLLoader loader = FXMLLoaderFactory.trendChartLoader();
		spTrendChart = (SplitPane) loader.getRoot();

		trendChartController = loader.getController();
		trendChartController.initialize(getApp());

		// data provider
		trendChartController.setProvider(this);

		setImages();

		lbBroker.setText(null);
	}
	return spTrendChart;
}
 
Example 12
Source File: DesignerApplication.java    From OEE-Designer with MIT License 6 votes vote down vote up
HttpSource showHttpServerEditor() throws Exception {
	FXMLLoader loader = FXMLLoaderFactory.httpServerLoader();
	AnchorPane page = (AnchorPane) loader.getRoot();

	// Create the dialog Stage.
	Stage dialogStage = new Stage(StageStyle.DECORATED);
	dialogStage.setTitle(DesignerLocalizer.instance().getLangString("http.servers.title"));
	dialogStage.initModality(Modality.WINDOW_MODAL);
	Scene scene = new Scene(page);
	dialogStage.setScene(scene);

	// get the controller
	HttpServerController httpServerController = loader.getController();
	httpServerController.setDialogStage(dialogStage);
	httpServerController.initializeServer();

	// Show the dialog and wait until the user closes it
	httpServerController.getDialogStage().showAndWait();

	return httpServerController.getSource();
}
 
Example 13
Source File: DesignerApplication.java    From OEE-Designer with MIT License 5 votes vote down vote up
void showOpcUaTrendDialog(EventResolver eventResolver) throws Exception {
	// Load the fxml file and create a new stage for the pop-up dialog.
	FXMLLoader loader = FXMLLoaderFactory.opcUaTrendLoader();
	AnchorPane page = (AnchorPane) loader.getRoot();

	// Create the dialog Stage.
	Stage dialogStage = new Stage(StageStyle.DECORATED);
	dialogStage.setTitle(DesignerLocalizer.instance().getLangString("opc.ua.trend"));
	dialogStage.initModality(Modality.NONE);
	// dialogStage.initOwner(primaryStage);
	Scene scene = new Scene(page);
	dialogStage.setScene(scene);

	// get the controller
	OpcUaTrendController opcUaTrendController = loader.getController();
	opcUaTrendController.setDialogStage(dialogStage);
	opcUaTrendController.setApp(this);

	// add the trend chart
	SplitPane chartPane = opcUaTrendController.initializeTrend();

	opcUaTrendController.setUpdatePeriodMsec(eventResolver.getUpdatePeriod());

	AnchorPane.setBottomAnchor(chartPane, 50.0);
	AnchorPane.setLeftAnchor(chartPane, 5.0);
	AnchorPane.setRightAnchor(chartPane, 5.0);
	AnchorPane.setTopAnchor(chartPane, 50.0);

	page.getChildren().add(0, chartPane);

	// set the script resolver
	opcUaTrendController.setScriptResolver(eventResolver);

	// show the window
	opcUaTrendController.getDialogStage().show();
}
 
Example 14
Source File: DesignerApplication.java    From OEE-Designer with MIT License 5 votes vote down vote up
void showCronTrendDialog(EventResolver eventResolver) throws Exception {
	// Load the fxml file and create a new stage for the pop-up dialog.
	FXMLLoader loader = FXMLLoaderFactory.cronTrendLoader();
	AnchorPane page = (AnchorPane) loader.getRoot();

	// Create the dialog Stage.
	Stage dialogStage = new Stage(StageStyle.DECORATED);
	dialogStage.setTitle(DesignerLocalizer.instance().getLangString("cron.event.trend"));
	dialogStage.initModality(Modality.NONE);
	Scene scene = new Scene(page);
	dialogStage.setScene(scene);

	// get the controller
	CronTrendController cronTrendController = loader.getController();
	cronTrendController.setDialogStage(dialogStage);
	cronTrendController.setApp(this);

	// add the trend chart
	SplitPane chartPane = cronTrendController.initializeTrend();

	AnchorPane.setBottomAnchor(chartPane, 50.0);
	AnchorPane.setLeftAnchor(chartPane, 5.0);
	AnchorPane.setRightAnchor(chartPane, 5.0);
	AnchorPane.setTopAnchor(chartPane, 50.0);

	page.getChildren().add(0, chartPane);

	// set the script resolver
	cronTrendController.setEventResolver(eventResolver);

	// start the job
	cronTrendController.subscribeToDataSource();

	// show the window
	cronTrendController.getDialogStage().show();
}
 
Example 15
Source File: DesignerApplication.java    From OEE-Designer with MIT License 5 votes vote down vote up
void showDashboard() throws Exception {
	PlantEntity entity = getPhysicalModelController().getSelectedEntity();

	FXMLLoader dialogLoader = FXMLLoaderFactory.dashboardDialogLoader();
	AnchorPane pane = (AnchorPane) dialogLoader.getRoot();

	// Create the dialog Stage.
	Stage dialogStage = new Stage(StageStyle.DECORATED);
	dialogStage.setTitle(DesignerLocalizer.instance().getLangString("oee.dashboard", entity.getDisplayString()));
	dialogStage.initModality(Modality.NONE);
	Scene scene = new Scene(pane);
	dialogStage.setScene(scene);

	// get the controller
	DashboardDialogController dashboardDialogController = dialogLoader.getController();
	dashboardDialogController.setDialogStage(dialogStage);

	// load the content
	FXMLLoader dashboardLoader = FXMLLoaderFactory.dashboardLoader();
	DashboardController dashboardController = dashboardLoader.getController();

	SplitPane spDashboard = (SplitPane) dashboardLoader.getRoot();

	pane.getChildren().add(0, spDashboard);

	AnchorPane.setTopAnchor(spDashboard, 0.0);
	AnchorPane.setBottomAnchor(spDashboard, 50.0);
	AnchorPane.setLeftAnchor(spDashboard, 0.0);
	AnchorPane.setRightAnchor(spDashboard, 0.0);

	dashboardController.enableRefresh(true);

	dashboardDialogController.setDashboardController(dashboardController);

	dashboardController.setupEquipmentLoss((Equipment) entity);

	// Show the dialog and wait until the user closes it
	dashboardDialogController.getDialogStage().showAndWait();
}
 
Example 16
Source File: AvailabilityEditorController.java    From OEE-Designer with MIT License 5 votes vote down vote up
@FXML
private void onShowReasonEditor() {
	try {
		// display the reason editor as a dialog
		if (reasonController == null) {
			FXMLLoader loader = FXMLLoaderFactory.reasonEditorLoader();
			AnchorPane page = (AnchorPane) loader.getRoot();

			// Create the dialog Stage.
			Stage dialogStage = new Stage(StageStyle.DECORATED);
			dialogStage.setTitle(DesignerLocalizer.instance().getLangString("reason.editor"));
			dialogStage.initModality(Modality.APPLICATION_MODAL);
			Scene scene = new Scene(page);
			dialogStage.setScene(scene);

			// get the controller
			reasonController = loader.getController();
			reasonController.setDialogStage(dialogStage);
			reasonController.initialize(null);
		}

		// Show the dialog and wait until the user closes it
		reasonController.getDialogStage().showAndWait();

		Reason reason = reasonController.getSelectedReason();

		if (reason != null) {
			availabilityEvent.setReason(reason);
			availabilityEvent.setInputValue(reason.getName());
			displayReason();
		}
	} catch (Exception e) {
		AppUtils.showErrorDialog(e);
	}
}
 
Example 17
Source File: SetupEditorController.java    From OEE-Designer with MIT License 5 votes vote down vote up
@FXML
private void onShowMaterialEditor() {
	try {
		// display the material editor as a dialog
		if (materialController == null) {
			FXMLLoader loader = FXMLLoaderFactory.materialEditorLoader();
			AnchorPane page = (AnchorPane) loader.getRoot();

			// Create the dialog Stage.
			Stage dialogStage = new Stage(StageStyle.DECORATED);
			dialogStage.setTitle(DesignerLocalizer.instance().getLangString("material.editor"));
			dialogStage.initModality(Modality.APPLICATION_MODAL);
			Scene scene = new Scene(page);
			dialogStage.setScene(scene);

			// get the controller
			materialController = loader.getController();
			materialController.setDialogStage(dialogStage);
			materialController.initialize(null);
		}

		// Show the dialog and wait until the user closes it
		materialController.getDialogStage().showAndWait();

		Material material = materialController.getSelectedMaterial();

		if (material != null) {
			setupEvent.setMaterial(material);
			setupEvent.setInputValue(material.getName());
			displayMaterial();
		}
	} catch (Exception e) {
		AppUtils.showErrorDialog(e);
	}
}
 
Example 18
Source File: FxmlManager.java    From triplea with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Simplified way to load a Node & Controller.
 *
 * @return A LoadedNode object
 */
public <C, N> LoadedNode<C, N> load() {
  try {
    final FXMLLoader loader = new FXMLLoader(getClass().getResource(value));
    // TODO load locale based on user setting
    loader.setResources(ResourceBundle.getBundle(LANG_CLASS_BASENAME, new Locale("en", "US")));
    loader.load();
    return new LoadedNode<>(loader.getController(), loader.getRoot());
  } catch (final IOException e) {
    throw new IllegalStateException("Failed to load FXML " + value, e);
  }
}
 
Example 19
Source File: UomEditorController.java    From OEE-Designer with MIT License 4 votes vote down vote up
@FXML
private void onImportUom() throws Exception {
	try {
		if (uomImportController == null) {
			FXMLLoader loader = FXMLLoaderFactory.uomImporterLoader();
			AnchorPane pane = (AnchorPane) loader.getRoot();

			// Create the dialog Stage.
			Stage dialogStage = new Stage(StageStyle.DECORATED);
			dialogStage.setTitle(DesignerLocalizer.instance().getLangString("import.uom.title"));
			dialogStage.initModality(Modality.NONE);
			Scene scene = new Scene(pane);
			dialogStage.setScene(scene);

			// get the controller
			uomImportController = loader.getController();
			uomImportController.setDialogStage(dialogStage);
		}

		// Show the dialog and wait until the user closes it
		uomImportController.getDialogStage().showAndWait();

		if (uomImportController.isCancelled()) {
			return;
		}

		UnitOfMeasure uom = uomImportController.getSelectedUom();

		if (uom == null) {
			throw new Exception(DesignerLocalizer.instance().getErrorString("unit.cannot.be.null"));
		}

		// make sure that there is a non-null category
		uom.getCategory();

		PersistenceService.instance().fetchReferencedUnits(uom);

		PersistenceService.instance().save(uom);

		onRefreshAllUoms();
	} catch (Exception e) {
		AppUtils.showErrorDialog(e);
	}
}
 
Example 20
Source File: MacMenuMain.java    From examples-javafx-repos1 with Apache License 2.0 4 votes vote down vote up
@Override
public void start(Stage primaryStage) throws Exception {
	
	System.setProperty("apple.laf.useScreenMenuBar", "false");

	FXMLLoader fxmlLoader = new FXMLLoader( this.getClass().getResource("/macmenu-fxml/MacMenu.fxml") );
	fxmlLoader.load();
	
	Parent p = fxmlLoader.getRoot();
	
	Scene scene = new Scene(p);
	
	primaryStage.setTitle( "Mac Menu" );
	primaryStage.setScene( scene );
	primaryStage.show();
}