org.eclipse.ui.forms_3.5.101.v20111011-1919

overState(2);
      }
    }
    
    private HoverListener() {}
    
    public void mouseHover(MouseEvent e) {}
  }
  
  private class MenuHyperlink
    extends Twistie
  {
    private boolean firstTime = true;
    
    public MenuHyperlink(Composite parent, int style)
    {
      super(style);
      setExpanded(true);
    }
    
    public void setExpanded(boolean expanded)
    {
      if (firstTime)
      {
        super.setExpanded(expanded);
        firstTime = false;
      }
      else
      {
        Menu menu = menuManager.createContextMenu(menuHyperlink);
        menu.setVisible(true);
      }
    }
  }
  
  private class TitleRegionLayout
    extends Layout
    implements ILayoutExtension
  {
    TitleRegionLayout(TitleRegionLayout paramTitleRegionLayout)
    {
      this();
    }
    
    protected Point computeSize(Composite composite, int wHint, int hHint, boolean flushCache)
    {
      return layout(composite, false, 0, 0, wHint, hHint, flushCache);
    }
    
    protected void layout(Composite composite, boolean flushCache)
    {
      Rectangle carea = composite.getClientArea();
      layout(composite, true, x, y, width, 
        height, flushCache);
    }
    
    private Point layout(Composite composite, boolean move, int x, int y, int width, int height, boolean flushCache)
    {
      int iwidth = width == -1 ? -1 : width - 2;
      
      Point bsize = null;
      Point tsize = null;
      Point msize = null;
      if (busyLabel != null) {
        bsize = busyLabel.computeSize(-1, -1);
      }
      if (menuManager != null)
      {
        menuHyperlink.setVisible((!menuManager.isEmpty()) && 
          (titleLabel.getVisible()));
        if (menuHyperlink.getVisible()) {
          msize = menuHyperlink.computeSize(-1, -1);
        }
      }
      if (flushCache) {
        titleCache.flush();
      }
      titleCache.setControl(titleLabel);
      int twidth = iwidth == -1 ? iwidth : iwidth - 10;
      if ((bsize != null) && (twidth != -1)) {
        twidth -= x + 5;
      }
      if ((msize != null) && (twidth != -1)) {
        twidth -= x + 5;
      }
      if (titleLabel.getVisible())
      {
        tsize = titleCache.computeSize(twidth, -1);
        if (twidth != -1)
        {
          int maxWidth = 
            titleCache.computeSize(-1, -1).x;
          x = Math.min(x, maxWidth);
        }
      }
      else
      {
        tsize = new Point(0, 0);
      }
      Point size = new Point(width, height);
      if (!move)
      {
        x = (x > 0 ? 12 + x : 0);
        y = y;
        if (bsize != null)
        {
          x += x + 5;
          y = Math.max(y, y);
        }
        if (msize != null)
        {
          x += x + 5;
          y = Math.max(y, y);
        }
        if (y > 0) {
          y += 10;
        }
      }
      else
      {
        int xloc = x + 1 + 5;
        int yloc = y + 5;
        if (bsize != null)
        {
          busyLabel.setBounds(xloc, 
          
            yloc + (getFontHeight() >= y ? getFontHeight() : y) - 1 - y, 
            x, y);
          xloc += x + 5;
        }
        if (titleLabel.getVisible())
        {
          int tw = width - 2 - 10;
          String os = System.getProperty("os.name");
          if ("linux".equalsIgnoreCase(os)) {
            tw++;
          }
          if (bsize != null) {
            tw -= x + 5;
          }
          if (msize != null) {
            tw -= x + 5;
          }
          titleLabel.setBounds(xloc, 
          
            yloc, tw, y);
          
          xloc += tw + 5;
        }
        if (msize != null) {
          menuHyperlink.setBounds(xloc, yloc + 
            getFontHeight() / 2 - y / 2, 
            x, y);
        }
      }
      return size;
    }
    
    public int computeMaximumWidth(Composite parent, boolean changed)
    {
      return computeSize-1-1x;
    }
    
    public int computeMinimumWidth(Composite parent, boolean changed)
    {
      return computeSize0-1x;
    }
    
    private TitleRegionLayout() {}
  }
  
  public TitleRegion(Composite parent)
  {
    super(parent, 0);
    titleLabel = new Label(this, 64);
    titleLabel.setVisible(false);
    titleCache = new SizeCache();
    super.setLayout(new TitleRegionLayout(null));
    hookHoverListeners();
    addListener(12, new Listener()
    {
      public void handleEvent(Event e)
      {
        if (dragImage != null)
        {
          dragImage.dispose();
          dragImage = null;
        }
      }
    });
  }
  
  public boolean forceFocus()
  {
    return false;
  }
  
  private Color getColor(String key)
  {
    return (Color)getParentcolors.get(key);
  }
  
  private void hookHoverListeners()
  {
    HoverListener listener = new HoverListener(null);
    addMouseTrackListener(listener);
    addMouseMoveListener(listener);
    titleLabel.addMouseTrackListener(listener);
    titleLabel.addMouseMoveListener(listener);
    addPaintListener(new PaintListener()
    {
      public void paintControl(PaintEvent e)
      {
        TitleRegion.this.onPaint(e);
      }
    });
  }
  
  private void onPaint(PaintEvent e)
  {
    if (hoverState == 0) {
      return;
    }
    GC gc = gc;
    Rectangle carea = getClientArea();
    gc.setBackground(getHoverBackground());
    int savedAntialias = gc.getAntialias();
    FormUtil.setAntialias(gc, 1);
    gc.fillRoundRectangle(x + 1, y + 2, width - 
      2, height - 4, 20, 20);
    FormUtil.setAntialias(gc, savedAntialias);
  }
  
  private Color getHoverBackground()
  {
    if (hoverState == 0) {
      return null;
    }
    Color color = getColor(hoverState == 2 ? "org.eclipse.ui.forms.H_H_HOVER_FULL" : 
      "org.eclipse.ui.forms.H_H_HOVER_LIGHT");
    if (color == null) {
      color = 
        getDisplay().getSystemColor(
        hoverState == 2 ? 22 : 
        19);
    }
    return color;
  }
  
  public void setHoverState(int state)
  {
    if ((dragSource == null) || (hoverState == state)) {
      return;
    }
    hoverState = state;
    Color color = getHoverBackground();
    titleLabel.setBackground(color != null ? color : 
      getColor("baseBg"));
    if (busyLabel != null) {
      busyLabel.setBackground(color != null ? color : 
        getColor("baseBg"));
    }
    if (menuHyperlink != null) {
      menuHyperlink.setBackground(color != null ? color : 
        getColor("baseBg"));
    }
    redraw();
  }
  
  public final Point computeSize(int wHint, int hHint, boolean changed)
  {
    return ((TitleRegionLayout)getLayout()).computeSize(this, wHint, 
      hHint, changed);
  }
  
  public final void setLayout(Layout layout) {}
  
  public Image getImage()
  {
    return image;
  }
  
  public void setImage(Image image)
  {
    this.image = image;
  }
  
  public void updateImage(Image newImage, boolean doLayout)
  {
    Image theImage = newImage != null ? newImage : image;
    if (theImage != null)
    {
      ensureBusyLabelExists();
    }
    else if ((busyLabel != null) && 
      (!busyLabel.isBusy()))
    {
      busyLabel.dispose();
      busyLabel = null;
    }
    if (busyLabel != null) {
      busyLabel.setImage(theImage);
    }
    if (doLayout) {
      layout();
    }
  }
  
  public void updateToolTip(String toolTip)
  {
    if (busyLabel != null) {
      busyLabel.setToolTipText(toolTip);
    }
  }
  
  public void setBackground(Color bg)
  {
    super.setBackground(bg);
    titleLabel.setBackground(bg);
    if (busyLabel != null) {
      busyLabel.setBackground(bg);
    }
    if (menuHyperlink != null) {
      menuHyperlink.setBackground(bg);
    }
  }
  
  public void setForeground(Color fg)
  {
    super.setForeground(fg);
    titleLabel.setForeground(fg);
    if (menuHyperlink != null) {
      menuHyperlink.setForeground(fg);
    }
  }
  
  public void setText(String text)
  {
    if (text != null) {
      titleLabel.setText(text);
    }
    titleLabel.setVisible(text != null);
    layout();
    redraw();
  }
  
  public String getText()
  {
    return titleLabel.getText();
  }
  
  public void setFont(Font font)
  {
    super.setFont(font);
    titleLabel.setFont(font);
    fontHeight = -1;
    fontBaselineHeight = -1;
    layout();
  }
  
  private void ensureBusyLabelExists()
  {
    if (busyLabel == null)
    {
      busyLabel = new BusyIndicator(this, 0);
      busyLabel.setBackground(getColor("baseBg"));
      HoverListener listener = new HoverListener(null);
      busyLabel.addMouseTrackListener(listener);
      busyLabel.addMouseMoveListener(listener);
      if (menuManager != null) {
        busyLabel.setMenu(menuManager.createContextMenu(this));
      }
      if (dragSupport) {
        addDragSupport(busyLabel, dragOperations, dragTransferTypes, dragListener);
      }
      IMessageToolTipManager mng = ((FormHeading)getParent())
        .getMessageToolTipManager();
      if (mng != null) {
        mng.createToolTip(busyLabel, true);
      }
    }
  }
  
  private void createMenuHyperlink()
  {
    menuHyperlink = new MenuHyperlink(this, 0);
    menuHyperlink.setBackground(getColor("baseBg"));
    menuHyperlink.setDecorationColor(getForeground());
    menuHyperlink.setHoverDecorationColor(getDisplay().getSystemColor(24));
    HoverListener listener = new HoverListener(null);
    menuHyperlink.addMouseTrackListener(listener);
    menuHyperlink.addMouseMoveListener(listener);
    if (dragSupport) {
      addDragSupport(menuHyperlink, dragOperations, dragTransferTypes, dragListener);
    }
  }
  
  public boolean setBusy(boolean busy)
  {
    if (busy) {
      ensureBusyLabelExists();
    } else if (busyLabel == null) {
      return false;
    }
    if (busy == busyLabel.isBusy()) {
      return false;
    }
    busyLabel.setBusy(busy);
    if (busyLabel.getImage() == null)
    {
      layout();
      return true;
    }
    return false;
  }
  
  public boolean isBusy()
  {
    return (busyLabel != null) && (busyLabel.isBusy());
  }
  
  public int getFontHeight()
  {
    if (fontHeight == -1)
    {
      Font font = getFont();
      GC gc = new GC(getDisplay());
      gc.setFont(font);
      FontMetrics fm = gc.getFontMetrics();
      fontHeight = fm.getHeight();
      gc.dispose();
    }
    return fontHeight;
  }
  
  public int getFontBaselineHeight()
  {
    if (fontBaselineHeight == -1)
    {
      Font font = getFont();
      GC gc = new GC(getDisplay());
      gc.setFont(font);
      FontMetrics fm = gc.getFontMetrics();
      fontBaselineHeight = (fm.getHeight() - fm.getDescent());
      gc.dispose();
    }
    return fontBaselineHeight;
  }
  
  public IMenuManager getMenuManager()
  {
    if (menuManager == null)
    {
      menuManager = new MenuManager();
      Menu menu = menuManager.createContextMenu(this);
      setMenu(menu);
      titleLabel.setMenu(menu);
      if (busyLabel != null) {
        busyLabel.setMenu(menu);
      }
      createMenuHyperlink();
    }
    return menuManager;
  }
  
  public void addDragSupport(int operations, Transfer[] transferTypes, DragSourceListener listener)
  {
    dragSupport = true;
    dragOperations = operations;
    dragTransferTypes = transferTypes;
    dragListener = listener;
    dragSource = addDragSupport(titleLabel, operations, transferTypes, 
      listener);
    addDragSupport(this, operations, transferTypes, listener);
    if (busyLabel != null) {
      addDragSupport(busyLabel, operations, transferTypes, listener);
    }
    if (menuHyperlink != null) {
      addDragSupport(menuHyperlink, operations, transferTypes, listener);
    }
  }
  
  private DragSource addDragSupport(Control control, int operations, Transfer[] transferTypes, DragSourceListener listener)
  {
    DragSource source = new DragSource(control, operations);
    source.setTransfer(transferTypes);
    source.addDragListener(listener);
    source.setDragSourceEffect(new DragSourceEffect(control)
    {
      public void dragStart(DragSourceEvent event)
      {
        image = TitleRegion.this.createDragEffectImage();
      }
    });
    return source;
  }
  
  private Image createDragEffectImage()
  {
    return null;
  }
  
  public void addDropSupport(int operations, Transfer[] transferTypes, DropTargetListener listener)
  {
    DropTarget target = new DropTarget(this, operations);
    target.setTransfer(transferTypes);
    target.addDropListener(listener);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.ui.internal.forms.widgets.TitleRegion
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.ui.internal.forms.widgets;

import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Layout;
import org.eclipse.ui.forms.widgets.ILayoutExtension;

class WrappedPageBook$PageBookLayout
  extends Layout
  implements ILayoutExtension
{
  final WrappedPageBook this$0;
  
  WrappedPageBook$PageBookLayout(WrappedPageBook paramWrappedPageBook)
  {
    this$0 = paramWrappedPageBook;
  }
  
  protected Point computeSize(Composite composite, int wHint, int hHint, boolean flushCache)
  {
    if ((wHint != -1) && (hHint != -1)) {
      return new Point(wHint, hHint);
    }
    Point result = null;
    if (WrappedPageBook.access$0(this$0) != null) {
      result = WrappedPageBook.access$0(this$0).computeSize(wHint, hHint, flushCache);
    } else {
      result = new Point(0, 0);
    }
    return result;
  }
  
  protected void layout(Composite composite, boolean flushCache)
  {
    if (WrappedPageBook.access$0(this$0) != null) {
      WrappedPageBook.access$0(this$0).setBounds(composite.getClientArea());
    }
  }
  
  public int computeMaximumWidth(Composite parent, boolean changed)
  {
    return computeSize-1-1x;
  }
  
  public int computeMinimumWidth(Composite parent, boolean changed)
  {
    return computeSize0-1x;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.ui.internal.forms.widgets.WrappedPageBook.PageBookLayout
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.ui.internal.forms.widgets;

import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Layout;
import org.eclipse.ui.forms.widgets.ILayoutExtension;

public class WrappedPageBook
  extends Composite
{
  class PageBookLayout
    extends Layout
    implements ILayoutExtension
  {
    PageBookLayout() {}
    
    protected Point computeSize(Composite composite, int wHint, int hHint, boolean flushCache)
    {
      if ((wHint != -1) && (hHint != -1)) {
        return new Point(wHint, hHint);
      }
      Point result = null;
      if (currentPage != null) {
        result = currentPage.computeSize(wHint, hHint, flushCache);
      } else {
        result = new Point(0, 0);
      }
      return result;
    }
    
    protected void layout(Composite composite, boolean flushCache)
    {
      if (currentPage != null) {
        currentPage.setBounds(composite.getClientArea());
      }
    }
    
    public int computeMaximumWidth(Composite parent, boolean changed)
    {
      return computeSize-1-1x;
    }
    
    public int computeMinimumWidth(Composite parent, boolean changed)
    {
      return computeSize0-1x;
    }
  }
  
  private Control currentPage = null;
  
  public WrappedPageBook(Composite parent, int style)
  {
    super(parent, style);
    setLayout(new PageBookLayout());
  }
  
  public void showPage(Control page)
  {
    if (page == currentPage) {
      return;
    }
    if (page.getParent() != this) {
      return;
    }
    Control oldPage = currentPage;
    currentPage = page;
    if ((page != null) && 
      (!page.isDisposed()))
    {
      layout(true);
      page.setVisible(true);
    }
    if ((oldPage != null) && (!oldPage.isDisposed())) {
      oldPage.setVisible(false);
    }
  }
  
  public Point computeSize(int wHint, int hHint, boolean changed)
  {
    return ((PageBookLayout)getLayout()).computeSize(this, wHint, hHint, 
      changed);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.ui.internal.forms.widgets.WrappedPageBook
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

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-2019. Infinite Loop Ltd