Author: fmancinelli
Date: 2007-11-07 20:29:07 +0100 (Wed, 07 Nov 2007)
New Revision: 5711
Added:
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/xeclipse/handlers/GrabSpaceHandler.java
Modified:
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/plugin.xml
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/xeclipse/XWikiEclipseConstants.java
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/xeclipse/XWikiEclipseEvent.java
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/xeclipse/views/XWikiExplorerView.java
Log:
* Added grab space functionality
Modified:
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/plugin.xml
===================================================================
--- xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/plugin.xml
2007-11-07 19:14:29 UTC (rev 5710)
+++ xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/plugin.xml
2007-11-07 19:29:07 UTC (rev 5711)
@@ -123,6 +123,10 @@
id="org.xwiki.xeclipse.command.OpenPage"
name="Open page...">
</command>
+ <command
+ id="org.xwiki.xeclipse.command.GrabSpace"
+ name="Grab space...">
+ </command>
</extension>
<extension
name="NEW ADAPTERS"
Modified:
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/xeclipse/XWikiEclipseConstants.java
===================================================================
---
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/xeclipse/XWikiEclipseConstants.java
2007-11-07 19:14:29 UTC (rev 5710)
+++
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/xeclipse/XWikiEclipseConstants.java
2007-11-07 19:29:07 UTC (rev 5711)
@@ -11,6 +11,7 @@
public static final String NEW_PAGE_COMMAND =
"org.xwiki.xeclipse.command.NewPage";
public static final String REMOVE_SPACE_COMMAND =
"org.xwiki.xeclipse.command.RemoveSpace";
public static final String REMOVE_PAGE_COMMAND =
"org.xwiki.xeclipse.command.RemovePage";
+ public static final String GRAB_SPACE_COMMAND =
"org.xwiki.xeclipse.command.GrabSpace";
public static final String CONNECTION_SETTINGS_BANNER =
"icons/connection-settings-banner.png";
public static final String SPACE_SETTINGS_BANNER =
"icons/space-settings-banner.png";
Modified:
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/xeclipse/XWikiEclipseEvent.java
===================================================================
---
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/xeclipse/XWikiEclipseEvent.java
2007-11-07 19:14:29 UTC (rev 5710)
+++
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/xeclipse/XWikiEclipseEvent.java
2007-11-07 19:29:07 UTC (rev 5711)
@@ -27,5 +27,8 @@
SPACE_REMOVED,
/* Data: {IXWikiSpace, IXWikiPage} */
- PAGE_REMOVED
+ PAGE_REMOVED,
+
+ /* Data: Collection<IXWikiPage> */
+ PAGES_GRABBED
}
Added:
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/xeclipse/handlers/GrabSpaceHandler.java
===================================================================
---
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/xeclipse/handlers/GrabSpaceHandler.java
(rev 0)
+++
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/xeclipse/handlers/GrabSpaceHandler.java
2007-11-07 19:29:07 UTC (rev 5711)
@@ -0,0 +1,98 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *
+ */
+package org.xwiki.xeclipse.handlers;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.Collection;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.ui.handlers.HandlerUtil;
+import org.xwiki.xeclipse.XWikiEclipseEvent;
+import org.xwiki.xeclipse.XWikiEclipseNotificationCenter;
+import org.xwiki.xeclipse.model.IXWikiPage;
+import org.xwiki.xeclipse.model.IXWikiSpace;
+import org.xwiki.xeclipse.model.XWikiConnectionException;
+import org.xwiki.xeclipse.utils.XWikiEclipseUtil;
+
+public class GrabSpaceHandler extends AbstractHandler
+{
+ /*
+ * This variable is used to pass data about grabbed pages from the
anonymous class performing
+ * the downloading to the outer class
+ */
+ private Collection<IXWikiPage> grabbedXwikiPages;
+
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException
+ {
+ ISelection selection = HandlerUtil.getCurrentSelection(event);
+
+ Object selectedObject =
+
XWikiEclipseUtil.getSingleSelectedObjectInStructuredSelection(selection);
+
+ if (selectedObject instanceof IXWikiSpace) {
+ final IXWikiSpace xwikiSpace = (IXWikiSpace) selectedObject;
+
+ try {
+ XWikiEclipseUtil.runOperationWithProgress(new
IRunnableWithProgress()
+ {
+ public void run(IProgressMonitor monitor) throws
InvocationTargetException,
+ InterruptedException
+ {
+ monitor.beginTask("Getting pages...",
IProgressMonitor.UNKNOWN);
+ try {
+ grabbedXwikiPages = xwikiSpace.getPages();
+ for (IXWikiPage xwikiPage : grabbedXwikiPages) {
+ xwikiPage.getContent();
+ }
+ } catch (XWikiConnectionException e) {
+ e.printStackTrace();
+ throw new InvocationTargetException(e,
+ "Error while downloading pages");
+ }
+ monitor.done();
+ }
+ }, HandlerUtil.getActiveShell(event));
+
+ XWikiEclipseNotificationCenter.getDefault().fireEvent(this,
+ XWikiEclipseEvent.PAGES_GRABBED, grabbedXwikiPages);
+
+ } catch (InvocationTargetException e) {
+
+ e.printStackTrace();
+ MessageDialog.openError(HandlerUtil.getActiveShell(event),
"Error", e
+ .getMessage());
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }
+
+ return null;
+ }
+}
Modified:
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/xeclipse/views/XWikiExplorerView.java
===================================================================
---
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/xeclipse/views/XWikiExplorerView.java
2007-11-07 19:14:29 UTC (rev 5710)
+++
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/xeclipse/views/XWikiExplorerView.java
2007-11-07 19:29:07 UTC (rev 5711)
@@ -20,6 +20,8 @@
*/
package org.xwiki.xeclipse.views;
+import java.util.Collection;
+
import org.eclipse.core.expressions.EvaluationResult;
import org.eclipse.core.expressions.Expression;
import org.eclipse.core.expressions.ExpressionInfo;
@@ -67,6 +69,7 @@
import org.xwiki.xeclipse.editors.XWikiPageEditorInput;
import org.xwiki.xeclipse.handlers.ConnectHandler;
import org.xwiki.xeclipse.handlers.DisconnectHandler;
+import org.xwiki.xeclipse.handlers.GrabSpaceHandler;
import org.xwiki.xeclipse.handlers.NewPageHandler;
import org.xwiki.xeclipse.handlers.NewSpaceHandler;
import org.xwiki.xeclipse.handlers.RemoveConnectionHandler;
@@ -273,6 +276,20 @@
menuManager.add(new CommandContributionItem(getSite(),
null,
+ XWikiEclipseConstants.GRAB_SPACE_COMMAND,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ SWT.NONE));
+
+ menuManager.add(new Separator());
+
+ menuManager.add(new CommandContributionItem(getSite(),
+ null,
"org.eclipse.ui.edit.delete",
null,
null,
@@ -331,6 +348,8 @@
this);
XWikiEclipseNotificationCenter.getDefault().addListener(XWikiEclipseEvent.PAGE_UPDATED,
this);
+ XWikiEclipseNotificationCenter.getDefault().addListener(
+ XWikiEclipseEvent.PAGES_GRABBED, this);
}
@Override
@@ -354,6 +373,8 @@
XWikiEclipseEvent.PAGE_REMOVED, this);
XWikiEclipseNotificationCenter.getDefault().removeListener(
XWikiEclipseEvent.PAGE_UPDATED, this);
+ XWikiEclipseNotificationCenter.getDefault().removeListener(
+ XWikiEclipseEvent.PAGES_GRABBED, this);
super.dispose();
}
@@ -420,6 +441,33 @@
}
});
+
handlerService.activateHandler(XWikiEclipseConstants.GRAB_SPACE_COMMAND,
+ new GrabSpaceHandler(), new Expression()
+ {
+ @Override
+ public void collectExpressionInfo(ExpressionInfo info)
+ {
+
info.addVariableNameAccess(ISources.ACTIVE_CURRENT_SELECTION_NAME);
+ }
+
+ @Override
+ public EvaluationResult evaluate(IEvaluationContext context)
throws CoreException
+ {
+ Object selection =
+
context.getVariable(ISources.ACTIVE_CURRENT_SELECTION_NAME);
+ Object selectedObject =
+
XWikiEclipseUtil.getSingleSelectedObjectInStructuredSelection(selection);
+
+ if (selectedObject instanceof IXWikiSpace) {
+ IXWikiSpace xwikiSpace = (IXWikiSpace) selectedObject;
+ return xwikiSpace.getConnection().isConnected() ?
EvaluationResult.TRUE
+ : EvaluationResult.FALSE;
+ }
+
+ return EvaluationResult.FALSE;
+ }
+ });
+
handlerService.activateHandler(XWikiEclipseConstants.NEW_SPACE_COMMAND,
new NewSpaceHandler(), new Expression()
{
@@ -484,6 +532,7 @@
*/
Display.getDefault().asyncExec(new Runnable()
{
+ @SuppressWarnings("unchecked")
public void run()
{
IXWikiSpace space;
@@ -515,8 +564,13 @@
case PAGE_UPDATED:
treeViewer.refresh(data);
treeViewer.setSelection(new StructuredSelection(data));
+ break;
+ case PAGES_GRABBED:
+ Collection<IXWikiPage> xwikiPages =
(Collection<IXWikiPage>) data;
+ for(IXWikiPage xwikiPage : xwikiPages) {
+ treeViewer.update(xwikiPage, null);
+ }
break;
-
}
}
_______________________________________________
notifications mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/notifications