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()));
}
});
}
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);
}
});
}
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;
}
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);
}
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);
}
Aggregations