Файли
openidea/src/features/settings/index.ts
T
LU XIANGRUIтаwildcatDownstairs 86fabc7d1b feat(project-structure): add Project Structure and Open Module Settings entry points (#6834)
Adds Project Structure… to the title bar gear menu (before Settings) and Open Module Settings to the Project view context menu (below Compare With, above Mark Directory as). Open Module Settings is offered on the project folder, Maven / Gradle / Project Structure module folders and sources / resources roots; it opens Project Structure › Modules with the innermost module holding the path selected, and F4 / Cmd+Down on a module folder opens it too. The action uses a new project-structure icon.

Artifacts in Project Structure are now editable when the project has no build tool, since the IDE builds and deploys them itself; with Maven or Gradle the page stays read-only with a note. The Tomcat run configuration's "No artifacts configured" Fix opens Project Structure › Artifacts and the deployment list refreshes when artifacts change.

Refs #404

Co-authored-by: wildcatDownstairs <[email protected]>
2026-11-29 19:15:50 +08:00

136 рядки
5.6 KiB
TypeScript
Неформатований Анотація Історія

Цей файл містить неоднозначні символи Юнікоду
Цей файл містить символи Юнікоду, які можна сплутати з іншими символами. Якщо ви вважаєте, що це зроблено навмисно, можете сміливо ігнорувати це попередження. Щоб показати їх, скористайтеся кнопкою Escape.
/**
* Settings: the Settings window (⌘,, action `file.settings`) with built-in
* pages (Appearance, System Settings, Keymap, Editor › General / Font / Code
* Style / Files) plus pages contributed via `registerSettingsPage`, and the
* runtime application of keymap / UI font size / high-contrast settings.
*
* On the desktop Settings open in a native child window (`activateSettingsWindow`
* runs there) unless Appearance › "Open Settings in a separate window" is off;
* then, and in the browser build, they open as an in-page dialog.
*
* `executeAction("file.settings", "keymap")` opens a specific page;
* `file.newProjectsSettings` (IDEA's Settings for New Projects) edits the
* global layer only, which new projects inherit.
*/
import { registerActions } from "@/platform/actions";
import { call, commands, isTauri } from "@/platform/ipc";
import { isWebMode } from "@/platform/webBridge";
import { lazyWhen } from "@/ui";
import { useProject } from "@/platform/project";
import { provideSettingsSearchIndex, registerOverlay } from "@/workbench/contributions";
import { windowBackgroundHex } from "@/workbench/theme";
import { NEW_PROJECTS_PAGE, settingsActions } from "./actions";
import {
LazyProjectStructureDialog,
LazySettingsDialog,
loadBuiltinPages,
unloadBuiltinPages,
} from "./dialog/LazySettingsDialog";
import {
openModuleSettings,
openProjectStructure,
openSettings,
trackPageHistoryActions,
useSettingsDialog,
} from "./model/staging";
import {
appearanceToggleActions,
navigationBarActions,
presentationAssistantAction,
zoomActions,
} from "./appearanceRuntime";
import { PresentationAssistant } from "./presentation/PresentationAssistant";
import { activateFileTypes } from "./fileTypesRuntime";
import { trackRuntimeSettings } from "./runtime";
import { activateSettingsWindow, relaunchSettings } from "./settingsWindow";
import { installSettingsHost } from "./window/bridge";
import { showAssignShortcut, useAssignShortcut } from "./keymap/assignShortcutStore";
import { settingsSearchEntries } from "./searchIndex";
import { activatePythonStatus } from "./languages/PythonStatus";
import { activatePhpStatus } from "./languages/PhpStatus";
import { trackIconThemePages } from "./iconThemePages";
export { activateSettingsWindow };
const separateWindow = () => useProject.getState().settings?.appearance?.settingsInSeparateWindow !== false;
/** The native Settings window when it is enabled and the backend can make one, else the dialog. */
async function showSettings(page?: string, newProjects = false) {
if (isTauri() && !isWebMode() && separateWindow()) {
try {
await call(commands.windowOpenSettings(page ?? null, newProjects, windowBackgroundHex()));
return;
} catch (e) {
console.warn("settings window unavailable, using the dialog", e);
}
}
const targetPage = page ?? (newProjects ? NEW_PROJECTS_PAGE : useSettingsDialog.getState().pageId);
await loadBuiltinPages({ pageId: targetPage });
// Like a launch into the open window: go to the page, keep the edits not applied yet.
if (useSettingsDialog.getState().open) relaunchSettings({ page, newProjects });
else openSettings(page, { newProjects });
}
const useAssignShortcutOpen = () => useAssignShortcut((s) => s.actionId !== null);
export function activate(): () => void {
const disposers = [
trackRuntimeSettings(),
trackIconThemePages(),
activatePythonStatus(),
activatePhpStatus(),
unloadBuiltinPages,
registerOverlay({ id: "settings.dialog", component: LazySettingsDialog }),
registerOverlay({ id: "settings.projectStructure", component: LazyProjectStructureDialog }),
registerOverlay({ id: "settings.presentationAssistant", component: PresentationAssistant }),
activateFileTypes(),
registerOverlay({
id: "settings.assignShortcut",
component: lazyWhen(useAssignShortcutOpen, () =>
import("./keymap/AssignShortcut").then((m) => m.AssignShortcutOverlay),
),
}),
registerActions([
...zoomActions(),
...appearanceToggleActions(),
presentationAssistantAction(),
...navigationBarActions(),
...settingsActions((page, newProjects) => showSettings(page, newProjects)),
{
id: "file.projectStructure",
title: "Project Structure…",
category: "File",
icon: "project-structure",
keywords: ["project structure", "sdk", "jdk", "modules", "libraries", "facets", "artifacts", "sources"],
run: ({ arg }) => openProjectStructure(typeof arg === "string" ? arg : undefined),
},
{
// IDEA's Open Module Settings (F4 / ⌘↓ on a module in the Project view): Project
// Structure › Modules with the module holding `arg` (a path) selected.
id: "project.openModuleSettings",
title: "Open Module Settings",
category: "Project View",
icon: "project-structure",
when: "projectOpen",
keywords: ["module settings", "project structure", "module"],
run: ({ arg }) => openModuleSettings(typeof arg === "string" ? arg : undefined),
},
{
// Search Everywhere's ⌥↵ on an action (arg: the action id).
id: "settings.assignShortcut",
title: "Assign Shortcut…",
category: "Settings",
hidden: true,
run: ({ arg }) => {
if (typeof arg === "string") showAssignShortcut(arg);
},
},
]),
provideSettingsSearchIndex(settingsSearchEntries),
// navigate.back / forward drive the page history while Settings is open.
trackPageHistoryActions(),
isTauri() ? installSettingsHost() : () => {},
];
return () => disposers.reverse().forEach((d) => d());
}