Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix localization import order #12993

Merged
merged 3 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

<a name="breaking_changes_1.43.0">[Breaking Changes:](#breaking_changes_1.43.0)</a>

- [core] moved `FrontendApplicationContribution` from `@theia/core/lib/browser/frontend-application` to `@theia/core/lib/browser/frontend-application-contribution` [#12993](https://github.com/eclipse-theia/theia/pull/12993)
- [core] removed `SETTINGS_OPEN` menupath constant - replaced by `MANAGE_GENERAL` [#12803](https://github.com/eclipse-theia/theia/pull/12803)
- [core] removed `SETTINGS__THEME` menupath constant - replaced by `MANAGE_SETTINGS` [#12803](https://github.com/eclipse-theia/theia/pull/12803)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { injectable, inject, named } from 'inversify';
import { ColorRegistry } from './color-registry';
import { Emitter } from '../common/event';
import { ThemeService } from './theming';
import { FrontendApplicationContribution } from './frontend-application';
import { FrontendApplicationContribution } from './frontend-application-contribution';
import { ContributionProvider } from '../common/contribution-provider';
import { Disposable, DisposableCollection } from '../common/disposable';
import { DEFAULT_BACKGROUND_COLOR_STORAGE_KEY } from './frontend-application-config-provider';
Expand Down
3 changes: 2 additions & 1 deletion packages/core/src/browser/common-frontend-contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ import debounce = require('lodash.debounce');
import { injectable, inject, optional } from 'inversify';
import { MAIN_MENU_BAR, MANAGE_MENU, MenuContribution, MenuModelRegistry, ACCOUNTS_MENU } from '../common/menu';
import { KeybindingContribution, KeybindingRegistry } from './keybinding';
import { FrontendApplication, FrontendApplicationContribution, OnWillStopAction } from './frontend-application';
import { FrontendApplication } from './frontend-application';
import { FrontendApplicationContribution, OnWillStopAction } from './frontend-application-contribution';
import { CommandContribution, CommandRegistry, Command } from '../common/command';
import { UriAwareCommandHandler } from '../common/uri-command-handler';
import { SelectionService } from '../common/selection-service';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/browser/connection-status-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import { inject, injectable, optional, postConstruct } from 'inversify';
import { ILogger } from '../common/logger';
import { Event, Emitter } from '../common/event';
import { DefaultFrontendApplicationContribution } from './frontend-application';
import { DefaultFrontendApplicationContribution } from './frontend-application-contribution';
import { StatusBar, StatusBarAlignment } from './status-bar/status-bar';
import { WebSocketConnectionProvider } from './messaging/ws-connection-provider';
import { Disposable, DisposableCollection, nls } from '../common';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/browser/dialogs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { injectable, inject } from 'inversify';
import { Disposable, MaybePromise, CancellationTokenSource, nls } from '../common';
import { Key } from './keyboard/keys';
import { Widget, BaseWidget, Message, addKeyListener, codiconArray } from './widgets';
import { FrontendApplicationContribution } from './frontend-application';
import { FrontendApplicationContribution } from './frontend-application-contribution';

@injectable()
export class DialogProps {
Expand Down
110 changes: 110 additions & 0 deletions packages/core/src/browser/frontend-application-contribution.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
// *****************************************************************************
// Copyright (C) 2023 TypeFox and others.
//
// This program and the accompanying materials are made available under the
// terms of the Eclipse Public License v. 2.0 which is available at
// http://www.eclipse.org/legal/epl-2.0.
//
// This Source Code may also be made available under the following Secondary
// Licenses when the conditions for such availability set forth in the Eclipse
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
// with the GNU Classpath Exception which is available at
// https://www.gnu.org/software/classpath/license.html.
//
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
// *****************************************************************************

import type { FrontendApplication } from './frontend-application';
import { MaybePromise, isObject } from '../common/types';
import { StopReason } from '../common/frontend-application-state';
import { injectable } from 'inversify';

/**
* Clients can implement to get a callback for contributing widgets to a shell on start.
*/
export const FrontendApplicationContribution = Symbol('FrontendApplicationContribution');
export interface FrontendApplicationContribution {

/**
* Called on application startup before configure is called.
*/
initialize?(): void;

/**
* Called before commands, key bindings and menus are initialized.
* Should return a promise if it runs asynchronously.
*/
configure?(app: FrontendApplication): MaybePromise<void>;

/**
* Called when the application is started. The application shell is not attached yet when this method runs.
* Should return a promise if it runs asynchronously.
*/
onStart?(app: FrontendApplication): MaybePromise<void>;

/**
* Called on `beforeunload` event, right before the window closes.
* Return `true` or an OnWillStopAction in order to prevent exit.
* Note: No async code allowed, this function has to run on one tick.
*/
onWillStop?(app: FrontendApplication): boolean | undefined | OnWillStopAction<unknown>;

/**
* Called when an application is stopped or unloaded.
*
* Note that this is implemented using `window.beforeunload` which doesn't allow any asynchronous code anymore.
* I.e. this is the last tick.
*/
onStop?(app: FrontendApplication): void;

/**
* Called after the application shell has been attached in case there is no previous workbench layout state.
* Should return a promise if it runs asynchronously.
*/
initializeLayout?(app: FrontendApplication): MaybePromise<void>;

/**
* An event is emitted when a layout is initialized, but before the shell is attached.
*/
onDidInitializeLayout?(app: FrontendApplication): MaybePromise<void>;
}

export interface OnWillStopAction<T = unknown> {
/**
* @resolves to a prepared value to be passed into the `action` function.
*/
prepare?: (stopReason?: StopReason) => MaybePromise<T>;
/**
* @resolves to `true` if it is safe to close the application; `false` otherwise.
*/
action: (prepared: T, stopReason?: StopReason) => MaybePromise<boolean>;
/**
* A descriptive string for the reason preventing close.
*/
reason: string;
/**
* A number representing priority. Higher priority items are run later.
* High priority implies that some options of this check will have negative impacts if
* the user subsequently cancels the shutdown.
*/
priority?: number;
}

export namespace OnWillStopAction {
export function is(candidate: unknown): candidate is OnWillStopAction {
return isObject(candidate) && 'action' in candidate && 'reason' in candidate;
}
}

/**
* Default frontend contribution that can be extended by clients if they do not want to implement any of the
* methods from the interface but still want to contribute to the frontend application.
*/
@injectable()
export abstract class DefaultFrontendApplicationContribution implements FrontendApplicationContribution {

initialize(): void {
// NOOP
}

}
3 changes: 2 additions & 1 deletion packages/core/src/browser/frontend-application-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ import {
MenuCommandExecutorImpl
} from '../common';
import { KeybindingRegistry, KeybindingContext, KeybindingContribution } from './keybinding';
import { FrontendApplication, FrontendApplicationContribution, DefaultFrontendApplicationContribution } from './frontend-application';
import { FrontendApplication } from './frontend-application';
import { FrontendApplicationContribution, DefaultFrontendApplicationContribution } from './frontend-application-contribution';
import { DefaultOpenerService, OpenerService, OpenHandler } from './opener-service';
import { HttpOpenHandler } from './http-open-handler';
import { CommonFrontendContribution } from './common-frontend-contribution';
Expand Down
94 changes: 2 additions & 92 deletions packages/core/src/browser/frontend-application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// *****************************************************************************

import { inject, injectable, named } from 'inversify';
import { ContributionProvider, CommandRegistry, MenuModelRegistry, isOSX, BackendStopwatch, LogLevel, Stopwatch, isObject } from '../common';
import { ContributionProvider, CommandRegistry, MenuModelRegistry, isOSX, BackendStopwatch, LogLevel, Stopwatch } from '../common';
import { MaybePromise } from '../common/types';
import { KeybindingRegistry } from './keybinding';
import { Widget } from './widgets';
Expand All @@ -26,100 +26,10 @@ import { preventNavigation, parseCssTime, animationFrame } from './browser';
import { CorePreferences } from './core-preferences';
import { WindowService } from './window/window-service';
import { TooltipService } from './tooltip-service';
import { StopReason } from '../common/frontend-application-state';

/**
* Clients can implement to get a callback for contributing widgets to a shell on start.
*/
export const FrontendApplicationContribution = Symbol('FrontendApplicationContribution');
export interface FrontendApplicationContribution {

/**
* Called on application startup before configure is called.
*/
initialize?(): void;

/**
* Called before commands, key bindings and menus are initialized.
* Should return a promise if it runs asynchronously.
*/
configure?(app: FrontendApplication): MaybePromise<void>;

/**
* Called when the application is started. The application shell is not attached yet when this method runs.
* Should return a promise if it runs asynchronously.
*/
onStart?(app: FrontendApplication): MaybePromise<void>;

/**
* Called on `beforeunload` event, right before the window closes.
* Return `true` or an OnWillStopAction in order to prevent exit.
* Note: No async code allowed, this function has to run on one tick.
*/
onWillStop?(app: FrontendApplication): boolean | undefined | OnWillStopAction<unknown>;

/**
* Called when an application is stopped or unloaded.
*
* Note that this is implemented using `window.beforeunload` which doesn't allow any asynchronous code anymore.
* I.e. this is the last tick.
*/
onStop?(app: FrontendApplication): void;

/**
* Called after the application shell has been attached in case there is no previous workbench layout state.
* Should return a promise if it runs asynchronously.
*/
initializeLayout?(app: FrontendApplication): MaybePromise<void>;

/**
* An event is emitted when a layout is initialized, but before the shell is attached.
*/
onDidInitializeLayout?(app: FrontendApplication): MaybePromise<void>;
}

export interface OnWillStopAction<T = unknown> {
/**
* @resolves to a prepared value to be passed into the `action` function.
*/
prepare?: (stopReason?: StopReason) => MaybePromise<T>;
/**
* @resolves to `true` if it is safe to close the application; `false` otherwise.
*/
action: (prepared: T, stopReason?: StopReason) => MaybePromise<boolean>;
/**
* A descriptive string for the reason preventing close.
*/
reason: string;
/**
* A number representing priority. Higher priority items are run later.
* High priority implies that some options of this check will have negative impacts if
* the user subsequently cancels the shutdown.
*/
priority?: number;
}

export namespace OnWillStopAction {
export function is(candidate: unknown): candidate is OnWillStopAction {
return isObject(candidate) && 'action' in candidate && 'reason' in candidate;
}
}
import { FrontendApplicationContribution } from './frontend-application-contribution';

const TIMER_WARNING_THRESHOLD = 100;

/**
* Default frontend contribution that can be extended by clients if they do not want to implement any of the
* methods from the interface but still want to contribute to the frontend application.
*/
@injectable()
export abstract class DefaultFrontendApplicationContribution implements FrontendApplicationContribution {

initialize(): void {
// NOOP
}

}

@injectable()
export class FrontendApplication {

Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/browser/icon-theme-contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// *****************************************************************************

import { injectable, inject, named } from 'inversify';
import { FrontendApplicationContribution } from './frontend-application';
import { FrontendApplicationContribution } from './frontend-application-contribution';
import { ContributionProvider } from '../common/contribution-provider';
import { IconThemeService, IconTheme } from './icon-theme-service';
import { MaybePromise } from '../common/types';
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/browser/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

export * from './shell';
export * from './frontend-application';
export * from './frontend-application-contribution';
export * from './keyboard';
export * from './opener-service';
export * from './browser';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/browser/json-schema-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import { injectable, inject, named } from 'inversify';
import { ContributionProvider } from '../common/contribution-provider';
import { FrontendApplicationContribution } from './frontend-application';
import { FrontendApplicationContribution } from './frontend-application-contribution';
import { MaybePromise } from '../common';
import { Endpoint } from './endpoint';
import { timeout, Deferred } from '../common/promise-util';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/browser/label-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import * as fileIcons from 'file-icons-js';
import URI from '../common/uri';
import { ContributionProvider } from '../common/contribution-provider';
import { Event, Emitter, Disposable, isObject, Path, Prioritizeable } from '../common';
import { FrontendApplicationContribution } from './frontend-application';
import { FrontendApplicationContribution } from './frontend-application-contribution';
import { EnvVariablesServer } from '../common/env-variables/env-variables-protocol';
import { ResourceLabelFormatter, ResourceLabelFormatting } from '../common/label-protocol';
import { codicon } from './widgets';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/browser/logger-frontend-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { ILoggerServer, loggerPath, ConsoleLogger } from '../common/logger-proto
import { ILogger, Logger, LoggerFactory, setRootLogger, LoggerName, rootLoggerName } from '../common/logger';
import { LoggerWatcher } from '../common/logger-watcher';
import { WebSocketConnectionProvider } from './messaging';
import { FrontendApplicationContribution } from './frontend-application';
import { FrontendApplicationContribution } from './frontend-application-contribution';
import { EncodingError } from '../common/message-rpc/rpc-message-encoder';

export const loggerFrontendModule = new ContainerModule(bind => {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/browser/menu/browser-menu-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// *****************************************************************************

import { ContainerModule } from 'inversify';
import { FrontendApplicationContribution } from '../frontend-application';
import { FrontendApplicationContribution } from '../frontend-application-contribution';
import { ContextMenuRenderer } from '../context-menu-renderer';
import { BrowserMenuBarContribution, BrowserMainMenuFactory } from './browser-menu-plugin';
import { BrowserContextMenuRenderer } from './browser-context-menu-renderer';
Expand Down
3 changes: 2 additions & 1 deletion packages/core/src/browser/menu/browser-menu-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ import {
MenuModelRegistry, MAIN_MENU_BAR, MenuPath, MenuNode, MenuCommandExecutor, CompoundMenuNode, CompoundMenuNodeRole, CommandMenuNode
} from '../../common';
import { KeybindingRegistry } from '../keybinding';
import { FrontendApplicationContribution, FrontendApplication } from '../frontend-application';
import { FrontendApplication } from '../frontend-application';
import { FrontendApplicationContribution } from '../frontend-application-contribution';
import { ContextKeyService, ContextMatcher } from '../context-key-service';
import { ContextMenuContext } from './context-menu-context';
import { waitForRevealed } from '../widgets';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import { injectable, inject, named } from 'inversify';
import { ContributionProvider } from '../../common';
import { FrontendApplicationContribution } from '../frontend-application';
import { FrontendApplicationContribution } from '../frontend-application-contribution';
import { QuickAccessContribution } from './quick-access';

@injectable()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
// *****************************************************************************

import { FrontendApplicationContribution } from '../frontend-application';
import { FrontendApplicationContribution } from '../frontend-application-contribution';
import { ApplicationShell } from './application-shell';
import { injectable, inject } from 'inversify';
import { DisposableCollection, Disposable } from '../../common/disposable';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/browser/shell/tab-bar-decorator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { Title, Widget } from '@phosphor/widgets';
import { inject, injectable, named } from 'inversify';
import { Event, Emitter, ContributionProvider } from '../../common';
import { WidgetDecoration } from '../widget-decoration';
import { FrontendApplicationContribution } from '../frontend-application';
import { FrontendApplicationContribution } from '../frontend-application-contribution';

export const TabBarDecorator = Symbol('TabBarDecorator');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { inject, injectable, named } from 'inversify';
// eslint-disable-next-line max-len
import { CommandMenuNode, CommandRegistry, CompoundMenuNode, ContributionProvider, Disposable, DisposableCollection, Emitter, Event, MenuModelRegistry, MenuNode, MenuPath } from '../../../common';
import { ContextKeyService } from '../../context-key-service';
import { FrontendApplicationContribution } from '../../frontend-application';
import { FrontendApplicationContribution } from '../../frontend-application-contribution';
import { Widget } from '../../widgets';
import { AnyToolbarItem, ConditionalToolbarItem, MenuDelegate, MenuToolbarItem, ReactTabBarToolbarItem, TabBarToolbarItem } from './tab-bar-toolbar-types';
import { ToolbarMenuNodeWrapper } from './tab-bar-toolbar-menu-adapters';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/browser/styling-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { ContributionProvider } from '../common/contribution-provider';
import { Theme, ThemeType } from '../common/theme';
import { ColorRegistry } from './color-registry';
import { DecorationStyle } from './decoration-style';
import { FrontendApplicationContribution } from './frontend-application';
import { FrontendApplicationContribution } from './frontend-application-contribution';
import { ThemeService } from './theming';
import { Disposable } from '../common';

Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/browser/window/browser-window-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import { ContainerModule } from 'inversify';
import { WindowService } from '../../browser/window/window-service';
import { DefaultWindowService } from '../../browser/window/default-window-service';
import { FrontendApplicationContribution } from '../frontend-application';
import { FrontendApplicationContribution } from '../frontend-application-contribution';
import { ClipboardService } from '../clipboard-service';
import { BrowserClipboardService } from '../browser-clipboard-service';
import { SecondaryWindowService } from './secondary-window-service';
Expand Down
Loading
Loading