Search in sources :

Example 1 with InsertMemberAction

use of com.google.security.zynamics.binnavi.Gui.GraphWindows.types.actions.InsertMemberAction in project binnavi by google.

the class TypeEditorMouseHandler method createNodeClickedMenu.

private JPopupMenu createNodeClickedMenu(final TreeNode clickedNode) {
    final JPopupMenu popupMenu = new JPopupMenu();
    if (clickedNode instanceof TypeMemberTreeNode) {
        final TypeMember selectedMember = ((TypeMemberTreeNode) clickedNode).getTypeMember();
        final AbstractAction editMemberAction = new EditMemberAction(owner, typeManager, selectedMember);
        final AbstractAction insertAction = new InsertMemberAction(owner, typeManager, selectedMember);
        if (tree.getSelectionCount() > 1) {
            editMemberAction.setEnabled(false);
            insertAction.setEnabled(false);
        }
        if (selectedMember.getParentType() != null && selectedMember.getParentType().getCategory() == BaseTypeCategory.STRUCT) {
            popupMenu.add(new AppendMemberAction(owner, typeManager, selectedMember.getParentType()));
            popupMenu.add(insertAction);
        }
        popupMenu.add(editMemberAction);
        popupMenu.add(new DeleteMemberAction(owner, typeManager, typeEditor));
    } else if (clickedNode instanceof BaseTypeTreeNode) {
        final BaseType selectedType = ((BaseTypeTreeNode) clickedNode).getBaseType();
        final AbstractAction editAction = new EditTypeAction(owner, typeManager, selectedType);
        final AbstractAction appendAction = new AppendMemberAction(owner, typeManager, selectedType);
        if (tree.getSelectionCount() > 1) {
            editAction.setEnabled(false);
            appendAction.setEnabled(false);
        } else if (selectedType.getCategory() != BaseTypeCategory.STRUCT) {
            appendAction.setEnabled(false);
        }
        popupMenu.add(editAction);
        popupMenu.add(appendAction);
        popupMenu.add(new DeleteTypeAction(owner, typeManager, typeEditor));
    }
    return popupMenu;
}
Also used : AppendMemberAction(com.google.security.zynamics.binnavi.Gui.GraphWindows.types.actions.AppendMemberAction) EditMemberAction(com.google.security.zynamics.binnavi.Gui.GraphWindows.types.actions.EditMemberAction) BaseType(com.google.security.zynamics.binnavi.disassembly.types.BaseType) TypeMember(com.google.security.zynamics.binnavi.disassembly.types.TypeMember) EditTypeAction(com.google.security.zynamics.binnavi.Gui.GraphWindows.types.actions.EditTypeAction) InsertMemberAction(com.google.security.zynamics.binnavi.Gui.GraphWindows.types.actions.InsertMemberAction) AbstractAction(javax.swing.AbstractAction) JPopupMenu(javax.swing.JPopupMenu)

Aggregations

AppendMemberAction (com.google.security.zynamics.binnavi.Gui.GraphWindows.types.actions.AppendMemberAction)1 EditMemberAction (com.google.security.zynamics.binnavi.Gui.GraphWindows.types.actions.EditMemberAction)1 EditTypeAction (com.google.security.zynamics.binnavi.Gui.GraphWindows.types.actions.EditTypeAction)1 InsertMemberAction (com.google.security.zynamics.binnavi.Gui.GraphWindows.types.actions.InsertMemberAction)1 BaseType (com.google.security.zynamics.binnavi.disassembly.types.BaseType)1 TypeMember (com.google.security.zynamics.binnavi.disassembly.types.TypeMember)1 AbstractAction (javax.swing.AbstractAction)1 JPopupMenu (javax.swing.JPopupMenu)1