/*
 * MIT License
 *
 * Copyright (c) 2021 Jannis Weis
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
 * associated documentation files (the "Software"), to deal in the Software without restriction,
 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all copies or
 * substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
 * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 */
package com.github.weisj.darklaf.components.border;

import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.border.CompoundBorder;
import javax.swing.plaf.UIResource;
import javax.swing.plaf.basic.BasicBorders;

public class MarginBorderWrapper extends CompoundBorder {

    public MarginBorderWrapper(final Border border) {
        super(border, new BasicBorders.MarginBorder());
    }

    public static void installBorder(final JComponent c) {
        Border border = c.getBorder();
        if (!(border instanceof MarginBorderWrapper)) {
            c.setBorder(wrapBorder(border));
        }
    }

    private static MarginBorderWrapper wrapBorder(final Border border) {
        if (border == null || border instanceof UIResource) {
            return new MarginBorderWrapper.UIBorder(border);
        } else {
            return new MarginBorderWrapper(border);
        }
    }

    public static void uninstallBorder(final JComponent c) {
        Border border = c.getBorder();
        if (border instanceof MarginBorderWrapper) {
            Border outside = ((MarginBorderWrapper) border).getOutsideBorder();
            c.setBorder(outside);
        }
    }

    public static Border getBorder(final JComponent c) {
        Border border = c.getBorder();
        if (border instanceof MarginBorderWrapper) {
            border = ((MarginBorderWrapper) border).getOutsideBorder();
        }
        return border;
    }

    public static class UIBorder extends MarginBorderWrapper implements UIResource {

        public UIBorder(final Border border) {
            super(border);
        }
    }
}

@@ -1174,16 +1174,129 @@
 order;%0A%0A
+import com.github.weisj.swingdsl.visualpadding.VisualPaddingProvider;%0Aimport org.jetbrains.annotations.NotNull;%0A%0A
 import j
@@ -1464,16 +1464,35 @@
 Borders;
+%0Aimport java.awt.*;
 %0A%0Apublic
@@ -1541,16 +1541,49 @@
 dBorder 
+implements VisualPaddingProvider 
 %7B%0A%0A    p
@@ -2729,32 +2729,330 @@
  border;%0A    %7D%0A%0A
+    @Override%0A    public @NotNull Insets getVisualPaddings(@NotNull Component component) %7B%0A        if (outsideBorder instanceof VisualPaddingProvider) %7B%0A            return ((VisualPaddingProvider) outsideBorder).getVisualPaddings(component);%0A        %7D%0A        return new Insets(0, 0, 0, 0);%0A    %7D%0A%0A
     public stati

Implement VisualPaddingProvider for MarginBorderWrapper