diff --git a/coderibbon-theia/src/browser/coderibbon-theia-commands.ts b/coderibbon-theia/src/browser/coderibbon-theia-commands.ts index 12a8965..5770d6a 100644 --- a/coderibbon-theia/src/browser/coderibbon-theia-commands.ts +++ b/coderibbon-theia/src/browser/coderibbon-theia-commands.ts @@ -13,9 +13,15 @@ import { CodeRibbonTheiaRibbonStrip } from "./cr-ribbon-strip"; import { crdebug } from "./cr-logger"; -export const CodeRibbonHelloWorldCommand = { - id: "CodeRibbon.HelloWorld", - label: "Hello, CodeRibbon.", +export const CodeRibbonDebuggingCommands = { + helloWorldCommand: { + id: "CodeRibbon.HelloWorld", + label: "Hello, CodeRibbon.", + }, + testFuzzyFinderCommand: { + id: "CodeRibbon.dev.test_ff", + label: "CodeRibbon Test FuzzyFinder", + }, }; export const CodeRibbonDevGetPanelCommand = { @@ -136,18 +142,22 @@ export class CodeRibbonTheiaCommandContribution implements CommandContribution { ) {} registerCommands(registry: CommandRegistry): void { - registry.registerCommand(CodeRibbonHelloWorldCommand, { + + // === NOTE: Debugging section + // TODO: only register these in debug mode + + registry.registerCommand(CodeRibbonDebuggingCommands.helloWorldCommand, { execute: () => { this.messageService.info("CodeRibbon says hello!"); crdebug("Hello console! CommandContribution:", this); // crdebug("CRAS is:", this.cras); }, }); - // registry.registerCommand(CodeRibbonDevGetPanelCommand, { - // execute: () => { - // crdebug(); - // } - // }); + registry.registerCommand(CodeRibbonDebuggingCommands.testFuzzyFinderCommand, { + execute: () => { + crdebug(); + } + }); // === NOTE: Nav section diff --git a/coderibbon-theia/src/browser/coderibbon-theia-frontend-module.ts b/coderibbon-theia/src/browser/coderibbon-theia-frontend-module.ts index be9bf7b..efce115 100644 --- a/coderibbon-theia/src/browser/coderibbon-theia-frontend-module.ts +++ b/coderibbon-theia/src/browser/coderibbon-theia-frontend-module.ts @@ -15,6 +15,7 @@ import { } from "@theia/core/lib/browser"; import { PreferenceContribution } from "@theia/core/lib/browser/preferences"; import { ApplicationShell } from "@theia/core/lib/browser/shell/application-shell"; +import { bindViewContribution, FrontendApplicationContribution, WidgetFactory } from '@theia/core/lib/browser'; // import { CodeRibbonTheiaRibbonViewContribution } from './coderibbon-theia-ribbon'; import { CodeRibbonTheiaCommandContribution } from "./coderibbon-theia-commands"; @@ -24,6 +25,10 @@ import { CodeRibbonTheiaManager } from "./coderibbon-theia-manager"; import { CodeRibbonTheiaRibbonPanel } from "./cr-ribbon"; import { CodeRibbonApplicationShell } from "./cr-application-shell"; import { CodeRibbonTheiaKeybindingContribution } from "./coderibbon-theia-keybinds"; +import { + CodeRibbonFuzzyFileOpenerWidget, + CodeRibbonFuzzyFileOpenerContribution, +} from "./cr-fuzzy-file-opener"; import "../../src/browser/style/ribbon.less"; // temp CSS @@ -39,6 +44,16 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => { bind(MenuContribution).to(CodeRibbonTheiaMenuContribution); bind(KeybindingContribution).to(CodeRibbonTheiaKeybindingContribution); + bindViewContribution(bind, CodeRibbonFuzzyFileOpenerContribution); + bind(FrontendApplicationContribution).toService(CodeRibbonFuzzyFileOpenerContribution); + bind(CodeRibbonFuzzyFileOpenerWidget).toSelf(); + bind(WidgetFactory).toDynamicValue(ctx => ({ + id: CodeRibbonFuzzyFileOpenerWidget.ID, + createWidget: () => ctx.container.get( + CodeRibbonFuzzyFileOpenerWidget + ), + })).inSingletonScope(); + // TODO fix prefs // bind(PreferenceContribution).toConstantValue({ // schema: CodeRibbonTheiaPreferenceSchema}); diff --git a/coderibbon-theia/src/browser/coderibbon-theia-menus.ts b/coderibbon-theia/src/browser/coderibbon-theia-menus.ts index 55d9f7c..b5b5f54 100644 --- a/coderibbon-theia/src/browser/coderibbon-theia-menus.ts +++ b/coderibbon-theia/src/browser/coderibbon-theia-menus.ts @@ -10,7 +10,7 @@ import { } from "@theia/core/lib/common"; import { - CodeRibbonHelloWorldCommand, + CodeRibbonDebuggingCommands, CodeRibbonNavigationCommands, CodeRibbonManipulationCommands, CodeRibbonArrangementCommands, @@ -36,9 +36,11 @@ export class CodeRibbonTheiaMenuContribution implements MenuContribution { registerMenus(menus: MenuModelRegistry): void { menus.registerSubmenu(CodeRibbonTopMenuPath, "CodeRibbon"); + // General + menus.registerMenuAction(CodeRibbonTopMenuPath, { - commandId: CodeRibbonHelloWorldCommand.id, - label: "Say Hello", + commandId: CodeRibbonDebuggingCommands.testFuzzyFinderCommand.id, + label: "Test FuzzyFinder", }); // Navigation diff --git a/coderibbon-theia/src/browser/cr-fuzzy-file-opener.tsx b/coderibbon-theia/src/browser/cr-fuzzy-file-opener.tsx new file mode 100644 index 0000000..b2a2a84 --- /dev/null +++ b/coderibbon-theia/src/browser/cr-fuzzy-file-opener.tsx @@ -0,0 +1,71 @@ +import * as React from 'react'; +import { injectable, postConstruct, inject } from '@theia/core/shared/inversify'; +import { AlertMessage } from '@theia/core/lib/browser/widgets/alert-message'; +import { ReactWidget } from '@theia/core/lib/browser/widgets/react-widget'; +import { MessageService } from '@theia/core'; +import { Message } from '@theia/core/lib/browser'; +import { AbstractViewContribution } from '@theia/core/lib/browser'; +import { Command, CommandRegistry } from '@theia/core/lib/common/command'; + +@injectable() +export class CodeRibbonFuzzyFileOpenerWidget extends ReactWidget { + static readonly ID = "coderibbon:fuzzy-file-opener"; + static readonly LABEL = "CodeRibbon Fuzzy File Finder"; + + @postConstruct() + protected init(): void { + this.id = CodeRibbonFuzzyFileOpenerWidget.ID; + this.title.label = CodeRibbonFuzzyFileOpenerWidget.LABEL; + this.title.caption = CodeRibbonFuzzyFileOpenerWidget.LABEL; + this.title.closable = true; + this.title.iconClass = "fa fa-window-maximize"; // example widget icon. + this.update(); + } + + render(): React.ReactElement { + const header = `This is a sample widget which simply calls the messageService in order to display an info message to end users.`; + return ( +
+ + +
+ ); + } + + @inject(MessageService) + protected readonly messageService!: MessageService; + + protected displayMessage(): void { + this.messageService.info( + "Congratulations: My Widget Successfully Created!", + ); + } +} + +export const TestOpenFFOCommand: Command = { id: 'coderibbon:test-ffo' }; + +@injectable() +export class CodeRibbonFuzzyFileOpenerContribution extends AbstractViewContribution { + constructor() { + super({ + widgetId: CodeRibbonFuzzyFileOpenerWidget.ID, + widgetName: CodeRibbonFuzzyFileOpenerWidget.LABEL, + defaultWidgetOptions: { area: 'main' }, + toggleCommandId: TestOpenFFOCommand.id + }); + } + + override registerCommands(commands: CommandRegistry): void { + commands.registerCommand(TestOpenFFOCommand, { + execute: () => super.openView({ activate: false, reveal: true }) + }); + } + + // registerMenus(menus:) +}