Esempio n. 1
0
 def SetRuby(self, e=None, *, ruby_=None):
     slc = self.editor.GetSelection()
     if slc[0] == slc[1]:
         MessageBox("選択されたテキストがありません", "エラー", style=OK)
         return
     if not ruby_:
         dialog = TextEntryDialog(None, "振り仮名を入力してください", "振り仮名を設定")
         if dialog.ShowModal() == ID_CANCEL:
             return
         dialog.Destroy()
         res = dialog.GetValue()
         if not res:
             MessageBox("空欄にはできません", "エラー", style=OK)
             return
     else:
         res = ruby_
     tmp = self.editor.GetValue()
     if linesep == "\r\n":
         newlines = tmp[:slc[0]].count("\n")
     else:
         newlines = 0
     slc = slc[0] - newlines, slc[1] - newlines
     tmp = tmp[:slc[0]], tmp[slc[0]:slc[1]], tmp[slc[1]:]
     if linesep in tmp[1]:
         MessageBox("改行を挟むことはできません。", "エラー", style=OK)
     self.editor.SetValue(tmp[0] + f"|{tmp[1]}《{res}》" + tmp[2])
     self.editor.SetInsertionPoint(slc[1] + newlines + len(res) + 3)
Esempio n. 2
0
 def OnLeftDClick(self, event):
     """
     """
     dlg = TextEntryDialog(None, _("Message"), _("Enter message"), self._pyutObject.getInstanceName(), OK | CANCEL | CENTRE)
     if dlg.ShowModal() == ID_OK:
         self._pyutObject.setInstanceName(dlg.GetValue())
     dlg.Destroy()
Esempio n. 3
0
async def opendialog():
    """ This functions demonstrate the use of 'AsyncShowDialog' to Show a 
        any wx.Dialog asynchronously, and wait for the result.
    """
    dlg = TextEntryDialog(None, "Please enter some text:")
    return_code = await AsyncShowDialog(dlg)
    print ("The ReturnCode is %s and you entered '%s'" % (return_code, dlg.GetValue()))
    app = wx.App.Get()
    app.ExitMainLoop()
Esempio n. 4
0
 def __create_test(self, page):
     modal = TextEntryDialog(self, u'Enter test case name',
                             u'Create new test case')
     if modal.ShowModal() == ID_OK:
         test_case_name = modal.GetValue()
         if StringUtils.is_test_case_name_correct(test_case_name):
             page.create_new_test_case(test_case_name)
         else:
             show_dialog_bad_name(self, test_case_name, 'test_search')
Esempio n. 5
0
 def __create_method(self, page):
     modal = TextEntryDialog(self, u'Enter method name', u'Create method')
     if modal.ShowModal() == ID_OK:
         method_name = modal.GetValue()
         if StringUtils.is_method_name_correct(method_name):
             page.create_method(method_name)
         else:
             show_dialog_bad_name(self, method_name, 'search', 'login',
                                  'fill_data')
Esempio n. 6
0
    def OnLeftDClick(self, event):
        """
        Callback for left double clicks.

        """
        dlg = TextEntryDialog(None, _("Message"), _("Enter message"),
                              self._pyutSDMessage.getMessage(),
                              OK | CANCEL | CENTRE)
        if dlg.ShowModal() == ID_OK:
            self._pyutSDMessage.setMessage(dlg.GetValue())
        dlg.Destroy()
Esempio n. 7
0
 def Post(self, e):
     if len(self.editor.GetValue()) < 10:
         MessageBox("投稿するためには10文字以上必要です。", "エラー", style=OK)
         return
     dialog = TextEntryDialog(None, "小説のタイトルを設定してください", "小説タイトルを設定")
     dialog.ShowModal()
     dialog.Destroy()
     try:
         self.stat.SetStatusText("投稿中...", 1)
         send(dialog.GetValue(), self.editor.GetValue(), load_config(),
              self._sent)
     except ValueError as err:
         MessageBox(str(err), "エラー", style=OK)
         return
     except Canceled:
         return
Esempio n. 8
0
def load_config():
    if not exists(config_path):
        config = {"user": {"password": "", "mailaddr": ""}, "post-to": ""}
        dialog = TextEntryDialog(None, "メールアドレスを入力してください。", "投稿元アドレスを設定")
        if dialog.ShowModal() == ID_CANCEL:
            raise Canceled()
        dialog.Destroy()
        res = dialog.GetValue()
        if not res:
            raise ValueError("空欄にはできません。")
        config["user"]["mailaddr"] = res

        dialog = TextEntryDialog(None, "パスワードを入力してください。", "投稿元アドレスのパスワードを設定")
        if dialog.ShowModal() == ID_CANCEL:
            raise Canceled()
        dialog.Destroy()
        res = dialog.GetValue()
        if not res:
            raise ValueError("空欄にはできません。")
        config["user"]["password"] = res

        dialog = TextEntryDialog(None, "投稿先メールアドレスを入力してください。", "投稿先アドレスを設定")
        if dialog.ShowModal() == ID_CANCEL:
            raise Canceled()
        dialog.Destroy()
        res = dialog.GetValue()
        if not res:
            raise ValueError("空欄にはできません。")
        config["post-to"] = res

        if not exists(default_wd):
            makedirs(default_wd)
        with open(config_path, 'w') as f:
            dump(config, f)
    else:
        with open(config_path) as f:
            config = load(f)
    return config
Esempio n. 9
0
    def editObject(self, x, y):
        """
        Edit the object at x, y.
        """
        umlFrame = self._fileHandling.getCurrentFrame()
        if umlFrame is None:
            return
        #
        # TODO I don't like in-line imports but moving them to top file causes a cyclic dependency error
        #
        from org.pyut.ogl.OglClass import OglClass
        from org.pyut.ogl.OglNote import OglNote
        from org.pyut.ogl.OglUseCase import OglUseCase
        from org.pyut.ogl.OglActor import OglActor
        from org.pyut.ogl.OglAssociation import OglAssociation
        from org.pyut.ogl.OglInterface import OglInterface

        diagramShape = umlFrame.FindShape(x, y)

        if diagramShape is None:
            return

        if isinstance(diagramShape, OglClass):
            pyutObject = diagramShape.getPyutObject()
            self.classEditor(pyutObject)
            self.autoResize(diagramShape)
        elif isinstance(diagramShape, OglInterface2):

            self.logger.info(f'Double clicked on lollipop')
            lollipop: OglInterface2 = cast(OglInterface2, diagramShape)
            pyutInterface: PyutInterface = lollipop.pyutInterface
            with DlgEditInterface(umlFrame, ID_ANY, pyutInterface) as dlg:
                if dlg.ShowModal() == OK:
                    self.logger.info(f'model: {pyutInterface}')
                else:
                    self.logger.info(f'Cancelled')

        elif isinstance(diagramShape, OglNote):
            pyutObject = diagramShape.getPyutObject()
            dlg = DlgEditNote(umlFrame, -1, pyutObject)
            dlg.Destroy()
        elif isinstance(diagramShape, OglUseCase):
            pyutObject = diagramShape.getPyutObject()
            dlg = DlgEditUseCase(umlFrame, -1, pyutObject)
            dlg.Destroy()
        elif isinstance(diagramShape, OglActor):
            pyutObject = diagramShape.getPyutObject()
            dlg = TextEntryDialog(umlFrame, "Actor name", "Enter actor name",
                                  pyutObject.getName(), OK | CANCEL | CENTRE)
            if dlg.ShowModal() == ID_OK:
                pyutObject.setName(dlg.GetValue())
            dlg.Destroy()
        elif isinstance(diagramShape, OglAssociation):
            dlg = DlgEditLink(None, -1, diagramShape.getPyutObject())
            dlg.ShowModal()
            rep = dlg.getReturnAction()
            dlg.Destroy()
            if rep == -1:  # destroy link
                diagramShape.Detach()
        elif isinstance(diagramShape, OglInterface):
            dlg = DlgEditLink(None, -1, diagramShape.getPyutObject())
            dlg.ShowModal()
            rep = dlg.getReturnAction()
            dlg.Destroy()
            if rep == -1:  # destroy link
                diagramShape.Detach()

        umlFrame.Refresh()
Esempio n. 10
0
    def doAction(self, x: float, y: float):
        """
        Do the current action at coordinates x, y.

        Args:
            x: x coord where the action must take place
            y: y coord where the action must take place
        """
        self.logger.debug(
            f'doAction: {self._currentAction}  ACTION_SELECTOR: {ACTION_SELECTOR}'
        )
        umlFrame = self._fileHandling.getCurrentFrame()
        if umlFrame is None:
            return
        self.resetStatusText()
        if self._currentAction == ACTION_SELECTOR:
            return SKIP_EVENT
        elif self._currentAction == ACTION_NEW_CLASS:
            from org.pyut.commands.CreateOglClassCommand import CreateOglClassCommand
            from org.pyut.commands.CommandGroup import CommandGroup
            cmd = CreateOglClassCommand(x, y, True)
            group = CommandGroup("Create class")
            group.addCommand(cmd)
            umlFrame.getHistory().addCommandGroup(group)
            umlFrame.getHistory().execute()

            if not self._currentActionPersistent:
                self._currentAction = ACTION_SELECTOR
                self.selectTool(self._tools[0])
        elif self._currentAction == ACTION_NEW_NOTE:
            pyutNote = umlFrame.createNewNote(x, y)
            if not self._currentActionPersistent:
                self._currentAction = ACTION_SELECTOR
                self.selectTool(self._tools[0])
            dlg = DlgEditNote(umlFrame, -1, pyutNote)
            dlg.Destroy()
            umlFrame.Refresh()
        elif self._currentAction == ACTION_NEW_ACTOR:
            pyutActor = umlFrame.createNewActor(x, y)
            if not self._currentActionPersistent:
                self._currentAction = ACTION_SELECTOR
                self.selectTool(self._tools[0])
            dlg = TextEntryDialog(umlFrame, "Actor name", "Enter actor name",
                                  pyutActor.getName(), OK | CANCEL | CENTRE)

            if dlg.ShowModal() == ID_OK:
                pyutActor.setName(dlg.GetValue())
            dlg.Destroy()
            umlFrame.Refresh()
        elif self._currentAction == ACTION_NEW_USECASE:
            pyutUseCase = umlFrame.createNewUseCase(x, y)
            if not self._currentActionPersistent:
                self._currentAction = ACTION_SELECTOR
                self.selectTool(self._tools[0])
            dlg = DlgEditUseCase(umlFrame, -1, pyutUseCase)
            dlg.Destroy()
            umlFrame.Refresh()
        elif self._currentAction == ACTION_NEW_SD_INSTANCE:
            try:
                from org.pyut.ui.UmlSequenceDiagramsFrame import UmlSequenceDiagramsFrame
                if not isinstance(umlFrame, UmlSequenceDiagramsFrame):
                    PyutUtils.displayError(
                        _("A SD INSTANCE can't be added to a class diagram. You must create a sequence diagram."
                          ))
                    return
                instance = umlFrame.createNewSDInstance(x, y)
                if not self._currentActionPersistent:
                    self._currentAction = ACTION_SELECTOR
                    self.selectTool(self._tools[0])

                dlg = TextEntryDialog(umlFrame, "Instance name",
                                      "Enter instance name",
                                      instance.getInstanceName(),
                                      OK | CANCEL | CENTRE)

                if dlg.ShowModal() == ID_OK:
                    instance.setInstanceName(dlg.GetValue())
                dlg.Destroy()
                umlFrame.Refresh()
            except (ValueError, Exception) as e:
                PyutUtils.displayError(
                    _(f"An error occurred while trying to do this action {e}"))
                umlFrame.Refresh()
        elif self._currentAction == ACTION_ZOOM_IN:
            return SKIP_EVENT
        elif self._currentAction == ACTION_ZOOM_OUT:
            umlFrame.DoZoomOut(x, y)
            umlFrame.Refresh()
            self.updateTitle()
        else:
            return SKIP_EVENT
        return EVENT_PROCESSED