mirror of
				https://github.com/Minres/RDL-Editor.git
				synced 2025-11-04 12:31:38 +00:00 
			
		
		
		
	Migrated to XText 2.14 and Photon for RDL Editor RCP
This commit is contained in:
		@@ -0,0 +1,40 @@
 | 
			
		||||
/**
 | 
			
		||||
 * generated by Xtext 2.14.0
 | 
			
		||||
 */
 | 
			
		||||
package com.minres.rdl.web;
 | 
			
		||||
 | 
			
		||||
import com.google.inject.Injector;
 | 
			
		||||
import com.minres.rdl.web.RDLWebSetup;
 | 
			
		||||
import javax.servlet.annotation.WebServlet;
 | 
			
		||||
import org.eclipse.xtext.util.DisposableRegistry;
 | 
			
		||||
import org.eclipse.xtext.web.servlet.XtextServlet;
 | 
			
		||||
import org.eclipse.xtext.xbase.lib.Exceptions;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Deploy this class into a servlet container to enable DSL-specific services.
 | 
			
		||||
 */
 | 
			
		||||
@WebServlet(name = "XtextServices", urlPatterns = "/xtext-service/*")
 | 
			
		||||
@SuppressWarnings("all")
 | 
			
		||||
public class RDLServlet extends XtextServlet {
 | 
			
		||||
  private DisposableRegistry disposableRegistry;
 | 
			
		||||
  
 | 
			
		||||
  @Override
 | 
			
		||||
  public void init() {
 | 
			
		||||
    try {
 | 
			
		||||
      super.init();
 | 
			
		||||
      final Injector injector = new RDLWebSetup().createInjectorAndDoEMFRegistration();
 | 
			
		||||
      this.disposableRegistry = injector.<DisposableRegistry>getInstance(DisposableRegistry.class);
 | 
			
		||||
    } catch (Throwable _e) {
 | 
			
		||||
      throw Exceptions.sneakyThrow(_e);
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  
 | 
			
		||||
  @Override
 | 
			
		||||
  public void destroy() {
 | 
			
		||||
    if ((this.disposableRegistry != null)) {
 | 
			
		||||
      this.disposableRegistry.dispose();
 | 
			
		||||
      this.disposableRegistry = null;
 | 
			
		||||
    }
 | 
			
		||||
    super.destroy();
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,13 @@
 | 
			
		||||
/**
 | 
			
		||||
 * generated by Xtext 2.14.0
 | 
			
		||||
 */
 | 
			
		||||
package com.minres.rdl.web;
 | 
			
		||||
 | 
			
		||||
import com.minres.rdl.web.AbstractRDLWebModule;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Use this class to register additional components to be used within the web application.
 | 
			
		||||
 */
 | 
			
		||||
@SuppressWarnings("all")
 | 
			
		||||
public class RDLWebModule extends AbstractRDLWebModule {
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,26 @@
 | 
			
		||||
/**
 | 
			
		||||
 * generated by Xtext 2.14.0
 | 
			
		||||
 */
 | 
			
		||||
package com.minres.rdl.web;
 | 
			
		||||
 | 
			
		||||
import com.google.inject.Guice;
 | 
			
		||||
import com.google.inject.Injector;
 | 
			
		||||
import com.minres.rdl.RDLRuntimeModule;
 | 
			
		||||
import com.minres.rdl.RDLStandaloneSetup;
 | 
			
		||||
import com.minres.rdl.ide.RDLIdeModule;
 | 
			
		||||
import com.minres.rdl.web.RDLWebModule;
 | 
			
		||||
import org.eclipse.xtext.util.Modules2;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Initialization support for running Xtext languages in web applications.
 | 
			
		||||
 */
 | 
			
		||||
@SuppressWarnings("all")
 | 
			
		||||
public class RDLWebSetup extends RDLStandaloneSetup {
 | 
			
		||||
  @Override
 | 
			
		||||
  public Injector createInjector() {
 | 
			
		||||
    RDLRuntimeModule _rDLRuntimeModule = new RDLRuntimeModule();
 | 
			
		||||
    RDLIdeModule _rDLIdeModule = new RDLIdeModule();
 | 
			
		||||
    RDLWebModule _rDLWebModule = new RDLWebModule();
 | 
			
		||||
    return Guice.createInjector(Modules2.mixin(_rDLRuntimeModule, _rDLIdeModule, _rDLWebModule));
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,77 @@
 | 
			
		||||
/**
 | 
			
		||||
 * generated by Xtext 2.14.0
 | 
			
		||||
 */
 | 
			
		||||
package com.minres.rdl.web;
 | 
			
		||||
 | 
			
		||||
import java.net.InetSocketAddress;
 | 
			
		||||
import java.net.URI;
 | 
			
		||||
import org.eclipse.jetty.annotations.AnnotationConfiguration;
 | 
			
		||||
import org.eclipse.jetty.server.Server;
 | 
			
		||||
import org.eclipse.jetty.util.log.Slf4jLog;
 | 
			
		||||
import org.eclipse.jetty.webapp.Configuration;
 | 
			
		||||
import org.eclipse.jetty.webapp.MetaInfConfiguration;
 | 
			
		||||
import org.eclipse.jetty.webapp.WebAppContext;
 | 
			
		||||
import org.eclipse.jetty.webapp.WebInfConfiguration;
 | 
			
		||||
import org.eclipse.jetty.webapp.WebXmlConfiguration;
 | 
			
		||||
import org.eclipse.xtext.xbase.lib.Exceptions;
 | 
			
		||||
import org.eclipse.xtext.xbase.lib.ObjectExtensions;
 | 
			
		||||
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * This program starts an HTTP server for testing the web integration of your DSL.
 | 
			
		||||
 * Just execute it and point a web browser to http://localhost:8080/
 | 
			
		||||
 */
 | 
			
		||||
@SuppressWarnings("all")
 | 
			
		||||
public class ServerLauncher {
 | 
			
		||||
  public static void main(final String[] args) {
 | 
			
		||||
    InetSocketAddress _inetSocketAddress = new InetSocketAddress("localhost", 8080);
 | 
			
		||||
    final Server server = new Server(_inetSocketAddress);
 | 
			
		||||
    WebAppContext _webAppContext = new WebAppContext();
 | 
			
		||||
    final Procedure1<WebAppContext> _function = (WebAppContext it) -> {
 | 
			
		||||
      it.setResourceBase("WebRoot");
 | 
			
		||||
      it.setWelcomeFiles(new String[] { "index.html" });
 | 
			
		||||
      it.setContextPath("/");
 | 
			
		||||
      AnnotationConfiguration _annotationConfiguration = new AnnotationConfiguration();
 | 
			
		||||
      WebXmlConfiguration _webXmlConfiguration = new WebXmlConfiguration();
 | 
			
		||||
      WebInfConfiguration _webInfConfiguration = new WebInfConfiguration();
 | 
			
		||||
      MetaInfConfiguration _metaInfConfiguration = new MetaInfConfiguration();
 | 
			
		||||
      it.setConfigurations(new Configuration[] { _annotationConfiguration, _webXmlConfiguration, _webInfConfiguration, _metaInfConfiguration });
 | 
			
		||||
      it.setAttribute(WebInfConfiguration.CONTAINER_JAR_PATTERN, ".*/com\\.minres\\.rdl\\.web/.*,.*\\.jar");
 | 
			
		||||
      it.setInitParameter("org.mortbay.jetty.servlet.Default.useFileMappedBuffer", "false");
 | 
			
		||||
    };
 | 
			
		||||
    WebAppContext _doubleArrow = ObjectExtensions.<WebAppContext>operator_doubleArrow(_webAppContext, _function);
 | 
			
		||||
    server.setHandler(_doubleArrow);
 | 
			
		||||
    String _name = ServerLauncher.class.getName();
 | 
			
		||||
    final Slf4jLog log = new Slf4jLog(_name);
 | 
			
		||||
    try {
 | 
			
		||||
      server.start();
 | 
			
		||||
      URI _uRI = server.getURI();
 | 
			
		||||
      String _plus = ("Server started " + _uRI);
 | 
			
		||||
      String _plus_1 = (_plus + "...");
 | 
			
		||||
      log.info(_plus_1);
 | 
			
		||||
      final Runnable _function_1 = () -> {
 | 
			
		||||
        try {
 | 
			
		||||
          log.info("Press enter to stop the server...");
 | 
			
		||||
          final int key = System.in.read();
 | 
			
		||||
          if ((key != (-1))) {
 | 
			
		||||
            server.stop();
 | 
			
		||||
          } else {
 | 
			
		||||
            log.warn("Console input is not available. In order to stop the server, you need to cancel process manually.");
 | 
			
		||||
          }
 | 
			
		||||
        } catch (Throwable _e) {
 | 
			
		||||
          throw Exceptions.sneakyThrow(_e);
 | 
			
		||||
        }
 | 
			
		||||
      };
 | 
			
		||||
      new Thread(_function_1).start();
 | 
			
		||||
      server.join();
 | 
			
		||||
    } catch (final Throwable _t) {
 | 
			
		||||
      if (_t instanceof Exception) {
 | 
			
		||||
        final Exception exception = (Exception)_t;
 | 
			
		||||
        log.warn(exception.getMessage());
 | 
			
		||||
        System.exit(1);
 | 
			
		||||
      } else {
 | 
			
		||||
        throw Exceptions.sneakyThrow(_t);
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user