UI(Composite parent) {
      super(parent, SWT.NONE);

      GridLayoutFactory.swtDefaults().numColumns(2).applyTo(this);

      new Label(this, SWT.NONE).setText("First Name:");
      new Label(this, SWT.NONE).setText("Last Name");

      GridDataFactory gdf =
          GridDataFactory.swtDefaults().align(SWT.FILL, SWT.FILL).grab(true, false);
      firstName = new Text(this, SWT.BORDER);
      gdf.applyTo(firstName);

      lastName = new Text(this, SWT.BORDER);
      gdf.applyTo(lastName);

      gdf =
          GridDataFactory.swtDefaults().span(2, 1).grab(true, false).align(SWT.FILL, SWT.BEGINNING);
      Label label = new Label(this, SWT.NONE);
      label.setText("Formatted Name:");
      gdf.applyTo(label);

      formattedName = new Text(this, SWT.BORDER);
      formattedName.setEditable(false);
      gdf.applyTo(formattedName);
    }
Esempio n. 2
0
  @Override
  protected Control createContents(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    POPUP_LAYOUT_FACTORY.applyTo(composite);

    // LAYOUTDATA_GRAB_BOTH.applyTo(composite);
    GridData gd = LAYOUTDATA_GRAB_BOTH.create();

    composite.setLayoutData(gd);
    if (hasTitleArea()) {
      createTitleMenuArea(composite);
      createHorizontalSeparator(composite);
    }
    dialogArea = createDialogArea(composite);
    if (dialogArea.getLayoutData() == null) LAYOUTDATA_GRAB_BOTH.applyTo(composite);

    gd = LAYOUTDATA_GRAB_BOTH.create();
    dialogArea.pack();
    gd.widthHint = dialogArea.getSize().x;
    gd.heightHint = dialogArea.getSize().y;
    dialogArea.setLayoutData(gd);

    if (hasInfoArea()) {
      createHorizontalSeparator(composite);
      createInfoTextArea(composite);
    }
    return composite;
  }
    @Override
    protected void createDetails(final Composite parent) {
      GridLayoutFactory.fillDefaults()
          .numColumns(2)
          .margins(20, 20)
          .spacing(10, 10)
          .equalWidth(false)
          .applyTo(parent);
      final GridDataFactory hFill = GridDataFactory.fillDefaults().grab(true, false);

      UIControlsFactory.createLabel(parent, "Last Name:"); // $NON-NLS-1$
      final Text txtLast = UIControlsFactory.createText(parent);
      hFill.applyTo(txtLast);
      addUIControl(txtLast, "txtLast"); // $NON-NLS-1$

      UIControlsFactory.createLabel(parent, "First Name:"); // $NON-NLS-1$
      final Text txtFirst = UIControlsFactory.createText(parent);
      hFill.applyTo(txtFirst);
      addUIControl(txtFirst, "txtFirst"); // $NON-NLS-1$
    }
  @Override
  protected void basicCreatePartControl(final Composite parent) {
    parent.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
    parent.setLayout(new GridLayout(1, false));
    final GridDataFactory fillFactory = GridDataFactory.fillDefaults();

    UIControlsFactory.createLabel(parent, "Want to go home?"); // $NON-NLS-1$

    final Button jumpBack = UIControlsFactory.createButton(parent);
    jumpBack.setText("Jump Back"); // $NON-NLS-1$
    fillFactory.applyTo(jumpBack);
    addUIControl(jumpBack, DemoTargetSubModuleController.JUMP_BACK_RIDGET_ID);
  }
  private void createProjectCombo(Composite _parent) {
    GridDataFactory grabHor = GridDataFactory.fillDefaults().grab(true, false);
    Composite parent = new Composite(_parent, SWT.NONE);
    parent.setLayout(new GridLayout(3, false));

    grabHor.applyTo(parent);

    Label label = new Label(parent, SWT.NONE);
    label.setText("Project");

    projectCombo = new Combo(parent, SWT.DROP_DOWN | SWT.READ_ONLY);
    List<GradleProject> projects = getGradleProjects();
    String[] items = new String[projects.size()];
    int i = 0;
    for (GradleProject p : projects) {
      items[i++] = p.getName();
    }
    projectCombo.setItems(items);

    if (project != null) {
      projectCombo.setText(project.getName());
    }

    projectCombo.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent e) {
            projectComboChanged();
          }
        });

    refreshButton = new Button(parent, SWT.PUSH);
    refreshButton.setText("Refresh");
    refreshButton.setToolTipText("Rebuild the gradle model and refresh the task list");
    refreshButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent evt) {
            try {
              GradleProject currentProject = project;
              if (currentProject != null) {
                currentProject.requestGradleModelRefresh();
                taskSelectionTreeViewer.refresh();
              }
            } catch (CoreException e) {
              GradleCore.log(e);
            }
          }
        });

    grabHor.align(SWT.RIGHT, SWT.CENTER).applyTo(refreshButton);
  }
  @Override
  protected Control createContents(final Composite parent) {
    final Composite composite = new Composite(parent, SWT.NONE);
    POPUP_LAYOUT_FACTORY.applyTo(composite);
    LAYOUTDATA_GRAB_BOTH.applyTo(composite);

    titleArea = (Composite) createTitleMenuArea(composite);
    separator = createHorizontalSeparator(composite);
    createInfoTextArea(composite);

    applyColors(composite);
    applyFonts(composite);
    return composite;
  }
Esempio n. 7
0
  @Override
  protected void basicCreatePartControl(final Composite parent) {
    parent.setBackground(LnfManager.getLnf().getColor(LnfKeyConstants.SUB_MODULE_BACKGROUND));
    // parent.setLayout(new GridLayout(1, false));
    final FillLayout layout = new FillLayout();
    layout.marginHeight = 5;
    layout.marginWidth = 5;
    parent.setLayout(layout);

    final Group group = UIControlsFactory.createGroup(parent, "Blocking Demo:"); // $NON-NLS-1$
    GridLayoutFactory.fillDefaults().margins(20, 20).numColumns(1).applyTo(group);

    final GridDataFactory fillFactory = GridDataFactory.fillDefaults();

    final Button button1 =
        UIControlsFactory.createButton(
            group, "", BlockingSubModuleController.RIDGET_BLOCK_SUB_MODULE); // $NON-NLS-1$
    fillFactory.applyTo(button1);

    final Button button2 =
        UIControlsFactory.createButton(
            group, "", BlockingSubModuleController.RIDGET_BLOCK_MODULE); // $NON-NLS-1$
    fillFactory.applyTo(button2);

    final Button button3 =
        UIControlsFactory.createButton(
            group, "", BlockingSubModuleController.RIDGET_BLOCK_SUB_APP); // $NON-NLS-1$
    fillFactory.applyTo(button3);

    final Button button4 =
        UIControlsFactory.createButton(
            group, "", BlockingSubModuleController.RIDGET_DISABLE_MODULE); // $NON-NLS-1$
    fillFactory.applyTo(button4);

    final Button button5 =
        UIControlsFactory.createButton(
            group, "", BlockingSubModuleController.RIDGET_BLOCK_APPLICATION); // $NON-NLS-1$
    fillFactory.applyTo(button5);

    final Button button6 =
        UIControlsFactory.createButton(
            group, "", BlockingSubModuleController.RIDGET_BLOCK_DIALOG); // $NON-NLS-1$
    fillFactory.applyTo(button6);

    final Label label =
        UIControlsFactory.createLabel(
            group,
            "",
            SWT.CENTER, //$NON-NLS-1$
            BlockingSubModuleController.RIDGET_STATUS);
    fillFactory.applyTo(label);
  }
  public Composite createPreferenceComposite(
      Composite parent, final IBuildParticipantWorkingCopy participant) {
    Composite master = new Composite(parent, SWT.NONE);
    master.setLayout(GridLayoutFactory.fillDefaults().create());

    GridDataFactory fillHoriz = GridDataFactory.fillDefaults().grab(true, false);

    // JSON Options
    Group group = new Group(master, SWT.BORDER);
    group.setText(Messages.JSLintValidatorPreferenceCompositeFactory_OptionsTitle);
    group.setLayout(new GridLayout());
    group.setLayoutData(fillHoriz.create());

    Label label = new Label(group, SWT.WRAP);
    label.setText(Messages.JSLintValidatorPreferenceCompositeFactory_OptionsMsg);
    fillHoriz.applyTo(label);

    final Text text = new Text(group, SWT.MULTI | SWT.V_SCROLL);

    final ControlDecoration decoration = new ControlDecoration(text, SWT.LEFT | SWT.TOP);
    decoration.setDescriptionText(
        Messages.JSLintValidatorPreferenceCompositeFactory_OptionsParseError);
    decoration.setImage(
        PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_DEC_FIELD_ERROR));
    decoration.hide();

    text.setText(participant.getPreferenceString(IPreferenceConstants.JS_LINT_OPTIONS));
    fillHoriz.hint(SWT.DEFAULT, 100).applyTo(text);
    text.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent e) {
            decoration.hide();
            try {
              String optionsAsJSON = text.getText();
              JSON.parse(optionsAsJSON);
              participant.setPreference(IPreferenceConstants.JS_LINT_OPTIONS, text.getText());
            } catch (IllegalStateException e1) {
              decoration.show();
            }
          }
        });

    // Filters
    Composite filtersGroup = new ValidatorFiltersPreferenceComposite(master, participant);
    filtersGroup.setLayoutData(fillHoriz.grab(true, true).hint(SWT.DEFAULT, 150).create());

    return master;
  }
  @Override
  public void createContents(Composite page) {
    Composite field = new Composite(page, SWT.NONE);
    int cols = sectionLabel == null ? 1 : 2;
    GridLayout layout = GridLayoutFactory.fillDefaults().numColumns(cols).create();
    field.setLayout(layout);

    searchBox = new Text(field, SWT.SINGLE | SWT.BORDER | SWT.SEARCH | SWT.ICON_CANCEL);
    searchBox.setMessage("Type pattern to match");

    Label fieldNameLabel = null;
    if (sectionLabel != null) {
      fieldNameLabel = new Label(field, SWT.NONE);
      fieldNameLabel.setText(sectionLabel);
    }

    treeviewer = new TreeViewer(field, SWT.SINGLE | SWT.BORDER | SWT.V_SCROLL);

    treeviewer.addFilter(filter = new ChoicesFilter());
    treeviewer.setLabelProvider(labelProvider);
    treeviewer.setContentProvider(contentProvider);
    treeviewer.setInput(content);
    treeviewer.expandAll();

    GridDataFactory grabHor = GridDataFactory.fillDefaults().grab(true, false);
    GridDataFactory fixHeight = GridDataFactory.fillDefaults().hint(SWT.DEFAULT, 200);
    grabHor.applyTo(field);
    grabHor.applyTo(searchBox);
    fixHeight.applyTo(treeviewer.getControl());
    if (fieldNameLabel != null) {
      GridDataFactory.fillDefaults().align(SWT.BEGINNING, SWT.BEGINNING).applyTo(fieldNameLabel);
    }

    whenVisible(
        treeviewer.getControl(),
        new Runnable() {
          public void run() {
            GSContent preSelect = selection.selection.getValue();
            if (preSelect != null) {
              treeviewer.setSelection(new StructuredSelection(preSelect), true);
            } else {
              treeviewer.setSelection(StructuredSelection.EMPTY, true);
            }
            if (initialFilterText != null) {
              searchBox.setText(initialFilterText);
              updateFilter();
            }
            if (category != null) {
              // System.out.println(category);
              ContentType<?> expand = null;
              ContentType<?>[] contentTypes = content.getTypes();
              for (ContentType<?> contentType : contentTypes) {
                // TODO: Miles(?) Searching by display name seems like a bad idea
                if (contentType.getDisplayName().equals(category)) {
                  expand = contentType;
                  break;
                }
              }
              if (expand != null) {
                treeviewer.setExpandedElements(new Object[] {expand});
              }
            }
          }
        });

    treeviewer.addSelectionChangedListener(
        new ISelectionChangedListener() {
          public void selectionChanged(SelectionChangedEvent event) {
            ISelection sel = treeviewer.getSelection();
            if (sel.isEmpty()) {
              setSelection(null);
            } else if (sel instanceof IStructuredSelection) {
              IStructuredSelection ss = (IStructuredSelection) sel;
              setSelection(ss.getFirstElement());
            } else {
              // Not expecting anything else. So ignore.
            }
          }

          private void setSelection(Object e) {
            if (e == null) {
              selection.selection.setValue(null);
              rawSelection.setValue(null);
            } else {
              rawSelection.setValue(e);
              if (e instanceof GSContent) {
                selection.selection.setValue((GSContent) e);
              }
            }
          }
        });

    searchBox.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent e) {
            updateFilter();
          }
        });
  }
  @Override
  public void createControl(Composite parent) {
    Composite container = new Composite(parent, SWT.NULL);
    setControl(container);

    GridData gridData = new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1);
    container.setLayoutData(gridData);
    container.setLayout(new GridLayout(1, false));

    Group nameGroup = new Group(container, SWT.NONE);
    nameGroup.setText("Name and location");
    GridDataFactory.fillDefaults().grab(true, false).applyTo(nameGroup);
    GridLayoutFactory.fillDefaults().numColumns(3).margins(8, 8).applyTo(nameGroup);

    Label nameLabel = new Label(nameGroup, SWT.NONE);
    nameLabel.setText(ProjectMessages.NewApplicationWizardPage_project_name_label);

    projectNameField = new Text(nameGroup, SWT.BORDER);
    projectNameField.setText(""); // $NON-NLS-1$
    projectNameField.setToolTipText(ProjectMessages.NewApplicationWizardPage_project_name_tooltip);
    projectNameField.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
    projectNameField.addFocusListener(
        new FocusAdapter() {
          @Override
          public void focusGained(FocusEvent e) {
            projectNameField.selectAll();
          }
        });
    projectNameField.addModifyListener(
        new ModifyListener() {
          @Override
          public void modifyText(ModifyEvent e) {
            updateName();
          }
        });

    Label locationLabel = new Label(nameGroup, SWT.NONE);
    locationLabel.setText(ProjectMessages.NewApplicationWizardPage_directory_label);

    projectLocationField = new Text(nameGroup, SWT.BORDER);
    projectLocationField.setText(defaultLocation);
    projectLocationField.setToolTipText(ProjectMessages.NewApplicationWizardPage_directory_tooltip);
    projectLocationField.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    projectLocationField.addFocusListener(
        new FocusAdapter() {
          @Override
          public void focusGained(FocusEvent e) {
            projectLocationField.selectAll();
          }
        });
    projectLocationField.addModifyListener(
        new ModifyListener() {
          @Override
          public void modifyText(ModifyEvent e) {
            updateLocation();
          }
        });

    Button browseButton = new Button(nameGroup, SWT.NONE);
    browseButton.setText(ProjectMessages.NewApplicationWizardPage_browse_label);
    browseButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            handleBrowseButton(projectLocationField);
          }
        });
    PixelConverter converter = new PixelConverter(browseButton);
    int widthHint = converter.convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
    GridDataFactory.swtDefaults().hint(widthHint, -1).applyTo(browseButton);

    projectNameField.setFocus();

    Group contentGroup = new Group(container, SWT.NONE);
    contentGroup.setText("Sample content");
    GridDataFactory.fillDefaults().span(3, 1).grab(true, false).indent(0, 10).applyTo(contentGroup);
    GridLayoutFactory.fillDefaults().margins(8, 8).applyTo(contentGroup);

    generateContentButton = new Button(contentGroup, SWT.CHECK);
    generateContentButton.setText("Generate sample content");
    generateContentButton.setSelection(getGenerateContentPreference());
    generateContentButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            IDialogSettings settings =
                DartToolsPlugin.getDefault().getDialogSettingsSection(NEW_APPPLICATION_SETTINGS);
            settings.put(CONTENT_GENERATION_DISABLED, !generateContentButton.getSelection());

            updateMessageAndEnablement();
          }
        });

    Label spacer = new Label(contentGroup, SWT.SEPARATOR | SWT.HORIZONTAL);
    GridDataFactory.fillDefaults().grab(true, false).align(SWT.FILL, SWT.CENTER).applyTo(spacer);

    samplesViewer =
        new TableViewer(contentGroup, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION);
    samplesViewer.setLabelProvider(new LabelProvider());
    samplesViewer.setContentProvider(new ArrayContentProvider());
    List<AbstractSample> samples = AbstractSample.getAllSamples();
    samplesViewer.setInput(samples);
    {
      Control samplesControl = samplesViewer.getControl();
      int height = new PixelConverter(samplesControl).convertHeightInCharsToPixels(8);
      GridDataFactory gdf = GridDataFactory.fillDefaults();
      gdf.hint(-1, height);
      gdf.grab(true, false);
      gdf.align(SWT.FILL, SWT.CENTER);
      gdf.applyTo(samplesControl);
    }
    samplesViewer.setSelection(new StructuredSelection(getDefaultSample(samples)));
    samplesViewer.addSelectionChangedListener(
        new ISelectionChangedListener() {
          @Override
          public void selectionChanged(SelectionChangedEvent event) {
            updateMessageAndEnablement();
          }
        });

    updateMessageAndEnablement();

    setPageComplete(false);
  }