diff options
author | Roland Grunberg | 2016-06-20 19:01:33 +0000 |
---|---|---|
committer | Roland Grunberg | 2016-06-22 15:55:51 +0000 |
commit | c51b627349a9e6741919dd92866bd4c508ef3b33 (patch) | |
tree | bb1bd21b836a59f8436cfda9a5445f6ab9624b62 | |
parent | 54c32230198a8538e2af33d27a0fef21ee8efd66 (diff) | |
download | org.eclipse.linuxtools-c51b627349a9e6741919dd92866bd4c508ef3b33.tar.gz org.eclipse.linuxtools-c51b627349a9e6741919dd92866bd4c508ef3b33.tar.xz org.eclipse.linuxtools-c51b627349a9e6741919dd92866bd4c508ef3b33.zip |
Bug 495693: Improve Registry Account UI.
- Create 'Browse' button to access Registry Accounts preference pages
from Image Pull/Push Wizard pages
- Add toolip text for Server Address, and Username fields
Change-Id: I9e6610675172efa6101df444d0ee19cdbfe0aaf5
Reviewed-on: https://git.eclipse.org/r/75582
Tested-by: Hudson CI
Reviewed-by: Roland Grunberg <rgrunber@redhat.com>
5 files changed, 93 insertions, 24 deletions
diff --git a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/preferences/DockerRegistryAccountPreferencePage.java b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/preferences/DockerRegistryAccountPreferencePage.java index 96528ee5fd..be6d11eb54 100644 --- a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/preferences/DockerRegistryAccountPreferencePage.java +++ b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/preferences/DockerRegistryAccountPreferencePage.java @@ -47,6 +47,8 @@ import org.eclipse.ui.IWorkbenchPreferencePage; public class DockerRegistryAccountPreferencePage extends PreferencePage implements IWorkbenchPreferencePage, Listener { + public static final String ACCOUNT_PREFERENCE_PAGE_ID = "org.eclipse.linuxtools.docker.ui.preferences.DockerRegistryAccountPreferencePage"; //$NON-NLS-1$ + /** * Inner class to keep track of password modifications (without committing * them to the keyring) while the user modifies the preferences. diff --git a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImagePullPage.java b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImagePullPage.java index a31d1e2be0..b14b7ff5f7 100644 --- a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImagePullPage.java +++ b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImagePullPage.java @@ -34,6 +34,7 @@ import org.eclipse.linuxtools.internal.docker.core.RegistryAccountManager; import org.eclipse.linuxtools.internal.docker.core.RegistryInfo; import org.eclipse.linuxtools.internal.docker.ui.SWTImagesFactory; import org.eclipse.linuxtools.internal.docker.ui.commands.CommandUtils; +import org.eclipse.linuxtools.internal.docker.ui.preferences.DockerRegistryAccountPreferencePage; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; @@ -44,6 +45,7 @@ import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.dialogs.PreferencesUtil; /** * @@ -113,16 +115,19 @@ public class ImagePullPage extends WizardPage { GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER) .grab(false, false).applyTo(accountLabel); - Combo accountCombo = new Combo(container, SWT.DROP_DOWN); + final Combo accountCombo = new Combo(container, SWT.DROP_DOWN); accountCombo.setToolTipText(WizardMessages.getString("ImagePullPage.registry.account.desc")); //$NON-NLS-1$ - List<String> items = RegistryAccountManager.getInstance().getAccounts() - .stream() - .map(e -> e.getUsername() + "@" + e.getServerAddress()) //$NON-NLS-1$ - .collect(Collectors.toList()); - items.add(0, DOCKER_DAEMON_DEFAULT); - accountCombo.setItems(items.toArray(new String[0])); + accountCombo.setItems(getAccountComboItems()); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER) - .grab(true, false).span(2, 1).applyTo(accountCombo); + .grab(true, false).applyTo(accountCombo); + + // Browse + final Button browseButton = new Button(container, SWT.NONE); + browseButton.setText( + WizardMessages.getString("ImagePullPushPage.browse.label")); //$NON-NLS-1$ + GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER) + .grab(false, false).applyTo(browseButton); + browseButton.addSelectionListener(onBrowse(accountCombo)); // Image name final Label imageNameLabel = new Label(container, SWT.NONE); @@ -167,6 +172,20 @@ public class ImagePullPage extends WizardPage { setControl(container); } + private SelectionListener onBrowse(Combo combo) { + return new SelectionAdapter() { + @Override + public void widgetSelected(final SelectionEvent e) { + PreferencesUtil.createPreferenceDialogOn(getShell(), + DockerRegistryAccountPreferencePage.ACCOUNT_PREFERENCE_PAGE_ID, + new String[] { DockerRegistryAccountPreferencePage.ACCOUNT_PREFERENCE_PAGE_ID }, + null) + .open(); + combo.setItems(getAccountComboItems()); + } + }; + } + /** * Opens the {@link ImageSearch} dialog with current image name pre-filled. * @@ -201,4 +220,13 @@ public class ImagePullPage extends WizardPage { }; } + private String[] getAccountComboItems() { + List<String> items = RegistryAccountManager.getInstance().getAccounts() + .stream() + .map(e -> e.getUsername() + "@" + e.getServerAddress()) //$NON-NLS-1$ + .collect(Collectors.toList()); + items.add(0, DOCKER_DAEMON_DEFAULT); + return items.toArray(new String[0]); + } + } diff --git a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImagePushPage.java b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImagePushPage.java index 172870ff06..88e1ec4abc 100644 --- a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImagePushPage.java +++ b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImagePushPage.java @@ -23,13 +23,19 @@ import org.eclipse.linuxtools.docker.core.IRegistry; import org.eclipse.linuxtools.internal.docker.core.RegistryAccountManager; import org.eclipse.linuxtools.internal.docker.core.RegistryInfo; import org.eclipse.linuxtools.internal.docker.ui.SWTImagesFactory; +import org.eclipse.linuxtools.internal.docker.ui.preferences.DockerRegistryAccountPreferencePage; import org.eclipse.swt.SWT; import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.dialogs.PreferencesUtil; public class ImagePushPage extends WizardPage { @@ -107,7 +113,7 @@ public class ImagePushPage extends WizardPage { public void createControl(final Composite parent) { parent.setLayout(new GridLayout()); final Composite container = new Composite(parent, SWT.NONE); - GridLayoutFactory.fillDefaults().numColumns(2).margins(6, 6) + GridLayoutFactory.fillDefaults().numColumns(3).margins(6, 6) .applyTo(container); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).span(1, 1) .grab(true, false).applyTo(container); @@ -120,7 +126,7 @@ public class ImagePushPage extends WizardPage { nameText.addModifyListener(Listener); nameText.setToolTipText(WizardMessages.getString(NAME_TOOLTIP)); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER) - .grab(true, false).applyTo(nameText); + .grab(true, false).span(2, 1).applyTo(nameText); } else { nameCombo = new Combo(container, SWT.DROP_DOWN | SWT.READ_ONLY); nameCombo.addModifyListener(Listener); @@ -128,7 +134,7 @@ public class ImagePushPage extends WizardPage { nameCombo.setItems(image.repoTags().toArray(new String[0])); nameCombo.setText(image.repoTags().get(0)); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER) - .grab(true, false).applyTo(nameCombo); + .grab(true, false).span(2, 1).applyTo(nameCombo); } final Label accountLabel = new Label(container, SWT.NULL); @@ -139,19 +145,44 @@ public class ImagePushPage extends WizardPage { accountCombo = new Combo(container, SWT.DROP_DOWN); accountCombo.addModifyListener(Listener); accountCombo.setToolTipText(WizardMessages.getString("ImagePushPage.registry.account.desc")); //$NON-NLS-1$ - List<String> items = RegistryAccountManager.getInstance() - .getAccounts() - .stream() - .map(e -> e.getUsername() + "@" + e.getServerAddress()) //$NON-NLS-1$ - .collect(Collectors.toList()); - accountCombo.setItems(items.toArray(new String[0])); - if (items.size() > 0) { - accountCombo.setText(items.get(0)); + accountCombo.setItems(getAccountComboItems()); + if (accountCombo.getItems().length > 0) { + accountCombo.select(0); } + + // Browse + final Button browseButton = new Button(container, SWT.NONE); + browseButton.setText(WizardMessages + .getString("ImagePullPushPage.browse.label")); //$NON-NLS-1$ + GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER) + .grab(false, false).applyTo(browseButton); + browseButton.addSelectionListener(onBrowse(accountCombo)); + GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER) .grab(true, false).applyTo(accountCombo); setControl(container); validate(); } + private SelectionListener onBrowse(Combo combo) { + return new SelectionAdapter() { + @Override + public void widgetSelected(final SelectionEvent e) { + PreferencesUtil.createPreferenceDialogOn(getShell(), + DockerRegistryAccountPreferencePage.ACCOUNT_PREFERENCE_PAGE_ID, + new String[] { DockerRegistryAccountPreferencePage.ACCOUNT_PREFERENCE_PAGE_ID }, + null) + .open(); + combo.setItems(getAccountComboItems()); + } + }; + } + + private String[] getAccountComboItems() { + List<String> items = RegistryAccountManager.getInstance().getAccounts() + .stream().map(e -> e.getUsername() + "@" + e.getServerAddress()) //$NON-NLS-1$ + .collect(Collectors.toList()); + return items.toArray(new String[0]); + } + } diff --git a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/RegistryAccountDialog.java b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/RegistryAccountDialog.java index 595908a9d7..a40c38e5cc 100644 --- a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/RegistryAccountDialog.java +++ b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/RegistryAccountDialog.java @@ -53,6 +53,8 @@ public class RegistryAccountDialog extends Dialog { GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER) .grab(false, false).applyTo(serverLabel); final Text serverText = new Text(container, SWT.BORDER); + serverText.setToolTipText( + WizardMessages.getString("RegistryAccountDialog.server.desc")); //$NON-NLS-1$ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER) .grab(true, false).applyTo(serverText); if (serverAddress != null) { @@ -69,6 +71,8 @@ public class RegistryAccountDialog extends Dialog { GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER) .grab(false, false).applyTo(usernameLabel); final Text usernameText = new Text(container, SWT.BORDER); + usernameText.setToolTipText(WizardMessages + .getString("RegistryAccountDialog.username.desc")); //$NON-NLS-1$ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER) .grab(true, false).applyTo(usernameText); if (username != null) { diff --git a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/WizardMessages.properties b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/WizardMessages.properties index 172cae55e7..f9db29a4fa 100644 --- a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/WizardMessages.properties +++ b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/WizardMessages.properties @@ -89,8 +89,8 @@ ImagePull.name.tooltip=Enter either a REPOSITORY to load all its images or REPOS ImagePull.search.label=Search... ImagePull.name.invalidformat.msg=Image name is invalid.\nExpected [REGISTRY_HOST[:REGISTRY_PORT]/]NAME[:TAG] ImagePull.assumeLatest.msg=Assuming image tag is 'latest' since none was specified -ImagePullPage.registry.account.desc=Select a specific registry/account to use -ImagePullPage.registry.account.label=Registry/Account: +ImagePullPage.registry.account.desc=Select a Registry Account to use, or enter a server (HOST/IP:PORT) for a registry. +ImagePullPage.registry.account.label=Account / Server: ImagePush.label=Push an image: ImagePush.desc=Specify the image tag to push to the host. @@ -100,8 +100,8 @@ ImagePush.name=Push Image ImagePushName.label=Name: ImagePushName.toolTip=Enter or choose a name to upload to the host (either NAME or NAME:TAG) ImagePushPage.empty.registry.account=A registry is necessary to push. -ImagePushPage.registry.account.desc=Select a specific registry/account account to use -ImagePushPage.registry.account.label=Registry/Account: +ImagePushPage.registry.account.desc=Select a Registry Account to use, or enter a server (HOST/IP:PORT) for a registry. +ImagePushPage.registry.account.label=Account / Server: ErrorNameEmpty.msg=Name field cannot be empty ErrorInvalidImageId.msg=Invalid image name specification @@ -337,4 +337,8 @@ RegistryAccountDialog.add.edit.explanation=Add/Edit a Registry Account RegistryAccountDialog.email.label=Email RegistryAccountDialog.password.label=Password RegistryAccountDialog.server.label=Server Address -RegistryAccountDialog.username.label=Username
\ No newline at end of file +RegistryAccountDialog.server.desc=Enter a server address. This can be a host name or an IP address with a port specified. +RegistryAccountDialog.username.label=Username +RegistryAccountDialog.username.desc=Enter username to use for this registry (eg. Docker Hub, OpenShift Docker Registry, etc.) + +ImagePullPushPage.browse.label=Browse
\ No newline at end of file |