本文整理汇总了Java中com.intellij.openapi.components.ServiceManager类的典型用法代码示例。如果您正苦于以下问题:Java ServiceManager类的具体用法?Java ServiceManager怎么用?Java ServiceManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ServiceManager类属于com.intellij.openapi.components包,在下文中一共展示了ServiceManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: perform
import com.intellij.openapi.components.ServiceManager; //导入依赖的package包/类
@Override
public void perform(Project project, MavenEmbeddersManager mavenEmbeddersManager,
MavenConsole mavenConsole, MavenProgressIndicator mavenProgressIndicator) {
debug(() -> log.debug(
"Project imported successfully, will trigger indexing via dumbservice for project "
+ project.getName()));
DumbService.getInstance(project).smartInvokeLater(() -> {
log.debug("Will attempt to trigger indexing for project " + project.getName());
try {
SuggestionIndexService service =
ServiceManager.getService(project, SuggestionIndexService.class);
if (!service.canProvideSuggestions(project, module)) {
service.reindex(project, module);
} else {
debug(() -> log.debug(
"Index is already built, no point in rebuilding index for project " + project
.getName()));
}
} catch (Throwable e) {
log.error("Error occurred while indexing project " + project.getName(), e);
}
});
}
示例2: getFilteredResult
import com.intellij.openapi.components.ServiceManager; //导入依赖的package包/类
@NotNull
public List<DictionaryComponent> getFilteredResult() {
List<DictionaryComponent> result = new ArrayList<>();
boolean filterStdCocoaTerminologyFlag = false; //if there was at least one dictionary from a real app imported
AppleScriptProjectDictionaryService dictionaryRegistry = ServiceManager.getService(myProject, AppleScriptProjectDictionaryService.class);
for (ApplicationDictionary collectedDictionary : collectedDictionaries) {
collectAllComponentsFromDictionary(collectedDictionary, result, filterStdCocoaTerminologyFlag);//was false??
filterStdCocoaTerminologyFlag = filterStdCocoaTerminologyFlag
|| !collectedDictionary.getName().equals(ApplicationDictionary.SCRIPTING_ADDITIONS_LIBRARY);
}
if (dictionaryRegistry != null) {
appendResultsIfNeeded(result, myProject, mySortedUseStatements.size() > 0,
collectedDictionaries.contains(dictionaryRegistry.getScriptingAdditionsTerminology()), filterStdCocoaTerminologyFlag);
}
return result;
}
示例3: collectNavigationMarkers
import com.intellij.openapi.components.ServiceManager; //导入依赖的package包/类
@Override
protected void collectNavigationMarkers(@NotNull PsiElement element,
@NotNull Collection<? super RelatedItemLineMarkerInfo> result) {
if (element instanceof AppleScriptApplicationReference) {
PsiElement leafNode = PsiTreeUtil.firstChild(element);
if (leafNode == null) return;
AppleScriptProjectDictionaryService dictionaryService = ServiceManager.getService(element.getProject(),
AppleScriptProjectDictionaryService.class);
AppleScriptApplicationReference appRef = (AppleScriptApplicationReference) element;
String appName = appRef.getApplicationName();
if (dictionaryService == null || StringUtil.isEmpty(appName)) return;
ApplicationDictionary dictionary = dictionaryService.getDictionary(appName);
if (dictionary == null /*|| dictionary.getApplicationBundle() == null*/) return;
NavigationGutterIconBuilder<PsiElement> builder =
NavigationGutterIconBuilder.create(dictionary.getIcon(0)).
setTargets(dictionary).setTooltipText("Navigate to application dictionary file");
result.add(builder.createLineMarkerInfo(leafNode));
}
}
示例4: findApplicationCommands
import com.intellij.openapi.components.ServiceManager; //导入依赖的package包/类
@NotNull
@Override
public List<AppleScriptCommand> findApplicationCommands(@NotNull Project project, @NotNull String applicationName,
@NotNull String commandName) {
AppleScriptProjectDictionaryService projectDictionaryRegistry =
ServiceManager.getService(project, AppleScriptProjectDictionaryService.class);
ApplicationDictionary dictionary = projectDictionaryRegistry.getDictionary(applicationName);
//among dictionaries there should always be Standard Additions dictionaries checked BUT
//if there was no command in that dictionaries found, we should initialize new dictionary here for the project
//and do it only once!
if (dictionary == null) {
dictionary = projectDictionaryRegistry.createDictionary(applicationName);
}
if (dictionary != null) {
return dictionary.findAllCommandsWithName(commandName);
}
return new ArrayList<>(0);// TODO: 29/11/15 use predefined empty list here
}
示例5: refreshDependencies
import com.intellij.openapi.components.ServiceManager; //导入依赖的package包/类
@Override
protected void refreshDependencies(ExternalProjectRefreshCallback cbk, @Nullable Collection<DataNode<LibraryDependencyData>> libraryDependencies) {
if (libraryDependencies != null) {
// Change the dependencies only if there are new dependencies
this.libraryDependencies = libraryDependencies;
cbk.onSuccess(null);
return;
}
if (this.libraryDependencies != null) {
cbk.onSuccess(null);
return;
}
ExternalSystemProcessingManager processingManager = ServiceManager.getService(ExternalSystemProcessingManager.class);
if (processingManager != null && processingManager.findTask(ExternalSystemTaskType.RESOLVE_PROJECT, GradleConstants.SYSTEM_ID, getProjectBasePath(project)) != null) {
// Another scan in progress
return;
}
ExternalSystemUtil.refreshProject(project, GradleConstants.SYSTEM_ID, getProjectBasePath(project), cbk, false, ProgressExecutionMode.IN_BACKGROUND_ASYNC);
}
示例6: actionPerformed
import com.intellij.openapi.components.ServiceManager; //导入依赖的package包/类
@Override
public void actionPerformed(AnActionEvent e) {
if (e.getProject() != null) {
ScanManager scanManager = ScanManagerFactory.getScanManager(e.getProject());
if (scanManager == null) {
// Check if the project is supported now
ScanManagerFactory scanManagerFactory = ServiceManager.getService(e.getProject(), ScanManagerFactory.class);
scanManagerFactory.initScanManager(e.getProject());
scanManager = ScanManagerFactory.getScanManager(e.getProject());
if (scanManager == null) {
return;
}
MessageBus messageBus = ApplicationManager.getApplication().getMessageBus();
messageBus.syncPublisher(Events.ON_IDEA_FRAMEWORK_CHANGE).update();
}
scanManager.asyncScanAndUpdateResults(false);
}
}
示例7: importData
import com.intellij.openapi.components.ServiceManager; //导入依赖的package包/类
/**
* This function is called after change in the build.gradle file or refresh gradle dependencies call.
* @param toImport the project dependencies
* @param projectData the project data
* @param project the current project
* @param modelsProvider contains the project modules
*/
@Override
public void importData(@NotNull Collection<DataNode<LibraryDependencyData>> toImport,
@Nullable ProjectData projectData,
@NotNull Project project,
@NotNull IdeModifiableModelsProvider modelsProvider) {
if (projectData == null || !projectData.getOwner().equals(GradleConstants.SYSTEM_ID)) {
return;
}
ScanManager scanManager = ScanManagerFactory.getScanManager(project);
if (scanManager == null) {
ScanManagerFactory scanManagerFactory = ServiceManager.getService(project, ScanManagerFactory.class);
scanManagerFactory.initScanManager(project);
scanManager = ScanManagerFactory.getScanManager(project);
if (scanManager == null) {
return;
}
MessageBus messageBus = ApplicationManager.getApplication().getMessageBus();
messageBus.syncPublisher(Events.ON_IDEA_FRAMEWORK_CHANGE).update();
}
if (GlobalSettings.getInstance().isCredentialsSet()) {
scanManager.asyncScanAndUpdateResults(true, toImport);
}
}
示例8: getAlreadyOpenedModules
import com.intellij.openapi.components.ServiceManager; //导入依赖的package包/类
@NotNull
protected Set<HybrisModuleDescriptor> getAlreadyOpenedModules(@NotNull final Project project) {
Validate.notNull(project);
final HybrisModuleDescriptorFactory hybrisModuleDescriptorFactory = ServiceManager.getService(
HybrisModuleDescriptorFactory.class
);
final Set<HybrisModuleDescriptor> existingModules = new THashSet<HybrisModuleDescriptor>();
for (Module module : ModuleManager.getInstance(project).getModules()) {
try {
final VirtualFile[] contentRoots = ModuleRootManager.getInstance(module).getContentRoots();
if (!ArrayUtils.isEmpty(contentRoots)) {
existingModules.add(hybrisModuleDescriptorFactory.createDescriptor(
VfsUtil.virtualToIoFile(contentRoots[0]), this
));
}
} catch (HybrisConfigurationException e) {
LOG.error(e);
}
}
return existingModules;
}
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:27,代码来源:DefaultHybrisProjectDescriptor.java
示例9: getRelativePath
import com.intellij.openapi.components.ServiceManager; //导入依赖的package包/类
@NotNull
@Override
public String getRelativePath() {
final VirtualFileSystemService virtualFileSystemService = ServiceManager.getService(
VirtualFileSystemService.class
);
final File projectRootDir = this.getRootProjectDescriptor().getRootDirectory();
final File moduleRootDir = this.getRootDirectory();
if (null != projectRootDir && virtualFileSystemService.fileContainsAnother(projectRootDir, moduleRootDir)) {
return virtualFileSystemService.getRelativePath(projectRootDir, moduleRootDir);
}
return moduleRootDir.getPath();
}
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:17,代码来源:AbstractHybrisModuleDescriptor.java
示例10: isOutOfTheBoxModule
import com.intellij.openapi.components.ServiceManager; //导入依赖的package包/类
@Override
public boolean isOutOfTheBoxModule(@NotNull final File file, final HybrisProjectDescriptor rootProjectDescriptor) {
Validate.notNull(file);
final File extDir = rootProjectDescriptor.getExternalExtensionsDirectory();
if (extDir != null) {
final VirtualFileSystemService virtualFSService = ServiceManager.getService(
VirtualFileSystemService.class
);
if (virtualFSService.fileContainsAnother(extDir, file)) {
// this will override bin/ext-* naming convention.
return false;
}
;
}
return file.getAbsolutePath().contains(HybrisConstants.PLATFORM_OOTB_MODULE_PREFIX)
&& new File(file, HybrisConstants.EXTENSION_INFO_XML).isFile();
}
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:18,代码来源:DefaultHybrisProjectService.java
示例11: projectOpened
import com.intellij.openapi.components.ServiceManager; //导入依赖的package包/类
@Override
public void projectOpened(final Project project) {
StartupManager.getInstance(project).registerPostStartupActivity((DumbAwareRunnable) () -> {
if (project.isDisposed()) {
return;
}
if (isOldHybrisProject(project)) {
showNotification(project);
}
if (isDiscountTargetGroup()) {
showDiscountOffer(project);
}
final CommonIdeaService commonIdeaService = ServiceManager.getService(CommonIdeaService.class);
if (!commonIdeaService.isHybrisProject(project)) {
return;
}
if (popupPermissionToSendStatistics(project)) {
continueOpening(project);
}
});
}
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:22,代码来源:HybrisProjectManagerListener.java
示例12: validateOneRule
import com.intellij.openapi.components.ServiceManager; //导入依赖的package包/类
protected void validateOneRule(
@NotNull final XmlRule rule,
@NotNull final ValidateContext context,
@NotNull final Collection<? super ProblemDescriptor> output
) throws XPathExpressionException {
final XPathService xPathService = ServiceManager.getService(XPathService.class);
final NodeList selection = xPathService.computeNodeSet(rule.getSelectionXPath(), context.getDocument());
for (int i = 0; i < selection.getLength(); i++) {
final Node nextSelected = selection.item(i);
boolean passed = xPathService.computeBoolean(rule.getTestXPath(), nextSelected);
if (rule.isFailOnTestQuery()) {
passed = !passed;
}
if (!passed) {
output.add(this.createProblem(context, nextSelected, rule));
}
}
}
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:20,代码来源:XmlRuleInspection.java
示例13: getCodeTemplateList
import com.intellij.openapi.components.ServiceManager; //导入依赖的package包/类
/**
* 获取选中的模板列表
* @return 选中的模板列表
*/
private List<CodeTemplate> getCodeTemplateList (){
List<CodeTemplate> tmpCodeTemplateList = new ArrayList<CodeTemplate>();
List<String> tmpSelectedList = listClassType.getSelectedValuesList();
CodeMakerSettings settings = ServiceManager.getService(CodeMakerSettings.class);
for(String tmp : tmpSelectedList){
tmpCodeTemplateList.add(settings.getCodeTemplate(tmp));
}
return tmpCodeTemplateList;
}
示例14: initToolWindow
import com.intellij.openapi.components.ServiceManager; //导入依赖的package包/类
private void initToolWindow() {
initTree();
JPanel panel = new SeedStackNavigatorPanel(myProject, tree);
final ToolWindowManagerEx manager = ToolWindowManagerEx.getInstanceEx(myProject);
toolWindow = (ToolWindowEx) manager.registerToolWindow(TOOL_WINDOW_ID, false, ToolWindowAnchor.LEFT, myProject, true);
toolWindow.setIcon(SeedStackIcons.LOGO);
final ContentFactory contentFactory = ServiceManager.getService(ContentFactory.class);
final Content content = contentFactory.createContent(panel, "", false);
ContentManager contentManager = toolWindow.getContentManager();
contentManager.addContent(content);
contentManager.setSelectedContent(content, false);
final ToolWindowManagerAdapter listener = new ToolWindowManagerAdapter() {
boolean wasVisible = false;
@Override
public void stateChanged() {
if (toolWindow.isDisposed()) return;
boolean visible = toolWindow.isVisible();
if (!visible) {
return;
}
scheduleStructureUpdate(null);
}
};
manager.addToolWindowManagerListener(listener, myProject);
ActionManager actionManager = ActionManager.getInstance();
DefaultActionGroup group = new DefaultActionGroup();
toolWindow.setAdditionalGearActions(group);
}
示例15: onSuccessImport
import com.intellij.openapi.components.ServiceManager; //导入依赖的package包/类
@Override
public void onSuccessImport(@NotNull Collection<DataNode<ModuleData>> imported,
@Nullable ProjectData projectData, @NotNull Project project,
@NotNull IdeModelsProvider modelsProvider) {
if (projectData != null) {
debug(() -> log.debug(
"Gradle dependencies are updated for project, will trigger indexing via dumbservice for project "
+ project.getName()));
DumbService.getInstance(project).smartInvokeLater(() -> {
log.debug("Will attempt to trigger indexing for project " + project.getName());
SuggestionIndexService service =
ServiceManager.getService(project, SuggestionIndexService.class);
try {
Module[] validModules = stream(modelsProvider.getModules()).filter(module -> {
String externalRootProjectPath = getExternalRootProjectPath(module);
return externalRootProjectPath != null && externalRootProjectPath
.equals(projectData.getLinkedExternalProjectPath());
}).toArray(Module[]::new);
if (validModules.length > 0) {
service.reindex(project, validModules);
} else {
debug(() -> log.debug(
"None of the modules " + moduleNamesAsStrCommaDelimited(modelsProvider.getModules(),
true) + " are relevant for indexing, skipping for project " + project
.getName()));
}
} catch (Throwable e) {
log.error("Error occurred while indexing project " + project.getName() + " & modules "
+ moduleNamesAsStrCommaDelimited(modelsProvider.getModules(), false), e);
}
});
}
}