KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > core > TargetPlatformResetJob


1 /*******************************************************************************
2  * Copyright (c) 2007 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.core;
12
13 import org.eclipse.core.runtime.IProgressMonitor;
14 import org.eclipse.core.runtime.IStatus;
15 import org.eclipse.core.runtime.Status;
16 import org.eclipse.core.runtime.jobs.Job;
17 import org.eclipse.pde.core.plugin.IPluginModelBase;
18
19 public class TargetPlatformResetJob extends Job {
20     
21     private PDEState fState;
22
23     public TargetPlatformResetJob(PDEState newState) {
24         super(PDECoreMessages.TargetPlatformResetJob_resetTarget);
25         fState = newState;
26     }
27     
28     protected IStatus run(IProgressMonitor monitor) {
29         EclipseHomeInitializer.resetEclipseHomeVariable();
30         PDECore.getDefault().getSourceLocationManager().reset();
31         PDECore.getDefault().getJavadocLocationManager().reset();
32         IPluginModelBase[] models = fState.getTargetModels();
33         removeDisabledBundles(models);
34         PluginModelManager manager = PDECore.getDefault().getModelManager();
35         manager.getExternalModelManager().setModels(models);
36         manager.resetState(fState);
37         PDECore.getDefault().getFeatureModelManager().targetReloaded();
38         monitor.done();
39         return Status.OK_STATUS;
40     }
41     
42     private void removeDisabledBundles(IPluginModelBase[] models) {
43         int number = models.length;
44         for (int i = 0; i < models.length; i++) {
45             if (!models[i].isEnabled()) {
46                 fState.removeBundleDescription(models[i].getBundleDescription());
47                 number -= 1;
48             }
49         }
50         if (number < models.length)
51             fState.resolveState(true);
52     }
53
54 }
55
Popular Tags