make delete and clone buttons project specific
[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.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 the given project was removed.
82          * 
83          * @param project
84          *            The project that was removed.
85          */
86         public void projectRemoved(Project project);
87
88         //
89         // node configuration
90         //
91
92         /**
93          * Notifies a listener that the nodes were successfully loaded.
94          * 
95          * @param directory
96          *            The directory the nodes were loaded from
97          */
98         public void loadingNodesDone(String directory);
99
100         /**
101          * Notifies a listener that loading the nodes has failed.
102          * 
103          * @param directory
104          *            The directory the nodes were loaded from
105          * @param throwable
106          *            The exception that occured while loading the nodes
107          */
108         public void loadingNodesFailed(String directory, Throwable throwable);
109
110         /**
111          * Notifies a listener that the nodes were successfully saved.
112          * 
113          * @param directory
114          *            The directory the nodes were saved to
115          */
116         public void savingNodesDone(String directory);
117
118         /**
119          * Notifies a listener that saving the nodes has failed.
120          * 
121          * @param directory
122          *            The directory the nodes were saved to
123          * @param throwable
124          *            The exception that occured while saving the nodes
125          */
126         public void savingNodesFailed(String directory, Throwable throwable);
127
128         //
129         // basic core functionality
130         //
131
132         /**
133          * Notifies all listeners that the core has loaded.
134          */
135         public void coreLoaded();
136
137         /**
138          * Notifies a listener that the core was stopped.
139          */
140         public void coreStopped();
141
142         //
143         // node stuff
144         //
145
146         /**
147          * Notifies a listener that a node was added to the core.
148          * 
149          * @param node
150          *            The node that was added.
151          */
152         public void nodeAdded(Node node);
153
154         /**
155          * Notifies a listener that a node was removed from the core. Before a node
156          * is removed, it will be disconnected (and
157          * {@link #nodeDisconnected(Node, Throwable)} will be called).
158          * 
159          * @param node
160          *            The node that was removed
161          */
162         public void nodeRemoved(Node node);
163
164         /**
165          * Notifies all listeners that the core started connecting to the given
166          * node. Before a node is connected, it will be added (and
167          * {@link #nodeAdded(Node)} will be called).
168          * 
169          * @param node
170          *            The node that is being connected
171          */
172         public void nodeConnecting(Node node);
173
174         /**
175          * Notifies all listeners that the core connected to the given node.
176          * 
177          * @param node
178          *            The node that is connected
179          */
180         public void nodeConnected(Node node);
181
182         /**
183          * Notifies a listener that a connection to a node has failed.
184          * 
185          * @param node
186          *            The node that could not be connected
187          * @param cause
188          *            The cause of the failure
189          */
190         public void nodeConnectionFailed(Node node, Throwable cause);
191
192         /**
193          * Notifies all listeners that the core disconnected from the given node.
194          * 
195          * @param node
196          *            The node that was diconnected
197          * @param throwable
198          *            The exception that caused the disconnect, or <code>null</code>
199          *            if there was no exception
200          */
201         public void nodeDisconnected(Node node, Throwable throwable);
202
203         //
204         // project insertion stuff
205         //
206
207         /**
208          * Notifies a listener that a project insert started.
209          * 
210          * @param project
211          *            The project that is now inserting
212          */
213         public void projectInsertStarted(Project project);
214
215         /**
216          * Notifies a listener that a project insert made progress.
217          * 
218          * @param project
219          *            The project that made progress
220          * @param totalBlocks
221          *            The number of total blocks
222          * @param requiredBlocks
223          *            The number of required blocks
224          * @param successfulBlocks
225          *            The number of successfully inserted blocks
226          * @param failedBlocks
227          *            The number of blocks that could not be inserted
228          * @param fatallyFailedBlocks
229          *            The number of blocks that can not be inserted even with
230          *            retries
231          * @param finalizedTotal
232          *            <code>true</code> if the number of total blocks is already
233          *            finalized, <code>false</code> otherwise
234          */
235         public void projectInsertProgressed(Project project, int totalBlocks, int requiredBlocks, int successfulBlocks, int failedBlocks, int fatallyFailedBlocks, boolean finalizedTotal);
236
237         /**
238          * Notifies a listener that a project insert has generated a URI.
239          * 
240          * @param project
241          *            The project that generated a URI
242          * @param uri
243          *            The URI that was generated
244          */
245         public void projectInsertGeneratedURI(Project project, String uri);
246
247         /**
248          * Notifies a listener that a project insert has finished.
249          * 
250          * @param project
251          *            The project that has finished
252          * @param success
253          *            <code>true</code> if the project was inserted successfully,
254          *            <code>false</code> otherwise
255          */
256         public void projectInsertFinished(Project project, boolean success);
257
258 }