package org.helioviewer.jhv.plugin.renderable;

import java.awt.Component;

import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.table.DefaultTableCellRenderer;

import org.helioviewer.jhv.gui.IconBank;
import org.helioviewer.jhv.gui.IconBank.JHVIcon;

public class RenderableRemoveCellRenderer extends DefaultTableCellRenderer {

    @Override
    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
        JLabel label = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
        Renderable renderable = (Renderable) value;
        if (renderable.isDeletable())
            label.setIcon(IconBank.getIcon(JHVIcon.REMOVE_LAYER));
        else {
            label.setIcon(IconBank.getIcon(JHVIcon.REMOVE_LAYER_GRAY));
        }
        label.setBorder(RenderableContainerPanel.commonRightBorder);
        label.setText("");
        label.setToolTipText("Click to remove");

        return label;

    }
}

@@ -705,17 +705,19 @@
 table())
+ %7B
 %0A
-
         
@@ -782,16 +782,71 @@
 %0A       
+     label.setToolTipText(%22Click to remove%22);%0A        %7D
  else %7B%0A
@@ -913,24 +913,79 @@
 YER_GRAY));%0A
+            label.setToolTipText(%22Cannot be removed%22);%0A
         %7D%0A  
@@ -1051,16 +1051,16 @@
 order);%0A
+
         
@@ -1081,57 +1081,8 @@
 %22%22);
-%0A        label.setToolTipText(%22Click to remove%22);
 %0A%0A  

add tooltip