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

16:43:37.032 INFO  jd.cli.Main - Decompiling org.eclipse.emf.edit.ui_2.7.0.v20120130-0943.jar
package org.eclipse.emf.edit.ui;

import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.emf.ecore.plugin.RegistryReader.PluginClassDescriptor;
import org.eclipse.emf.edit.ui.util.QueryDelegateTextViewer.Factory;
import org.eclipse.emf.edit.ui.util.QueryDelegateTextViewer.Factory.Descriptor;

class EMFEditUIPlugin$Implementation$1$1FactoryDescriptor
  extends RegistryReader.PluginClassDescriptor
  implements QueryDelegateTextViewer.Factory.Descriptor
{
  protected QueryDelegateTextViewer.Factory factory;
  
  public EMFEditUIPlugin$Implementation$1$1FactoryDescriptor(EMFEditUIPlugin.Implementation.1 param1, IConfigurationElement e, String attrName)
  {
    super(e, attrName);
  }
  
  public QueryDelegateTextViewer.Factory getFactory()
  {
    if (factory == null) {
      factory = ((QueryDelegateTextViewer.Factory)createInstance());
    }
    return factory;
  }
  
  public IConfigurationElement getElement()
  {
    return element;
  }
}

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

import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IContributor;
import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.emf.ecore.plugin.RegistryReader;
import org.eclipse.emf.ecore.plugin.RegistryReader.PluginClassDescriptor;
import org.eclipse.emf.edit.ui.util.QueryDelegateTextViewer.Factory;
import org.eclipse.emf.edit.ui.util.QueryDelegateTextViewer.Factory.Descriptor;
import org.eclipse.emf.edit.ui.util.QueryDelegateTextViewer.Factory.Registry;

class EMFEditUIPlugin$Implementation$1
  extends RegistryReader
{
  EMFEditUIPlugin$Implementation$1(EMFEditUIPlugin.Implementation paramImplementation, IExtensionRegistry $anonymous0, String $anonymous1, String $anonymous2)
  {
    super($anonymous0, $anonymous1, $anonymous2);
  }
  
  protected boolean readElement(IConfigurationElement element, boolean add)
  {
    if (element.getName().equals("factory"))
    {
      String uri = element.getAttribute("uri");
      if (uri == null) {
        logMissingAttribute(element, "uri");
      } else if (element.getAttribute("class") == null) {
        logMissingAttribute(element, "class");
      }
      if (add)
      {
        Object previous = QueryDelegateTextViewer.Factory.Registry.INSTANCE.put(uri, new RegistryReader.PluginClassDescriptor(element, "class")
        {
          protected QueryDelegateTextViewer.Factory factory;
          
          public QueryDelegateTextViewer.Factory getFactory()
          {
            if (factory == null) {
              factory = ((QueryDelegateTextViewer.Factory)createInstance());
            }
            return factory;
          }
          
          public IConfigurationElement getElement()
          {
            return element;
          }
        });
        if ((previous instanceof 1FactoryDescriptor))
        {
          RegistryReader.PluginClassDescriptor descriptor = (1FactoryDescriptor)previous;
          EMFEditUIPlugin.INSTANCE.log("Both '" + descriptor.getElement().getContributor().getName() + "' and '" + 
            element.getContributor().getName() + "' register a query delegate text viewer factory for '" + uri + "'");
        }
        return true;
      }
      QueryDelegateTextViewer.Factory.Registry.INSTANCE.remove(uri);
      return true;
    }
    return false;
  }
}

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

import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IContributor;
import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.Platform;
import org.eclipse.emf.common.ui.EclipseUIPlugin;
import org.eclipse.emf.ecore.plugin.RegistryReader;
import org.eclipse.emf.ecore.plugin.RegistryReader.PluginClassDescriptor;
import org.eclipse.emf.edit.ui.util.QueryDelegateTextViewer.Factory;
import org.eclipse.emf.edit.ui.util.QueryDelegateTextViewer.Factory.Descriptor;
import org.eclipse.emf.edit.ui.util.QueryDelegateTextViewer.Factory.Registry;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;

public class EMFEditUIPlugin$Implementation
  extends EclipseUIPlugin
{
  public EMFEditUIPlugin$Implementation()
  {
    EMFEditUIPlugin.access$0(this);
  }
  
  public void start(BundleContext context)
    throws Exception
  {
    super.start(context);
    
    Bundle bundle = Platform.getBundle("org.eclipse.jface.text");
    if ((bundle != null) && ((bundle.getState() & 0x2C) != 0)) {
      new RegistryReader(Platform.getExtensionRegistry(), EMFEditUIPlugin.getPlugin().getBundle().getSymbolicName(), "queryDelegateTextViewerFactories")
      {
        protected boolean readElement(IConfigurationElement element, boolean add)
        {
          if (element.getName().equals("factory"))
          {
            String uri = element.getAttribute("uri");
            if (uri == null) {
              logMissingAttribute(element, "uri");
            } else if (element.getAttribute("class") == null) {
              logMissingAttribute(element, "class");
            }
            if (add)
            {
              Object previous = QueryDelegateTextViewer.Factory.Registry.INSTANCE.put(uri, new RegistryReader.PluginClassDescriptor(element, "class")
              {
                protected QueryDelegateTextViewer.Factory factory;
                
                public QueryDelegateTextViewer.Factory getFactory()
                {
                  if (factory == null) {
                    factory = ((QueryDelegateTextViewer.Factory)createInstance());
                  }
                  return factory;
                }
                
                public IConfigurationElement getElement()
                {
                  return element;
                }
              });
              if ((previous instanceof 1FactoryDescriptor))
              {
                RegistryReader.PluginClassDescriptor descriptor = (1FactoryDescriptor)previous;
                EMFEditUIPlugin.INSTANCE.log("Both '" + descriptor.getElement().getContributor().getName() + "' and '" + 
                  element.getContributor().getName() + "' register a query delegate text viewer factory for '" + uri + "'");
              }
              return true;
            }
            QueryDelegateTextViewer.Factory.Registry.INSTANCE.remove(uri);
            return true;
          }
          return false;
        }
      }.readRegistry();
    }
  }
}

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

import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IContributor;
import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.Platform;
import org.eclipse.emf.common.EMFPlugin;
import org.eclipse.emf.common.ui.EclipseUIPlugin;
import org.eclipse.emf.common.util.ResourceLocator;
import org.eclipse.emf.ecore.plugin.RegistryReader;
import org.eclipse.emf.ecore.plugin.RegistryReader.PluginClassDescriptor;
import org.eclipse.emf.edit.ui.util.QueryDelegateTextViewer.Factory;
import org.eclipse.emf.edit.ui.util.QueryDelegateTextViewer.Factory.Descriptor;
import org.eclipse.emf.edit.ui.util.QueryDelegateTextViewer.Factory.Registry;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;

public final class EMFEditUIPlugin
  extends EMFPlugin
{
  public static final EMFEditUIPlugin INSTANCE = new EMFEditUIPlugin();
  private static Implementation plugin;
  public static final String QUERY_DELEGATE_TEXT_VIEWER_FACTORIES_PPID = "queryDelegateTextViewerFactories";
  
  private EMFEditUIPlugin()
  {
    super(new ResourceLocator[0]);
  }
  
  public ResourceLocator getPluginResourceLocator()
  {
    return plugin;
  }
  
  public static Implementation getPlugin()
  {
    return plugin;
  }
  
  public static class Implementation
    extends EclipseUIPlugin
  {
    public Implementation()
    {
      EMFEditUIPlugin.plugin = this;
    }
    
    public void start(BundleContext context)
      throws Exception
    {
      super.start(context);
      
      Bundle bundle = Platform.getBundle("org.eclipse.jface.text");
      if ((bundle != null) && ((bundle.getState() & 0x2C) != 0)) {
        new RegistryReader(Platform.getExtensionRegistry(), EMFEditUIPlugin.getPlugin().getBundle().getSymbolicName(), "queryDelegateTextViewerFactories")
        {
          protected boolean readElement(IConfigurationElement element, boolean add)
          {
            if (element.getName().equals("factory"))
            {
              String uri = element.getAttribute("uri");
              if (uri == null) {
                logMissingAttribute(element, "uri");
              } else if (element.getAttribute("class") == null) {
                logMissingAttribute(element, "class");
              }
              if (add)
              {
                Object previous = QueryDelegateTextViewer.Factory.Registry.INSTANCE.put(uri, new RegistryReader.PluginClassDescriptor(element, "class")
                {
                  protected QueryDelegateTextViewer.Factory factory;
                  
                  public QueryDelegateTextViewer.Factory getFactory()
                  {
                    if (factory == null) {
                      factory = ((QueryDelegateTextViewer.Factory)createInstance());
                    }
                    return factory;
                  }
                  
                  public IConfigurationElement getElement()
                  {
                    return element;
                  }
                });
                if ((previous instanceof 1FactoryDescriptor))
                {
                  RegistryReader.PluginClassDescriptor descriptor = (1FactoryDescriptor)previous;
                  EMFEditUIPlugin.INSTANCE.log("Both '" + descriptor.getElement().getContributor().getName() + "' and '" + 
                    element.getContributor().getName() + "' register a query delegate text viewer factory for '" + uri + "'");
                }
                return true;
              }
              QueryDelegateTextViewer.Factory.Registry.INSTANCE.remove(uri);
              return true;
            }
            return false;
          }
        }.readRegistry();
      }
    }
  }
}

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

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.common.command.CommandStack;
import org.eclipse.emf.common.command.UnexecutableCommand;
import org.eclipse.emf.edit.command.CommandActionDelegate;
import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.emf.edit.domain.IEditingDomainProvider;
import org.eclipse.emf.edit.ui.provider.ExtendedImageRegistry;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.widgets.Event;
import org.eclipse.ui.IActionDelegate2;
import org.eclipse.ui.IEditorActionDelegate;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IViewActionDelegate;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IWorkbenchPart;

public class CommandAction
  implements IEditorActionDelegate, IViewActionDelegate, IActionDelegate2
{
  protected IWorkbenchPart workbenchPart;
  @Deprecated
  protected IEditorPart editorPart;
  protected IAction action;
  protected EditingDomain editingDomain;
  protected Collection<Object> collection;
  protected Command command;
  
  protected Command createActionCommand(EditingDomain editingDomain, Collection<?> collection)
  {
    return UnexecutableCommand.INSTANCE;
  }
  
  protected ImageDescriptor getDefaultImageDescriptor()
  {
    return null;
  }
  
  public void init(IAction action)
  {
    this.action = action;
  }
  
  public void dispose() {}
  
  public void setActiveEditor(IAction action, IEditorPart editorPart)
  {
    setActiveWorkbenchPart(editorPart);
    this.editorPart = editorPart;
    this.action = action;
  }
  
  public void init(IViewPart view)
  {
    setActiveWorkbenchPart(view);
  }
  
  public void setActiveWorkbenchPart(IWorkbenchPart workbenchPart)
  {
    if (this.workbenchPart != workbenchPart)
    {
      editingDomain = null;
      if (workbenchPart != null) {
        if ((workbenchPart instanceof IEditingDomainProvider)) {
          editingDomain = ((IEditingDomainProvider)workbenchPart).getEditingDomain();
        }
      }
      this.workbenchPart = workbenchPart;
    }
  }
  
  public void runWithEvent(IAction action, Event event)
  {
    run(action);
  }
  
  public void run(IAction action)
  {
    if ((editingDomain != null) && (command != null)) {
      editingDomain.getCommandStack().execute(command);
    }
  }
  
  public void selectionChanged(IAction action, ISelection selection)
  {
    if ((selection instanceof IStructuredSelection))
    {
      List<?> list = ((IStructuredSelection)selection).toList();
      collection = new ArrayList(list);
      if ((workbenchPart == null) && (editorPart == null)) {
        for (Object object : collection)
        {
          editingDomain = AdapterFactoryEditingDomain.getEditingDomainFor(object);
          if (editingDomain != null) {
            break;
          }
        }
      }
      if (editingDomain != null)
      {
        command = createActionCommand(editingDomain, collection);
        
        ((Action)action).setEnabled(command.canExecute());
        if ((command instanceof CommandActionDelegate))
        {
          CommandActionDelegate commandActionDelegate = (CommandActionDelegate)command;
          Object object = commandActionDelegate.getImage();
          ImageDescriptor imageDescriptor = objectToImageDescriptor(object);
          if (imageDescriptor != null) {
            ((Action)action).setImageDescriptor(imageDescriptor);
          } else if (getDefaultImageDescriptor() != null) {
            ((Action)action).setImageDescriptor(getDefaultImageDescriptor());
          }
          if (commandActionDelegate.getText() != null) {
            ((Action)action).setText(commandActionDelegate.getText());
          }
          if (commandActionDelegate.getDescription() != null) {
            ((Action)action).setDescription(commandActionDelegate.getDescription());
          }
          if (commandActionDelegate.getToolTipText() != null) {
            ((Action)action).setToolTipText(commandActionDelegate.getToolTipText());
          }
        }
        return;
      }
    }
    ((Action)action).setEnabled(false);
    
    command = null;
    collection = null;
    if (getDefaultImageDescriptor() != null) {
      ((Action)action).setImageDescriptor(getDefaultImageDescriptor());
    }
  }
  
  protected ImageDescriptor objectToImageDescriptor(Object object)
  {
    return ExtendedImageRegistry.getInstance().getImageDescriptor(object);
  }
}

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

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.common.command.CommandStack;
import org.eclipse.emf.common.command.UnexecutableCommand;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.actions.BaseSelectionListenerAction;

public class CommandActionHandler
  extends BaseSelectionListenerAction
{
  protected EditingDomain domain;
  protected Command command;
  
  public CommandActionHandler(EditingDomain domain)
  {
    super("");
    
    this.domain = domain;
  }
  
  public CommandActionHandler(EditingDomain domain, String label)
  {
    super(label);
    
    this.domain = domain;
  }
  
  public EditingDomain getEditingDomain()
  {
    return domain;
  }
  
  public void setEditingDomain(EditingDomain domain)
  {
    this.domain = domain;
  }
  
  public void run()
  {
    domain.getCommandStack().execute(command);
  }
  
  public boolean updateSelection(IStructuredSelection selection)
  {
    List<?> list = selection.toList();
    Collection<Object> collection = new ArrayList(list);
    command = createCommand(collection);
    
    return command.canExecute();
  }
  
  public Command createCommand(Collection<?> selection)
  {
    return UnexecutableCommand.INSTANCE;
  }
}

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

import java.util.List;
import org.eclipse.emf.common.ui.dialogs.ResourceDialog;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.URIConverter;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.emf.edit.ui.EMFEditUIPlugin;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.widgets.Shell;

public class ControlAction$ControlResourceDialog
  extends ResourceDialog
{
  protected EditingDomain domain;
  protected Resource resource;
  protected Resource currentResource;
  
  public ControlAction$ControlResourceDialog(Shell parent, EditingDomain domain, Resource currentResource)
  {
    super(parent, EMFEditUIPlugin.INSTANCE.getString("_UI_ControlDialog_title"), 8192);
    this.domain = domain;
    this.currentResource = currentResource;
  }
  
  protected boolean processResources()
  {
    List<URI> uris = getURIs();
    if (uris.isEmpty()) {
      return false;
    }
    URI uri = (URI)uris.get(0);
    ResourceSet resourceSet = domain.getResourceSet();
    Resource resource = resourceSet.getResource(uri, false);
    boolean resourceInSet = resource != null;
    if (resource == currentResource)
    {
      MessageDialog.openError(getShell(), EMFEditUIPlugin.INSTANCE.getString("_UI_InvalidURI_label"), EMFEditUIPlugin.INSTANCE.getString("_WARN_AlreadyInResource"));
      return false;
    }
    if (domain.isReadOnly(resource))
    {
      MessageDialog.openError(getShell(), EMFEditUIPlugin.INSTANCE.getString("_UI_InvalidURI_label"), EMFEditUIPlugin.INSTANCE.getString("_WARN_ReadOnlyResource"));
      return false;
    }
    boolean resourceExists = resourceSet.getURIConverter().exists(uri, null);
    
    boolean resourceBad = false;
    if (!resourceInSet)
    {
      resource = resourceSet.createResource(uri);
      if (resource == null)
      {
        MessageDialog.openError(getShell(), EMFEditUIPlugin.INSTANCE.getString("_UI_InvalidURI_label"), EMFEditUIPlugin.INSTANCE.getString("_WARN_CannotCreateResource"));
        return false;
      }
      if (resourceExists) {
        try
        {
          resource = resourceSet.getResource(uri, true);
        }
        catch (RuntimeException exception)
        {
          EMFEditUIPlugin.INSTANCE.log(exception);
          resourceBad = resource.getContents().isEmpty();
        }
      }
    }
    boolean result = true;
    if (resourceBad) {
      result = MessageDialog.openQuestion(getShell(), EMFEditUIPlugin.INSTANCE.getString("_UI_ExistingResource_label"), EMFEditUIPlugin.INSTANCE.getString("_WARN_ReplaceResource"));
    } else if (resourceExists) {
      result = MessageDialog.openQuestion(getShell(), EMFEditUIPlugin.INSTANCE.getString("_UI_ExistingResource_label"), EMFEditUIPlugin.INSTANCE.getString("_WARN_AddToResource"));
    }
    if ((!result) && (!resourceInSet) && (resource != null))
    {
      resource.unload();
      resourceSet.getResources().remove(resource);
    }
    else
    {
      this.resource = resource;
    }
    return result;
  }
  
  public Resource getResource()
  {
    return resource;
  }
}

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

import java.util.Collection;
import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.common.command.CommandWrapper;
import org.eclipse.jface.viewers.IStructuredSelection;

public class ControlAction$SelfAffectingCommand
  extends CommandWrapper
{
  ControlAction$SelfAffectingCommand(ControlAction paramControlAction, String label, Command command)
  {
    super(label, command);
  }
  
  public Collection<?> getResult()
  {
    return this$0.selection.toList();
  }
  
  public Collection<?> getAffectedObjects()
  {
    return this$0.selection.toList();
  }
}

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

import java.util.Collection;
import java.util.List;
import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.common.command.CommandWrapper;
import org.eclipse.emf.common.ui.dialogs.ResourceDialog;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.URIConverter;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.edit.command.AddCommand;
import org.eclipse.emf.edit.command.RemoveCommand;
import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.emf.edit.domain.IEditingDomainProvider;
import org.eclipse.emf.edit.ui.EMFEditUIPlugin;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;

public class ControlAction
  extends CommandActionHandler
{
  protected IStructuredSelection selection = null;
  protected EObject eObject = null;
  
  public ControlAction(EditingDomain domain)
  {
    super(domain, EMFEditUIPlugin.INSTANCE.getString("_UI_Control_menu_item"));
  }
  
  public ControlAction()
  {
    this(null);
  }
  
  public boolean updateSelection(IStructuredSelection selection)
  {
    this.selection = selection;
    if (selection.size() != 1) {
      return false;
    }
    Object object = AdapterFactoryEditingDomain.unwrap(selection.getFirstElement());
    boolean result = domain.isControllable(object);
    eObject = (result ? (EObject)object : null);
    if (!AdapterFactoryEditingDomain.isControlled(object))
    {
      setText(EMFEditUIPlugin.INSTANCE.getString("_UI_Control_menu_item"));
      setDescription("_UI_Control_menu_item_description");
      command = null;
    }
    else
    {
      setText(EMFEditUIPlugin.INSTANCE.getString("_UI_Uncontrol_menu_item"));
      setDescription("_UI_Uncontrol_menu_item_description");
      if (result)
      {
        command = new RemoveCommand(domain, eObject.eResource().getContents(), eObject);
        command = new SelfAffectingCommand(EMFEditUIPlugin.INSTANCE.getString("_UI_UncontrolCommand_label"), command);
        result = command.canExecute();
      }
    }
    return result;
  }
  
  protected class SelfAffectingCommand
    extends CommandWrapper
  {
    SelfAffectingCommand(String label, Command command)
    {
      super(command);
    }
    
    public Collection<?> getResult()
    {
      return selection.toList();
    }
    
    public Collection<?> getAffectedObjects()
    {
      return selection.toList();
    }
  }
  
  public void run()
  {
    if (command == null)
    {
      if (eObject == null) {
        return;
      }
      Resource resource = getResource();
      if (resource == null) {
        return;
      }
      command = new AddCommand(domain, resource.getContents(), eObject);
      command = new SelfAffectingCommand(EMFEditUIPlugin.INSTANCE.getString("_UI_ControlCommand_label"), command);
    }
    EcoreUtil.resolveAll(domain.getResourceSet());
    
    super.run();
  }
  
  protected Resource getResource()
  {
    ControlResourceDialog dialog = new ControlResourceDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), domain, eObject.eResource());
    dialog.open();
    return dialog.getResource();
  }
  
  public void setActiveWorkbenchPart(IWorkbenchPart workbenchPart)
  {
    if ((workbenchPart instanceof IEditingDomainProvider)) {
      domain = ((IEditingDomainProvider)workbenchPart).getEditingDomain();
    }
  }
  
  protected static class ControlResourceDialog
    extends ResourceDialog
  {
    protected EditingDomain domain;
    protected Resource resource;
    protected Resource currentResource;
    
    public ControlResourceDialog(Shell parent, EditingDomain domain, Resource currentResource)
    {
      super(EMFEditUIPlugin.INSTANCE.getString("_UI_ControlDialog_title"), 8192);
      this.domain = domain;
      this.currentResource = currentResource;
    }
    
    protected boolean processResources()
    {
      List<URI> uris = getURIs();
      if (uris.isEmpty()) {
        return false;
      }
      URI uri = (URI)uris.get(0);
      ResourceSet resourceSet = domain.getResourceSet();
      Resource resource = resourceSet.getResource(uri, false);
      boolean resourceInSet = resource != null;
      if (resource == currentResource)
      {
        MessageDialog.openError(getShell(), EMFEditUIPlugin.INSTANCE.getString("_UI_InvalidURI_label"), EMFEditUIPlugin.INSTANCE.getString("_WARN_AlreadyInResource"));
        return false;
      }
      if (domain.isReadOnly(resource))
      {
        MessageDialog.openError(getShell(), EMFEditUIPlugin.INSTANCE.getString("_UI_InvalidURI_label"), EMFEditUIPlugin.INSTANCE.getString("_WARN_ReadOnlyResource"));
        return false;
      }
      boolean resourceExists = resourceSet.getURIConverter().exists(uri, null);
      
      boolean resourceBad = false;
      if (!resourceInSet)
      {
        resource = resourceSet.createResource(uri);
        if (resource == null)
        {
          MessageDialog.openError(getShell(), EMFEditUIPlugin.INSTANCE.getString("_UI_InvalidURI_label"), EMFEditUIPlugin.INSTANCE.getString("_WARN_CannotCreateResource"));
          return false;
        }
        if (resourceExists) {
          try
          {
            resource = resourceSet.getResource(uri, true);
          }
          catch (RuntimeException exception)
          {
            EMFEditUIPlugin.INSTANCE.log(exception);
            resourceBad = resource.getContents().isEmpty();
          }
        }
      }
      boolean result = true;
      if (resourceBad) {
        result = MessageDialog.openQuestion(getShell(), EMFEditUIPlugin.INSTANCE.getString("_UI_ExistingResource_label"), EMFEditUIPlugin.INSTANCE.getString("_WARN_ReplaceResource"));
      } else if (resourceExists) {
        result = MessageDialog.openQuestion(getShell(), EMFEditUIPlugin.INSTANCE.getString("_UI_ExistingResource_label"), EMFEditUIPlugin.INSTANCE.getString("_WARN_AddToResource"));
      }
      if ((!result) && (!resourceInSet) && (resource != null))
      {
        resource.unload();
        resourceSet.getResources().remove(resource);
      }
      else
      {
        this.resource = resource;
      }
      return result;
    }
    
    public Resource getResource()
    {
      return resource;
    }
  }
}

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

import java.util.Collection;
import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.edit.command.CopyToClipboardCommand;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.emf.edit.domain.IEditingDomainProvider;
import org.eclipse.emf.edit.ui.EMFEditUIPlugin;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbenchPart;

public class CopyAction
  extends CommandActionHandler
{
  public CopyAction(EditingDomain domain)
  {
    super(domain, EMFEditUIPlugin.INSTANCE.getString("_UI_Copy_menu_item"));
  }
  
  public CopyAction()
  {
    super(null, EMFEditUIPlugin.INSTANCE.getString("_UI_Copy_menu_item"));
  }
  
  public Command createCommand(Collection<?> selection)
  {
    return CopyToClipboardCommand.create(domain, selection);
  }
  
  @Deprecated
  public void setActiveEditor(IEditorPart editorPart)
  {
    setActiveWorkbenchPart(editorPart);
  }
  
  public void setActiveWorkbenchPart(IWorkbenchPart workbenchPart)
  {
    if ((workbenchPart instanceof IEditingDomainProvider)) {
      domain = ((IEditingDomainProvider)workbenchPart).getEditingDomain();
    }
  }
}

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

import java.util.Collection;
import java.util.Iterator;
import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.common.command.UnexecutableCommand;
import org.eclipse.emf.edit.command.CreateChildCommand;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbenchPart;

public class CreateChildAction
  extends StaticSelectionCommandAction
{
  protected Object descriptor;
  
  public CreateChildAction(IWorkbenchPart workbenchPart, ISelection selection, Object descriptor)
  {
    super(workbenchPart);
    this.descriptor = descriptor;
    configureAction(selection);
  }
  
  public CreateChildAction(IEditorPart editorPart, ISelection selection, Object descriptor)
  {
    this(editorPart, selection, descriptor);
  }
  
  public CreateChildAction(EditingDomain editingDomain, ISelection selection, Object descriptor)
  {
    super(editingDomain);
    this.descriptor = descriptor;
    configureAction(selection);
  }
  
  protected Command createActionCommand(EditingDomain editingDomain, Collection<?> collection)
  {
    if (collection.size() == 1)
    {
      Object owner = collection.iterator().next();
      return CreateChildCommand.create(editingDomain, owner, 
        descriptor, collection);
    }
    return UnexecutableCommand.INSTANCE;
  }
}

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

import java.util.Collection;
import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.common.command.UnexecutableCommand;
import org.eclipse.emf.edit.command.CreateChildCommand;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbenchPart;

public class CreateSiblingAction
  extends StaticSelectionCommandAction
{
  protected Object descriptor;
  
  public CreateSiblingAction(IWorkbenchPart workbenchPart, ISelection selection, Object descriptor)
  {
    super(workbenchPart);
    this.descriptor = descriptor;
    configureAction(selection);
  }
  
  public CreateSiblingAction(IEditorPart editorPart, ISelection selection, Object descriptor)
  {
    this(editorPart, selection, descriptor);
  }
  
  public CreateSiblingAction(EditingDomain editingDomain, ISelection selection, Object descriptor)
  {
    super(editingDomain);
    this.descriptor = descriptor;
    configureAction(selection);
  }
  
  protected Command createActionCommand(EditingDomain editingDomain, Collection<?> collection)
  {
    if (collection.size() == 1) {
      return CreateChildCommand.create(editingDomain, null, 
        descriptor, collection);
    }
    return UnexecutableCommand.INSTANCE;
  }
}

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

import java.util.Collection;
import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.edit.command.CutToClipboardCommand;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.emf.edit.domain.IEditingDomainProvider;
import org.eclipse.emf.edit.ui.EMFEditUIPlugin;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbenchPart;

public class CutAction
  extends CommandActionHandler
{
  public CutAction(EditingDomain domain)
  {
    super(domain, EMFEditUIPlugin.INSTANCE.getString("_UI_Cut_menu_item"));
  }
  
  public CutAction()
  {
    super(null, EMFEditUIPlugin.INSTANCE.getString("_UI_Cut_menu_item"));
  }
  
  public Command createCommand(Collection<?> selection)
  {
    return CutToClipboardCommand.create(domain, selection);
  }
  
  @Deprecated
  public void setActiveEditor(IEditorPart editorPart)
  {
    setActiveWorkbenchPart(editorPart);
  }
  
  public void setActiveWorkbenchPart(IWorkbenchPart workbenchPart)
  {
    if ((workbenchPart instanceof IEditingDomainProvider)) {
      domain = ((IEditingDomainProvider)workbenchPart).getEditingDomain();
    }
  }
}

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

import org.eclipse.jface.action.Action;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.ui.IActionDelegate;
import org.eclipse.ui.IEditorActionDelegate;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.ISelectionListener;
import org.eclipse.ui.IViewActionDelegate;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchPartSite;

public class DelegatingCommandAction
  extends Action
  implements ISelectionListener, ISelectionChangedListener
{
  protected IActionDelegate actionDelegate;
  @Deprecated
  protected IEditorActionDelegate editorActionDelegate;
  protected IWorkbenchPart workbenchPart;
  @Deprecated
  protected IEditorPart editorPart;
  
  public DelegatingCommandAction(IActionDelegate actionDelegate)
  {
    this.actionDelegate = actionDelegate;
    if ((actionDelegate instanceof IEditorActionDelegate)) {
      editorActionDelegate = ((IEditorActionDelegate)actionDelegate);
    }
  }
  
  public DelegatingCommandAction(IEditorActionDelegate editorActionDelegate)
  {
    this(editorActionDelegate);
  }
  
  public void selectionChanged(SelectionChangedEvent event)
  {
    handleSelection(event.getSelection());
  }
  
  public void selectionChanged(IWorkbenchPart part, ISelection selection)
  {
    handleSelection(selection);
  }
  
  protected void selectionChanged(ISelection selection)
  {
    if (actionDelegate != null) {
      editorActionDelegate.selectionChanged(this, selection);
    } else {
      actionDelegate.selectionChanged(this, selection);
    }
  }
  
  protected void handleSelection(ISelection selection)
  {
    selectionChanged(selection);
  }
  
  protected void registerSelectionListener(IWorkbenchPart workbenchPart)
  {
    ISelectionProvider selectionProvider = workbenchPart.getSite().getSelectionProvider();
    if (selectionProvider != null)
    {
      selectionProvider.addSelectionChangedListener(this);
      handleSelection(selectionProvider.getSelection());
    }
  }
  
  @Deprecated
  protected void registerSelectionListener(IEditorPart editorPart)
  {
    registerSelectionListener(editorPart);
  }
  
  protected void unregisterSelectionListener(IWorkbenchPart workbenchPart)
  {
    ISelectionProvider selectionProvider = workbenchPart.getSite().getSelectionProvider();
    if (selectionProvider != null) {
      selectionProvider.removeSelectionChangedListener(this);
    }
  }
  
  @Deprecated
  protected void unregisterSelectionListener(IEditorPart editorPart)
  {
    unregisterSelectionListener(editorPart);
  }
  
  @Deprecated
  public void setActiveEditor(IEditorPart editorPart)
  {
    setActiveWorkbenchPart(editorPart);
    this.editorPart = editorPart;
  }
  
  public void setActiveWorkbenchPart(IWorkbenchPart workbenchPart)
  {
    if (this.workbenchPart != workbenchPart)
    {
      if (this.workbenchPart != null) {
        unregisterSelectionListener(this.workbenchPart);
      }
      this.workbenchPart = workbenchPart;
      if (actionDelegate == null) {
        editorActionDelegate.setActiveEditor(this, (IEditorPart)workbenchPart);
      } else if ((actionDelegate instanceof IEditorActionDelegate)) {
        ((IEditorActionDelegate)actionDelegate).setActiveEditor(this, (IEditorPart)workbenchPart);
      } else {
        ((IViewActionDelegate)actionDelegate).init((IViewPart)workbenchPart);
      }
      if (workbenchPart != null) {
        registerSelectionListener(workbenchPart);
      }
    }
  }
  
  public void run()
  {
    actionDelegate.run(this);
  }
}

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

import java.util.Collection;
import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.edit.command.DeleteCommand;
import org.eclipse.emf.edit.command.RemoveCommand;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.emf.edit.domain.IEditingDomainProvider;
import org.eclipse.emf.edit.ui.EMFEditUIPlugin;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbenchPart;

public class DeleteAction
  extends CommandActionHandler
{
  protected boolean removeAllReferences;
  
  public DeleteAction(EditingDomain domain, boolean removeAllReferences)
  {
    super(domain, EMFEditUIPlugin.INSTANCE.getString("_UI_Delete_menu_item"));
    this.removeAllReferences = removeAllReferences;
  }
  
  public DeleteAction(EditingDomain domain)
  {
    this(domain, false);
  }
  
  public DeleteAction(boolean removeAllReferences)
  {
    this(null, removeAllReferences);
  }
  
  public DeleteAction()
  {
    this(null);
  }
  
  public Command createCommand(Collection<?> selection)
  {
    return removeAllReferences ? DeleteCommand.create(domain, selection) : RemoveCommand.create(domain, selection);
  }
  
  @Deprecated
  public void setActiveEditor(IEditorPart editorPart)
  {
    setActiveWorkbenchPart(editorPart);
  }
  
  public void setActiveWorkbenchPart(IWorkbenchPart workbenchPart)
  {
    if ((workbenchPart instanceof IEditingDomainProvider)) {
      domain = ((IEditingDomainProvider)workbenchPart).getEditingDomain();
    }
  }
}

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

import org.eclipse.emf.edit.domain.IEditingDomainProvider;
import org.eclipse.jface.action.ActionContributionItem;
import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuMana
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-2017. Infinite Loop Ltd