This repository has been archived by the owner on Jan 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: jpinkney <[email protected]>
- Loading branch information
Showing
9 changed files
with
561 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
che-theia-java-extension/src/browser/libraries/chelib-resource-provider.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* Copyright (c) 2012-2018 Red Hat, Inc. | ||
* This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v2.0 | ||
* which is available at http://www.eclipse.org/legal/epl-2.0.html | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Red Hat, Inc. - initial API and implementation | ||
*/ | ||
|
||
import { injectable, inject } from "inversify"; | ||
import URI from "@theia/core/lib/common/uri"; | ||
import { Resource, ResourceResolver } from '@theia/core/lib/common'; | ||
import { ClassFileContentsRequest } from '@theia/java/lib/browser'; | ||
import { LanguageClientProvider } from "@theia/languages/lib/browser/language-client-provider"; | ||
import { ILanguageClient } from "@theia/languages/lib/common"; | ||
|
||
export class CheLibResource implements Resource { | ||
|
||
constructor( | ||
public uri: URI, | ||
protected readonly clientContribution: Promise<ILanguageClient | undefined> | ||
) { } | ||
|
||
dispose(): void { | ||
} | ||
|
||
readContents(options: { encoding?: string }): Promise<string> { | ||
const uri = this.uri.toString(); | ||
return this.clientContribution.then(languageClient => { | ||
if (languageClient) { | ||
languageClient.sendRequest(ClassFileContentsRequest.type, { uri }).then(content => | ||
content || '' | ||
) | ||
} | ||
return ''; | ||
}); | ||
} | ||
|
||
} | ||
|
||
@injectable() | ||
export class CheLibResourceResolver implements ResourceResolver { | ||
|
||
constructor( | ||
@inject(LanguageClientProvider) | ||
protected readonly languageClientProvider: LanguageClientProvider | ||
) { } | ||
|
||
resolve(uri: URI): CheLibResource { | ||
if (!(uri.scheme === "chelib")) { | ||
throw new Error("The given URI is not a valid Chelib uri: " + uri); | ||
} | ||
let javaClient = this.languageClientProvider.getLanguageClient("java"); | ||
return new CheLibResource(uri, javaClient); | ||
} | ||
|
||
} |
58 changes: 58 additions & 0 deletions
58
che-theia-java-extension/src/browser/libraries/external-libraries-container.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* Copyright (c) 2012-2018 Red Hat, Inc. | ||
* This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v2.0 | ||
* which is available at http://www.eclipse.org/legal/epl-2.0.html | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Red Hat, Inc. - initial API and implementation | ||
*/ | ||
|
||
import { Container, interfaces } from 'inversify'; | ||
import { TreeModel, TreeProps, defaultTreeProps, Tree, TreeDecoratorService } from "@theia/core/lib/browser"; | ||
import { createFileTreeContainer, FileTreeModel, FileTree } from '@theia/filesystem/lib/browser'; | ||
import { ExternalLibrariesWidget } from './external-libraries-widget'; | ||
import { NavigatorDecoratorService, NavigatorTreeDecorator } from '@theia/navigator/lib/browser'; | ||
import { bindContributionProvider } from '@theia/core'; | ||
import { FileNavigatorSearch } from '@theia/navigator/lib/browser/navigator-search'; | ||
import { FileNavigatorTree } from '@theia/navigator/lib/browser/navigator-tree'; | ||
import { ExternalLibrariesTree } from './external-libraries-tree'; | ||
import { ExternalLibraryModel } from './external-libraries-model'; | ||
|
||
export const FILE_NAVIGATOR_PROPS = <TreeProps>{ | ||
...defaultTreeProps, | ||
contextMenuPath: ['navigator-context-menu'], | ||
multiSelect: false | ||
}; | ||
|
||
export function createExternalLibrariesContainer(parent: interfaces.Container): Container { | ||
const child = createFileTreeContainer(parent); | ||
|
||
child.unbind(FileTree); | ||
child.bind(FileNavigatorTree).toSelf(); | ||
child.bind(ExternalLibrariesTree).toSelf(); | ||
child.rebind(Tree).toDynamicValue(ctx => ctx.container.get(ExternalLibrariesTree)); | ||
|
||
child.unbind(FileTreeModel); | ||
child.bind(ExternalLibraryModel).toSelf(); | ||
child.rebind(TreeModel).toDynamicValue(ctx => ctx.container.get(ExternalLibraryModel)); | ||
|
||
child.bind(ExternalLibrariesWidget).toSelf(); | ||
|
||
child.rebind(TreeProps).toConstantValue(FILE_NAVIGATOR_PROPS); | ||
|
||
child.bind(NavigatorDecoratorService).toSelf().inSingletonScope(); | ||
child.rebind(TreeDecoratorService).toDynamicValue(ctx => ctx.container.get(NavigatorDecoratorService)).inSingletonScope(); | ||
bindContributionProvider(child, NavigatorTreeDecorator); | ||
|
||
child.bind(FileNavigatorSearch).toSelf().inSingletonScope(); | ||
child.bind(NavigatorTreeDecorator).toService(FileNavigatorSearch); | ||
|
||
return child; | ||
} | ||
|
||
export function createExternalLibrariesWidget(parent: interfaces.Container): ExternalLibrariesWidget { | ||
return createExternalLibrariesContainer(parent).get(ExternalLibrariesWidget); | ||
} |
33 changes: 33 additions & 0 deletions
33
che-theia-java-extension/src/browser/libraries/external-libraries-model.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright (c) 2012-2018 Red Hat, Inc. | ||
* This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v2.0 | ||
* which is available at http://www.eclipse.org/legal/epl-2.0.html | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Red Hat, Inc. - initial API and implementation | ||
*/ | ||
|
||
import { injectable, inject } from 'inversify'; | ||
import { OpenerService, open, TreeNode } from '@theia/core/lib/browser'; | ||
import { ExternalLibrariesTree, JarFileNode } from './external-libraries-tree'; | ||
import URI from '@theia/core/lib/common/uri'; | ||
import { FileNavigatorModel } from '@theia/navigator/lib/browser'; | ||
|
||
@injectable() | ||
export class ExternalLibraryModel extends FileNavigatorModel { | ||
|
||
@inject(OpenerService) protected readonly openerService!: OpenerService; | ||
@inject(ExternalLibrariesTree) readonly tree!: ExternalLibrariesTree; | ||
|
||
protected doOpenNode(node: TreeNode): void { | ||
if (JarFileNode.is(node)) { | ||
open(this.openerService, new URI(node.jarEntry.uri)); | ||
} else { | ||
super.doOpenNode(node); | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.