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

The following examples show how to use com.intellij.openapi.project.Project#getComponent() . 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 File: BuckCommandHandler.java    From buck with 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 File: ComponentProvider.java    From aem-ide-tooling-4-intellij with Apache License 2.0 5 votes vote down vote up
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 3
Source File: RTActionUtil.java    From react-templates-plugin with 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 4
Source File: FieldReferenceNodeManipulator.java    From protobuf-jetbrains-plugin with Apache License 2.0 5 votes vote down vote up
@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 5
Source File: InspectionProjectProfileManagerImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
public static InspectionProjectProfileManagerImpl getInstanceImpl(Project project) {
  return (InspectionProjectProfileManagerImpl)project.getComponent(InspectionProjectProfileManager.class);
}
 
Example 6
Source File: WolfTheProblemSolver.java    From consulo with Apache License 2.0 4 votes vote down vote up
public static WolfTheProblemSolver getInstance(Project project) {
  return project.getComponent(WolfTheProblemSolver.class);
}
 
Example 7
Source File: ShelveChangesManager.java    From consulo with Apache License 2.0 4 votes vote down vote up
public static ShelveChangesManager getInstance(@Nonnull Project project) {
  return project.getComponent(ShelveChangesManager.class);
}
 
Example 8
Source File: RunManager.java    From consulo with Apache License 2.0 4 votes vote down vote up
public static RunManager getInstance(final Project project) {
  return project.getComponent(RunManager.class);
}
 
Example 9
Source File: VcsDirtyScopeManager.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
public static VcsDirtyScopeManager getInstance(@Nonnull Project project) {
  return project.getComponent(VcsDirtyScopeManager.class);
}
 
Example 10
Source File: CoverageDataManager.java    From consulo with Apache License 2.0 4 votes vote down vote up
public static CoverageDataManager getInstance(Project project) {
  return project.getComponent(CoverageDataManager.class);
}
 
Example 11
Source File: RTProjectComponent.java    From react-templates-plugin with MIT License 4 votes vote down vote up
public static boolean isEnabled(@NotNull final Project project) {
    RTProjectComponent component = project.getComponent(RTProjectComponent.class);
    return component.isEnabled();
}
 
Example 12
Source File: CompilerCacheManager.java    From consulo with Apache License 2.0 4 votes vote down vote up
public static CompilerCacheManager getInstance(Project project) {
  return project.getComponent(CompilerCacheManager.class);
}
 
Example 13
Source File: Plugin.java    From markdown-doclet with GNU General Public License v3.0 4 votes vote down vote up
public static ProjectConfiguration projectConfiguration(Project project) {
    return (ProjectConfiguration)project.getComponent(PROJECT_CONFIG_NAME);
}
 
Example 14
Source File: Unity3dConsoleToolWindowService.java    From consulo-unity3d with Apache License 2.0 4 votes vote down vote up
@Nonnull
public static Unity3dConsoleToolWindowService getInstance(@Nonnull Project project)
{
	return project.getComponent(Unity3dConsoleToolWindowService.class);
}
 
Example 15
Source File: ChangeListManagerImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
public static ChangeListManagerImpl getInstanceImpl(final Project project) {
  return (ChangeListManagerImpl)project.getComponent(ChangeListManager.class);
}
 
Example 16
Source File: ShelvedChangesViewManager.java    From consulo with Apache License 2.0 4 votes vote down vote up
public static ShelvedChangesViewManager getInstance(Project project) {
  return project.getComponent(ShelvedChangesViewManager.class);
}
 
Example 17
Source File: EventLog.java    From consulo with Apache License 2.0 4 votes vote down vote up
static ProjectTracker getProjectComponent(Project project) {
  return project.getComponent(ProjectTracker.class);
}
 
Example 18
Source File: XDebuggerManager.java    From consulo with Apache License 2.0 4 votes vote down vote up
public static XDebuggerManager getInstance(@Nonnull Project project) {
  return project.getComponent(XDebuggerManager.class);
}
 
Example 19
Source File: ProjectLevelVcsManager.java    From consulo with 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 File: ProjectRootManager.java    From consulo with 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);
}