Merge pull request #2262 from eclipse/1878
Add possibility to install Orion plugins for the CHE editor6.19.x
commit
918ea65d03
|
|
@ -10,6 +10,9 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.che.ide.editor.orion.client.inject;
|
||||
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.core.client.JavaScriptObject;
|
||||
import com.google.gwt.core.client.JsArrayString;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
|
|
@ -17,6 +20,9 @@ import com.google.inject.Singleton;
|
|||
import org.eclipse.che.ide.editor.orion.client.jso.OrionCodeEditWidgetOverlay;
|
||||
import org.eclipse.che.ide.requirejs.ModuleHolder;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Provider of Orion CodeEdit widget instance.
|
||||
*
|
||||
|
|
@ -26,18 +32,32 @@ import org.eclipse.che.ide.requirejs.ModuleHolder;
|
|||
public class OrionCodeEditWidgetProvider implements Provider<OrionCodeEditWidgetOverlay> {
|
||||
|
||||
private final ModuleHolder moduleHolder;
|
||||
private final Set<OrionPlugin> orionPlugins;
|
||||
private OrionCodeEditWidgetOverlay orionCodeEditWidgetOverlay;
|
||||
|
||||
@Inject
|
||||
public OrionCodeEditWidgetProvider(ModuleHolder moduleHolder) {
|
||||
this.moduleHolder = moduleHolder;
|
||||
orionPlugins = new HashSet<>();
|
||||
}
|
||||
|
||||
@Inject(optional = true)
|
||||
private void registerPlugins(Set<OrionPlugin> plugins) {
|
||||
for (OrionPlugin registrar : plugins) {
|
||||
orionPlugins.add(registrar);
|
||||
}
|
||||
}
|
||||
|
||||
@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();
|
||||
orionCodeEditWidgetOverlay = codeEditWidgetModule.create(plugins);
|
||||
}
|
||||
return orionCodeEditWidgetOverlay;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,25 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2012-2016 Codenvy, S.A.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Codenvy, S.A. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.che.ide.editor.orion.client.inject;
|
||||
|
||||
/**
|
||||
* Interface for providing information needed for registering Orion plugin.
|
||||
* <p>
|
||||
* Implementations of this interface need to be registered using
|
||||
* a multibinder in order to be picked-up by CHE.
|
||||
*
|
||||
* @author Artem Zatsarynnyi
|
||||
*/
|
||||
public interface OrionPlugin {
|
||||
|
||||
/** Returns path to the Orion plugin's html file. Path should be relative to the GWT's 'public' folder. */
|
||||
String getRelPath();
|
||||
}
|
||||
|
|
@ -11,6 +11,7 @@
|
|||
package org.eclipse.che.ide.editor.orion.client.jso;
|
||||
|
||||
import com.google.gwt.core.client.JavaScriptObject;
|
||||
import com.google.gwt.core.client.JsArrayString;
|
||||
import com.google.gwt.dom.client.Element;
|
||||
|
||||
import org.eclipse.che.api.promises.client.Promise;
|
||||
|
|
@ -25,9 +26,14 @@ public class OrionCodeEditWidgetOverlay extends JavaScriptObject {
|
|||
protected OrionCodeEditWidgetOverlay() {
|
||||
}
|
||||
|
||||
/** Creates an Orion CodeEdit widget instance. */
|
||||
public final native OrionCodeEditWidgetOverlay create() /*-{
|
||||
return new this();
|
||||
/**
|
||||
* Creates an Orion CodeEdit widget instance.
|
||||
*
|
||||
* @param plugins
|
||||
* array of URLs of plugins that should be installed before CodeEdit widget initialization
|
||||
*/
|
||||
public final native OrionCodeEditWidgetOverlay create(JsArrayString plugins) /*-{
|
||||
return new this({userPlugins: plugins});
|
||||
}-*/;
|
||||
|
||||
/**
|
||||
|
|
@ -43,10 +49,10 @@ public class OrionCodeEditWidgetOverlay extends JavaScriptObject {
|
|||
options.parent = element;
|
||||
return this.create(options);
|
||||
}-*/;
|
||||
|
||||
|
||||
/**
|
||||
* Provides Access to Orion's service registry.
|
||||
*
|
||||
*
|
||||
* @return the service registry
|
||||
*/
|
||||
public final native OrionServiceRegistryOverlay getServiceRegistry() /*-{
|
||||
|
|
|
|||
Loading…
Reference in New Issue