def new_dataset(self, key='dataset', undolist=None):
        """
        Add a new Dataset object to the Project.

        The `data` field contains a nearly empty numarray (1 row, 2
        columns, all zero).

        If no key is given, then one is created.  If the key already
        exists, then the method assures that it is unique within the
        Project.

        Returns newly created Dataset.
        """
        if undolist is None:
            undolist = self.journal
        
        key = pdict.unique_key(self.datasets, key)
        ds = Dataset()
        pdict.setitem(self.datasets, key, ds)
        ds.data = Table(nrows=1,ncols=2)
        ds.data.column(0).designation = 'X'
        ds.data.column(1).designation = 'Y'        
        self.sig_emit("notify::datasets")

        ui = UndoInfo(self.remove_objects, [ds], False)
        ui.describe("Create new Dataset '%s'" % key)
        undolist.append(ui)
        
        return ds
    def rename_plot(self, xn_plot, new_key, undolist=None):
        " Analogon to `rename_dataset`. "
        if undolist is None:
            undolist = self.journal

        plotlist = [plot for plot in self.plots]
        plot = self.get_plot(xn_plot)
        plotlist.remove(plot)
        new_key = pdict.unique_key(plotlist, new_key)

        ui = UndoInfo(self.rename_plot, plot, plot.key)
        ui.describe("Rename Plot")

        try:
            plot.key = new_key
        except ValueError:
            globals.app.error_msg(MSG['invalid_key'] % new_key)
            return

        undolist.append(ui)
        return plot
    def rename_dataset(self, xn_dataset, new_key, undolist=None):
        """
        Rename a Dataset and make sure that its key is unique.
        The name might be modified so if the key is important to you,
        you might want to check it afterwards.
        Returns the Dataset.
        """
        if undolist is None:
            undolist = self.journal

        dataset = self.get_dataset(xn_dataset)

        dslist = [ds for ds in self.datasets]
        dslist.remove(dataset)
        new_key = pdict.unique_key(dslist, new_key)

        ui = UndoInfo(self.rename_dataset, dataset, dataset.key)
        ui.describe("Rename Dataset")

        try:
            dataset.key = new_key
        except ValueError, msg:
            self.app.error_msg(DC['invalid_key'] % new_key)            
            return