KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > update > internal > operations > UnconfigureAndUninstallFeatureOperation


1 /*******************************************************************************
2  * Copyright (c) 2005, 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.update.internal.operations;
12
13 import java.io.File JavaDoc;
14 import java.io.FileInputStream JavaDoc;
15 import java.io.FileOutputStream JavaDoc;
16 import java.io.IOException JavaDoc;
17 import java.lang.reflect.InvocationTargetException JavaDoc;
18 import java.net.URL JavaDoc;
19 import java.util.Properties JavaDoc;
20
21 import org.eclipse.core.runtime.CoreException;
22 import org.eclipse.core.runtime.IProgressMonitor;
23 import org.eclipse.update.configuration.IConfiguredSite;
24 import org.eclipse.update.configurator.ConfiguratorUtils;
25 import org.eclipse.update.core.IFeature;
26 import org.eclipse.update.operations.IOperationListener;
27 import org.eclipse.update.operations.IUnconfigFeatureOperation;
28 import org.eclipse.update.operations.OperationsManager;
29
30 public class UnconfigureAndUninstallFeatureOperation extends FeatureOperation
31         implements IUnconfigureAndUninstallFeatureOperation {
32
33     public UnconfigureAndUninstallFeatureOperation(IConfiguredSite targetSite, IFeature feature) {
34         super(targetSite, feature);
35     }
36
37     public boolean execute(IProgressMonitor pm, IOperationListener listener)
38             throws CoreException, InvocationTargetException JavaDoc {
39         
40         IUnconfigFeatureOperation unconfigOperation = OperationsManager.getOperationFactory().createUnconfigOperation(targetSite, feature);
41
42         /*boolean isRestartNeeded = */unconfigOperation.execute(pm, listener);
43         
44
45         URL JavaDoc platformXML = ConfiguratorUtils.getCurrentPlatformConfiguration().getConfigurationLocation();
46         
47         File JavaDoc f = new File JavaDoc(platformXML.getFile());
48
49         f = new File JavaDoc(f.getParentFile(), "toBeUninstalled"); //$NON-NLS-1$
50
try {
51             if (!f.exists()) {
52                 f.createNewFile();
53             }
54             FileInputStream JavaDoc fis = new FileInputStream JavaDoc(f);
55             Properties JavaDoc toBeUninstalled = new Properties JavaDoc();
56             toBeUninstalled.load(fis);
57             toBeUninstalled.put(new Integer JavaDoc(toBeUninstalled.size()+1).toString(), targetSite.getSite().getURL() + ";" + feature.getVersionedIdentifier().toString()); //$NON-NLS-1$
58
fis.close();
59             FileOutputStream JavaDoc fos = new FileOutputStream JavaDoc(f);
60             toBeUninstalled.store(fos, "to be uninstalled on start-up"); //$NON-NLS-1$
61
fos.close();
62             
63         } catch (IOException JavaDoc ioe) {
64             
65         }
66
67         
68         return true;
69     }
70
71 }
72
Popular Tags