mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-18 22:45:23 +02:00
[245043] import/export toolbar actions enabled without valid selection
This commit is contained in:
parent
83c2420761
commit
7174e4d974
3 changed files with 42 additions and 35 deletions
|
@ -41,7 +41,6 @@
|
|||
icon="icons/export.png"
|
||||
id="org.eclipse.dd.debug.ui.memory.transport.actions.ExportMemoryAction"
|
||||
label="%ExportMemoryAction.label"
|
||||
state="false"
|
||||
style="push"
|
||||
toolbarPath="additions"
|
||||
tooltip="%ExportMemoryAction.label"/>
|
||||
|
@ -51,7 +50,6 @@
|
|||
icon="icons/import.png"
|
||||
id="org.eclipse.dd.debug.ui.memory.transport.actions.ImportMemoryAction"
|
||||
label="%ImportMemoryAction.label"
|
||||
state="false"
|
||||
style="push"
|
||||
toolbarPath="additions"
|
||||
tooltip="%ImportMemoryAction.label"/>
|
||||
|
|
|
@ -37,42 +37,46 @@ public class ExportMemoryAction implements IViewActionDelegate {
|
|||
fView = (MemoryView) view;
|
||||
}
|
||||
|
||||
public void run(IAction action) {
|
||||
|
||||
ISelection selection = fView.getSite().getSelectionProvider()
|
||||
.getSelection();
|
||||
private IMemoryBlock getMemoryBlock(ISelection selection)
|
||||
{
|
||||
IMemoryBlock memBlock = null;
|
||||
|
||||
if (selection instanceof IStructuredSelection) {
|
||||
IStructuredSelection strucSel = (IStructuredSelection) selection;
|
||||
|
||||
// return if current selection is empty
|
||||
if (strucSel.isEmpty())
|
||||
return;
|
||||
return null;
|
||||
|
||||
Object obj = strucSel.getFirstElement();
|
||||
|
||||
if (obj == null)
|
||||
return;
|
||||
|
||||
IMemoryBlock memBlock = null;
|
||||
return null;
|
||||
|
||||
if (obj instanceof IMemoryRendering) {
|
||||
memBlock = ((IMemoryRendering) obj).getMemoryBlock();
|
||||
} else if (obj instanceof IMemoryBlock) {
|
||||
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) {
|
||||
|
||||
action.setEnabled(getMemoryBlock(selection) != null);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -37,43 +37,48 @@ public class ImportMemoryAction implements IViewActionDelegate {
|
|||
if (view instanceof MemoryView)
|
||||
fView = (MemoryView) view;
|
||||
}
|
||||
|
||||
public void run(IAction action) {
|
||||
|
||||
ISelection selection = fView.getSite().getSelectionProvider()
|
||||
.getSelection();
|
||||
|
||||
private IMemoryBlock getMemoryBlock(ISelection selection)
|
||||
{
|
||||
IMemoryBlock memBlock = null;
|
||||
|
||||
if (selection instanceof IStructuredSelection) {
|
||||
IStructuredSelection strucSel = (IStructuredSelection) selection;
|
||||
|
||||
// return if current selection is empty
|
||||
if (strucSel.isEmpty())
|
||||
return;
|
||||
return null;
|
||||
|
||||
Object obj = strucSel.getFirstElement();
|
||||
|
||||
if (obj == null)
|
||||
return;
|
||||
|
||||
IMemoryBlock memBlock = null;
|
||||
return null;
|
||||
|
||||
if (obj instanceof IMemoryRendering) {
|
||||
memBlock = ((IMemoryRendering) obj).getMemoryBlock();
|
||||
} else if (obj instanceof IMemoryBlock) {
|
||||
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) {
|
||||
|
||||
action.setEnabled(getMemoryBlock(selection) != null);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue