Search in sources :

Example 1 with JsArrayString

use of com.google.gwt.core.client.JsArrayString 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)

Example 2 with JsArrayString

use of com.google.gwt.core.client.JsArrayString in project che by eclipse.

the class OrionContentTypeRegistrant method registerFileType.

public void registerFileType(final OrionContentTypeOverlay contentType, final OrionHighlightingConfigurationOverlay config) {
    // register content type and configure orion
    JsArrayString extensions = contentType.getExtensions();
    for (int i = 0; i < extensions.length(); i++) {
        String extension = extensions.get(i);
        fileTypeIdentifier.registerNewExtension(extension, newArrayList(contentType.getId()));
    }
    editorModule.getInitializerPromise().then(new Operation<Void>() {

        @Override
        public void apply(Void arg) throws OperationException {
            OrionServiceRegistryOverlay serviceRegistry = codeEditWidgetProvider.get().getServiceRegistry();
            serviceRegistry.doRegisterService("orion.core.contenttype", JavaScriptObject.createObject(), contentType.toServiceObject());
            serviceRegistry.doRegisterService("orion.edit.highlighter", JavaScriptObject.createObject(), config);
        }
    });
}
Also used : JsArrayString(com.google.gwt.core.client.JsArrayString) JsArrayString(com.google.gwt.core.client.JsArrayString) OrionServiceRegistryOverlay(org.eclipse.che.ide.editor.orion.client.jso.OrionServiceRegistryOverlay) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 3 with JsArrayString

use of com.google.gwt.core.client.JsArrayString in project che by eclipse.

the class OrionCodeEditWidgetProvider method get.

@Override
public OrionCodeEditWidgetOverlay get() {
    if (orionCodeEditWidgetOverlay == null) {
        JsArrayString plugins = JavaScriptObject.createArray().cast();
        for (OrionPlugin orionPlugin : orionPlugins) {
            plugins.push(GWT.getModuleBaseURL() + orionPlugin.getRelPath());
        }
        OrionCodeEditWidgetOverlay codeEditWidgetModule = moduleHolder.getModule("CodeEditWidget").cast();
        orionCodeEditWidgetOverlay = codeEditWidgetModule.create(plugins);
    }
    return orionCodeEditWidgetOverlay;
}
Also used : JsArrayString(com.google.gwt.core.client.JsArrayString) OrionCodeEditWidgetOverlay(org.eclipse.che.ide.editor.orion.client.jso.OrionCodeEditWidgetOverlay)

Example 4 with JsArrayString

use of com.google.gwt.core.client.JsArrayString in project che by eclipse.

the class OrionContentTypeOverlay method setFileName.

public final void setFileName(String... fileNames) {
    JsArrayString arr = JavaScriptObject.createArray().cast();
    for (String value : fileNames) {
        arr.push(value);
    }
    setFileName(arr);
}
Also used : JsArrayString(com.google.gwt.core.client.JsArrayString) JsArrayString(com.google.gwt.core.client.JsArrayString)

Example 5 with JsArrayString

use of com.google.gwt.core.client.JsArrayString in project che by eclipse.

the class OrionHighlightingConfigurationOverlay method setContentTypes.

public final void setContentTypes(String... theContentTypes) {
    JsArrayString arr = JavaScriptObject.createArray().cast();
    for (String value : theContentTypes) {
        arr.push(value);
    }
    setContentTypes(arr);
}
Also used : JsArrayString(com.google.gwt.core.client.JsArrayString) JsArrayString(com.google.gwt.core.client.JsArrayString)

Aggregations

JsArrayString (com.google.gwt.core.client.JsArrayString)86 ArrayList (java.util.ArrayList)15 JSONString (com.google.gwt.json.client.JSONString)5 Position (org.rstudio.studio.client.workbench.views.source.editors.text.ace.Position)5 ServerError (org.rstudio.studio.client.server.ServerError)4 JsArrayInteger (com.google.gwt.core.client.JsArrayInteger)3 Command (com.google.gwt.user.client.Command)3 List (java.util.List)3 KeySequence (org.rstudio.core.client.command.KeyboardShortcut.KeySequence)3 JsObject (org.rstudio.core.client.js.JsObject)3 RmdTemplateFormatOption (org.rstudio.studio.client.rmarkdown.model.RmdTemplateFormatOption)3 JsArrayBoolean (com.google.gwt.core.client.JsArrayBoolean)2 FlowPanel (com.google.gwt.user.client.ui.FlowPanel)2 Label (com.google.gwt.user.client.ui.Label)2 OperationException (org.eclipse.che.api.promises.client.OperationException)2 Handler (org.rstudio.core.client.command.Handler)2 EnsureHeightHandler (org.rstudio.core.client.events.EnsureHeightHandler)2 EnsureVisibleHandler (org.rstudio.core.client.events.EnsureVisibleHandler)2 ChangeFontSizeHandler (org.rstudio.studio.client.application.events.ChangeFontSizeHandler)2 RmdFrontMatterOutputOptions (org.rstudio.studio.client.rmarkdown.model.RmdFrontMatterOutputOptions)2