/*
 * Copyright 2000-2009 JetBrains s.r.o.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.intellij.ui;



import com.intellij.ui.components.JBScrollPane;
import org.intellij.lang.annotations.MagicConstant;

import javax.swing.*;
import java.awt.*;

/**
 * @author beg
 */
public class ScrollPaneFactory implements ScrollPaneConstants {
  private ScrollPaneFactory() {
  }

  public static JScrollPane createScrollPane() {
    return new JBScrollPane();
  }

  public static JScrollPane createScrollPane(Component view) {
    return new JBScrollPane(view);
  }

  public static JScrollPane createScrollPane(int vsbPolicy, int hsbPolicy) {
    return new JBScrollPane(vsbPolicy, hsbPolicy);
  }

  public static JScrollPane createScrollPane(Component view,
                                             @MagicConstant(intValues = {
                                               VERTICAL_SCROLLBAR_ALWAYS,
                                               VERTICAL_SCROLLBAR_AS_NEEDED,
                                               VERTICAL_SCROLLBAR_NEVER}) int vsbPolicy,
                                             @MagicConstant(intValues = {
                                               HORIZONTAL_SCROLLBAR_ALWAYS,
                                               HORIZONTAL_SCROLLBAR_AS_NEEDED,
                                               HORIZONTAL_SCROLLBAR_NEVER}) int hsbPolicy) {
    return new JBScrollPane(view, vsbPolicy, hsbPolicy);
  }

  public static JScrollPane createScrollPane(Component view, boolean withoutBorder) {
    JBScrollPane scrollPane = new JBScrollPane(view);
    if (withoutBorder) {
      scrollPane.setBorder(IdeBorderFactory.createEmptyBorder(0)); // set empty border, because setting null doesn't always take effect
    }
    return scrollPane;
  }

  public static JScrollPane createScrollPane(Component view, @MagicConstant(flagsFromClass = SideBorder.class) int borders) {
    JBScrollPane scrollPane = new JBScrollPane(view);
    scrollPane.setBorder(IdeBorderFactory.createBorder(borders));
    return scrollPane;

  }
}

@@ -621,17 +621,16 @@
 j.ui;%0A%0A%0A
-%0A
 import c
@@ -1347,129 +1347,34 @@
  = %7B
-%0A                                               VERTICAL_SCROLLBAR_ALWAYS,%0A                                              
+VERTICAL_SCROLLBAR_ALWAYS,
  VER
@@ -1392,32 +1392,38 @@
 LBAR_AS_NEEDED,%0A
+      
                 
@@ -1572,131 +1572,36 @@
  = %7B
-%0A                                               HORIZONTAL_SCROLLBAR_ALWAYS,%0A                                              
+HORIZONTAL_SCROLLBAR_ALWAYS,
  HOR
@@ -1621,32 +1621,38 @@
 LBAR_AS_NEEDED,%0A
+      
                 
@@ -2017,17 +2017,16 @@
 yBorder(
-0
 )); // s
@@ -2090,16 +2090,90 @@
  effect%0A
+      scrollPane.setViewportBorder(IdeBorderFactory.createEmptyBorder());%0A
     %7D%0A  

set view border too