def applyChanges(self): """ Redefined from *EditionWidget* class. """ # pragma pylint: disable=no-member result = False var = self.variable edit = var is not None name = self._variableName() expr = self._variableExpression() comment = self._variableComment() if edit: try: with auto_dupl_on(self.stage.model.current_case): var.update(expr, name) if comment: var.comment = comment elif var.comment is not None: var.comment.delete() result = True except CyclicDependencyError: message = translate("AsterStudy", "Cyclic dependency detected") Q.QMessageBox.critical(self, "AsterStudy", message) result = False else: try: with auto_dupl_on(self.stage.model.current_case): if self.stage is not None: var = self.stage.add_variable(name, expr) if comment: var.comment = comment except StandardError: var = None result = var is not None if self.controllerOwner() is None: if result: if edit: op_name = translate("VariablePanel", "Edit variable") else: op_name = translate("VariablePanel", "Create variable") self.astergui().study().commit(op_name) self.astergui().update(autoSelect=var, context=Context.DataSettings) else: self.astergui().study().revert() self._updateState()
def applyChanges(self): """ Redefined from *EditionWidget* class. """ command = self._selected() if command: cmdobj = None selected = self.astergui().selected(Context.DataSettings) stage = self.astergui().study().node(selected[0]) if get_node_type(stage) not in (NodeType.Stage,): stage = stage.stage if stage is not None: try: cmdobj = stage.add_command(command) except Exception: # pragma pylint: disable=broad-except cmdobj = None if cmdobj is not None: with auto_dupl_on(self.astergui().study().activeCase): self.astergui().study().commit(translate("AsterStudy", "Add command")) self.astergui().update(autoSelect=cmdobj, context=Context.DataSettings) msg = translate("AsterStudy", "Command with type '{}' " "successfully added") msg = msg.format(command) self.astergui().showMessage(msg) else: self.astergui().study().revert()
def embedded(self, embedded): """Setter for 'embedded' property.""" assert len(self.entries) > 0 for entry in self.entries: stage = entry.stage with auto_dupl_on(stage.parent_case): info = stage.handle2info[self.unit] info.embedded = embedded
def attr(self, attr): """Setter for 'attr' property.""" assert len(self.entries) > 0 for entry in self.entries: stage = entry.stage with auto_dupl_on(stage.parent_case): info = stage.handle2info[self.unit] info.attr = attr
def filename(self, filename): """Setter for 'filename' property.""" assert len(self.entries) > 0 for entry in self.entries: stage = entry.stage with auto_dupl_on(stage.parent_case): info = stage.handle2info[self.unit] info.filename = filename
def applyChanges(self): """ Redefined from *EditionWidget* class. """ with auto_dupl_on(self.astergui().study().activeCase): self.prev_state = self.editor.text() self.stage.set_text(self.prev_state) msg = translate("StageTextEditor", "Edit stage") self.astergui().study().commit(msg) self.astergui().update()
def store(self): """ Save data from all parameter views. """ cmd = self.command() if cmd is not None: with auto_dupl_on(self.astergui().study().activeCase): cmd.rename(self._name.text()) wid = self._viewByPath(ParameterPath(cmd)) if wid is not None: cmd.init(wid.view().itemValue())
def unit(self, unit): """Setter for 'unit' property.""" assert len(self.entries) > 0 for entry in self.entries: stage = entry.stage with auto_dupl_on(stage.parent_case): info = None if entry.unit in stage.handle2info: info = stage.handle2info.pop(entry.unit) else: info = Info(stage) stage.handle2info[unit] = info entry.unit = unit
def applyChanges(self): """ Redefined from *EditionWidget* class. """ with auto_dupl_on(self.astergui().study().activeCase): self._prev_state = self.editor.toPlainText() if self.node is not None: node_type = get_node_type(self.node) if node_type in (NodeType.Command, NodeType.Variable): if not self._prev_state: self.node.comment.delete() else: self.node.comment = self._prev_state elif node_type in (NodeType.Comment, ): self.node.content = self._prev_state elif node_type in (NodeType.Case, ): self.node.description = self._prev_state if self.controllerOwner() is None: self.astergui().study().commit(self.controllerName()) self.astergui().update()