Skip to content

Commit 06a8690

Browse files
committed
Merge branch 'feature/fuzzy-opener' into activate-empty-patches
2 parents 9e3ac9c + f58a876 commit 06a8690

File tree

4 files changed

+110
-12
lines changed

4 files changed

+110
-12
lines changed

coderibbon-theia/src/browser/coderibbon-theia-commands.ts

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,15 @@ import { CodeRibbonTheiaRibbonStrip } from "./cr-ribbon-strip";
1515

1616
import { crdebug } from "./cr-logger";
1717

18-
export const CodeRibbonHelloWorldCommand = {
19-
id: "CodeRibbon.HelloWorld",
20-
label: "Hello, CodeRibbon.",
18+
export const CodeRibbonDebuggingCommands = {
19+
helloWorldCommand: {
20+
id: "CodeRibbon.HelloWorld",
21+
label: "Hello, CodeRibbon.",
22+
},
23+
testFuzzyFinderCommand: {
24+
id: "CodeRibbon.dev.test_ff",
25+
label: "CodeRibbon Test FuzzyFinder",
26+
},
2127
};
2228

2329
export const CodeRibbonDevGetPanelCommand = {
@@ -138,18 +144,22 @@ export class CodeRibbonTheiaCommandContribution implements CommandContribution {
138144
) {}
139145

140146
registerCommands(registry: CommandRegistry): void {
141-
registry.registerCommand(CodeRibbonHelloWorldCommand, {
147+
148+
// === NOTE: Debugging section
149+
// TODO: only register these in debug mode
150+
151+
registry.registerCommand(CodeRibbonDebuggingCommands.helloWorldCommand, {
142152
execute: () => {
143153
this.messageService.info("CodeRibbon says hello!");
144154
crdebug("Hello console! CommandContribution:", this);
145155
// crdebug("CRAS is:", this.cras);
146156
},
147157
});
148-
// registry.registerCommand(CodeRibbonDevGetPanelCommand, {
149-
// execute: () => {
150-
// crdebug();
151-
// }
152-
// });
158+
registry.registerCommand(CodeRibbonDebuggingCommands.testFuzzyFinderCommand, {
159+
execute: () => {
160+
crdebug();
161+
}
162+
});
153163

154164
// === NOTE: Nav section
155165

coderibbon-theia/src/browser/coderibbon-theia-frontend-module.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
} from "@theia/core/lib/browser";
1818
import { PreferenceContribution } from "@theia/core/lib/common/preferences";
1919
import { ApplicationShell } from "@theia/core/lib/browser/shell/application-shell";
20+
import { bindViewContribution, FrontendApplicationContribution, WidgetFactory } from '@theia/core/lib/browser';
2021

2122
// import { CodeRibbonTheiaRibbonViewContribution } from './coderibbon-theia-ribbon';
2223
import { CodeRibbonTheiaCommandContribution } from "./coderibbon-theia-commands";
@@ -26,6 +27,10 @@ import { CodeRibbonTheiaManager } from "./coderibbon-theia-manager";
2627
import { CodeRibbonTheiaRibbonPanel } from "./cr-ribbon";
2728
import { CodeRibbonApplicationShell } from "./cr-application-shell";
2829
import { CodeRibbonTheiaKeybindingContribution } from "./coderibbon-theia-keybinds";
30+
import {
31+
CodeRibbonFuzzyFileOpenerWidget,
32+
CodeRibbonFuzzyFileOpenerContribution,
33+
} from "./cr-fuzzy-file-opener";
2934

3035
import "../../src/browser/style/ribbon.less";
3136
// temp CSS
@@ -41,6 +46,16 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
4146
bind(MenuContribution).to(CodeRibbonTheiaMenuContribution);
4247
bind(KeybindingContribution).to(CodeRibbonTheiaKeybindingContribution);
4348

49+
bindViewContribution(bind, CodeRibbonFuzzyFileOpenerContribution);
50+
bind(FrontendApplicationContribution).toService(CodeRibbonFuzzyFileOpenerContribution);
51+
bind(CodeRibbonFuzzyFileOpenerWidget).toSelf();
52+
bind(WidgetFactory).toDynamicValue(ctx => ({
53+
id: CodeRibbonFuzzyFileOpenerWidget.ID,
54+
createWidget: () => ctx.container.get<CodeRibbonFuzzyFileOpenerWidget>(
55+
CodeRibbonFuzzyFileOpenerWidget
56+
),
57+
})).inSingletonScope();
58+
4459
// TODO fix prefs
4560
// bind(PreferenceContribution).toConstantValue({
4661
// schema: CodeRibbonTheiaPreferenceSchema});

coderibbon-theia/src/browser/coderibbon-theia-menus.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
} from "@theia/core/lib/common";
1313

1414
import {
15-
CodeRibbonHelloWorldCommand,
15+
CodeRibbonDebuggingCommands,
1616
CodeRibbonNavigationCommands,
1717
CodeRibbonManipulationCommands,
1818
CodeRibbonArrangementCommands,
@@ -38,9 +38,11 @@ export class CodeRibbonTheiaMenuContribution implements MenuContribution {
3838
registerMenus(menus: MenuModelRegistry): void {
3939
menus.registerSubmenu(CodeRibbonTopMenuPath, "CodeRibbon");
4040

41+
// General
42+
4143
menus.registerMenuAction(CodeRibbonTopMenuPath, {
42-
commandId: CodeRibbonHelloWorldCommand.id,
43-
label: "Say Hello",
44+
commandId: CodeRibbonDebuggingCommands.testFuzzyFinderCommand.id,
45+
label: "Test FuzzyFinder",
4446
});
4547

4648
// Navigation
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
import * as React from 'react';
2+
import { injectable, postConstruct, inject } from '@theia/core/shared/inversify';
3+
import { AlertMessage } from '@theia/core/lib/browser/widgets/alert-message';
4+
import { ReactWidget } from '@theia/core/lib/browser/widgets/react-widget';
5+
import { MessageService } from '@theia/core';
6+
import { Message } from '@theia/core/lib/browser';
7+
import { AbstractViewContribution } from '@theia/core/lib/browser';
8+
import { Command, CommandRegistry } from '@theia/core/lib/common/command';
9+
10+
@injectable()
11+
export class CodeRibbonFuzzyFileOpenerWidget extends ReactWidget {
12+
static readonly ID = "coderibbon:fuzzy-file-opener";
13+
static readonly LABEL = "CodeRibbon Fuzzy File Finder";
14+
15+
@postConstruct()
16+
protected init(): void {
17+
this.id = CodeRibbonFuzzyFileOpenerWidget.ID;
18+
this.title.label = CodeRibbonFuzzyFileOpenerWidget.LABEL;
19+
this.title.caption = CodeRibbonFuzzyFileOpenerWidget.LABEL;
20+
this.title.closable = true;
21+
this.title.iconClass = "fa fa-window-maximize"; // example widget icon.
22+
this.update();
23+
}
24+
25+
render(): React.ReactElement {
26+
const header = `This is a sample widget which simply calls the messageService in order to display an info message to end users.`;
27+
return (
28+
<div id="widget-container">
29+
<AlertMessage type="INFO" header={header} />
30+
<button
31+
className="theia-button secondary"
32+
title="Display Message"
33+
onClick={(_a) => this.displayMessage()}
34+
>
35+
Display Message
36+
</button>
37+
</div>
38+
);
39+
}
40+
41+
@inject(MessageService)
42+
protected readonly messageService!: MessageService;
43+
44+
protected displayMessage(): void {
45+
this.messageService.info(
46+
"Congratulations: My Widget Successfully Created!",
47+
);
48+
}
49+
}
50+
51+
export const TestOpenFFOCommand: Command = { id: 'coderibbon:test-ffo' };
52+
53+
@injectable()
54+
export class CodeRibbonFuzzyFileOpenerContribution extends AbstractViewContribution<CodeRibbonFuzzyFileOpenerWidget> {
55+
constructor() {
56+
super({
57+
widgetId: CodeRibbonFuzzyFileOpenerWidget.ID,
58+
widgetName: CodeRibbonFuzzyFileOpenerWidget.LABEL,
59+
defaultWidgetOptions: { area: 'main' },
60+
toggleCommandId: TestOpenFFOCommand.id
61+
});
62+
}
63+
64+
override registerCommands(commands: CommandRegistry): void {
65+
commands.registerCommand(TestOpenFFOCommand, {
66+
execute: () => super.openView({ activate: false, reveal: true })
67+
});
68+
}
69+
70+
// registerMenus(menus:)
71+
}

0 commit comments

Comments
 (0)