Author: fmancinelli
Date: 2007-11-16 13:46:40 +0100 (Fri, 16 Nov 2007)
New Revision: 5918
Modified:
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/eclipse/IXWikiEclipseEventListener.java
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/eclipse/XWikiConnectionManager.java
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/eclipse/XWikiEclipseConstants.java
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/eclipse/XWikiEclipseEvent.java
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/eclipse/XWikiEclipseNotificationCenter.java
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/eclipse/XWikiEclipsePageIndex.java
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/eclipse/XWikiEclipsePageIndexer.java
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/eclipse/editors/XWikiPageDocumentProvider.java
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/eclipse/handlers/ConnectHandler.java
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/eclipse/model/IXWikiConnection.java
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/eclipse/model/IXWikiConnectionListener.java
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/eclipse/model/IXWikiPage.java
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/eclipse/model/IXWikiSpace.java
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/eclipse/model/XWikiConnectionException.java
Log:
* Added documentation
Modified:
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/eclipse/IXWikiEclipseEventListener.java
===================================================================
---
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/eclipse/IXWikiEclipseEventListener.java
2007-11-16 12:37:57 UTC (rev 5917)
+++
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/eclipse/IXWikiEclipseEventListener.java
2007-11-16 12:46:40 UTC (rev 5918)
@@ -20,7 +20,17 @@
*/
package org.xwiki.eclipse;
+/**
+ * Interface that provides methods for dealing with XWiki Eclipse event
handling.
+ */
public interface IXWikiEclipseEventListener
{
+ /**
+ * Event notification.
+ *
+ * @param sender The object who generated the event.
+ * @param event The event type.
+ * @param data Additional data associated to the event (See [EMAIL
PROTECTED] XWikiEclipseEvent})
+ */
public void handleEvent(Object sender, XWikiEclipseEvent event, Object
data);
}
Modified:
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/eclipse/XWikiConnectionManager.java
===================================================================
---
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/eclipse/XWikiConnectionManager.java
2007-11-16 12:37:57 UTC (rev 5917)
+++
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/eclipse/XWikiConnectionManager.java
2007-11-16 12:46:40 UTC (rev 5918)
@@ -33,6 +33,9 @@
import org.xwiki.eclipse.model.IXWikiConnection;
import org.xwiki.eclipse.model.XWikiConnectionException;
+/**
+ * This singleton manages all the active connections
+ */
public class XWikiConnectionManager
{
private static XWikiConnectionManager sharedInstance;
@@ -41,6 +44,9 @@
private Map<String, String> idToPasswordMapping;
+ /**
+ * @return The shared instance of the singleton.
+ */
public static XWikiConnectionManager getDefault()
{
if (sharedInstance == null) {
@@ -56,11 +62,20 @@
idToPasswordMapping = new HashMap<String, String>();
}
+ /**
+ * @return A list of all registered connections.
+ */
public List<IXWikiConnection> getConnections()
{
return xwikiConnections;
}
+ /**
+ * Add a connection.
+ *
+ * @param xwikiConnection The connection to be added.
+ * @param password The password to be used for this connection.
+ */
public void addConnection(IXWikiConnection xwikiConnection, String
password)
{
if (!xwikiConnections.contains(xwikiConnection)) {
@@ -72,6 +87,11 @@
}
}
+ /**
+ * Remove a connection.
+ *
+ * @param xwikiConnection The connection to be removed.
+ */
public void removeConnection(IXWikiConnection xwikiConnection)
{
xwikiConnections.remove(xwikiConnection);
@@ -79,11 +99,23 @@
XWikiEclipseEvent.CONNECTION_REMOVED, xwikiConnection);
}
- public String getPasswordForConnection(String id)
+ /**
+ * Get the password associated to a given connection.
+ *
+ * @param xwikiConnection The connection object.
+ * @return The password associated to the given connection.
+ */
+ public String getPasswordForConnection(IXWikiConnection xwikiConnection)
{
- return idToPasswordMapping.get(id);
+ return idToPasswordMapping.get(xwikiConnection.getId());
}
+ /**
+ * Serialize registered connections to persistent storage.
+ *
+ * @param output The output file where to write the serialized data.
+ * @throws Exception
+ */
public void saveConnections(File output) throws Exception
{
ObjectOutputStream oos = new ObjectOutputStream(new
FileOutputStream(output));
@@ -95,6 +127,12 @@
oos.close();
}
+ /**
+ * Restore previously registered connections.
+ *
+ * @param input The file from where reading connection data.
+ * @throws Exception
+ */
@SuppressWarnings("unchecked")
public void restoreConnections(File input) throws Exception
{
@@ -104,6 +142,10 @@
ois.close();
}
+ /**
+ * Close all registered connections. This method should be called before
quitting the
+ * application in order to properly dispose all the resources associated
to the connections.
+ */
public void dispose()
{
for (IXWikiConnection xwikiConnecton : xwikiConnections) {
Modified:
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/eclipse/XWikiEclipseConstants.java
===================================================================
---
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/eclipse/XWikiEclipseConstants.java
2007-11-16 12:37:57 UTC (rev 5917)
+++
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/eclipse/XWikiEclipseConstants.java
2007-11-16 12:46:40 UTC (rev 5918)
@@ -20,6 +20,9 @@
*/
package org.xwiki.eclipse;
+/**
+ * Constants
+ */
public final class XWikiEclipseConstants
{
public static final Object[] NO_OBJECTS = new Object[0];
Modified:
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/eclipse/XWikiEclipseEvent.java
===================================================================
---
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/eclipse/XWikiEclipseEvent.java
2007-11-16 12:37:57 UTC (rev 5917)
+++
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/eclipse/XWikiEclipseEvent.java
2007-11-16 12:46:40 UTC (rev 5918)
@@ -20,6 +20,9 @@
*/
package org.xwiki.eclipse;
+/**
+ * XWiki Eclipse event definitions.
+ */
public enum XWikiEclipseEvent
{
/* Data: IXWikiConnection */
Modified:
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/eclipse/XWikiEclipseNotificationCenter.java
===================================================================
---
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/eclipse/XWikiEclipseNotificationCenter.java
2007-11-16 12:37:57 UTC (rev 5917)
+++
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/eclipse/XWikiEclipseNotificationCenter.java
2007-11-16 12:46:40 UTC (rev 5918)
@@ -25,6 +25,9 @@
import org.eclipse.core.runtime.ListenerList;
+/**
+ * This class implements a publish-subscribe notification hub for dispatching
events.
+ */
public class XWikiEclipseNotificationCenter
{
private Map<XWikiEclipseEvent, ListenerList> eventyTypeToListenersMapping;
@@ -36,6 +39,9 @@
eventyTypeToListenersMapping = new HashMap<XWikiEclipseEvent,
ListenerList>();
}
+ /**
+ * @return The shared instance.
+ */
public static XWikiEclipseNotificationCenter getDefault()
{
if (instance == null) {
@@ -45,7 +51,13 @@
return instance;
}
- public void addListener(XWikiEclipseEvent eventType, Object listener)
+ /**
+ * Register a listener for a given event type.
+ *
+ * @param eventType The event type.
+ * @param listener The associated listener.
+ */
+ public void addListener(XWikiEclipseEvent eventType,
IXWikiEclipseEventListener listener)
{
ListenerList listenerList =
eventyTypeToListenersMapping.get(eventType);
if (listenerList == null) {
@@ -56,6 +68,12 @@
listenerList.add(listener);
}
+ /**
+ * Unregister a listener for a given event type.
+ *
+ * @param eventType The event type.
+ * @param listener The associated listener.
+ */
public void removeListener(XWikiEclipseEvent eventType,
IXWikiEclipseEventListener listener)
{
ListenerList listenerList =
eventyTypeToListenersMapping.get(eventType);
@@ -64,6 +82,13 @@
}
}
+ /**
+ * Dispatch an event to all the listener registered for it.
+ *
+ * @param sender The object who sends the event.
+ * @param eventType The event type.
+ * @param data Additional data to be provided to the listener (depends on
the event type. See [EMAIL PROTECTED] XWikiEclipseEvent}
+ */
public void fireEvent(Object sender, XWikiEclipseEvent eventType, Object
data)
{
ListenerList listenerList =
eventyTypeToListenersMapping.get(eventType);
Modified:
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/eclipse/XWikiEclipsePageIndex.java
===================================================================
---
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/eclipse/XWikiEclipsePageIndex.java
2007-11-16 12:37:57 UTC (rev 5917)
+++
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/eclipse/XWikiEclipsePageIndex.java
2007-11-16 12:46:40 UTC (rev 5918)
@@ -27,6 +27,9 @@
import org.xwiki.eclipse.model.IXWikiConnection;
import org.xwiki.eclipse.model.IXWikiPage;
+/**
+ * A thread safe index for storing all known pages
+ */
public class XWikiEclipsePageIndex
{
private Set<IXWikiPage> pages;
@@ -38,6 +41,9 @@
pages = new CopyOnWriteArraySet<IXWikiPage>();
}
+ /**
+ * @return The shared instance
+ */
public static XWikiEclipsePageIndex getDefault()
{
if (instance == null) {
Modified:
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/eclipse/XWikiEclipsePageIndexer.java
===================================================================
---
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/eclipse/XWikiEclipsePageIndexer.java
2007-11-16 12:37:57 UTC (rev 5917)
+++
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/eclipse/XWikiEclipsePageIndexer.java
2007-11-16 12:46:40 UTC (rev 5918)
@@ -13,16 +13,29 @@
import org.xwiki.eclipse.model.IXWikiSpace;
import org.xwiki.plugins.eclipse.XWikiEclipsePlugin;
+/**
+ * A singleton that handles the indexing of available connections.
+ *
+ */
public class XWikiEclipsePageIndexer implements IXWikiEclipseEventListener
{
private static XWikiEclipsePageIndexer instance;
private Map<IXWikiConnection, Job> connectionToIndexerMapping;
+ /**
+ * The Eclipse job that performs the actual indexing for a given connection
+ *
+ */
private class IndexerJob extends Job
{
private IXWikiConnection connection;
+ /**
+ * Constructor.
+ *
+ * @param connection The connection to be indexed by this job.
+ */
public IndexerJob(IXWikiConnection connection)
{
super("Connection page indexer");
@@ -74,6 +87,9 @@
connectionToIndexerMapping = new HashMap<IXWikiConnection, Job>();
}
+ /**
+ * @return The shared instance.
+ */
public static XWikiEclipsePageIndexer getDefault()
{
if (instance == null) {
@@ -83,6 +99,9 @@
return instance;
}
+ /**
+ * Start the indexer.
+ */
public void start()
{
XWikiEclipseNotificationCenter.getDefault().addListener(
@@ -91,6 +110,9 @@
XWikiEclipseEvent.CONNECTION_CLOSED, this);
}
+ /**
+ * Stop the indexer.
+ */
public void stop()
{
XWikiEclipseNotificationCenter.getDefault().removeListener(
@@ -103,6 +125,16 @@
}
}
+ /**
+ * Event handling.
+ *
+ * When a connection is established, then an indexing job is created on
that connection.
+ * The job is re-scheduled at a fixed interval.
+ *
+ * When a connection is closed, the indexing job for that connection is
canceled.
+ *
+ * So only active connections are indexed.
+ */
public void handleEvent(Object sender, XWikiEclipseEvent event, Object
data)
{
IXWikiConnection connection;
Modified:
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/eclipse/editors/XWikiPageDocumentProvider.java
===================================================================
---
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/eclipse/editors/XWikiPageDocumentProvider.java
2007-11-16 12:37:57 UTC (rev 5917)
+++
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/eclipse/editors/XWikiPageDocumentProvider.java
2007-11-16 12:46:40 UTC (rev 5918)
@@ -107,10 +107,6 @@
"The page being saved has been modified remotely, and
is not up to date.\nLocal and remote content will be presented in the
editor.\n\nMerge the contents and resave the page in order to actualy update
the remote version.");
}
- // XWikiPageEditor.CaretState caretState =
xwikiPageEditor.getCaretState();
- // document.set(input.getXWikiPage().getContent());
- // xwikiPageEditor.updateEditor(input.getXWikiPage());
- // xwikiPageEditor.setCaretOffset(caretState);
xwikiPageEditor.updateEditor(input.getXWikiPage());
} catch (XWikiConnectionException e) {
throw new CoreException(new Status(IStatus.ERROR,
Modified:
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/eclipse/handlers/ConnectHandler.java
===================================================================
---
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/eclipse/handlers/ConnectHandler.java
2007-11-16 12:37:57 UTC (rev 5917)
+++
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/eclipse/handlers/ConnectHandler.java
2007-11-16 12:46:40 UTC (rev 5918)
@@ -52,8 +52,7 @@
try {
String password =
-
XWikiConnectionManager.getDefault().getPasswordForConnection(
- xwikiConnection.getId());
+
XWikiConnectionManager.getDefault().getPasswordForConnection(xwikiConnection);
if (password == null) {
InputDialog inputDialog =
new InputDialog(HandlerUtil.getActiveShell(event),
"Password", String
Modified:
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/eclipse/model/IXWikiConnection.java
===================================================================
---
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/eclipse/model/IXWikiConnection.java
2007-11-16 12:37:57 UTC (rev 5917)
+++
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/eclipse/model/IXWikiConnection.java
2007-11-16 12:46:40 UTC (rev 5918)
@@ -76,23 +76,63 @@
public Collection<IXWikiPage> getPages(IXWikiSpace space) throws
XWikiConnectionException;
/**
- * @return The pages that have already been fetched and for which we have
a local knwoledge.
+ * @return The pages that have already been fetched and for which we have
a local knowledge.
*/
public Collection<IXWikiPage> getKnownPages();
+ /**
+ * @param pageId The page id for the page to be retrieved.
+ * @return The page with the given id
+ * @throws XWikiConnectionException
+ */
public IXWikiPage getPage(String pageId) throws XWikiConnectionException;
+ /**
+ * @return The username associated to this connection.
+ */
public String getUserName();
+ /**
+ * @return The URL of the XWiki associated to this connection.
+ */
public String getServerUrl();
+ /**
+ * Create a space on the remove XWiki
+ *
+ * @param key
+ * @param name
+ * @param description
+ * @throws XWikiConnectionException
+ */
public void createSpace(String key, String name, String description)
throws XWikiConnectionException;
+ /**
+ * Create a page on the remote XWiki
+ *
+ * @param space The space where the page will be created.
+ * @param name The page name.
+ * @param content The page content.
+ * @return The newly created page.
+ * @throws XWikiConnectionException
+ */
public IXWikiPage createPage(IXWikiSpace space, String name, String
content)
throws XWikiConnectionException;
+ /**
+ * Remove a space from the remote XWiki.
+ *
+ * @param space The space to be removed.
+ * @throws XWikiConnectionException
+ */
public void removeSpace(IXWikiSpace space) throws XWikiConnectionException;
+ /**
+ * Remove a page from the remote XWiki.
+ *
+ * @param page The page to be removed.
+ * @throws XWikiConnectionException
+ */
public void removePage(IXWikiPage page) throws XWikiConnectionException;
}
Modified:
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/eclipse/model/IXWikiConnectionListener.java
===================================================================
---
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/eclipse/model/IXWikiConnectionListener.java
2007-11-16 12:37:57 UTC (rev 5917)
+++
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/eclipse/model/IXWikiConnectionListener.java
2007-11-16 12:46:40 UTC (rev 5918)
@@ -20,9 +20,20 @@
*/
package org.xwiki.eclipse.model;
+/**
+ * Interface providing methods that deal with connection lifecycle.
+ */
public interface IXWikiConnectionListener
{
+ /**
+ * Called when a connection to the remote XWiki is established.
+ * @param connection The connection object that generated the event.
+ */
public void connectionEstablished(IXWikiConnection connection);
+ /**
+ * Called when a connection to the remote XWiki is closed.
+ * @param connection The connection object that generated the event.
+ */
public void connectionClosed(IXWikiConnection connection);
}
Modified:
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/eclipse/model/IXWikiPage.java
===================================================================
---
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/eclipse/model/IXWikiPage.java
2007-11-16 12:37:57 UTC (rev 5917)
+++
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/eclipse/model/IXWikiPage.java
2007-11-16 12:46:40 UTC (rev 5918)
@@ -85,5 +85,10 @@
public IXWikiSpace getSpace() throws XWikiConnectionException;
+ /**
+ * Remove this page from the remote XWiki.
+ *
+ * @throws XWikiConnectionException
+ */
public void remove() throws XWikiConnectionException;
}
Modified:
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/eclipse/model/IXWikiSpace.java
===================================================================
---
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/eclipse/model/IXWikiSpace.java
2007-11-16 12:37:57 UTC (rev 5917)
+++
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/eclipse/model/IXWikiSpace.java
2007-11-16 12:46:40 UTC (rev 5918)
@@ -44,8 +44,20 @@
*/
public IXWikiConnection getConnection();
+ /**
+ * @return A collection containing all the pages stored in this space.
+ * @throws XWikiConnectionException
+ */
public Collection<IXWikiPage> getPages() throws XWikiConnectionException;
+ /**
+ * Create a page in this space.
+ *
+ * @param name The page name.
+ * @param content The page content.
+ * @return The newly created page.
+ * @throws XWikiConnectionException
+ */
public IXWikiPage createPage(String name, String content) throws
XWikiConnectionException;
public void remove() throws XWikiConnectionException;
Modified:
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/eclipse/model/XWikiConnectionException.java
===================================================================
---
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/eclipse/model/XWikiConnectionException.java
2007-11-16 12:37:57 UTC (rev 5917)
+++
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/eclipse/model/XWikiConnectionException.java
2007-11-16 12:46:40 UTC (rev 5918)
@@ -20,6 +20,9 @@
*/
package org.xwiki.eclipse.model;
+/**
+ * A checked exception representing errors generated while operating on a
connection.
+ */
public class XWikiConnectionException extends Exception
{
private static final long serialVersionUID = -2193452805890817846L;
_______________________________________________
notifications mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/notifications