package net.pterodactylus.jsite.core;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
/** The core listeners. */
private final List<CoreListener> coreListeners = new ArrayList<CoreListener>();
+ /** The project manager. */
+ private ProjectManager projectManager;
+
/** The node list. */
private List<Node> configuredNodes = new ArrayList<Node>();
}
/**
+ * Notifies all core listeners that loading the projects from the given
+ * directory has failed.
+ *
+ * @param directory
+ * The directory the projects were tried to load from
+ */
+ private void fireLoadingProjectsFailed(String directory) {
+ for (CoreListener coreListener: coreListeners) {
+ coreListener.loadingProjectsFailed(directory);
+ }
+ }
+
+ /**
* Notifies all core listeners that the core has loaded and is ready to run.
*/
private void fireCoreLoaded() {
//
/**
+ * Returns the project manager.
+ *
+ * @return The project manager
+ */
+ public ProjectManager getProjectManager() {
+ return projectManager;
+ }
+
+ /**
+ * Sets the project manager to use.
+ *
+ * @param projectManager
+ * The project manager to use
+ */
+ public void setProjectManager(ProjectManager projectManager) {
+ this.projectManager = projectManager;
+ }
+
+ /**
* Returns the list of all configured nodes.
*
* @return All configured nodes
* Starts the core.
*/
public void start() {
+ try {
+ projectManager.load();
+ } catch (IOException ioe1) {
+ fireLoadingProjectsFailed(projectManager.getDirectory());
+ }
fireCoreLoaded();
}