|
|
import java.util.HashSet; | import java.util.HashSet; |
import java.util.Iterator; | import java.util.Iterator; |
| |
|
import org.eclipse.core.runtime.Platform; |
|
import org.eclipse.core.runtime.CoreException; |
|
import org.eclipse.core.runtime.IStatus; |
import org.eclipse.jface.dialogs.Dialog; | import org.eclipse.jface.dialogs.Dialog; |
import org.eclipse.jface.dialogs.IDialogSettings; | import org.eclipse.jface.dialogs.IDialogSettings; |
import org.eclipse.jface.resource.ImageDescriptor; | import org.eclipse.jface.resource.ImageDescriptor; |
|
|
private Label installLocation; | private Label installLocation; |
private Button changeLocation; | private Button changeLocation; |
static HashSet added; | static HashSet added; |
|
private boolean isUpdate; // whether the wizard is updating a feature or installing a new one |
| |
class JobsContentProvider | class JobsContentProvider |
extends DefaultContentProvider | extends DefaultContentProvider |
|
|
/** | /** |
* Constructor for ReviewPage2 | * Constructor for ReviewPage2 |
*/ | */ |
public TargetPage(IInstallConfiguration config) { |
public TargetPage(IInstallConfiguration config, boolean isUpdate) { |
super("Target"); //$NON-NLS-1$ | super("Target"); //$NON-NLS-1$ |
setTitle(UpdateUIMessages.InstallWizard_TargetPage_title); | setTitle(UpdateUIMessages.InstallWizard_TargetPage_title); |
setDescription(UpdateUIMessages.InstallWizard_TargetPage_desc); | setDescription(UpdateUIMessages.InstallWizard_TargetPage_desc); |
this.config = config; | this.config = config; |
UpdateUI.getDefault().getLabelProvider().connect(this); | UpdateUI.getDefault().getLabelProvider().connect(this); |
configListener = new ConfigListener(); | configListener = new ConfigListener(); |
|
this.isUpdate = isUpdate; |
} | } |
| |
public void setJobs(IInstallFeatureOperation[] jobs) { | public void setJobs(IInstallFeatureOperation[] jobs) { |
|
|
label.setLayoutData(gd); | label.setLayoutData(gd); |
| |
installLocation = new Label(client, SWT.NULL); | installLocation = new Label(client, SWT.NULL); |
installLocation.setText("foo"); //$NON-NLS-1$ |
installLocation.setText(""); //$NON-NLS-1$ |
gd = new GridData(GridData.FILL_HORIZONTAL); | gd = new GridData(GridData.FILL_HORIZONTAL); |
installLocation.setLayoutData(gd); | installLocation.setLayoutData(gd); |
| |
|
|
continue; | continue; |
} | } |
| |
jobs[i].setTargetSite(getFirstTargetSite(jobs[i])); |
IConfiguredSite csite = getFirstTargetSite(jobs[i]); |
|
if (csite == null && Platform.getInstallLocation().isReadOnly() && isUpdate == false) { |
|
// there are no updateable sites, the installation location is read-only and we are installing a new feature |
|
// make an update site in the user's home direcotry |
|
File site= new File(System.getProperty("user.home") + File.separator + ".eclipse" + File.separator + //$NON-NLS-1$ |
|
Platform.getProduct().getId() + File.separator + "updates"); //$NON-NLS-1$ |
|
|
|
try { |
|
csite = config.createConfiguredSite(site); |
|
config.addConfiguredSite(csite); |
|
IStatus status = csite.verifyUpdatableStatus(); |
|
if (!status.isOK()) |
|
throw new CoreException(status); |
|
|
|
} catch (CoreException e) { |
|
// there was a problem, the user must choose an installation site |
|
csite = null; |
|
// no need to check if the directory exists because File.delete() returns false if it's not there |
|
deleteDir(site); |
|
} |
|
} |
|
|
|
jobs[i].setTargetSite(csite); |
| |
} | } |
| |
} | } |
|
|
|
private boolean deleteDir(File dir) { |
|
if (dir.isDirectory()) { |
|
String[] files = dir.list(); |
|
for (int i=0; i < files.length; i++) { |
|
if (!deleteDir(new File(dir, files[i]))) { |
|
return false; |
|
} |
|
} |
|
} |
|
return dir.delete(); |
|
} |
| |
private IConfiguredSite getMostReceantlyUsedSite() { | private IConfiguredSite getMostReceantlyUsedSite() { |
IDialogSettings master = UpdateUI.getDefault().getDialogSettings(); | IDialogSettings master = UpdateUI.getDefault().getDialogSettings(); |
|
|
IConfiguredSite[] sites = config.getConfiguredSites(); | IConfiguredSite[] sites = config.getConfiguredSites(); |
for (int i = 0; i < sites.length; i++) { | for (int i = 0; i < sites.length; i++) { |
IConfiguredSite csite = sites[i]; | IConfiguredSite csite = sites[i]; |
if (getSiteVisibility(csite, job)) |
if (getSiteVisibility(csite, job) && |
|
csite.getSite().getCurrentConfiguredSite().verifyUpdatableStatus().isOK()) |
return csite; | return csite; |
} | } |
return null; | return null; |