2 * jSite2 - UserInterface.java -
3 * Copyright © 2008 David Roden
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 package net.pterodactylus.jsite.core;
22 import net.pterodactylus.jsite.project.Project;
25 * Interface definition for user interfaces.
27 * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
30 public interface CoreListener {
33 // project configuration
37 * Notifies a listener that loading the projects finished successfully.
40 * The directory the nodes were loaded from
42 public void loadingProjectsDone(String directory);
45 * Notifies all listeners that loading the projects has failed.
48 * The directory the projects were tried to load from
50 * The exception that occured while saving, if any
52 public void loadingProjectsFailed(String directory, Throwable throwable);
55 * Notifies a listener that the projects were successfully saved to the
59 * The directory the projects were saved to
61 public void savingProjectsDone(String directory);
64 * Notifies a listener that saving the projects has failed.
67 * The directory the projects were to be saved to
69 * The exception that occured when saving the projects, if any
71 public void savingProjectsFailed(String directory, Throwable throwable);
78 * Notifies a listener that the nodes were successfully loaded.
81 * The directory the nodes were loaded from
83 public void loadingNodesDone(String directory);
86 * Notifies a listener that loading the nodes has failed.
89 * The directory the nodes were loaded from
91 * The exception that occured while loading the nodes
93 public void loadingNodesFailed(String directory, Throwable throwable);
96 * Notifies a listener that the nodes were successfully saved.
99 * The directory the nodes were saved to
101 public void savingNodesDone(String directory);
104 * Notifies a listener that saving the nodes has failed.
107 * The directory the nodes were saved to
109 * The exception that occured while saving the nodes
111 public void savingNodesFailed(String directory, Throwable throwable);
114 // basic core functionality
118 * Notifies all listeners that the core has loaded.
120 public void coreLoaded();
123 * Notifies a listener that the core was stopped.
125 public void coreStopped();
132 * Notifies a listener that a node was added to the core.
135 * The node that was added.
137 public void nodeAdded(Node node);
140 * Notifies a listener that a node was removed from the core. Before a node
141 * is removed, it will be disconnected (and
142 * {@link #nodeDisconnected(Node, Throwable)} will be called).
145 * The node that was removed
147 public void nodeRemoved(Node node);
150 * Notifies all listeners that the core started connecting to the given
151 * node. Before a node is connected, it will be added (and
152 * {@link #nodeAdded(Node)} will be called).
155 * The node that is being connected
157 public void nodeConnecting(Node node);
160 * Notifies all listeners that the core connected to the given node.
163 * The node that is connected
165 public void nodeConnected(Node node);
168 * Notifies a listener that a connection to a node has failed.
171 * The node that could not be connected
173 * The cause of the failure
175 public void nodeConnectionFailed(Node node, Throwable cause);
178 * Notifies all listeners that the core disconnected from the given node.
181 * The node that was diconnected
183 * The exception that caused the disconnect, or <code>null</code>
184 * if there was no exception
186 public void nodeDisconnected(Node node, Throwable throwable);
189 // project insertion stuff
193 * Notifies a listener that a project insert started.
196 * The project that is now inserting
198 public void projectInsertStarted(Project project);
201 * Notifies a listener that a project insert made progress.
204 * The project that made progress
206 * The number of total blocks
207 * @param requiredBlocks
208 * The number of required blocks
209 * @param successfulBlocks
210 * The number of successfully inserted blocks
211 * @param failedBlocks
212 * The number of blocks that could not be inserted
213 * @param fatallyFailedBlocks
214 * The number of blocks that can not be inserted even with
216 * @param finalizedTotal
217 * <code>true</code> if the number of total blocks is already
218 * finalized, <code>false</code> otherwise
220 public void projectInsertProgressed(Project project, int totalBlocks, int requiredBlocks, int successfulBlocks, int failedBlocks, int fatallyFailedBlocks, boolean finalizedTotal);
223 * Notifies a listener that a project insert has generated a URI.
226 * The project that generated a URI
228 * The URI that was generated
230 public void projectInsertGeneratedURI(Project project, String uri);
233 * Notifies a listener that a project insert has finished.
236 * The project that has finished
238 * <code>true</code> if the project was inserted successfully,
239 * <code>false</code> otherwise
241 public void projectInsertFinished(Project project, boolean success);