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%2FDisplayRepoInformation.java;h=f46b121cbe60e5a4c1d2672ea4677029475f8fbc;hb=0d236262a853a1286b317c30d64d4692bc21c7a4;hp=7bc06084feaf6071e64a62fc5376b3490020679d;hpb=3e2293b11242a1960217a278cfb3409508eb5a5d;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/DisplayRepoInformation.java b/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/commands/DisplayRepoInformation.java index 7bc06084f..f46b121cb 100644 --- a/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/commands/DisplayRepoInformation.java +++ b/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/commands/DisplayRepoInformation.java @@ -18,17 +18,16 @@ package org.argeo.slc.client.ui.dist.commands; import javax.jcr.RepositoryException; import javax.jcr.Session; -import org.argeo.jcr.ArgeoNames; import org.argeo.jcr.JcrUtils; import org.argeo.slc.SlcException; import org.argeo.slc.client.ui.dist.DistPlugin; -import org.argeo.slc.client.ui.dist.views.DistributionsView; -import org.argeo.slc.client.ui.dist.views.DistributionsView.DistributionViewSelectedElement; +import org.argeo.slc.client.ui.dist.model.RepoElem; 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.dialogs.IDialogConstants; +import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.layout.GridData; @@ -39,8 +38,7 @@ import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.handlers.HandlerUtil; /** * Create a new empty workspace in the current repository. @@ -52,34 +50,29 @@ public class DisplayRepoInformation extends AbstractHandler { public final static String DEFAULT_ICON_PATH = "icons/help.gif"; public Object execute(ExecutionEvent event) throws ExecutionException { - IWorkbenchWindow iww = DistPlugin.getDefault().getWorkbench() - .getActiveWorkbenchWindow(); - IWorkbenchPart view = iww.getActivePage().getActivePart(); - if (view instanceof DistributionsView) { - DistributionViewSelectedElement dvse = ((DistributionsView) view) - .getSelectedElement(); - if (dvse != null && (dvse.isRepository)) { - InformationDialog inputDialog = new InformationDialog( - iww.getShell()); - inputDialog.create(); - Session session = null; - try { - session = dvse.repository.login(dvse.credentials); - inputDialog.loginTxt.setText(session.getUserID()); - - inputDialog.nameTxt.setText(dvse.repoNode.getName()); - inputDialog.uriTxt.setText(JcrUtils.get(dvse.repoNode, - ArgeoNames.ARGEO_URI)); - inputDialog.readOnlyBtn.setSelection(dvse.isReadOnly); - - } catch (RepositoryException e) { - throw new SlcException("Unexpected error while " - + "getting repository infos.", e); - } finally { - JcrUtils.logoutQuietly(session); - } - inputDialog.open(); + + IStructuredSelection iss = (IStructuredSelection) HandlerUtil + .getActiveSite(event).getSelectionProvider().getSelection(); + + if (iss.getFirstElement() instanceof RepoElem) { + RepoElem re = (RepoElem) iss.getFirstElement(); + InformationDialog inputDialog = new InformationDialog(HandlerUtil + .getActiveSite(event).getShell()); + inputDialog.create(); + Session session = null; + try { + session = re.getRepository().login(re.getCredentials()); + inputDialog.loginTxt.setText(session.getUserID()); + inputDialog.nameTxt.setText(re.getLabel()); + inputDialog.uriTxt.setText(re.getUri()); + inputDialog.readOnlyBtn.setSelection(re.isReadOnly()); + } catch (RepositoryException e) { + throw new SlcException("Unexpected error while " + + "getting repository infos.", e); + } finally { + JcrUtils.logoutQuietly(session); } + inputDialog.open(); } return null; } @@ -93,8 +86,7 @@ public class DisplayRepoInformation extends AbstractHandler { @Override protected void createButtonsForButtonBar(Composite parent) { // No Cancel button - createButton(parent, IDialogConstants.OK_ID, - IDialogConstants.OK_LABEL, true); + createButton(parent, IDialogConstants.OK_ID, "OK", true); } public InformationDialog(Shell parentShell) {