Auto crete files with hello world content when creating C, C++, and Python projects from scratch
Signed-off-by: Eugene Ivantsov <eivantsov@codenvy.com>6.19.x
parent
6e3aa1c49e
commit
4ed78dfa7c
|
|
@ -32,6 +32,10 @@
|
|||
<groupId>com.google.inject.extensions</groupId>
|
||||
<artifactId>guice-multibindings</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.che.core</groupId>
|
||||
<artifactId>che-core-api-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.che.core</groupId>
|
||||
<artifactId>che-core-api-project</artifactId>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,39 @@
|
|||
/*******************************************************************************
|
||||
* 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.plugin.cpp.generator;
|
||||
|
||||
import org.eclipse.che.api.core.ConflictException;
|
||||
import org.eclipse.che.api.core.ForbiddenException;
|
||||
import org.eclipse.che.api.core.ServerException;
|
||||
import org.eclipse.che.api.project.server.FolderEntry;
|
||||
import org.eclipse.che.api.project.server.handlers.CreateProjectHandler;
|
||||
import org.eclipse.che.api.project.server.type.AttributeValue;
|
||||
import org.eclipse.che.plugin.cpp.shared.Constants;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class CProjectGenerator implements CreateProjectHandler {
|
||||
|
||||
private static final String FILE_NAME = "hello.c";
|
||||
|
||||
@Override
|
||||
public void onCreateProject(FolderEntry baseFolder,
|
||||
Map<String, AttributeValue> attributes,
|
||||
Map<String, String> options) throws ForbiddenException, ConflictException, ServerException {
|
||||
baseFolder.createFile(FILE_NAME, getClass().getClassLoader().getResourceAsStream("files/default_c_content"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProjectType() {
|
||||
return Constants.C_PROJECT_TYPE_ID;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
/*******************************************************************************
|
||||
* 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.plugin.cpp.generator;
|
||||
|
||||
import org.eclipse.che.api.core.ConflictException;
|
||||
import org.eclipse.che.api.core.ForbiddenException;
|
||||
import org.eclipse.che.api.core.ServerException;
|
||||
import org.eclipse.che.api.project.server.FolderEntry;
|
||||
import org.eclipse.che.api.project.server.handlers.CreateProjectHandler;
|
||||
import org.eclipse.che.api.project.server.type.AttributeValue;
|
||||
import org.eclipse.che.plugin.cpp.shared.Constants;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class CppProjectGenerator implements CreateProjectHandler {
|
||||
|
||||
private static final String FILE_NAME = "hello.cpp";
|
||||
|
||||
@Override
|
||||
public void onCreateProject(FolderEntry baseFolder,
|
||||
Map<String, AttributeValue> attributes,
|
||||
Map<String, String> options) throws ForbiddenException, ConflictException, ServerException {
|
||||
baseFolder.createFile(FILE_NAME, getClass().getClassLoader().getResourceAsStream("files/default_cpp_content"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProjectType() {
|
||||
return Constants.CPP_PROJECT_TYPE_ID;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -12,11 +12,17 @@ package org.eclipse.che.plugin.cpp.inject;
|
|||
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.multibindings.Multibinder;
|
||||
|
||||
import org.eclipse.che.api.project.server.handlers.ProjectHandler;
|
||||
import org.eclipse.che.api.project.server.type.ProjectTypeDef;
|
||||
import org.eclipse.che.inject.DynaModule;
|
||||
import org.eclipse.che.plugin.cpp.generator.CProjectGenerator;
|
||||
import org.eclipse.che.plugin.cpp.generator.CppProjectGenerator;
|
||||
import org.eclipse.che.plugin.cpp.projecttype.CProjectType;
|
||||
import org.eclipse.che.plugin.cpp.projecttype.CppProjectType;
|
||||
|
||||
import static com.google.inject.multibindings.Multibinder.newSetBinder;
|
||||
|
||||
/**
|
||||
* @author Vitaly Parfonov
|
||||
*/
|
||||
|
|
@ -27,5 +33,9 @@ public class CppModule extends AbstractModule {
|
|||
Multibinder<ProjectTypeDef> projectTypeMultibinder = Multibinder.newSetBinder(binder(), ProjectTypeDef.class);
|
||||
projectTypeMultibinder.addBinding().to(CProjectType.class);
|
||||
projectTypeMultibinder.addBinding().to(CppProjectType.class);
|
||||
|
||||
Multibinder<ProjectHandler> projectHandlerMultibinder = newSetBinder(binder(), ProjectHandler.class);
|
||||
projectHandlerMultibinder.addBinding().to(CppProjectGenerator.class);
|
||||
projectHandlerMultibinder.addBinding().to(CProjectGenerator.class);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
/* Hello World program */
|
||||
|
||||
#include<stdio.h>
|
||||
|
||||
main()
|
||||
{
|
||||
printf("Hello World");
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
/* Hello World program */
|
||||
|
||||
#include <iostream.h>
|
||||
|
||||
main()
|
||||
{
|
||||
cout << "Hello World!";
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -33,7 +33,7 @@ public class NodeJsProjectGenerator implements CreateProjectHandler {
|
|||
public void onCreateProject(FolderEntry baseFolder,
|
||||
Map<String, AttributeValue> attributes,
|
||||
Map<String, String> options) throws ForbiddenException, ConflictException, ServerException {
|
||||
baseFolder.createFile(FILE_NAME, getClass().getClassLoader().getResourceAsStream("files/default_content"));
|
||||
baseFolder.createFile(FILE_NAME, getClass().getClassLoader().getResourceAsStream("files/default_node_content"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -41,3 +41,4 @@ public class NodeJsProjectGenerator implements CreateProjectHandler {
|
|||
return Constants.NODE_JS_PROJECT_TYPE_ID;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,9 +24,14 @@ import java.util.Map;
|
|||
* @author Valeriy Svydenko
|
||||
*/
|
||||
public class PythonProjectGenerator implements CreateProjectHandler {
|
||||
|
||||
private static final String FILE_NAME = "main.py";
|
||||
|
||||
@Override
|
||||
public void onCreateProject(FolderEntry baseFolder, Map<String, AttributeValue> attributes, Map<String, String> options)
|
||||
throws ForbiddenException, ConflictException, ServerException {
|
||||
public void onCreateProject(FolderEntry baseFolder,
|
||||
Map<String, AttributeValue> attributes,
|
||||
Map<String, String> options) throws ForbiddenException, ConflictException, ServerException {
|
||||
baseFolder.createFile(FILE_NAME, getClass().getClassLoader().getResourceAsStream("files/default_python_content"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
print "Hello World!"
|
||||
Loading…
Reference in New Issue