/** initialize the rows (metrics and source folder children for each) */ private void initMetrics() { MetricsPlugin plugin = MetricsPlugin.getDefault(); String[] names = plugin.getMetricIds(); IPackageFragmentRoot[] roots = getPackageFragmentRoots(getProject()); for (String name : names) { MetricDescriptor md = plugin.getMetricDescriptor(name); if (md.isAllowDisable()) { createNewRow(md, roots); } } // gray those that cannot be enabled TableTreeItem[] items = getItems(); for (int i = 0; i < items.length; i++) { if (!allowEnable(items[i])) { items[i].setGrayed(true); } } }
/** * enable/disable all metrics that depend on the given metric * * @param descriptor * @param enable */ private void enableDependentMetrics(MetricDescriptor descriptor, boolean enable) { MetricsPlugin plugin = MetricsPlugin.getDefault(); String[] dependents = plugin.getDependentMetrics(descriptor); TableTreeItem[] items = getItems(); if (dependents != null && dependents.length > 0) { for (String dependent : dependents) { for (TableTreeItem item : items) { String id = (String) item.getData("id"); if (id.equals(dependent)) { if (!enable) { // simply disable enableItem(item, false, true); } else { // check all requirements and if ok, enable if (allowEnable(item)) { enableItem(item, true, false); } } } } } } }