mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Patch from Chris Songer to make multiple
selection works when setting formats.
This commit is contained in:
parent
2fbfc15fe4
commit
c6f2a35f9c
2 changed files with 39 additions and 32 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
2004-02-03 Alain Magloire
|
||||||
|
|
||||||
|
Derived from a patch by Chris Songer.
|
||||||
|
Accept multiple selection when doing setting the format variables.
|
||||||
|
|
||||||
|
* src/org/eclipse/cdt/debug/internal/ui/actions/VariableFormatActionDelegate.java
|
||||||
|
|
||||||
2004-01-30 Mikhail Khodjaiants
|
2004-01-30 Mikhail Khodjaiants
|
||||||
Fix for bug 50967: Linux/SWT blows when double click on the register view.
|
Fix for bug 50967: Linux/SWT blows when double click on the register view.
|
||||||
* ChangeRegisterValueAction.java
|
* ChangeRegisterValueAction.java
|
||||||
|
|
|
@ -5,6 +5,10 @@
|
||||||
*/
|
*/
|
||||||
package org.eclipse.cdt.debug.internal.ui.actions;
|
package org.eclipse.cdt.debug.internal.ui.actions;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.cdt.debug.core.cdi.ICDIFormat;
|
import org.eclipse.cdt.debug.core.cdi.ICDIFormat;
|
||||||
import org.eclipse.cdt.debug.core.model.ICVariable;
|
import org.eclipse.cdt.debug.core.model.ICVariable;
|
||||||
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
|
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
|
||||||
|
@ -27,8 +31,8 @@ import org.eclipse.ui.IWorkbenchWindow;
|
||||||
*/
|
*/
|
||||||
public class VariableFormatActionDelegate implements IObjectActionDelegate
|
public class VariableFormatActionDelegate implements IObjectActionDelegate
|
||||||
{
|
{
|
||||||
private int fFormat = ICDIFormat.DECIMAL;
|
private int fFormat = ICDIFormat.NATURAL;
|
||||||
private ICVariable fVariable = null;
|
private ICVariable[] fVariables = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for VariableFormatActionDelegate.
|
* Constructor for VariableFormatActionDelegate.
|
||||||
|
@ -50,7 +54,7 @@ public class VariableFormatActionDelegate implements IObjectActionDelegate
|
||||||
*/
|
*/
|
||||||
public void run( IAction action )
|
public void run( IAction action )
|
||||||
{
|
{
|
||||||
if ( getVariable() != null )
|
if ( fVariables != null && fVariables.length > 0 )
|
||||||
{
|
{
|
||||||
final MultiStatus ms = new MultiStatus( CDebugUIPlugin.getUniqueIdentifier(),
|
final MultiStatus ms = new MultiStatus( CDebugUIPlugin.getUniqueIdentifier(),
|
||||||
DebugException.REQUEST_FAILED, "", null );
|
DebugException.REQUEST_FAILED, "", null );
|
||||||
|
@ -61,7 +65,7 @@ public class VariableFormatActionDelegate implements IObjectActionDelegate
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
doAction( getVariable() );
|
doAction( fVariables );
|
||||||
}
|
}
|
||||||
catch( DebugException e )
|
catch( DebugException e )
|
||||||
{
|
{
|
||||||
|
@ -92,41 +96,37 @@ public class VariableFormatActionDelegate implements IObjectActionDelegate
|
||||||
{
|
{
|
||||||
if ( selection instanceof IStructuredSelection )
|
if ( selection instanceof IStructuredSelection )
|
||||||
{
|
{
|
||||||
Object element = ((IStructuredSelection)selection).getFirstElement();
|
List list = new ArrayList();
|
||||||
if ( element instanceof ICVariable )
|
IStructuredSelection ssel = (IStructuredSelection)selection;
|
||||||
|
Iterator i = ssel.iterator();
|
||||||
|
while ( i.hasNext() )
|
||||||
{
|
{
|
||||||
boolean enabled = enablesFor( (ICVariable)element );
|
Object o = i.next();
|
||||||
|
if ( o instanceof ICVariable )
|
||||||
|
{
|
||||||
|
ICVariable var = (ICVariable)o;
|
||||||
|
boolean enabled = var.isEditable();
|
||||||
action.setEnabled( enabled );
|
action.setEnabled( enabled );
|
||||||
if ( enabled )
|
if ( enabled )
|
||||||
{
|
{
|
||||||
action.setChecked( ( ((ICVariable)element).getFormat() == fFormat ) );
|
action.setChecked( var.getFormat() == fFormat );
|
||||||
setVariable( (ICVariable)element );
|
list.add(o);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
fVariables = new ICVariable[list.size()];
|
||||||
|
list.toArray(fVariables);
|
||||||
|
} else {
|
||||||
action.setChecked( false );
|
action.setChecked( false );
|
||||||
action.setEnabled( false );
|
action.setEnabled( false );
|
||||||
setVariable( null );
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean enablesFor( ICVariable var )
|
protected void doAction( ICVariable[] vars ) throws DebugException
|
||||||
{
|
{
|
||||||
return var.isEditable();
|
for (int i = 0; i < vars.length; i++ )
|
||||||
|
{
|
||||||
|
vars[i].setFormat(fFormat);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setVariable( ICVariable var )
|
|
||||||
{
|
|
||||||
fVariable = var;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected ICVariable getVariable()
|
|
||||||
{
|
|
||||||
return fVariable;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void doAction( ICVariable var ) throws DebugException
|
|
||||||
{
|
|
||||||
var.setFormat( fFormat );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue