本文整理汇总了Python中ninja_ide.gui.ide.IDE.get_service方法的典型用法代码示例。如果您正苦于以下问题:Python IDE.get_service方法的具体用法?Python IDE.get_service怎么用?Python IDE.get_service使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ninja_ide.gui.ide.IDE
的用法示例。
在下文中一共展示了IDE.get_service方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: install
# 需要导入模块: from ninja_ide.gui.ide import IDE [as 别名]
# 或者: from ninja_ide.gui.ide.IDE import get_service [as 别名]
def install(self):
ide = IDE.get_service('ide')
ide.place_me_on("explorer_container", self, "lateral")
#Searching the Preferences
self.tree_projects = None
self._treeSymbols = None
if settings.SHOW_SYMBOLS_LIST:
self.add_tab_symbols()
self._inspector = None
if settings.SHOW_WEB_INSPECTOR and settings.WEBINSPECTOR_SUPPORTED:
self.add_tab_inspector()
self._listErrors = None
if settings.SHOW_ERRORS_LIST:
self.add_tab_errors()
self._listMigration = None
if settings.SHOW_MIGRATION_LIST:
self.add_tab_migration()
if self.count() == 0:
central_container = IDE.get_service("central_container")
central_container.change_explorer_visibility(force_hide=True)
ui_tools.install_shortcuts(self, actions.ACTIONS, ide)
for each_tab in self.__tabs:
if hasattr(each_tab, "install"):
each_tab.install()
示例2: find
# 需要导入模块: from ninja_ide.gui.ide import IDE [as 别名]
# 或者: from ninja_ide.gui.ide.IDE import get_service [as 别名]
def find(self, backward=False, forward=False, rehighlight=True):
"""Collect flags and execute search in the editor"""
main_container = IDE.get_service("main_container")
editor = main_container.get_current_editor()
if editor is None:
return
cs, wo, highlight = self.search_flags
index, matches = 0, 0
found = editor.find_match(self.search_text, cs, wo, backward, forward)
if found:
if rehighlight:
editor.clear_found_results()
index, matches = editor.highlight_found_results(
self.search_text, cs, wo)
else:
editor.clear_found_results()
if matches == 0 and found:
index, matches = editor._get_find_index_results(
self.search_text, cs, wo)
matches = len(matches)
if index == 1:
ide = IDE.get_service("ide")
ide.show_message(translations.TR_SEARCH_FROM_TOP)
self._line_search.counter.update_count(
index, matches, len(self.search_text) > 0)
示例3: _add_file_to_project
# 需要导入模块: from ninja_ide.gui.ide import IDE [as 别名]
# 或者: from ninja_ide.gui.ide.IDE import get_service [as 别名]
def _add_file_to_project(self, path):
"""Add the file for 'path' in the project the user choose here."""
if self._active_project:
pathProject = [self._active_project.project]
addToProject = add_to_project.AddToProject(pathProject, self)
addToProject.exec_()
if not addToProject.pathSelected:
return
main_container = IDE.get_service('main_container')
if not main_container:
return
editorWidget = main_container.get_current_editor()
if not editorWidget.file_path:
name = QInputDialog.getText(None,
translations.TR_ADD_FILE_TO_PROJECT,
translations.TR_FILENAME + ": ")[0]
if not name:
QMessageBox.information(
self,
translations.TR_INVALID_FILENAME,
translations.TR_INVALID_FILENAME_ENTER_A_FILENAME)
return
else:
name = file_manager.get_basename(editorWidget.file_path)
new_path = file_manager.create_path(addToProject.pathSelected, name)
ide_srv = IDE.get_service("ide")
old_file = ide_srv.get_or_create_nfile(path)
new_file = old_file.save(editorWidget.get_text(), new_path)
#FIXME: Make this file replace the original in the open tab
else:
pass
示例4: _add_file_to_project
# 需要导入模块: from ninja_ide.gui.ide import IDE [as 别名]
# 或者: from ninja_ide.gui.ide.IDE import get_service [as 别名]
def _add_file_to_project(self, path):
"""Add the file for 'path' in the project the user choose here."""
if self._active_project:
pathProject = [self._active_project.project]
addToProject = add_to_project.AddToProject(pathProject, self)
addToProject.exec_()
if not addToProject.pathSelected:
return
main_container = IDE.get_service('main_container')
if not main_container:
return
editorWidget = main_container.get_current_editor()
if not editorWidget.file_path:
name = QInputDialog.getText(None,
self.tr("Add File To Project"), self.tr("File Name:"))[0]
if not name:
QMessageBox.information(self, self.tr("Invalid Name"),
self.tr("The file name is empty, please enter a name"))
return
else:
name = file_manager.get_basename(editorWidget.file_path)
new_path = file_manager.create_path(addToProject.pathSelected, name)
ide_srv = IDE.get_service("ide")
old_file, ide_srv.get_or_create_nfile(path)
new_file = old_file.save(editorWidget.get_text(), path)
#FIXME: Make this file replace the original in the open tab
else:
pass
示例5: _rename_file
# 需要导入模块: from ninja_ide.gui.ide import IDE [as 别名]
# 或者: from ninja_ide.gui.ide.IDE import get_service [as 别名]
def _rename_file(self):
path = self.model().filePath(self.currentIndex())
name = file_manager.get_basename(path)
new_name, ok = QInputDialog.getText(
self, translations.TR_RENAME_FILE,
translations.TR_ENTER_NEW_FILENAME,
text=name)
if ok and new_name.strip():
filename = file_manager.create_path(
file_manager.get_folder(path), new_name)
if path == filename:
return
ninjaide = IDE.get_service("ide")
print(ninjaide.filesystem.get_files())
current_nfile = ninjaide.get_or_create_nfile(path)
editable = ninjaide.get_editable(nfile=current_nfile)
current_nfile.move(filename)
if editable is not None:
main_container = IDE.get_service("main_container")
main_container.combo_area.bar.update_item_text(
editable, new_name)
tree = ninjaide.filesystem.get_files()
# FIXME: this is bad
tree[filename] = tree.pop(path)
print(ninjaide.filesystem.get_files())
示例6: __init__
# 需要导入模块: from ninja_ide.gui.ide import IDE [as 别名]
# 或者: from ninja_ide.gui.ide.IDE import get_service [as 别名]
def __init__(self, parent):
super(FindInFilesWidget, self).__init__(parent)
self._main_container = IDE.get_service('main_container')
self._explorer_container = IDE.get_service('explorer')
self._result_widget = FindInFilesResult()
self._open_find_button = QPushButton(translations.TR_FIND + "!")
self._stop_button = QPushButton(translations.TR_STOP + "!")
self._clear_button = QPushButton(translations.TR_CLEAR + "!")
self._replace_button = QPushButton(translations.TR_REPLACE)
self._find_widget = FindInFilesDialog(self._result_widget, self)
self._error_label = QLabel(translations.TR_NO_RESULTS)
self._error_label.setVisible(False)
#Replace Area
self.replace_widget = QWidget()
hbox_replace = QHBoxLayout(self.replace_widget)
hbox_replace.setContentsMargins(0, 0, 0, 0)
self.lbl_replace = QLabel(translations.TR_REPLACE_RESULTS_WITH)
self.lbl_replace.setTextFormat(Qt.PlainText)
self.replace_edit = QLineEdit()
hbox_replace.addWidget(self.lbl_replace)
hbox_replace.addWidget(self.replace_edit)
self.replace_widget.setVisible(False)
#Main Layout
main_hbox = QHBoxLayout(self)
#Result Layout
tree_vbox = QVBoxLayout()
tree_vbox.addWidget(self._result_widget)
tree_vbox.addWidget(self._error_label)
tree_vbox.addWidget(self.replace_widget)
main_hbox.addLayout(tree_vbox)
#Buttons Layout
vbox = QVBoxLayout()
vbox.addWidget(self._open_find_button)
vbox.addWidget(self._stop_button)
vbox.addWidget(self._clear_button)
vbox.addSpacerItem(
QSpacerItem(0, 50, QSizePolicy.Fixed, QSizePolicy.Expanding))
vbox.addWidget(self._replace_button)
main_hbox.addLayout(vbox)
self._open_find_button.setFocus()
#signals
self.connect(self._open_find_button, SIGNAL("clicked()"), self.open)
self.connect(self._stop_button, SIGNAL("clicked()"), self._find_stop)
self.connect(self._clear_button, SIGNAL("clicked()"),
self._clear_results)
self.connect(self._result_widget,
SIGNAL("itemActivated(QTreeWidgetItem *, int)"),
self._go_to)
self.connect(self._result_widget,
SIGNAL("itemClicked(QTreeWidgetItem *, int)"),
self._go_to)
self.connect(self._find_widget, SIGNAL("finished()"),
self._find_finished)
self.connect(self._find_widget, SIGNAL("findStarted()"),
self._find_started)
self.connect(self._replace_button, SIGNAL("clicked()"),
self._replace_results)
示例7: _replace
# 需要导入模块: from ninja_ide.gui.ide import IDE [as 别名]
# 或者: from ninja_ide.gui.ide.IDE import get_service [as 别名]
def _replace(self):
"""Replace one occurrence of the word"""
status_search = IDE.get_service("status_search")
cs, wo, highlight = status_search.search_flags
main_container = IDE.get_service("main_container")
editor_widget = main_container.get_current_editor()
editor_widget.replace_match(
status_search.search_text, self._line_replace.text(), cs, wo)
示例8: _replace_all
# 需要导入模块: from ninja_ide.gui.ide import IDE [as 别名]
# 或者: from ninja_ide.gui.ide.IDE import get_service [as 别名]
def _replace_all(self, selected=False):
"""Replace all the occurrences of the word"""
status_search = IDE.get_service("status_search")
cs, wo, highlight = status_search.search_flags
main_container = IDE.get_service("main_container")
editor_widget = main_container.get_current_editor()
editor_widget.replace_all(
status_search.search_text, self._line_replace.text(), cs, wo)
editor_widget.extra_selections.remove("find")
示例9: replace_all
# 需要导入模块: from ninja_ide.gui.ide import IDE [as 别名]
# 或者: from ninja_ide.gui.ide.IDE import get_service [as 别名]
def replace_all(self, selected=False):
"""Replace all the occurrences of the word."""
status_search = IDE.get_service("status_search")
main_container = IDE.get_service("main_container")
editor = None
if main_container:
editor = main_container.get_current_editor()
if editor:
editor.replace_match(status_search.search_text,
self._lineReplace.text(), True,
selected)
示例10: replace
# 需要导入模块: from ninja_ide.gui.ide import IDE [as 别名]
# 或者: from ninja_ide.gui.ide.IDE import get_service [as 别名]
def replace(self):
"""Replace one occurrence of the word."""
status_search = IDE.get_service("status_search")
main_container = IDE.get_service("main_container")
editor = None
if main_container:
editor = main_container.get_current_editor()
if editor:
editor.replace_match(status_search.search_text,
self._lineReplace.text())
status_search.find()
示例11: _open_project_folder
# 需要导入模块: from ninja_ide.gui.ide import IDE [as 别名]
# 或者: from ninja_ide.gui.ide.IDE import get_service [as 别名]
def _open_project_folder(self, folderName):
ninjaide = IDE.get_service("ide")
project = NProject(folderName)
qfsm = ninjaide.filesystem.open_project(project)
if qfsm:
self.add_project(project)
self.emit(SIGNAL("updateLocator()"))
self.save_recent_projects(folderName)
main_container = IDE.get_service('main_container')
if main_container:
main_container.show_editor_area()
示例12: find_occurrences
# 需要导入模块: from ninja_ide.gui.ide import IDE [as 别名]
# 或者: from ninja_ide.gui.ide.IDE import get_service [as 别名]
def find_occurrences(self, word):
self._find_widget.pattern_line_edit.setText(word)
ide = IDE.get_service('ide')
main_container = IDE.get_service('main_container')
editorWidget = main_container.get_current_editor()
nproject = ide.get_project_for_file(editorWidget.ID)
if nproject is None:
nproject = ide.get_current_project()
self._find_widget.dir_combo.clear()
self._find_widget.dir_combo.addItem(nproject.path)
self._find_widget.case_checkbox.setChecked(True)
self._find_widget._find_in_files()
示例13: _set_focus_to_editor
# 需要导入模块: from ninja_ide.gui.ide import IDE [as 别名]
# 或者: from ninja_ide.gui.ide.IDE import get_service [as 别名]
def _set_focus_to_editor(self):
status_bar = IDE.get_service("status_bar")
tools_doock = IDE.get_service("tools_dock")
editor_widget = self.get_current_editor()
if status_bar.isVisible() and tools_doock.isVisible():
status_bar.hide_status_bar()
elif tools_doock.isVisible():
tools_doock._hide()
elif status_bar.isVisible():
status_bar.hide_status_bar()
if editor_widget is not None:
editor_widget.extra_selections.remove("find")
editor_widget.scrollbar().remove_marker("find")
示例14: _add_new_file
# 需要导入模块: from ninja_ide.gui.ide import IDE [as 别名]
# 或者: from ninja_ide.gui.ide.IDE import get_service [as 别名]
def _add_new_file(self, path=''):
if not path:
path = self.model().filePath(self.currentIndex())
result = QInputDialog.getText(self, translations.TR_NEW_FILE,
translations.TR_ENTER_NEW_FILENAME + ": ")
fileName = result[0]
if result[1] and fileName.strip() != '':
fileName = os.path.join(path, fileName)
ide_srv = IDE.get_service('ide')
current_nfile = ide_srv.get_or_create_nfile(fileName)
current_nfile.create()
main_container = IDE.get_service('main_container')
if main_container:
main_container.open_file(fileName)
示例15: _add_new_file
# 需要导入模块: from ninja_ide.gui.ide import IDE [as 别名]
# 或者: from ninja_ide.gui.ide.IDE import get_service [as 别名]
def _add_new_file(self, path=''):
if not path:
path = self.model().filePath(self.currentIndex())
result = QInputDialog.getText(self, self.tr("New File"),
self.tr("Enter the File Name:"))
fileName = result[0]
if result[1] and fileName.strip() != '':
fileName = os.path.join(path, fileName)
ide_srv = IDE.get_service('ide')
current_nfile = ide_srv.get_or_create_nfile(fileName)
current_nfile.create()
main_container = IDE.get_service('main_container')
if main_container:
main_container.open_file(fileName)