1 11 package org.eclipse.debug.internal.ui.launchConfigurations; 12 13 import org.eclipse.core.runtime.CoreException; 14 import org.eclipse.debug.core.ILaunchConfiguration; 15 import org.eclipse.debug.core.ILaunchConfigurationType; 16 import org.eclipse.debug.ui.IDebugUIConstants; 17 import org.eclipse.jface.viewers.Viewer; 18 import org.eclipse.jface.viewers.ViewerFilter; 19 import org.eclipse.ui.activities.WorkbenchActivityHelper; 20 21 27 public class MultiLaunchGroupFilter extends ViewerFilter { 28 29 32 private LaunchGroupExtension[] fGroups; 33 34 public MultiLaunchGroupFilter(LaunchGroupExtension[] groups) { 35 fGroups = groups; 36 } 37 38 41 public boolean select(Viewer viewer, Object parentElement, Object element) { 42 ILaunchConfigurationType type = null; 43 ILaunchConfiguration config = null; 44 boolean priv = false; 45 if (parentElement instanceof ILaunchConfigurationType) { 46 type = (ILaunchConfigurationType)parentElement; 47 } 48 if (element instanceof ILaunchConfigurationType) { 49 type = (ILaunchConfigurationType)element; 50 priv = !type.isPublic(); 51 } 52 if (element instanceof ILaunchConfiguration) { 53 config = (ILaunchConfiguration)element; 54 try { 55 type = config.getType(); 56 priv = config.getAttribute(IDebugUIConstants.ATTR_PRIVATE, false); 57 } 58 catch (CoreException e) {} 59 } 60 if (type != null) { 61 return !priv && equalModes(type) && equalCategories(type.getCategory()) && !WorkbenchActivityHelper.filterItem(new LaunchConfigurationTypeContribution(type)); 62 } 63 return false; 64 } 65 66 71 private boolean equalModes(ILaunchConfigurationType type) { 72 for(int i = 0; i < fGroups.length; i++) { 73 if(type.supportsMode(fGroups[i].getMode())) { 74 return true; 75 } 76 } 77 return false; 78 } 79 80 85 private boolean equalCategories(String category) { 86 String lcat = null; 87 for(int i = 0; i < fGroups.length; i++) { 88 lcat = fGroups[i].getCategory(); 89 if(category == null || lcat == null) { 90 if(category == lcat) { 91 return true; 92 } 93 } 94 else { 95 if(category.equals(lcat)) { 96 return true; 97 } 98 } 99 } 100 return false; 101 } 102 103 } 104 | Popular Tags |