Search in sources :

Example 6 with MutablePicoContainer

use of org.picocontainer.MutablePicoContainer in project android by JetBrains.

the class AndroidTestCase method registerProjectComponent.

@NotNull
protected <T> T registerProjectComponent(@NotNull Class<T> key, @NotNull T instance) {
    MutablePicoContainer picoContainer = (MutablePicoContainer) getProject().getPicoContainer();
    @SuppressWarnings("unchecked") T old = (T) picoContainer.getComponentInstance(key.getName());
    picoContainer.unregisterComponent(key.getName());
    picoContainer.registerComponentInstance(key.getName(), instance);
    return old;
}
Also used : MutablePicoContainer(org.picocontainer.MutablePicoContainer) NotNull(org.jetbrains.annotations.NotNull)

Example 7 with MutablePicoContainer

use of org.picocontainer.MutablePicoContainer in project intellij-community by JetBrains.

the class ExtensionsImplTest method testTryPicoContainer.

@Test
public void testTryPicoContainer() {
    DefaultPicoContainer rootContainer = new DefaultPicoContainer();
    rootContainer.registerComponentInstance("plugin1", new DefaultPicoContainer(rootContainer));
    rootContainer.registerComponentInstance("plugin2", new DefaultPicoContainer(rootContainer));
    MutablePicoContainer container1 = (MutablePicoContainer) rootContainer.getComponentInstance("plugin1");
    MutablePicoContainer container2 = (MutablePicoContainer) rootContainer.getComponentInstance("plugin2");
    container1.registerComponentImplementation("component1", MyComponent1.class);
    container1.registerComponentImplementation("component1.1", MyComponent1.class);
    container2.registerComponentImplementation("component2", MyComponent2.class);
    MyInterface1 testInstance = new MyInterface1() {

        @Override
        public void run() {
        }
    };
    rootContainer.registerComponentInstance(testInstance);
    MyComponent1 component1 = (MyComponent1) container1.getComponentInstance("component1");
    assertEquals(testInstance, component1.testObject);
    rootContainer.registerComponentInstance("component1", component1);
    MyComponent1 component11 = (MyComponent1) container1.getComponentInstance("component1.1");
    rootContainer.registerComponentInstance("component11", component11);
    MyComponent2 component2 = (MyComponent2) container2.getComponentInstance("component2");
    assertEquals(testInstance, component2.testObject);
    assertTrue(Arrays.asList(component2.comp1).contains(component1));
    assertTrue(Arrays.asList(component2.comp1).contains(component11));
    rootContainer.registerComponentInstance("component2", component2);
    rootContainer.registerComponentImplementation(MyTestComponent.class);
    MyTestComponent testComponent = (MyTestComponent) rootContainer.getComponentInstance(MyTestComponent.class);
    assertTrue(Arrays.asList(testComponent.comp1).contains(component1));
    assertTrue(Arrays.asList(testComponent.comp1).contains(component11));
    assertEquals(component2, testComponent.comp2);
}
Also used : MutablePicoContainer(org.picocontainer.MutablePicoContainer) DefaultPicoContainer(org.picocontainer.defaults.DefaultPicoContainer) Test(org.junit.Test)

Example 8 with MutablePicoContainer

use of org.picocontainer.MutablePicoContainer in project intellij-plugins by JetBrains.

the class HbParserTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    final MutablePicoContainer appContainer = getApplication().getPicoContainer();
    appContainer.registerComponentInstance(PropertiesComponent.class.getName(), PropertiesComponentImpl.create());
    appContainer.registerComponentInstance(TemplateDataLanguageMappings.class.getName(), new TemplateDataLanguageMappings(getProject()));
    appContainer.registerComponentInstance(TemplateDataLanguagePatterns.class.getName(), new TemplateDataLanguagePatterns());
    addExplicitExtension(LanguageParserDefinitions.INSTANCE, HbLanguage.INSTANCE, new HbParseDefinition());
}
Also used : MutablePicoContainer(org.picocontainer.MutablePicoContainer) TemplateDataLanguagePatterns(com.intellij.psi.templateLanguages.TemplateDataLanguagePatterns) PropertiesComponent(com.intellij.ide.util.PropertiesComponent) TemplateDataLanguageMappings(com.intellij.psi.templateLanguages.TemplateDataLanguageMappings)

Example 9 with MutablePicoContainer

use of org.picocontainer.MutablePicoContainer in project intellij-plugins by JetBrains.

the class BaseEditorAction method update.

public void update(AnActionEvent e) {
    FileEditorManager editorManager = FileEditorManager.getInstance(getProject(e));
    Editor editor = editorManager.getSelectedTextEditor();
    T command = getCommand(e);
    MutablePicoContainer container = getContainer(e);
    if (command != null && editor != null && container != null) {
        VirtualFile file = FileDocumentManager.getInstance().getFile(editor.getDocument());
        if (file != null) {
            VFile vFile = VFSUtil.createFileFrom(file, editor.getProject());
            if (vFile == null) {
                return;
            }
            command.setVFile(vFile);
            setUser(container, command);
            prepareCommand(command, editor, container);
        }
    }
    super.update(e);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FileEditorManager(com.intellij.openapi.fileEditor.FileEditorManager) MutablePicoContainer(org.picocontainer.MutablePicoContainer) Editor(com.intellij.openapi.editor.Editor) VFile(jetbrains.communicator.core.vfs.VFile)

Example 10 with MutablePicoContainer

use of org.picocontainer.MutablePicoContainer in project intellij-plugins by JetBrains.

the class SearchHistoryAction method update.

public void update(AnActionEvent e) {
    super.update(e);
    Project project = getProject(e);
    MutablePicoContainer container = getContainer(project);
    SearchHistoryCommand command = getCommand(e);
    User selectedUser;
    if (container != null && project != null && command != null) {
        boolean focused = false;
        if (IDEtalkMessagesWindowImpl.PLACE_TOOLBAR.equals(e.getPlace())) {
            IDEtalkMessagesWindow messagesWindow = project.getComponent(IDEtalkMessagesWindow.class);
            selectedUser = messagesWindow.getSelectedUser();
            focused = messagesWindow.hasFocus();
        } else {
            UserListComponent userList = (UserListComponent) container.getComponentInstanceOfType(UserListComponent.class);
            selectedUser = userList.getSelectedUser();
            focused = userList.getComponent().hasFocus();
        }
        command.setUser(selectedUser);
        e.getPresentation().setEnabled(command.isEnabled() && focused);
    }
}
Also used : Project(com.intellij.openapi.project.Project) MutablePicoContainer(org.picocontainer.MutablePicoContainer) User(jetbrains.communicator.core.users.User) SearchHistoryCommand(jetbrains.communicator.commands.SearchHistoryCommand) IDEtalkMessagesWindow(jetbrains.communicator.idea.IDEtalkMessagesWindow) UserListComponent(jetbrains.communicator.ide.UserListComponent)

Aggregations

MutablePicoContainer (org.picocontainer.MutablePicoContainer)21 Test (org.junit.Test)3 PropertiesComponent (com.intellij.ide.util.PropertiesComponent)2 TemplateDataLanguageMappings (com.intellij.psi.templateLanguages.TemplateDataLanguageMappings)2 TemplateDataLanguagePatterns (com.intellij.psi.templateLanguages.TemplateDataLanguagePatterns)2 NotNull (org.jetbrains.annotations.NotNull)2 DefaultPicoContainer (org.picocontainer.defaults.DefaultPicoContainer)2 PropertiesComponentStub (com.dmarcotte.handlebars.config.PropertiesComponentStub)1 CoreASTFactory (com.intellij.core.CoreASTFactory)1 PsiBuilderFactoryImpl (com.intellij.lang.impl.PsiBuilderFactoryImpl)1 MockFileDocumentManagerImpl (com.intellij.mock.MockFileDocumentManagerImpl)1 Editor (com.intellij.openapi.editor.Editor)1 FileEditorManager (com.intellij.openapi.fileEditor.FileEditorManager)1 ProgressManager (com.intellij.openapi.progress.ProgressManager)1 CoreProgressManager (com.intellij.openapi.progress.impl.CoreProgressManager)1 Project (com.intellij.openapi.project.Project)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 PomModelImpl (com.intellij.pom.core.impl.PomModelImpl)1 TreeAspect (com.intellij.pom.tree.TreeAspect)1 PsiCachedValuesFactory (com.intellij.psi.impl.PsiCachedValuesFactory)1