1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-09 18:56:02 +02:00

Column support for Modules view.

This commit is contained in:
Mikhail Khodjaiants 2007-10-03 14:46:31 +00:00
parent 5edb9af176
commit 2a1bb17d2a
6 changed files with 242 additions and 7 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 343 B

View file

@ -14,6 +14,7 @@ import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
import java.util.Iterator;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.resource.ImageDescriptor;
@ -103,6 +104,7 @@ public class CDebugImages {
public static final String IMG_OBJS_EXTERNAL_SOURCE_FILE = NAME_PREFIX + "ext_file_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_PATH_MAPPING = NAME_PREFIX + "mapping_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_PATH_MAP_ENTRY = NAME_PREFIX + "mapentry_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_COMMON_TAB = NAME_PREFIX + "common_tab.gif"; //$NON-NLS-1$
public static final String IMG_LCL_TYPE_NAMES = NAME_PREFIX + "tnames_co.gif"; //$NON-NLS-1$
public static final String IMG_LCL_CHANGE_REGISTER_VALUE = NAME_PREFIX + "change_reg_value_co.gif"; //$NON-NLS-1$
@ -182,7 +184,8 @@ public class CDebugImages {
public static final ImageDescriptor DESC_OBJS_WORKSPACE_SOURCE_FILE = createManaged( T_OBJ, IMG_OBJS_WORKSPACE_SOURCE_FILE );
public static final ImageDescriptor DESC_OBJS_EXTERNAL_SOURCE_FILE = createManaged( T_OBJ, IMG_OBJS_EXTERNAL_SOURCE_FILE );
public static final ImageDescriptor DESC_OBJS_PATH_MAPPING = createManaged( T_OBJ, IMG_OBJS_PATH_MAPPING );
public static final ImageDescriptor DESC_OBJS_PATH_MAP_ENTRY = createManaged( T_OBJ, IMG_OBJS_PATH_MAP_ENTRY );
public static final ImageDescriptor DESC_OBJS_PATH_MAP_ENTRY = createManaged( T_OBJ, IMG_OBJS_PATH_MAP_ENTRY );
public static final ImageDescriptor DESC_OBJS_COMMON_TAB = createManaged( T_OBJ, IMG_OBJS_COMMON_TAB );
public static final ImageDescriptor DESC_WIZBAN_ADD_SOURCE = createManaged( T_WIZBAN, IMG_WIZBAN_ADD_SOURCE );
public static final ImageDescriptor DESC_WIZBAN_PATH_MAPPING = createManaged( T_WIZBAN, IMG_WIZBAN_PATH_MAPPING );
public static final ImageDescriptor DESC_WIZBAN_PATH_MAP_ENTRY = createManaged( T_WIZBAN, IMG_WIZBAN_PATH_MAP_ENTRY );
@ -248,9 +251,9 @@ public class CDebugImages {
//---- Helper methods to access icons on the file system --------------------------------------
private static void setImageDescriptors( IAction action, String type, String relPath )
private static void setImageDescriptors( IAction action, String type, String path )
{
relPath = relPath.substring( NAME_PREFIX_LENGTH );
String relPath = path.substring( NAME_PREFIX_LENGTH );
try
{
ImageDescriptor id = ImageDescriptor.createFromURL( makeIconFileURL( "d" + type, relPath ) ); //$NON-NLS-1$

View file

@ -48,6 +48,8 @@ public interface ICDebugHelpContextIds {
public static final String ENABLE_DISABLE_BREAKPOINT_ACTION = PREFIX + "enable_disable_breakpoint_action_context"; //$NON-NLS-1$
public static final String BREAKPOINT_PROPERTIES_ACTION = PREFIX + "breakpoint_properties_action_context"; //$NON-NLS-1$
public static final String SHOW_DETAIL_PANE_ACTION = PREFIX + "show_detail_pane_action_context"; //$NON-NLS-1$
public static final String CONFIGURE_COLUMNS_ACTION = PREFIX + "configure_columns_context"; //$NON-NLS-1$;
public static final String SHOW_COLUMNS_ACTION = PREFIX + "show_columns_context"; //$NON-NLS-1$;
// Views & Editors
public static final String MEMORY_VIEW = PREFIX + "memory_view_context"; //$NON-NLS-1$
@ -64,12 +66,13 @@ public interface ICDebugHelpContextIds {
public static final String C_DEBUG_PREFERENCE_PAGE = PREFIX + "c_debug_preference_page_context"; //$NON-NLS-1$
public static final String DEBUGGER_TYPES_PAGE = PREFIX + "debugger_typpes_preference_page_context"; //$NON-NLS-1$
// dialogs
// Dialogs
public static final String SOURCE_PATH_MAPPING_DIALOG = PREFIX + "source_path_mapping_dialog_context"; //$NON-NLS-1$
public static final String SOURCE_PATH_MAP_ENTRY_DIALOG = PREFIX + "source_path_map_entry_dialog_context"; //$NON-NLS-1$
public static final String ADD_SOURCE_CONTAINER_DIALOG = PREFIX + "add_source_container_dialog"; //$NON-NLS-1$
public static final String ADD_DIRECTORY_CONTAINER_DIALOG = PREFIX + "add_directory_container_dialog"; //$NON-NLS-1$
public static final String REGISTER_GROUP = PREFIX + "register_group_dialog"; //$NON-NLS-1$
public static final String CONFIGURE_COLUMNS_DIALOG = PREFIX + "configure_columns_dialog_context"; //$NON-NLS-1$;
// Wizards
public static final String IMPORT_EXECUTABLE_PAGE_ONE = PREFIX + "import_executable_page_one"; //$NON-NLS-1$

View file

@ -0,0 +1,138 @@
/*******************************************************************************
* Copyright (c) 2006 IBM Corporation 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:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.debug.internal.ui.actions;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.eclipse.cdt.debug.internal.ui.ICDebugHelpContextIds;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IColumnPresentation;
import org.eclipse.debug.internal.ui.viewers.model.provisional.TreeModelViewer;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.window.Window;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.dialogs.ListSelectionDialog;
import org.eclipse.ui.texteditor.IUpdate;
/**
* Configures visible columns in an asynch tree viewer/
*
* @since 5.0
*/
public class ConfigureColumnsAction extends Action implements IUpdate {
private TreeModelViewer fViewer;
class ColumnContentProvider implements IStructuredContentProvider {
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
*/
public Object[] getElements( Object inputElement ) {
return ((IColumnPresentation)inputElement).getAvailableColumns();
}
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.IContentProvider#dispose()
*/
public void dispose() {
}
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
*/
public void inputChanged( Viewer viewer, Object oldInput, Object newInput ) {
}
}
class ColumnLabelProvider extends LabelProvider {
private Map fImages = new HashMap();
public Image getImage( Object element ) {
ImageDescriptor imageDescriptor = fViewer.getColumnPresentation().getImageDescriptor( (String)element );
if ( imageDescriptor != null ) {
Image image = (Image)fImages.get( imageDescriptor );
if ( image == null ) {
image = imageDescriptor.createImage();
fImages.put( imageDescriptor, image );
}
return image;
}
return null;
}
public String getText( Object element ) {
return fViewer.getColumnPresentation().getHeader( (String)element );
}
public void dispose() {
super.dispose();
Iterator iterator = fImages.values().iterator();
while( iterator.hasNext() ) {
Image image = (Image)iterator.next();
image.dispose();
}
fImages.clear();
}
}
public ConfigureColumnsAction( TreeModelViewer viewer ) {
setText( "Select &Columns..." );
setId( CDebugUIPlugin.getUniqueIdentifier() + ".ConfigureColumnsAction" ); //$NON-NLS-1$
PlatformUI.getWorkbench().getHelpSystem().setHelp( this, ICDebugHelpContextIds.CONFIGURE_COLUMNS_ACTION );
fViewer = viewer;
}
/* (non-Javadoc)
* @see org.eclipse.ui.texteditor.IUpdate#update()
*/
public void update() {
setEnabled( fViewer.isShowColumns() );
}
/* (non-Javadoc)
* @see org.eclipse.jface.action.Action#run()
*/
public void run() {
ListSelectionDialog dialog = new ListSelectionDialog( fViewer.getControl().getShell(), fViewer.getColumnPresentation(), new ColumnContentProvider(),
new ColumnLabelProvider(), "Select the &columns to display:" );
PlatformUI.getWorkbench().getHelpSystem().setHelp( this, ICDebugHelpContextIds.CONFIGURE_COLUMNS_DIALOG );
String[] visibleColumns = fViewer.getVisibleColumns();
List initialSelection = new ArrayList( visibleColumns.length );
for( int i = 0; i < visibleColumns.length; i++ ) {
initialSelection.add( visibleColumns[i] );
}
dialog.setTitle( "Select Columns" );
dialog.setInitialElementSelections( initialSelection );
if ( dialog.open() == Window.OK ) {
Object[] result = dialog.getResult();
if ( result.length == 0 ) {
fViewer.setShowColumns( false );
}
else {
String[] ids = new String[result.length];
System.arraycopy( result, 0, ids, 0, result.length );
fViewer.resetColumnSizes( ids );
fViewer.setVisibleColumns( ids );
}
}
}
}

View file

@ -0,0 +1,63 @@
/*******************************************************************************
* Copyright (c) 2000, 2006 IBM Corporation 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:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.debug.internal.ui.actions;
import org.eclipse.cdt.debug.internal.ui.CDebugImages;
import org.eclipse.cdt.debug.internal.ui.ICDebugHelpContextIds;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
import org.eclipse.debug.internal.ui.viewers.model.provisional.TreeModelViewer;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;
import org.eclipse.swt.custom.BusyIndicator;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.texteditor.IUpdate;
/**
* Action to toggle the use of contributed variables content providers on and off.
* When on, all registered variables content providers for the current debug model
* are used. When off, the default content provider (that shows all children)
* is used for all debug models.
*/
public class ToggleShowColumnsAction extends Action implements IUpdate {
private TreeModelViewer fViewer;
public ToggleShowColumnsAction( TreeModelViewer viewew ) {
super( "&Show Columns", IAction.AS_CHECK_BOX );
fViewer = viewew;
setToolTipText( "Show Columns" );
setImageDescriptor( CDebugImages.DESC_OBJS_COMMON_TAB );
setId( CDebugUIPlugin.getUniqueIdentifier() + ".ToggleShowColumsAction" ); //$NON-NLS-1$
PlatformUI.getWorkbench().getHelpSystem().setHelp( this, ICDebugHelpContextIds.SHOW_COLUMNS_ACTION );
}
/* (non-Javadoc)
* @see org.eclipse.jface.action.Action#run()
*/
public void run() {
if ( fViewer.getControl().isDisposed() ) {
return;
}
BusyIndicator.showWhile( fViewer.getControl().getDisplay(), new Runnable() {
public void run() {
fViewer.setShowColumns( isChecked() );
}
} );
}
/* (non-Javadoc)
* @see org.eclipse.ui.texteditor.IUpdate#update()
*/
public void update() {
setEnabled( fViewer.canToggleColumns() );
setChecked( fViewer.isShowColumns() );
}
}

View file

@ -23,7 +23,9 @@ import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.debug.core.model.ICModule;
import org.eclipse.cdt.debug.internal.ui.ICDebugHelpContextIds;
import org.eclipse.cdt.debug.internal.ui.IInternalCDebugUIConstants;
import org.eclipse.cdt.debug.internal.ui.actions.ConfigureColumnsAction;
import org.eclipse.cdt.debug.internal.ui.actions.ToggleDetailPaneAction;
import org.eclipse.cdt.debug.internal.ui.actions.ToggleShowColumnsAction;
import org.eclipse.cdt.debug.internal.ui.preferences.ICDebugPreferenceConstants;
import org.eclipse.cdt.debug.internal.ui.views.IDebugExceptionHandler;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
@ -184,6 +186,7 @@ public class ModulesView extends AbstractDebugView implements IDebugContextListe
private int[] fLastSashWeights;
private boolean fToggledDetailOnce;
private ToggleDetailPaneAction[] fToggleDetailPaneActions;
protected ConfigureColumnsAction fConfigureColumnsAction;
private String fCurrentDetailPaneOrientation = ICDebugPreferenceConstants.MODULES_DETAIL_PANE_HIDDEN;
protected static final String SASH_WEIGHTS = CDebugUIPlugin.getUniqueIdentifier() + ".modulesView.SASH_WEIGHTS"; //$NON-NLS-1$
@ -209,7 +212,7 @@ public class ModulesView extends AbstractDebugView implements IDebugContextListe
createDetailsViewer();
getSashForm().setMaximizedControl( viewer.getControl() );
createOrientationActions();
createOrientationActions( viewer );
IPreferenceStore prefStore = CDebugUIPlugin.getDefault().getPreferenceStore();
String orientation = prefStore.getString( getDetailPanePreferenceKey() );
for( int i = 0; i < fToggleDetailPaneActions.length; i++ ) {
@ -595,9 +598,9 @@ public class ModulesView extends AbstractDebugView implements IDebugContextListe
fLastSashWeights = weights;
}
private void createOrientationActions() {
private void createOrientationActions( TreeModelViewer viewer ) {
IActionBars actionBars = getViewSite().getActionBars();
IMenuManager viewMenu = actionBars.getMenuManager();
final IMenuManager viewMenu = actionBars.getMenuManager();
fToggleDetailPaneActions = new ToggleDetailPaneAction[3];
fToggleDetailPaneActions[0] = new ToggleDetailPaneAction( this, ICDebugPreferenceConstants.MODULES_DETAIL_PANE_UNDERNEATH, null );
fToggleDetailPaneActions[1] = new ToggleDetailPaneAction( this, ICDebugPreferenceConstants.MODULES_DETAIL_PANE_RIGHT, null );
@ -607,6 +610,31 @@ public class ModulesView extends AbstractDebugView implements IDebugContextListe
viewMenu.add( fToggleDetailPaneActions[1] );
viewMenu.add( fToggleDetailPaneActions[2] );
viewMenu.add( new Separator() );
fConfigureColumnsAction = new ConfigureColumnsAction( viewer );
setAction( "ToggleColumns", new ToggleShowColumnsAction( viewer ) ); //$NON-NLS-1$
viewMenu.addMenuListener( new IMenuListener() {
public void menuAboutToShow( IMenuManager manager ) {
IAction action = getAction( "ToggleColumns" ); //$NON-NLS-1$
((IUpdate)action).update();
if ( action.isEnabled() ) {
if ( viewMenu.find( action.getId() ) == null )
viewMenu.add( action );
}
else {
viewMenu.remove( action.getId() );
}
fConfigureColumnsAction.update();
if ( fConfigureColumnsAction.isEnabled() ) {
if ( viewMenu.find( fConfigureColumnsAction.getId() ) == null )
viewMenu.add( fConfigureColumnsAction );
}
else {
viewMenu.remove( fConfigureColumnsAction.getId() );
}
}
} );
}
protected String getToggleActionLabel() {