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

  }
  
  private void setInputType(int inputTypeSelected)
  {
    inputType = inputTypeSelected;
    
    messageType = 0;
    
    fileInputButton.setSelection(inputType == 0);
    fileCombo.setEnabled(inputType == 0);
    browseButton.setEnabled(inputType == 0);
    urlInputButton.setSelection(inputType == 1);
    urlCombo.setEnabled(inputType == 1);
    if (inputType == 0) {
      updateFileEnablement();
    }
    if (inputType == 1) {
      updateUrlEnablement();
    }
  }
  
  public void createControl(Composite parent)
  {
    Composite composite = createComposite(parent, 1);
    initializeDialogUnits(composite);
    
    PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, "org.eclipse.team.ui.import_project_set_page_context");
    
    Composite inner = new Composite(composite, 0);
    inner.setLayoutData(new GridData(768));
    GridLayout layout = new GridLayout();
    numColumns = 3;
    marginHeight = 0;
    marginWidth = 0;
    inner.setLayout(layout);
    
    fileInputButton = new Button(inner, 16);
    fileInputButton
      .setText(TeamUIMessages.ImportProjectSetMainPage_Project_Set_File);
    fileInputButton.setEnabled(true);
    fileInputButton.addSelectionListener(new SelectionAdapter()
    {
      public void widgetSelected(SelectionEvent e)
      {
        ImportProjectSetMainPage.this.setInputType(0);
      }
    });
    fileCombo = createDropDownCombo(inner);
    file = psfFilenameStore.getSuggestedDefault();
    fileCombo.setItems(psfFilenameStore.getHistory());
    fileCombo.setText(file);
    fileCombo.addListener(24, new Listener()
    {
      public void handleEvent(Event event)
      {
        file = fileCombo.getText();
        ImportProjectSetMainPage.this.updateFileEnablement();
      }
    });
    browseButton = new Button(inner, 8);
    browseButton.setText(TeamUIMessages.ImportProjectSetMainPage_Browse_3);
    
    urlInputButton = new Button(inner, 16);
    urlInputButton
      .setText(TeamUIMessages.ImportProjectSetMainPage_Project_Set_Url);
    urlInputButton.addSelectionListener(new SelectionAdapter()
    {
      public void widgetSelected(SelectionEvent e)
      {
        ImportProjectSetMainPage.this.setInputType(1);
      }
    });
    urlCombo = createDropDownCombo(inner);
    urlString = psfUrlStore.getSuggestedDefault();
    urlCombo.setItems(psfUrlStore.getHistory());
    urlCombo.setText(urlString);
    GridData gd = new GridData(768);
    horizontalSpan = 2;
    urlCombo.setLayoutData(gd);
    urlCombo.addListener(24, new Listener()
    {
      public void handleEvent(Event event)
      {
        urlString = urlCombo.getText();
        ImportProjectSetMainPage.this.updateUrlEnablement();
      }
    });
    GridData data = new GridData();
    horizontalAlignment = 4;
    int widthHint = convertHorizontalDLUsToPixels(61);
    widthHint = Math.max(widthHint, browseButton.computeSize(-1, -1, true).x);
    browseButton.setLayoutData(data);
    browseButton.addListener(13, new Listener()
    {
      public void handleEvent(Event event)
      {
        FileDialog d = new FileDialog(getShell());
        d.setFilterExtensions(new String[] { "*.psf", "*" });
        d.setFilterNames(new String[] { TeamUIMessages.ImportProjectSetMainPage_Project_Set_Files_2, TeamUIMessages.ImportProjectSetMainPage_allFiles });
        String fileName = getFileName();
        if ((fileName != null) && (fileName.length() > 0))
        {
          int separator = fileName.lastIndexOf(System.getProperty("file.separator").charAt(0));
          if (separator != -1) {
            fileName = fileName.substring(0, separator);
          }
        }
        else
        {
          fileName = ResourcesPlugin.getWorkspace().getRoot().getLocation().toString();
        }
        d.setFilterPath(fileName);
        String f = d.open();
        if (f != null)
        {
          fileCombo.setText(f);
          file = f;
        }
      }
    });
    addWorkingSetSection(composite);
    
    Button runInBackgroundCheckbox = SWTUtils.createCheckBox(composite, TeamUIMessages.ImportProjectSetMainPage_runInBackground, 3);
    
    runInBackgroundCheckbox.setSelection(isRunInBackgroundPreferenceOn());
    runInBackgroundCheckbox.addSelectionListener(new SelectionAdapter()
    {
      public void widgetSelected(SelectionEvent e)
      {
        runInBackground = (!runInBackground);
      }
    });
    setControl(composite);
    setDefaultInputType();
    Dialog.applyDialogFont(parent);
  }
  
  private void setDefaultInputType()
  {
    Control c = getControl();
    if (c != null)
    {
      Clipboard clipboard = new Clipboard(c.getDisplay());
      Object o = clipboard.getContents(TextTransfer.getInstance());
      clipboard.dispose();
      if ((o instanceof String)) {
        try
        {
          URL url = new URL((String)o);
          if (url != null)
          {
            setInputType(1);
            urlCombo.setText((String)o);
            return;
          }
        }
        catch (MalformedURLException localMalformedURLException) {}
      }
    }
    setInputType(0);
  }
  
  private void addWorkingSetSection(Composite composite)
  {
    workingSetGroup = new WorkingSetGroup(
      composite, 
      null, 
      new String[] { "org.eclipse.ui.resourceWorkingSetPage", 
      "org.eclipse.jdt.ui.JavaWorkingSetPage" });
  }
  
  private void updateUrlEnablement()
  {
    boolean complete = false;
    setMessage(null);
    setErrorMessage(null);
    if (urlString.length() == 0)
    {
      setMessage(TeamUIMessages.ImportProjectSetMainPage_specifyURL, 
        messageType);
      complete = false;
    }
    else
    {
      try
      {
        new URL(urlString);
        
        complete = true;
      }
      catch (MalformedURLException localMalformedURLException)
      {
        messageType = 3;
        setMessage(TeamUIMessages.ImportProjectSetDialog_malformed_url, 
          messageType);
        complete = false;
      }
    }
    if (complete)
    {
      setErrorMessage(null);
      setDescription(TeamUIMessages.ImportProjectSetMainPage_description);
    }
    setPageComplete(complete);
  }
  
  private void updateFileEnablement()
  {
    boolean complete = false;
    setMessage(null);
    setErrorMessage(null);
    if (file.length() == 0)
    {
      setMessage(TeamUIMessages.ImportProjectSetMainPage_specifyFile, messageType);
      setPageComplete(false);
      return;
    }
    File f = new File(file);
    if (!f.exists())
    {
      messageType = 3;
      setMessage(TeamUIMessages.ImportProjectSetMainPage_The_specified_file_does_not_exist_4, messageType);
      setPageComplete(false);
      return;
    }
    if (f.isDirectory())
    {
      messageType = 3;
      setMessage(TeamUIMessages.ImportProjectSetMainPage_You_have_specified_a_folder_5, messageType);
      setPageComplete(false);
      return;
    }
    if (!ProjectSetImporter.isValidProjectSetFile(file))
    {
      messageType = 3;
      setMessage(TeamUIMessages.ImportProjectSetMainPage_projectSetFileInvalid, messageType);
      setPageComplete(false);
      return;
    }
    complete = true;
    if (complete)
    {
      setErrorMessage(null);
      setDescription(TeamUIMessages.ImportProjectSetMainPage_description);
    }
    setPageComplete(complete);
  }
  
  public String getFileName()
  {
    return file;
  }
  
  public String getUrl()
  {
    return urlString;
  }
  
  public void setVisible(boolean visible)
  {
    super.setVisible(visible);
    if (visible) {
      fileCombo.setFocus();
    }
  }
  
  public IWorkingSet[] getWorkingSets()
  {
    return workingSetGroup.getSelectedWorkingSets();
  }
  
  private static boolean isRunInBackgroundPreferenceOn()
  {
    return TeamUIPlugin.getPlugin().getPreferenceStore().getBoolean(
      "org.eclipse.team.ui.run_import_in_background_");
  }
  
  public boolean isRunInBackgroundOn()
  {
    return runInBackground;
  }
  
  public int getInputType()
  {
    return inputType;
  }
  
  public String getURLContents()
  {
    try
    {
      PsfUrlStore.getInstance().remember(urlString);
      String urlContent = Utilities.getURLContents(new URL(urlString), 
        getContainer());
      if (ProjectSetImporter.isValidProjectSetString(urlContent)) {
        return urlContent;
      }
      messageType = 3;
      setMessage(
        TeamUIMessages.ImportProjectSetMainPage_projectSetFileInvalid, 
        messageType);
      setPageComplete(false);
      return null;
    }
    catch (OperationCanceledException localOperationCanceledException) {}catch (InterruptedException localInterruptedException) {}catch (InvocationTargetException localInvocationTargetException)
    {
      messageType = 3;
      setMessage(
        TeamUIMessages.ImportProjectSetMainPage_The_given_URL_cannot_be_loaded, 
        messageType);
      setPageComplete(false);
    }
    catch (MalformedURLException localMalformedURLException) {}
    return null;
  }
}

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

import java.lang.reflect.InvocationTargetException;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.operation.IRunnableContext;
import org.eclipse.team.internal.ui.ProjectSetImporter;
import org.eclipse.team.internal.ui.TeamUIMessages;
import org.eclipse.team.internal.ui.TeamUIPlugin;
import org.eclipse.team.ui.TeamOperation;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkingSet;
import org.eclipse.ui.IWorkingSetManager;

public class ImportProjectSetOperation
  extends TeamOperation
{
  private String psfFileContents;
  private String urlString;
  private String psfFile;
  private IWorkingSet[] workingSets;
  
  public ImportProjectSetOperation(IRunnableContext context, String psfFileContents, String urlString, IWorkingSet[] workingSets)
  {
    super(context);
    this.psfFileContents = psfFileContents;
    this.workingSets = workingSets;
    this.urlString = urlString;
  }
  
  public ImportProjectSetOperation(IRunnableContext context, String psfFile, IWorkingSet[] workingSets)
  {
    super(context);
    this.psfFile = psfFile;
    this.workingSets = workingSets;
  }
  
  private void runForStringContent(IProgressMonitor monitor)
    throws InvocationTargetException
  {
    IProject[] newProjects = ProjectSetImporter.importProjectSetFromString(
      psfFileContents, urlString, getShell(), monitor);
    createWorkingSet(workingSets, newProjects);
  }
  
  private void runForFile(IProgressMonitor monitor)
    throws InvocationTargetException
  {
    PsfFilenameStore.getInstance().remember(psfFile);
    IProject[] newProjects = ProjectSetImporter.importProjectSet(psfFile, 
      getShell(), monitor);
    createWorkingSet(workingSets, newProjects);
  }
  
  public void run(IProgressMonitor monitor)
    throws InvocationTargetException, InterruptedException
  {
    if (psfFileContents != null) {
      runForStringContent(monitor);
    } else {
      runForFile(monitor);
    }
  }
  
  protected boolean canRunAsJob()
  {
    return true;
  }
  
  protected String getJobName()
  {
    return TeamUIMessages.ImportProjectSetMainPage_jobName;
  }
  
  private void createWorkingSet(IWorkingSet[] workingSets, IProject[] projects)
  {
    IWorkingSetManager manager = TeamUIPlugin.getPlugin().getWorkbench().getWorkingSetManager();
    for (int i = 0; i < workingSets.length; i++)
    {
      String workingSetName = workingSets[i].getName();
      IWorkingSet oldSet = manager.getWorkingSet(workingSetName);
      if (oldSet == null)
      {
        IWorkingSet newSet = manager.createWorkingSet(workingSetName, projects);
        manager.addWorkingSet(newSet);
      }
      else
      {
        IAdaptable[] tempElements = oldSet.getElements();
        IAdaptable[] adaptedProjects = oldSet.adaptElements(projects);
        IAdaptable[] finalElementList = new IAdaptable[tempElements.length + adaptedProjects.length];
        System.arraycopy(tempElements, 0, finalElementList, 0, tempElements.length);
        System.arraycopy(adaptedProjects, 0, finalElementList, tempElements.length, adaptedProjects.length);
        oldSet.setElements(finalElementList);
      }
    }
  }
}

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

import org.eclipse.core.resources.IProject;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.widgets.Display;
import org.eclipse.team.internal.ui.TeamUIMessages;
import org.eclipse.ui.model.WorkbenchLabelProvider;

class PatchInaccessibleProjectsPage$1
  extends WorkbenchLabelProvider
{
  final PatchInaccessibleProjectsPage this$0;
  
  PatchInaccessibleProjectsPage$1(PatchInaccessibleProjectsPage paramPatchInaccessibleProjectsPage)
  {
    this$0 = paramPatchInaccessibleProjectsPage;
  }
  
  public Color getForeground(Object element)
  {
    if (((element instanceof IProject)) && 
      (!((IProject)element).exists())) {
      return Display.getCurrent().getSystemColor(
        18);
    }
    return super.getForeground(element);
  }
  
  protected String decorateText(String input, Object element)
  {
    if (((element instanceof IProject)) && 
      (!((IProject)element).exists())) {
      return 
        input + NLS.bind(
        TeamUIMessages.PatchInaccessibleProjectsPage_projectDoesNotExistInWorkspace, 
        "");
    }
    return input;
  }
}

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

import org.eclipse.core.resources.IProject;
import org.eclipse.jface.viewers.CheckStateChangedEvent;
import org.eclipse.jface.viewers.CheckboxTableViewer;
import org.eclipse.jface.viewers.ICheckStateListener;

class PatchInaccessibleProjectsPage$2
  implements ICheckStateListener
{
  final PatchInaccessibleProjectsPage this$0;
  
  PatchInaccessibleProjectsPage$2(PatchInaccessibleProjectsPage paramPatchInaccessibleProjectsPage)
  {
    this$0 = paramPatchInaccessibleProjectsPage;
  }
  
  public void checkStateChanged(CheckStateChangedEvent event)
  {
    IProject project = (IProject)event.getElement();
    if ((event.getChecked()) && (!project.exists())) {
      PatchInaccessibleProjectsPage.access$0(this$0).setChecked(project, false);
    }
  }
}

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

import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;

class PatchInaccessibleProjectsPage$3
  extends SelectionAdapter
{
  final PatchInaccessibleProjectsPage this$0;
  
  PatchInaccessibleProjectsPage$3(PatchInaccessibleProjectsPage paramPatchInaccessibleProjectsPage)
  {
    this$0 = paramPatchInaccessibleProjectsPage;
  }
  
  public void widgetSelected(SelectionEvent e)
  {
    PatchInaccessibleProjectsPage.access$1(this$0, true);
  }
}

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

import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;

class PatchInaccessibleProjectsPage$4
  extends SelectionAdapter
{
  final PatchInaccessibleProjectsPage this$0;
  
  PatchInaccessibleProjectsPage$4(PatchInaccessibleProjectsPage paramPatchInaccessibleProjectsPage)
  {
    this$0 = paramPatchInaccessibleProjectsPage;
  }
  
  public void widgetSelected(SelectionEvent e)
  {
    PatchInaccessibleProjectsPage.access$1(this$0, false);
  }
}

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

import java.util.ArrayList;
import java.util.List;
import org.eclipse.compare.internal.core.patch.DiffProject;
import org.eclipse.compare.internal.patch.WorkspacePatcher;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.CheckStateChangedEvent;
import org.eclipse.jface.viewers.CheckboxTableViewer;
import org.eclipse.jface.viewers.ICheckStateListener;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
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.Table;
import org.eclipse.team.internal.ui.TeamUIMessages;
import org.eclipse.ui.model.WorkbenchLabelProvider;
import org.eclipse.ui.views.navigator.ResourceComparator;

public class PatchInaccessibleProjectsPage
  extends WizardPage
{
  private CheckboxTableViewer checkList;
  private Button checkAllButton;
  private Button uncheckAllButton;
  private WorkspacePatcher fPatcher;
  public static final String PATCH_INACCESSIBLE_PROJECTS_NAME = "PatchInaccessibleProjectsPage";
  
  public PatchInaccessibleProjectsPage(WorkspacePatcher patcher)
  {
    super("PatchInaccessibleProjectsPage", TeamUIMessages.PatchInaccessibleProjectsPage_title, null);
    setMessage(TeamUIMessages.PatchInaccessibleProjectsPage_message);
    fPatcher = patcher;
  }
  
  public void createControl(Composite parent)
  {
    initializeDialogUnits(parent);
    
    Composite composite = new Composite(parent, 0);
    composite.setLayout(new GridLayout(3, false));
    composite.setLayoutData(new GridData(272));
    
    setControl(composite);
    Font parentFont = composite.getFont();
    
    checkList = CheckboxTableViewer.newCheckList(composite, 2816);
    
    checkList.setContentProvider(new ArrayContentProvider());
    checkList.setLabelProvider(new WorkbenchLabelProvider()
    {
      public Color getForeground(Object element)
      {
        if (((element instanceof IProject)) && 
          (!((IProject)element).exists())) {
          return Display.getCurrent().getSystemColor(
            18);
        }
        return super.getForeground(element);
      }
      
      protected String decorateText(String input, Object element)
      {
        if (((element instanceof IProject)) && 
          (!((IProject)element).exists())) {
          return 
            input + NLS.bind(
            TeamUIMessages.PatchInaccessibleProjectsPage_projectDoesNotExistInWorkspace, 
            "");
        }
        return input;
      }
    });
    checkList.addCheckStateListener(new ICheckStateListener()
    {
      public void checkStateChanged(CheckStateChangedEvent event)
      {
        IProject project = (IProject)event.getElement();
        if ((event.getChecked()) && (!project.exists())) {
          checkList.setChecked(project, false);
        }
      }
    });checkList
      .setComparator(new ResourceComparator(1));
    
    Table table = checkList.getTable();
    GridData data = new GridData(272);
    
    horizontalSpan = 3;
    grabExcessHorizontalSpace = true;
    grabExcessVerticalSpace = true;
    table.setLayoutData(data);
    
    checkAllButton = new Button(composite, 0);
    checkAllButton
      .setText(TeamUIMessages.PatchInaccessibleProjectsPage_selectExisting);
    checkAllButton.addSelectionListener(new SelectionAdapter()
    {
      public void widgetSelected(SelectionEvent e)
      {
        PatchInaccessibleProjectsPage.this.setAllChecked(true);
      }
    });
    checkAllButton.setFont(parentFont);
    setButtonLayoutData(checkAllButton);
    
    uncheckAllButton = new Button(composite, 0);
    uncheckAllButton
      .setText(TeamUIMessages.PatchInaccessibleProjectsPage_deselectAll);
    uncheckAllButton.addSelectionListener(new SelectionAdapter()
    {
      public void widgetSelected(SelectionEvent e)
      {
        PatchInaccessibleProjectsPage.this.setAllChecked(false);
      }
    });
    uncheckAllButton.setFont(parentFont);
    setButtonLayoutData(uncheckAllButton);
    
    updateControls();
  }
  
  private void updateControls()
  {
    DiffProject[] diffProjects = fPatcher.getDiffProjects();
    List projects = new ArrayList();
    if (diffProjects != null) {
      for (int i = 0; i < diffProjects.length; i++)
      {
        IProject project = ResourcesPlugin.getWorkspace().getRoot()
          .getProject(diffProjects[i].getName());
        if (!project.isAccessible()) {
          projects.add(project);
        }
      }
    }
    checkList.setInput(projects.toArray(new IProject[0]));
  }
  
  public void setVisible(boolean visible)
  {
    super.setVisible(visible);
    if (visible) {
      updateControls();
    }
  }
  
  public IWizardPage getNextPage()
  {
    Control control = getControl();
    if ((control != null) && (control.isVisible())) {
      return null;
    }
    return super.getNextPage();
  }
  
  public IProject[] getSelectedProjects()
  {
    Object[] elements = checkList.getCheckedElements();
    List projects = new ArrayList();
    for (int i = 0; i < elements.length; i++) {
      projects.add(elements[i]);
    }
    return (IProject[])projects.toArray(new IProject[0]);
  }
  
  private void setAllChecked(boolean checked)
  {
    int count = checkList.getTable().getItemCount();
    for (int i = 0; i < count; i++)
    {
      IProject project = (IProject)checkList.getElementAt(i);
      if (project.exists()) {
        checkList.setChecked(project, checked);
      }
    }
  }
}

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

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

class ProjectSelectionPage$1
  implements ISelectionChangedListener
{
  final ProjectSelectionPage this$0;
  
  ProjectSelectionPage$1(ProjectSelectionPage paramProjectSelectionPage)
  {
    this$0 = paramProjectSelectionPage;
  }
  
  public void selectionChanged(SelectionChangedEvent event)
  {
    this$0.updateEnablements();
  }
}

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

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

class ProjectSelectionPage$2
  implements SelectionListener
{
  final ProjectSelectionPage this$0;
  
  ProjectSelectionPage$2(ProjectSelectionPage paramProjectSelectionPage)
  {
    this$0 = paramProjectSelectionPage;
  }
  
  public void widgetSelected(SelectionEvent e)
  {
    this$0.shareSelectedProject();
  }
  
  public void widgetDefaultSelected(SelectionEvent e) {}
}

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

import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Table;
import org.eclipse.team.core.RepositoryProvider;
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.ui.IConfigurationWizard;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.model.AdaptableList;
import org.eclipse.ui.model.WorkbenchContentProvider;
import org.eclipse.ui.model.WorkbenchLabelProvider;
import org.eclipse.ui.views.navigator.ResourceComparator;

public class ProjectSelectionPage
  extends WizardPage
{
  private final IProject[] projects;
  private final ConfigurationWizardElement element;
  private Button shareButton;
  private TableViewer projectViewer;
  private AdaptableList projectList;
  
  protected ProjectSelectionPage(IProject[] projects, ConfigurationWizardElement element)
  {
    super("projectSelectionPage", NLS.bind(TeamUIMessages.ProjectSelectionPage_1, element.getLabel(null)), TeamUIPlugin.getImageDescriptor("wizban/share_wizban.png"));
    setDescription(NLS.bind(TeamUIMessages.ProjectSelectionPage_0, element.getLabel(null)));
    this.projects = projects;
    this.element = element;
  }
  
  public void createControl(Composite parent)
  {
    Composite composite = SWTUtils.createHVFillComposite(parent, 1, 2);
    createProjectList(composite);
    createShareButton(composite);
    updateEnablements();
    setControl(composite);
  }
  
  private void createProjectList(Composite composite)
  {
    projectViewer = new TableViewer(composite, 2052);
    projectViewer.getControl().setLayoutData(SWTUtils.createHVFillGridData());
    projectList = new AdaptableList(projects);
    projectViewer.setContentProvider(new WorkbenchContentProvider());
    projectViewer.setLabelProvider(new WorkbenchLabelProvider());
    projectViewer.setComparator(new ResourceComparator(1));
    projectViewer.setInput(projectList);
    projectViewer.getTable().select(0);
    projectViewer.addSelectionChangedListener(new ISelectionChangedListener()
    {
      public void selectionChanged(SelectionChangedEvent event)
      {
        updateEnablements();
      }
    });
  }
  
  private void createShareButton(Composite composite)
  {
    shareButton = new Button(composite, 8);
    GridData gridData = new GridData();
    horizontalAlignment = 16777224;
    verticalAlignment = 128;
    shareButton.setLayoutData(gridData);
    shareButton.setText(TeamUIMessages.ProjectSelectionPage_2);
    shareButton.addSelectionListener(new SelectionListener()
    {
      public void widgetSelected(SelectionEvent e)
      {
        shareSelectedProject();
      }
      
      public void widgetDefaultSelected(SelectionEvent e) {}
    });
  }
  
  void shareSelectedProject()
  {
    IProject project = getSelectedProject();
    if (project != null) {
      try
      {
        IConfigurationWizard wizard = (IConfigurationWizard)element.createExecutableExtension();
        wizard.init(PlatformUI.getWorkbench(), project);
        ConfigureProjectWizard.openWizard(getShell(), wizard);
        updateProjectList(project);
        projectList.size();
      }
      catch (CoreException e)
      {
        ErrorDialog.openError(getShell(), null, null, e.getStatus());
      }
    }
  }
  
  private void updateProjectList(IProject project)
  {
    if (RepositoryProvider.isShared(project))
    {
      projectList.remove(project);
      projectViewer.refresh();
      if (hasUnsharedProjects()) {
        projectViewer.getTable().select(0);
      }
      updateEnablements();
    }
  }
  
  void updateEnablements()
  {
    shareButton.setEnabled(getSelectedProject() != null);
  }
  
  private IProject getSelectedProject()
  {
    ISelection selection = projectViewer.getSelection();
    if ((selection instanceof IStructuredSelection))
    {
      IStructuredSelection ss = (IStructuredSelection)selection;
      return (IProject)ss.getFirstElement();
    }
    return null;
  }
  
  public boolean hasUnsharedProjects()
  {
    return projectList.size() > 0;
  }
}

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

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.ui.XMLMemento;
import org.w3c.dom.Document;
import org.w3c.dom.Element;

class ProjectSetExportWizard$1
  implements IRunnableWithProgress
{
  final ProjectSetExportWizard this$0;
  private final boolean[] val$result;
  
  ProjectSetExportWizard$1(ProjectSetExportWizard paramProjectSetExportWizard, boolean[] paramArrayOfBoolean)
  {
    this$0 = paramProjectSetExportWizard;val$result = paramArrayOfBoolean;
  }
  
  /* Error */
  public void run(org.eclipse.core.runtime.IProgressMonitor monitor)
    throws java.lang.reflect.InvocationTargetException
  {
    // Byte code:
    //   0: aload_0
    //   1: getfield 364	org/eclipse/team/internal/ui/wizards/ProjectSetExportWizard$1:this$0	Lorg/eclipse/team/internal/ui/wizards/ProjectSetExportWizard;
    //   4: getfield 361	org/eclipse/team/internal/ui/wizards/ProjectSetExportWizard:locationPage	Lorg/eclipse/team/internal/ui/wizards/ExportProjectSetLocationPage;
    //   7: invokevirtual 402	org/eclipse/team/internal/ui/wizards/ExportProjectSetLocationPage:getFileName	()Ljava/lang/String;
    //   10: astore_2
    //   11: new 188	org/eclipse/core/runtime/Path
    //   14: dup
    //   15: aload_2
    //   16: invokespecial 388	org/eclipse/core/runtime/Path:<init>	(Ljava/lang/String;)V
    //   19: astore_3
    //   20: aload_3
    //   21: invokevirtual 387	org/eclipse/core/runtime/Path:getFileExtension	()Ljava/lang/String;
    //   24: ifnonnull +23 -> 47
    //   27: new 175	java/lang/StringBuffer
    //   30: dup
    //   31: aload_2
    //   32: invokestatic 376	java/lang/String:valueOf	(Ljava/lang/Object;)Ljava/lang/String;
    //   35: invokespecial 378	java/lang/StringBuffer:<init>	(Ljava/lang/String;)V
    //   38: ldc 1
    //   40: invokevirtual 379	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   43: invokevirtual 377	java/lang/StringBuffer:toString	()Ljava/lang/String;
    //   46: astore_2
    //   47: invokestatic 411	org/eclipse/team/internal/ui/wizards/PsfFilenameStore:getInstance	()Lorg/eclipse/team/internal/ui/wizards/PsfFilenameStore;
    //   50: aload_2
    //   51: invokevirtual 410	org/eclipse/team/internal/ui/wizards/PsfFilenameStore:remember	(Ljava/lang/String;)V
    //   54: new 168	java/io/File
    //   57: dup
    //   58: aload_2
    //   59: invokespecial 371	java/io/File:<init>	(Ljava/lang/String;)V
    //   62: astore 4
    //   64: aload 4
    //   66: invokevirtual 370	java/io/File:getParentFile	()Ljava/io/File;
    //   69: astore 5
    //   71: aload 5
    //   73: ifnull +78 -> 151
    //   76: aload 5
    //   78: invokevirtual 367	java/io/File:exists	()Z
    //   81: ifne +70 -> 151
    //   84: aload_0
    //   85: getfield 364	org/eclipse/team/internal/ui/wizards/ProjectSetExportWizard$1:this$0	Lorg/eclipse/team/internal/ui/wizards/ProjectSetExportWizard;
    //   88: invokevirtual 407	org/eclipse/team/internal/ui/wizards/ProjectSetExportWizard:getShell	()Lorg/eclipse/swt/widgets/Shell;
    //   91: getstatic 356	org/eclipse/team/internal/ui/TeamUIMessages:ProjectSetExportWizard_Question_4	Ljava/lang/String;
    //   94: getstatic 359	org/eclipse/team/internal/ui/TeamUIMessages:ProjectSetExportWizard_Target_directory_does_not_exist__Would_you_like_to_create_it__5	Ljava/lang/String;
    //   97: invokestatic 391	org/eclipse/jface/dialogs/MessageDialog:openQuestion	(Lorg/eclipse/swt/widgets/Shell;Ljava/lang/String;Ljava/lang/String;)Z
    //   100: istore 6
    //   102: iload 6
    //   104: ifne +11 -> 115
    //   107: aload_0
    //   108: getfield 363	org/eclipse/team/internal/ui/wizards/ProjectSetExportWizard$1:val$result	[Z
    //   111: iconst_0
    //   112: iconst_0
    //   113: bastore
    //   114: return
    //   115: aload 5
    //   117: invokevirtual 369	java/io/File:mkdirs	()Z
    //   120: istore 6
    //   122: iload 6
    //   124: ifne +27 -> 151
    //   127: aload_0
    //   128: getfield 364	org/eclipse/team/internal/ui/wizards/ProjectSetExportWizard$1:this$0	Lorg/eclipse/team/internal/ui/wizards/ProjectSetExportWizard;
    //   131: invokevirtual 407	org/eclipse/team/internal/ui/wizards/ProjectSetExportWizard:getShell	()Lorg/eclipse/swt/widgets/Shell;
    //   134: getstatic 355	org/eclipse/team/internal/ui/TeamUIMessages:ProjectSetExportWizard_Export_Problems_6	Ljava/lang/String;
    //   137: getstatic 354	org/eclipse/team/internal/ui/TeamUIMessages:ProjectSetExportWizard_An_error_occurred_creating_the_target_directory_7	Ljava/lang/String;
    //   140: invokestatic 390	org/eclipse/jface/dialogs/MessageDialog:openError	(Lorg/eclipse/swt/widgets/Shell;Ljava/lang/String;Ljava/lang/String;)V
    //   143: aload_0
    //   144: getfield 363	org/eclipse/team/internal/ui/wizards/ProjectSetExportWizard$1:val$result	[Z
    //   147: iconst_0
    //   148: iconst_0
    //   149: bastore
    //   150: return
    //   151: aload 4
    //   153: invokevirtual 367	java/io/File:exists	()Z
    //   156: ifeq +42 -> 198
    //   159: aload 4
    //   161: invokevirtual 368	java/io/File:isFile	()Z
    //   164: ifeq +34 -> 198
    //   167: aload_0
    //   168: getfield 364	org/eclipse/team/internal/ui/wizards/ProjectSetExportWizard$1:this$0	Lorg/eclipse/team/internal/ui/wizards/ProjectSetExportWizard;
    //   171: invokevirtual 407	org/eclipse/team/internal/ui/wizards/ProjectSetExportWizard:getShell	()Lorg/eclipse/swt/widgets/Shell;
    //   174: getstatic 357	org/eclipse/team/internal/ui/TeamUIMessages:ProjectSetExportWizard_Question_8	Ljava/lang/String;
    //   177: getstatic 358	org/eclipse/team/internal/ui/TeamUIMessages:ProjectSetExportWizard_Target_already_exists__Would_you_like_to_overwrite_it__9	Ljava/lang/String;
    //   180: invokestatic 391	org/eclipse/jface/dialogs/MessageDialog:openQuestion	(Lorg/eclipse/swt/widgets/Shell;Ljava/lang/String;Ljava/lang/String;)Z
    //   183: istore 6
    //   185: iload 6
    //   187: ifne +11 -> 198
    //   190: aload_0
    //   191: getfield 363	org/eclipse/team/internal/ui/wizards/ProjectSetExportWizard$1:val$result	[Z
    //   194: iconst_0
    //   195: iconst_0
    //   196: bastore
    //   197: return
    //   198: aconst_null
    //   199: checkcast 166	[Lorg/eclipse/ui/IWorkingSet;
    //   202: astore 6
    //   204: aload_0
    //   205: getfield 364	org/eclipse/team/internal/ui/wizards/ProjectSetExportWizard$1:this$0	Lorg/eclipse/team/internal/ui/wizards/ProjectSetExportWizard;
    //   208: getfield 362	org/eclipse/team/internal/ui/wizards/ProjectSetExportWizard:mainPage	Lorg/eclipse/team/internal/ui/wizards/ExportProjectSetMainPage;
    //   211: getfield 360	org/eclipse/team/internal/ui/wizards/ExportProjectSetMainPage:exportWorkingSets	Lorg/eclipse/swt/widgets/Button;
    //   214: invokevirtual 392	org/eclipse/swt/widgets/Button:getSelection	()Z
    //   217: ifeq +15 -> 232
    //   220: aload_0
    //   221: getfield 364	org/eclipse/team/internal/ui/wizards/ProjectSetExportWizard$1:this$0	Lorg/eclipse/team/internal/ui/wizards/ProjectSetExportWizard;
    //   224: getfield 362	org/eclipse/team/internal/ui/wizards/ProjectSetExportWizard:mainPage	Lorg/eclipse/team/internal/ui/wizards/ExportProjectSetMainPage;
    //   227: invokevirtual 406	org/eclipse/team/internal/ui/wizards/ExportProjectSetMainPage:getSelectedWorkingSets	()[Lorg/eclipse/ui/IWorkingSet;
    //   230: astore 6
    //   232: aload_0
    //   233: getfield 364	org/eclipse/team/internal/ui/wizards/ProjectSetExportWizard$1:this$0	Lorg/eclipse/team/internal/ui/wizards/ProjectSetExportWizard;
    //   236: getfield 362	org/eclipse/team/internal/ui/wizards/ProjectSetExportWizard:mainPage	Lorg/eclipse/team/internal/ui/wizards/ExportProjectSetMainPage;
    //   239: invokevirtual 405	org/eclipse/team/internal/ui/wizards/ExportProjectSetMainPage:getSelectedProjects	()[Lorg/eclipse/core/resources/IProject;
    //   242: astore 7
    //   244: new 177	java/util/HashMap
    //   247: dup
    //   248: invokespecial 381	java/util/HashMap:<init>	()V
    //   251: astore 8
    //   253: iconst_0
    //   254: istore 9
    //   256: goto +90 -> 346
    //   259: aload 7
    //   261: iload 9
    //   263: aaload
    //   264: astore 10
    //   266: aload 10
    //   268: invokestatic 397	org/eclipse/team/core/RepositoryProvider:getProvider	(Lorg/eclipse/core/resources/IProject;)Lorg/eclipse/team/core/RepositoryProvider;
    //   271: astore 11
    //   273: aload 11
    //   275: ifnull +68 -> 343
    //   278: aload 11
    //   280: invokevirtual 396	org/eclipse/team/core/RepositoryProvider:getID	()Ljava/lang/String;
    //   283: astore 12
    //   285: aload 8
    //   287: aload 12
    //   289: invokeinterface 418 2 0
    //   294: checkcast 180	java/util/Set
    //   297: astore 13
    //   299: aload 13
    //   301: ifnonnull +32 -> 333
    //   304: new 181	java/util/TreeSet
    //   307: dup
    //   308: new 203	org/eclipse/team/internal/ui/wizards/ProjectSetExportWizard$2
    //   311: dup
    //   312: aload_0
    //   313: invokespecial 409	org/eclipse/team/internal/ui/wizards/ProjectSetExportWizard$2:<init>	(Lorg/eclipse/team/internal/ui/wizards/ProjectSetExportWizard$1;)V
    //   316: invokespecial 382	java/util/TreeSet:<init>	(Ljava/util/Comparator;)V
    //   319: astore 13
    //   321: aload 8
    //   323: aload 12
    //   325: aload 13
    //   327: invokeinterface 419 3 0
    //   332: pop
    //   333: aload 13
    //   335: aload 10
    //   337: invokeinterface 421 2 0
    //   342: pop
    //   343: iinc 9 1
    //   346: iload 9
    //   348: aload 7
    //   350: arraylength
    //   351: if_icmplt -92 -> 259
    //   354: new 198	org/eclipse/team/internal/ui/UIProjectSetSerializationContext
    //   357: dup
    //   358: aload_0
    //   359: getfield 364	org/eclipse/team/internal/ui/wizards/ProjectSetExportWizard$1:this$0	Lorg/eclipse/team/internal/ui/wizards/ProjectSetExportWizard;
    //   362: invokevirtual 407	org/eclipse/team/internal/ui/wizards/ProjectSetExportWizard:getShell	()Lorg/eclipse/swt/widgets/Shell;
    //   365: aload_2
    //   366: invokespecial 400	org/eclipse/team/internal/ui/UIProjectSetSerializationContext:<init>	(Lorg/eclipse/swt/widgets/Shell;Ljava/lang/String;)V
    //   369: astore 9
    //   371: aconst_null
    //   372: astore 10
    //   374: aload_0
    //   375: getfield 364	org/eclipse/team/internal/ui/wizards/ProjectSetExportWizard$1:this$0	Lorg/eclipse/team/internal/ui/wizards/ProjectSetExportWizard;
    //   378: getfield 361	org/eclipse/team/internal/ui/wizards/ProjectSetExportWizard:locationPage	Lorg/eclipse/team/internal/ui/wizards/ExportProjectSetLocationPage;
    //   381: invokevirtual 401	org/eclipse/team/internal/ui/wizards/ExportProjectSetLocationPage:isSaveToFileSystem	()Z
    //   384: ifne +20 -> 404
    //   387: aload_0
    //   388: getfield 364	org/eclipse/team/internal/ui/wizards/ProjectSet
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