예제 #1
0
  @Override
  public void createControl(final Composite parent) {
    if (this.isSource) {
      setTitle("Source Type (Java)");
      setDescription("Specify details for the source Java class for this transformation.");
    } else {
      setTitle("Target Type (Java)");
      setDescription("Specify details for the target Java class for this transformation.");
    }
    observablesManager.runAndCollect(
        new Runnable() {

          @Override
          public void run() {
            createPage(parent);
          }
        });

    WizardPageSupport wps = WizardPageSupport.create(this, context);
    wps.setValidationMessageProvider(new WizardValidationMessageProvider());
    setErrorMessage(null); // clear any error messages at first
    setMessage(null); // now that we're using info messages, we must reset
    // this too

  }
  /* (non-Javadoc)
   * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
   */
  @Override
  public void createControl(Composite parent) {
    final Composite composite = new Composite(parent, SWT.NONE);

    context = new DataBindingContext();
    WizardPageSupport.create(this, context);
    composite.setLayout(new GridLayout(2, false));

    createNameAndDescription(composite);

    createTypeCombo(composite);

    configStackComposite = new Composite(composite, SWT.NONE);
    sLayout = new StackLayout();
    configStackComposite.setLayout(sLayout);
    configStackComposite.setLayoutData(
        GridDataFactory.fillDefaults().grab(true, true).span(2, 1).hint(SWT.DEFAULT, 200).create());

    Composite booleanComposite = createBooleanConfigurationComposite(configStackComposite);
    configCompositeMap.put(SimulationPackage.eINSTANCE.getSimulationBoolean(), booleanComposite);

    Composite literalsComposite = createLiteralsConfigurationComposite(configStackComposite);
    configCompositeMap.put(
        SimulationPackage.eINSTANCE.getSimulationLiteralData(), literalsComposite);

    Composite numberComposite = createNumberConfigurationComposite(configStackComposite);
    configCompositeMap.put(SimulationPackage.eINSTANCE.getSimulationNumberData(), numberComposite);

    context.bindValue(
        SWTObservables.observeVisible(configStackComposite),
        SWTObservables.observeSelection(isExpressionBased),
        null,
        new UpdateValueStrategy()
            .setConverter(
                new org.eclipse.core.databinding.conversion.Converter(
                    Boolean.class, Boolean.class) {

                  @Override
                  public Object convert(Object fromObject) {
                    return !((Boolean) fromObject);
                  }
                }));

    /* So like that it forces call to isPageCOmplete after that the model is updated.
     * what would be even better it to implement validator on each related bindings instead of doing the work in isPageComplete
     * */
    WizardPageSupport.create(this, context);

    changeDataConfigurationComposite(
        (EClass) ((IStructuredSelection) datatypeCombo.getSelection()).getFirstElement());
    setControl(composite);
  }
예제 #3
0
    protected void initBindings() {
      final Realm realm = Realm.getDefault();
      final DataBindingContext dbc = new DataBindingContext(realm);

      addBindings(dbc, realm);
      WizardPageSupport.create(this, dbc);
    }
 @Override
 public void dispose() {
   super.dispose();
   if (context != null) {
     context.dispose();
   }
   if (pageSupport != null) {
     pageSupport.dispose();
   }
 }
예제 #5
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);
  }
    public void createControl(Composite parent) {
      DataBindingContext dbc = new DataBindingContext();
      WizardPageSupport.create(this, dbc);
      Composite composite = new Composite(parent, SWT.NONE);
      Label label = new Label(composite, SWT.NONE);
      label.setText("Enter a date:");
      Text text = new Text(composite, SWT.BORDER);

      dbc.bindValue(
          SWTObservables.observeText(text, SWT.Modify),
          ((SampleWizard) getWizard()).getModel().dateValue,
          null,
          null);

      GridLayoutFactory.swtDefaults().numColumns(2).generateLayout(composite);
      setControl(composite);
    }
    public void createControl(Composite parent) {
      DataBindingContext dbc = new DataBindingContext();
      WizardPageSupport.create(this, dbc);
      Composite composite = new Composite(parent, SWT.NONE);
      Label label = new Label(composite, SWT.NONE);
      label.setText("Enter a number between 0 and 9:");
      Text text = new Text(composite, SWT.BORDER);

      dbc.bindValue(
          SWTObservables.observeText(text, SWT.Modify),
          ((SampleWizard) getWizard()).getModel().intValue,
          new UpdateValueStrategy().setAfterConvertValidator(new SingleDigitValidator()),
          null);

      GridLayoutFactory.swtDefaults().numColumns(2).generateLayout(composite);
      setControl(composite);
    }
  /** 对 UI 和 View Model 进行绑定 ; */
  private void bindValue() {
    DataBindingContext dbc = new DataBindingContext();
    WizardPageSupport.create(this, dbc);
    ConversionConfigBean configBean = conversionConfigBeans.get(0);

    // bind the format
    dbc.bindList(
        SWTObservables.observeItems(formatCombo),
        BeansObservables.observeList(configBean, "fileFormats")); // $NON-NLS-1$
    // final IObservableValue format = BeansObservables.observeValue(selectedModel, "selectedType");
    // dbc.bindValue(SWTObservables.observeSelection(formatCombo), format);

    // bind the source encoding
    dbc.bindList(
        SWTObservables.observeItems(srcEncCombo),
        BeansObservables.observeList(configBean, "pageEncoding")); // $NON-NLS-1$
  }
  public void createControl(Composite parent) {
    DataBindingContext dbc = new DataBindingContext();
    WizardPageSupport.create(this, dbc);

    Composite container = new Composite(parent, SWT.NONE);

    Button[] buttons = new Button[OSGiBundleFacetUninstallStrategy.values().length];
    for (int i = 0; i < buttons.length; i++) {
      buttons[i] = new Button(container, SWT.RADIO);
      buttons[i].setText(OSGiBundleFacetUninstallStrategy.values()[i].description());
      dbc.bindValue(
          SWTObservables.observeSelection(buttons[i]), config.getOptionValues()[i], null, null);
    }

    GridLayoutFactory.swtDefaults().generateLayout(container);
    setControl(container);
    Dialog.applyDialogFont(container);
  }
예제 #10
0
    @Override
    public void createControl(final Composite parent) {
      initializeDialogUnits(parent);

      final Composite composite = new Composite(parent, SWT.NONE);
      composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
      composite.setLayout(LayoutUtil.createContentGrid(1));

      final IRLibPaths rLibPaths = fRPkgManager.getRLibPaths();
      {
        final Group group = new Group(composite, SWT.NONE);
        group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
        group.setText("Target Library:");
        group.setLayout(LayoutUtil.createGroupGrid(1));

        fSelectTargetControl = new RLibrarySelectionComposite(group);
        fSelectTargetControl.setLayoutData(fSelectTargetControl.createGD());
        fSelectTargetControl.getValidator().setRequired(IRLibPaths.WRITABLE);
        fSelectTargetControl.setInput(rLibPaths);

        if (fMode == MODE_UPDATE) {
          fSameTargetControl = new Button(group, SWT.CHECK);
          fSameTargetControl.setText(
              "Install updates to the library of the installed package, if possible.");
          fSameTargetControl.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
        }
      }

      Dialog.applyDialogFont(composite);
      setControl(composite);

      final DataBindingSupport databinding = new DataBindingSupport(composite);
      addBindings(databinding);

      fTargetLibraryValue.setValue(RPkgUtil.getDefaultInstallLocation(rLibPaths));
      WizardPageSupport.create(this, databinding.getContext());
    }
  /* (non-Javadoc)
   * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
   */
  @Override
  public void createControl(Composite parent) {
    context = new EMFDataBindingContext();

    final Composite mainComposite = new Composite(parent, SWT.NONE);
    mainComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    mainComposite.setLayout(
        GridLayoutFactory.fillDefaults().numColumns(1).margins(15, 15).create());

    final Text searchText =
        new Text(mainComposite, SWT.SEARCH | SWT.ICON_SEARCH | SWT.BORDER | SWT.CANCEL);
    searchText.setMessage(Messages.search);
    searchText.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());

    final CheckboxTableViewer languageViewer =
        CheckboxTableViewer.newCheckList(
            mainComposite, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI | SWT.V_SCROLL);
    languageViewer
        .getTable()
        .setLayoutData(
            GridDataFactory.fillDefaults().grab(true, true).hint(SWT.DEFAULT, 190).create());
    languageViewer.getTable().setLinesVisible(true);
    languageViewer.getTable().setHeaderVisible(true);
    final TableLayout layout = new TableLayout();
    layout.addColumnData(new ColumnWeightData(65));
    layout.addColumnData(new ColumnWeightData(35));
    languageViewer.getTable().setLayout(layout);
    languageViewer.setContentProvider(new ArrayContentProvider());
    languageViewer.setLabelProvider(new LocaleLabelProvider());

    searchFilter =
        new ViewerFilter() {

          @Override
          public boolean select(Viewer arg0, Object arg1, Object element) {
            if (!searchText.getText().isEmpty()) {
              String searchQuery = searchText.getText().toLowerCase();
              Locale locale = (Locale) element;
              return locale.toString().toLowerCase().contains(searchQuery)
                  || locale.getDisplayName().toLowerCase().contains(searchQuery);
            }
            return true;
          }
        };
    languageViewer.addFilter(searchFilter);
    languageViewer.setInput(Locale.getAvailableLocales());
    languageViewer.getTable().setFocus();

    TableViewerColumn countryNameColumn = new TableViewerColumn(languageViewer, SWT.FILL);
    countryNameColumn.setLabelProvider(new LocaleLabelProvider());
    countryNameColumn.getColumn().setText(Messages.countryName);

    TableViewerColumn localeCodeNameColumn = new TableViewerColumn(languageViewer, SWT.FILL);
    localeCodeNameColumn.setLabelProvider(
        new ColumnLabelProvider() {
          @Override
          public String getText(Object element) {
            return ((Locale) element).toString();
          }
        });

    localeCodeNameColumn.getColumn().setText(Messages.locale);

    new TableColumnSorter(languageViewer).setColumn(countryNameColumn.getColumn());

    context.bindSet(
        ViewersObservables.observeCheckedElements(languageViewer, Locale.class),
        PojoObservables.observeSet(this, "selectedLocales"));

    searchText.addModifyListener(
        new ModifyListener() {

          @Override
          public void modifyText(ModifyEvent e) {
            languageViewer.refresh();
          }
        });

    pageSupport = WizardPageSupport.create(this, context);
    setControl(mainComposite);
  }
  /** {@inheritDoc} */
  @Override
  public void createControl(final Composite parent) {
    final Composite client = new Composite(parent, SWT.NULL);
    client.setLayout(new GridLayout(2, false));

    Label label;
    final GridDataFactory labelFactory = GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.TOP);
    Text text;
    final GridDataFactory textFactory =
        GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, false);

    label = new Label(client, SWT.NULL);
    label.setLayoutData(labelFactory.create());
    label.setText("Company:");
    text = new Text(client, SWT.BORDER);
    text.setLayoutData(textFactory.create());
    this.context.bindValue(
        WidgetProperties.text(SWT.Modify).observe(text),
        EMFObservables.observeValue(this.author, SpdPackage.Literals.AUTHOR__COMPANY),
        null,
        null);

    label = new Label(client, SWT.NULL);
    label.setLayoutData(labelFactory.create());
    label.setText("Webpage:");
    text = new Text(client, SWT.BORDER);
    text.setLayoutData(textFactory.create());
    this.context.bindValue(
        WidgetProperties.text(SWT.Modify).observe(text),
        EMFObservables.observeValue(this.author, SpdPackage.Literals.AUTHOR__WEBPAGE),
        null,
        null);

    label = new Label(client, SWT.NULL);
    label.setLayoutData(labelFactory.create());
    label.setText("Names:");
    final Composite namesComp = new Composite(client, SWT.NULL);
    namesComp.setLayoutData(
        new GridData(GridData.FILL_BOTH | GridData.GRAB_VERTICAL | GridData.GRAB_HORIZONTAL));
    final GridLayout layout = new GridLayout(2, false);
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    namesComp.setLayout(layout);

    this.tableViewer = new TableViewer(namesComp, SWT.BORDER);
    this.tableViewer.setContentProvider(
        new IStructuredContentProvider() {

          @Override
          public void inputChanged(
              final Viewer viewer, final Object oldInput, final Object newInput) {
            // TODO Auto-generated method stub

          }

          @Override
          public void dispose() {
            // TODO Auto-generated method stub

          }

          @Override
          public Object[] getElements(final Object inputElement) {
            return ((Author) inputElement).getName().toArray();
          }
        });
    this.tableViewer.setLabelProvider(new LabelProvider());
    this.tableViewer.setInput(this.author);
    this.tableViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 2));

    final Button addButton = new Button(namesComp, SWT.PUSH);
    addButton.setText("Add");
    addButton.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false, 1, 1));
    addButton.addSelectionListener(
        new SelectionAdapter() {
          /** {@inheritDoc} */
          @Override
          public void widgetSelected(final SelectionEvent e) {
            handleAddName();
          }
        });

    final Button removeButton = new Button(namesComp, SWT.PUSH);
    removeButton.setText("Remove");
    removeButton.setEnabled(false);
    removeButton.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false, 1, 1));
    this.tableViewer.addSelectionChangedListener(
        new ISelectionChangedListener() {

          @Override
          public void selectionChanged(final SelectionChangedEvent event) {
            removeButton.setEnabled(!event.getSelection().isEmpty());
          }
        });
    removeButton.addSelectionListener(
        new SelectionAdapter() {
          /** {@inheritDoc} */
          @Override
          public void widgetSelected(final SelectionEvent e) {
            AuthorWizardPage.this
                .author
                .getName()
                .remove(
                    ((IStructuredSelection) AuthorWizardPage.this.tableViewer.getSelection())
                        .getFirstElement());
            AuthorWizardPage.this.tableViewer.refresh();
          }
        });

    this.pageSupport = WizardPageSupport.create(this, this.context);

    this.setControl(client);
  }