本文的目的是介绍JComponent和ComponentUI委托之间的绑定事件的详细情况,特别关注componentjs的相关信息。我们将通过专业的研究、有关数据的分析等多种方式,为您呈现一个全面的了
本文的目的是介绍JComponent和ComponentUI委托之间的绑定事件的详细情况,特别关注component js的相关信息。我们将通过专业的研究、有关数据的分析等多种方式,为您呈现一个全面的了解JComponent和ComponentUI委托之间的绑定事件的机会,同时也不会遗漏关于Angular应用里child Component如何向parent Component发送事件、com.intellij.openapi.components.BaseComponent的实例源码、com.intellij.openapi.components.ComponentConfig的实例源码、com.intellij.openapi.components.ComponentManager的实例源码的知识。
本文目录一览:- JComponent和ComponentUI委托之间的绑定事件(component js)
- Angular应用里child Component如何向parent Component发送事件
- com.intellij.openapi.components.BaseComponent的实例源码
- com.intellij.openapi.components.ComponentConfig的实例源码
- com.intellij.openapi.components.ComponentManager的实例源码
JComponent和ComponentUI委托之间的绑定事件(component js)
我已经开始尝试创建普通的MVC
Swing组件。我对M和C没问题,但是V向我抛出了一个我通常无法解决的问题。问题是:控制器是组件的主类(例如MyComponent),并且它扩展了JComponent。视图是从ComponentUI类扩展的ui委托(MyCompanentUI)。委托所做的只是在MyCompanent中添加JTextField并提供MyComponentModel与该字段之间的数据绑定。它工作正常。但是,如何将事件从JTextField绑定到MyComponent?如果用户想要处理某些事件,则可以将侦听器添加到MyComponent,但是将JTextField截获的所有真实事件(鼠标,焦点,键等)添加,用户并不真正知道这些事件。那么有什么正常的方法可以做到这一点,除了捕获事件并手动将其转换为原始组件?还是有另一种创建委托的方式,而我只是做错了?
UPD:
感谢您的回复,垃圾桶。但是我的想法有所不同。我说的是“事件继承”之类的东西,例如“
inheritsPopupMenu”方法。因此,键,焦点或鼠标事件发生在组件上时,它本身不会对其进行处理,而是将其直接传递给父组件。但是这似乎是不可能的,因为我已经注意到JSpinner存在完全相同的问题-
您几乎无法从此组件获得任何事件通知。
答案1
小编典典如果您正在编写自己的JComponent
子类,并且希望允许自定义UI委托,那么我将从Kirill Grouchnikov的“
如何编写自定义Swing组件”开始 。
如果您正在编写一个包含现有JComponent
子类的组合,例如JTextField
,请参见
如何利用如何使用键绑定中Action
描述的现有实例。是一个例子。您可以从组件的源极(S),或使用这种学习行为的名字@
camickr的文章中所看到的方便实用
按键绑定 。
__ScrollAction
__
Angular应用里child Component如何向parent Component发送事件
detail Component里,使用event binding,给button click事件注册一个处理函数delete:
<img src="{
{itemImageUrl}}" [style.display]="displayNone">
<span [style.text-decoration]="lineThrough">{
{ item.name }}
</span>
<button (click)="delete()">Delete</button>
@Output() deleteRequest = new EventEmitter<Item>();
delete() {
this.deleteRequest.emit(this.item);
this.displayNone = this.displayNone ? '''' : ''none'';
this.lineThrough = this.lineThrough ? '''' : ''line-through'';
}
在delete函数里,使用EventEmitter发送一个事件。deleteRequest这个property需要加上@Output的注解。
在parent Component里,监听从child Component发送过来的自定义事件:
<app-item-detail (deleteRequest)="deleteItem($event)" [item]="currentItem"></app-item-detail>
本文分享 CSDN - 汪子熙。
如有侵权,请联系 support@oschina.cn 删除。
本文参与“OSC源创计划”,欢迎正在阅读的你也加入,一起分享。
com.intellij.openapi.components.BaseComponent的实例源码
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); }
@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; } }
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; }
@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,project.getpicocontainer()); } catch (ProcessCanceledException pce) { throw pce; } catch(Exception e) { LOG.error(e); return null; } }
@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"); } }
ComponentType(Class<? extends BaseComponent> clazz,@NonNls String name,@PropertyKey(resourceBundle = "org.jetbrains.idea.devkit.DevKitBundle") String propertyKey) { myPropertyKey = propertyKey; myClassName = clazz.getName(); myName = name; }
ComponentType(Class<? extends BaseComponent> clazz,@PropertyKey(resourceBundle = "org.jetbrains.idea.devkit.DevKitBundle") String propertyKey) { myPropertyKey = propertyKey; myClassName = clazz.getName(); myName = name; }
@Override public BaseComponent getComponent(@NotNull String name) { return null; }
@Override public BaseComponent getComponent(@NotNull String s) { return null; }
@Override public BaseComponent getComponent(@NotNull String name) { return null; }
@Override public BaseComponent getComponent(@NotNull String name) { return null; }
@Override public synchronized BaseComponent getComponent(@NotNull String name) { return myNametoComponent.get(name); }
@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; }
@Override public BaseComponent getComponent(@NotNull String s) { return null; }
@Override public BaseComponent getComponent(@NotNull String name) { return null; }
@Override public BaseComponent getComponent(@NotNull String name) { return null; }
@Override public BaseComponent getComponent(@NotNull String name) { return null; }
@Override public BaseComponent getComponent(@NotNull String name) { throw new UnsupportedOperationException(); }
@Override public void updateJavaParameters(runconfigurationBase configuration,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"); } }
@Override public BaseComponent getComponent(String name) { return null; }
@Override public void updateJavaParameters(runconfigurationBase configuration,OwnJavaParameters params,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"); } }
@Override public BaseComponent getComponent(String name) { throw new UnsupportedOperationException(); }
@Override public BaseComponent getComponent(String name) { return null; }
@Override public BaseComponent getComponent(@Nonnull String name) { return null; }
com.intellij.openapi.components.ComponentConfig的实例源码
protected final void init(@Nullable ProgressIndicator indicator,@Nullable Runnable componentsRegistered) { List<ComponentConfig> componentConfigs = getComponentConfigs(); for (ComponentConfig config : componentConfigs) { registerComponents(config); } myComponentConfigCount = componentConfigs.size(); if (componentsRegistered != null) { componentsRegistered.run(); } if (indicator != null) { indicator.setIndeterminate(false); } createComponents(indicator); myComponentsCreated = true; }
@NotNull private List<ComponentConfig> getComponentConfigs() { ArrayList<ComponentConfig> componentConfigs = new ArrayList<ComponentConfig>(); boolean isDefaultProject = this instanceof Project && ((Project)this).isDefault(); boolean headless = ApplicationManager.getApplication().isHeadlessEnvironment(); for (IdeaPluginDescriptor plugin : PluginManagerCore.getPlugins()) { if (PluginManagerCore.shouldSkipPlugin(plugin)) { continue; } ComponentConfig[] configs = getMyComponentConfigsFromDescriptor(plugin); componentConfigs.ensureCapacity(componentConfigs.size() + configs.length); for (ComponentConfig config : configs) { if ((!isDefaultProject || config.isLoadForDefaultProject()) && isComponentSuitable(config.options) && config.prepareClasses(headless)) { config.pluginDescriptor = plugin; componentConfigs.add(config); } } } return componentConfigs; }
private void registerComponents(@NotNull ComponentConfig config) { ClassLoader loader = config.getClassLoader(); try { final Class<?> interfaceClass = Class.forName(config.getInterfaceClass(),true,loader); final Class<?> implementationClass = Comparing.equal(config.getInterfaceClass(),config.getImplementationClass()) ? interfaceClass : StringUtil.isEmpty(config.getImplementationClass()) ? null : Class.forName(config.getImplementationClass(),loader); Mutablepicocontainer picocontainer = getpicocontainer(); if (config.options != null && Boolean.parseBoolean(config.options.get("overrides"))) { ComponentAdapter oldAdapter = picocontainer.getComponentAdapterOfType(interfaceClass); if (oldAdapter == null) { throw new RuntimeException(config + " does not override anything"); } picocontainer.unregisterComponent(oldAdapter.getComponentKey()); } // implementationClass == null means we want to unregister this component if (implementationClass != null) { picocontainer.registerComponent(new ComponentConfigComponentAdapter(interfaceClass,implementationClass,config.getPluginId(),config.options != null && Boolean.parseBoolean(config.options.get("workspace")))); } } catch (Throwable t) { handleInitComponentError(t,null,config.getPluginId()); } }
public static void handleComponentError(Throwable t,String componentClassName,ComponentConfig config) { if (t instanceof StartupAbortedException) { throw (StartupAbortedException)t; } PluginId pluginId = config != null ? config.getPluginId() : getPluginByClassName(componentClassName); if (pluginId != null && !CORE_PLUGIN_ID.equals(pluginId.getIdString())) { getLogger().warn(t); disablePlugin(pluginId.getIdString()); String message = "Plugin '" + pluginId.getIdString() + "' Failed to initialize and will be disabled\n" + "(reason: " + t.getMessage() + ")\n\n" + ApplicationNamesInfo.getInstance().getFullProductName() + " will be restarted."; Main.showMessage("Plugin Error",message,false); throw new StartupAbortedException(t).exitCode(Main.PLUGIN_ERROR).logError(false); } else { throw new StartupAbortedException("Fatal error initializing '" + componentClassName + "'",t); } }
private static ComponentConfig[] mergeComponents(ComponentConfig[] first,ComponentConfig[] second) { if (first == null) { return second; } if (second == null) { return first; } return ArrayUtil.mergeArrays(first,second); }
@Override protected void handleInitComponentError(Throwable t,ComponentConfig config) { if (!myHandlingInitComponentError) { myHandlingInitComponentError = true; try { PluginManager.handleComponentError(t,componentClassName,config); } finally { myHandlingInitComponentError = false; } } }
public void loadComponentsConfiguration(final ComponentConfig[] components,final PluginDescriptor descriptor,final boolean defaultProject) { if (components == null) return; loadConfiguration(components,defaultProject,descriptor); }
private static ComponentConfig[] mergeComponents(ComponentConfig[] first,second); }
@Override protected void handleInitComponentError(@Nonnull Throwable ex,@Nullable String componentClassName,@Nullable ComponentConfig config) { if (!myHandlingInitComponentError) { myHandlingInitComponentError = true; try { PluginManager.handleComponentError(ex,config); } finally { myHandlingInitComponentError = false; } } }
public static void handleComponentError(@Nonnull Throwable t,@Nullable ComponentConfig config) { if (t instanceof StartupAbortedException) { throw (StartupAbortedException)t; } PluginId pluginId = null; if (config != null) { pluginId = config.getPluginId(); } if (pluginId == null || CORE_PLUGIN.equals(pluginId)) { pluginId = componentClassName == null ? null : getPluginByClassName(componentClassName); } if (pluginId == null || CORE_PLUGIN.equals(pluginId)) { if (t instanceof PicopluginExtensionInitializationException) { pluginId = ((PicopluginExtensionInitializationException)t).getPluginId(); } } if (pluginId != null && !isSystemPlugin(pluginId)) { getLogger().warn(t); if(!ApplicationProperties.isInSandBox()) { disablePlugin(pluginId.getIdString()); } StringWriter message = new StringWriter(); message.append("Plugin '").append(pluginId.getIdString()).append("' Failed to initialize and will be disabled. "); message.append(" Please restart ").append(ApplicationNamesInfo.getInstance().getFullProductName()).append('.'); message.append("\n\n"); t.printstacktrace(new PrintWriter(message)); Main.showMessage("Plugin Error",message.toString(),t); } }
public void loadComponentsConfiguration(final ComponentConfig[] components,descriptor); }
private static ComponentConfig[] mergeComponents(ComponentConfig[] first,second); }
@NotNull ComponentConfig[] getAppComponents();
@NotNull ComponentConfig[] getProjectComponents();
@NotNull ComponentConfig[] getModuleComponents();
@NotNull @Override public ComponentConfig[] getMyComponentConfigsFromDescriptor(@NotNull IdeaPluginDescriptor plugin) { return plugin.getAppComponents(); }
@NotNull public ComponentConfig[] getComponentConfigurations() { return new ComponentConfig[0]; }
@Nullable public Object getComponent(final ComponentConfig componentConfig) { return null; }
public ComponentConfig getConfig(Class componentImplementation) { throw new UnsupportedOperationException("Method getConfig not implemented in " + getClass()); }
@NotNull public ComponentConfig[] getAppComponents() { throw new IllegalStateException(); }
@NotNull public ComponentConfig[] getProjectComponents() { throw new IllegalStateException(); }
@NotNull public ComponentConfig[] getModuleComponents() { throw new IllegalStateException(); }
@NotNull public ComponentConfig[] getMyComponentConfigsFromDescriptor(@NotNull IdeaPluginDescriptor plugin) { return plugin.getAppComponents(); }
@Override @NotNull public ComponentConfig[] getAppComponents() { return myAppComponents; }
@Override @NotNull public ComponentConfig[] getProjectComponents() { return myProjectComponents; }
@Override @NotNull public ComponentConfig[] getModuleComponents() { return myModuleComponents; }
@NotNull ComponentConfig[] getAppComponents();
@NotNull ComponentConfig[] getProjectComponents();
@NotNull ComponentConfig[] getModuleComponents();
@NotNull public ComponentConfig[] getComponentConfigurations() { return new ComponentConfig[0]; }
@Nullable public Object getComponent(final ComponentConfig componentConfig) { return null; }
public ComponentConfig getConfig(Class componentImplementation) { throw new UnsupportedOperationException("Method getConfig not implemented in " + getClass()); }
@NotNull public ComponentConfig[] getAppComponents() { throw new IllegalStateException(); }
@NotNull public ComponentConfig[] getProjectComponents() { throw new IllegalStateException(); }
@NotNull public ComponentConfig[] getModuleComponents() { throw new IllegalStateException(); }
private void loadConfiguration(final ComponentConfig[] configs,final boolean defaultProject,final PluginDescriptor descriptor) { for (ComponentConfig config : configs) { loadSingleConfig(defaultProject,config,descriptor); } }
private void loadSingleConfig(final boolean defaultProject,final ComponentConfig config,final PluginDescriptor descriptor) { if (defaultProject && !config.isLoadForDefaultProject()) return; if (!myComponentManager.isComponentSuitable(config.options)) return; myComponentManager.registerComponent(config,descriptor); }
@Override @NotNull public ComponentConfig[] getAppComponents() { return myAppComponents; }
@Override @NotNull public ComponentConfig[] getProjectComponents() { return myProjectComponents; }
@Override @NotNull public ComponentConfig[] getModuleComponents() { return myModuleComponents; }
com.intellij.openapi.components.ComponentManager的实例源码
private static void collect(@NotNull ComponentManager componentManager,@NotNull Set<String> unkNownMacros,@NotNull Map<TrackingPathMacroSubstitutor,IComponentStore> substitutorToStore) { IComponentStore store = ServiceKt.getStateStore(componentManager); TrackingPathMacroSubstitutor substitutor = store.getStateStorageManager().getMacroSubstitutor(); if (substitutor == null) { return; } Set<String> macros = substitutor.getUnkNownMacros(null); if (macros.isEmpty()) { return; } unkNownMacros.addAll(macros); substitutorToStore.put(substitutor,store); }
@Override public String getSdkHomePath(@Nullable final Module module) { if (isSquirrelModule(module)) { ComponentManager holder = ObjectUtils.notNull(module,myProject); return CachedValuesManager.getManager(myProject).getCachedValue(holder,new CachedValueProvider<String>() { @Nullable @Override public Result<String> compute() { Sdk sdk = getSquirrelSdk(module); return Result.create(sdk != null ? sdk.getHomePath() : null,SquirrelIdeaSdkService.this); } }); } else { return super.getSdkHomePath(module); } }
@Nullable @Override public String getSdkVersion(@Nullable final Module module) { if (isSquirrelModule(module)) { ComponentManager holder = ObjectUtils.notNull(module,new CachedValueProvider<String>() { @Nullable @Override public Result<String> compute() { Sdk sdk = getSquirrelSdk(module); return Result.create(sdk != null ? sdk.getVersionString() : null,SquirrelIdeaSdkService.this); } }); } else { return super.getSdkVersion(module); } }
@Nullable public String getSdkVersion(@Nullable final Module module) { ComponentManager holder = ObjectUtils.notNull(module,myProject); return CachedValuesManager.getManager(myProject).getCachedValue(holder,new CachedValueProvider<String>() { @Nullable @Override public Result<String> compute() { String result = null; String sdkHomePath = getSdkHomePath(module); if (sdkHomePath != null) { result = SquirrelSdkUtil.retrieveSquirrelVersion(sdkHomePath); } return Result.create(result,SquirrelSdkService.this); } }); }
protected void installEP(final ExtensionPointName<ServiceDescriptor> pointName,final ComponentManager componentManager) { myExtensionPointName = pointName; final ExtensionPoint<ServiceDescriptor> extensionPoint = Extensions.getArea(null).getExtensionPoint(pointName); assert extensionPoint != null; final Mutablepicocontainer picocontainer = (Mutablepicocontainer)componentManager.getpicocontainer(); myExtensionPointListener = new ExtensionPointListener<ServiceDescriptor>() { public void extensionAdded(@NotNull final ServiceDescriptor descriptor,final PluginDescriptor pluginDescriptor) { if (descriptor.overrides) { ComponentAdapter oldAdapter = picocontainer.unregisterComponent(descriptor.getInterface());// Allow to re-define service implementations in plugins. if (oldAdapter == null) { throw new RuntimeException("Service: " + descriptor.getInterface() + " doesn't override anything"); } } picocontainer.registerComponent(new MyComponentAdapter(descriptor,pluginDescriptor,(ComponentManagerEx)componentManager)); } public void extensionRemoved(@NotNull final ServiceDescriptor extension,final PluginDescriptor pluginDescriptor) { picocontainer.unregisterComponent(extension.getInterface()); } }; extensionPoint.addExtensionPointListener(myExtensionPointListener); }
@Override public void run() { Object res = get(); if (res == null) return; if (res instanceof PsiElement) { if (!((PsiElement)res).isValid()) return; } else if (res instanceof ComponentManager) { if (((ComponentManager)res).isdisposed()) return; } myDelegate.run(); }
protected void installEP(@NotNull ExtensionPointName<ServiceDescriptor> pointName,@NotNull final ComponentManager componentManager) { LOG.assertTrue(myExtensionPointName == null,"Already called installEP with " + myExtensionPointName); myExtensionPointName = pointName; final ExtensionPoint<ServiceDescriptor> extensionPoint = Extensions.getArea(null).getExtensionPoint(pointName); final Mutablepicocontainer picocontainer = (Mutablepicocontainer)componentManager.getpicocontainer(); myExtensionPointListener = new ExtensionPointListener<ServiceDescriptor>() { @Override public void extensionAdded(@NotNull final ServiceDescriptor descriptor,final PluginDescriptor pluginDescriptor) { if (descriptor.overrides) { // Allow to re-define service implementations in plugins. ComponentAdapter oldAdapter = picocontainer.unregisterComponent(descriptor.getInterface()); if (oldAdapter == null) { throw new RuntimeException("Service: " + descriptor.getInterface() + " doesn't override anything"); } } if (!ComponentManagerImpl.isComponentSuitableForOs(descriptor.os)) { return; } // empty serviceImplementation means we want to unregister service if (!StringUtil.isEmpty(descriptor.getImplementation())) { picocontainer.registerComponent(new MyComponentAdapter(descriptor,(ComponentManagerEx)componentManager)); } } @Override public void extensionRemoved(@NotNull final ServiceDescriptor extension,final PluginDescriptor pluginDescriptor) { picocontainer.unregisterComponent(extension.getInterface()); } }; extensionPoint.addExtensionPointListener(myExtensionPointListener); }
private String getSdkHomeLibPath(@Nullable Module module) { ComponentManager holder = ObjectUtils.notNull(module,new CachedValueProvider<String>() { @Nullable @Override public Result<String> compute() { return Result.create(ApplicationManager.getApplication().runReadAction(new Computable<String>() { @Nullable @Override public String compute() { LibraryTable table = LibraryTablesRegistrar.getInstance().getLibraryTable(myProject); for (Library library : table.getLibraries()) { String libraryName = library.getName(); if (libraryName != null && libraryName.startsWith(LIBRARY_NAME)) { for (VirtualFile root : library.getFiles(OrderRoottype.CLASSES)) { if (isSquirrelSdkLibroot(root)) { return root.getCanonicalPath(); } } } } return null; } }),SquirrelSdkService.this); } }); }
public static StorageData loadStorageFile(ComponentManager componentManager,VirtualFile modulesXml) throws JDOMException,IOException { final Document document = JDOMUtil.loadDocument(new ByteArrayInputStream(modulesXml.contentsToByteArray())); StorageData storageData = new StorageData("project"); final Element element = document.getRootElement(); PathMacroManager.getInstance(componentManager).expandpaths(element); storageData.load(element); return storageData; }
@Override public void run() { Object res = get(); if (res == null) return; if (res instanceof PsiElement) { if (!((PsiElement)res).isValid()) return; } else if (res instanceof ComponentManager) { if (((ComponentManager)res).isdisposed()) return; } myDelegate.run(); }
@Override public void run() { Object res = get(); if (res == null) return; if (res instanceof PsiElement) { if (!((PsiElement)res).isValid()) return; } else if (res instanceof ComponentManager) { if (((ComponentManager)res).isdisposed()) return; } myDelegate.run(); }
@NotNull public static TreeMap<String,Element> loadStorageFile(@NotNull ComponentManager componentManager,@NotNull VirtualFile modulesXml) throws JDOMException,IOException { return FileStorageCoreUtil.load(JDOMUtil.loadDocument(modulesXml.contentsToByteArray()).getRootElement(),PathMacroManager.getInstance(componentManager),false); }
protected disposeAwareProjectChange(@NotNull ComponentManager componentManager) { myComponentManager = componentManager; }
public static <T> T registerComponentInstance(final ComponentManager container,final Class<T> key,final T implementation) { return registerComponentInstance((Mutablepicocontainer)container.getpicocontainer(),key,implementation); }
protected ConfigurablesGroupBase(ComponentManager componentManager,final ExtensionPointName<ConfigurableEP<Configurable>> configurablesExtensionPoint,boolean loadComponents) { myComponentManager = componentManager; myConfigurablesExtensionPoint = configurablesExtensionPoint; myLoadComponents = loadComponents; }
protected PlatformComponentManagerImpl(@Nullable ComponentManager parent) { super(parent); }
protected PlatformComponentManagerImpl(@Nullable ComponentManager parent,@NotNull String name) { super(parent,name); }
protected ComponentManagerImpl(@Nullable ComponentManager parentComponentManager) { myParentComponentManager = parentComponentManager; bootstrappicocontainer(toString()); }
protected ComponentManagerImpl(@Nullable ComponentManager parentComponentManager,@NotNull String name) { myParentComponentManager = parentComponentManager; bootstrappicocontainer(name); }
protected final ComponentManager getParentComponentManager() { return myParentComponentManager; }
public static <T> T registerComponentInstance(final ComponentManager container,implementation); }
protected ConfigurablesGroupBase(ComponentManager componentManager,boolean loadComponents) { myComponentManager = componentManager; myConfigurablesExtensionPoint = configurablesExtensionPoint; myLoadComponents = loadComponents; }
protected disposeAwareProjectChange(@Nonnull ComponentManager componentManager) { myComponentManager = componentManager; }
public static <T> T registerComponentInstance(final ComponentManager container,implementation); }
@Nonnull public MultiHostInjector getInstance(@Nonnull ComponentManager componentManager) { return instantiate(myImplementationClassHandler.getValue(),componentManager.getpicocontainer()); }
protected PlatformComponentManagerImpl(ComponentManager parent) { super(parent); }
protected PlatformComponentManagerImpl(ComponentManager parent,@Nonnull String name) { super(parent,name); }
今天关于JComponent和ComponentUI委托之间的绑定事件和component js的介绍到此结束,谢谢您的阅读,有关Angular应用里child Component如何向parent Component发送事件、com.intellij.openapi.components.BaseComponent的实例源码、com.intellij.openapi.components.ComponentConfig的实例源码、com.intellij.openapi.components.ComponentManager的实例源码等更多相关知识的信息可以在本站进行查询。
本文标签: