def run(self, edit, event, operationId, params={}, action=""):

      self.x = int(event["x"])
      self.y = int(event["y"])

      self.selectedTextPoint = self.view.window_to_text((self.x, self.y))
      self.selectedWordRegions = self.view.word(self.selectedTextPoint)
      self.selectedWord = self.view.substr(self.selectedWordRegions)

      self.swaggerAPI = environment.getSwaggerAPI()

      if self.swaggerAPI == None:
         return

      if operationId == None or operationId == "":
         helpers.log_error("'operationId' not provided")
         return

      self.operationId = operationId
      self.setOperationFromId()

      self.parameters = params
      self.action = action

      # Start parsing parameters
      self.expandParams()
   def on_query_completions(self, view, prefix, locations):
      # helpers.log_info("--> " + __name__ + ": " + type(self).__name__ + "." + sys._getframe().f_code.co_name)
   
      # if (not helpers.is_a_gold_view(view)) or (len(prefix) < 4):
      #    return []
   
      # api = environment.getSwaggerAPI()
   
      # fullChoiceList = api.MMBrowserAPI.MMBrowserAPI_searchEntities(q=prefix).result()
   
      # result = []
      # for item in fullChoiceList:
      #    result.append((item['label'], item['label']))

      # print(result)

      # helpers.log_info("<-- " + __name__ + ": " + type(self).__name__ + "." + sys._getframe().f_code.co_name)

      # return result

      helpers.log_info("--> " + __name__ + ": " + type(self).__name__ + "." + sys._getframe().f_code.co_name)
   
      if not helpers.is_a_gold_view(view):
         return []

      moduleName = helpers.get_module_from_view(view)
      sourceCode = helpers.get_view_content(view).replace('\n', "\\r\\n")
      
      api = environment.getSwaggerAPI()
      tSuggestBody = api.get_model("tSuggestBody")
      tImplem = api.get_model("tImplem")

      rowcol = view.rowcol(locations[0])
      lineRegion = view.line(locations[0])
      lineContent = view.substr(lineRegion)
      lineInfo = { "lineContent": lineContent, "lineNumber": rowcol[0]+1, "ColumnNumber": rowcol[1]+1 }

      implem = { "name": moduleName, "ancestor": "", "content": sourceCode }

      suggestBody = tSuggestBody(implem=implem, lineInfo=lineInfo)

      fullChoiceList = api.ModuleDefAPI.ModuleDefAPI_Suggest(name=moduleName, body=suggestBody).result()

      result = []
      for item in fullChoiceList["items"]:
         if item['insertText'] == "":
            result.append((item["label"], item["label"]))
         else:
            result.append((item["label"], item["insertText"]))

      helpers.log_info("<-- " + __name__ + ": " + type(self).__name__ + "." + sys._getframe().f_code.co_name)

      if result == []:
         flag = 0
      else:
         flag = sublime.INHIBIT_WORD_COMPLETIONS

      return (result, flag)
Exemplo n.º 3
0
def open_entity(name, entity):
   if entity['theType'] == "aClassDef" or entity['theType'] == "aModuleDef":
      api = environment.getSwaggerAPI()
      module = api.ModuleDefAPI.ModuleDefAPI_Get(name=name).result()
      open_gold_window(name=name, content=module['content'])
   else:
      view = open_window(name=name+".gold", content=json.dumps(entity, indent=3))
      view.set_syntax_file('Packages/JavaScript/JSON.tmLanguage')
      view.set_scratch(True)
Exemplo n.º 4
0
def update_readonly(view=None):
   if view == None:
      view = sublime.active_window().active_view()

   if not helpers.is_a_gold_view(view):
      return

   module_name = helpers.get_module_from_view(view)

   api = environment.getSwaggerAPI()
   status = api.ModuleDefAPI.ModuleDefAPI_entityStatus(name=module_name).result()
   view.set_read_only(not status['checkedOut'])
Exemplo n.º 5
0
def choose_scenario(callback, view=None):
   name = helpers.get_module_from_view(view)

   api = environment.getSwaggerAPI()
   fullChoiceList = api.ModuleDefAPI.ModuleDefAPI_Scenarios(name=name).result()
   
   lightChoiceList = []
   for item in fullChoiceList:
      lightChoiceList.append([item['label']])

   choiceHandler = input_handler.ChoiceInputHandler(finalcallback=callback, selectionDone=scenario_chosen, fullChoiceList=fullChoiceList, lightChoiceList=lightChoiceList)
   
   choiceHandler.choice_input()
   def classname_chosen(self, name):
      self.modulename = name

      moduleImplem = "; " + self.modulename + "(Def Version:1) (Implem Version:1)" + "\n\n" + "module " + self.modulename + "\n"
      moduleImplem = moduleImplem.replace('\n', "\\r\\n")

      api = environment.getSwaggerAPI()
      implemModel = api.get_model("tImplem")
      implem = implemModel(content=moduleImplem, name=self.modulename, ancestorname="")

      res = api.ModuleDefAPI.ModuleDefAPI_Create(body=implem).result()

      res = api.ModuleDefAPI.ModuleDefAPI_Get(name=self.modulename).result()
      newView = actions.open_gold_window(res['name'], res['content'])
Exemplo n.º 7
0
def searchEntity(callback, name):
   api = environment.getSwaggerAPI()
   fullChoiceList = api.MMBrowserAPI.MMBrowserAPI_searchEntities(q=name).result()

   lightChoiceList = []
   for item in fullChoiceList:
      if item['ownerName'] == "nil" or item['ownerName'] == "":
         lightChoiceList.append([item['label'] + " : " + item['description']])
      else:
         lightChoiceList.append([item['label'] + " : " + item['description'], item['ownerName'] ])

   choiceHandler = input_handler.ChoiceInputHandler(finalcallback=callback, selectionDone=entityChosen, fullChoiceList=fullChoiceList, lightChoiceList=lightChoiceList)

   choiceHandler.choice_input()
Exemplo n.º 8
0
def on_classname_input_done(inputHandler, text):
   api = environment.getSwaggerAPI()

   fullChoiceList = api.MMBrowserAPI.MMBrowserAPI_searchEntities(q=text, _class="true", _module="true").result()
   
   lightChoiceList = []
   for item in fullChoiceList:
      if item['ownerName'] == "nil" or item['ownerName'] == "":
         lightChoiceList.append([item['label'] + " : " + item['description']])
      else:
         lightChoiceList.append([item['label'] + " : " + item['description'], item['ownerName'] ])

   choiceHandler = input_handler.ChoiceInputHandler(finalcallback=inputHandler.finalcallback, selectionDone=on_class_chosen, fullChoiceList=fullChoiceList, lightChoiceList=lightChoiceList)

   choiceHandler.choice_input()
   def run(self, operationId, params={}, action=""):
      self.swaggerAPI = environment.getSwaggerAPI()
      if self.swaggerAPI == None:
         return

      if operationId == None or operationId == "":
         helpers.log_error("'operationId' not provided")
         return

      self.operationId = operationId
      self.setOperationFromId()

      self.parameters = params
      self.action = action

      # Start parsing parameters
      self.expandParams()
   def run(self, edit, event=None, refresh=True):
      api = environment.getSwaggerAPI()

      implemModel = api.get_model("tImplem")
      content = helpers.get_view_content(self.view)
      moduleName = helpers.get_module_from_view(self.view)

      content = content.replace('\n', "\\r\\n")

      implem = implemModel(content=content, name=moduleName, ancestor="")

      res = api.ModuleDefAPI.ModuleDefAPI_Modify(name=moduleName, body=implem).result()

      actions.update_error_view(res['errors'], self.view)

      if len(res['errors']) == 0 and refresh:
         actions.update_content(self.view, res['content'])
   def run(self, edit, event=None):
      moduleName = helpers.get_module_from_view(self.view)

      if not helpers.is_entity_checkedout(moduleName):
         return

      x = int(event["x"])
      y = int(event["y"])

      word = helpers.get_word_at(x, y, self.view)
      if word == None or word == "":
         return

      classname = helpers.get_module_from_view(self.view)

      api = environment.getSwaggerAPI()

      res = api.Runner.Runner_RunClass(className=classname).result()
   def run(self):
      api = environment.getSwaggerAPI()
      print("Swag! ", api)
      # res = api.ModuleDefAPI.classOrModule(name="aRedgisTest").result()
      # print(res)
      # api.get_model('classOrModule')
      # api.get_model('ModuleDefAPI')

      print("descendants: ", api.ModuleDefAPI.ModuleDefAPI_GetDescendants(name="aFullObject").result())

      print("Get: ", api.ModuleDefAPI.ModuleDefAPI_Get(name="aRedgisTest").result())

      print("api", locals()['api'])

      moduleAPI = getattr(locals()['api'], 'ModuleDefAPI')
      print("attr:", moduleAPI)

      method = getattr(moduleAPI, 'ModuleDefAPI_Get')
      print(method)

      kwargs = {'name': "aRedgisTest"}
      print(method(**kwargs).result())
 def run(self, edit):
    api = environment.getSwaggerAPI()
    name = helpers.get_module_from_view(self.view)
    res = api.ModuleDefAPI.ModuleDefAPI_Deliver(name=name).result()
    actions.update_readonly(self.view)
 def inputResultCallback(self, scenario):
    api = environment.getSwaggerAPI()
    moduleName = helpers.get_module_from_view(self.view)
    res = api.ModuleDefAPI.ModuleDefAPI_GetMyScenario(name=moduleName, scenarioName=scenario['label']).result()
   def run(self, edit, event=None, refresh=True):
      api = environment.getSwaggerAPI()

      moduleName = helpers.get_module_from_view(self.view)
      inputs.choose_scenario(self.inputResultCallback, view=self.view)
Exemplo n.º 16
0
def is_entity_checkedout(entity_name):
   api = environment.getSwaggerAPI()
   res = api.ModuleDefAPI.ModuleDefAPI_entityStatus(name=entity_name).result()
   return res['checkedOut']