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

ger;
import org.eclipse.jface.action.IStatusLineManager;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IEditorSite;
import org.eclipse.ui.IPropertyListener;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IViewSite;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.actions.ActionFactory;
import org.eclipse.ui.part.IPage;
import org.eclipse.ui.part.MultiPageEditorActionBarContributor;
import org.eclipse.ui.views.properties.IPropertySheetPage;
import org.eclipse.ui.views.properties.PropertySheet;

public class EditingDomainActionBarContributor
  extends MultiPageEditorActionBarContributor
  implements IMenuListener, IPropertyListener
{
  protected IEditorPart activeEditor;
  protected DeleteAction deleteAction;
  protected CutAction cutAction;
  protected CopyAction copyAction;
  protected PasteAction pasteAction;
  protected UndoAction undoAction;
  protected RedoAction redoAction;
  protected LoadResourceAction loadResourceAction;
  protected ControlAction controlAction;
  protected ValidateAction validateAction;
  public static final int ADDITIONS_LAST_STYLE = 1;
  protected int style;
  
  public EditingDomainActionBarContributor() {}
  
  public EditingDomainActionBarContributor(int style)
  {
    this.style = style;
  }
  
  public void init(IActionBars actionBars)
  {
    super.init(actionBars);
    ISharedImages sharedImages = PlatformUI.getWorkbench().getSharedImages();
    
    deleteAction = createDeleteAction();
    deleteAction.setImageDescriptor(sharedImages.getImageDescriptor("IMG_TOOL_DELETE"));
    actionBars.setGlobalActionHandler(ActionFactory.DELETE.getId(), deleteAction);
    
    cutAction = createCutAction();
    cutAction.setImageDescriptor(sharedImages.getImageDescriptor("IMG_TOOL_CUT"));
    actionBars.setGlobalActionHandler(ActionFactory.CUT.getId(), cutAction);
    
    copyAction = createCopyAction();
    copyAction.setImageDescriptor(sharedImages.getImageDescriptor("IMG_TOOL_COPY"));
    actionBars.setGlobalActionHandler(ActionFactory.COPY.getId(), copyAction);
    
    pasteAction = createPasteAction();
    pasteAction.setImageDescriptor(sharedImages.getImageDescriptor("IMG_TOOL_PASTE"));
    actionBars.setGlobalActionHandler(ActionFactory.PASTE.getId(), pasteAction);
    
    undoAction = createUndoAction();
    undoAction.setImageDescriptor(sharedImages.getImageDescriptor("IMG_TOOL_UNDO"));
    actionBars.setGlobalActionHandler(ActionFactory.UNDO.getId(), undoAction);
    
    redoAction = createRedoAction();
    redoAction.setImageDescriptor(sharedImages.getImageDescriptor("IMG_TOOL_REDO"));
    actionBars.setGlobalActionHandler(ActionFactory.REDO.getId(), redoAction);
  }
  
  protected DeleteAction createDeleteAction()
  {
    return new DeleteAction(removeAllReferencesOnDelete());
  }
  
  protected CutAction createCutAction()
  {
    return new CutAction();
  }
  
  protected CopyAction createCopyAction()
  {
    return new CopyAction();
  }
  
  protected PasteAction createPasteAction()
  {
    return new PasteAction();
  }
  
  protected UndoAction createUndoAction()
  {
    return new UndoAction();
  }
  
  protected RedoAction createRedoAction()
  {
    return new RedoAction();
  }
  
  protected boolean removeAllReferencesOnDelete()
  {
    return false;
  }
  
  public void contributeToMenu(IMenuManager menuManager)
  {
    super.contributeToMenu(menuManager);
  }
  
  public void contributeToStatusLine(IStatusLineManager statusLineManager)
  {
    super.contributeToStatusLine(statusLineManager);
  }
  
  public void contributeToToolBar(IToolBarManager toolBarManager)
  {
    super.contributeToToolBar(toolBarManager);
  }
  
  public void shareGlobalActions(IPage page, IActionBars actionBars)
  {
    if (!(page instanceof IPropertySheetPage))
    {
      actionBars.setGlobalActionHandler(ActionFactory.DELETE.getId(), deleteAction);
      actionBars.setGlobalActionHandler(ActionFactory.CUT.getId(), cutAction);
      actionBars.setGlobalActionHandler(ActionFactory.COPY.getId(), copyAction);
      actionBars.setGlobalActionHandler(ActionFactory.PASTE.getId(), pasteAction);
    }
    actionBars.setGlobalActionHandler(ActionFactory.UNDO.getId(), undoAction);
    actionBars.setGlobalActionHandler(ActionFactory.REDO.getId(), redoAction);
  }
  
  @Deprecated
  public void setActiveView(IViewPart part)
  {
    IActionBars actionBars = part.getViewSite().getActionBars();
    if (!(part instanceof PropertySheet))
    {
      actionBars.setGlobalActionHandler(ActionFactory.DELETE.getId(), deleteAction);
      actionBars.setGlobalActionHandler(ActionFactory.CUT.getId(), cutAction);
      actionBars.setGlobalActionHandler(ActionFactory.COPY.getId(), copyAction);
      actionBars.setGlobalActionHandler(ActionFactory.PASTE.getId(), pasteAction);
    }
    actionBars.setGlobalActionHandler(ActionFactory.UNDO.getId(), undoAction);
    actionBars.setGlobalActionHandler(ActionFactory.REDO.getId(), redoAction);
    
    actionBars.updateActionBars();
  }
  
  public IEditorPart getActiveEditor()
  {
    return activeEditor;
  }
  
  public void setActiveEditor(IEditorPart part)
  {
    super.setActiveEditor(part);
    if (part != activeEditor)
    {
      if (activeEditor != null) {
        deactivate();
      }
      if ((part instanceof IEditingDomainProvider))
      {
        activeEditor = part;
        activate();
      }
    }
  }
  
  public void setActivePage(IEditorPart part) {}
  
  public void deactivate()
  {
    activeEditor.removePropertyListener(this);
    
    deleteAction.setActiveWorkbenchPart(null);
    cutAction.setActiveWorkbenchPart(null);
    copyAction.setActiveWorkbenchPart(null);
    pasteAction.setActiveWorkbenchPart(null);
    undoAction.setActiveWorkbenchPart(null);
    redoAction.setActiveWorkbenchPart(null);
    if (loadResourceAction != null) {
      loadResourceAction.setActiveWorkbenchPart(null);
    }
    if (controlAction != null) {
      controlAction.setActiveWorkbenchPart(null);
    }
    if (validateAction != null) {
      validateAction.setActiveWorkbenchPart(null);
    }
    ISelectionProvider selectionProvider = 
      (activeEditor instanceof ISelectionProvider) ? 
      (ISelectionProvider)activeEditor : 
      activeEditor.getEditorSite().getSelectionProvider();
    if (selectionProvider != null)
    {
      selectionProvider.removeSelectionChangedListener(deleteAction);
      selectionProvider.removeSelectionChangedListener(cutAction);
      selectionProvider.removeSelectionChangedListener(copyAction);
      selectionProvider.removeSelectionChangedListener(pasteAction);
      if (validateAction != null) {
        selectionProvider.removeSelectionChangedListener(validateAction);
      }
      if (controlAction != null) {
        selectionProvider.removeSelectionChangedListener(controlAction);
      }
    }
  }
  
  public void activate()
  {
    activeEditor.addPropertyListener(this);
    
    deleteAction.setActiveWorkbenchPart(activeEditor);
    cutAction.setActiveWorkbenchPart(activeEditor);
    copyAction.setActiveWorkbenchPart(activeEditor);
    pasteAction.setActiveWorkbenchPart(activeEditor);
    undoAction.setActiveWorkbenchPart(activeEditor);
    redoAction.setActiveWorkbenchPart(activeEditor);
    if (loadResourceAction != null) {
      loadResourceAction.setActiveWorkbenchPart(activeEditor);
    }
    if (controlAction != null) {
      controlAction.setActiveWorkbenchPart(activeEditor);
    }
    if (validateAction != null) {
      validateAction.setActiveWorkbenchPart(activeEditor);
    }
    ISelectionProvider selectionProvider = 
      (activeEditor instanceof ISelectionProvider) ? 
      (ISelectionProvider)activeEditor : 
      activeEditor.getEditorSite().getSelectionProvider();
    if (selectionProvider != null)
    {
      selectionProvider.addSelectionChangedListener(deleteAction);
      selectionProvider.addSelectionChangedListener(cutAction);
      selectionProvider.addSelectionChangedListener(copyAction);
      selectionProvider.addSelectionChangedListener(pasteAction);
      if (validateAction != null) {
        selectionProvider.addSelectionChangedListener(validateAction);
      }
      if (controlAction != null) {
        selectionProvider.addSelectionChangedListener(controlAction);
      }
    }
    update();
  }
  
  public void update()
  {
    ISelectionProvider selectionProvider = 
      (activeEditor instanceof ISelectionProvider) ? 
      (ISelectionProvider)activeEditor : 
      activeEditor.getEditorSite().getSelectionProvider();
    if (selectionProvider != null)
    {
      ISelection selection = selectionProvider.getSelection();
      IStructuredSelection structuredSelection = 
        (selection instanceof IStructuredSelection) ? (IStructuredSelection)selection : StructuredSelection.EMPTY;
      
      deleteAction.updateSelection(structuredSelection);
      cutAction.updateSelection(structuredSelection);
      copyAction.updateSelection(structuredSelection);
      pasteAction.updateSelection(structuredSelection);
      if (validateAction != null) {
        validateAction.updateSelection(structuredSelection);
      }
      if (controlAction != null) {
        controlAction.updateSelection(structuredSelection);
      }
    }
    undoAction.update();
    redoAction.update();
    if (loadResourceAction != null) {
      loadResourceAction.update();
    }
  }
  
  public void menuAboutToShow(IMenuManager menuManager)
  {
    if ((style & 0x1) == 0) {
      menuManager.add(new Separator("additions"));
    }
    menuManager.add(new Separator("edit"));
    
    menuManager.add(new ActionContributionItem(undoAction));
    menuManager.add(new ActionContributionItem(redoAction));
    menuManager.add(new Separator());
    menuManager.add(new ActionContributionItem(cutAction));
    menuManager.add(new ActionContributionItem(copyAction));
    menuManager.add(new ActionContributionItem(pasteAction));
    menuManager.add(new Separator());
    menuManager.add(new ActionContributionItem(deleteAction));
    menuManager.add(new Separator());
    if ((style & 0x1) != 0)
    {
      menuManager.add(new Separator("additions"));
      menuManager.add(new Separator());
    }
    menuManager.add(new Separator("additions-end"));
    
    addGlobalActions(menuManager);
  }
  
  protected void addGlobalActions(IMenuManager menuManager)
  {
    String key = (style & 0x1) == 0 ? "additions-end" : "additions";
    if (validateAction != null) {
      menuManager.insertBefore(key, new ActionContributionItem(validateAction));
    }
    if (controlAction != null) {
      menuManager.insertBefore(key, new ActionContributionItem(controlAction));
    }
    if ((validateAction != null) || (controlAction != null)) {
      menuManager.insertBefore(key, new Separator());
    }
    if (loadResourceAction != null)
    {
      menuManager.insertBefore("additions-end", new ActionContributionItem(loadResourceAction));
      menuManager.insertBefore("additions-end", new Separator());
    }
  }
  
  public void propertyChanged(Object source, int id)
  {
    update();
  }
}

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

import org.eclipse.emf.common.ui.dialogs.ResourceDialog;
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.edit.domain.EditingDomain;
import org.eclipse.emf.edit.ui.EMFEditUIPlugin;
import org.eclipse.swt.widgets.Shell;

public class LoadResourceAction$LoadResourceDialog
  extends ResourceDialog
{
  protected EditingDomain domain;
  
  public LoadResourceAction$LoadResourceDialog(Shell parent)
  {
    this(parent, null);
  }
  
  public LoadResourceAction$LoadResourceDialog(Shell parent, EditingDomain domain)
  {
    super(parent, EMFEditUIPlugin.INSTANCE.getString("_UI_LoadResourceDialog_title"), 4098);
    this.domain = domain;
  }
  
  protected boolean processResources()
  {
    if (domain != null) {
      for (URI uri : getURIs()) {
        try
        {
          if (!processResource(domain.getResourceSet().getResource(uri, true))) {
            return false;
          }
        }
        catch (RuntimeException exception)
        {
          EMFEditUIPlugin.INSTANCE.log(exception);
        }
      }
    }
    return true;
  }
  
  protected boolean processResource(Resource resource)
  {
    return true;
  }
}

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

import org.eclipse.emf.common.ui.dialogs.ResourceDialog;
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.edit.domain.EditingDomain;
import org.eclipse.emf.edit.domain.IEditingDomainProvider;
import org.eclipse.emf.edit.ui.EMFEditUIPlugin;
import org.eclipse.jface.action.Action;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;

public class LoadResourceAction
  extends Action
{
  protected EditingDomain domain;
  
  public LoadResourceAction(EditingDomain domain)
  {
    this();
    this.domain = domain;
    update();
  }
  
  public LoadResourceAction()
  {
    super(EMFEditUIPlugin.INSTANCE.getString("_UI_LoadResource_menu_item"));
    setDescription(EMFEditUIPlugin.INSTANCE.getString("_UI_LoadResource_menu_item_description"));
  }
  
  public EditingDomain getEditingDomain()
  {
    return domain;
  }
  
  public void setEditingDomain(EditingDomain domain)
  {
    this.domain = domain;
  }
  
  public void run()
  {
    LoadResourceDialog loadResourceDialog = 
      new LoadResourceDialog(
      PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), domain);
    
    loadResourceDialog.open();
  }
  
  public void update()
  {
    setEnabled(domain != null);
  }
  
  @Deprecated
  public void setActiveEditor(IEditorPart editorPart)
  {
    setActiveWorkbenchPart(editorPart);
  }
  
  public void setActiveWorkbenchPart(IWorkbenchPart workbenchPart)
  {
    setEditingDomain((workbenchPart instanceof IEditingDomainProvider) ? ((IEditingDomainProvider)workbenchPart).getEditingDomain() : null);
  }
  
  public static class LoadResourceDialog
    extends ResourceDialog
  {
    protected EditingDomain domain;
    
    public LoadResourceDialog(Shell parent)
    {
      this(parent, null);
    }
    
    public LoadResourceDialog(Shell parent, EditingDomain domain)
    {
      super(EMFEditUIPlugin.INSTANCE.getString("_UI_LoadResourceDialog_title"), 4098);
      this.domain = domain;
    }
    
    protected boolean processResources()
    {
      if (domain != null) {
        for (URI uri : getURIs()) {
          try
          {
            if (!processResource(domain.getResourceSet().getResource(uri, true))) {
              return false;
            }
          }
          catch (RuntimeException exception)
          {
            EMFEditUIPlugin.INSTANCE.log(exception);
          }
        }
      }
      return true;
    }
    
    protected boolean processResource(Resource resource)
    {
      return true;
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.edit.ui.action.LoadResourceAction
 * 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.PasteFromClipboardCommand;
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 PasteAction
  extends CommandActionHandler
{
  public PasteAction(EditingDomain domain)
  {
    super(domain, EMFEditUIPlugin.INSTANCE.getString("_UI_Paste_menu_item"));
  }
  
  public PasteAction()
  {
    super(null, EMFEditUIPlugin.INSTANCE.getString("_UI_Paste_menu_item"));
  }
  
  public Command createCommand(Collection<?> selection)
  {
    if (selection.size() == 1) {
      return PasteFromClipboardCommand.create(domain, selection.iterator().next(), null);
    }
    return UnexecutableCommand.INSTANCE;
  }
  
  @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.PasteAction
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.edit.ui.action;

import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.common.command.CommandStack;
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.action.Action;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbenchPart;

public class RedoAction
  extends Action
{
  protected EditingDomain domain;
  
  public RedoAction(EditingDomain domain)
  {
    super(EMFEditUIPlugin.INSTANCE.getString("_UI_Redo_menu_item", new Object[] { "" }));
    this.domain = domain;
    update();
  }
  
  public RedoAction()
  {
    super(EMFEditUIPlugin.INSTANCE.getString("_UI_Redo_menu_item", new Object[] { "" }));
  }
  
  public EditingDomain getEditingDomain()
  {
    return domain;
  }
  
  public void setEditingDomain(EditingDomain domain)
  {
    this.domain = domain;
  }
  
  public void run()
  {
    domain.getCommandStack().redo();
  }
  
  public void update()
  {
    setEnabled(domain.getCommandStack().canRedo());
    
    Command redoCommand = domain.getCommandStack().getRedoCommand();
    if ((redoCommand != null) && (redoCommand.getLabel() != null)) {
      setText(EMFEditUIPlugin.INSTANCE.getString("_UI_Redo_menu_item", new Object[] { redoCommand.getLabel() }));
    } else {
      setText(EMFEditUIPlugin.INSTANCE.getString("_UI_Redo_menu_item", new Object[] { "" }));
    }
    if ((redoCommand != null) && (redoCommand.getDescription() != null)) {
      setDescription(EMFEditUIPlugin.INSTANCE.getString("_UI_Redo_menu_item_description", new Object[] { redoCommand.getDescription() }));
    } else {
      setDescription(EMFEditUIPlugin.INSTANCE.getString("_UI_Redo_menu_item_simple_description"));
    }
  }
  
  @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.RedoAction
 * 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.resource.ImageDescriptor;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbenchPart;

public abstract class StaticSelectionCommandAction
  extends Action
{
  protected EditingDomain editingDomain;
  protected Command command;
  
  public StaticSelectionCommandAction(IWorkbenchPart workbenchPart)
  {
    if ((workbenchPart instanceof IEditingDomainProvider)) {
      editingDomain = ((IEditingDomainProvider)workbenchPart).getEditingDomain();
    }
  }
  
  public StaticSelectionCommandAction(IEditorPart editorPart)
  {
    this(editorPart);
  }
  
  public StaticSelectionCommandAction(EditingDomain editingDomain)
  {
    this.editingDomain = editingDomain;
  }
  
  public StaticSelectionCommandAction() {}
  
  protected abstract Command createActionCommand(EditingDomain paramEditingDomain, Collection<?> paramCollection);
  
  public void configureAction(ISelection selection)
  {
    if (!(selection instanceof IStructuredSelection))
    {
      disable();
    }
    else
    {
      IStructuredSelection sselection = (IStructuredSelection)selection;
      List<?> list = sselection.toList();
      Collection<Object> collection = new ArrayList(list);
      if (editingDomain == null) {
        for (Object o : collection)
        {
          editingDomain = AdapterFactoryEditingDomain.getEditingDomainFor(o);
          if (editingDomain != null) {
            break;
          }
        }
      }
      if (editingDomain != null)
      {
        command = createActionCommand(editingDomain, collection);
        setEnabled(command.canExecute());
      }
      if ((command == null) || (command == UnexecutableCommand.INSTANCE))
      {
        disable();
      }
      else if (!(command instanceof CommandActionDelegate))
      {
        if (getDefaultImageDescriptor() != null) {
          setImageDescriptor(getDefaultImageDescriptor());
        }
      }
      else
      {
        CommandActionDelegate commandActionDelegate = 
          (CommandActionDelegate)command;
        
        ImageDescriptor imageDescriptor = 
          objectToImageDescriptor(commandActionDelegate.getImage());
        if (imageDescriptor != null) {
          setImageDescriptor(imageDescriptor);
        } else if (getDefaultImageDescriptor() != null) {
          setImageDescriptor(getDefaultImageDescriptor());
        }
        if (commandActionDelegate.getText() != null) {
          setText(commandActionDelegate.getText());
        }
        if (commandActionDelegate.getDescription() != null) {
          setDescription(commandActionDelegate.getDescription());
        }
        if (commandActionDelegate.getToolTipText() != null) {
          setToolTipText(commandActionDelegate.getToolTipText());
        }
      }
    }
  }
  
  protected ImageDescriptor getDefaultImageDescriptor()
  {
    return null;
  }
  
  protected void disable()
  {
    setEnabled(false);
    if (getDefaultImageDescriptor() != null) {
      setImageDescriptor(getDefaultImageDescriptor());
    }
  }
  
  public void run()
  {
    if ((editingDomain != null) && (command != null)) {
      editingDomain.getCommandStack().execute(command);
    }
  }
  
  protected ImageDescriptor objectToImageDescriptor(Object object)
  {
    return ExtendedImageRegistry.getInstance().getImageDescriptor(object);
  }
}

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

import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.common.command.CommandStack;
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.action.Action;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbenchPart;

public class UndoAction
  extends Action
{
  protected EditingDomain domain;
  
  public UndoAction(EditingDomain domain)
  {
    super(EMFEditUIPlugin.INSTANCE.getString("_UI_Undo_menu_item", new Object[] { "" }));
    this.domain = domain;
    update();
  }
  
  public UndoAction()
  {
    super(EMFEditUIPlugin.INSTANCE.getString("_UI_Undo_menu_item", new Object[] { "" }));
  }
  
  public EditingDomain getEditingDomain()
  {
    return domain;
  }
  
  public void setEditingDomain(EditingDomain domain)
  {
    this.domain = domain;
  }
  
  public void run()
  {
    domain.getCommandStack().undo();
  }
  
  public void update()
  {
    setEnabled(domain.getCommandStack().canUndo());
    
    Command undoCommand = domain.getCommandStack().getUndoCommand();
    if ((undoCommand != null) && (undoCommand.getLabel() != null)) {
      setText(EMFEditUIPlugin.INSTANCE.getString("_UI_Undo_menu_item", new Object[] { undoCommand.getLabel() }));
    } else {
      setText(EMFEditUIPlugin.INSTANCE.getString("_UI_Undo_menu_item", new Object[] { "" }));
    }
    if ((undoCommand != null) && (undoCommand.getDescription() != null)) {
      setDescription(EMFEditUIPlugin.INSTANCE.getString("_UI_Undo_menu_item_description", new Object[] { undoCommand.getDescription() }));
    } else {
      setDescription(EMFEditUIPlugin.INSTANCE.getString("_UI_Undo_menu_item_simple_description"));
    }
  }
  
  @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.UndoAction
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.edit.ui.action;

import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.emf.common.util.Diagnostic;

class ValidateAction$1$1
  implements Runnable
{
  ValidateAction$1$1(ValidateAction.1 param1, IProgressMonitor paramIProgressMonitor, Diagnostic paramDiagnostic) {}
  
  public void run()
  {
    if (val$progressMonitor.isCanceled()) {
      ValidateAction.1.access$0(this$1).handleDiagnostic(Diagnostic.CANCEL_INSTANCE);
    } else {
      ValidateAction.1.access$0(this$1).handleDiagnostic(val$diagnostic);
    }
  }
}

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

import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.emf.common.util.Diagnostic;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.swt.widgets.Shell;

class ValidateAction$1
  implements IRunnableWithProgress
{
  ValidateAction$1(ValidateAction paramValidateAction, Shell paramShell) {}
  
  /* Error */
  public void run(final IProgressMonitor progressMonitor)
    throws java.lang.reflect.InvocationTargetException, java.lang.InterruptedException
  {
    // Byte code:
    //   0: aload_0
    //   1: getfield 55	org/eclipse/emf/edit/ui/action/ValidateAction$1:this$0	Lorg/eclipse/emf/edit/ui/action/ValidateAction;
    //   4: aload_1
    //   5: invokevirtual 58	org/eclipse/emf/edit/ui/action/ValidateAction:validate	(Lorg/eclipse/core/runtime/IProgressMonitor;)Lorg/eclipse/emf/common/util/Diagnostic;
    //   8: astore_2
    //   9: aload_0
    //   10: getfield 56	org/eclipse/emf/edit/ui/action/ValidateAction$1:val$shell	Lorg/eclipse/swt/widgets/Shell;
    //   13: invokevirtual 61	org/eclipse/swt/widgets/Shell:getDisplay	()Lorg/eclipse/swt/widgets/Display;
    //   16: new 30	org/eclipse/emf/edit/ui/action/ValidateAction$1$1
    //   19: dup
    //   20: aload_0
    //   21: aload_1
    //   22: aload_2
    //   23: invokespecial 59	org/eclipse/emf/edit/ui/action/ValidateAction$1$1:<init>	(Lorg/eclipse/emf/edit/ui/action/ValidateAction$1;Lorg/eclipse/core/runtime/IProgressMonitor;Lorg/eclipse/emf/common/util/Diagnostic;)V
    //   26: invokevirtual 60	org/eclipse/swt/widgets/Display:asyncExec	(Ljava/lang/Runnable;)V
    //   29: goto +12 -> 41
    //   32: astore_3
    //   33: aload_1
    //   34: invokeinterface 62 1 0
    //   39: aload_3
    //   40: athrow
    //   41: aload_1
    //   42: invokeinterface 62 1 0
    //   47: return
    // Line number table:
    //   Java source line #177	-> byte code offset #0
    //   Java source line #178	-> byte code offset #9
    //   Java source line #179	-> byte code offset #16
    //   Java source line #178	-> byte code offset #26
    //   Java source line #195	-> byte code offset #32
    //   Java source line #196	-> byte code offset #33
    //   Java source line #197	-> byte code offset #39
    //   Java source line #196	-> byte code offset #41
    //   Java source line #198	-> byte code offset #47
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	48	0	this	1
    //   0	48	1	progressMonitor	IProgressMonitor
    //   8	15	2	diagnostic	Diagnostic
    //   32	8	3	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   0	32	32	finally
  }
}

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

import java.util.Map;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.emf.common.notify.AdapterFactory;
import org.eclipse.emf.common.util.DiagnosticChain;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.util.Diagnostician;
import org.eclipse.emf.edit.provider.IItemLabelProvider;

class ValidateAction$2
  extends Diagnostician
{
  ValidateAction$2(ValidateAction paramValidateAction, AdapterFactory paramAdapterFactory, IProgressMonitor paramIProgressMonitor) {}
  
  public String getObjectLabel(EObject eObject)
  {
    if ((val$adapterFactory != null) && (!eObject.eIsProxy()))
    {
      IItemLabelProvider itemLabelProvider = (IItemLabelProvider)val$adapterFactory.adapt(eObject, IItemLabelProvider.class);
      if (itemLabelProvider != null) {
        return itemLabelProvider.getText(eObject);
      }
    }
    return super.getObjectLabel(eObject);
  }
  
  public boolean validate(EClass eClass, EObject eObject, DiagnosticChain diagnostics, Map<Object, Object> context)
  {
    val$progressMonitor.worked(1);
    return super.validate(eClass, eObject, diagnostics, context);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.edit.ui.action.ValidateAction.2
 * 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.core.resources.IMarker;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.emf.common.util.Diagnostic;
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.util.EcoreUtil;
import org.eclipse.emf.edit.ui.EMFEditUIPlugin;
import org.eclipse.emf.edit.ui.util.EditUIMarkerHelper;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.ui.actions.WorkspaceModifyDelegatingOperation;

public class ValidateAction$EclipseResourcesUtil
  extends EditUIMarkerHelper
{
  public IRunnableWithProgress getWorkspaceModifyOperation(IRunnableWithProgress runnableWithProgress)
  {
    try
    {
      return new WorkspaceModifyDelegatingOperation(runnableWithProgress);
    }
    catch (NoClassDefFoundError exception) {}
    return runnableWithProgress;
  }
  
  protected String getMarkerID()
  {
    return "org.eclipse.emf.ecore.diagnostic";
  }
  
  public void createMarkers(Resource resource, Diagnostic diagnostic)
  {
    try
    {
      createMarkers(getFile(resource), diagnostic, null);
    }
    catch (CoreException e)
    {
      EMFEditUIPlugin.INSTANCE.log(e);
    }
  }
  
  protected String composeMessage(Diagnostic diagnostic, Diagnostic parentDiagnostic)
  {
    String message = diagnostic.getMessage();
    if (parentDiagnostic != null)
    {
      String parentMessage = parentDiagnostic.getMessage();
      if (parentMessage != null) {
        message = message != null ? parentMessage + ". " + message : parentMessage;
      }
    }
    return message;
  }
  
  protected void adjustMarker(IMarker marker, Diagnostic diagnostic, Diagnostic parentDiagnostic)
    throws CoreException
  {
    List<?> data = diagnostic.getData();
    StringBuilder relatedURIs = new StringBuilder();
    boolean first = true;
    for (Object object : data) {
      if ((object instanceof EObject))
      {
        EObject eObject = (EObject)object;
        if (first)
        {
          first = false;
          marker.setAttribute("uri", EcoreUtil.getURI(eObject).toString());
        }
        else
        {
          if (relatedURIs.length() != 0) {
            relatedURIs.append(' ');
          }
          relatedURIs.append(URI.encodeFragment(EcoreUtil.getURI(eObject).toString(), false));
        }
      }
    }
    if (relatedURIs.length() > 0) {
      marker.setAttribute("relatedURIs", relatedURIs.toString());
    }
    super.adjustMarker(marker, diagnostic, parentDiagnostic);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.edit.ui.action.ValidateAction.EclipseResourcesUtil
 * 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.Iterator;
import java.util.List;
import java.util.Map;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.emf.common.EMFPlugin;
import org.eclipse.emf.common.notify.AdapterFactory;
import org.eclipse.emf.common.ui.dialogs.DiagnosticDialog;
import org.eclipse.emf.common.ui.viewer.IViewerProvider;
import org.eclipse.emf.common.util.BasicDiagnostic;
import org.eclipse.emf.common.util.Diagnostic;
import org.eclipse.emf.common.util.DiagnosticChain;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EClass;
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.util.Diagnostician;
import org.eclipse.emf.ecore.util.EcoreUtil;
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.provider.IItemLabelProvider;
import org.eclipse.emf.edit.ui.EMFEditUIPlugin;
import org.eclipse.emf.edit.ui.util.EditUIMarkerHelper;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.actions.WorkspaceModifyDelegatingOperation;
import org.eclipse.ui.part.ISetSelectionTarget;

public class ValidateAction
  extends Action
  implements ISelectionChangedListener
{
  protected ISelectionProvider selectionProvider;
  protected List<EObject> selectedObjects;
  protected EditingDomain domain;
  
  public static class EclipseResourcesUtil
    extends EditUIMarkerHelper
  {
    public IRunnableWithProgress getWorkspaceModifyOperation(IRunnableWithProgress runnableWithProgress)
    {
      try
      {
        return new WorkspaceModifyDelegatingOperation(runnableWithProgress);
      }
      catch (NoClassDefFoundError exception) {}
      return runnableWithProgress;
    }
    
    protected String getMarkerID()
    {
      return "org.eclipse.emf.ecore.diagnostic";
    }
    
    public void createMarkers(Resource resource, Diagnostic diagnostic)
    {
      try
      {
        createMarkers(getFile(resource), diagnostic, null);
      }
      catch (CoreException e)
      {
        EMFEditUIPlugin.INSTANCE.log(e);
      }
    }
    
    protected String composeMessage(Diagnostic diagnostic, Diagnostic parentDiagnostic)
    {
      String message = diagnostic.getMessage();
      if (parentDiagnostic != null)
      {
        String parentMessage = parentDiagnostic.getMessage();
        if (parentMessage != null) {
          message = message != null ? parentMessage + ". " + message : parentMessage;
        }
      }
      return message;
    }
    
    protected void adjustMarker(IMarker marker, Diagnostic diagnostic, Diagnostic parentDiagnostic)
      throws CoreException
    {
      List<?> data = diagnostic.getData();
      StringBuilder relatedURIs = new StringBuilder();
      boolean first = true;
      for (Object object : data) {
        if ((object instanceof EObject))
        {
          EObject eObject = (EObject)object;
          if (first)
          {
            first = false;
            marker.setAttribute("uri", EcoreUtil.getURI(eObject).toString());
          }
          else
          {
            if (relatedURIs.length() != 0) {
              relatedURIs.append(' ');
            }
            relatedURIs.append(URI.encodeFragment(EcoreUtil.getURI(eObject).toString(), false));
          }
        }
      }
      if (relatedURIs.length() > 0) {
        marker.setAttribute("relatedURIs", relatedURIs.toString());
      }
      super.adjustMarker(marker, diagnostic, parentDiagnostic);
    }
  }
  
  protected EclipseResourcesUtil eclipseResourcesUtil = EMFPlugin.IS_RESOURCES_BUNDLE_AVAILABLE ? 
    new EclipseResourcesUtil() : 
    null;
  
  public ValidateAction()
  {
    super(EMFEditUIPlugin.INSTANCE.getString("_UI_Validate_menu_item"));
    setDescription(EMFEditUIPlugin.INSTANCE.getString("_UI_Validate_simple_description"));
  }
  
  public void run()
  {
    final Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
    IRunnableWithProgress runnableWithProgress = new IRunnableWithProgress()
    {
      /* Error */
      public void run(final IProgressMonitor progressMonitor)
        throws java.lang.reflect.InvocationTargetException, java.lang.InterruptedException
      {
        // Byte code:
        //   0: aload_0
        //   1: getfield 55	org/eclipse/emf/edit/ui/action/ValidateAction$1:this$0	Lorg/eclipse/emf/edit/ui/action/ValidateAction;
        //   4: aload_1
        //   5: invokevirtual 58	org/eclipse/emf/edit/ui/action/ValidateAction:validate	(Lorg/eclipse/core/runtime/IProgressMonitor;)Lorg/eclipse/emf/common/util/Diagnostic;
        //   8: astore_2
        //   9: aload_0
        //   10: getfield 56	org/eclipse/emf/edit/ui/action/ValidateAction$1:val$shell	Lorg/eclipse/swt/widgets/Shell;
        //   13: invokevirtual 61	org/eclipse/swt/widgets/Shell:getDisplay	()Lorg/eclipse/swt/widgets/Display;
        //   16: new 30	
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