use of com.intellij.openapi.progress.ProgressIndicator in project intellij-community by JetBrains.
the class InitialConfigurationDialog method doOKAction.
@Override
protected void doOKAction() {
Project project = CommonDataKeys.PROJECT.getData(DataManager.getInstance().getDataContext(myMainPanel));
super.doOKAction();
// set keymap
((KeymapManagerImpl) KeymapManager.getInstance()).setActiveKeymap((Keymap) myKeymapComboBox.getSelectedItem());
// set color scheme
EditorColorsManager.getInstance().setGlobalScheme((EditorColorsScheme) myColorSchemeComboBox.getSelectedItem());
// create default todo_pattern for color scheme
TodoConfiguration.getInstance().resetToDefaultTodoPatterns();
final boolean createScript = myCreateScriptCheckbox.isSelected();
final boolean createEntry = myCreateEntryCheckBox.isSelected();
if (createScript || createEntry) {
final String pathName = myScriptPathTextField.getText();
final boolean globalEntry = myGlobalEntryCheckBox.isSelected();
ProgressManager.getInstance().run(new Task.Backgroundable(project, getTitle()) {
@Override
public void run(@NotNull final ProgressIndicator indicator) {
indicator.setFraction(0.0);
if (createScript) {
indicator.setText("Creating launcher script...");
try {
CreateLauncherScriptAction.createLauncherScript(pathName);
} catch (Exception e) {
CreateLauncherScriptAction.reportFailure(e, getProject());
}
}
indicator.setFraction(0.5);
if (createEntry) {
indicator.setText("Creating desktop entry...");
try {
CreateDesktopEntryAction.createDesktopEntry(globalEntry);
} catch (Exception e) {
CreateDesktopEntryAction.reportFailure(e, getProject());
}
}
indicator.setFraction(1.0);
}
});
}
UIManager.LookAndFeelInfo info = (UIManager.LookAndFeelInfo) myAppearanceComboBox.getSelectedItem();
LafManagerImpl lafManager = (LafManagerImpl) LafManager.getInstance();
if (info.getName().contains("Darcula") != (LafManager.getInstance().getCurrentLookAndFeel() instanceof DarculaLookAndFeelInfo)) {
lafManager.setLookAndFeelAfterRestart(info);
String message = "IDE appearance settings will be applied after restart. Would you like to restart now?";
int rc = Messages.showYesNoDialog(project, message, "IDE Appearance", Messages.getQuestionIcon());
if (rc == Messages.YES) {
((ApplicationImpl) ApplicationManager.getApplication()).restart(true);
}
} else if (!info.equals(lafManager.getCurrentLookAndFeel())) {
lafManager.setCurrentLookAndFeel(info);
lafManager.updateUI();
}
}
use of com.intellij.openapi.progress.ProgressIndicator in project intellij-community by JetBrains.
the class DaemonCodeAnalyzerImpl method runMainPasses.
@Override
@NotNull
public List<HighlightInfo> runMainPasses(@NotNull PsiFile psiFile, @NotNull Document document, @NotNull final ProgressIndicator progress) {
if (ApplicationManager.getApplication().isDispatchThread()) {
throw new IllegalStateException("Must not run highlighting from under EDT");
}
if (!ApplicationManager.getApplication().isReadAccessAllowed()) {
throw new IllegalStateException("Must run highlighting from under read action");
}
ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
if (!(indicator instanceof DaemonProgressIndicator)) {
throw new IllegalStateException("Must run highlighting under progress with DaemonProgressIndicator");
}
// clear status maps to run passes from scratch so that refCountHolder won't conflict and try to restart itself on partially filled maps
myFileStatusMap.markAllFilesDirty("prepare to run main passes");
stopProcess(false, "disable background daemon");
myPassExecutorService.cancelAll(true);
final List<HighlightInfo> result;
try {
result = new ArrayList<>();
final VirtualFile virtualFile = psiFile.getVirtualFile();
if (virtualFile != null && !virtualFile.getFileType().isBinary()) {
List<TextEditorHighlightingPass> passes = TextEditorHighlightingPassRegistrarEx.getInstanceEx(myProject).instantiateMainPasses(psiFile, document, HighlightInfoProcessor.getEmpty());
Collections.sort(passes, (o1, o2) -> {
if (o1 instanceof GeneralHighlightingPass)
return -1;
if (o2 instanceof GeneralHighlightingPass)
return 1;
return 0;
});
try {
for (TextEditorHighlightingPass pass : passes) {
pass.doCollectInformation(progress);
result.addAll(pass.getInfos());
}
} catch (ProcessCanceledException e) {
LOG.debug("Canceled: " + progress);
throw e;
}
}
} finally {
stopProcess(true, "re-enable background daemon after main passes run");
}
return result;
}
use of com.intellij.openapi.progress.ProgressIndicator in project intellij-community by JetBrains.
the class LocalInspectionsPass method visitPriorityElementsAndInit.
@NotNull
private List<InspectionContext> visitPriorityElementsAndInit(@NotNull Map<LocalInspectionToolWrapper, Set<String>> toolToSpecifiedLanguageIds, @NotNull final InspectionManager iManager, final boolean isOnTheFly, @NotNull final ProgressIndicator indicator, @NotNull final List<PsiElement> elements, @NotNull final LocalInspectionToolSession session, @NotNull final Set<String> elementDialectIds) {
final List<InspectionContext> init = new ArrayList<>();
List<Map.Entry<LocalInspectionToolWrapper, Set<String>>> entries = new ArrayList<>(toolToSpecifiedLanguageIds.entrySet());
Processor<Map.Entry<LocalInspectionToolWrapper, Set<String>>> processor = pair -> {
LocalInspectionToolWrapper toolWrapper = pair.getKey();
Set<String> dialectIdsSpecifiedForTool = pair.getValue();
runToolOnElements(toolWrapper, dialectIdsSpecifiedForTool, iManager, isOnTheFly, indicator, elements, session, init, elementDialectIds);
return true;
};
boolean result = JobLauncher.getInstance().invokeConcurrentlyUnderProgress(entries, indicator, myFailFastOnAcquireReadAction, processor);
if (!result)
throw new ProcessCanceledException();
return init;
}
use of com.intellij.openapi.progress.ProgressIndicator in project intellij-community by JetBrains.
the class LocalInspectionsPass method doInspectInBatch.
public void doInspectInBatch(@NotNull final GlobalInspectionContextImpl context, @NotNull final InspectionManager iManager, @NotNull final List<LocalInspectionToolWrapper> toolWrappers) {
final ProgressIndicator progress = ProgressManager.getInstance().getProgressIndicator();
inspect(new ArrayList<>(toolWrappers), iManager, false, false, progress);
addDescriptorsFromInjectedResults(iManager, context);
List<InspectionResult> resultList = result.get(getFile());
if (resultList == null)
return;
for (InspectionResult inspectionResult : resultList) {
LocalInspectionToolWrapper toolWrapper = inspectionResult.tool;
for (ProblemDescriptor descriptor : inspectionResult.foundProblems) {
addDescriptors(toolWrapper, descriptor, context);
}
}
}
use of com.intellij.openapi.progress.ProgressIndicator in project intellij-community by JetBrains.
the class HTMLExportUtil method writeFile.
public static void writeFile(final String folder, @NonNls final String fileName, CharSequence buf, final Project project) {
ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
final File fullPath = new File(folder + File.separator + fileName);
if (indicator != null) {
ProgressManager.checkCanceled();
indicator.setText(InspectionsBundle.message("inspection.export.generating.html.for", fullPath.getAbsolutePath()));
}
try {
FileWriter writer = null;
try {
final File dir = fullPath.getParentFile();
if (!dir.exists() && !dir.mkdirs()) {
showErrorMessage("Can't create dir", dir, project);
return;
}
if (!dir.canWrite() && !fullPath.canWrite()) {
showErrorMessage("Permission denied", fullPath, project);
return;
}
writer = new FileWriter(fullPath, false);
writer.write(buf.toString().toCharArray());
} finally {
if (writer != null) {
try {
writer.close();
} catch (IOException e) {
//Cannot do anything in case of exception
}
}
}
} catch (IOException e) {
showErrorMessage(String.valueOf(e.getCause()), fullPath, project);
}
}
Aggregations