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

fuzzy finder opener in patches #28

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
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
28 changes: 19 additions & 9 deletions coderibbon-theia/src/browser/coderibbon-theia-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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

Expand Down
15 changes: 15 additions & 0 deletions coderibbon-theia/src/browser/coderibbon-theia-frontend-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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
Expand All @@ -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>(
CodeRibbonFuzzyFileOpenerWidget
),
})).inSingletonScope();

// TODO fix prefs
// bind(PreferenceContribution).toConstantValue({
// schema: CodeRibbonTheiaPreferenceSchema});
Expand Down
8 changes: 5 additions & 3 deletions coderibbon-theia/src/browser/coderibbon-theia-menus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
} from "@theia/core/lib/common";

import {
CodeRibbonHelloWorldCommand,
CodeRibbonDebuggingCommands,
CodeRibbonNavigationCommands,
CodeRibbonManipulationCommands,
CodeRibbonArrangementCommands,
Expand All @@ -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
Expand Down
71 changes: 71 additions & 0 deletions coderibbon-theia/src/browser/cr-fuzzy-file-opener.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<div id="widget-container">
<AlertMessage type="INFO" header={header} />
<button
className="theia-button secondary"
title="Display Message"
onClick={(_a) => this.displayMessage()}
>
Display Message
</button>
</div>
);
}

@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<CodeRibbonFuzzyFileOpenerWidget> {
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:)
}