public static void showModulesConfigurable(@NotNull Project project) { ApplicationManager.getApplication().assertIsDispatchThread(); if (!project.isDisposed()) { ShowSettingsUtil.getInstance().editConfigurable(project, new GoConfigurableProvider.GoProjectSettingsConfigurable(project)); } }
public static void showModulesConfigurable(@NotNull Project project) { ApplicationManager.getApplication().assertIsDispatchThread(); if (!project.isDisposed()) { Configurable configurable = new GoLibrariesConfigurableProvider(project).createConfigurable(true); ShowSettingsUtil.getInstance().editConfigurable(project, configurable); } } }
public static void showModulesConfigurable(@NotNull Module module) { ApplicationManager.getApplication().assertIsDispatchThread(); if (!module.isDisposed()) { ShowSettingsUtil.getInstance().editConfigurable(module.getProject(), new GoModuleSettingsConfigurable(module, true)); } } }
public static void showModulesConfigurable(@NotNull Project project) { ApplicationManager.getApplication().assertIsDispatchThread(); if (!project.isDisposed()) { ShowSettingsUtil.getInstance().editConfigurable(project, new BallerinaConfigurableProvider .BallerinaProjectSettingsConfigurable(project)); } }
public static void showModulesConfigurable(@NotNull Project project) { ApplicationManager.getApplication().assertIsDispatchThread(); if (!project.isDisposed()) { Configurable configurable = new BallerinaLibrariesConfigurableProvider(project).createConfigurable(true); ShowSettingsUtil.getInstance().editConfigurable(project, configurable); } } }
public static void showModulesConfigurable(@NotNull Module module) { ApplicationManager.getApplication().assertIsDispatchThread(); if (!module.isDisposed()) { ShowSettingsUtil.getInstance().editConfigurable(module.getProject(), new BallerinaModuleSettingsConfigurable(module, true)); } } }
private void asyncUpdateSdkVersion(@NotNull String sdkPath) { ApplicationManager.getApplication().assertIsDispatchThread(); ((CardLayout)myVersionPanel.getLayout()).show(myVersionPanel, VERSION_GETTING); if (!myAlarm.isDisposed()) { myAlarm.cancelAllRequests(); myAlarm.addRequest(() -> { String version = GoSdkUtil.retrieveGoVersion(GoSdkUtil.adjustSdkPath(sdkPath)); ApplicationManager.getApplication().invokeLater(() -> { if (!Disposer.isDisposed(myDisposable)) { setVersion(version); } }, ModalityState.any()); }, 100); } }
private void asyncUpdateSdkVersion(@NotNull String sdkPath) { ApplicationManager.getApplication().assertIsDispatchThread(); ((CardLayout) myVersionPanel.getLayout()).show(myVersionPanel, VERSION_GETTING); if (!myAlarm.isDisposed()) { myAlarm.cancelAllRequests(); myAlarm.addRequest(() -> { String version = BallerinaSdkUtil.retrieveBallerinaVersion(BallerinaSdkUtil.adjustSdkPath(sdkPath)); ApplicationManager.getApplication().invokeLater(() -> { if (!Disposer.isDisposed(myDisposable)) { setVersion(version); } }, ModalityState.any()); }, 100); } }
private void attachLibraries(@NotNull Collection<VirtualFile> libraryRoots, Set<VirtualFile> exclusions) { ApplicationManager.getApplication().assertIsDispatchThread(); if (!libraryRoots.isEmpty()) { ApplicationManager.getApplication().runWriteAction(() -> { ModuleRootManager model = ModuleRootManager.getInstance(myModule); LibraryOrderEntry goLibraryEntry = OrderEntryUtil.findLibraryOrderEntry(model, getLibraryName()); if (goLibraryEntry != null && goLibraryEntry.isValid()) { Library library = goLibraryEntry.getLibrary(); if (library != null && !((LibraryEx)library).isDisposed()) { fillLibrary(library, libraryRoots, exclusions); } } else { LibraryTable libraryTable = LibraryTablesRegistrar.getInstance().getLibraryTable(myModule.getProject()); Library library = libraryTable.createLibrary(getLibraryName()); fillLibrary(library, libraryRoots, exclusions); ModuleRootModificationUtil.addDependency(myModule, library); } }); showNotification(myModule.getProject()); } else { removeLibraryIfNeeded(); } }
private void attachLibraries(@NotNull Collection<VirtualFile> libraryRoots, Set<VirtualFile> exclusions) { ApplicationManager.getApplication().assertIsDispatchThread(); if (!libraryRoots.isEmpty()) { ApplicationManager.getApplication().runWriteAction(() -> { ModuleRootManager model = ModuleRootManager.getInstance(myModule); LibraryOrderEntry ballerinaLibraryEntry = OrderEntryUtil.findLibraryOrderEntry(model, getLibraryName()); if (ballerinaLibraryEntry != null && ballerinaLibraryEntry.isValid()) { Library library = ballerinaLibraryEntry.getLibrary(); if (library != null && !((LibraryEx) library).isDisposed()) { fillLibrary(library, libraryRoots, exclusions); } } else { LibraryTable libraryTable = LibraryTablesRegistrar.getInstance().getLibraryTable(myModule .getProject()); Library library = libraryTable.createLibrary(getLibraryName()); fillLibrary(library, libraryRoots, exclusions); ModuleRootModificationUtil.addDependency(myModule, library); } }); showNotification(myModule.getProject()); } else { removeLibraryIfNeeded(); } }
private void removeLibraryIfNeeded() { ApplicationManager.getApplication().assertIsDispatchThread(); ModifiableModelsProvider modelsProvider = ModifiableModelsProvider.SERVICE.getInstance(); ModifiableRootModel model = modelsProvider.getModuleModifiableModel(myModule); LibraryOrderEntry goLibraryEntry = OrderEntryUtil.findLibraryOrderEntry(model, getLibraryName()); if (goLibraryEntry != null) { ApplicationManager.getApplication().runWriteAction(() -> { Library library = goLibraryEntry.getLibrary(); if (library != null) { LibraryTable table = library.getTable(); if (table != null) { table.removeLibrary(library); model.removeOrderEntry(goLibraryEntry); modelsProvider.commitModuleModifiableModel(model); } } else { modelsProvider.disposeModuleModifiableModel(model); } }); } else { ApplicationManager.getApplication().runWriteAction(() -> modelsProvider.disposeModuleModifiableModel(model)); } }
private void removeLibraryIfNeeded() { ApplicationManager.getApplication().assertIsDispatchThread(); ModifiableModelsProvider modelsProvider = ModifiableModelsProvider.SERVICE.getInstance(); ModifiableRootModel model = modelsProvider.getModuleModifiableModel(myModule); LibraryOrderEntry ballerinaLibraryEntry = OrderEntryUtil.findLibraryOrderEntry(model, getLibraryName()); if (ballerinaLibraryEntry != null) { ApplicationManager.getApplication().runWriteAction(() -> { Library library = ballerinaLibraryEntry.getLibrary(); if (library != null) { LibraryTable table = library.getTable(); if (table != null) { table.removeLibrary(library); model.removeOrderEntry(ballerinaLibraryEntry); modelsProvider.commitModuleModifiableModel(model); } } else { modelsProvider.disposeModuleModifiableModel(model); } }); } else { ApplicationManager.getApplication().runWriteAction(() -> modelsProvider.disposeModuleModifiableModel(model)); } }
public void load(Collection<SonarQubeServer> servers, boolean enabled, @Nullable String selectedServerId, @Nullable String selectedProjectKey) { ApplicationManager.getApplication().assertIsDispatchThread(); this.bindEnable.setSelected(enabled); serverComboBox.removeAllItems(); setServerList(servers, selectedServerId); if (selectedProjectKey != null) { projectKeyTextField.setText(selectedProjectKey); } }
private void updateEditor(String text) { ApplicationManager.getApplication().assertIsDispatchThread(); if (editor == null) { panel.removeAll(); editor = createEditor(); panel.add(editor, BorderLayout.CENTER); } SwingHelper.setHtml(editor, text, null); editor.setCaretPosition(0); panel.revalidate(); }
public void serversChanged(List<SonarQubeServer> serverList) { ApplicationManager.getApplication().assertIsDispatchThread(); // keep selection if possible String previousSelectedStorageId = getSelectedStorageId(); serverComboBox.removeAllItems(); setServerList(serverList, previousSelectedStorageId); }
/** * If no server is selected, some components items disabled. * Should be called when selected Server changes. */ private void onServerSelected() { ApplicationManager.getApplication().assertIsDispatchThread(); boolean serverSelected = getSelectedStorageId() != null; projectKeyTextField.setEnabled(serverSelected); projectKeyTextField.setEditable(serverSelected); searchProjectButton.setEnabled(serverSelected); }
/** * Must run in EDT */ public void openAnalysisResults() { ApplicationManager.getApplication().assertIsDispatchThread(); ToolWindow toolWindow = getToolWindow(); if (toolWindow != null) { toolWindow.show(() -> selectTab(toolWindow, SonarLintToolWindowFactory.TAB_ANALYSIS_RESULTS)); } }
/** * Must run in EDT */ public void openCurrentFile() { ApplicationManager.getApplication().assertIsDispatchThread(); ToolWindow toolWindow = getToolWindow(); if (toolWindow != null) { toolWindow.show(() -> selectTab(toolWindow, SonarLintToolWindowFactory.TAB_CURRENT_FILE)); } }
/** * Must be called from EDT */ public static boolean saveFiles(final Collection<VirtualFile> virtualFiles) { ApplicationManager.getApplication().assertIsDispatchThread(); boolean[] success = new boolean[] {true}; ApplicationManager.getApplication().runWriteAction(() -> { for (VirtualFile file : virtualFiles) { if (!saveFile(file)) { success[0] = false; } } }); return success[0]; }
/** * Must be called from EDT */ private static boolean saveFile(final VirtualFile virtualFile) { ApplicationManager.getApplication().assertIsDispatchThread(); final FileDocumentManager fileDocumentManager = FileDocumentManager.getInstance(); if (fileDocumentManager.isFileModified(virtualFile)) { final Document document = fileDocumentManager.getDocument(virtualFile); if (document != null) { fileDocumentManager.saveDocument(document); return true; } } return false; }