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);
77 * Notifies a listener that the nodes were successfully loaded.
80 * The directory the nodes were loaded from
82 public void loadingNodesDone(String directory);
85 * Notifies a listener that loading the nodes has failed.
88 * The directory the nodes were loaded from
90 * The exception that occured while loading the nodes
92 public void loadingNodesFailed(String directory, Throwable throwable);
95 * Notifies a listener that the nodes were successfully saved.
98 * The directory the nodes were saved to
100 public void savingNodesDone(String directory);
103 * Notifies a listener that saving the nodes has failed.
106 * The directory the nodes were saved to
108 * The exception that occured while saving the nodes
110 public void savingNodesFailed(String directory, Throwable throwable);
113 // basic core functionality
117 * Notifies all listeners that the core has loaded.
119 public void coreLoaded();
122 * Notifies a listener that the core was stopped.
124 public void coreStopped();
131 * Notifies a listener that a node was added to the core.
134 * The node that was added.
136 public void nodeAdded(Node node);
139 * Notifies a listener that a node was removed from the core. Before a node
140 * is removed, it will be disconnected (and
141 * {@link #nodeDisconnected(Node, Throwable)} will be called).
144 * The node that was removed
146 public void nodeRemoved(Node node);
149 * Notifies all listeners that the core started connecting to the given
150 * node. Before a node is connected, it will be added (and
151 * {@link #nodeAdded(Node)} will be called).
154 * The node that is being connected
156 public void nodeConnecting(Node node);
159 * Notifies all listeners that the core connected to the given node.
162 * The node that is connected
164 public void nodeConnected(Node node);
167 * Notifies a listener that a connection to a node has failed.
170 * The node that could not be connected
172 * The cause of the failure
174 public void nodeConnectionFailed(Node node, Throwable cause);
177 * Notifies all listeners that the core disconnected from the given node.
180 * The node that was diconnected
182 * The exception that caused the disconnect, or <code>null</code>
183 * if there was no exception
185 public void nodeDisconnected(Node node, Throwable throwable);
188 // project insertion stuff
192 * Notifies a listener that a project insert started.
195 * The project that is now inserting
197 public void projectInsertStarted(Project project);
200 * Notifies a listener that a project insert made progress.
203 * The project that made progress
205 * The number of total blocks
206 * @param requiredBlocks
207 * The number of required blocks
208 * @param successfulBlocks
209 * The number of successfully inserted blocks
210 * @param failedBlocks
211 * The number of blocks that could not be inserted
212 * @param fatallyFailedBlocks
213 * The number of blocks that can not be inserted even with
215 * @param finalizedTotal
216 * <code>true</code> if the number of total blocks is already
217 * finalized, <code>false</code> otherwise
219 public void projectInsertProgressed(Project project, int totalBlocks, int requiredBlocks, int successfulBlocks, int failedBlocks, int fatallyFailedBlocks, boolean finalizedTotal);
222 * Notifies a listener that a project insert has generated a URI.
225 * The project that generated a URI
227 * The URI that was generated
229 public void projectInsertGeneratedURI(Project project, String uri);
232 * Notifies a listener that a project insert has finished.
235 * The project that has finished
237 * <code>true</code> if the project was inserted successfully,
238 * <code>false</code> otherwise
240 public void projectInsertFinished(Project project, boolean success);