Skip to main content
summaryrefslogtreecommitdiffstats
blob: 7844875c8c22e83a4a06af414d3969b2e1d8e63b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*******************************************************************************
 * Copyright (c) 2012 BestSolution.at and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Tom Schindl<tom.schindl@bestsolution.at> - initial API and implementation
 *******************************************************************************/
package org.eclipse.fx.ui.di;

import java.io.IOException;
import java.util.ResourceBundle;

import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;

import javafx.util.BuilderFactory;

/**
 * Builder for an FXMLLoader
 * 
 * @param <N>
 *            the root type loaded by the builder
 */
public interface FXMLBuilder<N> {
	/**
	 * Associate a resource bundle with the loader
	 * 
	 * @param resourceBundle
	 *            the resource bundle
	 * @return the builder instance
	 */
	@NonNull
	FXMLBuilder<N> resourceBundle(@NonNull ResourceBundle resourceBundle);

	/**
	 * Associate a builder factory with the loader
	 * 
	 * @param builderFactory
	 *            the builder factory
	 * @return the builder instance
	 */
	@NonNull
	FXMLBuilder<N> builderFactory(@NonNull BuilderFactory builderFactory);

	/**
	 * Load the FXML-Document
	 * 
	 * @return the root node
	 * @throws IOException
	 *             if there is a problem loading the fxml
	 */
	@NonNull
	N load() throws IOException;

	/**
	 * Load the FXML and return the root node and the controller
	 * 
	 * @return a structure holding root node and controller
	 * @throws IOException
	 *             if there is a problem loading the fxml
	 */
	<C> Data<N,C> loadWithController() throws IOException;

	/**
	 * Data struct holing root node and controller
	 * 
	 * @param <N>
	 *            the root node type
	 * @param <C>
	 *            the controller type
	 */
	public interface Data<N, C> {
		/**
		 * @return the root node
		 */
		@NonNull
		public N getNode();

		/**
		 * @return the controller, might be <code>null</code> if the fxml is not
		 *         associated to a controller
		 */
		@Nullable
		public C getController();
	}
}

Back to the top