Java 类com.intellij.openapi.components.impl.ServiceManagerImpl 实例源码

项目:intellij-ce-playground    文件:ApplicationImpl.java   
@Override
public void load(@Nullable final String configPath) {
  AccessToken token = HeavyProcessLatch.INSTANCE.processStarted("Loading application components");
  try {
    long t = System.currentTimeMillis();
    init(mySplash == null ? null : new EmptyProgressIndicator() {
      @Override
      public void setFraction(double fraction) {
        mySplash.showProgress("", (float)(0.65 + getPercentageOfComponentsLoaded() * 0.35));
      }
    }, new Runnable() {
      @Override
      public void run() {
        // create ServiceManagerImpl at first to force extension classes registration
        getPicoContainer().getComponentInstance(ServiceManagerImpl.class);

        String effectiveConfigPath = FileUtilRt.toSystemIndependentName(configPath == null ? PathManager.getConfigPath() : configPath);
        for (ApplicationLoadListener listener : ApplicationLoadListener.EP_NAME.getExtensions()) {
          try {
            listener.beforeApplicationLoaded(ApplicationImpl.this, effectiveConfigPath);
          }
          catch (Throwable e) {
            LOG.error(e);
          }
        }

        // we set it after beforeApplicationLoaded call, because app store can depends on stream provider state
        ServiceKt.getStateStore(ApplicationImpl.this).setPath(effectiveConfigPath);
      }
    });
    t = System.currentTimeMillis() - t;
    LOG.info(getComponentConfigCount() + " application components initialized in " + t + " ms");
  }
  finally {
    token.finish();
  }
  myLoaded = true;

  createLocatorFile();
}
项目:intellij-ce-playground    文件:FocusManagerImpl.java   
@SuppressWarnings("UnusedParameters")  // the dependencies are needed to ensure correct loading order
public FocusManagerImpl(ServiceManagerImpl serviceManager, WindowManager wm, UiActivityMonitor monitor) {
  myApp = ApplicationManager.getApplication();
  myQueue = IdeEventQueue.getInstance();
  myActivityMonitor = monitor;

  myFocusedComponentAlarm = new EdtAlarm();
  myForcedFocusRequestsAlarm = new EdtAlarm();
  myIdleAlarm = new EdtAlarm();

  final AppListener myAppListener = new AppListener();
  myApp.getMessageBus().connect().subscribe(ApplicationActivationListener.TOPIC, myAppListener);

  IdeEventQueue.getInstance().addDispatcher(new IdeEventQueue.EventDispatcher() {
    @Override
    public boolean dispatch(AWTEvent e) {
      if (e instanceof FocusEvent) {
        final FocusEvent fe = (FocusEvent)e;
        final Component c = fe.getComponent();
        if (c instanceof Window || c == null) return false;

        Component parent = UIUtil.findUltimateParent(c);

        if (parent instanceof IdeFrame) {
          myLastFocused.put((IdeFrame)parent, c);
        }
      }
      else if (e instanceof WindowEvent) {
        Window wnd = ((WindowEvent)e).getWindow();
        if (e.getID() == WindowEvent.WINDOW_CLOSED) {
          if (wnd instanceof IdeFrame) {
            myLastFocused.remove(wnd);
            myLastFocusedAtDeactivation.remove(wnd);
          }
        }
      }

      return false;
    }
  }, this);

  KeyboardFocusManager.getCurrentKeyboardFocusManager().addPropertyChangeListener("focusedWindow", new PropertyChangeListener() {
    @Override
    public void propertyChange(PropertyChangeEvent evt) {
      if (evt.getNewValue() instanceof IdeFrame) {
        myLastFocusedFrame = (IdeFrame)evt.getNewValue();
      }
    }
  });
}
项目:tools-idea    文件:FocusManagerImpl.java   
@SuppressWarnings("UnusedParameters")  // the dependencies are needed to ensure correct loading order
public FocusManagerImpl(ServiceManagerImpl serviceManager, WindowManager wm, UiActivityMonitor monitor) {
  myApp = ApplicationManager.getApplication();
  myQueue = IdeEventQueue.getInstance();
  myActivityMonitor = monitor;

  myFocusedComponentAlaram = new EdtAlarm();
  myForcedFocusRequestsAlarm = new EdtAlarm();
  myIdleAlarm = new EdtAlarm();

  final AppListener myAppListener = new AppListener();
  myApp.getMessageBus().connect().subscribe(ApplicationActivationListener.TOPIC, myAppListener);

  IdeEventQueue.getInstance().addDispatcher(new IdeEventQueue.EventDispatcher() {
    public boolean dispatch(AWTEvent e) {
      if (e instanceof FocusEvent) {
        final FocusEvent fe = (FocusEvent)e;
        final Component c = fe.getComponent();
        if (c instanceof Window || c == null) return false;

        Component parent = SwingUtilities.getWindowAncestor(c);

        if (parent instanceof IdeFrame) {
          myLastFocused.put((IdeFrame)parent, new WeakReference<Component>(c));
        }
      } else if (e instanceof WindowEvent) {
        Window wnd = ((WindowEvent)e).getWindow();
        if (e.getID() == WindowEvent.WINDOW_CLOSED) {
          if (wnd instanceof IdeFrame) {
            myLastFocused.remove((IdeFrame)wnd);
            myLastFocusedAtDeactivation.remove((IdeFrame)wnd);
          }
        }
      }

      return false;
    }
  }, this);

  KeyboardFocusManager.getCurrentKeyboardFocusManager().addPropertyChangeListener("focusedWindow", new PropertyChangeListener() {
    @Override
    public void propertyChange(PropertyChangeEvent evt) {
      if (evt.getNewValue() instanceof IdeFrame) {
        myLastFocusedFrame = (IdeFrame)evt.getNewValue();
      }
    }
  });
}
项目:consulo    文件:FocusManagerImpl.java   
@SuppressWarnings("UnusedParameters")  // the dependencies are needed to ensure correct loading order
public FocusManagerImpl(ServiceManagerImpl serviceManager, WindowManager wm, UiActivityMonitor monitor) {
  myApp = ApplicationManager.getApplication();
  myQueue = IdeEventQueue.getInstance();
  myActivityMonitor = monitor;

  myFocusedComponentAlarm = new EdtAlarm();
  myForcedFocusRequestsAlarm = new EdtAlarm();

  final AppListener myAppListener = new AppListener();
  myApp.getMessageBus().connect().subscribe(ApplicationActivationListener.TOPIC, myAppListener);

  IdeEventQueue.getInstance().addDispatcher(e -> {
    if (e instanceof FocusEvent) {
      final FocusEvent fe = (FocusEvent)e;
      final Component c = fe.getComponent();
      if (c instanceof Window || c == null) return false;

      Component parent = UIUtil.findUltimateParent(c);

      if (parent instanceof IdeFrame) {
        myLastFocused.put((IdeFrame)parent, c);
      }
    }
    else if (e instanceof WindowEvent) {
      Window wnd = ((WindowEvent)e).getWindow();
      if (e.getID() == WindowEvent.WINDOW_CLOSED) {
        if (wnd instanceof IdeFrame) {
          myLastFocused.remove(wnd);
          myLastFocusedAtDeactivation.remove(wnd);
        }
      }
    }

    return false;
  }, this);

  KeyboardFocusManager.getCurrentKeyboardFocusManager().addPropertyChangeListener("focusedWindow", new PropertyChangeListener() {
    @Override
    public void propertyChange(PropertyChangeEvent evt) {
      if (evt.getNewValue() instanceof IdeFrame) {
        myLastFocusedFrame = (IdeFrame)evt.getNewValue();
      }
    }
  });
}
项目:consulo    文件:ExportSettingsAction.java   
@Nonnull
public static MultiMap<File, ExportableItem> getExportableComponentsMap(final boolean onlyExisting) {
  final MultiMap<File, ExportableItem> result = MultiMap.createLinkedSet();

  ApplicationImpl application = (ApplicationImpl)ApplicationManager.getApplication();
  final StateStorageManager storageManager = application.getStateStore().getStateStorageManager();
  ServiceManagerImpl.processAllImplementationClasses(application, (aClass, pluginDescriptor) -> {
    State stateAnnotation = aClass.getAnnotation(State.class);
    if (stateAnnotation != null && !StringUtil.isEmpty(stateAnnotation.name())) {
      int storageIndex;
      Storage[] storages = stateAnnotation.storages();
      if (storages.length == 1) {
        storageIndex = 0;
      }
      else if (storages.length > 1) {
        storageIndex = storages.length - 1;
      }
      else {
        return true;
      }

      Storage storage = storages[storageIndex];
      if (storage.roamingType() != RoamingType.DISABLED) {
        String fileSpec = storageManager.buildFileSpec(storage);

        if (!fileSpec.startsWith(StoragePathMacros.APP_CONFIG)) {
          return true;
        }

        File file = new File(storageManager.expandMacros(fileSpec));

        File additionalExportFile = null;
        if (!StringUtil.isEmpty(stateAnnotation.additionalExportFile())) {
          additionalExportFile = new File(storageManager.expandMacros(stateAnnotation.additionalExportFile()));
          if (onlyExisting && !additionalExportFile.exists()) {
            additionalExportFile = null;
          }
        }

        boolean fileExists = !onlyExisting || file.exists();
        if (fileExists || additionalExportFile != null) {
          File[] files;
          if (additionalExportFile == null) {
            files = new File[]{file};
          }
          else {
            files = fileExists ? new File[]{file, additionalExportFile} : new File[]{additionalExportFile};
          }
          ExportableItem item = new ExportableItem(files, getComponentPresentableName(stateAnnotation, aClass, pluginDescriptor));
          result.putValue(file, item);
          if (additionalExportFile != null) {
            result.putValue(additionalExportFile, item);
          }
        }
      }
    }
    return true;
  });
  return result;
}