]> git.argeo.org Git - gpl/argeo-slc.git/blob - plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/commands/RegisterRepository.java
fix grouping issue for workspaces that have the same prefix.
[gpl/argeo-slc.git] / plugins / org.argeo.slc.client.ui.dist / src / main / java / 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 /**
36 * Register a remote repository by creating a node in the current
37 */
38 public class RegisterRepository extends AbstractHandler implements ArgeoNames,
39 SlcNames {
40
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");
45
46 /* DEPENDENCY INJECTION */
47 private RepositoryFactory repositoryFactory;
48 private Repository nodeRepository;
49 private Keyring keyring;
50
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);
59 return null;
60 }
61
62 public void setRepositoryFactory(RepositoryFactory repositoryFactory) {
63 this.repositoryFactory = repositoryFactory;
64 }
65
66 public void setKeyring(Keyring keyring) {
67 this.keyring = keyring;
68 }
69
70 public void setNodeRepository(Repository nodeRepository) {
71 this.nodeRepository = nodeRepository;
72 }
73 }