whitespace fixups
[jSite2.git] / src / net / pterodactylus / jsite / core / CoreListener.java
1 /*
2  * jSite2 - UserInterface.java -
3  * Copyright © 2008 David Roden
4  *
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.
9  *
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.
14  *
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.
18  */
19
20 package net.pterodactylus.jsite.core;
21
22 /**
23  * Interface definition for user interfaces.
24  *
25  * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
26  */
27 public interface CoreListener {
28
29         //
30         // project configuration
31         //
32
33         /**
34          * Notifies a listener that loading the projects finished successfully.
35          *
36          * @param directory
37          *            The directory the nodes were loaded from
38          */
39         public void loadingProjectsDone(String directory);
40
41         /**
42          * Notifies all listeners that loading the projects has failed.
43          *
44          * @param directory
45          *            The directory the projects were tried to load from
46          * @param throwable
47          *            The exception that occured while saving, if any
48          */
49         public void loadingProjectsFailed(String directory, Throwable throwable);
50
51         /**
52          * Notifies a listener that the projects were successfully saved to the
53          * given directory.
54          *
55          * @param directory
56          *            The directory the projects were saved to
57          */
58         public void savingProjectsDone(String directory);
59
60         /**
61          * Notifies a listener that saving the projects has failed.
62          *
63          * @param directory
64          *            The directory the projects were to be saved to
65          * @param throwable
66          *            The exception that occured when saving the projects, if any
67          */
68         public void savingProjectsFailed(String directory, Throwable throwable);
69
70         /**
71          * Notifies a listener that the given project was added.
72          *
73          * @param project
74          *            The project that was added.
75          */
76         public void projectAdded(Project project);
77
78         /**
79          * Notifies a listener that a project was cloned.
80          *
81          * @param clonedProject
82          *            The clones project
83          * @param projectClone
84          *            The clone of the project
85          */
86         public void projectCloned(Project clonedProject, Project projectClone);
87
88         /**
89          * Notifies a listener that the given project was removed.
90          *
91          * @param project
92          *            The project that was removed.
93          */
94         public void projectRemoved(Project project);
95
96         //
97         // node configuration
98         //
99
100         /**
101          * Notifies a listener that the nodes were successfully loaded.
102          *
103          * @param directory
104          *            The directory the nodes were loaded from
105          */
106         public void loadingNodesDone(String directory);
107
108         /**
109          * Notifies a listener that loading the nodes has failed.
110          *
111          * @param directory
112          *            The directory the nodes were loaded from
113          * @param throwable
114          *            The exception that occured while loading the nodes
115          */
116         public void loadingNodesFailed(String directory, Throwable throwable);
117
118         /**
119          * Notifies a listener that the nodes were successfully saved.
120          *
121          * @param directory
122          *            The directory the nodes were saved to
123          */
124         public void savingNodesDone(String directory);
125
126         /**
127          * Notifies a listener that saving the nodes has failed.
128          *
129          * @param directory
130          *            The directory the nodes were saved to
131          * @param throwable
132          *            The exception that occured while saving the nodes
133          */
134         public void savingNodesFailed(String directory, Throwable throwable);
135
136         //
137         // basic core functionality
138         //
139
140         /**
141          * Notifies all listeners that the core has loaded.
142          */
143         public void coreLoaded();
144
145         /**
146          * Notifies a listener that the core was stopped.
147          */
148         public void coreStopped();
149
150         //
151         // node stuff
152         //
153
154         /**
155          * Notifies a listener that a node was added to the core.
156          *
157          * @param node
158          *            The node that was added.
159          */
160         public void nodeAdded(Node node);
161
162         /**
163          * Notifies a listener that a node was removed from the core. Before a node
164          * is removed, it will be disconnected (and
165          * {@link #nodeDisconnected(Node, Throwable)} will be called).
166          *
167          * @param node
168          *            The node that was removed
169          */
170         public void nodeRemoved(Node node);
171
172         /**
173          * Notifies all listeners that the core started connecting to the given
174          * node. Before a node is connected, it will be added (and
175          * {@link #nodeAdded(Node)} will be called).
176          *
177          * @param node
178          *            The node that is being connected
179          */
180         public void nodeConnecting(Node node);
181
182         /**
183          * Notifies all listeners that the core connected to the given node.
184          *
185          * @param node
186          *            The node that is connected
187          */
188         public void nodeConnected(Node node);
189
190         /**
191          * Notifies a listener that a connection to a node has failed.
192          *
193          * @param node
194          *            The node that could not be connected
195          * @param cause
196          *            The cause of the failure
197          */
198         public void nodeConnectionFailed(Node node, Throwable cause);
199
200         /**
201          * Notifies all listeners that the core disconnected from the given node.
202          *
203          * @param node
204          *            The node that was diconnected
205          * @param throwable
206          *            The exception that caused the disconnect, or <code>null</code>
207          *            if there was no exception
208          */
209         public void nodeDisconnected(Node node, Throwable throwable);
210
211         //
212         // project insertion stuff
213         //
214
215         /**
216          * Notifies a listener that a project insert started.
217          *
218          * @param project
219          *            The project that is now inserting
220          */
221         public void projectInsertStarted(Project project);
222
223         /**
224          * Notifies a listener that a project insert made progress.
225          *
226          * @param project
227          *            The project that made progress
228          * @param totalBlocks
229          *            The number of total blocks
230          * @param requiredBlocks
231          *            The number of required blocks
232          * @param successfulBlocks
233          *            The number of successfully inserted blocks
234          * @param failedBlocks
235          *            The number of blocks that could not be inserted
236          * @param fatallyFailedBlocks
237          *            The number of blocks that can not be inserted even with
238          *            retries
239          * @param finalizedTotal
240          *            <code>true</code> if the number of total blocks is already
241          *            finalized, <code>false</code> otherwise
242          */
243         public void projectInsertProgressed(Project project, int totalBlocks, int requiredBlocks, int successfulBlocks, int failedBlocks, int fatallyFailedBlocks, boolean finalizedTotal);
244
245         /**
246          * Notifies a listener that a project insert has generated a URI.
247          *
248          * @param project
249          *            The project that generated a URI
250          * @param uri
251          *            The URI that was generated
252          */
253         public void projectInsertGeneratedURI(Project project, String uri);
254
255         /**
256          * Notifies a listener that a project insert has finished.
257          *
258          * @param project
259          *            The project that has finished
260          * @param success
261          *            <code>true</code> if the project was inserted successfully,
262          *            <code>false</code> otherwise
263          */
264         public void projectInsertFinished(Project project, boolean success);
265
266 }