org.eclipse.jst.jsf.facesconfig.ui_1.2.2.v201103292152

   if (active) {
        g.setBackgroundColor(pane == null ? ColorConstants.white : 
          pane.getBackgroundColor());
      } else {
        g.setBackgroundColor(this$0.getBackgroundColor());
      }
      w--;
      g.setForegroundColor(active ? ColorConstants.buttonDarkest : 
        ColorConstants.buttonDarker);
      
      g.drawRectangle(x, y + h / 2, w, h);
      
      g.fillRoundRectangle(new Rectangle(x, y, w, h), radius, radius);
      
      g.drawRoundRectangle(new Rectangle(x, y, w, h), radius, radius);
      
      g.fillRectangle(x + 1, y + h / 2, w - 1, h);
    }
    else
    {
      g.setBackgroundColor(this$0.getBackgroundColor());
    }
    g.setFont(this$0.getFont());
    g.setForegroundColor(this$0.getTextColor());
    if (label != null) {
      g.drawString(label, x + access$0this$0).left + 1, y + access$0this$0).top);
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.facesconfig.ui.preference.TabbedTitleBarBorder.Tab
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.jsf.facesconfig.ui.preference;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.eclipse.core.runtime.ListenerList;
import org.eclipse.draw2d.ColorConstants;
import org.eclipse.draw2d.FigureUtilities;
import org.eclipse.draw2d.Graphics;
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.MouseEvent;
import org.eclipse.draw2d.MouseListener;
import org.eclipse.draw2d.SchemeBorder;
import org.eclipse.draw2d.SchemeBorder.SCHEMES;
import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.draw2d.geometry.Insets;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.jface.resource.FontRegistry;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.widgets.Composite;

class TabbedTitleBarBorder
  extends SchemeBorder
{
  private IFigure parent;
  private ListenerList listenerList;
  private List tabList;
  private int currentTab;
  private Font font;
  private boolean visible = true;
  private Color textColor = ColorConstants.black;
  private Color bgColor = ColorConstants.menuBackground;
  private Insets insets;
  private Insets padding = new Insets(2, 2, 2, 2);
  
  public TabbedTitleBarBorder(final IFigure parent)
  {
    super(SchemeBorder.SCHEMES.LOWERED);
    
    this.parent = parent;
    
    parent.addMouseListener(new MouseListener()
    {
      public void mousePressed(MouseEvent me)
      {
        Insets padding_ = getPadding();
        Point mp = me.getLocation();
        x -= left;
        y -= top + 3;
        Point pp = parent.getBounds().getLocation();
        Rectangle tr = new Rectangle(x, y, 0, 0);
        for (int i = 0; i < getTabList().size(); i++)
        {
          TabbedTitleBarBorder.Tab t = (TabbedTitleBarBorder.Tab)tabList.get(i);
          Dimension d = t.getTextExtents();
          height += top + bottom;
          width += left;
          tr.setSize(d);
          if (tr.contains(mp))
          {
            setCurrentTab(i);
            return;
          }
          x += width;
        }
      }
      
      public void mouseReleased(MouseEvent me) {}
      
      public void mouseDoubleClicked(MouseEvent me) {}
    });
  }
  
  protected List getTabList()
  {
    if (tabList == null) {
      tabList = new ArrayList();
    }
    return tabList;
  }
  
  public int addTab(String text)
  {
    getTabList().add(new Tab(text));
    return getTabList().size() - 1;
  }
  
  public void removeTab(int index)
  {
    if ((index >= 0) && (index < getTabList().size()))
    {
      tabList.remove(index);
      if (index >= tabList.size()) {
        index = tabList.size() - 1;
      }
      setCurrentTab(index);
    }
  }
  
  public void setCurrentTab(int newIndex)
  {
    if ((newIndex >= 0) && (newIndex < getTabList().size()))
    {
      Tab newTab = (Tab)tabList.get(newIndex);
      int oldIndex = -1;
      for (int i = 0; i < tabList.size(); i++)
      {
        Tab t = (Tab)tabList.get(i);
        if (t.isActive())
        {
          oldIndex = i;
          t.setActive(false);
          break;
        }
      }
      newTab.setActive(true);
      if (parent != null)
      {
        parent.invalidate();
        parent.repaint();
      }
      currentTab = newIndex;
      fireTabChanged(oldIndex, newIndex);
    }
  }
  
  public int getCurrentTab()
  {
    return currentTab;
  }
  
  public Object getContents(int index)
  {
    if ((index >= 0) && (index < getTabList().size())) {
      return ((Tab)tabList.get(index)).getContents();
    }
    return null;
  }
  
  public void setContents(int index, Object contents)
  {
    if ((index >= 0) && (index < getTabList().size())) {
      ((Tab)tabList.get(index)).setContents(contents);
    }
  }
  
  public void addTabbedWindowListener(WindowFigureListener listener)
  {
    if (listenerList == null) {
      listenerList = new ListenerList(1);
    }
    listenerList.add(listener);
  }
  
  public void removeTabbedWindowListener(WindowFigureListener listener)
  {
    if (listenerList != null) {
      listenerList.remove(listener);
    }
  }
  
  public Object[] getListeners()
  {
    return listenerList.getListeners();
  }
  
  protected void fireTabChanged(int oldIndex, int newIndex)
  {
    Object[] l = listenerList.getListeners();
    for (int i = 0; i < l.length; i++) {
      if ((l[i] instanceof WindowFigureListener)) {
        ((WindowFigureListener)l[i]).tabChanged(oldIndex, newIndex);
      }
    }
  }
  
  public Font getFont()
  {
    if (font == null)
    {
      font = parent.getFont();
      if (font == null) {
        font = JFaceResources.getFontRegistry().get(
          "org.eclipse.jface.defaultfont");
      }
    }
    return font;
  }
  
  public void setFont(Font font)
  {
    this.font = font;
    invalidate();
  }
  
  public Insets getInsets()
  {
    return insets;
  }
  
  public void setTextColor(Color c)
  {
    textColor = c;
  }
  
  public Color getTextColor()
  {
    return textColor;
  }
  
  public void setBackgroundColor(Color c)
  {
    bgColor = c;
  }
  
  public Color getBackgroundColor()
  {
    return bgColor;
  }
  
  public void setPadding(Insets p)
  {
    padding = p;
    invalidate();
  }
  
  public Insets getPadding()
  {
    return padding;
  }
  
  public void setLabel(String text)
  {
    setLabel(currentTab, text);
  }
  
  public void setLabel(int index, String text)
  {
    if ((index >= 0) && (index < getTabList().size())) {
      ((Tab)tabList.get(index)).setLabel(text);
    }
  }
  
  public String getLabel()
  {
    return getLabel(currentTab);
  }
  
  public String getLabel(int index)
  {
    if ((index >= 0) && (index < getTabList().size())) {
      return ((Tab)tabList.get(index)).getLabel();
    }
    return "";
  }
  
  public IFigure getParent()
  {
    return parent;
  }
  
  public void invalidate()
  {
    insets = null;
    for (int i = 0; i < getTabList().size(); i++)
    {
      Tab t = (Tab)tabList.get(i);
      t.invalidate();
    }
  }
  
  public Dimension getTextExtents(IFigure f)
  {
    Dimension d = new Dimension(0, 0);
    for (int i = 0; i < getTabList().size(); i++)
    {
      Tab t = (Tab)tabList.get(i);
      if (height == 0) {
        d = t.getTextExtents();
      } else {
        width += getTextExtentswidth;
      }
    }
    return d;
  }
  
  public void setVisible(boolean flag)
  {
    visible = flag;
  }
  
  protected Insets calculateInsets(IFigure figure)
  {
    insets = new Insets(super.getInsets(figure));
    insets.top = getTextExtentsheight;
    return insets;
  }
  
  public Insets getInsets(IFigure figure)
  {
    if (insets == null) {
      calculateInsets(figure);
    }
    return insets;
  }
  
  public void paint(IFigure figure, Graphics g, Insets in)
  {
    if (!visible) {
      return;
    }
    Insets is = new Insets(in);
    getInsets(figure);
    top += insets.top;
    super.paint(figure, g, is);
    
    tempRect.setBounds(getPaintRectangle(figure, in));
    Rectangle r = tempRect;
    height = Math.min(height, getTextExtentsheight);
    
    g.clipRect(r);
    g.setBackgroundColor(getBackgroundColor());
    g.fillRectangle(r);
    int x = x;
    int y = y;
    
    Iterator iter = getTabList().iterator();
    while (iter.hasNext())
    {
      Tab t = (Tab)iter.next();
      t.paint(g, figure, x, y);
      x += getTextExtentswidth;
    }
    g.setBackgroundColor(getBackgroundColor());
  }
  
  public Dimension getMinimumSize(int wHint, int hHint)
  {
    Dimension d = getTextExtents(parent);
    getInsets(parent);
    d.expand(insets.left + insets.right, insets.top + insets.bottom);
    
    return d;
  }
  
  private class Tab
  {
    private String label = "";
    private Object contents = null;
    private Dimension textExtents;
    private boolean active;
    
    public Tab(String text)
    {
      label = text;
    }
    
    public void setContents(Object contents)
    {
      this.contents = contents;
    }
    
    public Object getContents()
    {
      return contents;
    }
    
    public void setActive(boolean active)
    {
      this.active = active;
    }
    
    public boolean isActive()
    {
      return active;
    }
    
    public String getLabel()
    {
      return label;
    }
    
    public void setLabel(String text)
    {
      if (text == null) {
        label = "";
      } else {
        label = text;
      }
      textExtents = null;
    }
    
    public Dimension calculateTextExtents()
    {
      textExtents = FigureUtilities.getTextExtents(label == null ? "W" : 
        label, getFont());
      textExtents.width += getPadding().getWidth();
      textExtents.height += getPadding().getHeight();
      return textExtents;
    }
    
    public Dimension getTextExtents()
    {
      if (textExtents == null) {
        calculateTextExtents();
      }
      return textExtents.getCopy();
    }
    
    public void invalidate()
    {
      textExtents = null;
    }
    
    public void paint(Graphics g, IFigure f, int x, int y)
    {
      if ((contents instanceof Composite)) {
        return;
      }
      IFigure pane = (IFigure)contents;
      getTextExtents();
      
      Insets p = getPadding();
      int w = textExtents.width;
      int h = textExtents.height;
      int radius = Math.max(p.getWidth(), p.getHeight()) + 2;
      if (getTabList().size() > 1)
      {
        if (active) {
          g.setBackgroundColor(pane == null ? ColorConstants.white : 
            pane.getBackgroundColor());
        } else {
          g.setBackgroundColor(getBackgroundColor());
        }
        w--;
        g.setForegroundColor(active ? ColorConstants.buttonDarkest : 
          ColorConstants.buttonDarker);
        
        g.drawRectangle(x, y + h / 2, w, h);
        
        g.fillRoundRectangle(new Rectangle(x, y, w, h), radius, radius);
        
        g.drawRoundRectangle(new Rectangle(x, y, w, h), radius, radius);
        
        g.fillRectangle(x + 1, y + h / 2, w - 1, h);
      }
      else
      {
        g.setBackgroundColor(getBackgroundColor());
      }
      g.setFont(getFont());
      g.setForegroundColor(getTextColor());
      if (label != null) {
        g.drawString(label, x + padding.left + 1, y + padding.top);
      }
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.facesconfig.ui.preference.TabbedTitleBarBorder
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.jsf.facesconfig.ui.preference;

import org.eclipse.draw2d.SchemeBorder.Scheme;
import org.eclipse.swt.graphics.Color;

class TabbedWindowBorder$MySchemeBorder$MyScheme
  extends SchemeBorder.Scheme
{
  public TabbedWindowBorder$MySchemeBorder$MyScheme(Color[] highlight, Color[] shadow)
  {
    super(highlight, shadow);
  }
  
  public Color[] getHighlight()
  {
    return super.getHighlight();
  }
  
  public Color[] getShadow()
  {
    return super.getHighlight();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.facesconfig.ui.preference.TabbedWindowBorder.MySchemeBorder.MyScheme
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.jsf.facesconfig.ui.preference;

import org.eclipse.draw2d.ColorConstants;
import org.eclipse.draw2d.SchemeBorder;
import org.eclipse.draw2d.SchemeBorder.Scheme;
import org.eclipse.draw2d.geometry.Insets;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Composite;

class TabbedWindowBorder$MySchemeBorder
  extends SchemeBorder
{
  private static class MyScheme
    extends SchemeBorder.Scheme
  {
    public MyScheme(Color[] highlight, Color[] shadow)
    {
      super(shadow);
    }
    
    public Color[] getHighlight()
    {
      return super.getHighlight();
    }
    
    public Color[] getShadow()
    {
      return super.getHighlight();
    }
  }
  
  TabbedWindowBorder$MySchemeBorder(MyScheme scheme)
  {
    super(scheme);
  }
  
  public MyScheme getMyScheme()
  {
    return (MyScheme)super.getScheme();
  }
  
  public void paint(Composite comp, GC gc, Insets insets)
  {
    Color[] tl = getMyScheme().getHighlight();
    Color[] br = getMyScheme().getShadow();
    paint(comp, gc, insets, tl, br);
  }
  
  protected void paint(Composite comp, GC gc, Insets insets, Color[] tl, Color[] br)
  {
    Rectangle rect = comp.getBounds();
    
    gc.setLineWidth(1);
    gc.setLineStyle(1);
    
    int top = y - top;
    int left = x - left;
    int bottom = y + height + bottom;
    int right = x + width + right;
    gc.setClipping(new Rectangle(left, top, 
      right - left, bottom - top));
    
    Color color = ColorConstants.red;
    gc.setForeground(color);
    gc.drawLine(left, top, right, bottom);
    for (int i = 0; i < br.length; i++)
    {
      gc.setForeground(color);
      gc.drawLine(right - i, bottom - i, right - i, top + i);
      gc.drawLine(right - i, bottom - i, left + i, bottom - i);
    }
    right--;
    bottom--;
    for (int i = 0; i < tl.length; i++)
    {
      gc.setForeground(color);
      gc.drawLine(left + i, top + i, right - i, top + i);
      gc.drawLine(left + i, top + i, left + i, bottom - i);
    }
    color.dispose();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.facesconfig.ui.preference.TabbedWindowBorder.MySchemeBorder
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.jsf.facesconfig.ui.preference;

import org.eclipse.draw2d.ColorConstants;
import org.eclipse.draw2d.FigureUtilities;
import org.eclipse.draw2d.FrameBorder;
import org.eclipse.draw2d.Graphics;
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.SchemeBorder;
import org.eclipse.draw2d.SchemeBorder.Scheme;
import org.eclipse.draw2d.geometry.Insets;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Composite;

final class TabbedWindowBorder
  extends FrameBorder
{
  private boolean isVisible = true;
  private static MySchemeBorder normalBorder = new MySchemeBorder(
    new TabbedWindowBorder.MySchemeBorder.MyScheme(
    new Color[] { ColorConstants.button, ColorConstants.buttonLightest, 
    ColorConstants.button }, 
    new Color[] { ColorConstants.buttonDarkest, ColorConstants.buttonDarker, 
    ColorConstants.button }));
  private static MySchemeBorder highlightBorder = new MySchemeBorder(
    new TabbedWindowBorder.MySchemeBorder.MyScheme(
    new Color[] { FigureUtilities.lighter(ColorConstants.titleBackground), 
    ColorConstants.titleBackground, 
    FigureUtilities.darker(ColorConstants.titleBackground) }, 
    
    new Color[] {
    
    FigureUtilities.darker(ColorConstants.titleGradient), 
    ColorConstants.titleGradient, 
    
    FigureUtilities.lighter(ColorConstants.titleGradient) }));
  private Composite comp;
  
  private static class MySchemeBorder
    extends SchemeBorder
  {
    private static class MyScheme
      extends SchemeBorder.Scheme
    {
      public MyScheme(Color[] highlight, Color[] shadow)
      {
        super(shadow);
      }
      
      public Color[] getHighlight()
      {
        return super.getHighlight();
      }
      
      public Color[] getShadow()
      {
        return super.getHighlight();
      }
    }
    
    MySchemeBorder(MyScheme scheme)
    {
      super();
    }
    
    public MyScheme getMyScheme()
    {
      return (MyScheme)super.getScheme();
    }
    
    public void paint(Composite comp, GC gc, Insets insets)
    {
      Color[] tl = getMyScheme().getHighlight();
      Color[] br = getMyScheme().getShadow();
      paint(comp, gc, insets, tl, br);
    }
    
    protected void paint(Composite comp, GC gc, Insets insets, Color[] tl, Color[] br)
    {
      Rectangle rect = comp.getBounds();
      
      gc.setLineWidth(1);
      gc.setLineStyle(1);
      
      int top = y - top;
      int left = x - left;
      int bottom = y + height + bottom;
      int right = x + width + right;
      gc.setClipping(new Rectangle(left, top, 
        right - left, bottom - top));
      
      Color color = ColorConstants.red;
      gc.setForeground(color);
      gc.drawLine(left, top, right, bottom);
      for (int i = 0; i < br.length; i++)
      {
        gc.setForeground(color);
        gc.drawLine(right - i, bottom - i, right - i, top + i);
        gc.drawLine(right - i, bottom - i, left + i, bottom - i);
      }
      right--;
      bottom--;
      for (int i = 0; i < tl.length; i++)
      {
        gc.setForeground(color);
        gc.drawLine(left + i, top + i, right - i, top + i);
        gc.drawLine(left + i, top + i, left + i, bottom - i);
      }
      color.dispose();
    }
  }
  
  public TabbedWindowBorder(IFigure parent)
  {
    inner = new TabbedTitleBarBorder(parent);
    outer = normalBorder;
  }
  
  public void setVisible(boolean flag)
  {
    if (isVisible != flag)
    {
      isVisible = flag;
      ((TabbedTitleBarBorder)inner).setVisible(flag);
      if (flag) {
        ((TabbedTitleBarBorder)inner).getParent().repaint();
      }
    }
  }
  
  public void setHighlight(boolean flag)
  {
    if (flag) {
      outer = highlightBorder;
    } else {
      outer = normalBorder;
    }
    ((TabbedTitleBarBorder)inner).getParent().repaint();
  }
  
  protected void createBorders() {}
  
  public void paint(IFigure figure, Graphics g, Insets insets)
  {
    if (isVisible) {
      if (comp != null)
      {
        GC gc = new GC(comp);
        paint(comp, gc, insets);
        gc.dispose();
      }
      else
      {
        super.paint(figure, g, insets);
      }
    }
  }
  
  public void paint(Composite comp_, GC gc, Insets insets)
  {
    comp = comp_;
    if (isVisible) {
      ((MySchemeBorder)outer).paint(comp_, gc, insets);
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.facesconfig.ui.preference.TabbedWindowBorder
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.jsf.facesconfig.ui.preference;

import org.eclipse.draw2d.ActionEvent;
import org.eclipse.draw2d.ActionListener;

class TitleBarButton$1
  implements ActionListener
{
  TitleBarButton$1(TitleBarButton paramTitleBarButton) {}
  
  public void actionPerformed(ActionEvent event)
  {
    this$0.setState(!TitleBarButton.access$0(this$0));
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.facesconfig.ui.preference.TitleBarButton.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.jsf.facesconfig.ui.preference;

import org.eclipse.draw2d.MouseEvent;
import org.eclipse.draw2d.MouseMotionListener;

class TitleBarButton$2
  implements MouseMotionListener
{
  TitleBarButton$2(TitleBarButton paramTitleBarButton) {}
  
  public void mouseDragged(MouseEvent me) {}
  
  public void mouseEntered(MouseEvent me)
  {
    TitleBarButton.access$1(this$0, true);
    this$0.repaint();
  }
  
  public void mouseExited(MouseEvent me)
  {
    TitleBarButton.access$1(this$0, false);
    this$0.repaint();
  }
  
  public void mouseHover(MouseEvent me) {}
  
  public void mouseMoved(MouseEvent me) {}
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.facesconfig.ui.preference.TitleBarButton.2
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.jsf.facesconfig.ui.preference;

import java.util.Iterator;
import org.eclipse.draw2d.ActionEvent;
import org.eclipse.draw2d.ActionListener;
import org.eclipse.draw2d.Button;
import org.eclipse.draw2d.ColorConstants;
import org.eclipse.draw2d.Cursors;
import org.eclipse.draw2d.Graphics;
import org.eclipse.draw2d.MouseEvent;
import org.eclipse.draw2d.MouseMotionListener;
import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.jface.resource.FontRegistry;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.swt.graphics.Image;

final class TitleBarButton
  extends Button
{
  private boolean state = false;
  private Image uncheckedImage;
  private Image checkedImage;
  private Image uncheckedHiliteImage;
  private Image checkedHiliteImage;
  private RectangleList uncheckedRects;
  private RectangleList checkedRects;
  private boolean hilite = false;
  
  public TitleBarButton(Image unchecked, Image uncheckedHilite, Image checked, Image checkedHilite)
  {
    uncheckedImage = unchecked;
    if (uncheckedHilite == null) {
      uncheckedHiliteImage = unchecked;
    } else {
      uncheckedHiliteImage = uncheckedHilite;
    }
    if (checked == null) {
      checkedImage = unchecked;
    } else {
      checkedImage = checked;
    }
    if (checkedHilite == null) {
      checkedHiliteImage = unchecked;
    } else {
      checkedHiliteImage = checkedHilite;
    }
    initialize();
  }
  
  public TitleBarButton(RectangleList rects)
  {
    uncheckedRects = rects;
    initialize();
  }
  
  public TitleBarButton(RectangleList unchecked, RectangleList checked)
  {
    uncheckedRects = unchecked;
    checkedRects = checked;
    initialize();
  }
  
  public boolean getState()
  {
    return state;
  }
  
  public void setState(boolean newState)
  {
    state = newState;
    hilite = false;
  }
  
  private void initialize()
  {
    setRequestFocusEnabled(true);
    setFocusTraversable(true);
    if (uncheckedImage != null)
    {
      org.eclipse.swt.graphics.Rectangle r = uncheckedImage.getBounds();
      setBounds(new org.eclipse.draw2d.geometry.Rectangle(0, 0, width, height));
      prefSize = new Dimension(width, height);
    }
    else
    {
      setForegroundColor(ColorConstants.black);
      setBackgroundColor(ColorConstants.white);
      calculatePreferredSize();
      setBounds(new org.eclipse.draw2d.geometry.Rectangle(0, 0, prefSize.width, prefSize.height));
    }
    setCursor(Cursors.ARROW);
    setBorder(null);
    setFont(JFaceResources.getFontRegistry().get(
      "org.eclipse.jface.defaultfont"));
    
    addActionListener(new ActionListener()
    {
      public void actionPerformed(ActionEvent event)
      {
        setState(!state);
      }
    });
    addMouseMotionListener(new MouseMotionListener()
    {
      public void mouseDragged(MouseEvent me) {}
      
      public void mouseEntered(MouseEvent me)
      {
        hilite = true;
        repaint();
      }
      
      public void mouseExited(MouseEvent me)
      {
        hilite = false;
        repaint();
      }
      
      public void mouseHover(MouseEvent me) {}
      
      public void mouseMoved(MouseEvent me) {}
    });
  }
  
  public Dimension calculatePreferredSize()
  {
    if (prefSize == null)
    {
      org.eclipse.draw2d.geometry.Rectangle rect = new org.eclipse.draw2d.geometry.Rectangle(0, 0, 0, 0);
      if (uncheckedRects != null)
      {
        Iterator<org.eclipse.draw2d.geometry.Rectangle> iter = uncheckedRects.iterator();
        while (iter.hasNext())
        {
          getLocation();
          org.eclipse.draw2d.geometry.Rectangle r = ((org.eclipse.draw2d.geometry.Rectangle)iter.next()).getCopy();
          rect = rect.getUnion(r);
        }
      }
      if (checkedRects != null)
      {
        Iterator<org.eclipse.draw2d.geometry.Rectangle> iter = checkedRects.iterator();
        while (iter.hasNext())
        {
          getLocation();
          org.eclipse.draw2d.geometry.Rectangle r = ((org.eclipse.draw2d.geometry.Rectangle)iter.next()).getCopy();
          rect = rect.getUnion(r);
        }
      }
      prefSize = rect.getSize();
      if (prefSize.width > prefSize.height) {
        prefSize.height = prefSize.width;
      } else if (prefSize.height > prefSize.width) {
        prefSize.width = prefSize.height;
      }
      prefSize.width += 4;
      prefSize.height += 4;
    }
    return prefSize;
  }
  
  public void paint(Graphics graphics)
  {
    if (!isVisible()) {
      return;
    }
    if (uncheckedImage != null)
    {
      if (hilite)
      {
        if (!state) {
          graphics.drawImage(uncheckedHiliteImage, getLocation());
        } else {
          graphics.drawImage(checkedHiliteImage, getLocation());
        }
      }
      else if (!state) {
        graphics.drawImage(uncheckedImage, getLocation());
      } else {
        graphics.drawImage(checkedImage, getLocation());
      }
    }
    else
    {
      Iterator<org.eclipse.draw2d.geometry.Rectangle> iter = null;
      if (!state) {
        iter = uncheckedRects.iterator();
      } else {
        iter = checkedRects.iterator();
      }
      while (iter.hasNext())
      {
        Point p = getLocation();
        org.eclipse.draw2d.geometry.Rectangle r = ((org.eclipse.draw2d.geometry.Rectangle)iter.next()).getCopy();
        r = r.translate(x, y);
        graphics.setForegroundColor(getForegroundColor());
        if (hilite) {
          graphics.setBackgroundColor(ColorConstants.lightBlue);
        } else {
          graphics.setBackgroundColor(ColorConstants.white);
        }
        graphics.fillRectangle(r);
        graphics.drawRectangle(r);
      }
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.facesconfig.ui.preference.TitleBarButton
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.jsf.facesconfig.ui.preference;

class WindowFigure$1
  implements WindowFigureListener
{
  WindowFigure$1(WindowFigure paramWindowFigure) {}
  
  public void tabChanged(int oldIndex, int newIndex)
  {
    WindowFigure.access$0(this$0, newIndex);
    this$0.validate();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.facesconfig.ui.preference.WindowFigure.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.jsf.facesconfig.ui.preference;

import org.eclipse.draw2d.AncestorListener;
import org.eclipse.draw2d.IFigure;

class WindowFigure$2
  implements AncestorListener
{
  WindowFigure$2(WindowFigure paramWindowFigure) {}
  
  public void ancestorAdded(IFigure ancestor)
  {
    this$0.setVisible(true);
  }
  
  public void ancestorMoved(IFigure ancestor) {}
  
  public void ancestorRemoved(IFigure ancestor)
  {
    this$0.setVisible(false);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.facesconfig.ui.preference.WindowFigure.2
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.jsf.facesconfig.ui.preference;

import org.eclipse.draw2d.FreeformLayer;

class WindowFigure$MyFeedbackLayer
  extends FreeformLayer
{
  WindowFigure$MyFeedbackLayer(WindowFigure paramWindowFigure)
  {
    setEnabled(false);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.facesconfig.ui.preference.WindowFigure.MyFeedbackLayer
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.jsf.facesconfig.ui.preference;

import org.eclipse.gef.editparts.GridLayer;

class WindowFigure$MyGridLayer
  extends GridLayer
{
  private WindowFigure$MyGridLayer(WindowFigure paramWindowFigure) {}
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.facesconfig.ui.preference.WindowFigure.MyGridLayer
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.jsf.facesconfig.ui.preference;

import java.util.Iterator;
import java.util.List;
import org.eclipse.draw2d.AncestorListener;
import org.eclipse.draw2d.ColorConstants;
import org.eclipse.draw2d.ConnectionLayer;
import org.eclipse.draw2d.FreeformFigure;
import org.eclipse.draw2d.FreeformLayer;
import org.eclipse.draw2d.FreeformLayeredPane;
import org.eclipse.draw2d.FreeformLayout;
import org.eclipse.draw2d.FreeformListener;
import org.eclipse.draw2d.FreeformViewport;
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.Layer;
import org.eclipse.draw2d.LayeredPane;
import org.eclipse.draw2d.LayoutManager;
import org.eclipse.draw2d.RangeModel;
import org.eclipse.draw2d.ScalableFreeformLayeredPane;
import org.eclipse.draw2d.ScrollBar;
import org.eclipse.draw2d.ScrollPane;
import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.draw2d.geometry.Insets;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.gef.LayerConstants;
import org.eclipse.gef.editparts.GridLayer;
import org.eclipse.gef.editparts.GuideLayer;
import org.eclipse.jface.resource.FontRegistry;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Composite;

class WindowFigure
  extends ScrollPane
  implements IContainerFigure, LayerConstants, FreeformFigure
{
  private TabbedWindowBorder windowBorder;
  private TabbedTitleBarBorder titleBarBorder;
  private FreeformViewport myViewport;
  private ScalableFreeformLayeredPane scaledLayers;
  private LayeredPane innerLayers;
  private LayeredPane printableLayers;
  private FreeformLayer primaryLayer;
  private static final Font defaultFont = JFaceResources.getFontRegistry().get(
    "org.eclipse.jface.defaultfont");
  private static final Color defaultForegroundColor = ColorConstants.black;
  private static final Color defaultBackgroundColor = ColorConstants.white;
  private static final Color defaultGridColor = ColorConstants.lightGray;
  private static final Dimension defaultGridSpacing = null;
  private static final boolean defaultGridEnabled = false;
  private static final int LINE_ROUTING_MANUAL = 0;
  private static int defaultLineRoutingStyle = 0;
  
  private class MyFeedbackLayer
    extends FreeformLayer
  {
    MyFeedbackLayer()
    {
      setEnabled(false);
    }
  }
  
  public WindowFigure()
  {
    windowBorder = new TabbedWindowBorder(this);
    titleBarBorder = ((TabbedTitleBarBorder)windowBorder.getInnerBorder());
    setBorder(windowBorder);
    setFont(defaultFont);
    setForegroundColor(defaultForegroundColor);
    setBackgroundColor(defaultBackgroundColor);
    
    innerLayers = new FreeformLayeredPane();
    createLayers(innerLayers);
    
    myViewport = new FreeformViewport();
    myViewport.setContents(innerLayers);
    
    setViewport(myViewport);
    
    getGridLayer().setVisible(false);
    getGridLayer().setSpacing(defaultGridSpacing);
    getGridLayer().setForegroundColor(defaultGridColor);
    
    setText(PreferenceMessages.WindowFigure_Title);
    
    addTabbedWindowListener(new WindowFigureListener()
    {
      public void tabChanged(int oldIndex, int newIndex)
      {
        WindowFigure.this.internalSetCurrentTab(newIndex);
        validate();
      }
    });
    addAncestorListener(new AncestorListener()
    {
      public void ancestorAdded(IFigure ancestor)
      {
        setVisible(true);
      }
      
      public void ancestorMoved(IFigure ancestor) {}
      
      public void ancestorRemoved(IFigure ancestor)
      {
        setVisible(false);
      }
    });
  }
  
  protected void createLayers(LayeredPane layeredPane)
  {
    layeredPane.add(getScaledLayers(), "Scalable Layers");
    layeredPane.add(new FreeformLayer(), "Handle Layer");
    
    layeredPane.add(new GuideLayer(), "Guide Layer");
  }
  
  protected ScalableFreeformLayeredPane createScaledLayers()
  {
    ScalableFreeformLayeredPane layers = new ScalableFreeformLayeredPane();
    layers.add(createGridLayer(), "Grid Layer");
    layers.add(getPrintableLayers(), "Printable Layers");
    
    return layers;
  }
  
  protected LayeredPane getScaledLayers()
  {
    if (scaledLayers == null) {
      scaledLayers = createScaledLayers();
    }
    return scaledLayers;
  }
  
  protected LayeredPane createPrintableLayers()
  {
    FreeformLayeredPane layeredPane = new FreeformLayeredPane();
    
    PrintedPageLayer pageTileLayer = new PrintedPageLayer(this);
    
    pageTileLayer.setPageSize(new Dimension(0, 0));
    layeredPane.add(pageTileLayer, "Printed Page", -1);
    
    layeredPane.add(new ConnectionLayer(), "Connection Layer", -1);
    primaryLayer = new FreeformLayer();
    layeredPane.add(primaryLayer, "Primary Layer", -1);
    primaryLayer.setLayoutManager(new FreeformLayout());
    
    layeredPane.add(new MyFeedbackLayer(), "Feedback Layer");
    return layeredPane;
  }
  
  protected LayeredPane getPrintableLayers()
  {
    if (printableLayers == null) {
      printableLayers = createPrintableLayers();
    }
    return printableLayers;
  }
  
  protected GridLayer createGridLayer()
  {
    return new MyGridLayer(null);
  }
  
  public GridLayer getGridLayer()
  {
    return (GridLayer)getLayer("Grid Layer");
  }
  
  public Layer getLayer(Object key)
  {
    Layer layer = null;
    if (scaledLayers != null) {
      layer = scaledLayers.getLayer(key);
    }
    if (layer != null) {
      return layer;
    }
    if (innerLayers == null) {
      return null;
    }
    layer = innerLayers.getLayer(key);
    if (layer != null) {
      return layer;
    }
    if (printableLayers == null) {
      return null;
    }
    return printableLayers.getLayer(key);
  }
  
  public Point getScrollPosition()
  {
    int x = getHorizontalScrollBar().getRangeModel().getValue();
    int y = getVerticalScrollBar().getRangeModel().getValue();
    return new Point(x, y);
  }
  
  public TabbedTitleBarBorder getTabbedTitleBarBorder()
  {
    return titleBarBorder;
  }
  
  public TabbedWindowBorder getTabbedWindowBorder()
  {
    return windowBorder;
  }
  
  public void addTabbedWindowListener(WindowFigureListener listener)
  {
    titleBarBorder.addTabbedWindowListener(listener);
  }
  
  public void removeTabbedWindowListener(WindowFigureListener listener)
  {
    titleBarBorder.removeTabbedWindowListener(listener);
  }
  
  public Dimension getMinimumSize(int wHint, int hHint)
  {
    Dimension d = titleBarBorder.getMinimumSize(wHint, hHint);
    d.expand(getInsets().getWidth(), getInsets().getHeight());
    return d;
  }
  
  public int addTab(String s)
  {
    return titleBarBorder.addTab(s);
  }
  
  public void removeTab(int index)
  {
    titleBarBorder.removeTab(index);
    internalSetCurrentTab(titleBarBorder.getCurrentTab());
  }
  
  private void internalSetCurrentTab(int index) {}
  
  public void setCurrentTab(int index)
  {
    internalSetCurrentTab(index);
    titleBarBorder.setCurrentTab(index);
  }
  
  public int getCurrentTab()
  {
    return titleBarBorder.getCurrentTab();
  }
  
  public void setContents(IFigure figure)
  {
    titleBarBorder.setContents(0, figure);
    super.setContents(figure);
  }
  
  public void setContents(int index, Object contents)
  {
    if ((contents instanceof IFigure)) {
      setContents((IFigure)contents);
    }
    titleBarBorder.setContents(index, contents);
  }
  
  public Object getContents(int index)
  {
    return titleBarBorder.getContents(index);
  }
  
  public void setVisible(boolean flag)
  {
    super.setVisible(flag);
    windowBorder.setVisible(flag);
    
    Object contents = getContents();
    if ((contents instanceof Composite)) {
      ((Composite)contents).setVisible(flag);
    }
  }
  
  public void setHighlight(boolean flag)
  {
    windowBorder.setHighlight(flag);
  }
  
  public void setFont(Font f)
  {
    titleBarBorder.setFont(f);
  }
  
  public void setForegroundColor(Color c)
  {
    titleBarBorder.setTextColor(c);
  }
  
  public void setLineRoutingStyle(int style)
  {
    defaultLineRoutingStyle = style;
    revalidate();
  }
  
  public int getLineRoutingStyle()
  {
    return defaultLineRoutingStyle;
  }
  
  public Dimension getPreferredSize(int wHint, int hHint)
  {
    if (prefSize == null)
    {
      IFigure parent = getParent();
      prefSize = parent.getSize();
      getLayoutManager().invalidate();
      Dimension m = super.getPreferredSize(wHint, hHint);
      if ((getParent() instanceof CompoundNodeFigure))
      {
        if (((CompoundNodeFigure)parent).getState() == 2)
        {
          Insets in = ((CompoundNodeFigure)getParent())
            .getAnchorInsets();
          prefSize.width -= in.getWidth();
          prefSize.height -= in.getHeight();
        }
      }
      else
      {
        if (width > prefSize.width) {
          prefSize.width = width;
        }
        if (height > prefSize.height) {
          prefSize.height = height;
        }
      }
    }
    return prefSize;
  }
  
  protected boolean isValidationRoot()
  {
    return true;
  }
  
  public void invalidate()
  {
    prefSize = null;
    super.invalidate();
  }
  
  public void setText(String name)
  {
    titleBarBorder.setLabel(name);
  }
  
  public String getText()
  {
    if (titleBarBorder == null) {
      return PreferenceMessages.WindowFigure_NoTitleText;
    }
    return titleBarBorder.getLabel();
  }
  
  public Rectangle getTextBounds()
  {
    Rectangle r = getClientArea().getCopy();
    height = titleBarBorder.getTextExtents(this).height;
    x += getInsetsleft;
    y -= getInsetstop;
    return r;
  }
  
  public Image getIcon()
  {
    return null;
  }
  
  public void setIcon(Image image) {}
  
  public void setToolTipText(String text) {}
  
  public String getToolTipText()
  {
    return null;
  }
  
  public void addDecorator(BaseFigureDecorator decorator) {}
  
  public void removeDecorator() {}
  
  public void removeDecorator(int position) {}
  
  public List getDecorators()
  {
    return null;
  }
  
  private WindowFreeformHelper helper = new WindowFreeformHelper(this);
  
  public void addFreeformListener(FreeformListener listener)
  {
    addListener(FreeformListener.class, listener);
  }
  
  public void fireExtentChanged()
  {
    Iterator iter = getListeners(FreeformListener.class);
    while (iter.hasNext()) {
      ((FreeformListener)iter.next()).notifyFreeformExtentChanged();
    }
  }
  
  public Rectangle getFreeformExtent()
  {
    Rectangle r = helper.getFreeformExtent();
    x = 0;
    y = 0;
    return r;
  }
  
  public void removeFreeformListener(FreeformListener listener)
  {
    removeListener(FreeformListener.class, listener);
  }
  
  public void setFreeformBounds(Rectangle bounds)
  {
    helper.setFreeformBounds(bounds);
  }
  
  private class MyGridLayer
    extends GridLayer
  {
    private MyGridLayer() {}
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.facesconfig.ui.preference.WindowFigure
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.jsf.facesconfig.ui.preference;

abstract interface WindowFigureListener
{
  public abstract void tabChanged(int paramInt1, int paramInt2);
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.facesconfig.ui.preference.WindowFigureListener
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.jsf.facesconfig.ui.preference;

import org.eclipse.draw2d.FigureListener;
import org.eclipse.draw2d.IFigure;

class WindowFreeformHelper$ChildTracker
  implements FigureListener
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40

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