1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-26 02:15:31 +02:00

[245043] import/export toolbar actions enabled without valid selection

This commit is contained in:
Ted Williams 2008-08-24 17:04:27 +00:00
parent 83c2420761
commit 7174e4d974
3 changed files with 42 additions and 35 deletions

View file

@ -41,7 +41,6 @@
icon="icons/export.png" icon="icons/export.png"
id="org.eclipse.dd.debug.ui.memory.transport.actions.ExportMemoryAction" id="org.eclipse.dd.debug.ui.memory.transport.actions.ExportMemoryAction"
label="%ExportMemoryAction.label" label="%ExportMemoryAction.label"
state="false"
style="push" style="push"
toolbarPath="additions" toolbarPath="additions"
tooltip="%ExportMemoryAction.label"/> tooltip="%ExportMemoryAction.label"/>
@ -51,7 +50,6 @@
icon="icons/import.png" icon="icons/import.png"
id="org.eclipse.dd.debug.ui.memory.transport.actions.ImportMemoryAction" id="org.eclipse.dd.debug.ui.memory.transport.actions.ImportMemoryAction"
label="%ImportMemoryAction.label" label="%ImportMemoryAction.label"
state="false"
style="push" style="push"
toolbarPath="additions" toolbarPath="additions"
tooltip="%ImportMemoryAction.label"/> tooltip="%ImportMemoryAction.label"/>

View file

@ -37,42 +37,46 @@ public class ExportMemoryAction implements IViewActionDelegate {
fView = (MemoryView) view; fView = (MemoryView) view;
} }
public void run(IAction action) { private IMemoryBlock getMemoryBlock(ISelection selection)
{
ISelection selection = fView.getSite().getSelectionProvider() IMemoryBlock memBlock = null;
.getSelection();
if (selection instanceof IStructuredSelection) { if (selection instanceof IStructuredSelection) {
IStructuredSelection strucSel = (IStructuredSelection) selection; IStructuredSelection strucSel = (IStructuredSelection) selection;
// return if current selection is empty // return if current selection is empty
if (strucSel.isEmpty()) if (strucSel.isEmpty())
return; return null;
Object obj = strucSel.getFirstElement(); Object obj = strucSel.getFirstElement();
if (obj == null) if (obj == null)
return; return null;
IMemoryBlock memBlock = null;
if (obj instanceof IMemoryRendering) { if (obj instanceof IMemoryRendering) {
memBlock = ((IMemoryRendering) obj).getMemoryBlock(); memBlock = ((IMemoryRendering) obj).getMemoryBlock();
} else if (obj instanceof IMemoryBlock) { } else if (obj instanceof IMemoryBlock) {
memBlock = (IMemoryBlock) obj; memBlock = (IMemoryBlock) obj;
} }
if(memBlock == null)
return;
ExportMemoryDialog dialog = new ExportMemoryDialog(DebugUIPlugin.getShell(), memBlock);
dialog.open();
dialog.getResult();
} }
return memBlock;
}
public void run(IAction action) {
ISelection selection = fView.getSite().getSelectionProvider()
.getSelection();
IMemoryBlock memBlock = getMemoryBlock(selection);
if(memBlock == null)
return;
ExportMemoryDialog dialog = new ExportMemoryDialog(DebugUIPlugin.getShell(), memBlock);
dialog.open();
dialog.getResult();
} }
public void selectionChanged(IAction action, ISelection selection) { public void selectionChanged(IAction action, ISelection selection) {
action.setEnabled(getMemoryBlock(selection) != null);
} }
} }

View file

@ -37,43 +37,48 @@ public class ImportMemoryAction implements IViewActionDelegate {
if (view instanceof MemoryView) if (view instanceof MemoryView)
fView = (MemoryView) view; fView = (MemoryView) view;
} }
public void run(IAction action) { private IMemoryBlock getMemoryBlock(ISelection selection)
{
ISelection selection = fView.getSite().getSelectionProvider() IMemoryBlock memBlock = null;
.getSelection();
if (selection instanceof IStructuredSelection) { if (selection instanceof IStructuredSelection) {
IStructuredSelection strucSel = (IStructuredSelection) selection; IStructuredSelection strucSel = (IStructuredSelection) selection;
// return if current selection is empty // return if current selection is empty
if (strucSel.isEmpty()) if (strucSel.isEmpty())
return; return null;
Object obj = strucSel.getFirstElement(); Object obj = strucSel.getFirstElement();
if (obj == null) if (obj == null)
return; return null;
IMemoryBlock memBlock = null;
if (obj instanceof IMemoryRendering) { if (obj instanceof IMemoryRendering) {
memBlock = ((IMemoryRendering) obj).getMemoryBlock(); memBlock = ((IMemoryRendering) obj).getMemoryBlock();
} else if (obj instanceof IMemoryBlock) { } else if (obj instanceof IMemoryBlock) {
memBlock = (IMemoryBlock) obj; memBlock = (IMemoryBlock) obj;
} }
if(memBlock == null)
return;
ImportMemoryDialog dialog = new ImportMemoryDialog(DebugUIPlugin.getShell(), memBlock);
dialog.open();
dialog.getResult();
} }
return memBlock;
}
public void run(IAction action) {
ISelection selection = fView.getSite().getSelectionProvider()
.getSelection();
IMemoryBlock memBlock = getMemoryBlock(selection);
if(memBlock == null)
return;
ImportMemoryDialog dialog = new ImportMemoryDialog(DebugUIPlugin.getShell(), memBlock);
dialog.open();
dialog.getResult();
} }
public void selectionChanged(IAction action, ISelection selection) { public void selectionChanged(IAction action, ISelection selection) {
action.setEnabled(getMemoryBlock(selection) != null);
} }
} }