Java Code Examples for com.intellij.openapi.wm.IdeFrame#getProject()
The following examples show how to use
com.intellij.openapi.wm.IdeFrame#getProject() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FlutterDescriptionProvider.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 5 votes |
public static Collection<ModuleGalleryEntry> getGalleryList(boolean isCreatingProject) { boolean projectHasFlutter = isCreatingProject; // True for projects, false for modules. boolean isAndroidProject = false; // True if the host project is an Android app. OptionalValueProperty<FlutterProjectModel> sharedModel = new OptionalValueProperty<>(); ArrayList<ModuleGalleryEntry> res = new ArrayList<>(); if (!isCreatingProject) { IdeFrame frame = IdeFocusManager.getGlobalInstance().getLastFocusedFrame(); Project project = frame == null ? null : frame.getProject(); if (project == null) return res; for (Module module : FlutterModuleUtils.getModules(project)) { if (FlutterModuleUtils.isFlutterModule(module)) { projectHasFlutter = true; break; } } isAndroidProject = AndroidUtils.isAndroidProject(project); } if (projectHasFlutter) { // Makes no sense to add some Flutter templates to Android projects. if (isCreatingProject) { res.add(new FlutterApplicationGalleryEntry(sharedModel)); } res.add(new FlutterPluginGalleryEntry(sharedModel)); res.add(new FlutterPackageGalleryEntry(sharedModel)); if (isCreatingProject) { res.add(new FlutterModuleGalleryEntry(sharedModel)); } else if (isAndroidProject) { res.add(new AddToAppModuleGalleryEntry(sharedModel)); res.add(new ImportFlutterModuleGalleryEntry(sharedModel)); } } else { // isCreatingProject == false res.add(new AddToAppModuleGalleryEntry(sharedModel)); res.add(new ImportFlutterModuleGalleryEntry(sharedModel)); } return res; }
Example 2
Source File: FlutterDescriptionProvider.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 5 votes |
public static Collection<ModuleGalleryEntry> getGalleryList(boolean isCreatingProject) { boolean projectHasFlutter = isCreatingProject; // True for projects, false for modules. boolean isAndroidProject = false; // True if the host project is an Android app. OptionalValueProperty<FlutterProjectModel> sharedModel = new OptionalValueProperty<>(); ArrayList<ModuleGalleryEntry> res = new ArrayList<>(); if (!isCreatingProject) { IdeFrame frame = IdeFocusManager.getGlobalInstance().getLastFocusedFrame(); Project project = frame == null ? null : frame.getProject(); if (project == null) return res; for (Module module : FlutterModuleUtils.getModules(project)) { if (FlutterModuleUtils.isFlutterModule(module)) { projectHasFlutter = true; break; } } isAndroidProject = AndroidUtils.isAndroidProject(project); } if (projectHasFlutter) { // Makes no sense to add some Flutter templates to Android projects. if (isCreatingProject) { res.add(new FlutterApplicationGalleryEntry(sharedModel)); } res.add(new FlutterPluginGalleryEntry(sharedModel)); res.add(new FlutterPackageGalleryEntry(sharedModel)); if (isCreatingProject) { res.add(new FlutterModuleGalleryEntry(sharedModel)); } else if (isAndroidProject) { res.add(new AddToAppModuleGalleryEntry(sharedModel)); res.add(new ImportFlutterModuleGalleryEntry(sharedModel)); } } else { // isCreatingProject == false res.add(new AddToAppModuleGalleryEntry(sharedModel)); res.add(new ImportFlutterModuleGalleryEntry(sharedModel)); } return res; }
Example 3
Source File: EditorEmptyTextPainter.java From consulo with Apache License 2.0 | 5 votes |
protected static boolean isToolwindowVisible(@Nonnull JComponent splitters, @Nonnull String toolwindowId) { Window frame = SwingUtilities.getWindowAncestor(splitters); IdeFrame ideFrameIfRoot = IdeFrameUtil.findRootIdeFrame(TargetAWT.from(frame)); if (ideFrameIfRoot != null) { Project project = ideFrameIfRoot.getProject(); if (project != null) { if (!project.isInitialized()) return true; ToolWindow toolWindow = ToolWindowManager.getInstance(project).getToolWindow(toolwindowId); return toolWindow != null && toolWindow.isVisible(); } } return false; }
Example 4
Source File: CommandLineProcessor.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull private static Project findBestProject(VirtualFile virtualFile) { Project[] projects = ProjectManager.getInstance().getOpenProjects(); for (Project aProject : projects) { if (ProjectRootManager.getInstance(aProject).getFileIndex().isInContent(virtualFile)) { return aProject; } } IdeFrame frame = IdeFocusManager.getGlobalInstance().getLastFocusedFrame(); Project project = frame == null ? null : frame.getProject(); return project != null ? project : projects[0]; }
Example 5
Source File: EditorTracker.java From consulo with Apache License 2.0 | 5 votes |
private Window windowByEditor(Editor editor) { Window window = TargetAWT.from(SwingUtilities.windowForComponent(editor.getComponent())); if (window != null) { IdeFrame ideFrame = window.getUserData(IdeFrame.KEY); if (IdeFrameUtil.isRootFrame(ideFrame)) { if (myProject != ideFrame.getProject()) { return null; } } } return window; }
Example 6
Source File: FlutterProjectCreator.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 4 votes |
public void createProject() { IdeFrame frame = IdeFocusManager.getGlobalInstance().getLastFocusedFrame(); final Project projectToClose = frame != null ? frame.getProject() : null; VirtualFile baseDir = getLocationFromModel(projectToClose, true); if (baseDir == null) { return; } //noinspection ConstantConditions (Keep this refresh even if the converter is removed.) VfsUtil.markDirtyAndRefresh(false, true, true, baseDir); // Create the project files using 'flutter create'. FlutterSdk sdk = FlutterSdk.forPath(myModel.flutterSdk().get()); if (sdk == null) { FlutterMessages.showError("Error creating project", myModel.flutterSdk().get() + " is not a valid Flutter SDK"); return; } final OutputListener listener = new OutputListener(); // TODO(messick,pq): Refactor createFiles() to accept a logging interface instead of module, and display it in the wizard. ProgressManager progress = ProgressManager.getInstance(); AtomicReference<PubRoot> result = new AtomicReference<>(null); progress.runProcessWithProgressSynchronously(() -> { progress.getProgressIndicator().setIndeterminate(true); sdk.createFiles(baseDir, null, listener, makeAdditionalSettings()); VfsUtil.markDirtyAndRefresh(false, true, true, baseDir); result.set(PubRoot.forDirectory(baseDir)); }, "Creating Flutter Project", false, null); PubRoot root = result.get(); if (root == null) { String stderr = listener.getOutput().getStderr(); FlutterMessages.showError("Error creating project", stderr.isEmpty() ? "Flutter create command was unsuccessful" : stderr); return; } Project project = null; if (myModel.shouldOpenNewWindow()) { // Open the project window. EnumSet<PlatformProjectOpenProcessor.Option> options = EnumSet.noneOf(PlatformProjectOpenProcessor.Option.class); project = PlatformProjectOpenProcessor.doOpenProject(baseDir, projectToClose, -1, null, options); } if (project != null) { // Android Studio changes the default project type, so we need to set it. ProjectTypeService.setProjectType(project, ProjectOpenActivity.FLUTTER_PROJECT_TYPE); disableGradleProjectMigrationNotification(project); disableUserConfig(project); Project proj = project; StartupManager.getInstance(project).registerPostStartupActivity( () -> ApplicationManager.getApplication().invokeLater( () -> { // We want to show the Project view, not the Android view since it doesn't make the Dart code visible. DumbService.getInstance(proj).runWhenSmart( () -> { ToolWindowManager.getInstance(proj).getToolWindow(ToolWindowId.PROJECT_VIEW).activate(null); ProjectView.getInstance(proj).changeView(ProjectViewPane.ID); }); }, ModalityState.defaultModalityState())); } }
Example 7
Source File: FlutterProjectCreator.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 4 votes |
public void createProject() { IdeFrame frame = IdeFocusManager.getGlobalInstance().getLastFocusedFrame(); final Project projectToClose = frame != null ? frame.getProject() : null; VirtualFile baseDir = getLocationFromModel(projectToClose, true); if (baseDir == null) { return; } //noinspection ConstantConditions (Keep this refresh even if the converter is removed.) VfsUtil.markDirtyAndRefresh(false, true, true, baseDir); // Create the project files using 'flutter create'. FlutterSdk sdk = FlutterSdk.forPath(myModel.flutterSdk().get()); if (sdk == null) { FlutterMessages.showError("Error creating project", myModel.flutterSdk().get() + " is not a valid Flutter SDK"); return; } final OutputListener listener = new OutputListener(); // TODO(messick,pq): Refactor createFiles() to accept a logging interface instead of module, and display it in the wizard. ProgressManager progress = ProgressManager.getInstance(); AtomicReference<PubRoot> result = new AtomicReference<>(null); progress.runProcessWithProgressSynchronously(() -> { progress.getProgressIndicator().setIndeterminate(true); sdk.createFiles(baseDir, null, listener, makeAdditionalSettings()); VfsUtil.markDirtyAndRefresh(false, true, true, baseDir); result.set(PubRoot.forDirectory(baseDir)); }, "Creating Flutter Project", false, null); PubRoot root = result.get(); if (root == null) { String stderr = listener.getOutput().getStderr(); FlutterMessages.showError("Error creating project", stderr.isEmpty() ? "Flutter create command was unsuccessful" : stderr); return; } Project project = null; if (myModel.shouldOpenNewWindow()) { // Open the project window. EnumSet<PlatformProjectOpenProcessor.Option> options = EnumSet.noneOf(PlatformProjectOpenProcessor.Option.class); project = PlatformProjectOpenProcessor.doOpenProject(baseDir, projectToClose, -1, null, options); } if (project != null) { // Android Studio changes the default project type, so we need to set it. ProjectTypeService.setProjectType(project, ProjectOpenActivity.FLUTTER_PROJECT_TYPE); disableGradleProjectMigrationNotification(project); disableUserConfig(project); Project proj = project; StartupManager.getInstance(project).registerPostStartupActivity( () -> ApplicationManager.getApplication().invokeLater( () -> { // We want to show the Project view, not the Android view since it doesn't make the Dart code visible. DumbService.getInstance(proj).runWhenSmart( () -> { ToolWindowManager.getInstance(proj).getToolWindow(ToolWindowId.PROJECT_VIEW).activate(null); ProjectView.getInstance(proj).changeView(ProjectViewPane.ID); }); }, ModalityState.defaultModalityState())); } }
Example 8
Source File: WindowManagerEx.java From consulo with Apache License 2.0 | 4 votes |
@Override public void requestUserAttention(@Nonnull IdeFrame frame, boolean critical) { Project project = frame.getProject(); if (project != null) AppIcon.getInstance().requestAttention(project, critical); }
Example 9
Source File: IdeaHelper.java From azure-devops-intellij with MIT License | 2 votes |
/** * Find the project that is associated with the current open frame * Got this method from how Git gets the current project * * @return project based on repo */ public static Project getCurrentProject() { final IdeFrame frame = IdeFocusManager.getGlobalInstance().getLastFocusedFrame(); return frame == null || frame.getProject() == null ? ProjectManager.getInstance().getDefaultProject() : frame.getProject(); }