package com.intellij.uiDesigner.propertyInspector;

import com.intellij.openapi.diagnostic.Logger;
import com.intellij.uiDesigner.ErrorInfo;
import com.intellij.uiDesigner.designSurface.GuiEditor;
import com.intellij.uiDesigner.quickFixes.QuickFixManager;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import java.awt.*;

/**
 * @author Anton Katilin
 * @author Vladimir Kondratyev
 */
final class QuickFixManagerImpl extends QuickFixManager <PropertyInspectorTable>{
  private static final Logger LOG = Logger.getInstance("#com.intellij.propertyInspector.QuickFixManagerImpl");

  public QuickFixManagerImpl(final GuiEditor editor, final PropertyInspectorTable propertyInspectorTable) {
    super(editor, propertyInspectorTable);
    propertyInspectorTable.getSelectionModel().addListSelectionListener(new MyListSelectionListener());
  }

  @Nullable
  public Rectangle getErrorBounds() {
    final int selectedRow = myComponent.getSelectedRow();
    if(selectedRow < 0 || selectedRow >= myComponent.getRowCount()){
      return null;
    }

    final Rectangle rowRect = myComponent.getCellRect(selectedRow, 0, true);
    LOG.assertTrue(rowRect != null);
    final Rectangle visibleRect = myComponent.getVisibleRect();
    if(visibleRect.intersects(rowRect)){
      return visibleRect.intersection(rowRect);
    }
    else{
      return null;
    }
  }

  @NotNull
  public ErrorInfo[] getErrorInfos() {
    final int selectedRow = myComponent.getSelectedRow();
    if(selectedRow < 0 || selectedRow >= myComponent.getRowCount()){
      return ErrorInfo.EMPTY_ARRAY;
    }
    return new ErrorInfo[] { myComponent.getErrorInfoForRow(selectedRow) };
  }

  private final class MyListSelectionListener implements ListSelectionListener{
    public void valueChanged(final ListSelectionEvent e) {
      hideIntentionHint();
      updateIntentionHintVisibility();
    }
  }
}

@@ -1709,18 +1709,13 @@
     
-return new
+final
  Err
@@ -1724,12 +1724,15 @@
 Info
-%5B%5D %7B
+ info =
  myC
@@ -1771,18 +1771,119 @@
 ctedRow)
- %7D
+;%0A    if (info != null) %7B%0A      return new ErrorInfo%5B%5D %7B info %7D;%0A    %7D%0A    return ErrorInfo.EMPTY_ARRAY
 ;%0A  %7D%0A%0A 

fix exception