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

 ModelSynchronizeParticipant createParticipant(SynchronizationContext context, String name)
  {
    return new ModelSynchronizeParticipant(context, name);
  }
  
  private ModelSynchronizeParticipant(SynchronizationContext context, String name)
  {
    initializeContext(context);
    try
    {
      setInitializationData(TeamUI.getSynchronizeManager().getParticipantDescriptor("org.eclipse.team.ui.synchronization_context_synchronize_participant"));
    }
    catch (CoreException e)
    {
      TeamUIPlugin.log(e);
    }
    setSecondaryId(Long.toString(System.currentTimeMillis()));
    setName(name);
    refreshSchedule = new SubscriberRefreshSchedule(createRefreshable());
  }
  
  public ModelSynchronizeParticipant(SynchronizationContext context)
  {
    initializeContext(context);
    refreshSchedule = new SubscriberRefreshSchedule(createRefreshable());
  }
  
  public ModelSynchronizeParticipant() {}
  
  public String getName()
  {
    String name = super.getName();
    if (description == null) {
      description = Utils.getScopeDescription(getContext().getScope());
    }
    return NLS.bind(TeamUIMessages.SubscriberParticipant_namePattern, new String[] { name, description });
  }
  
  protected final String getShortName()
  {
    return super.getName();
  }
  
  protected void initializeConfiguration(ISynchronizePageConfiguration configuration)
  {
    if (isMergingEnabled())
    {
      configuration.addMenuGroup("org.eclipse.team.ui.P_TOOLBAR_MENU", "merge");
      configuration.addActionContribution(createMergeActionGroup());
    }
    configuration.setSupportedModes(15);
    configuration.setMode(4);
    configuration.setProperty("org.eclipse.team.ui.synchronizationContext", getContext());
    configuration.setProperty("org.eclipse.team.ui.synchronizationScope", getContext().getScope());
    if (getHandler() != null) {
      configuration.setProperty("org.eclipse.team.ui.startupPreferences", preferences);
    }
  }
  
  protected ModelSynchronizeParticipantActionGroup createMergeActionGroup()
  {
    return new ModelSynchronizeParticipantActionGroup();
  }
  
  public final IPageBookViewPage createPage(ISynchronizePageConfiguration configuration)
  {
    return new ModelSynchronizePage(configuration);
  }
  
  public void run(IWorkbenchPart part)
  {
    refresh(part != null ? part.getSite() : null, context.getScope().getMappings());
  }
  
  public final void refresh(IWorkbenchSite site, ResourceMapping[] mappings)
  {
    IRefreshSubscriberListener listener = new RefreshUserNotificationPolicy(this);
    internalRefresh(mappings, null, null, site, listener);
  }
  
  public void dispose()
  {
    context.dispose();
    Job.getJobManager().cancel(this);
    refreshSchedule.dispose();
  }
  
  protected void initializeContext(SynchronizationContext context)
  {
    this.context = context;
    mergingEnabled = (context instanceof IMergeContext);
    SubscriberDiffTreeEventHandler handler = getHandler();
    if (handler != null)
    {
      preferences.setDefault("startupAction", "none");
      if (isSynchronizeOnStartup()) {
        run(null);
      } else if (isPopulateOnStartup()) {
        handler.initializeIfNeeded();
      }
    }
  }
  
  private boolean isPopulateOnStartup()
  {
    String pref = preferences.getString("startupAction");
    return (pref != null) && (pref.equals("populate"));
  }
  
  private boolean isSynchronizeOnStartup()
  {
    String pref = preferences.getString("startupAction");
    return (pref != null) && (pref.equals("synchronize"));
  }
  
  public ISynchronizationContext getContext()
  {
    return context;
  }
  
  public ICompareInput asCompareInput(Object object)
  {
    if ((object instanceof ICompareInput)) {
      return (ICompareInput)object;
    }
    ISynchronizationCompareAdapter adapter = Utils.getCompareAdapter(object);
    if (adapter != null) {
      return adapter.asCompareInput(getContext(), object);
    }
    return null;
  }
  
  public boolean hasCompareInputFor(Object object)
  {
    ISynchronizationCompareAdapter adapter = Utils.getCompareAdapter(object);
    if (adapter != null) {
      return adapter.hasCompareInput(getContext(), object);
    }
    return false;
  }
  
  public boolean isMergingEnabled()
  {
    return mergingEnabled;
  }
  
  public void setMergingEnabled(boolean mergingEnabled)
  {
    this.mergingEnabled = mergingEnabled;
  }
  
  private void internalRefresh(ResourceMapping[] mappings, String jobName, String taskName, IWorkbenchSite site, IRefreshSubscriberListener listener)
  {
    if (jobName == null) {
      jobName = getShortTaskName();
    }
    if (taskName == null) {
      taskName = getLongTaskName(mappings);
    }
    Job.getJobManager().cancel(this);
    RefreshParticipantJob job = new RefreshModelParticipantJob(this, jobName, taskName, mappings, listener);
    job.setUser(true);
    job.setProperty(IProgressConstants2.SHOW_IN_TASKBAR_ICON_PROPERTY, Boolean.TRUE);
    Utils.schedule(job, site);
    
    TeamUIPlugin.getPlugin().getPreferenceStore().setValue("org.eclipse.team.ui.sychronizing_default_participant", getId());
    TeamUIPlugin.getPlugin().getPreferenceStore().setValue("org.eclipse.team.ui.sychronizing_default_participant_sec_id", getSecondaryId());
  }
  
  protected String getShortTaskName()
  {
    return NLS.bind(TeamUIMessages.Participant_synchronizingDetails, getShortName());
  }
  
  protected String getLongTaskName(ResourceMapping[] mappings)
  {
    if (mappings == null) {
      mappings = getContext().getScope().getMappings();
    }
    int mappingCount = mappings.length;
    if (mappingCount == getContext().getScope().getMappings().length)
    {
      mappings = getContext().getScope().getInputMappings();
      mappingCount = mappings.length;
    }
    if (mappingCount == 1) {
      return NLS.bind(TeamUIMessages.Participant_synchronizingMoreDetails, new String[] { getShortName(), Utils.getLabel(mappings[0]) });
    }
    return NLS.bind(TeamUIMessages.Participant_synchronizingResources, new String[] { getShortName(), Integer.toString(mappingCount) });
  }
  
  private IRefreshable createRefreshable()
  {
    new IRefreshable()
    {
      public RefreshParticipantJob createJob(String interval)
      {
        String jobName = NLS.bind(TeamUIMessages.RefreshSchedule_15, new String[] { getName(), interval });
        return new RefreshModelParticipantJob(ModelSynchronizeParticipant.this, 
          jobName, 
          jobName, 
          context.getScope().getMappings(), 
          new RefreshUserNotificationPolicy(ModelSynchronizeParticipant.this));
      }
      
      public ISynchronizeParticipant getParticipant()
      {
        return ModelSynchronizeParticipant.this;
      }
      
      public void setRefreshSchedule(SubscriberRefreshSchedule schedule)
      {
        ModelSynchronizeParticipant.this.setRefreshSchedule(schedule);
      }
      
      public SubscriberRefreshSchedule getRefreshSchedule()
      {
        return refreshSchedule;
      }
    };
  }
  
  public Object getAdapter(Class adapter)
  {
    if ((adapter == IRefreshable.class) && (refreshSchedule != null)) {
      return refreshSchedule.getRefreshable();
    }
    if (adapter == SubscriberRefreshSchedule.class) {
      return refreshSchedule;
    }
    return super.getAdapter(adapter);
  }
  
  public void saveState(IMemento memento)
  {
    super.saveState(memento);
    IMemento settings = memento.createChild("org.eclipse.team.ui.MODEL_PARTICIPANT_SETTINGS");
    if (description != null) {
      settings.putString("org.eclipse.team.ui.MODEL_PARTICIPANT_DESCRIPTION", description);
    }
    refreshSchedule.saveState(settings.createChild("org.eclipse.team.ui.MODEL_PARTICIPANT_REFRESH_SCHEDULE"));
    saveMappings(settings);
    settings.putString("startupAction", preferences.getString("startupAction"));
  }
  
  private void saveMappings(IMemento settings)
  {
    ISynchronizationScope inputScope = getContext().getScope().asInputScope();
    ModelProvider[] providers = inputScope.getModelProviders();
    for (int i = 0; i < providers.length; i++)
    {
      ModelProvider provider = providers[i];
      ISynchronizationCompareAdapter adapter = Utils.getCompareAdapter(provider);
      if (adapter != null)
      {
        IMemento child = settings.createChild("org.eclipse.team.ui.MODEL_PARTICIPANT_MAPPINGS");
        String id = provider.getDescriptor().getId();
        child.putString("modelProviderId", id);
        adapter.save(inputScope.getMappings(id), child.createChild("mappings"));
      }
    }
  }
  
  public void init(String secondaryId, IMemento memento)
    throws PartInitException
  {
    super.init(secondaryId, memento);
    if (memento != null)
    {
      IMemento settings = memento.getChild("org.eclipse.team.ui.MODEL_PARTICIPANT_SETTINGS");
      String startupAction = settings.getString("startupAction");
      if (startupAction != null) {
        preferences.putValue("startupAction", startupAction);
      }
      ResourceMapping[] mappings = loadMappings(settings);
      if (mappings.length == 0) {
        throw new PartInitException(NLS.bind(TeamUIMessages.ModelSynchronizeParticipant_0, getId()));
      }
      initializeContext(mappings);
      if (settings != null)
      {
        SubscriberRefreshSchedule schedule = SubscriberRefreshSchedule.init(settings.getChild("org.eclipse.team.ui.MODEL_PARTICIPANT_REFRESH_SCHEDULE"), createRefreshable());
        description = settings.getString("org.eclipse.team.ui.MODEL_PARTICIPANT_DESCRIPTION");
        setRefreshSchedule(schedule);
        if (schedule.isEnabled()) {
          schedule.startJob();
        }
      }
    }
  }
  
  private ResourceMapping[] loadMappings(IMemento settings)
    throws PartInitException
  {
    List result = new ArrayList();
    IMemento[] children = settings.getChildren("org.eclipse.team.ui.MODEL_PARTICIPANT_MAPPINGS");
    for (int i = 0; i < children.length; i++)
    {
      IMemento memento = children[i];
      String id = memento.getString("modelProviderId");
      if (id != null)
      {
        IModelProviderDescriptor desc = ModelProvider.getModelProviderDescriptor(id);
        try
        {
          ModelProvider provider = desc.getModelProvider();
          ISynchronizationCompareAdapter adapter = Utils.getCompareAdapter(provider);
          if (adapter != null)
          {
            ResourceMapping[] mappings = adapter.restore(memento.getChild("mappings"));
            for (int j = 0; j < mappings.length; j++)
            {
              ResourceMapping mapping = mappings[j];
              result.add(mapping);
            }
          }
        }
        catch (CoreException e)
        {
          TeamUIPlugin.log(e);
        }
      }
    }
    return (ResourceMapping[])result.toArray(new ResourceMapping[result.size()]);
  }
  
  private void initializeContext(ResourceMapping[] mappings)
    throws PartInitException
  {
    try
    {
      ISynchronizationScopeManager manager = createScopeManager(mappings);
      MergeContext context = restoreContext(manager);
      initializeContext(context);
    }
    catch (CoreException e)
    {
      TeamUIPlugin.log(e);
      throw new PartInitException(e.getStatus());
    }
  }
  
  protected MergeContext restoreContext(ISynchronizationScopeManager manager)
    throws CoreException
  {
    throw new PartInitException(NLS.bind(TeamUIMessages.ModelSynchronizeParticipant_1, getId()));
  }
  
  protected ISynchronizationScopeManager createScopeManager(ResourceMapping[] mappings)
  {
    return new SynchronizationScopeManager(super.getName(), mappings, ResourceMappingContext.LOCAL_CONTEXT, true);
  }
  
  void setRefreshSchedule(SubscriberRefreshSchedule schedule)
  {
    if (refreshSchedule != schedule)
    {
      if (refreshSchedule != null) {
        refreshSchedule.dispose();
      }
      refreshSchedule = schedule;
    }
    firePropertyChange(this, "org.eclipse.team.schedule", schedule, schedule);
  }
  
  public SaveableComparison getActiveSaveable()
  {
    return activeSaveable;
  }
  
  public void setActiveSaveable(SaveableComparison activeSaveable)
  {
    boolean wasDirty = false;
    SaveableComparison oldModel = this.activeSaveable;
    if (oldModel != null)
    {
      oldModel.removePropertyListener(dirtyListener);
      wasDirty = oldModel.isDirty();
    }
    this.activeSaveable = activeSaveable;
    firePropertyChange(this, "org.eclipse.team.ui.ACTIVE_SAVEABLE", oldModel, activeSaveable);
    boolean isDirty = false;
    if (activeSaveable != null)
    {
      activeSaveable.addPropertyListener(dirtyListener);
      isDirty = activeSaveable.isDirty();
    }
    if (isDirty != wasDirty) {
      firePropertyChange(this, "org.eclipse.team.ui.DIRTY", Boolean.valueOf(wasDirty), Boolean.valueOf(isDirty));
    }
  }
  
  public boolean checkForBufferChange(Shell shell, ISynchronizationCompareInput input, boolean cancelAllowed, IProgressMonitor monitor)
    throws CoreException
  {
    SaveableComparison currentBuffer = getActiveSaveable();
    SaveableComparison targetBuffer = input.getSaveable();
    if (monitor == null) {
      monitor = new NullProgressMonitor();
    }
    try
    {
      ModelParticipantAction.handleTargetSaveableChange(shell, targetBuffer, currentBuffer, cancelAllowed, Policy.subMonitorFor(monitor, 10));
    }
    catch (InterruptedException localInterruptedException)
    {
      return false;
    }
    setActiveSaveable(targetBuffer);
    return true;
  }
  
  public ModelProvider[] getEnabledModelProviders()
  {
    return getContext().getScope().getModelProviders();
  }
  
  public PreferencePage[] getPreferencePages()
  {
    List pages = new ArrayList();
    SyncViewerPreferencePage syncViewerPreferencePage = new SyncViewerPreferencePage();
    syncViewerPreferencePage.setIncludeDefaultLayout(false);
    pages.add(syncViewerPreferencePage);
    pages.add(new ModelEnablementPreferencePage());
    ITeamContentProviderDescriptor[] descriptors = TeamUI.getTeamContentProviderManager().getDescriptors();
    for (int i = 0; i < descriptors.length; i++)
    {
      ITeamContentProviderDescriptor descriptor = descriptors[i];
      if (isIncluded(descriptor)) {
        try
        {
          PreferencePage page = (PreferencePage)descriptor.createPreferencePage();
          if (page != null) {
            pages.add(page);
          }
        }
        catch (CoreException e)
        {
          TeamUIPlugin.log(e);
        }
      }
    }
    if (getHandler() != null) {
      pages.add(new StartupPreferencePage(preferences));
    }
    return (PreferencePage[])pages.toArray(new PreferencePage[pages.size()]);
  }
  
  private boolean isIncluded(ITeamContentProviderDescriptor descriptor)
  {
    ModelProvider[] providers = getEnabledModelProviders();
    for (int i = 0; i < providers.length; i++)
    {
      ModelProvider provider = providers[i];
      if (provider.getId().equals(descriptor.getModelProviderId())) {
        return true;
      }
    }
    return false;
  }
  
  private SubscriberDiffTreeEventHandler getHandler()
  {
    return (SubscriberDiffTreeEventHandler)Utils.getAdapter(context, SubscriberDiffTreeEventHandler.class);
  }
}

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

import org.eclipse.jface.action.Action;
import org.eclipse.team.internal.ui.synchronize.actions.OpenInCompareAction;

class ModelSynchronizeParticipantActionGroup$1
  extends Action
{
  final ModelSynchronizeParticipantActionGroup this$0;
  
  ModelSynchronizeParticipantActionGroup$1(ModelSynchronizeParticipantActionGroup paramModelSynchronizeParticipantActionGroup)
  {
    this$0 = paramModelSynchronizeParticipantActionGroup;
  }
  
  public void run()
  {
    ModelSynchronizeParticipantActionGroup.access$0(this$0).run();
  }
}

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

import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IContributionItem;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.team.core.mapping.IMergeContext;
import org.eclipse.team.core.mapping.ISynchronizationContext;
import org.eclipse.team.internal.ui.Utils;
import org.eclipse.team.internal.ui.mapping.CommonMenuManager;
import org.eclipse.team.internal.ui.mapping.MergeAction;
import org.eclipse.team.internal.ui.mapping.MergeIncomingChangesAction;
import org.eclipse.team.internal.ui.mapping.ModelSelectionDropDownAction;
import org.eclipse.team.internal.ui.synchronize.actions.OpenInCompareAction;
import org.eclipse.team.internal.ui.synchronize.actions.SyncViewerShowPreferencesAction;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IKeyBindingService;
import org.eclipse.ui.IViewSite;
import org.eclipse.ui.IWorkbenchSite;
import org.eclipse.ui.actions.ActionContext;

public class ModelSynchronizeParticipantActionGroup
  extends SynchronizePageActionGroup
{
  public static final String MERGE_ACTION_GROUP = "merge";
  public static final String OTHER_ACTION_GROUP = "other";
  protected static final String MERGE_ALL_ACTION_ID = "org.eclipse.team.ui.mergeAll";
  private MergeIncomingChangesAction updateToolbarAction;
  private ModelSelectionDropDownAction modelPicker;
  private SyncViewerShowPreferencesAction showPreferences;
  private OpenInCompareAction openInCompareAction;
  private MergeAction merge;
  private MergeAction overwrite;
  private MergeAction markAsMerged;
  
  public void initialize(ISynchronizePageConfiguration configuration)
  {
    super.initialize(configuration);
    
    ModelSynchronizeParticipant participant = (ModelSynchronizeParticipant)configuration.getParticipant();
    if (participant.isMergingEnabled())
    {
      updateToolbarAction = new MergeIncomingChangesAction(configuration);
      configureMergeAction("org.eclipse.team.ui.mergeAll", updateToolbarAction);
      appendToGroup(
        "org.eclipse.team.ui.P_TOOLBAR_MENU", 
        "merge", 
        updateToolbarAction);
    }
    modelPicker = new ModelSelectionDropDownAction(configuration);
    appendToGroup(
      "org.eclipse.team.ui.P_TOOLBAR_MENU", 
      "navigate", 
      modelPicker);
    ISynchronizePageSite site = configuration.getSite();
    IWorkbenchSite ws = site.getWorkbenchSite();
    if ((ws instanceof IViewSite))
    {
      showPreferences = new SyncViewerShowPreferencesAction(configuration);
      openInCompareAction = new OpenInCompareAction(configuration);
      configuration.setProperty("org.eclipse.team.ui.P_OPEN_ACTION", new Action()
      {
        public void run()
        {
          openInCompareAction.run();
        }
      });
    }
  }
  
  public void fillActionBars(IActionBars actionBars)
  {
    super.fillActionBars(actionBars);
    if ((actionBars != null) && (showPreferences != null))
    {
      IMenuManager menu = actionBars.getMenuManager();
      appendToGroup(menu, "preferences", showPreferences);
    }
  }
  
  public void fillContextMenu(IMenuManager menu)
  {
    super.fillContextMenu(menu);
    if ((menu instanceof CommonMenuManager))
    {
      CommonMenuManager cmm = (CommonMenuManager)menu;
      addMergeActions(cmm);
    }
    Object[] elements = ((IStructuredSelection)getContext().getSelection()).toArray();
    if ((elements.length > 0) && (openInCompareAction != null))
    {
      IContributionItem fileGroup = findGroup(menu, "file");
      if (fileGroup != null)
      {
        ModelSynchronizeParticipant msp = (ModelSynchronizeParticipant)getConfiguration().getParticipant();
        boolean allElementsHaveCompareInput = true;
        for (int i = 0; i < elements.length; i++) {
          if (!msp.hasCompareInputFor(elements[i]))
          {
            allElementsHaveCompareInput = false;
            break;
          }
        }
        if (allElementsHaveCompareInput) {
          menu.appendToGroup(fileGroup.getId(), openInCompareAction);
        }
      }
    }
  }
  
  private void addMergeActions(CommonMenuManager cmm)
  {
    ModelSynchronizeParticipant participant = (ModelSynchronizeParticipant)getConfiguration().getParticipant();
    if (participant.isMergingEnabled())
    {
      if (!isTwoWayMerge())
      {
        if (merge == null)
        {
          merge = new MergeAction("org.eclipse.team.ui.mergeAction", cmm, getConfiguration());
          configureMergeAction("org.eclipse.team.ui.mergeAction", merge);
          registerActionWithWorkbench(merge);
        }
        merge.update();
        addToContextMenu("org.eclipse.team.ui.mergeAction", merge, cmm);
      }
      if (overwrite == null)
      {
        overwrite = new MergeAction("org.eclipse.team.ui.overwriteAction", cmm, getConfiguration());
        configureMergeAction("org.eclipse.team.ui.overwriteAction", overwrite);
        registerActionWithWorkbench(overwrite);
      }
      overwrite.update();
      addToContextMenu("org.eclipse.team.ui.overwriteAction", overwrite, cmm);
      if (!isTwoWayMerge())
      {
        if (markAsMerged == null)
        {
          markAsMerged = new MergeAction("org.eclipse.team.ui.markAsMergeAction", cmm, getConfiguration());
          configureMergeAction("org.eclipse.team.ui.markAsMergeAction", markAsMerged);
        }
        markAsMerged.update();
        addToContextMenu("org.eclipse.team.ui.markAsMergeAction", markAsMerged, cmm);
        registerActionWithWorkbench(markAsMerged);
      }
    }
  }
  
  private void registerActionWithWorkbench(IAction action)
  {
    ISynchronizePageSite site = getConfiguration().getSite();
    String id = action.getId();
    if (id != null)
    {
      site.getActionBars().setGlobalActionHandler(id, action);
      IKeyBindingService keyBindingService = site.getKeyBindingService();
      if (keyBindingService != null) {
        keyBindingService.registerAction(action);
      }
    }
  }
  
  protected void configureMergeAction(String mergeActionId, Action action)
  {
    if (mergeActionId == "org.eclipse.team.ui.mergeAction") {
      Utils.initAction(action, "action.merge.");
    } else if (mergeActionId == "org.eclipse.team.ui.overwriteAction")
    {
      if (isTwoWayMerge()) {
        Utils.initAction(action, "action.replace.");
      } else {
        Utils.initAction(action, "action.overwrite.");
      }
    }
    else if (mergeActionId == "org.eclipse.team.ui.markAsMergeAction") {
      Utils.initAction(action, "action.markAsMerged.");
    } else if (mergeActionId == "org.eclipse.team.ui.mergeAll") {
      if (isTwoWayMerge()) {
        Utils.initAction(action, "action.replaceAll.");
      } else {
        Utils.initAction(action, "action.mergeAll.");
      }
    }
  }
  
  private boolean isTwoWayMerge()
  {
    ModelSynchronizeParticipant participant = (ModelSynchronizeParticipant)getConfiguration().getParticipant();
    ISynchronizationContext context = participant.getContext();
    if ((context instanceof IMergeContext))
    {
      IMergeContext mc = (IMergeContext)context;
      return mc.getMergeType() == 2;
    }
    return false;
  }
  
  protected void addToContextMenu(String mergeActionId, Action action, IMenuManager manager)
  {
    IContributionItem group = null;
    if (mergeActionId == "org.eclipse.team.ui.mergeAction") {
      group = manager.find("merge");
    } else if (mergeActionId == "org.eclipse.team.ui.overwriteAction") {
      group = manager.find("merge");
    } else if (mergeActionId == "org.eclipse.team.ui.markAsMergeAction") {
      group = manager.find("other");
    }
    if (group != null) {
      manager.appendToGroup(group.getId(), action);
    } else {
      manager.add(action);
    }
  }
  
  public void dispose()
  {
    if (modelPicker != null) {
      modelPicker.dispose();
    }
    if (merge != null) {
      merge.dispose();
    }
    if (overwrite != null) {
      overwrite.dispose();
    }
    if (markAsMerged != null) {
      markAsMerged.dispose();
    }
    if (updateToolbarAction != null) {
      updateToolbarAction.dispose();
    }
    super.dispose();
  }
}

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

import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;

class ParticipantPageCompareEditorInput$1
  implements IPropertyChangeListener
{
  final ParticipantPageCompareEditorInput this$0;
  
  ParticipantPageCompareEditorInput$1(ParticipantPageCompareEditorInput paramParticipantPageCompareEditorInput)
  {
    this$0 = paramParticipantPageCompareEditorInput;
  }
  
  public void propertyChange(PropertyChangeEvent event)
  {
    if (event.getProperty().equals("org.eclipse.team.ui.P_PAGE_DESCRIPTION")) {
      this$0.updateDescription();
    }
  }
}

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

import java.lang.reflect.InvocationTargetException;
import org.eclipse.compare.CompareConfiguration;
import org.eclipse.compare.CompareViewerPane;
import org.eclipse.compare.IContentChangeNotifier;
import org.eclipse.compare.ITypedElement;
import org.eclipse.compare.structuremergeviewer.DiffNode;
import org.eclipse.compare.structuremergeviewer.ICompareInput;
import org.eclipse.compare.structuremergeviewer.IDiffElement;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.resource.ImageDescriptor;
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.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.team.internal.ui.TeamUIMessages;
import org.eclipse.team.internal.ui.Utils;
import org.eclipse.team.internal.ui.synchronize.DialogSynchronizePageSite;
import org.eclipse.team.internal.ui.synchronize.LocalResourceTypedElement;
import org.eclipse.team.internal.ui.synchronize.SynchronizePageConfiguration;
import org.eclipse.team.ui.PageCompareEditorInput;
import org.eclipse.team.ui.TeamUI;
import org.eclipse.team.ui.mapping.ISynchronizationCompareInput;
import org.eclipse.team.ui.mapping.SaveableComparison;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.part.IPage;
import org.eclipse.ui.part.IPageBookViewPage;

public class ParticipantPageCompareEditorInput
  extends PageCompareEditorInput
{
  private ISynchronizeParticipant participant;
  private ISynchronizePageConfiguration pageConfiguration;
  private Image titleImage;
  private IPageBookViewPage page;
  private DialogSynchronizePageSite site;
  private IPropertyChangeListener listener;
  private Button rememberParticipantButton;
  
  public ParticipantPageCompareEditorInput(CompareConfiguration configuration, ISynchronizePageConfiguration pageConfiguration, ISynchronizeParticipant participant)
  {
    super(configuration);
    this.pageConfiguration = pageConfiguration;
    this.participant = participant;
    pageConfiguration.setRunnableContext(this);
  }
  
  protected Object prepareInput(IProgressMonitor monitor)
    throws InvocationTargetException, InterruptedException
  {
    setTitle(Utils.shortenText(100, participant.getName()));
    return participant;
  }
  
  public Image getTitleImage()
  {
    if (titleImage == null) {
      titleImage = participant.getImageDescriptor().createImage();
    }
    return titleImage;
  }
  
  protected void handleDispose()
  {
    if (titleImage != null) {
      titleImage.dispose();
    }
    if (page != null) {
      page.dispose();
    }
    if (site != null) {
      site.dispose();
    }
    pageConfiguration.removePropertyChangeListener(listener);
    super.handleDispose();
  }
  
  protected IPage createPage(CompareViewerPane parent, IToolBarManager toolBarManager)
  {
    listener = new IPropertyChangeListener()
    {
      public void propertyChange(PropertyChangeEvent event)
      {
        if (event.getProperty().equals("org.eclipse.team.ui.P_PAGE_DESCRIPTION")) {
          updateDescription();
        }
      }
    };
    pageConfiguration.addPropertyChangeListener(listener);
    updateDescription();
    
    page = participant.createPage(pageConfiguration);
    site = new DialogSynchronizePageSite(parent.getShell(), true);
    ((SynchronizePageConfiguration)pageConfiguration).setSite(site);
    site.createActionBars(toolBarManager);
    try
    {
      ((ISynchronizePage)page).init(pageConfiguration.getSite());
    }
    catch (PartInitException localPartInitException) {}
    page.createControl(parent);
    
    page.setActionBars(site.getActionBars());
    toolBarManager.update(true);
    return page;
  }
  
  void updateDescription()
  {
    String description = (String)pageConfiguration.getProperty("org.eclipse.team.ui.P_PAGE_DESCRIPTION");
    if (description != null) {
      setPageDescription(description);
    }
  }
  
  protected ISelectionProvider getSelectionProvider()
  {
    return ((ISynchronizePage)page).getViewer();
  }
  
  protected ICompareInput asCompareInput(ISelection selection)
  {
    ICompareInput compareInput = super.asCompareInput(selection);
    if (compareInput != null) {
      return compareInput;
    }
    if ((selection != null) && ((selection instanceof IStructuredSelection)))
    {
      IStructuredSelection ss = (IStructuredSelection)selection;
      if (ss.size() == 1)
      {
        Object o = ss.getFirstElement();
        if ((participant instanceof ModelSynchronizeParticipant))
        {
          ModelSynchronizeParticipant msp = (ModelSynchronizeParticipant)participant;
          return msp.asCompareInput(o);
        }
      }
    }
    return null;
  }
  
  /* Error */
  protected void prepareInput(ICompareInput input, CompareConfiguration configuration, IProgressMonitor monitor)
    throws InvocationTargetException
  {
    // Byte code:
    //   0: aload_3
    //   1: getstatic 426	org/eclipse/team/internal/ui/TeamUIMessages:SyncInfoCompareInput_3	Ljava/lang/String;
    //   4: bipush 100
    //   6: invokeinterface 502 3 0
    //   11: aload_3
    //   12: getstatic 426	org/eclipse/team/internal/ui/TeamUIMessages:SyncInfoCompareInput_3	Ljava/lang/String;
    //   15: invokeinterface 501 2 0
    //   20: aload_0
    //   21: aload_0
    //   22: getfield 432	org/eclipse/team/ui/synchronize/ParticipantPageCompareEditorInput:pageConfiguration	Lorg/eclipse/team/ui/synchronize/ISynchronizePageConfiguration;
    //   25: invokeinterface 515 1 0
    //   30: invokeinterface 518 1 0
    //   35: aload_1
    //   36: iconst_0
    //   37: aload_3
    //   38: invokespecial 497	org/eclipse/team/ui/synchronize/ParticipantPageCompareEditorInput:checkForBufferChange	(Lorg/eclipse/swt/widgets/Shell;Lorg/eclipse/compare/structuremergeviewer/ICompareInput;ZLorg/eclipse/core/runtime/IProgressMonitor;)V
    //   41: aload_1
    //   42: instanceof 215
    //   45: ifeq +48 -> 93
    //   48: aload_1
    //   49: checkcast 215	org/eclipse/team/internal/ui/synchronize/SyncInfoModelElement
    //   52: astore 4
    //   54: aload 4
    //   56: invokevirtual 467	org/eclipse/team/internal/ui/synchronize/SyncInfoModelElement:getResource	()Lorg/eclipse/core/resources/IResource;
    //   59: astore 5
    //   61: aload 5
    //   63: ifnull +82 -> 145
    //   66: aload 5
    //   68: invokeinterface 499 1 0
    //   73: iconst_1
    //   74: if_icmpne +71 -> 145
    //   77: aload_0
    //   78: getfield 433	org/eclipse/team/ui/synchronize/ParticipantPageCompareEditorInput:participant	Lorg/eclipse/team/ui/synchronize/ISynchronizeParticipant;
    //   81: aload 4
    //   83: aload_2
    //   84: aload_3
    //   85: invokeinterface 524 4 0
    //   90: goto +55 -> 145
    //   93: aload_0
    //   94: aload_1
    //   95: invokespecial 496	org/eclipse/team/ui/synchronize/ParticipantPageCompareEditorInput:asModelCompareInput	(Lorg/eclipse/compare/structuremergeviewer/ICompareInput;)Lorg/eclipse/team/ui/mapping/ISynchronizationCompareInput;
    //   98: astore 4
    //   100: aload 4
    //   102: ifnull +43 -> 145
    //   105: aload 4
    //   107: aload_2
    //   108: aload_3
    //   109: bipush 90
    //   111: invokestatic 458	org/eclipse/team/internal/ui/Policy:subMonitorFor	(Lorg/eclipse/core/runtime/IProgressMonitor;I)Lorg/eclipse/core/runtime/IProgressMonitor;
    //   114: invokeinterface 506 3 0
    //   119: goto +26 -> 145
    //   122: astore 4
    //   124: new 192	java/lang/reflect/InvocationTargetException
    //   127: dup
    //   128: aload 4
    //   130: invokespecial 438	java/lang/reflect/InvocationTargetException:<init>	(Ljava/lang/Throwable;)V
    //   133: athrow
    //   134: astore 6
    //   136: aload_3
    //   137: invokeinterface 500 1 0
    //   142: aload 6
    //   144: athrow
    //   145: aload_3
    //   146: invokeinterface 500 1 0
    //   151: return
    // Line number table:
    //   Java source line #180	-> byte code offset #0
    //   Java source line #181	-> byte code offset #11
    //   Java source line #184	-> byte code offset #20
    //   Java source line #185	-> byte code offset #41
    //   Java source line #186	-> byte code offset #48
    //   Java source line #187	-> byte code offset #54
    //   Java source line #188	-> byte code offset #61
    //   Java source line #189	-> byte code offset #77
    //   Java source line #192	-> byte code offset #93
    //   Java source line #193	-> byte code offset #100
    //   Java source line #194	-> byte code offset #105
    //   Java source line #197	-> byte code offset #122
    //   Java source line #198	-> byte code offset #124
    //   Java source line #199	-> byte code offset #134
    //   Java source line #200	-> byte code offset #136
    //   Java source line #201	-> byte code offset #142
    //   Java source line #200	-> byte code offset #145
    //   Java source line #202	-> byte code offset #151
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	152	0	this	ParticipantPageCompareEditorInput
    //   0	152	1	input	ICompareInput
    //   0	152	2	configuration	CompareConfiguration
    //   0	152	3	monitor	IProgressMonitor
    //   52	30	4	node	org.eclipse.team.internal.ui.synchronize.SyncInfoModelElement
    //   98	8	4	adapter	ISynchronizationCompareInput
    //   122	7	4	e	CoreException
    //   59	8	5	resource	org.eclipse.core.resources.IResource
    //   134	9	6	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   20	119	122	org/eclipse/core/runtime/CoreException
    //   20	134	134	finally
  }
  
  private void checkForBufferChange(Shell shell, ICompareInput input, boolean cancelAllowed, IProgressMonitor monitor)
    throws CoreException
  {
    ISynchronizeParticipant participant = pageConfiguration.getParticipant();
    if ((participant instanceof ModelSynchronizeParticipant))
    {
      ModelSynchronizeParticipant msp = (ModelSynchronizeParticipant)participant;
      if ((input instanceof ISynchronizationCompareInput))
      {
        ISynchronizationCompareInput mci = (ISynchronizationCompareInput)input;
        msp.checkForBufferChange(shell, mci, cancelAllowed, monitor);
      }
    }
  }
  
  private ISynchronizationCompareInput asModelCompareInput(ICompareInput input)
  {
    return (ISynchronizationCompareInput)Utils.getAdapter(input, ISynchronizationCompareInput.class);
  }
  
  public boolean isSaveNeeded()
  {
    if ((participant instanceof ModelSynchronizeParticipant))
    {
      ModelSynchronizeParticipant msp = (ModelSynchronizeParticipant)participant;
      SaveableComparison currentBuffer = msp.getActiveSaveable();
      if (currentBuffer != null) {
        return currentBuffer.isDirty();
      }
    }
    return super.isSaveNeeded();
  }
  
  /* Error */
  public void saveChanges(IProgressMonitor monitor)
    throws CoreException
  {
    // Byte code:
    //   0: aload_0
    //   1: aload_1
    //   2: invokespecial 475	org/eclipse/team/ui/PageCompareEditorInput:saveChanges	(Lorg/eclipse/core/runtime/IProgressMonitor;)V
    //   5: aload_0
    //   6: getfield 434	org/eclipse/team/ui/synchronize/ParticipantPageCompareEditorInput:page	Lorg/eclipse/ui/part/IPageBookViewPage;
    //   9: checkcast 223	org/eclipse/team/ui/synchronize/ISynchronizePage
    //   12: invokeinterface 510 1 0
    //   17: invokevirtual 447	org/eclipse/jface/viewers/Viewer:getInput	()Ljava/lang/Object;
    //   20: astore_2
    //   21: aload_2
    //   22: instanceof 222
    //   25: ifeq +60 -> 85
    //   28: aload_2
    //   29: checkcast 222	org/eclipse/team/ui/synchronize/ISynchronizeModelElement
    //   32: astore_3
    //   33: aload_3
    //   34: ifnull +51 -> 85
    //   37: aload_3
    //   38: instanceof 195
    //   41: ifeq +44 -> 85
    //   44: aload_1
    //   45: aload_3
    //   46: checkcast 195	org/eclipse/compare/structuremergeviewer/DiffNode
    //   49: invokestatic 495	org/eclipse/team/ui/synchronize/ParticipantPageCompareEditorInput:commit	(Lorg/eclipse/core/runtime/IProgressMonitor;Lorg/eclipse/compare/structuremergeviewer/DiffNode;)V
    //   52: goto +28 -> 80
    //   55: astore 4
    //   57: aload 4
    //   59: invokestatic 459	org/eclipse/team/internal/ui/Utils:handle	(Ljava/lang/Throwable;)V
    //   62: aload_0
    //   63: iconst_0
    //   64: invokevirtual 489	org/eclipse/team/ui/synchronize/ParticipantPageCompareEditorInput:setDirty	(Z)V
    //   67: goto +18 -> 85
    //   70: astore 5
    //   72: aload_0
    //   73: iconst_0
    //   74: invokevirtual 489	org/eclipse/team/ui/synchronize/ParticipantPageCompareEditorInput:setDirty	(Z)V
    //   77: aload 5
    //   79: athrow
    //   80: aload_0
    //   81: iconst_0
    //   82: invokevirtual 489	org/eclipse/team/ui/synchronize/ParticipantPageCompareEditorInput:setDirty	(Z)V
    //   85: return
    // Line number table:
    //   Java source line #237	-> byte code offset #0
    //   Java source line #238	-> byte code offset #5
    //   Java source line #239	-> byte code offset #21
    //   Java source line #240	-> byte code offset #28
    //   Java source line #241	-> byte code offset #33
    //   Java source line #243	-> byte code offset #44
    //   Java source line #244	-> byte code offset #55
    //   Java source line #245	-> byte code offset #57
    //   Java source line #247	-> byte code offset #62
    //   Java source line #246	-> byte code offset #70
    //   Java source line #247	-> byte code offset #72
    //   Java source line #248	-> byte code offset #77
    //   Java source line #247	-> byte code offset #80
    //   Java source line #251	-> byte code offset #85
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	86	0	this	ParticipantPageCompareEditorInput
    //   0	86	1	monitor	IProgressMonitor
    //   20	9	2	input	Object
    //   32	14	3	root	ISynchronizeModelElement
    //   55	3	4	e	CoreException
    //   70	8	5	localObject1	Object
    // Exception table:
    //   from	to	target	type
    //   44	52	55	org/eclipse/core/runtime/CoreException
    //   44	62	70	finally
  }
  
  private static void commit(IProgr
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