1 11 12 package org.eclipse.ui.internal.intro.universal.contentdetect; 13 14 import java.util.HashSet ; 15 import java.util.Set ; 16 17 import org.eclipse.core.runtime.IExtension; 18 import org.eclipse.core.runtime.Platform; 19 import org.eclipse.ui.intro.IntroContentDetector; 20 21 public class ContentDetector extends IntroContentDetector { 22 23 private static Set newContributors; 24 private static boolean detectorCalled = false; 25 26 public ContentDetector() { 27 } 28 29 public boolean isNewContentAvailable() { 30 try { 31 detectorCalled = true; 32 if (newContributors != null && !newContributors.isEmpty()) { 34 return true; 35 } 36 IExtension[] extensions = Platform 37 .getExtensionRegistry() 38 .getExtensionPoint("org.eclipse.ui.intro.configExtension").getExtensions(); int numIntroExtensions = extensions.length; 40 41 ContentDetectHelper helper = new ContentDetectHelper(); 42 int previous = helper.getExtensionCount(); 43 if (numIntroExtensions != previous) { 44 helper.saveExtensionCount(numIntroExtensions); 45 Set contributors = new HashSet (); 46 for (int i = 0; i < extensions.length; i++) { 47 contributors.add(extensions[i].getContributor().getName()); 48 } 49 if (numIntroExtensions > previous && previous != ContentDetectHelper.NO_STATE) { 50 Set previousContributors = helper.getContributors(); 51 newContributors = helper.findNewContributors(contributors, previousContributors); 52 helper.saveContributors(contributors); 53 return true; 54 } 55 helper.saveContributors(contributors); 56 } 57 } catch (Exception e) { 58 return false; 59 } 60 newContributors = new HashSet (); 61 return false; 62 } 63 64 68 public static Set getNewContributors() { 69 if (!detectorCalled) { 70 detectorCalled = true; 71 new ContentDetector().isNewContentAvailable(); 72 } 73 return newContributors; 74 } 75 76 81 public static boolean isNew(String contributionId) { 82 if (!detectorCalled) { 83 detectorCalled = true; 84 new ContentDetector().isNewContentAvailable(); 85 } 86 return newContributors != null && newContributors.contains(contributionId); 87 } 88 89 } 90 | Popular Tags |