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

rt org.eclipse.jface.action.IAction;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.swt.custom.BusyIndicator;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.team.core.RepositoryProvider;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.internal.core.TeamPlugin;
import org.eclipse.team.internal.ui.TeamUIMessages;
import org.eclipse.team.internal.ui.TeamUIPlugin;
import org.eclipse.team.internal.ui.Utils;
import org.eclipse.ui.IActionDelegate2;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IObjectActionDelegate;
import org.eclipse.ui.IPartListener2;
import org.eclipse.ui.ISelectionListener;
import org.eclipse.ui.ISelectionService;
import org.eclipse.ui.IViewActionDelegate;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchPartReference;
import org.eclipse.ui.IWorkbenchPartSite;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.handlers.HandlerUtil;
import org.eclipse.ui.ide.ResourceUtil;

public abstract class TeamAction
  extends AbstractHandler
  implements IObjectActionDelegate, IViewActionDelegate, IWorkbenchWindowActionDelegate, IActionDelegate2
{
  private IStructuredSelection selection;
  private Shell shell;
  public static final int PROGRESS_DIALOG = 1;
  public static final int PROGRESS_BUSYCURSOR = 2;
  private IWorkbenchPart targetPart;
  private IWorkbenchWindow window;
  private IPartListener2 targetPartListener = new IPartListener2()
  {
    public void partActivated(IWorkbenchPartReference partRef) {}
    
    public void partBroughtToTop(IWorkbenchPartReference partRef) {}
    
    public void partClosed(IWorkbenchPartReference partRef)
    {
      if (targetPart == partRef.getPart(false)) {
        targetPart = null;
      }
    }
    
    public void partDeactivated(IWorkbenchPartReference partRef) {}
    
    public void partHidden(IWorkbenchPartReference partRef) {}
    
    public void partInputChanged(IWorkbenchPartReference partRef) {}
    
    public void partOpened(IWorkbenchPartReference partRef) {}
    
    public void partVisible(IWorkbenchPartReference partRef) {}
  };
  private ISelectionListener selectionListener = new ISelectionListener()
  {
    public void selectionChanged(IWorkbenchPart part, ISelection selection)
    {
      if ((selection instanceof IStructuredSelection)) {
        TeamAction.this.selection = ((IStructuredSelection)selection);
      }
    }
  };
  
  public static Object[] getSelectedAdaptables(ISelection selection, Class c)
  {
    ArrayList result = null;
    if ((selection != null) && (!selection.isEmpty()))
    {
      result = new ArrayList();
      Iterator elements = ((IStructuredSelection)selection).iterator();
      while (elements.hasNext())
      {
        Object adapter = getAdapter(elements.next(), c);
        if (c.isInstance(adapter)) {
          result.add(adapter);
        }
      }
    }
    if ((result != null) && (!result.isEmpty())) {
      return result.toArray((Object[])Array.newInstance(c, result.size()));
    }
    return (Object[])Array.newInstance(c, 0);
  }
  
  public static Object getAdapter(Object adaptable, Class c)
  {
    if (c.isInstance(adaptable)) {
      return adaptable;
    }
    if ((adaptable instanceof IAdaptable))
    {
      IAdaptable a = (IAdaptable)adaptable;
      Object adapter = a.getAdapter(c);
      if (c.isInstance(adapter)) {
        return adapter;
      }
    }
    return null;
  }
  
  protected IProject[] getSelectedProjects()
  {
    IResource[] selectedResources = getSelectedResources();
    if (selectedResources.length == 0) {
      return new IProject[0];
    }
    ArrayList projects = new ArrayList();
    for (int i = 0; i < selectedResources.length; i++)
    {
      IResource resource = selectedResources[i];
      if (resource.getType() == 4) {
        projects.add(resource);
      }
    }
    return (IProject[])projects.toArray(new IProject[projects.size()]);
  }
  
  protected Object[] getAdaptedSelection(Class c)
  {
    return getSelectedAdaptables(selection, c);
  }
  
  protected IResource[] getSelectedResources()
  {
    return Utils.getContributedResources(getSelection().toArray());
  }
  
  protected IStructuredSelection getSelection()
  {
    if (selection == null) {
      selection = StructuredSelection.EMPTY;
    }
    return selection;
  }
  
  protected ResourceMapping[] getSelectedResourceMappings(String providerId)
  {
    Object[] elements = getSelection().toArray();
    ArrayList providerMappings = new ArrayList();
    for (int i = 0; i < elements.length; i++)
    {
      Object object = elements[i];
      Object adapted = getResourceMapping(object);
      if ((adapted instanceof ResourceMapping))
      {
        ResourceMapping mapping = (ResourceMapping)adapted;
        if ((providerId == null) || (isMappedToProvider(mapping, providerId))) {
          providerMappings.add(mapping);
        }
      }
    }
    return (ResourceMapping[])providerMappings.toArray(new ResourceMapping[providerMappings.size()]);
  }
  
  private Object getResourceMapping(Object object)
  {
    if ((object instanceof ResourceMapping)) {
      return object;
    }
    return Utils.getResourceMapping(object);
  }
  
  private boolean isMappedToProvider(ResourceMapping element, String providerId)
  {
    IProject[] projects = element.getProjects();
    for (int k = 0; k < projects.length; k++)
    {
      IProject project = projects[k];
      RepositoryProvider provider = RepositoryProvider.getProvider(project);
      if ((provider != null) && (provider.getID().equals(providerId))) {
        return true;
      }
    }
    return false;
  }
  
  protected Shell getShell()
  {
    if (shell != null) {
      return shell;
    }
    if (targetPart != null) {
      return targetPart.getSite().getShell();
    }
    if (this.window != null) {
      return this.window.getShell();
    }
    IWorkbench workbench = TeamUIPlugin.getPlugin().getWorkbench();
    if (workbench == null) {
      return null;
    }
    IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
    if (window == null) {
      return null;
    }
    return window.getShell();
  }
  
  protected final void run(IRunnableWithProgress runnable, String problemMessage, int progressKind)
  {
    Exception[] exceptions = new Exception[1];
    switch (progressKind)
    {
    case 2: 
      BusyIndicator.showWhile(Display.getCurrent(), new Runnable()
      {
        private final IRunnableWithProgress val$runnable;
        private final Exception[] val$exceptions;
        
        public void run()
        {
          try
          {
            val$runnable.run(new NullProgressMonitor());
          }
          catch (InvocationTargetException e)
          {
            val$exceptions[0] = e;
          }
          catch (InterruptedException localInterruptedException)
          {
            val$exceptions[0] = null;
          }
        }
      });
      break;
    case 1: 
    default: 
      try
      {
        new ProgressMonitorDialog(getShell()).run(true, true, runnable);
      }
      catch (InvocationTargetException e)
      {
        exceptions[0] = e;
      }
      catch (InterruptedException localInterruptedException)
      {
        exceptions[0] = null;
      }
    }
    if (exceptions[0] != null) {
      handle(exceptions[0], null, problemMessage);
    }
  }
  
  public void selectionChanged(IAction action, ISelection selection)
  {
    if ((selection instanceof IStructuredSelection))
    {
      this.selection = ((IStructuredSelection)selection);
      if (action != null) {
        setActionEnablement(action);
      }
    }
  }
  
  protected void setActionEnablement(IAction action)
  {
    action.setEnabled(isEnabled());
  }
  
  protected boolean isEnabledForException(TeamException exception)
  {
    if (exception.getStatus().getCode() == 274) {
      return true;
    }
    TeamPlugin.log(exception);
    return false;
  }
  
  public void setActivePart(IAction action, IWorkbenchPart targetPart)
  {
    if (targetPart != null)
    {
      shell = targetPart.getSite().getShell();
      this.targetPart = targetPart;
    }
  }
  
  protected void handle(Exception exception, String title, String message)
  {
    Utils.handleError(getShell(), exception, title, message);
  }
  
  protected Hashtable getProviderMapping(IResource[] resources)
  {
    Hashtable result = new Hashtable();
    for (int i = 0; i < resources.length; i++)
    {
      RepositoryProvider provider = RepositoryProvider.getProvider(resources[i].getProject());
      List list = (List)result.get(provider);
      if (list == null)
      {
        list = new ArrayList();
        result.put(provider, list);
      }
      list.add(resources[i]);
    }
    return result;
  }
  
  protected IWorkbenchPart getTargetPart()
  {
    if (targetPart == null)
    {
      IWorkbenchPage page = TeamUIPlugin.getActivePage();
      if (page != null) {
        targetPart = page.getActivePart();
      }
    }
    return targetPart;
  }
  
  protected IWorkbenchPage getTargetPage()
  {
    if (getTargetPart() == null) {
      return TeamUIPlugin.getActivePage();
    }
    return getTargetPart().getSite().getPage();
  }
  
  protected IViewPart showView(String viewId)
  {
    try
    {
      return getTargetPage().showView(viewId);
    }
    catch (PartInitException localPartInitException) {}
    return null;
  }
  
  public void init(IViewPart view)
  {
    if (view != null)
    {
      shell = view.getSite().getShell();
      targetPart = view;
    }
  }
  
  public void init(IWorkbenchWindow window)
  {
    this.window = window;
    shell = window.getShell();
    window.getSelectionService().addPostSelectionListener(selectionListener);
    window.getActivePage().addPartListener(targetPartListener);
  }
  
  public IWorkbenchWindow getWindow()
  {
    return window;
  }
  
  public void dispose()
  {
    super.dispose();
    if (window != null)
    {
      window.getSelectionService().removePostSelectionListener(selectionListener);
      if (window.getActivePage() != null) {
        window.getActivePage().removePartListener(targetPartListener);
      }
      targetPartListener = null;
    }
    selection = null;
    window = null;
    targetPart = null;
    shell = null;
  }
  
  protected abstract void execute(IAction paramIAction)
    throws InvocationTargetException, InterruptedException;
  
  public Object execute(ExecutionEvent event)
    throws ExecutionException
  {
    IWorkbenchWindow activeWorkbenchWindow = HandlerUtil.getActiveWorkbenchWindow(event);
    if (activeWorkbenchWindow != null)
    {
      ISelection selection = HandlerUtil.getCurrentSelection(event);
      if (selection != null)
      {
        IWorkbenchPart part = HandlerUtil.getActivePart(event);
        try
        {
          execute(activeWorkbenchWindow, part, selection);
        }
        catch (InvocationTargetException e)
        {
          throw new ExecutionException(TeamUIMessages.TeamAction_errorTitle, e);
        }
        catch (InterruptedException localInterruptedException) {}
      }
    }
    return null;
  }
  
  private void execute(IWorkbenchWindow activeWorkbenchWindow, IWorkbenchPart part, ISelection selection)
    throws InvocationTargetException, InterruptedException
  {
    if ((part != null) && ((part instanceof IEditorPart)))
    {
      IEditorInput input = ((IEditorPart)part).getEditorInput();
      IFile file = ResourceUtil.getFile(input);
      if (file != null) {
        selectionChanged(null, new StructuredSelection(file));
      }
    }
    else
    {
      selectionChanged(null, selection);
    }
    if (isEnabled()) {
      execute(null);
    } else {
      MessageDialog.openInformation(activeWorkbenchWindow.getShell(), 
        TeamUIMessages.TeamAction_handlerNotEnabledTitle, 
        TeamUIMessages.TeamAction_handlerNotEnabledMessage);
    }
  }
  
  public void run(IAction action)
  {
    try
    {
      execute(action);
    }
    catch (InvocationTargetException e)
    {
      handle(e);
    }
    catch (InterruptedException localInterruptedException) {}
  }
  
  protected void handle(Exception e)
  {
    handle(e, TeamUIMessages.TeamAction_errorTitle, null);
  }
  
  public void init(IAction action) {}
  
  public final void runWithEvent(IAction action, Event event)
  {
    run(action);
  }
  
  public void setEnabled(Object evaluationContext)
  {
    IWorkbenchWindow activeWorkbenchWindow = (IWorkbenchWindow)
      HandlerUtil.getVariable(evaluationContext, 
      "activeWorkbenchWindow");
    if (activeWorkbenchWindow != null)
    {
      ISelection selection = (ISelection)HandlerUtil.getVariable(
        evaluationContext, "selection");
      if (selection == null) {
        selection = StructuredSelection.EMPTY;
      }
      IWorkbenchPart part = (IWorkbenchPart)HandlerUtil.getVariable(
        evaluationContext, "activePart");
      updateSelection(part, selection);
    }
  }
  
  private void updateSelection(IWorkbenchPart part, ISelection selection)
  {
    setActivePart(null, part);
    if ((part != null) && ((part instanceof IEditorPart)))
    {
      IEditorInput input = ((IEditorPart)part).getEditorInput();
      IFile file = ResourceUtil.getFile(input);
      if (file != null) {
        selectionChanged(null, new StructuredSelection(file));
      }
    }
    else
    {
      selectionChanged(null, selection);
    }
  }
}

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

import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.widgets.Button;

class AdditionalMappingsDialog$1
  implements SelectionListener
{
  final AdditionalMappingsDialog this$0;
  private final Button val$forcePreviewButton;
  
  AdditionalMappingsDialog$1(AdditionalMappingsDialog paramAdditionalMappingsDialog, Button paramButton)
  {
    this$0 = paramAdditionalMappingsDialog;val$forcePreviewButton = paramButton;
  }
  
  public void widgetDefaultSelected(SelectionEvent e) {}
  
  public void widgetSelected(SelectionEvent e)
  {
    this$0.forcePreview = val$forcePreviewButton.getSelection();
  }
}

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

import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
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.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.team.core.mapping.ISynchronizationContext;
import org.eclipse.team.core.mapping.ISynchronizationScope;
import org.eclipse.team.internal.ui.SWTUtils;
import org.eclipse.team.internal.ui.TeamUIMessages;

public class AdditionalMappingsDialog
  extends DetailsDialog
{
  private ResourceMappingHierarchyArea selectedMappingsArea;
  private ResourceMappingHierarchyArea allMappingsArea;
  private final ISynchronizationScope scope;
  private final ISynchronizationContext context;
  private String previewMessage;
  protected boolean forcePreview = true;
  
  public AdditionalMappingsDialog(Shell parentShell, String dialogTitle, ISynchronizationScope scope, ISynchronizationContext context)
  {
    super(parentShell, dialogTitle);
    this.scope = scope;
    this.context = context;
  }
  
  protected void createMainDialogArea(Composite parent)
  {
    createWrappingLabel(parent, TeamUIMessages.AdditionalMappingsDialog_0);
    createSelectedMappingsArea(parent);
    createAllMappingsArea(parent);
    createPreviewOptionArea(parent);
  }
  
  private void createSelectedMappingsArea(Composite parent)
  {
    Composite composite = createComposite(parent);
    GridLayout layout = new GridLayout(1, false);
    marginHeight = 0;
    marginWidth = 0;
    composite.setLayout(layout);
    selectedMappingsArea = ResourceMappingHierarchyArea.create(scope.asInputScope(), null);
    selectedMappingsArea.setDescription(TeamUIMessages.AdditionalMappingsDialog_1);
    selectedMappingsArea.createArea(composite);
    
    Label seperator = new Label(composite, 258);
    seperator.setLayoutData(new GridData(768));
  }
  
  private void createAllMappingsArea(Composite parent)
  {
    Composite composite = createComposite(parent);
    GridLayout layout = new GridLayout(1, false);
    marginHeight = 0;
    marginWidth = 0;
    composite.setLayout(layout);
    allMappingsArea = ResourceMappingHierarchyArea.create(scope, context);
    allMappingsArea.setDescription(TeamUIMessages.AdditionalMappingsDialog_2);
    
    allMappingsArea.createArea(composite);
  }
  
  private void createPreviewOptionArea(Composite parent)
  {
    if (previewMessage != null)
    {
      Button forcePreviewButton = SWTUtils.createCheckBox(parent, previewMessage);
      forcePreviewButton.setSelection(forcePreview);
      forcePreviewButton.addSelectionListener(new SelectionListener()
      {
        private final Button val$forcePreviewButton;
        
        public void widgetDefaultSelected(SelectionEvent e) {}
        
        public void widgetSelected(SelectionEvent e)
        {
          forcePreview = val$forcePreviewButton.getSelection();
        }
      });
    }
  }
  
  protected Composite createDropDownDialogArea(Composite parent)
  {
    return null;
  }
  
  protected void updateEnablements() {}
  
  protected boolean includeDetailsButton()
  {
    return false;
  }
  
  public String getPreviewMessage()
  {
    return previewMessage;
  }
  
  public void setPreviewMessage(String previewMessage)
  {
    this.previewMessage = previewMessage;
  }
  
  public boolean isForcePreview()
  {
    return forcePreview;
  }
}

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

import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.TrayDialog;
import org.eclipse.jface.resource.ImageRegistry;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
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.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.help.IWorkbenchHelpSystem;

public abstract class DetailsDialog
  extends TrayDialog
{
  private Button detailsButton;
  private Button okButton;
  private String title;
  private Label errorMessageLabel;
  private Composite detailsComposite;
  private boolean detailsCreated = false;
  private String imageKey = null;
  
  public DetailsDialog(Shell parentShell, String dialogTitle)
  {
    super(parentShell);
    title = dialogTitle;
    initializeStyle();
  }
  
  protected void initializeStyle()
  {
    setShellStyle(67696);
  }
  
  protected void buttonPressed(int id)
  {
    if (id == 13) {
      toggleDetailsArea();
    } else {
      super.buttonPressed(id);
    }
  }
  
  protected void configureShell(Shell shell)
  {
    super.configureShell(shell);
    shell.setText(title);
    String helpContextId = getHelpContextId();
    if (helpContextId != null) {
      PlatformUI.getWorkbench().getHelpSystem().setHelp(shell, helpContextId);
    }
  }
  
  protected void createButtonsForButtonBar(Composite parent)
  {
    if (includeOkButton()) {
      okButton = createButton(parent, 0, IDialogConstants.OK_LABEL, true);
    }
    if (includeCancelButton()) {
      createButton(parent, 1, IDialogConstants.CANCEL_LABEL, false);
    }
    if (includeDetailsButton()) {
      detailsButton = createButton(parent, 13, getDetailsButtonLabelShow(), false);
    }
    updateEnablements();
  }
  
  protected String getDetailsButtonLabelShow()
  {
    return IDialogConstants.SHOW_DETAILS_LABEL;
  }
  
  protected String getDetailsButtonLabelHide()
  {
    return IDialogConstants.HIDE_DETAILS_LABEL;
  }
  
  protected final Control createDialogArea(Composite parent)
  {
    applyDialogFont(parent);
    initializeDialogUnits(parent);
    
    Composite composite = (Composite)super.createDialogArea(parent);
    if (!isMainGrabVertical()) {
      composite.setLayoutData(new GridData(4, 128, true, false));
    }
    String helpContextId = getHelpContextId();
    if (helpContextId != null) {
      PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, helpContextId);
    }
    String key = getImageKey();
    Image image = null;
    if (key != null) {
      image = JFaceResources.getImageRegistry().get(key);
    }
    if (image != null)
    {
      Composite top = new Composite(composite, 0);
      GridLayout layout = new GridLayout();
      marginHeight = 0;
      marginWidth = 0;
      verticalSpacing = 0;
      horizontalSpacing = convertHorizontalDLUsToPixels(4);
      numColumns = 2;
      top.setLayout(layout);
      top.setLayoutData(new GridData(1808));
      
      Label label = new Label(top, 0);
      image.setBackground(label.getBackground());
      label.setImage(image);
      label.setLayoutData(new GridData(
        66));
      
      Composite right = new Composite(top, 0);
      layout = new GridLayout();
      marginHeight = 0;
      marginWidth = 0;
      verticalSpacing = convertVerticalDLUsToPixels(4);
      horizontalSpacing = convertHorizontalDLUsToPixels(4);
      right.setLayout(layout);
      right.setLayoutData(new GridData(1808));
      createMainDialogArea(right);
    }
    else
    {
      createMainDialogArea(composite);
    }
    if (includeErrorMessage())
    {
      errorMessageLabel = new Label(composite, 0);
      errorMessageLabel.setLayoutData(new GridData(
        768));
      
      errorMessageLabel.setForeground(getShell().getDisplay().getSystemColor(3));
    }
    Dialog.applyDialogFont(parent);
    return composite;
  }
  
  protected String getHelpContextId()
  {
    return null;
  }
  
  protected boolean isMainGrabVertical()
  {
    return true;
  }
  
  protected abstract void createMainDialogArea(Composite paramComposite);
  
  protected abstract Composite createDropDownDialogArea(Composite paramComposite);
  
  private void toggleDetailsArea()
  {
    Point windowSize = getShell().getSize();
    Point oldSize = getContents().computeSize(-1, -1);
    if (detailsCreated)
    {
      detailsComposite.dispose();
      detailsCreated = false;
      detailsButton.setText(getDetailsButtonLabelShow());
    }
    else
    {
      detailsComposite = createDropDownDialogArea((Composite)getContents());
      detailsCreated = true;
      detailsButton.setText(getDetailsButtonLabelHide());
    }
    Dialog.applyDialogFont(getContents());
    Point newSize = getContents().computeSize(-1, -1);
    
    getShell().setSize(new Point(x, y + (y - y)));
  }
  
  protected final void setErrorMessage(String error)
  {
    if (errorMessageLabel != null)
    {
      if ((error == null) || (error.length() == 0)) {
        errorMessageLabel.setText("");
      } else {
        errorMessageLabel.setText(error);
      }
      errorMessageLabel.update();
    }
  }
  
  protected final void setPageComplete(boolean complete)
  {
    if (okButton != null) {
      okButton.setEnabled(complete);
    }
  }
  
  protected abstract void updateEnablements();
  
  protected boolean includeCancelButton()
  {
    return true;
  }
  
  protected boolean includeOkButton()
  {
    return true;
  }
  
  protected String getImageKey()
  {
    return imageKey;
  }
  
  protected void setImageKey(String imageKey)
  {
    this.imageKey = imageKey;
  }
  
  protected Label createWrappingLabel(Composite parent, String text)
  {
    Label label = new Label(parent, 16448);
    label.setText(text);
    GridData data = new GridData();
    horizontalSpan = 1;
    horizontalAlignment = 4;
    horizontalIndent = 0;
    grabExcessHorizontalSpace = true;
    widthHint = convertHorizontalDLUsToPixels(300);
    label.setLayoutData(data);
    label.setFont(parent.getFont());
    return label;
  }
  
  protected Composite createComposite(Composite parent)
  {
    Composite composite = new Composite(parent, 0);
    GridLayout layout = new GridLayout();
    composite.setLayout(layout);
    composite.setLayoutData(new GridData(1808));
    composite.setFont(parent.getFont());
    return composite;
  }
  
  protected boolean isDetailsVisible()
  {
    return detailsCreated;
  }
  
  protected boolean includeErrorMessage()
  {
    return true;
  }
  
  protected boolean includeDetailsButton()
  {
    return true;
  }
}

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

import org.eclipse.core.resources.IProject;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.List;
import org.eclipse.swt.widgets.Shell;

public class DetailsDialogWithProjects
  extends DetailsDialog
{
  private String message;
  private String detailsTitle;
  private IProject[] projects;
  private List detailsList;
  private boolean includeCancelButton;
  
  public DetailsDialogWithProjects(Shell parentShell, String dialogTitle, String dialogMessage, String detailsTitle, IProject[] projects, boolean includeCancelButton, String imageKey)
  {
    super(parentShell, dialogTitle);
    setImageKey(imageKey);
    message = dialogMessage;
    this.detailsTitle = detailsTitle;
    this.projects = projects;
    this.includeCancelButton = includeCancelButton;
  }
  
  protected void createMainDialogArea(Composite composite)
  {
    Label label = new Label(composite, 64);
    label.setText(message);
    GridData data = new GridData(4, 16777220, true, false);
    widthHint = convertHorizontalDLUsToPixels(300);
    label.setLayoutData(data);
    updateEnablements();
  }
  
  protected Composite createDropDownDialogArea(Composite parent)
  {
    Composite composite = new Composite(parent, 0);
    GridLayout layout = new GridLayout();
    marginHeight = convertVerticalDLUsToPixels(7);
    marginWidth = convertHorizontalDLUsToPixels(7);
    verticalSpacing = convertVerticalDLUsToPixels(4);
    horizontalSpacing = convertHorizontalDLUsToPixels(4);
    composite.setLayout(layout);
    composite.setLayoutData(new GridData(1808));
    if (detailsTitle != null)
    {
      Label title = new Label(composite, 64);
      title.setText(detailsTitle);
      title.setLayoutData(new GridData(4, 4, true, false));
    }
    detailsList = new List(composite, 2818);
    GridData data = new GridData(4, 4, true, true);
    heightHint = convertHeightInCharsToPixels(5);
    detailsList.setLayoutData(data);
    for (int i = 0; i < projects.length; i++) {
      detailsList.add(projects[i].getName());
    }
    return composite;
  }
  
  protected void updateEnablements()
  {
    setPageComplete(true);
  }
  
  protected boolean includeCancelButton()
  {
    return includeCancelButton;
  }
  
  protected boolean isMainGrabVertical()
  {
    return false;
  }
}

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

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontMetrics;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Point;
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.Label;

public abstract class DialogArea
{
  private FontMetrics fontMetrics;
  private List listeners;
  
  protected DialogArea()
  {
    listeners = new ArrayList();
  }
  
  public void addPropertyChangeListener(IPropertyChangeListener listener)
  {
    if (!listeners.contains(listener)) {
      listeners.add(listener);
    }
  }
  
  public void removePropertyChangeListener(IPropertyChangeListener listener)
  {
    listeners.remove(listener);
  }
  
  protected void firePropertyChangeChange(String property, Object oldValue, Object newValue)
  {
    PropertyChangeEvent event = new PropertyChangeEvent(this, property, oldValue, newValue);
    for (Iterator iter = listeners.iterator(); iter.hasNext();)
    {
      IPropertyChangeListener listener = (IPropertyChangeListener)iter.next();
      listener.propertyChange(event);
    }
  }
  
  protected void initializeDialogUnits(Control control)
  {
    GC gc = new GC(control);
    gc.setFont(control.getFont());
    fontMetrics = gc.getFontMetrics();
    gc.dispose();
  }
  
  public abstract void createArea(Composite paramComposite);
  
  protected Button createCheckbox(Composite parent, String label, int span)
  {
    Button button = new Button(parent, 16416);
    button.setText(label);
    button.setFont(parent.getFont());
    GridData data = new GridData();
    horizontalSpan = span;
    button.setLayoutData(data);
    return button;
  }
  
  protected Button createButton(Composite parent, String label, int style)
  {
    Button button = new Button(parent, 8);
    button.setText(label);
    
    button.setFont(parent.getFont());
    GridData data = new GridData(style);
    heightHint = Dialog.convertVerticalDLUsToPixels(fontMetrics, 14);
    int widthHint = Dialog.convertHorizontalDLUsToPixels(fontMetrics, 61);
    widthHint = Math.max(widthHint, computeSize-1-1x);
    button.setLayoutData(data);
    return button;
  }
  
  protected Button createRadioButton(Composite parent, String label, int span)
  {
    Button button = new Button(parent, 16);
    button.setText(label);
    GridData data = new GridData();
    horizontalSpan = span;
    button.setLayoutData(data);
    return button;
  }
  
  protected Label createWrappingLabel(Composite parent, String text, int horizontalSpan)
  {
    Label label = new Label(parent, 16448);
    label.setText(text);
    label.setFont(parent.getFont());
    GridData data = new GridData();
    horizontalSpan = horizontalSpan;
    horizontalAlignment = 4;
    grabExcessHorizontalSpace = true;
    widthHint = 0;
    label.setLayoutData(data);
    return label;
  }
  
  protected Label createLabel(Composite parent, String text, int horizontalSpan)
  {
    Label label = new Label(parent, 16384);
    label.setText(text);
    GridData data = new GridData();
    horizontalSpan = horizontalSpan;
    horizontalAlignment = 4;
    label.setLayoutData(data);
    return label;
  }
  
  protected Composite createComposite(Composite parent, int numColumns, boolean grab)
  {
    Composite composite = new Composite(parent, 0);
    Font font = parent.getFont();
    composite.setFont(font);
    
    composite.setLayout(new GridLayout(numColumns, false));
    composite.setLayoutData(new GridData(4, 4, grab, grab));
    
    return composite;
  }
  
  protected Composite createGrabbingComposite(Composite parent, int numColumns)
  {
    Composite composite = new Composite(parent, 0);
    Font font = parent.getFont();
    composite.setFont(font);
    
    GridLayout layout = new GridLayout();
    numColumns = numColumns;
    marginHeight = 0;
    marginWidth = 0;
    composite.setLayout(layout);
    
    GridData data = new GridData();
    verticalAlignment = 4;
    horizontalAlignment = 4;
    grabExcessHorizontalSpace = true;
    grabExcessVerticalSpace = true;
    composite.setLayoutData(data);
    return composite;
  }
  
  protected int convertVerticalDLUsToPixels(int dlus)
  {
    return Dialog.convertVerticalDLUsToPixels(fontMetrics, dlus);
  }
  
  protected int convertHorizontalDLUsToPixels(int dlus)
  {
    return Dialog.convertHorizontalDLUsToPixels(fontMetrics, dlus);
  }
}

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

import org.eclipse.core.resources.IResource;

public abstract interface IPromptCondition
{
  public abstract boolean needsPrompt(IResource paramIResource);
  
  public abstract String promptMessage(IResource paramIResource);
}

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

import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.mapping.ResourceMapping;
import org.eclipse.core.resources.mapping.ResourceTraversal;
import org.eclipse.core.runtime.CoreException;

public abstract interface IResourceMappingResourceFilter
{
  public abstract boolean select(IResource paramIResource, ResourceMapping paramResourceMapping, ResourceTraversal paramResourceTraversal)
    throws CoreException;
}

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

import org.eclipse.jface.dialogs.MessageDialog;

class MultipleYesNoPrompter$1
  implements Runnable
{
  final MultipleYesNoPrompter this$0;
  private final MessageDialog val$dialog;
  
  MultipleYesNoPrompter$1(MultipleYesNoPrompter paramMultipleYesNoPrompter, MessageDialog paramMessageDialog)
  {
    this$0 = paramMultipleYesNoPrompter;val$dialog = paramMessageDialog;
  }
  
  public void run()
  {
    val$dialog.open();
  }
}

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

import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.window.IShellProvider;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class MultipleYesNoPrompter
{
  private static final int ALWAYS_ASK = 0;
  private static final int YES_TO_ALL = 1;
  private static final int NO_TO_ALL = 2;
  private String[] buttons;
  private int confirmation = 0;
  private String title;
  private boolean hasMultiple;
  private boolean allOrNothing;
  private IShellProvider shellProvider;
  
  public MultipleYesNoPrompter(IShellProvider provider, String title, boolean hasMultiple, boolean allOrNothing)
  {
    this.title = title;
    shellProvider = provider;
    this.hasMultiple = hasMultiple;
    this.allOrNothing = allOrNothing;
    if (hasMultiple)
    {
      if (allOrNothing) {
        buttons = new String[] {
          IDialogConstants.YES_LABEL, 
          IDialogConstants.YES_TO_ALL_LABEL, 
          IDialogConstants.CANCEL_LABEL };
      } else {
        buttons = new String[] {
          IDialogConstants.YES_LABEL, 
          IDialogConstants.YES_TO_ALL_LABEL, 
          IDialogConstants.NO_LABEL, 
          IDialogConstants.NO_TO_ALL_LABEL, 
          IDialogConstants.CANCEL_LABEL };
      }
    }
    else {
      buttons = new String[] {
        IDialogConstants.YES_LABEL, 
        IDialogConstants.NO_LABEL, 
        IDialogConstants.CANCEL_LABEL };
    }
  }
  
  public boolean shouldInclude(String message)
    throws InterruptedException
  {
    if (confirmation == 1) {
      return true;
    }
    switch (confirmation)
    {
    case 0: 
      if (confirmOverwrite(message)) {
        return true;
      }
      break;
    case 1: 
      return true;
    }
    return false;
  }
  
  private boolean confirmOverwrite(String msg)
    throws InterruptedException
  {
    Shell shell = shellProvider.getShell();
    if (shell == null) {
      return false;
    }
    MessageDialog dialog = 
      new MessageDialog(shell, title, null, msg, 3, buttons, 0);
    
    shell.getDisplay().syncExec(
      new Runnable()
      {
        private final MessageDialog val$dialog;
        
        public void run()
        {
          val$dialog.open();
        }
      });
    if (hasMultiple)
    {
      switch (dialog.getReturnCode())
      {
      case 0: 
        return true;
      case 1: 
        confirmation = 1;
        return true;
      case 2: 
        if (allOrNothing) {
          throw new InterruptedException();
        }
        return false;
      case 3: 
        confirmation = 2;
        return false;
      }
      throw new InterruptedException();
    }
    switch (dialog.getReturnCode())
    {
    case 0: 
      return true;
    case 1: 
      return false;
    }
    throw new InterruptedException();
  }
  
  public void setTitle(String title)
  {
    this.title = title;
  }
}

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

import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Display;

class NoChangesDialog$1
  implements Runnable
{
  final NoChangesDialog this$0;
  private final Image[] val$image;
  private final Display val$display;
  private final int val$imageID;
  
  NoChangesDialog$1(NoChangesDialog paramNoChangesDialog, Image[] paramArrayOfImage, Display paramDisplay, int paramInt)
  {
    this$0 = paramNoChangesDialog;val$image = paramArrayOfImage;val$display = paramDisplay;val$imageID = paramInt;
  }
  
  public void run()
  {
    val$image[0] = val$display.getSystemImage(val$imageID);
  }
}

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

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.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.team.core.mapping.ISynchronizationScope;

public class NoChangesDialog
  extends DetailsDialog
{
  private String message;
  private Label messageLabel;
  private Label imageLabel;
  private ResourceMappingHierarchyArea selectedMappingsArea;
  private final ISynchronizationScope scope;
  private final String description;
  
  public NoChangesDialog(Shell parentShell, String dialogTitle, String message, String description, ISynchronizationScope scope)
  {
    super(parentShell, dialogTitle);
    th
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