Skip to content

Commit 770eb38

Browse files
author
Vitaly Parfonov
committed
Add C/C++ project type
C/C++ Editor (with syntax highlighter only) Signed-off-by: Vitaly Parfonov <vparfonov@codenvy.com>
1 parent a0b3c18 commit 770eb38

37 files changed

Lines changed: 1286 additions & 11 deletions

File tree

assembly/assembly-ide-war/pom.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,14 @@
160160
<groupId>org.eclipse.che.lib</groupId>
161161
<artifactId>che-swagger-module</artifactId>
162162
</dependency>
163+
<dependency>
164+
<groupId>org.eclipse.che.plugin</groupId>
165+
<artifactId>che-plugin-cpp-lang-ide</artifactId>
166+
</dependency>
167+
<dependency>
168+
<groupId>org.eclipse.che.plugin</groupId>
169+
<artifactId>che-plugin-cpp-lang-shared</artifactId>
170+
</dependency>
163171
<dependency>
164172
<groupId>org.eclipse.che.plugin</groupId>
165173
<artifactId>che-plugin-docker-client</artifactId>

assembly/assembly-ide-war/src/main/resources/org/eclipse/che/ide/IDE.gwt.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
<inherits name='org.eclipse.che.env.local.LocalEnvironment'/>
5656
<inherits name='org.eclipse.che.ide.ext.plugins.PluginsDevelopment'/>
5757

58+
<inherits name='org.eclipse.che.plugin.cpp.Cpp'/>
5859
<inherits name='org.eclipse.che.plugin.python.Python'/>
5960
<inherits name='org.eclipse.che.plugin.docker.client.dto.Dto'/>
6061

assembly/assembly-machine-war/pom.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,14 @@
9595
<artifactId>che-jdt-ext-machine</artifactId>
9696
<type>jar</type>
9797
</dependency>
98+
<dependency>
99+
<groupId>org.eclipse.che.plugin</groupId>
100+
<artifactId>che-plugin-cpp-lang-server</artifactId>
101+
</dependency>
102+
<dependency>
103+
<groupId>org.eclipse.che.plugin</groupId>
104+
<artifactId>che-plugin-cpp-lang-shared</artifactId>
105+
</dependency>
98106
<dependency>
99107
<groupId>org.eclipse.che.plugin</groupId>
100108
<artifactId>che-plugin-git-provider-che</artifactId>

core/commons/che-core-commons-gwt/src/main/java/org/eclipse/che/ide/MimeType.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,10 @@ public interface MimeType {
6767
String TEXT_CSS = "text/css";
6868

6969
/** "text/x-c" */
70-
String TEXT_C = "text/x-c";
70+
String TEXT_C = "text/x-csrc";
71+
72+
/** "text/x-c" */
73+
String TEXT_CPP = "text/x-c++src";
7174

7275
/** "text/x-h" */
7376
String TEXT_H = "text/x-h";

core/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/projecttype/wizard/presenter/ProjectWizardPresenter.java

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import com.google.inject.Provider;
1515
import com.google.inject.Singleton;
1616

17+
import org.eclipse.che.api.project.shared.dto.AttributeDto;
1718
import org.eclipse.che.api.project.shared.dto.ItemReference;
1819
import org.eclipse.che.api.project.shared.dto.ProjectTemplateDescriptor;
1920
import org.eclipse.che.api.project.shared.dto.ProjectTypeDto;
@@ -32,6 +33,7 @@
3233
import org.eclipse.che.ide.ui.dialogs.DialogFactory;
3334

3435
import javax.validation.constraints.NotNull;
36+
import java.util.Collections;
3537
import java.util.HashMap;
3638
import java.util.List;
3739
import java.util.Map;
@@ -191,19 +193,25 @@ public void onProjectTypeSelected(ProjectTypeDto projectType) {
191193
wizard = getWizardForProjectType(projectType, prevData);
192194
wizard.navigateToFirst();
193195
final ProjectConfigDto newProject = wizard.getDataObject();
194-
195-
// some values should be shared between wizards for different project types
196-
newProject.setPath(prevData.getPath());
196+
newProject.setType(projectType.getId());
197197
newProject.setName(prevData.getName());
198198
newProject.setDescription(prevData.getDescription());
199-
newProject.setMixins(prevData.getMixins());
200-
if (wizardMode == UPDATE) {
199+
if (wizardMode == CREATE) {
200+
newProject.setMixins(Collections.<String>emptyList());
201+
List<AttributeDto> attributes = projectType.getAttributes();
202+
Map<String, List<String>> prevDataAttributes = prevData.getAttributes();
203+
Map<String, List<String>> newAttributes = new HashMap<>();
204+
for (AttributeDto attribute : attributes) {
205+
if(prevDataAttributes.containsKey(attribute.getId())) {
206+
newAttributes.put(attribute.getId(), prevDataAttributes.get(attribute.getId()));
207+
}
208+
}
209+
newProject.setAttributes(newAttributes);
210+
} else {
211+
// some values should be shared between wizards for different project types
212+
newProject.setMixins(prevData.getMixins());
201213
newProject.setAttributes(prevData.getAttributes());
202214
}
203-
204-
// set dataObject's values from projectType
205-
newProject.setType(projectType.getId());
206-
// newProject.setRecipe(projectType.getDefaultRecipe());
207215
}
208216

209217
@Override

core/ide/che-core-ide-jseditor/src/main/java/org/eclipse/che/ide/jseditor/client/filetype/ExtensionFileTypeIdentifier.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public List<String> identifyType(final VirtualFile file) {
4848

4949
/** Prepares the know extension registry. */
5050
public void init() {
51-
this.mappings.put("c", makeList("text/x-c"));
51+
this.mappings.put("c", makeList("text/x-csrc"));
5252
this.mappings.put("C", makeList("text/x-c++src"));
5353
this.mappings.put("cc", makeList("text/x-c++src"));
5454
this.mappings.put("cpp", makeList("text/x-c++src"));
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
4+
Copyright (c) 2012-2016 Codenvy, S.A.
5+
All rights reserved. This program and the accompanying materials
6+
are made available under the terms of the Eclipse Public License v1.0
7+
which accompanies this distribution, and is available at
8+
http://www.eclipse.org/legal/epl-v10.html
9+
10+
Contributors:
11+
Codenvy, S.A. - initial API and implementation
12+
13+
-->
14+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
15+
<modelVersion>4.0.0</modelVersion>
16+
<parent>
17+
<artifactId>che-plugin-cpp-parent</artifactId>
18+
<groupId>org.eclipse.che.plugin</groupId>
19+
<version>4.1.0-RC1-SNAPSHOT</version>
20+
</parent>
21+
<artifactId>che-plugin-cpp-lang-ide</artifactId>
22+
<packaging>jar</packaging>
23+
<name>Che Plugin :: C/C++ :: IDE</name>
24+
<dependencies>
25+
<dependency>
26+
<groupId>com.google.gwt.inject</groupId>
27+
<artifactId>gin</artifactId>
28+
</dependency>
29+
<dependency>
30+
<groupId>com.google.inject</groupId>
31+
<artifactId>guice</artifactId>
32+
</dependency>
33+
<dependency>
34+
<groupId>javax.inject</groupId>
35+
<artifactId>javax.inject</artifactId>
36+
</dependency>
37+
<dependency>
38+
<groupId>javax.validation</groupId>
39+
<artifactId>validation-api</artifactId>
40+
</dependency>
41+
<dependency>
42+
<groupId>org.eclipse.che.core</groupId>
43+
<artifactId>che-core-api-workspace</artifactId>
44+
</dependency>
45+
<dependency>
46+
<groupId>org.eclipse.che.core</groupId>
47+
<artifactId>che-core-commons-annotations</artifactId>
48+
</dependency>
49+
<dependency>
50+
<groupId>org.eclipse.che.core</groupId>
51+
<artifactId>che-core-ide-api</artifactId>
52+
</dependency>
53+
<dependency>
54+
<groupId>org.eclipse.che.core</groupId>
55+
<artifactId>che-core-ide-app</artifactId>
56+
</dependency>
57+
<dependency>
58+
<groupId>org.eclipse.che.core</groupId>
59+
<artifactId>che-core-ide-jseditor</artifactId>
60+
</dependency>
61+
<dependency>
62+
<groupId>org.eclipse.che.plugin</groupId>
63+
<artifactId>che-plugin-cpp-lang-shared</artifactId>
64+
</dependency>
65+
<dependency>
66+
<groupId>org.vectomatic</groupId>
67+
<artifactId>lib-gwt-svg</artifactId>
68+
</dependency>
69+
<dependency>
70+
<groupId>com.google.gwt</groupId>
71+
<artifactId>gwt-user</artifactId>
72+
<scope>provided</scope>
73+
</dependency>
74+
</dependencies>
75+
<build>
76+
<resources>
77+
<resource>
78+
<directory>src/main/java</directory>
79+
</resource>
80+
<resource>
81+
<directory>src/main/resources</directory>
82+
</resource>
83+
</resources>
84+
</build>
85+
</project>
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2012-2016 Codenvy, S.A.
3+
* All rights reserved. This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License v1.0
5+
* which accompanies this distribution, and is available at
6+
* http://www.eclipse.org/legal/epl-v10.html
7+
*
8+
* Contributors:
9+
* Codenvy, S.A. - initial API and implementation
10+
*******************************************************************************/
11+
package org.eclipse.che.plugin.cpp.ide;
12+
13+
import com.google.inject.Inject;
14+
import com.google.inject.name.Named;
15+
16+
import org.eclipse.che.ide.api.action.ActionManager;
17+
import org.eclipse.che.ide.api.action.DefaultActionGroup;
18+
import org.eclipse.che.ide.api.constraints.Constraints;
19+
import org.eclipse.che.ide.api.extension.Extension;
20+
import org.eclipse.che.ide.api.filetypes.FileType;
21+
import org.eclipse.che.ide.api.filetypes.FileTypeRegistry;
22+
import org.eclipse.che.ide.api.icon.Icon;
23+
import org.eclipse.che.ide.api.icon.IconRegistry;
24+
import org.eclipse.che.plugin.cpp.ide.action.CreateCSourceFileAction;
25+
import org.eclipse.che.plugin.cpp.ide.action.CreateCppSourceFileAction;
26+
import org.eclipse.che.plugin.cpp.ide.action.CreateHeaderSourceFileAction;
27+
28+
import static org.eclipse.che.ide.api.action.IdeActions.GROUP_FILE_NEW;
29+
30+
/**
31+
* @author Vitalii Parfonov
32+
*
33+
* */
34+
@Extension(title = "Cpp")
35+
public class CppExtension {
36+
37+
public static String C_CATEGORY = "C/C++";
38+
39+
@Inject
40+
public CppExtension(FileTypeRegistry fileTypeRegistry,
41+
@Named("CFileType") FileType cFile,
42+
@Named("CppFileType") FileType cppFile,
43+
@Named("HFileType") FileType hFile) {
44+
fileTypeRegistry.registerFileType(cFile);
45+
fileTypeRegistry.registerFileType(cppFile);
46+
fileTypeRegistry.registerFileType(hFile);
47+
}
48+
49+
@Inject
50+
private void prepareActions(CreateCSourceFileAction newCSourceFileAction,
51+
CreateCppSourceFileAction newCppSourceFileAction,
52+
CreateHeaderSourceFileAction newHeadSourceFileAction,
53+
ActionManager actionManager,
54+
CppResources resources,
55+
IconRegistry iconRegistry) {
56+
57+
DefaultActionGroup newGroup = (DefaultActionGroup)actionManager.getAction(GROUP_FILE_NEW);
58+
59+
actionManager.registerAction("newCFile", newCSourceFileAction);
60+
actionManager.registerAction("newCppFile", newCppSourceFileAction);
61+
actionManager.registerAction("newHFile", newHeadSourceFileAction);
62+
newGroup.add(newCSourceFileAction, Constraints.FIRST);
63+
newGroup.add(newHeadSourceFileAction, Constraints.FIRST);
64+
newGroup.add(newCppSourceFileAction, Constraints.FIRST);
65+
iconRegistry.registerIcon(new Icon(C_CATEGORY + ".samples.category.icon", resources.category()));
66+
67+
}
68+
69+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2012-2016 Codenvy, S.A.
3+
* All rights reserved. This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License v1.0
5+
* which accompanies this distribution, and is available at
6+
* http://www.eclipse.org/legal/epl-v10.html
7+
*
8+
* Contributors:
9+
* Codenvy, S.A. - initial API and implementation
10+
*******************************************************************************/
11+
package org.eclipse.che.plugin.cpp.ide;
12+
13+
import com.google.inject.name.Named;
14+
15+
import org.eclipse.che.ide.api.editor.EditorRegistry;
16+
import org.eclipse.che.ide.api.extension.Extension;
17+
import org.eclipse.che.ide.api.filetypes.FileType;
18+
import org.eclipse.che.plugin.cpp.ide.editor.CEditorProvider;
19+
import org.eclipse.che.plugin.cpp.ide.editor.CppEditorProvider;
20+
21+
import javax.inject.Inject;
22+
23+
@Extension(title = "C/C++ JS Editor")
24+
public class CppJsEditorExtension {
25+
26+
@Inject
27+
public CppJsEditorExtension(final EditorRegistry editorRegistry,
28+
final @Named("CFileType") FileType cFile,
29+
final @Named("HFileType") FileType hFile,
30+
final @Named("CppFileType") FileType classFile,
31+
final CEditorProvider cEditorProvider,
32+
final CppEditorProvider cppEditorProvider) {
33+
// register editor provider
34+
editorRegistry.registerDefaultEditor(cFile, cEditorProvider);
35+
editorRegistry.registerDefaultEditor(hFile, cEditorProvider);
36+
editorRegistry.registerDefaultEditor(classFile, cppEditorProvider);
37+
editorRegistry.registerDefaultEditor(classFile, cppEditorProvider);
38+
}
39+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2012-2016 Codenvy, S.A.
3+
* All rights reserved. This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License v1.0
5+
* which accompanies this distribution, and is available at
6+
* http://www.eclipse.org/legal/epl-v10.html
7+
*
8+
* Contributors:
9+
* Codenvy, S.A. - initial API and implementation
10+
*******************************************************************************/
11+
package org.eclipse.che.plugin.cpp.ide;
12+
13+
import com.google.gwt.i18n.client.Messages;
14+
15+
/**
16+
* Localization constants. Interface to represent the constants defined in resource bundle:
17+
* 'CppLocalizationConstant.properties'.
18+
*
19+
* @author Vitalii PArfonov
20+
*/
21+
public interface CppLocalizationConstant extends Messages {
22+
23+
24+
@Key("cpp.action.create.c.file.title")
25+
@DefaultMessage("New C File")
26+
String createCFileActionTitle();
27+
28+
@Key("cpp.action.create.c.file.description")
29+
@DefaultMessage("Create C File")
30+
String createCFileActionDescription();
31+
32+
@Key("cpp.action.create.h.file.title")
33+
@DefaultMessage("New H File")
34+
String createCHeaderFileActionTitle();
35+
36+
@Key("cpp.action.create.c.file.description")
37+
@DefaultMessage("Create C Header File")
38+
String createCHeaderFileActionDescription();
39+
40+
@Key("cpp.action.create.cpp.file.title")
41+
@DefaultMessage("New C++ File")
42+
String createCppFileActionTitle();
43+
44+
@Key("cpp.action.create.cpp.file.description")
45+
@DefaultMessage("Create C++ File")
46+
String createCppFileActionDescription();
47+
48+
}

0 commit comments

Comments
 (0)