private void handleHyperlinkDefaultKeyModifierModified() {
    String modifiers = fHyperlinkDefaultKeyModifierText.getText();

    int stateMask = computeStateMask(modifiers);

    if (fHyperlinksEnabledCheckBox.getSelection()
        && (stateMask == -1 || (stateMask & SWT.SHIFT) != 0)) {
      if (stateMask == -1)
        fHyperlinkKeyModifierStatus =
            new StatusInfo(
                IStatus.ERROR,
                NLSUtility.format(
                    TextEditorMessages.HyperlinkKeyModifier_error_modifierIsNotValid, modifiers));
      else
        fHyperlinkKeyModifierStatus =
            new StatusInfo(
                IStatus.ERROR, TextEditorMessages.HyperlinkKeyModifier_error_shiftIsDisabled);
      applyToStatusLine(getHyperlinkKeyModifierStatus());
      fPreferencePage.setValid(getHyperlinkKeyModifierStatus().isOK());
    } else {
      fStore.setValue(
          AbstractDecoratedTextEditorPreferenceConstants.EDITOR_HYPERLINK_KEY_MODIFIER, modifiers);
      fHyperlinkKeyModifierStatus = new StatusInfo();
      fPreferencePage.setValid(true);
      applyToStatusLine(fHyperlinkKeyModifierStatus);
      fHyperlinkDetectorsViewer.refresh();
      handleListSelection();
    }
  }
  private void handleHyperlinkKeyModifierModified() {
    String modifiers = fHyperlinkKeyModifierText.getText();

    int stateMask = computeStateMask(modifiers);

    if (fHyperlinksEnabledCheckBox.getSelection()
        && (stateMask == -1 || (stateMask & SWT.SHIFT) != 0)) {
      if (stateMask == -1)
        fHyperlinkKeyModifierStatus =
            new StatusInfo(
                IStatus.ERROR,
                NLSUtility.format(
                    TextEditorMessages.HyperlinkKeyModifier_error_modifierIsNotValid, modifiers));
      else
        fHyperlinkKeyModifierStatus =
            new StatusInfo(
                IStatus.ERROR, TextEditorMessages.HyperlinkKeyModifier_error_shiftIsDisabled);
      applyToStatusLine(getHyperlinkKeyModifierStatus());
      fPreferencePage.setValid(getHyperlinkKeyModifierStatus().isOK());
    } else {
      ListItem item = getSelectedItem();
      if (item != null) {
        if (item.modifierKeys != null
            || !modifiers.equalsIgnoreCase(fHyperlinkDefaultKeyModifierText.getText()))
          item.modifierKeys = modifiers;
        fHyperlinkDetectorsViewer.refresh(getSelectedItem());
        fStore.setValue(item.id + HyperlinkDetectorDescriptor.STATE_MASK_POSTFIX, stateMask);
      }
      fHyperlinkKeyModifierStatus = new StatusInfo();
      fPreferencePage.setValid(true);
      applyToStatusLine(fHyperlinkKeyModifierStatus);
    }
  }
コード例 #3
0
  private void updateStatus(HoverConfig hoverConfig) {
    if (hoverConfig != null && hoverConfig.fIsEnabled && hoverConfig.fStateMask == -1)
      fStatus =
          new StatusInfo(
              IStatus.ERROR,
              Messages.format(
                  PreferencesMessages.DLTKEditorHoverConfigurationBlock_modifierIsNotValid,
                  hoverConfig.fModifierString));
    else fStatus = new StatusInfo();

    int i = 0;
    HashMap stateMasks = new HashMap(fHoverConfigs.length);
    while (fStatus.isOK() && i < fHoverConfigs.length) {
      if (fHoverConfigs[i].fIsEnabled) {
        String label = getContributedHovers()[i].getLabel();
        Integer stateMask = Integer.valueOf(fHoverConfigs[i].fStateMask);
        if (fHoverConfigs[i].fStateMask == -1)
          fStatus =
              new StatusInfo(
                  IStatus.ERROR,
                  Messages.format(
                      PreferencesMessages
                          .DLTKEditorHoverConfigurationBlock_modifierIsNotValidForHover,
                      new String[] {fHoverConfigs[i].fModifierString, label}));
        else if (stateMasks.containsKey(stateMask))
          fStatus =
              new StatusInfo(
                  IStatus.ERROR,
                  Messages.format(
                      PreferencesMessages.DLTKEditorHoverConfigurationBlock_duplicateModifier,
                      new String[] {label, (String) stateMasks.get(stateMask)}));
        else stateMasks.put(stateMask, label);
      }
      i++;
    }

    fMainPreferencePage.setValid(fStatus.isOK());
    StatusUtil.applyToStatusLine(fMainPreferencePage, fStatus);
  }