Search in sources :

Example 1 with CLittleEndiannessAction

use of com.google.security.zynamics.binnavi.Gui.Debug.MemoryPanel.Actions.CLittleEndiannessAction in project binnavi by google.

the class HexViewOptionsMenu method createHexViewOptionsMenu.

public static JMenu createHexViewOptionsMenu(final JHexView hexView) {
    final JMenu menu = new JMenu("Options");
    final JMenu groupingMenu = new JMenu("Byte Grouping");
    final ButtonGroup group = new ButtonGroup();
    final JRadioButtonMenuItem groupingByteMenu = new JRadioButtonMenuItem(CActionProxy.proxy(new CSelectGroupingAction(hexView, "Byte", 1)));
    group.add(groupingByteMenu);
    final JRadioButtonMenuItem groupingWordMenu = new JRadioButtonMenuItem(CActionProxy.proxy(new CSelectGroupingAction(hexView, "Word", 2)));
    group.add(groupingWordMenu);
    final JRadioButtonMenuItem groupingDwordMenu = new JRadioButtonMenuItem(CActionProxy.proxy(new CSelectGroupingAction(hexView, "Double Word", 4)));
    group.add(groupingDwordMenu);
    final int grouping = hexView.getBytesPerColumn();
    switch(grouping) {
        case 1:
            groupingByteMenu.setSelected(true);
            break;
        case 2:
            groupingWordMenu.setSelected(true);
            break;
        case 4:
            groupingDwordMenu.setSelected(true);
            break;
        default:
            throw new IllegalStateException("IE01123: Unknown grouping value: " + grouping);
    }
    groupingMenu.add(groupingByteMenu);
    groupingMenu.add(groupingWordMenu);
    groupingMenu.add(groupingDwordMenu);
    menu.add(groupingMenu);
    final JMenu endiannessMenu = new JMenu("Endianness");
    final ButtonGroup endiannessGroup = new ButtonGroup();
    final JRadioButtonMenuItem littleEndiannessMenu = new JRadioButtonMenuItem(CActionProxy.proxy(new CLittleEndiannessAction(hexView)));
    endiannessGroup.add(littleEndiannessMenu);
    final JRadioButtonMenuItem bigEndiannessMenu = new JRadioButtonMenuItem(CActionProxy.proxy(new CBigEndiannessAction(hexView)));
    endiannessGroup.add(bigEndiannessMenu);
    final boolean flip = hexView.doFlipBytes();
    if (flip) {
        littleEndiannessMenu.setSelected(true);
    } else {
        bigEndiannessMenu.setSelected(true);
    }
    endiannessMenu.add(bigEndiannessMenu);
    endiannessMenu.add(littleEndiannessMenu);
    menu.add(endiannessMenu);
    return menu;
}
Also used : ButtonGroup(javax.swing.ButtonGroup) JRadioButtonMenuItem(javax.swing.JRadioButtonMenuItem) CSelectGroupingAction(com.google.security.zynamics.binnavi.Gui.Debug.MemoryPanel.Actions.CSelectGroupingAction) CLittleEndiannessAction(com.google.security.zynamics.binnavi.Gui.Debug.MemoryPanel.Actions.CLittleEndiannessAction) JMenu(javax.swing.JMenu) CBigEndiannessAction(com.google.security.zynamics.binnavi.Gui.Debug.MemoryPanel.Actions.CBigEndiannessAction)

Aggregations

CBigEndiannessAction (com.google.security.zynamics.binnavi.Gui.Debug.MemoryPanel.Actions.CBigEndiannessAction)1 CLittleEndiannessAction (com.google.security.zynamics.binnavi.Gui.Debug.MemoryPanel.Actions.CLittleEndiannessAction)1 CSelectGroupingAction (com.google.security.zynamics.binnavi.Gui.Debug.MemoryPanel.Actions.CSelectGroupingAction)1 ButtonGroup (javax.swing.ButtonGroup)1 JMenu (javax.swing.JMenu)1 JRadioButtonMenuItem (javax.swing.JRadioButtonMenuItem)1