Top Fields Constructors Methods
org.jabref.gui.groups

public Class UndoableAddOrRemoveGroup

extends AbstractUndoableJabRefEdit
Class Inheritance
Imports
java.util.List, org.jabref.gui.undo.AbstractUndoableJabRefEdit, org.jabref.logic.l10n.Localization, org.jabref.model.groups.GroupTreeNode

Field Summary

Modifier and TypeField and Description
public static final int
ADD_NODE

Adding of a single node (group).

private final int
m_editType

The type of the editing (ADD_NODE, REMOVE_NODE_KEEP_CHILDREN, REMOVE_NODE_AND_CHILDREN)

private final GroupTreeNodeViewModel
m_groupsRootHandle

The root of the global groups tree

private final List<Integer>
m_pathToNode

The path to the edited subtree's root node

private final GroupTreeNode
m_subtreeBackup

The subtree that was added or removed

private final int
m_subtreeRootChildCount

In case of removing a node but keeping all of its children, the number of children has to be stored.

public static final int
REMOVE_NODE_AND_CHILDREN

Removal of a node and all of its children.

public static final int
REMOVE_NODE_KEEP_CHILDREN

Removal of a single node.

Constructor Summary

AccessConstructor and Description
public
UndoableAddOrRemoveGroup(GroupTreeNodeViewModel
The global groups root.
groupsRoot
,
GroupTreeNodeViewModel
The edited node (which was added or will be removed). The node must be a descendant of node groupsRoot! This means that, in case of adding, you first have to add it to the tree, then call this constructor. When removing, you first have to call this constructor, then remove the node.
editedNode
,
int
The type of editing (ADD_NODE, REMOVE_NODE_KEEP_CHILDREN, REMOVE_NODE_AND_CHILDREN)
editType
)

Creates an object that can undo/redo an edit event.

Method Summary

Modifier and TypeMethod and Description
private void
doOperation(boolean undo)

public String
public void
redo()

Overrides javax.swing.undo.AbstractUndoableEdit.redo.

Implements javax.swing.undo.UndoableEdit.redo.

Throws CannotRedoException if canRedo returns false.

public void
undo()

Overrides javax.swing.undo.AbstractUndoableEdit.undo.

Implements javax.swing.undo.UndoableEdit.undo.

Throws CannotUndoException if canUndo returns false.

Inherited from org.jabref.gui.undo.AbstractUndoableJabRefEdit:
getRedoPresentationNamegetUndoPresentationName

Field Detail

ADD_NODEback to summary
public static final int ADD_NODE

Adding of a single node (group).

m_editTypeback to summary
private final int m_editType

The type of the editing (ADD_NODE, REMOVE_NODE_KEEP_CHILDREN, REMOVE_NODE_AND_CHILDREN)

m_groupsRootHandleback to summary
private final GroupTreeNodeViewModel m_groupsRootHandle

The root of the global groups tree

m_pathToNodeback to summary
private final List<Integer> m_pathToNode

The path to the edited subtree's root node

m_subtreeBackupback to summary
private final GroupTreeNode m_subtreeBackup

The subtree that was added or removed

m_subtreeRootChildCountback to summary
private final int m_subtreeRootChildCount

In case of removing a node but keeping all of its children, the number of children has to be stored.

REMOVE_NODE_AND_CHILDRENback to summary
public static final int REMOVE_NODE_AND_CHILDREN

Removal of a node and all of its children.

REMOVE_NODE_KEEP_CHILDRENback to summary
public static final int REMOVE_NODE_KEEP_CHILDREN

Removal of a single node. Children, if any, are kept.

Constructor Detail

UndoableAddOrRemoveGroupback to summary
public UndoableAddOrRemoveGroup(GroupTreeNodeViewModel groupsRoot, GroupTreeNodeViewModel editedNode, int editType)

Creates an object that can undo/redo an edit event.

Parameters
groupsRoot:GroupTreeNodeViewModel

The global groups root.

editedNode:GroupTreeNodeViewModel

The edited node (which was added or will be removed). The node must be a descendant of node groupsRoot! This means that, in case of adding, you first have to add it to the tree, then call this constructor. When removing, you first have to call this constructor, then remove the node.

editType:int

The type of editing (ADD_NODE, REMOVE_NODE_KEEP_CHILDREN, REMOVE_NODE_AND_CHILDREN)

Method Detail

doOperationback to summary
private void doOperation(boolean undo)
getPresentationNameback to summary
public String getPresentationName()

Overrides javax.swing.undo.AbstractUndoableEdit.getPresentationName.

Implements javax.swing.undo.UndoableEdit.getPresentationName.

Doc from javax.swing.undo.AbstractUndoableEdit.getPresentationName.

This default implementation returns "". Used by getUndoPresentationName and getRedoPresentationName to construct the strings they return. Subclasses should override to return an appropriate description of the operation this edit represents.

Returns:String

the empty string ""

Annotations
@Override
redoback to summary
public void redo()

Overrides javax.swing.undo.AbstractUndoableEdit.redo.

Implements javax.swing.undo.UndoableEdit.redo.

Doc from javax.swing.undo.AbstractUndoableEdit.redo.

Throws CannotRedoException if canRedo returns false. Sets hasBeenDone to true. Subclasses should override to redo the operation represented by this edit. Override should begin with a call to super.

Annotations
@Override
undoback to summary
public void undo()

Overrides javax.swing.undo.AbstractUndoableEdit.undo.

Implements javax.swing.undo.UndoableEdit.undo.

Doc from javax.swing.undo.AbstractUndoableEdit.undo.

Throws CannotUndoException if canUndo returns false. Sets hasBeenDone to false. Subclasses should override to undo the operation represented by this edit. Override should begin with a call to super.

Annotations
@Override