1 package org
.argeo
.slc
.client
.ui
.dist
.commands
;
3 import java
.util
.Iterator
;
6 import javax
.jcr
.RepositoryException
;
8 import org
.argeo
.slc
.SlcException
;
9 import org
.argeo
.slc
.SlcTypes
;
10 import org
.argeo
.slc
.client
.ui
.dist
.DistPlugin
;
11 import org
.eclipse
.core
.commands
.AbstractHandler
;
12 import org
.eclipse
.core
.commands
.ExecutionEvent
;
13 import org
.eclipse
.core
.commands
.ExecutionException
;
14 import org
.eclipse
.jface
.dialogs
.MessageDialog
;
15 import org
.eclipse
.jface
.resource
.ImageDescriptor
;
16 import org
.eclipse
.jface
.viewers
.ISelection
;
17 import org
.eclipse
.jface
.viewers
.IStructuredSelection
;
18 import org
.eclipse
.ui
.IEditorPart
;
19 import org
.eclipse
.ui
.IWorkbenchPart
;
20 import org
.eclipse
.ui
.handlers
.HandlerUtil
;
22 /** Delete chosen artifacts from the current workspace */
23 public class DeleteArtifacts
extends AbstractHandler
{
24 // private static final CmsLog log = CmsLog.getLog(DeleteWorkspace.class);
26 public final static String ID
= DistPlugin
.PLUGIN_ID
+ ".deleteArtifacts";
27 public final static String DEFAULT_LABEL
= "Delete selected items";
28 public final static ImageDescriptor DEFAULT_ICON
= DistPlugin
29 .getImageDescriptor("icons/removeItem.gif");
31 public Object
execute(ExecutionEvent event
) throws ExecutionException
{
33 IWorkbenchPart activePart
= HandlerUtil
.getActivePart(event
);
35 if (activePart
instanceof IEditorPart
) {
36 ISelection selector
= ((IEditorPart
) activePart
)
37 .getEditorSite().getSelectionProvider().getSelection();
39 && selector
instanceof IStructuredSelection
) {
40 Iterator
<?
> it
= ((IStructuredSelection
) selector
)
43 String msg
= "Your are about to definitively remove the "
44 + ((IStructuredSelection
) selector
).size()
45 + " selected artifacts.\n"
46 + "Are you sure you want to proceed?";
48 boolean result
= MessageDialog
.openConfirm(DistPlugin
49 .getDefault().getWorkbench().getDisplay()
50 .getActiveShell(), "Confirm Deletion", msg
);
53 while (it
.hasNext()) {
54 Node node
= (Node
) it
.next();
55 if (node
.isNodeType(SlcTypes
.SLC_ARTIFACT
)) {
56 // we remove the artifactVersion, that is the
58 node
.getParent().remove();
59 node
.getSession().save();
65 // CommandHelpers.callCommand(RefreshDistributionOverviewPage.ID);
66 } catch (RepositoryException re
) {
67 throw new SlcException(
68 "Unexpected error while deleting artifacts.", re
);