Search in sources :

Example 11 with FileType

use of org.eclipse.che.ide.api.filetypes.FileType in project che by eclipse.

the class EditorAgentImpl method doOpen.

private void doOpen(final VirtualFile file, final OpenEditorCallback callback, final Constraints constraints) {
    EditorPartStack activePartStack = editorMultiPartStack.getActivePartStack();
    if (constraints == null && activePartStack != null) {
        PartPresenter partPresenter = activePartStack.getPartByPath(file.getLocation());
        if (partPresenter != null) {
            workspaceAgent.setActivePart(partPresenter, EDITING);
            callback.onEditorActivated((EditorPartPresenter) partPresenter);
            return;
        }
    }
    final FileType fileType = fileTypeRegistry.getFileTypeByFile(file);
    final EditorProvider editorProvider = editorRegistry.getEditor(fileType);
    if (editorProvider instanceof AsyncEditorProvider) {
        AsyncEditorProvider provider = (AsyncEditorProvider) editorProvider;
        Promise<EditorPartPresenter> promise = provider.createEditor(file);
        if (promise != null) {
            promise.then(new Operation<EditorPartPresenter>() {

                @Override
                public void apply(EditorPartPresenter arg) throws OperationException {
                    initEditor(file, callback, fileType, arg, constraints, editorProvider);
                }
            });
            return;
        }
    }
    final EditorPartPresenter editor = editorProvider.getEditor();
    initEditor(file, callback, fileType, editor, constraints, editorProvider);
}
Also used : FileType(org.eclipse.che.ide.api.filetypes.FileType) AsyncEditorProvider(org.eclipse.che.ide.api.editor.AsyncEditorProvider) PartPresenter(org.eclipse.che.ide.api.parts.PartPresenter) EditorPartPresenter(org.eclipse.che.ide.api.editor.EditorPartPresenter) EditorPartPresenter(org.eclipse.che.ide.api.editor.EditorPartPresenter) EditorPartStack(org.eclipse.che.ide.api.parts.EditorPartStack) EditorProvider(org.eclipse.che.ide.api.editor.EditorProvider) AsyncEditorProvider(org.eclipse.che.ide.api.editor.AsyncEditorProvider) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 12 with FileType

use of org.eclipse.che.ide.api.filetypes.FileType in project che by eclipse.

the class EditorTabWidget method update.

/** {@inheritDoc} */
@Override
public void update(@NotNull PartPresenter part) {
    title.setText(part.getTitle());
    if (part instanceof EditorPartPresenter) {
        file = ((EditorPartPresenter) part).getEditorInput().getFile();
        FileType fileType = fileTypeRegistry.getFileTypeByFile(file);
        icon = fileType.getImage();
        iconPanel.setWidget(getIcon());
    }
}
Also used : FileType(org.eclipse.che.ide.api.filetypes.FileType) EditorPartPresenter(org.eclipse.che.ide.api.editor.EditorPartPresenter)

Aggregations

FileType (org.eclipse.che.ide.api.filetypes.FileType)12 Test (org.junit.Test)5 EditorPartPresenter (org.eclipse.che.ide.api.editor.EditorPartPresenter)3 Operation (org.eclipse.che.api.promises.client.Operation)2 OperationException (org.eclipse.che.api.promises.client.OperationException)2 EditorInput (org.eclipse.che.ide.api.editor.EditorInput)2 PartPresenter (org.eclipse.che.ide.api.parts.PartPresenter)2 Before (org.junit.Before)2 Lists.newArrayList (com.google.common.collect.Lists.newArrayList)1 JsArrayString (com.google.gwt.core.client.JsArrayString)1 Inject (com.google.inject.Inject)1 List (java.util.List)1 Logger (java.util.logging.Logger)1 DebugSessionDto (org.eclipse.che.api.debug.shared.dto.DebugSessionDto)1 LanguageDescriptionDTO (org.eclipse.che.api.languageserver.shared.lsapi.LanguageDescriptionDTO)1 PromiseError (org.eclipse.che.api.promises.client.PromiseError)1 AsyncEditorProvider (org.eclipse.che.ide.api.editor.AsyncEditorProvider)1 EditorProvider (org.eclipse.che.ide.api.editor.EditorProvider)1 OpenEditorCallbackImpl (org.eclipse.che.ide.api.editor.OpenEditorCallbackImpl)1 Document (org.eclipse.che.ide.api.editor.document.Document)1