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