org.eclipse.ui.navigator.resources_3.4.400.v20120705-114010

16:48:20.690 INFO  jd.cli.Main - Decompiling org.eclipse.ui.navigator.resources_3.4.400.v20120705-114010.jar
package org.eclipse.ui.internal.navigator.resources;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Stack;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.swt.widgets.Item;
import org.eclipse.ui.navigator.CommonViewer;
import org.eclipse.ui.navigator.ICommonViewerMapper;

public class ResourceToItemsMapper
  implements ICommonViewerMapper
{
  private static final int NUMBER_LIST_REUSE = 10;
  private HashMap _resourceToItem;
  private Stack _reuseLists;
  private CommonViewer _commonViewer;
  
  public ResourceToItemsMapper(CommonViewer viewer)
  {
    _resourceToItem = new HashMap();
    _reuseLists = new Stack();
    
    _commonViewer = viewer;
    viewer.setMapper(this);
  }
  
  public void addToMap(Object element, Item item)
  {
    IResource resource = getCorrespondingResource(element);
    if (resource != null)
    {
      Object existingMapping = _resourceToItem.get(resource);
      if (existingMapping == null)
      {
        _resourceToItem.put(resource, item);
      }
      else if ((existingMapping instanceof Item))
      {
        if (existingMapping != item)
        {
          List list = getNewList();
          list.add(existingMapping);
          list.add(item);
          _resourceToItem.put(resource, list);
        }
      }
      else
      {
        List list = (List)existingMapping;
        if (!list.contains(item)) {
          list.add(item);
        }
      }
    }
  }
  
  public void removeFromMap(Object element, Item item)
  {
    IResource resource = getCorrespondingResource(element);
    if (resource != null)
    {
      Object existingMapping = _resourceToItem.get(resource);
      if (existingMapping == null) {
        return;
      }
      if ((existingMapping instanceof Item))
      {
        _resourceToItem.remove(resource);
      }
      else
      {
        List list = (List)existingMapping;
        list.remove(item);
        if (list.isEmpty())
        {
          _resourceToItem.remove(list);
          releaseList(list);
        }
      }
    }
  }
  
  public void clearMap()
  {
    _resourceToItem.clear();
  }
  
  public boolean isEmpty()
  {
    return _resourceToItem.isEmpty();
  }
  
  private List getNewList()
  {
    if (!_reuseLists.isEmpty()) {
      return (List)_reuseLists.pop();
    }
    return new ArrayList(2);
  }
  
  private void releaseList(List list)
  {
    if (_reuseLists.size() < 10) {
      _reuseLists.push(list);
    }
  }
  
  public boolean handlesObject(Object object)
  {
    return object instanceof IResource;
  }
  
  public void objectChanged(Object changedResource)
  {
    Object obj = _resourceToItem.get(changedResource);
    if (obj != null) {
      if ((obj instanceof Item))
      {
        updateItem((Item)obj);
      }
      else
      {
        List list = (List)obj;
        for (int k = 0; k < list.size(); k++) {
          updateItem((Item)list.get(k));
        }
      }
    }
  }
  
  private void updateItem(Item item)
  {
    if (!item.isDisposed()) {
      _commonViewer.doUpdateItem(item);
    }
  }
  
  private static IResource getCorrespondingResource(Object element)
  {
    if ((element instanceof IResource)) {
      return (IResource)element;
    }
    if ((element instanceof IAdaptable)) {
      return (IResource)((IAdaptable)element).getAdapter(IResource.class);
    }
    return null;
  }
}

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

import java.util.Iterator;
import java.util.List;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.SWTError;
import org.eclipse.swt.dnd.Clipboard;
import org.eclipse.swt.dnd.FileTransfer;
import org.eclipse.swt.dnd.TextTransfer;
import org.eclipse.swt.dnd.Transfer;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.actions.SelectionListenerAction;
import org.eclipse.ui.help.IWorkbenchHelpSystem;
import org.eclipse.ui.internal.navigator.resources.plugin.WorkbenchNavigatorMessages;
import org.eclipse.ui.part.ResourceTransfer;

class CopyAction
  extends SelectionListenerAction
{
  public static final String ID = "org.eclipse.ui.CopyAction";
  private Shell shell;
  private Clipboard clipboard;
  private PasteAction pasteAction;
  
  public CopyAction(Shell shell, Clipboard clipboard)
  {
    super(WorkbenchNavigatorMessages.CopyAction_Cop_);
    Assert.isNotNull(shell);
    Assert.isNotNull(clipboard);
    this.shell = shell;
    this.clipboard = clipboard;
    setToolTipText(WorkbenchNavigatorMessages.CopyAction_Copy_selected_resource_s_);
    setId("org.eclipse.ui.CopyAction");
    PlatformUI.getWorkbench().getHelpSystem().setHelp(this, "CopyHelpId");
  }
  
  public CopyAction(Shell shell, Clipboard clipboard, PasteAction pasteAction)
  {
    this(shell, clipboard);
    this.pasteAction = pasteAction;
  }
  
  public void run()
  {
    List selectedResources = getSelectedResources();
    IResource[] resources = (IResource[])selectedResources
      .toArray(new IResource[selectedResources.size()]);
    
    int length = resources.length;
    int actualLength = 0;
    String[] fileNames = new String[length];
    StringBuffer buf = new StringBuffer();
    for (int i = 0; i < length; i++)
    {
      IPath location = resources[i].getLocation();
      if (location != null) {
        fileNames[(actualLength++)] = location.toOSString();
      }
      if (i > 0) {
        buf.append("\n");
      }
      buf.append(resources[i].getName());
    }
    if (actualLength < length)
    {
      String[] tempFileNames = fileNames;
      fileNames = new String[actualLength];
      for (int i = 0; i < actualLength; i++) {
        fileNames[i] = tempFileNames[i];
      }
    }
    setClipboard(resources, fileNames, buf.toString());
    if ((pasteAction != null) && (pasteAction.getStructuredSelection() != null)) {
      pasteAction.selectionChanged(pasteAction.getStructuredSelection());
    }
  }
  
  private void setClipboard(IResource[] resources, String[] fileNames, String names)
  {
    try
    {
      if (fileNames.length > 0) {
        clipboard.setContents(new Object[] { resources, fileNames, 
          names }, 
          new Transfer[] { ResourceTransfer.getInstance(), 
          FileTransfer.getInstance(), 
          TextTransfer.getInstance() });
      } else {
        clipboard.setContents(new Object[] { resources, names }, 
          new Transfer[] { ResourceTransfer.getInstance(), 
          TextTransfer.getInstance() });
      }
    }
    catch (SWTError e)
    {
      if (code != 2002) {
        throw e;
      }
      if (MessageDialog.openQuestion(
        shell, 
        "Problem with copy title", 
        "Problem with copy.")) {
        setClipboard(resources, fileNames, names);
      }
    }
  }
  
  protected boolean updateSelection(IStructuredSelection selection)
  {
    if (!super.updateSelection(selection)) {
      return false;
    }
    if (getSelectedNonResources().size() > 0) {
      return false;
    }
    List selectedResources = getSelectedResources();
    if (selectedResources.size() == 0) {
      return false;
    }
    boolean projSelected = selectionIsOfType(4);
    boolean fileFoldersSelected = selectionIsOfType(3);
    if ((!projSelected) && (!fileFoldersSelected)) {
      return false;
    }
    if ((projSelected) && (fileFoldersSelected)) {
      return false;
    }
    IContainer firstParent = ((IResource)selectedResources.get(0))
      .getParent();
    if (firstParent == null) {
      return false;
    }
    Iterator resourcesEnum = selectedResources.iterator();
    while (resourcesEnum.hasNext())
    {
      IResource currentResource = (IResource)resourcesEnum.next();
      if (!currentResource.getParent().equals(firstParent)) {
        return false;
      }
      if (currentResource.getLocationURI() == null) {
        return false;
      }
    }
    return true;
  }
}

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

import org.eclipse.jface.window.IShellProvider;
import org.eclipse.swt.widgets.Shell;

class EditActionGroup$1
  implements IShellProvider
{
  final EditActionGroup this$0;
  
  EditActionGroup$1(EditActionGroup paramEditActionGroup)
  {
    this$0 = paramEditActionGroup;
  }
  
  public Shell getShell()
  {
    return EditActionGroup.access$0(this$0);
  }
}

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

import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.window.IShellProvider;
import org.eclipse.swt.dnd.Clipboard;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.actions.ActionContext;
import org.eclipse.ui.actions.ActionGroup;
import org.eclipse.ui.actions.DeleteResourceAction;
import org.eclipse.ui.actions.TextActionHandler;
import org.eclipse.ui.ide.ResourceSelectionUtil;

public class EditActionGroup
  extends ActionGroup
{
  private Clipboard clipboard;
  private CopyAction copyAction;
  private DeleteResourceAction deleteAction;
  private PasteAction pasteAction;
  private TextActionHandler textActionHandler;
  private Shell shell;
  
  public EditActionGroup(Shell aShell)
  {
    shell = aShell;
    makeActions();
  }
  
  public void dispose()
  {
    if (clipboard != null)
    {
      clipboard.dispose();
      clipboard = null;
    }
    super.dispose();
  }
  
  public void fillContextMenu(IMenuManager menu)
  {
    IStructuredSelection selection = (IStructuredSelection)getContext().getSelection();
    
    boolean anyResourceSelected = (!selection.isEmpty()) && 
      (ResourceSelectionUtil.allResourcesAreOfType(selection, 7));
    
    copyAction.selectionChanged(selection);
    menu.appendToGroup("group.edit", copyAction);
    pasteAction.selectionChanged(selection);
    
    menu.appendToGroup("group.edit", pasteAction);
    if (anyResourceSelected)
    {
      deleteAction.selectionChanged(selection);
      
      menu.appendToGroup("group.edit", deleteAction);
    }
  }
  
  public void fillActionBars(IActionBars actionBars)
  {
    if (textActionHandler == null) {
      textActionHandler = new TextActionHandler(actionBars);
    }
    textActionHandler.setCopyAction(copyAction);
    textActionHandler.setPasteAction(pasteAction);
    textActionHandler.setDeleteAction(deleteAction);
    
    updateActionBars();
    
    textActionHandler.updateActionBars();
  }
  
  public void handleKeyPressed(KeyEvent event)
  {
    if ((character == '') && (stateMask == 0))
    {
      if (deleteAction.isEnabled()) {
        deleteAction.run();
      }
      doit = false;
    }
  }
  
  protected void makeActions()
  {
    clipboard = new Clipboard(shell.getDisplay());
    
    pasteAction = new PasteAction(shell, clipboard);
    ISharedImages images = PlatformUI.getWorkbench().getSharedImages();
    pasteAction.setDisabledImageDescriptor(images.getImageDescriptor("IMG_TOOL_PASTE_DISABLED"));
    pasteAction.setImageDescriptor(images.getImageDescriptor("IMG_TOOL_PASTE"));
    pasteAction.setActionDefinitionId("org.eclipse.ui.edit.paste");
    
    copyAction = new CopyAction(shell, clipboard, pasteAction);
    copyAction.setDisabledImageDescriptor(images.getImageDescriptor("IMG_TOOL_COPY_DISABLED"));
    copyAction.setImageDescriptor(images.getImageDescriptor("IMG_TOOL_COPY"));
    copyAction.setActionDefinitionId("org.eclipse.ui.edit.copy");
    
    IShellProvider sp = new IShellProvider()
    {
      public Shell getShell()
      {
        return shell;
      }
    };
    deleteAction = new DeleteResourceAction(sp);
    deleteAction.setDisabledImageDescriptor(images.getImageDescriptor("IMG_TOOL_DELETE_DISABLED"));
    deleteAction.setImageDescriptor(images.getImageDescriptor("IMG_TOOL_DELETE"));
    deleteAction.setActionDefinitionId("org.eclipse.ui.edit.delete");
  }
  
  public void updateActionBars()
  {
    IStructuredSelection selection = (IStructuredSelection)getContext().getSelection();
    
    copyAction.selectionChanged(selection);
    pasteAction.selectionChanged(selection);
    deleteAction.selectionChanged(selection);
  }
}

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

import org.eclipse.jface.action.IMenuManager;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.actions.ActionContext;
import org.eclipse.ui.navigator.CommonActionProvider;
import org.eclipse.ui.navigator.ICommonActionExtensionSite;
import org.eclipse.ui.navigator.ICommonViewerSite;

public class EditActionProvider
  extends CommonActionProvider
{
  private EditActionGroup editGroup;
  private ICommonActionExtensionSite site;
  
  public void init(ICommonActionExtensionSite anActionSite)
  {
    site = anActionSite;
    editGroup = new EditActionGroup(site.getViewSite().getShell());
  }
  
  public void dispose()
  {
    editGroup.dispose();
  }
  
  public void fillActionBars(IActionBars actionBars)
  {
    editGroup.fillActionBars(actionBars);
  }
  
  public void fillContextMenu(IMenuManager menu)
  {
    editGroup.fillContextMenu(menu);
  }
  
  public void setContext(ActionContext context)
  {
    editGroup.setContext(context);
  }
  
  public void updateActionBars()
  {
    editGroup.updateActionBars();
  }
}

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

import org.eclipse.ui.IActionBars;
import org.eclipse.ui.navigator.CommonActionProvider;
import org.eclipse.ui.navigator.CommonViewer;
import org.eclipse.ui.navigator.ICommonActionExtensionSite;
import org.eclipse.ui.navigator.ICommonViewerSite;

public class GotoActionProvider
  extends CommonActionProvider
{
  private GotoResourceAction gotoAction;
  
  public void init(ICommonActionExtensionSite anActionSite)
  {
    gotoAction = new GotoResourceAction(anActionSite.getViewSite().getShell(), (CommonViewer)anActionSite.getStructuredViewer());
  }
  
  public void fillActionBars(IActionBars actionBars)
  {
    actionBars.setGlobalActionHandler(
      "goToResource", gotoAction);
    updateActionBars();
  }
}

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

import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.help.IWorkbenchHelpSystem;

public class GotoResourceAction
  extends Action
{
  protected Shell shell;
  protected TreeViewer viewer;
  
  public GotoResourceAction(Shell shell, TreeViewer viewer)
  {
    this.shell = shell;
    this.viewer = viewer;
    PlatformUI.getWorkbench().getHelpSystem().setHelp(this, 
      "org.eclipse.ui.goto_resource_action_context");
  }
  
  public void run()
  {
    GotoResourceDialog dialog = new GotoResourceDialog(shell, 
      ResourcesPlugin.getWorkspace().getRoot(), 7);
    
    dialog.open();
    Object[] result = dialog.getResult();
    if ((result == null) || (result.length == 0) || 
      (!(result[0] instanceof IResource))) {
      return;
    }
    IResource selection = (IResource)result[0];
    viewer.setSelection(new StructuredSelection(selection), true);
  }
}

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

import org.eclipse.core.resources.IContainer;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.dialogs.FilteredResourcesSelectionDialog;
import org.eclipse.ui.help.IWorkbenchHelpSystem;
import org.eclipse.ui.internal.navigator.resources.plugin.WorkbenchNavigatorMessages;

class GotoResourceDialog
  extends FilteredResourcesSelectionDialog
{
  protected GotoResourceDialog(Shell parentShell, IContainer container, int typesMask)
  {
    super(parentShell, false, container, typesMask);
    setTitle(WorkbenchNavigatorMessages.GotoResourceDialog_GoToTitle);
    PlatformUI.getWorkbench().getHelpSystem().setHelp(parentShell, 
      "org.eclipse.ui.goto_resource_dialog_context");
  }
}

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

import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.actions.ActionFactory;
import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction;
import org.eclipse.ui.actions.NewExampleAction;
import org.eclipse.ui.actions.NewProjectAction;
import org.eclipse.ui.internal.navigator.resources.plugin.WorkbenchNavigatorMessages;
import org.eclipse.ui.navigator.CommonActionProvider;
import org.eclipse.ui.navigator.ICommonActionExtensionSite;
import org.eclipse.ui.navigator.ICommonViewerWorkbenchSite;
import org.eclipse.ui.navigator.WizardActionGroup;
import org.eclipse.ui.wizards.IWizardCategory;
import org.eclipse.ui.wizards.IWizardRegistry;

public class NewActionProvider
  extends CommonActionProvider
{
  private static final String FULL_EXAMPLES_WIZARD_CATEGORY = "org.eclipse.ui.Examples";
  private static final String NEW_MENU_NAME = "common.new.menu";
  private ActionFactory.IWorkbenchAction showDlgAction;
  private IAction newProjectAction;
  private IAction newExampleAction;
  private WizardActionGroup newWizardActionGroup;
  private boolean contribute = false;
  
  public void init(ICommonActionExtensionSite anExtensionSite)
  {
    if ((anExtensionSite.getViewSite() instanceof ICommonViewerWorkbenchSite))
    {
      IWorkbenchWindow window = ((ICommonViewerWorkbenchSite)anExtensionSite.getViewSite()).getWorkbenchWindow();
      showDlgAction = ActionFactory.NEW.create(window);
      newProjectAction = new NewProjectAction(window);
      newExampleAction = new NewExampleAction(window);
      
      newWizardActionGroup = new WizardActionGroup(window, PlatformUI.getWorkbench().getNewWizardRegistry(), "new", anExtensionSite.getContentService());
      
      contribute = true;
    }
  }
  
  public void fillContextMenu(IMenuManager menu)
  {
    IMenuManager submenu = new MenuManager(
      WorkbenchNavigatorMessages.NewActionProvider_NewMenu_label, 
      "common.new.menu");
    if (!contribute) {
      return;
    }
    submenu.add(newProjectAction);
    submenu.add(new Separator());
    
    newWizardActionGroup.setContext(getContext());
    newWizardActionGroup.fillContextMenu(submenu);
    
    submenu.add(new Separator("additions"));
    if (hasExamples())
    {
      submenu.add(new Separator());
      submenu.add(newExampleAction);
    }
    submenu.add(new Separator());
    submenu.add(showDlgAction);
    
    menu.insertAfter("group.new", submenu);
  }
  
  private boolean hasExamples()
  {
    IWizardRegistry newRegistry = PlatformUI.getWorkbench().getNewWizardRegistry();
    IWizardCategory category = newRegistry.findCategory("org.eclipse.ui.Examples");
    return category != null;
  }
  
  public void dispose()
  {
    if (showDlgAction != null)
    {
      showDlgAction.dispose();
      showDlgAction = null;
    }
    super.dispose();
  }
}

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

import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.mapping.ResourceMapping;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.jface.action.GroupMarker;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.actions.ActionContext;
import org.eclipse.ui.actions.OpenFileAction;
import org.eclipse.ui.actions.OpenWithMenu;
import org.eclipse.ui.internal.navigator.AdaptabilityUtility;
import org.eclipse.ui.internal.navigator.resources.plugin.WorkbenchNavigatorMessages;
import org.eclipse.ui.navigator.CommonActionProvider;
import org.eclipse.ui.navigator.ICommonActionExtensionSite;
import org.eclipse.ui.navigator.ICommonViewerWorkbenchSite;

public class OpenActionProvider
  extends CommonActionProvider
{
  private OpenFileAction openFileAction;
  private ICommonViewerWorkbenchSite viewSite = null;
  private boolean contribute = false;
  
  public void init(ICommonActionExtensionSite aConfig)
  {
    if ((aConfig.getViewSite() instanceof ICommonViewerWorkbenchSite))
    {
      viewSite = ((ICommonViewerWorkbenchSite)aConfig.getViewSite());
      openFileAction = new OpenFileAction(viewSite.getPage());
      contribute = true;
    }
  }
  
  public void fillContextMenu(IMenuManager aMenu)
  {
    if ((!contribute) || (getContext().getSelection().isEmpty())) {
      return;
    }
    IStructuredSelection selection = (IStructuredSelection)getContext()
      .getSelection();
    
    openFileAction.selectionChanged(selection);
    if (openFileAction.isEnabled()) {
      aMenu.insertAfter("group.open", openFileAction);
    }
    addOpenWithMenu(aMenu);
  }
  
  public void fillActionBars(IActionBars theActionBars)
  {
    if (!contribute) {
      return;
    }
    IStructuredSelection selection = (IStructuredSelection)getContext()
      .getSelection();
    if ((selection.size() == 1) && 
      ((selection.getFirstElement() instanceof IFile)))
    {
      openFileAction.selectionChanged(selection);
      theActionBars.setGlobalActionHandler("org.eclipse.ui.navigator.Open", 
        openFileAction);
    }
  }
  
  private void addOpenWithMenu(IMenuManager aMenu)
  {
    IStructuredSelection ss = (IStructuredSelection)getContext()
      .getSelection();
    if ((ss == null) || (ss.size() != 1)) {
      return;
    }
    Object o = ss.getFirstElement();
    
    IAdaptable openable = (IAdaptable)AdaptabilityUtility.getAdapter(o, 
      IResource.class);
    if (openable == null) {
      openable = (IAdaptable)AdaptabilityUtility.getAdapter(o, 
        ResourceMapping.class);
    } else if (((IResource)openable).getType() != 1) {
      openable = null;
    }
    if (openable != null)
    {
      IMenuManager submenu = new MenuManager(
        WorkbenchNavigatorMessages.OpenActionProvider_OpenWithMenu_label, 
        "group.openWith");
      submenu.add(new GroupMarker("group.top"));
      submenu.add(new OpenWithMenu(viewSite.getPage(), openable));
      submenu.add(new GroupMarker("additions"));
      if ((submenu.getItems().length > 2) && (submenu.isEnabled())) {
        aMenu.appendToGroup("group.openWith", 
          submenu);
      }
    }
  }
}

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

import org.eclipse.core.resources.IResource;
import org.eclipse.swt.dnd.Clipboard;
import org.eclipse.ui.part.ResourceTransfer;

class PasteAction$1
  implements Runnable
{
  final PasteAction this$0;
  private final IResource[][] val$clipboardData;
  
  PasteAction$1(PasteAction paramPasteAction, IResource[][] paramArrayOfIResource)
  {
    this$0 = paramPasteAction;val$clipboardData = paramArrayOfIResource;
  }
  
  public void run()
  {
    ResourceTransfer resTransfer = ResourceTransfer.getInstance();
    val$clipboardData[0] = 
      ((IResource[])PasteAction.access$0(this$0).getContents(resTransfer));
  }
}

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

import java.util.List;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.Assert;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.dnd.Clipboard;
import org.eclipse.swt.dnd.FileTransfer;
import org.eclipse.swt.dnd.TransferData;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.actions.CopyFilesAndFoldersOperation;
import org.eclipse.ui.actions.CopyProjectOperation;
import org.eclipse.ui.actions.SelectionListenerAction;
import org.eclipse.ui.help.IWorkbenchHelpSystem;
import org.eclipse.ui.internal.navigator.resources.plugin.WorkbenchNavigatorMessages;
import org.eclipse.ui.part.ResourceTransfer;

class PasteAction
  extends SelectionListenerAction
{
  public static final String ID = "org.eclipse.ui.PasteAction";
  private Shell shell;
  private Clipboard clipboard;
  
  public PasteAction(Shell shell, Clipboard clipboard)
  {
    super(WorkbenchNavigatorMessages.PasteAction_Past_);
    Assert.isNotNull(shell);
    Assert.isNotNull(clipboard);
    this.shell = shell;
    this.clipboard = clipboard;
    setToolTipText(WorkbenchNavigatorMessages.PasteAction_Paste_selected_resource_s_);
    setId("org.eclipse.ui.PasteAction");
    PlatformUI.getWorkbench().getHelpSystem().setHelp(this, "HelpId");
  }
  
  private IResource getTarget()
  {
    List selectedResources = getSelectedResources();
    for (int i = 0; i < selectedResources.size(); i++)
    {
      IResource resource = (IResource)selectedResources.get(i);
      if (((resource instanceof IProject)) && (!((IProject)resource).isOpen())) {
        return null;
      }
      if (resource.getType() == 1) {
        resource = resource.getParent();
      }
      if (resource != null) {
        return resource;
      }
    }
    return null;
  }
  
  private boolean isLinked(IResource[] resources)
  {
    for (int i = 0; i < resources.length; i++) {
      if (resources[i].isLinked()) {
        return true;
      }
    }
    return false;
  }
  
  public void run()
  {
    ResourceTransfer resTransfer = ResourceTransfer.getInstance();
    IResource[] resourceData = (IResource[])clipboard
      .getContents(resTransfer);
    if ((resourceData != null) && (resourceData.length > 0))
    {
      if (resourceData[0].getType() == 4)
      {
        for (int i = 0; i < resourceData.length; i++)
        {
          CopyProjectOperation operation = new CopyProjectOperation(
            shell);
          operation.copyProject((IProject)resourceData[i]);
        }
      }
      else
      {
        IContainer container = getContainer();
        
        CopyFilesAndFoldersOperation operation = new CopyFilesAndFoldersOperation(
          shell);
        operation.copyResources(resourceData, container);
      }
      return;
    }
    FileTransfer fileTransfer = FileTransfer.getInstance();
    String[] fileData = (String[])clipboard.getContents(fileTransfer);
    if (fileData != null)
    {
      IContainer container = getContainer();
      
      CopyFilesAndFoldersOperation operation = new CopyFilesAndFoldersOperation(
        shell);
      operation.copyFiles(fileData, container);
    }
  }
  
  private IContainer getContainer()
  {
    List selection = getSelectedResources();
    if ((selection.get(0) instanceof IFile)) {
      return ((IFile)selection.get(0)).getParent();
    }
    return (IContainer)selection.get(0);
  }
  
  protected boolean updateSelection(IStructuredSelection selection)
  {
    if (!super.updateSelection(selection)) {
      return false;
    }
    IResource[][] clipboardData = new IResource[1][];
    shell.getDisplay().syncExec(new Runnable()
    {
      private final IResource[][] val$clipboardData;
      
      public void run()
      {
        ResourceTransfer resTransfer = ResourceTransfer.getInstance();
        val$clipboardData[0] = 
          ((IResource[])clipboard.getContents(resTransfer));
      }
    });
    IResource[] resourceData = clipboardData[0];
    boolean isProjectRes = (resourceData != null) && (resourceData.length > 0) && 
      (resourceData[0].getType() == 4);
    if (isProjectRes)
    {
      for (int i = 0; i < resourceData.length; i++) {
        if ((resourceData[i].getType() != 4) || 
          (!((IProject)resourceData[i]).isOpen())) {
          return false;
        }
      }
      return true;
    }
    if (getSelectedNonResources().size() > 0) {
      return false;
    }
    IResource targetResource = getTarget();
    if (targetResource == null) {
      return false;
    }
    List selectedResources = getSelectedResources();
    if (selectedResources.size() > 1) {
      for (int i = 0; i < selectedResources.size(); i++)
      {
        IResource resource = (IResource)selectedResources.get(i);
        if (resource.getType() != 1) {
          return false;
        }
        if (!targetResource.equals(resource.getParent())) {
          return false;
        }
      }
    }
    if (resourceData != null)
    {
      if ((isLinked(resourceData)) && 
        (targetResource.getType() != 4) && 
        (targetResource.getType() != 2)) {
        return false;
      }
      if (targetResource.getType() == 2) {
        for (int i = 0; i < resourceData.length; i++) {
          if (targetResource.equals(resourceData[i])) {
            return false;
          }
        }
      }
      return true;
    }
    TransferData[] transfers = clipboard.getAvailableTypes();
    FileTransfer fileTransfer = FileTransfer.getInstance();
    for (int i = 0; i < transfers.length; i++) {
      if (fileTransfer.isSupportedType(transfers[i])) {
        return true;
      }
    }
    return false;
  }
}

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

import java.net.URL;
import java.util.Collections;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.Path;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.actions.ActionContext;
import org.eclipse.ui.actions.ExportResourcesAction;
import org.eclipse.ui.actions.ImportResourcesAction;
import org.eclipse.ui.internal.navigator.resources.plugin.WorkbenchNavigatorMessages;
import org.eclipse.ui.internal.navigator.resources.plugin.WorkbenchNavigatorPlugin;
import org.eclipse.ui.navigator.CommonActionProvider;
import org.eclipse.ui.navigator.ICommonActionExtensionSite;
import org.eclipse.ui.navigator.ICommonViewerWorkbenchSite;
import org.eclipse.ui.navigator.WizardActionGroup;

public class PortingActionProvider
  extends CommonActionProvider
{
  private static final String COMMON_NAVIGATOR_IMPORT_MENU = "common.import.menu";
  private static final String COMMON_NAVIGATOR_EXPORT_MENU = "common.export.menu";
  private ImportResourcesAction importAction;
  private ExportResourcesAction exportAction;
  private WizardActionGroup importWizardActionGroup;
  private WizardActionGroup exportWizardActionGroup;
  private boolean disposed = false;
  private boolean contribute = false;
  
  public void init(ICommonActionExtensionSite anExtensionSite)
  {
    Assert.isTrue(!disposed);
    if ((anExtensionSite.getViewSite() instanceof ICommonViewerWorkbenchSite))
    {
      IWorkbenchWindow window = ((ICommonViewerWorkbenchSite)anExtensionSite
        .getViewSite()).getWorkbenchWindow();
      importAction = new ImportResourcesAction(window);
      exportAction = new ExportResourcesAction(window);
      importWizardActionGroup = new WizardActionGroup(window, 
        PlatformUI.getWorkbench().getImportWizardRegistry(), 
        "import", anExtensionSite.getContentService());
      exportWizardActionGroup = new WizardActionGroup(window, 
        PlatformUI.getWorkbench().getExportWizardRegistry(), 
        "export", anExtensionSite.getContentService());
      contribute = true;
    }
  }
  
  public void dispose()
  {
    if (!contribute) {
      return;
    }
    importWizardActionGroup.dispose();
    exportWizardActionGroup.dispose();
    importAction = null;
    exportAction = null;
    disposed = true;
  }
  
  public void fillContextMenu(IMenuManager aMenu)
  {
    if (!contribute) {
      return;
    }
    Assert.isTrue(!disposed);
    
    ISelection selection = getContext().getSelection();
    if ((!(selection instanceof IStructuredSelection)) || (((IStructuredSelection)selection).size() > 1))
    {
      addSimplePortingMenus(aMenu);
    }
    else
    {
      addImportMenu(aMenu);
      addExportMenu(aMenu);
    }
  }
  
  protected ImageDescriptor getImageDescriptor(String relativePath)
  {
    String iconPath = "icons/full/";
    URL url = FileLocator.find(WorkbenchNavigatorPlugin.getDefault().getBundle(), new Path(iconPath + relativePath), Collections.EMPTY_MAP);
    if (url == null) {
      return ImageDescriptor.getMissingImageDescriptor();
    }
    return ImageDescriptor.createFromURL(url);
  }
  
  private void addSimplePortingMenus(IMenuManager aMenu)
  {
    aMenu.appendToGroup("group.port", importAction);
    aMenu.appendToGroup("group.port", exportAction);
  }
  
  private void addImportMenu(IMenuManager aMenu)
  {
    importWizardActionGroup.setContext(getContext());
    if (importWizardActionGroup.getWizardActionIds().length == 0)
    {
      aMenu.appendToGroup("group.port", importAction);
      return;
    }
    IMenuManager submenu = new MenuManager(
      WorkbenchNavigatorMessages.PortingActionProvider_ImportResourcesMenu_label, 
      "common.import.menu");
    importWizardActionGroup.fillContextMenu(submenu);
    
    submenu.add(new Separator("additions"));
    submenu.add(new Separator());
    submenu.add(importAction);
    aMenu.appendToGroup("group.port", submenu);
  }
  
  private void addExportMenu(IMenuManager aMenu)
  {
    exportWizardActionGroup.setContext(getContext());
    if (exportWizardActionGroup.getWizardActionIds().length == 0)
    {
      aMenu.appendToGroup("group.port", exportAction);
      return;
    }
    IMenuManager submenu = new MenuManager(
      WorkbenchNavigatorMessages.PortingActionProvider_ExportResourcesMenu_label, 
      "common.export.menu");
    exportWizardActionGroup.fillContextMenu(submenu);
    
    submenu.add(new Separator("additions"));
    submenu.add(new Separator());
    submenu.add(exportAction);
    aMenu.appendToGroup("group.port", submenu);
  }
}

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

import org.eclipse.jface.window.IShellProvider;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.navigator.ICommonActionExtensionSite;
import org.eclipse.ui.navigator.ICommonViewerSite;

class PropertiesActionProvider$1
  implements IShellProvider
{
  final PropertiesActionProvider this$0;
  private final ICommonActionExtensionSite val$aSite;
  
  PropertiesActionProvider$1(PropertiesActionProvider paramPropertiesActionProvider, ICommonActionExtensionSite paramICommonActionExtensionSite)
  {
    this$0 = paramPropertiesActionProvider;val$aSite = paramICommonActionExtensionSite;
  }
  
  public Shell getShell()
  {
    return val$aSite.getViewSite().getShell();
  }
}

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

import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IAdapterManager;
import org.eclipse.core.runtime.Platform;

class PropertiesActionProvider$DelegateIAdaptable
  implements IAdaptable
{
  private Object delegate;
  final PropertiesActionProvider this$0;
  
  PropertiesActionProvider$DelegateIAdaptable(PropertiesActionProvider paramPropertiesActionProvider, Object paramObject, DelegateIAdaptable paramDelegateIAdaptable)
  {
    this(paramPropertiesActionProvider, paramObject);
  }
  
  private PropertiesActionProvider$DelegateIAdaptable(PropertiesActionProvider paramPropertiesActionProvider, Object o)
  {
    this$0 = paramPropertiesActionProvider;
    delegate = o;
  }
  
  public Object getAdapter(Class adapter)
  {
    if ((adapter.isInstance(delegate)) || (delegate == null)) {
      return delegate;
    }
    return Platform.getAdapterManager().getAdapter(delegate, adapter);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.ui.internal.navigator.resources.actions.PropertiesActionProvider.DelegateIAdaptable
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.ui.internal.navigator.resources.actions;

import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;

class PropertiesActionProvider$DelegateSelectionProvider
  implements ISelectionProvider
{
  private ISelectionProvider delegate;
  final PropertiesActionProvider this$0;
  
  PropertiesActionProvider$DelegateSelectionProvider(PropertiesActionProvider paramPropertiesActionProvider, ISelectionProvider paramISelectionProvider, DelegateSelectionProvider paramDelegateSelectionProvider)
  {
    this(paramPropertiesActionProvider, paramIS
1 2 3 4 5 6

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