X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=plugins%2Forg.argeo.slc.client.ui.dist%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fslc%2Fclient%2Fui%2Fdist%2Fcommands%2FRegisterRepository.java;h=c044c59d848126eb1b3879c313bc16078d15bef1;hb=706b98df2c68382d7bd501fa05cb128f329087ee;hp=805257a121662ca2508fe4a8540f7bdc07494ec6;hpb=e2ad359a9b5d3822dcc2ad0576070fc46e2847d8;p=gpl%2Fargeo-slc.git diff --git a/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/commands/RegisterRepository.java b/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/commands/RegisterRepository.java index 805257a12..c044c59d8 100644 --- a/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/commands/RegisterRepository.java +++ b/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/commands/RegisterRepository.java @@ -28,18 +28,20 @@ import org.eclipse.core.commands.AbstractHandler; import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionException; import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.wizard.WizardDialog; import org.eclipse.ui.handlers.HandlerUtil; /** - * Connect to a remote repository. + * Register a remote repository by creating a node in the current */ public class RegisterRepository extends AbstractHandler implements ArgeoNames, SlcNames { public final static String ID = DistPlugin.ID + ".registerRepository"; - public final static String DEFAULT_LABEL = "Register a repository"; - public final static String DEFAULT_ICON_PATH = "icons/addRepo.gif"; + public final static String DEFAULT_LABEL = "Register a repository..."; + public final static ImageDescriptor DEFAULT_ICON = DistPlugin + .getImageDescriptor("icons/addRepo.gif"); /* DEPENDENCY INJECTION */ private RepositoryFactory repositoryFactory; @@ -54,11 +56,6 @@ public class RegisterRepository extends AbstractHandler implements ArgeoNames, int result = dialog.open(); if (result == Dialog.OK) CommandHelpers.callCommand(RefreshDistributionsView.ID); - - // RemoteRepositoryLoginDialog dlg = new RemoteRepositoryLoginDialog( - // Display.getDefault().getActiveShell()); - // if (dlg.open() == Dialog.OK) { - // } return null; } @@ -73,154 +70,4 @@ public class RegisterRepository extends AbstractHandler implements ArgeoNames, public void setNodeRepository(Repository nodeRepository) { this.nodeRepository = nodeRepository; } - - // class RemoteRepositoryLoginDialog extends TitleAreaDialog { - // private Text name; - // private Text uri; - // private Text username; - // private Text password; - // private Button saveInKeyring; - // - // public RemoteRepositoryLoginDialog(Shell parentShell) { - // super(parentShell); - // } - // - // protected Point getInitialSize() { - // return new Point(600, 400); - // } - // - // protected Control createDialogArea(Composite parent) { - // Composite dialogarea = (Composite) super.createDialogArea(parent); - // dialogarea.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, - // true)); - // Composite composite = new Composite(dialogarea, SWT.NONE); - // composite.setLayout(new GridLayout(2, false)); - // composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, - // false)); - // setMessage("Login to remote repository", IMessageProvider.NONE); - // name = createLT(composite, "Name", "Example Java Repository"); - // uri = createLT(composite, "URI", - // "https://example.com/data/jcr/java"); - // username = createLT(composite, "User", ""); - // password = createLP(composite, "Password"); - // - // saveInKeyring = createLC(composite, "Remember password", false); - // parent.pack(); - // return composite; - // } - // - // @Override - // protected void createButtonsForButtonBar(Composite parent) { - // super.createButtonsForButtonBar(parent); - // Button test = createButton(parent, 2, "Test", false); - // test.addSelectionListener(new SelectionAdapter() { - // public void widgetSelected(SelectionEvent arg0) { - // testConnection(); - // } - // }); - // } - // - // void testConnection() { - // Session session = null; - // try { - // if (uri.getText().startsWith("http")) {// http, https - // URI checkedUri = new URI(uri.getText()); - // String checkedUriStr = checkedUri.toString(); - // Hashtable params = new Hashtable(); - // params.put(ArgeoJcrConstants.JCR_REPOSITORY_URI, - // checkedUriStr); - // Repository repository = ArgeoJcrUtils.getRepositoryByUri( - // repositoryFactory, checkedUriStr); - // if (username.getText().trim().equals("")) {// anonymous - // session = repository.login(); - // } else { - // // FIXME use getTextChars() when upgrading to 3.7 - // // see - // // https://bugs.eclipse.org/bugs/show_bug.cgi?id=297412 - // char[] pwd = password.getText().toCharArray(); - // SimpleCredentials sc = new SimpleCredentials( - // username.getText(), pwd); - // session = repository.login(sc); - // } - // } else {// alias - // Repository repository = ArgeoJcrUtils.getRepositoryByAlias( - // repositoryFactory, uri.getText()); - // session = repository.login(); - // } - // MessageDialog.openInformation(getParentShell(), "Success", - // "Connection to '" + uri.getText() + "' successful"); - // } catch (Exception e) { - // ErrorFeedback.show( - // "Connection test failed for " + uri.getText(), e); - // } finally { - // JcrUtils.logoutQuietly(session); - // } - // } - // - // @Override - // protected void okPressed() { - // Session nodeSession = null; - // try { - // nodeSession = nodeRepository.login(); - // String reposPath = UserJcrUtils.getUserHome(nodeSession) - // .getPath() + RepoConstants.REPOSITORIES_BASE_PATH; - // - // Node repos = nodeSession.getNode(reposPath); - // String repoNodeName = JcrUtils.replaceInvalidChars(name - // .getText()); - // if (repos.hasNode(repoNodeName)) - // throw new ArgeoException( - // "There is already a remote repository named " - // + repoNodeName); - // Node repoNode = repos.addNode(repoNodeName, - // ArgeoTypes.ARGEO_REMOTE_REPOSITORY); - // repoNode.setProperty(ARGEO_URI, uri.getText()); - // repoNode.setProperty(ARGEO_USER_ID, username.getText()); - // repoNode.addMixin(NodeType.MIX_TITLE); - // repoNode.setProperty(Property.JCR_TITLE, name.getText()); - // nodeSession.save(); - // if (saveInKeyring.getSelection()) { - // String pwdPath = repoNode.getPath() + '/' + ARGEO_PASSWORD; - // keyring.set(pwdPath, password.getText().toCharArray()); - // nodeSession.save(); - // } - // MessageDialog.openInformation(getParentShell(), - // "Repository Added", - // "Remote repository " + uri.getText() + "' added"); - // - // super.okPressed(); - // } catch (Exception e) { - // ErrorFeedback.show("Cannot add remote repository", e); - // } finally { - // JcrUtils.logoutQuietly(nodeSession); - // } - // } - // - // /** Creates label and text. */ - // protected Text createLT(Composite parent, String label, String initial) { - // new Label(parent, SWT.NONE).setText(label); - // Text text = new Text(parent, SWT.SINGLE | SWT.LEAD | SWT.BORDER); - // text.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - // text.setText(initial); - // return text; - // } - // - // /** Creates label and check. */ - // protected Button createLC(Composite parent, String label, - // Boolean initial) { - // new Label(parent, SWT.NONE).setText(label); - // Button check = new Button(parent, SWT.CHECK); - // check.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - // check.setSelection(initial); - // return check; - // } - // - // protected Text createLP(Composite parent, String label) { - // new Label(parent, SWT.NONE).setText(label); - // Text text = new Text(parent, SWT.SINGLE | SWT.LEAD | SWT.BORDER - // | SWT.PASSWORD); - // text.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - // return text; - // } - // } }