1 package org
.argeo
.slc
.client
.ui
.commands
;
3 import java
.util
.Iterator
;
7 import org
.apache
.commons
.logging
.Log
;
8 import org
.apache
.commons
.logging
.LogFactory
;
9 import org
.argeo
.eclipse
.ui
.Error
;
10 import org
.argeo
.slc
.BasicNameVersion
;
11 import org
.argeo
.slc
.NameVersion
;
12 import org
.argeo
.slc
.deploy
.ModulesManager
;
13 import org
.argeo
.slc
.jcr
.SlcNames
;
14 import org
.argeo
.slc
.jcr
.SlcTypes
;
15 import org
.eclipse
.core
.commands
.AbstractHandler
;
16 import org
.eclipse
.core
.commands
.ExecutionEvent
;
17 import org
.eclipse
.core
.commands
.ExecutionException
;
18 import org
.eclipse
.jface
.viewers
.ISelection
;
19 import org
.eclipse
.jface
.viewers
.IStructuredSelection
;
20 import org
.eclipse
.ui
.handlers
.HandlerUtil
;
22 /** Deletes one or many results */
23 public class UpdateModule
extends AbstractHandler
{
24 private final static Log log
= LogFactory
.getLog(UpdateModule
.class);
26 private ModulesManager modulesManager
;
28 public Object
execute(ExecutionEvent event
) throws ExecutionException
{
29 ISelection selection
= HandlerUtil
.getActiveWorkbenchWindow(event
)
30 .getActivePage().getSelection();
31 if (selection
!= null && selection
instanceof IStructuredSelection
) {
32 Iterator
<?
> it
= ((IStructuredSelection
) selection
).iterator();
35 while (it
.hasNext()) {
37 if (obj
instanceof Node
) {
38 Node node
= (Node
) obj
;
39 if (node
.isNodeType(SlcTypes
.SLC_EXECUTION_MODULE
)) {
40 NameVersion nameVersion
= new BasicNameVersion(
41 node
.getProperty(SlcNames
.SLC_NAME
)
42 .getString(), node
.getProperty(
43 SlcNames
.SLC_VERSION
).getString());
44 modulesManager
.upgrade(nameVersion
);
45 log
.info("Module " + nameVersion
+ " updated");
49 } catch (Exception e
) {
50 Error
.show("Cannot update " + obj
, e
);
56 public void setModulesManager(ModulesManager modulesManager
) {
57 this.modulesManager
= modulesManager
;