Ejemplo n.º 1
0
 @SuppressWarnings("unchecked")
 private IObservableValue<String> createImageSelectionControls(final Composite container) {
   final Label nameLabel = new Label(container, SWT.NULL);
   nameLabel.setText(WizardMessages.getString("ImagePullPushPage.name.label")); // $NON-NLS-1$
   GridDataFactory.fillDefaults()
       .align(SWT.FILL, SWT.CENTER)
       .grab(false, false)
       .applyTo(nameLabel);
   final Combo imageNameCombo = new Combo(container, SWT.DROP_DOWN);
   imageNameCombo.setToolTipText(WizardMessages.getString("ImagePushName.toolTip")); // $NON-NLS-1$
   GridDataFactory.fillDefaults()
       .align(SWT.FILL, SWT.CENTER)
       .grab(true, false)
       .applyTo(imageNameCombo);
   final ComboViewer imageNameComboViewer = new ComboViewer(imageNameCombo);
   imageNameComboViewer.setContentProvider(new ArrayContentProvider());
   imageNameComboViewer.setInput(getModel().getImage().repoTags());
   // binding must take place after the input is set, so that default
   // repo/name can be selected.
   final IObservableValue<String> imageNameObservable =
       BeanProperties.value(ImagePushPageModel.class, ImagePullPushPageModel.SELECTED_IMAGE_NAME)
           .observe(getModel());
   dbc.bindValue(WidgetProperties.selection().observe(imageNameCombo), imageNameObservable);
   // filler for the last column
   GridDataFactory.fillDefaults()
       .align(SWT.FILL, SWT.CENTER)
       .grab(false, false)
       .applyTo(new Label(container, SWT.NONE));
   return imageNameObservable;
 }
Ejemplo n.º 2
0
  @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("ImagePushPage.forcetagging.label")); // $NON-NLS-1$ );
    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("ImagePushPage.keeptaggedimage.label")); // $NON-NLS-1$ );
    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);
  }
/** A PolicyPageFactory that factors a GenericPolicyCreationPage. */
public class PolicyCreationPageFactory {

  /** The ResourceBundle associated with Wizard pages. */
  private static final ResourceBundle RESOURCE_BUNDLE = WizardMessages.getResourceBundle();

  /** The prefix for resources for this factories pages. */
  private static final String RESOURCE_PREFIX = "GenericPolicyCreationPage.";

  // The properties for the page to create.
  private String elementName;
  private String policyExtension;
  private String titleKey;
  private String messageKey;
  private String descriptionKey;
  private String icon;

  /**
   * Construct a new PolicyCreationPageFactory.
   *
   * @param elementName The element name representing the policy to create. attribute.
   * @param icon The icon associated with the policy page.
   */
  public PolicyCreationPageFactory(String elementName, String icon) {
    this.elementName = elementName;
    this.icon = icon;
    this.policyExtension = FileExtension.getFileExtensionForPolicyType(elementName).getExtension();
    this.titleKey = RESOURCE_PREFIX + "title";
    this.messageKey = RESOURCE_PREFIX + "message";
    this.descriptionKey = RESOURCE_PREFIX + "description";
  }

  // javadoc inherited
  public GenericPolicyCreationPage createPolicyCreationPage(IStructuredSelection selection) {

    String policyTypeName = EclipseCommonMessages.getLocalizedPolicyName(elementName);

    GenericPolicyCreationPage page =
        new GenericPolicyCreationPage(policyTypeName, policyExtension, selection);

    MessageFormat format;
    String args[] = {policyTypeName};
    format = new MessageFormat(RESOURCE_BUNDLE.getString(titleKey));
    String title = format.format(args);

    format = new MessageFormat(RESOURCE_BUNDLE.getString(messageKey));
    String message = format.format(args);

    format = new MessageFormat(RESOURCE_BUNDLE.getString(descriptionKey));
    String description = format.format(args);

    page.setTitle(title);
    page.setMessage(message);
    page.setDescription(description);

    ImageDescriptor id = ABPlugin.getImageDescriptor(icon);
    page.setImageDescriptor(id);

    return page;
  }
}
Ejemplo n.º 4
0
 /**
  * Constructor
  *
  * @param image the {@link IDockerImage} to push.
  * @param selectedImageName the default image name/tag
  */
 public ImagePushPage(final IDockerImage image, final String selectedImageName) {
   super(
       WizardMessages.getString("ImagePush.name"), // $NON-NLS-1$
       WizardMessages.getString("ImagePush.title"), // $NON-NLS-1$
       new ImagePushPageModel(image, selectedImageName));
 }