@theia/toolbar 1.45.1 → 1.46.0-next.72
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +32 -32
- package/lib/browser/abstract-toolbar-contribution.d.ts +16 -16
- package/lib/browser/abstract-toolbar-contribution.js +68 -68
- package/lib/browser/application-shell-with-toolbar-override.d.ts +15 -15
- package/lib/browser/application-shell-with-toolbar-override.js +101 -101
- package/lib/browser/codicons.d.ts +1 -1
- package/lib/browser/codicons.js +20 -20
- package/lib/browser/font-awesome-icons.d.ts +1 -1
- package/lib/browser/font-awesome-icons.js +20 -20
- package/lib/browser/package.spec.js +18 -18
- package/lib/browser/toolbar-command-contribution.d.ts +25 -25
- package/lib/browser/toolbar-command-contribution.js +211 -211
- package/lib/browser/toolbar-command-quick-input-service.d.ts +19 -19
- package/lib/browser/toolbar-command-quick-input-service.js +112 -112
- package/lib/browser/toolbar-constants.d.ts +23 -23
- package/lib/browser/toolbar-constants.js +75 -75
- package/lib/browser/toolbar-controller.d.ts +34 -34
- package/lib/browser/toolbar-controller.js +186 -186
- package/lib/browser/toolbar-defaults.d.ts +3 -3
- package/lib/browser/toolbar-defaults.js +60 -60
- package/lib/browser/toolbar-frontend-module.d.ts +4 -4
- package/lib/browser/toolbar-frontend-module.js +25 -25
- package/lib/browser/toolbar-icon-selector-dialog.d.ts +65 -65
- package/lib/browser/toolbar-icon-selector-dialog.js +235 -235
- package/lib/browser/toolbar-interfaces.d.ts +45 -45
- package/lib/browser/toolbar-interfaces.js +42 -42
- package/lib/browser/toolbar-preference-contribution.d.ts +9 -9
- package/lib/browser/toolbar-preference-contribution.js +34 -34
- package/lib/browser/toolbar-preference-schema.d.ts +5 -5
- package/lib/browser/toolbar-preference-schema.js +73 -73
- package/lib/browser/toolbar-storage-provider.d.ts +47 -47
- package/lib/browser/toolbar-storage-provider.js +357 -357
- package/lib/browser/toolbar.d.ts +56 -56
- package/lib/browser/toolbar.js +380 -380
- package/package.json +11 -11
- package/src/browser/abstract-toolbar-contribution.tsx +53 -53
- package/src/browser/application-shell-with-toolbar-override.ts +98 -98
- package/src/browser/codicons.ts +18 -18
- package/src/browser/font-awesome-icons.ts +18 -18
- package/src/browser/package.spec.ts +19 -19
- package/src/browser/style/toolbar.css +255 -255
- package/src/browser/toolbar-command-contribution.ts +211 -211
- package/src/browser/toolbar-command-quick-input-service.ts +86 -86
- package/src/browser/toolbar-constants.ts +79 -79
- package/src/browser/toolbar-controller.ts +185 -185
- package/src/browser/toolbar-defaults.ts +58 -58
- package/src/browser/toolbar-frontend-module.ts +30 -30
- package/src/browser/toolbar-icon-selector-dialog.tsx +296 -296
- package/src/browser/toolbar-interfaces.ts +76 -76
- package/src/browser/toolbar-preference-contribution.ts +38 -38
- package/src/browser/toolbar-preference-schema.ts +75 -75
- package/src/browser/toolbar-storage-provider.ts +352 -352
- package/src/browser/toolbar.tsx +424 -424
|
@@ -1,212 +1,212 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// *****************************************************************************
|
|
3
|
-
// Copyright (C) 2022 Ericsson and others.
|
|
4
|
-
//
|
|
5
|
-
// This program and the accompanying materials are made available under the
|
|
6
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
-
//
|
|
9
|
-
// This Source Code may also be made available under the following Secondary
|
|
10
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
-
// with the GNU Classpath Exception which is available at
|
|
13
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
14
|
-
//
|
|
15
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
16
|
-
// *****************************************************************************
|
|
17
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
18
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
19
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
20
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
21
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
22
|
-
};
|
|
23
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
24
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
25
|
-
};
|
|
26
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
-
exports.bindToolbar = exports.ToolbarCommandContribution = void 0;
|
|
28
|
-
const core_1 = require("@theia/core");
|
|
29
|
-
const browser_1 = require("@theia/core/lib/browser");
|
|
30
|
-
const inversify_1 = require("@theia/core/shared/inversify");
|
|
31
|
-
const browser_2 = require("@theia/editor/lib/browser");
|
|
32
|
-
const toolbar_1 = require("./toolbar");
|
|
33
|
-
const toolbar_icon_selector_dialog_1 = require("./toolbar-icon-selector-dialog");
|
|
34
|
-
const toolbar_interfaces_1 = require("./toolbar-interfaces");
|
|
35
|
-
const toolbar_command_quick_input_service_1 = require("./toolbar-command-quick-input-service");
|
|
36
|
-
const toolbar_storage_provider_1 = require("./toolbar-storage-provider");
|
|
37
|
-
const toolbar_controller_1 = require("./toolbar-controller");
|
|
38
|
-
const toolbar_preference_contribution_1 = require("./toolbar-preference-contribution");
|
|
39
|
-
const toolbar_defaults_1 = require("./toolbar-defaults");
|
|
40
|
-
const toolbar_constants_1 = require("./toolbar-constants");
|
|
41
|
-
const json_schema_store_1 = require("@theia/core/lib/browser/json-schema-store");
|
|
42
|
-
const toolbar_preference_schema_1 = require("./toolbar-preference-schema");
|
|
43
|
-
const uri_1 = require("@theia/core/lib/common/uri");
|
|
44
|
-
let ToolbarCommandContribution = class ToolbarCommandContribution {
|
|
45
|
-
constructor() {
|
|
46
|
-
this.schemaURI = new uri_1.default(toolbar_preference_schema_1.toolbarSchemaId);
|
|
47
|
-
}
|
|
48
|
-
registerSchemas(context) {
|
|
49
|
-
this.inMemoryResources.add(this.schemaURI, JSON.stringify(toolbar_preference_schema_1.toolbarConfigurationSchema));
|
|
50
|
-
context.registerSchema({
|
|
51
|
-
fileMatch: ['toolbar.json'],
|
|
52
|
-
url: this.schemaURI.toString(),
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
registerCommands(registry) {
|
|
56
|
-
registry.registerCommand(toolbar_constants_1.ToolbarCommands.CUSTOMIZE_TOOLBAR, {
|
|
57
|
-
execute: () => this.model.openOrCreateJSONFile(true),
|
|
58
|
-
});
|
|
59
|
-
registry.registerCommand(toolbar_constants_1.ToolbarCommands.RESET_TOOLBAR, {
|
|
60
|
-
execute: () => this.model.clearAll(),
|
|
61
|
-
});
|
|
62
|
-
registry.registerCommand(toolbar_constants_1.ToolbarCommands.TOGGLE_TOOLBAR, {
|
|
63
|
-
execute: () => {
|
|
64
|
-
const isVisible = this.preferenceService.get(toolbar_preference_contribution_1.TOOLBAR_ENABLE_PREFERENCE_ID);
|
|
65
|
-
this.preferenceService.set(toolbar_preference_contribution_1.TOOLBAR_ENABLE_PREFERENCE_ID, !isVisible, browser_1.PreferenceScope.User);
|
|
66
|
-
},
|
|
67
|
-
});
|
|
68
|
-
registry.registerCommand(toolbar_constants_1.ToolbarCommands.REMOVE_COMMAND_FROM_TOOLBAR, {
|
|
69
|
-
execute: async (_widget, position, id) => position && this.model.removeItem(position, id),
|
|
70
|
-
isVisible: (...args) => this.isToolbarWidget(args[0]),
|
|
71
|
-
});
|
|
72
|
-
registry.registerCommand(toolbar_constants_1.ToolbarCommands.INSERT_GROUP_LEFT, {
|
|
73
|
-
execute: async (_widget, position) => position && this.model.insertGroup(position, 'left'),
|
|
74
|
-
isVisible: (widget, position) => {
|
|
75
|
-
if (position) {
|
|
76
|
-
const { alignment, groupIndex, itemIndex } = position;
|
|
77
|
-
const owningGroupLength = this.toolbarModel.toolbarItems.items[alignment][groupIndex].length;
|
|
78
|
-
return this.isToolbarWidget(widget) && (owningGroupLength > 1) && (itemIndex > 0);
|
|
79
|
-
}
|
|
80
|
-
return false;
|
|
81
|
-
},
|
|
82
|
-
});
|
|
83
|
-
registry.registerCommand(toolbar_constants_1.ToolbarCommands.INSERT_GROUP_RIGHT, {
|
|
84
|
-
execute: async (_widget, position) => position && this.model.insertGroup(position, 'right'),
|
|
85
|
-
isVisible: (widget, position) => {
|
|
86
|
-
if (position) {
|
|
87
|
-
const { alignment, groupIndex, itemIndex } = position;
|
|
88
|
-
const owningGroupLength = this.toolbarModel.toolbarItems.items[alignment][groupIndex].length;
|
|
89
|
-
const isNotLastItem = itemIndex < (owningGroupLength - 1);
|
|
90
|
-
return this.isToolbarWidget(widget) && owningGroupLength > 1 && isNotLastItem;
|
|
91
|
-
}
|
|
92
|
-
return false;
|
|
93
|
-
},
|
|
94
|
-
});
|
|
95
|
-
registry.registerCommand(toolbar_constants_1.ToolbarCommands.ADD_COMMAND_TO_TOOLBAR, {
|
|
96
|
-
execute: () => this.toolbarCommandPickService.openIconDialog(),
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
isToolbarWidget(arg) {
|
|
100
|
-
return arg instanceof toolbar_1.ToolbarImpl;
|
|
101
|
-
}
|
|
102
|
-
registerKeybindings(keys) {
|
|
103
|
-
keys.registerKeybinding({
|
|
104
|
-
command: toolbar_constants_1.ToolbarCommands.TOGGLE_TOOLBAR.id,
|
|
105
|
-
keybinding: 'alt+t',
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
registerMenus(registry) {
|
|
109
|
-
registry.registerMenuAction(browser_1.CommonMenus.VIEW_LAYOUT, {
|
|
110
|
-
commandId: toolbar_constants_1.ToolbarCommands.TOGGLE_TOOLBAR.id,
|
|
111
|
-
order: 'z',
|
|
112
|
-
});
|
|
113
|
-
registry.registerMenuAction(toolbar_constants_1.ToolbarMenus.TOOLBAR_ITEM_CONTEXT_MENU, {
|
|
114
|
-
commandId: toolbar_constants_1.ToolbarCommands.ADD_COMMAND_TO_TOOLBAR.id,
|
|
115
|
-
order: 'a',
|
|
116
|
-
});
|
|
117
|
-
registry.registerMenuAction(toolbar_constants_1.ToolbarMenus.TOOLBAR_ITEM_CONTEXT_MENU, {
|
|
118
|
-
commandId: toolbar_constants_1.ToolbarCommands.INSERT_GROUP_LEFT.id,
|
|
119
|
-
order: 'b',
|
|
120
|
-
});
|
|
121
|
-
registry.registerMenuAction(toolbar_constants_1.ToolbarMenus.TOOLBAR_ITEM_CONTEXT_MENU, {
|
|
122
|
-
commandId: toolbar_constants_1.ToolbarCommands.INSERT_GROUP_RIGHT.id,
|
|
123
|
-
order: 'c',
|
|
124
|
-
});
|
|
125
|
-
registry.registerMenuAction(toolbar_constants_1.ToolbarMenus.TOOLBAR_ITEM_CONTEXT_MENU, {
|
|
126
|
-
commandId: toolbar_constants_1.ToolbarCommands.REMOVE_COMMAND_FROM_TOOLBAR.id,
|
|
127
|
-
order: 'd',
|
|
128
|
-
});
|
|
129
|
-
registry.registerMenuAction(toolbar_constants_1.ToolbarMenus.TOOLBAR_BACKGROUND_CONTEXT_MENU, {
|
|
130
|
-
commandId: toolbar_constants_1.ToolbarCommands.ADD_COMMAND_TO_TOOLBAR.id,
|
|
131
|
-
order: 'a',
|
|
132
|
-
});
|
|
133
|
-
registry.registerMenuAction(toolbar_constants_1.ToolbarMenus.TOOLBAR_BACKGROUND_CONTEXT_MENU, {
|
|
134
|
-
commandId: toolbar_constants_1.ToolbarCommands.CUSTOMIZE_TOOLBAR.id,
|
|
135
|
-
order: 'b',
|
|
136
|
-
});
|
|
137
|
-
registry.registerMenuAction(toolbar_constants_1.ToolbarMenus.TOOLBAR_BACKGROUND_CONTEXT_MENU, {
|
|
138
|
-
commandId: toolbar_constants_1.ToolbarCommands.TOGGLE_TOOLBAR.id,
|
|
139
|
-
order: 'c',
|
|
140
|
-
});
|
|
141
|
-
registry.registerMenuAction(toolbar_constants_1.ToolbarMenus.TOOLBAR_BACKGROUND_CONTEXT_MENU, {
|
|
142
|
-
commandId: toolbar_constants_1.ToolbarCommands.RESET_TOOLBAR.id,
|
|
143
|
-
order: 'd',
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
};
|
|
147
|
-
__decorate([
|
|
148
|
-
(0, inversify_1.inject)(toolbar_controller_1.ToolbarController),
|
|
149
|
-
__metadata("design:type", toolbar_controller_1.ToolbarController)
|
|
150
|
-
], ToolbarCommandContribution.prototype, "model", void 0);
|
|
151
|
-
__decorate([
|
|
152
|
-
(0, inversify_1.inject)(browser_1.QuickInputService),
|
|
153
|
-
__metadata("design:type", Object)
|
|
154
|
-
], ToolbarCommandContribution.prototype, "quickInputService", void 0);
|
|
155
|
-
__decorate([
|
|
156
|
-
(0, inversify_1.inject)(toolbar_command_quick_input_service_1.ToolbarCommandQuickInputService),
|
|
157
|
-
__metadata("design:type", toolbar_command_quick_input_service_1.ToolbarCommandQuickInputService)
|
|
158
|
-
], ToolbarCommandContribution.prototype, "toolbarCommandPickService", void 0);
|
|
159
|
-
__decorate([
|
|
160
|
-
(0, inversify_1.inject)(core_1.CommandService),
|
|
161
|
-
__metadata("design:type", Object)
|
|
162
|
-
], ToolbarCommandContribution.prototype, "commandService", void 0);
|
|
163
|
-
__decorate([
|
|
164
|
-
(0, inversify_1.inject)(browser_2.EditorManager),
|
|
165
|
-
__metadata("design:type", browser_2.EditorManager)
|
|
166
|
-
], ToolbarCommandContribution.prototype, "editorManager", void 0);
|
|
167
|
-
__decorate([
|
|
168
|
-
(0, inversify_1.inject)(browser_1.PreferenceService),
|
|
169
|
-
__metadata("design:type", Object)
|
|
170
|
-
], ToolbarCommandContribution.prototype, "preferenceService", void 0);
|
|
171
|
-
__decorate([
|
|
172
|
-
(0, inversify_1.inject)(toolbar_controller_1.ToolbarController),
|
|
173
|
-
__metadata("design:type", toolbar_controller_1.ToolbarController)
|
|
174
|
-
], ToolbarCommandContribution.prototype, "toolbarModel", void 0);
|
|
175
|
-
__decorate([
|
|
176
|
-
(0, inversify_1.inject)(core_1.InMemoryResources),
|
|
177
|
-
__metadata("design:type", core_1.InMemoryResources)
|
|
178
|
-
], ToolbarCommandContribution.prototype, "inMemoryResources", void 0);
|
|
179
|
-
ToolbarCommandContribution = __decorate([
|
|
180
|
-
(0, inversify_1.injectable)()
|
|
181
|
-
], ToolbarCommandContribution);
|
|
182
|
-
exports.ToolbarCommandContribution = ToolbarCommandContribution;
|
|
183
|
-
function bindToolbar(bind) {
|
|
184
|
-
bind(toolbar_interfaces_1.ToolbarFactory).toFactory(({ container }) => () => {
|
|
185
|
-
const child = new inversify_1.Container({ defaultScope: 'Singleton' });
|
|
186
|
-
child.parent = container;
|
|
187
|
-
child.bind(toolbar_interfaces_1.Toolbar).to(toolbar_1.ToolbarImpl);
|
|
188
|
-
return child.get(toolbar_interfaces_1.Toolbar);
|
|
189
|
-
});
|
|
190
|
-
bind(ToolbarCommandContribution).toSelf().inSingletonScope();
|
|
191
|
-
bind(core_1.CommandContribution).to(ToolbarCommandContribution);
|
|
192
|
-
bind(core_1.MenuContribution).toService(ToolbarCommandContribution);
|
|
193
|
-
bind(browser_1.KeybindingContribution).toService(ToolbarCommandContribution);
|
|
194
|
-
bind(json_schema_store_1.JsonSchemaContribution).toService(ToolbarCommandContribution);
|
|
195
|
-
bind(toolbar_command_quick_input_service_1.ToolbarCommandQuickInputService).toSelf().inSingletonScope();
|
|
196
|
-
(0, toolbar_icon_selector_dialog_1.bindToolbarIconDialog)(bind);
|
|
197
|
-
bind(toolbar_defaults_1.ToolbarDefaultsFactory).toConstantValue(toolbar_defaults_1.ToolbarDefaults);
|
|
198
|
-
bind(toolbar_preference_contribution_1.ToolbarPreferences).toDynamicValue(({ container }) => {
|
|
199
|
-
const preferences = container.get(browser_1.PreferenceService);
|
|
200
|
-
return (0, browser_1.createPreferenceProxy)(preferences, toolbar_preference_contribution_1.ToolbarPreferencesSchema);
|
|
201
|
-
}).inSingletonScope();
|
|
202
|
-
bind(browser_1.PreferenceContribution).toConstantValue({
|
|
203
|
-
schema: toolbar_preference_contribution_1.ToolbarPreferencesSchema,
|
|
204
|
-
});
|
|
205
|
-
bind(toolbar_constants_1.UserToolbarURI).toConstantValue(toolbar_constants_1.USER_TOOLBAR_URI);
|
|
206
|
-
bind(toolbar_controller_1.ToolbarController).toSelf().inSingletonScope();
|
|
207
|
-
bind(toolbar_storage_provider_1.ToolbarStorageProvider).toSelf().inSingletonScope();
|
|
208
|
-
(0, core_1.bindContributionProvider)(bind, toolbar_interfaces_1.ToolbarContribution);
|
|
209
|
-
bind(toolbar_interfaces_1.LateInjector).toFactory((context) => (id) => (0, toolbar_interfaces_1.lateInjector)(context.container, id));
|
|
210
|
-
}
|
|
211
|
-
exports.bindToolbar = bindToolbar;
|
|
1
|
+
"use strict";
|
|
2
|
+
// *****************************************************************************
|
|
3
|
+
// Copyright (C) 2022 Ericsson and others.
|
|
4
|
+
//
|
|
5
|
+
// This program and the accompanying materials are made available under the
|
|
6
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
+
//
|
|
9
|
+
// This Source Code may also be made available under the following Secondary
|
|
10
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
+
// with the GNU Classpath Exception which is available at
|
|
13
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
14
|
+
//
|
|
15
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
16
|
+
// *****************************************************************************
|
|
17
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
18
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
19
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
20
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
21
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
22
|
+
};
|
|
23
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
24
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
25
|
+
};
|
|
26
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
+
exports.bindToolbar = exports.ToolbarCommandContribution = void 0;
|
|
28
|
+
const core_1 = require("@theia/core");
|
|
29
|
+
const browser_1 = require("@theia/core/lib/browser");
|
|
30
|
+
const inversify_1 = require("@theia/core/shared/inversify");
|
|
31
|
+
const browser_2 = require("@theia/editor/lib/browser");
|
|
32
|
+
const toolbar_1 = require("./toolbar");
|
|
33
|
+
const toolbar_icon_selector_dialog_1 = require("./toolbar-icon-selector-dialog");
|
|
34
|
+
const toolbar_interfaces_1 = require("./toolbar-interfaces");
|
|
35
|
+
const toolbar_command_quick_input_service_1 = require("./toolbar-command-quick-input-service");
|
|
36
|
+
const toolbar_storage_provider_1 = require("./toolbar-storage-provider");
|
|
37
|
+
const toolbar_controller_1 = require("./toolbar-controller");
|
|
38
|
+
const toolbar_preference_contribution_1 = require("./toolbar-preference-contribution");
|
|
39
|
+
const toolbar_defaults_1 = require("./toolbar-defaults");
|
|
40
|
+
const toolbar_constants_1 = require("./toolbar-constants");
|
|
41
|
+
const json_schema_store_1 = require("@theia/core/lib/browser/json-schema-store");
|
|
42
|
+
const toolbar_preference_schema_1 = require("./toolbar-preference-schema");
|
|
43
|
+
const uri_1 = require("@theia/core/lib/common/uri");
|
|
44
|
+
let ToolbarCommandContribution = class ToolbarCommandContribution {
|
|
45
|
+
constructor() {
|
|
46
|
+
this.schemaURI = new uri_1.default(toolbar_preference_schema_1.toolbarSchemaId);
|
|
47
|
+
}
|
|
48
|
+
registerSchemas(context) {
|
|
49
|
+
this.inMemoryResources.add(this.schemaURI, JSON.stringify(toolbar_preference_schema_1.toolbarConfigurationSchema));
|
|
50
|
+
context.registerSchema({
|
|
51
|
+
fileMatch: ['toolbar.json'],
|
|
52
|
+
url: this.schemaURI.toString(),
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
registerCommands(registry) {
|
|
56
|
+
registry.registerCommand(toolbar_constants_1.ToolbarCommands.CUSTOMIZE_TOOLBAR, {
|
|
57
|
+
execute: () => this.model.openOrCreateJSONFile(true),
|
|
58
|
+
});
|
|
59
|
+
registry.registerCommand(toolbar_constants_1.ToolbarCommands.RESET_TOOLBAR, {
|
|
60
|
+
execute: () => this.model.clearAll(),
|
|
61
|
+
});
|
|
62
|
+
registry.registerCommand(toolbar_constants_1.ToolbarCommands.TOGGLE_TOOLBAR, {
|
|
63
|
+
execute: () => {
|
|
64
|
+
const isVisible = this.preferenceService.get(toolbar_preference_contribution_1.TOOLBAR_ENABLE_PREFERENCE_ID);
|
|
65
|
+
this.preferenceService.set(toolbar_preference_contribution_1.TOOLBAR_ENABLE_PREFERENCE_ID, !isVisible, browser_1.PreferenceScope.User);
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
registry.registerCommand(toolbar_constants_1.ToolbarCommands.REMOVE_COMMAND_FROM_TOOLBAR, {
|
|
69
|
+
execute: async (_widget, position, id) => position && this.model.removeItem(position, id),
|
|
70
|
+
isVisible: (...args) => this.isToolbarWidget(args[0]),
|
|
71
|
+
});
|
|
72
|
+
registry.registerCommand(toolbar_constants_1.ToolbarCommands.INSERT_GROUP_LEFT, {
|
|
73
|
+
execute: async (_widget, position) => position && this.model.insertGroup(position, 'left'),
|
|
74
|
+
isVisible: (widget, position) => {
|
|
75
|
+
if (position) {
|
|
76
|
+
const { alignment, groupIndex, itemIndex } = position;
|
|
77
|
+
const owningGroupLength = this.toolbarModel.toolbarItems.items[alignment][groupIndex].length;
|
|
78
|
+
return this.isToolbarWidget(widget) && (owningGroupLength > 1) && (itemIndex > 0);
|
|
79
|
+
}
|
|
80
|
+
return false;
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
registry.registerCommand(toolbar_constants_1.ToolbarCommands.INSERT_GROUP_RIGHT, {
|
|
84
|
+
execute: async (_widget, position) => position && this.model.insertGroup(position, 'right'),
|
|
85
|
+
isVisible: (widget, position) => {
|
|
86
|
+
if (position) {
|
|
87
|
+
const { alignment, groupIndex, itemIndex } = position;
|
|
88
|
+
const owningGroupLength = this.toolbarModel.toolbarItems.items[alignment][groupIndex].length;
|
|
89
|
+
const isNotLastItem = itemIndex < (owningGroupLength - 1);
|
|
90
|
+
return this.isToolbarWidget(widget) && owningGroupLength > 1 && isNotLastItem;
|
|
91
|
+
}
|
|
92
|
+
return false;
|
|
93
|
+
},
|
|
94
|
+
});
|
|
95
|
+
registry.registerCommand(toolbar_constants_1.ToolbarCommands.ADD_COMMAND_TO_TOOLBAR, {
|
|
96
|
+
execute: () => this.toolbarCommandPickService.openIconDialog(),
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
isToolbarWidget(arg) {
|
|
100
|
+
return arg instanceof toolbar_1.ToolbarImpl;
|
|
101
|
+
}
|
|
102
|
+
registerKeybindings(keys) {
|
|
103
|
+
keys.registerKeybinding({
|
|
104
|
+
command: toolbar_constants_1.ToolbarCommands.TOGGLE_TOOLBAR.id,
|
|
105
|
+
keybinding: 'alt+t',
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
registerMenus(registry) {
|
|
109
|
+
registry.registerMenuAction(browser_1.CommonMenus.VIEW_LAYOUT, {
|
|
110
|
+
commandId: toolbar_constants_1.ToolbarCommands.TOGGLE_TOOLBAR.id,
|
|
111
|
+
order: 'z',
|
|
112
|
+
});
|
|
113
|
+
registry.registerMenuAction(toolbar_constants_1.ToolbarMenus.TOOLBAR_ITEM_CONTEXT_MENU, {
|
|
114
|
+
commandId: toolbar_constants_1.ToolbarCommands.ADD_COMMAND_TO_TOOLBAR.id,
|
|
115
|
+
order: 'a',
|
|
116
|
+
});
|
|
117
|
+
registry.registerMenuAction(toolbar_constants_1.ToolbarMenus.TOOLBAR_ITEM_CONTEXT_MENU, {
|
|
118
|
+
commandId: toolbar_constants_1.ToolbarCommands.INSERT_GROUP_LEFT.id,
|
|
119
|
+
order: 'b',
|
|
120
|
+
});
|
|
121
|
+
registry.registerMenuAction(toolbar_constants_1.ToolbarMenus.TOOLBAR_ITEM_CONTEXT_MENU, {
|
|
122
|
+
commandId: toolbar_constants_1.ToolbarCommands.INSERT_GROUP_RIGHT.id,
|
|
123
|
+
order: 'c',
|
|
124
|
+
});
|
|
125
|
+
registry.registerMenuAction(toolbar_constants_1.ToolbarMenus.TOOLBAR_ITEM_CONTEXT_MENU, {
|
|
126
|
+
commandId: toolbar_constants_1.ToolbarCommands.REMOVE_COMMAND_FROM_TOOLBAR.id,
|
|
127
|
+
order: 'd',
|
|
128
|
+
});
|
|
129
|
+
registry.registerMenuAction(toolbar_constants_1.ToolbarMenus.TOOLBAR_BACKGROUND_CONTEXT_MENU, {
|
|
130
|
+
commandId: toolbar_constants_1.ToolbarCommands.ADD_COMMAND_TO_TOOLBAR.id,
|
|
131
|
+
order: 'a',
|
|
132
|
+
});
|
|
133
|
+
registry.registerMenuAction(toolbar_constants_1.ToolbarMenus.TOOLBAR_BACKGROUND_CONTEXT_MENU, {
|
|
134
|
+
commandId: toolbar_constants_1.ToolbarCommands.CUSTOMIZE_TOOLBAR.id,
|
|
135
|
+
order: 'b',
|
|
136
|
+
});
|
|
137
|
+
registry.registerMenuAction(toolbar_constants_1.ToolbarMenus.TOOLBAR_BACKGROUND_CONTEXT_MENU, {
|
|
138
|
+
commandId: toolbar_constants_1.ToolbarCommands.TOGGLE_TOOLBAR.id,
|
|
139
|
+
order: 'c',
|
|
140
|
+
});
|
|
141
|
+
registry.registerMenuAction(toolbar_constants_1.ToolbarMenus.TOOLBAR_BACKGROUND_CONTEXT_MENU, {
|
|
142
|
+
commandId: toolbar_constants_1.ToolbarCommands.RESET_TOOLBAR.id,
|
|
143
|
+
order: 'd',
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
__decorate([
|
|
148
|
+
(0, inversify_1.inject)(toolbar_controller_1.ToolbarController),
|
|
149
|
+
__metadata("design:type", toolbar_controller_1.ToolbarController)
|
|
150
|
+
], ToolbarCommandContribution.prototype, "model", void 0);
|
|
151
|
+
__decorate([
|
|
152
|
+
(0, inversify_1.inject)(browser_1.QuickInputService),
|
|
153
|
+
__metadata("design:type", Object)
|
|
154
|
+
], ToolbarCommandContribution.prototype, "quickInputService", void 0);
|
|
155
|
+
__decorate([
|
|
156
|
+
(0, inversify_1.inject)(toolbar_command_quick_input_service_1.ToolbarCommandQuickInputService),
|
|
157
|
+
__metadata("design:type", toolbar_command_quick_input_service_1.ToolbarCommandQuickInputService)
|
|
158
|
+
], ToolbarCommandContribution.prototype, "toolbarCommandPickService", void 0);
|
|
159
|
+
__decorate([
|
|
160
|
+
(0, inversify_1.inject)(core_1.CommandService),
|
|
161
|
+
__metadata("design:type", Object)
|
|
162
|
+
], ToolbarCommandContribution.prototype, "commandService", void 0);
|
|
163
|
+
__decorate([
|
|
164
|
+
(0, inversify_1.inject)(browser_2.EditorManager),
|
|
165
|
+
__metadata("design:type", browser_2.EditorManager)
|
|
166
|
+
], ToolbarCommandContribution.prototype, "editorManager", void 0);
|
|
167
|
+
__decorate([
|
|
168
|
+
(0, inversify_1.inject)(browser_1.PreferenceService),
|
|
169
|
+
__metadata("design:type", Object)
|
|
170
|
+
], ToolbarCommandContribution.prototype, "preferenceService", void 0);
|
|
171
|
+
__decorate([
|
|
172
|
+
(0, inversify_1.inject)(toolbar_controller_1.ToolbarController),
|
|
173
|
+
__metadata("design:type", toolbar_controller_1.ToolbarController)
|
|
174
|
+
], ToolbarCommandContribution.prototype, "toolbarModel", void 0);
|
|
175
|
+
__decorate([
|
|
176
|
+
(0, inversify_1.inject)(core_1.InMemoryResources),
|
|
177
|
+
__metadata("design:type", core_1.InMemoryResources)
|
|
178
|
+
], ToolbarCommandContribution.prototype, "inMemoryResources", void 0);
|
|
179
|
+
ToolbarCommandContribution = __decorate([
|
|
180
|
+
(0, inversify_1.injectable)()
|
|
181
|
+
], ToolbarCommandContribution);
|
|
182
|
+
exports.ToolbarCommandContribution = ToolbarCommandContribution;
|
|
183
|
+
function bindToolbar(bind) {
|
|
184
|
+
bind(toolbar_interfaces_1.ToolbarFactory).toFactory(({ container }) => () => {
|
|
185
|
+
const child = new inversify_1.Container({ defaultScope: 'Singleton' });
|
|
186
|
+
child.parent = container;
|
|
187
|
+
child.bind(toolbar_interfaces_1.Toolbar).to(toolbar_1.ToolbarImpl);
|
|
188
|
+
return child.get(toolbar_interfaces_1.Toolbar);
|
|
189
|
+
});
|
|
190
|
+
bind(ToolbarCommandContribution).toSelf().inSingletonScope();
|
|
191
|
+
bind(core_1.CommandContribution).to(ToolbarCommandContribution);
|
|
192
|
+
bind(core_1.MenuContribution).toService(ToolbarCommandContribution);
|
|
193
|
+
bind(browser_1.KeybindingContribution).toService(ToolbarCommandContribution);
|
|
194
|
+
bind(json_schema_store_1.JsonSchemaContribution).toService(ToolbarCommandContribution);
|
|
195
|
+
bind(toolbar_command_quick_input_service_1.ToolbarCommandQuickInputService).toSelf().inSingletonScope();
|
|
196
|
+
(0, toolbar_icon_selector_dialog_1.bindToolbarIconDialog)(bind);
|
|
197
|
+
bind(toolbar_defaults_1.ToolbarDefaultsFactory).toConstantValue(toolbar_defaults_1.ToolbarDefaults);
|
|
198
|
+
bind(toolbar_preference_contribution_1.ToolbarPreferences).toDynamicValue(({ container }) => {
|
|
199
|
+
const preferences = container.get(browser_1.PreferenceService);
|
|
200
|
+
return (0, browser_1.createPreferenceProxy)(preferences, toolbar_preference_contribution_1.ToolbarPreferencesSchema);
|
|
201
|
+
}).inSingletonScope();
|
|
202
|
+
bind(browser_1.PreferenceContribution).toConstantValue({
|
|
203
|
+
schema: toolbar_preference_contribution_1.ToolbarPreferencesSchema,
|
|
204
|
+
});
|
|
205
|
+
bind(toolbar_constants_1.UserToolbarURI).toConstantValue(toolbar_constants_1.USER_TOOLBAR_URI);
|
|
206
|
+
bind(toolbar_controller_1.ToolbarController).toSelf().inSingletonScope();
|
|
207
|
+
bind(toolbar_storage_provider_1.ToolbarStorageProvider).toSelf().inSingletonScope();
|
|
208
|
+
(0, core_1.bindContributionProvider)(bind, toolbar_interfaces_1.ToolbarContribution);
|
|
209
|
+
bind(toolbar_interfaces_1.LateInjector).toFactory((context) => (id) => (0, toolbar_interfaces_1.lateInjector)(context.container, id));
|
|
210
|
+
}
|
|
211
|
+
exports.bindToolbar = bindToolbar;
|
|
212
212
|
//# sourceMappingURL=toolbar-command-contribution.js.map
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { Command, CommandRegistry, CommandService } from '@theia/core';
|
|
2
|
-
import { QuickCommandService, QuickInputService, QuickPickItem } from '@theia/core/lib/browser';
|
|
3
|
-
import { ToolbarIconDialogFactory } from './toolbar-icon-selector-dialog';
|
|
4
|
-
import { ToolbarController } from './toolbar-controller';
|
|
5
|
-
export declare class ToolbarCommandQuickInputService {
|
|
6
|
-
protected readonly commandService: CommandService;
|
|
7
|
-
protected readonly quickInputService: QuickInputService;
|
|
8
|
-
protected readonly commandRegistry: CommandRegistry;
|
|
9
|
-
protected readonly quickCommandService: QuickCommandService;
|
|
10
|
-
protected readonly model: ToolbarController;
|
|
11
|
-
protected readonly iconDialogFactory: ToolbarIconDialogFactory;
|
|
12
|
-
protected quickPickItems: QuickPickItem[];
|
|
13
|
-
protected iconClass: string | undefined;
|
|
14
|
-
protected commandToAdd: Command | undefined;
|
|
15
|
-
protected columnQuickPickItems: QuickPickItem[];
|
|
16
|
-
openIconDialog(): void;
|
|
17
|
-
protected openColumnQP(): Promise<QuickPickItem | undefined>;
|
|
18
|
-
protected generateCommandsList(): QuickPickItem[];
|
|
19
|
-
}
|
|
1
|
+
import { Command, CommandRegistry, CommandService } from '@theia/core';
|
|
2
|
+
import { QuickCommandService, QuickInputService, QuickPickItem } from '@theia/core/lib/browser';
|
|
3
|
+
import { ToolbarIconDialogFactory } from './toolbar-icon-selector-dialog';
|
|
4
|
+
import { ToolbarController } from './toolbar-controller';
|
|
5
|
+
export declare class ToolbarCommandQuickInputService {
|
|
6
|
+
protected readonly commandService: CommandService;
|
|
7
|
+
protected readonly quickInputService: QuickInputService;
|
|
8
|
+
protected readonly commandRegistry: CommandRegistry;
|
|
9
|
+
protected readonly quickCommandService: QuickCommandService;
|
|
10
|
+
protected readonly model: ToolbarController;
|
|
11
|
+
protected readonly iconDialogFactory: ToolbarIconDialogFactory;
|
|
12
|
+
protected quickPickItems: QuickPickItem[];
|
|
13
|
+
protected iconClass: string | undefined;
|
|
14
|
+
protected commandToAdd: Command | undefined;
|
|
15
|
+
protected columnQuickPickItems: QuickPickItem[];
|
|
16
|
+
openIconDialog(): void;
|
|
17
|
+
protected openColumnQP(): Promise<QuickPickItem | undefined>;
|
|
18
|
+
protected generateCommandsList(): QuickPickItem[];
|
|
19
|
+
}
|
|
20
20
|
//# sourceMappingURL=toolbar-command-quick-input-service.d.ts.map
|