mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-23 17:05:26 +02:00
Bug 82264: Enhance the Shared Libraries view. Implementing module's properties.
This commit is contained in:
parent
31ac25cbd5
commit
ff7b845bec
4 changed files with 181 additions and 22 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
2005-02-14 Mikhail Khodjaiants
|
||||||
|
Bug 82264: Enhance the Shared Libraries view.
|
||||||
|
Implementing module's properties.
|
||||||
|
* PropertyPageMessages.properties
|
||||||
|
* ModuleProperties.java (former ModuleProperties.java)
|
||||||
|
* ModulePropertyPage.java
|
||||||
|
|
||||||
2005-02-14 Mikhail Khodjaiants
|
2005-02-14 Mikhail Khodjaiants
|
||||||
Bug 82264: Enhance the Shared Libraries view.
|
Bug 82264: Enhance the Shared Libraries view.
|
||||||
Implementing module's properties.
|
Implementing module's properties.
|
||||||
|
|
|
@ -11,12 +11,13 @@
|
||||||
package org.eclipse.cdt.debug.internal.ui.propertypages;
|
package org.eclipse.cdt.debug.internal.ui.propertypages;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
import org.eclipse.cdt.debug.core.model.ICModule;
|
import org.eclipse.cdt.debug.core.model.ICModule;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A module's properties store.
|
* A module's properties store.
|
||||||
*/
|
*/
|
||||||
public class CModuleProperties {
|
public class ModuleProperties {
|
||||||
|
|
||||||
final static public String TYPE = "type"; //$NON-NLS-1$
|
final static public String TYPE = "type"; //$NON-NLS-1$
|
||||||
final static public String CPU = "cpu"; //$NON-NLS-1$
|
final static public String CPU = "cpu"; //$NON-NLS-1$
|
||||||
|
@ -45,18 +46,31 @@ public class CModuleProperties {
|
||||||
public Object getValue() {
|
public Object getValue() {
|
||||||
return fValue;
|
return fValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
String result = ""; //$NON-NLS-1$
|
||||||
|
if ( getKey() != null )
|
||||||
|
result += getKey();
|
||||||
|
if ( getValue() != null ) {
|
||||||
|
result += "="; //$NON-NLS-1$
|
||||||
|
result += getValue().toString();
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private ArrayList fProperties;
|
private ArrayList fProperties;
|
||||||
|
|
||||||
static CModuleProperties create( ICModule module ) {
|
private boolean fIsDirty = false;
|
||||||
return new CModuleProperties( module );
|
|
||||||
|
static ModuleProperties create( ICModule module ) {
|
||||||
|
return new ModuleProperties( module );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for CModuleProperties.
|
* Constructor for ModuleProperties.
|
||||||
*/
|
*/
|
||||||
private CModuleProperties( ICModule module ) {
|
private ModuleProperties( ICModule module ) {
|
||||||
fProperties = new ArrayList( 10 );
|
fProperties = new ArrayList( 10 );
|
||||||
fProperties.add( new Property( TYPE, new Integer( module.getType() ) ) );
|
fProperties.add( new Property( TYPE, new Integer( module.getType() ) ) );
|
||||||
fProperties.add( new Property( CPU, module.getCPU() ) );
|
fProperties.add( new Property( CPU, module.getCPU() ) );
|
||||||
|
@ -70,7 +84,38 @@ public class CModuleProperties {
|
||||||
return (Property[])fProperties.toArray( new Property[fProperties.size()] );
|
return (Property[])fProperties.toArray( new Property[fProperties.size()] );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Object getProperty( String key ) {
|
||||||
|
return find( key ).getValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProperty( String key, Object value ) {
|
||||||
|
Property p = find( key );
|
||||||
|
if ( !p.getValue().equals( value ) ) {
|
||||||
|
fProperties.set( fProperties.indexOf( p ), new Property( key, value ) );
|
||||||
|
setDirty( true );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isDirty() {
|
||||||
|
return fIsDirty;
|
||||||
|
}
|
||||||
|
|
||||||
public void dispose() {
|
public void dispose() {
|
||||||
fProperties.clear();
|
fProperties.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setDirty( boolean dirty ) {
|
||||||
|
fIsDirty = dirty;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Property find( String key ) {
|
||||||
|
Iterator it = fProperties.iterator();
|
||||||
|
while( it.hasNext() ) {
|
||||||
|
Property p = (Property)it.next();
|
||||||
|
if ( p.getKey().equals( key ) ) {
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new IllegalArgumentException( key );
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -11,9 +11,21 @@
|
||||||
package org.eclipse.cdt.debug.internal.ui.propertypages;
|
package org.eclipse.cdt.debug.internal.ui.propertypages;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.IAddress;
|
import org.eclipse.cdt.core.IAddress;
|
||||||
|
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.core.model.ICModule;
|
||||||
|
import org.eclipse.cdt.debug.internal.core.ICDebugInternalConstants;
|
||||||
import org.eclipse.cdt.debug.internal.ui.PixelConverter;
|
import org.eclipse.cdt.debug.internal.ui.PixelConverter;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
import org.eclipse.core.runtime.IStatus;
|
||||||
|
import org.eclipse.core.runtime.MultiStatus;
|
||||||
|
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.IStructuredContentProvider;
|
||||||
import org.eclipse.jface.viewers.ITableLabelProvider;
|
import org.eclipse.jface.viewers.ITableLabelProvider;
|
||||||
import org.eclipse.jface.viewers.LabelProvider;
|
import org.eclipse.jface.viewers.LabelProvider;
|
||||||
|
@ -26,8 +38,10 @@ import org.eclipse.swt.layout.GridData;
|
||||||
import org.eclipse.swt.layout.GridLayout;
|
import org.eclipse.swt.layout.GridLayout;
|
||||||
import org.eclipse.swt.widgets.Composite;
|
import org.eclipse.swt.widgets.Composite;
|
||||||
import org.eclipse.swt.widgets.Control;
|
import org.eclipse.swt.widgets.Control;
|
||||||
|
import org.eclipse.swt.widgets.FileDialog;
|
||||||
import org.eclipse.swt.widgets.Table;
|
import org.eclipse.swt.widgets.Table;
|
||||||
import org.eclipse.swt.widgets.TableColumn;
|
import org.eclipse.swt.widgets.TableColumn;
|
||||||
|
import org.eclipse.swt.widgets.TableItem;
|
||||||
import org.eclipse.ui.dialogs.PropertyPage;
|
import org.eclipse.ui.dialogs.PropertyPage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -48,9 +62,9 @@ public class ModulePropertyPage extends PropertyPage {
|
||||||
* @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
|
* @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
|
||||||
*/
|
*/
|
||||||
public String getColumnText( Object element, int columnIndex ) {
|
public String getColumnText( Object element, int columnIndex ) {
|
||||||
if ( element instanceof CModuleProperties.Property ) {
|
if ( element instanceof ModuleProperties.Property ) {
|
||||||
CModuleProperties.Property property = (CModuleProperties.Property)element;
|
ModuleProperties.Property property = (ModuleProperties.Property)element;
|
||||||
if ( CModuleProperties.TYPE.equals( property.getKey() ) ) {
|
if ( ModuleProperties.TYPE.equals( property.getKey() ) ) {
|
||||||
if ( columnIndex == 0 ) {
|
if ( columnIndex == 0 ) {
|
||||||
return PropertyPageMessages.getString( "ModulePropertyPage.0" ); //$NON-NLS-1$
|
return PropertyPageMessages.getString( "ModulePropertyPage.0" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
@ -65,35 +79,35 @@ public class ModulePropertyPage extends PropertyPage {
|
||||||
return PropertyPageMessages.getString( "ModulePropertyPage.3" ); //$NON-NLS-1$
|
return PropertyPageMessages.getString( "ModulePropertyPage.3" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( CModuleProperties.CPU.equals( property.getKey() ) ) {
|
else if ( ModuleProperties.CPU.equals( property.getKey() ) ) {
|
||||||
if ( columnIndex == 0 ) {
|
if ( columnIndex == 0 ) {
|
||||||
return PropertyPageMessages.getString( "ModulePropertyPage.4" ); //$NON-NLS-1$
|
return PropertyPageMessages.getString( "ModulePropertyPage.4" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
String cpu = (String)property.getValue();
|
String cpu = (String)property.getValue();
|
||||||
return ( cpu != null ) ? cpu : PropertyPageMessages.getString( "ModulePropertyPage.5" ); //$NON-NLS-1$
|
return ( cpu != null ) ? cpu : PropertyPageMessages.getString( "ModulePropertyPage.5" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
else if ( CModuleProperties.BASE_ADDRESS.equals( property.getKey() ) ) {
|
else if ( ModuleProperties.BASE_ADDRESS.equals( property.getKey() ) ) {
|
||||||
if ( columnIndex == 0 ) {
|
if ( columnIndex == 0 ) {
|
||||||
return PropertyPageMessages.getString( "ModulePropertyPage.6" ); //$NON-NLS-1$
|
return PropertyPageMessages.getString( "ModulePropertyPage.6" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
IAddress address = (IAddress)property.getValue();
|
IAddress address = (IAddress)property.getValue();
|
||||||
return ( address != null && !address.isZero() ) ? address.toHexAddressString() : PropertyPageMessages.getString( "ModulePropertyPage.7" ); //$NON-NLS-1$
|
return ( address != null && !address.isZero() ) ? address.toHexAddressString() : PropertyPageMessages.getString( "ModulePropertyPage.7" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
else if ( CModuleProperties.SIZE.equals( property.getKey() ) ) {
|
else if ( ModuleProperties.SIZE.equals( property.getKey() ) ) {
|
||||||
if ( columnIndex == 0 ) {
|
if ( columnIndex == 0 ) {
|
||||||
return PropertyPageMessages.getString( "ModulePropertyPage.8" ); //$NON-NLS-1$
|
return PropertyPageMessages.getString( "ModulePropertyPage.8" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
Long size = (Long)property.getValue();
|
Long size = (Long)property.getValue();
|
||||||
return ( size != null && size.longValue() > 0 ) ? size.toString() : PropertyPageMessages.getString( "ModulePropertyPage.9" ); //$NON-NLS-1$
|
return ( size != null && size.longValue() > 0 ) ? size.toString() : PropertyPageMessages.getString( "ModulePropertyPage.9" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
else if ( CModuleProperties.SYMBOLS_LOADED.equals( property.getKey() ) ) {
|
else if ( ModuleProperties.SYMBOLS_LOADED.equals( property.getKey() ) ) {
|
||||||
if ( columnIndex == 0 ) {
|
if ( columnIndex == 0 ) {
|
||||||
return PropertyPageMessages.getString( "ModulePropertyPage.10" ); //$NON-NLS-1$
|
return PropertyPageMessages.getString( "ModulePropertyPage.10" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
Boolean loaded = (Boolean)property.getValue();
|
Boolean loaded = (Boolean)property.getValue();
|
||||||
return ( loaded != null && loaded.booleanValue() ) ? PropertyPageMessages.getString( "ModulePropertyPage.11" ) : PropertyPageMessages.getString( "ModulePropertyPage.12" ); //$NON-NLS-1$ //$NON-NLS-2$
|
return ( loaded != null && loaded.booleanValue() ) ? PropertyPageMessages.getString( "ModulePropertyPage.11" ) : PropertyPageMessages.getString( "ModulePropertyPage.12" ); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
}
|
}
|
||||||
else if ( CModuleProperties.SYMBOLS_FILE.equals( property.getKey() ) ) {
|
else if ( ModuleProperties.SYMBOLS_FILE.equals( property.getKey() ) ) {
|
||||||
if ( columnIndex == 0 ) {
|
if ( columnIndex == 0 ) {
|
||||||
return PropertyPageMessages.getString( "ModulePropertyPage.13" ); //$NON-NLS-1$
|
return PropertyPageMessages.getString( "ModulePropertyPage.13" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
@ -107,8 +121,6 @@ public class ModulePropertyPage extends PropertyPage {
|
||||||
|
|
||||||
public class ModulePropertyContentProvider implements IStructuredContentProvider {
|
public class ModulePropertyContentProvider implements IStructuredContentProvider {
|
||||||
|
|
||||||
private CModuleProperties fProperties = null;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for ModulePropertyContentProvider.
|
* Constructor for ModulePropertyContentProvider.
|
||||||
*/
|
*/
|
||||||
|
@ -121,10 +133,10 @@ public class ModulePropertyPage extends PropertyPage {
|
||||||
*/
|
*/
|
||||||
public Object[] getElements( Object inputElement ) {
|
public Object[] getElements( Object inputElement ) {
|
||||||
if ( inputElement instanceof ICModule ) {
|
if ( inputElement instanceof ICModule ) {
|
||||||
if ( fProperties == null ) {
|
if ( getModuleProperties() == null ) {
|
||||||
fProperties = CModuleProperties.create( (ICModule)inputElement );
|
setModuleProperties( ModuleProperties.create( (ICModule)inputElement ) );
|
||||||
}
|
}
|
||||||
return fProperties.getProperties();
|
return getModuleProperties().getProperties();
|
||||||
}
|
}
|
||||||
return new Object[0];
|
return new Object[0];
|
||||||
}
|
}
|
||||||
|
@ -146,13 +158,15 @@ public class ModulePropertyPage extends PropertyPage {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void disposeProperties() {
|
private void disposeProperties() {
|
||||||
if ( fProperties != null ) {
|
if ( getModuleProperties() != null ) {
|
||||||
fProperties.dispose();
|
getModuleProperties().dispose();
|
||||||
fProperties = null;
|
setModuleProperties( null );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ModuleProperties fProperties = null;
|
||||||
|
|
||||||
private TableViewer fViewer;
|
private TableViewer fViewer;
|
||||||
|
|
||||||
// Column properties
|
// Column properties
|
||||||
|
@ -187,6 +201,8 @@ public class ModulePropertyPage extends PropertyPage {
|
||||||
columns[1].setWidth( pc.convertWidthInCharsToPixels( 40 ) );
|
columns[1].setWidth( pc.convertWidthInCharsToPixels( 40 ) );
|
||||||
|
|
||||||
fViewer.setColumnProperties( new String[]{ CP_NAME, CP_VALUE } );
|
fViewer.setColumnProperties( new String[]{ CP_NAME, CP_VALUE } );
|
||||||
|
fViewer.setCellEditors( new CellEditor[]{ null, createSymbolsFileCellEditor( table ) } );
|
||||||
|
fViewer.setCellModifier( createCellModifier() );
|
||||||
|
|
||||||
fViewer.setContentProvider( createContentProvider() );
|
fViewer.setContentProvider( createContentProvider() );
|
||||||
fViewer.setLabelProvider( createLabelProvider() );
|
fViewer.setLabelProvider( createLabelProvider() );
|
||||||
|
@ -215,7 +231,95 @@ public class ModulePropertyPage extends PropertyPage {
|
||||||
getViewer().setInput( getElement() );
|
getViewer().setInput( getElement() );
|
||||||
}
|
}
|
||||||
|
|
||||||
private TableViewer getViewer() {
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.jface.preference.IPreferencePage#performOk()
|
||||||
|
*/
|
||||||
|
public boolean performOk() {
|
||||||
|
if ( getModuleProperties() != null && getModuleProperties().isDirty() ) {
|
||||||
|
final IPath path = (IPath)getModuleProperties().getProperty( ModuleProperties.SYMBOLS_FILE );
|
||||||
|
final ICModule module = getModule();
|
||||||
|
if ( module != null ) {
|
||||||
|
|
||||||
|
DebugPlugin.getDefault().asyncExec(
|
||||||
|
new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
module.setSymbolsFileName( path );
|
||||||
|
}
|
||||||
|
catch( DebugException e ) {
|
||||||
|
failed( PropertyPageMessages.getString( "ModulePropertyPage.15" ), e ); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return super.performOk();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected TableViewer getViewer() {
|
||||||
return fViewer;
|
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() {
|
||||||
|
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() );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,3 +51,6 @@ ModulePropertyPage.11=loaded
|
||||||
ModulePropertyPage.12=not loaded
|
ModulePropertyPage.12=not loaded
|
||||||
ModulePropertyPage.13=Symbols file
|
ModulePropertyPage.13=Symbols file
|
||||||
ModulePropertyPage.14=not found
|
ModulePropertyPage.14=not found
|
||||||
|
ModulePropertyPage.15=Error
|
||||||
|
ModulePropertyPage.15=Unable to load symbols.
|
||||||
|
ModulePropertyPage.16=Unable to load symbols.
|
||||||
|
|
Loading…
Add table
Reference in a new issue