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>
29 public interface CoreListener {
32 // project configuration
36 * Notifies a listener that loading the projects finished successfully.
39 * The directory the nodes were loaded from
41 public void loadingProjectsDone(String directory);
44 * Notifies all listeners that loading the projects has failed.
47 * The directory the projects were tried to load from
49 * The exception that occured while saving, if any
51 public void loadingProjectsFailed(String directory, Throwable throwable);
54 * Notifies a listener that the projects were successfully saved to the
58 * The directory the projects were saved to
60 public void savingProjectsDone(String directory);
63 * Notifies a listener that saving the projects has failed.
66 * The directory the projects were to be saved to
68 * The exception that occured when saving the projects, if any
70 public void savingProjectsFailed(String directory, Throwable throwable);
73 * Notifies a listener that the given project was added.
76 * The project that was added.
78 public void projectAdded(Project project);
81 * Notifies a listener that a project was cloned.
83 * @param clonedProject
86 * The clone of the project
88 public void projectCloned(Project clonedProject, Project projectClone);
91 * Notifies a listener that the given project was removed.
94 * The project that was removed.
96 public void projectRemoved(Project project);
103 * Notifies a listener that the nodes were successfully loaded.
106 * The directory the nodes were loaded from
108 public void loadingNodesDone(String directory);
111 * Notifies a listener that loading the nodes has failed.
114 * The directory the nodes were loaded from
116 * The exception that occured while loading the nodes
118 public void loadingNodesFailed(String directory, Throwable throwable);
121 * Notifies a listener that the nodes were successfully saved.
124 * The directory the nodes were saved to
126 public void savingNodesDone(String directory);
129 * Notifies a listener that saving the nodes has failed.
132 * The directory the nodes were saved to
134 * The exception that occured while saving the nodes
136 public void savingNodesFailed(String directory, Throwable throwable);
139 // basic core functionality
143 * Notifies all listeners that the core has loaded.
145 public void coreLoaded();
148 * Notifies a listener that the core was stopped.
150 public void coreStopped();
157 * Notifies a listener that a node was added to the core.
160 * The node that was added.
162 public void nodeAdded(Node node);
165 * Notifies a listener that a node was removed from the core. Before a node
166 * is removed, it will be disconnected (and
167 * {@link #nodeDisconnected(Node, Throwable)} will be called).
170 * The node that was removed
172 public void nodeRemoved(Node node);
175 * Notifies all listeners that the core started connecting to the given
176 * node. Before a node is connected, it will be added (and
177 * {@link #nodeAdded(Node)} will be called).
180 * The node that is being connected
182 public void nodeConnecting(Node node);
185 * Notifies all listeners that the core connected to the given node.
188 * The node that is connected
190 public void nodeConnected(Node node);
193 * Notifies a listener that a connection to a node has failed.
196 * The node that could not be connected
198 * The cause of the failure
200 public void nodeConnectionFailed(Node node, Throwable cause);
203 * Notifies all listeners that the core disconnected from the given node.
206 * The node that was diconnected
208 * The exception that caused the disconnect, or <code>null</code>
209 * if there was no exception
211 public void nodeDisconnected(Node node, Throwable throwable);
214 // project insertion stuff
218 * Notifies a listener that a project insert started.
221 * The project that is now inserting
223 public void projectInsertStarted(Project project);
226 * Notifies a listener that a project insert made progress.
229 * The project that made progress
231 * The number of total blocks
232 * @param requiredBlocks
233 * The number of required blocks
234 * @param successfulBlocks
235 * The number of successfully inserted blocks
236 * @param failedBlocks
237 * The number of blocks that could not be inserted
238 * @param fatallyFailedBlocks
239 * The number of blocks that can not be inserted even with
241 * @param finalizedTotal
242 * <code>true</code> if the number of total blocks is already
243 * finalized, <code>false</code> otherwise
245 public void projectInsertProgressed(Project project, int totalBlocks, int requiredBlocks, int successfulBlocks, int failedBlocks, int fatallyFailedBlocks, boolean finalizedTotal);
248 * Notifies a listener that a project insert has generated a URI.
251 * The project that generated a URI
253 * The URI that was generated
255 public void projectInsertGeneratedURI(Project project, String uri);
258 * Notifies a listener that a project insert has finished.
261 * The project that has finished
263 * <code>true</code> if the project was inserted successfully,
264 * <code>false</code> otherwise
266 public void projectInsertFinished(Project project, boolean success);