org.eclipse.team.ui_3.6.101.R37x_v20111109-0800

InfoFilter;
import org.eclipse.team.internal.ui.TeamUIMessages;
import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;
import org.eclipse.team.ui.synchronize.SynchronizeModelAction;
import org.eclipse.team.ui.synchronize.SynchronizeModelOperation;

class ChangeSetActionGroup$CreateChangeSetAction
  extends SynchronizeModelAction
{
  final ChangeSetActionGroup this$0;
  
  public ChangeSetActionGroup$CreateChangeSetAction(ChangeSetActionGroup paramChangeSetActionGroup, ISynchronizePageConfiguration configuration)
  {
    super(TeamUIMessages.ChangeLogModelProvider_0, configuration);
    this$0 = paramChangeSetActionGroup;
  }
  
  protected boolean needsToSaveDirtyEditors()
  {
    return false;
  }
  
  protected FastSyncInfoFilter getSyncInfoFilter()
  {
    return ChangeSetActionGroup.OUTGOING_RESOURCE_FILTER;
  }
  
  protected SynchronizeModelOperation getSubscriberOperation(ISynchronizePageConfiguration configuration, IDiffElement[] elements)
  {
    return new ChangeSetActionGroup.1(this, configuration, elements);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.team.internal.ui.synchronize.actions.ChangeSetActionGroup.CreateChangeSetAction
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.team.internal.ui.synchronize.actions;

import org.eclipse.team.internal.core.subscribers.ActiveChangeSet;
import org.eclipse.team.internal.ui.TeamUIMessages;
import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;

class ChangeSetActionGroup$EditChangeSetAction
  extends ChangeSetActionGroup.ChangeSetAction
{
  final ChangeSetActionGroup this$0;
  
  public ChangeSetActionGroup$EditChangeSetAction(ChangeSetActionGroup paramChangeSetActionGroup, ISynchronizePageConfiguration configuration)
  {
    super(paramChangeSetActionGroup, TeamUIMessages.ChangeLogModelProvider_6, configuration);
    this$0 = paramChangeSetActionGroup;
  }
  
  public void run()
  {
    ActiveChangeSet set = getSelectedSet();
    if (set == null) {
      return;
    }
    ChangeSetActionGroup.access$3(this$0, set);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.team.internal.ui.synchronize.actions.ChangeSetActionGroup.EditChangeSetAction
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.team.internal.ui.synchronize.actions;

import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.team.internal.core.subscribers.ActiveChangeSetManager;
import org.eclipse.team.internal.ui.TeamUIMessages;
import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;

class ChangeSetActionGroup$MakeDefaultChangeSetAction
  extends ChangeSetActionGroup.ChangeSetAction
{
  final ChangeSetActionGroup this$0;
  
  public ChangeSetActionGroup$MakeDefaultChangeSetAction(ChangeSetActionGroup paramChangeSetActionGroup, ISynchronizePageConfiguration configuration)
  {
    super(paramChangeSetActionGroup, TeamUIMessages.ChangeLogModelProvider_9, configuration);
    this$0 = paramChangeSetActionGroup;
  }
  
  protected boolean updateSelection(IStructuredSelection selection)
  {
    if (getSelectedSet() != null)
    {
      setText(TeamUIMessages.ChangeLogModelProvider_9);
      setChecked(getSelectedSet().equals(
        this$0.getActiveChangeSetManager().getDefaultSet()));
    }
    else
    {
      setText(TeamUIMessages.ChangeLogModelProvider_10);
      setChecked(false);
    }
    return true;
  }
  
  public void run()
  {
    this$0.getActiveChangeSetManager().makeDefault(
      isChecked() ? getSelectedSet() : null);
    if (getSelectedSet() == null) {
      setChecked(false);
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.team.internal.ui.synchronize.actions.ChangeSetActionGroup.MakeDefaultChangeSetAction
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.team.internal.ui.synchronize.actions;

import org.eclipse.jface.action.LegacyActionTools;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.osgi.util.NLS;
import org.eclipse.team.internal.core.subscribers.ActiveChangeSet;
import org.eclipse.team.internal.core.subscribers.ActiveChangeSetManager;
import org.eclipse.team.internal.ui.TeamUIMessages;
import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;
import org.eclipse.team.ui.synchronize.ISynchronizePageSite;

class ChangeSetActionGroup$RemoveChangeSetAction
  extends ChangeSetActionGroup.ChangeSetAction
{
  final ChangeSetActionGroup this$0;
  
  public ChangeSetActionGroup$RemoveChangeSetAction(ChangeSetActionGroup paramChangeSetActionGroup, ISynchronizePageConfiguration configuration)
  {
    super(paramChangeSetActionGroup, TeamUIMessages.ChangeLogModelProvider_7, configuration);
    this$0 = paramChangeSetActionGroup;
  }
  
  public void run()
  {
    ActiveChangeSet set = getSelectedSet();
    if (set == null) {
      return;
    }
    if (MessageDialog.openConfirm(this$0.getConfiguration().getSite().getShell(), TeamUIMessages.ChangeSetActionGroup_0, NLS.bind(TeamUIMessages.ChangeSetActionGroup_1, new String[] { LegacyActionTools.escapeMnemonics(set.getTitle()) }))) {
      this$0.getActiveChangeSetManager().remove(set);
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.team.internal.ui.synchronize.actions.ChangeSetActionGroup.RemoveChangeSetAction
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.team.internal.ui.synchronize.actions;

import org.eclipse.jface.action.Action;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.team.internal.ui.synchronize.ChangeSetModelProvider;
import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;
import org.eclipse.team.ui.synchronize.ISynchronizePageSite;

class ChangeSetActionGroup$ToggleSortOrderAction
  extends Action
{
  private int criteria;
  final ChangeSetActionGroup this$0;
  
  protected ChangeSetActionGroup$ToggleSortOrderAction(ChangeSetActionGroup paramChangeSetActionGroup, String name, int criteria)
  {
    super(name, 8);this$0 = paramChangeSetActionGroup;
    this.criteria = criteria;
    update();
  }
  
  public void run()
  {
    if ((isChecked()) && (ChangeSetActionGroup.access$4(this$0) != criteria))
    {
      ChangeSetActionGroup.access$5(this$0, criteria);
      String key = getSettingsKey();
      IDialogSettings pageSettings = this$0.getConfiguration().getSite().getPageSettings();
      if (pageSettings != null) {
        pageSettings.put(key, criteria);
      }
      update();
      ChangeSetActionGroup.access$6(this$0).setViewerSorter(this$0.getViewerSorter());
    }
  }
  
  public void update()
  {
    setChecked(criteria == ChangeSetActionGroup.access$4(this$0));
  }
  
  protected String getSettingsKey()
  {
    return "org.eclipse.team.ui.P_LAST_COMMENT_SORT";
  }
}

/* Location:
 * Qualified Name:     org.eclipse.team.internal.ui.synchronize.actions.ChangeSetActionGroup.ToggleSortOrderAction
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.team.internal.ui.synchronize.actions;

import java.text.Collator;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import org.eclipse.compare.structuremergeviewer.IDiffElement;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.LegacyActionTools;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerSorter;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.team.core.diff.IDiff;
import org.eclipse.team.core.subscribers.Subscriber;
import org.eclipse.team.core.synchronize.FastSyncInfoFilter;
import org.eclipse.team.core.synchronize.FastSyncInfoFilter.SyncInfoDirectionFilter;
import org.eclipse.team.internal.core.subscribers.ActiveChangeSet;
import org.eclipse.team.internal.core.subscribers.ActiveChangeSetManager;
import org.eclipse.team.internal.core.subscribers.ChangeSet;
import org.eclipse.team.internal.ui.TeamUIMessages;
import org.eclipse.team.internal.ui.TeamUIPlugin;
import org.eclipse.team.internal.ui.synchronize.ChangeSetCapability;
import org.eclipse.team.internal.ui.synchronize.ChangeSetModelProvider;
import org.eclipse.team.internal.ui.synchronize.ChangeSetModelSorter;
import org.eclipse.team.ui.synchronize.ISynchronizePage;
import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;
import org.eclipse.team.ui.synchronize.ISynchronizePageSite;
import org.eclipse.team.ui.synchronize.SubscriberParticipant;
import org.eclipse.team.ui.synchronize.SynchronizeModelAction;
import org.eclipse.team.ui.synchronize.SynchronizeModelOperation;
import org.eclipse.team.ui.synchronize.SynchronizePageActionGroup;
import org.eclipse.ui.actions.ActionContext;
import org.eclipse.ui.actions.BaseSelectionListenerAction;

public class ChangeSetActionGroup
  extends SynchronizePageActionGroup
{
  public static final String CHANGE_SET_GROUP = "change_set_group";
  private static final String P_LAST_COMMENTSORT = "org.eclipse.team.ui.P_LAST_COMMENT_SORT";
  public static final FastSyncInfoFilter OUTGOING_RESOURCE_FILTER = new FastSyncInfoFilter.SyncInfoDirectionFilter(
    new int[] { 4, 12 });
  private ChangeSetModelProvider provider;
  private MenuManager sortByComment;
  private CreateChangeSetAction createChangeSet;
  private MenuManager addToChangeSet;
  private EditChangeSetAction editChangeSet;
  private RemoveChangeSetAction removeChangeSet;
  private MakeDefaultChangeSetAction makeDefault;
  private SynchronizePageActionGroup subActions;
  
  private class CreateChangeSetAction
    extends SynchronizeModelAction
  {
    public CreateChangeSetAction(ISynchronizePageConfiguration configuration)
    {
      super(configuration);
    }
    
    protected boolean needsToSaveDirtyEditors()
    {
      return false;
    }
    
    protected FastSyncInfoFilter getSyncInfoFilter()
    {
      return ChangeSetActionGroup.OUTGOING_RESOURCE_FILTER;
    }
    
    protected SynchronizeModelOperation getSubscriberOperation(ISynchronizePageConfiguration configuration, IDiffElement[] elements)
    {
      return new ChangeSetActionGroup.1(this, configuration, elements);
    }
  }
  
  private abstract class ChangeSetAction
    extends BaseSelectionListenerAction
  {
    public ChangeSetAction(String title, ISynchronizePageConfiguration configuration)
    {
      super();
    }
    
    protected boolean updateSelection(IStructuredSelection selection)
    {
      return getSelectedSet() != null;
    }
    
    protected ActiveChangeSet getSelectedSet()
    {
      IStructuredSelection selection = getStructuredSelection();
      if (selection.size() == 1)
      {
        Object first = selection.getFirstElement();
        if ((first instanceof IAdaptable))
        {
          Class tmp36_33 = ChangeSetActionGroup.class$0;
          if (tmp36_33 == null)
          {
            tmp36_33;
            try
            {
              tmpTernaryOp = (ChangeSetActionGroup.class$0 = Class.forName("org.eclipse.team.internal.core.subscribers.ChangeSet"));
            }
            catch (ClassNotFoundException localClassNotFoundException)
            {
              throw new NoClassDefFoundError(localClassNotFoundException.getMessage());
            }
          }
          Object adapter = ((IAdaptable)first).getAdapter(tmp36_33);
          if ((adapter instanceof ActiveChangeSet)) {
            return (ActiveChangeSet)adapter;
          }
        }
      }
      return null;
    }
  }
  
  private class EditChangeSetAction
    extends ChangeSetActionGroup.ChangeSetAction
  {
    public EditChangeSetAction(ISynchronizePageConfiguration configuration)
    {
      super(TeamUIMessages.ChangeLogModelProvider_6, configuration);
    }
    
    public void run()
    {
      ActiveChangeSet set = getSelectedSet();
      if (set == null) {
        return;
      }
      ChangeSetActionGroup.this.editChangeSet(set);
    }
  }
  
  private class RemoveChangeSetAction
    extends ChangeSetActionGroup.ChangeSetAction
  {
    public RemoveChangeSetAction(ISynchronizePageConfiguration configuration)
    {
      super(TeamUIMessages.ChangeLogModelProvider_7, configuration);
    }
    
    public void run()
    {
      ActiveChangeSet set = getSelectedSet();
      if (set == null) {
        return;
      }
      if (MessageDialog.openConfirm(getConfiguration().getSite().getShell(), TeamUIMessages.ChangeSetActionGroup_0, NLS.bind(TeamUIMessages.ChangeSetActionGroup_1, new String[] { LegacyActionTools.escapeMnemonics(set.getTitle()) }))) {
        getActiveChangeSetManager().remove(set);
      }
    }
  }
  
  private class MakeDefaultChangeSetAction
    extends ChangeSetActionGroup.ChangeSetAction
  {
    public MakeDefaultChangeSetAction(ISynchronizePageConfiguration configuration)
    {
      super(TeamUIMessages.ChangeLogModelProvider_9, configuration);
    }
    
    protected boolean updateSelection(IStructuredSelection selection)
    {
      if (getSelectedSet() != null)
      {
        setText(TeamUIMessages.ChangeLogModelProvider_9);
        setChecked(getSelectedSet().equals(
          getActiveChangeSetManager().getDefaultSet()));
      }
      else
      {
        setText(TeamUIMessages.ChangeLogModelProvider_10);
        setChecked(false);
      }
      return true;
    }
    
    public void run()
    {
      getActiveChangeSetManager().makeDefault(
        isChecked() ? getSelectedSet() : null);
      if (getSelectedSet() == null) {
        setChecked(false);
      }
    }
  }
  
  private class AddToChangeSetAction
    extends SynchronizeModelAction
  {
    private final ActiveChangeSet set;
    
    public AddToChangeSetAction(ISynchronizePageConfiguration configuration, ActiveChangeSet set, ISelection selection)
    {
      super(configuration);
      this.set = set;
      selectionChanged(selection);
    }
    
    protected FastSyncInfoFilter getSyncInfoFilter()
    {
      return ChangeSetActionGroup.OUTGOING_RESOURCE_FILTER;
    }
    
    protected boolean needsToSaveDirtyEditors()
    {
      return false;
    }
    
    protected SynchronizeModelOperation getSubscriberOperation(ISynchronizePageConfiguration configuration, IDiffElement[] elements)
    {
      return new ChangeSetActionGroup.3(this, configuration, elements);
    }
  }
  
  private class ToggleSortOrderAction
    extends Action
  {
    private int criteria;
    
    protected ToggleSortOrderAction(String name, int criteria)
    {
      super(8);
      this.criteria = criteria;
      update();
    }
    
    public void run()
    {
      if ((isChecked()) && (sortCriteria != criteria))
      {
        sortCriteria = criteria;
        String key = getSettingsKey();
        IDialogSettings pageSettings = getConfiguration().getSite().getPageSettings();
        if (pageSettings != null) {
          pageSettings.put(key, criteria);
        }
        update();
        provider.setViewerSorter(getViewerSorter());
      }
    }
    
    public void update()
    {
      setChecked(criteria == sortCriteria);
    }
    
    protected String getSettingsKey()
    {
      return "org.eclipse.team.ui.P_LAST_COMMENT_SORT";
    }
  }
  
  private int sortCriteria = 1;
  static Class class$0;
  
  public static int getSortCriteria(ISynchronizePageConfiguration configuration)
  {
    int sortCriteria = 1;
    try
    {
      IDialogSettings pageSettings = configuration.getSite().getPageSettings();
      if (pageSettings != null) {
        sortCriteria = pageSettings.getInt("org.eclipse.team.ui.P_LAST_COMMENT_SORT");
      }
    }
    catch (NumberFormatException localNumberFormatException) {}
    switch (sortCriteria)
    {
    case 1: 
    case 2: 
    case 3: 
      break;
    default: 
      sortCriteria = 1;
    }
    return sortCriteria;
  }
  
  public ChangeSetActionGroup(ChangeSetModelProvider provider)
  {
    this.provider = provider;
  }
  
  public void initialize(ISynchronizePageConfiguration configuration)
  {
    super.initialize(configuration);
    if (getChangeSetCapability().supportsCheckedInChangeSets())
    {
      sortCriteria = getSortCriteria(configuration);
      sortByComment = new MenuManager(TeamUIMessages.ChangeLogModelProvider_0a);
      sortByComment.add(new ToggleSortOrderAction(TeamUIMessages.ChangeLogModelProvider_1a, 2));
      sortByComment.add(new ToggleSortOrderAction(TeamUIMessages.ChangeLogModelProvider_2a, 1));
      sortByComment.add(new ToggleSortOrderAction(TeamUIMessages.ChangeLogModelProvider_3a, 3));
    }
    if (getChangeSetCapability().supportsActiveChangeSets())
    {
      addToChangeSet = new MenuManager(TeamUIMessages.ChangeLogModelProvider_12);
      addToChangeSet.setRemoveAllWhenShown(true);
      addToChangeSet.addMenuListener(new IMenuListener()
      {
        public void menuAboutToShow(IMenuManager manager)
        {
          addChangeSets(manager);
        }
      });
      createChangeSet = new CreateChangeSetAction(configuration);
      addToChangeSet.add(createChangeSet);
      addToChangeSet.add(new Separator());
      editChangeSet = new EditChangeSetAction(configuration);
      makeDefault = new MakeDefaultChangeSetAction(configuration);
      removeChangeSet = new RemoveChangeSetAction(configuration);
    }
    subActions = getChangeSetCapability().getActionGroup();
    if (subActions != null) {
      subActions.initialize(configuration);
    }
  }
  
  public void fillContextMenu(IMenuManager menu)
  {
    if (getChangeSetCapability().enableCheckedInChangeSetsFor(getConfiguration())) {
      appendToGroup(menu, "sort", sortByComment);
    }
    if (getChangeSetCapability().enableActiveChangeSetsFor(getConfiguration()))
    {
      appendToGroup(
        menu, 
        "change_set_group", 
        addToChangeSet);
      appendToGroup(
        menu, 
        "change_set_group", 
        editChangeSet);
      appendToGroup(
        menu, 
        "change_set_group", 
        removeChangeSet);
      appendToGroup(
        menu, 
        "change_set_group", 
        makeDefault);
    }
    if (subActions != null) {
      subActions.fillContextMenu(menu);
    }
  }
  
  protected void addChangeSets(IMenuManager manager)
  {
    ChangeSet[] sets = getActiveChangeSetManager().getSets();
    Arrays.sort(sets, new Comparator()
    {
      private Collator collator = Collator.getInstance();
      
      public int compare(Object o1, Object o2)
      {
        return collator.compare(((ChangeSet)o1).getName(), ((ChangeSet)o2).getName());
      }
    });
    ISelection selection = getContext().getSelection();
    createChangeSet.selectionChanged(selection);
    addToChangeSet.add(createChangeSet);
    addToChangeSet.add(new Separator());
    for (int i = 0; i < sets.length; i++)
    {
      ActiveChangeSet set = (ActiveChangeSet)sets[i];
      AddToChangeSetAction action = new AddToChangeSetAction(getConfiguration(), set, selection);
      manager.add(action);
    }
    addToChangeSet.add(new Separator());
    
    addToChangeSet.add(new AddToChangeSetAction(getConfiguration(), null, selection));
  }
  
  protected ActiveChangeSetManager getActiveChangeSetManager()
  {
    return getChangeSetCapability().getActiveChangeSetManager();
  }
  
  public void dispose()
  {
    if (addToChangeSet != null)
    {
      addToChangeSet.dispose();
      addToChangeSet.removeAll();
    }
    if (sortByComment != null)
    {
      sortByComment.dispose();
      sortByComment.removeAll();
    }
    if (subActions != null) {
      subActions.dispose();
    }
    super.dispose();
  }
  
  public void updateActionBars()
  {
    if (editChangeSet != null) {
      editChangeSet.selectionChanged((IStructuredSelection)getContext().getSelection());
    }
    if (removeChangeSet != null) {
      removeChangeSet.selectionChanged((IStructuredSelection)getContext().getSelection());
    }
    if (makeDefault != null) {
      makeDefault.selectionChanged((IStructuredSelection)getContext().getSelection());
    }
    super.updateActionBars();
  }
  
  private void syncExec(Runnable runnable)
  {
    Control ctrl = getConfiguration().getPage().getViewer().getControl();
    if ((ctrl != null) && (!ctrl.isDisposed())) {
      ctrl.getDisplay().syncExec(new Runnable()
      {
        private final Control val$ctrl;
        private final Runnable val$runnable;
        
        public void run()
        {
          if (!val$ctrl.isDisposed()) {
            val$runnable.run();
          }
        }
      });
    }
  }
  
  public ViewerSorter getViewerSorter()
  {
    return new ChangeSetModelSorter(provider, sortCriteria);
  }
  
  private ActiveChangeSet createChangeSet(IDiff[] diffs)
  {
    return getChangeSetCapability().createChangeSet(getConfiguration(), diffs);
  }
  
  private void editChangeSet(ActiveChangeSet set)
  {
    getChangeSetCapability().editChangeSet(getConfiguration(), set);
  }
  
  private ChangeSetCapability getChangeSetCapability()
  {
    return provider.getChangeSetCapability();
  }
  
  private IDiff[] getDiffs(IResource[] resources)
  {
    List diffs = new ArrayList();
    Subscriber s = ((SubscriberParticipant)getConfiguration().getParticipant()).getSubscriber();
    for (int i = 0; i < resources.length; i++)
    {
      IResource resource = resources[i];
      try
      {
        IDiff diff = s.getDiff(resource);
        if (diff != null) {
          diffs.add(diff);
        }
      }
      catch (CoreException e)
      {
        TeamUIPlugin.log(e);
      }
    }
    IDiff[] diffArray = (IDiff[])diffs
      .toArray(new IDiff[diffs.size()]);
    return diffArray;
  }
}

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

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import org.eclipse.compare.ITypedElement;
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.ILabelProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.ITreePathLabelProvider;
import org.eclipse.jface.viewers.TreePath;
import org.eclipse.jface.viewers.TreeSelection;
import org.eclipse.jface.viewers.ViewerLabel;
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.team.internal.ui.TeamUIMessages;
import org.eclipse.team.internal.ui.Utils;
import org.eclipse.ui.actions.SelectionListenerAction;
import org.eclipse.ui.navigator.INavigatorContentService;
import org.eclipse.ui.part.ResourceTransfer;

class CopyToClipboardAction
  extends SelectionListenerAction
{
  private static final String EOL = System.getProperty("line.separator", "\n");
  private static final String ID = "org.eclipse.team.ui.synchronize.action.copy";
  private final Shell fShell;
  private final Clipboard fClipboard;
  private final INavigatorContentService navigatorContentService;
  
  protected CopyToClipboardAction(Shell shell, INavigatorContentService navigatorContentService)
  {
    super(TeamUIMessages.CopyToClipboardAction_1);
    this.navigatorContentService = navigatorContentService;
    Assert.isNotNull(shell);
    fShell = shell;
    fClipboard = new Clipboard(shell.getDisplay());
    setToolTipText(TeamUIMessages.CopyToClipboardAction_2);
    setId("org.eclipse.team.ui.synchronize.action.copy");
  }
  
  public void run()
  {
    copyResources(getSelectedResources(), getTextualClipboardContents());
  }
  
  private String getTextualClipboardContents()
  {
    StringBuffer buf = new StringBuffer();
    int i = 0;
    IStructuredSelection structuredSelection = getStructuredSelection();
    if ((structuredSelection instanceof TreeSelection))
    {
      TreeSelection ts = (TreeSelection)structuredSelection;
      TreePath[] paths = ts.getPaths();
      for (int j = 0; j < paths.length; j++)
      {
        TreePath path = paths[j];
        String text = getTextFor(path);
        if ((text != null) && (text.length() > 0))
        {
          if (i > 0) {
            buf.append(EOL);
          }
          buf.append(text);
          i++;
        }
      }
    }
    else
    {
      for (Iterator it = structuredSelection.iterator(); it.hasNext();)
      {
        Object element = it.next();
        if ((element instanceof ITypedElement))
        {
          if (i > 0) {
            buf.append(EOL);
          }
          buf.append(((ITypedElement)element).getName());
          i++;
        }
        else
        {
          IResource resource = Utils.getResource(element);
          if (resource != null)
          {
            if (i > 0) {
              buf.append(EOL);
            }
            buf.append(resource.getName());
            i++;
          }
        }
      }
    }
    return buf.toString();
  }
  
  private String getTextFor(TreePath path)
  {
    Object element = path.getLastSegment();
    if ((element instanceof ITypedElement)) {
      return ((ITypedElement)element).getName();
    }
    INavigatorContentService service = getNavigatorContentService();
    if (service != null)
    {
      ILabelProvider provider = service.createCommonLabelProvider();
      if ((provider instanceof ITreePathLabelProvider))
      {
        ITreePathLabelProvider tplp = (ITreePathLabelProvider)provider;
        ViewerLabel viewerLabel = new ViewerLabel("", null);
        tplp.updateLabel(viewerLabel, path);
        return viewerLabel.getText();
      }
      return provider.getText(element);
    }
    if ((element instanceof IResource))
    {
      IResource resource = (IResource)element;
      return resource.getName();
    }
    return null;
  }
  
  private INavigatorContentService getNavigatorContentService()
  {
    return navigatorContentService;
  }
  
  private void copyResources(List selectedResources, String text)
  {
    IResource[] resources = (IResource[])selectedResources.toArray(new IResource[selectedResources.size()]);
    
    int length = resources.length;
    int actualLength = 0;
    String[] fileNames = new String[length];
    for (int i = 0; i < length; i++)
    {
      IPath location = resources[i].getLocation();
      if (location != null) {
        fileNames[(actualLength++)] = location.toOSString();
      }
    }
    if (actualLength < length)
    {
      String[] tempFileNames = fileNames;
      fileNames = new String[actualLength];
      for (int i = 0; i < actualLength; i++) {
        fileNames[i] = tempFileNames[i];
      }
    }
    setClipboard(resources, fileNames, text);
  }
  
  private void setClipboard(IResource[] resources, String[] fileNames, String names)
  {
    try
    {
      List data = new ArrayList();
      List dataTypes = new ArrayList();
      if (resources.length > 0)
      {
        data.add(resources);
        dataTypes.add(ResourceTransfer.getInstance());
      }
      if (fileNames.length > 0)
      {
        data.add(fileNames);
        dataTypes.add(FileTransfer.getInstance());
      }
      if ((names != null) && (names.length() > 0))
      {
        data.add(names);
        dataTypes.add(TextTransfer.getInstance());
      }
      if (!data.isEmpty()) {
        fClipboard.setContents(
          data.toArray(), 
          (Transfer[])dataTypes.toArray(new Transfer[dataTypes.size()]));
      }
    }
    catch (SWTError e)
    {
      if (code != 2002) {
        throw e;
      }
      if (MessageDialog.openQuestion(fShell, TeamUIMessages.CopyToClipboardAction_3, TeamUIMessages.CopyToClipboardAction_4)) {
        setClipboard(resources, fileNames, names);
      }
    }
  }
  
  protected boolean updateSelection(IStructuredSelection selection)
  {
    if (!super.updateSelection(selection)) {
      return false;
    }
    List selectedResources = getSelectedResources();
    List selectedNonResources = getSelectedNonResources();
    if ((selectedResources.size() > 0) && (selectedNonResources.size() == 0))
    {
      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.getLocation() == null) {
          return false;
        }
      }
      return true;
    }
    if ((selectedNonResources.size() > 0) && (selectedResources.size() == 0)) {
      return true;
    }
    return false;
  }
  
  protected List getSelectedNonResources()
  {
    return Arrays.asList(Utils.getNonResources(getStructuredSelection().toArray()));
  }
  
  protected List getSelectedResources()
  {
    return Arrays.asList(Utils.getResources(getStructuredSelection().toArray()));
  }
  
  public void dispose()
  {
    fClipboard.dispose();
  }
}

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

import org.eclipse.jface.action.Action;

class DefaultSynchronizePageActions$1
  extends Action
{
  final DefaultSynchronizePageActions this$0;
  
  DefaultSynchronizePageActions$1(DefaultSynchronizePageActions paramDefaultSynchronizePageActions)
  {
    this$0 = paramDefaultSynchronizePageActions;
  }
  
  public void run()
  {
    DefaultSynchronizePageActions.access$0(this$0).openInCompareEditor();
  }
}

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

import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IContributionItem;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;
import org.eclipse.team.ui.synchronize.ISynchronizePageSite;
import org.eclipse.team.ui.synchronize.SynchronizePageActionGroup;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IViewSite;
import org.eclipse.ui.IWorkbenchSite;
import org.eclipse.ui.actions.ActionContext;

public class DefaultSynchronizePageActions
  extends SynchronizePageActionGroup
{
  private OpenWithActionGroup openWithActions;
  private RefactorActionGroup refactorActions;
  private SyncViewerShowPreferencesAction showPreferences;
  
  public void initialize(ISynchronizePageConfiguration configuration)
  {
    super.initialize(configuration);
    ISynchronizePageSite site = configuration.getSite();
    IWorkbenchSite ws = site.getWorkbenchSite();
    if ((ws instanceof IViewSite))
    {
      openWithActions = new OpenWithActionGroup(configuration, true);
      refactorActions = new RefactorActionGroup(site);
      configuration.setProperty("org.eclipse.team.ui.P_OPEN_ACTION", new Action()
      {
        public void run()
        {
          openWithActions.openInCompareEditor();
        }
      });
      showPreferences = new SyncViewerShowPreferencesAction(configuration);
    }
  }
  
  public void fillActionBars(IActionBars actionBars)
  {
    if (openWithActions != null) {
      openWithActions.fillActionBars(actionBars);
    }
    if (refactorActions != null) {
      refactorActions.fillActionBars(actionBars);
    }
    if ((actionBars != null) && (showPreferences != null))
    {
      IMenuManager menu = actionBars.getMenuManager();
      appendToGroup(menu, "preferences", showPreferences);
    }
  }
  
  public void updateActionBars()
  {
    if (openWithActions != null) {
      openWithActions.updateActionBars();
    }
    if (refactorActions != null) {
      refactorActions.updateActionBars();
    }
  }
  
  public void fillContextMenu(IMenuManager manager)
  {
    IContributionItem fileGroup = findGroup(manager, "file");
    if ((openWithActions != null) && (fileGroup != null)) {
      openWithActions.fillContextMenu(manager, fileGroup.getId());
    }
    IContributionItem editGroup = findGroup(manager, "edit");
    if ((refactorActions != null) && (editGroup != null)) {
      refactorActions.fillContextMenu(manager, editGroup.getId());
    }
  }
  
  public void dispose()
  {
    super.dispose();
    if (refactorActions != null) {
      refactorActions.dispose();
    }
    if (openWithActions != null) {
      openWithActions.dispose();
    }
  }
  
  public void setContext(ActionContext context)
  {
    if (openWithActions != null) {
      openWithActions.setContext(context);
    }
    if (refactorActions != null) {
      refactorActions.setContext(context);
    }
  }
}

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

import org.eclipse.jface.action.Action;
import org.eclipse.team.internal.ui.Utils;
import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;

class DirectionFilterActionGroup$DirectionFilterAction
  extends Action
{
  private int modeId;
  final DirectionFilterActionGroup this$0;
  
  public DirectionFilterActionGroup$DirectionFilterAction(DirectionFilterActionGroup paramDirectionFilterActionGroup, String prefix, String commandId, int modeId)
  {
    super("", 8);this$0 = paramDirectionFilterActionGroup;
    this.modeId = modeId;
    Utils.initAction(this, prefix);
  }
  
  public void run()
  {
    if (isChecked()) {
      DirectionFilterActionGroup.access$0(this$0).setMode(modeId);
    }
  }
  
  public int getModeId()
  {
    return modeId;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.team.internal.ui.synchronize.actions.DirectionFilterActionGroup.DirectionFilterAction
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.team.internal.ui.synchronize.actions;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IContributionManager;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.team.internal.ui.Utils;
import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.actions.ActionGroup;

public class DirectionFilterActionGroup
  extends ActionGroup
  implements IPropertyChangeListener
{
  private List actions = new ArrayList(3);
  private DirectionFilterAction incomingMode;
  private DirectionFilterAction outgoingMode;
  private DirectionFilterAction bothMode;
  private DirectionFilterAction conflictsMode;
  private ISynchronizePageConfiguration configuration;
  
  class DirectionFilterAction
    extends Action
  {
    private int modeId;
    
    public DirectionFilterAction(String prefix, String commandId, int modeId)
    {
      super(8);
      this.modeId = modeId;
      Utils.initAction(this, prefix);
    }
    
    public void run()
    {
      if (isChecked()) {
        configuration.setMode(modeId);
      }
    }
    
    public int getModeId()
    {
      return modeId;
    }
  }
  
  public DirectionFilterActionGroup(ISynchronizePageConfiguration configuration)
  {
    this.configuration = configuration;
    createActions();
    configuration.addPropertyChangeListener(this);
    checkMode(configuration.getMode());
  }
  
  private void createActions()
  {
    int supportedModes = configuration.getSupportedModes();
    if (supportedModes == 0) {
      return;
    }
    int currentMode = configuration.getMode();
    if ((supportedModes & currentMode) == 0)
    {
      currentMode = getSupportedMode(supportedModes);
      if (currentMode == 0) {
        return;
      }
      configuration.setMode(currentMode);
    }
    if ((supportedModes & 0x1) != 0)
    {
      incomingMode = new DirectionFilterAction("action.directionFilterIncoming.", "org.eclipse.team.ui.syncview.incomingFilter", 1);
      actions.add(incomingMode);
      incomingMode.setChecked(currentMode == 1);
    }
    if ((supportedModes & 0x2) != 0)
    {
      outgoingMode = new DirectionFilterAction("action.directionFilterOutgoing.", "org.eclipse.team.ui.syncview.outgoingFilter", 2);
      actions.add(outgoingMode);
      outgoingMode.setChecked(currentMode == 2);
    }
    if ((supportedModes & 0x4) != 0)
    {
      bothMode = new DirectionFilterAction("action.directionFilterBoth.", "org.eclipse.team.ui.syncview.bothFilter", 4);
      actions.add(bothMode);
      bothMode.setChecked(currentMode == 4);
    }
    if ((supportedModes & 0x8) != 0)
    {
      conflictsMode = new DirectionFilterAction("action.directionFilterConflicts.", "org.eclipse.team.ui.syncview.conflictsFilter", 8);
      actions.add(conflictsMode);
      conflictsMode.setChecked(currentMode == 8);
    }
  }
  
  private int getSupportedMode(int supportedModes)
  {
    if ((supportedModes & 0x1) != 0) {
      return 1;
    }
    if ((supportedModes & 0x2) != 0) {
      return 2;
    }
    if ((supportedModes & 0x4) != 0) {
      return 4;
    }
    if ((supportedModes & 0x8) != 0) {
      return 8;
    }
    return 0;
  }
  
  public void fillActionBars(IActionBars actionBars, String group)
  {
    super.fillActionBars(actionBars);
    IToolBarManager toolBar = actionBars.getToolBarManager();
    for (Iterator it = actions.iterator(); it.hasNext();)
    {
      DirectionFilterAction action = (DirectionFilterAction)it.next();
      if (group != null) {
        toolBar.appendToGroup(group, action);
      } else {
        toolBar.add(action);
      }
    }
  }
  
  public void fillToolBar(String groupId, IToolBarManager toolBar)
  {
    for (Iterator it = actions.iterator(); it.hasNext();)
    {
      DirectionFilterAction action = (DirectionFilterAction)it.next();
      toolBar.appendToGroup(groupId, action);
    }
  }
  
  public void fillMenu(IContributionManager manager)
  {
    for (Iterator it = actions.iterator(); it.hasNext();)
    {
      DirectionFilterAction action = (DirectionFilterAction)it.next();
      manager.add(action);
    }
  }
  
  private void checkMode(int mode)
  {
    for (Iterator it = actions.iterator(); it.hasNext();)
    {
      DirectionFilterAction action = (DirectionFilterAction)it.next();
      if (action.getModeId() == mode) {
        action.setChecked(true);
      } else {
        action.setChecked(false);
      }
    }
  }
  
  public void propertyChange(PropertyChangeEvent event)
  {
    if (event.getProperty().equals("org.eclipse.team.ui.P_SYNCVIEWPAGE_MODE"))
    {
      In
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69

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