|
|
9ef820f |
Index: src/org/eclipse/update/internal/ui/wizards/ModeSelectionPage.java
|
|
|
9ef820f |
===================================================================
|
|
|
9ef820f |
RCS file: /home/eclipse/org.eclipse.update.ui/src/org/eclipse/update/internal/ui/wizards/ModeSelectionPage.java,v
|
|
|
9ef820f |
retrieving revision 1.18
|
|
|
9ef820f |
diff -u -r1.18 ModeSelectionPage.java
|
|
|
9ef820f |
--- src/org/eclipse/update/internal/ui/wizards/ModeSelectionPage.java 11 Apr 2005 22:45:30 -0000 1.18
|
|
|
9ef820f |
+++ src/org/eclipse/update/internal/ui/wizards/ModeSelectionPage.java 18 May 2005 01:18:01 -0000
|
|
|
9ef820f |
@@ -10,17 +10,23 @@
|
|
|
9ef820f |
*******************************************************************************/
|
|
|
9ef820f |
package org.eclipse.update.internal.ui.wizards;
|
|
|
9ef820f |
|
|
|
9ef820f |
-import org.eclipse.jface.dialogs.*;
|
|
|
9ef820f |
+import org.eclipse.core.runtime.Platform;
|
|
|
9ef820f |
import org.eclipse.jface.dialogs.Dialog;
|
|
|
9ef820f |
+import org.eclipse.jface.dialogs.IDialogSettings;
|
|
|
9ef820f |
import org.eclipse.swt.SWT;
|
|
|
9ef820f |
-import org.eclipse.swt.events.*;
|
|
|
9ef820f |
-import org.eclipse.swt.layout.*;
|
|
|
9ef820f |
-import org.eclipse.swt.widgets.*;
|
|
|
9ef820f |
-import org.eclipse.ui.*;
|
|
|
9ef820f |
+import org.eclipse.swt.events.SelectionAdapter;
|
|
|
9ef820f |
+import org.eclipse.swt.events.SelectionEvent;
|
|
|
9ef820f |
+import org.eclipse.swt.layout.GridData;
|
|
|
9ef820f |
+import org.eclipse.swt.layout.GridLayout;
|
|
|
9ef820f |
+import org.eclipse.swt.widgets.Button;
|
|
|
9ef820f |
+import org.eclipse.swt.widgets.Composite;
|
|
|
9ef820f |
+import org.eclipse.swt.widgets.Control;
|
|
|
9ef820f |
+import org.eclipse.swt.widgets.Label;
|
|
|
9ef820f |
+import org.eclipse.ui.PlatformUI;
|
|
|
9ef820f |
import org.eclipse.update.internal.operations.UpdateUtils;
|
|
|
9ef820f |
import org.eclipse.update.internal.ui.UpdateUI;
|
|
|
9ef820f |
import org.eclipse.update.internal.ui.UpdateUIMessages;
|
|
|
9ef820f |
-import org.eclipse.update.search.*;
|
|
|
9ef820f |
+import org.eclipse.update.search.UpdateSearchRequest;
|
|
|
9ef820f |
|
|
|
9ef820f |
/**
|
|
|
9ef820f |
*/
|
|
|
9ef820f |
@@ -65,10 +71,17 @@
|
|
|
9ef820f |
GridLayout layout = new GridLayout();
|
|
|
9ef820f |
composite.setLayout(layout);
|
|
|
9ef820f |
updatesButton = new Button(composite, SWT.RADIO);
|
|
|
9ef820f |
- updatesButton.setText(UpdateUIMessages.ModeSelectionPage_updates);
|
|
|
9ef820f |
+ updatesButton.setText(UpdateUIMessages.ModeSelectionPage_updates);
|
|
|
9ef820f |
updateMode = !getSettings().getBoolean(P_NEW_FEATURES_MODE);
|
|
|
9ef820f |
+ // don't allow updates if the installation location is readonly
|
|
|
9ef820f |
+ if (Platform.getInstallLocation().isReadOnly()) {
|
|
|
9ef820f |
+ updatesButton.setEnabled(false);
|
|
|
9ef820f |
+ updateMode = false;
|
|
|
9ef820f |
+ }
|
|
|
9ef820f |
updatesButton.setSelection(updateMode);
|
|
|
9ef820f |
|
|
|
9ef820f |
+
|
|
|
9ef820f |
+
|
|
|
9ef820f |
final Label updatesText = new Label(composite, SWT.WRAP);
|
|
|
9ef820f |
updatesText.setText(UpdateUIMessages.ModeSelectionPage_updatesText);
|
|
|
9ef820f |
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
|
|
Andrew Overholt |
33dd0d6 |
Index: src/org/eclipse/update/internal/ui/wizards/TargetPage.java
|
|
Andrew Overholt |
33dd0d6 |
===================================================================
|
|
Andrew Overholt |
33dd0d6 |
RCS file: /home/eclipse/org.eclipse.update.ui/src/org/eclipse/update/internal/ui/wizards/TargetPage.java,v
|
|
|
9ef820f |
retrieving revision 1.71
|
|
|
9ef820f |
diff -u -r1.71 TargetPage.java
|
|
|
9ef820f |
--- src/org/eclipse/update/internal/ui/wizards/TargetPage.java 28 Apr 2005 18:22:31 -0000 1.71
|
|
|
9ef820f |
+++ src/org/eclipse/update/internal/ui/wizards/TargetPage.java 18 May 2005 01:18:01 -0000
|
|
|
9ef820f |
@@ -1,420 +1,463 @@
|
|
|
9ef820f |
-/*******************************************************************************
|
|
|
9ef820f |
- * Copyright (c) 2000, 2005 IBM Corporation and others.
|
|
|
9ef820f |
- * All rights reserved. This program and the accompanying materials
|
|
|
9ef820f |
- * are made available under the terms of the Eclipse Public License v1.0
|
|
|
9ef820f |
- * which accompanies this distribution, and is available at
|
|
|
9ef820f |
- * http://www.eclipse.org/legal/epl-v10.html
|
|
|
9ef820f |
- *
|
|
|
9ef820f |
- * Contributors:
|
|
|
9ef820f |
- * IBM Corporation - initial API and implementation
|
|
|
9ef820f |
- *******************************************************************************/
|
|
|
9ef820f |
-package org.eclipse.update.internal.ui.wizards;
|
|
|
9ef820f |
-
|
|
Andrew Overholt |
33dd0d6 |
-import java.io.*;
|
|
Andrew Overholt |
33dd0d6 |
-import java.util.*;
|
|
|
9ef820f |
-
|
|
|
9ef820f |
-import org.eclipse.jface.dialogs.Dialog;
|
|
Andrew Overholt |
33dd0d6 |
-import org.eclipse.jface.resource.*;
|
|
Andrew Overholt |
33dd0d6 |
-import org.eclipse.jface.viewers.*;
|
|
|
9ef820f |
-import org.eclipse.osgi.util.NLS;
|
|
Andrew Overholt |
33dd0d6 |
-import org.eclipse.swt.*;
|
|
Andrew Overholt |
33dd0d6 |
-import org.eclipse.swt.events.*;
|
|
Andrew Overholt |
33dd0d6 |
-import org.eclipse.swt.graphics.*;
|
|
Andrew Overholt |
33dd0d6 |
-import org.eclipse.swt.layout.*;
|
|
Andrew Overholt |
33dd0d6 |
-import org.eclipse.swt.widgets.*;
|
|
|
9ef820f |
-import org.eclipse.ui.*;
|
|
Andrew Overholt |
33dd0d6 |
-import org.eclipse.update.configuration.*;
|
|
Andrew Overholt |
33dd0d6 |
-import org.eclipse.update.core.*;
|
|
Andrew Overholt |
33dd0d6 |
-import org.eclipse.update.internal.operations.*;
|
|
Andrew Overholt |
33dd0d6 |
-import org.eclipse.update.internal.ui.*;
|
|
Andrew Overholt |
33dd0d6 |
-import org.eclipse.update.internal.ui.parts.*;
|
|
Andrew Overholt |
33dd0d6 |
-import org.eclipse.update.operations.*;
|
|
|
9ef820f |
-
|
|
|
9ef820f |
-public class TargetPage extends BannerPage implements IDynamicPage {
|
|
|
9ef820f |
- private TableViewer jobViewer;
|
|
|
9ef820f |
- private IInstallConfiguration config;
|
|
|
9ef820f |
- private ConfigListener configListener;
|
|
|
9ef820f |
- private Label requiredSpaceLabel;
|
|
|
9ef820f |
- private Label availableSpaceLabel;
|
|
|
9ef820f |
- private IInstallFeatureOperation[] jobs;
|
|
|
9ef820f |
- //private IInstallFeatureOperation currentJob;
|
|
|
9ef820f |
- private Label installLocation;
|
|
|
9ef820f |
- private Button changeLocation;
|
|
|
9ef820f |
- static HashSet added;
|
|
|
9ef820f |
-
|
|
|
9ef820f |
- class JobsContentProvider
|
|
|
9ef820f |
- extends DefaultContentProvider
|
|
|
9ef820f |
- implements IStructuredContentProvider {
|
|
|
9ef820f |
- public Object[] getElements(Object parent) {
|
|
|
9ef820f |
- return jobs;
|
|
|
9ef820f |
- }
|
|
|
9ef820f |
- }
|
|
|
9ef820f |
-
|
|
|
9ef820f |
- class JobsLabelProvider
|
|
|
9ef820f |
- extends LabelProvider
|
|
|
9ef820f |
- implements ITableLabelProvider {
|
|
|
9ef820f |
-
|
|
|
9ef820f |
- public Image getColumnImage(Object obj, int col) {
|
|
|
9ef820f |
- UpdateLabelProvider provider = UpdateUI.getDefault().getLabelProvider();
|
|
|
9ef820f |
-
|
|
|
9ef820f |
- IInstallFeatureOperation job = (IInstallFeatureOperation) obj;
|
|
|
9ef820f |
- ImageDescriptor base =
|
|
|
9ef820f |
- job.getFeature().isPatch()
|
|
|
9ef820f |
- ? UpdateUIImages.DESC_EFIX_OBJ
|
|
|
9ef820f |
- : UpdateUIImages.DESC_FEATURE_OBJ;
|
|
|
9ef820f |
- int flags = 0;
|
|
|
9ef820f |
- if (job.getTargetSite() == null)
|
|
|
9ef820f |
- flags = UpdateLabelProvider.F_ERROR;
|
|
|
9ef820f |
- return provider.get(base, flags);
|
|
|
9ef820f |
- }
|
|
|
9ef820f |
-
|
|
|
9ef820f |
- public String getColumnText(Object obj, int col) {
|
|
|
9ef820f |
- if (col == 0) {
|
|
|
9ef820f |
- IFeature feature = ((IInstallFeatureOperation) obj).getFeature();
|
|
|
9ef820f |
- return feature.getLabel()
|
|
|
9ef820f |
- + " " //$NON-NLS-1$
|
|
|
9ef820f |
- + feature.getVersionedIdentifier().getVersion().toString();
|
|
|
9ef820f |
- }
|
|
|
9ef820f |
- return null;
|
|
|
9ef820f |
- }
|
|
|
9ef820f |
- }
|
|
|
9ef820f |
-
|
|
|
9ef820f |
- class ConfigListener implements IInstallConfigurationChangedListener {
|
|
|
9ef820f |
- public void installSiteAdded(IConfiguredSite csite) {
|
|
|
9ef820f |
-
|
|
|
9ef820f |
- // set the site as target for all jobs without a target
|
|
|
9ef820f |
- for (int i=0; jobs != null && i
|
|
|
9ef820f |
- if (jobs[i].getTargetSite() == null && getSiteVisibility(csite, jobs[i])) {
|
|
|
9ef820f |
- jobs[i].setTargetSite(csite);
|
|
|
9ef820f |
- }
|
|
|
9ef820f |
-
|
|
|
9ef820f |
- jobViewer.refresh();
|
|
|
9ef820f |
- }
|
|
|
9ef820f |
-
|
|
|
9ef820f |
- public void installSiteRemoved(IConfiguredSite csite) {
|
|
|
9ef820f |
- // remove the target site for all jobs that use it
|
|
|
9ef820f |
- // set the site as target for all jobs without a target
|
|
|
9ef820f |
- boolean refreshJobs = false;
|
|
|
9ef820f |
- for (int i=0; jobs != null && i
|
|
|
9ef820f |
- if (jobs[i].getTargetSite() == csite) {
|
|
|
9ef820f |
- jobs[i].setTargetSite(null);
|
|
|
9ef820f |
- refreshJobs = true;
|
|
|
9ef820f |
- }
|
|
|
9ef820f |
-
|
|
|
9ef820f |
- pageChanged();
|
|
|
9ef820f |
-
|
|
|
9ef820f |
- jobViewer.refresh();
|
|
|
9ef820f |
- if (refreshJobs) {
|
|
|
9ef820f |
- jobViewer.getControl().setFocus();
|
|
|
9ef820f |
- }
|
|
|
9ef820f |
- }
|
|
|
9ef820f |
- }
|
|
|
9ef820f |
-
|
|
|
9ef820f |
- /**
|
|
|
9ef820f |
- * Constructor for ReviewPage2
|
|
|
9ef820f |
- */
|
|
|
9ef820f |
- public TargetPage(IInstallConfiguration config) {
|
|
|
9ef820f |
- super("Target"); //$NON-NLS-1$
|
|
|
9ef820f |
- setTitle(UpdateUIMessages.InstallWizard_TargetPage_title);
|
|
|
9ef820f |
- setDescription(UpdateUIMessages.InstallWizard_TargetPage_desc);
|
|
|
9ef820f |
- this.config = config;
|
|
|
9ef820f |
- UpdateUI.getDefault().getLabelProvider().connect(this);
|
|
|
9ef820f |
- configListener = new ConfigListener();
|
|
|
9ef820f |
- }
|
|
|
9ef820f |
-
|
|
|
9ef820f |
- public void setJobs(IInstallFeatureOperation[] jobs) {
|
|
|
9ef820f |
- this.jobs = jobs;
|
|
|
9ef820f |
- }
|
|
|
9ef820f |
-
|
|
|
9ef820f |
- public void dispose() {
|
|
|
9ef820f |
- UpdateUI.getDefault().getLabelProvider().disconnect(this);
|
|
|
9ef820f |
-// config.removeInstallConfigurationChangedListener(configListener);
|
|
|
9ef820f |
- super.dispose();
|
|
|
9ef820f |
- }
|
|
|
9ef820f |
-
|
|
|
9ef820f |
- public Control createContents(Composite parent) {
|
|
|
9ef820f |
- Composite client = new Composite(parent, SWT.NULL);
|
|
|
9ef820f |
- GridLayout layout = new GridLayout();
|
|
|
9ef820f |
- layout.numColumns = 3;
|
|
|
9ef820f |
- layout.marginWidth = layout.marginHeight = 0;
|
|
|
9ef820f |
- client.setLayout(layout);
|
|
|
9ef820f |
- client.setLayoutData(new GridData(GridData.FILL_BOTH));
|
|
|
9ef820f |
-
|
|
|
9ef820f |
- Label label = new Label(client, SWT.NULL);
|
|
|
9ef820f |
- label.setText(UpdateUIMessages.InstallWizard_TargetPage_jobsLabel);
|
|
|
9ef820f |
- createJobViewer(client);
|
|
|
9ef820f |
-
|
|
|
9ef820f |
- label = new Label(client, SWT.NULL);
|
|
|
9ef820f |
- label.setText(UpdateUIMessages.InstallWizard_TargetPage_location);
|
|
|
9ef820f |
- GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
|
|
|
9ef820f |
- label.setLayoutData(gd);
|
|
|
9ef820f |
-
|
|
|
9ef820f |
- installLocation = new Label(client, SWT.NULL);
|
|
Andrew Overholt |
33dd0d6 |
- installLocation.setText("foo");
|
|
|
9ef820f |
- gd = new GridData(GridData.FILL_HORIZONTAL);
|
|
|
9ef820f |
- installLocation.setLayoutData(gd);
|
|
|
9ef820f |
-
|
|
|
9ef820f |
- changeLocation = new Button(client, SWT.PUSH);
|
|
|
9ef820f |
- changeLocation.setText(UpdateUIMessages.InstallWizard_TargetPage_location_change);
|
|
|
9ef820f |
- changeLocation.addSelectionListener(new SelectionAdapter() {
|
|
|
9ef820f |
- public void widgetSelected(SelectionEvent e) {
|
|
|
9ef820f |
- IStructuredSelection selection = (IStructuredSelection) jobViewer.getSelection();
|
|
|
9ef820f |
- if (selection == null)
|
|
|
9ef820f |
- return;
|
|
|
9ef820f |
- IInstallFeatureOperation job = (IInstallFeatureOperation) selection.getFirstElement();
|
|
|
9ef820f |
- if (job == null)
|
|
|
9ef820f |
- return;
|
|
|
9ef820f |
-
|
|
|
9ef820f |
- TargetSiteDialog dialog = new TargetSiteDialog(getShell(), config, job, configListener);
|
|
|
9ef820f |
- dialog.create();
|
|
|
9ef820f |
-
|
|
|
9ef820f |
- SWTUtil.setDialogSize(dialog, 400, 300);
|
|
|
9ef820f |
-
|
|
|
9ef820f |
- dialog.getShell().setText(UpdateUIMessages.SitePage_new);
|
|
|
9ef820f |
- dialog.open();
|
|
|
9ef820f |
- setTargetLocation(job);
|
|
|
9ef820f |
- pageChanged();
|
|
|
9ef820f |
- jobViewer.refresh();
|
|
|
9ef820f |
- updateStatus(job.getTargetSite());
|
|
|
9ef820f |
- }
|
|
|
9ef820f |
- });
|
|
|
9ef820f |
-
|
|
|
9ef820f |
- Composite status = new Composite(client, SWT.NULL);
|
|
|
9ef820f |
- gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
|
|
|
9ef820f |
- gd.horizontalSpan = 3;
|
|
|
9ef820f |
- status.setLayoutData(gd);
|
|
|
9ef820f |
- layout = new GridLayout();
|
|
|
9ef820f |
- layout.numColumns = 2;
|
|
|
9ef820f |
- status.setLayout(layout);
|
|
|
9ef820f |
- label = new Label(status, SWT.NULL);
|
|
|
9ef820f |
- label.setText(UpdateUIMessages.InstallWizard_TargetPage_requiredSpace);
|
|
|
9ef820f |
- requiredSpaceLabel = new Label(status, SWT.NULL);
|
|
|
9ef820f |
- requiredSpaceLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
|
|
9ef820f |
- label = new Label(status, SWT.NULL);
|
|
|
9ef820f |
- label.setText(UpdateUIMessages.InstallWizard_TargetPage_availableSpace);
|
|
|
9ef820f |
- availableSpaceLabel = new Label(status, SWT.NULL);
|
|
|
9ef820f |
- availableSpaceLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
|
|
9ef820f |
-
|
|
|
9ef820f |
- PlatformUI.getWorkbench().getHelpSystem().setHelp(client, "org.eclipse.update.ui.MultiTargetPage2"); //$NON-NLS-1$
|
|
|
9ef820f |
-
|
|
|
9ef820f |
- Dialog.applyDialogFont(parent);
|
|
|
9ef820f |
-
|
|
|
9ef820f |
- return client;
|
|
|
9ef820f |
- }
|
|
|
9ef820f |
-
|
|
|
9ef820f |
- private void createJobViewer(Composite parent) {
|
|
|
9ef820f |
- jobViewer = new TableViewer(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
|
|
|
9ef820f |
- GridData gd = new GridData(GridData.FILL_BOTH);
|
|
|
9ef820f |
- gd.horizontalSpan = 3;
|
|
|
9ef820f |
- gd.widthHint = 150;
|
|
|
9ef820f |
- jobViewer.getTable().setLayoutData(gd);
|
|
|
9ef820f |
- jobViewer.setContentProvider(new JobsContentProvider());
|
|
|
9ef820f |
- jobViewer.setLabelProvider(new JobsLabelProvider());
|
|
|
9ef820f |
-
|
|
|
9ef820f |
- jobViewer.addSelectionChangedListener(new ISelectionChangedListener() {
|
|
|
9ef820f |
- public void selectionChanged(SelectionChangedEvent event) {
|
|
|
9ef820f |
- IStructuredSelection selection = (IStructuredSelection) event.getSelection();
|
|
|
9ef820f |
- IInstallFeatureOperation job = (IInstallFeatureOperation) selection.getFirstElement();
|
|
|
9ef820f |
- setTargetLocation(job);
|
|
|
9ef820f |
- }
|
|
|
9ef820f |
- });
|
|
|
9ef820f |
- }
|
|
|
9ef820f |
-
|
|
|
9ef820f |
- public void setVisible(boolean visible) {
|
|
|
9ef820f |
- if (visible) {
|
|
|
9ef820f |
- initializeDefaultTargetSites();
|
|
|
9ef820f |
- jobViewer.setInput(jobs);
|
|
|
9ef820f |
- if (jobViewer.getSelection().isEmpty() && jobs.length > 0)
|
|
|
9ef820f |
- jobViewer.setSelection(new StructuredSelection(jobs[0]));
|
|
|
9ef820f |
- }
|
|
|
9ef820f |
-
|
|
|
9ef820f |
- super.setVisible(visible);
|
|
|
9ef820f |
- }
|
|
|
9ef820f |
-
|
|
|
9ef820f |
- private void verifyNotEmpty(boolean empty) {
|
|
|
9ef820f |
- String errorMessage = null;
|
|
|
9ef820f |
- if (empty)
|
|
|
9ef820f |
- errorMessage = UpdateUIMessages.InstallWizard_TargetPage_location_empty;
|
|
|
9ef820f |
- setErrorMessage(errorMessage);
|
|
|
9ef820f |
- setPageComplete(!empty);
|
|
|
9ef820f |
- }
|
|
|
9ef820f |
-
|
|
|
9ef820f |
-
|
|
|
9ef820f |
- private void updateStatus(Object element) {
|
|
|
9ef820f |
- if (element == null) {
|
|
|
9ef820f |
- requiredSpaceLabel.setText(""); //$NON-NLS-1$
|
|
|
9ef820f |
- availableSpaceLabel.setText(""); //$NON-NLS-1$
|
|
|
9ef820f |
- return;
|
|
|
9ef820f |
- }
|
|
|
9ef820f |
- IConfiguredSite site = (IConfiguredSite) element;
|
|
|
9ef820f |
- File file = new File(site.getSite().getURL().getFile());
|
|
|
9ef820f |
- long available = LocalSystemInfo.getFreeSpace(file);
|
|
|
9ef820f |
- long required = computeRequiredSizeFor(site);
|
|
|
9ef820f |
- if (required <= 0)
|
|
|
9ef820f |
- requiredSpaceLabel.setText(UpdateUIMessages.InstallWizard_TargetPage_unknownSize);
|
|
|
9ef820f |
- else
|
|
|
9ef820f |
- requiredSpaceLabel.setText(
|
|
|
9ef820f |
- NLS.bind(UpdateUIMessages.InstallWizard_TargetPage_size, "" + required)); //$NON-NLS-1$
|
|
|
9ef820f |
-
|
|
|
9ef820f |
- if (available == LocalSystemInfo.SIZE_UNKNOWN)
|
|
|
9ef820f |
- availableSpaceLabel.setText(UpdateUIMessages.InstallWizard_TargetPage_unknownSize);
|
|
|
9ef820f |
- else
|
|
|
9ef820f |
- availableSpaceLabel.setText(
|
|
|
9ef820f |
- NLS.bind(UpdateUIMessages.InstallWizard_TargetPage_size, "" + available)); //$NON-NLS-1$
|
|
|
9ef820f |
- }
|
|
|
9ef820f |
-
|
|
|
9ef820f |
- private long computeRequiredSizeFor(IConfiguredSite site) {
|
|
|
9ef820f |
- long totalSize = 0;
|
|
|
9ef820f |
- for (int i = 0; i < jobs.length; i++) {
|
|
|
9ef820f |
- if (site.equals(jobs[i].getTargetSite())) {
|
|
|
9ef820f |
- long jobSize = site.getSite().getInstallSizeFor(jobs[i].getFeature());
|
|
|
9ef820f |
- if (jobSize == -1)
|
|
|
9ef820f |
- return -1;
|
|
|
9ef820f |
- totalSize += jobSize;
|
|
|
9ef820f |
- }
|
|
|
9ef820f |
- }
|
|
|
9ef820f |
- return totalSize;
|
|
|
9ef820f |
- }
|
|
|
9ef820f |
-
|
|
|
9ef820f |
- private void pageChanged() {
|
|
|
9ef820f |
- boolean empty = false;
|
|
|
9ef820f |
- for (int i=0; jobs!=null && i
|
|
|
9ef820f |
- if (jobs[i].getTargetSite() == null) {
|
|
|
9ef820f |
- empty = true;
|
|
|
9ef820f |
- break;
|
|
|
9ef820f |
- }
|
|
|
9ef820f |
-
|
|
|
9ef820f |
- IFeature feature = jobs[i].getFeature();
|
|
|
9ef820f |
- if (feature.isPatch()) {
|
|
|
9ef820f |
- // Patches must go together with the features
|
|
|
9ef820f |
- // they are patching.
|
|
|
9ef820f |
-
|
|
|
9ef820f |
- // Check current jobs
|
|
|
9ef820f |
- IInstallFeatureOperation patchedFeatureJob = findPatchedFeature(feature);
|
|
|
9ef820f |
- if (patchedFeatureJob != null
|
|
|
9ef820f |
- && patchedFeatureJob.getTargetSite() != null
|
|
|
9ef820f |
- && !jobs[i].getTargetSite().equals(patchedFeatureJob.getTargetSite())) {
|
|
|
9ef820f |
- String msg = NLS.bind(UpdateUIMessages.InstallWizard_TargetPage_patchError, (new String[] {
|
|
|
9ef820f |
- feature.getLabel(),
|
|
|
9ef820f |
- patchedFeatureJob.getFeature().getLabel()}));
|
|
|
9ef820f |
- setErrorMessage(msg);
|
|
|
9ef820f |
- setPageComplete(false);
|
|
|
9ef820f |
- return;
|
|
|
9ef820f |
- }
|
|
|
9ef820f |
- // Check installed features
|
|
|
9ef820f |
- IFeature patchedFeature = UpdateUtils.getPatchedFeature(feature);
|
|
|
9ef820f |
- if (patchedFeature != null
|
|
|
9ef820f |
- && !jobs[i].getTargetSite().equals(patchedFeature.getSite().getCurrentConfiguredSite())) {
|
|
|
9ef820f |
- String msg = NLS.bind(UpdateUIMessages.InstallWizard_TargetPage_patchError2, (new String[] {
|
|
|
9ef820f |
- feature.getLabel(),
|
|
|
9ef820f |
- patchedFeature.getLabel(),
|
|
|
9ef820f |
- patchedFeature.getSite().getCurrentConfiguredSite().getSite().getURL().getFile()}));
|
|
|
9ef820f |
- setErrorMessage(msg);
|
|
|
9ef820f |
- setPageComplete(false);
|
|
|
9ef820f |
- return;
|
|
|
9ef820f |
- }
|
|
|
9ef820f |
- }
|
|
|
9ef820f |
- }
|
|
|
9ef820f |
- verifyNotEmpty(empty);
|
|
|
9ef820f |
- }
|
|
|
9ef820f |
-
|
|
|
9ef820f |
-
|
|
|
9ef820f |
- private boolean getSiteVisibility(IConfiguredSite site, IInstallFeatureOperation job) {
|
|
|
9ef820f |
- // Do not allow installing into a non-updateable site
|
|
|
9ef820f |
- if (!site.isUpdatable())
|
|
|
9ef820f |
- return false;
|
|
|
9ef820f |
-
|
|
|
9ef820f |
- // If affinity site is known, only it should be shown
|
|
|
9ef820f |
- IConfiguredSite affinitySite = UpdateUtils.getAffinitySite(config, job.getFeature());
|
|
|
9ef820f |
- if (affinitySite != null) {
|
|
|
9ef820f |
- // Must compare referenced sites because
|
|
|
9ef820f |
- // configured sites themselves may come from
|
|
|
9ef820f |
- // different configurations
|
|
|
9ef820f |
- return site.getSite().equals(affinitySite.getSite());
|
|
|
9ef820f |
- }
|
|
|
9ef820f |
-
|
|
|
9ef820f |
- // Co-locate updates with the old feature
|
|
|
9ef820f |
- if (job.getOldFeature() != null) {
|
|
|
9ef820f |
- IConfiguredSite oldSite = UpdateUtils.getSiteWithFeature(config, job.getOldFeature().getVersionedIdentifier().getIdentifier());
|
|
|
9ef820f |
- return (site == oldSite);
|
|
|
9ef820f |
- }
|
|
|
9ef820f |
-
|
|
|
9ef820f |
- // Allow installing into any site that is updateable and there is no affinity specified
|
|
|
9ef820f |
- return true;
|
|
|
9ef820f |
- }
|
|
|
9ef820f |
-
|
|
|
9ef820f |
- private void initializeDefaultTargetSites() {
|
|
|
9ef820f |
- for (int i = 0; i < jobs.length; i++) {
|
|
|
9ef820f |
- if (jobs[i].getTargetSite() != null)
|
|
|
9ef820f |
- continue;
|
|
|
9ef820f |
-
|
|
|
9ef820f |
- IConfiguredSite affinitySite = UpdateUtils.getAffinitySite(config, jobs[i].getFeature());
|
|
|
9ef820f |
- if (affinitySite != null) {
|
|
|
9ef820f |
- jobs[i].setTargetSite(affinitySite);
|
|
|
9ef820f |
- continue;
|
|
|
9ef820f |
- }
|
|
|
9ef820f |
-
|
|
|
9ef820f |
- IConfiguredSite defaultSite = UpdateUtils.getDefaultTargetSite(config, jobs[i], false);
|
|
|
9ef820f |
- if (defaultSite != null) {
|
|
|
9ef820f |
- jobs[i].setTargetSite(defaultSite);
|
|
|
9ef820f |
- continue;
|
|
|
9ef820f |
- }
|
|
|
9ef820f |
-
|
|
Andrew Overholt |
33dd0d6 |
- jobs[i].setTargetSite(getFirstTargetSite(jobs[i]));
|
|
Ben Konrath |
4bcf195 |
-
|
|
|
9ef820f |
- }
|
|
|
9ef820f |
- }
|
|
|
9ef820f |
-
|
|
|
9ef820f |
-
|
|
|
9ef820f |
- private IConfiguredSite getFirstTargetSite(IInstallFeatureOperation job) {
|
|
|
9ef820f |
- IConfiguredSite[] sites = config.getConfiguredSites();
|
|
|
9ef820f |
- for (int i = 0; i < sites.length; i++) {
|
|
|
9ef820f |
- IConfiguredSite csite = sites[i];
|
|
Ben Konrath |
4bcf195 |
- if (getSiteVisibility(csite, job))
|
|
|
9ef820f |
- return csite;
|
|
|
9ef820f |
- }
|
|
|
9ef820f |
- return null;
|
|
|
9ef820f |
- }
|
|
|
9ef820f |
-
|
|
|
9ef820f |
- public IInstallFeatureOperation findPatchedFeature(IFeature patch) {
|
|
|
9ef820f |
- for (int i=0; i
|
|
|
9ef820f |
- IFeature target = jobs[i].getFeature();
|
|
|
9ef820f |
- if (!target.equals(patch) && UpdateUtils.isPatch(target, patch))
|
|
|
9ef820f |
- return jobs[i];
|
|
|
9ef820f |
- }
|
|
|
9ef820f |
- return null;
|
|
|
9ef820f |
- }
|
|
|
9ef820f |
-
|
|
|
9ef820f |
-
|
|
|
9ef820f |
- void removeAddedSites() {
|
|
|
9ef820f |
- if (added != null) {
|
|
|
9ef820f |
- while (!added.isEmpty()) {
|
|
|
9ef820f |
- Iterator it = added.iterator();
|
|
|
9ef820f |
- if (it.hasNext())
|
|
|
9ef820f |
- config.removeConfiguredSite((IConfiguredSite) it.next());
|
|
|
9ef820f |
- }
|
|
|
9ef820f |
- }
|
|
|
9ef820f |
- }
|
|
|
9ef820f |
-
|
|
|
9ef820f |
- /* (non-Javadoc)
|
|
|
9ef820f |
- * @see org.eclipse.jface.wizard.IWizardPage#isPageComplete()
|
|
|
9ef820f |
- */
|
|
|
9ef820f |
- public boolean isPageComplete() {
|
|
|
9ef820f |
- // check if all jobs have a target site set
|
|
|
9ef820f |
- for (int i = 0; jobs != null && i < jobs.length; i++) {
|
|
|
9ef820f |
- if (jobs[i].getTargetSite() == null)
|
|
|
9ef820f |
- return false;
|
|
|
9ef820f |
- }
|
|
|
9ef820f |
- return super.isPageComplete();
|
|
|
9ef820f |
- }
|
|
|
9ef820f |
-
|
|
|
9ef820f |
- /**
|
|
|
9ef820f |
- * @param job
|
|
|
9ef820f |
- */
|
|
|
9ef820f |
- private void setTargetLocation(IInstallFeatureOperation job) {
|
|
|
9ef820f |
- if (job != null && job.getTargetSite() != null) {
|
|
|
9ef820f |
- installLocation.setText(new File(job.getTargetSite().getSite().getURL().getFile()).toString());
|
|
|
9ef820f |
- updateStatus(job.getTargetSite());
|
|
|
9ef820f |
- }
|
|
|
9ef820f |
- }
|
|
|
9ef820f |
-}
|
|
|
9ef820f |
+/*******************************************************************************
|
|
|
9ef820f |
+ * Copyright (c) 2000, 2005 IBM Corporation and others.
|
|
|
9ef820f |
+ * All rights reserved. This program and the accompanying materials
|
|
|
9ef820f |
+ * are made available under the terms of the Eclipse Public License v1.0
|
|
|
9ef820f |
+ * which accompanies this distribution, and is available at
|
|
|
9ef820f |
+ * http://www.eclipse.org/legal/epl-v10.html
|
|
|
9ef820f |
+ *
|
|
|
9ef820f |
+ * Contributors:
|
|
|
9ef820f |
+ * IBM Corporation - initial API and implementation
|
|
|
9ef820f |
+ *******************************************************************************/
|
|
|
9ef820f |
+package org.eclipse.update.internal.ui.wizards;
|
|
|
9ef820f |
+
|
|
|
9ef820f |
+import java.io.File;
|
|
|
9ef820f |
+import java.util.HashSet;
|
|
|
9ef820f |
+import java.util.Iterator;
|
|
|
9ef820f |
+
|
|
|
9ef820f |
+import org.eclipse.core.runtime.CoreException;
|
|
|
9ef820f |
+import org.eclipse.core.runtime.IStatus;
|
|
|
9ef820f |
+import org.eclipse.core.runtime.Platform;
|
|
|
9ef820f |
+import org.eclipse.jface.dialogs.Dialog;
|
|
|
9ef820f |
+import org.eclipse.jface.resource.ImageDescriptor;
|
|
|
9ef820f |
+import org.eclipse.jface.viewers.ISelectionChangedListener;
|
|
|
9ef820f |
+import org.eclipse.jface.viewers.IStructuredContentProvider;
|
|
|
9ef820f |
+import org.eclipse.jface.viewers.IStructuredSelection;
|
|
|
9ef820f |
+import org.eclipse.jface.viewers.ITableLabelProvider;
|
|
|
9ef820f |
+import org.eclipse.jface.viewers.LabelProvider;
|
|
|
9ef820f |
+import org.eclipse.jface.viewers.SelectionChangedEvent;
|
|
|
9ef820f |
+import org.eclipse.jface.viewers.StructuredSelection;
|
|
|
9ef820f |
+import org.eclipse.jface.viewers.TableViewer;
|
|
|
9ef820f |
+import org.eclipse.osgi.util.NLS;
|
|
|
9ef820f |
+import org.eclipse.swt.SWT;
|
|
|
9ef820f |
+import org.eclipse.swt.events.SelectionAdapter;
|
|
|
9ef820f |
+import org.eclipse.swt.events.SelectionEvent;
|
|
|
9ef820f |
+import org.eclipse.swt.graphics.Image;
|
|
|
9ef820f |
+import org.eclipse.swt.layout.GridData;
|
|
|
9ef820f |
+import org.eclipse.swt.layout.GridLayout;
|
|
|
9ef820f |
+import org.eclipse.swt.widgets.Button;
|
|
|
9ef820f |
+import org.eclipse.swt.widgets.Composite;
|
|
|
9ef820f |
+import org.eclipse.swt.widgets.Control;
|
|
|
9ef820f |
+import org.eclipse.swt.widgets.Label;
|
|
|
9ef820f |
+import org.eclipse.ui.PlatformUI;
|
|
|
9ef820f |
+import org.eclipse.update.configuration.IConfiguredSite;
|
|
|
9ef820f |
+import org.eclipse.update.configuration.IInstallConfiguration;
|
|
|
9ef820f |
+import org.eclipse.update.configuration.IInstallConfigurationChangedListener;
|
|
|
9ef820f |
+import org.eclipse.update.configuration.LocalSystemInfo;
|
|
|
9ef820f |
+import org.eclipse.update.core.IFeature;
|
|
|
9ef820f |
+import org.eclipse.update.internal.operations.UpdateUtils;
|
|
|
9ef820f |
+import org.eclipse.update.internal.ui.UpdateLabelProvider;
|
|
|
9ef820f |
+import org.eclipse.update.internal.ui.UpdateUI;
|
|
|
9ef820f |
+import org.eclipse.update.internal.ui.UpdateUIImages;
|
|
|
9ef820f |
+import org.eclipse.update.internal.ui.UpdateUIMessages;
|
|
|
9ef820f |
+import org.eclipse.update.internal.ui.parts.DefaultContentProvider;
|
|
|
9ef820f |
+import org.eclipse.update.internal.ui.parts.SWTUtil;
|
|
|
9ef820f |
+import org.eclipse.update.operations.IInstallFeatureOperation;
|
|
|
9ef820f |
+
|
|
|
9ef820f |
+public class TargetPage extends BannerPage implements IDynamicPage {
|
|
|
9ef820f |
+ private TableViewer jobViewer;
|
|
|
9ef820f |
+ private IInstallConfiguration config;
|
|
|
9ef820f |
+ private ConfigListener configListener;
|
|
|
9ef820f |
+ private Label requiredSpaceLabel;
|
|
|
9ef820f |
+ private Label availableSpaceLabel;
|
|
|
9ef820f |
+ private IInstallFeatureOperation[] jobs;
|
|
|
9ef820f |
+ //private IInstallFeatureOperation currentJob;
|
|
|
9ef820f |
+ private Label installLocation;
|
|
|
9ef820f |
+ private Button changeLocation;
|
|
|
9ef820f |
+ static HashSet added;
|
|
|
9ef820f |
+
|
|
|
9ef820f |
+ class JobsContentProvider
|
|
|
9ef820f |
+ extends DefaultContentProvider
|
|
|
9ef820f |
+ implements IStructuredContentProvider {
|
|
|
9ef820f |
+ public Object[] getElements(Object parent) {
|
|
|
9ef820f |
+ return jobs;
|
|
|
9ef820f |
+ }
|
|
|
9ef820f |
+ }
|
|
|
9ef820f |
+
|
|
|
9ef820f |
+ class JobsLabelProvider
|
|
|
9ef820f |
+ extends LabelProvider
|
|
|
9ef820f |
+ implements ITableLabelProvider {
|
|
|
9ef820f |
+
|
|
|
9ef820f |
+ public Image getColumnImage(Object obj, int col) {
|
|
|
9ef820f |
+ UpdateLabelProvider provider = UpdateUI.getDefault().getLabelProvider();
|
|
|
9ef820f |
+
|
|
|
9ef820f |
+ IInstallFeatureOperation job = (IInstallFeatureOperation) obj;
|
|
|
9ef820f |
+ ImageDescriptor base =
|
|
|
9ef820f |
+ job.getFeature().isPatch()
|
|
|
9ef820f |
+ ? UpdateUIImages.DESC_EFIX_OBJ
|
|
|
9ef820f |
+ : UpdateUIImages.DESC_FEATURE_OBJ;
|
|
|
9ef820f |
+ int flags = 0;
|
|
|
9ef820f |
+ if (job.getTargetSite() == null)
|
|
|
9ef820f |
+ flags = UpdateLabelProvider.F_ERROR;
|
|
|
9ef820f |
+ return provider.get(base, flags);
|
|
|
9ef820f |
+ }
|
|
|
9ef820f |
+
|
|
|
9ef820f |
+ public String getColumnText(Object obj, int col) {
|
|
|
9ef820f |
+ if (col == 0) {
|
|
|
9ef820f |
+ IFeature feature = ((IInstallFeatureOperation) obj).getFeature();
|
|
|
9ef820f |
+ return feature.getLabel()
|
|
|
9ef820f |
+ + " " //$NON-NLS-1$
|
|
|
9ef820f |
+ + feature.getVersionedIdentifier().getVersion().toString();
|
|
|
9ef820f |
+ }
|
|
|
9ef820f |
+ return null;
|
|
|
9ef820f |
+ }
|
|
|
9ef820f |
+ }
|
|
|
9ef820f |
+
|
|
|
9ef820f |
+ class ConfigListener implements IInstallConfigurationChangedListener {
|
|
|
9ef820f |
+ public void installSiteAdded(IConfiguredSite csite) {
|
|
|
9ef820f |
+
|
|
|
9ef820f |
+ // set the site as target for all jobs without a target
|
|
|
9ef820f |
+ for (int i=0; jobs != null && i
|
|
|
9ef820f |
+ if (jobs[i].getTargetSite() == null && getSiteVisibility(csite, jobs[i])) {
|
|
|
9ef820f |
+ jobs[i].setTargetSite(csite);
|
|
|
9ef820f |
+ }
|
|
|
9ef820f |
+
|
|
|
9ef820f |
+ jobViewer.refresh();
|
|
|
9ef820f |
+ }
|
|
|
9ef820f |
+
|
|
|
9ef820f |
+ public void installSiteRemoved(IConfiguredSite csite) {
|
|
|
9ef820f |
+ // remove the target site for all jobs that use it
|
|
|
9ef820f |
+ // set the site as target for all jobs without a target
|
|
|
9ef820f |
+ boolean refreshJobs = false;
|
|
|
9ef820f |
+ for (int i=0; jobs != null && i
|
|
|
9ef820f |
+ if (jobs[i].getTargetSite() == csite) {
|
|
|
9ef820f |
+ jobs[i].setTargetSite(null);
|
|
|
9ef820f |
+ refreshJobs = true;
|
|
|
9ef820f |
+ }
|
|
|
9ef820f |
+
|
|
|
9ef820f |
+ pageChanged();
|
|
|
9ef820f |
+
|
|
|
9ef820f |
+ jobViewer.refresh();
|
|
|
9ef820f |
+ if (refreshJobs) {
|
|
|
9ef820f |
+ jobViewer.getControl().setFocus();
|
|
|
9ef820f |
+ }
|
|
|
9ef820f |
+ }
|
|
|
9ef820f |
+ }
|
|
|
9ef820f |
+
|
|
|
9ef820f |
+ /**
|
|
|
9ef820f |
+ * Constructor for ReviewPage2
|
|
|
9ef820f |
+ */
|
|
|
9ef820f |
+ public TargetPage(IInstallConfiguration config) {
|
|
|
9ef820f |
+ super("Target"); //$NON-NLS-1$
|
|
|
9ef820f |
+ setTitle(UpdateUIMessages.InstallWizard_TargetPage_title);
|
|
|
9ef820f |
+ setDescription(UpdateUIMessages.InstallWizard_TargetPage_desc);
|
|
|
9ef820f |
+ this.config = config;
|
|
|
9ef820f |
+ UpdateUI.getDefault().getLabelProvider().connect(this);
|
|
|
9ef820f |
+ configListener = new ConfigListener();
|
|
|
9ef820f |
+ }
|
|
|
9ef820f |
+
|
|
|
9ef820f |
+ public void setJobs(IInstallFeatureOperation[] jobs) {
|
|
|
9ef820f |
+ this.jobs = jobs;
|
|
|
9ef820f |
+ }
|
|
|
9ef820f |
+
|
|
|
9ef820f |
+ public void dispose() {
|
|
|
9ef820f |
+ UpdateUI.getDefault().getLabelProvider().disconnect(this);
|
|
|
9ef820f |
+// config.removeInstallConfigurationChangedListener(configListener);
|
|
|
9ef820f |
+ super.dispose();
|
|
|
9ef820f |
+ }
|
|
|
9ef820f |
+
|
|
|
9ef820f |
+ public Control createContents(Composite parent) {
|
|
|
9ef820f |
+ Composite client = new Composite(parent, SWT.NULL);
|
|
|
9ef820f |
+ GridLayout layout = new GridLayout();
|
|
|
9ef820f |
+ layout.numColumns = 3;
|
|
|
9ef820f |
+ layout.marginWidth = layout.marginHeight = 0;
|
|
|
9ef820f |
+ client.setLayout(layout);
|
|
|
9ef820f |
+ client.setLayoutData(new GridData(GridData.FILL_BOTH));
|
|
|
9ef820f |
+
|
|
|
9ef820f |
+ Label label = new Label(client, SWT.NULL);
|
|
|
9ef820f |
+ label.setText(UpdateUIMessages.InstallWizard_TargetPage_jobsLabel);
|
|
|
9ef820f |
+ createJobViewer(client);
|
|
|
9ef820f |
+
|
|
|
9ef820f |
+ label = new Label(client, SWT.NULL);
|
|
|
9ef820f |
+ label.setText(UpdateUIMessages.InstallWizard_TargetPage_location);
|
|
|
9ef820f |
+ GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
|
|
|
9ef820f |
+ label.setLayoutData(gd);
|
|
|
9ef820f |
+
|
|
|
9ef820f |
+ installLocation = new Label(client, SWT.NULL);
|
|
|
9ef820f |
+ installLocation.setText("");
|
|
|
9ef820f |
+ gd = new GridData(GridData.FILL_HORIZONTAL);
|
|
|
9ef820f |
+ installLocation.setLayoutData(gd);
|
|
|
9ef820f |
+
|
|
|
9ef820f |
+ changeLocation = new Button(client, SWT.PUSH);
|
|
|
9ef820f |
+ changeLocation.setText(UpdateUIMessages.InstallWizard_TargetPage_location_change);
|
|
|
9ef820f |
+ changeLocation.addSelectionListener(new SelectionAdapter() {
|
|
|
9ef820f |
+ public void widgetSelected(SelectionEvent e) {
|
|
|
9ef820f |
+ IStructuredSelection selection = (IStructuredSelection) jobViewer.getSelection();
|
|
|
9ef820f |
+ if (selection == null)
|
|
|
9ef820f |
+ return;
|
|
|
9ef820f |
+ IInstallFeatureOperation job = (IInstallFeatureOperation) selection.getFirstElement();
|
|
|
9ef820f |
+ if (job == null)
|
|
|
9ef820f |
+ return;
|
|
|
9ef820f |
+
|
|
|
9ef820f |
+ TargetSiteDialog dialog = new TargetSiteDialog(getShell(), config, job, configListener);
|
|
|
9ef820f |
+ dialog.create();
|
|
|
9ef820f |
+
|
|
|
9ef820f |
+ SWTUtil.setDialogSize(dialog, 400, 300);
|
|
|
9ef820f |
+
|
|
|
9ef820f |
+ dialog.getShell().setText(UpdateUIMessages.SitePage_new);
|
|
|
9ef820f |
+ dialog.open();
|
|
|
9ef820f |
+ setTargetLocation(job);
|
|
|
9ef820f |
+ pageChanged();
|
|
|
9ef820f |
+ jobViewer.refresh();
|
|
|
9ef820f |
+ updateStatus(job.getTargetSite());
|
|
|
9ef820f |
+ }
|
|
|
9ef820f |
+ });
|
|
|
9ef820f |
+
|
|
|
9ef820f |
+ Composite status = new Composite(client, SWT.NULL);
|
|
|
9ef820f |
+ gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
|
|
|
9ef820f |
+ gd.horizontalSpan = 3;
|
|
|
9ef820f |
+ status.setLayoutData(gd);
|
|
|
9ef820f |
+ layout = new GridLayout();
|
|
|
9ef820f |
+ layout.numColumns = 2;
|
|
|
9ef820f |
+ status.setLayout(layout);
|
|
|
9ef820f |
+ label = new Label(status, SWT.NULL);
|
|
|
9ef820f |
+ label.setText(UpdateUIMessages.InstallWizard_TargetPage_requiredSpace);
|
|
|
9ef820f |
+ requiredSpaceLabel = new Label(status, SWT.NULL);
|
|
|
9ef820f |
+ requiredSpaceLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
|
|
9ef820f |
+ label = new Label(status, SWT.NULL);
|
|
|
9ef820f |
+ label.setText(UpdateUIMessages.InstallWizard_TargetPage_availableSpace);
|
|
|
9ef820f |
+ availableSpaceLabel = new Label(status, SWT.NULL);
|
|
|
9ef820f |
+ availableSpaceLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
|
|
9ef820f |
+
|
|
|
9ef820f |
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(client, "org.eclipse.update.ui.MultiTargetPage2"); //$NON-NLS-1$
|
|
|
9ef820f |
+
|
|
|
9ef820f |
+ Dialog.applyDialogFont(parent);
|
|
|
9ef820f |
+
|
|
|
9ef820f |
+ return client;
|
|
|
9ef820f |
+ }
|
|
|
9ef820f |
+
|
|
|
9ef820f |
+ private void createJobViewer(Composite parent) {
|
|
|
9ef820f |
+ jobViewer = new TableViewer(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
|
|
|
9ef820f |
+ GridData gd = new GridData(GridData.FILL_BOTH);
|
|
|
9ef820f |
+ gd.horizontalSpan = 3;
|
|
|
9ef820f |
+ gd.widthHint = 150;
|
|
|
9ef820f |
+ jobViewer.getTable().setLayoutData(gd);
|
|
|
9ef820f |
+ jobViewer.setContentProvider(new JobsContentProvider());
|
|
|
9ef820f |
+ jobViewer.setLabelProvider(new JobsLabelProvider());
|
|
|
9ef820f |
+
|
|
|
9ef820f |
+ jobViewer.addSelectionChangedListener(new ISelectionChangedListener() {
|
|
|
9ef820f |
+ public void selectionChanged(SelectionChangedEvent event) {
|
|
|
9ef820f |
+ IStructuredSelection selection = (IStructuredSelection) event.getSelection();
|
|
|
9ef820f |
+ IInstallFeatureOperation job = (IInstallFeatureOperation) selection.getFirstElement();
|
|
|
9ef820f |
+ setTargetLocation(job);
|
|
|
9ef820f |
+ }
|
|
|
9ef820f |
+ });
|
|
|
9ef820f |
+ }
|
|
|
9ef820f |
+
|
|
|
9ef820f |
+ public void setVisible(boolean visible) {
|
|
|
9ef820f |
+ if (visible) {
|
|
|
9ef820f |
+ initializeDefaultTargetSites();
|
|
|
9ef820f |
+ jobViewer.setInput(jobs);
|
|
|
9ef820f |
+ if (jobViewer.getSelection().isEmpty() && jobs.length > 0)
|
|
|
9ef820f |
+ jobViewer.setSelection(new StructuredSelection(jobs[0]));
|
|
|
9ef820f |
+ }
|
|
|
9ef820f |
+
|
|
|
9ef820f |
+ super.setVisible(visible);
|
|
|
9ef820f |
+ }
|
|
|
9ef820f |
+
|
|
|
9ef820f |
+ private void verifyNotEmpty(boolean empty) {
|
|
|
9ef820f |
+ String errorMessage = null;
|
|
|
9ef820f |
+ if (empty)
|
|
|
9ef820f |
+ errorMessage = UpdateUIMessages.InstallWizard_TargetPage_location_empty;
|
|
|
9ef820f |
+ setErrorMessage(errorMessage);
|
|
|
9ef820f |
+ setPageComplete(!empty);
|
|
|
9ef820f |
+ }
|
|
|
9ef820f |
+
|
|
|
9ef820f |
+
|
|
|
9ef820f |
+ private void updateStatus(Object element) {
|
|
|
9ef820f |
+ if (element == null) {
|
|
|
9ef820f |
+ requiredSpaceLabel.setText(""); //$NON-NLS-1$
|
|
|
9ef820f |
+ availableSpaceLabel.setText(""); //$NON-NLS-1$
|
|
|
9ef820f |
+ return;
|
|
|
9ef820f |
+ }
|
|
|
9ef820f |
+ IConfiguredSite site = (IConfiguredSite) element;
|
|
|
9ef820f |
+ File file = new File(site.getSite().getURL().getFile());
|
|
|
9ef820f |
+ long available = LocalSystemInfo.getFreeSpace(file);
|
|
|
9ef820f |
+ long required = computeRequiredSizeFor(site);
|
|
|
9ef820f |
+ if (required <= 0)
|
|
|
9ef820f |
+ requiredSpaceLabel.setText(UpdateUIMessages.InstallWizard_TargetPage_unknownSize);
|
|
|
9ef820f |
+ else
|
|
|
9ef820f |
+ requiredSpaceLabel.setText(
|
|
|
9ef820f |
+ NLS.bind(UpdateUIMessages.InstallWizard_TargetPage_size, "" + required)); //$NON-NLS-1$
|
|
|
9ef820f |
+
|
|
|
9ef820f |
+ if (available == LocalSystemInfo.SIZE_UNKNOWN)
|
|
|
9ef820f |
+ availableSpaceLabel.setText(UpdateUIMessages.InstallWizard_TargetPage_unknownSize);
|
|
|
9ef820f |
+ else
|
|
|
9ef820f |
+ availableSpaceLabel.setText(
|
|
|
9ef820f |
+ NLS.bind(UpdateUIMessages.InstallWizard_TargetPage_size, "" + available)); //$NON-NLS-1$
|
|
|
9ef820f |
+ }
|
|
|
9ef820f |
+
|
|
|
9ef820f |
+ private long computeRequiredSizeFor(IConfiguredSite site) {
|
|
|
9ef820f |
+ long totalSize = 0;
|
|
|
9ef820f |
+ for (int i = 0; i < jobs.length; i++) {
|
|
|
9ef820f |
+ if (site.equals(jobs[i].getTargetSite())) {
|
|
|
9ef820f |
+ long jobSize = site.getSite().getInstallSizeFor(jobs[i].getFeature());
|
|
|
9ef820f |
+ if (jobSize == -1)
|
|
|
9ef820f |
+ return -1;
|
|
|
9ef820f |
+ totalSize += jobSize;
|
|
|
9ef820f |
+ }
|
|
|
9ef820f |
+ }
|
|
|
9ef820f |
+ return totalSize;
|
|
|
9ef820f |
+ }
|
|
|
9ef820f |
+
|
|
|
9ef820f |
+ private void pageChanged() {
|
|
|
9ef820f |
+ boolean empty = false;
|
|
|
9ef820f |
+ for (int i=0; jobs!=null && i
|
|
|
9ef820f |
+ if (jobs[i].getTargetSite() == null) {
|
|
|
9ef820f |
+ empty = true;
|
|
|
9ef820f |
+ break;
|
|
|
9ef820f |
+ }
|
|
|
9ef820f |
+
|
|
|
9ef820f |
+ IFeature feature = jobs[i].getFeature();
|
|
|
9ef820f |
+ if (feature.isPatch()) {
|
|
|
9ef820f |
+ // Patches must go together with the features
|
|
|
9ef820f |
+ // they are patching.
|
|
|
9ef820f |
+
|
|
|
9ef820f |
+ // Check current jobs
|
|
|
9ef820f |
+ IInstallFeatureOperation patchedFeatureJob = findPatchedFeature(feature);
|
|
|
9ef820f |
+ if (patchedFeatureJob != null
|
|
|
9ef820f |
+ && patchedFeatureJob.getTargetSite() != null
|
|
|
9ef820f |
+ && !jobs[i].getTargetSite().equals(patchedFeatureJob.getTargetSite())) {
|
|
|
9ef820f |
+ String msg = NLS.bind(UpdateUIMessages.InstallWizard_TargetPage_patchError, (new String[] {
|
|
|
9ef820f |
+ feature.getLabel(),
|
|
|
9ef820f |
+ patchedFeatureJob.getFeature().getLabel()}));
|
|
|
9ef820f |
+ setErrorMessage(msg);
|
|
|
9ef820f |
+ setPageComplete(false);
|
|
|
9ef820f |
+ return;
|
|
|
9ef820f |
+ }
|
|
|
9ef820f |
+ // Check installed features
|
|
|
9ef820f |
+ IFeature patchedFeature = UpdateUtils.getPatchedFeature(feature);
|
|
|
9ef820f |
+ if (patchedFeature != null
|
|
|
9ef820f |
+ && !jobs[i].getTargetSite().equals(patchedFeature.getSite().getCurrentConfiguredSite())) {
|
|
|
9ef820f |
+ String msg = NLS.bind(UpdateUIMessages.InstallWizard_TargetPage_patchError2, (new String[] {
|
|
|
9ef820f |
+ feature.getLabel(),
|
|
|
9ef820f |
+ patchedFeature.getLabel(),
|
|
|
9ef820f |
+ patchedFeature.getSite().getCurrentConfiguredSite().getSite().getURL().getFile()}));
|
|
|
9ef820f |
+ setErrorMessage(msg);
|
|
|
9ef820f |
+ setPageComplete(false);
|
|
|
9ef820f |
+ return;
|
|
|
9ef820f |
+ }
|
|
|
9ef820f |
+ }
|
|
|
9ef820f |
+ }
|
|
|
9ef820f |
+ verifyNotEmpty(empty);
|
|
|
9ef820f |
+ }
|
|
|
9ef820f |
+
|
|
|
9ef820f |
+
|
|
|
9ef820f |
+ private boolean getSiteVisibility(IConfiguredSite site, IInstallFeatureOperation job) {
|
|
|
9ef820f |
+ // Do not allow installing into a non-updateable site
|
|
|
9ef820f |
+ if (!site.isUpdatable())
|
|
|
9ef820f |
+ return false;
|
|
|
9ef820f |
+
|
|
|
9ef820f |
+ // If affinity site is known, only it should be shown
|
|
|
9ef820f |
+ IConfiguredSite affinitySite = UpdateUtils.getAffinitySite(config, job.getFeature());
|
|
|
9ef820f |
+ if (affinitySite != null) {
|
|
|
9ef820f |
+ // Must compare referenced sites because
|
|
|
9ef820f |
+ // configured sites themselves may come from
|
|
|
9ef820f |
+ // different configurations
|
|
|
9ef820f |
+ return site.getSite().equals(affinitySite.getSite());
|
|
|
9ef820f |
+ }
|
|
|
9ef820f |
+
|
|
|
9ef820f |
+ // Co-locate updates with the old feature
|
|
|
9ef820f |
+ if (job.getOldFeature() != null) {
|
|
|
9ef820f |
+ IConfiguredSite oldSite = UpdateUtils.getSiteWithFeature(config, job.getOldFeature().getVersionedIdentifier().getIdentifier());
|
|
|
9ef820f |
+ return (site == oldSite);
|
|
|
9ef820f |
+ }
|
|
|
9ef820f |
+
|
|
|
9ef820f |
+ // Allow installing into any site that is updateable and there is no affinity specified
|
|
|
9ef820f |
+ return true;
|
|
|
9ef820f |
+ }
|
|
|
9ef820f |
+
|
|
|
9ef820f |
+ private void initializeDefaultTargetSites() {
|
|
|
9ef820f |
+ for (int i = 0; i < jobs.length; i++) {
|
|
|
9ef820f |
+ if (jobs[i].getTargetSite() != null)
|
|
|
9ef820f |
+ continue;
|
|
|
9ef820f |
+
|
|
|
9ef820f |
+ IConfiguredSite affinitySite = UpdateUtils.getAffinitySite(config, jobs[i].getFeature());
|
|
|
9ef820f |
+ if (affinitySite != null) {
|
|
|
9ef820f |
+ jobs[i].setTargetSite(affinitySite);
|
|
|
9ef820f |
+ continue;
|
|
|
9ef820f |
+ }
|
|
|
9ef820f |
+
|
|
|
9ef820f |
+ IConfiguredSite defaultSite = UpdateUtils.getDefaultTargetSite(config, jobs[i], false);
|
|
|
9ef820f |
+ if (defaultSite != null) {
|
|
|
9ef820f |
+ jobs[i].setTargetSite(defaultSite);
|
|
|
9ef820f |
+ continue;
|
|
|
9ef820f |
+ }
|
|
|
9ef820f |
+
|
|
|
9ef820f |
+ IConfiguredSite csite = getFirstTargetSite(jobs[i]);
|
|
|
9ef820f |
+ if (csite == null && Platform.getInstallLocation().isReadOnly()) {
|
|
|
9ef820f |
+ // there are no updateable sites and the installation location is read only
|
|
|
9ef820f |
+ // make an update site in the user's home direcotry
|
|
|
9ef820f |
+ String sitePath = System.getProperty("user.home") + File.separator + ".eclipse" + File.separator +
|
|
|
9ef820f |
+ Platform.getProduct().getId() + File.separator + "updates"; //$NON-NLS-1$ //$NON-NLS-2$
|
|
|
9ef820f |
+
|
|
|
9ef820f |
+ try {
|
|
|
9ef820f |
+ csite = config.createConfiguredSite(new File(sitePath));
|
|
|
9ef820f |
+ config.addConfiguredSite(csite);
|
|
|
9ef820f |
+ IStatus status = csite.verifyUpdatableStatus();
|
|
|
9ef820f |
+ if (!status.isOK())
|
|
|
9ef820f |
+ throw new CoreException(status);
|
|
|
9ef820f |
+
|
|
|
9ef820f |
+ } catch (CoreException e) {
|
|
|
9ef820f |
+ // there was a problem, the user must choose an installation site
|
|
|
9ef820f |
+ csite = null;
|
|
|
9ef820f |
+ }
|
|
|
9ef820f |
+ }
|
|
|
9ef820f |
+
|
|
|
9ef820f |
+ jobs[i].setTargetSite(csite);
|
|
|
9ef820f |
+
|
|
|
9ef820f |
+ }
|
|
|
9ef820f |
+ }
|
|
|
9ef820f |
+
|
|
|
9ef820f |
+
|
|
|
9ef820f |
+ private IConfiguredSite getFirstTargetSite(IInstallFeatureOperation job) {
|
|
|
9ef820f |
+ IConfiguredSite[] sites = config.getConfiguredSites();
|
|
|
9ef820f |
+ for (int i = 0; i < sites.length; i++) {
|
|
|
9ef820f |
+ IConfiguredSite csite = sites[i];
|
|
|
9ef820f |
+ if (getSiteVisibility(csite, job) && csite.verifyUpdatableStatus().isOK() == true)
|
|
|
9ef820f |
+ return csite;
|
|
|
9ef820f |
+ }
|
|
|
9ef820f |
+ return null;
|
|
|
9ef820f |
+ }
|
|
|
9ef820f |
+
|
|
|
9ef820f |
+ public IInstallFeatureOperation findPatchedFeature(IFeature patch) {
|
|
|
9ef820f |
+ for (int i=0; i
|
|
|
9ef820f |
+ IFeature target = jobs[i].getFeature();
|
|
|
9ef820f |
+ if (!target.equals(patch) && UpdateUtils.isPatch(target, patch))
|
|
|
9ef820f |
+ return jobs[i];
|
|
|
9ef820f |
+ }
|
|
|
9ef820f |
+ return null;
|
|
|
9ef820f |
+ }
|
|
|
9ef820f |
+
|
|
|
9ef820f |
+
|
|
|
9ef820f |
+ void removeAddedSites() {
|
|
|
9ef820f |
+ if (added != null) {
|
|
|
9ef820f |
+ while (!added.isEmpty()) {
|
|
|
9ef820f |
+ Iterator it = added.iterator();
|
|
|
9ef820f |
+ if (it.hasNext())
|
|
|
9ef820f |
+ config.removeConfiguredSite((IConfiguredSite) it.next());
|
|
|
9ef820f |
+ }
|
|
|
9ef820f |
+ }
|
|
|
9ef820f |
+ }
|
|
|
9ef820f |
+
|
|
|
9ef820f |
+ /* (non-Javadoc)
|
|
|
9ef820f |
+ * @see org.eclipse.jface.wizard.IWizardPage#isPageComplete()
|
|
|
9ef820f |
+ */
|
|
|
9ef820f |
+ public boolean isPageComplete() {
|
|
|
9ef820f |
+ // check if all jobs have a target site set
|
|
|
9ef820f |
+ for (int i = 0; jobs != null && i < jobs.length; i++) {
|
|
|
9ef820f |
+ if (jobs[i].getTargetSite() == null)
|
|
|
9ef820f |
+ return false;
|
|
|
9ef820f |
+ }
|
|
|
9ef820f |
+ return super.isPageComplete();
|
|
|
9ef820f |
+ }
|
|
|
9ef820f |
+
|
|
|
9ef820f |
+ /**
|
|
|
9ef820f |
+ * @param job
|
|
|
9ef820f |
+ */
|
|
|
9ef820f |
+ private void setTargetLocation(IInstallFeatureOperation job) {
|
|
|
9ef820f |
+ if (job != null && job.getTargetSite() != null) {
|
|
|
9ef820f |
+ installLocation.setText(new File(job.getTargetSite().getSite().getURL().getFile()).toString());
|
|
|
9ef820f |
+ updateStatus(job.getTargetSite());
|
|
|
9ef820f |
+ }
|
|
|
9ef820f |
+ }
|
|
|
9ef820f |
+}
|