]>
git.argeo.org Git - gpl/argeo-slc.git/blob - eclipse/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/commands/CreateWorkspace.java
1 package org
.argeo
.slc
.client
.ui
.dist
.commands
;
3 import javax
.jcr
.Repository
;
4 import javax
.jcr
.RepositoryException
;
5 import javax
.jcr
.Session
;
7 import org
.apache
.commons
.logging
.Log
;
8 import org
.apache
.commons
.logging
.LogFactory
;
9 import org
.argeo
.ArgeoException
;
10 import org
.argeo
.slc
.client
.ui
.dist
.DistPlugin
;
11 import org
.argeo
.slc
.client
.ui
.dist
.utils
.CommandHelpers
;
12 import org
.eclipse
.core
.commands
.AbstractHandler
;
13 import org
.eclipse
.core
.commands
.ExecutionEvent
;
14 import org
.eclipse
.core
.commands
.ExecutionException
;
15 import org
.eclipse
.jface
.dialogs
.InputDialog
;
16 import org
.eclipse
.ui
.IWorkbenchWindow
;
19 * Create a new empty workspace in the current repository.
22 public class CreateWorkspace
extends AbstractHandler
{
23 private static final Log log
= LogFactory
.getLog(CreateWorkspace
.class);
24 public final static String ID
= DistPlugin
.ID
+ ".createWorkspace";
25 public final static String DEFAULT_LABEL
= "Create new workspace";
26 public final static String DEFAULT_ICON_PATH
= "icons/addItem.gif";
28 /* DEPENDENCY INJECTION */
29 private Repository repository
;
31 public Object
execute(ExecutionEvent event
) throws ExecutionException
{
32 IWorkbenchWindow iww
= DistPlugin
.getDefault().getWorkbench()
33 .getActiveWorkbenchWindow();
34 // TODO : add an input validator
35 InputDialog inputDialog
= new InputDialog(iww
.getShell(),
36 "New workspace", "Choose a name for the workspace to create",
39 String workspaceName
= inputDialog
.getValue();
40 Session session
= null;
42 session
= repository
.login();
43 session
.getWorkspace().createWorkspace(workspaceName
);
44 CommandHelpers
.callCommand(RefreshDistributionsView
.ID
);
45 } catch (RepositoryException re
) {
46 throw new ArgeoException(
47 "Unexpected error while creating the new workspace.", re
);
52 if (log
.isTraceEnabled())
53 log
.debug("WORKSPACE " + workspaceName
+ " CREATED");
57 /* DEPENDENCY INJECTION */
58 public void setRepository(Repository repository
) {
59 this.repository
= repository
;