mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-20 07:25:23 +02:00
Bug 173792: Modules view needs to catch up with 3.3M5. Added ModuleLabelProvider.
This commit is contained in:
parent
a1966c4e46
commit
603cc6b75b
5 changed files with 144 additions and 1 deletions
|
@ -1260,5 +1260,11 @@
|
|||
id="org.eclipse.cdt.debug.internal.ui.sourcelookup.CSourceNotFoundEditor">
|
||||
</editor>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.ui.startup">
|
||||
<startup
|
||||
class="org.eclipse.cdt.debug.internal.ui.Startup">
|
||||
</startup>
|
||||
</extension>
|
||||
|
||||
</plugin>
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 ARM 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:
|
||||
* ARM - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.debug.internal.ui;
|
||||
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
import org.eclipse.ui.IStartup;
|
||||
|
||||
/**
|
||||
* Forces the org.eclipse.cdt.debug.ui plugin to be loaded. The Modules view requires
|
||||
* CElementAdapterFactory to be registered to display the labels and images of ICElement's.
|
||||
*/
|
||||
public class Startup implements IStartup {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.IStartup#earlyStartup()
|
||||
*/
|
||||
public void earlyStartup() {
|
||||
CUIPlugin.getDefault();
|
||||
}
|
||||
}
|
|
@ -14,9 +14,11 @@ import org.eclipse.cdt.core.model.ICElement;
|
|||
import org.eclipse.cdt.debug.core.model.ICModule;
|
||||
import org.eclipse.cdt.debug.core.model.IModuleRetrieval;
|
||||
import org.eclipse.cdt.debug.internal.ui.views.modules.ModuleContentProvider;
|
||||
import org.eclipse.cdt.debug.internal.ui.views.modules.ModuleLabelProvider;
|
||||
import org.eclipse.cdt.debug.internal.ui.views.modules.ModuleProxyFactory;
|
||||
import org.eclipse.core.runtime.IAdapterFactory;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementContentProvider;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementLabelProvider;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelProxyFactoryAdapter;
|
||||
|
||||
/**
|
||||
|
@ -24,6 +26,7 @@ import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelProxyFactor
|
|||
*/
|
||||
public class CDebugElementAdapterFactory implements IAdapterFactory {
|
||||
|
||||
private static IElementLabelProvider fgModuleLabelProvider = new ModuleLabelProvider();
|
||||
private static IElementContentProvider fgModuleContentProvider = new ModuleContentProvider();
|
||||
private static IModelProxyFactoryAdapter fgModuleProxyFactory = new ModuleProxyFactory();
|
||||
|
||||
|
@ -35,6 +38,14 @@ public class CDebugElementAdapterFactory implements IAdapterFactory {
|
|||
if ( adapterType.isInstance( adaptableObject ) ) {
|
||||
return adaptableObject;
|
||||
}
|
||||
if ( adapterType.equals( IElementLabelProvider.class ) ) {
|
||||
if ( adaptableObject instanceof ICModule ) {
|
||||
return fgModuleLabelProvider;
|
||||
}
|
||||
if ( adaptableObject instanceof ICElement ) {
|
||||
return fgModuleLabelProvider;
|
||||
}
|
||||
}
|
||||
if ( adapterType.equals( IElementContentProvider.class ) ) {
|
||||
if ( adaptableObject instanceof IModuleRetrieval ) {
|
||||
return fgModuleContentProvider;
|
||||
|
@ -59,6 +70,7 @@ public class CDebugElementAdapterFactory implements IAdapterFactory {
|
|||
*/
|
||||
public Class[] getAdapterList() {
|
||||
return new Class[] {
|
||||
IElementLabelProvider.class,
|
||||
IElementContentProvider.class,
|
||||
IModelProxyFactoryAdapter.class
|
||||
};
|
||||
|
|
|
@ -0,0 +1,82 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 ARM 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:
|
||||
* ARM - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.debug.internal.ui.views.modules;
|
||||
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.debug.core.model.ICModule;
|
||||
import org.eclipse.cdt.debug.internal.ui.CDebugImages;
|
||||
import org.eclipse.cdt.debug.internal.ui.views.modules.ModulesView.ModulesViewPresentationContext;
|
||||
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
|
||||
import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider;
|
||||
import org.eclipse.cdt.ui.CElementLabelProvider;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IAdaptable;
|
||||
import org.eclipse.debug.internal.ui.model.elements.ElementLabelProvider;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
|
||||
import org.eclipse.debug.internal.ui.views.launch.ImageImageDescriptor;
|
||||
import org.eclipse.debug.ui.IDebugModelPresentation;
|
||||
import org.eclipse.jface.resource.ImageDescriptor;
|
||||
import org.eclipse.jface.viewers.ILabelProvider;
|
||||
import org.eclipse.jface.viewers.TreePath;
|
||||
import org.eclipse.swt.graphics.Image;
|
||||
import org.eclipse.ui.model.IWorkbenchAdapter;
|
||||
|
||||
/**
|
||||
* org.eclipse.cdt.debug.internal.ui.views.modules.CElementLabelProvider:
|
||||
* //TODO Add description.
|
||||
*/
|
||||
public class ModuleLabelProvider extends ElementLabelProvider {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.internal.ui.model.elements.ElementLabelProvider#getLabel(org.eclipse.jface.viewers.TreePath, org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext, java.lang.String)
|
||||
*/
|
||||
protected String getLabel( TreePath elementPath, IPresentationContext presentationContext, String columnId ) throws CoreException {
|
||||
Object element = elementPath.getLastSegment();
|
||||
if ( element instanceof ICModule && presentationContext instanceof ModulesViewPresentationContext ) {
|
||||
IDebugModelPresentation presentation = ((ModulesViewPresentationContext)presentationContext).getModelPresentation();
|
||||
return presentation.getText( element );
|
||||
}
|
||||
if ( element instanceof IAdaptable ) {
|
||||
IWorkbenchAdapter adapter = (IWorkbenchAdapter)(((IAdaptable)element).getAdapter( IWorkbenchAdapter.class ));
|
||||
if ( adapter != null )
|
||||
return adapter.getLabel( element );
|
||||
}
|
||||
return ""; //$NON-NLS-1$
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.internal.ui.model.elements.ElementLabelProvider#getImageDescriptor(org.eclipse.jface.viewers.TreePath, org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext, java.lang.String)
|
||||
*/
|
||||
protected ImageDescriptor getImageDescriptor( TreePath elementPath, IPresentationContext presentationContext, String columnId ) throws CoreException {
|
||||
Object element = elementPath.getLastSegment();
|
||||
if ( element instanceof ICModule ) {
|
||||
ICModule module = (ICModule)element;
|
||||
switch( module.getType() ) {
|
||||
case ICModule.EXECUTABLE:
|
||||
if ( module.areSymbolsLoaded() ) {
|
||||
return CDebugImages.DESC_OBJS_EXECUTABLE_WITH_SYMBOLS;
|
||||
}
|
||||
return CDebugImages.DESC_OBJS_EXECUTABLE;
|
||||
case ICModule.SHARED_LIBRARY:
|
||||
if ( module.areSymbolsLoaded() ) {
|
||||
return CDebugImages.DESC_OBJS_SHARED_LIBRARY_WITH_SYMBOLS;
|
||||
}
|
||||
return CDebugImages.DESC_OBJS_SHARED_LIBRARY;
|
||||
}
|
||||
}
|
||||
if ( element instanceof ICElement ) {
|
||||
IWorkbenchAdapter adapter = (IWorkbenchAdapter)(((IAdaptable)element).getAdapter( IWorkbenchAdapter.class ));
|
||||
if ( adapter != null )
|
||||
return adapter.getImageDescriptor( element );
|
||||
}
|
||||
return super.getImageDescriptor( elementPath, presentationContext, columnId );
|
||||
}
|
||||
}
|
|
@ -40,6 +40,7 @@ import org.eclipse.debug.internal.ui.viewers.model.provisional.PresentationConte
|
|||
import org.eclipse.debug.internal.ui.viewers.model.provisional.TreeModelViewer;
|
||||
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;
|
||||
|
@ -102,6 +103,20 @@ import org.eclipse.ui.texteditor.IWorkbenchActionDefinitionIds;
|
|||
*/
|
||||
public class ModulesView extends AbstractDebugView implements IDebugContextListener, IDebugExceptionHandler, IPropertyChangeListener, IPerspectiveListener, IModelChangedListener, IViewerUpdateListener {
|
||||
|
||||
public class ModulesViewPresentationContext extends PresentationContext {
|
||||
|
||||
private IDebugModelPresentation fModelPresentation;
|
||||
|
||||
public ModulesViewPresentationContext( IDebugModelPresentation modelPresentation ) {
|
||||
super( ICDebugUIConstants.ID_MODULES_VIEW );
|
||||
fModelPresentation = modelPresentation;
|
||||
}
|
||||
|
||||
public IDebugModelPresentation getModelPresentation() {
|
||||
return fModelPresentation;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal interface for a cursor listener. I.e. aggregation
|
||||
* of mouse and key listener.
|
||||
|
@ -881,7 +896,7 @@ public class ModulesView extends AbstractDebugView implements IDebugContextListe
|
|||
}
|
||||
|
||||
private IPresentationContext getPresentationContext() {
|
||||
return new PresentationContext( ICDebugUIConstants.ID_MODULES_VIEW );
|
||||
return new ModulesViewPresentationContext( CDebugUIPlugin.getDebugModelPresentation() );
|
||||
}
|
||||
|
||||
private void clearDetails() {
|
||||
|
|
Loading…
Add table
Reference in a new issue