Example #1
0
  /** Selects the appropriate alphabet for the analysed text and sets the combo box selection. */
  private void selectAppropriateAlphabet() {
    AbstractAlphabet[] alphas = AlphabetsManager.getInstance().getAlphabets();
    String prevAlpha = myOverlayAlphabet;

    double bestrating = -99999;
    int bestindex = 0;
    double actualrating = 0;
    for (int i = 0; i < alphas.length; i++) {
      actualrating = rateAlphabetTextDifference(String.valueOf(alphas[i].getCharacterSet()), text);
      if (actualrating > bestrating) {
        bestrating = actualrating;
        bestindex = i;
      }
    }

    String bestAlphaString = String.valueOf(alphas[bestindex].getCharacterSet());
    if (bestAlphaString != null && !bestAlphaString.equals(prevAlpha)) {
      if (combo2.isVisible() && combo2.isEnabled()) {
        tipLauncher.showNewTooltip(
            combo2.toDisplay(
                new Point((int) Math.round((combo2.getSize().x) * 0.612), combo2.getSize().y)),
            9000,
            "",
            Messages.FullAnalysisUI_5); // $NON-NLS-1$
      }
    }

    combo2.select(bestindex);
    combo2WidgetSelected(null);
  }
  private void relayoutControls() {
    boolean twoRowToolbar = Math.abs(feederRegistry.current().getSize().y - buttonHeight * 2) <= 10;

    feederSelectionCombo.setLayoutData(
        LayoutHelper.formData(
            SWT.DEFAULT, buttonHeight, new FormAttachment(0), null, new FormAttachment(0), null));
    if (twoRowToolbar) {
      startStopButton.setLayoutData(
          LayoutHelper.formData(
              feederSelectionCombo.getSize().x,
              Platform.MAC_OS ? SWT.DEFAULT : buttonHeight,
              new FormAttachment(0),
              null,
              new FormAttachment(feederSelectionCombo, 0),
              null));
      prefsButton.setLayoutData(
          LayoutHelper.formData(
              new FormAttachment(feederSelectionCombo),
              null,
              new FormAttachment(feederSelectionCombo, 0, SWT.CENTER),
              null));
      fetchersButton.setLayoutData(
          LayoutHelper.formData(
              new FormAttachment(startStopButton),
              null,
              new FormAttachment(startStopButton, 0, SWT.CENTER),
              null));
    } else {
      startStopButton.setLayoutData(
          LayoutHelper.formData(
              feederSelectionCombo.getSize().x,
              Platform.MAC_OS ? SWT.DEFAULT : buttonHeight,
              new FormAttachment(feederSelectionCombo),
              null,
              new FormAttachment(-1),
              null));
      prefsButton.setLayoutData(
          LayoutHelper.formData(
              new FormAttachment(startStopButton),
              null,
              new FormAttachment(feederSelectionCombo, 0, SWT.CENTER),
              null));
      fetchersButton.setLayoutData(
          LayoutHelper.formData(
              new FormAttachment(prefsButton),
              null,
              new FormAttachment(startStopButton, 0, SWT.CENTER),
              null));
    }
  }
 @Override
 public Rectangle getInsertionBounds(Control control) {
   // This doesn't take horizontal scrolling into affect.
   // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=204599
   Combo combo = (Combo) control;
   int position = combo.getSelection().y;
   String contents = combo.getText();
   GC gc = new GC(combo);
   gc.setFont(combo.getFont());
   Point extent = gc.textExtent(contents.substring(0, Math.min(position, contents.length())));
   gc.dispose();
   if (COMPUTE_TEXT_USING_CLIENTAREA) {
     return new Rectangle(
         combo.getClientArea().x + extent.x,
         combo.getClientArea().y,
         1,
         combo.getClientArea().height);
   }
   return new Rectangle(extent.x, 0, 1, combo.getSize().y);
 }
    private void createAccessControl(Composite parent) throws JavaModelException {
      Composite access = new Composite(parent, SWT.NONE);
      GridLayout layout = new GridLayout();
      layout.marginHeight = 0;
      layout.marginWidth = 0;
      access.setLayout(layout);

      final int[] availableVisibilities =
          getChangeMethodSignatureProcessor().getAvailableVisibilities();
      int currentVisibility = getChangeMethodSignatureProcessor().getVisibility();

      Label label = new Label(access, SWT.NONE);
      label.setText(RefactoringMessages.ChangeSignatureInputPage_access_modifier);

      final Combo combo = new Combo(access, SWT.DROP_DOWN | SWT.READ_ONLY);
      if (availableVisibilities.length == 0) {
        combo.setEnabled(false);
      } else {
        for (int i = 0; i < availableVisibilities.length; i++) {
          combo.add(getAccessModifierString(availableVisibilities[i]));
        }
        combo.addSelectionListener(
            new SelectionAdapter() {
              @Override
              public void widgetSelected(SelectionEvent e) {
                int newVisibility = availableVisibilities[combo.getSelectionIndex()];
                getChangeMethodSignatureProcessor().setVisibility(newVisibility);
                update(true);
              }
            });
      }
      combo.setText(getAccessModifierString(currentVisibility));
      combo.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));

      // ensure that "Access modifier:" and "Return type:" Labels are not too close:
      Dialog.applyDialogFont(access);
      access.pack();
      int minLabelWidth = label.getSize().x + 3 * layout.horizontalSpacing;
      if (minLabelWidth > combo.getSize().x)
        label.setLayoutData(new GridData(minLabelWidth, label.getSize().y));
    }