mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Module configuration UI: hide tab header if one tab is shown
This commit is contained in:
+95
@@ -0,0 +1,95 @@
|
||||
package com.intellij.openapi.roots.ui.configuration;
|
||||
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleConfigurationEditor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.ui.navigation.Place;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* @author ksafonov
|
||||
*/
|
||||
public abstract class HeaderHidingTabbedModuleEditor extends TabbedModuleEditor {
|
||||
|
||||
public HeaderHidingTabbedModuleEditor(Project project, ModulesProvider modulesProvider, @NotNull Module module) {
|
||||
super(project, modulesProvider, module);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JComponent createCenterPanel() {
|
||||
ModuleConfigurationEditor singleEditor = getSingleEditor();
|
||||
if (singleEditor != null) {
|
||||
final JComponent component = singleEditor.createComponent();
|
||||
singleEditor.reset();
|
||||
return component;
|
||||
}
|
||||
else {
|
||||
return super.createCenterPanel();
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private ModuleConfigurationEditor getSingleEditor() {
|
||||
return myEditors.size() == 1 ? myEditors.get(0) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModuleConfigurationEditor getSelectedEditor() {
|
||||
ModuleConfigurationEditor singleEditor = getSingleEditor();
|
||||
return singleEditor != null ? singleEditor : super.getSelectedEditor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectEditor(String displayName) {
|
||||
if (displayName != null) {
|
||||
ModuleConfigurationEditor singleEditor = getSingleEditor();
|
||||
if (singleEditor != null) {
|
||||
assert singleEditor.getDisplayName().equals(displayName);
|
||||
}
|
||||
else {
|
||||
super.selectEditor(displayName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void restoreSelectedEditor() {
|
||||
ModuleConfigurationEditor singleEditor = getSingleEditor();
|
||||
if (singleEditor == null) {
|
||||
super.restoreSelectedEditor();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModuleConfigurationEditor getEditor(@NotNull String displayName) {
|
||||
ModuleConfigurationEditor singleEditor = getSingleEditor();
|
||||
if (singleEditor != null) {
|
||||
assert singleEditor.getDisplayName().equals(displayName);
|
||||
return singleEditor;
|
||||
}
|
||||
else {
|
||||
return super.getEditor(displayName);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void disposeCenterPanel() {
|
||||
if (getSingleEditor() == null) {
|
||||
super.disposeCenterPanel();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void queryPlace(@NotNull Place place) {
|
||||
ModuleConfigurationEditor singleEditor = getSingleEditor();
|
||||
if (singleEditor != null) {
|
||||
place.putPath(SELECTED_EDITOR_NAME, singleEditor.getDisplayName());
|
||||
}
|
||||
else {
|
||||
super.queryPlace(place);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -62,6 +62,7 @@ import java.util.List;
|
||||
@SuppressWarnings({"AssignmentToStaticFieldFromInstanceMethod"})
|
||||
public abstract class ModuleEditor implements Place.Navigator, Disposable {
|
||||
private static final ExtensionPointName<ModuleConfigurableEP> MODULE_CONFIGURABLES = ExtensionPointName.create("com.intellij.moduleConfigurable");
|
||||
public static final String SELECTED_EDITOR_NAME = "selectedEditor";
|
||||
|
||||
private final Project myProject;
|
||||
private JPanel myGenericSettingsPanel;
|
||||
|
||||
+1
-1
@@ -162,7 +162,7 @@ public class ModulesConfigurator implements ModulesProvider, ModuleEditor.Change
|
||||
}
|
||||
|
||||
private ModuleEditor doCreateModuleEditor(final Module module) {
|
||||
final ModuleEditor moduleEditor = new TabbedModuleEditor(myProject, this, module) {
|
||||
final ModuleEditor moduleEditor = new HeaderHidingTabbedModuleEditor(myProject, this, module) {
|
||||
@Override
|
||||
public ProjectFacetsConfigurator getFacetsConfigurator() {
|
||||
return myFacetsConfigurator;
|
||||
|
||||
+1
-1
@@ -375,7 +375,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(TabbedModuleEditor.EDITOR_NAME, editorNameToSelect);
|
||||
place = place.putPath(ModuleStructureConfigurable.TREE_OBJECT, module).putPath(ModuleEditor.SELECTED_EDITOR_NAME, editorNameToSelect);
|
||||
}
|
||||
return navigateTo(place, requestFocus);
|
||||
}
|
||||
|
||||
+2
-3
@@ -18,7 +18,6 @@ import javax.swing.event.ChangeEvent;
|
||||
*/
|
||||
public abstract class TabbedModuleEditor extends ModuleEditor {
|
||||
|
||||
public static final String EDITOR_NAME = "selectedEditor";
|
||||
private static final String SELECTED_EDITOR_KEY = TabbedModuleEditor.class.getName() + ".selectedEditor";
|
||||
|
||||
private TabbedPaneWrapper myTabbedPane;
|
||||
@@ -66,13 +65,13 @@ public abstract class TabbedModuleEditor extends ModuleEditor {
|
||||
|
||||
public ActionCallback navigateTo(@Nullable final Place place, final boolean requestFocus) {
|
||||
if (place != null) {
|
||||
myTabbedPane.setSelectedTitle((String)place.getPath(EDITOR_NAME));
|
||||
selectEditor((String)place.getPath(SELECTED_EDITOR_NAME));
|
||||
}
|
||||
return new ActionCallback.Done();
|
||||
}
|
||||
|
||||
public void queryPlace(@NotNull final Place place) {
|
||||
place.putPath(EDITOR_NAME, getSavedSelectedEditor());
|
||||
place.putPath(SELECTED_EDITOR_NAME, getSavedSelectedEditor());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
Reference in New Issue
Block a user