boolean (String featureId, Project project, final long timeUnit) { ProductivityFeaturesRegistry registry = ProductivityFeaturesRegistry.getInstance(); if (registry == null) return false; FeatureDescriptor descriptor = registry.getFeatureDescriptor(featureId); if (descriptor == null || !descriptor.isUnused()) { return false; } String[] dependencyFeatures = descriptor.getDependencyFeatures(); boolean locked = dependencyFeatures.length > 0; for (int i = 0; locked && i < dependencyFeatures.length; i++) { if (!registry.getFeatureDescriptor(dependencyFeatures[i]).isUnused()) { locked = false; } } if (locked) return false; ApplicabilityFilter[] filters = registry.getMatchingFilters(featureId); for (ApplicabilityFilter filter: filters) { if (!filter.isApplicable(featureId, project)) return false; } long current = System.currentTimeMillis(); long succesive_interval = descriptor.getDaysBetweenSuccessiveShowUps() * timeUnit + descriptor.getShownCount() * 2L; long firstShowUpInterval = descriptor.getDaysBeforeFirstShowUp() * timeUnit; long lastTimeUsed = descriptor.getLastTimeUsed(); long lastTimeShown = descriptor.getLastTimeShown(); return lastTimeShown == 0 && firstShowUpInterval + getFirstRunTime() < current || lastTimeShown > 0 && current - lastTimeShown > succesive_interval && current - lastTimeUsed > succesive_interval; }