Beispiel #1
0
    def __init__(self, variableCreationController):
        """Constructor of VariableIDTreeController:

                @type variableCreationController: VariableCreationController
                @param variableCreationController: the variable creation controller that indirectly causes this variableIDTreeController to appear.
        """
        self.view = VariableTreeView(self)
        self.netzob = variableCreationController.netzob
        self.variableCreationController = variableCreationController
        self.registerContent()
        self.selectedVariable = None
        self.view.getWidg("createDefaultVariable_button").set_visible(False)
Beispiel #2
0
    def __init__(self, netzob, symbol, field):
        """Constructor of VariableTreeController:

                @type netzob: netzob.Common.NetzobGui.NetzobGui
                @param netzob: the main netzob project.
                @type field: netzob.Common.Field.Field
                @param field: the field, the variable of which we want to display.
        """
        self.netzob = netzob
        self.symbol = symbol
        self.field = field

        self.view = VariableTreeView(self)
        self.view.getWidg("dialog").set_title(_("Configure definition domain for the field: {0}").format(field.getName()))
#        if self.field.getVariable() is not None:
        self.registerContent(self.field.getVariable())
        self.initIndexesList()
        self.initCallbacks()
Beispiel #3
0
    def __init__(self, variableCreationController):
        """Constructor of VariableIDTreeController:

                @type variableCreationController: VariableCreationController
                @param variableCreationController: the variable creation controller that indirectly causes this variableIDTreeController to appear.
        """
        self.view = VariableTreeView(self)
        self.netzob = variableCreationController.netzob
        self.variableCreationController = variableCreationController
        self.registerContent()
Beispiel #4
0
    def __init__(self, netzob, symbol, field):
        """Constructor of VariableTreeController:

                @type netzob: netzob.Common.NetzobGui.NetzobGui
                @param netzob: the main netzob project.
                @type field: netzob.Common.Field.Field
                @param field: the field, the variable of which we want to display.
        """
        self.netzob = netzob
        self.symbol = symbol
        self.field = field

        self.view = VariableTreeView(self)
#        if self.field.getVariable() is not None:
        self.registerContent(self.field.getVariable())
        self.initCallbacks()
Beispiel #5
0
class VariableIDTreeController(object):
    """VariableIDTreeController:
            Controls a variable's ID tree view display.
            This treeview displays every variable of the vocabulary and is useful for selecting one of them.
    """

    def __init__(self, variableCreationController):
        """Constructor of VariableIDTreeController:

                @type variableCreationController: VariableCreationController
                @param variableCreationController: the variable creation controller that indirectly causes this variableIDTreeController to appear.
        """
        self.view = VariableTreeView(self)
        self.netzob = variableCreationController.netzob
        self.variableCreationController = variableCreationController
        self.registerContent()

    def initCallbacks(self):
        """initCallbacks:
                Init the callbacks.
        """
        self.view.getWidg("treeview").connect('button-press-event', self.showMenu)
        self.view.getWidg("button").connect('clicked', self.view.destroyDialog)

    def registerContent(self):
        """registerContent:
                Register each variable and their entry in the tree view.
                Fill the tree view of a variable with all its displayable content.
        """
        self.dictEntry = dict()
        self.dictVariable = dict()
        self.treestore = Gtk.TreeStore(str, str)  # id of the data, description
        for symbol in self.netzob.getCurrentProject().getVocabulary().getSymbols():
            self.registerVariable(None, symbol.getRoot())
        self.initCallbacks()
        self.view.getWidg("treeview").set_model(self.treestore)

    def registerVariable(self, rootEntry, variable):
        """registerVariable:
                Register a variable in the tree view under its root variable (Aggregate or Alternate).
                May be recursive.

                @type rootEntry: Gtk.treerow
                @param rootEntry: the root entry under which we will add this entry.
                @type variable: netzob.Common.MMSTD.Dictionary.Variables.AbstractVariable.AbstractVariable
                @param variable: the variable which will be added to the tree view representation.
        """
        self.dictVariable[str(variable.getID())] = variable
        newEntry = self.treestore.append(rootEntry, [str(variable.getID()), variable.toString()])
        self.dictEntry[str(variable.getID())] = newEntry
        if variable.getVariableType() == AggregateVariable.TYPE or variable.getVariableType() == AlternateVariable.TYPE:
            if variable.getChildren() is not None:
                for child in variable.getChildren():
                    self.registerVariable(newEntry, child)
        if variable.getVariableType() == RepeatVariable.TYPE:
            if variable.getChild() is not None:
                self.registerVariable(newEntry, variable.getChild())

    def showMenu(self, treeview, event):
        """showMenu:
                Called on right click on a variable.

                @param treeview: the treeview which contains the triggering variable.
                @param event: the mouse event which called this function.
        """
        variable = None
        if event.button == 3:
            x = int(event.x)
            y = int(event.y)
            (path, treeviewColumn, x, y) = treeview.get_path_at_pos(x, y)

            # Retrieve the selected variable
            varid = None
            aniter = treeview.get_model().get_iter(path)
            if aniter:
                if treeview.get_model().iter_is_valid(aniter):
                    varid = treeview.get_model().get_value(aniter, 0)

                    if varid is not None:
                        variable = self.dictVariable[varid]
        else:
            # Wrong mouse click
            return

        if variable is None:
            logging.debug("Impossible to find the selected variable.")
            return

        # We display the menu for the insertion of sub-elements if its an Aggregate or an Alternative
        self.menu = Gtk.Menu()

        # To select an element.
        itemSelect = Gtk.MenuItem(_("Select this element"))
        itemSelect.connect("activate", self.selectElement, variable)
        itemSelect.show()

        self.menu.append(itemSelect)
        self.menu.popup(None, None, None, None, event.button, event.time)

    def selectElement(self, widget, variable):
        """selectElement:
                Give the ID of the variable associated to the selected element to the globally calling variableCreationController.

                @param widget: the widget on which this function is connected.
                @type variable: netzob.Common.MMSTD.Dictionary.Variables.AbstractVariable
                @param variable: the variable that is selected/of which we want the ID.
        """
        self.variableCreationController.view.getWidg("IDEntry").set_text(str(variable.getID()))
        self.view.getWidg("dialog").destroy()
Beispiel #6
0
class VariableTreeController(object):
    """VariableTreeController:
            Controls a variable's tree view display
    """

    def __init__(self, netzob, symbol, field):
        """Constructor of VariableTreeController:

                @type netzob: netzob.Common.NetzobGui.NetzobGui
                @param netzob: the main netzob project.
                @type field: netzob.Common.Field.Field
                @param field: the field, the variable of which we want to display.
        """
        self.netzob = netzob
        self.symbol = symbol
        self.field = field

        self.view = VariableTreeView(self)
#        if self.field.getVariable() is not None:
        self.registerContent(self.field.getVariable())
        self.initCallbacks()

    def initCallbacks(self):
        """initCallbacks:
                Init the callbacks.
        """
        self.view.getWidg("treeview").connect('button-press-event', self.showMenu)
        self.view.getWidg("button").connect('clicked', self.view.destroyDialog)
        self.view.getWidg("createDefaultVariable_button").connect('clicked', self.createDefaultVariable_cb)

    def registerContent(self, variable):
        """registerContent:
                Register each variable, their entry in the tree view.
                Fill the tree view of a variable with all its displayable content.

                @type variable: netzob.Common.MMSTD.Dictionary.Variables.AbstractVariable.AbstractVariable
                @param variable: the root variable which content will be displayed.
        """
        self.dictVariable = dict()
        self.dictEntry = dict()

        self.treestore = Gtk.TreeStore(str, str)  # id of the data, description
        self.registerVariable(None, variable)
        self.view.getWidg("treeview").set_model(self.treestore)

    def registerVariable(self, rootEntry, variable):
        """registerVariable:
                Register a variable in the tree view under its root variable (Aggregate or Alternate).
                May be recursive.

                @type rootEntry: Gtk.treerow
                @param rootEntry: the root entry under which we will add this entry.
                @type variable: netzob.Common.MMSTD.Dictionary.Variables.AbstractVariable.AbstractVariable
                @param variable: the variable which will be added to the tree view representation.
        """
        if variable is None:
            return
        self.dictVariable[str(variable.getID())] = variable
        newEntry = self.treestore.append(rootEntry, [str(variable.getID()), variable.toString()])
        self.dictEntry[str(variable.getID())] = newEntry
        if variable.getVariableType() == AggregateVariable.TYPE or variable.getVariableType() == AlternateVariable.TYPE:
            if variable.getChildren() is not None:
                for child in variable.getChildren():
                    self.registerVariable(newEntry, child)
        if variable.getVariableType() == RepeatVariable.TYPE:
            if variable.getChild() is not None:
                self.registerVariable(newEntry, variable.getChild())

    def showMenu(self, treeview, event):
        """showMenu:
                Called on right click on a variable.

                @param treeview: the treeview which contains the triggering variable.
                @param event: the mouse event which called this function.
        """
        variable = None
        if event.button == 3:
            x = int(event.x)
            y = int(event.y)
            (path, treeviewColumn, x, y) = treeview.get_path_at_pos(x, y)

            # Retrieve the selected variable
            varid = None
            aniter = treeview.get_model().get_iter(path)
            if aniter:
                if treeview.get_model().iter_is_valid(aniter):
                    varid = treeview.get_model().get_value(aniter, 0)

                    if varid is not None:
                        variable = self.dictVariable[varid]
        else:
            # Wrong mouse click
            return

        if variable is None:
            logging.debug("Impossible to find the selected variable.")
            return

        # We display the menu for the insertion of sub-elements if its an Aggregate or an Alternative
        self.menu = Gtk.Menu()

        # We can add elements only to node variable.
        if variable.isNode():
            if variable.getVariableType() == RepeatVariable.TYPE:
                # Add an element to a repeat variable will replace the previous one.
                itemAdd = Gtk.MenuItem(_("Edit the sub-element"))
            else:
                itemAdd = Gtk.MenuItem(_("Add a sub-element"))
            itemAdd.connect("activate", VariableCreationController, self, variable, aniter, False)
            itemAdd.show()
            self.menu.append(itemAdd)

        # To edit an element.
        itemEdit = Gtk.MenuItem(_("Edit this element"))
        itemEdit.connect("activate", VariableCreationController, self, variable, aniter, True)
        itemEdit.show()

        # If we have not click on the root variable, we can move and remove it. The root variable can be edited. it is way enough.
        if variable.getID() != self.field.getVariable().getID():
            # To move an element.
            itemMove = Gtk.MenuItem(_("Move this element"))
            itemMove.connect("activate", VariableMovingController, self, variable)
            itemMove.show()
            self.menu.append(itemMove)

            # To remove an element.
            itemRemove = Gtk.MenuItem(_("Remove this element"))
            itemRemove.connect("activate", self.removeVariable, variable)
            itemRemove.show()
            self.menu.append(itemRemove)

        self.menu.append(itemEdit)
        self.menu.popup(None, None, None, None, event.button, event.time)

    def removeVariable(self, item, variable):
        """removeVariable:
                Remove a variable and its presence in the tree view.

                @type item: Gtk.Menuitem
                @param item: the menu item which calls this function.
                @type variable: netzob.Common.MMSTD.Dictionary.Variables.AbstractVariable
                @param variable: the variable that will be removed.
        """
        questionMsg = _("Click yes to confirm the removal of the variable {0}").format(variable.getName())
        md = Gtk.MessageDialog(None, Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT, Gtk.MessageType.QUESTION, Gtk.ButtonsType.YES_NO, questionMsg)
        result = md.run()
        md.destroy()
        if result == Gtk.ResponseType.YES:
            # Remove the variable from the global tree.
            father = variable.getFathers()[0]
            father.removeChildByID(variable)
            # Remove its entry.
            entry = self.dictEntry[str(variable.getID())]
            self.treestore.remove(entry)

            # Remove the variable and its entry from dictionaries.
            self.dictEntry.pop(str(variable.getID()))
            self.dictVariable.pop(str(variable.getID()))

        else:
            logging.info("The user didn't confirm the deletion of the variable {0}".format(variable.getName()))

    def editVariable(self, variable):
        """editVariable:
                Edit a variable and its representation on the tree row.

                @type variable: netzob.Common.MMSTD.Dictionary.Variables.AbstractVariable
                @param variable: the variable that will be edited.
        """
        questionMsg = _("Click yes to confirm the edition of the variable {0}").format(variable.getName())
        md = Gtk.MessageDialog(None, Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT, Gtk.MessageType.QUESTION, Gtk.ButtonsType.YES_NO, questionMsg)
        result = md.run()
        md.destroy()
        if result == Gtk.ResponseType.YES:
            pass
            if variable.getID() == self.field.getVariable().getID():
                # Edit the variable
                self.field.setVariable(variable)

                # Update its entry
                entry = self.dictEntry[variable.getID()]
                self.treestore.remove(entry)
                self.registerVariable(None, variable)
            else:
                # Edit the variable
                father = variable.getFathers()[0]
                father.editChildByID(variable)

                # Update its entry
                entry = self.dictEntry[variable.getID()]
                self.treestore.set_value(entry, 1, variable.toString())
                #self.registerVariable(self.dictEntry[father.getID()], variable)
        else:
            logging.info("The user didn't confirm the edition of the variable {0}".format(variable.getName()))

    def createDefaultVariable_cb(self, event):
        """createDefaultVariable_cb:
                Create a default variable, which is an alternate of
                all the possible values of the field.
        """
#        if self.field.getVariable() is None:
        self.field.variable = self.field.getDefaultVariable(self.symbol)
        self.registerContent(self.field.getVariable())
Beispiel #7
0
class VariableIDTreeController(object):
    """VariableIDTreeController:
            Controls a variable's ID tree view display.
            This treeview displays every variable of the vocabulary and is useful for selecting one of them.
    """

    def __init__(self, variableCreationController):
        """Constructor of VariableIDTreeController:

                @type variableCreationController: VariableCreationController
                @param variableCreationController: the variable creation controller that indirectly causes this variableIDTreeController to appear.
        """
        self.view = VariableTreeView(self)
        self.netzob = variableCreationController.netzob
        self.variableCreationController = variableCreationController
        self.registerContent()
        self.selectedVariable = None
        self.view.getWidg("createDefaultVariable_button").set_visible(False)

    def initCallbacks(self):
        """initCallbacks:
                Init the callbacks.
        """
        self.view.getWidg("treeview").connect('button-press-event', self.clickOnElement)
        self.view.getWidg("button").connect('clicked', self.selectElement)

    def registerContent(self):
        """registerContent:
                Register each variable and their entry in the tree view.
                Fill the tree view of a variable with all its displayable content.
        """
        self.dictEntry = dict()
        self.dictVariable = dict()
        self.treestore = Gtk.TreeStore(str, str)  # id of the data, description
        for symbol in self.netzob.getCurrentProject().getVocabulary().getSymbols():
            self.registerVariable(None, symbol.getRoot())
        self.initCallbacks()
        self.view.getWidg("treeview").set_model(self.treestore)

    def registerVariable(self, rootEntry, variable):
        """registerVariable:
                Register a variable in the tree view under its root variable (Aggregate or Alternate).
                May be recursive.

                @type rootEntry: Gtk.treerow
                @param rootEntry: the root entry under which we will add this entry.
                @type variable: netzob.Common.MMSTD.Dictionary.Variables.AbstractVariable.AbstractVariable
                @param variable: the variable which will be added to the tree view representation.
        """
        self.dictVariable[str(variable.getID())] = variable
        newEntry = self.treestore.append(rootEntry, [str(variable.getID()), variable.toString()])
        self.dictEntry[str(variable.getID())] = newEntry
        if variable.getVariableType() == AggregateVariable.TYPE or variable.getVariableType() == AlternateVariable.TYPE:
            if variable.getChildren() is not None:
                for child in variable.getChildren():
                    self.registerVariable(newEntry, child)
        if variable.getVariableType() == RepeatVariable.TYPE:
            if variable.getChild() is not None:
                self.registerVariable(newEntry, variable.getChild())

    def clickOnElement(self, treeview, event):
        """clickOnElement:
                Called on click on a variable.

                @param treeview: the treeview which contains the triggering variable.
                @param event: the mouse event which called this function.
        """
        if event.button == 1:  # left click
            try:
                x = int(event.x)
                y = int(event.y)
                (path, treeviewColumn, x, y) = treeview.get_path_at_pos(x, y)

                # Retrieve the selected variable
                varid = None
                aniter = treeview.get_model().get_iter(path)
                if aniter:
                    if treeview.get_model().iter_is_valid(aniter):
                        varid = treeview.get_model().get_value(aniter, 0)

                        if varid is not None:
                            self.selectedVariable = self.dictVariable[varid]
            except:
                logging.debug(_("The user clicks on no variable."))
        else:
            # Wrong mouse click
            return

    def selectElement(self, widget):
        """selectElement:
                Give the ID of the variable associated to the selected element to the globally calling variableCreationController.

                @param widget: the widget on which this function is connected.
        """
        if self.selectedVariable is not None:
            self.variableCreationController.view.getWidg("IDEntry").set_text(str(self.selectedVariable.getID()))
            self.view.getWidg("dialog").destroy()
        else:
            NetzobErrorMessage(_("No variable selected."))
Beispiel #8
0
class VariableTreeController(object):
    """VariableTreeController:
            Controls a variable's tree view display
    """

    # Indexes of variable in the variable type combo box.
    VARIABLE_INDEX_LIST = []

    # Indexes of DataVariable type in the type combo box.
    TYPE_INDEX_LIST = []

    # Index of ComputedRelationVariable type in the relation type combo box.
    RELATION_TYPE_INDEX_LIST = []

    def __init__(self, netzob, symbol, field):
        """Constructor of VariableTreeController:

                @type netzob: netzob.Common.NetzobGui.NetzobGui
                @param netzob: the main netzob project.
                @type field: netzob.Common.Field.Field
                @param field: the field, the variable of which we want to display.
        """
        self.netzob = netzob
        self.symbol = symbol
        self.field = field

        self.view = VariableTreeView(self)
        self.view.getWidg("dialog").set_title(_("Configure definition domain for the field: {0}").format(field.getName()))
#        if self.field.getVariable() is not None:
        self.registerContent(self.field.getVariable())
        self.initIndexesList()
        self.initCallbacks()

    def initIndexesList(self):
        """initIndexesList:
                Initiate the indexes list. These list keep links between index in combo box and type.
        """
        VariableTreeController.VARIABLE_INDEX_LIST = [AggregateVariable.TYPE, AlternateVariable.TYPE, ComputedRelationVariable.TYPE, DataVariable.TYPE, RepeatVariable.TYPE]
        VariableTreeController.TYPE_INDEX_LIST = [BinaryType.TYPE, DecimalWordType.TYPE, HexWordType.TYPE, IntegerType.TYPE, IPv4WordType.TYPE, MACWordType.TYPE, WordType.TYPE]
        VariableTreeController.RELATION_TYPE_INDEX_LIST = [BinarySizeRelationType.TYPE, WordSizeRelationType.TYPE]

    def initCallbacks(self):
        """initCallbacks:
                Init the callbacks.
        """
        self.view.getWidg("treeview").connect('button-press-event', self.showMenu)
        self.view.getWidg("button").connect('clicked', self.view.destroyDialog)
        self.view.getWidg("createDefaultVariable_button").connect('clicked', self.createDefaultVariable_cb)

    def registerContent(self, variable):
        """registerContent:
                Register each variable, their entry in the tree view.
                Fill the tree view of a variable with all its displayable content.

                @type variable: netzob.Common.MMSTD.Dictionary.Variables.AbstractVariable.AbstractVariable
                @param variable: the root variable which content will be displayed.
        """
        self.dictVariable = dict()
        self.dictEntry = dict()

        self.treestore = Gtk.TreeStore(str, str)  # id of the data, description
        self.registerVariable(None, variable)
        self.view.getWidg("treeview").set_model(self.treestore)

    def registerVariable(self, rootEntry, variable):
        """registerVariable:
                Register a variable in the tree view under its root variable (Aggregate or Alternate).
                May be recursive.

                @type rootEntry: Gtk.treerow
                @param rootEntry: the root entry under which we will add this entry.
                @type variable: netzob.Common.MMSTD.Dictionary.Variables.AbstractVariable.AbstractVariable
                @param variable: the variable which will be added to the tree view representation.
        """
        if variable is None:
            return
        self.dictVariable[str(variable.getID())] = variable
        newEntry = self.treestore.append(rootEntry, [str(variable.getID()), variable.toString()])
        self.dictEntry[str(variable.getID())] = newEntry
        if variable.getVariableType() == AggregateVariable.TYPE or variable.getVariableType() == AlternateVariable.TYPE:
            if variable.getChildren() is not None:
                for child in variable.getChildren():
                    self.registerVariable(newEntry, child)
        if variable.getVariableType() == RepeatVariable.TYPE:
            if variable.getChild() is not None:
                self.registerVariable(newEntry, variable.getChild())

    def showMenu(self, treeview, event):
        """showMenu:
                Called on right click on a variable.

                @param treeview: the treeview which contains the triggering variable.
                @param event: the mouse event which called this function.
        """
        variable = None
        if event.button == 3:
            try:
                x = int(event.x)
                y = int(event.y)
                (path, treeviewColumn, x, y) = treeview.get_path_at_pos(x, y)

                # Retrieve the selected variable
                varid = None
                aniter = treeview.get_model().get_iter(path)
                if aniter:
                    if treeview.get_model().iter_is_valid(aniter):
                        varid = treeview.get_model().get_value(aniter, 0)

                        if varid is not None:
                            variable = self.dictVariable[varid]
            except:
                logging.debug(_("The user clicks on no variable."))
        else:
            # Wrong mouse click
            return

        if variable is None:
            logging.debug("Impossible to find the selected variable.")
            return

        # We display the menu for the insertion of sub-elements if its an Aggregate or an Alternative
        self.menu = Gtk.Menu()

        # We can add elements only to node variable.
        if variable.isNode():
            if variable.getVariableType() == RepeatVariable.TYPE:
                # Add an element to a repeat variable will replace the previous one.
                itemAdd = Gtk.MenuItem(_("Edit the sub-element"))
            else:
                itemAdd = Gtk.MenuItem(_("Add a sub-element"))
            itemAdd.connect("activate", VariableCreationController, self, variable, aniter, False)
            itemAdd.show()
            self.menu.append(itemAdd)

        # To edit an element.
        itemEdit = Gtk.MenuItem(_("Edit this element"))
        itemEdit.connect("activate", VariableCreationController, self, variable, aniter, True)
        itemEdit.show()

        # If we have not click on the root variable, we can move and remove it. The root variable can be edited. it is way enough.
        if variable.getID() != self.field.getVariable().getID():
            # To move an element.
            itemMove = Gtk.MenuItem(_("Move this element"))
            itemMove.connect("activate", VariableMovingController, self, variable)
            itemMove.show()
            self.menu.append(itemMove)

            # To remove an element.
            itemRemove = Gtk.MenuItem(_("Remove this element"))
            itemRemove.connect("activate", self.removeVariable, variable)
            itemRemove.show()
            self.menu.append(itemRemove)

        self.menu.append(itemEdit)
        self.menu.popup(None, None, None, None, event.button, event.time)

    def removeVariable(self, item, variable):
        """removeVariable:
                Remove a variable and its presence in the tree view.

                @type item: Gtk.Menuitem
                @param item: the menu item which calls this function.
                @type variable: netzob.Common.MMSTD.Dictionary.Variables.AbstractVariable
                @param variable: the variable that will be removed.
        """
        questionMsg = _("Click yes to confirm the removal of the variable {0}").format(variable.getName())
        md = Gtk.MessageDialog(None, Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT, Gtk.MessageType.QUESTION, Gtk.ButtonsType.YES_NO, questionMsg)
        result = md.run()
        md.destroy()
        if result == Gtk.ResponseType.YES:
            # Remove the variable from the global tree.
            father = variable.getFathers()[0]
            father.removeChildByID(variable)
            # Remove its entry.
            entry = self.dictEntry[str(variable.getID())]
            self.treestore.remove(entry)

            # Remove the variable and its entry from dictionaries.
            self.dictEntry.pop(str(variable.getID()))
            self.dictVariable.pop(str(variable.getID()))

        else:
            logging.info("The user didn't confirm the deletion of the variable {0}".format(variable.getName()))

    def editVariable(self, variable):
        """editVariable:
                Edit a variable and its representation on the tree row.

                @type variable: netzob.Common.MMSTD.Dictionary.Variables.AbstractVariable
                @param variable: the variable that will be edited.
        """
        questionMsg = _("Click yes to confirm the edition of the variable {0}").format(variable.getName())
        md = Gtk.MessageDialog(None, Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT, Gtk.MessageType.QUESTION, Gtk.ButtonsType.YES_NO, questionMsg)
        result = md.run()
        md.destroy()

        if result == Gtk.ResponseType.YES:
            pass
            # The root variable.
            if variable.getID() == self.field.getVariable().getID():
                # Edit the variable
                self.field.setVariable(variable)

                # Update its entry
                entry = self.dictEntry[variable.getID()]
                self.treestore.remove(entry)
                self.registerVariable(None, variable)
            # Other variables.
            else:
                # Edit the variable
                father = variable.getFathers()[0]
                father.editChildByID(variable)

                logging.debug("variable: {0}, fathers: {1}".format(variable.getName(), variable.getFathers()))

                # Update its entry
                entry = self.dictEntry[variable.getID()]
                self.treestore.set_value(entry, 1, variable.toString())
                self.dictVariable[variable.getID()] = variable
        else:
            logging.info("The user didn't confirm the edition of the variable {0}".format(variable.getName()))

    def createDefaultVariable_cb(self, event):
        """createDefaultVariable_cb:
                Create a default variable, which is an alternate of
                all the possible values of the field.
        """
        self.field.generateDefaultVariable(self.symbol)
        self.registerContent(self.field.getVariable())