1 11 package org.eclipse.update.standalone; 12 import java.io.*; 13 import java.net.*; 14 15 import org.eclipse.core.runtime.*; 16 import org.eclipse.update.configuration.*; 17 import org.eclipse.update.core.*; 18 import org.eclipse.update.internal.core.*; 19 20 21 31 public class ListFeaturesCommand extends ScriptedCommand { 32 private IConfiguredSite[] sites = getConfiguration().getConfiguredSites(); 33 34 37 public ListFeaturesCommand(String fromSite) throws Exception { 38 try { 39 if (fromSite != null) { 40 File sitePath = new File(fromSite); 41 if (!sitePath.exists()) 42 throw new Exception (Messages.Standalone_noSite + fromSite); 43 44 URL fromSiteURL = sitePath.toURL(); 45 ISite site = SiteManager.getSite(fromSiteURL, null); 46 if (site == null) { 47 throw new Exception (Messages.Standalone_noSite + fromSite); 48 } 49 IConfiguredSite csite = site.getCurrentConfiguredSite(); 50 if (csite == null) 51 throw new Exception (Messages.Standalone_noConfiguredSite + fromSite); 52 sites = new IConfiguredSite[] { csite }; 53 } 54 55 } catch (Exception e) { 56 throw e; 57 } 58 } 59 60 62 public boolean run(IProgressMonitor monitor) { 63 try { 64 if (sites != null) { 65 for (int i = 0; i < sites.length; i++) { 66 System.out.println("Site: " + sites[i].getSite().getURL()); IFeatureReference[] features = sites[i] 68 .getFeatureReferences(); 69 for (int f = 0; f < features.length; f++) { 70 boolean configured = sites[i].isConfigured(features[f] 71 .getFeature(null)); 72 System.out.println(" Feature: " + features[f].getVersionedIdentifier() 74 .getIdentifier() 75 + " " + features[f].getVersionedIdentifier() 77 .getVersion() + " " + (configured ? "enabled" : "disabled")); } 80 } 81 } 82 return true; 83 } catch (CoreException e) { 84 StandaloneUpdateApplication.exceptionLogged(); 85 UpdateCore.log(e); 86 return false; 87 } 88 } 89 } 90 | Popular Tags |