Java Code Examples for com.intellij.openapi.project.Project#getComponent()

The following examples show how to use com.intellij.openapi.project.Project#getComponent() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: buck   File: BuckCommandHandler.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * @param project a project
 * @param command a command to execute (if empty string, the parameter is ignored)
 * @param doStartNotify true if the handler should call OSHandler#startNotify
 */
public BuckCommandHandler(Project project, BuckCommand command, boolean doStartNotify) {
  this.doStartNotify = doStartNotify;

  String buckExecutable =
      BuckExecutableSettingsProvider.getInstance(project).resolveBuckExecutable();

  this.project = project;
  this.buckModule = project.getComponent(BuckModule.class);
  this.command = command;
  commandLine = new GeneralCommandLine();
  commandLine.setExePath(buckExecutable);
  commandLine.withWorkDirectory(calcWorkingDirFor(project));
  commandLine.withEnvironment(EnvironmentUtil.getEnvironmentMap());
  commandLine.addParameter(command.name());
  for (String parameter : command.getParameters()) {
    commandLine.addParameter(parameter);
  }
}
 
Example 2
Source Project: react-templates-plugin   File: RTActionUtil.java    License: MIT License 5 votes vote down vote up
public static boolean isRTEnabled(Project project) {
    if (project == null) {
        return false;
    }
    RTProjectComponent conf = project.getComponent(RTProjectComponent.class);
    return conf != null && conf.isEnabled();
}
 
Example 3
@Override
public FieldReferenceNode handleContentChange(@NotNull FieldReferenceNode node,
        @NotNull TextRange range, String newContent) throws IncorrectOperationException {
    String oldText = node.getText();
    String newText = oldText.substring(0, range.getStartOffset()) + newContent + oldText
            .substring(range.getEndOffset());
    Project project = node.getProject();
    ProtoElementFactory elementFactory = project.getComponent(ProtoElementFactory.class);
    FieldReferenceNode newNode = elementFactory.createFieldReferenceNode(newText);
    return (FieldReferenceNode) node.replace(newNode);
}
 
Example 4
public static <T> T getComponent(Project project, Class<T> clazz) {
    T ret = null;
    if(project != null) {
        // IntelliJ 15+ should find all components / servies here
        ret = project.getComponent(clazz);
    }
    if(ret == null) {
        // If not found then we try IntelliJ 14's way through the Application Manager
        // which only works for Application Components but worth a shot
        ret = ApplicationManager.getApplication().getComponent(clazz);
    }
    //AS TODO: We should report an error here and maybe throw an exception to make sure the plugin is proceeding
    return ret;
}
 
Example 5
Source Project: consulo   File: CompilerCacheManager.java    License: Apache License 2.0 4 votes vote down vote up
public static CompilerCacheManager getInstance(Project project) {
  return project.getComponent(CompilerCacheManager.class);
}
 
Example 6
Source Project: consulo   File: XDebuggerManager.java    License: Apache License 2.0 4 votes vote down vote up
public static XDebuggerManager getInstance(@Nonnull Project project) {
  return project.getComponent(XDebuggerManager.class);
}
 
Example 7
Source Project: consulo   File: EventLog.java    License: Apache License 2.0 4 votes vote down vote up
static ProjectTracker getProjectComponent(Project project) {
  return project.getComponent(ProjectTracker.class);
}
 
Example 8
public static ShelvedChangesViewManager getInstance(Project project) {
  return project.getComponent(ShelvedChangesViewManager.class);
}
 
Example 9
Source Project: consulo   File: ChangeListManagerImpl.java    License: Apache License 2.0 4 votes vote down vote up
public static ChangeListManagerImpl getInstanceImpl(final Project project) {
  return (ChangeListManagerImpl)project.getComponent(ChangeListManager.class);
}
 
Example 10
@Nonnull
public static Unity3dConsoleToolWindowService getInstance(@Nonnull Project project)
{
	return project.getComponent(Unity3dConsoleToolWindowService.class);
}
 
Example 11
public static ProjectConfiguration projectConfiguration(Project project) {
    return (ProjectConfiguration)project.getComponent(PROJECT_CONFIG_NAME);
}
 
Example 12
public static InspectionProjectProfileManagerImpl getInstanceImpl(Project project) {
  return (InspectionProjectProfileManagerImpl)project.getComponent(InspectionProjectProfileManager.class);
}
 
Example 13
public static boolean isEnabled(@NotNull final Project project) {
    RTProjectComponent component = project.getComponent(RTProjectComponent.class);
    return component.isEnabled();
}
 
Example 14
Source Project: consulo   File: CoverageDataManager.java    License: Apache License 2.0 4 votes vote down vote up
public static CoverageDataManager getInstance(Project project) {
  return project.getComponent(CoverageDataManager.class);
}
 
Example 15
Source Project: consulo   File: VcsDirtyScopeManager.java    License: Apache License 2.0 4 votes vote down vote up
@Nonnull
public static VcsDirtyScopeManager getInstance(@Nonnull Project project) {
  return project.getComponent(VcsDirtyScopeManager.class);
}
 
Example 16
Source Project: consulo   File: RunManager.java    License: Apache License 2.0 4 votes vote down vote up
public static RunManager getInstance(final Project project) {
  return project.getComponent(RunManager.class);
}
 
Example 17
Source Project: consulo   File: ShelveChangesManager.java    License: Apache License 2.0 4 votes vote down vote up
public static ShelveChangesManager getInstance(@Nonnull Project project) {
  return project.getComponent(ShelveChangesManager.class);
}
 
Example 18
Source Project: consulo   File: WolfTheProblemSolver.java    License: Apache License 2.0 4 votes vote down vote up
public static WolfTheProblemSolver getInstance(Project project) {
  return project.getComponent(WolfTheProblemSolver.class);
}
 
Example 19
Source Project: consulo   File: ProjectLevelVcsManager.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Returns the <code>ProjectLevelVcsManager<code> instance for the specified project.
 *
 * @param project the project for which the instance is requested.
 * @return the manager instance.
 */
public static ProjectLevelVcsManager getInstance(Project project) {
  return project.getComponent(ProjectLevelVcsManager.class);
}
 
Example 20
Source Project: consulo   File: ProjectRootManager.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Returns the project root manager instance for the specified project.
 *
 * @param project the project for which the instance is requested.
 * @return the instance.
 */
public static ProjectRootManager getInstance(Project project) {
  return project.getComponent(ProjectRootManager.class);
}