org.eclipse.emf.edit.ui_2.7.0.v20120130-0943

lic DragAndDropCommandInformation(EditingDomain domain, Object target, float location, int operations, int operation, Collection<?> source)
    {
      this.domain = domain;
      this.target = target;
      this.location = location;
      this.operations = operations;
      this.operation = operation;
      this.source = new ArrayList(source);
    }
    
    public Command createCommand()
    {
      return DragAndDropCommand.create(domain, target, location, operations, operation, source);
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.edit.ui.dnd.EditingDomainViewerDropAdapter
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.edit.ui.dnd;

import org.eclipse.swt.dnd.ByteArrayTransfer;
import org.eclipse.swt.dnd.TransferData;

public class LocalTransfer
  extends ByteArrayTransfer
{
  protected static final String TYPE_NAME = "local-transfer-format";
  protected static final int TYPE_ID = registerType("local-transfer-format");
  protected static LocalTransfer instance;
  protected long startTime;
  protected Object object;
  
  public static LocalTransfer getInstance()
  {
    if (instance == null) {
      instance = new LocalTransfer();
    }
    return instance;
  }
  
  protected int[] getTypeIds()
  {
    return new int[] { TYPE_ID };
  }
  
  public String[] getTypeNames()
  {
    return new String[] { "local-transfer-format" };
  }
  
  public void javaToNative(Object object, TransferData transferData)
  {
    startTime = System.currentTimeMillis();
    this.object = object;
    if (transferData != null) {
      super.javaToNative(String.valueOf(startTime).getBytes(), transferData);
    }
  }
  
  public Object nativeToJava(TransferData transferData)
  {
    byte[] bytes = (byte[])super.nativeToJava(transferData);
    if (bytes == null) {
      return null;
    }
    try
    {
      long startTime = Long.parseLong(new String(bytes));
      return this.startTime == startTime ? object : null;
    }
    catch (NumberFormatException exception) {}
    return null;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.edit.ui.dnd.LocalTransfer
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.edit.ui.dnd;

import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.dnd.DragSourceEvent;
import org.eclipse.swt.dnd.DragSourceListener;

public class ViewerDragAdapter
  implements DragSourceListener
{
  protected Viewer viewer;
  protected ISelection selection;
  
  public ViewerDragAdapter(Viewer viewer)
  {
    this.viewer = viewer;
  }
  
  public void dragStart(DragSourceEvent event)
  {
    selection = viewer.getSelection();
  }
  
  public void dragFinished(DragSourceEvent event)
  {
    selection = null;
    LocalTransfer.getInstance().javaToNative(null, null);
  }
  
  public void dragSetData(DragSourceEvent event)
  {
    if (LocalTransfer.getInstance().isSupportedType(dataType)) {
      data = selection;
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.edit.ui.dnd.ViewerDragAdapter
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.edit.ui.provider;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.emf.edit.provider.IViewerNotification;
import org.eclipse.emf.edit.provider.ViewerNotification;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.StructuredViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.widgets.Control;

public class AdapterFactoryContentProvider$ViewerRefresh
  implements Runnable
{
  Viewer viewer;
  List<IViewerNotification> notifications;
  boolean compatibility;
  
  public AdapterFactoryContentProvider$ViewerRefresh(Viewer viewer)
  {
    this.viewer = viewer;
  }
  
  @Deprecated
  public AdapterFactoryContentProvider$ViewerRefresh(Viewer viewer, IViewerNotification notification)
  {
    this.viewer = viewer;
    addNotification(notification);
    compatibility = true;
  }
  
  public synchronized boolean addNotification(IViewerNotification notification)
  {
    if (notifications == null) {
      notifications = new ArrayList();
    }
    if (notifications.isEmpty())
    {
      notifications.add(notification);
      return true;
    }
    if ((viewer instanceof StructuredViewer))
    {
      for (Iterator<IViewerNotification> i = notifications.iterator(); (i.hasNext()) && (notification != null);)
      {
        IViewerNotification old = (IViewerNotification)i.next();
        IViewerNotification merged = merge(old, notification);
        if (merged == old)
        {
          notification = null;
        }
        else if (merged != null)
        {
          notification = merged;
          i.remove();
        }
      }
      if (notification != null) {
        notifications.add(notification);
      }
    }
    return false;
  }
  
  protected IViewerNotification merge(IViewerNotification n1, IViewerNotification n2)
  {
    if ((n1.getElement() == null) && (n1.isLabelUpdate())) {
      return n1;
    }
    if ((n2.getElement() == null) && (n2.isLabelUpdate())) {
      return n2;
    }
    if (n1.getElement() == null)
    {
      if (n2.isLabelUpdate()) {
        n1 = new ViewerNotification(n1);
      }
      return n1;
    }
    if (n2.getElement() == null)
    {
      if (n1.isLabelUpdate()) {
        n2 = new ViewerNotification(n2);
      }
      return n2;
    }
    if (n1.getElement() == n2.getElement())
    {
      if ((n1.isContentRefresh()) && (n1.isLabelUpdate())) {
        return n1;
      }
      if ((n2.isContentRefresh()) && (n2.isLabelUpdate())) {
        return n2;
      }
      if (n1.isContentRefresh())
      {
        if (n2.isLabelUpdate()) {
          n1 = new ViewerNotification(n1, n1.getElement(), true, true);
        }
        return n1;
      }
      if (n2.isContentRefresh())
      {
        if (n1.isLabelUpdate()) {
          n2 = new ViewerNotification(n2, n2.getElement(), true, true);
        }
        return n2;
      }
      if (n1.isLabelUpdate()) {
        return n1;
      }
      return n2;
    }
    return null;
  }
  
  public void run()
  {
    if ((viewer != null) && (viewer.getControl() != null) && (!viewer.getControl().isDisposed()))
    {
      synchronized (this)
      {
        List<IViewerNotification> current = notifications;
        notifications = null;
      }
      List<IViewerNotification> current;
      if (current != null) {
        for (IViewerNotification viewerNotification : current) {
          refresh(viewerNotification);
        }
      }
    }
  }
  
  protected void refresh(IViewerNotification notification)
  {
    if ((compatibility) && (notification.getEventType() == 9)) {
      return;
    }
    Object element = notification.getElement();
    if ((viewer instanceof StructuredViewer))
    {
      StructuredViewer structuredViewer = (StructuredViewer)viewer;
      
      ISelection selection = structuredViewer.getSelection();
      boolean isStaleSelection = AdapterFactoryEditingDomain.isStale(selection);
      if (isStaleSelection) {
        viewer.setSelection(StructuredSelection.EMPTY);
      }
      if (element != null)
      {
        if (notification.isContentRefresh()) {
          structuredViewer.refresh(element, notification.isLabelUpdate());
        } else if (notification.isLabelUpdate()) {
          structuredViewer.update(element, null);
        }
      }
      else {
        structuredViewer.refresh(notification.isLabelUpdate());
      }
      if (isStaleSelection)
      {
        Object object = structuredViewer.getInput();
        EditingDomain editingDomain = AdapterFactoryEditingDomain.getEditingDomainFor(object);
        if (editingDomain == null)
        {
          Object[] arrayOfObject;
          int j = (arrayOfObject = ((IStructuredContentProvider)structuredViewer.getContentProvider()).getElements(object)).length;
          for (int i = 0; i < j; i++)
          {
            Object child = arrayOfObject[i];
            
            editingDomain = AdapterFactoryEditingDomain.getEditingDomainFor(child);
            if (editingDomain != null) {
              break;
            }
          }
        }
        if ((editingDomain instanceof AdapterFactoryEditingDomain)) {
          structuredViewer.setSelection(
            new StructuredSelection(((AdapterFactoryEditingDomain)editingDomain).resolve(((IStructuredSelection)selection).toList())), true);
        }
      }
    }
    else
    {
      viewer.refresh();
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider.ViewerRefresh
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.edit.ui.provider;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import org.eclipse.emf.common.notify.AdapterFactory;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.emf.edit.provider.IChangeNotifier;
import org.eclipse.emf.edit.provider.IItemPropertySource;
import org.eclipse.emf.edit.provider.INotifyChangedListener;
import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
import org.eclipse.emf.edit.provider.IViewerNotification;
import org.eclipse.emf.edit.provider.ViewerNotification;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.StructuredViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.views.properties.IPropertySource;
import org.eclipse.ui.views.properties.IPropertySourceProvider;

public class AdapterFactoryContentProvider
  implements ITreeContentProvider, IPropertySourceProvider, INotifyChangedListener
{
  protected AdapterFactory adapterFactory;
  protected Viewer viewer;
  protected ViewerRefresh viewerRefresh;
  private static final Class<?> IStructuredItemContentProviderClass = IStructuredItemContentProvider.class;
  private static final Class<?> ITreeItemContentProviderClass = ITreeItemContentProvider.class;
  private static final Class<?> IItemPropertySourceClass = IItemPropertySource.class;
  
  public AdapterFactoryContentProvider(AdapterFactory adapterFactory)
  {
    this.adapterFactory = adapterFactory;
    if ((adapterFactory instanceof IChangeNotifier)) {
      ((IChangeNotifier)adapterFactory).addListener(this);
    }
  }
  
  public void setAdapterFactory(AdapterFactory adapterFactory)
  {
    if ((this.adapterFactory instanceof IChangeNotifier)) {
      ((IChangeNotifier)this.adapterFactory).removeListener(this);
    }
    if ((adapterFactory instanceof IChangeNotifier)) {
      ((IChangeNotifier)adapterFactory).addListener(this);
    }
    this.adapterFactory = adapterFactory;
  }
  
  public AdapterFactory getAdapterFactory()
  {
    return adapterFactory;
  }
  
  public void inputChanged(Viewer viewer, Object oldInput, Object newInput)
  {
    this.viewer = viewer;
  }
  
  public Object[] getElements(Object object)
  {
    IStructuredItemContentProvider structuredItemContentProvider = 
      (IStructuredItemContentProvider)adapterFactory.adapt(object, IStructuredItemContentProviderClass);
    
    return 
      (structuredItemContentProvider != null ? 
      structuredItemContentProvider.getElements(object) : 
      Collections.EMPTY_LIST).toArray();
  }
  
  public Object[] getChildren(Object object)
  {
    ITreeItemContentProvider treeItemContentProvider = 
      (ITreeItemContentProvider)adapterFactory.adapt(object, ITreeItemContentProviderClass);
    
    return 
      (treeItemContentProvider != null ? 
      treeItemContentProvider.getChildren(object) : 
      Collections.EMPTY_LIST).toArray();
  }
  
  public boolean hasChildren(Object object)
  {
    ITreeItemContentProvider treeItemContentProvider = 
      (ITreeItemContentProvider)adapterFactory.adapt(object, ITreeItemContentProviderClass);
    
    return (treeItemContentProvider != null) && (treeItemContentProvider.hasChildren(object));
  }
  
  public Object getParent(Object object)
  {
    ITreeItemContentProvider treeItemContentProvider = 
      (ITreeItemContentProvider)adapterFactory.adapt(object, ITreeItemContentProviderClass);
    
    return 
      treeItemContentProvider != null ? 
      treeItemContentProvider.getParent(object) : 
      null;
  }
  
  public void dispose()
  {
    if ((adapterFactory instanceof IChangeNotifier)) {
      ((IChangeNotifier)adapterFactory).removeListener(this);
    }
    viewer = null;
  }
  
  public IPropertySource getPropertySource(Object object)
  {
    if ((object instanceof IPropertySource)) {
      return (IPropertySource)object;
    }
    IItemPropertySource itemPropertySource = 
      (IItemPropertySource)
      (((object instanceof EObject)) && (((EObject)object).eClass() == null) ? 
      null : 
      adapterFactory.adapt(object, IItemPropertySourceClass));
    
    return 
      itemPropertySource != null ? createPropertySource(object, itemPropertySource) : null;
  }
  
  protected IPropertySource createPropertySource(Object object, IItemPropertySource itemPropertySource)
  {
    return new PropertySource(object, itemPropertySource);
  }
  
  public void notifyChanged(Notification notification)
  {
    if ((viewer != null) && (viewer.getControl() != null) && (!viewer.getControl().isDisposed())) {
      if ((notification instanceof IViewerNotification))
      {
        if (viewerRefresh == null) {
          viewerRefresh = new ViewerRefresh(viewer);
        }
        if (viewerRefresh.addNotification((IViewerNotification)notification)) {
          viewer.getControl().getDisplay().asyncExec(viewerRefresh);
        }
      }
      else
      {
        NotifyChangedToViewerRefresh.handleNotifyChanged(
          viewer, 
          notification.getNotifier(), 
          notification.getEventType(), 
          notification.getFeature(), 
          notification.getOldValue(), 
          notification.getNewValue(), 
          notification.getPosition());
      }
    }
  }
  
  public static class ViewerRefresh
    implements Runnable
  {
    Viewer viewer;
    List<IViewerNotification> notifications;
    boolean compatibility;
    
    public ViewerRefresh(Viewer viewer)
    {
      this.viewer = viewer;
    }
    
    @Deprecated
    public ViewerRefresh(Viewer viewer, IViewerNotification notification)
    {
      this.viewer = viewer;
      addNotification(notification);
      compatibility = true;
    }
    
    public synchronized boolean addNotification(IViewerNotification notification)
    {
      if (notifications == null) {
        notifications = new ArrayList();
      }
      if (notifications.isEmpty())
      {
        notifications.add(notification);
        return true;
      }
      if ((viewer instanceof StructuredViewer))
      {
        for (Iterator<IViewerNotification> i = notifications.iterator(); (i.hasNext()) && (notification != null);)
        {
          IViewerNotification old = (IViewerNotification)i.next();
          IViewerNotification merged = merge(old, notification);
          if (merged == old)
          {
            notification = null;
          }
          else if (merged != null)
          {
            notification = merged;
            i.remove();
          }
        }
        if (notification != null) {
          notifications.add(notification);
        }
      }
      return false;
    }
    
    protected IViewerNotification merge(IViewerNotification n1, IViewerNotification n2)
    {
      if ((n1.getElement() == null) && (n1.isLabelUpdate())) {
        return n1;
      }
      if ((n2.getElement() == null) && (n2.isLabelUpdate())) {
        return n2;
      }
      if (n1.getElement() == null)
      {
        if (n2.isLabelUpdate()) {
          n1 = new ViewerNotification(n1);
        }
        return n1;
      }
      if (n2.getElement() == null)
      {
        if (n1.isLabelUpdate()) {
          n2 = new ViewerNotification(n2);
        }
        return n2;
      }
      if (n1.getElement() == n2.getElement())
      {
        if ((n1.isContentRefresh()) && (n1.isLabelUpdate())) {
          return n1;
        }
        if ((n2.isContentRefresh()) && (n2.isLabelUpdate())) {
          return n2;
        }
        if (n1.isContentRefresh())
        {
          if (n2.isLabelUpdate()) {
            n1 = new ViewerNotification(n1, n1.getElement(), true, true);
          }
          return n1;
        }
        if (n2.isContentRefresh())
        {
          if (n1.isLabelUpdate()) {
            n2 = new ViewerNotification(n2, n2.getElement(), true, true);
          }
          return n2;
        }
        if (n1.isLabelUpdate()) {
          return n1;
        }
        return n2;
      }
      return null;
    }
    
    public void run()
    {
      if ((viewer != null) && (viewer.getControl() != null) && (!viewer.getControl().isDisposed()))
      {
        synchronized (this)
        {
          List<IViewerNotification> current = notifications;
          notifications = null;
        }
        List<IViewerNotification> current;
        if (current != null) {
          for (IViewerNotification viewerNotification : current) {
            refresh(viewerNotification);
          }
        }
      }
    }
    
    protected void refresh(IViewerNotification notification)
    {
      if ((compatibility) && (notification.getEventType() == 9)) {
        return;
      }
      Object element = notification.getElement();
      if ((viewer instanceof StructuredViewer))
      {
        StructuredViewer structuredViewer = (StructuredViewer)viewer;
        
        ISelection selection = structuredViewer.getSelection();
        boolean isStaleSelection = AdapterFactoryEditingDomain.isStale(selection);
        if (isStaleSelection) {
          viewer.setSelection(StructuredSelection.EMPTY);
        }
        if (element != null)
        {
          if (notification.isContentRefresh()) {
            structuredViewer.refresh(element, notification.isLabelUpdate());
          } else if (notification.isLabelUpdate()) {
            structuredViewer.update(element, null);
          }
        }
        else {
          structuredViewer.refresh(notification.isLabelUpdate());
        }
        if (isStaleSelection)
        {
          Object object = structuredViewer.getInput();
          EditingDomain editingDomain = AdapterFactoryEditingDomain.getEditingDomainFor(object);
          if (editingDomain == null)
          {
            Object[] arrayOfObject;
            int j = (arrayOfObject = ((IStructuredContentProvider)structuredViewer.getContentProvider()).getElements(object)).length;
            for (int i = 0; i < j; i++)
            {
              Object child = arrayOfObject[i];
              
              editingDomain = AdapterFactoryEditingDomain.getEditingDomainFor(child);
              if (editingDomain != null) {
                break;
              }
            }
          }
          if ((editingDomain instanceof AdapterFactoryEditingDomain)) {
            structuredViewer.setSelection(
              new StructuredSelection(((AdapterFactoryEditingDomain)editingDomain).resolve(((IStructuredSelection)selection).toList())), true);
          }
        }
      }
      else
      {
        viewer.refresh();
      }
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.edit.ui.provider;

import org.eclipse.emf.common.notify.AdapterFactory;
import org.eclipse.jface.viewers.IColorProvider;
import org.eclipse.jface.viewers.IFontProvider;
import org.eclipse.jface.viewers.ITableColorProvider;
import org.eclipse.jface.viewers.ITableFontProvider;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.widgets.Control;

public class AdapterFactoryLabelProvider$ColorProvider
  extends AdapterFactoryLabelProvider
  implements IColorProvider, IFontProvider, ITableColorProvider, ITableFontProvider
{
  public AdapterFactoryLabelProvider$ColorProvider(AdapterFactory adapterFactory, Color defaultForeground, Color defaultBackground)
  {
    super(adapterFactory);
    setDefaultForeground(defaultForeground);
    setDefaultBackground(defaultBackground);
  }
  
  public AdapterFactoryLabelProvider$ColorProvider(AdapterFactory adapterFactory, Viewer viewer)
  {
    this(adapterFactory, viewer.getControl().getForeground(), viewer.getControl().getBackground());
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider.ColorProvider
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.edit.ui.provider;

import org.eclipse.emf.common.notify.AdapterFactory;
import org.eclipse.jface.viewers.IColorProvider;
import org.eclipse.jface.viewers.IFontProvider;
import org.eclipse.jface.viewers.ITableColorProvider;
import org.eclipse.jface.viewers.ITableFontProvider;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.widgets.Control;

public class AdapterFactoryLabelProvider$FontAndColorProvider
  extends AdapterFactoryLabelProvider
  implements IColorProvider, IFontProvider, ITableColorProvider, ITableFontProvider
{
  public AdapterFactoryLabelProvider$FontAndColorProvider(AdapterFactory adapterFactory, Font defaultFont, Color defaultForeground, Color defaultBackground)
  {
    super(adapterFactory);
    setDefaultFont(defaultFont);
    setDefaultForeground(defaultForeground);
    setDefaultBackground(defaultBackground);
  }
  
  public AdapterFactoryLabelProvider$FontAndColorProvider(AdapterFactory adapterFactory, Viewer viewer)
  {
    this(adapterFactory, viewer.getControl().getFont(), viewer.getControl().getForeground(), viewer.getControl().getBackground());
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider.FontAndColorProvider
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.edit.ui.provider;

import org.eclipse.emf.common.notify.AdapterFactory;
import org.eclipse.jface.viewers.IColorProvider;
import org.eclipse.jface.viewers.IFontProvider;
import org.eclipse.jface.viewers.ITableColorProvider;
import org.eclipse.jface.viewers.ITableFontProvider;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.widgets.Control;

public class AdapterFactoryLabelProvider$FontProvider
  extends AdapterFactoryLabelProvider
  implements IColorProvider, IFontProvider, ITableColorProvider, ITableFontProvider
{
  public AdapterFactoryLabelProvider$FontProvider(AdapterFactory adapterFactory, Font defaultFont)
  {
    super(adapterFactory);
    setDefaultFont(defaultFont);
  }
  
  public AdapterFactoryLabelProvider$FontProvider(AdapterFactory adapterFactory, Viewer viewer)
  {
    this(adapterFactory, viewer.getControl().getFont());
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider.FontProvider
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.edit.ui.provider;

import java.util.ArrayList;
import java.util.Collection;
import org.eclipse.emf.common.notify.AdapterFactory;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.edit.EMFEditPlugin;
import org.eclipse.emf.edit.provider.IChangeNotifier;
import org.eclipse.emf.edit.provider.IItemColorProvider;
import org.eclipse.emf.edit.provider.IItemFontProvider;
import org.eclipse.emf.edit.provider.IItemLabelProvider;
import org.eclipse.emf.edit.provider.INotifyChangedListener;
import org.eclipse.emf.edit.provider.ITableItemColorProvider;
import org.eclipse.emf.edit.provider.ITableItemFontProvider;
import org.eclipse.emf.edit.provider.ITableItemLabelProvider;
import org.eclipse.emf.edit.provider.IViewerNotification;
import org.eclipse.jface.viewers.IColorProvider;
import org.eclipse.jface.viewers.IFontProvider;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.jface.viewers.ITableColorProvider;
import org.eclipse.jface.viewers.ITableFontProvider;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.LabelProviderChangedEvent;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Control;

public class AdapterFactoryLabelProvider
  implements ILabelProvider, ITableLabelProvider, INotifyChangedListener
{
  protected AdapterFactory adapterFactory;
  protected Font defaultFont;
  protected Color defaultForeground;
  protected Color defaultBackground;
  protected Collection<ILabelProviderListener> labelProviderListeners;
  protected boolean isFireLabelUpdateNotifications;
  
  public static class FontProvider
    extends AdapterFactoryLabelProvider
    implements IColorProvider, IFontProvider, ITableColorProvider, ITableFontProvider
  {
    public FontProvider(AdapterFactory adapterFactory, Font defaultFont)
    {
      super();
      setDefaultFont(defaultFont);
    }
    
    public FontProvider(AdapterFactory adapterFactory, Viewer viewer)
    {
      this(adapterFactory, viewer.getControl().getFont());
    }
  }
  
  public static class ColorProvider
    extends AdapterFactoryLabelProvider
    implements IColorProvider, IFontProvider, ITableColorProvider, ITableFontProvider
  {
    public ColorProvider(AdapterFactory adapterFactory, Color defaultForeground, Color defaultBackground)
    {
      super();
      setDefaultForeground(defaultForeground);
      setDefaultBackground(defaultBackground);
    }
    
    public ColorProvider(AdapterFactory adapterFactory, Viewer viewer)
    {
      this(adapterFactory, viewer.getControl().getForeground(), viewer.getControl().getBackground());
    }
  }
  
  public static class FontAndColorProvider
    extends AdapterFactoryLabelProvider
    implements IColorProvider, IFontProvider, ITableColorProvider, ITableFontProvider
  {
    public FontAndColorProvider(AdapterFactory adapterFactory, Font defaultFont, Color defaultForeground, Color defaultBackground)
    {
      super();
      setDefaultFont(defaultFont);
      setDefaultForeground(defaultForeground);
      setDefaultBackground(defaultBackground);
    }
    
    public FontAndColorProvider(AdapterFactory adapterFactory, Viewer viewer)
    {
      this(adapterFactory, viewer.getControl().getFont(), viewer.getControl().getForeground(), viewer.getControl().getBackground());
    }
  }
  
  private static final Class<?> IItemLabelProviderClass = IItemLabelProvider.class;
  private static final Class<?> ITableItemLabelProviderClass = ITableItemLabelProvider.class;
  private static final Class<?> IItemFontProviderClass = IItemFontProvider.class;
  private static final Class<?> IItemColorProviderClass = IItemColorProvider.class;
  private static final Class<?> ITableItemFontProviderClass = ITableItemFontProvider.class;
  private static final Class<?> ITableItemColorProviderClass = ITableItemColorProvider.class;
  
  public AdapterFactoryLabelProvider(AdapterFactory adapterFactory)
  {
    this.adapterFactory = adapterFactory;
    if ((adapterFactory instanceof IChangeNotifier)) {
      ((IChangeNotifier)adapterFactory).addListener(this);
    }
    labelProviderListeners = new ArrayList();
  }
  
  public AdapterFactory getAdapterFactory()
  {
    return adapterFactory;
  }
  
  public void setAdapterFactory(AdapterFactory adapterFactory)
  {
    if ((this.adapterFactory instanceof IChangeNotifier)) {
      ((IChangeNotifier)this.adapterFactory).removeListener(this);
    }
    if ((adapterFactory instanceof IChangeNotifier)) {
      ((IChangeNotifier)adapterFactory).addListener(this);
    }
    this.adapterFactory = adapterFactory;
  }
  
  public Font getDefaultFont()
  {
    return defaultFont;
  }
  
  public void setDefaultFont(Font font)
  {
    defaultFont = font;
  }
  
  public Color getDefaultForeground()
  {
    return defaultForeground;
  }
  
  public void setDefaultForeground(Color color)
  {
    defaultForeground = color;
  }
  
  public Color getDefaultBackground()
  {
    return defaultBackground;
  }
  
  public void setDefaultBackground(Color color)
  {
    defaultBackground = color;
  }
  
  public void addListener(ILabelProviderListener listener)
  {
    labelProviderListeners.add(listener);
  }
  
  public void removeListener(ILabelProviderListener listener)
  {
    labelProviderListeners.remove(listener);
  }
  
  public void dispose()
  {
    if ((adapterFactory instanceof IChangeNotifier)) {
      ((IChangeNotifier)adapterFactory).removeListener(this);
    }
  }
  
  public boolean isLabelProperty(Object object, String id)
  {
    return true;
  }
  
  public Image getImage(Object object)
  {
    IItemLabelProvider itemLabelProvider = (IItemLabelProvider)adapterFactory.adapt(object, IItemLabelProviderClass);
    
    return 
      itemLabelProvider != null ? 
      getImageFromObject(itemLabelProvider.getImage(object)) : 
      getDefaultImage(object);
  }
  
  protected Image getDefaultImage(Object object)
  {
    String image = "full/obj16/GenericValue";
    if ((object instanceof String)) {
      image = "full/obj16/TextValue";
    } else if ((object instanceof Boolean)) {
      image = "full/obj16/BooleanValue";
    } else if (((object instanceof Float)) || ((object instanceof Double))) {
      image = "full/obj16/RealValue";
    } else if (((object instanceof Integer)) || ((object instanceof Short)) || ((object instanceof Long)) || ((object instanceof Byte))) {
      image = "full/obj16/RealValue";
    }
    return getImageFromObject(EMFEditPlugin.INSTANCE.getImage(image));
  }
  
  protected Image getImageFromObject(Object object)
  {
    return ExtendedImageRegistry.getInstance().getImage(object);
  }
  
  public String getText(Object object)
  {
    IItemLabelProvider itemLabelProvider = (IItemLabelProvider)adapterFactory.adapt(object, IItemLabelProviderClass);
    
    return 
    
      object == null ? 
      "" : itemLabelProvider != null ? itemLabelProvider.getText(object) : 
      object.toString();
  }
  
  public Font getFont(Object object)
  {
    IItemFontProvider itemFontProvider = (IItemFontProvider)adapterFactory.adapt(object, IItemFontProviderClass);
    
    return 
      itemFontProvider != null ? 
      getFontFromObject(itemFontProvider.getFont(object)) : 
      null;
  }
  
  protected Font getFontFromObject(Object object)
  {
    return object == null ? null : ExtendedFontRegistry.INSTANCE.getFont(defaultFont, object);
  }
  
  public Color getForeground(Object object)
  {
    IItemColorProvider itemColorProvider = (IItemColorProvider)adapterFactory.adapt(object, IItemColorProviderClass);
    
    return 
      itemColorProvider != null ? 
      getColorFromObject(itemColorProvider.getForeground(object)) : 
      null;
  }
  
  public Color getBackground(Object object)
  {
    IItemColorProvider itemColorProvider = (IItemColorProvider)adapterFactory.adapt(object, IItemColorProviderClass);
    
    return 
      itemColorProvider != null ? 
      getColorFromObject(itemColorProvider.getBackground(object)) : 
      null;
  }
  
  protected Color getColorFromObject(Object object)
  {
    return object == null ? null : ExtendedColorRegistry.INSTANCE.getColor(defaultForeground, defaultBackground, object);
  }
  
  public Image getColumnImage(Object object, int columnIndex)
  {
    ITableItemLabelProvider tableItemLabelProvider = (ITableItemLabelProvider)adapterFactory.adapt(object, ITableItemLabelProviderClass);
    
    Image result = null;
    if (tableItemLabelProvider != null)
    {
      result = getImageFromObject(tableItemLabelProvider.getColumnImage(object, columnIndex));
    }
    else
    {
      IItemLabelProvider itemLabelProvider = (IItemLabelProvider)adapterFactory.adapt(object, IItemLabelProviderClass);
      if (itemLabelProvider != null) {
        result = getImageFromObject(itemLabelProvider.getImage(object));
      }
    }
    return result;
  }
  
  public String getColumnText(Object object, int columnIndex)
  {
    ITableItemLabelProvider tableItemLabelProvider = (ITableItemLabelProvider)adapterFactory.adapt(object, ITableItemLabelProviderClass);
    if (tableItemLabelProvider != null) {
      return tableItemLabelProvider.getColumnText(object, columnIndex);
    }
    IItemLabelProvider itemLabelProvider = (IItemLabelProvider)adapterFactory.adapt(object, IItemLabelProviderClass);
    if (itemLabelProvider != null) {
      return itemLabelProvider.getText(object);
    }
    if (object != null) {
      return object.toString();
    }
    return "";
  }
  
  public Font getFont(Object object, int columnIndex)
  {
    ITableItemFontProvider tableItemFontProvider = (ITableItemFontProvider)adapterFactory.adapt(object, ITableItemFontProviderClass);
    
    Font result = null;
    if (tableItemFontProvider != null)
    {
      result = getFontFromObject(tableItemFontProvider.getFont(object, columnIndex));
    }
    else
    {
      IItemFontProvider itemFontProvider = (IItemFontProvider)adapterFactory.adapt(object, IItemFontProviderClass);
      if (itemFontProvider != null) {
        result = getFontFromObject(itemFontProvider.getFont(object));
      }
    }
    return result;
  }
  
  public Color getForeground(Object object, int columnIndex)
  {
    ITableItemColorProvider tableItemColorProvider = (ITableItemColorProvider)adapterFactory.adapt(object, ITableItemColorProviderClass);
    
    Color result = null;
    if (tableItemColorProvider != null)
    {
      result = getColorFromObject(tableItemColorProvider.getForeground(object, columnIndex));
    }
    else
    {
      IItemColorProvider itemColorProvider = (IItemColorProvider)adapterFactory.adapt(object, IItemColorProviderClass);
      if (itemColorProvider != null) {
        result = getColorFromObject(itemColorProvider.getForeground(object));
      }
    }
    return result;
  }
  
  public Color getBackground(Object object, int columnIndex)
  {
    ITableItemColorProvider tableItemColorProvider = (ITableItemColorProvider)adapterFactory.adapt(object, ITableItemColorProviderClass);
    
    Color result = null;
    if (tableItemColorProvider != null)
    {
      result = getColorFromObject(tableItemColorProvider.getBackground(object, columnIndex));
    }
    else
    {
      IItemColorProvider itemColorProvider = (IItemColorProvider)adapterFactory.adapt(object, IItemColorProviderClass);
      if (itemColorProvider != null) {
        result = getColorFromObject(itemColorProvider.getBackground(object));
      }
    }
    return result;
  }
  
  public boolean isFireLabelUpdateNotifications()
  {
    return isFireLabelUpdateNotifications;
  }
  
  public void setFireLabelUpdateNotifications(boolean isFireLabelUpdateNotifications)
  {
    this.isFireLabelUpdateNotifications = isFireLabelUpdateNotifications;
  }
  
  public void fireLabelProviderChanged()
  {
    for (ILabelProviderListener labelProviderListener : labelProviderListeners) {
      labelProviderListener.labelProviderChanged(new LabelProviderChangedEvent(this));
    }
  }
  
  public void notifyChanged(Notification notification)
  {
    if (isFireLabelUpdateNotifications()) {
      if ((!(notification instanceof IViewerNotification)) || (((IViewerNotification)notification).isLabelUpdate())) {
        for (ILabelProviderListener labelProviderListener : labelProviderListeners) {
          labelProviderListener.labelProviderChanged(new LabelProviderChangedEvent(this, notification.getNotifier()));
        }
      }
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.edit.ui.provider;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.eclipse.emf.edit.provider.ComposedImage;
import org.eclipse.emf.edit.provider.ComposedImage.Point;
import org.eclipse.emf.edit.provider.ComposedImage.Size;
import org.eclipse.jface.resource.CompositeImageDescriptor;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.ImageData;
import org.eclipse.swt.graphics.Point;

class ComposedImageDescriptor
  extends CompositeImageDescriptor
{
  protected ComposedImage composedImage;
  protected List<ImageData> imageDatas;
  
  public ComposedImageDescriptor(ComposedImage composedImage)
  {
    this.composedImage = composedImage;
  }
  
  public void drawCompositeImage(int width, int height)
  {
    ComposedImage.Size size = new ComposedImage.Size();
    width = width;
    height = height;
    Iterator<ImageData> images = imageDatas.iterator();
    for (Iterator<ComposedImage.Point> points = composedImage.getDrawPoints(size).iterator(); points.hasNext();)
    {
      ComposedImage.Point point = (ComposedImage.Point)points.next();
      drawImage((ImageData)images.next(), x, y);
    }
  }
  
  public Point getSize()
  {
    List<Object> images = composedImage.getImages();
    imageDatas = new ArrayList(images.size());
    List<ComposedImage.Size> sizes = new ArrayList(images.size());
    for (Object object : images)
    {
      Image image = ExtendedImageRegistry.getInstance().getImage(object);
      ImageData imageData = image.getImageData();
      imageDatas.add(imageData);
      
      ComposedImage.Size size = new ComposedImage.Size();
      width = width;
      height = height;
      sizes.add(size);
    }
    ComposedImage.Size result = composedImage.getSize(sizes);
    return new Point(width, height);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.edit.ui.provider.ComposedImageDescriptor
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.edit.ui.provider;

class ExtendedColorRegistry$1
  implements Runnable
{
  ExtendedColorRegistry$1(ExtendedColorRegistry paramExtendedColorRegistry) {}
  
  public void run()
  {
    this$0.handleDisplayDispose();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.edit.ui.provider.ExtendedColorRegistry.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.edit.ui.provider;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.edit.ui.EMFEditUIPlugin;
import org.eclipse.jface.resource.ColorDescriptor;
import org.eclipse.jface.resource.DeviceResourceException;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.widgets.Display;

public class ExtendedColorRegistry
{
  public static final ExtendedColorRegistry INSTANCE = new ExtendedColorRegistry();
  protected Display display;
  protected HashMap<Collection<?>, Color> table = new HashMap(10);
  
  public ExtendedColorRegistry()
  {
    display = Display.getCurrent();
    hookDisplayDi
1 2 3 4 5 6 7 8

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