Search in sources :

Example 1 with FileType

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

the class MavenExtension method registerFileType.

@Inject
private void registerFileType(FileTypeRegistry fileTypeRegistry, MavenResources mavenResources, EditorRegistry editorRegistry, PomEditorProvider editorProvider) {
    FileType pomFile = new FileType(mavenResources.maven(), "pom.xml", "pom\\.xml");
    fileTypeRegistry.registerFileType(pomFile);
    editorRegistry.register(pomFile, editorProvider);
}
Also used : FileType(org.eclipse.che.ide.api.filetypes.FileType) Inject(com.google.inject.Inject)

Example 2 with FileType

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

the class RecipeEditorPanelTest method scriptShouldBeReturned.

@Test
public void scriptShouldBeReturned() throws Exception {
    FileType fileType = mock(FileType.class);
    Document document = mock(Document.class);
    when(fileTypeRegistry.getFileTypeByFile(recipeFile)).thenReturn(fileType);
    when(editor.getDocument()).thenReturn(document);
    presenter.showEditor();
    presenter.getScript();
    verify(editor).getDocument();
    verify(document).getContents();
}
Also used : FileType(org.eclipse.che.ide.api.filetypes.FileType) Document(org.eclipse.che.ide.api.editor.document.Document) Test(org.junit.Test)

Example 3 with FileType

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

the class RecipeEditorPanel method initializeEditor.

private void initializeEditor(@NotNull final VirtualFile file) {
    FileType fileType = fileTypeRegistry.getFileTypeByFile(file);
    editor = getEditor();
    editor.activate();
    editor.onOpen();
    view.showEditor(editor);
    // wait when editor is initialized
    editor.addPropertyListener(new PropertyListener() {

        @Override
        public void propertyChanged(PartPresenter source, int propId) {
            switch(propId) {
                case PROP_INPUT:
                    view.showEditor(editor);
                    break;
                case PROP_DIRTY:
                    if (validateUndoOperation()) {
                        setEnableSaveAndCancelButtons(true);
                    }
                    break;
                default:
            }
        }
    });
    editor.init(new RecipeEditorInput(fileType, file), new OpenEditorCallbackImpl());
}
Also used : FileType(org.eclipse.che.ide.api.filetypes.FileType) PropertyListener(org.eclipse.che.ide.api.parts.PropertyListener) OpenEditorCallbackImpl(org.eclipse.che.ide.api.editor.OpenEditorCallbackImpl) PartPresenter(org.eclipse.che.ide.api.parts.PartPresenter) EditorPartPresenter(org.eclipse.che.ide.api.editor.EditorPartPresenter)

Example 4 with FileType

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

the class DebuggerPresenterTest method setup.

@Before
public void setup() {
    doReturn(debugger).when(debuggerManager).getActiveDebugger();
    doReturn(ERROR_MESSAGE).when(promiseError).getMessage();
    presenter = spy(new DebuggerPresenter(view, constant, breakpointManager, notificationManager, debuggerResources, debuggerToolbar, debuggerManager, workspaceAgent));
    doNothing().when(presenter).showDebuggerPanel();
    presenter.onSelectedVariableElement(selectedVariable);
    FileType fileType = mock(FileType.class);
    doReturn("java").when(fileType).getExtension();
    doReturn(fileType).when(fileTypeRegistry).getFileTypeByFile(eq(file));
}
Also used : FileType(org.eclipse.che.ide.api.filetypes.FileType) Before(org.junit.Before)

Example 5 with FileType

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

the class LanguageServerFileTypeRegister method start.

@Override
public void start(final Callback<WsAgentComponent, Exception> callback) {
    Promise<List<LanguageDescriptionDTO>> registeredLanguages = serverLanguageRegistry.getSupportedLanguages();
    registeredLanguages.then(new Operation<List<LanguageDescriptionDTO>>() {

        @Override
        public void apply(List<LanguageDescriptionDTO> langs) throws OperationException {
            if (!langs.isEmpty()) {
                JsArrayString contentTypes = JsArrayString.createArray().cast();
                for (LanguageDescriptionDTO lang : langs) {
                    String primaryExtension = lang.getFileExtensions().get(0);
                    for (String ext : lang.getFileExtensions()) {
                        final FileType fileType = new FileType(resources.file(), ext);
                        fileTypeRegistry.registerFileType(fileType);
                        editorRegistry.registerDefaultEditor(fileType, editorProvider);
                        ext2langId.put(ext, lang.getLanguageId());
                    }
                    List<String> mimeTypes = lang.getMimeTypes();
                    if (mimeTypes.isEmpty()) {
                        mimeTypes = newArrayList("text/x-" + lang.getLanguageId());
                    }
                    for (String contentTypeId : mimeTypes) {
                        contentTypes.push(contentTypeId);
                        OrionContentTypeOverlay contentType = OrionContentTypeOverlay.create();
                        contentType.setId(contentTypeId);
                        contentType.setName(lang.getLanguageId());
                        contentType.setExtension(primaryExtension);
                        contentType.setExtends("text/plain");
                        // highlighting
                        OrionHighlightingConfigurationOverlay config = OrionHighlightingConfigurationOverlay.create();
                        config.setId(lang.getLanguageId() + ".highlighting");
                        config.setContentTypes(contentTypeId);
                        config.setPatterns(lang.getHighlightingConfiguration());
                        Logger logger = Logger.getLogger(LanguageServerFileTypeRegister.class.getName());
                        contentTypeRegistrant.registerFileType(contentType, config);
                    }
                }
                orionHoverRegistrant.registerHover(contentTypes, hoverProvider);
                orionOccurrencesRegistrant.registerOccurrencesHandler(contentTypes, occurrencesProvider);
            }
            callback.onSuccess(LanguageServerFileTypeRegister.this);
        }
    }).catchError(new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError arg) throws OperationException {
            callback.onFailure(new Exception(arg.getMessage(), arg.getCause()));
        }
    });
}
Also used : OrionHighlightingConfigurationOverlay(org.eclipse.che.ide.editor.orion.client.jso.OrionHighlightingConfigurationOverlay) LanguageDescriptionDTO(org.eclipse.che.api.languageserver.shared.lsapi.LanguageDescriptionDTO) OrionContentTypeOverlay(org.eclipse.che.ide.editor.orion.client.jso.OrionContentTypeOverlay) Operation(org.eclipse.che.api.promises.client.Operation) JsArrayString(com.google.gwt.core.client.JsArrayString) JsArrayString(com.google.gwt.core.client.JsArrayString) Logger(java.util.logging.Logger) OperationException(org.eclipse.che.api.promises.client.OperationException) PromiseError(org.eclipse.che.api.promises.client.PromiseError) FileType(org.eclipse.che.ide.api.filetypes.FileType) List(java.util.List) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) OperationException(org.eclipse.che.api.promises.client.OperationException)

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