1 package org
.argeo
.slc
.client
.ui
.dist
.commands
;
3 import java
.util
.Iterator
;
6 import javax
.jcr
.RepositoryException
;
8 import org
.argeo
.ArgeoException
;
9 import org
.argeo
.slc
.client
.ui
.dist
.DistPlugin
;
10 import org
.argeo
.slc
.client
.ui
.dist
.utils
.CommandHelpers
;
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
.viewers
.ISelection
;
16 import org
.eclipse
.jface
.viewers
.IStructuredSelection
;
17 import org
.eclipse
.ui
.IEditorPart
;
18 import org
.eclipse
.ui
.IWorkbenchPart
;
21 * Delete chosen artifacts from the current workspace.
24 public class DeleteArtifacts
extends AbstractHandler
{
25 // private static final Log log = LogFactory.getLog(DeleteWorkspace.class);
26 public final static String ID
= DistPlugin
.ID
+ ".deleteArtifacts";
27 public final static String DEFAULT_LABEL
= "Delete selected items";
28 public final static String DEFAULT_ICON_PATH
= "icons/removeItem.gif";
30 public Object
execute(ExecutionEvent event
) throws ExecutionException
{
32 IWorkbenchPart activePart
= DistPlugin
.getDefault().getWorkbench()
33 .getActiveWorkbenchWindow().getActivePage().getActivePart();
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 Delete", msg
);
53 while (it
.hasNext()) {
54 Node node
= (Node
) it
.next();
55 // we remove the artifactVersion, that is the parent
56 node
.getParent().remove();
57 node
.getSession().save();
62 CommandHelpers
.callCommand(RefreshDistributionOverviewPage
.ID
);
63 } catch (RepositoryException re
) {
64 throw new ArgeoException(
65 "Unexpected error while deleting artifacts.", re
);