/*
 * Copyright 2000-2015 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.diff.tools.util;

import com.intellij.openapi.diff.DiffBundle;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.ui.IdeBorderFactory;
import com.intellij.util.ui.AnimatedIcon;
import com.intellij.util.ui.AsyncProcessIcon;
import org.jetbrains.annotations.Nullable;

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

public class StatusPanel extends JPanel {
  private final JLabel myTextLabel;
  private final AnimatedIcon myBusySpinner;

  public StatusPanel() {
    super(new BorderLayout());
    myTextLabel = new JLabel("");
    myTextLabel.setVisible(false);
    myBusySpinner = new AsyncProcessIcon("StatusPanelSpinner");
    myBusySpinner.setVisible(false);

    add(myTextLabel, BorderLayout.CENTER);
    add(myBusySpinner, BorderLayout.WEST);
    setBorder(IdeBorderFactory.createEmptyBorder(0, 4, 0, 4));
  }

  public void update() {
    String message = getMessage();
    myTextLabel.setVisible(message != null);
    myTextLabel.setText(StringUtil.notNullize(message));
  }

  public void setBusy(boolean busy) {
    if (busy) {
      myBusySpinner.setVisible(true);
      myBusySpinner.resume();
    }
    else {
      myBusySpinner.setVisible(false);
      myBusySpinner.suspend();
    }
  }

  @Nullable
  protected String getMessage() {
    int count = getChangesCount();
    if (count == -1) return null;
    return DiffBundle.message("diff.count.differences.status.text", count);
  }

  protected int getChangesCount() {
    return -1;
  }
}

@@ -732,49 +732,8 @@
 il;%0A
-import com.intellij.ui.IdeBorderFactory;%0A
 impo
@@ -812,24 +812,95 @@
 rocessIcon;%0A
+import com.intellij.util.ui.GridBag;%0Aimport com.intellij.util.ui.JBUI;%0A
 import org.j
@@ -1135,22 +1135,23 @@
 per(new 
-Border
+GridBag
 Layout()
@@ -1332,87 +1332,180 @@
     
-add(myTextLabel, BorderLayout.CENTER);%0A    add(myBusySpinner, BorderLayout.WEST
+GridBag bag = new GridBag().setDefaultInsets(JBUI.insets(0, 2)).setDefaultFill(GridBagConstraints.BOTH);%0A    add(myBusySpinner, bag.next());%0A    add(myTextLabel, bag.next()
 );%0A 
@@ -1521,53 +1521,31 @@
 der(
-Ide
+JBUI.
 Border
-Factory.createEmptyBorder(0, 4, 0, 4
+s.empty(0, 2
 ));%0A

add more space between status text and spinner