2 * Copyright (C) 2007-2012 Argeo GmbH
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org
.argeo
.slc
.client
.ui
.dist
.commands
;
18 import javax
.jcr
.Repository
;
19 import javax
.jcr
.RepositoryFactory
;
21 import org
.argeo
.jcr
.ArgeoNames
;
22 import org
.argeo
.slc
.client
.ui
.dist
.DistPlugin
;
23 import org
.argeo
.slc
.client
.ui
.dist
.utils
.CommandHelpers
;
24 import org
.argeo
.slc
.client
.ui
.dist
.wizards
.RegisterRepoWizard
;
25 import org
.argeo
.slc
.jcr
.SlcNames
;
26 import org
.argeo
.util
.security
.Keyring
;
27 import org
.eclipse
.core
.commands
.AbstractHandler
;
28 import org
.eclipse
.core
.commands
.ExecutionEvent
;
29 import org
.eclipse
.core
.commands
.ExecutionException
;
30 import org
.eclipse
.jface
.dialogs
.Dialog
;
31 import org
.eclipse
.jface
.resource
.ImageDescriptor
;
32 import org
.eclipse
.jface
.wizard
.WizardDialog
;
33 import org
.eclipse
.ui
.handlers
.HandlerUtil
;
36 * Register a remote repository by creating a node in the current
38 public class RegisterRepository
extends AbstractHandler
implements ArgeoNames
,
41 public final static String ID
= DistPlugin
.ID
+ ".registerRepository";
42 public final static String DEFAULT_LABEL
= "Register a repository...";
43 public final static ImageDescriptor DEFAULT_ICON
= DistPlugin
44 .getImageDescriptor("icons/addRepo.gif");
46 /* DEPENDENCY INJECTION */
47 private RepositoryFactory repositoryFactory
;
48 private Repository nodeRepository
;
49 private Keyring keyring
;
51 public Object
execute(ExecutionEvent event
) throws ExecutionException
{
52 RegisterRepoWizard wizard
= new RegisterRepoWizard(keyring
,
53 repositoryFactory
, nodeRepository
);
54 WizardDialog dialog
= new WizardDialog(
55 HandlerUtil
.getActiveShell(event
), wizard
);
56 int result
= dialog
.open();
57 if (result
== Dialog
.OK
)
58 CommandHelpers
.callCommand(RefreshDistributionsView
.ID
);
62 public void setRepositoryFactory(RepositoryFactory repositoryFactory
) {
63 this.repositoryFactory
= repositoryFactory
;
66 public void setKeyring(Keyring keyring
) {
67 this.keyring
= keyring
;
70 public void setNodeRepository(Repository nodeRepository
) {
71 this.nodeRepository
= nodeRepository
;