/**
   * Paint the drop lines, if any.
   *
   * @param context the Synth context.
   * @param g the Graphics context.
   */
  private void paintDropLines(SeaGlassContext context, Graphics g) {
    JTable.DropLocation loc = table.getDropLocation();

    if (loc == null) {
      return;
    }

    Color color = (Color) style.get(context, "Table.dropLineColor");
    Color shortColor = (Color) style.get(context, "Table.dropLineShortColor");

    if (color == null && shortColor == null) {
      return;
    }

    Rectangle rect;

    rect = getHDropLineRect(loc);
    if (rect != null) {
      int x = rect.x;
      int w = rect.width;

      if (color != null) {
        extendRect(rect, true);
        g.setColor(color);
        g.fillRect(rect.x, rect.y, rect.width, rect.height);
      }

      if (!loc.isInsertColumn() && shortColor != null) {
        g.setColor(shortColor);
        g.fillRect(x, rect.y, w, rect.height);
      }
    }

    rect = getVDropLineRect(loc);
    if (rect != null) {
      int y = rect.y;
      int h = rect.height;

      if (color != null) {
        extendRect(rect, false);
        g.setColor(color);
        g.fillRect(rect.x, rect.y, rect.width, rect.height);
      }

      if (!loc.isInsertRow() && shortColor != null) {
        g.setColor(shortColor);
        g.fillRect(rect.x, y, rect.width, h);
      }
    }
  }
  private static void patchGtkDefaults(UIDefaults defaults) {
    if (!UIUtil.isUnderGTKLookAndFeel()) return;

    Map<String, Icon> map =
        ContainerUtil.newHashMap(
            Arrays.asList(
                "OptionPane.errorIcon",
                "OptionPane.informationIcon",
                "OptionPane.warningIcon",
                "OptionPane.questionIcon"),
            Arrays.asList(
                AllIcons.General.ErrorDialog,
                AllIcons.General.InformationDialog,
                AllIcons.General.WarningDialog,
                AllIcons.General.QuestionDialog));
    // GTK+ L&F keeps icons hidden in style
    SynthStyle style = SynthLookAndFeel.getStyle(new JOptionPane(""), Region.DESKTOP_ICON);
    for (String key : map.keySet()) {
      if (defaults.get(key) != null) continue;

      Object icon = style == null ? null : style.get(null, key);
      defaults.put(key, icon instanceof Icon ? icon : map.get(key));
    }

    Color fg = defaults.getColor("Label.foreground");
    Color bg = defaults.getColor("Label.background");
    if (fg != null && bg != null) {
      defaults.put("Label.disabledForeground", UIUtil.mix(fg, bg, 0.5));
    }
  }
 private static void patchOptionPaneIcons(final UIDefaults defaults) {
   if (UIUtil.isUnderGTKLookAndFeel() && defaults.get(ourOptionPaneIconKeys[0]) == null) {
     // GTK+ L&F keeps icons hidden in style
     final SynthStyle style = SynthLookAndFeel.getStyle(new JOptionPane(""), Region.DESKTOP_ICON);
     if (style != null) {
       for (final String key : ourOptionPaneIconKeys) {
         final Object icon = style.get(null, key);
         if (icon != null) defaults.put(key, icon);
       }
     }
   }
 }
  /**
   * Update the style.
   *
   * @param c the component.
   */
  private void updateStyle(JTable c) {
    SeaGlassContext context = getContext(c, ENABLED);
    SynthStyle oldStyle = style;

    style = SeaGlassLookAndFeel.updateStyle(context, this);

    selectionActiveBottomBorderColor = UIManager.getColor("seaGlassTableSelectionActiveBottom");
    selectionInactiveBottomBorderColor = UIManager.getColor("seaGlassTableSelectionInactiveBottom");
    transparentColor = UIManager.getColor("seaGlassTransparent");

    if (style != oldStyle) {
      table.remove(rendererPane);
      rendererPane = createCustomCellRendererPane();
      table.add(rendererPane);

      context.setComponentState(ENABLED | SELECTED);

      Color sbg = table.getSelectionBackground();

      if (sbg == null || sbg instanceof UIResource) {
        table.setSelectionBackground(style.getColor(context, ColorType.TEXT_BACKGROUND));
      }

      Color sfg = table.getSelectionForeground();

      if (sfg == null || sfg instanceof UIResource) {
        table.setSelectionForeground(style.getColor(context, ColorType.TEXT_FOREGROUND));
      }

      context.setComponentState(ENABLED);

      Color gridColor = table.getGridColor();

      if (gridColor == null || gridColor instanceof UIResource) {
        gridColor = (Color) style.get(context, "Table.gridColor");
        if (gridColor == null) {
          gridColor = style.getColor(context, ColorType.FOREGROUND);
        }

        table.setGridColor(gridColor);
      }

      useTableColors = style.getBoolean(context, "Table.rendererUseTableColors", true);
      useUIBorder = style.getBoolean(context, "Table.rendererUseUIBorder", true);

      Object rowHeight = style.get(context, "Table.rowHeight");

      if (rowHeight != null) {
        LookAndFeel.installProperty(table, "rowHeight", rowHeight);
      }

      boolean showGrid = style.getBoolean(context, "Table.showGrid", true);

      if (!showGrid) {
        table.setShowGrid(false);
      }

      Dimension d = table.getIntercellSpacing();
      // if (d == null || d instanceof UIResource) {
      if (d != null) {
        d = (Dimension) style.get(context, "Table.intercellSpacing");
      }

      alternateColor = (Color) style.get(context, "Table.alternateRowColor");
      if (d != null) {
        table.setIntercellSpacing(d);
      }

      table.setOpaque(false);

      if (alternateColor != null) {
        table.setShowHorizontalLines(false);
      }

      // Make header column extend the width of the viewport (if there is
      // a viewport).
      table.getTableHeader().setBorder(createTableHeaderEmptyColumnPainter(table));
      setViewPortListeners(table);

      if (oldStyle != null) {
        uninstallKeyboardActions();
        installKeyboardActions();
      }
    }

    context.dispose();
  }
  /**
   * Sea Glass code to support the search JTextField.variant.
   *
   * @param c the JTextField component.
   * @param context the SeaGlassContext.
   * @param prefix the control prefix, e.g. "TextField", "FormattedTextField", or "PasswordField".
   */
  private void updateSearchStyle(JTextComponent c, SeaGlassContext context, String prefix) {
    searchIconWidth = 0;
    Object o = style.get(context, prefix + ".searchIconWidth");

    if (o != null && o instanceof Integer) {
      searchIconWidth = (Integer) o;
    }

    popupIconWidth = 0;
    o = style.get(context, prefix + ".popupIconWidth");
    if (o != null && o instanceof Integer) {
      popupIconWidth = (Integer) o;
    }

    cancelIconWidth = 0;
    o = style.get(context, prefix + ".cancelIconWidth");
    if (o != null && o instanceof Integer) {
      cancelIconWidth = (Integer) o;
    }

    searchLeftInnerMargin = 0;
    o = style.get(context, prefix + ".searchLeftInnerMargin");
    if (o != null && o instanceof Integer) {
      searchLeftInnerMargin = (Integer) o;
    }

    searchRightInnerMargin = 0;
    o = style.get(context, prefix + ".searchRightInnerMargin");
    if (o != null && o instanceof Integer) {
      searchRightInnerMargin = (Integer) o;
    }

    placeholderColor = Color.GRAY;
    o = style.get(context, "placeholderTextColor");
    if (o != null && o instanceof Color) {
      placeholderColor = (Color) o;
    }

    Border border = c.getBorder();

    if (border == null || border instanceof UIResource && !(border instanceof TextFieldBorder)) {
      c.setBorder(createTextFieldBorder(context));
    }

    if (isSearchField.isInState(c)) {
      o = c.getClientProperty("JTextField.Search.PlaceholderText");
      if (o != null && o instanceof String) {
        placeholderText = (String) o;
      } else if (placeholderText != null) {
        placeholderText = null;
      }

      o = c.getClientProperty("JTextField.Search.FindAction");
      if (o != null && o instanceof ActionListener) {
        if (findAction == null) {
          findAction = (ActionListener) o;
        }
      }

      o = c.getClientProperty("JTextField.Search.FindPopup");
      if (o != null && o instanceof JPopupMenu) {
        if (findPopup == null) {
          findPopup = (JPopupMenu) o;
        }
      }

      o = c.getClientProperty("JTextField.Search.CancelAction");
      if (o != null && o instanceof ActionListener) {
        if (cancelAction == null) {
          cancelAction = (ActionListener) o;
        }
      }

      installMouseListeners();
    } else {
      placeholderText = null;

      if (findAction != null) {
        findAction = null;
      }

      if (findPopup != null) {
        findPopup = null;
      }

      if (cancelAction != null) {
        cancelAction = null;
      }

      uninstallMouseListeners();
    }
  }