Exemplo n.º 1
0
 public static Color getConnectionTypeColor(DBPConnectionType connectionType) {
   String rgbString = connectionType.getColor();
   if (CommonUtils.isEmpty(rgbString)) {
     return null;
   }
   return DBeaverUI.getSharedTextColors().getColor(StringConverter.asRGB(rgbString));
 }
  private void adaptToTextForegroundChange(Highlighting highlighting, PropertyChangeEvent event) {
    RGB rgb = null;

    Object value = event.getNewValue();
    if (value instanceof RGB) rgb = (RGB) value;
    else if (value instanceof String) rgb = StringConverter.asRGB((String) value);

    if (rgb != null) {

      String property = event.getProperty();
      Color color = fColorManager.getColor(property);

      if ((color == null || !rgb.equals(color.getRGB()))
          && fColorManager instanceof IColorManagerExtension) {
        IColorManagerExtension ext = (IColorManagerExtension) fColorManager;
        ext.unbindColor(property);
        ext.bindColor(property, rgb);
        color = fColorManager.getColor(property);
      }

      TextAttribute oldAttr = highlighting.getTextAttribute();
      highlighting.setTextAttribute(
          new TextAttribute(color, oldAttr.getBackground(), oldAttr.getStyle()));
    }
  }
Exemplo n.º 3
0
  @Inject
  public void setOkForegroundColor(
      Display display,
      @Preference(nodePath = IConstant.PREFERENCE_NODE, value = IPreferenceKey.COLOR_OK_FOREGROUND)
          String rgbText) {

    okForegroundColor = new Color(display, StringConverter.asRGB(rgbText));
  }
Exemplo n.º 4
0
  @Inject
  public void setSuppressedGrblBackgroundColor(
      Display display,
      @Preference(
              nodePath = IConstant.PREFERENCE_NODE,
              value = IPreferenceKey.COLOR_GRBL_SUPPRESSED_BACKGROUND)
          String rgbText) {

    suppressedGrblBackgroundColor = new Color(display, StringConverter.asRGB(rgbText));
  }
Exemplo n.º 5
0
  @Inject
  public void setSuppressedErrorForegroundColor(
      Display display,
      @Preference(
              nodePath = IConstant.PREFERENCE_NODE,
              value = IPreferenceKey.COLOR_ERROR_SUPPRESSED_FOREGROUND)
          String rgbText) {

    supppressedErrorForegroundColor = new Color(display, StringConverter.asRGB(rgbText));
  }
Exemplo n.º 6
0
  @Inject
  public void setTimestampBackgroundColor(
      Display display,
      @Preference(
              nodePath = IConstant.PREFERENCE_NODE,
              value = IPreferenceKey.COLOR_TIMESTAMP_BACKGROUND)
          String rgbText) {

    timestampBackgroundColor = new Color(display, StringConverter.asRGB(rgbText));
  }
Exemplo n.º 7
0
  @Inject
  public void setTerminalForegroundColor(
      Display display,
      @Preference(
              nodePath = IConstant.PREFERENCE_NODE,
              value = IPreferenceKey.COLOR_TERMINAL_FOREGROUND)
          String rgbText) {

    terminalForegroundColor = new Color(display, StringConverter.asRGB(rgbText));
    if (terminalText != null && !terminalText.isDisposed())
      terminalText.setForeground(terminalForegroundColor);
  }
Exemplo n.º 8
0
 public static Color getConnectionColor(DBPConnectionConfiguration connectionInfo) {
   String rgbString = connectionInfo.getConnectionColor();
   if (CommonUtils.isEmpty(rgbString)) {
     rgbString = connectionInfo.getConnectionType().getColor();
   }
   if (CommonUtils.isEmpty(rgbString)) {
     return null;
   }
   Color connectionColor =
       DBeaverUI.getSharedTextColors().getColor(StringConverter.asRGB(rgbString));
   if (connectionColor.getBlue() == 255
       && connectionColor.getRed() == 255
       && connectionColor.getGreen() == 255) {
     // For white color return just null to avoid explicit color set.
     // It is important for dark themes
     return null;
   }
   return connectionColor;
 }
 private void adaptToColorChange(PropertyChangeEvent event) {
   RGB rgb = null;
   Token token = (Token) tokenMap.get(event.getProperty());
   LToken lToken = (LToken) tokenMap.get(event.getProperty() + MARK_SUFFIX);
   if (token == null && lToken == null) {
     return;
   }
   Object value = event.getNewValue();
   if (value instanceof RGB) rgb = (RGB) value;
   else if (value instanceof String) rgb = StringConverter.asRGB((String) value);
   if (rgb != null) {
     String property = event.getProperty();
     Object data = token.getData();
     if (data instanceof TextAttribute) {
       TextAttribute oldAttr = (TextAttribute) data;
       TextAttribute newAttr =
           new TextAttribute(
               colorManager.getColor(property), oldAttr.getBackground(), oldAttr.getStyle());
       if (token != null) token.setData(newAttr);
       if (lToken != null) lToken.setData(newAttr);
     }
   }
 }
  /**
   * Creates a <code>AnnotationPreference</code> the given configuration element.
   *
   * @param element the configuration element
   * @return the created annotation preference
   */
  private AnnotationPreference createSpec(IConfigurationElement element) {

    String s;
    int i;
    boolean b;

    ReadOnlyAnnotationPreference info = new ReadOnlyAnnotationPreference();

    s = element.getAttribute("annotationType"); // $NON-NLS-1$
    if (s == null || s.trim().length() == 0) return null;
    info.setAnnotationType(s);

    s = element.getAttribute("label"); // $NON-NLS-1$
    if (s != null && s.trim().length() > 0) info.setPreferenceLabel(s);

    s = element.getAttribute("markerType"); // $NON-NLS-1$
    if (s != null && s.trim().length() > 0) info.setMarkerType(s);

    s = element.getAttribute("markerSeverity"); // $NON-NLS-1$
    if (s != null && s.trim().length() > 0) {
      i = StringConverter.asInt(s, IMarker.SEVERITY_INFO);
      info.setSeverity(i);
    }

    s = element.getAttribute("textPreferenceKey"); // $NON-NLS-1$
    if (s != null && s.trim().length() > 0) info.setTextPreferenceKey(s);

    s = element.getAttribute("textPreferenceValue"); // $NON-NLS-1$
    if (s != null && s.trim().length() > 0) {
      b = StringConverter.asBoolean(s, false);
      info.setTextPreferenceValue(b);
    }

    s = element.getAttribute("highlightPreferenceKey"); // $NON-NLS-1$
    if (s != null && s.trim().length() > 0) info.setHighlightPreferenceKey(s);

    s = element.getAttribute("highlightPreferenceValue"); // $NON-NLS-1$
    if (s != null && s.trim().length() > 0) {
      b = StringConverter.asBoolean(s, false);
      info.setHighlightPreferenceValue(b);
    }

    s = element.getAttribute("overviewRulerPreferenceKey"); // $NON-NLS-1$
    if (s != null && s.trim().length() > 0) info.setOverviewRulerPreferenceKey(s);

    s = element.getAttribute("overviewRulerPreferenceValue"); // $NON-NLS-1$
    if (s != null && s.trim().length() > 0) {
      b = StringConverter.asBoolean(s, false);
      info.setOverviewRulerPreferenceValue(b);
    }

    s = element.getAttribute("verticalRulerPreferenceKey"); // $NON-NLS-1$
    if (s != null && s.trim().length() > 0) info.setVerticalRulerPreferenceKey(s);

    s = element.getAttribute("verticalRulerPreferenceValue"); // $NON-NLS-1$
    if (s != null && s.trim().length() > 0) {
      b = StringConverter.asBoolean(s, true);
      info.setVerticalRulerPreferenceValue(b);
    }

    s = element.getAttribute("colorPreferenceKey"); // $NON-NLS-1$
    if (s != null && s.trim().length() > 0) info.setColorPreferenceKey(s);

    s = element.getAttribute("colorPreferenceValue"); // $NON-NLS-1$
    if (s != null && s.trim().length() > 0) {
      RGB rgb = StringConverter.asRGB(s);
      info.setColorPreferenceValue(rgb == null ? new RGB(0, 0, 0) : rgb);
    }

    s = element.getAttribute("presentationLayer"); // $NON-NLS-1$
    if (s != null && s.trim().length() > 0) {
      i = StringConverter.asInt(s, 0);
      info.setPresentationLayer(i);
    }

    s = element.getAttribute("contributesToHeader"); // $NON-NLS-1$
    if (s != null && s.trim().length() > 0) {
      b = StringConverter.asBoolean(s, false);
      info.setContributesToHeader(b);
    }

    s = element.getAttribute("showInNextPrevDropdownToolbarActionKey"); // $NON-NLS-1$
    if (s != null && s.trim().length() > 0) info.setShowInNextPrevDropdownToolbarActionKey(s);

    s = element.getAttribute("showInNextPrevDropdownToolbarAction"); // $NON-NLS-1$
    if (s != null && s.trim().length() > 0) {
      b = StringConverter.asBoolean(s, false);
      info.setShowInNextPrevDropdownToolbarAction(b);
    }

    s = element.getAttribute("isGoToNextNavigationTargetKey"); // $NON-NLS-1$
    if (s != null && s.trim().length() > 0) info.setIsGoToNextNavigationTargetKey(s);

    s = element.getAttribute("isGoToNextNavigationTarget"); // $NON-NLS-1$
    if (s != null && s.trim().length() > 0) {
      b = StringConverter.asBoolean(s, false);
      info.setIsGoToNextNavigationTarget(b);
    }

    s = element.getAttribute("isGoToPreviousNavigationTargetKey"); // $NON-NLS-1$
    if (s != null && s.trim().length() > 0) info.setIsGoToPreviousNavigationTargetKey(s);

    s = element.getAttribute("isGoToPreviousNavigationTarget"); // $NON-NLS-1$
    if (s != null && s.trim().length() > 0) {
      b = StringConverter.asBoolean(s, false);
      info.setIsGoToPreviousNavigationTarget(b);
    }

    s = element.getAttribute("symbolicIcon"); // $NON-NLS-1$
    if (s != null && s.trim().length() > 0) info.setSymbolicImageName(s);

    s = element.getAttribute("icon"); // $NON-NLS-1$
    if (s != null && s.trim().length() > 0) info.setImageDescriptor(getImageDescriptor(s, element));

    s = element.getAttribute("quickFixIcon"); // $NON-NLS-1$
    if (s != null && s.trim().length() > 0)
      info.setQuickFixImageDescriptor(getImageDescriptor(s, element));

    s = element.getAttribute("annotationImageProvider"); // $NON-NLS-1$
    if (s != null && s.trim().length() > 0)
      info.setAnnotationImageProviderData(element, "annotationImageProvider"); // $NON-NLS-1$

    s = element.getAttribute("textStylePreferenceKey"); // $NON-NLS-1$
    if (s != null && s.trim().length() > 0) info.setTextStylePreferenceKey(s);

    s = element.getAttribute("textStylePreferenceValue"); // $NON-NLS-1$
    if (s != null && s.trim().length() > 0) {

      if (AnnotationPreference.STYLE_BOX.equals(s)
          || AnnotationPreference.STYLE_DASHED_BOX.equals(s)
          || AnnotationPreference.STYLE_IBEAM.equals(s)
          || AnnotationPreference.STYLE_SQUIGGLES.equals(s)
          || AnnotationPreference.STYLE_PROBLEM_UNDERLINE.equals(s)
          || AnnotationPreference.STYLE_UNDERLINE.equals(s)) info.setTextStyleValue(s);
      else info.setTextStyleValue(AnnotationPreference.STYLE_NONE);
    }

    s = element.getAttribute("includeOnPreferencePage"); // $NON-NLS-1$
    info.setIncludeOnPreferencePage(s == null || StringConverter.asBoolean(s, true));

    info.markReadOnly();

    return info;
  }
Exemplo n.º 11
0
 public Color3f getMinorColor() {
   String value = getString(MINOR_GRID_COLOR);
   RGB color = StringConverter.asRGB(value);
   return new Color3f(
       (float) (color.red / 255.0), (float) (color.green / 255.0), (float) (color.blue / 255.0));
 }