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

ewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.StructuredViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.team.internal.ui.Utils;
import org.eclipse.team.internal.ui.synchronize.LocalResourceTypedElement;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.part.IPage;
import org.eclipse.ui.progress.IProgressService;

public abstract class PageCompareEditorInput
  extends CompareEditorInput
  implements IContentChangeListener
{
  private CompareViewerPane pagePane;
  private ICompareInput hookedInput;
  
  protected PageCompareEditorInput(CompareConfiguration configuration)
  {
    super(configuration);
  }
  
  protected CompareViewerPane createStructureInputPane(Composite parent)
  {
    pagePane = new CompareViewerPane(parent, 8390656)
    {
      public void selectionChanged(SelectionChangedEvent ev)
      {
        ISelection selection = ev.getSelection();
        StructuredSelection newSelection = convertSelection(selection, false);
        SelectionChangedEvent newEv = new SelectionChangedEvent(pagePane, newSelection);
        super.selectionChanged(newEv);
      }
      
      private StructuredSelection convertSelection(ISelection selection, boolean prepare)
      {
        ICompareInput ci = asCompareInput(selection);
        StructuredSelection newSelection;
        StructuredSelection newSelection;
        if (ci != null)
        {
          if (prepare) {
            prepareCompareInput(ci);
          }
          newSelection = new StructuredSelection(ci);
        }
        else
        {
          newSelection = StructuredSelection.EMPTY;
        }
        return newSelection;
      }
      
      public ISelection getSelection()
      {
        return convertSelection(getSelectionProvider().getSelection(), false);
      }
      
      public Object getInput()
      {
        return getCompareResult();
      }
      
      public void open(OpenEvent event)
      {
        ISelection selection = event.getSelection();
        StructuredSelection newSelection = convertSelection(selection, true);
        super.open(new OpenEvent((Viewer)event.getSource(), newSelection));
      }
      
      public void doubleClick(DoubleClickEvent event)
      {
        ISelection selection = event.getSelection();
        StructuredSelection newSelection = convertSelection(selection, true);
        super.doubleClick(new DoubleClickEvent((Viewer)event.getSource(), newSelection));
      }
      
      public void setInput(Object input)
      {
        super.setInput(input);
        Composite c = getParent();
        if ((c instanceof Splitter)) {
          ((Splitter)c).setVisible(this, true);
        }
        layout(true);
      }
    };
    ToolBarManager toolBarManager = CompareViewerPane.getToolBarManager(pagePane);
    IPage page = createPage(pagePane, toolBarManager);
    pagePane.setContent(page.getControl());
    if ((parent instanceof Splitter)) {
      ((Splitter)parent).setVisible(pagePane, false);
    }
    hookupListeners();
    return pagePane;
  }
  
  protected abstract IPage createPage(CompareViewerPane paramCompareViewerPane, IToolBarManager paramIToolBarManager);
  
  protected abstract ISelectionProvider getSelectionProvider();
  
  protected void setPageDescription(String title)
  {
    pagePane.setText(title);
  }
  
  protected void handleDispose()
  {
    super.handleDispose();
    cleanupListeners();
    unhookContentChangeListener();
  }
  
  private void hookupListeners()
  {
    ISelectionProvider selectionProvider = getSelectionProvider();
    if (selectionProvider != null) {
      selectionProvider.addSelectionChangedListener(pagePane);
    }
    if ((selectionProvider instanceof StructuredViewer))
    {
      StructuredViewer sv = (StructuredViewer)selectionProvider;
      sv.addOpenListener(pagePane);
      sv.addDoubleClickListener(pagePane);
    }
  }
  
  private void cleanupListeners()
  {
    ISelectionProvider selectionProvider = getSelectionProvider();
    if (selectionProvider != null) {
      selectionProvider.removeSelectionChangedListener(pagePane);
    }
    if ((selectionProvider instanceof StructuredViewer))
    {
      StructuredViewer sv = (StructuredViewer)selectionProvider;
      sv.removeOpenListener(pagePane);
      sv.removeDoubleClickListener(pagePane);
    }
  }
  
  private void hookContentChangeListener(ICompareInput node)
  {
    if (hookedInput == node) {
      return;
    }
    unhookContentChangeListener();
    hookedInput = node;
    ITypedElement left = node.getLeft();
    if ((left instanceof IContentChangeNotifier)) {
      ((IContentChangeNotifier)left).addContentChangeListener(this);
    }
    ITypedElement right = node.getRight();
    if ((right instanceof IContentChangeNotifier)) {
      ((IContentChangeNotifier)right).addContentChangeListener(this);
    }
  }
  
  private void unhookContentChangeListener()
  {
    if (hookedInput != null)
    {
      ITypedElement left = hookedInput.getLeft();
      if ((left instanceof IContentChangeNotifier)) {
        ((IContentChangeNotifier)left).addContentChangeListener(this);
      }
      ITypedElement right = hookedInput.getRight();
      if ((right instanceof IContentChangeNotifier)) {
        ((IContentChangeNotifier)right).addContentChangeListener(this);
      }
    }
  }
  
  protected ICompareInput asCompareInput(ISelection selection)
  {
    if ((selection != null) && ((selection instanceof IStructuredSelection)))
    {
      IStructuredSelection ss = (IStructuredSelection)selection;
      if (ss.size() == 1)
      {
        Object o = ss.getFirstElement();
        if ((o instanceof ICompareInput)) {
          return (ICompareInput)o;
        }
      }
    }
    return null;
  }
  
  protected final void prepareCompareInput(ICompareInput input)
  {
    if (input == null) {
      return;
    }
    Object left = input.getLeft();
    if ((left instanceof LocalResourceTypedElement))
    {
      LocalResourceTypedElement lrte = (LocalResourceTypedElement)left;
      lrte.enableSharedDocument(false);
    }
    IProgressService manager = PlatformUI.getWorkbench().getProgressService();
    try
    {
      manager.busyCursorWhile(new IRunnableWithProgress()
      {
        private final ICompareInput val$input;
        
        public void run(IProgressMonitor monitor)
          throws InvocationTargetException, InterruptedException
        {
          prepareInput(val$input, getCompareConfiguration(), monitor);
          PageCompareEditorInput.this.hookContentChangeListener(val$input);
        }
      });
    }
    catch (InvocationTargetException e)
    {
      Utils.handle(e);
    }
    catch (InterruptedException localInterruptedException) {}
  }
  
  public void contentChanged(IContentChangeNotifier source)
  {
    setDirty(true);
  }
  
  public boolean canRunAsJob()
  {
    return true;
  }
  
  protected abstract void prepareInput(ICompareInput paramICompareInput, CompareConfiguration paramCompareConfiguration, IProgressMonitor paramIProgressMonitor)
    throws InvocationTargetException;
}

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

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

class PageSaveablePart$1
  implements IPropertyChangeListener
{
  final PageSaveablePart this$0;
  
  PageSaveablePart$1(PageSaveablePart paramPageSaveablePart)
  {
    this$0 = paramPageSaveablePart;
  }
  
  public void propertyChange(PropertyChangeEvent e)
  {
    String propertyName = e.getProperty();
    if ("DIRTY_STATE".equals(propertyName))
    {
      boolean changed = false;
      Object newValue = e.getNewValue();
      if ((newValue instanceof Boolean)) {
        changed = ((Boolean)newValue).booleanValue();
      }
      PageSaveablePart.access$0(this$0, e.getSource(), changed);
    }
  }
}

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

import org.eclipse.compare.CompareViewerSwitchingPane;
import org.eclipse.compare.structuremergeviewer.ICompareInput;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.widgets.Composite;

class PageSaveablePart$2
  extends CompareViewerSwitchingPane
{
  final PageSaveablePart this$0;
  
  PageSaveablePart$2(PageSaveablePart paramPageSaveablePart, Composite $anonymous0, int $anonymous1, boolean $anonymous2)
  {
    super($anonymous0, $anonymous1, $anonymous2);this$0 = paramPageSaveablePart;
  }
  
  protected Viewer getViewer(Viewer oldViewer, Object input)
  {
    if ((input instanceof ICompareInput)) {
      return PageSaveablePart.access$1(this$0, this, oldViewer, (ICompareInput)input);
    }
    return null;
  }
}

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

import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.SelectionChangedEvent;

class PageSaveablePart$3
  implements ISelectionChangedListener
{
  final PageSaveablePart this$0;
  
  PageSaveablePart$3(PageSaveablePart paramPageSaveablePart)
  {
    this$0 = paramPageSaveablePart;
  }
  
  public void selectionChanged(SelectionChangedEvent e)
  {
    PageSaveablePart.access$2(this$0, e.getSelection());
  }
}

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

import org.eclipse.compare.CompareViewerSwitchingPane;
import org.eclipse.compare.IPropertyChangeNotifier;
import org.eclipse.compare.structuremergeviewer.ICompareInput;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;

class PageSaveablePart$4
  extends CompareViewerSwitchingPane
{
  final PageSaveablePart this$0;
  
  PageSaveablePart$4(PageSaveablePart paramPageSaveablePart, Composite $anonymous0, int $anonymous1)
  {
    super($anonymous0, $anonymous1);this$0 = paramPageSaveablePart;
  }
  
  protected Viewer getViewer(Viewer oldViewer, Object input)
  {
    if (!(input instanceof ICompareInput)) {
      return null;
    }
    Viewer newViewer = PageSaveablePart.access$3(this$0, this, oldViewer, (ICompareInput)input);
    boolean isNewViewer = newViewer != oldViewer;
    if ((isNewViewer) && ((newViewer instanceof IPropertyChangeNotifier)))
    {
      IPropertyChangeNotifier dsp = (IPropertyChangeNotifier)newViewer;
      dsp.addPropertyChangeListener(PageSaveablePart.access$4(this$0));
      Control c = newViewer.getControl();
      c.addDisposeListener(
        new PageSaveablePart.5(this, dsp));
      
      PageSaveablePart.access$5(this$0, (ICompareInput)input);
    }
    return newViewer;
  }
}

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

import org.eclipse.compare.IPropertyChangeNotifier;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;

class PageSaveablePart$5
  implements DisposeListener
{
  final PageSaveablePart.4 this$1;
  private final IPropertyChangeNotifier val$dsp;
  
  PageSaveablePart$5(PageSaveablePart.4 param4, IPropertyChangeNotifier paramIPropertyChangeNotifier)
  {
    this$1 = param4;val$dsp = paramIPropertyChangeNotifier;
  }
  
  public void widgetDisposed(DisposeEvent e)
  {
    val$dsp.removePropertyChangeListener(PageSaveablePart.access$4(PageSaveablePart.4.access$0(this$1)));
  }
}

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

import org.eclipse.compare.structuremergeviewer.ICompareInput;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.SelectionChangedEvent;

class PageSaveablePart$6
  implements ISelectionChangedListener
{
  final PageSaveablePart this$0;
  
  PageSaveablePart$6(PageSaveablePart paramPageSaveablePart)
  {
    this$0 = paramPageSaveablePart;
  }
  
  public void selectionChanged(SelectionChangedEvent event)
  {
    ICompareInput input = this$0.getCompareInput(event.getSelection());
    if (input != null) {
      this$0.prepareCompareInput(input);
    }
    PageSaveablePart.access$6(this$0, input);
  }
}

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

import java.lang.reflect.InvocationTargetException;
import org.eclipse.compare.structuremergeviewer.ICompareInput;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.operation.IRunnableWithProgress;

class PageSaveablePart$7
  implements IRunnableWithProgress
{
  final PageSaveablePart this$0;
  private final ICompareInput val$input;
  
  PageSaveablePart$7(PageSaveablePart paramPageSaveablePart, ICompareInput paramICompareInput)
  {
    this$0 = paramPageSaveablePart;val$input = paramICompareInput;
  }
  
  public void run(IProgressMonitor monitor)
    throws InvocationTargetException, InterruptedException
  {
    this$0.prepareInput(val$input, PageSaveablePart.access$7(this$0), monitor);
    PageSaveablePart.access$5(this$0, val$input);
  }
}

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

import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Iterator;
import org.eclipse.compare.CompareConfiguration;
import org.eclipse.compare.CompareUI;
import org.eclipse.compare.CompareViewerPane;
import org.eclipse.compare.CompareViewerSwitchingPane;
import org.eclipse.compare.IContentChangeListener;
import org.eclipse.compare.IContentChangeNotifier;
import org.eclipse.compare.IPropertyChangeNotifier;
import org.eclipse.compare.ITypedElement;
import org.eclipse.compare.Splitter;
import org.eclipse.compare.contentmergeviewer.IFlushable;
import org.eclipse.compare.internal.CompareEditorInputNavigator;
import org.eclipse.compare.structuremergeviewer.ICompareInput;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.action.ToolBarManager;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.Viewer;
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.Shell;
import org.eclipse.team.internal.ui.TeamUIMessages;
import org.eclipse.team.internal.ui.Utils;
import org.eclipse.team.internal.ui.synchronize.LocalResourceTypedElement;
import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.progress.IProgressService;

/**
 * @deprecated
 */
public abstract class PageSaveablePart
  extends SaveablePartAdapter
  implements IContentChangeListener
{
  private CompareConfiguration cc;
  Shell shell;
  private boolean fDirty = false;
  private ArrayList fDirtyViewers = new ArrayList();
  private IPropertyChangeListener fDirtyStateListener;
  private CompareViewerSwitchingPane fContentPane;
  private CompareViewerPane fEditionPane;
  private CompareViewerSwitchingPane fStructuredComparePane;
  private Control control;
  private boolean showContentPanes = true;
  
  protected PageSaveablePart(Shell shell, CompareConfiguration compareConfiguration)
  {
    this.shell = shell;
    cc = compareConfiguration;
    
    fDirtyStateListener = new IPropertyChangeListener()
    {
      public void propertyChange(PropertyChangeEvent e)
      {
        String propertyName = e.getProperty();
        if ("DIRTY_STATE".equals(propertyName))
        {
          boolean changed = false;
          Object newValue = e.getNewValue();
          if ((newValue instanceof Boolean)) {
            changed = ((Boolean)newValue).booleanValue();
          }
          PageSaveablePart.this.setDirty(e.getSource(), changed);
        }
      }
    };
  }
  
  public boolean isDirty()
  {
    return (fDirty) || (fDirtyViewers.size() > 0);
  }
  
  public void createPartControl(Composite parent)
  {
    Composite composite = new Composite(parent, 0);
    GridLayout layout = new GridLayout();
    marginHeight = 0;
    marginWidth = 0;
    verticalSpacing = 0;
    GridData data = new GridData(1808);
    grabExcessHorizontalSpace = true;
    composite.setLayout(layout);
    composite.setLayoutData(data);
    
    shell = parent.getShell();
    
    Splitter vsplitter = new Splitter(composite, 512);
    vsplitter.setLayoutData(new GridData(1808));
    
    Splitter hsplitter = new Splitter(vsplitter, 256);
    fEditionPane = new CompareViewerPane(hsplitter, 8390656);
    fStructuredComparePane = new CompareViewerSwitchingPane(hsplitter, 8390656, true)
    {
      protected Viewer getViewer(Viewer oldViewer, Object input)
      {
        if ((input instanceof ICompareInput)) {
          return PageSaveablePart.this.findStructureViewer(this, oldViewer, (ICompareInput)input);
        }
        return null;
      }
    };
    fStructuredComparePane.addSelectionChangedListener(new ISelectionChangedListener()
    {
      public void selectionChanged(SelectionChangedEvent e)
      {
        PageSaveablePart.this.feedInput2(e.getSelection());
      }
    });
    fEditionPane.setText(TeamUIMessages.ParticipantPageSaveablePart_0);
    fContentPane = new CompareViewerSwitchingPane(vsplitter, 8390656)
    {
      protected Viewer getViewer(Viewer oldViewer, Object input)
      {
        if (!(input instanceof ICompareInput)) {
          return null;
        }
        Viewer newViewer = PageSaveablePart.this.findContentViewer(this, oldViewer, (ICompareInput)input);
        boolean isNewViewer = newViewer != oldViewer;
        if ((isNewViewer) && ((newViewer instanceof IPropertyChangeNotifier)))
        {
          IPropertyChangeNotifier dsp = (IPropertyChangeNotifier)newViewer;
          dsp.addPropertyChangeListener(fDirtyStateListener);
          Control c = newViewer.getControl();
          c.addDisposeListener(
            new PageSaveablePart.5(this, dsp));
          
          PageSaveablePart.this.hookContentChangeListener((ICompareInput)input);
        }
        return newViewer;
      }
    };
    vsplitter.setWeights(new int[] { 30, 70 });
    
    control = composite;
    
    ToolBarManager toolBarManager = CompareViewerPane.getToolBarManager(fEditionPane);
    Control c = createPage(fEditionPane, toolBarManager);
    fEditionPane.setContent(c);
    if (!showContentPanes) {
      hsplitter.setMaximizedControl(fEditionPane);
    }
    getSelectionProvider().addSelectionChangedListener(new ISelectionChangedListener()
    {
      public void selectionChanged(SelectionChangedEvent event)
      {
        ICompareInput input = getCompareInput(event.getSelection());
        if (input != null) {
          prepareCompareInput(input);
        }
        PageSaveablePart.this.setInput(input);
      }
    });
  }
  
  protected abstract ISelectionProvider getSelectionProvider();
  
  protected abstract Control createPage(Composite paramComposite, ToolBarManager paramToolBarManager);
  
  protected void setPageDescription(String title)
  {
    fEditionPane.setText(title);
  }
  
  protected void setDirty(boolean dirty)
  {
    boolean confirmSave = true;
    Object o = cc.getProperty("org.eclipse.compare.internal.CONFIRM_SAVE_PROPERTY");
    if ((o instanceof Boolean)) {
      confirmSave = ((Boolean)o).booleanValue();
    }
    if (!confirmSave)
    {
      fDirty = dirty;
      if (!fDirty) {
        fDirtyViewers.clear();
      }
    }
  }
  
  private void setDirty(Object source, boolean dirty)
  {
    Assert.isNotNull(source);
    if (dirty) {
      fDirtyViewers.add(source);
    } else {
      fDirtyViewers.remove(source);
    }
  }
  
  private void setInput(Object input)
  {
    CompareViewerPane pane = fContentPane;
    if ((pane != null) && (!pane.isDisposed())) {
      fContentPane.setInput(input);
    }
    if ((fStructuredComparePane != null) && (!fStructuredComparePane.isDisposed())) {
      fStructuredComparePane.setInput(input);
    }
  }
  
  private void feedInput2(ISelection sel)
  {
    ICompareInput input = getCompareInput(sel);
    prepareCompareInput(input);
    if (input != null) {
      fContentPane.setInput(input);
    }
  }
  
  protected void prepareCompareInput(ICompareInput input)
  {
    if (input == null) {
      return;
    }
    Object left = input.getLeft();
    if ((left instanceof LocalResourceTypedElement))
    {
      LocalResourceTypedElement lrte = (LocalResourceTypedElement)left;
      lrte.enableSharedDocument(false);
    }
    IProgressService manager = PlatformUI.getWorkbench().getProgressService();
    try
    {
      manager.busyCursorWhile(new IRunnableWithProgress()
      {
        private final ICompareInput val$input;
        
        public void run(IProgressMonitor monitor)
          throws InvocationTargetException, InterruptedException
        {
          prepareInput(val$input, PageSaveablePart.this.getCompareConfiguration(), monitor);
          PageSaveablePart.this.hookContentChangeListener(val$input);
        }
      });
    }
    catch (InvocationTargetException e)
    {
      Utils.handle(e);
    }
    catch (InterruptedException localInterruptedException) {}
  }
  
  protected abstract void prepareInput(ICompareInput paramICompareInput, CompareConfiguration paramCompareConfiguration, IProgressMonitor paramIProgressMonitor)
    throws InvocationTargetException;
  
  private void hookContentChangeListener(ICompareInput node)
  {
    ITypedElement left = node.getLeft();
    if ((left instanceof IContentChangeNotifier)) {
      ((IContentChangeNotifier)left).addContentChangeListener(this);
    }
    ITypedElement right = node.getRight();
    if ((right instanceof IContentChangeNotifier)) {
      ((IContentChangeNotifier)right).addContentChangeListener(this);
    }
  }
  
  protected Shell getShell()
  {
    return shell;
  }
  
  protected void setNavigator(ISynchronizePageConfiguration configuration)
  {
    configuration.setProperty("org.eclipse.team.ui.P_NAVIGATOR", new CompareEditorInputNavigator(
      new Object[] {
      configuration.getProperty("org.eclipse.team.ui.P_ADVISOR"), 
      fStructuredComparePane, 
      fContentPane }));
  }
  
  private Viewer findStructureViewer(Composite parent, Viewer oldViewer, ICompareInput input)
  {
    return CompareUI.findStructureViewer(oldViewer, input, parent, cc);
  }
  
  private Viewer findContentViewer(Composite parent, Viewer oldViewer, ICompareInput input)
  {
    return CompareUI.findContentViewer(oldViewer, input, parent, cc);
  }
  
  protected ICompareInput getCompareInput(ISelection selection)
  {
    if ((selection != null) && ((selection instanceof IStructuredSelection)))
    {
      IStructuredSelection ss = (IStructuredSelection)selection;
      if (ss.size() == 1)
      {
        Object o = ss.getFirstElement();
        if ((o instanceof ICompareInput)) {
          return (ICompareInput)o;
        }
      }
    }
    return null;
  }
  
  public void setShowContentPanes(boolean showContentPanes)
  {
    this.showContentPanes = showContentPanes;
  }
  
  public Control getControl()
  {
    return control;
  }
  
  private CompareConfiguration getCompareConfiguration()
  {
    return cc;
  }
  
  public void doSave(IProgressMonitor monitor)
  {
    flushViewers(monitor);
  }
  
  private void flushViewers(IProgressMonitor monitor)
  {
    Iterator iter = fDirtyViewers.iterator();
    for (int i = 0; i < fDirtyViewers.size(); i++)
    {
      Object element = iter.next();
      IFlushable flushable = (IFlushable)Utils.getAdapter(element, IFlushable.class);
      if (flushable != null) {
        flushable.flush(monitor);
      }
    }
  }
}

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

import org.eclipse.ui.IPropertyListener;
import org.eclipse.ui.IWorkbenchPartSite;

/**
 * @deprecated
 */
public abstract class SaveablePartAdapter
  implements ISaveableWorkbenchPart
{
  public void doSaveAs() {}
  
  public boolean isSaveAsAllowed()
  {
    return false;
  }
  
  public boolean isSaveOnCloseNeeded()
  {
    return false;
  }
  
  public void addPropertyListener(IPropertyListener listener) {}
  
  public void dispose() {}
  
  public IWorkbenchPartSite getSite()
  {
    return null;
  }
  
  public String getTitleToolTip()
  {
    return null;
  }
  
  public void removePropertyListener(IPropertyListener listener) {}
  
  public void setFocus() {}
  
  public Object getAdapter(Class adapter)
  {
    return null;
  }
}

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

import org.eclipse.core.runtime.NullProgressMonitor;

class SaveablePartDialog$1
  implements Runnable
{
  final SaveablePartDialog this$0;
  
  SaveablePartDialog$1(SaveablePartDialog paramSaveablePartDialog)
  {
    this$0 = paramSaveablePartDialog;
  }
  
  public void run()
  {
    SaveablePartDialog.access$0(this$0).doSave(new NullProgressMonitor());
  }
}

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

import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.dialogs.TrayDialog;
import org.eclipse.swt.custom.BusyIndicator;
import org.eclipse.swt.graphics.Point;
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.TeamUIPlugin;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.help.IWorkbenchHelpSystem;

/**
 * @deprecated
 */
public class SaveablePartDialog
  extends TrayDialog
{
  private ISaveableWorkbenchPart input;
  private String fContextId;
  private boolean hasSettings = true;
  
  public SaveablePartDialog(Shell shell, ISaveableWorkbenchPart input)
  {
    super(shell);
    setShellStyle(getShellStyle() | 0x10 | 0x400);
    this.input = input;
  }
  
  protected void createButtonsForButtonBar(Composite parent)
  {
    createButton(parent, 0, IDialogConstants.OK_LABEL, true);
  }
  
  protected Control createDialogArea(Composite parent2)
  {
    Composite parent = (Composite)super.createDialogArea(parent2);
    input.createPartControl(parent);
    Shell shell = getShell();
    shell.setText(input.getTitle());
    shell.setImage(input.getTitleImage());
    Dialog.applyDialogFont(parent2);
    return parent;
  }
  
  public boolean close()
  {
    saveChanges();
    return super.close();
  }
  
  private void saveChanges()
  {
    MessageDialog dialog = new MessageDialog(
      getShell(), TeamUIMessages.ParticipantCompareDialog_2, null, 
      TeamUIMessages.ParticipantCompareDialog_3, 3, new String[] { IDialogConstants.YES_LABEL, 
      IDialogConstants.NO_LABEL }, 0);
    if ((input.isDirty()) && (dialog.open() == 0)) {
      BusyIndicator.showWhile(null, new Runnable()
      {
        public void run()
        {
          input.doSave(new NullProgressMonitor());
        }
      });
    }
  }
  
  protected ISaveableWorkbenchPart getInput()
  {
    return input;
  }
  
  protected IDialogSettings getDialogBoundsSettings()
  {
    IDialogSettings compareSettings = TeamUIPlugin.getPlugin().getDialogSettings();
    String sectionName = getClass().getName();
    IDialogSettings dialogSettings = compareSettings.getSection(sectionName);
    if (dialogSettings == null)
    {
      hasSettings = false;
      dialogSettings = compareSettings.addNewSection(sectionName);
    }
    return dialogSettings;
  }
  
  public void setHelpContextId(String contextId)
  {
    fContextId = contextId;
  }
  
  protected void configureShell(Shell newShell)
  {
    super.configureShell(newShell);
    if (fContextId != null) {
      PlatformUI.getWorkbench().getHelpSystem().setHelp(newShell, fContextId);
    }
  }
  
  protected Point getInitialSize()
  {
    Point initialSize = super.getInitialSize();
    if (hasSettings) {
      return initialSize;
    }
    int width = 0;
    int height = 0;
    Shell shell = getParentShell();
    if (shell != null)
    {
      Point parentSize = shell.getSize();
      width = x - 100;
      height = y - 100;
    }
    if (width < 700) {
      width = 700;
    }
    if (height < 500) {
      height = 500;
    }
    return new Point(width, height);
  }
}

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

import org.eclipse.core.runtime.IExtension;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.team.internal.ui.TeamUIPlugin;

public class TeamImages
{
  public static ImageDescriptor getImageDescriptor(String id)
  {
    return TeamUIPlugin.getImageDescriptor(id);
  }
  
  public static ImageDescriptor getImageDescriptorFromExtension(IExtension extension, String subdirectoryAndFilename)
  {
    return TeamUIPlugin.getImageDescriptorFromExtension(extension, subdirectoryAndFilename);
  }
}

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

import org.eclipse.swt.widgets.Shell;
import org.eclipse.team.internal.ui.Utils;

class TeamOperation$1
  implements Runnable
{
  final TeamOperation this$0;
  private final Shell[] val$shell;
  
  TeamOperation$1(TeamOperation paramTeamOperation, Shell[] paramArrayOfShell)
  {
    this$0 = paramTeamOperation;val$shell = paramArrayOfShell;
  }
  
  public void run()
  {
    val$shell[0] = Utils.getShell(TeamOperation.access$0(this$0));
  }
}

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

import java.net.URL;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.team.internal.ui.actions.JobRunnableContext;
import org.eclipse.team.internal.ui.actions.JobRunnableContext.IContextJob;
import org.eclipse.ui.progress.IProgressConstants;

class TeamOperation$TeamOperationJobContext
  extends JobRunnableContext
{
  private final TeamOperation operation;
  private IAction gotoAction;
  
  public TeamOperation$TeamOperationJobContext(TeamOperation operation)
  {
    super(operation.getJobName(), operation, TeamOperation.access$0(operation));
    this.operation = operation;
  }
  
  protected void configureJob(Job job)
  {
    super.configureJob(job);
    if (operation.isKeepOneProgressServiceEntry()) {
      job.setProperty(IProgressConstants.KEEPONE_PROPERTY, Boolean.TRUE);
    } else if (operation.getKeepOperation()) {
      job.setProperty(IProgressConstants.KEEP_PROPERTY, Boolean.TRUE);
    }
    gotoAction = operation.getGotoAction();
    if (gotoAction != null) {
      job.setProperty(IProgressConstants.ACTION_PROPERTY, gotoAction);
    }
    URL icon = operation.getOperationIcon();
    if (icon != null) {
      job.setProperty(IProgressConstants.ICON_PROPERTY, icon);
    }
  }
  
  protected boolean belongsTo(JobRunnableContext.IContextJob job, Object family)
  {
    if ((family instanceof JobRunnableContext.IContextJob))
    {
      JobRunnableContext.IContextJob otherJob = (JobRunnableContext.IContextJob)family;
      IRunnableWithProgress runnable = otherJob.getRunnable();
      if ((runnable instanceof TeamOperation)) {
        return operation.isSameFamilyAs((TeamOperation)runnable);
      }
    }
    return operation.belongsTo(family);
  }
  
  protected IStatus getCompletionStatus()
  {
    if (gotoAction != null) {
      return new Status(0, "org.eclipse.team.ui", 0, gotoAction.getText(), null);
    }
    return super.getCompletionStatus();
  }
  
  protected boolean isUser()
  {
    return operation.isUserInitiated();
  }
}

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

import java.lang.reflect.InvocationTargetException;
import java.net.URL;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.ISchedulingRule;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.core.runtime.jobs.JobChangeAdapter;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.operation.IRunnableContext;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.team.internal.ui.Utils;
import org.eclipse.team.internal.ui.actions.ITeamRunnableContext;
import org.eclipse.team.internal.ui.actions.JobRunnableContext;
import org.eclipse.team.internal.ui.actions.JobRunnableContext.IContextJob;
import org.eclipse.team.internal.ui.actions.ProgressDialogRunnableContext;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchSite;
import org.eclipse.ui.progress.IProgressConstants;

public abstract class TeamOperation
  extends JobChangeAdapter
  implements IRunnableWithProgress
{
  private IWorkbenchPart part;
  private IRunnableContext context;
  
  private static class TeamOperationJobContext
    extends JobRunnableContext
  {
    private final TeamOperation operation;
    private IAction gotoAction;
    
    public TeamOperationJobContext(TeamOperation operation)
    {
      super(operation, operation.getSite());
      this.operation = operation;
    }
    
    protected void configureJob(Job job)
    {
      super.configureJob(job);
      if (operation.isKeepOneProgressServiceEntry()) {
        job.setProperty(IProgressConstants.KEEPONE_PROPERTY, Boolean.TRUE);
      } else if (operation.getKeepOperation()) {
        job.setProperty(IProgressConstants.KEEP_PROPERTY, Boolean.TRUE);
      }
      gotoAction = operation.getGotoAction();
      if (gotoAction != null) {
        job.setProperty(IProgressConstants.ACTION_PROPERTY, gotoAction);
      }
      URL icon = operation.getOperationIcon();
      if (icon != null) {
        job.setProperty(IProgressConstants.ICON_PROPERTY, icon);
      }
    }
    
    protected boolean belongsTo(JobRunnableContext.IContextJob job, Object family)
    {
      if ((family instanceof JobRunnableContext.IContextJob))
      {
        JobRunnableContext.IContextJob otherJob = (JobRunnableContext.IContextJob)family;
        IRunnableWithProgress runnable = otherJob.getRunnable();
        if ((runnable instanceof TeamOperation)) {
          return operation.isSameFamilyAs((TeamOperation)runnable);
        }
      }
      return operation.belongsTo(family);
    }
    
    protected IStatus getCompletionStatus()
    {
      if (gotoAction != null) {
        return new Status(0, "org.eclipse.team.ui", 0, gotoAction.getText(), null);
      }
      return super.getCompletionStatus();
    }
    
    protected boolean isUser()
    {
      return operation.isUserInitiated();
    }
  }
  
  protected TeamOperation(IWorkbenchPart part)
  {
    this(part, null);
  }
  
  protected TeamOperation(IRunnableContext context)
  {
    this(null, context);
  }
  
  protected TeamOperation(IWorkbenchPart part, IRunnableContext context)
  {
    this.part = part;
    this.context = context;
  }
  
  public IWorkbenchPart getPart()
  {
    return part;
  }
  
  public final void run()
    throws InvocationTargetException, InterruptedException
  {
    if (shouldRun()) {
      getRunnableContext().run(this);
    }
  }
  
  protected boolean shouldRun()
  {
    return true;
  }
  
  protected ISchedulingRule getSchedulingRule()
  {
    return null;
  }
  
  protected boolean isPostponeAutobuild()
  {
    return true;
  }
  
  protected boolean canRunAsJob()
  {
    return false;
  }
  
  protected String getJobName()
  {
    return "";
  }
  
  protected IAction getGotoAction()
  {
    return null;
  }
  
  protected URL getOperationIcon()
  {
    return null;
  }
  
  protected boolean getKeepOperation()
  {
    return false;
  }
  
  public boolean isKeepOneProgressServiceEntry()
  {
    return false;
  }
  
  protected boolean isSameFamilyAs(TeamOperation operation)
  {
    return false;
  }
  
  public boolean belongsTo(Object family)
  {
    return false;
  }
  
  public boolean isUserInitiated()
  {
    return true;
  }
  
  protected Shell getShell()
  {
    Shell[] shell = new Shell[1];
    if (Display.getCurrent() == null) {
      Display.getDefault().syncExec(new Runnable()
      {
        private final Shell[] val$shell;
        
        public void run()
        {
          val$shell[0] = Utils.getShell(TeamOperation.this.getSite());
        }
      });
    } else {
      shell[0] = Utils.getShell(getSite());
    }
    return shell[0];
  }
  
  private ITeamRunnableContext getRunnableContext()
  {
    if ((this.context == null) && (canRunAsJob()))
    {
      JobRunnableContext context = new TeamOperationJobContext(this);
      context.setPostponeBuild(isPostponeAutobuild());
      context.setSchedulingRule(getSchedulingRule());
      return context;
    }
    ProgressDialogRunnableContext context = new ProgressDialogRunnableContext();
    context.setPostponeBuild(isPostponeAutobuild());
    context.setSchedulingRule(getSchedulingRule());
    if (this.context != null) {
      context.setRunnableContext(this.context);
    }
    return context;
  }
  
  private IWorkbenchSite getSite()
  {
    IWorkbenchSite site = null;
    if (part != null) {
      site = part.getSite();
    }
    return site;
  }
}

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

import java.net.URI;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.team.core.RepositoryProviderType;
import org.eclipse.team.core.ScmUrlImportDescription;
import org.eclipse.team.internal.ui.TeamUIPlugin;
import org.eclipse.team.internal.ui.history.GenericHistoryView;
import org.eclipse.team.internal.ui.registry.TeamConte
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