@staticmethod
    def create_component(collection):
        """Present user with a dialog to define and add new components.

        Parameters
        ----------
        collection : A `DataCollection` to edit
        """
        # pylint: disable=W0212
        widget = CustomComponentWidget(collection)
        while True:
            widget.ui.show()
            if widget.ui.exec_() == QtGui.QDialog.Accepted:
                if len(str(widget.ui.expression.toPlainText())) == 0:
                    QtGui.QMessageBox.critical(widget.ui, "Error", "No expression set",
                                               buttons=QtGui.QMessageBox.Ok)
                elif widget._number_targets == 0:
                    QtGui.QMessageBox.critical(widget.ui, "Error", "Please specify the target dataset(s)",
                                               buttons=QtGui.QMessageBox.Ok)
                elif len(widget.ui.new_label.text()) == 0:
                    QtGui.QMessageBox.critical(widget.ui, "Error", "Please specify the new component name",
                                               buttons=QtGui.QMessageBox.Ok)
                else:
                    link = widget._create_link()
                    if link:
                        widget._add_link_to_targets(link)
                    break
            else:
                break
dataset/ETHPy150Open glue-viz/glue/glue/dialogs/custom_component/qt/widget.py/CustomComponentWidget.create_component/original