mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
show various settings dialogs in a transaction + cleanup
This commit is contained in:
@@ -24,6 +24,7 @@ import com.intellij.ide.util.projectWizard.ProjectBuilder;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.Presentation;
|
||||
import com.intellij.openapi.application.TransactionGuard;
|
||||
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
|
||||
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory;
|
||||
import com.intellij.openapi.fileChooser.FileChooserDialog;
|
||||
@@ -34,6 +35,7 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectManager;
|
||||
import com.intellij.openapi.roots.ui.configuration.actions.NewModuleAction;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.projectImport.ProjectImportProvider;
|
||||
@@ -83,9 +85,15 @@ public class ImportModuleAction extends AnAction {
|
||||
}
|
||||
|
||||
public static List<Module> createFromWizard(@Nullable Project project, AbstractProjectWizard wizard) {
|
||||
Ref<List<Module>> result = Ref.create();
|
||||
TransactionGuard.getInstance().submitTransactionAndWait(() -> result.set(doCreateFromWizard(project, wizard)));
|
||||
return result.get();
|
||||
}
|
||||
|
||||
private static List<Module> doCreateFromWizard(@Nullable Project project, AbstractProjectWizard wizard) {
|
||||
if (project == null) {
|
||||
Project newProject = NewProjectUtil.createFromWizard(wizard, null);
|
||||
return newProject == null ? Collections.<Module>emptyList() : Arrays.asList(ModuleManager.getInstance(newProject).getModules());
|
||||
return newProject == null ? Collections.emptyList() : Arrays.asList(ModuleManager.getInstance(newProject).getModules());
|
||||
}
|
||||
|
||||
final ProjectBuilder projectBuilder = wizard.getProjectBuilder();
|
||||
|
||||
@@ -26,6 +26,11 @@ import com.intellij.openapi.wm.impl.welcomeScreen.NewWelcomeScreen;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class NewProjectAction extends AnAction implements DumbAware {
|
||||
@Override
|
||||
public boolean startInTransaction() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
NewProjectWizard wizard = new NewProjectWizard(null, ModulesProvider.EMPTY_MODULES_PROVIDER, null);
|
||||
NewProjectUtil.createNewProject(getEventProject(e), wizard);
|
||||
|
||||
@@ -26,6 +26,12 @@ import com.intellij.openapi.roots.ui.configuration.ProjectStructureConfigurable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ShowStructureSettingsAction extends AnAction implements DumbAware {
|
||||
|
||||
@Override
|
||||
public boolean startInTransaction() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
Project project = e.getProject();
|
||||
|
||||
+13
-20
@@ -20,7 +20,9 @@ import com.intellij.facet.Facet;
|
||||
import com.intellij.ide.util.PropertiesComponent;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.application.AccessToken;
|
||||
import com.intellij.openapi.application.TransactionGuard;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleManager;
|
||||
import com.intellij.openapi.options.BaseConfigurable;
|
||||
@@ -67,6 +69,7 @@ import static com.intellij.openapi.roots.ui.configuration.ProjectStructureConfig
|
||||
|
||||
public class ProjectStructureConfigurable extends BaseConfigurable implements SearchableConfigurable, Place.Navigator,
|
||||
Configurable.NoMargin, Configurable.NoScroll {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.roots.ui.configuration.ProjectStructureConfigurable");
|
||||
|
||||
public static final DataKey<ProjectStructureConfigurable> KEY = DataKey.create("ProjectStructureConfiguration");
|
||||
|
||||
@@ -309,6 +312,8 @@ public class ProjectStructureConfigurable extends BaseConfigurable implements Se
|
||||
|
||||
@Override
|
||||
public void apply() throws ConfigurationException {
|
||||
LOG.assertTrue(TransactionGuard.getInstance().getContextTransaction() != null, "Project Structure should be shown in a transaction, see AnAction#startInTransaction");
|
||||
|
||||
for (Configurable each : myName2Config) {
|
||||
if (each instanceof BaseStructureConfigurable && each.isModified()) {
|
||||
((BaseStructureConfigurable)each).checkCanApply();
|
||||
@@ -331,7 +336,7 @@ public class ProjectStructureConfigurable extends BaseConfigurable implements Se
|
||||
}
|
||||
|
||||
myContext.getDaemonAnalyzer().clearCaches();
|
||||
SwingUtilities.invokeLater(() -> BuildManager.getInstance().scheduleAutoMake());
|
||||
BuildManager.getInstance().scheduleAutoMake();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -376,10 +381,6 @@ public class ProjectStructureConfigurable extends BaseConfigurable implements Se
|
||||
}
|
||||
}
|
||||
|
||||
public void hideSidePanel() {
|
||||
mySplitter.getFirstComponent().setVisible(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disposeUIResources() {
|
||||
if (!myUiInitialized) return;
|
||||
@@ -434,7 +435,7 @@ public class ProjectStructureConfigurable extends BaseConfigurable implements Se
|
||||
if (moduleToSelect != null) {
|
||||
final Module module = ModuleManager.getInstance(myProject).findModuleByName(moduleToSelect);
|
||||
assert module != null;
|
||||
place = place.putPath(ModuleStructureConfigurable.TREE_OBJECT, module).putPath(ModuleEditor.SELECTED_EDITOR_NAME, editorNameToSelect);
|
||||
place = place.putPath(MasterDetailsComponent.TREE_OBJECT, module).putPath(ModuleEditor.SELECTED_EDITOR_NAME, editorNameToSelect);
|
||||
}
|
||||
return navigateTo(place, requestFocus);
|
||||
}
|
||||
@@ -444,20 +445,20 @@ public class ProjectStructureConfigurable extends BaseConfigurable implements Se
|
||||
}
|
||||
|
||||
public Place createModulePlace(@NotNull Module module) {
|
||||
return createModulesPlace().putPath(ModuleStructureConfigurable.TREE_OBJECT, module);
|
||||
return createModulesPlace().putPath(MasterDetailsComponent.TREE_OBJECT, module);
|
||||
}
|
||||
|
||||
public ActionCallback select(@Nullable final Facet facetToSelect, final boolean requestFocus) {
|
||||
Place place = createModulesPlace();
|
||||
if (facetToSelect != null) {
|
||||
place = place.putPath(ModuleStructureConfigurable.TREE_OBJECT, facetToSelect);
|
||||
place = place.putPath(MasterDetailsComponent.TREE_OBJECT, facetToSelect);
|
||||
}
|
||||
return navigateTo(place, requestFocus);
|
||||
}
|
||||
|
||||
public ActionCallback select(@NotNull Sdk sdk, final boolean requestFocus) {
|
||||
Place place = createPlaceFor(myJdkListConfig);
|
||||
place.putPath(BaseStructureConfigurable.TREE_NAME, sdk.getName());
|
||||
place.putPath(MasterDetailsComponent.TREE_NAME, sdk.getName());
|
||||
return navigateTo(place, requestFocus);
|
||||
}
|
||||
|
||||
@@ -473,7 +474,7 @@ public class ProjectStructureConfigurable extends BaseConfigurable implements Se
|
||||
|
||||
public Place createProjectOrGlobalLibraryPlace(Library library) {
|
||||
Place place = createPlaceFor(getConfigurableFor(library));
|
||||
place.putPath(BaseStructureConfigurable.TREE_NAME, library.getName());
|
||||
place.putPath(MasterDetailsComponent.TREE_NAME, library.getName());
|
||||
return place;
|
||||
}
|
||||
|
||||
@@ -485,7 +486,7 @@ public class ProjectStructureConfigurable extends BaseConfigurable implements Se
|
||||
public Place createArtifactPlace(Artifact artifact) {
|
||||
Place place = createPlaceFor(myArtifactsStructureConfigurable);
|
||||
if (artifact != null) {
|
||||
place.putPath(BaseStructureConfigurable.TREE_NAME, artifact.getName());
|
||||
place.putPath(MasterDetailsComponent.TREE_NAME, artifact.getName());
|
||||
}
|
||||
return place;
|
||||
}
|
||||
@@ -496,7 +497,7 @@ public class ProjectStructureConfigurable extends BaseConfigurable implements Se
|
||||
return selectOrderEntry(libraryOrderEntry.getOwnerModule(), libraryOrderEntry);
|
||||
}
|
||||
Place place = createPlaceFor(getConfigurableFor(lib));
|
||||
place.putPath(BaseStructureConfigurable.TREE_NAME, libraryOrderEntry.getLibraryName());
|
||||
place.putPath(MasterDetailsComponent.TREE_NAME, libraryOrderEntry.getLibraryName());
|
||||
return navigateTo(place, requestFocus);
|
||||
}
|
||||
|
||||
@@ -600,14 +601,6 @@ public class ProjectStructureConfigurable extends BaseConfigurable implements Se
|
||||
return myJdkListConfig;
|
||||
}
|
||||
|
||||
public ProjectLibrariesConfigurable getProjectLibrariesConfig() {
|
||||
return myProjectLibrariesConfig;
|
||||
}
|
||||
|
||||
public GlobalLibrariesConfigurable getGlobalLibrariesConfig() {
|
||||
return myGlobalLibrariesConfig;
|
||||
}
|
||||
|
||||
public ModuleStructureConfigurable getModulesConfig() {
|
||||
return myModulesConfig;
|
||||
}
|
||||
|
||||
+4
-1
@@ -18,6 +18,7 @@ package com.intellij.openapi.options.newEditor;
|
||||
import com.intellij.CommonBundle;
|
||||
import com.intellij.openapi.actionSystem.DataProvider;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.TransactionGuard;
|
||||
import com.intellij.openapi.help.HelpManager;
|
||||
import com.intellij.openapi.options.Configurable;
|
||||
import com.intellij.openapi.options.ConfigurableGroup;
|
||||
@@ -74,7 +75,9 @@ public class SettingsDialog extends DialogWrapper implements DataProvider {
|
||||
|
||||
@Override
|
||||
public void show() {
|
||||
DumbService.allowStartingDumbModeInside(DumbModePermission.MAY_START_BACKGROUND, () -> super.show());
|
||||
TransactionGuard.getInstance().submitTransactionAndWait(
|
||||
() -> DumbService.allowStartingDumbModeInside(DumbModePermission.MAY_START_BACKGROUND, () ->
|
||||
super.show()));
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user