Search in sources :

Example 1 with IRegistry

use of org.eclipse.linuxtools.docker.core.IRegistry 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 2 with IRegistry

use of org.eclipse.linuxtools.docker.core.IRegistry in project linuxtools by eclipse.

the class ImagePushPage method createControl.

@SuppressWarnings("unchecked")
@Override
public void createControl(final Composite parent) {
    parent.setLayout(new GridLayout());
    final Composite container = new Composite(parent, SWT.NONE);
    GridLayoutFactory.fillDefaults().numColumns(3).margins(6, 6).applyTo(container);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(container);
    // registry selection
    final IObservableValue<IRegistry> registryAccountObservable = super.createRegistrySelectionControls(container);
    // image selection
    final IObservableValue<String> imageNameObservable = createImageSelectionControls(container);
    // force tagging
    final Button forceTaggingButton = new Button(container, SWT.CHECK);
    forceTaggingButton.setText(WizardMessages.getString(// $NON-NLS-1$ );
    "ImagePushPage.forcetagging.label"));
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).span(2, 1).applyTo(forceTaggingButton);
    dbc.bindValue(WidgetProperties.selection().observe(forceTaggingButton), BeanProperties.value(ImagePushPageModel.class, ImagePushPageModel.FORCE_TAGGING).observe(getModel()));
    // keep tagged image upon completion
    final Button keepTaggedImageButton = new Button(container, SWT.CHECK);
    keepTaggedImageButton.setText(WizardMessages.getString(// $NON-NLS-1$ );
    "ImagePushPage.keeptaggedimage.label"));
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).span(2, 1).applyTo(keepTaggedImageButton);
    dbc.bindValue(WidgetProperties.selection().observe(keepTaggedImageButton), BeanProperties.value(ImagePushPageModel.class, ImagePushPageModel.KEEP_TAGGED_IMAGE).observe(getModel()));
    // setup validation support
    WizardPageSupport.create(this, dbc);
    dbc.addValidationStatusProvider(getModel().new ImagePushValidator(imageNameObservable, registryAccountObservable));
    setControl(container);
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) Button(org.eclipse.swt.widgets.Button) IRegistry(org.eclipse.linuxtools.docker.core.IRegistry)

Example 3 with IRegistry

use of org.eclipse.linuxtools.docker.core.IRegistry 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)

Aggregations

IRegistry (org.eclipse.linuxtools.docker.core.IRegistry)3 RegistryInfo (org.eclipse.linuxtools.internal.docker.core.RegistryInfo)2 ArrayList (java.util.ArrayList)1 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)1 ComboViewer (org.eclipse.jface.viewers.ComboViewer)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Button (org.eclipse.swt.widgets.Button)1 Combo (org.eclipse.swt.widgets.Combo)1 Composite (org.eclipse.swt.widgets.Composite)1 Label (org.eclipse.swt.widgets.Label)1 Link (org.eclipse.swt.widgets.Link)1