From 226ace7ccc7bc8d749f01d998a17737e385b5a4f Mon Sep 17 00:00:00 2001 From: Mikhail Khodjaiants Date: Thu, 17 Feb 2005 00:09:09 +0000 Subject: [PATCH] Bug 82264: Enhance the Shared Libraries view. Replaced the table viewer by text widgets. --- debug/org.eclipse.cdt.debug.ui/ChangeLog | 6 + .../ui/propertypages/ModulePropertyPage.java | 374 +++++++----------- .../PropertyPageMessages.properties | 14 +- 3 files changed, 157 insertions(+), 237 deletions(-) diff --git a/debug/org.eclipse.cdt.debug.ui/ChangeLog b/debug/org.eclipse.cdt.debug.ui/ChangeLog index 22f33602bb0..8134b3221eb 100644 --- a/debug/org.eclipse.cdt.debug.ui/ChangeLog +++ b/debug/org.eclipse.cdt.debug.ui/ChangeLog @@ -1,3 +1,9 @@ +2005-02-16 Mikhail Khodjaiants + Bug 82264: Enhance the Shared Libraries view. + Replaced the table viewer by text widgets. + * PropertyPageMessages.properties + * ModulePropertyPage.java + 2005-02-16 Mikhail Khodjaiants Bug 82264: Enhance the Shared Libraries view. The symbols file name isn't shown in the detail pane if module's diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/propertypages/ModulePropertyPage.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/propertypages/ModulePropertyPage.java index d4d4e4c0607..3461e8d4667 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/propertypages/ModulePropertyPage.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/propertypages/ModulePropertyPage.java @@ -15,7 +15,6 @@ import org.eclipse.cdt.debug.core.CDIDebugModel; import org.eclipse.cdt.debug.core.CDebugUtils; import org.eclipse.cdt.debug.core.model.ICModule; import org.eclipse.cdt.debug.internal.core.ICDebugInternalConstants; -import org.eclipse.cdt.debug.internal.ui.PixelConverter; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.MultiStatus; @@ -23,25 +22,18 @@ import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Status; import org.eclipse.debug.core.DebugException; import org.eclipse.debug.core.DebugPlugin; -import org.eclipse.jface.viewers.CellEditor; -import org.eclipse.jface.viewers.DialogCellEditor; -import org.eclipse.jface.viewers.ICellModifier; -import org.eclipse.jface.viewers.IStructuredContentProvider; -import org.eclipse.jface.viewers.ITableLabelProvider; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jface.viewers.Viewer; import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.graphics.Image; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.FileDialog; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableColumn; -import org.eclipse.swt.widgets.TableItem; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Text; import org.eclipse.ui.dialogs.PropertyPage; /** @@ -49,130 +41,16 @@ import org.eclipse.ui.dialogs.PropertyPage; */ public class ModulePropertyPage extends PropertyPage { - public class ModulePropertyLabelProvider extends LabelProvider implements ITableLabelProvider { - - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int) - */ - public Image getColumnImage( Object element, int columnIndex ) { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int) - */ - public String getColumnText( Object element, int columnIndex ) { - if ( element instanceof ModuleProperties.Property ) { - ModuleProperties.Property property = (ModuleProperties.Property)element; - if ( ModuleProperties.TYPE.equals( property.getKey() ) ) { - if ( columnIndex == 0 ) { - return PropertyPageMessages.getString( "ModulePropertyPage.0" ); //$NON-NLS-1$ - } - Integer type = (Integer)property.getValue(); - if ( type.intValue() == ICModule.EXECUTABLE ) { - return PropertyPageMessages.getString( "ModulePropertyPage.1" ); //$NON-NLS-1$ - } - if ( type.intValue() == ICModule.SHARED_LIBRARY ) { - return PropertyPageMessages.getString( "ModulePropertyPage.2" ); //$NON-NLS-1$ - } - if ( type.intValue() == ICModule.CORE ) { - return PropertyPageMessages.getString( "ModulePropertyPage.3" ); //$NON-NLS-1$ - } - } - else if ( ModuleProperties.CPU.equals( property.getKey() ) ) { - if ( columnIndex == 0 ) { - return PropertyPageMessages.getString( "ModulePropertyPage.4" ); //$NON-NLS-1$ - } - String cpu = (String)property.getValue(); - return ( cpu != null ) ? cpu : PropertyPageMessages.getString( "ModulePropertyPage.5" ); //$NON-NLS-1$ - } - else if ( ModuleProperties.BASE_ADDRESS.equals( property.getKey() ) ) { - if ( columnIndex == 0 ) { - return PropertyPageMessages.getString( "ModulePropertyPage.6" ); //$NON-NLS-1$ - } - IAddress address = (IAddress)property.getValue(); - return ( address != null && !address.isZero() ) ? address.toHexAddressString() : PropertyPageMessages.getString( "ModulePropertyPage.7" ); //$NON-NLS-1$ - } - else if ( ModuleProperties.SIZE.equals( property.getKey() ) ) { - if ( columnIndex == 0 ) { - return PropertyPageMessages.getString( "ModulePropertyPage.8" ); //$NON-NLS-1$ - } - Long size = (Long)property.getValue(); - return ( size != null && size.longValue() > 0 ) ? size.toString() : PropertyPageMessages.getString( "ModulePropertyPage.9" ); //$NON-NLS-1$ - } - else if ( ModuleProperties.SYMBOLS_LOADED.equals( property.getKey() ) ) { - if ( columnIndex == 0 ) { - return PropertyPageMessages.getString( "ModulePropertyPage.10" ); //$NON-NLS-1$ - } - Boolean loaded = (Boolean)property.getValue(); - return ( loaded != null && loaded.booleanValue() ) ? PropertyPageMessages.getString( "ModulePropertyPage.11" ) : PropertyPageMessages.getString( "ModulePropertyPage.12" ); //$NON-NLS-1$ //$NON-NLS-2$ - } - else if ( ModuleProperties.SYMBOLS_FILE.equals( property.getKey() ) ) { - if ( columnIndex == 0 ) { - return PropertyPageMessages.getString( "ModulePropertyPage.13" ); //$NON-NLS-1$ - } - IPath path = (IPath)property.getValue(); - return ( path != null ) ? path.toOSString() : PropertyPageMessages.getString( "ModulePropertyPage.14" ); //$NON-NLS-1$ - } - } - return null; - } - } - - public class ModulePropertyContentProvider implements IStructuredContentProvider { - - /** - * Constructor for ModulePropertyContentProvider. - */ - public ModulePropertyContentProvider() { - super(); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object) - */ - public Object[] getElements( Object inputElement ) { - if ( inputElement instanceof ICModule ) { - if ( getModuleProperties() == null ) { - setModuleProperties( ModuleProperties.create( (ICModule)inputElement ) ); - } - return getModuleProperties().getProperties(); - } - return new Object[0]; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.IContentProvider#dispose() - */ - public void dispose() { - disposeProperties(); - } - - /* (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 ) { - if ( oldInput != null && oldInput.equals( newInput ) ) - return; - disposeProperties(); - } - - private void disposeProperties() { - if ( getModuleProperties() != null ) { - getModuleProperties().dispose(); - setModuleProperties( null ); - } - } - } + private Label fTypeField; + private Label fCPUField; + private Label fBaseAddressField; + private Label fSizeField; + private Label fSymbolsField; + protected Text fSymbolsFileField; + protected Button fBrowseButton; private ModuleProperties fProperties = null; - private TableViewer fViewer; - - // Column properties - private static final String CP_NAME = "name"; //$NON-NLS-1$ - private static final String CP_VALUE = "value"; //$NON-NLS-1$ - /* (non-Javadoc) * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite) */ @@ -181,31 +59,13 @@ public class ModulePropertyPage extends PropertyPage { Composite composite = new Composite( parent, SWT.NONE ); Font font = parent.getFont(); composite.setFont( font ); - composite.setLayout( new GridLayout() ); + GridLayout topLayout = new GridLayout(); + topLayout.numColumns = 2; + composite.setLayout( topLayout ); composite.setLayoutData( new GridData( GridData.FILL_BOTH ) ); - fViewer = new TableViewer( composite, SWT.BORDER ); - Table table = fViewer.getTable(); - table.setLinesVisible( true ); - table.setHeaderVisible( true ); - table.setLayoutData( new GridData( GridData.FILL_BOTH ) ); - - // Create the table columns - new TableColumn( table, SWT.NULL ); - new TableColumn( table, SWT.NULL ); - TableColumn[] columns = table.getColumns(); - columns[0].setResizable( true ); - columns[1].setResizable( true ); - - PixelConverter pc = new PixelConverter( parent ); - columns[0].setWidth( pc.convertWidthInCharsToPixels( 15 ) ); - columns[1].setWidth( pc.convertWidthInCharsToPixels( 40 ) ); - - fViewer.setColumnProperties( new String[]{ CP_NAME, CP_VALUE } ); - fViewer.setCellEditors( new CellEditor[]{ null, createSymbolsFileCellEditor( table ) } ); - fViewer.setCellModifier( createCellModifier() ); - - fViewer.setContentProvider( createContentProvider() ); - fViewer.setLabelProvider( createLabelProvider() ); + + createFields( composite ); + initializeFields(); setValid( true ); return composite; @@ -215,22 +75,6 @@ public class ModulePropertyPage extends PropertyPage { return (ICModule)getElement(); } - private ModulePropertyContentProvider createContentProvider() { - return new ModulePropertyContentProvider(); - } - - private ModulePropertyLabelProvider createLabelProvider() { - return new ModulePropertyLabelProvider(); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) - */ - public void createControl( Composite parent ) { - super.createControl( parent ); - getViewer().setInput( getElement() ); - } - /* (non-Javadoc) * @see org.eclipse.jface.preference.IPreferencePage#performOk() */ @@ -256,70 +100,138 @@ public class ModulePropertyPage extends PropertyPage { return super.performOk(); } - protected TableViewer getViewer() { - return fViewer; - } - - private ICellModifier createCellModifier() { - return new ICellModifier() { - - public boolean canModify( Object element, String property ) { - return ( element instanceof ModuleProperties.Property && - ModuleProperties.SYMBOLS_FILE.equals( ((ModuleProperties.Property)element).getKey() ) && - CP_VALUE.equals( property ) && - getModule().canModifySymbolsSource() ); - } - - public void modify( Object element, String property, Object value ) { - ModuleProperties.Property mp = (ModuleProperties.Property)((TableItem)element).getData(); - if ( ModuleProperties.SYMBOLS_FILE.equals( mp.getKey() ) && - CP_VALUE.equals( property ) && - getModule().canModifySymbolsSource() && - value instanceof IPath ) { - getModuleProperties().setProperty( mp.getKey(), value ); - if ( getModuleProperties().isDirty() ) { - getViewer().refresh(); - } - } - } - - public Object getValue( Object element, String property ) { - if ( element instanceof ModuleProperties.Property && - ModuleProperties.SYMBOLS_FILE.equals( ((ModuleProperties.Property)element).getKey() ) && - CP_VALUE.equals( property ) && - getModule().canModifySymbolsSource() ) { - return ((ModuleProperties.Property)element).getValue(); - } - return null; - } - }; - } - - private CellEditor createSymbolsFileCellEditor( Table table ) { - - return new DialogCellEditor( table ) { - - protected Object openDialogBox( Control cellEditorWindow ) { - FileDialog dialog = new FileDialog( cellEditorWindow.getShell() ); - dialog.setFileName( ((IPath)getModuleProperties().getProperty( ModuleProperties.SYMBOLS_FILE )).toOSString() ); - String fn = dialog.open(); - return ( fn != null ) ? new Path( dialog.getFilterPath() ).append( dialog.getFileName() ) : getModule().getSymbolsFileName(); - } - - }; - } - protected ModuleProperties getModuleProperties() { + if ( fProperties == null ) { + fProperties = ModuleProperties.create( getModule() ); + } return fProperties; } - protected void setModuleProperties( ModuleProperties properties ) { - fProperties = properties; - } - protected void failed( String message, Throwable e ) { MultiStatus ms = new MultiStatus( CDIDebugModel.getPluginIdentifier(), ICDebugInternalConstants.STATUS_CODE_ERROR, message, null ); ms.add( new Status( IStatus.ERROR, CDIDebugModel.getPluginIdentifier(), ICDebugInternalConstants.STATUS_CODE_ERROR, e.getMessage(), null ) ); CDebugUtils.error( ms, getModule() ); } + + private void createFields( Composite parent ) { + fTypeField = createField( parent, PropertyPageMessages.getString( "ModulePropertyPage.0" ) ); //$NON-NLS-1$ + fCPUField = createField( parent, PropertyPageMessages.getString( "ModulePropertyPage.4" ) ); //$NON-NLS-1$ + fBaseAddressField = createField( parent, PropertyPageMessages.getString( "ModulePropertyPage.6" ) ); //$NON-NLS-1$ + fSizeField = createField( parent, PropertyPageMessages.getString( "ModulePropertyPage.8" ) ); //$NON-NLS-1$ + fSymbolsField = createField( parent, PropertyPageMessages.getString( "ModulePropertyPage.10" ) ); //$NON-NLS-1$ + createSymbolsFileField( parent ); + } + + private Label createField( Composite parent, String label ) { + Font font = parent.getFont(); + Label l = new Label( parent, SWT.LEFT ); + l.setText( label ); + GridData gd = new GridData( GridData.HORIZONTAL_ALIGN_FILL ); + l.setLayoutData( gd ); + l.setFont( font ); + Label v = new Label( parent, SWT.LEFT ); + gd = new GridData( GridData.HORIZONTAL_ALIGN_FILL ); + v.setLayoutData( gd ); + v.setFont( font ); + return v; + } + + private void createSymbolsFileField( Composite parent ) { + Font font = parent.getFont(); + + // Separator + Label l = new Label( parent, SWT.LEFT ); + GridData gd = new GridData( GridData.FILL_HORIZONTAL ); + gd.horizontalSpan = 2; + l.setLayoutData( gd ); + + l = new Label( parent, SWT.LEFT ); + l.setText( PropertyPageMessages.getString( "ModulePropertyPage.13" ) ); //$NON-NLS-1$ + gd = new GridData( GridData.FILL_HORIZONTAL ); + gd.horizontalSpan = 2; + l.setLayoutData( gd ); + l.setFont( font ); + Composite composite = new Composite( parent, SWT.NONE ); + composite.setFont( font ); + GridLayout layout = new GridLayout(); + layout.numColumns = 5; + composite.setLayout( layout ); + gd = new GridData( GridData.FILL_BOTH ); + gd.horizontalSpan = 2; + composite.setLayoutData( gd ); + + // Text + fSymbolsFileField = new Text( composite, SWT.SINGLE | SWT.BORDER ); + gd = new GridData( GridData.FILL_HORIZONTAL ); + gd.horizontalSpan = 4; + fSymbolsFileField.setLayoutData( gd ); + + fBrowseButton = new Button( composite, SWT.PUSH ); + fBrowseButton.setText( PropertyPageMessages.getString( "ModulePropertyPage.3" ) ); //$NON-NLS-1$ + fBrowseButton.addSelectionListener( + new SelectionListener() { + + public void widgetSelected( SelectionEvent e ) { + FileDialog dialog = new FileDialog( fBrowseButton.getShell() ); + dialog.setFileName( ((IPath)getModuleProperties().getProperty( ModuleProperties.SYMBOLS_FILE )).toOSString() ); + String fn = dialog.open(); + if ( fn != null ) { + IPath path = new Path( fn ); + fSymbolsFileField.setText( path.toOSString() ); + getModuleProperties().setProperty( ModuleProperties.SYMBOLS_FILE, path ); + } + } + + public void widgetDefaultSelected( SelectionEvent e ) { + } + } ); + } + + private void initializeFields() { + // Type + Integer type = (Integer)getModuleProperties().getProperty( ModuleProperties.TYPE ); + String value = PropertyPageMessages.getString( "ModulePropertyPage.16" ); //$NON-NLS-1$ + if ( type.intValue() == ICModule.EXECUTABLE ) { + value = PropertyPageMessages.getString( "ModulePropertyPage.1" ); //$NON-NLS-1$ + } + if ( type.intValue() == ICModule.SHARED_LIBRARY ) { + value = PropertyPageMessages.getString( "ModulePropertyPage.2" ); //$NON-NLS-1$ + } + fTypeField.setText( value ); + + // CPU + String cpu = (String)getModuleProperties().getProperty( ModuleProperties.CPU ); + value = ( cpu != null ) ? cpu : PropertyPageMessages.getString( "ModulePropertyPage.5" ); //$NON-NLS-1$ + fCPUField.setText( value ); + + // Base address + IAddress address = (IAddress)getModuleProperties().getProperty( ModuleProperties.BASE_ADDRESS ); + value = ( address != null && !address.isZero() ) ? address.toHexAddressString() : PropertyPageMessages.getString( "ModulePropertyPage.7" ); //$NON-NLS-1$ + fBaseAddressField.setText( value ); + + // Size + Long size = (Long)getModuleProperties().getProperty( ModuleProperties.SIZE ); + value = ( size != null && size.longValue() > 0 ) ? size.toString() : PropertyPageMessages.getString( "ModulePropertyPage.9" ); //$NON-NLS-1$ + fSizeField.setText( value ); + + // Symbols flag + Boolean loaded = (Boolean)getModuleProperties().getProperty( ModuleProperties.SYMBOLS_LOADED ); + value = ( loaded != null && loaded.booleanValue() ) ? PropertyPageMessages.getString( "ModulePropertyPage.11" ) : PropertyPageMessages.getString( "ModulePropertyPage.12" ); //$NON-NLS-1$ //$NON-NLS-2$ + fSymbolsField.setText( value ); + + // Symbols file: + IPath path = (IPath)getModuleProperties().getProperty( ModuleProperties.SYMBOLS_FILE ); + value = ( path != null ) ? path.toOSString() : PropertyPageMessages.getString( "ModulePropertyPage.14" ); //$NON-NLS-1$ + fSymbolsFileField.setText( value ); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.IDialogPage#dispose() + */ + public void dispose() { + if ( getModuleProperties() != null ) { + getModuleProperties().dispose(); + } + super.dispose(); + } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/propertypages/PropertyPageMessages.properties b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/propertypages/PropertyPageMessages.properties index 0990db5fe26..32de621a5de 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/propertypages/PropertyPageMessages.properties +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/propertypages/PropertyPageMessages.properties @@ -36,21 +36,23 @@ SignalPropertyPage.2=Suspend the program when this signal happens. SignalPropertyPage.3=Error SignalPropertyPage.4=Operation failed. SignalPropertyPage.5=Unable to change signal properties. -ModulePropertyPage.0=Type +ModulePropertyPage.0=Type: ModulePropertyPage.1=executable ModulePropertyPage.2=shared library ModulePropertyPage.3=core file -ModulePropertyPage.4=CPU +ModulePropertyPage.3=Browse... +ModulePropertyPage.4=CPU: ModulePropertyPage.5=not available -ModulePropertyPage.6=Base address +ModulePropertyPage.6=Base address: ModulePropertyPage.7=not available -ModulePropertyPage.8=Size +ModulePropertyPage.8=Size: ModulePropertyPage.9=not available -ModulePropertyPage.10=Symbols +ModulePropertyPage.10=Symbols: ModulePropertyPage.11=loaded ModulePropertyPage.12=not loaded -ModulePropertyPage.13=Symbols file +ModulePropertyPage.13=Symbols file: ModulePropertyPage.14=not found ModulePropertyPage.15=Error ModulePropertyPage.15=Unable to load symbols. ModulePropertyPage.16=Unable to load symbols. +ModulePropertyPage.16=not available