Java 类com.intellij.openapi.components.BaseComponent 实例源码

项目:intellij-ce-playground    文件:ComponentManagerImpl.java   
private void registerComponentInstance(@NotNull Object instance) {
  myInstantiatedComponentCount++;

  if (instance instanceof com.intellij.openapi.Disposable) {
    Disposer.register(this, (com.intellij.openapi.Disposable)instance);
  }

  if (!(instance instanceof BaseComponent)) {
    return;
  }

  BaseComponent baseComponent = (BaseComponent)instance;
  String componentName = baseComponent.getComponentName();
  if (myNameToComponent.containsKey(componentName)) {
    BaseComponent loadedComponent = myNameToComponent.get(componentName);
    // component may have been already loaded by PicoContainer, so fire error only if components are really different
    if (!instance.equals(loadedComponent)) {
      LOG.error("Component name collision: " + componentName + " " + loadedComponent.getClass() + " and " + instance.getClass());
    }
  }
  else {
    myNameToComponent.put(componentName, baseComponent);
  }

  myBaseComponents.add(baseComponent);
}
项目:intellij-ce-playground    文件:VcsEP.java   
@Nullable
private AbstractVcs getInstance(@NotNull Project project, @NotNull String vcsClass) {
  try {
    final Class<? extends AbstractVcs> foundClass = findClass(vcsClass);
    final Class<?>[] interfaces = foundClass.getInterfaces();
    for (Class<?> anInterface : interfaces) {
      if (BaseComponent.class.isAssignableFrom(anInterface)) {
        return PeriodicalTasksCloser.getInstance().safeGetComponent(project, foundClass);
      }
    }
    return instantiate(vcsClass, project.getPicoContainer());
  }
  catch (ProcessCanceledException pce) {
    throw pce;
  }
  catch(Exception e) {
    LOG.error(e);
    return null;
  }
}
项目:tools-idea    文件:VcsEP.java   
public AbstractVcs getVcs(Project project) {
  if (myVcs == null) {
    try {
      final Class<? extends AbstractVcs> foundClass = findClass(vcsClass);
      final Class<?>[] interfaces = foundClass.getInterfaces();
      for (Class<?> anInterface : interfaces) {
        if (BaseComponent.class.isAssignableFrom(anInterface)) {
          myVcs = PeriodicalTasksCloser.getInstance().safeGetComponent(project, foundClass);
          myVcs = VcsActiveEnvironmentsProxy.proxyVcs(myVcs);
          return myVcs;
        }
      }
      myVcs = VcsActiveEnvironmentsProxy.proxyVcs((AbstractVcs)instantiate(vcsClass, project.getPicoContainer()));
    }
    catch(Exception e) {
      LOG.error(e);
      return null;
    }
  }
  return myVcs;
}
项目:consulo    文件:VcsEP.java   
@Nullable
private AbstractVcs getInstance(@Nonnull Project project, @Nonnull String vcsClass) {
  try {
    final Class<? extends AbstractVcs> foundClass = findClass(vcsClass);
    final Class<?>[] interfaces = foundClass.getInterfaces();
    for (Class<?> anInterface : interfaces) {
      if (BaseComponent.class.isAssignableFrom(anInterface)) {
        return PeriodicalTasksCloser.getInstance().safeGetComponent(project, foundClass);
      }
    }
    return instantiate(vcsClass, project.getPicoContainer());
  }
  catch (ProcessCanceledException pce) {
    throw pce;
  }
  catch(Exception e) {
    LOG.error(e);
    return null;
  }
}
项目:intellij-ce-playground    文件:SnapShooterConfigurationExtension.java   
@Override
public void updateJavaParameters(RunConfigurationBase configuration, JavaParameters params, RunnerSettings runnerSettings) {
  if (!isApplicableFor(configuration)) {
    return;
  }
  ApplicationConfiguration appConfiguration = (ApplicationConfiguration) configuration;
  SnapShooterConfigurationSettings settings = appConfiguration.getUserData(SnapShooterConfigurationSettings.SNAP_SHOOTER_KEY);
  if (settings == null) {
    settings = new SnapShooterConfigurationSettings();
    appConfiguration.putUserData(SnapShooterConfigurationSettings.SNAP_SHOOTER_KEY, settings);
  }
  if (appConfiguration.ENABLE_SWING_INSPECTOR) {
    settings.setLastPort(NetUtils.tryToFindAvailableSocketPort());
  }

  if (appConfiguration.ENABLE_SWING_INSPECTOR && settings.getLastPort() != -1) {
    params.getProgramParametersList().prepend(appConfiguration.MAIN_CLASS_NAME);
    params.getProgramParametersList().prepend(Integer.toString(settings.getLastPort()));
    // add +1 because idea_rt.jar will be added as the last entry to the classpath
    params.getProgramParametersList().prepend(Integer.toString(params.getClassPath().getPathList().size() + 1));
    Set<String> paths = new TreeSet<String>();
    paths.add(PathUtil.getJarPathForClass(SnapShooter.class));         // ui-designer-impl
    paths.add(PathUtil.getJarPathForClass(BaseComponent.class));       // appcore-api
    paths.add(PathUtil.getJarPathForClass(ProjectComponent.class));    // openapi
    paths.add(PathUtil.getJarPathForClass(LwComponent.class));         // UIDesignerCore
    paths.add(PathUtil.getJarPathForClass(GridConstraints.class));     // forms_rt
    paths.add(PathUtil.getJarPathForClass(PaletteGroup.class));        // openapi
    paths.add(PathUtil.getJarPathForClass(LafManagerListener.class));  // ui-impl
    paths.add(PathUtil.getJarPathForClass(DataProvider.class));        // action-system-openapi
    paths.add(PathUtil.getJarPathForClass(XmlStringUtil.class));       // idea
    paths.add(PathUtil.getJarPathForClass(Navigatable.class));         // pom
    paths.add(PathUtil.getJarPathForClass(AreaInstance.class));        // extensions
    paths.add(PathUtil.getJarPathForClass(FormLayout.class));          // jgoodies
    paths.addAll(PathManager.getUtilClassPath());
    for(String path: paths) {
      params.getClassPath().addFirst(path);
    }
    params.setMainClass("com.intellij.uiDesigner.snapShooter.SnapShooter");
  }
}
项目:intellij-ce-playground    文件:ComponentType.java   
ComponentType(Class<? extends BaseComponent> clazz, @NonNls String name,
              @PropertyKey(resourceBundle = "org.jetbrains.idea.devkit.DevKitBundle") String propertyKey)
{
  myPropertyKey = propertyKey;
  myClassName = clazz.getName();
  myName = name;
}
项目:tools-idea    文件:ComponentType.java   
ComponentType(Class<? extends BaseComponent> clazz, @NonNls String name,
              @PropertyKey(resourceBundle = "org.jetbrains.idea.devkit.DevKitBundle") String propertyKey)
{
  myPropertyKey = propertyKey;
  myClassName = clazz.getName();
  myName = name;
}
项目:jfrog-idea-plugin    文件:NpmProjectImpl.java   
@Override
public BaseComponent getComponent(@NotNull String name) {
    return null;
}
项目:stack-intheflow    文件:ProjectMock.java   
@Override
public BaseComponent getComponent(@NotNull String s) {
    return null;
}
项目:intellij-ce-playground    文件:DummyProject.java   
@Override
public BaseComponent getComponent(@NotNull String name) {
  return null;
}
项目:intellij-ce-playground    文件:MockComponentManager.java   
@Override
public BaseComponent getComponent(@NotNull String name) {
  return null;
}
项目:intellij-ce-playground    文件:ComponentManagerImpl.java   
@Override
public synchronized BaseComponent getComponent(@NotNull String name) {
  return myNameToComponent.get(name);
}
项目:intellij-ce-playground    文件:ComponentManagerImpl.java   
@Override
public Object getComponentInstance(PicoContainer picoContainer) throws PicoInitializationException, PicoIntrospectionException, ProcessCanceledException {
  Object instance = myInitializedComponentInstance;
  if (instance != null) {
    return instance;
  }

  try {
    //noinspection SynchronizeOnThis
    synchronized (this) {
      instance = myInitializedComponentInstance;
      if (instance != null) {
        return instance;
      }

      long startTime = System.nanoTime();

      instance = super.getComponentInstance(picoContainer);

      if (myInitializing) {
        String errorMessage = "Cyclic component initialization: " + getComponentKey();
        if (myPluginId != null) {
          LOG.error(new PluginException(errorMessage, myPluginId));
        }
        else {
          LOG.error(new Throwable(errorMessage));
        }
      }

      try {
        myInitializing = true;
        registerComponentInstance(instance);

        ProgressIndicator indicator = getProgressIndicator();
        if (indicator != null) {
          indicator.checkCanceled();
          setProgressDuringInit(indicator);
        }
        initializeComponent(instance, false);
        if (instance instanceof BaseComponent) {
          ((BaseComponent)instance).initComponent();
        }

        long ms = (System.nanoTime() - startTime) / 1000000;
        if (ms > 10 && logSlowComponents()) {
          LOG.info(instance.getClass().getName() + " initialized in " + ms + " ms");
        }
      }
      finally {
        myInitializing = false;
      }
      myInitializedComponentInstance = instance;
    }
  }
  catch (ProcessCanceledException e) {
    throw e;
  }
  catch (Throwable t) {
    handleInitComponentError(t, ((Class)getComponentKey()).getName(), myPluginId);
  }

  return instance;
}
项目:aem-ide-tooling-4-intellij    文件:MockProject.java   
@Override
public BaseComponent getComponent(@NotNull String s) {
    return null;
}
项目:shared-views    文件:MockProject.java   
@Override
public BaseComponent getComponent(@NotNull String name) {
    return null;
}
项目:tools-idea    文件:DummyProject.java   
@Override
public BaseComponent getComponent(@NotNull String name) {
  return null;
}
项目:tools-idea    文件:MockComponentManager.java   
@Override
public BaseComponent getComponent(@NotNull String name) {
  return null;
}
项目:tools-idea    文件:MockProject.java   
@Override
public BaseComponent getComponent(@NotNull String name) {
  throw new UnsupportedOperationException();
}
项目:tools-idea    文件:SnapShooterConfigurationExtension.java   
@Override
public void updateJavaParameters(RunConfigurationBase configuration, JavaParameters params, RunnerSettings runnerSettings) {
  if (!isApplicableFor(configuration)) {
    return;
  }
  ApplicationConfiguration appConfiguration = (ApplicationConfiguration) configuration;
  SnapShooterConfigurationSettings settings = appConfiguration.getUserData(SnapShooterConfigurationSettings.SNAP_SHOOTER_KEY);
  if (settings == null) {
    settings = new SnapShooterConfigurationSettings();
    appConfiguration.putUserData(SnapShooterConfigurationSettings.SNAP_SHOOTER_KEY, settings);
  }
  if (appConfiguration.ENABLE_SWING_INSPECTOR) {
    try {
      settings.setLastPort(NetUtils.findAvailableSocketPort());
    }
    catch(IOException ex) {
      settings.setLastPort(-1);
    }
  }

  if (appConfiguration.ENABLE_SWING_INSPECTOR && settings.getLastPort() != -1) {
    params.getProgramParametersList().prepend(appConfiguration.MAIN_CLASS_NAME);
    params.getProgramParametersList().prepend(Integer.toString(settings.getLastPort()));
    // add +1 because idea_rt.jar will be added as the last entry to the classpath
    params.getProgramParametersList().prepend(Integer.toString(params.getClassPath().getPathList().size() + 1));
    Set<String> paths = new TreeSet<String>();
    paths.add(PathUtil.getJarPathForClass(SnapShooter.class));         // ui-designer-impl
    paths.add(PathUtil.getJarPathForClass(BaseComponent.class));       // appcore-api
    paths.add(PathUtil.getJarPathForClass(ProjectComponent.class));    // openapi
    paths.add(PathUtil.getJarPathForClass(LwComponent.class));         // UIDesignerCore
    paths.add(PathUtil.getJarPathForClass(GridConstraints.class));     // forms_rt
    paths.add(PathUtil.getJarPathForClass(LafManagerListener.class));  // ui-impl
    paths.add(PathUtil.getJarPathForClass(DataProvider.class));        // action-system-openapi
    paths.add(PathUtil.getJarPathForClass(XmlStringUtil.class));       // idea
    paths.add(PathUtil.getJarPathForClass(Navigatable.class));         // pom
    paths.add(PathUtil.getJarPathForClass(AreaInstance.class));        // extensions
    paths.add(PathUtil.getJarPathForClass(FormLayout.class));          // jgoodies
    paths.addAll(PathManager.getUtilClassPath());
    for(String path: paths) {
      params.getClassPath().addFirst(path);
    }
    params.setMainClass("com.intellij.uiDesigner.snapShooter.SnapShooter");
  }
}
项目:EclipseCodeFormatter    文件:StringUtilsTest.java   
@Override
public BaseComponent getComponent(String name) {
    return null;
}
项目:consulo-ui-designer    文件:SnapShooterConfigurationExtension.java   
@Override
public void updateJavaParameters(RunConfigurationBase configuration, OwnJavaParameters params, RunnerSettings runnerSettings) {
  if (!isApplicableFor(configuration)) {
    return;
  }
  ApplicationConfiguration appConfiguration = (ApplicationConfiguration) configuration;
  SnapShooterConfigurationSettings settings = appConfiguration.getUserData(SnapShooterConfigurationSettings.SNAP_SHOOTER_KEY);
  if (settings == null) {
    settings = new SnapShooterConfigurationSettings();
    appConfiguration.putUserData(SnapShooterConfigurationSettings.SNAP_SHOOTER_KEY, settings);
  }
  if (appConfiguration.ENABLE_SWING_INSPECTOR) {
    try {
      settings.setLastPort(NetUtils.findAvailableSocketPort());
    }
    catch(IOException ex) {
      settings.setLastPort(-1);
    }
  }

  if (appConfiguration.ENABLE_SWING_INSPECTOR && settings.getLastPort() != -1) {
    params.getProgramParametersList().prepend(appConfiguration.MAIN_CLASS_NAME);
    params.getProgramParametersList().prepend(Integer.toString(settings.getLastPort()));
    // add +1 because idea_rt.jar will be added as the last entry to the classpath
    params.getProgramParametersList().prepend(Integer.toString(params.getClassPath().getPathList().size() + 1));
    Set<String> paths = new TreeSet<String>();
    paths.add(PathUtil.getJarPathForClass(SnapShooter.class));         // ui-designer-impl
    paths.add(PathUtil.getJarPathForClass(BaseComponent.class));       // appcore-api
    paths.add(PathUtil.getJarPathForClass(ProjectComponent.class));    // openapi
    paths.add(PathUtil.getJarPathForClass(LwComponent.class));         // UIDesignerCore
    paths.add(PathUtil.getJarPathForClass(GridConstraints.class));     // forms_rt
    paths.add(PathUtil.getJarPathForClass(LafManagerListener.class));  // ui-impl
    paths.add(PathUtil.getJarPathForClass(DataProvider.class));        // action-system-openapi
    paths.add(PathUtil.getJarPathForClass(XmlStringUtil.class));       // idea
    paths.add(PathUtil.getJarPathForClass(Navigatable.class));         // pom
    paths.add(PathUtil.getJarPathForClass(AreaInstance.class));        // extensions
    paths.add(PathUtil.getJarPathForClass(FormLayout.class));          // jgoodies
    paths.addAll(PathManager.getUtilClassPath());
    for(String path: paths) {
      params.getClassPath().addFirst(path);
    }
    params.setMainClass("com.intellij.uiDesigner.snapShooter.SnapShooter");
  }
}
项目:consulo    文件:MockProject.java   
@Override
public BaseComponent getComponent(String name) {
  throw new UnsupportedOperationException();
}
项目:consulo    文件:DummyProject.java   
@Override
public BaseComponent getComponent(String name) {
  return null;
}
项目:consulo    文件:MockComponentManager.java   
@Override
public BaseComponent getComponent(@Nonnull String name) {
  return null;
}