Author: fmancinelli
Date: 2007-11-03 13:48:22 +0100 (Sat, 03 Nov 2007)
New Revision: 5621
Added:
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/xeclipse/handlers/RemovePageHandler.java
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/xeclipse/handlers/RemoveSpaceHandler.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/plugins/eclipse/model/impl/XWikiPage.java
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/model/IXWikiConnection.java
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/xeclipse/model/IXWikiPage.java
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/xeclipse/model/IXWikiSpace.java
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/xeclipse/model/impl/AbstractXWikiConnection.java
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/xeclipse/model/impl/DiskCacheDAO.java
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/xeclipse/model/impl/IXWikiDAO.java
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/xeclipse/model/impl/XWikiCachedConnection.java
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/xeclipse/model/impl/XWikiPage.java
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/xeclipse/model/impl/XWikiPlainConnection.java
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/xeclipse/model/impl/XWikiRemoteDAO.java
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/xeclipse/model/impl/XWikiSpace.java
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/xeclipse/views/XWikiExplorerView.java
Log:
XECLIPSE-30
* Added page/space removal functionalities
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-02 18:58:42 UTC (rev 5620)
+++ xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/plugin.xml
2007-11-03 12:48:22 UTC (rev 5621)
@@ -110,6 +110,14 @@
id="org.xwiki.xeclipse.command.NewPage"
name="New page...">
</command>
+ <command
+ id="org.xwiki.xeclipse.command.RemoveSpace"
+ name="Remove space">
+ </command>
+ <command
+ id="org.xwiki.xeclipse.command.RemovePage"
+ name="Remove page">
+ </command>
</extension>
<extension
name="NEW ADAPTERS"
Modified:
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/plugins/eclipse/model/impl/XWikiPage.java
===================================================================
---
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/plugins/eclipse/model/impl/XWikiPage.java
2007-11-02 18:58:42 UTC (rev 5620)
+++
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/plugins/eclipse/model/impl/XWikiPage.java
2007-11-03 12:48:22 UTC (rev 5621)
@@ -537,7 +537,7 @@
/**
* [EMAIL PROTECTED]
*
- * @see org.xwiki.plugins.eclipse.model.IXWikiPage#getSpace()
+ * @see org.xwiki.plugins.eclipse.model.IXWikiPage#getSpaceKey()
*/
public IXWikiSpace getParentSpace()
{
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-02 18:58:42 UTC (rev 5620)
+++
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/xeclipse/XWikiEclipseConstants.java
2007-11-03 12:48:22 UTC (rev 5621)
@@ -9,6 +9,8 @@
public static final String NEW_CONNECTION_COMMAND =
"org.xwiki.xeclipse.command.NewConnection";
public static final String NEW_SPACE_COMMAND =
"org.xwiki.xeclipse.command.NewSpace";
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 CONNECTION_SETTINGS_BANNER =
"icons/connection-settings-banner.png";
public static final String SPACE_SETTINGS_BANNER =
"icons/space-settings-banner.png";
@@ -18,7 +20,4 @@
public static final String XWIKI_PAGE_CACHED_ICON =
"icons/xwiki-page-cached.png";
public static final String XWIKI_PAGE_CONFLICT_ICON =
"icons/xwiki-page-conflict.png";
public static final String SHOW_EDITOR_PREVIEW_ICON =
"icons/show-editor-preview.gif";
-
-
-
}
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-02 18:58:42 UTC (rev 5620)
+++
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/xeclipse/XWikiEclipseEvent.java
2007-11-03 12:48:22 UTC (rev 5621)
@@ -15,5 +15,9 @@
/* Data: IXWikiConnection - the connection to be refreshed */
SPACE_CREATED,
/* Data: IXWikiSpace - the space to be refreshed */
- PAGE_CREATED
+ PAGE_CREATED,
+ /* Data: IXWikiConnection */
+ SPACE_REMOVED,
+ /* Data: IXWikiSpace */
+ PAGE_REMOVED
}
Added:
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/xeclipse/handlers/RemovePageHandler.java
===================================================================
---
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/xeclipse/handlers/RemovePageHandler.java
(rev 0)
+++
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/xeclipse/handlers/RemovePageHandler.java
2007-11-03 12:48:22 UTC (rev 5621)
@@ -0,0 +1,66 @@
+/*
+ * 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 org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.MessageBox;
+import org.eclipse.ui.handlers.HandlerUtil;
+import org.xwiki.xeclipse.model.IXWikiPage;
+import org.xwiki.xeclipse.model.XWikiConnectionException;
+import org.xwiki.xeclipse.utils.XWikiEclipseUtil;
+
+public class RemovePageHandler extends AbstractHandler
+{
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException
+ {
+ ISelection selection = HandlerUtil.getCurrentSelection(event);
+
+ Object selectedObject =
+
XWikiEclipseUtil.getSingleSelectedObjectInStructuredSelection(selection);
+
+ if (selectedObject instanceof IXWikiPage) {
+ IXWikiPage xwikiPage = (IXWikiPage) selectedObject;
+
+ try {
+ MessageBox messageBox =
+ new MessageBox(HandlerUtil.getActiveShell(event), SWT.YES
| SWT.NO
+ | SWT.ICON_QUESTION);
+ messageBox.setMessage(String.format("Do you really want to
delete '%s'?",
+ xwikiPage.getTitle()));
+ int result = messageBox.open();
+ if (result == SWT.YES) {
+ xwikiPage.remove();
+ }
+ } catch (XWikiConnectionException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }
+
+ return null;
+ }
+}
Added:
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/xeclipse/handlers/RemoveSpaceHandler.java
===================================================================
---
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/xeclipse/handlers/RemoveSpaceHandler.java
(rev 0)
+++
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/xeclipse/handlers/RemoveSpaceHandler.java
2007-11-03 12:48:22 UTC (rev 5621)
@@ -0,0 +1,71 @@
+/*
+ * 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 org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.MessageBox;
+import org.eclipse.ui.handlers.HandlerUtil;
+import org.xwiki.xeclipse.XWikiConnectionManager;
+import org.xwiki.xeclipse.model.IXWikiConnection;
+import org.xwiki.xeclipse.model.IXWikiSpace;
+import org.xwiki.xeclipse.model.XWikiConnectionException;
+import org.xwiki.xeclipse.utils.XWikiEclipseUtil;
+
+public class RemoveSpaceHandler extends AbstractHandler
+{
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException
+ {
+ ISelection selection = HandlerUtil.getCurrentSelection(event);
+
+ Object selectedObject =
+
XWikiEclipseUtil.getSingleSelectedObjectInStructuredSelection(selection);
+
+ if (selectedObject instanceof IXWikiSpace) {
+ IXWikiSpace xwikiSpace = (IXWikiSpace) selectedObject;
+
+ try {
+ MessageBox messageBox =
+ new MessageBox(HandlerUtil.getActiveShell(event), SWT.YES
| SWT.NO
+ | SWT.ICON_QUESTION);
+ messageBox
+ .setMessage(String.format(
+ "Do you really want to delete '%s' and all its
pages?", xwikiSpace
+ .getName()));
+ int result = messageBox.open();
+ if (result == SWT.YES) {
+ xwikiSpace.remove();
+ }
+
+ } catch (XWikiConnectionException 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/model/IXWikiConnection.java
===================================================================
---
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/xeclipse/model/IXWikiConnection.java
2007-11-02 18:58:42 UTC (rev 5620)
+++
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/xeclipse/model/IXWikiConnection.java
2007-11-03 12:48:22 UTC (rev 5621)
@@ -73,11 +73,7 @@
public Collection<IXWikiPage> getPages(IXWikiSpace space)
throws XWikiConnectionException;
- /**
- * @param pageId The id of the page to be retrieved.
- * @return The complete page content for the given id.
- * @throws XWikiConnectionException
- */
+
public IXWikiPage getPage(String pageId) throws XWikiConnectionException;
public String getUserName();
@@ -85,4 +81,6 @@
public void createSpace(String key, String name, String description)
throws XWikiConnectionException;
public IXWikiPage createPage(IXWikiSpace space, String name, String
content) throws XWikiConnectionException;
+ public void removeSpace(IXWikiSpace space) throws XWikiConnectionException;
+ public void removePage(IXWikiPage page) throws XWikiConnectionException;
}
Modified:
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/xeclipse/model/IXWikiPage.java
===================================================================
---
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/xeclipse/model/IXWikiPage.java
2007-11-02 18:58:42 UTC (rev 5620)
+++
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/xeclipse/model/IXWikiPage.java
2007-11-03 12:48:22 UTC (rev 5621)
@@ -30,7 +30,7 @@
public String getId();
public int getLocks();
public String getParentId();
- public String getSpace();
+ public String getSpaceKey();
public String getTitle();
public String getUrl();
public String getCreator();
@@ -70,4 +70,8 @@
* @return The connection where this page has been fetched from.
*/
public IXWikiConnection getConnection();
+
+ public IXWikiSpace getSpace() throws XWikiConnectionException;
+
+ public void remove() throws XWikiConnectionException;
}
Modified:
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/xeclipse/model/IXWikiSpace.java
===================================================================
---
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/xeclipse/model/IXWikiSpace.java
2007-11-02 18:58:42 UTC (rev 5620)
+++
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/xeclipse/model/IXWikiSpace.java
2007-11-03 12:48:22 UTC (rev 5621)
@@ -41,4 +41,5 @@
public Collection<IXWikiPage> getPages() 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/xeclipse/model/impl/AbstractXWikiConnection.java
===================================================================
---
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/xeclipse/model/impl/AbstractXWikiConnection.java
2007-11-02 18:58:42 UTC (rev 5620)
+++
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/xeclipse/model/impl/AbstractXWikiConnection.java
2007-11-03 12:48:22 UTC (rev 5621)
@@ -89,5 +89,5 @@
abstract Page getRawPage(String pageId) throws XWikiConnectionException;
- abstract Space getRawSpace(String key);
+ abstract Space getRawSpace(String key) throws XWikiConnectionException;
}
Modified:
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/xeclipse/model/impl/DiskCacheDAO.java
===================================================================
---
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/xeclipse/model/impl/DiskCacheDAO.java
2007-11-02 18:58:42 UTC (rev 5620)
+++
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/xeclipse/model/impl/DiskCacheDAO.java
2007-11-03 12:48:22 UTC (rev 5621)
@@ -40,6 +40,11 @@
private Map<String, String> pageToDataFileNameIndex;
/**
+ * A mapping that associates a page to the space where it belongs to.
+ */
+ private HashMap<String, String> pageToSpaceIndex;
+
+ /**
* A mapping that associates a space id to the list of the pages id
contained in that space.
*/
private Map<String, Set<String>> spaceToPagesIndex;
@@ -63,6 +68,7 @@
public IndexAggregate()
{
pageToDataFileNameIndex = new HashMap<String, String>();
+ pageToSpaceIndex = new HashMap<String, String>();
spaceToPagesIndex = new HashMap<String, Set<String>>();
spaceToDataFileNameIndex = new HashMap<String, String>();
dirtyPagesIndex = new HashSet<String>();
@@ -94,6 +100,16 @@
return conflictPagesIndex;
}
+ public static long getSerialVersionUID()
+ {
+ return serialVersionUID;
+ }
+
+ public HashMap<String, String> getPageToSpaceIndex()
+ {
+ return pageToSpaceIndex;
+ }
+
}
private static final String INDEXES_FILENAME = "indexes.data";
@@ -172,16 +188,17 @@
List<SpaceSummary> result = new ArrayList<SpaceSummary>();
try {
- for(String spaceKey :
indexAggregate.getSpaceToPagesIndex().keySet()) {
-
if(!indexAggregate.getSpaceToPagesIndex().get(spaceKey).isEmpty()) {
- String dataFileName =
indexAggregate.getSpaceToDataFileNameIndex().get(spaceKey);
+ for (String spaceKey :
indexAggregate.getSpaceToPagesIndex().keySet()) {
+ if
(!indexAggregate.getSpaceToPagesIndex().get(spaceKey).isEmpty()) {
+ String dataFileName =
+
indexAggregate.getSpaceToDataFileNameIndex().get(spaceKey);
ObjectInputStream ois =
new ObjectInputStream(new FileInputStream(new
File(cacheDir, dataFileName)));
Map map = (Map) ois.readObject();
ois.close();
result.add(new SpaceSummary(map));
}
- }
+ }
} catch (Exception e) {
throw new XWikiDAOException(e);
}
@@ -386,4 +403,33 @@
{
throw new XWikiDAOException("Cannot create pages on a local cache");
}
+
+ public void removePage(String id) throws XWikiDAOException
+ {
+ String space = indexAggregate.getPageToSpaceIndex().get(id);
+ indexAggregate.getPageToDataFileNameIndex().remove(id);
+ indexAggregate.getDirtyPagesIndex().remove(id);
+ indexAggregate.getConflictPagesIndex().remove(id);
+ Set<String> pages = indexAggregate.getSpaceToPagesIndex().get(space);
+ if(pages != null) {
+ pages.remove(id);
+ }
+ indexAggregate.getPageToSpaceIndex().remove(id);
+
+ /* TODO: Remove also files from the filesystem */
+ }
+
+ public void removeSpace(String key) throws XWikiDAOException
+ {
+ Set<String> pages = indexAggregate.getSpaceToPagesIndex().get(key);
+ indexAggregate.getSpaceToDataFileNameIndex().remove(key);
+ indexAggregate.getSpaceToPagesIndex().remove(key);
+ if (pages != null) {
+ for (String id : pages) {
+ removePage(id);
+ }
+ }
+
+ /* TODO: Remove space also from fileSystem */
+ }
}
Modified:
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/xeclipse/model/impl/IXWikiDAO.java
===================================================================
---
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/xeclipse/model/impl/IXWikiDAO.java
2007-11-02 18:58:42 UTC (rev 5620)
+++
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/xeclipse/model/impl/IXWikiDAO.java
2007-11-03 12:48:22 UTC (rev 5621)
@@ -16,5 +16,7 @@
public void storePage(Page page) throws XWikiDAOException;
public void close() throws XWikiDAOException;
public Space createSpace(String key, String name, String description)
throws XWikiDAOException;
- public Page createPage(String spaceKey, String title, String content)
throws XWikiDAOException;
+ public Page createPage(String spaceKey, String title, String content)
throws XWikiDAOException;
+ public void removeSpace(String key) throws XWikiDAOException;
+ public void removePage(String id) throws XWikiDAOException;
}
Modified:
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/xeclipse/model/impl/XWikiCachedConnection.java
===================================================================
---
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/xeclipse/model/impl/XWikiCachedConnection.java
2007-11-02 18:58:42 UTC (rev 5620)
+++
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/xeclipse/model/impl/XWikiCachedConnection.java
2007-11-03 12:48:22 UTC (rev 5621)
@@ -163,7 +163,7 @@
cacheDAO.setConflict(pageId, false);
}
}
-
+
return remotePage;
}
@@ -175,9 +175,10 @@
*/
void synchronizeAll() throws XWikiDAOException, XWikiConnectionException
{
- /* This is necessary in order to avoid concurrent modification to the
dirtyPages set when synchronizing.
- * In fact, in synchronize we remove elements from
cacheDAO.getDirtyPages() and we cannot use it
- * directly for iterating.
+ /*
+ * This is necessary in order to avoid concurrent modification to the
dirtyPages set when
+ * synchronizing. In fact, in synchronize we remove elements from
cacheDAO.getDirtyPages()
+ * and we cannot use it directly for iterating.
*/
Set<String> dirtyPages = new HashSet<String>(cacheDAO.getDirtyPages());
for (String pageId : dirtyPages) {
@@ -216,7 +217,8 @@
throw new XWikiConnectionException(e);
}
- XWikiEclipseNotificationCenter.getDefault().fireEvent(this,
XWikiEclipseEvent.CONNECTION_ESTABLISHED, this);
+ XWikiEclipseNotificationCenter.getDefault().fireEvent(this,
+ XWikiEclipseEvent.CONNECTION_ESTABLISHED, this);
}
/**
@@ -239,7 +241,8 @@
e.printStackTrace();
}
- XWikiEclipseNotificationCenter.getDefault().fireEvent(this,
XWikiEclipseEvent.CONNECTION_CLOSED, this);
+ XWikiEclipseNotificationCenter.getDefault().fireEvent(this,
+ XWikiEclipseEvent.CONNECTION_CLOSED, this);
}
/**
@@ -321,7 +324,7 @@
if (pageSummaries != null) {
for (PageSummary pageSummary : pageSummaries) {
- result.add(new XWikiPage(this, pageSummary.getId(),
pageSummary.toMap()));
+ result.add(new XWikiPage(this, pageSummary.getId(), space,
pageSummary.toMap()));
}
}
} catch (Exception e) {
@@ -336,7 +339,8 @@
assertNotDisposed();
Page page = getRawPage(pageId);
- return page != null ? new XWikiPage(this, pageId, page.toMap()) : null;
+ Space space = getRawSpace(page.getSpace());
+ return page != null ? new XWikiPage(this, pageId, new XWikiSpace(this,
space.getKey(), space.toMap()), page.toMap()) : null;
}
/**
@@ -373,14 +377,24 @@
}
}
- /*
- * For the moment we don't retrieve full space information. Since we store
only page summary
- * typically all the information is already provided. However this will be
implemented in the
- * same way as it is implemented for pages.
- */
- Space getRawSpace(String key)
+ Space getRawSpace(String key) throws XWikiConnectionException
{
- return null;
+ assertNotDisposed();
+
+ try {
+ Space space = cacheDAO.getSpace(key);
+ if (space != null) {
+ return space;
+ }
+
+ if (isConnected()) {
+ space = remoteDAO.getSpace(key);
+ }
+
+ return space;
+ } catch (Exception e) {
+ throw new XWikiConnectionException(e);
+ }
}
/**
@@ -469,42 +483,79 @@
@Override
boolean isPageCached(String pageId)
{
- return cacheDAO.isCached(pageId);
+ return cacheDAO.isCached(pageId);
}
- public void createSpace(String key, String name, String description)
throws XWikiConnectionException
+ public void createSpace(String key, String name, String description)
+ throws XWikiConnectionException
{
- if(isConnected()) {
+ if (isConnected()) {
try {
Space space = remoteDAO.createSpace(key, name, description);
- XWikiEclipseNotificationCenter.getDefault().fireEvent(this,
XWikiEclipseEvent.SPACE_CREATED, this);
- } catch (XWikiDAOException e) {
+ XWikiEclipseNotificationCenter.getDefault().fireEvent(this,
+ XWikiEclipseEvent.SPACE_CREATED, this);
+ } catch (XWikiDAOException e) {
e.printStackTrace();
throw new XWikiConnectionException(e);
}
- }
- else {
+ } else {
throw new XWikiConnectionException("Cannot create a space if not
connected");
}
-
+
}
public IXWikiPage createPage(IXWikiSpace space, String name, String
content)
throws XWikiConnectionException
{
- if(isConnected()) {
+ if (isConnected()) {
try {
Page page = remoteDAO.createPage(space.getKey(), name,
content);
- XWikiEclipseNotificationCenter.getDefault().fireEvent(this,
XWikiEclipseEvent.PAGE_CREATED, space);
- return new XWikiPage(this, page.getId(), page.toMap());
- } catch (XWikiDAOException e) {
+ XWikiEclipseNotificationCenter.getDefault().fireEvent(this,
+ XWikiEclipseEvent.PAGE_CREATED, space);
+ return new XWikiPage(this, page.getId(), space, page.toMap());
+ } catch (XWikiDAOException e) {
e.printStackTrace();
throw new XWikiConnectionException(e);
- }
+ }
+ } else {
+ throw new XWikiConnectionException("Cannot create a page if not
connected");
}
- else {
- throw new XWikiConnectionException("Cannot create a page if not
connected");
- }
}
+ public void removePage(IXWikiPage page) throws XWikiConnectionException
+ {
+ try {
+ if (isConnected()) {
+ remoteDAO.removePage(page.getId());
+ }
+
+ cacheDAO.removePage(page.getId());
+
+ XWikiEclipseNotificationCenter.getDefault().fireEvent(this,
+ XWikiEclipseEvent.PAGE_REMOVED, page.getSpace());
+ } catch (XWikiDAOException e) {
+ e.printStackTrace();
+ throw new XWikiConnectionException(e);
+ }
+
+ }
+
+ public void removeSpace(IXWikiSpace space) throws XWikiConnectionException
+ {
+ try {
+ if (isConnected()) {
+ remoteDAO.removeSpace(space.getKey());
+ }
+
+ cacheDAO.removeSpace(space.getKey());
+
+ XWikiEclipseNotificationCenter.getDefault().fireEvent(this,
+ XWikiEclipseEvent.SPACE_REMOVED, this);
+ } catch (XWikiDAOException e) {
+ e.printStackTrace();
+ throw new XWikiConnectionException(e);
+ }
+
+
+ }
}
Modified:
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/xeclipse/model/impl/XWikiPage.java
===================================================================
---
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/xeclipse/model/impl/XWikiPage.java
2007-11-02 18:58:42 UTC (rev 5620)
+++
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/xeclipse/model/impl/XWikiPage.java
2007-11-03 12:48:22 UTC (rev 5621)
@@ -4,8 +4,10 @@
import java.util.Map;
import org.codehaus.swizzle.confluence.Page;
+import org.codehaus.swizzle.confluence.Space;
import org.xwiki.xeclipse.model.IXWikiConnection;
import org.xwiki.xeclipse.model.IXWikiPage;
+import org.xwiki.xeclipse.model.IXWikiSpace;
import org.xwiki.xeclipse.model.XWikiConnectionException;
public class XWikiPage implements IXWikiPage
@@ -15,12 +17,15 @@
private String id;
private Page page;
+
+ private IXWikiSpace space;
- public XWikiPage(AbstractXWikiConnection connection, String id, Map
properties)
+ public XWikiPage(AbstractXWikiConnection connection, String id,
IXWikiSpace space, Map properties)
{
this.connection = connection;
this.id = id;
page = new Page(properties);
+ this.space = space;
}
public String getContent()
@@ -140,7 +145,7 @@
return page.getParentId();
}
- public String getSpace()
+ public String getSpaceKey()
{
String result = page.getSpace();
if (result != null) {
@@ -189,21 +194,22 @@
private void getFullPageInformation()
{
try {
- Page page = connection.getRawPage(id);
- if (page != null) {
- this.page = page;
+ Page page = connection.getRawPage(id);
+ if (page != null) {
+ this.page = page;
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
}
- }
- catch(Exception e) {
- e.printStackTrace();
- }
}
-
- public IXWikiConnection getConnection() {
+
+ public IXWikiConnection getConnection()
+ {
return connection;
}
-
- public boolean isCached() {
+
+ public boolean isCached()
+ {
return connection.isPageCached(page.getId());
}
@@ -233,4 +239,13 @@
return false;
return true;
}
+
+ public IXWikiSpace getSpace() throws XWikiConnectionException
+ {
+ return space;
+ }
+
+ public void remove() throws XWikiConnectionException {
+ connection.removePage(this);
+ }
}
Modified:
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/xeclipse/model/impl/XWikiPlainConnection.java
===================================================================
---
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/xeclipse/model/impl/XWikiPlainConnection.java
2007-11-02 18:58:42 UTC (rev 5620)
+++
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/xeclipse/model/impl/XWikiPlainConnection.java
2007-11-03 12:48:22 UTC (rev 5621)
@@ -20,7 +20,7 @@
private static final long serialVersionUID = -8019449922717442495L;
private transient IXWikiDAO remoteDAO;
-
+
/**
* Constructor.
*
@@ -33,7 +33,7 @@
{
super(serverUrl, username);
}
-
+
/**
* [EMAIL PROTECTED]
*/
@@ -46,7 +46,7 @@
}
try {
- remoteDAO = new XWikiRemoteDAO(getServerUrl(), getUserName(),
password);
+ remoteDAO = new XWikiRemoteDAO(getServerUrl(), getUserName(),
password);
} catch (XWikiDAOException e) {
if (remoteDAO != null) {
try {
@@ -56,12 +56,13 @@
}
}
- remoteDAO = null;
+ remoteDAO = null;
throw new XWikiConnectionException(e);
}
- XWikiEclipseNotificationCenter.getDefault().fireEvent(this,
XWikiEclipseEvent.CONNECTION_ESTABLISHED, this);
+ XWikiEclipseNotificationCenter.getDefault().fireEvent(this,
+ XWikiEclipseEvent.CONNECTION_ESTABLISHED, this);
}
/**
@@ -84,7 +85,8 @@
e.printStackTrace();
}
- XWikiEclipseNotificationCenter.getDefault().fireEvent(this,
XWikiEclipseEvent.CONNECTION_CLOSED, this);
+ XWikiEclipseNotificationCenter.getDefault().fireEvent(this,
+ XWikiEclipseEvent.CONNECTION_CLOSED, this);
}
/**
@@ -95,7 +97,7 @@
public void dispose() throws XWikiConnectionException
{
disconnect();
-
+
isDisposed = true;
}
@@ -112,9 +114,9 @@
if (isConnected()) {
spaceSummaries = remoteDAO.getSpaces();
for (SpaceSummary spaceSummary : spaceSummaries) {
- result.add(new XWikiSpace(this, spaceSummary.getKey(),
spaceSummary.toMap()));
+ result.add(new XWikiSpace(this, spaceSummary.getKey(),
spaceSummary.toMap()));
}
- }
+ }
} catch (Exception e) {
throw new XWikiConnectionException(e);
}
@@ -146,11 +148,11 @@
List<PageSummary> pageSummaries = null;
if (isConnected()) {
pageSummaries = remoteDAO.getPages(space.getKey());
- }
+ }
if (pageSummaries != null) {
for (PageSummary pageSummary : pageSummaries) {
- result.add(new XWikiPage(this, pageSummary.getId(),
pageSummary.toMap()));
+ result.add(new XWikiPage(this, pageSummary.getId(), space,
pageSummary.toMap()));
}
}
} catch (Exception e) {
@@ -165,8 +167,8 @@
assertNotDisposed();
Page page = getRawPage(pageId);
-
- return page != null ? new XWikiPage(this, pageId, page.toMap()) : null;
+ Space space = getRawSpace(page.getSpace());
+ return page != null ? new XWikiPage(this, pageId, new XWikiSpace(this,
space.getKey(), space.toMap()), page.toMap()) : null;
}
/**
@@ -176,14 +178,14 @@
{
assertNotDisposed();
- try {
+ try {
if (isConnected()) {
- return remoteDAO.getPage(pageId);
+ return remoteDAO.getPage(pageId);
}
} catch (Exception e) {
throw new XWikiConnectionException(e);
}
-
+
return null;
}
@@ -236,7 +238,7 @@
return false;
}
-
+
private synchronized void writeObject(java.io.ObjectOutputStream s) throws
IOException
{
s.defaultWriteObject();
@@ -245,9 +247,9 @@
private synchronized void readObject(java.io.ObjectInputStream s) throws
IOException,
ClassNotFoundException
{
- s.defaultReadObject();
+ s.defaultReadObject();
}
-
+
/**
* USED ONLY FOR UNIT TESTING
*
@@ -260,31 +262,73 @@
@Override
boolean isPageCached(String pageId)
- {
+ {
return false;
}
- public void createSpace(String key, String name, String description)
throws XWikiConnectionException
+ public void createSpace(String key, String name, String description)
+ throws XWikiConnectionException
{
try {
Space space = remoteDAO.createSpace(key, name, description);
- XWikiEclipseNotificationCenter.getDefault().fireEvent(this,
XWikiEclipseEvent.SPACE_CREATED, this);
- } catch (XWikiDAOException e) {
+ XWikiEclipseNotificationCenter.getDefault().fireEvent(this,
+ XWikiEclipseEvent.SPACE_CREATED, this);
+ } catch (XWikiDAOException e) {
e.printStackTrace();
throw new XWikiConnectionException(e);
- }
+ }
}
public IXWikiPage createPage(IXWikiSpace space, String name, String
content)
throws XWikiConnectionException
{
try {
- Page page = remoteDAO.createPage(space.getKey(), name, content);
- XWikiEclipseNotificationCenter.getDefault().fireEvent(this,
XWikiEclipseEvent.PAGE_CREATED, space);
- return new XWikiPage(this, page.getId(), page.toMap());
- } catch (XWikiDAOException e) {
+ Page page = remoteDAO.createPage(space.getKey(), name, content);
+ XWikiEclipseNotificationCenter.getDefault().fireEvent(this,
+ XWikiEclipseEvent.PAGE_CREATED, space);
+ return new XWikiPage(this, page.getId(), space, page.toMap());
+ } catch (XWikiDAOException e) {
e.printStackTrace();
throw new XWikiConnectionException(e);
- }
+ }
}
+
+ public IXWikiSpace getSpace(String spaceKey) throws
XWikiConnectionException
+ {
+ Space space = null;
+
+ try {
+ space = remoteDAO.getSpace(spaceKey);
+ } catch (XWikiDAOException e) {
+ e.printStackTrace();
+ throw new XWikiConnectionException(e);
+ }
+
+ return space != null ? new XWikiSpace(this, spaceKey, space.toMap()) :
null;
+ }
+
+ public void removePage(IXWikiPage page) throws XWikiConnectionException
+ {
+ try {
+ remoteDAO.removePage(page.getId());
+ XWikiEclipseNotificationCenter.getDefault().fireEvent(this,
+ XWikiEclipseEvent.PAGE_REMOVED, page.getSpace());
+ } catch (XWikiDAOException e) {
+ e.printStackTrace();
+ throw new XWikiConnectionException(e);
+ }
+
+ }
+
+ public void removeSpace(IXWikiSpace space) throws XWikiConnectionException
+ {
+ try {
+ remoteDAO.removePage(space.getKey());
+ XWikiEclipseNotificationCenter.getDefault().fireEvent(this,
+ XWikiEclipseEvent.SPACE_REMOVED, this);
+ } catch (XWikiDAOException e) {
+ e.printStackTrace();
+ throw new XWikiConnectionException(e);
+ }
+ }
}
Modified:
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/xeclipse/model/impl/XWikiRemoteDAO.java
===================================================================
---
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/xeclipse/model/impl/XWikiRemoteDAO.java
2007-11-02 18:58:42 UTC (rev 5620)
+++
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/xeclipse/model/impl/XWikiRemoteDAO.java
2007-11-03 12:48:22 UTC (rev 5621)
@@ -166,5 +166,26 @@
return page;
}
+
+ public void removePage(String id) throws XWikiDAOException
+ {
+ try {
+ swizzleXWiki.removePage(id);
+ } catch (SwizzleConfluenceException e) {
+ e.printStackTrace();
+ throw new XWikiDAOException(e);
+ }
+
+ }
+
+ public void removeSpace(String key) throws XWikiDAOException
+ {
+ try {
+ swizzleXWiki.removeSpace(key);
+ } catch (SwizzleConfluenceException e) {
+ e.printStackTrace();
+ throw new XWikiDAOException(e);
+ }
+ }
}
Modified:
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/xeclipse/model/impl/XWikiSpace.java
===================================================================
---
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/xeclipse/model/impl/XWikiSpace.java
2007-11-02 18:58:42 UTC (rev 5620)
+++
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/xeclipse/model/impl/XWikiSpace.java
2007-11-03 12:48:22 UTC (rev 5621)
@@ -37,48 +37,48 @@
public String getDescription()
{
String result = space.getDescription();
- if(result != null) {
+ if (result != null) {
return result;
}
-
+
getFullSpaceInformation();
-
+
return space.getDescription();
}
public String getHomePage()
{
String result = space.getHomepage();
- if(result != null) {
+ if (result != null) {
return result;
}
-
+
getFullSpaceInformation();
-
+
return space.getHomepage();
}
public String getKey()
{
String result = space.getKey();
- if(result != null) {
+ if (result != null) {
return result;
}
-
+
getFullSpaceInformation();
-
+
return space.getKey();
}
public String getName()
{
String result = space.getName();
- if(result != null) {
+ if (result != null) {
return result;
}
-
+
getFullSpaceInformation();
-
+
return space.getName();
}
@@ -90,39 +90,43 @@
public String getType()
{
String result = space.getType();
- if(result != null) {
+ if (result != null) {
return result;
}
-
+
getFullSpaceInformation();
-
+
return space.getType();
}
public String getUrl()
{
String result = space.getUrl();
- if(result != null) {
+ if (result != null) {
return result;
}
-
+
getFullSpaceInformation();
-
+
return space.getUrl();
}
-
+
private void getFullSpaceInformation()
{
- Space space = connection.getRawSpace(key);
- if(space != null) {
- this.space = space;
+ try {
+ Space space = connection.getRawSpace(key);
+ if (space != null) {
+ this.space = space;
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
}
-
+
}
public IXWikiPage createPage(String name, String content) throws
XWikiConnectionException
{
- return connection.createPage(this, name, content);
+ return connection.createPage(this, name, content);
}
public IXWikiConnection getConnection()
@@ -156,6 +160,11 @@
return false;
return true;
}
-
-
+
+ public void remove() throws XWikiConnectionException
+ {
+ connection.removeSpace(this);
+
+ }
+
}
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-02 18:58:42 UTC (rev 5620)
+++
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/xeclipse/views/XWikiExplorerView.java
2007-11-03 12:48:22 UTC (rev 5621)
@@ -56,6 +56,8 @@
import org.xwiki.xeclipse.handlers.NewPageHandler;
import org.xwiki.xeclipse.handlers.NewSpaceHandler;
import org.xwiki.xeclipse.handlers.RemoveConnectionHandler;
+import org.xwiki.xeclipse.handlers.RemovePageHandler;
+import org.xwiki.xeclipse.handlers.RemoveSpaceHandler;
import org.xwiki.xeclipse.model.IXWikiConnection;
import org.xwiki.xeclipse.model.IXWikiPage;
import org.xwiki.xeclipse.model.IXWikiSpace;
@@ -163,7 +165,7 @@
null,
null,
SWT.NONE));
-
+
menuManager.add(new CommandContributionItem(getSite(),
null,
XWikiEclipseConstants.NEW_PAGE_COMMAND,
@@ -180,6 +182,32 @@
menuManager.add(new CommandContributionItem(getSite(),
null,
+ XWikiEclipseConstants.REMOVE_SPACE_COMMAND,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ SWT.NONE));
+
+ menuManager.add(new CommandContributionItem(getSite(),
+ null,
+ XWikiEclipseConstants.REMOVE_PAGE_COMMAND,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ SWT.NONE));
+
+ menuManager.add(new Separator());
+
+ menuManager.add(new CommandContributionItem(getSite(),
+ null,
XWikiEclipseConstants.NEW_CONNECTION_COMMAND,
null,
null,
@@ -218,6 +246,10 @@
this);
XWikiEclipseNotificationCenter.getDefault().addListener(XWikiEclipseEvent.PAGE_CREATED,
this);
+
XWikiEclipseNotificationCenter.getDefault().addListener(XWikiEclipseEvent.SPACE_REMOVED,
+ this);
+
XWikiEclipseNotificationCenter.getDefault().addListener(XWikiEclipseEvent.PAGE_REMOVED,
+ this);
XWikiEclipseNotificationCenter.getDefault().addListener(XWikiEclipseEvent.PAGE_UPDATED,
this);
}
@@ -238,6 +270,10 @@
XWikiEclipseNotificationCenter.getDefault().removeListener(
XWikiEclipseEvent.PAGE_CREATED, this);
XWikiEclipseNotificationCenter.getDefault().removeListener(
+ XWikiEclipseEvent.SPACE_REMOVED, this);
+ XWikiEclipseNotificationCenter.getDefault().removeListener(
+ XWikiEclipseEvent.PAGE_REMOVED, this);
+ XWikiEclipseNotificationCenter.getDefault().removeListener(
XWikiEclipseEvent.PAGE_UPDATED, this);
super.dispose();
@@ -356,7 +392,7 @@
return EvaluationResult.FALSE;
}
});
-
+
handlerService.activateHandler(XWikiEclipseConstants.NEW_PAGE_COMMAND,
new NewPageHandler(), new Expression()
{
@@ -383,11 +419,69 @@
return EvaluationResult.FALSE;
}
});
+
+
handlerService.activateHandler(XWikiEclipseConstants.REMOVE_SPACE_COMMAND,
+ new RemoveSpaceHandler(), 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 xwikiPage = (IXWikiSpace) selectedObject;
+ return xwikiPage.getConnection().isConnected() ?
EvaluationResult.TRUE
+ : EvaluationResult.FALSE;
+ }
+
+ return EvaluationResult.FALSE;
+ }
+ });
+
+
handlerService.activateHandler(XWikiEclipseConstants.REMOVE_PAGE_COMMAND,
+ new RemovePageHandler(), 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 IXWikiPage) {
+ IXWikiPage xwikiPage = (IXWikiPage) selectedObject;
+ return xwikiPage.getConnection().isConnected() ?
EvaluationResult.TRUE
+ : EvaluationResult.FALSE;
+ }
+
+ return EvaluationResult.FALSE;
+ }
+ });
+
}
public void handleEvent(final Object sender, final XWikiEclipseEvent
event, final Object data)
{
- /* Things that updates the UI must be run asynchronously otherwise
they can conflict with other UI updates */
+ /*
+ * Things that updates the UI must be run asynchronously otherwise
they can conflict with
+ * other UI updates
+ */
Display.getDefault().asyncExec(new Runnable()
{
public void run()
@@ -399,17 +493,18 @@
break;
case CONNECTION_ESTABLISHED:
case CONNECTION_CLOSED:
- case SPACE_CREATED:
+ case SPACE_CREATED:
+ case SPACE_REMOVED:
if
(XWikiConnectionManager.getDefault().getConnections().contains(data)) {
treeViewer.refresh(data);
}
break;
- case PAGE_CREATED:
+ case PAGE_CREATED:
+ case PAGE_REMOVED:
+ case PAGE_UPDATED:
treeViewer.refresh(data);
break;
- case PAGE_UPDATED:
- treeViewer.refresh(data);
- break;
+
}
}
_______________________________________________
notifications mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/notifications