org.eclipse.ui.presentations.r21_3.2.200.I20100517-1500

16:48:24.970 INFO  jd.cli.Main - Decompiling org.eclipse.ui.presentations.r21_3.2.200.I20100517-1500.jar
package org.eclipse.ui.internal.presentations;

import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.ui.internal.presentations.r21.widgets.CTabItem;
import org.eclipse.ui.internal.presentations.r21.widgets.R21PaneFolder;
import org.eclipse.ui.presentations.IPresentablePart;
import org.eclipse.ui.presentations.IStackPresentationSite;

class R21BasicStackPresentation$1
  extends MouseAdapter
{
  final R21BasicStackPresentation this$0;
  
  R21BasicStackPresentation$1(R21BasicStackPresentation paramR21BasicStackPresentation)
  {
    this$0 = paramR21BasicStackPresentation;
  }
  
  public void mouseDown(MouseEvent e)
  {
    if ((widget instanceof Control))
    {
      Control ctrl = (Control)widget;
      Point globalPos = ctrl.toDisplay(new Point(x, y));
      
      CTabItem newItem = R21BasicStackPresentation.access$0(this$0).getItem(R21BasicStackPresentation.access$0(this$0).getControl()
        .toControl(globalPos));
      if (newItem != null)
      {
        CTabItem oldItem = R21BasicStackPresentation.access$0(this$0).getSelection();
        if (newItem != oldItem) {
          return;
        }
      }
      if (R21BasicStackPresentation.access$1(this$0) != null) {
        R21BasicStackPresentation.access$1(this$0).setFocus();
      }
    }
  }
  
  public void mouseDoubleClick(MouseEvent e)
  {
    if (R21BasicStackPresentation.access$2(this$0).getState() == 1) {
      R21BasicStackPresentation.access$2(this$0).setState(2);
    } else {
      R21BasicStackPresentation.access$2(this$0).setState(1);
    }
  }
}

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

import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;

class R21BasicStackPresentation$10
  extends SelectionAdapter
{
  final R21BasicStackPresentation this$0;
  
  R21BasicStackPresentation$10(R21BasicStackPresentation paramR21BasicStackPresentation)
  {
    this$0 = paramR21BasicStackPresentation;
  }
  
  public void widgetSelected(SelectionEvent e)
  {
    this$0.showPaneMenu();
  }
}

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

import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;

class R21BasicStackPresentation$11
  extends SelectionAdapter
{
  final R21BasicStackPresentation this$0;
  
  R21BasicStackPresentation$11(R21BasicStackPresentation paramR21BasicStackPresentation)
  {
    this$0 = paramR21BasicStackPresentation;
  }
  
  public void widgetSelected(SelectionEvent e)
  {
    this$0.close(this$0.getCurrent());
  }
}

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

import org.eclipse.swt.custom.CLabel;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Control;

class R21BasicStackPresentation$2
  extends MouseAdapter
{
  final R21BasicStackPresentation this$0;
  
  R21BasicStackPresentation$2(R21BasicStackPresentation paramR21BasicStackPresentation)
  {
    this$0 = paramR21BasicStackPresentation;
  }
  
  public void mouseDown(MouseEvent e)
  {
    if ((widget instanceof Control))
    {
      Control ctrl = (Control)widget;
      Point globalPos = ctrl.toDisplay(new Point(0, 
        access$3this$0).getBounds().height));
      if ((button == 1) && (R21BasicStackPresentation.access$4(this$0, x))) {
        this$0.showSystemMenu(globalPos);
      }
    }
  }
}

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

import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;

class R21BasicStackPresentation$3
  implements Listener
{
  final R21BasicStackPresentation this$0;
  
  R21BasicStackPresentation$3(R21BasicStackPresentation paramR21BasicStackPresentation)
  {
    this$0 = paramR21BasicStackPresentation;
  }
  
  public void handleEvent(Event event)
  {
    Point pos = new Point(x, y);
    
    this$0.showSystemMenu(pos);
  }
}

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

import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.ui.internal.presentations.r21.widgets.CTabItem;
import org.eclipse.ui.internal.presentations.r21.widgets.R21PaneFolder;
import org.eclipse.ui.presentations.IPresentablePart;
import org.eclipse.ui.presentations.IStackPresentationSite;

class R21BasicStackPresentation$4
  implements Listener
{
  final R21BasicStackPresentation this$0;
  
  R21BasicStackPresentation$4(R21BasicStackPresentation paramR21BasicStackPresentation)
  {
    this$0 = paramR21BasicStackPresentation;
  }
  
  public void handleEvent(Event event)
  {
    Point localPos = new Point(x, y);
    CTabItem tabUnderPointer = R21BasicStackPresentation.access$0(this$0).getItem(localPos);
    if (tabUnderPointer == null)
    {
      if (R21BasicStackPresentation.access$0(this$0).getTabPosition() == 1024) {
        if (y < access$0this$0).getControl().getBounds().height - R21BasicStackPresentation.access$0(this$0).getTabHeight())
        {
          tabUnderPointer = R21BasicStackPresentation.access$0(this$0).getSelection();
          break label140;
        }
      }
      if ((R21BasicStackPresentation.access$0(this$0).getTabPosition() == 128) && 
        (y > R21BasicStackPresentation.access$0(this$0).getTabHeight())) {
        tabUnderPointer = R21BasicStackPresentation.access$0(this$0).getSelection();
      }
    }
    label140:
    if (tabUnderPointer == null)
    {
      R21BasicStackPresentation.access$2(this$0).dragStart(
        R21BasicStackPresentation.access$0(this$0).getControl().toDisplay(localPos), false);
      return;
    }
    IPresentablePart part = this$0.getPartForTab(tabUnderPointer);
    if (R21BasicStackPresentation.access$2(this$0).isPartMoveable(part)) {
      R21BasicStackPresentation.access$2(this$0).dragStart(part, 
        R21BasicStackPresentation.access$0(this$0).getControl().toDisplay(localPos), false);
    }
  }
}

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

import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.ui.internal.presentations.r21.widgets.CTabItem;
import org.eclipse.ui.presentations.IPresentablePart;
import org.eclipse.ui.presentations.IStackPresentationSite;

class R21BasicStackPresentation$5
  implements Listener
{
  final R21BasicStackPresentation this$0;
  
  R21BasicStackPresentation$5(R21BasicStackPresentation paramR21BasicStackPresentation)
  {
    this$0 = paramR21BasicStackPresentation;
  }
  
  public void handleEvent(Event e)
  {
    IPresentablePart item = this$0.getPartForTab((CTabItem)item);
    if (item != null) {
      R21BasicStackPresentation.access$2(this$0).selectPart(item);
    }
  }
}

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

import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;

class R21BasicStackPresentation$6
  implements Listener
{
  final R21BasicStackPresentation this$0;
  
  R21BasicStackPresentation$6(R21BasicStackPresentation paramR21BasicStackPresentation)
  {
    this$0 = paramR21BasicStackPresentation;
  }
  
  public void handleEvent(Event e)
  {
    this$0.setControlSize();
  }
}

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

import org.eclipse.ui.IPropertyListener;
import org.eclipse.ui.presentations.IPresentablePart;

class R21BasicStackPresentation$7
  implements IPropertyListener
{
  final R21BasicStackPresentation this$0;
  
  R21BasicStackPresentation$7(R21BasicStackPresentation paramR21BasicStackPresentation)
  {
    this$0 = paramR21BasicStackPresentation;
  }
  
  public void propertyChanged(Object source, int property)
  {
    if ((source instanceof IPresentablePart))
    {
      IPresentablePart part = (IPresentablePart)source;
      this$0.childPropertyChanged(part, property);
    }
  }
}

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

import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.ui.internal.presentations.r21.widgets.CTabItem;
import org.eclipse.ui.presentations.IPresentablePart;

class R21BasicStackPresentation$8
  implements DisposeListener
{
  final R21BasicStackPresentation this$0;
  
  R21BasicStackPresentation$8(R21BasicStackPresentation paramR21BasicStackPresentation)
  {
    this$0 = paramR21BasicStackPresentation;
  }
  
  public void widgetDisposed(DisposeEvent e)
  {
    if ((widget instanceof CTabItem))
    {
      CTabItem item = (CTabItem)widget;
      
      IPresentablePart part = this$0.getPartForTab(item);
      
      part.removePropertyListener(R21BasicStackPresentation.access$5(this$0));
    }
  }
}

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

import org.eclipse.swt.events.ShellAdapter;
import org.eclipse.swt.events.ShellEvent;

class R21BasicStackPresentation$9
  extends ShellAdapter
{
  final R21BasicStackPresentation this$0;
  
  R21BasicStackPresentation$9(R21BasicStackPresentation paramR21BasicStackPresentation)
  {
    this$0 = paramR21BasicStackPresentation;
  }
  
  public void shellActivated(ShellEvent event)
  {
    R21BasicStackPresentation.access$6(this$0, true);
    this$0.updateGradient();
  }
  
  public void shellDeactivated(ShellEvent event)
  {
    R21BasicStackPresentation.access$6(this$0, false);
    this$0.updateGradient();
  }
}

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

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.eclipse.core.runtime.Assert;
import org.eclipse.jface.action.GroupMarker;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.jface.util.Geometry;
import org.eclipse.jface.window.Window;
import org.eclipse.swt.custom.CLabel;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.ShellAdapter;
import org.eclipse.swt.events.ShellEvent;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.ToolItem;
import org.eclipse.ui.IMemento;
import org.eclipse.ui.IPropertyListener;
import org.eclipse.ui.internal.WorkbenchImages;
import org.eclipse.ui.internal.dnd.DragUtil;
import org.eclipse.ui.internal.presentations.r21.R21Colors;
import org.eclipse.ui.internal.presentations.r21.R21PresentationMessages;
import org.eclipse.ui.internal.presentations.r21.widgets.CTabItem;
import org.eclipse.ui.internal.presentations.r21.widgets.R21PaneFolder;
import org.eclipse.ui.presentations.IPartMenu;
import org.eclipse.ui.presentations.IPresentablePart;
import org.eclipse.ui.presentations.IPresentationSerializer;
import org.eclipse.ui.presentations.IStackPresentationSite;
import org.eclipse.ui.presentations.PresentationUtil;
import org.eclipse.ui.presentations.StackDropResult;
import org.eclipse.ui.presentations.StackPresentation;

public class R21BasicStackPresentation
  extends StackPresentation
{
  private R21PaneFolder paneFolder;
  private IPresentablePart current;
  private boolean activeState = false;
  private MenuManager systemMenuManager = new MenuManager();
  private CLabel titleLabel;
  private boolean shellActive = true;
  private static final String TAB_DATA = R21BasicStackPresentation.class
    .getName() + 
    ".partId";
  private MouseListener mouseListener = new MouseAdapter()
  {
    public void mouseDown(MouseEvent e)
    {
      if ((widget instanceof Control))
      {
        Control ctrl = (Control)widget;
        Point globalPos = ctrl.toDisplay(new Point(x, y));
        
        CTabItem newItem = paneFolder.getItem(paneFolder.getControl()
          .toControl(globalPos));
        if (newItem != null)
        {
          CTabItem oldItem = paneFolder.getSelection();
          if (newItem != oldItem) {
            return;
          }
        }
        if (current != null) {
          current.setFocus();
        }
      }
    }
    
    public void mouseDoubleClick(MouseEvent e)
    {
      if (getSite().getState() == 1) {
        getSite().setState(2);
      } else {
        getSite().setState(1);
      }
    }
  };
  private MouseListener titleMouseListener = new MouseAdapter()
  {
    public void mouseDown(MouseEvent e)
    {
      if ((widget instanceof Control))
      {
        Control ctrl = (Control)widget;
        Point globalPos = ctrl.toDisplay(new Point(0, 
          titleLabel.getBounds().height));
        if ((button == 1) && (R21BasicStackPresentation.this.overImage(x))) {
          showSystemMenu(globalPos);
        }
      }
    }
  };
  private Listener menuListener = new Listener()
  {
    public void handleEvent(Event event)
    {
      Point pos = new Point(x, y);
      
      showSystemMenu(pos);
    }
  };
  private Listener dragListener = new Listener()
  {
    public void handleEvent(Event event)
    {
      Point localPos = new Point(x, y);
      CTabItem tabUnderPointer = paneFolder.getItem(localPos);
      if (tabUnderPointer == null)
      {
        if (paneFolder.getTabPosition() == 1024) {
          if (y < paneFolder.getControl().getBounds().height - paneFolder.getTabHeight())
          {
            tabUnderPointer = paneFolder.getSelection();
            break label140;
          }
        }
        if ((paneFolder.getTabPosition() == 128) && 
          (y > paneFolder.getTabHeight())) {
          tabUnderPointer = paneFolder.getSelection();
        }
      }
      label140:
      if (tabUnderPointer == null)
      {
        getSite().dragStart(
          paneFolder.getControl().toDisplay(localPos), false);
        return;
      }
      IPresentablePart part = getPartForTab(tabUnderPointer);
      if (getSite().isPartMoveable(part)) {
        getSite().dragStart(part, 
          paneFolder.getControl().toDisplay(localPos), false);
      }
    }
  };
  private Listener selectionListener = new Listener()
  {
    public void handleEvent(Event e)
    {
      IPresentablePart item = getPartForTab((CTabItem)item);
      if (item != null) {
        getSite().selectPart(item);
      }
    }
  };
  private Listener resizeListener = new Listener()
  {
    public void handleEvent(Event e)
    {
      setControlSize();
    }
  };
  private IPropertyListener childPropertyChangeListener = new IPropertyListener()
  {
    public void propertyChanged(Object source, int property)
    {
      if ((source instanceof IPresentablePart))
      {
        IPresentablePart part = (IPresentablePart)source;
        childPropertyChanged(part, property);
      }
    }
  };
  private DisposeListener tabDisposeListener = new DisposeListener()
  {
    public void widgetDisposed(DisposeEvent e)
    {
      if ((widget instanceof CTabItem))
      {
        CTabItem item = (CTabItem)widget;
        
        IPresentablePart part = getPartForTab(item);
        
        part.removePropertyListener(childPropertyChangeListener);
      }
    }
  };
  private ShellAdapter shellListener = new ShellAdapter()
  {
    public void shellActivated(ShellEvent event)
    {
      shellActive = true;
      updateGradient();
    }
    
    public void shellDeactivated(ShellEvent event)
    {
      shellActive = false;
      updateGradient();
    }
  };
  private ToolBar viewToolBar;
  private ToolItem pullDownButton;
  private ToolItem closeButton;
  
  public R21BasicStackPresentation(R21PaneFolder control, IStackPresentationSite stackSite)
  {
    super(stackSite);
    paneFolder = control;
    
    shellActive = paneFolder.getControl().getShell().equals(
      control.getControl().getDisplay().getActiveShell());
    
    titleLabel = new CLabel(paneFolder.getControl(), 32);
    titleLabel.setVisible(false);
    titleLabel.moveAbove(null);
    titleLabel.addMouseListener(titleMouseListener);
    titleLabel.addMouseListener(mouseListener);
    titleLabel.addListener(35, menuListener);
    PresentationUtil.addDragListener(titleLabel, dragListener);
    
    viewToolBar = new ToolBar(control.getControl(), 8388864);
    
    viewToolBar.moveAbove(null);
    
    pullDownButton = new ToolItem(viewToolBar, 8);
    
    Image hoverImage = 
      WorkbenchImages.getImage("IMG_LCL_VIEW_MENU");
    pullDownButton.setDisabledImage(null);
    
    pullDownButton.setImage(hoverImage);
    pullDownButton.setToolTipText(
      R21PresentationMessages.getString("BasicStackPresentation.menu.tooltip"));
    pullDownButton.addSelectionListener(new SelectionAdapter()
    {
      public void widgetSelected(SelectionEvent e)
      {
        showPaneMenu();
      }
    });
    paneFolder.getControl().addListener(13, selectionListener);
    
    paneFolder.getControl().addListener(11, resizeListener);
    
    paneFolder.getControl().addMouseListener(mouseListener);
    
    paneFolder.getControl().addListener(35, menuListener);
    
    PresentationUtil.addDragListener(paneFolder.getControl(), dragListener);
    
    paneFolder.getControl().getShell().addShellListener(shellListener);
    
    populateSystemMenu(systemMenuManager);
  }
  
  private boolean overImage(int x)
  {
    return x < titleLabel.getImage().getBounds().width;
  }
  
  private void populateSystemMenu(IMenuManager systemMenuManager)
  {
    systemMenuManager.add(new GroupMarker("misc"));
    systemMenuManager.add(new GroupMarker("restore"));
    systemMenuManager.add(new UpdatingActionContributionItem(
      new SystemMenuRestore(getSite())));
    
    systemMenuManager.add(new SystemMenuMove(getSite(), getPaneName()));
    systemMenuManager.add(new GroupMarker("size"));
    systemMenuManager.add(new GroupMarker("state"));
    systemMenuManager.add(new UpdatingActionContributionItem(
      new SystemMenuMinimize(getSite())));
    
    systemMenuManager.add(new UpdatingActionContributionItem(
      new SystemMenuMaximize(getSite())));
    systemMenuManager.add(new Separator("close"));
    systemMenuManager.add(new UpdatingActionContributionItem(
      new SystemMenuClose(getSite())));
    
    getSite().addSystemActions(systemMenuManager);
  }
  
  protected String getPaneName()
  {
    return R21PresentationMessages.getString("BasicStackPresentation.pane");
  }
  
  public void showPaneMenu()
  {
    IPartMenu menu = getPartMenu();
    if (menu != null)
    {
      Rectangle bounds = DragUtil.getDisplayBounds(viewToolBar);
      menu.showMenu(new Point(x, y + height));
    }
  }
  
  protected IPresentablePart getCurrent()
  {
    return current;
  }
  
  private final int indexOf(IPresentablePart part)
  {
    if (part == null) {
      return paneFolder.getItemCount();
    }
    CTabItem[] items = paneFolder.getItems();
    for (int idx = 0; idx < items.length; idx++)
    {
      IPresentablePart tabPart = getPartForTab(items[idx]);
      if (part == tabPart) {
        return idx;
      }
    }
    return items.length;
  }
  
  protected final CTabItem getTab(IPresentablePart part)
  {
    CTabItem[] items = paneFolder.getItems();
    
    int idx = indexOf(part);
    if (idx < items.length) {
      return items[idx];
    }
    return null;
  }
  
  protected void childPropertyChanged(IPresentablePart part, int property)
  {
    CTabItem tab = getTab(part);
    initTab(tab, part);
    switch (property)
    {
    case 146: 
      break;
    case 1: 
    case 147: 
    case 148: 
    case 770: 
      setControlSize();
    }
  }
  
  protected final IPresentablePart getPartForTab(CTabItem item)
  {
    IPresentablePart part = (IPresentablePart)item.getData(TAB_DATA);
    
    return part;
  }
  
  protected R21PaneFolder getPaneFolder()
  {
    return paneFolder;
  }
  
  public boolean isDisposed()
  {
    return (paneFolder == null) || (paneFolder.isDisposed());
  }
  
  protected void updateGradient()
  {
    if (isDisposed()) {
      return;
    }
    boolean vertical = false;
    int[] bgPercents;
    Color fgColor;
    Color[] bgColors;
    int[] bgPercents;
    if (isActive())
    {
      int[] bgPercents;
      if (getShellActivated())
      {
        Color fgColor = R21Colors.getSystemColor(30);
        Color[] bgColors = R21Colors.getActiveViewGradient();
        bgPercents = R21Colors.getActiveViewGradientPercents();
      }
      else
      {
        Color fgColor = 
          R21Colors.getSystemColor(33);
        Color[] bgColors = R21Colors.getDeactivatedViewGradient();
        bgPercents = R21Colors.getDeactivatedViewGradientPercents();
      }
    }
    else
    {
      fgColor = R21Colors.getSystemColor(24);
      bgColors = (Color[])null;
      bgPercents = (int[])null;
    }
    drawGradient(fgColor, bgColors, bgPercents, vertical);
  }
  
  public void drawGradient(Color fgColor, Color[] bgColors, int[] percentages, boolean vertical)
  {
    if ((titleLabel == null) || (viewToolBar == null)) {
      return;
    }
    titleLabel.setBackground(bgColors, percentages, vertical);
    titleLabel.setForeground(fgColor);
    
    titleLabel.update();
  }
  
  public boolean isActive()
  {
    return activeState;
  }
  
  public void setControlSize()
  {
    if (current != null)
    {
      paneFolder.setTopLeft(titleLabel);
      titleLabel.setText(current.getTitle());
      titleLabel.setImage(current.getTitleImage());
      titleLabel.setVisible(true);
      
      String toolTipText = current.getTitleToolTip();
      titleLabel.setToolTipText(toolTipText
        .equals("") ? null : toolTipText);
    }
    Control currentToolbar = getCurrentToolbar();
    paneFolder.setTopCenter(currentToolbar);
    
    IPartMenu partMenu = getPartMenu();
    if (partMenu != null) {
      pullDownButton.setEnabled(true);
    } else {
      pullDownButton.setEnabled(false);
    }
    paneFolder.setTopRight(viewToolBar);
    viewToolBar.setVisible(true);
    
    paneFolder.layout(true);
    if (current != null)
    {
      Rectangle clientArea = paneFolder.getClientArea();
      Rectangle bounds = paneFolder.getControl().getBounds();
      x += x;
      y += y;
      
      current.setBounds(clientArea);
    }
  }
  
  protected IPartMenu getPartMenu()
  {
    IPresentablePart part = getCurrentPart();
    if (part == null) {
      return null;
    }
    return part.getMenu();
  }
  
  public void dispose()
  {
    if (isDisposed()) {
      return;
    }
    paneFolder.getControl().getShell().removeShellListener(shellListener);
    
    PresentationUtil.removeDragListener(paneFolder.getControl(), 
      dragListener);
    PresentationUtil.removeDragListener(titleLabel, dragListener);
    
    systemMenuManager.dispose();
    systemMenuManager.removeAll();
    paneFolder.getControl().dispose();
    paneFolder = null;
    
    titleLabel.dispose();
    titleLabel = null;
    
    viewToolBar.dispose();
  }
  
  public void setActive(boolean isActive)
  {
    activeState = isActive;
    updateGradient();
  }
  
  boolean getShellActivated()
  {
    return shellActive;
  }
  
  public Window getWindow()
  {
    Control ctrl = getControl();
    if (ctrl != null)
    {
      Object data = ctrl.getShell().getData();
      if ((data instanceof Window)) {
        return (Window)data;
      }
    }
    return null;
  }
  
  private CTabItem createPartTab(IPresentablePart part, int tabIndex)
  {
    int style = 0;
    if (getSite().isCloseable(part)) {
      style |= 0x40;
    }
    CTabItem tabItem = paneFolder.createItem(style, tabIndex);
    
    tabItem.setData(TAB_DATA, part);
    
    part.addPropertyListener(childPropertyChangeListener);
    tabItem.addDisposeListener(tabDisposeListener);
    
    initTab(tabItem, part);
    
    return tabItem;
  }
  
  private void updateCloseButton()
  {
    if ((current == null) || (!getSite().isCloseable(current)))
    {
      if (closeButton != null)
      {
        closeButton.dispose();
        closeButton = null;
        
        paneFolder.flush();
      }
      return;
    }
    if (closeButton != null) {
      return;
    }
    closeButton = new ToolItem(viewToolBar, 8);
    closeButton.setDisabledImage(null);
    closeButton.setImage(
      WorkbenchImages.getImage("IMG_LCL_CLOSE_VIEW"));
    closeButton.setToolTipText(
      R21PresentationMessages.getString("BasicStackPresentation.close.tooltip"));
    closeButton.addSelectionListener(new SelectionAdapter()
    {
      public void widgetSelected(SelectionEvent e)
      {
        close(getCurrent());
      }
    });
    paneFolder.flush();
  }
  
  protected void initTab(CTabItem tabItem, IPresentablePart part)
  {
    tabItem.setText(part.getName());
  }
  
  public void addPart(IPresentablePart newPart, Object cookie)
  {
    int idx;
    int idx;
    if ((cookie instanceof Integer)) {
      idx = ((Integer)cookie).intValue();
    } else {
      idx = paneFolder.getItemCount();
    }
    addPart(newPart, idx);
  }
  
  public void addPart(IPresentablePart newPart, int index)
  {
    if (getTab(newPart) != null) {
      return;
    }
    createPartTab(newPart, index);
    
    setControlSize();
  }
  
  public void removePart(IPresentablePart oldPart)
  {
    if (current == oldPart)
    {
      titleLabel.setImage(null);
      current = null;
    }
    CTabItem item = getTab(oldPart);
    if (item == null) {
      return;
    }
    oldPart.setVisible(false);
    
    item.dispose();
    
    setControlSize();
  }
  
  public void selectPart(IPresentablePart toSelect)
  {
    if (toSelect == current) {
      return;
    }
    IPresentablePart oldPart = current;
    
    current = toSelect;
    if (current != null)
    {
      paneFolder.setSelection(indexOf(current));
      current.setVisible(true);
      updateCloseButton();
      setControlSize();
    }
    if (oldPart != null) {
      oldPart.setVisible(false);
    }
  }
  
  public IPresentablePart getCurrentPart()
  {
    return current;
  }
  
  public void setBounds(Rectangle bounds)
  {
    if (getSite().getState() == 0)
    {
      bounds = Geometry.copy(bounds);
      height = computePreferredSize(false, Integer.MAX_VALUE, 
        width, Integer.MAX_VALUE);
    }
    paneFolder.getControl().setBounds(bounds);
    setControlSize();
  }
  
  public Point computeMinimumSize()
  {
    Point result = Geometry.getSize(paneFolder.computeTrim(0, 0, 0, 0));
    
    x += 100;
    
    return result;
  }
  
  public void setVisible(boolean isVisible)
  {
    if (current != null) {
      current.setVisible(isVisible);
    }
    paneFolder.getControl().setVisible(isVisible);
  }
  
  public void setState(int state) {}
  
  public IMenuManager getSystemMenuManager()
  {
    return systemMenuManager;
  }
  
  protected void showSystemMenu(Point point)
  {
    Menu aMenu = systemMenuManager.createContextMenu(paneFolder
      .getControl().getParent());
    systemMenuManager.update(true);
    aMenu.setLocation(x, y);
    aMenu.setVisible(true);
  }
  
  public Control getControl()
  {
    return paneFolder.getControl();
  }
  
  public StackDropResult dragOver(Control currentControl, Point location)
  {
    Point localPos = paneFolder.getControl().toControl(location);
    CTabItem tabUnderPointer = paneFolder.getItem(localPos);
    if (tabUnderPointer == null) {
      return null;
    }
    int dragOverIndex = paneFolder.indexOf(tabUnderPointer);
    
    return new StackDropResult(Geometry.toDisplay(paneFolder.getControl(), 
      tabUnderPointer.getBounds()), new Integer(dragOverIndex));
  }
  
  protected Control getCurrentToolbar()
  {
    IPresentablePart part = getCurrentPart();
    if (part == null) {
      return null;
    }
    return part.getToolBar();
  }
  
  public void showSystemMenu()
  {
    IPresentablePart part = getCurrentPart();
    if (part != null)
    {
      Rectangle bounds = DragUtil.getDisplayBounds(paneFolder
        .getControl());
      
      int idx = paneFolder.getSelectionIndex();
      if (idx > -1)
      {
        CTabItem item = paneFolder.getItem(idx);
        Rectangle itemBounds = item.getBounds();
        
        x += x;
        y += y;
      }
      Point location = new Point(x, y + 
        paneFolder.getTabHeight());
      showSystemMenu(location);
    }
  }
  
  public Control[] getTabList(IPresentablePart part)
  {
    ArrayList list = new ArrayList();
    if (paneFolder.getTabPosition() == 1024)
    {
      if (part.getToolBar() != null) {
        list.add(part.getToolBar());
      }
      if (part.getControl() != null) {
        list.add(part.getControl());
      }
      if (getPaneFolder() != null) {
        list.add(getPaneFolder().getControl());
      }
    }
    else
    {
      if (getPaneFolder() != null) {
        list.add(getPaneFolder().getControl());
      }
      if (part.getToolBar() != null) {
        list.add(part.getToolBar());
      }
      if (part.getControl() != null) {
        list.add(part.getControl());
      }
    }
    return (Control[])list.toArray(new Control[list.size()]);
  }
  
  protected void showList(Shell parentShell, int x, int y) {}
  
  protected void showListDefaultLocation()
  {
    R21PaneFolder tabFolder = getPaneFolder();
    Shell shell = tabFolder.getControl().getShell();
    Rectangle clientArea = tabFolder.getClientArea();
    Point location = tabFolder.getControl().getDisplay().map(
      tabFolder.getControl(), null, x, y);
    showList(shell, x, y);
  }
  
  void setSelection(CTabItem tabItem)
  {
    getSite().selectPart(getPartForTab(tabItem));
  }
  
  void close(IPresentablePart presentablePart)
  {
    getSite().close(new IPresentablePart[] { presentablePart });
  }
  
  Image getLabelImage(IPresentablePart presentablePart)
  {
    return presentablePart.getTitleImage();
  }
  
  String getLabelText(IPresentablePart presentablePart, boolean includePath)
  {
    String title = presentablePart.getTitle().trim();
    return title;
  }
  
  public void setActive(int newState)
  {
    setActive(newState == 1);
  }
  
  public void restoreState(IPresentationSerializer serializer, IMemento savedState)
  {
    IMemento[] parts = savedState.getChildren("part");
    for (int idx = 0; idx < parts.length; idx++)
    {
      String id = parts[idx].getString("id");
      if (id != null)
      {
        IPresentablePart part = serializer.getPart(id);
        if (part != null) {
          addPart(part, getPaneFolder().getItemCount());
        }
      }
    }
  }
  
  public void saveState(IPresentationSerializer context, IMemento memento)
  {
    super.saveState(context, memento);
    
    List parts = getPresentableParts();
    
    Iterator iter = parts.iterator();
    while (iter.hasNext())
    {
      IPresentablePart next = (IPresentablePart)iter.next();
      
      IMemento childMem = memento
        .createChild("part");
      childMem.putString("id", context.getId(next));
    }
  }
  
  private List getPresentableParts()
  {
    Assert.isTrue(!isDisposed());
    
    CTabItem[] items = getPaneFolder().getItems();
    List result = new ArrayList(items.length);
    for (int idx = 0; idx < getPaneFolder().getItemCount(); idx++) {
      result.add(getPartForTab(items[idx]));
    }
    return result;
  }
}

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

import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.ui.internal.presentations.r21.widgets.CTabFolder;
import org.eclipse.ui.internal.presentations.r21.widgets.CTabItem;
import org.eclipse.ui.presentations.IPresentablePart;
import org.eclipse.ui.presentations.IStackPresentationSite;

class R21EditorStackPresentation$1
  implements Listener
{
  final R21EditorStackPresentation this$0;
  
  R21EditorStackPresentation$1(R21EditorStackPresentation paramR21EditorStackPresentation)
  {
    this$0 = paramR21EditorStackPresentation;
  }
  
  public void handleEvent(Event event)
  {
    Point localPos = new Point(x, y);
    CTabItem tabUnderPointer = R21EditorStackPresentation.access$0(this$0).getItem(localPos);
    if (tabUnderPointer == null)
    {
      if (R21EditorStackPresentation.access$1(this$0).isStackMoveable()) {
        R21EditorStackPresentation.access$1(this$0).dragStart(R21EditorStackPresentation.access$0(this$0).toDisplay(localPos), false);
      }
      return;
    }
    IPresentablePart part = this$0.getPartForTab(tabUnderPointer);
    if (R21EditorStackPresentation.access$1(this$0).isPartMoveable(part)) {
      R21EditorStackPresentation.access$1(this$0).dragStart(part, R21EditorStackPresentation.access$0(this$0).toDisplay(localPos), false);
    }
  }
}

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

import org.eclipse.ui.internal.presentations.r21.widgets.CTabFolderEvent;
import org.eclipse.ui.internal.presentations.r21.widgets.CTabFolderListener;
import org.eclipse.ui.internal.presentations.r21.widgets.CTabItem;
import org.eclipse.ui.presentations.IPresentablePart;
import org.eclipse.ui.presentations.IStackPresentationSite;

class R21EditorStackPresentation$2
  implements CTabFolderListener
{
  final R21EditorStackPresentation this$0;
  
  R21EditorStackPresentation$2(R21EditorStackPresentation paramR21EditorStackPresentation)
  {
    this$0 = paramR21EditorStackPresentation;
  }
  
  public void itemClosed(CTabFolderEvent e)
  {
    CTabItem item = (CTabItem)item;
    if (item != null)
    {
      doit = false;
      R21EditorStackPresentation.access$1(this$0).close(new IPresentablePart[] { this$0.getPartForTab(item) });
    }
  }
}

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

import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Control;
import org.eclipse.ui.internal.presentations.r21.widgets.CTabFolder;
import org.eclipse.ui.internal.presentations.r21.widgets.CTabItem;
import org.eclipse.ui.presentations.IPresentablePart;
import org.eclipse.ui.presentations.IStackPresentationSite;

class R21EditorStackPresentation$3
  extends MouseAdapter
{
  final R21EditorStackPresentation this$0;
  
  R21EditorStackPresentation$3(R21EditorStackPresentation paramR21EditorStackPresentation)
  {
    this$0 = paramR21EditorStackPresentation;
  }
  
  public void mouseDown(MouseEvent e)
  {
    if ((widget instanceof Control))
    {
      Control ctrl = (Control)widget;
      
      Point globalPos = ctrl.toDisplay(new Point(x, y));
      
      CTabItem newItem = R21EditorStackPresentation.access$0(this$0).getItem(R21EditorStackPresentation.access$0(this$0)
        .toControl(globalPos));
      if (newItem != null)
      {
        if ((button == 1) && (R21EditorStackPresentation.overImage(newItem, x)))
        {
          R21EditorStackPresentation.access$1(this$0).selectPart(this$0.getPartForTab(newItem));
          this$0.showSystemMenu();
        }
        CTabItem oldItem = R21EditorStackPresentation.access$0(this$0).getSelection();
        if (newItem != oldItem) {
          return;
        }
      }
      if (R21EditorStackPresentation.access$2(this$0) != null) {
        R21EditorStackPresentation.access$2(this$0).setFocus();
      }
    }
  }
  
  public void mouseDoubleClick(MouseEvent e)
  {
    if (R21EditorStackPresentation.access$1(this$0).getState() == 1) {
      R21EditorStackPresentation.access$1(this$0).setState(2);
    } else {
      R21EditorStackPresentation.access$1(this$0).setState(1);
    }
  }
}

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

import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;

class R21EditorStackPresentation$4
  implements Listener
{
  final R21EditorStackPresentation this$0;
  
  R21EditorStackPresentation$4(R21EditorStackPresentation paramR21EditorStackPresentation)
  {
    this$0 = paramR21EditorStackPresentation;
  }
  
  public void handleEvent(Event event)
  {
    Point pos = new Point(x, y);
    this$0.showSystemMenu(pos);
  }
}

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

import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.ui.internal.presentations.r21.widgets.CTabItem;
import org.eclipse.ui.presentations.IPresentablePart;
import org.eclipse.ui.presentations.IStackPresentationSite;

class R21EditorStackPresentation$5
  implements Listener
{
  final R21EditorStackPresentation this$0;
  
  R21EditorStackPresentation$5(R21EditorStackPresentation paramR21EditorStackPresentation)
  {
    this$0 = paramR21EditorStackPresentation;
  }
  
  public void handleEven
1 2 3 4 5

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