1 /******************************************************************************* 2 * Copyright (c) 2017 Igor Fedorenko. 3 * 4 * This program and the accompanying materials 5 * are made available under the terms of the Eclipse Public License 2.0 6 * which accompanies this distribution, and is available at 7 * https://www.eclipse.org/legal/epl-2.0/ 8 * 9 * SPDX-License-Identifier: EPL-2.0 10 * 11 * Contributors: 12 * Igor Fedorenko - initial API and implementation 13 *******************************************************************************/ 14 package org.eclipse.jdt.internal.debug.ui.actions; 15 16 import org.eclipse.debug.core.DebugException; 17 import org.eclipse.jdt.debug.core.IJavaThread; 18 import org.eclipse.jdt.debug.ui.IJavaDebugUIConstants; 19 import org.eclipse.jface.preference.IPreferenceStore; 20 import org.eclipse.ui.IViewPart; 21 22 /** 23 * An action delegate that toggles the state of its viewer to show/hide running threads. 24 */ 25 public class ShowRunningThreadsAction extends AbstractThreadsViewFilterAction { 26 27 @Override init(IViewPart view)28 public void init(IViewPart view) { 29 // compensate for a bug in how ViewFilterAction stores compositeKey value 30 // which does not allow default==true and explicit==false 31 IPreferenceStore store = getPreferenceStore(); 32 String preferenceKey = getPreferenceKey(); 33 if (store.contains(preferenceKey)) { 34 String compositeKey = view.getSite().getId() + "." + preferenceKey; //$NON-NLS-1$ 35 store.setDefault(compositeKey, store.getBoolean(preferenceKey)); 36 } 37 38 super.init(view); 39 } 40 41 @Override getPreferenceKey()42 protected String getPreferenceKey() { 43 return IJavaDebugUIConstants.PREF_SHOW_RUNNING_THREADS; 44 } 45 46 @Override selectThread(IJavaThread thread)47 protected boolean selectThread(IJavaThread thread) throws DebugException { 48 return thread.isSuspended(); 49 } 50 51 @Override isCandidateThread(IJavaThread thread)52 protected boolean isCandidateThread(IJavaThread thread) throws DebugException { 53 return true; 54 } 55 } 56