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

er.getNavigator());
      return nav;
    }
    return super.getNavigator();
  }
  
  private boolean isSelectedInSynchronizeView()
  {
    ISelection s = synchronizeConfiguration.getSite().getSelectionProvider().getSelection();
    if ((s instanceof IStructuredSelection))
    {
      IStructuredSelection ss = (IStructuredSelection)s;
      Object element = ss.getFirstElement();
      return matches(element, participant);
    }
    return false;
  }
  
  public boolean equals(Object obj)
  {
    if (obj == this) {
      return true;
    }
    if ((obj instanceof ModelCompareEditorInput))
    {
      ModelCompareEditorInput other = (ModelCompareEditorInput)obj;
      return (input.equals(input)) && (participant.equals(participant));
    }
    return false;
  }
  
  public int hashCode()
  {
    return input.hashCode();
  }
  
  private boolean isLeftEditable(ICompareInput input)
  {
    Object left = input.getLeft();
    if ((left instanceof IEditableContent)) {
      return ((IEditableContent)left).isEditable();
    }
    return false;
  }
}

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

import org.eclipse.core.resources.mapping.ModelProvider;
import org.eclipse.core.resources.mapping.ResourceMapping;
import org.eclipse.jface.viewers.CheckStateChangedEvent;
import org.eclipse.jface.viewers.ICheckStateListener;
import org.eclipse.jface.viewers.ICheckable;
import org.eclipse.team.internal.ui.Utils;

class ModelElementSelectionPage$1
  implements ICheckStateListener
{
  final ModelElementSelectionPage this$0;
  
  ModelElementSelectionPage$1(ModelElementSelectionPage paramModelElementSelectionPage)
  {
    this$0 = paramModelElementSelectionPage;
  }
  
  public void checkStateChanged(CheckStateChangedEvent event)
  {
    Object element = event.getElement();
    if ((event.getChecked()) && ((element instanceof ModelProvider)) && (((ModelProvider)element).getId().equals("org.eclipse.core.resources.modelProvider")))
    {
      ModelElementSelectionPage.access$0(this$0, true);
    }
    else
    {
      ResourceMapping mapping = Utils.getResourceMapping(element);
      if (mapping != null)
      {
        if (!(element instanceof ModelProvider))
        {
          ModelElementSelectionPage.access$1(this$0, mapping.getModelProviderId());
          event.getCheckable().setChecked(event.getElement(), event.getChecked());
        }
        ModelElementSelectionPage.access$2(this$0);
      }
      else
      {
        ModelElementSelectionPage.access$2(this$0);
      }
    }
  }
}

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

import org.eclipse.swt.events.TreeEvent;
import org.eclipse.swt.events.TreeListener;

class ModelElementSelectionPage$2
  implements TreeListener
{
  final ModelElementSelectionPage this$0;
  
  ModelElementSelectionPage$2(ModelElementSelectionPage paramModelElementSelectionPage)
  {
    this$0 = paramModelElementSelectionPage;
  }
  
  public void treeCollapsed(TreeEvent e) {}
  
  public void treeExpanded(TreeEvent e)
  {
    if (ModelElementSelectionPage.access$3(this$0)) {
      this$0.checkWorkingSetElements();
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.team.internal.ui.mapping.ModelElementSelectionPage.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 org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.team.core.mapping.ISynchronizationScopeManager;

class ModelElementSelectionPage$3
  implements IRunnableWithProgress
{
  final ModelElementSelectionPage this$0;
  
  ModelElementSelectionPage$3(ModelElementSelectionPage paramModelElementSelectionPage)
  {
    this$0 = paramModelElementSelectionPage;
  }
  
  public void run(IProgressMonitor monitor)
    throws InvocationTargetException, InterruptedException
  {
    try
    {
      ModelElementSelectionPage.access$4(this$0).initialize(monitor);
      ModelElementSelectionPage.access$5(this$0, true);
    }
    catch (CoreException e)
    {
      throw new InvocationTargetException(e);
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.team.internal.ui.mapping.ModelElementSelectionPage.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 java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.mapping.IModelProviderDescriptor;
import org.eclipse.core.resources.mapping.ModelProvider;
import org.eclipse.core.resources.mapping.ResourceMapping;
import org.eclipse.core.resources.mapping.ResourceMappingContext;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.viewers.CheckStateChangedEvent;
import org.eclipse.jface.viewers.DecoratingLabelProvider;
import org.eclipse.jface.viewers.ICheckStateListener;
import org.eclipse.jface.viewers.ICheckable;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.wizard.IWizardContainer;
import org.eclipse.swt.events.TreeEvent;
import org.eclipse.swt.events.TreeListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.team.core.mapping.ISynchronizationScope;
import org.eclipse.team.core.mapping.ISynchronizationScopeManager;
import org.eclipse.team.core.mapping.provider.SynchronizationScopeManager;
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.GlobalRefreshElementSelectionPage;
import org.eclipse.team.ui.TeamUI;
import org.eclipse.team.ui.mapping.ITeamContentProviderDescriptor;
import org.eclipse.team.ui.mapping.ITeamContentProviderManager;
import org.eclipse.ui.IDecoratorManager;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkingSet;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.dialogs.ContainerCheckedTreeViewer;
import org.eclipse.ui.navigator.IExtensionStateModel;
import org.eclipse.ui.navigator.INavigatorActivationService;
import org.eclipse.ui.navigator.INavigatorContentExtension;
import org.eclipse.ui.navigator.INavigatorContentService;
import org.eclipse.ui.navigator.INavigatorContentServiceListener;
import org.eclipse.ui.navigator.NavigatorContentServiceFactory;
import org.eclipse.ui.views.navigator.ResourceComparator;

public class ModelElementSelectionPage
  extends GlobalRefreshElementSelectionPage
  implements INavigatorContentServiceListener
{
  private INavigatorContentService service;
  private ISynchronizationScopeManager manager;
  private ContainerCheckedTreeViewer fViewer;
  private boolean initialized;
  
  public ModelElementSelectionPage(IResource[] roots)
  {
    super("elementSelection");
    setDescription(TeamUIMessages.GlobalRefreshResourceSelectionPage_2);
    setTitle(TeamUIMessages.GlobalRefreshResourceSelectionPage_3);
    List result = new ArrayList();
    for (int i = 0; i < roots.length; i++)
    {
      IResource resource = roots[i];
      result.add(Utils.getResourceMapping(resource));
    }
    manager = new SynchronizationScopeManager(TeamUIMessages.ModelElementSelectionPage_0, (ResourceMapping[])result.toArray(new ResourceMapping[result.size()]), 
      ResourceMappingContext.LOCAL_CONTEXT, true);
  }
  
  protected ContainerCheckedTreeViewer createViewer(Composite top)
  {
    fViewer = new ContainerCheckedTreeViewer(top, 2048);
    service = NavigatorContentServiceFactory.INSTANCE.createContentService("org.eclipse.team.ui.navigatorViewer", fViewer);
    service.bindExtensions(TeamUI.getTeamContentProviderManager().getContentProviderIds(manager.getScope()), true);
    service.getActivationService().activateExtensions(TeamUI.getTeamContentProviderManager().getContentProviderIds(manager.getScope()), true);
    service.addListener(this);
    GridData data = new GridData(1808);
    
    heightHint = 100;
    fViewer.getControl().setLayoutData(data);
    fViewer.setContentProvider(service.createCommonContentProvider());
    fViewer.setLabelProvider(new DecoratingLabelProvider(service.createCommonLabelProvider(), PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator()));
    fViewer.addCheckStateListener(new ICheckStateListener()
    {
      public void checkStateChanged(CheckStateChangedEvent event)
      {
        Object element = event.getElement();
        if ((event.getChecked()) && ((element instanceof ModelProvider)) && (((ModelProvider)element).getId().equals("org.eclipse.core.resources.modelProvider")))
        {
          setWorkspaceSelected(true);
        }
        else
        {
          ResourceMapping mapping = Utils.getResourceMapping(element);
          if (mapping != null)
          {
            if (!(element instanceof ModelProvider))
            {
              ModelElementSelectionPage.this.uncheckOtherModels(mapping.getModelProviderId());
              event.getCheckable().setChecked(event.getElement(), event.getChecked());
            }
            updateOKStatus();
          }
          else
          {
            updateOKStatus();
          }
        }
      }
    });
    fViewer.getTree().addTreeListener(new TreeListener()
    {
      public void treeCollapsed(TreeEvent e) {}
      
      public void treeExpanded(TreeEvent e)
      {
        if (isWorkingSetSelected()) {
          checkWorkingSetElements();
        }
      }
    });
    fViewer.setComparator(new ResourceComparator(1));
    return fViewer;
  }
  
  public ResourceMapping[] getSelectedMappings()
  {
    if (isWorkingSetSelected())
    {
      List result = new ArrayList();
      IWorkingSet[] sets = getWorkingSets();
      for (int i = 0; i < sets.length; i++)
      {
        IWorkingSet set = sets[i];
        result.add(Utils.getResourceMapping(set));
      }
      return (ResourceMapping[])result.toArray(new ResourceMapping[result.size()]);
    }
    if (isWorkspaceSelected()) {
      try
      {
        ModelProvider provider = ModelProvider.getModelProviderDescriptor("org.eclipse.core.resources.modelProvider").getModelProvider();
        ResourceMapping mapping = Utils.getResourceMapping(provider);
        if (mapping != null) {
          return new ResourceMapping[] { mapping };
        }
      }
      catch (CoreException e)
      {
        TeamUIPlugin.log(e);
        
        return manager.getScope().getMappings("org.eclipse.core.resources.modelProvider");
      }
    }
    List result = new ArrayList();
    Object[] objects = getRootElement();
    for (int i = 0; i < objects.length; i++)
    {
      Object object = objects[i];
      ResourceMapping mapping = Utils.getResourceMapping(object);
      if (mapping != null) {
        result.add(mapping);
      }
    }
    return (ResourceMapping[])result.toArray(new ResourceMapping[result.size()]);
  }
  
  public void dispose()
  {
    service.dispose();
    super.dispose();
  }
  
  protected void checkAll()
  {
    getViewer().setCheckedElements(manager.getScope().getModelProviders());
  }
  
  protected boolean checkWorkingSetElements()
  {
    List allWorkingSetElements = new ArrayList();
    IWorkingSet[] workingSets = getWorkingSets();
    for (int i = 0; i < workingSets.length; i++)
    {
      IWorkingSet set = workingSets[i];
      allWorkingSetElements.addAll(computeSelectedResources(new StructuredSelection(set.getElements())));
    }
    getViewer().setCheckedElements(allWorkingSetElements.toArray());
    return !allWorkingSetElements.isEmpty();
  }
  
  private Collection computeSelectedResources(StructuredSelection selection)
  {
    List result = new ArrayList();
    for (Iterator iter = selection.iterator(); iter.hasNext();)
    {
      Object element = iter.next();
      ResourceMapping mapping = Utils.getResourceMapping(element);
      if ((mapping != null) && (scopeContainsMapping(mapping))) {
        result.add(element);
      }
    }
    return result;
  }
  
  private boolean scopeContainsMapping(ResourceMapping mapping)
  {
    ResourceMapping[] mappings = manager.getScope().getMappings();
    for (int i = 0; i < mappings.length; i++)
    {
      ResourceMapping m = mappings[i];
      if (m.contains(mapping)) {
        return true;
      }
    }
    return false;
  }
  
  public void onLoad(INavigatorContentExtension anExtension)
  {
    anExtension.getStateModel().setProperty("org.eclipse.team.ui.synchronizationScope", manager.getScope());
  }
  
  public void setVisible(boolean visible)
  {
    super.setVisible(visible);
    if ((visible) && (!initialized))
    {
      initialize();
      if (initialized)
      {
        ISynchronizationScope syncScope = manager.getScope();
        ModelProvider[] providers = syncScope.getModelProviders();
        boolean foundEnabledModelProvider = false;
        for (int i = 0; i < providers.length; i++) {
          if (isEnabled(providers[i]))
          {
            foundEnabledModelProvider = true;
            break;
          }
        }
        if ((!foundEnabledModelProvider) && 
          (MessageDialog.openConfirm(getShell(), TeamUIMessages.ModelElementSelectionPage_AllModelsDisabledTitle, TeamUIMessages.ModelElementSelectionPage_AllModelsDisabledMessage)))
        {
          ArrayList teamProviderDescriptors = new ArrayList();
          for (int i = 0; i < providers.length; i++) {
            teamProviderDescriptors.add(TeamUI.getTeamContentProviderManager().getDescriptor(providers[i].getId()));
          }
          ITeamContentProviderDescriptor[] desc = (ITeamContentProviderDescriptor[])teamProviderDescriptors.toArray(new ITeamContentProviderDescriptor[teamProviderDescriptors.size()]);
          TeamUI.getTeamContentProviderManager().setEnabledDescriptors(desc);
        }
        service.bindExtensions(TeamUI.getTeamContentProviderManager().getContentProviderIds(syncScope), true);
        service.getActivationService().activateExtensions(TeamUI.getTeamContentProviderManager().getContentProviderIds(syncScope), true);
        fViewer.setInput(syncScope);
        initializeScopingHint();
      }
    }
  }
  
  private void initialize()
  {
    try
    {
      getContainer().run(true, true, new IRunnableWithProgress()
      {
        public void run(IProgressMonitor monitor)
          throws InvocationTargetException, InterruptedException
        {
          try
          {
            manager.initialize(monitor);
            initialized = true;
          }
          catch (CoreException e)
          {
            throw new InvocationTargetException(e);
          }
        }
      });
    }
    catch (InvocationTargetException e)
    {
      Utils.handleError(getShell(), e, null, null);
    }
    catch (InterruptedException localInterruptedException) {}
  }
  
  private boolean isEnabled(ModelProvider provider)
  {
    ITeamContentProviderDescriptor desc = TeamUI.getTeamContentProviderManager().getDescriptor(provider.getId());
    return (desc != null) && (desc.isEnabled());
  }
  
  private void uncheckOtherModels(String modelProviderId)
  {
    if (!isSelectedResourcesSelected())
    {
      ModelProvider[] providers = manager.getScope().getModelProviders();
      ArrayList disabledProviders = new ArrayList();
      for (int i = 0; i < providers.length; i++) {
        if (!providers[i].getId().equals(modelProviderId)) {
          disabledProviders.add(providers[i]);
        }
      }
      for (Iterator iterator = disabledProviders.iterator(); iterator.hasNext();)
      {
        ModelProvider disable = (ModelProvider)iterator.next();
        fViewer.setChecked(disable, false);
      }
    }
  }
}

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

import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.team.ui.mapping.ITeamContentProviderManager;

class ModelEnablementPreferencePage$1
  implements IStructuredContentProvider
{
  final ModelEnablementPreferencePage this$0;
  
  ModelEnablementPreferencePage$1(ModelEnablementPreferencePage paramModelEnablementPreferencePage)
  {
    this$0 = paramModelEnablementPreferencePage;
  }
  
  public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
  
  public void dispose() {}
  
  public Object[] getElements(Object element)
  {
    if ((element instanceof ITeamContentProviderManager))
    {
      ITeamContentProviderManager manager = (ITeamContentProviderManager)element;
      return manager.getDescriptors();
    }
    return new Object[0];
  }
}

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

import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import org.eclipse.core.resources.mapping.IModelProviderDescriptor;
import org.eclipse.core.resources.mapping.ModelProvider;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.graphics.Image;
import org.eclipse.team.ui.mapping.ITeamContentProviderDescriptor;

class ModelEnablementPreferencePage$2
  extends LabelProvider
{
  Map images;
  final ModelEnablementPreferencePage this$0;
  
  ModelEnablementPreferencePage$2(ModelEnablementPreferencePage paramModelEnablementPreferencePage)
  {
    this$0 = paramModelEnablementPreferencePage;
    images = new HashMap();
  }
  
  public String getText(Object element)
  {
    if ((element instanceof ITeamContentProviderDescriptor))
    {
      ITeamContentProviderDescriptor desc = (ITeamContentProviderDescriptor)element;
      return getTextFor(desc);
    }
    return super.getText(element);
  }
  
  private String getTextFor(ITeamContentProviderDescriptor teamContentDescriptor)
  {
    String name = teamContentDescriptor.getName();
    if ((name != null) && (!name.equals(""))) {
      return name;
    }
    String modelProviderID = teamContentDescriptor.getModelProviderId();
    IModelProviderDescriptor desc = ModelProvider.getModelProviderDescriptor(modelProviderID);
    if (desc != null) {
      return ModelEnablementPreferencePage.access$0(this$0, desc);
    }
    return modelProviderID;
  }
  
  public Image getImage(Object element)
  {
    if ((element instanceof ITeamContentProviderDescriptor))
    {
      ITeamContentProviderDescriptor desc = (ITeamContentProviderDescriptor)element;
      Image image = (Image)images.get(desc);
      if (image == null)
      {
        ImageDescriptor idesc = desc.getImageDescriptor();
        if (idesc != null)
        {
          image = idesc.createImage();
          if (image != null) {
            images.put(desc, image);
          }
        }
      }
      return image;
    }
    return super.getImage(element);
  }
  
  public void dispose()
  {
    for (Iterator iter = images.values().iterator(); iter.hasNext();)
    {
      Image image = (Image)iter.next();
      image.dispose();
    }
    super.dispose();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.team.internal.ui.mapping.ModelEnablementPreferencePage.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.resources.mapping.IModelProviderDescriptor;
import org.eclipse.core.resources.mapping.ModelProvider;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerComparator;
import org.eclipse.team.ui.mapping.ITeamContentProviderDescriptor;

class ModelEnablementPreferencePage$3
  extends ViewerComparator
{
  final ModelEnablementPreferencePage this$0;
  
  ModelEnablementPreferencePage$3(ModelEnablementPreferencePage paramModelEnablementPreferencePage)
  {
    this$0 = paramModelEnablementPreferencePage;
  }
  
  public int compare(Viewer viewer, Object e1, Object e2)
  {
    if (((e1 instanceof ITeamContentProviderDescriptor)) && ((e2 instanceof ITeamContentProviderDescriptor)))
    {
      ITeamContentProviderDescriptor d1 = (ITeamContentProviderDescriptor)e1;
      ITeamContentProviderDescriptor d2 = (ITeamContentProviderDescriptor)e2;
      IModelProviderDescriptor md1 = ModelProvider.getModelProviderDescriptor(d1.getModelProviderId());
      IModelProviderDescriptor md2 = ModelProvider.getModelProviderDescriptor(d2.getModelProviderId());
      if ((md1 != null) && (md2 != null)) {
        return ModelEnablementPreferencePage.access$0(this$0, md1).compareTo(ModelEnablementPreferencePage.access$0(this$0, md2));
      }
    }
    return super.compare(viewer, e1, e2);
  }
}

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

import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import org.eclipse.core.resources.mapping.IModelProviderDescriptor;
import org.eclipse.core.resources.mapping.ModelProvider;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.preference.PreferencePage;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.CheckboxTableViewer;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerComparator;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Table;
import org.eclipse.team.internal.ui.SWTUtils;
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.TeamUI;
import org.eclipse.team.ui.mapping.ITeamContentProviderDescriptor;
import org.eclipse.team.ui.mapping.ITeamContentProviderManager;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.help.IWorkbenchHelpSystem;

public class ModelEnablementPreferencePage
  extends PreferencePage
  implements IWorkbenchPreferencePage
{
  private Set previosulyEnabled = new HashSet();
  private CheckboxTableViewer tableViewer;
  
  public ModelEnablementPreferencePage()
  {
    setTitle(TeamUIMessages.ModelEnablementPreferencePage_0);
    setPreferenceStore(TeamUIPlugin.getPlugin().getPreferenceStore());
  }
  
  protected Control createContents(Composite parent)
  {
    Composite composite = new Composite(parent, 0);
    composite.setLayout(new GridLayout());
    composite.setLayoutData(new GridData(1808));
    
    Label l = SWTUtils.createLabel(composite, TeamUIMessages.ModelEnablementPreferencePage_1);
    l.setLayoutData(new GridData(768));
    
    tableViewer = CheckboxTableViewer.newCheckList(composite, 2048);
    tableViewer.getTable().setLayoutData(new GridData(1808));
    tableViewer.setContentProvider(new IStructuredContentProvider()
    {
      public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
      
      public void dispose() {}
      
      public Object[] getElements(Object element)
      {
        if ((element instanceof ITeamContentProviderManager))
        {
          ITeamContentProviderManager manager = (ITeamContentProviderManager)element;
          return manager.getDescriptors();
        }
        return new Object[0];
      }
    });
    tableViewer.setLabelProvider(new LabelProvider()
    {
      Map images = new HashMap();
      
      public String getText(Object element)
      {
        if ((element instanceof ITeamContentProviderDescriptor))
        {
          ITeamContentProviderDescriptor desc = (ITeamContentProviderDescriptor)element;
          return getTextFor(desc);
        }
        return super.getText(element);
      }
      
      private String getTextFor(ITeamContentProviderDescriptor teamContentDescriptor)
      {
        String name = teamContentDescriptor.getName();
        if ((name != null) && (!name.equals(""))) {
          return name;
        }
        String modelProviderID = teamContentDescriptor.getModelProviderId();
        IModelProviderDescriptor desc = ModelProvider.getModelProviderDescriptor(modelProviderID);
        if (desc != null) {
          return ModelEnablementPreferencePage.this.getLabel(desc);
        }
        return modelProviderID;
      }
      
      public Image getImage(Object element)
      {
        if ((element instanceof ITeamContentProviderDescriptor))
        {
          ITeamContentProviderDescriptor desc = (ITeamContentProviderDescriptor)element;
          Image image = (Image)images.get(desc);
          if (image == null)
          {
            ImageDescriptor idesc = desc.getImageDescriptor();
            if (idesc != null)
            {
              image = idesc.createImage();
              if (image != null) {
                images.put(desc, image);
              }
            }
          }
          return image;
        }
        return super.getImage(element);
      }
      
      public void dispose()
      {
        for (Iterator iter = images.values().iterator(); iter.hasNext();)
        {
          Image image = (Image)iter.next();
          image.dispose();
        }
        super.dispose();
      }
    });
    tableViewer.setComparator(new ViewerComparator()
    {
      public int compare(Viewer viewer, Object e1, Object e2)
      {
        if (((e1 instanceof ITeamContentProviderDescriptor)) && ((e2 instanceof ITeamContentProviderDescriptor)))
        {
          ITeamContentProviderDescriptor d1 = (ITeamContentProviderDescriptor)e1;
          ITeamContentProviderDescriptor d2 = (ITeamContentProviderDescriptor)e2;
          IModelProviderDescriptor md1 = ModelProvider.getModelProviderDescriptor(d1.getModelProviderId());
          IModelProviderDescriptor md2 = ModelProvider.getModelProviderDescriptor(d2.getModelProviderId());
          if ((md1 != null) && (md2 != null)) {
            return ModelEnablementPreferencePage.this.getLabel(md1).compareTo(ModelEnablementPreferencePage.this.getLabel(md2));
          }
        }
        return super.compare(viewer, e1, e2);
      }
    });
    tableViewer.setInput(TeamUI.getTeamContentProviderManager());
    updateChecks();
    applyDialogFont(composite);
    
    PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), "org.eclipse.team.ui.model_preference_page_context");
    
    return composite;
  }
  
  private void updateChecks()
  {
    ITeamContentProviderDescriptor[] descriptors = TeamUI.getTeamContentProviderManager().getDescriptors();
    for (int i = 0; i < descriptors.length; i++)
    {
      ITeamContentProviderDescriptor descriptor = descriptors[i];
      if (descriptor.isEnabled()) {
        previosulyEnabled.add(descriptor);
      }
    }
    tableViewer.setCheckedElements(previosulyEnabled.toArray());
  }
  
  public boolean performOk()
  {
    Object[] checked = tableViewer.getCheckedElements();
    Set nowEnabled = new HashSet();
    nowEnabled.addAll(Arrays.asList(checked));
    if (hasDescriptorEnablementChanged(checked))
    {
      TeamUI.getTeamContentProviderManager().setEnabledDescriptors(
        (ITeamContentProviderDescriptor[])nowEnabled.toArray(new ITeamContentProviderDescriptor[nowEnabled.size()]));
      previosulyEnabled = nowEnabled;
    }
    return true;
  }
  
  private boolean hasDescriptorEnablementChanged(Object[] checked)
  {
    ITeamContentProviderDescriptor[] descriptors = TeamUI.getTeamContentProviderManager().getDescriptors();
    for (int i = 0; i < descriptors.length; i++)
    {
      ITeamContentProviderDescriptor descriptor = descriptors[i];
      boolean enable = false;
      for (int j = 0; j < checked.length; j++)
      {
        ITeamContentProviderDescriptor checkedDesc = (ITeamContentProviderDescriptor)checked[j];
        if (checkedDesc.getModelProviderId().equals(descriptor.getModelProviderId()))
        {
          enable = true;
          break;
        }
      }
      if (descriptor.isEnabled() != enable) {
        return true;
      }
    }
    return false;
  }
  
  protected void performDefaults()
  {
    tableViewer.setCheckedElements(TeamUI.getTeamContentProviderManager().getDescriptors());
  }
  
  public void init(IWorkbench workbench) {}
  
  private String getLabel(IModelProviderDescriptor desc)
  {
    if (desc.getId().equals("org.eclipse.core.resources.modelProvider")) {
      try
      {
        return Utils.getLabel(desc.getModelProvider());
      }
      catch (CoreException e)
      {
        TeamUIPlugin.log(e);
      }
    }
    return desc.getLabel();
  }
}

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

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

class ModelSelectionDropDownAction$1
  implements IPropertyChangeListener
{
  final ModelSelectionDropDownAction this$0;
  
  ModelSelectionDropDownAction$1(ModelSelectionDropDownAction paramModelSelectionDropDownAction)
  {
    this$0 = paramModelSelectionDropDownAction;
  }
  
  public void propertyChange(PropertyChangeEvent event)
  {
    if (event.getProperty() == "org.eclipse.team.ui.activeModelProvider") {
      this$0.update();
    }
    if (event.getProperty().equals("org.eclipse.team.ui.ENABLED_MODEL_PROVIDERS")) {
      ModelSelectionDropDownAction.access$8(this$0);
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.team.internal.ui.mapping.ModelSelectionDropDownAction.1
 * 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.Action;
import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;

class ModelSelectionDropDownAction$2
  extends Action
{
  final ModelSelectionDropDownAction this$0;
  
  ModelSelectionDropDownAction$2(ModelSelectionDropDownAction paramModelSelectionDropDownAction, String $anonymous0, int $anonymous1)
  {
    super($anonymous0, $anonymous1);this$0 = paramModelSelectionDropDownAction;
  }
  
  public void run()
  {
    ModelSelectionDropDownAction.access$9(this$0).setProperty(
      "org.eclipse.team.ui.activeModelProvider", 
      "org.eclipse.team.ui.activeModelProvider");
  }
}

/* Location:
 * Qualified Name:     org.eclipse.team.internal.ui.mapping.ModelSelectionDropDownAction.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.Action;
import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;

class ModelSelectionDropDownAction$3
  extends Action
{
  final ModelSelectionDropDownAction this$0;
  
  ModelSelectionDropDownAction$3(ModelSelectionDropDownAction paramModelSelectionDropDownAction, String $anonymous0, int $anonymous1)
  {
    super($anonymous0, $anonymous1);this$0 = paramModelSelectionDropDownAction;
  }
  
  public void run()
  {
    boolean checked = ModelSelectionDropDownAction.access$4(this$0).isChecked();
    ModelSelectionDropDownAction.access$9(this$0).setProperty(
      "org.eclipse.team.ui.pageLayout", 
      checked ? "org.eclipse.team.ui.flatLayout" : "org.eclipse.team.ui.treeLayout");
  }
}

/* Location:
 * Qualified Name:     org.eclipse.team.internal.ui.mapping.ModelSelectionDropDownAction.3
 * 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.MenuManager;

class ModelSelectionDropDownAction$4
  implements Runnable
{
  final ModelSelectionDropDownAction this$0;
  
  ModelSelectionDropDownAction$4(ModelSelectionDropDownAction paramModelSelectionDropDownAction)
  {
    this$0 = paramModelSelectionDropDownAction;
  }
  
  public void run()
  {
    if (ModelSelectionDropDownAction.access$0(this$0) != null)
    {
      ModelSelectionDropDownAction.access$0(this$0).dispose();
      ModelSelectionDropDownAction.access$1(this$0, null);
    }
    this$0.update();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.team.internal.ui.mapping.ModelSelectionDropDownAction.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.resources.mapping.ModelProvider;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IMenuCreator;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Menu;

class ModelSelectionDropDownAction$MenuCreator
  implements IMenuCreator
{
  final ModelSelectionDropDownAction this$0;
  
  private ModelSelectionDropDownAction$MenuCreator(ModelSelectionDropDownAction paramModelSelectionDropDownAction)
  {
    this$0 = paramModelSelectionDropDownAction;
  }
  
  ModelSelectionDropDownAction$MenuCreator(ModelSelectionDropDownAction paramModelSelectionDropDownAction, MenuCreator paramMenuCreator)
  {
    this(paramModelSelectionDropDownAction);
  }
  
  public void dispose()
  {
    if (ModelSelectionDropDownAction.access$0(this$0) != null)
    {
      ModelSelectionDropDownAction.access$0(this$0).dispose();
      ModelSelectionDropDownAction.access$1(this$0, null);
    }
  }
  
  public Menu getMenu(Control parent)
  {
    Menu fMenu = null;
    if (ModelSelectionDropDownAction.access$0(this$0) == null)
    {
      ModelSelectionDropDownAction.access$1(this$0, new MenuManager());
      fMenu = ModelSelectionDropDownAction.access$0(this$0).createContextMenu(parent);
      ModelSelectionDropDownAction.access$0(this$0).add(ModelSelectionDropDownAction.access$2(this$0));
      ModelSelectionDropDownAction.access$2(this$0).setChecked(ModelSelectionDropDownAction.access$3(this$0).equals("org.eclipse.team.ui.activeModelProvider"));
      ModelSelectionDropDownAction.access$4(this$0).setChecked(ModelSelectionDropDownAction.access$5(this$0));
      ModelProvider[] modelProviders = ModelSelectionDropDownAction.access$6(this$0);
      if (modelProviders.length > 0) {
        ModelSelectionDropDownAction.access$0(this$0).add(new Separator());
      }
      ModelSelectionDropDownAction.access$7(this$0, modelProviders);
      ModelSelectionDropDownAction.access$0(this$0).add(new Separator());
      ModelSelectionDropDownAction.access$0(this$0).add(ModelSelectionDropDownAction.access$4(this$0));
      
      ModelSelectionDropDownAction.access$0(this$0).update(true);
    }
    else
    {
      fMenu = ModelSelectionDropDownAction.access$0(this$0).getMenu();
    }
    return fMenu;
  }
  
  public Menu getMenu(Menu parent)
  {
    return null;
  }
}

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

import java.util.HashSet;
import java.util.Set;
import org.eclipse.core.resources.mapping.IModelProviderDescriptor;
import org.eclipse.core.resources.mapping.ModelProvider;
import org.eclipse.core.resources.mapping.ResourceMapping;
import org.eclipse.core.resources.mapping.ResourceTraversal;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.ActionContributionItem;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IContributionItem;
import org.eclipse.jface.action.IMenuCreator;
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.osgi.util.NLS;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.team.core.mapping.ISynchronizationContext;
import org.eclipse.team.core.mapping.ISynchronizationScope;
import org.eclipse.team.core.mapping.ISynchronizationScopeChangeListener;
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.TeamImages;
import org.eclipse.team.ui.TeamUI;
import org.eclipse.team.ui.mapping.ITeamContentProviderDescriptor;
import org.eclipse.team.ui.mapping.ITeamContentProviderManager;
import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;
import org.eclipse.team.ui.synchronize.ModelMergeOperation;
import org.eclipse.team.ui.synchronize.ModelOperation;
import org.eclipse.team.ui.synchronize.ModelSynchronizeParticipant;

public class ModelSelectionDropDownAction
  extends Action
  implements ISynchronizationScopeChangeListener
{
  private final ISynchronizePageConfiguration configuration;
  private MenuManager menuManager;
  private Action showAllAction;
  private IPropertyChangeListener listener;
  private MenuCreator menuCreator;
  private Action showAllFlatAction;
  
  private class MenuCreator
    implements IMenuCreator
  {
    MenuCreator(MenuCreator paramMenuCreator)
    {
      this();
    }
    
    public void dispose()
    {
      if (menuManager != null)
      {
        menuManager.dispose();
        menuManager = null;
      }
    }
    
    public Menu getMenu(Control parent)
    {
      Menu fMenu = null;
      if (menuManager == null)
      {
        menuManager = new MenuManager();
        fMenu = menuManager.createContextMenu(parent);
        menuManager.add(showAllAction);
        showAllAction.setChecked(ModelSelectionDropDownAction.this.getActiveProviderId().equals("org.eclipse.team.ui.activeModelProvider"));
        showAllFlatAction.setChecked(ModelSelectionDropDownAction.this.isFlatEnabled());
        ModelProvider[] modelProviders = ModelSelectionDropDownAction.this.getEnabledModelProviders();
        if (modelProviders.length > 0) {
          menuManager.add(new Separator());
        }
        ModelSelectionDropDownAction.this.addModelsToMenu(modelProviders);
        menuManager.add(new Separator());
        menuManager.add(showAllFlatAction);
        
        menuManager.update(true);
      }
      else
      {
        fMenu = menuManager.getMenu();
      }
      return fMenu;
    }
    
    public Menu getMenu(Menu parent)
    {
      return null;
    }
    
    private MenuCreator() {}
  }
  
  public ModelSelectionDropDownAction(ISynchronizePageConfiguration configuration)
  {
    Utils.initAction(this, "action.pickModels.");
    this.configuration = configuration;
    listener = new IPropertyChangeListener()
    {
      public void propertyChange(PropertyChangeEvent event)
      {
        if (event.getProperty
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