Example usage for com.intellij.openapi.project ProjectManagerAdapter ProjectManagerAdapter

List of usage examples for com.intellij.openapi.project ProjectManagerAdapter ProjectManagerAdapter

Introduction

In this page you can find the example usage for com.intellij.openapi.project ProjectManagerAdapter ProjectManagerAdapter.

Prototype

ProjectManagerAdapter

Source Link

Usage

From source file:automation.RobotControl.java

License:Apache License

public void waitProjectOpening(Runnable runnable, int myTimeout) throws InterruptedException {
    ProjectManagerAdapter projectManagerListener = new ProjectManagerAdapter() {
        public void projectOpened(Project project) {
            ProjectManagerEx.getInstanceEx().removeProjectManagerListener(this);
            StartupManager.getInstance(project).registerPostStartupActivity(new Runnable() {
                @Override// w  w  w . j  a  v a 2  s. c om
                public void run() {
                    try {
                        waitIdeaOpening(runnable, project);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            });
        }
    };
    ProjectManagerEx.getInstanceEx().addProjectManagerListener(projectManagerListener);

}

From source file:com.android.tools.idea.startup.AndroidStudioInitializer.java

License:Apache License

private static void setUpExperimentalFeatures() {
    if (System.getProperty(ProfilerState.ENABLE_EXPERIMENTAL_PROFILING) != null) {
        ProjectManager.getInstance().addProjectManagerListener(new ProjectManagerAdapter() {
            @Override//from   w w  w.j ava  2 s .com
            public void projectOpened(final Project project) {
                StartupManager.getInstance(project).runWhenProjectIsInitialized(() -> {
                    ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(project);
                    ToolWindow toolWindow = toolWindowManager.registerToolWindow(
                            AndroidMonitorToolWindowFactory.ID, false, ToolWindowAnchor.BOTTOM, project, true);
                    toolWindow.setIcon(AndroidIcons.AndroidToolWindow);
                    new AndroidMonitorToolWindowFactory().createToolWindowContent(project, toolWindow);
                    toolWindow.show(null);
                });
            }
        });
    }
}

From source file:com.android.tools.idea.startup.AndroidStudioInitializer.java

License:Apache License

private static void disableGroovyLanguageInjection() {
    ProjectManager.getInstance().addProjectManagerListener(new ProjectManagerAdapter() {
        @Override/*ww  w.j av  a  2 s  . c  o m*/
        public void projectOpened(@NotNull Project project) {
            ExtensionPoint<MultiHostInjector> extensionPoint = Extensions.getArea(project)
                    .getExtensionPoint(MultiHostInjector.MULTIHOST_INJECTOR_EP_NAME);

            for (MultiHostInjector injector : extensionPoint.getExtensions()) {
                if (injector instanceof GrConcatenationInjector) {
                    extensionPoint.unregisterExtension(injector);
                    return;
                }
            }

            LOG.info(
                    "Failed to disable 'org.intellij.plugins.intelliLang.inject.groovy.GrConcatenationInjector'");
        }

    });
}

From source file:com.ansorgit.plugins.bash.lang.BashLoader.java

License:Apache License

public void initComponent() {
    ProjectManager.getInstance().addProjectManagerListener(new ProjectManagerAdapter() {
        public void projectOpened(final Project project) {
        }//w  w  w .  ja  va 2 s  .  c o  m
    });
}

From source file:com.google.cloud.tools.intellij.appengine.cloud.AppEngineCloudType.java

License:Apache License

/**
 * Initialize the App Engine Cloud Type and handle cleanup.
 *///from  ww  w  . j  a  v a2s  . co m
public AppEngineCloudType() {
    super("gcp-app-engine"); // "google-app-engine" is used by the native IJ app engine support.

    // listen for project closing event and close all active server connections
    ProjectManager projectManager = ProjectManager.getInstance();
    if (projectManager != null) {
        projectManager.addProjectManagerListener(new ProjectManagerAdapter() {
            @Override
            public void projectClosing(Project project) {
                super.projectClosing(project);
                for (ServerConnection connection : ServerConnectionManager.getInstance().getConnections()) {
                    if (connection.getServer().getType() instanceof AppEngineCloudType) {
                        connection.disconnect();
                    }
                }
            }
        });
    }

}

From source file:com.google.idea.blaze.base.plugin.dependency.ProjectDependencyMigration.java

License:Open Source License

@Override
public void initComponent() {
    ProjectManager projectManager = ProjectManager.getInstance();
    projectManager.addProjectManagerListener(new ProjectManagerAdapter() {
        @Override//ww  w  .  jav a  2s  .c o m
        public void projectOpened(Project project) {
            if (Blaze.isBlazeProject(project)) {
                PluginDependencyHelper.addDependencyOnSyncPlugin(project);
            }
        }
    });
}

From source file:com.headwire.aem.tooling.intellij.console.ConsoleLogConsole.java

License:Apache License

private Editor createLogEditor() {
    Project project = myProjectModel.getProject();
    final Editor editor = ConsoleViewUtil.setupConsoleEditor(project, false, false);
    myProjectModel.getProject().getMessageBus().connect().subscribe(ProjectManager.TOPIC,
            new ProjectManagerAdapter() {
                @Override/*from  w w w .j a  v a  2s .  c o  m*/
                public void projectClosed(Project project) {
                    if (project == myProjectModel.getProject()) {
                        EditorFactory.getInstance().releaseEditor(editor);
                    }
                }
            });

    ((EditorMarkupModel) editor.getMarkupModel()).setErrorStripeVisible(true);

    final ClearLogAction clearLog = new ClearLogAction(this);
    clearLog.registerCustomShortcutSet(
            ActionManager.getInstance().getAction(IdeActions.CONSOLE_CLEAR_ALL).getShortcutSet(),
            editor.getContentComponent());

    editor.addEditorMouseListener(new EditorPopupHandler() {
        public void invokePopup(final EditorMouseEvent event) {
            final ActionManager actionManager = ActionManager.getInstance();
            final ActionPopupMenu menu = actionManager.createActionPopupMenu(ActionPlaces.EDITOR_POPUP,
                    createPopupActions(actionManager, clearLog));
            final MouseEvent mouseEvent = event.getMouseEvent();
            menu.getComponent().show(mouseEvent.getComponent(), mouseEvent.getX(), mouseEvent.getY());
        }
    });
    return editor;
}

From source file:com.hp.alm.ali.idea.genesis.GenesisAction.java

License:Apache License

public void actionPerformed(AnActionEvent anActionEvent) {
    final GenesisDialog genesis = new GenesisDialog();
    genesis.show();// ww  w . ja  v a2s. com
    if (genesis.isOK()) {
        Checkout checkout = genesis.getCheckout();
        if (checkout != null) {
            VcsConfiguration configuration = VcsConfiguration
                    .getInstance(ProjectManager.getInstance().getDefaultProject());
            configuration.PERFORM_CHECKOUT_IN_BACKGROUND = false;
            Project p = ProjectManager.getInstance().getDefaultProject();
            checkout.setTarget(genesis.getTarget());
            checkout.doCheckout(p, new CheckoutProvider.Listener() {
                // 11.0.1
                public void directoryCheckedOut(File file, VcsKey vcsKey) {
                }

                // 10.5.4
                public void directoryCheckedOut(File file) {
                }

                public void checkoutCompleted() {
                    ProjectManagerAdapter adapter = new ProjectManagerAdapter() {
                        public void projectOpened(Project project) {
                            AliProjectConfiguration conf = project.getComponent(AliProjectConfiguration.class);
                            conf.ALM_LOCATION = genesis.getAlmLocation();
                            conf.ALM_PROJECT = genesis.getProject();
                            conf.ALM_DOMAIN = genesis.getDomain();
                            conf.ALM_USERNAME = genesis.getUsername();
                            conf.ALM_PASSWORD = genesis.getPassword();
                        }
                    };

                    ProjectManager.getInstance().addProjectManagerListener(adapter);
                    try {
                        VirtualFile file = LocalFileSystem.getInstance()
                                .findFileByIoFile(new File(genesis.getTarget()));
                        AddModuleWizard wizard = ImportModuleAction.createImportWizard(null, null, file,
                                ProjectImportProvider.PROJECT_IMPORT_PROVIDER.getExtensions());
                        NewProjectUtil.createNewProject(null, wizard);
                    } catch (Exception e) {
                        Messages.showErrorDialog(
                                "Failed to complete the operation. Please invoke the project wizard manually.\nSources were "
                                        + "checked out to the following location:\n\n " + genesis.getTarget(),
                                "Operation Failed");
                    }
                    ProjectManager.getInstance().removeProjectManagerListener(adapter);
                }
            });
        }
    }
}

From source file:com.intellij.codeInsight.completion.impl.CompletionServiceImpl.java

License:Apache License

public CompletionServiceImpl() {
    ProjectManager.getInstance().addProjectManagerListener(new ProjectManagerAdapter() {
        @Override/*  w ww  . j  ava  2  s. co  m*/
        public void projectClosing(Project project) {
            CompletionProgressIndicator indicator = getCurrentCompletion();
            if (indicator != null && indicator.getProject() == project) {
                LookupManager.getInstance(indicator.getProject()).hideActiveLookup();
                setCompletionPhase(CompletionPhase.NoCompletion);
            } else if (indicator == null) {
                setCompletionPhase(CompletionPhase.NoCompletion);
            }
        }
    });
}

From source file:com.intellij.execution.ExecutorRegistryImpl.java

License:Apache License

@Override
public void initComponent() {
    ProjectManager.getInstance().addProjectManagerListener(new ProjectManagerAdapter() {
        @Override/*from ww w.jav  a  2 s  .  com*/
        public void projectOpened(final Project project) {
            final MessageBusConnection connect = project.getMessageBus().connect(project);
            connect.subscribe(ExecutionManager.EXECUTION_TOPIC, new ExecutionAdapter() {
                @Override
                public void processStartScheduled(String executorId, ExecutionEnvironment environment) {
                    myInProgress.add(createExecutionId(executorId, environment));
                }

                @Override
                public void processNotStarted(String executorId, @NotNull ExecutionEnvironment environment) {
                    myInProgress.remove(createExecutionId(executorId, environment));
                }

                @Override
                public void processStarted(String executorId, @NotNull ExecutionEnvironment environment,
                        @NotNull ProcessHandler handler) {
                    myInProgress.remove(createExecutionId(executorId, environment));
                }
            });
        }

        @Override
        public void projectClosed(final Project project) {
            // perform cleanup
            synchronized (myInProgress) {
                for (Iterator<Trinity<Project, String, String>> it = myInProgress.iterator(); it.hasNext();) {
                    final Trinity<Project, String, String> trinity = it.next();
                    if (project.equals(trinity.first)) {
                        it.remove();
                    }
                }
            }
        }
    });

    for (Executor executor : Executor.EP_NAME.getExtensions()) {
        initExecutor(executor);
    }
}