package org.helioviewer.plugins.eveplugin.view.linedataselector.cellrenderer;

import java.awt.Color;
import java.awt.Component;

import javax.swing.JPanel;
import javax.swing.JProgressBar;
import javax.swing.JTable;
import javax.swing.table.DefaultTableCellRenderer;

import org.helioviewer.plugins.eveplugin.view.linedataselector.LineDataSelectorElement;
import org.helioviewer.plugins.eveplugin.view.linedataselector.LineDateSelectorTablePanel;

public class LoadingCellRenderer extends DefaultTableCellRenderer {

    private final JProgressBar downloadProgressBar = new JProgressBar();

    @Override
    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
        LineDataSelectorElement element = (LineDataSelectorElement) value;
        if (element.isDownloading()) {
            downloadProgressBar.setIndeterminate(true);
            downloadProgressBar.setVisible(element.isDownloading());
            downloadProgressBar.setBorder(LineDateSelectorTablePanel.commonBorder);
            return downloadProgressBar;
        } else {
            JPanel p = new JPanel();
            p.setBorder(LineDateSelectorTablePanel.commonBorder);
            p.setBackground(Color.WHITE);
            return p;
        }
    }

}

@@ -76,31 +76,8 @@
 r;%0A%0A
-import java.awt.Color;%0A
 impo
@@ -120,19 +120,19 @@
 .swing.J
-Pan
+Lab
 el;%0Aimpo
@@ -1031,32 +1031,82 @@
 .commonBorder);%0A
+            downloadProgressBar.setOpaque(false);%0A
             retu
@@ -1163,29 +1163,110 @@
    J
-Pan
+Lab
 el p = 
-new JPanel(
+(JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column
 );%0A 
@@ -1351,30 +1351,15 @@
 .set
-Background(Color.WHITE
+Text(%22%22
 );%0A 

Fix loading panel not selected