コード例 #1
0
  private void createButtons(final Composite buttonsComp) {
    String sAdd = UITexts.cabalImplsBlock_btnAdd;
    btnAdd = SWTUtil.createPushButton(buttonsComp, sAdd);
    btnAdd.addListener(
        SWT.Selection,
        new Listener() {
          @Override
          public void handleEvent(final Event evt) {
            addCabalImplementation();
          }
        });

    String sEdit = UITexts.implementationsBlock_btnEdit;
    btnEdit = SWTUtil.createPushButton(buttonsComp, sEdit);
    btnEdit.addListener(
        SWT.Selection,
        new Listener() {
          @Override
          public void handleEvent(final Event evt) {
            editCabalImplementation();
          }
        });

    String sRemove = UITexts.cabalImplsBlock_btnRemove;
    btnRemove = SWTUtil.createPushButton(buttonsComp, sRemove);
    btnRemove.addListener(
        SWT.Selection,
        new Listener() {
          @Override
          public void handleEvent(final Event evt) {
            removeSelectedCabalImplementations();
          }
        });

    String sDetect = UITexts.cabalImplsBlock_btnAutoDetect;
    btnAutoDetect = SWTUtil.createPushButton(buttonsComp, sDetect);
    btnAutoDetect.addListener(
        SWT.Selection,
        new Listener() {
          @Override
          public void handleEvent(final Event ev) {
            autoDetectCabalImpls();
          }
        });
  }
コード例 #2
0
  Composite createControl(final Composite parent, final PreferencePage prefParent) {
    Composite composite = new Composite(parent, SWT.NONE);
    Font parentFont = parent.getFont();

    GridLayout glayout = new GridLayout(2, false);
    glayout.marginHeight = 0;
    glayout.marginWidth = 0;
    composite.setLayout(glayout);
    composite.setFont(parentFont);

    Label tableLabel = new Label(composite, SWT.NONE);
    tableLabel.setText(UITexts.cabalImplsBlock_installed);
    GridData gdata = new GridData(SWT.FILL, SWT.TOP, true, false);
    gdata.horizontalSpan = 2;
    tableLabel.setLayoutData(gdata);
    tableLabel.setFont(parentFont);

    Composite tableComposite = new Composite(composite, SWT.NONE);
    tableComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    table = SWTUtil.createTable(tableComposite);
    createColumns(tableComposite);
    createViewer();

    // Deep copy the implementations, replace them later.
    CabalImplementationManager cMgr = CabalImplementationManager.getInstance();
    impls.clear();
    for (CabalImplementation impl : cMgr.getCabalImplementations()) {
      impls.add(new CabalImplementation(impl));
    }

    viewer.setInput(impls);

    // And set the current default (checked) implementation
    CabalImplementation defImpl = cMgr.getDefaultCabalImplementation();
    if (defImpl != null) {
      CabalImplementation impl = findImplementation(defImpl.getUserIdentifier());
      setCheckedCabalImplementation(impl);
    }

    Composite buttonsComp = new Composite(composite, SWT.NONE);

    glayout = new GridLayout(1, true);
    glayout.marginHeight = 0;
    glayout.marginWidth = 0;
    buttonsComp.setLayout(glayout);
    buttonsComp.setLayoutData(new GridData(SWT.CENTER, SWT.TOP, false, false));
    buttonsComp.setFont(parentFont);
    createButtons(buttonsComp);
    enableButtons();

    return composite;
  }