/**
* Exception that is thrown when there is a problem with the FCP backend.
- *
+ *
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
*/
public class BackendException extends JSiteException {
/**
* Creates a new backend exception with the given message.
- *
+ *
* @param message
* The message of the exception
*/
/**
* Creates a new backend exception with the given cause.
- *
+ *
* @param cause
* The cause of the exception
*/
/**
* Creates a new backend exception with the given message and cause.
- *
+ *
* @param message
* The message of the exception
* @param cause
import java.util.List;
import java.util.concurrent.Executor;
-
/**
* Interface for the core.
- *
+ *
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
*/
public interface Core {
/**
* Adds the given listener to the list of registered listeners.
- *
+ *
* @param coreListener
* The listener to add
*/
/**
* Removes the given listener from the list of registered listeners.
- *
+ *
* @param coreListener
* The listener to remove
*/
/**
* Returns a thread pool.
- *
+ *
* @return A thread pool
*/
public Executor getThreadPool();
/**
* Adds the given node to the core.
- *
+ *
* @param node
* The node to add
* @return <code>true</code> if the node was added, <code>false</code>
/**
* Removes the given node from the core.
- *
+ *
* @param node
* The node to remove
*/
/**
* Returns the list of all configured nodes.
- *
+ *
* @return All configured nodes
*/
public List<Node> getNodes();
/**
* Returns whether the core is currently connected to the given node.
- *
+ *
* @param node
* The node to check
* @return <code>true</code> if the core is currently connected to the
/**
* Connects to the given node.
- *
+ *
* @param node
* The node to connect to
*/
/**
* Disconnects from the given node.
- *
+ *
* @param node
* The node to disconnect from
*/
/**
* Creates a new project.
- *
+ *
* @throws IOException
* if an I/O error occured communicating with the node
* @throws JSiteException
* Clones the given project. {@link CoreListener}s will be notified of the
* new clone via the {@link CoreListener#projectCloned(Project, Project)}
* event.
- *
+ *
* @param project
* The project to clone
*/
/**
* Removes the given project.
- *
+ *
* @param project
* The project to remove
*/
/**
* Returns a list of all projects.
- *
+ *
* @return A list of all projects
*/
public List<Project> getProjects();
/**
* The core of jSite.
- *
+ *
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
*/
public class CoreImpl implements Core, NodeListener, RequestListener {
/**
* Notifies all listeners that the projects were loaded successfully.
- *
+ *
* @param directory
* The directory the projects were loaded from
*/
/**
* Notifies all core listeners that loading the projects from the given
* directory has failed.
- *
+ *
* @param directory
* The directory the projects were tried to load from
* @param throwable
/**
* Notifies all listeners that the projects were successfully saved.
- *
+ *
* @param directory
* The directory the projects were saved to
*/
/**
* Notifies all listeners that the projects could not be saved.
- *
+ *
* @param directory
* The directory the projects were to be saved to
* @param throwable
/**
* Notifies all listeners that a project was added.
- *
+ *
* @param project
* The project that was added
*/
/**
* Notifies all listeners that a project was cloned.
- *
+ *
* @param clonedProject
* The project that was cloned
* @param projectClone
/**
* Notifies all listeners that a project was removed.
- *
+ *
* @param project
* The project that was removed
*/
/**
* Notifies all listeners that the nodes were successfully loaded.
- *
+ *
* @param directory
* The directory the nodes were loaded from
*/
/**
* Notifies all listeners that loading the nodes has failed.
- *
+ *
* @param directory
* The directory the nodes were loaded from
* @param throwable
/**
* Notifies all listeners that the nodes were saved successfully.
- *
+ *
* @param directory
* The directory the nodes were saved to
*/
/**
* Notifies all listeners that saving the nodes has failed.
- *
+ *
* @param directory
* The directory the nodes were saved to
* @param throwable
/**
* Notifies all listeners that a node was added to the core.
- *
+ *
* @param node
* The node that was added
*/
/**
* Notifies all listeners that a node was removed from the core.
- *
+ *
* @param node
* The node that was removed
*/
/**
* Notifies all listeners that a connection to the given node is now being
* established.
- *
+ *
* @param node
* The node that is being connected to
*/
/**
* Notifies all listeners that the given node is now connected.
- *
+ *
* @param node
* The node that is now connected
*/
/**
* Notifies all listeners that a connection to a node has failed.
- *
+ *
* @param node
* The node that could not be connected
* @param cause
/**
* Notifies all listeners that the given node was disconnected.
- *
+ *
* @param node
* The node that is now disconnected
* @param throwable
/**
* Returns the project manager.
- *
+ *
* @return The project manager
*/
public ProjectManager getProjectManager() {
/**
* Sets the project manager to use.
- *
+ *
* @param projectManager
* The project manager to use
*/
/**
* Returns the node manager.
- *
+ *
* @return The node manager
*/
public NodeManager getNodeManager() {
/**
* Sets the node manager to use.
- *
+ *
* @param nodeManager
* The node manager to use
*/
/**
* Sets the request manager to use.
- *
+ *
* @param requestManager
* The request manager to use
*/
/**
* Interface definition for user interfaces.
- *
+ *
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
*/
public interface CoreListener {
/**
* Notifies a listener that loading the projects finished successfully.
- *
+ *
* @param directory
* The directory the nodes were loaded from
*/
/**
* Notifies all listeners that loading the projects has failed.
- *
+ *
* @param directory
* The directory the projects were tried to load from
* @param throwable
/**
* Notifies a listener that the projects were successfully saved to the
* given directory.
- *
+ *
* @param directory
* The directory the projects were saved to
*/
/**
* Notifies a listener that saving the projects has failed.
- *
+ *
* @param directory
* The directory the projects were to be saved to
* @param throwable
/**
* Notifies a listener that the given project was added.
- *
+ *
* @param project
* The project that was added.
*/
/**
* Notifies a listener that a project was cloned.
- *
+ *
* @param clonedProject
* The clones project
* @param projectClone
/**
* Notifies a listener that the given project was removed.
- *
+ *
* @param project
* The project that was removed.
*/
/**
* Notifies a listener that the nodes were successfully loaded.
- *
+ *
* @param directory
* The directory the nodes were loaded from
*/
/**
* Notifies a listener that loading the nodes has failed.
- *
+ *
* @param directory
* The directory the nodes were loaded from
* @param throwable
/**
* Notifies a listener that the nodes were successfully saved.
- *
+ *
* @param directory
* The directory the nodes were saved to
*/
/**
* Notifies a listener that saving the nodes has failed.
- *
+ *
* @param directory
* The directory the nodes were saved to
* @param throwable
/**
* Notifies a listener that a node was added to the core.
- *
+ *
* @param node
* The node that was added.
*/
* Notifies a listener that a node was removed from the core. Before a node
* is removed, it will be disconnected (and
* {@link #nodeDisconnected(Node, Throwable)} will be called).
- *
+ *
* @param node
* The node that was removed
*/
* Notifies all listeners that the core started connecting to the given
* node. Before a node is connected, it will be added (and
* {@link #nodeAdded(Node)} will be called).
- *
+ *
* @param node
* The node that is being connected
*/
/**
* Notifies all listeners that the core connected to the given node.
- *
+ *
* @param node
* The node that is connected
*/
/**
* Notifies a listener that a connection to a node has failed.
- *
+ *
* @param node
* The node that could not be connected
* @param cause
/**
* Notifies all listeners that the core disconnected from the given node.
- *
+ *
* @param node
* The node that was diconnected
* @param throwable
/**
* Notifies a listener that a project insert started.
- *
+ *
* @param project
* The project that is now inserting
*/
/**
* Notifies a listener that a project insert made progress.
- *
+ *
* @param project
* The project that made progress
* @param totalBlocks
/**
* Notifies a listener that a project insert has generated a URI.
- *
+ *
* @param project
* The project that generated a URI
* @param uri
/**
* Notifies a listener that a project insert has finished.
- *
+ *
* @param project
* The project that has finished
* @param success
/**
* An override is used to enter other information about a file than the defaults
* would have yielded. It is also used to add redirects to a project.
- *
+ *
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
- * @version $Id$
*/
public class FileOverride {
/**
* Checks whether this override has any content.
- *
+ *
* @return <code>true</code> if this override does not have any effects,
* <code>false</code> otherwise
*/
/**
* Returns the insert override.
- *
+ *
* @return <code>true</code> if the entry should be inserted,
* <code>false</code> if it should not be inserted,
* <code>null</code> if the default should not be overridden
/**
* Sets the insert override.
- *
+ *
* @param insert
* <code>true</code> if the entry should be inserted,
* <code>false</code> if it should not be inserted,
/**
* Returns the override content type.
- *
+ *
* @return The override content type, or <code>null</code> to not override
* the default
*/
/**
* Sets the override content type.
- *
+ *
* @param contentType
* The override content type, or <code>null</code> to not
* override the default
/**
* Returns the target of a redirect.
- *
+ *
* @return The target URI of the redirect, or <code>null</code> if no
* redirect should be created
*/
/**
* Sets the target of a redirect.
- *
+ *
* @param redirectTarget
* The target URI of the redirect, or <code>null</code> if no
* redirect should be created
/**
* Converts an override string created by {@link #toString()} back to an
* {@link FileOverride} object.
- *
+ *
* @param overrideString
* The textual representation of the override
* @return The parsed override, or <code>null</code> if the string could
/*
* jSite2 - Insert.java - Copyright © 2008 David Roden
- *
+ *
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
- *
+ *
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
- *
+ *
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 59 Temple
* Place - Suite 330, Boston, MA 02111-1307, USA.
/**
* Represents a currently running or past insert.
- *
+ *
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
*/
public class Insert extends Request {
/**
* Creates a new insert that starts now.
- *
+ *
* @param project
* The project that is inserted
* @param node
/**
* Creates a new insert.
- *
+ *
* @param project
* The project that is inserted
* @param node
/**
* Returns the project that is inserted.
- *
+ *
* @return The inserted project
*/
public Project getProject() {
/**
* Returns the start time of the insert.
- *
+ *
* @return The start time of the insert
*/
public long getStartTime() {
/**
* Returns the end time of the insert. If the insert has not yet finished,
* <code>-1</code> is returned.
- *
+ *
* @return The end time of the insert, or <code>-1</code> if the insert is
* still running
*/
/**
* Sets the end time of the insert.
- *
+ *
* @param endTime
* The end time of the insert
*/
/*
* jSite2 - InsertListener.java - Copyright © 2008 David Roden
- *
+ *
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
- *
+ *
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
- *
+ *
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 59 Temple
* Place - Suite 330, Boston, MA 02111-1307, USA.
*/
+
package net.pterodactylus.jsite.core;
import java.util.EventListener;
/**
* Interface for objects that want to be notified on events emitted by the
* {@link InsertManager}.
- *
+ *
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
*/
public interface InsertListener extends EventListener {
/**
* Notifies a listener that an insert was added.
- *
+ *
* @param insert
* The insert that was added
*/
/**
* Notifies a listener that an insert was removed.
- *
+ *
* @param insert
* The insert that was removed
*/
/**
* Notifies a listener that an insert was started.
- *
+ *
* @param insert
* The insert that was started
*/
/**
* Notifies a listener that an insert made some progress.
- *
+ *
* @param insert
* The insert that made some progress
*/
/**
* Notifies listeners that an insert generated a URI.
- *
+ *
* @param insert
* The insert that generated a URI
* @param uri
/**
* Notifies a listener that an insert has finished.
- *
+ *
* @param insert
* The insert that has finished
*/
/*
* jSite2 - InsertManager.java - Copyright © 2008 David Roden
- *
+ *
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
- *
+ *
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
- *
+ *
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 59 Temple
* Place - Suite 330, Boston, MA 02111-1307, USA.
/**
* Manages all currently running and past inserts.
- *
+ *
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
*/
public class InsertManager {
/**
* Adds an insert listener to the list of insert listeners.
- *
+ *
* @param insertListener
* The insert listener to add
*/
/**
* Removes an insert listener from the list of insert listeners.
- *
+ *
* @param insertListener
* The insert listener to remove
*/
/**
* Notifies all listeners that an insert was added.
- *
+ *
* @param insert
* The insert that was added
*/
/**
* Notifies all listeners that an insert was removed.
- *
+ *
* @param insert
* The insert that was removes
*/
/**
* Notifies all listeners that an insert was started.
- *
+ *
* @param insert
* The insert that was started
*/
/**
* Notifies all listeners that an insert made some progress
- *
+ *
* @param insert
* The insert that made some progress
*/
/**
* Notifies all listeners that an insert generated a URI.
- *
+ *
* @param insert
* The insert that generated a URI
* @param uri
/**
* Notifies all listeners that an insert has finished.
- *
+ *
* @param insert
* The insert that has finished
*/
* Starts to insert the given project. The insert will be made to the node
* stored in the project, and if no node is specified in the project, the
* given node will be used.
- *
+ *
* @param project
* The project to insert
* @param node
/**
* Base exception for all jSite-specific exceptions.
- *
+ *
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
*/
public class JSiteException extends Exception {
/**
* Creates a new jSite exception with the given message.
- *
+ *
* @param message
* The message of the exception
*/
/**
* Creates a new jSite exception with the given cause.
- *
+ *
* @param cause
* The cause of the exception
*/
/**
* Creates a new jSite exception with the given message and cause.
- *
+ *
* @param message
* The message of the exception
* @param cause
/**
* Exception that signals the lack of configured nodes that are required for the
* action.
- *
+ *
* @see NodeManager#generateKeyPair()
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
*/
/**
* Creates a new exception with the given message.
- *
+ *
* @param message
* The message of the exception
*/
/**
* Creates a new exception with the given cause.
- *
+ *
* @param cause
* The cause of the exception
*/
/**
* Creates a new exception with the given message and cause.
- *
+ *
* @param message
* The message of the exception
* @param cause
/**
* Container for a Freenet node. A Node is capable of notifying
* {@link PropertyChangeListener}s if any of the contained properties change.
- *
+ *
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
*/
public class Node extends AbstractBean {
/**
* Returns the internal ID of the node.
- *
+ *
* @return The internal ID of the node
*/
String getId() {
/**
* Sets the internal ID of the node.
- *
+ *
* @param id
* The internal ID of the node
*/
/**
* Returns the user-given name of the node.
- *
+ *
* @return The name of the node
*/
public String getName() {
/**
* Sets the user-given name of the node.
- *
+ *
* @param name
* The name of the node
*/
/**
* Returns the hostname of the node.
- *
+ *
* @return The hostname of the node
*/
public String getHostname() {
/**
* Sets the hostname of the node.
- *
+ *
* @param hostname
* The hostname of the node
*/
/**
* Returns the port number of the node.
- *
+ *
* @return The port number of the node
*/
public int getPort() {
/**
* Sets the port number of the node.
- *
+ *
* @param port
* The port number of the node
*/
/**
* Interface for listeners that want to be notified about node events.
- *
+ *
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
*/
public interface NodeListener extends EventListener {
/**
* Notifies a listener that a node was added.
- *
+ *
* @param node
* The node that was added
*/
/**
* Notifies a listener that a node was removed.
- *
+ *
* @param node
* The node that was removed
*/
/**
* Notifies a listener that a connection to the given node was established.
- *
+ *
* @param node
* The node that is now connected
*/
/**
* Notifies a listener that a connection to a node has failed.
- *
+ *
* @param node
* The node that could not be connected
* @param cause
* anything else (like deregistering as listener from it) it should retrieve
* the high-level client using {@link NodeManager#getHighLevelClient(Node)}
* before this method returns!
- *
+ *
* @param node
* The node that is now disconnected
* @param throwable
/**
* TODO
- *
+ *
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
*/
public class NodeManager implements Iterable<Node>, PropertyChangeListener, HighLevelClientListener {
/**
* Creates a new FCP collector.
- *
+ *
* @param clientName
* The name of the FCP client
* @param directory
/**
* Adds the given listener to the list of listeners.
- *
+ *
* @param nodeListener
* The listener to add
*/
/**
* Removes the given listener from the list of listeners.
- *
+ *
* @param nodeListener
* The listener to remove
*/
/**
* Notifies all listeners that a node was added.
- *
+ *
* @param node
* The node that was added.
*/
/**
* Notifies all listeners that a node was removed.
- *
+ *
* @param node
* The node that was removed
*/
/**
* Notifies all listeners that the given node was connected.
- *
+ *
* @param node
* The node that is now connected
*/
/**
* Notifies all listeners that a connection to a node has failed.
- *
+ *
* @param node
* The node that could not be connected
* @param cause
/**
* Notifies all listeners that the given node was disconnected.
- *
+ *
* @param node
* The node that is now disconnected
* @param throwable
/**
* Returns the directory in which the nodes are stored.
- *
+ *
* @return The directory the nodes are stored in
*/
public String getDirectory() {
/**
* Checks whether the given node is already connected.
- *
+ *
* @param node
* The node to check
* @return <code>true</code> if the node is already connected,
/**
* Loads nodes.
- *
+ *
* @throws IOException
* if an I/O error occurs loading the nodes
*/
/**
* Saves all configured nodes.
- *
+ *
* @throws IOException
* if an I/O error occurs saving the nodes
*/
/**
* Adds the given node to this manager.
- *
+ *
* @see #connect(Node)
* @param node
* The node to connect to
/**
* Removes the given node from the node manager, disconnecting it if it is
* currently connected.
- *
+ *
* @param node
* The node to remove
*/
/**
* Tries to establish a connection with the given node.
- *
+ *
* @param node
* The node to connect to
*/
/**
* Disconnects the given node without removing it.
- *
+ *
* @param node
* The node to disconnect
*/
/**
* Returns a list of all nodes.
- *
+ *
* @return A list of all nodes
*/
public List<Node> getNodes() {
/**
* Returns the high-level client for a given node.
- *
+ *
* @param node
* The node to get a high-level client for
* @return The high-level client for a node, or <code>null</code> if the
/**
* Returns the node for a high-level client.
- *
+ *
* @param highLevelClient
* The high-level client to get the node for
* @return The node for the high-level client, or <code>null</code> if the
/**
* Returns the node identified by the given ID.
- *
+ *
* @param id
* The ID of the node
* @return The node with the given ID, or <code>null</code> if no such
/**
* Generates a new SSK key pair.
- *
+ *
* @return An array with the private key at index <code>0</code> and the
* public key at index <code>1</code>
* @throws IOException
/**
* Container for project information. A Project is capable of notifying
* {@link PropertyChangeListener}s if any of the contained properties change.
- *
+ *
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
*/
public class Project extends AbstractBean {
/**
* Clones the given project.
- *
+ *
* @param project
*/
Project(Project project) {
/**
* Returns the internal ID.
- *
+ *
* @return The internal ID
*/
String getId() {
/**
* Sets the internal ID.
- *
+ *
* @param id
* The internal ID
*/
/**
* Returns the name of the project.
- *
+ *
* @return The name of the project
*/
public String getName() {
/**
* Sets the name of the project.
- *
+ *
* @param name
* The name of the project
*/
/**
* Returns the description of the project.
- *
+ *
* @return The description of the project
*/
public String getDescription() {
/**
* Sets the description of the project
- *
+ *
* @param description
* The description of the project
*/
/**
* Returns the public key of the project.
- *
+ *
* @return The public key of the project
*/
public String getPublicKey() {
/**
* Sets the public key of the project.
- *
+ *
* @param publicKey
* The public key of the project
*/
/**
* Returns the private key of the project.
- *
+ *
* @return The private key of the project
*/
public String getPrivateKey() {
/**
* Sets the private key of the project.
- *
+ *
* @param privateKey
* The private key of the project
*/
/**
* Returns the base path of the project.
- *
+ *
* @return The base path of the project
*/
public String getBasePath() {
/**
* Sets the base path of the project.
- *
+ *
* @param basePath
* The base path of the project
*/
/**
* Returns the default file.
- *
+ *
* @return The default file
*/
public String getDefaultFile() {
/**
* Sets the default file.
- *
+ *
* @param defaultFile
* The default file
*/
/**
* Adds a file override for the given file.
- *
+ *
* @param projectFile
* The file
* @param override
/**
* Adds a file override for the given file.
- *
+ *
* @param filePath
* The file path
* @param override
/**
* Removes the file override for the given file.
- *
+ *
* @param projectFile
* The file for which to remove the override
*/
/**
* Removes the file override for the given file.
- *
+ *
* @param filePath
* The file path for which to remove the override
*/
/**
* Returns the file override for the given file.
- *
+ *
* @param projectFile
* The file for which to get the override
* @return The file override, or <code>null</code> if the given file does
/**
* Returns the file override for the given file.
- *
+ *
* @param filePath
* The file path for which to get the override
* @return The file override, or <code>null</code> if the given file does
/**
* Returns the list of {@link FileOverride}s.
- *
+ *
* @return All file overrides
*/
public Map<String, FileOverride> getFileOverrides() {
* base path. From this file it is possible to reach all files in the base
* path. This method is disk-intensive and may take some time on larger
* directories!
- *
+ *
* @return The file for the base path, or <code>null</code> if the base
* path does not denote an existing directory
*/
/**
* Returns the file that is specified by its complete path.
- *
+ *
* @param completePath
* The complete path of the file
* @return The project file at the given path, or <code>null</code> if
/**
* Returns the default node to insert this project to.
- *
+ *
* @return The node to insert this project to
*/
public Node getNode() {
/**
* Sets the default node to insert this project to.
- *
+ *
* @param node
* The node to insert this project to
*/
/**
* Scans the given directory and recreates the file and directory structure
* in the given project file.
- *
+ *
* @param directory
* The directory to scan
* @param projectFile
/**
* Implementation of a {@link ProjectFile}.
- *
+ *
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
*/
private static class ProjectFileImpl implements ProjectFile, Comparable<ProjectFileImpl> {
/**
* Creates a new project fie.
- *
+ *
* @param parentProjectFile
* The parent of the project file, or <code>null</code> if
* the new project file does not have a parent
/**
* Returns the project file with the given name. The project file has to
* be a direct child of this project file.
- *
+ *
* @param name
* The name of the file to get
* @return The project file, or <code>null</code> if there is no
/**
* Adds a new project file as child to this project file.
- *
+ *
* @param name
* The name of the file
* @param size
import java.io.File;
import java.util.List;
-
/**
* Abstraction for a that exists on the machine {@link Core} is being run on.
* This abstraction layer exists to make it possible to run jSite as a daemon
/**
* Lifetime statistics of a project.
- *
+ *
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
*/
public class ProjectLifetime {
/**
* Creates new lifetime statistics.
- *
+ *
* @param creationTime
* The creation time of the project
*/
/**
* Returns the creation time of the project. The time is given in
* milliseconds since Jan 1, 1970 UTC.
- *
+ *
* @see System#currentTimeMillis()
* @return The creation time of the project
*/
/**
* Manages projects, taking care of persistence, lifetime statistics, and other
* things.
- *
+ *
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
*/
public class ProjectManager implements PropertyChangeListener {
/**
* Creates a new project manager that saves and restores its state to/from
* the given directory.
- *
+ *
* @param directory
* The directory to save and restore states to/from
*/
/**
* Returns the directory the projects are loaded from and saved to.
- *
+ *
* @return The directory for storing the projects
*/
public String getDirectory() {
/**
* Returns a list of all projects.
- *
+ *
* @return A list of all projects
*/
public List<Project> getProjects() {
/**
* Sets the node manager to use.
- *
+ *
* @param nodeManager
* The node manager to use
*/
/**
* Loads projects and statistics.
- *
+ *
* @throws IOException
* if an I/O error occurs
*/
/**
* Saves projects and statistics.
- *
+ *
* @throws IOException
* if an I/O error occurs
*/
/**
* Creates a new project. The returned {@link Project} will contain a newly
* generated key pair.
- *
+ *
* @return A newly created project
* @throws IOException
* if an I/O error occured communicating with the node
* Clones the given project and returns the clone. The clone will be
* identical in all user-exposed fields, except for the project’s
* {@link Project#getId ID}.
- *
+ *
* @param project
* The project to clone
* @return The cloned project
/**
* Removes the given project.
- *
+ *
* @param project
* The project to remove
*/
/**
* A request is an ongoing download or upload reported by the freenet node.
- *
+ *
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
*/
public class Request extends AbstractBean {
/**
* The type of a request.
- *
+ *
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
*/
public enum Type {
/**
* Creates a new request with the given identifier.
- *
+ *
* @param node
* The node the request belongs to
* @param identifier
/**
* Returns the node the request belongs to.
- *
+ *
* @return The node the request belongs to
*/
public Node getNode() {
/**
* Returns the identifier of the request. It is unique per node.
- *
+ *
* @return The identifier of the request
*/
public String getIdentifier() {
/**
* Returns the type of the request.
- *
+ *
* @return The type of the request
*/
/**
* Sets the type of the request.
- *
+ *
* @param type
* The type of the request
*/
/**
* Returns the client token of the request.
- *
+ *
* @return The client token of the request
*/
public String getClientToken() {
/**
* Sets the client token of the request.
- *
+ *
* @param clientToken
* The client token of the request
*/
/**
* Returns whether the request has finished.
- *
+ *
* @see #isSuccessful()
* @return <code>true</code> if the request is finished,
* <code>false</code> otherwise
/**
* Sets whether the request has finished.
- *
+ *
* @param finished
* <code>true</code> if the request has finished,
* <code>false</code> otherwise
/**
* Returns whether the request finished successfully. This value will only
* have meaning if {@link #isFinished()} returns <code>true</code>.
- *
+ *
* @return <code>true</code> if the request finished successfully,
* <code>false</code> otherwise
*/
/**
* Sets whether this request finished successfully.
- *
+ *
* @param successful
* <code>true</code> if the request finished successfully,
* <code>false</code> otherwise
/**
* Returns whether the data inserted by this {@link Type#put} or
* {@link Type#putDir} request is already fetchable by other clients.
- *
+ *
* @return <code>true</code> if the data is already fetchable,
* <code>false</code> otherwise
*/
/**
* Sets whether the data inserted by this {@link Type#put} or
* {@link Type#putDir} request is already fetchable by other clients.
- *
+ *
* @param fetchable
* <code>true</code> if the data is already fetchable,
* <code>false</code> otherwise
/**
* Returns the URI generated by this request.
- *
+ *
* @return The generated URI
*/
public String getURI() {
/**
* Sets the URI generated by this request.
- *
+ *
* @param uri
* The generated URI
*/
* Returns the total number of blocks of a request. Until
* {@link #isTotalFinalized()} returns <code>true</code> this value may
* change!
- *
+ *
* @return The total number of blocks of a request
*/
public int getTotalBlocks() {
/**
* Sets the total number of blocks of a request.
- *
+ *
* @param totalBlocks
* The total number of blocks
*/
/**
* Interface for objects that want to be notified on request events.
- *
+ *
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
*/
public interface RequestListener extends EventListener {
/**
* Notifies a listener that a request was added to a node.
- *
+ *
* @param request
* The request that was added
*/
/**
* Notifies a listener that a request made progress.
- *
+ *
* @param request
* The request
*/
/**
* Notifies a listener that a request was removed.
- *
+ *
* @param request
* The request that was removed
*/
/**
* Notifies a listener that a Put request has generated a URI.
- *
+ *
* @param request
* The request that generated a URI
* @param uri
/**
* Notifies a listener that a request has completed.
- *
+ *
* @param request
* The finished request
*/
* The request manager is added to the {@link NodeManager} as a
* {@link NodeListener} so that it can fire request-removed events in case a
* node is disconnected.
- *
+ *
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
*/
public class RequestManager implements NodeListener, HighLevelProgressListener {
/**
* Adds a request listener.
- *
+ *
* @param requestListener
* The request listener to add
*/
/**
* Removes a request listener.
- *
+ *
* @param requestListener
* The request listener to remove
*/
/**
* Notifies all listeners that a request was added.
- *
+ *
* @param request
* The request that was added
*/
private void fireRequestAdded(Request request) {
- for (RequestListener requestListener: requestListeners) {
+ for (RequestListener requestListener : requestListeners) {
requestListener.requestAdded(request);
}
}
/**
* Notifies all listeners that a request progressed.
- *
+ *
* @param request
* The request
*/
private void fireRequestProgressed(Request request) {
- for (RequestListener requestListener: requestListeners) {
+ for (RequestListener requestListener : requestListeners) {
requestListener.requestProgressed(request);
}
}
/**
* Notifies all listeners that a request was removed.
- *
+ *
* @param request
* The request that was removed
*/
private void fireRequestRemoved(Request request) {
- for (RequestListener requestListener: requestListeners) {
+ for (RequestListener requestListener : requestListeners) {
requestListener.requestRemoved(request);
}
}
/**
* Notifies all listeners that a request has finished.
- *
+ *
* @see RequestListener#requestFinished(Request)
* @param request
* The request that has finished
*/
private void fireRequestFinished(Request request) {
- for (RequestListener requestListener: requestListeners) {
+ for (RequestListener requestListener : requestListeners) {
requestListener.requestFinished(request);
}
}
/**
* Notifies all listeners that a request has generated a URI.
- *
+ *
* @see RequestListener#requestGeneratedURI(Request, String)
* @param request
* The request that has generated a URI
* The generated URI
*/
private void fireRequestGeneratedURI(Request request, String uri) {
- for (RequestListener requestListener: requestListeners) {
+ for (RequestListener requestListener : requestListeners) {
requestListener.requestGeneratedURI(request, uri);
}
}
/**
* Sets the node manager to use.
- *
+ *
* @param nodeManager
* The node manager
*/
/**
* Requests a list of all running requests from a node. This method will
* block until the request has been sent!
- *
+ *
* @param node
* The node to get all requests for
* @throws IOException
logger.log(Level.SEVERE, "getResult() blocked and was interrupted");
return;
}
- for (RequestResult requestResult: requestListResult) {
+ for (RequestResult requestResult : requestListResult) {
String identifier = requestResult.getIdentifier();
logger.log(Level.FINER, "got identifier: " + identifier);
Request request = identifierRequests.get(identifier);
logger.warning("got node without request map: " + node);
return;
}
- for (Request request: identifierRequests.values()) {
+ for (Request request : identifierRequests.values()) {
fireRequestRemoved(request);
}
identifierRequests.clear();
/**
* Contains verifier for various settings.
- *
+ *
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
*/
public class Verifier {
/**
* Checks whether the given name is a valid node name.
- *
+ *
* @param name
* The name to verify
* @return <code>true</code> if the name is okay, <code>false</code> if
/**
* Verifies the given hostname by trying to resolve it.
- *
+ *
* @param hostname
* The hostname to verify
* @return <code>true</code> if the hostname is not empty and can be
/**
* Verifies that the port number is numeric and in the range from
* <code>0</code> to <code>65535</code>.
- *
+ *
* @param portString
* The port number string
* @return <code>true</code> if the port number is okay,
/**
* An “about” dialog.
- *
+ *
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
*/
public class AboutDialog extends JDialog implements I18nable {
/**
* Creates a new “about” dialog.
- *
+ *
* @param swingInterface
* The Swing interface
*/
/**
* Creates the “about” page.
- *
+ *
* @return The “about” page
*/
private JComponent createAboutPage() {
textPanel.add(Box.createVerticalStrut(12));
contributorsLabel.setFont(contributorsLabel.getFont().deriveFont(Font.BOLD));
- for (Contributor contributor: CONTRIBUTORS) {
+ for (Contributor contributor : CONTRIBUTORS) {
JLabel contributorLabel = new JLabel(contributor.getName() + " <" + contributor.getEmail() + "> (" + contributor.getPart() + ")");
textPanel.add(contributorLabel);
}
textPanel.add(codeUsageLabel);
textPanel.add(Box.createVerticalStrut(12));
- for (CodeUsage codeUsage: CODE_USAGES) {
+ for (CodeUsage codeUsage : CODE_USAGES) {
JLabel usageLabel = new JLabel(codeUsage.getName() + " (" + codeUsage.getURL() + ", " + codeUsage.getLicense() + ")");
textPanel.add(usageLabel);
}
/**
* Creates the “license” page.
- *
+ *
* @return The “license” page
*/
private JComponent createLicensePage() {
/**
* Loads the license text.
- *
+ *
* @return The license text
*/
private String loadLicenseText() {
/**
* Container for a contributor.
- *
+ *
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
*/
private static class Contributor {
/**
* Creates a new contributor.
- *
+ *
* @param name
* The name of the contributor
* @param email
/**
* Returns the name of the contributor.
- *
+ *
* @return The name of the contributor
*/
String getName() {
/**
* Returns the email address of the contributor.
- *
+ *
* @return The email address of the contributor
*/
String getEmail() {
/**
* Returns the parts where the contributor helped.
- *
+ *
* @return The parts where the contributor helped
*/
String getPart() {
/**
* A code usage object describes code or other resources that have been
* taken from other projects.
- *
+ *
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
*/
private static class CodeUsage {
/**
* Creates a new code usage object.
- *
+ *
* @param name
* The name of the project
* @param url
/**
* Returns the name of the project.
- *
+ *
* @return The name of the project
*/
public String getName() {
/**
* Returns the URL of the project.
- *
+ *
* @return The URL of the project
*/
public String getURL() {
/**
* Returns the license of the used part.
- *
+ *
* @return The license of the used part
*/
public String getLicense() {
/**
* Returns the used part.
- *
+ *
* @return The used part
*/
public String getPart() {
/**
* Dialog that lets the user edit the properties of a node.
- *
+ *
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
*/
public class AddNodeDialog extends JDialog implements I18nable {
/**
* Creates a new node edit dialog with the given parent.
- *
+ *
* @param parentFrame
* The parent frame of this dialog
*/
/**
* Returns the user-given name of the node.
- *
+ *
* @return The user-given name of the node
*/
public String getNodeName() {
/**
* Sets the user-given name of the node.
- *
+ *
* @param name
* The name of the node
*/
/**
* Returns the hostname of the node.
- *
+ *
* @return The hostname of the node
*/
public String getNodeHostname() {
/**
* Sets the hostname of the node.
- *
+ *
* @param hostname
* The hostname of the node
*/
/**
* Returns the FCP port number of the node.
- *
+ *
* @return The FCP port number of the node
*/
public int getNodePort() {
/**
* Sets the FCP port number of the node.
- *
+ *
* @param port
* The FCP port number of the node
*/
/**
* Returns whether the dialog was cancelled.
- *
+ *
* @return <code>true</code> if the dialog was cancelled,
* <code>false</code> if the user clicked “okay”
*/
/**
* The configuration dialog.
- *
+ *
* @author <a href="mailto:dr@ina-germany.de">David Roden</a>
*/
public class ConfigurationDialog extends JDialog implements I18nable {
/**
* Creates a new configuration dialog.
- *
+ *
* @param swingInterface
* The Swing interface
*/
/**
* Returns whether the dialog was cancelled or confirmed. If the dialog was
* cancelled, no further processing should be done.
- *
+ *
* @return <code>true</code> if the dialog was cancelled,
* <code>false</code> otherwise
*/
/**
* Returns whether the advanced mode is selected.
- *
+ *
* @return <code>true</code> if the advanced mode is selected,
* <code>false</code> otherwise
*/
/**
* Sets whether the advanced mode is selected.
- *
+ *
* @param advancedMode
* <code>true</code> if the advanced mode is selected,
* <code>false</code> otherwise
* Returns whether the “beautify” checkbox has been selected. The result of
* this method should not be used if {@link #wasCancelled()} returned
* <code>true</code>!
- *
+ *
* @return <code>true</code> if the checkbox was selected,
* <code>false</code> otherwise
*/
/**
* Sets the state of the “antialias” checkbox.
- *
+ *
* @param antialias
* The state of the checkbox
*/
/**
* Returns the font for the controls.
- *
+ *
* @return The control font, or <code>null</code> if no custom control
* font is to be used
*/
/**
* Sets the font for the controls.
- *
+ *
* @param controlFont
* The control font, or <code>null</code> if no custom control
* font is to be used
/**
* Returns the font for user input.
- *
+ *
* @return The font for user input, or <code>null</code> if no custom user
* input font is to be used
*/
/**
* Sets the font for user input.
- *
+ *
* @param userFont
* The font for user input, or <code>null</code> if no custom
* user input font is to be used
/**
* Returns the class name of the selected look and feel, if a custom look
* and feel is selected.
- *
+ *
* @return The class name of the look and feel to load, or <code>null</code>
* if no special look and feel should be used
*/
/**
* Sets the given look and feel.
- *
+ *
* @param lookAndFeel
* The class name of the look and feel, or <code>null</code> to
* not select a custom look and feel
/**
* Creates the interface configuration panel.
- *
+ *
* @return The interface configuration panel
*/
private JComponent createInterfaceConfig() {
/**
* Creates the panel for the interface tweaks configuration.
- *
+ *
* @return The interface tweaks configuration panel
*/
private JComponent createInterfaceTweaksConfig() {
LookAndFeelInfo[] lookAndFeelInfos = UIManager.getInstalledLookAndFeels();
List<LookAndFeelWrapper> lookAndFeelWrappers = new ArrayList<LookAndFeelWrapper>();
- for (LookAndFeelInfo lookAndFeelInfo: lookAndFeelInfos) {
+ for (LookAndFeelInfo lookAndFeelInfo : lookAndFeelInfos) {
lookAndFeelWrappers.add(new LookAndFeelWrapper(lookAndFeelInfo.getClassName(), lookAndFeelInfo.getName()));
}
customLAFComboBox = new JComboBox(lookAndFeelWrappers.toArray(new LookAndFeelWrapper[0]));
/**
* Wrapper around class name and name of a {@link LookAndFeel}.
- *
+ *
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
*/
private static class LookAndFeelWrapper {
/**
* Creates a new wrapper around the given class name and name of a look
* and feel.
- *
+ *
* @param className
* The class name of the look and feel
* @param lookAndFeelName
/**
* Returns the class name of the look and feel.
- *
+ *
* @return The class name of the look and feel
*/
public String getClassName() {
/**
* Manages physical and virtual files in a project.
- *
+ *
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
*/
public class FileManager extends JDialog implements I18nable, TreeSelectionListener, MouseListener {
/**
* Creates a new file manager.
- *
+ *
* @param swingInterface
* The Swing interface
* @param project
/**
* Creates the main panel with the file tree and the file properties.
- *
+ *
* @return The mail panel
*/
private Component createFileManagerPanel() {
/**
* Creates the button panel.
- *
+ *
* @return The button panel
*/
private Component createButtonPanel() {
/**
* Checks whether the given mouse event is a popup trigger and occured over
* a file. If so, the context menu is shown.
- *
+ *
* @param mouseEvent
* The mouse event to check
*/
/**
* Finds whether the {@link ProjectFile} given by
* <code>projectFileWrapper</code> is hidden.
- *
+ *
* @param projectFileWrapper
* The wrapped project file
* @return <code>true</code> if the file is hidden and should not be
/**
* Returns all currently selected {@link ProjectFileWrapper}s.
- *
+ *
* @param filesOnly
* <code>true</code> to return only selected files,
* <code>false</code> to include directories
/**
* Sets the given action’s enabled state to the given enabled state if the
* action’s current enabled state is not the given enabled state.
- *
+ *
* @param action
* The action to set the enabled state on
* @param enabled
/**
* Sets the given button’s selected state to the given selected state if the
* button’s current selected state is not the given selected state.
- *
+ *
* @param button
* The button to set the selected state on
* @param selected
* Returns the extension of the given filename. If the file name does not
* have an extension, the name of the file (without any path components) is
* returned.
- *
+ *
* @param fileName
* The name of the file
* @return The extension of the file
/**
* Repopulates the content type combo box with all content types, putting
* the most probably ones to the front of the list.
- *
+ *
* @param fileName
* The name of the file
*/
/**
* Tree cell renderer that takes care of certain display properties for
* project-specific stuff.
- *
+ *
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
*/
private class FileCellRenderer extends DefaultTreeCellRenderer {
/**
* TreeModel that is based on {@link Project#getBaseFile()}.
- *
+ *
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
*/
private class ProjectFileTreeModel implements TreeModel, PropertyChangeListener {
/**
* Notifies all listeners that a node has changed.
- *
+ *
* @param changedProjectFileWrapper
* The wrapper around the changed project file
*/
/**
* Notifies all listeners that the tree structure has changed
* significantly.
- *
+ *
* @see TreeModelListener#treeStructureChanged(TreeModelEvent)
* @param newRootNode
*/
/**
* Sets the new base project file. This causes the model to reload.
- *
+ *
* @param baseProjectFile
* The new base project file
*/
/**
* Creates {@link ProjectFileWrapper}s for all files below the given
* project file.
- *
+ *
* @param projectFile
* The base project file for all project files to create
* wrappers for
/**
* Wrapper around a {@link ProjectFile} that overwrites
* {@link Object#toString()} to return the project file’s name.
- *
+ *
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
*/
private static class ProjectFileWrapper {
/**
* Creates a new wrapper around a project file.
- *
+ *
* @param projectFile
* The project file to wrap
*/
/**
* Returns the wrapped project file.
- *
+ *
* @return The wrapped project file
*/
public ProjectFile getProjectFile() {
/**
* Sets the name override. If the name override is not <code>null</code>
* it will be shown insted of the project file’s name.
- *
+ *
* @param nameOverride
* The name override
*/
/**
* A cell renderer for combo boxes that converts the string “--” to a
* separator.
- *
+ *
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
*/
private class MimeTypeComboBoxRenderer extends DefaultListCellRenderer {
* upen is changed this change is not picked up (see <a
* href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4304129">bug
* #4304129</a>).
- *
+ *
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
*/
public class FixedJMenuItem extends JMenuItem {
/**
* Creates a new fixed menu item.
- *
+ *
* @param action
* The action of the menu item
*/
/**
* Combobox that displays a list of all available fonts, showing the name of the
* font in the font itself.
- *
+ *
* @see GraphicsEnvironment#getAllFonts()
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
*/
System.out.println("got " + allFonts.length + " fonts");
fontNames = new String[allFonts.length];
int fontIndex = 0;
- for (Font font: allFonts) {
+ for (Font font : allFonts) {
fontNames[fontIndex++] = font.getName();
}
}
/**
* The cell renderer for the font name cells.
- *
+ *
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
*/
private static class FontCellRenderer extends JLabel implements ListCellRenderer {
/**
* Frame that shows log messages as they occur.
- *
+ *
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
*/
public class LogWindow extends JFrame implements LoggingListener, ActionListener {
/**
* Table model for the log message table.
- *
+ *
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
*/
private class LogRecordTableModel extends AbstractTableModel {
/**
* Adds a log record.
- *
+ *
* @param logRecord
* The log record to add
*/
/**
* Defines the main window of the application.
- *
+ *
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
*/
public class MainWindow extends JFrame implements WindowListener, I18nable, PropertyChangeListener {
/**
* Creates a new main window that redirects all actions to the given swing
* interface.
- *
+ *
* @param swingInterface
* The swing interface to receive all actions
*/
/**
* Sets the text of the status bar.
- *
+ *
* @param text
* The text of the status bar
*/
/**
* Returns the status bar clear delay (in milliseconds).
- *
+ *
* @return The status bar clear delay
*/
public int getStatusBarClearDelay() {
/**
* Sets the status bar clear delay (in milliseconds).
- *
+ *
* @param statusBarClearDelay
* The status bar clear delay
*/
/**
* Sets whether the advanced mode is activated.
- *
+ *
* @param advancedMode
* <code>true</code> if the advanced mode is activated,
* <code>false</code> if the simple mode is activated
/**
* Returns the currently selected project.
- *
+ *
* @return The currently selected project
*/
public Project getSelectedProject() {
/**
* Sets the given node to the “online” state.
- *
+ *
* @param node
* The node to set online
*/
/**
* Sets the given node to the “offline” state in the status bar.
- *
+ *
* @param node
* The node to set offline
*/
/**
* Sets the given node to the “error” state in the status bar.
- *
+ *
* @param node
* The node to set the error state for
*/
/**
* Adds a node to the menu.
- *
+ *
* @param node
* The node to add
*/
/**
* Removes a node from the menu.
- *
+ *
* @param node
* The node to remove
*/
/**
* Adds a project to the project pane.
- *
+ *
* @param project
* The project to add
* @param switchToProject
/**
* Removes the pane containing the given project.
- *
+ *
* @param project
* The project whose pane to remove
*/
/**
* Returns the index of the project panel that contains the given project.
- *
+ *
* @param project
* The wanted project
* @return The index of {@link #projectPane}’s tab that contains the given
* A node label is a small component that sits in the status bar, displays the
* current status of a node and offers a context menu to connect and disconnect
* from the node.
- *
+ *
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
*/
public class NodeLabel extends JLabel implements PropertyChangeListener, MouseListener, I18nable {
/**
* Creates a new node label.
- *
+ *
* @param swingInterface
* The Swing interface
* @param node
/**
* Checks whether the given mouse event is a trigger for popup menues and
* shows the popup menu if it is.
- *
+ *
* @param mouseEvent
* The mouse event to check for being a popup trigger
*/
/**
* A panel that contains all information about a project and lets the user edit
* the properties of the project.
- *
+ *
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
*/
public class ProjectPanel extends JPanel implements DocumentListener, I18nable {
/**
* Creates a new project panel.
- *
+ *
* @param swingInterface
* The Swing interface
* @param project
/**
* Returns the project that is displayed in this panel.
- *
+ *
* @return The project of this panel
*/
public Project getProject() {
/**
* Adds the given node to the node combo boxes in all {@link ProjectPanel}s.
- *
+ *
* @param node
* The node to add
*/
/**
* Removes the given node from the node combo boxes in all
* {@link ProjectPanel}s.
- *
+ *
* @param node
* The node to remove
*/
/**
* Creates the properties panel.
- *
+ *
* @return The properties panel
*/
private JPanel createPropertiesPanel() {
/**
* Creates the button panel.
- *
+ *
* @return The button panel
*/
private JPanel createButtonPanel() {
/**
* Updates the project from changes in the text fields.
- *
+ *
* @param document
* The document that was changed
*/
/**
* Cell cenderer for the node combo box.
- *
+ *
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
*/
private static class NodeComboBoxCellRenderer extends DefaultListCellRenderer {
}
};
List<Locale> availableLanguages = I18n.findAvailableLanguages();
- for (final Locale locale: availableLanguages) {
+ for (final Locale locale : availableLanguages) {
String language = locale.getLanguage();
I18nAction languageAction = new I18nAction("general.language." + language, IconLoader.loadIcon("/flag-" + language + ".png")) {
* The action that triggered the change
*/
private void changeLanguage(Locale newLocale, I18nAction languageAction) {
- for (I18nAction i18nAction: languageActions) {
+ for (I18nAction i18nAction : languageActions) {
i18nAction.setEnabled(i18nAction != languageAction);
}
I18n.setLocale(newLocale);
*/
public void loadingProjectsDone(String directory) {
mainWindow.setStatusBarText(I18n.get("mainWindow.statusBar.projectLoadingDone"));
- for (Project project: core.getProjects()) {
+ for (Project project : core.getProjects()) {
projectAdded(project, false);
}
}
/**
* Class that handles i18n.
- *
+ *
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
*/
public class I18n {
/**
* Returns the translated value for a key. The translated values may contain
* placeholders that are replaced with the given parameters.
- *
+ *
* @see MessageFormat
* @param key
* The key to get
* Returns the keycode from the value of the given key. You can specify the
* constants in {@link KeyEvent} in the properties file, e.g. VK_S for the
* keycode ‘s’ when used for mnemonics.
- *
+ *
* @param key
* The key under which the keycode is stored
* @return The keycode
/**
* Returns a key stroke for use with swing accelerators.
- *
+ *
* @param key
* The key of the key stroke
* @return The key stroke, or <code>null</code> if no key stroke could be
/**
* Sets the current locale.
- *
+ *
* @param newLocale
* The new locale to use
*/
/**
* Sets the current locale.
- *
+ *
* @param newLocale
* The new locale to use
* @param notify
/**
* Returns the current locale.
- *
+ *
* @return The current locale
*/
public static Locale getLocale() {
/**
* Finds all available locales.
- *
+ *
* @return All available locales
*/
public static List<Locale> findAvailableLanguages() {
/**
* Registers the given I18nable to be updated when the language is changed.
- *
+ *
* @param i18nable
* The i18nable to register
*/
/**
* Deregisters the given I18nable to be updated when the language is
* changed.
- *
+ *
* @param i18nable
* The i18nable to register
*/
* Notifies all registered {@link I18nable}s that the language was changed.
*/
private static void notifyI18nables() {
- for (I18nable i18nable: i18nables) {
+ for (I18nable i18nable : i18nables) {
i18nable.updateI18n();
}
}
/**
* Interface for objects that want to be notified when the language is changed.
- *
+ *
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
*/
public interface I18nable {
/**
* Helper class that initializes actions with values from {@link I18n}.
- *
+ *
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
*/
public abstract class I18nAction extends AbstractAction implements I18nable {
/**
* Creates a new action that uses the given name as base name to get values
* from {@link I18n}.
- *
+ *
* @param i18nName
* The base name of the action
*/
/**
* Creates a new action that uses the given name as base name to get values
* from {@link I18n} and the given icon.
- *
+ *
* @param i18nName
* The base name of the action
* @param icon
/**
* Creates a new action that uses the given name as base name to get values
* from {@link I18n}.
- *
+ *
* @param i18nName
* The base name of the action
* @param enabled
/**
* Creates a new action that uses the given name as base name to get values
* from {@link I18n} and the given icon.
- *
+ *
* @param i18nName
* The base name of the action
* @param enabled
/**
* Label that can update itself from {@link I18n}.
- *
+ *
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
*/
public class I18nLabel extends JLabel implements I18nable {
/**
* Creates a new label with the given I18n basename.
- *
+ *
* @param i18nBasename
* The I18n basename of the label
*/
/**
* Creates a new label with the given I18n basename that optionally is a
* label for the given component.
- *
+ *
* @param i18nBasename
* The I18n basename of the label
* @param component
/**
* Creates a new label with the given I18n basename that optionally is a
* label for the given component.
- *
+ *
* @param i18nBasename
* The I18n basename of the label
* @param arguments
/**
* Creates a new label with the given I18n basename that optionally is a
* label for the given component.
- *
+ *
* @param i18nBasename
* The I18n basename of the label
* @param component
/**
* Menu that receives its properties from {@link I18n}.
- *
+ *
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
*/
public class I18nMenu extends JMenu implements I18nable {
/**
* Creates a new menu with the given {@link I18n} basename.
- *
+ *
* @param i18nBasename
* The basename of the {@link I18n} properties
*/
/**
* Contains various i18n-related Swing helper classes.
- *
+ *
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
*/
/**
* Main class that is called by the VM.
- *
+ *
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
*/
public class Main {
/**
* Main entry method for the VM.
- *
+ *
* @param args
* The command-line arguments
*/
/**
* Tries to load the class with the given name and includes the look & feel
* in the UIManager, if it exists.
- *
+ *
* @param name
* The name of the look & feel
* @param className
/**
* Tries to load each look & feel and adds it to the list of installed look &
* feels.
- *
+ *
* @see UIManager#setInstalledLookAndFeels(LookAndFeelInfo[])
* @param lookAndFeelInfos
* The look & feels to add
*/
private void addLookAndFeels(LookAndFeelInfo... lookAndFeelInfos) {
List<LookAndFeelInfo> allLookAndFeelInfos = new ArrayList<LookAndFeelInfo>(Arrays.asList(UIManager.getInstalledLookAndFeels()));
- for (LookAndFeelInfo lookAndFeelInfo: lookAndFeelInfos) {
+ for (LookAndFeelInfo lookAndFeelInfo : lookAndFeelInfos) {
try {
Class.forName(lookAndFeelInfo.getClassName());
allLookAndFeelInfos.add(lookAndFeelInfo);
/**
* Container for version information.
- *
+ *
* @author David Roden <bombe@freenetproject.org>
*/
public class Version implements Comparable<Version> {
/**
* Creates a new version with the given major level and minor and patch
* levels set to <code>0</code>.
- *
+ *
* @param major
* The major level of the version
*/
/**
* Creates a new version with the given major and minor level and the patch
* level set to <code>0</code>.
- *
+ *
* @param major
* The major level of the version
* @param minor
/**
* Creates a new version with the given major, minor, and patch level.
- *
+ *
* @param major
* The major level of the version
* @param minor
/**
* Returns the version of the application.
- *
+ *
* @return The version of the application
*/
public static Version getVersion() {
/**
* Returns the major level of the version.
- *
+ *
* @return The major level of the version
*/
public int getMajor() {
/**
* Returns the minor level of the version.
- *
+ *
* @return The minor level of the version
*/
public int getMinor() {
/**
* Returns the patch level of the version.
- *
+ *
* @return The patch level of the version
*/
public int getPatch() {
/**
* A generator for internal IDs.
- *
+ *
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
*/
public class IdGenerator {
/**
* Generates a new random ID, consisting of {@link #DEFAULT_LENGTH} random
* bytes.
- *
+ *
* @return The new ID
*/
public static byte[] generateId() {
/**
* Generates a new random ID, consisting of <code>length</code> random
* bytes.
- *
+ *
* @param length
* The length of the ID in bytes before conversion to a string
* @return The new ID
/**
* Abstract bean super class that contains property change listener management.
- *
+ *
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
*/
public abstract class AbstractBean {
/**
* Adds a property change listener.
- *
+ *
* @param propertyChangeListener
* The property change listener to add
*/
/**
* Removes a property change listener.
- *
+ *
* @param propertyChangeListener
* The property change listener to remove
*/
/**
* Notifies all listeners that a property has changed.
- *
+ *
* @param property
* The name of the property
* @param oldValue
*/
protected void firePropertyChange(String property, Object oldValue, Object newValue) {
PropertyChangeEvent propertyChangeEvent = new PropertyChangeEvent(this, property, oldValue, newValue);
- for (PropertyChangeListener propertyChangeListener: propertyChangeListeners) {
+ for (PropertyChangeListener propertyChangeListener : propertyChangeListeners) {
propertyChangeListener.propertyChange(propertyChangeEvent);
}
/**
* Fires a property change event if the two values are not equal.
- *
+ *
* @param propertyName
* The name of the property
* @param oldValue
* Compares the two objects and returns whether they are equal according to
* {@link Object#equals(Object)}. This method takes <code>null</code>
* into account as a valid value for an object.
- *
+ *
* @param first
* The first object
* @param second
* A node that can be stored in a {@link Tree}. A node has exactly one parent
* (which is <code>null</code> if the node is the {@link Tree#getRootNode()}
* of the tree) and an arbitrary amount of child nodes.
- *
+ *
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
* @param <E>
* The type of the element to store
/**
* Returns the parent node of the node.
- *
+ *
* @return The parent node
*/
public Node<E> getParent();
/**
* Returns the element that is stored in the node.
- *
+ *
* @return The node’s element
*/
public E getElement();
/**
* Adds an element as a child to this node and returns the created node.
- *
+ *
* @param child
* The child node’s element
* @return The created child node
/**
* Returns the number of children this node has.
- *
+ *
* @return The number of children
*/
public int size();
/**
* Returns the child at the given index.
- *
+ *
* @param index
* The index of the child
* @return The child at the given index
/**
* Returns the direct child node that contains the given element.
- *
+ *
* @param element
* The element
* @return The direct child node containing the given element, or
/**
* Returns whether the given node is a direct child of this node.
- *
+ *
* @param childNode
* The child node
* @return <code>true</code> if the given node is a direct child of this
/**
* Returns whether this node contains a child node containing the given
* element.
- *
+ *
* @param element
* The element
* @return <code>true</code> if this node contains a direct child node
/**
* Returns the index of the given child node.
- *
+ *
* @param childNode
* The child node
* @return The index of the child node, or <code>-1</code> if the child
/**
* Returns the index of the child node containing the given element.
- *
+ *
* @param element
* The element
* @return The index of the child node, or <code>-1</code> if the child
/**
* Remove the given child node from this node. If the given node is not a
* child of this node, nothing happens.
- *
+ *
* @param childNode
* The child node to remove
*/
/**
* Removes the child node that contains the given element. The element in
* the node is checked using {@link Object#equals(Object)}.
- *
+ *
* @param child
* The child element to remove
*/
/**
* Removes the child at the given index.
- *
+ *
* @param childIndex
* The index of the child to remove
*/
/**
* Searches this node’s children recursively for a node that contains the
* given element.
- *
+ *
* @param element
* The element to search
* @return The node that contains the given element, or <code>null</code>
/**
* Sorts all children with the given comparator.
- *
+ *
* @param comparator
* The comparator used to sort the children
*/
/**
* Implementation of the {@link Node} interface.
- *
+ *
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
* @param <E>
* The type of the element to store
/**
* Creates a new node with the given parent and element.
- *
+ *
* @param parentNode
* The parent of this node
* @param element
* {@inheritDoc}
*/
public Node<E> getChild(E element) {
- for (Node<E> childNode: children) {
+ for (Node<E> childNode : children) {
if (childNode.getElement().equals(element)) {
return childNode;
}
* {@inheritDoc}
*/
public boolean hasChild(E element) {
- for (Node<E> childNode: children) {
+ for (Node<E> childNode : children) {
if (childNode.getElement().equals(element)) {
return true;
}
*/
public int getIndexOfChild(Node<E> childNode) {
int childIndex = 0;
- for (Node<E> node: children) {
+ for (Node<E> node : children) {
if (node.equals(childNode)) {
return childIndex;
}
*/
public int getIndexOfChild(E element) {
int childIndex = 0;
- for (Node<E> node: children) {
+ for (Node<E> node : children) {
if (node.getElement().equals(element)) {
return childIndex;
}
* {@inheritDoc}
*/
public void removeChild(E child) {
- for (Node<E> childNode: children) {
+ for (Node<E> childNode : children) {
if (child.equals(childNode.getElement())) {
children.remove(childNode);
break;
* {@inheritDoc}
*/
public Node<E> findChild(E element) {
- for (Node<E> childNode: children) {
+ for (Node<E> childNode : children) {
Node<E> wantedNode = childNode.findChild(element);
if (wantedNode != null) {
return wantedNode;
/**
* A tree structure in which every node can have an arbitrary amount of
* children.
- *
+ *
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
* @param <E>
* The type of the element to store
/**
* Returns the root node of the tree.
- *
+ *
* @return The root node of the tree
*/
public Node<E> getRootNode() {
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
- *
+ *
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
- *
+ *
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 59 Temple
* Place - Suite 330, Boston, MA 02111-1307, USA.
/**
* Loads an {@link Icon} from the class path.
- *
+ *
* @author <a href="mailto:droden@gmail.com">David Roden</a>
*/
public class IconLoader {
/**
* Loads an icon from the class path.
- *
+ *
* @param resourceName
* The name of the icon
* @return The icon, or <code>null</code> if no icon was found
/**
* Loads an image from the class path.
- *
+ *
* @param resourceName
* The name of the image
* @return The image, or <code>null</code> if no image was found
/*
* freenet - Closer.java Copyright © 2007 David Roden
- *
+ *
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
- *
+ *
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
- *
+ *
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 59 Temple
* Place - Suite 330, Boston, MA 02111-1307, USA.
* <code>null</code> before being closed, and every possible execption is
* swallowed. That makes this class perfect for use in the finally blocks of
* try-catch-finally blocks.
- *
+ *
* @author David ‘Roden’ <bombe@freenetproject.org>
*/
public class Closer {
/**
* Closes the given closeable.
- *
+ *
* @param closeable
* The closeable to close
*/
/**
* Closes the given socket.
- *
+ *
* @param socket
* The socket to close
*/
/**
* Closes the given jar file.
- *
+ *
* @param jarFile
* The jar file to close
*/
/**
* Closes the given zip file.
- *
+ *
* @param zipFile
* The zip file to close
*/
/**
* A wrapper around an {@link InputStream} that only supplies a limit number of
* bytes from the underlying input stream.
- *
+ *
* @author <a href="mailto:dr@ina-germany.de">David Roden</a>
*/
public class LimitedInputStream extends FilterInputStream {
/**
* Creates a new LimitedInputStream that supplies at most
* <code>length</code> bytes from the given input stream.
- *
+ *
* @param inputStream
* The input stream
* @param length
/**
* {@inheritDoc} This method does nothing, as {@link #mark(int)} and
* {@link #reset()} are not supported.
- *
+ *
* @see java.io.FilterInputStream#mark(int)
*/
@Override
/**
* {@inheritDoc}
- *
+ *
* @see java.io.FilterInputStream#markSupported()
* @return <code>false</code>
*/
/**
* {@inheritDoc} This method does nothing, as {@link #mark(int)} and
* {@link #reset()} are not supported.
- *
+ *
* @see java.io.FilterInputStream#reset()
*/
@Override
/**
* Consumes the input stream, i.e. read all bytes until the limit is
* reached.
- *
+ *
* @throws IOException
* if an I/O error occurs
*/
/**
* Handles MIME types and maps them to file extensions.
- *
+ *
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
*/
public class MimeTypes {
/**
* Returns a list of all known MIME types.
- *
+ *
* @return All known MIME types
*/
public static List<String> getAllMimeTypes() {
/**
* Returns a list of MIME types that are registered for the given extension.
- *
+ *
* @param extension
* The extension to get the MIME types for
* @return A list of MIME types, or an empty list if there are no registered
* Returns a default MIME type for the given extension. If the extension
* does not match a MIME type the default MIME typ
* “application/octet-stream” is returned.
- *
+ *
* @param extension
* The extension to get the MIME type for
* @return The MIME type for the extension, or the default MIME type
/**
* Adds a MIME type and optional extensions.
- *
+ *
* @param mimeType
* The MIME type to add
* @param extensions
/**
* Helper class that copies bytes from an {@link InputStream} to an
* {@link OutputStream}.
- *
+ *
* @author <a href="mailto:dr@ina-germany.de">David Roden</a>
*/
public class StreamCopier {
/**
* Sets the buffer size for following transfers.
- *
+ *
* @param bufferSize
* The new buffer size
*/
* as much bytes as possible will be copied (i.e. until
* {@link InputStream#read()} returns <code>-1</code> to signal the end of
* the stream).
- *
+ *
* @param source
* The input stream to read from
* @param destination
* Copies as much bytes as possible (i.e. until {@link InputStream#read()}
* returns <code>-1</code>) from the source input stream to the
* destination output stream.
- *
+ *
* @param source
* The input stream to read from
* @param destination
/**
* Finds the length of the input stream by reading until
* {@link InputStream#read(byte[])} returns <code>-1</code>.
- *
+ *
* @param source
* The input stream to measure
* @return The length of the input stream in bytes
/**
* Sets up logging.
- *
+ *
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
*/
public class Logging {
/**
* Adds a listener to the log handler.
- *
+ *
* @param loggingListener
* The listener to add
*/
/**
* Removes a listener from the log handler.
- *
+ *
* @param loggingListener
* The listener to remove
*/
/**
* Sets up logging and installs the log handler.
- *
+ *
* @param hierarchyName
* The name of the hierarchy root logger
*/
}
recordBuffer.append("\n");
StackTraceElement[] stackTraceElements = throwable.getStackTrace();
- for (StackTraceElement stackTraceElement: stackTraceElements) {
+ for (StackTraceElement stackTraceElement : stackTraceElements) {
recordBuffer.append(linePrefix).append(" at ").append(stackTraceElement.getClassName()).append('.').append(stackTraceElement.getMethodName()).append("(").append(stackTraceElement.getFileName()).append(':').append(stackTraceElement.getLineNumber()).append(')').append("\n");
}
throwable = throwable.getCause();
/**
* Returns a named logger from the jSite hierarchy.
- *
+ *
* @param name
* The name of the logger
* @return The logger
/**
* The log handler simply forwards every log message it receives to all
* registered listeners.
- *
+ *
* @see LoggingListener
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
*/
/**
* Adds a listener to the log handler.
- *
+ *
* @param loggingListener
* The listener to add
*/
/**
* Removes a listener from the log handler.
- *
+ *
* @param loggingListener
* The listener to remove
*/
/**
* Notifies all listeners that a log record was received.
- *
+ *
* @param logRecord
* The received log record
*/
private void fireLogged(LogRecord logRecord) {
- for (LoggingListener loggingListener: loggingListeners) {
+ for (LoggingListener loggingListener : loggingListeners) {
loggingListener.logged(logRecord);
}
}
/**
* Interface for components that want to received logged messages.
- *
+ *
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
*/
public interface LoggingListener extends EventListener {
/**
* Notifies a listener that a new log record was received.
- *
+ *
* @param logRecord
* The received log record
*/
/**
* Conversion routines for handling hexadecimal numbers.
- *
+ *
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
*/
public class Hex {
/**
* Converts the given byte array to a hexadecimal string.
- *
+ *
* @param dataBytes
* The bytes to convert
* @return A string of hexadecimal numbers
*/
public static String toHex(byte[] dataBytes) {
StringBuilder hexString = new StringBuilder(dataBytes.length * 2);
- for (byte dataByte: dataBytes) {
+ for (byte dataByte : dataBytes) {
String hexByte = "0" + Integer.toHexString(dataByte & 0xff);
hexString.append(hexByte.substring(hexByte.length() - 2));
}
/**
* {@link MutableTreeNode} subclass that allows to sort its children.
- *
+ *
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
*/
public class SortableTreeNode implements MutableTreeNode {
/**
* Creates a new sortable tree node.
- *
+ *
* @param allowsChildren
* <code>true</code> if this node allows children,
* <code>false</code> otherwise
/**
* Creates a new sortable tree node that contains the given user-defined
* object.
- *
+ *
* @param userObject
* The user-defined object
*/
/**
* Creates a new sortable tree node that contains the given user-defined
* object.
- *
+ *
* @param userObject
* The user-defined object
* @param allowsChildren
/**
* Returns the user-defined object.
- *
+ *
* @return The user-defined object
*/
public Object getUserObject() {
/**
* Adds the given node to this node as a child.
- *
+ *
* @param child
* The child node to add
*/
* Removes all children of this node.
*/
public void removeAll() {
- for (MutableTreeNode childNode: children) {
+ for (MutableTreeNode childNode : children) {
childNode.setParent(null);
}
children.clear();
/**
* Status bar component that can be added to the {@link BorderLayout#SOUTH} area
* of a {@link JFrame}’s {@link JFrame#getContentPane() content pane}.
- *
+ *
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
*/
/* TODO - make it possible to add further components. */
/**
* Sets the text of the label.
- *
+ *
* @param text
* The text of the label
*/
/**
* Adds a side component to the right side of the status bar, pushing all
* previously added side components to the left.
- *
+ *
* @param component
* The component to add
*/
/**
* Returns the number of side components.
- *
+ *
* @return The number of side components
*/
public int getSideComponentCount() {
/**
* Returns all side components in order.
- *
+ *
* @return All side components
*/
public List<Component> getSideComponents() {
/**
* Removes the side component with the given index.
- *
+ *
* @param sideComponentIndex
* The index of the side component to remove
*/
/**
* Removes the given side component.
- *
+ *
* @param sideComponent
* The side component to remove
*/
/**
* Helper utilities for working with Swing.
- *
+ *
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
*/
public class SwingUtils {
/**
* Returns the size of the screen.
- *
+ *
* @return The size of the screen
*/
public static Dimension getScreenSize() {
/**
* Centers the given window on the screen.
- *
+ *
* @param window
* The window to center
*/
/**
* {@link Window#pack() Packs} the given window and positions it so that its
* center stays the same.
- *
+ *
* @param window
* The window to pack and recenter
*/
/**
* Returns the center of the given rectangle.
- *
+ *
* @param bounds
* The rectangle which center to get
* @return The center of the rectangle