KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > ui > wizards > tools > UpdateBuildpathWizard


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.pde.internal.ui.wizards.tools;
12
13 import org.eclipse.core.runtime.jobs.Job;
14 import org.eclipse.jface.dialogs.IDialogSettings;
15 import org.eclipse.jface.wizard.Wizard;
16 import org.eclipse.pde.core.plugin.IPluginModelBase;
17 import org.eclipse.pde.internal.ui.PDEPlugin;
18 import org.eclipse.pde.internal.ui.PDEPluginImages;
19 import org.eclipse.pde.internal.ui.PDEUIMessages;
20 import org.eclipse.ui.PlatformUI;
21
22 public class UpdateBuildpathWizard extends Wizard {
23     private UpdateBuildpathWizardPage page1;
24     private IPluginModelBase[] fSelected;
25     private IPluginModelBase[] fUnupdated;
26     private static final String JavaDoc STORE_SECTION = "UpdateBuildpathWizard"; //$NON-NLS-1$
27
public UpdateBuildpathWizard(IPluginModelBase[] models, IPluginModelBase[] selected) {
28         IDialogSettings masterSettings = PDEPlugin.getDefault().getDialogSettings();
29         setDialogSettings(getSettingsSection(masterSettings));
30         setDefaultPageImageDescriptor(PDEPluginImages.DESC_CONVJPPRJ_WIZ);
31         setWindowTitle(PDEUIMessages.UpdateBuildpathWizard_wtitle);
32         setNeedsProgressMonitor(true);
33         this.fSelected = selected;
34         this.fUnupdated = models;
35     }
36     
37     private IDialogSettings getSettingsSection(IDialogSettings master) {
38         IDialogSettings setting = master.getSection(STORE_SECTION);
39         if (setting == null) {
40             setting = master.addNewSection(STORE_SECTION);
41         }
42         return setting;
43     }
44     
45     public boolean performFinish() {
46         if (!PlatformUI.getWorkbench().saveAllEditors(true))
47             return false;
48         
49         Object JavaDoc [] finalSelected = page1.getSelected();
50         page1.storeSettings();
51         IPluginModelBase [] modelArray = new IPluginModelBase[finalSelected.length];
52         System.arraycopy(finalSelected, 0, modelArray, 0, finalSelected.length);
53         Job j = new UpdateClasspathJob(modelArray);
54         j.setUser(true);
55         j.schedule();
56         return true;
57     }
58     
59     public void addPages() {
60         page1 = new UpdateBuildpathWizardPage(fUnupdated, fSelected);
61         addPage(page1);
62     }
63 }
64
Popular Tags