Java Code Examples for com.intellij.openapi.project.Project#isDisposed()
The following examples show how to use
com.intellij.openapi.project.Project#isDisposed() .
These examples are extracted from open source projects.
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 Project: consulo File: CreateFromTemplateGroup.java License: Apache License 2.0 | 6 votes |
@RequiredUIAccess @Override public void update(@Nonnull AnActionEvent event) { Project project = event.getData(CommonDataKeys.PROJECT); Presentation presentation = event.getPresentation(); if(project != null && !project.isDisposed()) { FileTemplate[] allTemplates = FileTemplateManager.getInstance(project).getAllTemplates(); for (FileTemplate template : allTemplates) { if (canCreateFromTemplate(event, template)) { presentation.setEnabled(true); return; } } } presentation.setEnabled(false); }
Example 2
Source Project: consulo File: SettingsImpl.java License: Apache License 2.0 | 6 votes |
@Override public int getTabSize(Project project) { if (myTabSize != null) return myTabSize; if (myCachedTabSize != null) return myCachedTabSize; int tabSize; if (project == null || project.isDisposed()) { tabSize = CodeStyleSettingsManager.getSettings(null).getTabSize(null); } else { PsiFile file = getPsiFile(project); if (myEditor != null && myEditor.isViewer()) { FileType fileType = file != null ? file.getFileType() : null; tabSize = CodeStyleSettingsManager.getSettings(project).getIndentOptions(fileType).TAB_SIZE; } else { tabSize = CodeStyleSettingsManager.getSettings(project).getIndentOptionsByFile(file).TAB_SIZE; } } myCachedTabSize = Integer.valueOf(tabSize); return tabSize; }
Example 3
Source Project: consulo File: BaseApplication.java License: Apache License 2.0 | 6 votes |
@RequiredUIAccess @Override public void saveAll() { if (myDoNotSave) return; FileDocumentManager.getInstance().saveAllDocuments(); Project[] openProjects = ProjectManager.getInstance().getOpenProjects(); for (Project openProject : openProjects) { if (openProject.isDisposed()) { // debug for https://github.com/consulo/consulo/issues/296 LOG.error("Project is disposed: " + openProject.getName() + ", isInitialized: " + openProject.isInitialized()); continue; } ProjectEx project = (ProjectEx)openProject; project.save(); } saveSettings(); }
Example 4
Source Project: intellij File: BlazeNdkSupportEnabler.java License: Apache License 2.0 | 6 votes |
private static void doRebuildSymbols(Project project) { if (project.isDisposed()) { return; } // Notifying BuildSettingsChangeTracker in unitTestMode will leads to a dead lock. // See b/23087433 for more information. if (!ApplicationManager.getApplication().isUnitTestMode()) { OCWorkspaceEventImpl event = new OCWorkspaceEventImpl( /* resolveConfigurationsChanged= */ false, /* sourceFilesChanged= */ false, /* compilerSettingsChanged= */ true); ((OCWorkspaceModificationTrackersImpl) OCWorkspace.getInstance(project).getModificationTrackers()) .fireWorkspaceChanged(event); } }
Example 5
Source Project: consulo File: ProjectStorageUtil.java License: Apache License 2.0 | 6 votes |
private UnableToSaveProjectNotification(@Nonnull final Project project, final Collection<File> readOnlyFiles) { super("Project Settings", "Could not save project!", buildMessage(), NotificationType.ERROR, new NotificationListener() { @Override public void hyperlinkUpdate(@Nonnull Notification notification, @Nonnull HyperlinkEvent event) { final UnableToSaveProjectNotification unableToSaveProjectNotification = (UnableToSaveProjectNotification)notification; final Project _project = unableToSaveProjectNotification.getProject(); notification.expire(); if (_project != null && !_project.isDisposed()) { _project.save(); } } }); myProject = project; myFileNames = ContainerUtil.map(readOnlyFiles, File::getPath); }
Example 6
Source Project: consulo File: BreadcrumbsInitializingActivity.java License: Apache License 2.0 | 6 votes |
@Override public void runActivity(@Nonnull Project project) { if (project.isDefault() || ApplicationManager.getApplication().isUnitTestMode() || project.isDisposed()) { return; } MessageBusConnection connection = project.getMessageBus().connect(); connection.subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, new MyFileEditorManagerListener()); connection.subscribe(FileTypeManager.TOPIC, new FileTypeListener() { @Override public void fileTypesChanged(@Nonnull FileTypeEvent event) { reinitBreadcrumbsInAllEditors(project); } }); VirtualFileManager.getInstance().addVirtualFileListener(new MyVirtualFileListener(project), project); connection.subscribe(UISettingsListener.TOPIC, uiSettings -> reinitBreadcrumbsInAllEditors(project)); UIUtil.invokeLaterIfNeeded(() -> reinitBreadcrumbsInAllEditors(project)); }
Example 7
Source Project: crud-intellij-plugin File: CrudUtils.java License: Apache License 2.0 | 5 votes |
public static void runWhenInitialized(final Project project, final Runnable r) { if (project.isDisposed()) { return; } if (isNoBackgroundMode()) { r.run(); return; } if (!project.isInitialized()) { StartupManager.getInstance(project).registerPostStartupActivity(DisposeAwareRunnable.create(r, project)); return; } runDumbAware(project, r); }
Example 8
Source Project: flutter-intellij File: FlutterModuleUtils.java License: BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * If no files are open, show lib/main.dart for the given PubRoot. */ public static void autoShowMain(@NotNull Project project, @NotNull PubRoot root) { if (project.isDisposed()) return; final VirtualFile main = root.getFileToOpen(); if (main == null) return; DumbService.getInstance(project).runWhenSmart(() -> { final FileEditorManager manager = FileEditorManager.getInstance(project); if (manager.getAllEditors().length == 0) { manager.openFile(main, true); } }); }
Example 9
Source Project: consulo File: ForwardAction.java License: Apache License 2.0 | 5 votes |
public void update(AnActionEvent e){ Presentation presentation = e.getPresentation(); Project project = e.getData(CommonDataKeys.PROJECT); if (project == null || project.isDisposed()) { presentation.setEnabled(false); return; } presentation.setEnabled(IdeDocumentHistory.getInstance(project).isForwardAvailable()); }
Example 10
Source Project: mule-intellij-plugins File: FlowInPlaceRenamer.java License: Apache License 2.0 | 5 votes |
private void finish() { ourRenamersStack.pop(); if (this.myHighlighters != null) { Project project = this.myEditor.getProject(); if (project != null && !project.isDisposed()) { HighlightManager highlightManager = HighlightManager.getInstance(project); Iterator var3 = this.myHighlighters.iterator(); while (var3.hasNext()) { RangeHighlighter highlighter = (RangeHighlighter) var3.next(); highlightManager.removeSegmentHighlighter(this.myEditor, highlighter); } } } }
Example 11
Source Project: consulo File: DvcsStatusWidget.java License: Apache License 2.0 | 5 votes |
@javax.annotation.Nullable @Override public ListPopup getPopupStep() { Project project = getProject(); if (project == null || project.isDisposed()) return null; T repository = guessCurrentRepository(project); if (repository == null) return null; return getPopup(project, repository); }
Example 12
Source Project: flutter-intellij File: FlutterSdk.java License: BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Returns the Flutter SDK for a project that has a possibly broken "Dart SDK" project library. * <p> * (This can happen for a newly-cloned Flutter SDK where the Dart SDK is not cached yet.) */ @Nullable public static FlutterSdk getIncomplete(@NotNull final Project project) { if (project.isDisposed()) { return null; } final Library lib = getDartSdkLibrary(project); if (lib == null) { return null; } return getFlutterFromDartSdkLibrary(lib); }
Example 13
Source Project: consulo File: IdeFocusManager.java License: Apache License 2.0 | 5 votes |
@Nullable static IdeFocusManager getInstanceSafe(@Nullable Project project) { if (project != null && !project.isDisposed() && project.isInitialized()) { return getInstance(project); } return null; }
Example 14
Source Project: consulo File: ImageOrColorPreviewManager.java License: Apache License 2.0 | 5 votes |
private void registerListeners(final Editor editor) { if (editor.isOneLineMode()) { return; } Project project = editor.getProject(); if (project == null || project.isDisposed()) { return; } PsiFile psiFile = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument()); if (psiFile == null || psiFile instanceof PsiCompiledElement || !isSupportedFile(psiFile)) { return; } editor.addEditorMouseMotionListener(this); KeyListener keyListener = new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_SHIFT && !editor.isOneLineMode()) { PointerInfo pointerInfo = MouseInfo.getPointerInfo(); if (pointerInfo != null) { Point location = pointerInfo.getLocation(); SwingUtilities.convertPointFromScreen(location, editor.getContentComponent()); alarm.cancelAllRequests(); alarm.addRequest(new PreviewRequest(location, editor, true), 100); } } } }; editor.getContentComponent().addKeyListener(keyListener); EDITOR_LISTENER_ADDED.set(editor, keyListener); }
Example 15
Source Project: consulo File: ImageOrColorPreviewManager.java License: Apache License 2.0 | 5 votes |
@Nonnull private static Collection<PsiElement> getPsiElementsAt(Point point, Editor editor) { if (editor.isDisposed()) { return Collections.emptySet(); } Project project = editor.getProject(); if (project == null || project.isDisposed()) { return Collections.emptySet(); } final PsiDocumentManager documentManager = PsiDocumentManager.getInstance(project); final Document document = editor.getDocument(); PsiFile psiFile = documentManager.getPsiFile(document); if (psiFile == null || psiFile instanceof PsiCompiledElement || !psiFile.isValid()) { return Collections.emptySet(); } final Set<PsiElement> elements = Collections.newSetFromMap(ContainerUtil.createWeakMap()); final int offset = editor.logicalPositionToOffset(editor.xyToLogicalPosition(point)); if (documentManager.isCommitted(document)) { ContainerUtil.addIfNotNull(elements, InjectedLanguageUtil.findElementAtNoCommit(psiFile, offset)); } for (PsiFile file : psiFile.getViewProvider().getAllFiles()) { ContainerUtil.addIfNotNull(elements, file.findElementAt(offset)); } return elements; }
Example 16
Source Project: consulo File: CodeStyle.java License: Apache License 2.0 | 5 votes |
/** * Updates document's indent options from indent options providers. * <p><b>Note:</b> Calling this method directly when there is an editor associated with the document may cause the editor work * incorrectly. To keep consistency with the editor call {@code EditorEx.reinitSettings()} instead. * * @param project The project of the document. * @param document The document to update indent options for. */ public static void updateDocumentIndentOptions(@Nonnull Project project, @Nonnull Document document) { if (!project.isDisposed()) { PsiDocumentManager documentManager = PsiDocumentManager.getInstance(project); if (documentManager != null) { PsiFile file = documentManager.getPsiFile(document); if (file != null) { CommonCodeStyleSettings.IndentOptions indentOptions = getSettings(file).getIndentOptionsByFile(file, null, true, null); indentOptions.associateWithDocument(document); } } } }
Example 17
Source Project: flutter-intellij File: FlutterSdk.java License: BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Returns the Flutter SDK for a project that has a possibly broken "Dart SDK" project library. * <p> * (This can happen for a newly-cloned Flutter SDK where the Dart SDK is not cached yet.) */ @Nullable public static FlutterSdk getIncomplete(@NotNull final Project project) { if (project.isDisposed()) { return null; } final Library lib = getDartSdkLibrary(project); if (lib == null) { return null; } return getFlutterFromDartSdkLibrary(lib); }
Example 18
Source Project: consulo File: ExternalSystemTaskId.java License: Apache License 2.0 | 4 votes |
@Nonnull public static String getProjectId(@Nonnull Project project) { return project.isDisposed() ? project.getName() : project.getName() + ":" + project.getLocationHash(); }
Example 19
Source Project: CppTools File: CommunicatorCommand.java License: Apache License 2.0 | 4 votes |
public void post(Project project) { if (project.isDisposed()) { return; } Communicator.getInstance(project).sendCommand(this); }
Example 20
Source Project: intellij File: BuildFileFormatOnSaveHandler.java License: Apache License 2.0 | 4 votes |
private static boolean isProjectValid(Project project) { return project.isInitialized() && !project.isDisposed(); }