Changeset 816:ebf9c3f0b052
- 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
| r761 |
r816 |
|
| 11 | 11 | * Stefan Groschupf - logError |
|---|
| 12 | 12 | * Stefan C - Code cleanup |
|---|
| | 13 | * Bastian Doetsch - make map operation asynchronous |
|---|
| 13 | 14 | *******************************************************************************/ |
|---|
| 14 | 15 | |
|---|
| … | … | |
| 27 | 28 | package com.vectrace.MercurialEclipse.team; |
|---|
| 28 | 29 | |
|---|
| 29 | | import java.io.BufferedReader; |
|---|
| 30 | | import java.io.InputStreamReader; |
|---|
| 31 | 30 | |
|---|
| 32 | 31 | import org.eclipse.core.resources.IProject; |
|---|
| 33 | | import org.eclipse.core.resources.IResource; |
|---|
| 34 | 32 | import org.eclipse.jface.wizard.Wizard; |
|---|
| 35 | 33 | import org.eclipse.jface.wizard.WizardPage; |
|---|
| … | … | |
| 45 | 43 | import org.eclipse.swt.widgets.Shell; |
|---|
| 46 | 44 | import org.eclipse.swt.widgets.Text; |
|---|
| 47 | | import org.eclipse.team.core.RepositoryProvider; |
|---|
| 48 | | import org.eclipse.team.core.TeamException; |
|---|
| 49 | 45 | import org.eclipse.team.ui.IConfigurationWizard; |
|---|
| 50 | 46 | import org.eclipse.ui.IWorkbench; |
|---|
| 51 | 47 | |
|---|
| 52 | 48 | import com.vectrace.MercurialEclipse.MercurialEclipsePlugin; |
|---|
| 53 | | import com.vectrace.MercurialEclipse.commands.HgClients; |
|---|
| 54 | 49 | import com.vectrace.MercurialEclipse.exception.HgException; |
|---|
| 55 | | import com.vectrace.MercurialEclipse.team.cache.MercurialStatusCache; |
|---|
| | 50 | import com.vectrace.MercurialEclipse.operations.InitOperation; |
|---|
| 56 | 51 | |
|---|
| 57 | 52 | /** |
|---|
| … | … | |
| 62 | 57 | public class MercurialConfigurationWizard extends Wizard implements |
|---|
| 63 | 58 | IConfigurationWizard { |
|---|
| 64 | | public class NewWizardPage extends WizardPage implements SelectionListener { |
|---|
| | 59 | private class NewWizardPage extends WizardPage implements SelectionListener { |
|---|
| 65 | 60 | Button changeDirButton; |
|---|
| 66 | 61 | Button restoreDefaultDirButton; |
|---|
| … | … | |
| 158 | 153 | |
|---|
| 159 | 154 | private IProject project; |
|---|
| 160 | | private String hgPath; // TODO: Not sure if this is required. |
|---|
| | 155 | private String hgPath; |
|---|
| 161 | 156 | private String hgPathOrginal; |
|---|
| 162 | 157 | private String foundhgPath; |
|---|
| 163 | 158 | private Text directoryText; |
|---|
| | 159 | private NewWizardPage page; |
|---|
| 164 | 160 | |
|---|
| 165 | 161 | public MercurialConfigurationWizard() { |
|---|
| 166 | 162 | setWindowTitle("MercurialConfigurationWizard"); |
|---|
| | 163 | setNeedsProgressMonitor(true); |
|---|
| 167 | 164 | } |
|---|
| 168 | 165 | |
|---|
| … | … | |
| 182 | 179 | hgPathOrginal = project.getLocation().toString(); |
|---|
| 183 | 180 | hgPath = hgPathOrginal; |
|---|
| 184 | | addPage(new NewWizardPage(true)); |
|---|
| | 181 | page = new NewWizardPage(true); |
|---|
| | 182 | addPage(page); |
|---|
| 185 | 183 | } else { |
|---|
| 186 | 184 | foundhgPath = mercurialRootDir; |
|---|
| … | … | |
| 199 | 197 | hgPath = directoryText.getText(); |
|---|
| 200 | 198 | } |
|---|
| 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 | | } |
|---|
| 221 | 199 | 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) { |
|---|
| 225 | 204 | MercurialEclipsePlugin.logError(e); |
|---|
| | 205 | page.setErrorMessage(e.getCause().getLocalizedMessage()); |
|---|
| 226 | 206 | return false; |
|---|
| 227 | | } |
|---|
| 228 | | |
|---|
| 229 | | try { |
|---|
| 230 | | MercurialStatusCache.getInstance().refresh(project); |
|---|
| 231 | | } catch (TeamException e) { |
|---|
| 232 | | MercurialEclipsePlugin.logError("Unable to refresh project: ", e); |
|---|
| 233 | 207 | } |
|---|
| 234 | 208 | return true; |
|---|