1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Bug 338908 - Turn the Signals view into a flexible hierarchy view

This commit is contained in:
Anton Leherbauer 2011-03-08 08:31:36 +00:00
parent 6f33dd512d
commit 9b091e5b66
14 changed files with 714 additions and 31 deletions

View file

@ -165,7 +165,7 @@
name="%SignalsView.name"
icon="icons/view16/signals_view.gif"
category="org.eclipse.debug.ui"
class="org.eclipse.cdt.debug.internal.ui.views.signals.SignalsView"
class="org.eclipse.cdt.debug.internal.ui.views.signals.FlexibleSignalsView"
id="org.eclipse.cdt.debug.ui.SignalsView">
</view>
</extension>
@ -1365,9 +1365,8 @@
class="org.eclipse.cdt.debug.internal.ui.elements.adapters.CDebugElementAdapterFactory">
<adapter type="org.eclipse.debug.internal.ui.viewers.model.provisional.IElementContentProvider"/>
<adapter type="org.eclipse.debug.internal.ui.viewers.model.provisional.IModelProxyFactory"/>
<adapter
type="org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerInputProvider">
</adapter>
<adapter type="org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerInputProvider"/>
<adapter type="org.eclipse.debug.internal.ui.viewers.model.provisional.IColumnPresentationFactory"/>
</factory>
<factory
adaptableType="org.eclipse.cdt.debug.core.model.ICThread"
@ -1375,9 +1374,7 @@
<adapter type="org.eclipse.debug.internal.ui.viewers.model.provisional.IElementContentProvider"/>
<adapter type="org.eclipse.debug.internal.ui.viewers.model.provisional.IModelProxyFactory"/>
<adapter type="org.eclipse.debug.internal.ui.viewers.model.provisional.IElementMementoProvider"/>
<adapter
type="org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerInputProvider">
</adapter>
<adapter type="org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerInputProvider"/>
</factory>
<factory
adaptableType="org.eclipse.cdt.debug.core.model.ICStackFrame"
@ -1385,12 +1382,8 @@
<adapter type="org.eclipse.debug.internal.ui.viewers.model.provisional.IElementContentProvider"/>
<adapter type="org.eclipse.debug.internal.ui.viewers.model.provisional.IModelProxyFactory"/>
<adapter type="org.eclipse.debug.internal.ui.viewers.model.provisional.IElementMementoProvider"/>
<adapter
type="org.eclipse.cdt.debug.ui.disassembly.IDocumentElementContentProvider">
</adapter>
<adapter
type="org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerInputProvider">
</adapter>
<adapter type="org.eclipse.cdt.debug.ui.disassembly.IDocumentElementContentProvider"/>
<adapter type="org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerInputProvider"/>
</factory>
<factory
adaptableType="org.eclipse.cdt.debug.core.model.ICModule"
@ -1414,10 +1407,6 @@
type="org.eclipse.debug.internal.ui.viewers.model.provisional.IElementContentProvider">
</adapter>
<adapter type="org.eclipse.debug.internal.ui.viewers.model.provisional.IElementMementoProvider"/>
</factory>
<factory
adaptableType="org.eclipse.cdt.core.model.ICElement"
class="org.eclipse.cdt.debug.internal.ui.elements.adapters.CDebugElementLabelProviderFactory">
<adapter
type="org.eclipse.debug.internal.ui.viewers.model.provisional.IElementLabelProvider">
</adapter>
@ -1425,6 +1414,11 @@
<factory
adaptableType="org.eclipse.cdt.debug.core.model.ICVariable"
class="org.eclipse.cdt.debug.internal.ui.elements.adapters.CDebugElementLabelProviderFactory">
<adapter type="org.eclipse.debug.internal.ui.viewers.model.provisional.IElementLabelProvider"/>
</factory>
<factory
adaptableType="org.eclipse.cdt.debug.core.model.ICSignal"
class="org.eclipse.cdt.debug.internal.ui.elements.adapters.CDebugElementLabelProviderFactory">
<adapter
type="org.eclipse.debug.internal.ui.viewers.model.provisional.IElementLabelProvider">
</adapter>

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2004, 2010 QNX Software Systems and others.
* Copyright (c) 2004, 2011 QNX Software 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
@ -10,11 +10,13 @@
* IBM Corporation
* ARM Limited - https://bugs.eclipse.org/bugs/show_bug.cgi?id=186981
* Wind River Systems - adapted to work with platform Modules view (bug 210558)
* Wind River Systems - flexible hierarchy Signals view (bug 338908)
*******************************************************************************/
package org.eclipse.cdt.debug.internal.ui.elements.adapters;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.debug.core.disassembly.IDisassemblyContextProvider;
import org.eclipse.cdt.debug.core.model.ICDebugElement;
import org.eclipse.cdt.debug.core.model.ICDebugTarget;
import org.eclipse.cdt.debug.core.model.ICModule;
import org.eclipse.cdt.debug.core.model.ICStackFrame;
@ -60,6 +62,7 @@ public class CDebugElementAdapterFactory implements IAdapterFactory {
private static IViewerInputProvider fgDefaultViewerInputProvider = new CDefaultViewerInputProvider();
private static IViewerInputProvider fgStackFrameViewerInputProvider = new CStackFrameViewerInputProvider();
private static IColumnPresentationFactory fgRegistersViewColumnPresentationFactory = new RegistersViewColumnPresentationFactory();
private static IColumnPresentationFactory fgDefaultViewColumnPresentationFactory = new DefaultViewColumnPresentationFactory();
private static IElementMementoProvider fgRegisterManagerProxyMementoProvider = new CRegisterManagerProxyMementoProvider();
/* (non-Javadoc)
@ -84,8 +87,8 @@ public class CDebugElementAdapterFactory implements IAdapterFactory {
return fgCRegisterManagerContentProvider;
}
if ( adaptableObject instanceof ICModule ||
adaptableObject instanceof ICElement ) {
return fgModuleContentProvider;
adaptableObject instanceof ICElement ) {
return fgModuleContentProvider;
}
}
if ( adapterType.equals( IModelProxyFactory.class ) ) {
@ -158,6 +161,8 @@ public class CDebugElementAdapterFactory implements IAdapterFactory {
if ( adapterType.equals( IColumnPresentationFactory.class ) ) {
if ( adaptableObject instanceof CRegisterManagerProxy ) {
return fgRegistersViewColumnPresentationFactory;
} else if (adaptableObject instanceof ICDebugElement) {
return fgDefaultViewColumnPresentationFactory;
}
}
return null;

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2007 ARM Limited and others.
* Copyright (c) 2007, 2011 ARM Limited 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
@ -7,13 +7,16 @@
*
* Contributors:
* ARM Limited - Initial API and implementation
* Wind River Systems - flexible hierarchy Signals view (bug 338908)
*******************************************************************************/
package org.eclipse.cdt.debug.internal.ui.elements.adapters;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.debug.core.model.ICModule;
import org.eclipse.cdt.debug.core.model.ICSignal;
import org.eclipse.cdt.debug.core.model.ICVariable;
import org.eclipse.cdt.debug.internal.ui.views.modules.ModuleLabelProvider;
import org.eclipse.cdt.debug.internal.ui.views.signals.SignalLabelProvider;
import org.eclipse.core.runtime.IAdapterFactory;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementLabelProvider;
@ -24,10 +27,12 @@ public class CDebugElementLabelProviderFactory implements IAdapterFactory {
private static IElementLabelProvider fgModuleLabelProvider = new ModuleLabelProvider();
private static IElementLabelProvider fgVariableLabelProvider = new CVariableLabelProvider();
private static IElementLabelProvider fgSignalLabelProvider = new SignalLabelProvider();
/* (non-Javadoc)
* @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class)
*/
@SuppressWarnings("rawtypes")
public Object getAdapter( Object adaptableObject, Class adapterType ) {
if ( adapterType.equals( IElementLabelProvider.class ) ) {
if ( adaptableObject instanceof ICModule ) {
@ -39,6 +44,9 @@ public class CDebugElementLabelProviderFactory implements IAdapterFactory {
if ( adaptableObject instanceof ICVariable ) {
return fgVariableLabelProvider;
}
if ( adaptableObject instanceof ICSignal ) {
return fgSignalLabelProvider;
}
}
return null;
}
@ -46,6 +54,7 @@ public class CDebugElementLabelProviderFactory implements IAdapterFactory {
/* (non-Javadoc)
* @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList()
*/
@SuppressWarnings("rawtypes")
public Class[] getAdapterList() {
return new Class[] {
IElementLabelProvider.class,

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2004, 2010 QNX Software Systems and others.
* Copyright (c) 2004, 2011 QNX Software 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
@ -9,6 +9,7 @@
* QNX Software Systems - Initial API and implementation
* IBM Corporation
* Wind River Systems - adapted to work with platform Modules view (bug 210558)
* Wind River Systems - flexible hierarchy Signals view (bug 338908)
*******************************************************************************/
package org.eclipse.cdt.debug.internal.ui.elements.adapters;
@ -16,6 +17,7 @@ import org.eclipse.cdt.debug.core.model.ICDebugTarget;
import org.eclipse.cdt.debug.core.model.IModuleRetrieval;
import org.eclipse.cdt.debug.internal.core.model.DisassemblyRetrieval;
import org.eclipse.cdt.debug.internal.ui.views.modules.ModulesViewModelProxy;
import org.eclipse.cdt.debug.internal.ui.views.signals.SignalsViewModelProxy;
import org.eclipse.cdt.debug.ui.ICDebugUIConstants;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelProxy;
@ -28,6 +30,7 @@ public class CDebugElementProxyFactory extends DefaultModelProxyFactory {
/* (non-Javadoc)
* @see org.eclipse.debug.internal.ui.viewers.provisional.IModelProxyFactoryAdapter#createModelProxy(java.lang.Object, org.eclipse.debug.internal.ui.viewers.provisional.IPresentationContext)
*/
@Override
public IModelProxy createModelProxy( Object element, IPresentationContext context ) {
if ( IDebugUIConstants.ID_MODULE_VIEW.equals( context.getId() ) ) {
IModuleRetrieval mr = null;
@ -50,6 +53,11 @@ public class CDebugElementProxyFactory extends DefaultModelProxyFactory {
return new DisassemblyElementProxy( element );
}
}
else if ( ICDebugUIConstants.ID_SIGNALS_VIEW.equals( context.getId() ) ) {
if ( element instanceof ICDebugTarget ) {
return new SignalsViewModelProxy( element );
}
}
return super.createModelProxy( element, context );
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2008 Wind River Systems and others.
* Copyright (c) 2008, 2011 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
@ -7,10 +7,13 @@
*
* Contributors:
* Wind River Systems - initial API and implementation
* Wind River Systems - flexible hierarchy Signals view (bug 338908)
*******************************************************************************/
package org.eclipse.cdt.debug.internal.ui.elements.adapters;
import org.eclipse.cdt.debug.internal.ui.views.modules.ModuleContentProvider;
import org.eclipse.cdt.debug.internal.ui.views.signals.SignalsContentProvider;
import org.eclipse.cdt.debug.ui.ICDebugUIConstants;
import org.eclipse.debug.internal.ui.model.elements.DebugTargetContentProvider;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IChildrenCountUpdate;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IChildrenUpdate;
@ -24,12 +27,16 @@ import org.eclipse.debug.ui.IDebugUIConstants;
* implementation.
*/
public class CDebugTargetContentProvider extends DebugTargetContentProvider {
private ModuleContentProvider fModuleContentProvider = new ModuleContentProvider();
private final ModuleContentProvider fModuleContentProvider = new ModuleContentProvider();
private final SignalsContentProvider fSignalsContentProvider = new SignalsContentProvider();
@Override
public void update(IChildrenCountUpdate[] updates) {
if (updates[0].getPresentationContext().getId().equals(IDebugUIConstants.ID_MODULE_VIEW)) {
String id = updates[0].getPresentationContext().getId();
if (IDebugUIConstants.ID_MODULE_VIEW.equals(id)) {
fModuleContentProvider.update(updates);
} else if (ICDebugUIConstants.ID_SIGNALS_VIEW.equals(id)) {
fSignalsContentProvider.update(updates);
} else {
super.update(updates);
}
@ -37,8 +44,11 @@ public class CDebugTargetContentProvider extends DebugTargetContentProvider {
@Override
public void update(IHasChildrenUpdate[] updates) {
if (updates[0].getPresentationContext().getId().equals(IDebugUIConstants.ID_MODULE_VIEW)) {
String id = updates[0].getPresentationContext().getId();
if (IDebugUIConstants.ID_MODULE_VIEW.equals(id)) {
fModuleContentProvider.update(updates);
} else if (ICDebugUIConstants.ID_SIGNALS_VIEW.equals(id)) {
fSignalsContentProvider.update(updates);
} else {
super.update(updates);
}
@ -46,8 +56,11 @@ public class CDebugTargetContentProvider extends DebugTargetContentProvider {
@Override
public void update(IChildrenUpdate[] updates) {
if (updates[0].getPresentationContext().getId().equals(IDebugUIConstants.ID_MODULE_VIEW)) {
String id = updates[0].getPresentationContext().getId();
if (IDebugUIConstants.ID_MODULE_VIEW.equals(id)) {
fModuleContentProvider.update(updates);
} else if (ICDebugUIConstants.ID_SIGNALS_VIEW.equals(id)) {
fSignalsContentProvider.update(updates);
} else {
super.update(updates);
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2010 CodeSourcery and others.
* Copyright (c) 2010, 2011 CodeSourcery 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
@ -7,13 +7,14 @@
*
* Contributors:
* CodeSourcery - Initial API and implementation
* Wind River Systems - flexible hierarchy Signals view (bug 338908)
*******************************************************************************/
package org.eclipse.cdt.debug.internal.ui.elements.adapters;
import org.eclipse.cdt.debug.core.model.ICDebugElement;
import org.eclipse.cdt.debug.core.model.ICDebugTarget;
import org.eclipse.cdt.debug.internal.ui.CRegisterManagerProxies;
import org.eclipse.cdt.debug.ui.ICDebugUIConstants;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.internal.ui.elements.adapters.DefaultViewerInputProvider;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
@ -32,6 +33,10 @@ public class CDefaultViewerInputProvider extends DefaultViewerInputProvider impl
ICDebugTarget target = (ICDebugTarget)((ICDebugElement)source).getDebugTarget();
return CRegisterManagerProxies.getInstance().getRegisterManagerProxy( target );
}
if ( ICDebugUIConstants.ID_SIGNALS_VIEW.equals( context.getId() ) && source instanceof ICDebugElement ) {
ICDebugTarget target = (ICDebugTarget)((ICDebugElement)source).getDebugTarget();
return target;
}
return super.getViewerInput( source, context, update );
}
@ -42,6 +47,8 @@ public class CDefaultViewerInputProvider extends DefaultViewerInputProvider impl
protected boolean supportsContextId( String id ) {
if ( IDebugUIConstants.ID_REGISTER_VIEW.equals( id ) )
return true;
if ( ICDebugUIConstants.ID_SIGNALS_VIEW.equals( id ) )
return true;
return super.supportsContextId( id );
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2010 CodeSourcery and others.
* Copyright (c) 2010, 2011 CodeSourcery 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
@ -7,13 +7,15 @@
*
* Contributors:
* CodeSourcery - Initial API and implementation
* Wind River Systems - flexible hierarchy Signals view (bug 338908)
*******************************************************************************/
package org.eclipse.cdt.debug.internal.ui.elements.adapters;
import org.eclipse.cdt.debug.core.model.ICDebugElement;
import org.eclipse.cdt.debug.core.model.ICDebugTarget;
import org.eclipse.cdt.debug.core.model.ICStackFrame;
import org.eclipse.cdt.debug.internal.ui.CRegisterManagerProxies;
import org.eclipse.cdt.debug.ui.ICDebugUIConstants;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.internal.ui.elements.adapters.StackFrameViewerInputProvider;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
@ -31,6 +33,17 @@ public class CStackFrameViewerInputProvider extends StackFrameViewerInputProvide
ICDebugTarget target = (ICDebugTarget)((ICStackFrame)source).getDebugTarget();
return CRegisterManagerProxies.getInstance().getRegisterManagerProxy( target );
}
if ( ICDebugUIConstants.ID_SIGNALS_VIEW.equals( context.getId() ) && source instanceof ICDebugElement ) {
ICDebugTarget target = (ICDebugTarget)((ICDebugElement)source).getDebugTarget();
return target;
}
return super.getViewerInput( source, context, update );
}
@Override
protected boolean supportsContextId(String id) {
if ( ICDebugUIConstants.ID_SIGNALS_VIEW.equals( id ) )
return true;
return super.supportsContextId(id);
}
}

View file

@ -0,0 +1,33 @@
/*******************************************************************************
* Copyright (c) 2010, 2011 CodeSourcery 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:
* CodeSourcery - Initial API and implementation
* Wind River Systems - flexible hierarchy Signals view (bug 338908)
*******************************************************************************/
package org.eclipse.cdt.debug.internal.ui.elements.adapters;
import org.eclipse.cdt.debug.internal.ui.views.signals.SignalsViewColumnPresentation;
import org.eclipse.cdt.debug.ui.ICDebugUIConstants;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IColumnPresentation;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IColumnPresentationFactory;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
public class DefaultViewColumnPresentationFactory implements IColumnPresentationFactory {
public IColumnPresentation createColumnPresentation( IPresentationContext context, Object element ) {
if ( context.getId().equals( ICDebugUIConstants.ID_SIGNALS_VIEW ) )
return new SignalsViewColumnPresentation();
return null;
}
public String getColumnPresentationId( IPresentationContext context, Object element ) {
if ( context.getId().equals( ICDebugUIConstants.ID_SIGNALS_VIEW ) )
return SignalsViewColumnPresentation.ID;
return null;
}
}

View file

@ -0,0 +1,244 @@
/*******************************************************************************
* Copyright (c) 2011 Wind River Systems, Inc. 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.internal.ui.views.signals;
import org.eclipse.cdt.debug.internal.ui.ICDebugHelpContextIds;
import org.eclipse.cdt.debug.ui.ICDebugUIConstants;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.debug.internal.ui.DelegatingModelPresentation;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelChangedListener;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelDelta;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelProxy;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerInputRequestor;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerInputUpdate;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdateListener;
import org.eclipse.debug.internal.ui.viewers.model.provisional.PresentationContext;
import org.eclipse.debug.internal.ui.viewers.model.provisional.TreeModelViewer;
import org.eclipse.debug.internal.ui.viewers.model.provisional.ViewerInputService;
import org.eclipse.debug.internal.ui.views.DebugModelPresentationContext;
import org.eclipse.debug.ui.AbstractDebugView;
import org.eclipse.debug.ui.DebugUITools;
import org.eclipse.debug.ui.IDebugModelPresentation;
import org.eclipse.debug.ui.contexts.DebugContextEvent;
import org.eclipse.debug.ui.contexts.IDebugContextListener;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.IWorkbenchActionConstants;
import org.eclipse.ui.progress.IWorkbenchSiteProgressService;
/**
* A Signals view based on flexible hierarchy.
*/
public class FlexibleSignalsView extends AbstractDebugView implements IViewerUpdateListener, IDebugContextListener, IModelChangedListener {
private PresentationContext fPresentationContext;
private DelegatingModelPresentation fModelPresentation;
/**
* Viewer input requester used to update the viewer once the viewer input has been
* resolved.
*/
private IViewerInputRequestor fRequester = new IViewerInputRequestor() {
public void viewerInputComplete(IViewerInputUpdate update) {
if (!update.isCanceled()) {
viewerInputUpdateComplete(update);
}
}
};
private ViewerInputService fInputService;
@Override
protected Viewer createViewer(Composite parent) {
getModelPresentation();
TreeModelViewer signalsViewer = createTreeViewer(parent);
fInputService = new ViewerInputService(signalsViewer, fRequester);
getSite().setSelectionProvider(signalsViewer);
signalsViewer.addModelChangedListener(this);
signalsViewer.addViewerUpdateListener(this);
return signalsViewer;
}
/**
* @return the model presentation to be used for this view
*/
protected IDebugModelPresentation getModelPresentation() {
if (fModelPresentation == null) {
fModelPresentation = new DelegatingModelPresentation();
}
return fModelPresentation;
}
protected TreeModelViewer createTreeViewer(Composite parent) {
int style = getViewerStyle();
fPresentationContext = new DebugModelPresentationContext(getPresentationContextId(), this, fModelPresentation);
final TreeModelViewer variablesViewer = new TreeModelViewer(parent, style, fPresentationContext);
variablesViewer.getPresentationContext().addPropertyChangeListener(
new IPropertyChangeListener() {
public void propertyChange(PropertyChangeEvent event) {
if (IPresentationContext.PROPERTY_COLUMNS.equals(event.getProperty())) {
IAction action = getAction("ShowTypeNames"); //$NON-NLS-1$
if (action != null) {
action.setEnabled(event.getNewValue() == null);
}
}
}
});
DebugUITools.getDebugContextManager().getContextService(getSite().getWorkbenchWindow()).addDebugContextListener(this);
return variablesViewer;
}
protected void viewerInputUpdateComplete(IViewerInputUpdate update) {
setViewerInput(update.getInputElement());
}
/**
* Sets the input to the viewer
* @param context the object context
*/
protected void setViewerInput(Object context) {
Object current = getViewer().getInput();
if (current == null && context == null) {
return;
}
if (current != null && current.equals(context)) {
return;
}
showViewer();
getViewer().setInput(context);
}
/**
* Returns the presentation context id for this view.
*
* @return context id
*/
protected String getPresentationContextId() {
return ICDebugUIConstants.ID_SIGNALS_VIEW;
}
/**
* Returns the style bits for the viewer.
*
* @return SWT style
*/
protected int getViewerStyle() {
return SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL | SWT.VIRTUAL | SWT.FULL_SELECTION;
}
@Override
protected void createActions() {
}
@Override
protected String getHelpContextId() {
return ICDebugHelpContextIds.SIGNALS_VIEW;
}
@Override
protected void fillContextMenu(IMenuManager menu) {
menu.add( new Separator( IWorkbenchActionConstants.MB_ADDITIONS ) );
updateObjects();
}
@Override
protected void configureToolBar(IToolBarManager tbm) {
}
/*
* @see org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdateListener#viewerUpdatesBegin()
*/
public void viewerUpdatesBegin() {
IWorkbenchSiteProgressService progressService =
(IWorkbenchSiteProgressService)getSite().getAdapter(IWorkbenchSiteProgressService.class);
if (progressService != null) {
progressService.incrementBusy();
}
}
/*
* @see org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdateListener#viewerUpdatesComplete()
*/
public void viewerUpdatesComplete() {
IWorkbenchSiteProgressService progressService =
(IWorkbenchSiteProgressService)getSite().getAdapter(IWorkbenchSiteProgressService.class);
if (progressService != null) {
progressService.decrementBusy();
}
}
/*
* @see org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdateListener#updateStarted(org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate)
*/
public void updateStarted(IViewerUpdate update) {
}
/*
* @see org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdateListener#updateComplete(org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate)
*/
public void updateComplete(IViewerUpdate update) {
IStatus status = update.getStatus();
if (!update.isCanceled()) {
if (status != null && !status.isOK()) {
showMessage(status.getMessage());
} else {
showViewer();
}
}
}
/*
* @see org.eclipse.debug.ui.contexts.IDebugContextListener#debugContextChanged(org.eclipse.debug.ui.contexts.DebugContextEvent)
*/
public void debugContextChanged(DebugContextEvent event) {
if ((event.getFlags() & DebugContextEvent.ACTIVATED) > 0) {
contextActivated(event.getContext());
}
}
/**
* Updates actions and sets the viewer input when a context is activated.
* @param selection
*/
protected void contextActivated(ISelection selection) {
if (!isAvailable() || !isVisible()) {
return;
}
if (selection instanceof IStructuredSelection) {
Object source = ((IStructuredSelection)selection).getFirstElement();
fInputService.resolveViewerInput(source);
}
}
/*
* @see org.eclipse.debug.internal.ui.viewers.model.provisional.IModelChangedListener#modelChanged(org.eclipse.debug.internal.ui.viewers.model.provisional.IModelDelta, org.eclipse.debug.internal.ui.viewers.model.provisional.IModelProxy)
*/
public void modelChanged(IModelDelta delta, IModelProxy proxy) {
}
}

View file

@ -0,0 +1,93 @@
/*******************************************************************************
* Copyright (c) 2004, 2011 QNX Software 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:
* QNX Software Systems - Initial API and implementation
* Wind River Systems - flexible hierarchy Signals view (bug 338908)
*******************************************************************************/
package org.eclipse.cdt.debug.internal.ui.views.signals;
import org.eclipse.cdt.debug.core.model.ICSignal;
import org.eclipse.debug.core.DebugEvent;
import org.eclipse.debug.core.model.IDebugTarget;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelDelta;
import org.eclipse.debug.internal.ui.viewers.model.provisional.ModelDelta;
import org.eclipse.debug.internal.ui.viewers.provisional.AbstractModelProxy;
import org.eclipse.debug.internal.ui.viewers.update.DebugEventHandler;
/**
*/
public class FlexibleSignalsViewEventHandler extends DebugEventHandler {
private Object fTarget;
/**
* Constructor for SignalsViewEventHandler.
*/
public FlexibleSignalsViewEventHandler( AbstractModelProxy proxy, Object target ) {
super( proxy );
fTarget = target;
}
@Override
protected boolean handlesEvent( DebugEvent event ) {
int kind = event.getKind();
if ( kind == DebugEvent.CREATE ||
kind == DebugEvent.TERMINATE ||
kind == DebugEvent.CHANGE ||
kind == DebugEvent.SUSPEND)
return true;
return false;
}
@Override
protected void handleChange( DebugEvent event ) {
if ( event.getSource() instanceof ICSignal )
fireDelta( (ICSignal)event.getSource(), IModelDelta.STATE );
}
@Override
protected void handleCreate( DebugEvent event ) {
Object source = event.getSource();
if ( source instanceof IDebugTarget ) {
refreshRoot( event );
}
else if ( source instanceof ICSignal ) {
if ( accept( (ICSignal)source ) ) {
ICSignal signal = (ICSignal)source;
fireDelta( signal, IModelDelta.ADDED );
}
}
}
@Override
protected void handleTerminate( DebugEvent event ) {
Object source = event.getSource();
if ( source instanceof IDebugTarget ) {
refreshRoot( event );
}
else if ( source instanceof ICSignal ) {
fireDelta( (ICSignal)source, IModelDelta.REMOVED );
}
}
private void fireDelta( ICSignal signal, int flags ) {
ModelDelta root = new ModelDelta( fTarget, IModelDelta.NO_CHANGE );
root.addNode( signal, flags );
fireDelta( root );
}
@Override
public synchronized void dispose() {
super.dispose();
fTarget = null;
}
private boolean accept( ICSignal signal ) {
return fTarget.equals( signal.getDebugTarget() );
}
}

View file

@ -0,0 +1,75 @@
/*******************************************************************************
* Copyright (c) 2004, 2011 QNX Software 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:
* QNX Software Systems - Initial API and implementation
* Wind River Systems - flexible hierarchy Signals view (bug 338908)
*******************************************************************************/
package org.eclipse.cdt.debug.internal.ui.views.signals;
import java.util.Arrays;
import org.eclipse.cdt.debug.core.model.ICSignal;
import org.eclipse.cdt.debug.internal.ui.CDebugImages;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.internal.ui.model.elements.ElementLabelProvider;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.TreePath;
/**
* Label provider for <code>ICSignal</code>s.
*/
public class SignalLabelProvider extends ElementLabelProvider {
@Override
protected String getLabel(TreePath elementPath, IPresentationContext presentationContext, String columnId)
throws CoreException {
Object element = elementPath.getLastSegment();
String[] columns = presentationContext.getColumns();
int columnIdx = columns != null ? Arrays.asList(columns).indexOf(columnId) : 0;
String label = getColumnText(element, columnIdx);
return label != null ? label : ""; //$NON-NLS-1$
}
@Override
protected ImageDescriptor getImageDescriptor(TreePath elementPath, IPresentationContext presentationContext, String columnId)
throws CoreException {
Object element = elementPath.getLastSegment();
if (element instanceof ICSignal) {
String[] columns = presentationContext.getColumns();
int columnIdx = columns != null ? Arrays.asList(columns).indexOf(columnId) : 0;
if (columnIdx == 0) {
return CDebugImages.DESC_OBJS_SIGNAL;
}
}
return super.getImageDescriptor(elementPath, presentationContext, columnId);
}
private String getColumnText(Object element, int columnIndex) {
if (element instanceof ICSignal) {
try {
switch (columnIndex) {
case 0:
return ((ICSignal) element).getName();
case 1:
return (((ICSignal) element).isPassEnabled()) ? SignalsViewer.YES_VALUE
: SignalsViewer.NO_VALUE;
case 2:
return (((ICSignal) element).isStopEnabled()) ? SignalsViewer.YES_VALUE
: SignalsViewer.NO_VALUE;
case 3:
return ((ICSignal) element).getDescription();
}
} catch (DebugException e) {
}
}
return null;
}
}

View file

@ -0,0 +1,53 @@
/*******************************************************************************
* Copyright (c) 2004, 2011 QNX Software 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:
* QNX Software Systems - Initial API and implementation
* Wind River Systems - flexible hierarchy Signals view (bug 338908)
*******************************************************************************/
package org.eclipse.cdt.debug.internal.ui.views.signals;
import org.eclipse.cdt.debug.core.model.ICDebugTarget;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
import org.eclipse.cdt.debug.ui.ICDebugUIConstants;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.internal.ui.model.elements.ElementContentProvider;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate;
public class SignalsContentProvider extends ElementContentProvider {
@Override
protected int getChildCount( Object element, IPresentationContext context, IViewerUpdate monitor ) throws CoreException {
return getAllChildren( element, context ).length;
}
@Override
protected Object[] getChildren( Object parent, int index, int length, IPresentationContext context, IViewerUpdate monitor ) throws CoreException {
return getElements( getAllChildren( parent, context ), index, length );
}
@Override
protected boolean supportsContextId( String id ) {
return ICDebugUIConstants.ID_SIGNALS_VIEW.equals( id );
}
protected Object[] getAllChildren(Object parent, IPresentationContext context) throws CoreException {
if (parent instanceof ICDebugTarget) {
ICDebugTarget target = (ICDebugTarget) parent;
try {
Object[] signals = target.getSignals();
if (signals != null)
return signals;
} catch (DebugException e) {
CDebugUIPlugin.log(e);
}
}
return EMPTY;
}
}

View file

@ -0,0 +1,94 @@
/*******************************************************************************
* Copyright (c) 2010, 2011 CodeSourcery 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:
* CodeSourcery - Initial API and implementation
* Wind River Systems - flexible hierarchy Signals view (bug 338908)
*******************************************************************************/
package org.eclipse.cdt.debug.internal.ui.views.signals;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
import org.eclipse.debug.internal.ui.elements.adapters.VariableColumnPresentation;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IColumnPresentation;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
import org.eclipse.jface.resource.ImageDescriptor;
/**
* Signals view column presentation.
*/
public class SignalsViewColumnPresentation implements IColumnPresentation {
private static final String PREFIX = CDebugUIPlugin.PLUGIN_ID + "."; //$NON-NLS-1$
public static final String ID = PREFIX + "signalsViewColumnPresentationId"; //$NON-NLS-1$
private static final String COLUMN_ID_NAME = VariableColumnPresentation.COLUMN_VARIABLE_NAME;
private static final String COLUMN_ID_PASS = PREFIX + "signalsColumn.pass"; //$NON-NLS-1$
private static final String COLUMN_ID_STOP = PREFIX + "signalsColumn.stop"; //$NON-NLS-1$
private static final String COLUMN_ID_DESC = PREFIX + "signalsColumn.desc"; //$NON-NLS-1$
private static final String CL_NAME = SignalsMessages.getString( "SignalsViewer.4" ); //$NON-NLS-1$
private static final String CL_PASS = SignalsMessages.getString( "SignalsViewer.5" ); //$NON-NLS-1$
private static final String CL_SUSPEND = SignalsMessages.getString( "SignalsViewer.6" ); //$NON-NLS-1$
private static final String CL_DESCRIPTION = SignalsMessages.getString( "SignalsViewer.7" ); //$NON-NLS-1$
private static final String[] ALL_COLUMNS = new String[] {
COLUMN_ID_NAME,
COLUMN_ID_PASS,
COLUMN_ID_STOP,
COLUMN_ID_DESC
};
private static final String[] INITIAL_COLUMNS = new String[] {
COLUMN_ID_NAME,
COLUMN_ID_PASS,
COLUMN_ID_STOP,
COLUMN_ID_DESC
};
public void init( IPresentationContext context ) {
}
public void dispose() {
}
public String[] getAvailableColumns() {
return ALL_COLUMNS;
}
public String[] getInitialColumns() {
return INITIAL_COLUMNS;
}
public String getHeader( String id ) {
if ( COLUMN_ID_NAME.equals( id ) ) {
return CL_NAME;
}
if ( COLUMN_ID_PASS.equals( id ) ) {
return CL_PASS;
}
if ( COLUMN_ID_STOP.equals( id ) ) {
return CL_SUSPEND;
}
if ( COLUMN_ID_DESC.equals( id ) ) {
return CL_DESCRIPTION;
}
return null;
}
public ImageDescriptor getImageDescriptor( String id ) {
return null;
}
public String getId() {
return ID;
}
public boolean isOptional() {
return true;
}
}

View file

@ -0,0 +1,42 @@
/*******************************************************************************
* Copyright (c) 2004, 2011 QNX Software 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:
* QNX Software Systems - Initial API and implementation
* Wind River Systems - flexible hierarchy Signals view (bug 338908)
*******************************************************************************/
package org.eclipse.cdt.debug.internal.ui.views.signals;
import org.eclipse.debug.internal.ui.viewers.update.DebugEventHandler;
import org.eclipse.debug.internal.ui.viewers.update.EventHandlerModelProxy;
/**
* Default update for Signals view.
*/
public class SignalsViewModelProxy extends EventHandlerModelProxy {
private Object fTarget;
/**
* Constructor for SignalesViewModelProxy.
*/
public SignalsViewModelProxy( Object target ) {
super();
fTarget = target;
}
@Override
protected DebugEventHandler[] createEventHandlers() {
return new DebugEventHandler[] { new FlexibleSignalsViewEventHandler( this, fTarget ) };
}
@Override
public synchronized void dispose() {
super.dispose();
fTarget = null;
}
}