KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*******************************************************************************
2  * Copyright (c) 2000, 2007 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.core;
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.core.commands.IStepFiltersHandler;
17 import org.eclipse.debug.internal.core.commands.DebugCommandRequest;
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     public static final String JavaDoc PREF_USE_STEP_FILTERS = DebugPlugin.getUniqueIdentifier() + ".USE_STEP_FILTERS"; //$NON-NLS-1$
28

29     /**
30      * The step filter manager is instantiated by the debug UI plug-in,
31      * and should be accessed from the <code>DebugUIPlugin</code> class.
32      */

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

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

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

53     public void launchChanged(ILaunch launch) {
54         IStepFiltersHandler command = (IStepFiltersHandler)launch.getAdapter(IStepFiltersHandler.class);
55         if (command != null) {
56             command.execute(new DebugCommandRequest(new Object JavaDoc[]{launch}));
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         return DebugPlugin.getDefault().getPluginPreferences().getBoolean(PREF_USE_STEP_FILTERS);
67     }
68     
69     /**
70      * Sets whether to use step filters.
71      *
72      * @param useFilters whether to use step filters
73      */

74     public void setUseStepFilters(boolean useFilters) {
75         DebugPlugin.getDefault().getPluginPreferences().setValue(PREF_USE_STEP_FILTERS, useFilters);
76         ILaunch[] launchs = DebugPlugin.getDefault().getLaunchManager().getLaunches();
77         for (int i = 0; i < launchs.length; i++) {
78             ILaunch launch = launchs[i];
79             launchChanged(launch);
80         }
81     }
82     
83     /* (non-Javadoc)
84      * @see org.eclipse.debug.core.ILaunchListener#launchRemoved(org.eclipse.debug.core.ILaunch)
85      */

86     public void launchRemoved(ILaunch launch) {}
87 }
88
Popular Tags