1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-24 01:15:29 +02:00

Bug 360588 - [breakpoints] Allow user to edit all its properties prior to creating the breakpoint

Added ICBreakpointContext interface.
This commit is contained in:
Pawel Piech 2012-03-13 11:31:36 -07:00
parent 5fc0587f6d
commit b9f5e87587
6 changed files with 81 additions and 22 deletions

View file

@ -10,6 +10,7 @@ Export-Package:
org.eclipse.cdt.debug.internal.ui;x-internal:=true,
org.eclipse.cdt.debug.internal.ui.actions;x-friends:="org.eclipse.cdt.dsf.ui,org.eclipse.cdt.debug.ui.memory.memorybrowser",
org.eclipse.cdt.debug.internal.ui.actions.breakpoints;x-internal:=true,
org.eclipse.cdt.debug.internal.ui.breakpoints;x-internal:=true,
org.eclipse.cdt.debug.internal.ui.commands;x-internal:=true,
org.eclipse.cdt.debug.internal.ui.dialogfields;x-internal:=true,
org.eclipse.cdt.debug.internal.ui.dialogs;x-internal:=true,

View file

@ -1194,8 +1194,7 @@
</and>
<and>
<instanceof value="org.eclipse.cdt.debug.internal.ui.breakpoints.CBreakpointContext">
</instanceof>
<instanceof value="org.eclipse.cdt.debug.ui.breakpoints.ICBreakpointContext"/>
<test property="org.eclipse.cdt.debug.ui.createBreakpointAdapt" value="org.eclipse.cdt.debug.core.model.ICBreakpoint" />
<not>
<test property="org.eclipse.cdt.debug.ui.createBreakpointAdapt" value="org.eclipse.cdt.debug.core.model.ICTracepoint"/>
@ -2571,7 +2570,7 @@
id="org.eclipse.cdt.debug.ui.CreateBreakpointTester"
namespace="org.eclipse.cdt.debug.ui"
properties="createBreakpointAdapt"
type="org.eclipse.cdt.debug.internal.ui.breakpoints.CBreakpointContext">
type="org.eclipse.cdt.debug.ui.breakpoints.ICBreakpointContext">
</propertyTester>
</extension>

View file

@ -15,6 +15,7 @@ import java.util.Map;
import org.eclipse.cdt.debug.core.model.ICBreakpoint;
import org.eclipse.cdt.debug.core.model.ICTracepoint;
import org.eclipse.cdt.debug.ui.breakpoints.ICBreakpointContext;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IAdapterFactory;
@ -24,7 +25,6 @@ import org.eclipse.debug.core.model.IBreakpoint;
import org.eclipse.debug.core.model.IDebugElement;
import org.eclipse.debug.core.model.IDebugModelProvider;
import org.eclipse.debug.ui.contexts.IDebugContextListener;
import org.eclipse.debug.ui.contexts.IDebugContextProvider;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
@ -37,7 +37,7 @@ import org.eclipse.ui.IWorkbenchPart;
* This combined context can then be used by breakpoint property
* pages to access model and target specific breakpoint settings.
*/
public class CBreakpointContext extends PlatformObject implements IDebugContextProvider {
public class CBreakpointContext extends PlatformObject implements ICBreakpointContext {
// Register an adapter factory for the class when it is first loaded.
static {
@ -62,7 +62,7 @@ public class CBreakpointContext extends PlatformObject implements IDebugContextP
/**
* Associated preference store.
*/
final CBreakpointPreferenceStore fPreferenceStore;
private final CBreakpointPreferenceStore fPreferenceStore;
/**
* Creates a new breakpoint context with given breakpoint and debug
@ -79,13 +79,15 @@ public class CBreakpointContext extends PlatformObject implements IDebugContextP
fPreferenceStore = new CBreakpointPreferenceStore(this, attributes);
}
/**
* Returns the breakpoint.
*/
@Override
public ICBreakpoint getBreakpoint() { return fBreakpoint; }
@Override
public IResource getResource() { return fResource; }
@Override
public IPreferenceStore getPreferenceStore() { return fPreferenceStore; }
/**
* Returns the debug context.
*/
@ -170,7 +172,7 @@ class CBreakpointContextAdapterFactory implements IAdapterFactory {
}
if ( IPreferenceStore.class.equals(adapterType) ) {
return ((CBreakpointContext)obj).fPreferenceStore;
return ((CBreakpointContext)obj).getPreferenceStore();
}
if (IActionFilter.class.equals(adapterType)) {

View file

@ -20,6 +20,7 @@ import org.eclipse.cdt.debug.core.model.ICLineBreakpoint;
import org.eclipse.cdt.debug.core.model.ICWatchpoint;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
import org.eclipse.cdt.debug.ui.breakpoints.CBreakpointUIContributionFactory;
import org.eclipse.cdt.debug.ui.breakpoints.ICBreakpointContext;
import org.eclipse.cdt.debug.ui.breakpoints.ICBreakpointsUIContribution;
import org.eclipse.cdt.debug.ui.preferences.ReadOnlyFieldEditor;
import org.eclipse.core.resources.IFile;
@ -389,16 +390,16 @@ public class CBreakpointPropertyPage extends FieldEditorPreferencePage implement
public IPreferenceStore getPreferenceStore() {
IAdaptable element = getElement();
IPreferenceStore store = (IPreferenceStore) element.getAdapter(IPreferenceStore.class);
if (store == null) {
if (fCBreakpointPreferenceStore == null) {
CBreakpointContext bpContext = element instanceof CBreakpointContext ?
(CBreakpointContext)element : null;
fCBreakpointPreferenceStore = new CBreakpointPreferenceStore(bpContext, null);
}
store = fCBreakpointPreferenceStore;
}
return store;
if (element instanceof ICBreakpointContext) {
return ((ICBreakpointContext)element).getPreferenceStore();
}
if (fCBreakpointPreferenceStore == null) {
CBreakpointContext bpContext = element instanceof CBreakpointContext ?
(CBreakpointContext)element : null;
fCBreakpointPreferenceStore = new CBreakpointPreferenceStore(bpContext, null);
}
return fCBreakpointPreferenceStore;
}
@Override

View file

@ -11,6 +11,7 @@
package org.eclipse.cdt.debug.internal.ui.breakpoints;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
import org.eclipse.cdt.debug.ui.breakpoints.ICBreakpointContext;
import org.eclipse.core.expressions.PropertyTester;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
@ -25,13 +26,13 @@ public class CreateBreakpointTester extends PropertyTester {
@Override
public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
if (PROP_CREATE_BREAKPOINT_ADAPT.equals(property) &&
receiver instanceof CBreakpointContext &&
receiver instanceof ICBreakpointContext &&
expectedValue instanceof String)
{
try {
Class<?> expectedClass = Class.forName((String)expectedValue);
return expectedClass.isAssignableFrom(
((CBreakpointContext)receiver).getBreakpoint().getClass());
((ICBreakpointContext)receiver).getBreakpoint().getClass());
} catch (ClassNotFoundException e) {
CDebugUIPlugin.log(new Status(IStatus.ERROR, CDebugUIPlugin.PLUGIN_ID, "Unable to create class: " + expectedValue, e)); //$NON-NLS-1$
}

View file

@ -0,0 +1,55 @@
/*******************************************************************************
* Copyright (c) 2012 Wind River Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Wind River Systems - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.debug.ui.breakpoints;
import org.eclipse.cdt.debug.core.model.ICBreakpoint;
import org.eclipse.core.resources.IResource;
import org.eclipse.debug.ui.contexts.IDebugContextProvider;
import org.eclipse.jface.preference.IPreferenceStore;
/**
* Input for the breakpoint properties dialog. It captures both the
* selected breakpoint object as well as the selected debug context.
* This combined context can then be used by breakpoint property
* pages to access model and target specific breakpoint settings.
*
* @since 7.2
*/
public interface ICBreakpointContext extends IDebugContextProvider {
/**
* Returns the breakpoint object that this context represents.
* <p>
* Note: The returned breakpoint may not yet have an associated marker.
* This is for the case where the property dialog is opened for a breakpoint
* that is yet to be created.
*
* @return Breakpoint object.
*/
public ICBreakpoint getBreakpoint();
/**
* Resource object that the breakpoint marker is on. In case where
* the breakpoint marker is not yet created, clients can access the intended
* breakpoint resource object through this method.
*
* @return The breakpoint's resource object.
*/
public IResource getResource();
/**
* Returns the preference store to be used by property pages. This
* preference overrides values in the breakpoint marker.
* @return Preference store for the property pages.
*/
public IPreferenceStore getPreferenceStore();
}