1 11 package org.eclipse.debug.internal.ui.launchConfigurations; 12 13 14 import org.eclipse.core.runtime.CoreException; 15 import org.eclipse.debug.core.ILaunchConfiguration; 16 import org.eclipse.debug.core.ILaunchConfigurationType; 17 import org.eclipse.debug.ui.IDebugUIConstants; 18 import org.eclipse.debug.ui.ILaunchGroup; 19 import org.eclipse.jface.viewers.Viewer; 20 import org.eclipse.jface.viewers.ViewerFilter; 21 import org.eclipse.ui.activities.WorkbenchActivityHelper; 22 23 26 public class LaunchGroupFilter extends ViewerFilter { 27 28 private ILaunchGroup fGroup; 29 30 34 public LaunchGroupFilter(ILaunchGroup groupExtension) { 35 super(); 36 fGroup = groupExtension; 37 } 38 39 42 public boolean select(Viewer viewer, Object parentElement, Object element) { 43 ILaunchConfigurationType type = null; 44 ILaunchConfiguration config = null; 45 if (parentElement instanceof ILaunchConfigurationType) { 46 type = (ILaunchConfigurationType)parentElement; 47 } 48 if (element instanceof ILaunchConfigurationType) { 49 type = (ILaunchConfigurationType)element; 50 } 51 if (element instanceof ILaunchConfiguration) { 52 config = (ILaunchConfiguration)element; 53 try { 54 type = config.getType(); 55 } 56 catch (CoreException e) {} 57 } 58 boolean priv = false; 59 if (config != null) { 60 try { 61 priv = config.getAttribute(IDebugUIConstants.ATTR_PRIVATE, false); 62 } catch (CoreException e) { 63 } 64 } 65 if (type != null) { 66 return !priv && type.supportsMode(fGroup.getMode()) && equalCategories(type.getCategory(), fGroup.getCategory()) && !WorkbenchActivityHelper.filterItem(new LaunchConfigurationTypeContribution(type)); 67 } 68 return false; 69 } 70 71 78 private boolean equalCategories(String c1, String c2) { 79 if (c1 == null || c2 == null) { 80 return c1 == c2; 81 } 82 return c1.equals(c2); 83 } 84 85 } 86 | Popular Tags |