KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > debug > internal > ui > StepFilterManager


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.debug.internal.ui;
12
13 import org.eclipse.debug.core.DebugPlugin;
14 import org.eclipse.debug.core.ILaunch;
15 import org.eclipse.debug.core.ILaunchListener;
16 import org.eclipse.debug.internal.ui.actions.context.ActionRequestMonitor;
17 import org.eclipse.debug.internal.ui.actions.provisional.IAsynchronousStepFiltersAdapter;
18
19 /**
20  * As targets are launched, this manager sets its step filter
21  * support settings according to the "use step filter" setting.
22  *
23  * @since 3.0
24  */

25 public class StepFilterManager implements ILaunchListener {
26     
27     /**
28      * The step filter manager is instantiated by the debug UI plug-in,
29      * and should be accessed from the <code>DebugUIPlugin</code> class.
30      */

31     protected StepFilterManager() {
32         DebugPlugin.getDefault().getLaunchManager().addLaunchListener(this);
33     }
34     
35     /**
36      * This method is called by the debug UI plug-in at shutdown.
37      */

38     public void shutdown() {
39         DebugPlugin.getDefault().getLaunchManager().removeLaunchListener(this);
40     }
41     
42     /* (non-Javadoc)
43      * @see org.eclipse.debug.core.ILaunchListener#launchAdded(org.eclipse.debug.core.ILaunch)
44      */

45     public void launchAdded(ILaunch launch) {
46         launchChanged(launch);
47     }
48     /* (non-Javadoc)
49      * @see org.eclipse.debug.core.ILaunchListener#launchChanged(org.eclipse.debug.core.ILaunch)
50      */

51     public void launchChanged(ILaunch launch) {
52         boolean useStepFilters = isUseStepFilters();
53         IAsynchronousStepFiltersAdapter stepFilterAdapter = (IAsynchronousStepFiltersAdapter)launch.getAdapter(IAsynchronousStepFiltersAdapter.class);
54         if (stepFilterAdapter != null)
55         {
56             stepFilterAdapter.setStepFiltersEnabled(launch, useStepFilters, new ActionRequestMonitor());
57         }
58     }
59     
60     /**
61      * Returns whether the 'use step filters' preference is on.
62      *
63      * @return whether to use step filters
64      */

65     public boolean isUseStepFilters() {
66         //TODO: revert once API freeze is over
67
return DebugUIPlugin.getDefault().getPreferenceStore().getBoolean(IInternalDebugUIConstants.PREF_USE_STEP_FILTERS/*IDebugUIConstants.PREF_USE_STEP_FILTERS*/);
68     }
69     
70     /**
71      * Sets whether to use step filters.
72      *
73      * @param useFilters whether to use step filters
74      */

75     public void setUseStepFilters(boolean useFilters) {
76         //TODO: revert onve API freeze is over
77
DebugUIPlugin.getDefault().getPreferenceStore().setValue(IInternalDebugUIConstants.PREF_USE_STEP_FILTERS/*IDebugUIConstants.PREF_USE_STEP_FILTERS*/, useFilters);
78         ILaunch[] launchs = DebugPlugin.getDefault().getLaunchManager().getLaunches();
79         for (int i = 0; i < launchs.length; i++) {
80             ILaunch launch = launchs[i];
81             launchChanged(launch);
82         }
83     }
84     
85     /* (non-Javadoc)
86      * @see org.eclipse.debug.core.ILaunchListener#launchRemoved(org.eclipse.debug.core.ILaunch)
87      */

88     public void launchRemoved(ILaunch launch) {
89     }
90 }
91
Popular Tags