예제 #1
0
  /**
   * Builds the SWT controls for the three areas of a compare/merge viewer.
   *
   * <p>Calls the hooks <code>createControls</code> and <code>createToolItems</code> to let
   * subclasses build the specific content areas and to add items to an enclosing toolbar.
   *
   * <p>This method must only be called in the constructor of subclasses.
   *
   * @param parent the parent control
   * @return the new control
   */
  protected final Control buildControl(Composite parent) {

    fComposite =
        new Composite(parent, fStyles | SWT.LEFT_TO_RIGHT) { // we
          // force
          // a
          // specific
          // direction
          public boolean setFocus() {
            return ContentMergeViewer.this.handleSetFocus();
          }
        };
    fComposite.setData(CompareUI.COMPARE_VIEWER_TITLE, getTitle());

    hookControl(fComposite); // hook help & dispose listener

    fComposite.setLayout(new ContentMergeViewerLayout());

    int style = SWT.SHADOW_OUT;
    fAncestorLabel = new CLabel(fComposite, style | Window.getDefaultOrientation());

    fLeftLabel = new CLabel(fComposite, style | Window.getDefaultOrientation());
    new Resizer(fLeftLabel, VERTICAL);

    fDirectionLabel = new CLabel(fComposite, style);
    fDirectionLabel.setAlignment(SWT.CENTER);
    new Resizer(fDirectionLabel, HORIZONTAL | VERTICAL);

    fRightLabel = new CLabel(fComposite, style | Window.getDefaultOrientation());
    new Resizer(fRightLabel, VERTICAL);

    if (fCenter == null || fCenter.isDisposed()) fCenter = createCenterControl(fComposite);

    createControls(fComposite);

    fHandlerService =
        CompareHandlerService.createFor(
            getCompareConfiguration().getContainer(), fComposite.getShell());

    initializeToolbars(parent);

    return fComposite;
  }
    public Composite createControls(Composite parent) {
      setPreferenceKey("mp3converttab");

      // set default for preferences.
      getPreferenceStore().setDefault(getPreferenceKey() + "." + "quickcopy", true);
      getPreferenceStore().setDefault(getPreferenceKey() + "." + "forceconvert", false);

      getPreferenceStore().setDefault(getPreferenceKey() + "." + "audioBitrate", "128");
      getPreferenceStore().setDefault(getPreferenceKey() + "." + "useAvisynth", false);

      Composite composite = new Composite(parent, SWT.NULL);
      composite.setLayout(new GridLayout(1, true));

      Group exportDir = new Group(composite, SWT.NULL);
      exportDir.setToolTipText(Messages.getString("mp3convert.exportDir.tooltip"));
      exportDir.setLayout(new GridLayout());
      exportDir.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
      exportDir.setText(Messages.getString("mp3convert.exportDir"));

      createDirectoryInfo(exportDir);

      Group detailSetting = new Group(composite, SWT.NULL);
      detailSetting.setLayout(new FillLayout());
      detailSetting.setLayoutData(new GridData(GridData.FILL_BOTH));
      detailSetting.setText(Messages.getString("mp3convert.detail"));

      ExpandBar bar = new ExpandBar(detailSetting, SWT.V_SCROLL);

      Composite copybase = new Composite(bar, SWT.NULL);
      copybase.setLayout(new RowLayout());
      quickCopy = new Button(copybase, SWT.CHECK);
      quickCopy.setText(Messages.getString("mp3convert.quickcopy"));
      quickCopy.addSelectionListener(
          new SelectionListener() {

            public void widgetDefaultSelected(SelectionEvent e) {}

            public void widgetSelected(SelectionEvent e) {
              updateStatus();
            }
          });
      // quickCopy.setSelection(true);//

      ExpandItem item0 = new ExpandItem(bar, SWT.NONE, 0);
      item0.setText(Messages.getString("mp3convert.aboutcopy"));
      item0.setHeight(copybase.computeSize(SWT.DEFAULT, SWT.DEFAULT).y);
      item0.setControl(copybase);

      Composite advancedSetting = new Composite(bar, SWT.NULL);
      advancedSetting.setLayout(new GridLayout(1, false));

      Composite changebase = new Composite(advancedSetting, SWT.NULL);
      changebase.setLayout(new GridLayout(1, false));
      forceConvert = new Button(changebase, SWT.CHECK);
      forceConvert.setText(Messages.getString("mp3convert.forceconvert"));
      mp3setting = new MP3AudioSettingComposite(changebase, SWT.NULL, false, getPreferenceKey());
      ExpandItem item1 = new ExpandItem(bar, SWT.NONE, 1);
      item1.setText(Messages.getString("mp3convert.convertsetting"));
      item1.setHeight(advancedSetting.computeSize(SWT.DEFAULT, SWT.DEFAULT).y);
      item1.setControl(advancedSetting);

      Composite bitrateBase = new Composite(bar, SWT.NULL);
      bitrateBase.setLayout(new RowLayout());
      Label label1 = new Label(bitrateBase, SWT.NULL);
      label1.setText(Messages.getString("mp3convert.defaultBitrate"));
      defaultBitrate = new CCombo(bitrateBase, SWT.NULL);
      int bitrates[] = {64, 80, 96, 112, 128, 160, 192, 224, 256, 320};
      for (int i = 0; i < bitrates.length; i++) {
        defaultBitrate.add("" + bitrates[i]);
      }
      defaultBitrate.select(4);
      Label label = new Label(bitrateBase, SWT.NULL);
      label.setText("kbps");

      ExpandItem item2 = new ExpandItem(bar, SWT.NONE, 2);
      item2.setText(Messages.getString("mp3convert.optionbitrate"));
      item2.setHeight(bitrateBase.computeSize(SWT.DEFAULT, SWT.DEFAULT).y);
      item2.setControl(bitrateBase);

      forceConvert.addSelectionListener(new SynchEnabled(mp3setting));

      Composite avisynthBase = new Composite(bar, SWT.NULL);
      avisynthBase.setLayout(new RowLayout());
      useAvisynth = new Button(avisynthBase, SWT.CHECK);
      useAvisynth.setText(Messages.getString("mp3convert.useAvisynth"));
      // quickCopy.setSelection(true);//

      ExpandItem item3 = new ExpandItem(bar, SWT.NONE, 3);
      item3.setText(Messages.getString("mp3convert.about_useAvisynth"));
      item3.setHeight(avisynthBase.computeSize(SWT.DEFAULT, SWT.DEFAULT).y);
      item3.setControl(avisynthBase);

      canConvertImage =
          AbstractUIPlugin.imageDescriptorFromPlugin(
                  "jp.sourceforge.akjrcp.akj_betas", "icons/dandd_mp3.png")
              .createImage();
      noFFMpegImage =
          AbstractUIPlugin.imageDescriptorFromPlugin(
                  "jp.sourceforge.akjrcp.akj_betas", "icons/dandd_noffmpeg.png")
              .createImage();
      // bitrate
      // framerate
      // channel

      dragHere = new CLabel(composite, SWT.BORDER | SWT.LEFT);
      dragHere.setBackground(ColorConstants.white);
      dragHere.setImage(canConvertImage);
      dragHere.setAlignment(SWT.CENTER);

      dragHere.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

      // keep preference store
      SavePreferenceStore sps = new SavePreferenceStore();

      // restore from setting..
      restoreControl(forceConvert);
      restoreControl(quickCopy);
      restoreControl(defaultBitrate);
      restoreControl(useAvisynth);

      forceConvert.addSelectionListener(sps);
      quickCopy.addSelectionListener(sps);
      defaultBitrate.addSelectionListener(sps);
      useAvisynth.addSelectionListener(sps);

      mp3setting.setEnabled(forceConvert.getSelection());
      mp3setting.setPreferenceStore(getPreferenceStore());

      // update status
      setCanConvert(true);
      updateStatus();
      PlatformUI.getPreferenceStore().addPropertyChangeListener(new SettingMonitor());
      return composite;
    }
  /*
   * (non-Javadoc)
   *
   * @see
   * org.talend.designer.core.ui.editor.properties2.editors.AbstractElementPropertySectionController#createControl()
   */
  @Override
  public Control createControl(
      final Composite subComposite,
      final IElementParameter param,
      final int numInRow,
      final int nbInRow,
      final int top,
      final Control lastControl) {
    this.curParameter = param;
    FormData data;
    Button btnEdit = getWidgetFactory().createButton(subComposite, "", SWT.PUSH); // $NON-NLS-1$

    btnEdit.setImage(ImageProvider.getImage(CoreUIPlugin.getImageDescriptor(DOTS_BUTTON)));

    data = new FormData();
    data.left = new FormAttachment(0, 120);
    data.top = new FormAttachment(0, top);
    data.height = STANDARD_HEIGHT - 2;
    btnEdit.setLayoutData(data);
    btnEdit.setData(NAME, ICON_SELECTION);
    btnEdit.setData(PARAMETER_NAME, param.getName());
    btnEdit.setEnabled(!param.isReadOnly());
    btnEdit.addSelectionListener(listenerSelection);

    DecoratedField dField =
        new DecoratedField(
            subComposite,
            SWT.NONE,
            new IControlCreator() {

              @Override
              public Control createControl(Composite parent, int style) {

                return new Label(parent, style);
              }
            });
    // revert btn
    Button btnRevert =
        getWidgetFactory()
            .createButton(
                subComposite,
                Messages.getString("IconSelectionController.Revert"),
                SWT.PUSH); //$NON-NLS-1$

    data = new FormData();
    data.left = new FormAttachment(btnEdit, 5);
    data.top = new FormAttachment(0, top);
    data.height = STANDARD_HEIGHT - 2;
    btnRevert.setLayoutData(data);
    btnRevert.setData(NAME, ICON_REVERT);
    btnRevert.setData(PARAMETER_NAME, param.getName());
    btnRevert.setEnabled(!param.isReadOnly());
    btnRevert.addSelectionListener(listenerSelection);

    if (param.isRequired()) {
      FieldDecoration decoration =
          FieldDecorationRegistry.getDefault()
              .getFieldDecoration(FieldDecorationRegistry.DEC_REQUIRED);
      dField.addFieldDecoration(decoration, SWT.RIGHT | SWT.TOP, false);
    }
    if (param.isRepositoryValueUsed()) {
      FieldDecoration decoration =
          FieldDecorationRegistry.getDefault()
              .getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL);
      decoration.setDescription(
          Messages.getString("FileController.decoration.description")); // $NON-NLS-1$
      dField.addFieldDecoration(decoration, SWT.RIGHT | SWT.BOTTOM, false);
    }

    Control cLayout = dField.getLayoutControl();
    filePathText = (Label) dField.getControl();
    String file = (String) elem.getPropertyValue(PARAMETER_NAME);
    if (file != null) {
      // ImageData imageData = new ImageData(file);
      // image = new Image(composite.getShell().getDisplay(), imageData);
      // filePathText.setImage(image);
    }

    CLabel labelLabel = getWidgetFactory().createCLabel(subComposite, param.getDisplayName(), 0);
    data = new FormData();
    if (lastControl != null) {
      data.left = new FormAttachment(lastControl, 0);
    } else {
      data.left = new FormAttachment((((numInRow - 1) * MAX_PERCENT) / nbInRow), 0);
    }
    data.top = new FormAttachment(0, top);
    labelLabel.setLayoutData(data);
    if (numInRow != 1) {
      labelLabel.setAlignment(SWT.RIGHT);
    }

    // **************************
    data = new FormData();
    int currentLabelWidth = 50;
    GC gc = new GC(labelLabel);
    Point labelSize = gc.stringExtent(param.getDisplayName());
    gc.dispose();

    if ((labelSize.x + ITabbedPropertyConstants.HSPACE) > currentLabelWidth) {
      currentLabelWidth = labelSize.x + ITabbedPropertyConstants.HSPACE;
    }

    if (numInRow == 1) {
      if (lastControl != null) {
        data.left = new FormAttachment(lastControl, currentLabelWidth);
      } else {
        data.left = new FormAttachment(0, currentLabelWidth);
      }
    } else {
      data.left = new FormAttachment(labelLabel, 0, SWT.RIGHT);
    }
    data.top = new FormAttachment(btnEdit, 0, SWT.CENTER);
    data.height = 34;
    data.width = 30;
    cLayout.setLayoutData(data);

    Point initialSize = dField.getLayoutControl().computeSize(SWT.DEFAULT, SWT.DEFAULT);
    dynamicProperty.setCurRowSize(initialSize.y + ITabbedPropertyConstants.VSPACE);
    return btnEdit;
  }
  /*
   * (non-Javadoc)
   *
   * @see
   * org.talend.designer.core.ui.editor.properties2.editors.AbstractElementPropertySectionController#createControl()
   */
  @Override
  public Control createControl(
      final Composite subComposite,
      final IElementParameter param,
      final int numInRow,
      final int nbInRow,
      final int top,
      final Control lastControl) {
    this.curParameter = param;
    this.paramFieldType = param.getFieldType();
    int nbLines = param.getNbLines();

    DecoratedField dField =
        new DecoratedField(
            subComposite,
            SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL | SWT.WRAP,
            new SelectAllTextControlCreator());
    if (param.isRequired()) {
      FieldDecoration decoration =
          FieldDecorationRegistry.getDefault()
              .getFieldDecoration(FieldDecorationRegistry.DEC_REQUIRED);
      dField.addFieldDecoration(decoration, SWT.RIGHT | SWT.TOP, false);
    }
    Control cLayout = dField.getLayoutControl();
    Text text = (Text) dField.getControl();

    editionControlHelper.register(param.getName(), text);

    FormData d = (FormData) text.getLayoutData();
    if (getAdditionalHeightSize() != 0) {
      nbLines += this.getAdditionalHeightSize() / text.getLineHeight();
    }
    d.height = text.getLineHeight() * nbLines;
    FormData data;
    text.getParent().setSize(subComposite.getSize().x, text.getLineHeight() * nbLines);
    cLayout.setBackground(subComposite.getBackground());
    // for bug 7580
    if (!(text instanceof Text)) {
      text.setEnabled(!param.isReadOnly());
    } else {
      text.setEditable(!param.isReadOnly());
    }
    IPreferenceStore preferenceStore = CorePlugin.getDefault().getPreferenceStore();
    String fontType = preferenceStore.getString(TalendDesignerPrefConstants.MEMO_TEXT_FONT);
    FontData fontData = new FontData(fontType);
    Font font = new Font(null, fontData);
    addResourceDisposeListener(text, font);
    text.setFont(font);
    if (elem instanceof Node) {
      text.setToolTipText(VARIABLE_TOOLTIP + param.getVariableName());
    }
    addDragAndDropTarget(text);

    CLabel labelLabel = getWidgetFactory().createCLabel(subComposite, param.getDisplayName());
    data = new FormData();
    if (lastControl != null) {
      data.left = new FormAttachment(lastControl, 0);
    } else {
      data.left = new FormAttachment((((numInRow - 1) * MAX_PERCENT) / nbInRow), 0);
    }
    data.top = new FormAttachment(0, top);
    labelLabel.setLayoutData(data);
    if (numInRow != 1) {
      labelLabel.setAlignment(SWT.RIGHT);
    }
    // *********************
    data = new FormData();
    int currentLabelWidth = STANDARD_LABEL_WIDTH;
    GC gc = new GC(labelLabel);
    Point labelSize = gc.stringExtent(param.getDisplayName());
    gc.dispose();

    if ((labelSize.x + ITabbedPropertyConstants.HSPACE) > currentLabelWidth) {
      currentLabelWidth = labelSize.x + ITabbedPropertyConstants.HSPACE;
    }

    if (numInRow == 1) {
      if (lastControl != null) {
        data.left = new FormAttachment(lastControl, currentLabelWidth);
      } else {
        data.left = new FormAttachment(0, currentLabelWidth);
      }

    } else {
      data.left = new FormAttachment(labelLabel, 0, SWT.RIGHT);
    }
    data.right = new FormAttachment((numInRow * MAX_PERCENT) / nbInRow, 0);
    data.top = new FormAttachment(0, top);
    cLayout.setLayoutData(data);
    // **********************
    hashCurControls.put(param.getName(), text);

    Point initialSize = dField.getLayoutControl().computeSize(SWT.DEFAULT, SWT.DEFAULT);

    dynamicProperty.setCurRowSize(initialSize.y + ITabbedPropertyConstants.VSPACE);
    return null;
  }
  /*
   * (non-Javadoc)
   *
   * @see
   * org.talend.designer.core.ui.editor.properties2.editors.AbstractElementPropertySectionController#createControl()
   */
  @Override
  public Control createControl(
      final Composite subComposite,
      final IElementParameter param,
      final int numInRow,
      final int nbInRow,
      final int top,
      final Control lastControl) {
    if (param.getDisplayName().startsWith("!!")) { // $NON-NLS-1$
      if (param.getFieldType() == EParameterFieldType.MODULE_LIST) {
        param.setDisplayName(EParameterName.MODULE_LIST.getDisplayName());
      }
    }

    DecoratedField dField = new DecoratedField(subComposite, SWT.BORDER, cbCtrl);
    if (param.isRequired()) {
      FieldDecoration decoration =
          FieldDecorationRegistry.getDefault()
              .getFieldDecoration(FieldDecorationRegistry.DEC_REQUIRED);
      dField.addFieldDecoration(decoration, SWT.RIGHT | SWT.TOP, false);
    }

    Control cLayout = dField.getLayoutControl();
    CCombo combo = (CCombo) dField.getControl();

    combo.setEditable(false);
    cLayout.setBackground(subComposite.getBackground());
    combo.setEnabled(!param.isReadOnly());
    combo.addSelectionListener(listenerSelection);
    if (elem instanceof Node) {
      combo.setToolTipText(VARIABLE_TOOLTIP + param.getVariableName());
    }

    CLabel labelLabel = getWidgetFactory().createCLabel(subComposite, param.getDisplayName());
    FormData data = new FormData();
    if (lastControl != null) {
      data.left = new FormAttachment(lastControl, 0);
    } else {
      data.left = new FormAttachment((((numInRow - 1) * MAX_PERCENT) / nbInRow), 0);
    }
    data.top = new FormAttachment(0, top);
    labelLabel.setLayoutData(data);
    if (numInRow != 1) {
      labelLabel.setAlignment(SWT.RIGHT);
    }
    // *********************
    data = new FormData();
    int currentLabelWidth = STANDARD_LABEL_WIDTH;
    GC gc = new GC(labelLabel);
    Point labelSize = gc.stringExtent(param.getDisplayName());
    gc.dispose();

    if ((labelSize.x + ITabbedPropertyConstants.HSPACE) > currentLabelWidth) {
      currentLabelWidth = labelSize.x + ITabbedPropertyConstants.HSPACE;
    }

    if (numInRow == 1) {
      if (lastControl != null) {
        data.left = new FormAttachment(lastControl, currentLabelWidth);
      } else {
        data.left = new FormAttachment(0, currentLabelWidth);
      }

    } else {
      data.left = new FormAttachment(labelLabel, 0, SWT.RIGHT);
    }
    data.top = new FormAttachment(0, top);
    cLayout.setLayoutData(data);
    Point initialSize = dField.getLayoutControl().computeSize(SWT.DEFAULT, SWT.DEFAULT);

    Button btnEdit = getWidgetFactory().createButton(subComposite, "", SWT.PUSH); // $NON-NLS-1$
    btnEdit.setImage(ImageProvider.getImage(CoreUIPlugin.getImageDescriptor(DOTS_BUTTON)));

    data = new FormData();
    data.left = new FormAttachment(cLayout, 0, SWT.RIGHT);
    data.right =
        new FormAttachment(
            cLayout, ITabbedPropertyConstants.HSPACE + STANDARD_BUTTON_WIDTH, SWT.RIGHT);
    data.top = new FormAttachment(0, top);
    data.height = STANDARD_HEIGHT - 2;
    btnEdit.setLayoutData(data);
    btnEdit.setData(NAME, MODULE);
    btnEdit.setData(PARAMETER_NAME, param.getName());
    btnEdit.setEnabled(!param.isReadOnly());
    btnEdit.addSelectionListener(listenerSelection);

    // **********************
    hashCurControls.put(param.getName(), combo);
    hashCurControls.put(param.getName() + BUTTON_EDIT, btnEdit);
    updateData();
    // this.dynamicTabbedPropertySection.updateColumnList(null);

    dynamicProperty.setCurRowSize(initialSize.y + ITabbedPropertyConstants.VSPACE);
    return cLayout;
  }
예제 #6
0
  private void addTextPatternControls(Composite group) {
    // grid layout with 2 columns

    // Info text
    Label label = new Label(group, SWT.LEAD);
    label.setText(SearchMessages.SearchPage_containingText_text);
    label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 2, 1));
    label.setFont(group.getFont());

    // Pattern combo
    fPattern = new Combo(group, SWT.SINGLE | SWT.BORDER);
    // Not done here to prevent page from resizing
    // fPattern.setItems(getPreviousSearchPatterns());
    fPattern.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            handleWidgetSelected();
            updateOKStatus();
          }
        });
    // add some listeners for regex syntax checking
    fPattern.addModifyListener(
        new ModifyListener() {
          @Override
          public void modifyText(ModifyEvent e) {
            updateOKStatus();
          }
        });
    fPattern.setFont(group.getFont());
    GridData data = new GridData(GridData.FILL, GridData.FILL, true, false, 1, 1);
    data.widthHint = convertWidthInCharsToPixels(50);
    fPattern.setLayoutData(data);

    ComboContentAdapter contentAdapter = new ComboContentAdapter();
    FindReplaceDocumentAdapterContentProposalProvider findProposer =
        new FindReplaceDocumentAdapterContentProposalProvider(true);
    fPatterFieldContentAssist =
        new ContentAssistCommandAdapter(
            fPattern,
            contentAdapter,
            findProposer,
            ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS,
            new char[0],
            true);
    fPatterFieldContentAssist.setEnabled(fIsRegExSearch);

    fIsCaseSensitiveCheckbox = new Button(group, SWT.CHECK);
    fIsCaseSensitiveCheckbox.setText(SearchMessages.SearchPage_caseSensitive);
    fIsCaseSensitiveCheckbox.setSelection(fIsCaseSensitive);
    fIsCaseSensitiveCheckbox.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            fIsCaseSensitive = fIsCaseSensitiveCheckbox.getSelection();
          }
        });
    fIsCaseSensitiveCheckbox.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    fIsCaseSensitiveCheckbox.setFont(group.getFont());

    // Text line which explains the special characters
    fStatusLabel = new CLabel(group, SWT.LEAD);
    fStatusLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    fStatusLabel.setFont(group.getFont());
    fStatusLabel.setAlignment(SWT.LEFT);
    fStatusLabel.setText(SearchMessages.SearchPage_containingText_hint);

    // RegEx checkbox
    fIsRegExCheckbox = new Button(group, SWT.CHECK);
    fIsRegExCheckbox.setText(SearchMessages.SearchPage_regularExpression);
    fIsRegExCheckbox.setSelection(fIsRegExSearch);

    fIsRegExCheckbox.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            fIsRegExSearch = fIsRegExCheckbox.getSelection();
            updateOKStatus();

            writeConfiguration();
            fPatterFieldContentAssist.setEnabled(fIsRegExSearch);
          }
        });
    fIsRegExCheckbox.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    fIsRegExCheckbox.setFont(group.getFont());
  }