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

Action
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.team.internal.ui.mapping;

import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.osgi.util.NLS;
import org.eclipse.team.core.mapping.IResourceDiffTree;
import org.eclipse.team.internal.ui.TeamUIMessages;
import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;
import org.eclipse.team.ui.synchronize.ISynchronizePageSite;

class MergeAllActionHandler$1
  implements Runnable
{
  final MergeAllActionHandler this$0;
  private final long val$count;
  private final IResourceDiffTree val$tree;
  private final boolean[] val$result;
  
  MergeAllActionHandler$1(MergeAllActionHandler paramMergeAllActionHandler, long paramLong, IResourceDiffTree paramIResourceDiffTree, boolean[] paramArrayOfBoolean)
  {
    this$0 = paramMergeAllActionHandler;val$count = paramLong;val$tree = paramIResourceDiffTree;val$result = paramArrayOfBoolean;
  }
  
  public void run()
  {
    String sizeString = Long.toString(val$count);
    String message = val$tree.size() > 1 ? NLS.bind(TeamUIMessages.MergeAllActionHandler_1, new String[] { sizeString }) : 
      NLS.bind(TeamUIMessages.MergeAllActionHandler_2, new String[] { sizeString });
    val$result[0] = MessageDialog.openQuestion(MergeAllActionHandler.access$0(this$0).getSite().getShell(), 
      NLS.bind(TeamUIMessages.MergeAllActionHandler_3, new String[] { sizeString }), message);
  }
}

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

import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.mapping.ResourceMapping;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.widgets.Display;
import org.eclipse.team.core.diff.IDiffChangeEvent;
import org.eclipse.team.core.diff.IDiffChangeListener;
import org.eclipse.team.core.diff.IDiffTree;
import org.eclipse.team.core.mapping.IMergeContext;
import org.eclipse.team.core.mapping.IResourceDiffTree;
import org.eclipse.team.core.mapping.ISynchronizationScope;
import org.eclipse.team.internal.ui.TeamUIMessages;
import org.eclipse.team.internal.ui.TeamUIPlugin;
import org.eclipse.team.internal.ui.Utils;
import org.eclipse.team.ui.mapping.MergeActionHandler;
import org.eclipse.team.ui.mapping.SynchronizationOperation;
import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;
import org.eclipse.team.ui.synchronize.ISynchronizePageSite;
import org.eclipse.team.ui.synchronize.ISynchronizeParticipant;
import org.eclipse.ui.ide.IDE;

public class MergeAllActionHandler
  extends MergeActionHandler
  implements IDiffChangeListener
{
  private MergeAllOperation operation;
  
  public MergeAllActionHandler(ISynchronizePageConfiguration configuration)
  {
    super(configuration);
    getContext().getDiffTree().addDiffChangeListener(this);
  }
  
  protected synchronized SynchronizationOperation getOperation()
  {
    if (operation == null) {
      operation = createOperation();
    }
    return operation;
  }
  
  protected MergeAllOperation createOperation()
  {
    return new MergeAllOperation(getJobName(), getConfiguration(), getMappings(), getContext());
  }
  
  private IMergeContext getContext()
  {
    return (IMergeContext)getConfiguration().getProperty("org.eclipse.team.ui.synchronizationContext");
  }
  
  private ResourceMapping[] getMappings()
  {
    return ((ISynchronizationScope)getConfiguration().getProperty("org.eclipse.team.ui.synchronizationScope")).getMappings();
  }
  
  public void diffsChanged(IDiffChangeEvent event, IProgressMonitor monitor)
  {
    synchronized (this)
    {
      operation = null;
    }
    setEnabled((event.getTree().countFor(512, 768) > 0L) || 
      (event.getTree().countFor(768, 768) > 0L));
  }
  
  public void propertyChanged(IDiffTree tree, int property, IPath[] paths) {}
  
  public void dispose()
  {
    getContext().getDiffTree().removeDiffChangeListener(this);
    super.dispose();
  }
  
  public Object execute(ExecutionEvent event)
    throws ExecutionException
  {
    if ((saveDirtyEditors()) && (promptToUpdate())) {
      return super.execute(event);
    }
    return null;
  }
  
  public final boolean saveDirtyEditors()
  {
    if ((needsToSaveDirtyEditors()) && 
      (!saveAllEditors(getTargetResources(), confirmSaveOfDirtyEditor()))) {
      return false;
    }
    return true;
  }
  
  private IResource[] getTargetResources()
  {
    return getContext().getDiffTree().getAffectedResources();
  }
  
  public final boolean saveAllEditors(IResource[] resources, boolean confirm)
  {
    return IDE.saveAllEditors(resources, confirm);
  }
  
  protected boolean needsToSaveDirtyEditors()
  {
    return true;
  }
  
  protected boolean confirmSaveOfDirtyEditor()
  {
    return true;
  }
  
  protected String getJobName()
  {
    String name = getConfiguration().getParticipant().getName();
    return NLS.bind(TeamUIMessages.MergeAllActionHandler_0, Utils.shortenText(100, name));
  }
  
  protected boolean promptToUpdate()
  {
    IResourceDiffTree tree = getContext().getDiffTree();
    if (tree.isEmpty()) {
      return false;
    }
    long count = tree.countFor(512, 768) + tree.countFor(768, 768);
    if (count == 0L) {
      return false;
    }
    boolean[] result = { true };
    TeamUIPlugin.getStandardDisplay().syncExec(new Runnable()
    {
      private final long val$count;
      private final IResourceDiffTree val$tree;
      private final boolean[] val$result;
      
      public void run()
      {
        String sizeString = Long.toString(val$count);
        String message = val$tree.size() > 1 ? NLS.bind(TeamUIMessages.MergeAllActionHandler_1, new String[] { sizeString }) : 
          NLS.bind(TeamUIMessages.MergeAllActionHandler_2, new String[] { sizeString });
        val$result[0] = MessageDialog.openQuestion(getConfiguration().getSite().getShell(), 
          NLS.bind(TeamUIMessages.MergeAllActionHandler_3, new String[] { sizeString }), message);
      }
    });
    return result[0];
  }
}

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

import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.team.core.mapping.IMergeContext;
import org.eclipse.team.core.mapping.ISynchronizationContext;
import org.eclipse.team.core.mapping.ISynchronizationScopeManager;
import org.eclipse.team.internal.ui.Policy;
import org.eclipse.team.ui.synchronize.ModelMergeOperation;
import org.eclipse.ui.IWorkbenchPart;

class MergeAllOperation$1
  extends ModelMergeOperation
{
  final MergeAllOperation this$0;
  
  MergeAllOperation$1(MergeAllOperation paramMergeAllOperation, IWorkbenchPart $anonymous0, ISynchronizationScopeManager $anonymous1)
  {
    super($anonymous0, $anonymous1);this$0 = paramMergeAllOperation;
  }
  
  public boolean isPreviewRequested()
  {
    return false;
  }
  
  protected void initializeContext(IProgressMonitor monitor)
    throws CoreException
  {
    monitor.beginTask(null, 10);
    monitor.done();
  }
  
  protected ISynchronizationContext getContext()
  {
    return MergeAllOperation.access$0(this$0);
  }
  
  protected void executeMerge(IProgressMonitor monitor)
    throws CoreException
  {
    monitor.beginTask(null, 100);
    if (!hasChangesOfInterest())
    {
      handleNoChanges();
    }
    else if (isPreviewRequested())
    {
      handlePreviewRequest();
    }
    else
    {
      IStatus status = ModelMergeOperation.validateMerge(getMergeContext(), Policy.subMonitorFor(monitor, 10));
      if ((!status.isOK()) && 
        (!promptToContinue(status))) {
        return;
      }
      status = performMerge(Policy.subMonitorFor(monitor, 90));
      if (!status.isOK()) {
        handleMergeFailure(status);
      }
    }
    monitor.done();
  }
  
  private IMergeContext getMergeContext()
  {
    return (IMergeContext)getContext();
  }
  
  private boolean promptToContinue(IStatus status)
  {
    boolean[] result = new boolean[1];
    Runnable runnable = new MergeAllOperation.2(this, status, result);
    
    getShell().getDisplay().syncExec(runnable);
    return result[0];
  }
}

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

import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.team.internal.ui.TeamUIMessages;

class MergeAllOperation$2
  implements Runnable
{
  final MergeAllOperation.1 this$1;
  private final IStatus val$status;
  private final boolean[] val$result;
  
  MergeAllOperation$2(MergeAllOperation.1 param1, IStatus paramIStatus, boolean[] paramArrayOfBoolean)
  {
    this$1 = param1;val$status = paramIStatus;val$result = paramArrayOfBoolean;
  }
  
  public void run()
  {
    ErrorDialog dialog = new MergeAllOperation.3(this, MergeAllOperation.1.access$0(this$1), TeamUIMessages.ModelMergeOperation_0, TeamUIMessages.ModelMergeOperation_1, val$status, 7);
    
    int code = dialog.open();
    val$result[0] = (code == 0 ? 1 : false);
  }
}

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

import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Shell;

class MergeAllOperation$3
  extends ErrorDialog
{
  final MergeAllOperation.2 this$2;
  
  MergeAllOperation$3(MergeAllOperation.2 param2, Shell $anonymous0, String $anonymous1, String $anonymous2, IStatus $anonymous3, int $anonymous4)
  {
    super($anonymous0, $anonymous1, $anonymous2, $anonymous3, $anonymous4);this$2 = param2;
  }
  
  protected void createButtonsForButtonBar(Composite parent)
  {
    createButton(parent, 2, IDialogConstants.YES_LABEL, 
      false);
    createButton(parent, 3, IDialogConstants.NO_LABEL, 
      true);
    createDetailsButton(parent);
  }
  
  protected void buttonPressed(int id)
  {
    if (id == 2) {
      super.buttonPressed(0);
    } else if (id == 3) {
      super.buttonPressed(1);
    }
    super.buttonPressed(id);
  }
}

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

import java.lang.reflect.InvocationTargetException;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.team.core.mapping.IMergeContext;
import org.eclipse.team.core.mapping.ISynchronizationContext;
import org.eclipse.team.core.mapping.ISynchronizationScopeManager;
import org.eclipse.team.core.mapping.provider.SynchronizationContext;
import org.eclipse.team.internal.ui.Policy;
import org.eclipse.team.ui.mapping.SynchronizationOperation;
import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;
import org.eclipse.team.ui.synchronize.ModelMergeOperation;
import org.eclipse.ui.IWorkbenchPart;

public final class MergeAllOperation
  extends SynchronizationOperation
{
  private final IMergeContext context;
  private final String jobName;
  
  public MergeAllOperation(String jobName, ISynchronizePageConfiguration configuration, Object[] elements, IMergeContext context)
  {
    super(configuration, elements);
    this.jobName = jobName;
    this.context = context;
  }
  
  public void execute(IProgressMonitor monitor)
    throws InvocationTargetException, InterruptedException
  {
    new ModelMergeOperation(getPart(), ((SynchronizationContext)context).getScopeManager())
    {
      public boolean isPreviewRequested()
      {
        return false;
      }
      
      protected void initializeContext(IProgressMonitor monitor)
        throws CoreException
      {
        monitor.beginTask(null, 10);
        monitor.done();
      }
      
      protected ISynchronizationContext getContext()
      {
        return context;
      }
      
      protected void executeMerge(IProgressMonitor monitor)
        throws CoreException
      {
        monitor.beginTask(null, 100);
        if (!hasChangesOfInterest())
        {
          handleNoChanges();
        }
        else if (isPreviewRequested())
        {
          handlePreviewRequest();
        }
        else
        {
          IStatus status = ModelMergeOperation.validateMerge(getMergeContext(), Policy.subMonitorFor(monitor, 10));
          if ((!status.isOK()) && 
            (!promptToContinue(status))) {
            return;
          }
          status = performMerge(Policy.subMonitorFor(monitor, 90));
          if (!status.isOK()) {
            handleMergeFailure(status);
          }
        }
        monitor.done();
      }
      
      private IMergeContext getMergeContext()
      {
        return (IMergeContext)getContext();
      }
      
      private boolean promptToContinue(IStatus status)
      {
        boolean[] result = new boolean[1];
        Runnable runnable = new MergeAllOperation.2(this, status, result);
        
        getShell().getDisplay().syncExec(runnable);
        return result[0];
      }
    }.run(monitor);
  }
  
  protected boolean canRunAsJob()
  {
    return true;
  }
  
  protected String getJobName()
  {
    return jobName;
  }
}

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

import org.eclipse.team.core.diff.FastDiffFilter;
import org.eclipse.team.core.diff.IDiff;
import org.eclipse.team.core.diff.IThreeWayDiff;

class MergeIncomingChangesAction$1
  extends FastDiffFilter
{
  final MergeIncomingChangesAction this$0;
  
  MergeIncomingChangesAction$1(MergeIncomingChangesAction paramMergeIncomingChangesAction)
  {
    this$0 = paramMergeIncomingChangesAction;
  }
  
  public boolean select(IDiff node)
  {
    if ((node instanceof IThreeWayDiff))
    {
      IThreeWayDiff twd = (IThreeWayDiff)node;
      if ((twd.getDirection() == 768) || (twd.getDirection() == 512)) {
        return true;
      }
    }
    return false;
  }
}

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

import java.lang.reflect.InvocationTargetException;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.team.ui.mapping.SaveableComparison;
import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;
import org.eclipse.team.ui.synchronize.ISynchronizePageSite;

class MergeIncomingChangesAction$2
  implements IRunnableWithProgress
{
  final MergeIncomingChangesAction this$0;
  private final SaveableComparison val$currentBuffer;
  
  MergeIncomingChangesAction$2(MergeIncomingChangesAction paramMergeIncomingChangesAction, SaveableComparison paramSaveableComparison)
  {
    this$0 = paramMergeIncomingChangesAction;val$currentBuffer = paramSaveableComparison;
  }
  
  public void run(IProgressMonitor monitor)
    throws InvocationTargetException, InterruptedException
  {
    try
    {
      MergeIncomingChangesAction.handleTargetSaveableChange(MergeIncomingChangesAction.access$0(this$0).getSite().getShell(), null, val$currentBuffer, true, monitor);
    }
    catch (CoreException e)
    {
      throw new InvocationTargetException(e);
    }
  }
}

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

import java.lang.reflect.InvocationTargetException;
import java.util.Collections;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.commands.HandlerEvent;
import org.eclipse.core.commands.IHandler;
import org.eclipse.core.commands.IHandlerListener;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.widgets.Event;
import org.eclipse.team.core.diff.FastDiffFilter;
import org.eclipse.team.core.diff.IDiff;
import org.eclipse.team.core.diff.IThreeWayDiff;
import org.eclipse.team.internal.ui.Utils;
import org.eclipse.team.ui.mapping.SaveableComparison;
import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;
import org.eclipse.team.ui.synchronize.ISynchronizePageSite;
import org.eclipse.team.ui.synchronize.ModelParticipantAction;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.progress.IProgressService;

public class MergeIncomingChangesAction
  extends ModelParticipantAction
  implements IHandlerListener
{
  IHandler handler;
  
  public MergeIncomingChangesAction(ISynchronizePageConfiguration configuration)
  {
    super(null, configuration);
    
    handler = ((IHandler)configuration.getProperty("org.eclipse.team.ui.mergeAll"));
    if (handler == null) {
      handler = new MergeAllActionHandler(configuration);
    }
    handler.addHandlerListener(this);
  }
  
  public void runWithEvent(Event event)
  {
    if ((handler == null) || (!handler.isEnabled())) {
      return;
    }
    try
    {
      handleTargetSaveableChange();
    }
    catch (InvocationTargetException e)
    {
      handle(e);
      return;
    }
    catch (InterruptedException localInterruptedException)
    {
      return;
    }
    try
    {
      handler.execute(new ExecutionEvent(null, Collections.EMPTY_MAP, event, null));
    }
    catch (ExecutionException e)
    {
      handle(e);
    }
  }
  
  private void handle(Throwable throwable)
  {
    if ((throwable instanceof ExecutionException))
    {
      ExecutionException ee = (ExecutionException)throwable;
      if (ee.getCause() != null) {
        throwable = ee.getCause();
      }
    }
    Utils.handle(throwable);
  }
  
  protected boolean isEnabledForSelection(IStructuredSelection selection)
  {
    return handler.isEnabled();
  }
  
  protected FastDiffFilter getDiffFilter()
  {
    new FastDiffFilter()
    {
      public boolean select(IDiff node)
      {
        if ((node instanceof IThreeWayDiff))
        {
          IThreeWayDiff twd = (IThreeWayDiff)node;
          if ((twd.getDirection() == 768) || (twd.getDirection() == 512)) {
            return true;
          }
        }
        return false;
      }
    };
  }
  
  protected void handleTargetSaveableChange()
    throws InvocationTargetException, InterruptedException
  {
    SaveableComparison currentBuffer = getActiveSaveable();
    if ((currentBuffer != null) && (currentBuffer.isDirty())) {
      PlatformUI.getWorkbench().getProgressService().run(true, true, new IRunnableWithProgress()
      {
        private final SaveableComparison val$currentBuffer;
        
        public void run(IProgressMonitor monitor)
          throws InvocationTargetException, InterruptedException
        {
          try
          {
            MergeIncomingChangesAction.handleTargetSaveableChange(getConfiguration().getSite().getShell(), null, val$currentBuffer, true, monitor);
          }
          catch (CoreException e)
          {
            throw new InvocationTargetException(e);
          }
        }
      });
    }
    setActiveSaveable(null);
  }
  
  public void dispose()
  {
    handler.dispose();
  }
  
  public void handlerChanged(HandlerEvent handlerEvent)
  {
    setEnabled(handler.isEnabled());
  }
}

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

import org.eclipse.team.core.ICache;
import org.eclipse.team.core.ICacheListener;

class ModelCompareEditorInput$1
  implements ICacheListener
{
  final ModelCompareEditorInput this$0;
  
  ModelCompareEditorInput$1(ModelCompareEditorInput paramModelCompareEditorInput)
  {
    this$0 = paramModelCompareEditorInput;
  }
  
  public void cacheDisposed(ICache cache)
  {
    ModelCompareEditorInput.access$0(this$0, true);
  }
}

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

import org.eclipse.compare.CompareNavigator;
import org.eclipse.compare.INavigatable;

class ModelCompareEditorInput$2
  extends CompareNavigator
{
  final ModelCompareEditorInput this$0;
  
  ModelCompareEditorInput$2(ModelCompareEditorInput paramModelCompareEditorInput)
  {
    this$0 = paramModelCompareEditorInput;
  }
  
  protected INavigatable[] getNavigatables()
  {
    return new INavigatable[0];
  }
}

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

import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager;

class ModelCompareEditorInput$3
  implements IMenuListener
{
  final ModelCompareEditorInput this$0;
  
  ModelCompareEditorInput$3(ModelCompareEditorInput paramModelCompareEditorInput)
  {
    this$0 = paramModelCompareEditorInput;
  }
  
  public void menuAboutToShow(IMenuManager manager)
  {
    this$0.handleMenuAboutToShow(manager);
  }
}

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

import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.jface.action.Action;
import org.eclipse.team.internal.ui.TeamUIPlugin;

class ModelCompareEditorInput$4
  extends Action
{
  final ModelCompareEditorInput this$0;
  private final ResourceMarkAsMergedHandler val$markAsMergedHandler;
  
  ModelCompareEditorInput$4(ModelCompareEditorInput paramModelCompareEditorInput, String $anonymous0, ResourceMarkAsMergedHandler paramResourceMarkAsMergedHandler)
  {
    super($anonymous0);this$0 = paramModelCompareEditorInput;val$markAsMergedHandler = paramResourceMarkAsMergedHandler;
  }
  
  public void run()
  {
    try
    {
      val$markAsMergedHandler.execute(new ExecutionEvent());
    }
    catch (ExecutionException e)
    {
      TeamUIPlugin.log(4, e.getMessage(), e);
    }
  }
}

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

import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.jface.action.Action;
import org.eclipse.team.internal.ui.TeamUIPlugin;

class ModelCompareEditorInput$5
  extends Action
{
  final ModelCompareEditorInput this$0;
  private final ResourceMergeHandler val$mergeHandler;
  
  ModelCompareEditorInput$5(ModelCompareEditorInput paramModelCompareEditorInput, String $anonymous0, ResourceMergeHandler paramResourceMergeHandler)
  {
    super($anonymous0);this$0 = paramModelCompareEditorInput;val$mergeHandler = paramResourceMergeHandler;
  }
  
  public void run()
  {
    try
    {
      val$mergeHandler.execute(new ExecutionEvent());
    }
    catch (ExecutionException e)
    {
      TeamUIPlugin.log(4, e.getMessage(), e);
    }
  }
}

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

import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.jface.action.Action;
import org.eclipse.team.internal.ui.TeamUIPlugin;

class ModelCompareEditorInput$6
  extends Action
{
  final ModelCompareEditorInput this$0;
  private final ResourceMergeHandler val$overwriteHandler;
  
  ModelCompareEditorInput$6(ModelCompareEditorInput paramModelCompareEditorInput, String $anonymous0, ResourceMergeHandler paramResourceMergeHandler)
  {
    super($anonymous0);this$0 = paramModelCompareEditorInput;val$overwriteHandler = paramResourceMergeHandler;
  }
  
  public void run()
  {
    try
    {
      val$overwriteHandler.execute(new ExecutionEvent());
    }
    catch (ExecutionException e)
    {
      TeamUIPlugin.log(4, e.getMessage(), e);
    }
  }
}

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

import org.eclipse.compare.CompareConfiguration;
import org.eclipse.compare.CompareNavigator;
import org.eclipse.compare.ICompareNavigator;
import org.eclipse.compare.IEditableContent;
import org.eclipse.compare.INavigatable;
import org.eclipse.compare.IResourceProvider;
import org.eclipse.compare.structuremergeviewer.ICompareInput;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.Assert;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
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.osgi.util.NLS;
import org.eclipse.team.core.ICache;
import org.eclipse.team.core.ICacheListener;
import org.eclipse.team.core.mapping.ISynchronizationContext;
import org.eclipse.team.internal.ui.TeamUIMessages;
import org.eclipse.team.internal.ui.TeamUIPlugin;
import org.eclipse.team.internal.ui.Utils;
import org.eclipse.team.internal.ui.synchronize.LocalResourceSaveableComparison;
import org.eclipse.team.ui.mapping.ISynchronizationCompareInput;
import org.eclipse.team.ui.mapping.SaveableComparison;
import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;
import org.eclipse.team.ui.synchronize.ISynchronizePageSite;
import org.eclipse.team.ui.synchronize.ISynchronizeParticipant;
import org.eclipse.team.ui.synchronize.ModelSynchronizeParticipant;
import org.eclipse.team.ui.synchronize.SaveableCompareEditorInput;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.Saveable;

public class ModelCompareEditorInput
  extends SaveableCompareEditorInput
  implements IPropertyChangeListener
{
  private static final String IGNORE_WHITSPACE_PAGE_PROPERTY = "org.eclipse.compare.IGNORE_WHITESPACE";
  private final ModelSynchronizeParticipant participant;
  private final ICompareInput input;
  private final ICacheListener contextListener;
  private final ISynchronizePageConfiguration synchronizeConfiguration;
  
  public ModelCompareEditorInput(ModelSynchronizeParticipant participant, ICompareInput input, IWorkbenchPage page, ISynchronizePageConfiguration synchronizeConfiguration)
  {
    super(createCompareConfiguration(synchronizeConfiguration), page);
    this.synchronizeConfiguration = synchronizeConfiguration;
    Assert.isNotNull(participant);
    Assert.isNotNull(input);
    this.participant = participant;
    this.input = input;
    contextListener = new ICacheListener()
    {
      public void cacheDisposed(ICache cache)
      {
        closeEditor(true);
      }
    };
    getCompareConfiguration().addPropertyChangeListener(this);
    setTitle(NLS.bind(TeamUIMessages.SyncInfoCompareInput_title, new String[] { input.getName() }));
  }
  
  private static CompareConfiguration createCompareConfiguration(ISynchronizePageConfiguration pageConfiguration)
  {
    CompareConfiguration compareConfiguration = new CompareConfiguration();
    Object o = pageConfiguration.getProperty("org.eclipse.compare.IGNORE_WHITESPACE");
    if ((o != null) && ((o.equals(Boolean.TRUE)) || (o.equals(Boolean.FALSE)))) {
      compareConfiguration.setProperty("IGNORE_WHITESPACE", o);
    }
    return compareConfiguration;
  }
  
  protected void contentsCreated()
  {
    super.contentsCreated();
    participant.getContext().getCache().addCacheListener(contextListener);
  }
  
  protected void handleDispose()
  {
    super.handleDispose();
    participant.getContext().getCache().removeCacheListener(contextListener);
    getCompareConfiguration().removePropertyChangeListener(this);
    ICompareNavigator navigator = (ICompareNavigator)synchronizeConfiguration.getProperty("org.eclipse.team.ui.P_INPUT_NAVIGATOR");
    if ((navigator != null) && (navigator == super.getNavigator())) {
      synchronizeConfiguration.setProperty("org.eclipse.team.ui.P_INPUT_NAVIGATOR", new CompareNavigator()
      {
        protected INavigatable[] getNavigatables()
        {
          return new INavigatable[0];
        }
      });
    }
  }
  
  protected Saveable createSaveable()
  {
    if ((input instanceof ISynchronizationCompareInput))
    {
      ISynchronizationCompareInput mci = (ISynchronizationCompareInput)input;
      SaveableComparison compareModel = mci.getSaveable();
      if (compareModel != null) {
        return compareModel;
      }
    }
    return super.createSaveable();
  }
  
  /* Error */
  protected ICompareInput prepareCompareInput(org.eclipse.core.runtime.IProgressMonitor monitor)
    throws java.lang.reflect.InvocationTargetException, java.lang.InterruptedException
  {
    // Byte code:
    //   0: aload_1
    //   1: getstatic 407	org/eclipse/team/internal/ui/TeamUIMessages:SyncInfoCompareInput_3	Ljava/lang/String;
    //   4: bipush 100
    //   6: invokeinterface 480 3 0
    //   11: aload_1
    //   12: getstatic 407	org/eclipse/team/internal/ui/TeamUIMessages:SyncInfoCompareInput_3	Ljava/lang/String;
    //   15: invokeinterface 479 2 0
    //   20: aload_0
    //   21: invokevirtual 445	org/eclipse/team/internal/ui/mapping/ModelCompareEditorInput:getCompareConfiguration	()Lorg/eclipse/compare/CompareConfiguration;
    //   24: aload_0
    //   25: aload_0
    //   26: getfield 411	org/eclipse/team/internal/ui/mapping/ModelCompareEditorInput:input	Lorg/eclipse/compare/structuremergeviewer/ICompareInput;
    //   29: invokespecial 447	org/eclipse/team/internal/ui/mapping/ModelCompareEditorInput:isLeftEditable	(Lorg/eclipse/compare/structuremergeviewer/ICompareInput;)Z
    //   32: invokevirtual 423	org/eclipse/compare/CompareConfiguration:setLeftEditable	(Z)V
    //   35: aload_0
    //   36: invokevirtual 445	org/eclipse/team/internal/ui/mapping/ModelCompareEditorInput:getCompareConfiguration	()Lorg/eclipse/compare/CompareConfiguration;
    //   39: iconst_0
    //   40: invokevirtual 424	org/eclipse/compare/CompareConfiguration:setRightEditable	(Z)V
    //   43: aload_0
    //   44: aload_0
    //   45: getfield 411	org/eclipse/team/internal/ui/mapping/ModelCompareEditorInput:input	Lorg/eclipse/compare/structuremergeviewer/ICompareInput;
    //   48: invokespecial 451	org/eclipse/team/internal/ui/mapping/ModelCompareEditorInput:asModelCompareInput	(Lorg/eclipse/compare/structuremergeviewer/ICompareInput;)Lorg/eclipse/team/ui/mapping/ISynchronizationCompareInput;
    //   51: astore_2
    //   52: aload_2
    //   53: ifnull +41 -> 94
    //   56: aload_2
    //   57: aload_0
    //   58: invokevirtual 445	org/eclipse/team/internal/ui/mapping/ModelCompareEditorInput:getCompareConfiguration	()Lorg/eclipse/compare/CompareConfiguration;
    //   61: aload_1
    //   62: bipush 100
    //   64: invokestatic 437	org/eclipse/team/internal/ui/Policy:subMonitorFor	(Lorg/eclipse/core/runtime/IProgressMonitor;I)Lorg/eclipse/core/runtime/IProgressMonitor;
    //   67: invokeinterface 491 3 0
    //   72: goto +22 -> 94
    //   75: astore_2
    //   76: new 198	java/lang/reflect/InvocationTargetException
    //   79: dup
    //   80: aload_2
    //   81: invokespecial 421	java/lang/reflect/InvocationTargetException:<init>	(Ljava/lang/Throwable;)V
    //   84: athrow
    //   85: astore_3
    //   86: aload_1
    //   87: invokeinterface 478 1 0
    //   92: aload_3
    //   93: athrow
    //   94: aload_1
    //   95: invokeinterface 478 1 0
    //   100: aload_0
    //   101: getfield 411	org/eclipse/team/internal/ui/mapping/ModelCompareEditorInput:input	Lorg/eclipse/compare/structuremergeviewer/ICompareInput;
    //   104: areturn
    // Line number table:
    //   Java source line #114	-> byte code offset #0
    //   Java source line #115	-> byte code offset #11
    //   Java source line #116	-> byte code offset #20
    //   Java source line #117	-> byte code offset #35
    //   Java source line #119	-> byte code offset #43
    //   Java source line #120	-> byte code offset #52
    //   Java source line #121	-> byte code offset #56
    //   Java source line #123	-> byte code offset #75
    //   Java source line #124	-> byte code offset #76
    //   Java source line #125	-> byte code offset #85
    //   Java source line #126	-> byte code offset #86
    //   Java source line #127	-> byte code offset #92
    //   Java source line #126	-> byte code offset #94
    //   Java source line #128	-> byte code offset #100
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	105	0	this	ModelCompareEditorInput
    //   0	105	1	monitor	org.eclipse.core.runtime.IProgressMonitor
    //   51	6	2	adapter	ISynchronizationCompareInput
    //   75	6	2	e	org.eclipse.core.runtime.CoreException
    //   85	8	3	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   43	72	75	org/eclipse/core/runtime/CoreException
    //   43	85	85	finally
  }
  
  private ISynchronizationCompareInput asModelCompareInput(ICompareInput input)
  {
    return (ISynchronizationCompareInput)Utils.getAdapter(input, ISynchronizationCompareInput.class);
  }
  
  public boolean matches(Object object, ISynchronizeParticipant participant)
  {
    if ((participant == this.participant) && ((input instanceof ISynchronizationCompareInput)))
    {
      ISynchronizationCompareInput mci = (ISynchronizationCompareInput)input;
      return mci.isCompareInputFor(object);
    }
    return false;
  }
  
  public String getToolTipText()
  {
    ISynchronizationCompareInput adapter = asModelCompareInput(input);
    String fullPath;
    String fullPath;
    if (adapter != null) {
      fullPath = adapter.getFullPath();
    } else {
      fullPath = getName();
    }
    return NLS.bind(TeamUIMessages.SyncInfoCompareInput_tooltip, new String[] { Utils.shortenText(100, participant.getName()), fullPath });
  }
  
  protected void fireInputChange()
  {
    if ((input instanceof ResourceDiffCompareInput))
    {
      ResourceDiffCompareInput rdci = (ResourceDiffCompareInput)input;
      rdci.fireChange();
    }
  }
  
  public void registerContextMenu(MenuManager menu, ISelectionProvider provider)
  {
    super.registerContextMenu(menu, provider);
    Saveable saveable = getSaveable();
    if ((saveable instanceof LocalResourceSaveableComparison)) {
      menu.addMenuListener(new IMenuListener()
      {
        public void menuAboutToShow(IMenuManager manager)
        {
          handleMenuAboutToShow(manager);
        }
      });
    }
  }
  
  protected void handleMenuAboutToShow(IMenuManager manager)
  {
    StructuredSelection selection = new StructuredSelection(((IResourceProvider)getCompareInput()).getResource());
    ResourceMarkAsMergedHandler markAsMergedHandler = new ResourceMarkAsMergedHandler(getSynchronizeConfiguration());
    markAsMergedHandler.updateEnablement(selection);
    Action markAsMergedAction = new Action(TeamUIMessages.ModelCompareEditorInput_0)
    {
      private final ResourceMarkAsMergedHandler val$markAsMergedHandler;
      
      public void run()
      {
        try
        {
          val$markAsMergedHandler.execute(new ExecutionEvent());
        }
        catch (ExecutionException e)
        {
          TeamUIPlugin.log(4, e.getMessage(), e);
        }
      }
    };
    Utils.initAction(markAsMergedAction, "action.markAsMerged.");
    markAsMergedAction.setEnabled(markAsMergedAction.isEnabled());
    
    ResourceMergeHandler mergeHandler = new ResourceMergeHandler(getSynchronizeConfiguration(), false);
    mergeHandler.updateEnablement(selection);
    Action mergeAction = new Action(TeamUIMessages.ModelCompareEditorInput_1)
    {
      private final ResourceMergeHandler val$mergeHandler;
      
      public void run()
      {
        try
        {
          val$mergeHandler.execute(new ExecutionEvent());
        }
        catch (ExecutionException e)
        {
          TeamUIPlugin.log(4, e.getMessage(), e);
        }
      }
    };
    Utils.initAction(mergeAction, "action.merge.");
    mergeAction.setEnabled(mergeAction.isEnabled());
    
    ResourceMergeHandler overwriteHandler = new ResourceMergeHandler(getSynchronizeConfiguration(), true);
    overwriteHandler.updateEnablement(selection);
    Action overwriteAction = new Action(TeamUIMessages.ModelCompareEditorInput_2)
    {
      private final ResourceMergeHandler val$overwriteHandler;
      
      public void run()
      {
        try
        {
          val$overwriteHandler.execute(new ExecutionEvent());
        }
        catch (ExecutionException e)
        {
          TeamUIPlugin.log(4, e.getMessage(), e);
        }
      }
    };
    Utils.initAction(overwriteAction, "action.overwrite.");
    overwriteAction.setEnabled(overwriteAction.isEnabled());
    
    manager.insertAfter("additions", new Separator("merge"));
    manager.insertAfter("merge", new Separator("overwrite"));
    manager.insertAfter("merge", markAsMergedAction);
    manager.insertAfter("merge", mergeAction);
    manager.insertAfter("overwrite", overwriteAction);
  }
  
  protected ISynchronizePageConfiguration getSynchronizeConfiguration()
  {
    return synchronizeConfiguration;
  }
  
  public void propertyChange(PropertyChangeEvent event)
  {
    if (event.getProperty().equals("IGNORE_WHITESPACE")) {
      synchronizeConfiguration.setProperty("org.eclipse.compare.IGNORE_WHITESPACE", event.getNewValue());
    }
  }
  
  public boolean belongsTo(Object family)
  {
    return (super.belongsTo(family)) || (family == participant);
  }
  
  public synchronized ICompareNavigator getNavigator()
  {
    if (isSelectedInSynchronizeView())
    {
      ICompareNavigator nav = (ICompareNavigator)synchronizeConfiguration.getProperty("org.eclipse.team.ui.P_NAVIGATOR");
      
      synchronizeConfiguration.setProperty("org.eclipse.team.ui.P_INPUT_NAVIGATOR", sup
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