Search in sources :

Example 1 with RegistryInfo

use of org.eclipse.linuxtools.internal.docker.core.RegistryInfo in project linuxtools by eclipse.

the class RunImageMainTab method onSearchImage.

private SelectionListener onSearchImage() {
    return SelectionListener.widgetSelectedAdapter(e -> {
        final ImageSearch imageSearchWizard = new ImageSearch(RunImageMainTab.this.model.getSelectedConnection(), RunImageMainTab.this.model.getSelectedImageName(), new RegistryInfo(AbstractRegistry.DOCKERHUB_REGISTRY, true));
        final boolean completed = CommandUtils.openWizard(imageSearchWizard, getShell());
        if (completed) {
            model.setSelectedImageName(imageSearchWizard.getSelectedImage());
        }
    });
}
Also used : ImageSearch(org.eclipse.linuxtools.docker.ui.wizards.ImageSearch) RegistryInfo(org.eclipse.linuxtools.internal.docker.core.RegistryInfo)

Example 2 with RegistryInfo

use of org.eclipse.linuxtools.internal.docker.core.RegistryInfo in project linuxtools by eclipse.

the class ImagePullPushPage method getRegistryAccounts.

/**
 * @return all existing {@link IRegistryAccount} plus an entry at the first
 *         position for the registry configured in the selected Docker
 *         daemon.
 */
protected List<IRegistry> getRegistryAccounts() {
    // get a local copy an insert an entry at the first position for Docker
    // Hub with no credentials
    final List<IRegistry> accounts = new ArrayList<>(RegistryAccountManager.getInstance().getAccounts());
    accounts.add(0, new RegistryInfo(DOCKER_DAEMON_DEFAULT, true));
    return accounts;
}
Also used : RegistryInfo(org.eclipse.linuxtools.internal.docker.core.RegistryInfo) ArrayList(java.util.ArrayList) IRegistry(org.eclipse.linuxtools.docker.core.IRegistry)

Example 3 with RegistryInfo

use of org.eclipse.linuxtools.internal.docker.core.RegistryInfo in project linuxtools by eclipse.

the class ImagePullPushPage method createRegistrySelectionControls.

@SuppressWarnings("unchecked")
IObservableValue<IRegistry> createRegistrySelectionControls(Composite parent) {
    // registry selection
    final Label accountLabel = new Label(parent, SWT.NULL);
    accountLabel.setText(WizardMessages.getString(// $NON-NLS-1$
    "ImagePullPushPage.registry.account.label"));
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(false, false).applyTo(accountLabel);
    final Combo registryAccountCombo = new Combo(parent, SWT.DROP_DOWN | SWT.READ_ONLY);
    registryAccountCombo.setToolTipText(WizardMessages.getString(// $NON-NLS-1$
    "ImagePullPushPage.registry.account.desc"));
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(registryAccountCombo);
    final ComboViewer registryAccountComboViewer = new ComboViewer(registryAccountCombo);
    registryAccountComboViewer.setContentProvider(ArrayContentProvider.getInstance());
    registryAccountComboViewer.setLabelProvider(new RegistryAccountLabelProvider());
    final List<IRegistry> allRegistryAccounts = getRegistryAccounts();
    final IPreferenceStore store = Activator.getDefault().getPreferenceStore();
    // Calculate selected registry account to be the last one used
    // or else default to the first in the list
    IRegistry defaultRegistry = null;
    String lastRegistry = store.getString(PreferenceConstants.LAST_REGISTRY_ACCOUNT);
    if (!allRegistryAccounts.isEmpty()) {
        defaultRegistry = allRegistryAccounts.get(0);
    }
    IRegistry selectedRegistry = allRegistryAccounts.stream().filter(x -> ((RegistryInfo) x).getRegistryId().equals(lastRegistry)).findFirst().orElse(defaultRegistry);
    registryAccountComboViewer.setInput(allRegistryAccounts);
    if (selectedRegistry != null) {
        getModel().setSelectedRegistry(selectedRegistry);
    }
    final IObservableValue<IRegistry> registryAccountObservable = BeanProperties.value(ImagePushPageModel.class, ImagePullPushPageModel.SELECTED_REGISTRY).observe(model);
    dbc.bindValue(ViewerProperties.singleSelection().observe(registryAccountComboViewer), registryAccountObservable);
    // link to add registries and accounts
    final Link addRegistryLink = new Link(parent, SWT.NONE);
    addRegistryLink.setText(// $NON-NLS-1$
    WizardMessages.getString("ImagePullPushPage.add.link"));
    GridDataFactory.fillDefaults().align(SWT.RIGHT, SWT.CENTER).grab(false, false).applyTo(addRegistryLink);
    addRegistryLink.addSelectionListener(onAddRegistry(registryAccountComboViewer));
    return registryAccountObservable;
}
Also used : ComboViewer(org.eclipse.jface.viewers.ComboViewer) RegistryInfo(org.eclipse.linuxtools.internal.docker.core.RegistryInfo) Label(org.eclipse.swt.widgets.Label) Combo(org.eclipse.swt.widgets.Combo) IRegistry(org.eclipse.linuxtools.docker.core.IRegistry) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) Link(org.eclipse.swt.widgets.Link)

Example 4 with RegistryInfo

use of org.eclipse.linuxtools.internal.docker.core.RegistryInfo in project linuxtools by eclipse.

the class ImageRunSelectionPage method onSearchImage.

private SelectionListener onSearchImage() {
    return SelectionListener.widgetSelectedAdapter(e -> {
        final ImageSearch imageSearchWizard = new ImageSearch(ImageRunSelectionPage.this.model.getSelectedConnection(), ImageRunSelectionPage.this.model.getSelectedImageName(), new RegistryInfo(AbstractRegistry.DOCKERHUB_REGISTRY, true));
        final boolean completed = CommandUtils.openWizard(imageSearchWizard, getShell());
        if (completed) {
            model.setSelectedImageName(imageSearchWizard.getSelectedImage());
        }
    });
}
Also used : ImageSearch(org.eclipse.linuxtools.docker.ui.wizards.ImageSearch) RegistryInfo(org.eclipse.linuxtools.internal.docker.core.RegistryInfo)

Aggregations

RegistryInfo (org.eclipse.linuxtools.internal.docker.core.RegistryInfo)4 IRegistry (org.eclipse.linuxtools.docker.core.IRegistry)2 ImageSearch (org.eclipse.linuxtools.docker.ui.wizards.ImageSearch)2 ArrayList (java.util.ArrayList)1 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)1 ComboViewer (org.eclipse.jface.viewers.ComboViewer)1 Combo (org.eclipse.swt.widgets.Combo)1 Label (org.eclipse.swt.widgets.Label)1 Link (org.eclipse.swt.widgets.Link)1