org.eclipse.ui.workbench_3.104.0.v20130204-164612

16:48:34.005 INFO  jd.cli.Main - Decompiling org.eclipse.ui.workbench_3.104.0.v20130204-164612.jar
package org.eclipse.e4.ui.workbench.addons.perspectiveswitcher;

import org.eclipse.e4.ui.model.application.ui.MUIElement;
import org.eclipse.e4.ui.model.application.ui.advanced.MPerspective;
import org.eclipse.e4.ui.model.application.ui.advanced.MPerspectiveStack;
import org.eclipse.e4.ui.model.application.ui.basic.MWindow;
import org.eclipse.e4.ui.workbench.modeling.EModelService;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.ToolItem;
import org.osgi.service.event.Event;
import org.osgi.service.event.EventHandler;

class PerspectiveSwitcher$1
  implements EventHandler
{
  PerspectiveSwitcher$1(PerspectiveSwitcher paramPerspectiveSwitcher) {}
  
  public void handleEvent(Event event)
  {
    if (PerspectiveSwitcher.access$0(this$0).isDisposed()) {
      return;
    }
    MUIElement changedElement = (MUIElement)event.getProperty("ChangedElement");
    if ((PerspectiveSwitcher.access$1(this$0) == null) || (!(changedElement instanceof MPerspectiveStack))) {
      return;
    }
    MWindow perspWin = this$0.modelService.getTopLevelWindowFor(changedElement);
    MWindow switcherWin = this$0.modelService.getTopLevelWindowFor(PerspectiveSwitcher.access$1(this$0));
    if (perspWin != switcherWin) {
      return;
    }
    MPerspectiveStack perspStack = (MPerspectiveStack)changedElement;
    if (!perspStack.isToBeRendered()) {
      return;
    }
    MPerspective selElement = (MPerspective)perspStack.getSelectedElement();
    ToolItem[] arrayOfToolItem;
    int j = (arrayOfToolItem = PerspectiveSwitcher.access$0(this$0).getItems()).length;
    for (int i = 0; i < j; i++)
    {
      ToolItem ti = arrayOfToolItem[i];
      ti.setSelection(ti.getData() == selElement);
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.e4.ui.workbench.addons.perspectiveswitcher.PerspectiveSwitcher.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.e4.ui.workbench.addons.perspectiveswitcher;

import org.eclipse.swt.accessibility.AccessibleAdapter;
import org.eclipse.swt.accessibility.AccessibleEvent;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.ToolItem;

class PerspectiveSwitcher$10
  extends AccessibleAdapter
{
  PerspectiveSwitcher$10(PerspectiveSwitcher paramPerspectiveSwitcher) {}
  
  public void getName(AccessibleEvent e)
  {
    if ((childID >= 0) && (childID < PerspectiveSwitcher.access$0(this$0).getItemCount()))
    {
      ToolItem item = PerspectiveSwitcher.access$0(this$0).getItem(childID);
      if (item != null) {
        result = item.getToolTipText();
      }
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.e4.ui.workbench.addons.perspectiveswitcher.PerspectiveSwitcher.10
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.e4.ui.workbench.addons.perspectiveswitcher;

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

class PerspectiveSwitcher$11
  implements SelectionListener
{
  PerspectiveSwitcher$11(PerspectiveSwitcher paramPerspectiveSwitcher) {}
  
  public void widgetSelected(SelectionEvent e)
  {
    PerspectiveSwitcher.access$6(this$0);
  }
  
  public void widgetDefaultSelected(SelectionEvent e)
  {
    PerspectiveSwitcher.access$6(this$0);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.e4.ui.workbench.addons.perspectiveswitcher.PerspectiveSwitcher.11
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.e4.ui.workbench.addons.perspectiveswitcher;

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

class PerspectiveSwitcher$12
  implements Listener
{
  PerspectiveSwitcher$12(PerspectiveSwitcher paramPerspectiveSwitcher, Image paramImage) {}
  
  public void handleEvent(Event event)
  {
    val$image.dispose();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.e4.ui.workbench.addons.perspectiveswitcher.PerspectiveSwitcher.12
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.e4.ui.workbench.addons.perspectiveswitcher;

import org.eclipse.e4.ui.model.application.ui.MElementContainer;
import org.eclipse.e4.ui.model.application.ui.advanced.MPerspective;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.widgets.Widget;

class PerspectiveSwitcher$13
  implements SelectionListener
{
  PerspectiveSwitcher$13(PerspectiveSwitcher paramPerspectiveSwitcher) {}
  
  public void widgetSelected(SelectionEvent e)
  {
    MPerspective persp = (MPerspective)widget.getData();
    persp.getParent().setSelectedElement(persp);
  }
  
  public void widgetDefaultSelected(SelectionEvent e)
  {
    MPerspective persp = (MPerspective)widget.getData();
    persp.getParent().setSelectedElement(persp);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.e4.ui.workbench.addons.perspectiveswitcher.PerspectiveSwitcher.13
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.e4.ui.workbench.addons.perspectiveswitcher;

import org.eclipse.e4.ui.model.application.ui.advanced.MPerspective;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.ToolItem;
import org.eclipse.swt.widgets.Widget;

class PerspectiveSwitcher$14
  implements Listener
{
  PerspectiveSwitcher$14(PerspectiveSwitcher paramPerspectiveSwitcher, ToolItem paramToolItem) {}
  
  public void handleEvent(Event event)
  {
    MPerspective persp = (MPerspective)widget.getData();
    PerspectiveSwitcher.access$5(this$0, val$psItem, persp);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.e4.ui.workbench.addons.perspectiveswitcher.PerspectiveSwitcher.14
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.e4.ui.workbench.addons.perspectiveswitcher;

import org.eclipse.swt.widgets.Menu;

class PerspectiveSwitcher$15$1
  implements Runnable
{
  PerspectiveSwitcher$15$1(PerspectiveSwitcher.15 param15, Menu paramMenu) {}
  
  public void run()
  {
    val$menu.dispose();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.e4.ui.workbench.addons.perspectiveswitcher.PerspectiveSwitcher.15.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.e4.ui.workbench.addons.perspectiveswitcher;

import org.eclipse.swt.events.MenuEvent;
import org.eclipse.swt.events.MenuListener;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.ToolBar;

class PerspectiveSwitcher$15
  implements MenuListener
{
  PerspectiveSwitcher$15(PerspectiveSwitcher paramPerspectiveSwitcher, Menu paramMenu) {}
  
  public void menuHidden(MenuEvent e)
  {
    PerspectiveSwitcher.access$0(this$0).getDisplay().asyncExec(new Runnable()
    {
      public void run()
      {
        val$menu.dispose();
      }
    });
  }
  
  public void menuShown(MenuEvent e) {}
}

/* Location:
 * Qualified Name:     org.eclipse.e4.ui.workbench.addons.perspectiveswitcher.PerspectiveSwitcher.15
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.e4.ui.workbench.addons.perspectiveswitcher;

import org.eclipse.e4.ui.model.application.ui.advanced.MPerspective;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Menu;

class PerspectiveSwitcher$16
  extends SelectionAdapter
{
  PerspectiveSwitcher$16(PerspectiveSwitcher paramPerspectiveSwitcher, Menu paramMenu) {}
  
  public void widgetSelected(SelectionEvent e)
  {
    MPerspective persp = (MPerspective)val$menu.getData();
    if (persp != null) {
      PerspectiveSwitcher.access$7(this$0, persp);
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.e4.ui.workbench.addons.perspectiveswitcher.PerspectiveSwitcher.16
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.e4.ui.workbench.addons.perspectiveswitcher;

import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.commands.NotEnabledException;
import org.eclipse.core.commands.NotHandledException;
import org.eclipse.core.commands.common.NotDefinedException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.handlers.IHandlerService;
import org.eclipse.ui.statushandlers.StatusManager;

class PerspectiveSwitcher$17
  extends SelectionAdapter
{
  PerspectiveSwitcher$17(PerspectiveSwitcher paramPerspectiveSwitcher, IWorkbenchWindow paramIWorkbenchWindow) {}
  
  public void widgetSelected(SelectionEvent event)
  {
    if (PerspectiveSwitcher.access$0(this$0).isDisposed()) {
      return;
    }
    IHandlerService handlerService = (IHandlerService)val$workbenchWindow
      .getService(IHandlerService.class);
    IStatus status = Status.OK_STATUS;
    try
    {
      handlerService.executeCommand(
        "org.eclipse.ui.window.savePerspective", null);
    }
    catch (ExecutionException e)
    {
      status = new Status(4, "org.eclipse.ui", e.getMessage(), e);
    }
    catch (NotDefinedException e)
    {
      status = new Status(4, "org.eclipse.ui", e.getMessage(), e);
    }
    catch (NotEnabledException e)
    {
      status = new Status(4, "org.eclipse.ui", e.getMessage(), e);
    }
    catch (NotHandledException localNotHandledException) {}
    if (!status.isOK()) {
      StatusManager.getManager().handle(status, 
        3);
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.e4.ui.workbench.addons.perspectiveswitcher.PerspectiveSwitcher.17
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.e4.ui.workbench.addons.perspectiveswitcher;

import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.commands.NotEnabledException;
import org.eclipse.core.commands.NotHandledException;
import org.eclipse.core.commands.common.NotDefinedException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.handlers.IHandlerService;
import org.eclipse.ui.statushandlers.StatusManager;

class PerspectiveSwitcher$18
  extends SelectionAdapter
{
  PerspectiveSwitcher$18(PerspectiveSwitcher paramPerspectiveSwitcher, IWorkbenchWindow paramIWorkbenchWindow) {}
  
  public void widgetSelected(SelectionEvent event)
  {
    if (PerspectiveSwitcher.access$0(this$0).isDisposed()) {
      return;
    }
    IHandlerService handlerService = (IHandlerService)val$workbenchWindow
      .getService(IHandlerService.class);
    IStatus status = Status.OK_STATUS;
    try
    {
      handlerService.executeCommand(
        "org.eclipse.ui.window.resetPerspective", null);
    }
    catch (ExecutionException e)
    {
      status = new Status(4, "org.eclipse.ui", e.getMessage(), e);
    }
    catch (NotDefinedException e)
    {
      status = new Status(4, "org.eclipse.ui", e.getMessage(), e);
    }
    catch (NotEnabledException e)
    {
      status = new Status(4, "org.eclipse.ui", e.getMessage(), e);
    }
    catch (NotHandledException localNotHandledException) {}
    if (!status.isOK()) {
      StatusManager.getManager().handle(status, 
        3);
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.e4.ui.workbench.addons.perspectiveswitcher.PerspectiveSwitcher.18
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.e4.ui.workbench.addons.perspectiveswitcher;

import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.ui.internal.util.PrefUtil;

class PerspectiveSwitcher$19
  extends SelectionAdapter
{
  PerspectiveSwitcher$19(PerspectiveSwitcher paramPerspectiveSwitcher, MenuItem paramMenuItem) {}
  
  public void widgetSelected(SelectionEvent e)
  {
    boolean preference = val$showtextMenuItem.getSelection();
    if (preference != PrefUtil.getAPIPreferenceStore().getDefaultBoolean("SHOW_TEXT_ON_PERSPECTIVE_BAR")) {
      PrefUtil.getInternalPreferenceStore().setValue(
        "overridepresentation", true);
    }
    PrefUtil.getAPIPreferenceStore().setValue(
      "SHOW_TEXT_ON_PERSPECTIVE_BAR", preference);
    PerspectiveSwitcher.access$8(this$0, preference);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.e4.ui.workbench.addons.perspectiveswitcher.PerspectiveSwitcher.19
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.e4.ui.workbench.addons.perspectiveswitcher;

import org.eclipse.e4.ui.model.application.ui.MElementContainer;
import org.eclipse.e4.ui.model.application.ui.MUIElement;
import org.eclipse.e4.ui.model.application.ui.advanced.MPerspective;
import org.eclipse.e4.ui.model.application.ui.basic.MWindow;
import org.eclipse.e4.ui.workbench.modeling.EModelService;
import org.eclipse.swt.widgets.ToolBar;
import org.osgi.service.event.Event;
import org.osgi.service.event.EventHandler;

class PerspectiveSwitcher$2
  implements EventHandler
{
  PerspectiveSwitcher$2(PerspectiveSwitcher paramPerspectiveSwitcher) {}
  
  public void handleEvent(Event event)
  {
    if (PerspectiveSwitcher.access$0(this$0).isDisposed()) {
      return;
    }
    MUIElement changedElement = (MUIElement)event.getProperty("ChangedElement");
    if ((PerspectiveSwitcher.access$1(this$0) == null) || (!(changedElement instanceof MPerspective))) {
      return;
    }
    MWindow perspWin = this$0.modelService.getTopLevelWindowFor(changedElement);
    MWindow switcherWin = this$0.modelService.getTopLevelWindowFor(PerspectiveSwitcher.access$1(this$0));
    if (perspWin != switcherWin) {
      return;
    }
    MPerspective persp = (MPerspective)changedElement;
    if (!persp.getParent().isToBeRendered()) {
      return;
    }
    if (changedElement.isToBeRendered()) {
      PerspectiveSwitcher.access$2(this$0, persp);
    } else {
      PerspectiveSwitcher.access$3(this$0, persp);
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.e4.ui.workbench.addons.perspectiveswitcher.PerspectiveSwitcher.2
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.e4.ui.workbench.addons.perspectiveswitcher;

import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;

class PerspectiveSwitcher$20
  implements IPropertyChangeListener
{
  PerspectiveSwitcher$20(PerspectiveSwitcher paramPerspectiveSwitcher) {}
  
  public void propertyChange(PropertyChangeEvent propertyChangeEvent)
  {
    if ("SHOW_TEXT_ON_PERSPECTIVE_BAR".equals(propertyChangeEvent.getProperty()))
    {
      Object newValue = propertyChangeEvent.getNewValue();
      boolean showText = true;
      if ((newValue instanceof Boolean)) {
        showText = ((Boolean)newValue).booleanValue();
      } else if ("false".equals(newValue)) {
        showText = false;
      }
      PerspectiveSwitcher.access$8(this$0, showText);
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.e4.ui.workbench.addons.perspectiveswitcher.PerspectiveSwitcher.20
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.e4.ui.workbench.addons.perspectiveswitcher;

import org.eclipse.e4.ui.model.application.ui.MUIElement;
import org.eclipse.e4.ui.model.application.ui.advanced.MPerspective;
import org.eclipse.e4.ui.model.application.ui.basic.MWindow;
import org.eclipse.e4.ui.workbench.modeling.EModelService;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.ToolItem;
import org.eclipse.ui.internal.util.PrefUtil;
import org.osgi.service.event.Event;
import org.osgi.service.event.EventHandler;

class PerspectiveSwitcher$3
  implements EventHandler
{
  PerspectiveSwitcher$3(PerspectiveSwitcher paramPerspectiveSwitcher) {}
  
  public void handleEvent(Event event)
  {
    if (PerspectiveSwitcher.access$0(this$0).isDisposed()) {
      return;
    }
    MUIElement changedElement = (MUIElement)event.getProperty("ChangedElement");
    if ((PerspectiveSwitcher.access$1(this$0) == null) || (!(changedElement instanceof MPerspective))) {
      return;
    }
    String attName = (String)event.getProperty("AttName");
    Object newValue = event.getProperty("NewValue");
    
    MWindow perspWin = this$0.modelService.getTopLevelWindowFor(changedElement);
    MWindow switcherWin = this$0.modelService.getTopLevelWindowFor(PerspectiveSwitcher.access$1(this$0));
    if (perspWin != switcherWin) {
      return;
    }
    MPerspective perspective = (MPerspective)changedElement;
    if (!perspective.isToBeRendered()) {
      return;
    }
    ToolItem[] arrayOfToolItem;
    int j = (arrayOfToolItem = PerspectiveSwitcher.access$0(this$0).getItems()).length;
    for (int i = 0; i < j; i++)
    {
      ToolItem ti = arrayOfToolItem[i];
      if (ti.getData() == perspective) {
        updateToolItem(ti, attName, newValue);
      }
    }
    PerspectiveSwitcher.access$4(this$0);
  }
  
  private void updateToolItem(ToolItem ti, String attName, Object newValue)
  {
    boolean showText = PrefUtil.getAPIPreferenceStore().getBoolean(
      "SHOW_TEXT_ON_PERSPECTIVE_BAR");
    if ((showText) && ("label".equals(attName)))
    {
      String newName = (String)newValue;
      ti.setText(newName);
    }
    else if ("tooltip".equals(attName))
    {
      String newTTip = (String)newValue;
      ti.setToolTipText(newTTip);
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.e4.ui.workbench.addons.perspectiveswitcher.PerspectiveSwitcher.3
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.e4.ui.workbench.addons.perspectiveswitcher;

import org.eclipse.e4.ui.model.application.ui.MUIElement;
import org.eclipse.e4.ui.model.application.ui.advanced.MPerspective;
import org.eclipse.e4.ui.model.application.ui.advanced.MPerspectiveStack;
import org.eclipse.e4.ui.model.application.ui.basic.MWindow;
import org.eclipse.e4.ui.workbench.UIEvents;
import org.eclipse.e4.ui.workbench.modeling.EModelService;
import org.eclipse.swt.widgets.ToolBar;
import org.osgi.service.event.Event;
import org.osgi.service.event.EventHandler;

class PerspectiveSwitcher$4
  implements EventHandler
{
  PerspectiveSwitcher$4(PerspectiveSwitcher paramPerspectiveSwitcher) {}
  
  public void handleEvent(Event event)
  {
    if (PerspectiveSwitcher.access$0(this$0).isDisposed()) {
      return;
    }
    Object changedObj = event.getProperty("ChangedElement");
    if ((PerspectiveSwitcher.access$1(this$0) == null) || (!(changedObj instanceof MPerspectiveStack))) {
      return;
    }
    MWindow perspWin = this$0.modelService.getTopLevelWindowFor((MUIElement)changedObj);
    MWindow switcherWin = this$0.modelService.getTopLevelWindowFor(PerspectiveSwitcher.access$1(this$0));
    if (perspWin != switcherWin) {
      return;
    }
    if (UIEvents.isADD(event)) {
      for (Object o : UIEvents.asIterable(event, "NewValue"))
      {
        MPerspective added = (MPerspective)o;
        if (added.isToBeRendered()) {
          PerspectiveSwitcher.access$2(this$0, added);
        }
      }
    } else if (UIEvents.isREMOVE(event)) {
      for (Object o : UIEvents.asIterable(event, "OldValue"))
      {
        MPerspective removed = (MPerspective)o;
        if (removed.isToBeRendered()) {
          PerspectiveSwitcher.access$3(this$0, removed);
        }
      }
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.e4.ui.workbench.addons.perspectiveswitcher.PerspectiveSwitcher.4
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.e4.ui.workbench.addons.perspectiveswitcher;

import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;

class PerspectiveSwitcher$5
  implements PaintListener
{
  PerspectiveSwitcher$5(PerspectiveSwitcher paramPerspectiveSwitcher) {}
  
  public void paintControl(PaintEvent e)
  {
    this$0.paint(e);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.e4.ui.workbench.addons.perspectiveswitcher.PerspectiveSwitcher.5
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.e4.ui.workbench.addons.perspectiveswitcher;

import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;

class PerspectiveSwitcher$6
  implements PaintListener
{
  PerspectiveSwitcher$6(PerspectiveSwitcher paramPerspectiveSwitcher) {}
  
  public void paintControl(PaintEvent e)
  {
    if (this$0.borderColor == null) {
      this$0.borderColor = display.getSystemColor(2);
    }
    gc.setForeground(this$0.borderColor);
    Rectangle bounds = ((Control)widget).getBounds();
    gc.drawLine(0, height - 1, width, height - 1);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.e4.ui.workbench.addons.perspectiveswitcher.PerspectiveSwitcher.6
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.e4.ui.workbench.addons.perspectiveswitcher;

import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;

class PerspectiveSwitcher$7
  implements DisposeListener
{
  PerspectiveSwitcher$7(PerspectiveSwitcher paramPerspectiveSwitcher) {}
  
  public void widgetDisposed(DisposeEvent e)
  {
    this$0.dispose();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.e4.ui.workbench.addons.perspectiveswitcher.PerspectiveSwitcher.7
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.e4.ui.workbench.addons.perspectiveswitcher;

import org.eclipse.e4.ui.model.application.ui.advanced.MPerspective;
import org.eclipse.swt.events.MenuDetectEvent;
import org.eclipse.swt.events.MenuDetectListener;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.ToolItem;
import org.eclipse.ui.internal.e4.compatibility.E4Util;

class PerspectiveSwitcher$8
  implements MenuDetectListener
{
  PerspectiveSwitcher$8(PerspectiveSwitcher paramPerspectiveSwitcher) {}
  
  public void menuDetected(MenuDetectEvent e)
  {
    ToolBar tb = (ToolBar)widget;
    Point p = new Point(x, y);
    p = PerspectiveSwitcher.access$0(this$0).getDisplay().map(null, PerspectiveSwitcher.access$0(this$0), p);
    ToolItem item = tb.getItem(p);
    if (item == null)
    {
      E4Util.message("  ToolBar menu");
    }
    else
    {
      MPerspective persp = (MPerspective)item.getData();
      if (persp == null) {
        E4Util.message("  Add button Menu");
      } else {
        PerspectiveSwitcher.access$5(this$0, item, persp);
      }
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.e4.ui.workbench.addons.perspectiveswitcher.PerspectiveSwitcher.8
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.e4.ui.workbench.addons.perspectiveswitcher;

import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;

class PerspectiveSwitcher$9
  implements DisposeListener
{
  PerspectiveSwitcher$9(PerspectiveSwitcher paramPerspectiveSwitcher) {}
  
  public void widgetDisposed(DisposeEvent e)
  {
    this$0.disposeTBImages();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.e4.ui.workbench.addons.perspectiveswitcher.PerspectiveSwitcher.9
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.e4.ui.workbench.addons.perspectiveswitcher;

import java.util.Collections;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.inject.Inject;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.commands.NotEnabledException;
import org.eclipse.core.commands.NotHandledException;
import org.eclipse.core.commands.ParameterizedCommand;
import org.eclipse.core.commands.common.NotDefinedException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.e4.core.commands.ECommandService;
import org.eclipse.e4.core.commands.EHandlerService;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.core.services.events.IEventBroker;
import org.eclipse.e4.ui.model.application.ui.MElementContainer;
import org.eclipse.e4.ui.model.application.ui.MUIElement;
import org.eclipse.e4.ui.model.application.ui.SideValue;
import org.eclipse.e4.ui.model.application.ui.advanced.MPerspective;
import org.eclipse.e4.ui.model.application.ui.advanced.MPerspectiveStack;
import org.eclipse.e4.ui.model.application.ui.basic.MTrimBar;
import org.eclipse.e4.ui.model.application.ui.basic.MWindow;
import org.eclipse.e4.ui.model.application.ui.menu.MToolControl;
import org.eclipse.e4.ui.workbench.UIEvents;
import org.eclipse.e4.ui.workbench.modeling.EModelService;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.swt.accessibility.Accessible;
import org.eclipse.swt.accessibility.AccessibleAdapter;
import org.eclipse.swt.accessibility.AccessibleEvent;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.MenuDetectEvent;
import org.eclipse.swt.events.MenuDetectListener;
import org.eclipse.swt.events.MenuEvent;
import org.eclipse.swt.events.MenuListener;
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.graphics.Region;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.ToolItem;
import org.eclipse.swt.widgets.Widget;
import org.eclipse.ui.IPerspectiveDescriptor;
import org.eclipse.ui.IPerspectiveRegistry;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.handlers.IHandlerService;
import org.eclipse.ui.help.IWorkbenchHelpSystem;
import org.eclipse.ui.internal.WorkbenchImages;
import org.eclipse.ui.internal.WorkbenchMessages;
import org.eclipse.ui.internal.WorkbenchPage;
import org.eclipse.ui.internal.e4.compatibility.E4Util;
import org.eclipse.ui.internal.registry.PerspectiveRegistry;
import org.eclipse.ui.internal.util.PrefUtil;
import org.eclipse.ui.statushandlers.StatusManager;
import org.osgi.service.event.EventHandler;

public class PerspectiveSwitcher
{
  public static final String PERSPECTIVE_SWITCHER_ID = "org.eclipse.e4.ui.PerspectiveSwitcher";
  @Inject
  protected IEventBroker eventBroker;
  @Inject
  EModelService modelService;
  @Inject
  private EHandlerService handlerService;
  @Inject
  private ECommandService commandService;
  @Inject
  private MWindow window;
  private MToolControl psME;
  private ToolBar psTB;
  private Composite comp;
  private Image backgroundImage;
  private Image perspectiveImage;
  Color borderColor;
  Color curveColor;
  Control toolParent;
  IPropertyChangeListener propertyChangeListener;
  private EventHandler selectionHandler = new EventHandler()
  {
    public void handleEvent(org.osgi.service.event.Event event)
    {
      if (psTB.isDisposed()) {
        return;
      }
      MUIElement changedElement = (MUIElement)event.getProperty("ChangedElement");
      if ((psME == null) || (!(changedElement instanceof MPerspectiveStack))) {
        return;
      }
      MWindow perspWin = modelService.getTopLevelWindowFor(changedElement);
      MWindow switcherWin = modelService.getTopLevelWindowFor(psME);
      if (perspWin != switcherWin) {
        return;
      }
      MPerspectiveStack perspStack = (MPerspectiveStack)changedElement;
      if (!perspStack.isToBeRendered()) {
        return;
      }
      MPerspective selElement = (MPerspective)perspStack.getSelectedElement();
      ToolItem[] arrayOfToolItem;
      int j = (arrayOfToolItem = psTB.getItems()).length;
      for (int i = 0; i < j; i++)
      {
        ToolItem ti = arrayOfToolItem[i];
        ti.setSelection(ti.getData() == selElement);
      }
    }
  };
  private EventHandler toBeRenderedHandler = new EventHandler()
  {
    public void handleEvent(org.osgi.service.event.Event event)
    {
      if (psTB.isDisposed()) {
        return;
      }
      MUIElement changedElement = (MUIElement)event.getProperty("ChangedElement");
      if ((psME == null) || (!(changedElement instanceof MPerspective))) {
        return;
      }
      MWindow perspWin = modelService.getTopLevelWindowFor(changedElement);
      MWindow switcherWin = modelService.getTopLevelWindowFor(psME);
      if (perspWin != switcherWin) {
        return;
      }
      MPerspective persp = (MPerspective)changedElement;
      if (!persp.getParent().isToBeRendered()) {
        return;
      }
      if (changedElement.isToBeRendered()) {
        PerspectiveSwitcher.this.addPerspectiveItem(persp);
      } else {
        PerspectiveSwitcher.this.removePerspectiveItem(persp);
      }
    }
  };
  private EventHandler labelHandler = new EventHandler()
  {
    public void handleEvent(org.osgi.service.event.Event event)
    {
      if (psTB.isDisposed()) {
        return;
      }
      MUIElement changedElement = (MUIElement)event.getProperty("ChangedElement");
      if ((psME == null) || (!(changedElement instanceof MPerspective))) {
        return;
      }
      String attName = (String)event.getProperty("AttName");
      Object newValue = event.getProperty("NewValue");
      
      MWindow perspWin = modelService.getTopLevelWindowFor(changedElement);
      MWindow switcherWin = modelService.getTopLevelWindowFor(psME);
      if (perspWin != switcherWin) {
        return;
      }
      MPerspective perspective = (MPerspective)changedElement;
      if (!perspective.isToBeRendered()) {
        return;
      }
      ToolItem[] arrayOfToolItem;
      int j = (arrayOfToolItem = psTB.getItems()).length;
      for (int i = 0; i < j; i++)
      {
        ToolItem ti = arrayOfToolItem[i];
        if (ti.getData() == perspective) {
          updateToolItem(ti, attName, newValue);
        }
      }
      PerspectiveSwitcher.this.fixSize();
    }
    
    private void updateToolItem(ToolItem ti, String attName, Object newValue)
    {
      boolean showText = PrefUtil.getAPIPreferenceStore().getBoolean(
        "SHOW_TEXT_ON_PERSPECTIVE_BAR");
      if ((showText) && ("label".equals(attName)))
      {
        String newName = (String)newValue;
        ti.setText(newName);
      }
      else if ("tooltip".equals(attName))
      {
        String newTTip = (String)newValue;
        ti.setToolTipText(newTTip);
      }
    }
  };
  private EventHandler childrenHandler = new EventHandler()
  {
    public void handleEvent(org.osgi.service.event.Event event)
    {
      if (psTB.isDisposed()) {
        return;
      }
      Object changedObj = event.getProperty("ChangedElement");
      if ((psME == null) || (!(changedObj instanceof MPerspectiveStack))) {
        return;
      }
      MWindow perspWin = modelService.getTopLevelWindowFor((MUIElement)changedObj);
      MWindow switcherWin = modelService.getTopLevelWindowFor(psME);
      if (perspWin != switcherWin) {
        return;
      }
      if (UIEvents.isADD(event)) {
        for (Object o : UIEvents.asIterable(event, "NewValue"))
        {
          MPerspective added = (MPerspective)o;
          if (added.isToBeRendered()) {
            PerspectiveSwitcher.this.addPerspectiveItem(added);
          }
        }
      } else if (UIEvents.isREMOVE(event)) {
        for (Object o : UIEvents.asIterable(event, "OldValue"))
        {
          MPerspective removed = (MPerspective)o;
          if (removed.isToBeRendered()) {
            PerspectiveSwitcher.this.removePerspectiveItem(removed);
          }
        }
      }
    }
  };
  
  @PostConstruct
  void init()
  {
    eventBroker.subscribe("org/eclipse/e4/ui/model/ui/ElementContainer/children/*", childrenHandler);
    eventBroker.subscribe("org/eclipse/e4/ui/model/ui/UIElement/toBeRendered/*", 
      toBeRenderedHandler);
    eventBroker.subscribe("org/eclipse/e4/ui/model/ui/ElementContainer/selectedElement/*", selectionHandler);
    eventBroker.subscribe("org/eclipse/e4/ui/model/ui/UILabel/*", 
      labelHandler);
    
    setPropertyChangeListener();
  }
  
  @PreDestroy
  void cleanUp()
  {
    if (perspectiveImage != null)
    {
      perspectiveImage.dispose();
      perspectiveImage = null;
    }
    eventBroker.unsubscribe(toBeRenderedHandler);
    eventBroker.unsubscribe(childrenHandler);
    eventBroker.unsubscribe(selectionHandler);
    eventBroker.unsubscribe(labelHandler);
    
    PrefUtil.getAPIPreferenceStore().removePropertyChangeListener(propertyChangeListener);
  }
  
  @PostConstruct
  void createWidget(Composite parent, MToolControl toolControl)
  {
    psME = toolControl;
    MUIElement meParent = psME.getParent();
    int orientation = 256;
    if ((meParent instanceof MTrimBar))
    {
      MTrimBar bar = (MTrimBar)meParent;
      if ((bar.getSide() == SideValue.RIGHT) || (bar.getSide() == SideValue.LEFT)) {
        orientation = 512;
      }
    }
    comp = new Composite(parent, 0);
    RowLayout layout = new RowLayout(256);
    marginLeft = (marginRight = 8);
    marginBottom = 4;
    marginTop = 6;
    comp.setLayout(layout);
    psTB = new ToolBar(comp, 0x800040 | 131072 + orientation);
    comp.addPaintListener(new PaintListener()
    {
      public void paintControl(PaintEvent e)
      {
        paint(e);
      }
    });
    toolParent = ((Control)toolControl.getParent().getWidget());
    toolParent.addPaintListener(new PaintListener()
    {
      public void paintControl(PaintEvent e)
      {
        if (borderColor == null) {
          borderColor = display.getSystemColor(2);
        }
        gc.setForeground(borderColor);
        Rectangle bounds = ((Control)widget).getBounds();
        gc.drawLine(0, height - 1, width, height - 1);
      }
    });
    comp.addDisposeListener(new DisposeListener()
    {
      public void widgetDisposed(DisposeEvent e)
      {
        dispose();
      }
    });
    psTB.addMenuDetectListener(new MenuDetectListener()
    {
      public void menuDetected(MenuDetectEvent e)
      {
        ToolBar tb = (ToolBar)widget;
        Point p = new Point(x, y);
        p = psTB.getDisplay().map(null, psTB, p);
        ToolItem item = tb.getItem(p);
        if (item == null)
        {
          E4Util.message("  ToolBar menu");
        }
        else
        {
          MPerspective persp = (MPerspective)item.getData();
          if (persp == null) {
            E4Util.message("  Add button Menu");
          } else {
            PerspectiveSwitcher.this.openMenuFor(item, persp);
          }
        }
      }
    });
    psTB.addDisposeListener(new DisposeListener()
    {
      public void widgetDisposed(DisposeEvent e)
      {
        disposeTBImages();
      }
    });
    psTB.getAccessible().addAccessibleListener(new AccessibleAdapter()
    {
      public void getName(AccessibleEvent e)
      {
        if ((childID >= 0) && (childID < psTB.getItemCount()))
        {
          ToolItem item = psTB.getItem(childID);
          if (item != null) {
            result = item.getToolTipText();
          }
        }
      }
    });
    ToolItem createItem = new ToolItem(psTB, 8);
    createItem.setImage(getOpenPerspectiveImage());
    createItem.setToolTipText(WorkbenchMessages.OpenPerspectiveDialogAction_tooltip);
    createItem.addSelectionListener(new SelectionListener()
    {
      public void widgetSelected(SelectionEvent e)
      {
        PerspectiveSwitcher.this.selectPerspective();
      }
      
      public void widgetDefaultSelected(SelectionEvent e)
      {
        PerspectiveSwitcher.this.selectPerspective();
      }
    });
    new ToolItem(psTB, 2);
    
    MPerspectiveStack stack = getPerspectiveStack();
    if (stack != null) {
      for (MPerspective persp : stack.getChildren()) {
        if (persp.isToBeRendered()) {
          addPerspectiveItem(persp);
        }
      }
    }
  }
  
  private Image getOpenPerspectiveImage()
  {
    if ((perspectiveImage == null) || (perspectiveImage.isDisposed()))
    {
      ImageDescriptor desc = 
        WorkbenchImages.getImageDescriptor("IMG_ETOOL_NEW_PAGE");
      perspectiveImage = desc.createImage();
    }
    return perspectiveImage;
  }
  
  MPerspectiveStack getPerspectiveStack()
  {
    List<MPerspectiveStack> psList = modelService.findElements(window, null, 
      MPerspectiveStack.class, null);
    if (psList.size() > 0) {
      return (MPerspectiveStack)psList.get(0);
    }
    return null;
  }
  
  private ToolItem addPerspectiveItem(MPerspective persp)
  {
    final ToolItem psItem = new ToolItem(psTB, 16);
    psItem.setData(persp);
    IPerspectiveDescriptor descriptor = getDescriptorFor(persp.getElementId());
    boolean foundImage = false;
    if (descriptor != null)
    {
      ImageDescriptor desc = descriptor.getImageDescriptor();
      if (desc != null)
      {
        final Image image = desc.createImage(false);
        if (image != null)
        {
          psItem.setImage(image);
          
          psItem.addListener(12, new Listener()
          {
            public void handleEvent(org.eclipse.swt.widgets.Event event)
            {
              image.dispose();
            }
          });
          foundImage = true;
          psItem.setToolTipText(persp.getLocalizedLabel());
        }
      }
    }
    if ((!foundImage) || 
    
      (PrefUtil.getAPIPreferenceStore().getBoolean("SHOW_TEXT_ON_PERSPECTIVE_BAR")))
    {
      psItem.setText(persp.getLocalizedLabel());
      psItem.setToolTipText(persp.getLocalizedTooltip());
    }
    psItem.setSelection(persp == persp.getParent().getSelectedElement());
    
    psItem.addSelectionListener(new SelectionListener()
    {
      public void widgetSelected(SelectionEvent e)
      {
        MPerspective persp = (MPerspective)widget.getData();
        persp.getParent().setSelectedElement(persp);
      }
      
      public void widgetDefaultSelected(SelectionEvent e)
      {
        MPerspective persp = (MPerspective)widget.getData();
        persp.getParent().setSelectedElement(persp);
      }
    });
    psItem.addListener(35, new Listener()
    {
      public void handleEvent(org.eclipse.swt.widgets.Event event)
      {
        MPerspective persp = (MPerspective)widget.getData();
        PerspectiveSwitcher.this.openMenuFor(psItem, persp);
      }
    });
    fixSize();
    
    return psItem;
  }
  
  private IPerspectiveDescriptor getDescriptorFor(String id)
  {
    IPerspectiveRegistry perspectiveRegist
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 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179

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