public void createControl(Composite parent) {
    Composite contents = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    contents.setLayout(layout);
    GridData gridData = new GridData();
    gridData.horizontalAlignment = SWT.FILL;
    gridData.grabExcessHorizontalSpace = true;
    contents.setLayoutData(gridData);

    createFilesGroup(contents); // 文件列表区域
    createPropertiesGroup(contents); // 源文件属性区域组
    createConversionOptionsGroup(contents); // 转换选项组
    createSegmentationGroup(contents); // 分段规则选择区域组

    bindValue(); // 数据绑定

    loadFiles(); // 加载文件列表

    filesTable.select(0); // 默认选中第一行数据
    filesTable.notifyListeners(SWT.Selection, null);

    Dialog.applyDialogFont(parent);

    Point defaultMargins = LayoutConstants.getMargins();
    GridLayoutFactory.fillDefaults()
        .numColumns(1)
        .margins(defaultMargins.x, defaultMargins.y)
        .generateLayout(contents);

    setControl(contents);

    srxFile.setText(ConverterContext.defaultSrx);

    validate();
  }
 /**
  * Creates a DpiGridLayoutFactory that creates DpiGridLayouts with no margins and default dialog
  * spacing.
  *
  * <p>Initial values are:
  *
  * <ul>
  *   <li>numColumns(1)
  *   <li>margins(0,0)
  *   <li>extendedMargins(0,0,0,0)
  *   <li>spacing(LayoutConstants.getSpacing())
  *   <li>equalWidth(false)
  * </ul>
  *
  * @return a DpiGridLayoutFactory that creates DpiGridLayouts as though created with their default
  *     constructor
  * @see #swtDefaults
  */
 public static DpiGridLayoutFactory fillDefaults() {
   final DpiGridLayout layout = new DpiGridLayout();
   layout.marginWidth = 0;
   layout.marginHeight = 0;
   final Point defaultSpacing = LayoutConstants.getSpacing();
   layout.horizontalSpacing = defaultSpacing.x;
   layout.verticalSpacing = defaultSpacing.y;
   return new DpiGridLayoutFactory(layout);
 }
  @Override
  protected Control createDialogArea(Composite parent) {
    Composite parentComposite = (Composite) super.createDialogArea(parent);

    Composite contents = new Composite(parentComposite, SWT.NONE);
    GridLayout layout = new GridLayout();
    contents.setLayout(layout);
    GridData gridData = new GridData();
    gridData.horizontalAlignment = SWT.FILL;
    gridData.grabExcessHorizontalSpace = true;
    contents.setLayoutData(gridData);

    Composite converterComposite = new Composite(contents, SWT.NONE);
    converterComposite.setLayout(new GridLayout(2, false));

    gridData = new GridData();
    gridData.horizontalAlignment = SWT.FILL;
    gridData.grabExcessHorizontalSpace = true;
    converterComposite.setLayoutData(gridData);

    String direction = converterViewModel.getDirection();
    if (direction.equals(Converter.DIRECTION_POSITIVE)) {
      supportList = createConvertControl("Convert from Suport format to Xliff", converterComposite);
    } else {
      supportList =
          createConvertControl("Convert from Xliff to Support format", converterComposite);
    }
    supportList.getCombo().setFocus();

    bindValue();

    Dialog.applyDialogFont(parentComposite);

    Point defaultMargins = LayoutConstants.getMargins();
    GridLayoutFactory.fillDefaults()
        .numColumns(2)
        .margins(defaultMargins.x, defaultMargins.y)
        .generateLayout(contents);

    return contents;
  }
Example #4
0
  @Override
  protected Control createDialogArea(Composite parent) {
    Composite parentComposite = (Composite) super.createDialogArea(parent);

    Composite contents = new Composite(parentComposite, SWT.NONE);
    contents.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    setTitle("Create a project");
    setMessage(
        "Debrief requires a project to store your data in, which will stored be in the. DebriefNG folder in\nyour home directory. "
            + "Debrief can also provide you with some sample data, for use in the tutorials.");

    new Label(contents, SWT.LEFT).setText("Project name:");

    projectNameText = new Text(contents, SWT.SINGLE | SWT.BORDER);
    projectName = "DebriefProject";
    IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
    if (project != null && project.exists()) {
      projectName = "";
    }
    projectNameText.setText(projectName);
    projectNameText.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent event) {
            if (event.widget == projectNameText) {
              projectName = projectNameText.getText().trim();
              okButton.setEnabled(validate());
            }
          }
        });

    addDebriefSamplesButton = new Button(contents, SWT.CHECK);
    GridData gd = new GridData(SWT.FILL, SWT.FILL, true, false);
    gd.horizontalSpan = 2;
    addDebriefSamplesButton.setLayoutData(gd);

    addDebriefSamplesButton.setText("Add Debrief Samples (required for self-teach tutorials)");
    addDebriefSamplesButton.setSelection(true);

    if (showAskMeButton) {
      final Button askMeNextTime = new Button(contents, SWT.CHECK);
      gd = new GridData(SWT.FILL, SWT.FILL, true, false);
      gd.horizontalSpan = 2;
      askMeNextTime.setLayoutData(gd);

      askMeNextTime.setText("Always check at startup");
      askMeNextTime.setSelection(true);
      askMeNextTime.addSelectionListener(
          new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
              Boolean askMe = askMeNextTime.getSelection();
              CorePlugin.getDefault()
                  .getPreferenceStore()
                  .putValue(PrefsPage.PreferenceConstants.ASK_ABOUT_PROJECT, askMe.toString());
            }
          });
    }
    projectNameText.setFocus();

    Dialog.applyDialogFont(parentComposite);

    Point defaultMargins = LayoutConstants.getMargins();
    GridLayoutFactory.fillDefaults()
        .numColumns(2)
        .margins(defaultMargins.x, defaultMargins.y)
        .generateLayout(contents);

    return contents;
  }