org-netbeans-swing-tabcontrol

16:40:22.840 INFO  jd.cli.Main - Decompiling org-netbeans-swing-tabcontrol.jar
package com.sun.java.swing;

import java.awt.Graphics2D;

public abstract interface Painter<T>
{
  public abstract void paint(Graphics2D paramGraphics2D, T paramT, int paramInt1, int paramInt2);
}

/* Location:
 * Qualified Name:     com.sun.java.swing.Painter
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package javax.swing;

import java.awt.Graphics2D;

public abstract interface Painter<T>
{
  public abstract void paint(Graphics2D paramGraphics2D, T paramT, int paramInt1, int paramInt2);
}

/* Location:
 * Qualified Name:     javax.swing.Painter
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.swing.popupswitcher;

class SwitcherTable$1 {}

/* Location:
 * Qualified Name:     org.netbeans.swing.popupswitcher.SwitcherTable.1
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.swing.popupswitcher;

import java.awt.Component;
import java.awt.Graphics;
import javax.swing.Icon;

class SwitcherTable$NullIcon
  implements Icon
{
  public int getIconWidth()
  {
    return 0;
  }
  
  public int getIconHeight()
  {
    return 0;
  }
  
  public void paintIcon(Component paramComponent, Graphics paramGraphics, int paramInt1, int paramInt2) {}
}

/* Location:
 * Qualified Name:     org.netbeans.swing.popupswitcher.SwitcherTable.NullIcon
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.swing.popupswitcher;

import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.image.BufferedImage;
import java.lang.ref.SoftReference;
import javax.swing.BorderFactory;
import javax.swing.Icon;
import javax.swing.JTable;
import javax.swing.ListSelectionModel;
import javax.swing.UIManager;
import javax.swing.border.Border;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumn;
import javax.swing.table.TableColumnModel;
import org.openide.util.Utilities;

public class SwitcherTable
  extends JTable
{
  private static final Border rendererBorder = BorderFactory.createEmptyBorder(2, 5, 0, 5);
  private Icon nullIcon = new NullIcon(null);
  private Color foreground;
  private Color background;
  private Color selForeground;
  private Color selBackground;
  private Dimension prefSize;
  private boolean needCalcRowHeight = true;
  
  public SwitcherTable(SwitcherTableItem[] paramArrayOfSwitcherTableItem)
  {
    this(paramArrayOfSwitcherTableItem, 0);
  }
  
  public SwitcherTable(SwitcherTableItem[] paramArrayOfSwitcherTableItem, int paramInt)
  {
    init();
    
    int i = paramInt == 0 ? 10 : 5;
    int j = getUsableScreenBoundsheight - paramInt - i;
    setModel(new SwitcherTableModel(paramArrayOfSwitcherTableItem, getRowHeight(), j));
    getSelectionModel().clearSelection();
    getSelectionModel().setAnchorSelectionIndex(-1);
    getSelectionModel().setLeadSelectionIndex(-1);
    setAutoscrolls(false);
  }
  
  private void init()
  {
    setBorder(BorderFactory.createLineBorder(getForeground()));
    setShowHorizontalLines(false);
    
    calcRowHeight(getOffscreenGraphics());
  }
  
  public void updateUI()
  {
    needCalcRowHeight = true;
    super.updateUI();
  }
  
  public void setFont(Font paramFont)
  {
    needCalcRowHeight = true;
    super.setFont(paramFont);
  }
  
  private static final boolean TABNAMES_HTML = Boolean.parseBoolean(System.getProperty("nb.tabnames.html", "true"));
  
  public Component prepareRenderer(TableCellRenderer paramTableCellRenderer, int paramInt1, int paramInt2)
  {
    SwitcherTableItem localSwitcherTableItem = (SwitcherTableItem)getSwitcherTableModel().getValueAt(paramInt1, paramInt2);
    
    boolean bool1 = (paramInt1 == getSelectedRow()) && (paramInt2 == getSelectedColumn()) && (localSwitcherTableItem != null);
    
    DefaultTableCellRenderer localDefaultTableCellRenderer = (DefaultTableCellRenderer)paramTableCellRenderer.getTableCellRendererComponent(this, localSwitcherTableItem, bool1, bool1, paramInt1, paramInt2);
    if (localSwitcherTableItem == null)
    {
      localDefaultTableCellRenderer.setOpaque(false);
      localDefaultTableCellRenderer.setIcon(null);
      return localDefaultTableCellRenderer;
    }
    Icon localIcon = localSwitcherTableItem.getIcon();
    if (localIcon == null) {
      localIcon = nullIcon;
    }
    boolean bool2 = localSwitcherTableItem.isActive();
    localDefaultTableCellRenderer.setText(((bool1) || (bool2)) && (!TABNAMES_HTML) ? stripHtml(localSwitcherTableItem.getHtmlName()) : localSwitcherTableItem.getHtmlName());
    localDefaultTableCellRenderer.setIcon(localIcon);
    localDefaultTableCellRenderer.setBorder(rendererBorder);
    localDefaultTableCellRenderer.setIconTextGap(26 - localIcon.getIconWidth());
    if (bool2) {
      if (TABNAMES_HTML) {
        localDefaultTableCellRenderer.setText(localDefaultTableCellRenderer.getText() + " ?");
      } else if (Utilities.isWindows()) {
        localDefaultTableCellRenderer.setFont(getFont().deriveFont(1, getFont().getSize()));
      } else {
        localDefaultTableCellRenderer.setFont(new Font(getFont().getName(), 1, getFont().getSize()));
      }
    }
    localDefaultTableCellRenderer.setOpaque(true);
    
    return localDefaultTableCellRenderer;
  }
  
  private String stripHtml(String paramString)
  {
    if (null == paramString) {
      return null;
    }
    String str = paramString.replaceAll("<[^>]*>", "");
    str = str.replaceAll("&nbsp;", " ");
    str = str.trim();
    return str;
  }
  
  private static class NullIcon
    implements Icon
  {
    public int getIconWidth()
    {
      return 0;
    }
    
    public int getIconHeight()
    {
      return 0;
    }
    
    public void paintIcon(Component paramComponent, Graphics paramGraphics, int paramInt1, int paramInt2) {}
  }
  
  public Color getForeground()
  {
    if (foreground == null) {
      foreground = UIManager.getColor("ComboBox.foreground");
    }
    return foreground != null ? foreground : super.getForeground();
  }
  
  public Color getBackground()
  {
    if (background == null) {
      background = UIManager.getColor("ComboBox.background");
    }
    return background != null ? background : super.getBackground();
  }
  
  public Color getSelectionForeground()
  {
    if (selForeground == null) {
      selForeground = UIManager.getColor("ComboBox.selectionForeground");
    }
    return selForeground != null ? selForeground : super.getSelectionForeground();
  }
  
  public Color getSelectionBackground()
  {
    if (selBackground == null) {
      selBackground = UIManager.getColor("ComboBox.selectionBackground");
    }
    return selBackground != null ? selBackground : super.getSelectionBackground();
  }
  
  private void calcRowHeight(Graphics paramGraphics)
  {
    Font localFont = getFont();
    FontMetrics localFontMetrics = paramGraphics.getFontMetrics(localFont);
    
    int i = Math.max(localFontMetrics.getHeight(), 16) + 4;
    needCalcRowHeight = false;
    setRowHeight(i);
  }
  
  private static SoftReference<BufferedImage> ctx = null;
  
  private static Graphics2D getOffscreenGraphics()
  {
    BufferedImage localBufferedImage = null;
    if (ctx != null) {
      localBufferedImage = (BufferedImage)ctx.get();
    }
    if (localBufferedImage == null)
    {
      localBufferedImage = new BufferedImage(10, 10, 1);
      ctx = new SoftReference(localBufferedImage);
    }
    return (Graphics2D)localBufferedImage.getGraphics();
  }
  
  public Dimension getPreferredSize()
  {
    if (prefSize == null)
    {
      int i = getColumnCount();
      int j = getRowCount();
      
      int k = 0;
      for (int m = 0; m < i; m++) {
        for (int n = 0; n < j; n++)
        {
          TableCellRenderer localTableCellRenderer = getCellRenderer(n, m);
          Component localComponent = prepareRenderer(localTableCellRenderer, n, m);
          
          k = Math.max(getPreferredSizewidth + 1, k);
        }
      }
      k = Math.min(k, 250);
      for (m = 0; m < i; m++) {
        getColumnModel().getColumn(m).setPreferredWidth(k);
      }
      prefSize = new Dimension(k * i, j * getRowHeight());
    }
    return prefSize;
  }
  
  private SwitcherTableModel getSwitcherTableModel()
  {
    return (SwitcherTableModel)getModel();
  }
  
  public SwitcherTableItem getSelectedItem()
  {
    return (SwitcherTableItem)getValueAt(getSelectedRow(), getSelectedColumn());
  }
  
  public void paint(Graphics paramGraphics)
  {
    if (needCalcRowHeight) {
      calcRowHeight(paramGraphics);
    }
    super.paint(paramGraphics);
  }
  
  public int getLastValidRow()
  {
    int i = getColumnCount() - 1;
    for (int j = getRowCount() - 1; j >= 0; j--) {
      if (getValueAt(j, i) != null) {
        return j;
      }
    }
    return -1;
  }
}

/* Location:
 * Qualified Name:     org.netbeans.swing.popupswitcher.SwitcherTable
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.swing.popupswitcher;

public abstract interface SwitcherTableItem$Activatable
{
  public abstract void activate();
}

/* Location:
 * Qualified Name:     org.netbeans.swing.popupswitcher.SwitcherTableItem.Activatable
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.swing.popupswitcher;

import javax.swing.Icon;

public class SwitcherTableItem
  implements Comparable
{
  private String name;
  private String htmlName;
  private String description;
  private Icon icon;
  private boolean active;
  private Activatable activatable;
  
  public SwitcherTableItem(Activatable paramActivatable, String paramString)
  {
    this(paramActivatable, paramString, null);
  }
  
  public SwitcherTableItem(Activatable paramActivatable, String paramString, Icon paramIcon)
  {
    this(paramActivatable, paramString, paramString, paramIcon, false);
  }
  
  public SwitcherTableItem(Activatable paramActivatable, String paramString1, String paramString2, Icon paramIcon, boolean paramBoolean)
  {
    this(paramActivatable, paramString1, paramString2, paramIcon, paramBoolean, null);
  }
  
  public SwitcherTableItem(Activatable paramActivatable, String paramString1, String paramString2, Icon paramIcon, boolean paramBoolean, String paramString3)
  {
    activatable = paramActivatable;
    name = paramString1;
    htmlName = paramString2;
    icon = paramIcon;
    active = paramBoolean;
    description = paramString3;
  }
  
  public void activate()
  {
    activatable.activate();
  }
  
  public String getName()
  {
    return name;
  }
  
  public String getHtmlName()
  {
    return htmlName;
  }
  
  public String getDescription()
  {
    return description;
  }
  
  public Icon getIcon()
  {
    return icon;
  }
  
  public Activatable getActivatable()
  {
    return activatable;
  }
  
  public boolean isActive()
  {
    return active;
  }
  
  public String toString()
  {
    return super.toString() + "[name=" + name + ", icon=" + icon + "]";
  }
  
  public boolean equals(Object paramObject)
  {
    if (paramObject == this) {
      return true;
    }
    if ((paramObject instanceof SwitcherTableItem))
    {
      SwitcherTableItem localSwitcherTableItem = (SwitcherTableItem)paramObject;
      boolean bool = (localSwitcherTableItem.getName().equals(name)) && (localSwitcherTableItem.getActivatable().equals(activatable));
      
      return bool;
    }
    return false;
  }
  
  public int hashCode()
  {
    return (name == null ? 1 : name.hashCode()) * activatable.hashCode();
  }
  
  public int compareTo(Object paramObject)
  {
    String str1 = getName();
    String str2 = null;
    if ((paramObject instanceof SwitcherTableItem)) {
      str2 = ((SwitcherTableItem)paramObject).getName();
    }
    if (str2 == null) {
      return str1 == null ? 0 : -1;
    }
    return str1 == null ? 1 : str1.compareToIgnoreCase(str2);
  }
  
  public static abstract interface Activatable
  {
    public abstract void activate();
  }
}

/* Location:
 * Qualified Name:     org.netbeans.swing.popupswitcher.SwitcherTableItem
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.swing.popupswitcher;

import java.awt.Rectangle;
import javax.swing.event.TableModelEvent;
import javax.swing.table.AbstractTableModel;
import org.openide.util.Utilities;

class SwitcherTableModel
  extends AbstractTableModel
{
  private TableModelEvent event;
  private int rows;
  private int cols;
  private SwitcherTableItem[] items;
  
  SwitcherTableModel(SwitcherTableItem[] paramArrayOfSwitcherTableItem, int paramInt)
  {
    this(paramArrayOfSwitcherTableItem, paramInt, getUsableScreenBoundsheight);
  }
  
  SwitcherTableModel(SwitcherTableItem[] paramArrayOfSwitcherTableItem, int paramInt1, int paramInt2)
  {
    items = paramArrayOfSwitcherTableItem;
    computeRowsAndCols(paramInt1, paramInt2);
  }
  
  private void computeRowsAndCols(int paramInt1, int paramInt2)
  {
    int i = items.length;
    if (i > 0)
    {
      int j = paramInt2 / paramInt1;
      int k = i / j;
      if (i % j > 0) {
        k++;
      }
      int m = i / k;
      if (i % k > 0) {
        m++;
      }
      setRowsAndColumns(m, k);
    }
    else
    {
      setRowsAndColumns(0, 0);
    }
  }
  
  private void setRowsAndColumns(int paramInt1, int paramInt2)
  {
    if ((rows != paramInt1) || (cols != paramInt2))
    {
      rows = paramInt1;
      cols = paramInt2;
      if (event == null) {
        event = new TableModelEvent(this);
      }
      fireTableChanged(event);
    }
  }
  
  public Class getColumnClass(int paramInt)
  {
    return SwitcherTableItem.class;
  }
  
  public String getColumnName(int paramInt)
  {
    return "";
  }
  
  public boolean isCellEditable(int paramInt1, int paramInt2)
  {
    return true;
  }
  
  public Object getValueAt(int paramInt1, int paramInt2)
  {
    if ((paramInt1 == -1) || (paramInt2 == -1)) {
      return null;
    }
    int i = paramInt2 * getRowCount() + paramInt1;
    return i < items.length ? items[i] : null;
  }
  
  public int getRowCount()
  {
    return rows;
  }
  
  public int getColumnCount()
  {
    return cols;
  }
}

/* Location:
 * Qualified Name:     org.netbeans.swing.popupswitcher.SwitcherTableModel
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.swing.tabcontrol;

import javax.swing.Popup;

class ButtonPopupSwitcher$PopupHider
  implements Runnable
{
  private Popup toHide;
  
  public ButtonPopupSwitcher$PopupHider(ButtonPopupSwitcher paramButtonPopupSwitcher, Popup paramPopup)
  {
    toHide = paramPopup;
  }
  
  public void run()
  {
    toHide.hide();
    toHide = null;
  }
}

/* Location:
 * Qualified Name:     org.netbeans.swing.tabcontrol.ButtonPopupSwitcher.PopupHider
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.swing.tabcontrol;

import java.awt.AWTEvent;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Point;
import java.awt.Toolkit;
import java.awt.event.AWTEventListener;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import javax.swing.JComponent;
import javax.swing.Popup;
import javax.swing.PopupFactory;
import javax.swing.SwingUtilities;
import javax.swing.event.MouseInputListener;
import org.netbeans.swing.popupswitcher.SwitcherTable;
import org.netbeans.swing.popupswitcher.SwitcherTableItem;

final class ButtonPopupSwitcher
  implements MouseInputListener, AWTEventListener
{
  private static Popup popup;
  private Component invokingComponent = null;
  private long invocationTime = -1L;
  private static boolean shown;
  private static ButtonPopupSwitcher currentSwitcher;
  private SwitcherTable pTable;
  private int x;
  private int y;
  private boolean isDragging = true;
  
  public static void selectItem(JComponent paramJComponent, SwitcherTableItem[] paramArrayOfSwitcherTableItem, int paramInt1, int paramInt2)
  {
    ButtonPopupSwitcher localButtonPopupSwitcher = new ButtonPopupSwitcher(paramArrayOfSwitcherTableItem, paramInt1, paramInt2);
    
    localButtonPopupSwitcher.doSelect(paramJComponent);
    currentSwitcher = localButtonPopupSwitcher;
  }
  
  private ButtonPopupSwitcher(SwitcherTableItem[] paramArrayOfSwitcherTableItem, int paramInt1, int paramInt2)
  {
    pTable = new SwitcherTable(paramArrayOfSwitcherTableItem, paramInt2);
    x = (paramInt1 - (int)pTable.getPreferredSize().getWidth());
    y = (paramInt2 + 1);
  }
  
  private void doSelect(JComponent paramJComponent)
  {
    invokingComponent = paramJComponent;
    invokingComponent.addMouseListener(this);
    invokingComponent.addMouseMotionListener(this);
    pTable.addMouseListener(this);
    pTable.addMouseMotionListener(this);
    
    Toolkit.getDefaultToolkit().addAWTEventListener(this, 24L);
    
    popup = PopupFactory.getSharedInstance().getPopup(invokingComponent, pTable, x, y);
    
    popup.show();
    shown = true;
    invocationTime = System.currentTimeMillis();
  }
  
  public static boolean isShown()
  {
    return shown;
  }
  
  static void hidePopup()
  {
    if (isShown()) {
      currentSwitcher.hideCurrentPopup();
    }
  }
  
  private synchronized void hideCurrentPopup()
  {
    pTable.removeMouseListener(this);
    pTable.removeMouseMotionListener(this);
    Toolkit.getDefaultToolkit().removeAWTEventListener(this);
    if (invokingComponent != null)
    {
      invokingComponent.removeMouseListener(this);
      invokingComponent.removeMouseMotionListener(this);
      invokingComponent = null;
    }
    if (popup != null)
    {
      SwingUtilities.invokeLater(new PopupHider(popup));
      popup = null;
      shown = false;
      currentSwitcher = null;
    }
  }
  
  private class PopupHider
    implements Runnable
  {
    private Popup toHide;
    
    public PopupHider(Popup paramPopup)
    {
      toHide = paramPopup;
    }
    
    public void run()
    {
      toHide.hide();
      toHide = null;
    }
  }
  
  public void mouseMoved(MouseEvent paramMouseEvent)
  {
    paramMouseEvent.consume();
    changeSelection(paramMouseEvent);
    isDragging = false;
  }
  
  public void mousePressed(MouseEvent paramMouseEvent)
  {
    paramMouseEvent.consume();
  }
  
  public void mouseReleased(MouseEvent paramMouseEvent)
  {
    if (paramMouseEvent.getSource() == invokingComponent)
    {
      long l = System.currentTimeMillis();
      if ((l - invocationTime > 500L) && (isDragging)) {
        mouseClicked(paramMouseEvent);
      }
    }
    isDragging = false;
    paramMouseEvent.consume();
  }
  
  public void mouseClicked(MouseEvent paramMouseEvent)
  {
    Point localPoint = paramMouseEvent.getPoint();
    localPoint = SwingUtilities.convertPoint((Component)paramMouseEvent.getSource(), localPoint, pTable);
    if (pTable.contains(localPoint))
    {
      SwitcherTableItem localSwitcherTableItem = pTable.getSelectedItem();
      if (localSwitcherTableItem != null)
      {
        localSwitcherTableItem.activate();
        hideCurrentPopup();
      }
    }
    isDragging = false;
    paramMouseEvent.consume();
  }
  
  public void mouseEntered(MouseEvent paramMouseEvent)
  {
    mouseDragged(paramMouseEvent);
    paramMouseEvent.consume();
  }
  
  public void mouseExited(MouseEvent paramMouseEvent)
  {
    pTable.clearSelection();
    paramMouseEvent.consume();
  }
  
  public void mouseDragged(MouseEvent paramMouseEvent)
  {
    changeSelection(paramMouseEvent);
    paramMouseEvent.consume();
  }
  
  private void changeSelection(MouseEvent paramMouseEvent)
  {
    Point localPoint = paramMouseEvent.getPoint();
    if (paramMouseEvent.getSource() != this) {
      localPoint = SwingUtilities.convertPoint((Component)paramMouseEvent.getSource(), localPoint, pTable);
    }
    if (pTable.contains(localPoint))
    {
      int i = pTable.rowAtPoint(localPoint);
      int j = pTable.columnAtPoint(localPoint);
      pTable.changeSelection(i, j, false, false);
    }
    else
    {
      pTable.clearSelection();
    }
  }
  
  private boolean onSwitcherTable(MouseEvent paramMouseEvent)
  {
    Point localPoint = paramMouseEvent.getPoint();
    if (!(paramMouseEvent.getSource() instanceof Component)) {
      return false;
    }
    localPoint = SwingUtilities.convertPoint((Component)paramMouseEvent.getSource(), localPoint, pTable);
    return pTable.contains(localPoint);
  }
  
  public void eventDispatched(AWTEvent paramAWTEvent)
  {
    if (paramAWTEvent.getSource() == this) {
      return;
    }
    if ((paramAWTEvent instanceof MouseEvent))
    {
      if (paramAWTEvent.getID() == 502)
      {
        long l = System.currentTimeMillis();
        if ((l - invocationTime > 500L) && 
          (!onSwitcherTable((MouseEvent)paramAWTEvent)) && (paramAWTEvent.getSource() != invokingComponent)) {
          hideCurrentPopup();
        }
      }
      else if ((paramAWTEvent.getID() == 501) && 
        (!onSwitcherTable((MouseEvent)paramAWTEvent)))
      {
        if (paramAWTEvent.getSource() != invokingComponent) {
          hideCurrentPopup();
        }
      }
    }
    else if (((paramAWTEvent instanceof KeyEvent)) && 
      (paramAWTEvent.getID() == 401))
    {
      Toolkit.getDefaultToolkit().removeAWTEventListener(this);
      hideCurrentPopup();
    }
  }
}

/* Location:
 * Qualified Name:     org.netbeans.swing.tabcontrol.ButtonPopupSwitcher
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.swing.tabcontrol;

import java.awt.Component;

final class ComponentConverter$1
  implements ComponentConverter
{
  public Component getComponent(TabData paramTabData)
  {
    return paramTabData.getComponent();
  }
}

/* Location:
 * Qualified Name:     org.netbeans.swing.tabcontrol.ComponentConverter.1
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.swing.tabcontrol;

import java.awt.Component;

public final class ComponentConverter$Fixed
  implements ComponentConverter
{
  private final Component component;
  
  public ComponentConverter$Fixed(Component paramComponent)
  {
    component = paramComponent;
  }
  
  public Component getComponent(TabData paramTabData)
  {
    return component;
  }
}

/* Location:
 * Qualified Name:     org.netbeans.swing.tabcontrol.ComponentConverter.Fixed
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.swing.tabcontrol;

import java.awt.Component;

public abstract interface ComponentConverter
{
  public static final ComponentConverter DEFAULT = new ComponentConverter()
  {
    public Component getComponent(TabData paramAnonymousTabData)
    {
      return paramAnonymousTabData.getComponent();
    }
  };
  
  public abstract Component getComponent(TabData paramTabData);
  
  public static final class Fixed
    implements ComponentConverter
  {
    private final Component component;
    
    public Fixed(Component paramComponent)
    {
      component = paramComponent;
    }
    
    public Component getComponent(TabData paramTabData)
    {
      return component;
    }
  }
}

/* Location:
 * Qualified Name:     org.netbeans.swing.tabcontrol.ComponentConverter
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.swing.tabcontrol;

class DefaultTabDataModel$1 {}

/* Location:
 * Qualified Name:     org.netbeans.swing.tabcontrol.DefaultTabDataModel.1
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.swing.tabcontrol;

import java.util.ArrayList;

class DefaultTabDataModel$L
  extends ArrayList<TabData>
{
  private DefaultTabDataModel$L(DefaultTabDataModel paramDefaultTabDataModel) {}
  
  public void removeRange(int paramInt1, int paramInt2)
  {
    super.removeRange(paramInt1, paramInt2);
  }
}

/* Location:
 * Qualified Name:     org.netbeans.swing.tabcontrol.DefaultTabDataModel.L
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.swing.tabcontrol;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.swing.Icon;
import javax.swing.event.ChangeListener;
import javax.swing.event.ListDataEvent;
import org.netbeans.swing.tabcontrol.event.ComplexListDataEvent;
import org.netbeans.swing.tabcontrol.event.ComplexListDataListener;
import org.netbeans.swing.tabcontrol.event.VeryComplexListDataEvent;
import org.openide.util.ChangeSupport;

public class DefaultTabDataModel
  implements TabDataModel
{
  private transient ArrayList<ComplexListDataListener> listenerList;
  public DefaultTabDataModel() {}
  
  private class L
    extends ArrayList<TabData>
  {
    private L() {}
    
    public void removeRange(int paramInt1, int paramInt2)
    {
      super.removeRange(paramInt1, paramInt2);
    }
  }
  
  private L list = new L(null);
  private final ChangeSupport cs = new ChangeSupport(this);
  
  public DefaultTabDataModel(TabData[] paramArrayOfTabData)
  {
    list.addAll(Arrays.asList(paramArrayOfTabData));
  }
  
  public List<TabData> getTabs()
  {
    return Collections.unmodifiableList(list);
  }
  
  public TabData getTab(int paramInt)
  {
    return (TabData)list.get(paramInt);
  }
  
  public void setTabs(TabData[] paramArrayOfTabData)
  {
    TabData[] arrayOfTabData = new TabData[list.size()];
    arrayOfTabData = (TabData[])list.toArray(arrayOfTabData);
    if (Arrays.equals(paramArrayOfTabData, arrayOfTabData)) {
      return;
    }
    List localList = Arrays.asList(paramArrayOfTabData);
    
    list.clear();
    list.addAll(Arrays.asList(paramArrayOfTabData));
    
    VeryComplexListDataEvent localVeryComplexListDataEvent = new VeryComplexListDataEvent(this, arrayOfTabData, paramArrayOfTabData);
    
    fireIndicesChanged(localVeryComplexListDataEvent);
  }
  
  public void setIcon(int paramInt, Icon paramIcon)
  {
    boolean[] arrayOfBoolean = { false };
    
    boolean bool = _setIcon(paramInt, paramIcon, arrayOfBoolean);
    if (bool)
    {
      ComplexListDataEvent localComplexListDataEvent = new ComplexListDataEvent(this, 0, paramInt, paramInt, arrayOfBoolean[0]);
      
      fireContentsChanged(localComplexListDataEvent);
    }
  }
  
  private boolean _setIcon(int paramInt, Icon paramIcon, boolean[] paramArrayOfBoolean)
  {
    if (paramIcon == null) {
      paramIcon = TabData.NO_ICON;
    }
    TabData localTabData = getTab(paramInt);
    if (paramIcon != localTabData.getIcon())
    {
      paramArrayOfBoolean[0] = (localTabData.getIcon().getIconWidth() != paramIcon.getIconWidth() ? 1 : false);
      
      icon = paramIcon;
      return true;
    }
    return false;
  }
  
  public void setText(int paramInt, String paramString)
  {
    boolean[] arrayOfBoolean = { false };
    boolean bool = _setText(paramInt, paramString, arrayOfBoolean);
    if (bool)
    {
      ComplexListDataEvent localComplexListDataEvent = new ComplexListDataEvent(this, 0, paramInt, paramInt, arrayOfBoolean[0]);
      
      fireContentsChanged(localComplexListDataEvent);
    }
  }
  
  private int[] _setText(int[] paramArrayOfInt, String[] paramArrayOfString, boolean[] paramArrayOfBoolean)
  {
    paramArrayOfBoolean[0] = false;
    boolean bool = false;
    boolean[] arrayOfBoolean1 = new boolean[paramArrayOfInt.length];
    int i = 0;
    Arrays.fill(arrayOfBoolean1, false);
    for (int j = 0; j < paramArrayOfInt.length; j++)
    {
      boolean[] arrayOfBoolean2 = { false };
      bool |= _setText(paramArrayOfInt[j], paramArrayOfString[j], arrayOfBoolean2);
      
      paramArrayOfBoolean[0] |= arrayOfBoolean2[0];
      if (arrayOfBoolean2[0] != 0) {
        i++;
      }
      arrayOfBoolean1[j] = arrayOfBoolean2[0];
    }
    if ((paramArrayOfBoolean[0] != 0) || (bool))
    {
      int[] arrayOfInt;
      if (i == paramArrayOfInt.length)
      {
        arrayOfInt = paramArrayOfInt;
      }
      else
      {
        arrayOfInt = new int[i];
        int k = 0;
        for (int m = 0; m < paramArrayOfInt.length; m++) {
          if (arrayOfBoolean1[m] != 0)
          {
            arrayOfInt[k] = paramArrayOfInt[m];
            k++;
          }
        }
      }
      return arrayOfInt;
    }
    return null;
  }
  
  private int[] _setIcon(int[] paramArrayOfInt, Icon[] paramArrayOfIcon, boolean[] paramArrayOfBoolean)
  {
    paramArrayOfBoolean[0] = false;
    boolean bool1 = false;
    boolean[] arrayOfBoolean1 = new boolean[paramArrayOfInt.length];
    int i = 0;
    Arrays.fill(arrayOfBoolean1, false);
    boolean[] arrayOfBoolean2 = { false };
    boolean bool2 = false;
    for (int j = 0; j < paramArrayOfInt.length; j++)
    {
      bool2 = _setIcon(paramArrayOfInt[j], paramArrayOfIcon[j], arrayOfBoolean2);
      
      bool1 |= bool2;
      paramArrayOfBoolean[0] |= arrayOfBoolean2[0];
      if (bool2) {
        i++;
      }
      arrayOfBoolean1[j] = bool2;
    }
    if ((paramArrayOfBoolean[0] != 0) || (bool1))
    {
      int[] arrayOfInt;
      if (i == paramArrayOfInt.length)
      {
        arrayOfInt = paramArrayOfInt;
      }
      else
      {
        arrayOfInt = new int[i];
        int k = 0;
        for (int m = 0; m < paramArrayOfInt.length; m++) {
          if (arrayOfBoolean1[m] != 0)
          {
            arrayOfInt[k] = paramArrayOfInt[m];
            k++;
          }
        }
      }
      return arrayOfInt;
    }
    return null;
  }
  
  public void setIconsAndText(int[] paramArrayOfInt, String[] paramArrayOfString, Icon[] paramArrayOfIcon)
  {
    boolean[] arrayOfBoolean1 = { false };
    boolean[] arrayOfBoolean2 = { false };
    int[] arrayOfInt1 = _setIcon(paramArrayOfInt, paramArrayOfIcon, arrayOfBoolean1);
    int[] arrayOfInt2 = _setText(paramArrayOfInt, paramArrayOfString, arrayOfBoolean2);
    boolean bool = (arrayOfBoolean1[0] != 0) || (arrayOfBoolean2[0] != 0);
    int i = (bool) || (arrayOfInt1 != null) || (arrayOfInt2 != null) ? 1 : 0;
    if (i != 0) {
      if ((paramArrayOfInt == arrayOfInt1) && (paramArrayOfInt == arrayOfInt2))
      {
        ComplexListDataEvent localComplexListDataEvent1 = new ComplexListDataEvent(this, 0, paramArrayOfInt, bool);
        
        fireContentsChanged(localComplexListDataEvent1);
      }
      else
      {
        int j = (arrayOfInt1 != null ? arrayOfInt1.length : 0) + (arrayOfInt2 != null ? arrayOfInt2.length : 0);
        
        HashSet localHashSet = new HashSet(j);
        Integer[] arrayOfInteger1;
        if (arrayOfInt1 != null)
        {
          arrayOfInteger1 = toObjectArray(arrayOfInt1);
          localHashSet.addAll(Arrays.asList(arrayOfInteger1));
        }
        if (arrayOfInt2 != null)
        {
          arrayOfInteger1 = toObjectArray(arrayOfInt2);
          localHashSet.addAll(Arrays.asList(arrayOfInteger1));
        }
        Integer[] arrayOfInteger2 = new Integer[localHashSet.size()];
        arrayOfInteger2 = (Integer[])localHashSet.toArray(arrayOfInteger2);
        int[] arrayOfInt3 = toPrimitiveArray(arrayOfInteger2);
        ComplexListDataEvent localComplexListDataEvent2 = new ComplexListDataEvent(this, 0, arrayOfInt3, bool);
        
        fireContentsChanged(localComplexListDataEvent2);
      }
    }
  }
  
  public void setIcon(int[] paramArrayOfInt, Icon[] paramArrayOfIcon)
  {
    boolean[] arrayOfBoolean = { false };
    int[] arrayOfInt = _setIcon(paramArrayOfInt, paramArrayOfIcon, arrayOfBoolean);
    if (arrayOfInt != null)
    {
      ComplexListDataEvent localComplexListDataEvent = new ComplexListDataEvent(this, 0, arrayOfInt, arrayOfBoolean[0]);
      
      fireContentsChanged(localComplexListDataEvent);
    }
  }
  
  public void setText(int[] paramArrayOfInt, String[] paramArrayOfString)
  {
    boolean[] arrayOfBoolean = { false };
    int[] arrayOfInt = _setText(paramArrayOfInt, paramArrayOfString, arrayOfBoolean);
    if (arrayOfInt != null)
    {
      ComplexListDataEvent localComplexListDataEvent = new ComplexListDataEvent(this, 0, arrayOfInt, arrayOfBoolean[0]);
      
      fireContentsChanged(localComplexListDataEvent);
    }
  }
  
  private boolean _setText(int paramInt, String paramString, boolean[] paramArrayOfBoolean)
  {
    TabData localTabData = getTab(paramInt);
    if (paramString != txt)
    {
      paramArrayOfBoolean[0] = (localTabData.getText() != paramString ? 1 : false);
      txt = paramString;
      return true;
    }
    return false;
  }
  
  public void setTab(int paramInt, TabData paramTabData)
  {
    if (!paramTabData.equals(getTab(paramInt)))
    {
      TabData localTabData = getTab(paramInt);
      boolean bool1 = paramTabData.getText().equals(localTabData.getText());
      boolean bool2 = paramTabData.getUserObject() != localTabData.getUserObject();
      list.set(paramInt, paramTabData);
      ComplexListDataEvent localComplexListDataEvent = new ComplexListDataEvent(this, 0, paramInt, paramInt, bool1, bool2);
      
      localComplexListDataEvent.setAffectedItems(new TabData[] { paramTabData });
      fireContentsChanged(localComplexListDataEvent);
    }
  }
  
  public void addTab(int paramInt, TabData paramTabData)
  {
    list.add(paramInt, paramTabData);
    ComplexListDataEvent localComplexListDataEvent = new ComplexListDataEvent(this, 1, paramInt, paramInt, true);
    
    localComplexListDataEvent.setAffectedItems(new TabData[] { paramTabData });
    fireIntervalAdded(localComplexListDataEvent);
  }
  
  public void addTabs(int paramInt, TabData[] paramArrayOfTabData)
  {
    list.addAll(paramInt, Arrays.asList(paramArrayOfTabData));
    ComplexListDataEvent localComplexListDataEvent = new ComplexListDataEvent(this, 1, paramInt, paramInt + paramArrayOfTabData.length - 1, true);
    
    localComplexListDataEvent.setAffectedItems(paramArrayOfTabData);
    fireIntervalAdded(localComplexListDataEvent);
  }
  
  public void removeTab(int paramInt)
  {
    TabData[] arrayOfTabData = { (TabData)list.get(paramInt) };
    list.remove(paramInt);
    ComplexListDataEvent localComplexListDataEvent = new ComplexListDataEvent(this, 2, paramInt, paramInt);
    
    localComplexListDataEvent.setAffectedItems(arrayOfTabData);
    fireIntervalRemoved(localComplexListDataEvent);
  }
  
  public void removeTabs(int paramInt1, int paramInt2)
  {
    List localList = list.subList(paramInt1, paramInt2);
    if (paramInt1 == paramInt2) {
      list.remove(paramInt1);
    } else {
      list.removeRange(paramInt1, paramInt2 + 1);
    }
    ComplexListDataEvent localComplexListDataEvent = new ComplexListDataEvent(this, 2, paramInt1, paramInt2);
    
    localComplexListDataEvent.setAffectedItems((TabData[])list.toArray(new TabData[0]));
    fireIntervalRemoved(localComplexListDataEvent);
  }
  
  public void addTabs(int[] paramArrayOfInt, TabData[] paramArrayOfTabData)
  {
    HashMap localHashMap = new HashMap(paramArrayOfTabData.length);
    for (int i = 0; i < paramArrayOfTabData.length; i++) {
      localHashMap.put(new Integer(paramArrayOfInt[i]), paramArrayOfTabData[i]);
    }
    Arrays.sort(paramArrayOfInt);
    for (i = 0; i < paramArrayOfInt.length; i++)
    {
      Integer localInteger = new Integer(paramArrayOfInt[i]);
      TabData localTabData = (TabData)localHashMap.get(localInteger);
      list.add(paramArrayOfInt[i], localTabData);
    }
    ComplexListDataEvent localComplexListDataEvent = new ComplexListDataEvent(this, 3, paramArrayOfInt, true);
    
    localComplexListDataEvent.setAffectedItems(paramArrayOfTabData);
    fireIndicesAdded(localComplexListDataEvent);
  }
  
  public void removeTabs(int[] paramArrayOfInt)
  {
    Arrays.sort(paramArrayOfInt);
    TabData[] arrayOfTabData = new TabData[paramArrayOfInt.length];
    for (int i = paramArrayOfInt.length - 1; i >= 0; i--) {
      arrayOfTabData[i] = ((TabData)list.remove(paramArrayOfInt[i]));
    }
    ComplexListDataEvent localComplexListDataEvent = new ComplexListDataEvent(this, 4, paramArrayOfInt, true);
    
    localComplexListDataEvent.setAffectedItems(arrayOfTabData);
    fireIndicesRemoved(localComplexListDataEvent);
  }
  
  public int size()
  {
    return list.size();
  }
  
  public synchronized void addComplexListDataListener(ComplexListDataListener paramComplexListDataListener)
  {
    if (listenerList == null) {
      listenerList = new ArrayList();
    }
    listenerList.add(paramComplexListDataListener);
  }
  
  public synchronized void removeComplexListDataListener(ComplexListDataListener paramComplexListDataListener)
  {
    listenerList.remove(paramComplexListDataListener);
  }
  
  private void fireIntervalAdded(ListDataEvent paramListDataEvent)
  {
    if (listenerList == null) {
      return;
    }
    int i = listenerList.size();
    for (int j = 0; j < i; j++)
    {
      ComplexListDataListener localComplexListDataListener = (ComplexListDataListener)listenerList.get(j);
      
      localComplexListDataListener.intervalAdded(paramListDataEvent);
    }
    cs.fireChange();
  }
  
  private void fireIntervalRemoved(ListDataEvent paramListDataEvent)
  {
    if (listenerList == null) {
      return;
    }
    int i = listenerList.size();
    for (int j = 0; j < i; j++)
    {
      ComplexListDataListener localComplexListDataListener = (ComplexListDataListener)listenerList.get(j);
      
      localComplexListDataListener.intervalRemoved(paramListDataEvent);
    }
    cs.fireChange();
  }
  
  private void fireContentsChanged(ListDataEvent paramListDataEvent)
  {
    if (listenerList == null) {
      return;
    }
    int i = listenerList.size();
    for (int j = 0; j < i; j++)
    {
      ComplexListDataListener localComplexListDataListener = (ComplexListDataListener)listenerList.get(j);
      
      localComplexListDataListener.contentsChanged(paramListDataEvent);
    }
    cs.fireChange();
  }
  
  private void fireIndicesAdded(ComplexListDataEvent paramComplexListDataEvent)
  {
    if (listenerList == null) {
      return;
    }
    int i = listenerList.size();
    for (int j = 0; j < i; j++)
    {
      ComplexListDataListener localComplexListDataListener = (ComplexListDataListener)listenerList.get(j);
      
      localComplexListDataListener.indicesAdded(paramComplexListDataEvent);
    }
    cs.fireChange();
  }
  
  private void fireIndicesRemoved(ComplexListDataEvent paramComplexListDataEvent)
  {
    if (listenerList == null) {
      return;
    }
    int i = listenerList.size();
    for (int j = 0; j < i; j++)
    {
      ComplexListDataListener localComplexListDataListener = (ComplexListDataListener)listenerList.get(j);
      
      localComplexListDataListener.indicesRemoved(paramComplexListDataEvent);
    }
    cs.fireChange();
  }
  
  private void fireIndicesChanged(ComplexListDataEvent paramComplexListDataEvent)
  {
    if (listenerList == null) {
      return;
    }
    int i = listenerList.size();
    for (int j = 0; j < i; j++)
    {
      ComplexListDataListener localComplexListDataListener = (ComplexListDataListener)listenerList.get(j);
      
      localComplexListDataListener.indicesChanged(paramComplexListDataEvent);
    }
    cs.fireChange();
  }
  
  public String toString()
  {
    StringBuffer localStringBuffer = new StringBuffer(getClass().getName());
    localStringBuffer.append(" size =");
    int i = size();
    localStringBuffer.append(i);
    localStringBuffer.append(" - ");
    for (int j = 0; j < i; j++)
    {
      TabData localTabData = getTab(j);
      localStringBuffer.append(localTabData.toString());
      if (j != i - 1) {
        localStringBuffer.append(',');
      }
    }
    return localStringBuffer.toString();
  }
  
  public void addChangeListener(ChangeListener paramChangeListener)
  {
    cs.addChangeListener(paramChangeListener);
  }
  
  public void removeChangeListener(ChangeListener paramChangeListener)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd