]> git.argeo.org Git - gpl/argeo-slc.git/blob - org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/RegisterRepository.java
Adapt to Commons 2.x and some subtle comments cleaning.
[gpl/argeo-slc.git] / org.argeo.slc.client.ui.dist / src / org / argeo / slc / client / ui / dist / commands / RegisterRepository.java
1 /*
2 * Copyright (C) 2007-2012 Argeo GmbH
3 *
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
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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.
15 */
16 package org.argeo.slc.client.ui.dist.commands;
17
18 import javax.jcr.Repository;
19 import javax.jcr.RepositoryFactory;
20
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;
34
35 /** Register a remote repository by creating a node in the current local node. */
36 public class RegisterRepository extends AbstractHandler implements ArgeoNames,
37 SlcNames {
38
39 public final static String ID = DistPlugin.PLUGIN_ID
40 + ".registerRepository";
41 public final static String DEFAULT_LABEL = "Register a repository...";
42 public final static ImageDescriptor DEFAULT_ICON = DistPlugin
43 .getImageDescriptor("icons/addRepo.gif");
44
45 /* DEPENDENCY INJECTION */
46 private RepositoryFactory repositoryFactory;
47 private Repository nodeRepository;
48 private Keyring keyring;
49
50 public Object execute(ExecutionEvent event) throws ExecutionException {
51 RegisterRepoWizard wizard = new RegisterRepoWizard(keyring,
52 repositoryFactory, nodeRepository);
53 WizardDialog dialog = new WizardDialog(
54 HandlerUtil.getActiveShell(event), wizard);
55 int result = dialog.open();
56 if (result == Dialog.OK)
57 CommandHelpers.callCommand(RefreshDistributionsView.ID);
58 return null;
59 }
60
61 public void setRepositoryFactory(RepositoryFactory repositoryFactory) {
62 this.repositoryFactory = repositoryFactory;
63 }
64
65 public void setKeyring(Keyring keyring) {
66 this.keyring = keyring;
67 }
68
69 public void setNodeRepository(Repository nodeRepository) {
70 this.nodeRepository = nodeRepository;
71 }
72 }