Assembla home | Assembla project page
 

Changeset 816:ebf9c3f0b052

Show
Ignore:
Timestamp:
08/08/08 16:47:50 (4 months ago)
Author:
Bastian Doetsch <bastian.doetsch@gmx.de>
branch:
default
Message:

"Cleanup of Share... functionality

Now uses asynchronous operation, so the wizard gives

a) progress indication and
b) doesn't freeze the GUI."

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • src/com/vectrace/MercurialEclipse/team/MercurialConfigurationWizard.java

    r761 r816  
    1111 *     Stefan Groschupf          - logError 
    1212 *     Stefan C                  - Code cleanup 
     13 *     Bastian Doetsch           - make map operation asynchronous 
    1314 *******************************************************************************/ 
    1415 
     
    2728package com.vectrace.MercurialEclipse.team; 
    2829 
    29 import java.io.BufferedReader; 
    30 import java.io.InputStreamReader; 
    3130 
    3231import org.eclipse.core.resources.IProject; 
    33 import org.eclipse.core.resources.IResource; 
    3432import org.eclipse.jface.wizard.Wizard; 
    3533import org.eclipse.jface.wizard.WizardPage; 
     
    4543import org.eclipse.swt.widgets.Shell; 
    4644import org.eclipse.swt.widgets.Text; 
    47 import org.eclipse.team.core.RepositoryProvider; 
    48 import org.eclipse.team.core.TeamException; 
    4945import org.eclipse.team.ui.IConfigurationWizard; 
    5046import org.eclipse.ui.IWorkbench; 
    5147 
    5248import com.vectrace.MercurialEclipse.MercurialEclipsePlugin; 
    53 import com.vectrace.MercurialEclipse.commands.HgClients; 
    5449import com.vectrace.MercurialEclipse.exception.HgException; 
    55 import com.vectrace.MercurialEclipse.team.cache.MercurialStatusCache
     50import com.vectrace.MercurialEclipse.operations.InitOperation
    5651 
    5752/** 
     
    6257public class MercurialConfigurationWizard extends Wizard implements 
    6358        IConfigurationWizard { 
    64     public class NewWizardPage extends WizardPage implements SelectionListener { 
     59    private class NewWizardPage extends WizardPage implements SelectionListener { 
    6560        Button changeDirButton; 
    6661        Button restoreDefaultDirButton; 
     
    158153 
    159154    private IProject project; 
    160     private String hgPath; // TODO: Not sure if this is required. 
     155    private String hgPath;  
    161156    private String hgPathOrginal; 
    162157    private String foundhgPath; 
    163158    private Text directoryText; 
     159    private NewWizardPage page; 
    164160 
    165161    public MercurialConfigurationWizard() { 
    166162        setWindowTitle("MercurialConfigurationWizard"); 
     163        setNeedsProgressMonitor(true); 
    167164    } 
    168165 
     
    182179            hgPathOrginal = project.getLocation().toString(); 
    183180            hgPath = hgPathOrginal; 
    184             addPage(new NewWizardPage(true)); 
     181            page = new NewWizardPage(true); 
     182            addPage(page); 
    185183        } else { 
    186184            foundhgPath = mercurialRootDir; 
     
    199197            hgPath = directoryText.getText(); 
    200198        } 
    201         if ((foundhgPath == null) || (!foundhgPath.equals(hgPath))) { 
    202             String launchCmd[] = { MercurialUtilities.getHGExecutable(true), 
    203                     "init", hgPath }; 
    204             try { 
    205                 String line; 
    206                 Process process = Runtime.getRuntime().exec(launchCmd); 
    207                 BufferedReader input = new BufferedReader( 
    208                         new InputStreamReader(process.getInputStream())); 
    209                 while ((line = input.readLine()) != null) { 
    210                     HgClients.getConsole().printMessage(line, null); 
    211                 } 
    212                 input.close(); 
    213                 process.waitFor(); 
    214                 project.refreshLocal(IResource.DEPTH_INFINITE, null); 
    215             } catch (Exception e) { 
    216                 MercurialEclipsePlugin.logError(e); 
    217                 return false; 
    218             } 
    219                          
    220         } 
    221199        try { 
    222             RepositoryProvider.map(project, MercurialTeamProvider.class 
    223                     .getName()); 
    224         } catch (TeamException e) { 
     200            getContainer().run(true, false, 
     201                    new InitOperation(getContainer(), project, foundhgPath, 
     202                            hgPath)); 
     203        } catch (Exception e) { 
    225204            MercurialEclipsePlugin.logError(e); 
     205            page.setErrorMessage(e.getCause().getLocalizedMessage()); 
    226206            return false; 
    227         } 
    228  
    229         try { 
    230             MercurialStatusCache.getInstance().refresh(project); 
    231         } catch (TeamException e) { 
    232             MercurialEclipsePlugin.logError("Unable to refresh project: ", e); 
    233207        } 
    234208        return true;