Skip to content

Commit 0f30417

Browse files
Merge remote-tracking branch 'origin/v1-2-0'
2 parents 4d5bff5 + 8c5fe57 commit 0f30417

File tree

8 files changed

+199
-113
lines changed

8 files changed

+199
-113
lines changed

META-INF/plugin.xml

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
<idea-plugin version="2">
3939
<id>io.github.francoiscambell.clionarduinoplugin</id>
4040
<name>CLion Arduino</name>
41-
<version>1.1.0</version>
41+
<version>1.2.0</version>
4242
<vendor email="" url="https://github.com/francoiscampbell/CLionArduinoPlugin">Francois Campbell</vendor>
4343

4444
<description><![CDATA[
@@ -55,13 +55,17 @@
5555
project from queezythegreat.
5656
<br>
5757
<br>
58-
The current features are to convert a default CLion project into an Arduino CMake one in one click, and to create new sketch files. When CLion adds the ability to hook into project creation directly, I will be able to make it selectable at project creation time, but for now, we're stuck with having to create a new CLion project and then convert it.
58+
The current features are to create an Arduino CMake project in one click, and to create new sketch files.
5959
<br>
6060
<br>
61-
Future features are to add menu option to easily change the board type, port number, etc.
61+
Future features are to add menu option to easily change the board type, port number, import existing Arduino projects, etc.
6262
]]></description>
6363

6464
<change-notes><![CDATA[
65+
<b>1.2.0</b>
66+
<ul>
67+
<li>Added new project creation to Welcome Screen and File menu</li>
68+
</ul>
6569
<b>1.1.0</b>
6670
<ul>
6771
<li>Compatiblity with Arduino SDK 1.6 on Mac OS X</li>
@@ -96,8 +100,11 @@
96100
on how to target different products -->
97101
<depends>com.intellij.modules.clion</depends>
98102

103+
99104
<extensions defaultExtensionNs="com.intellij">
100105
<!-- Add your extensions here -->
106+
<!--<moduleType id="ARDUINO" implementationClass="io.github.francoiscambell.clionarduinoplugin.module.ArduinoModuleType"/>-->
107+
<!--<moduleBuilder builderClass="io.github.francoiscambell.clionarduinoplugin.module.ArduinoModuleBuilder"/>-->
101108
</extensions>
102109

103110
<application-components>
@@ -112,18 +119,20 @@
112119
<!-- Add your project components here -->
113120
</project-components>
114121

122+
115123
<actions>
116124
<!-- Add your actions here -->
117125
<action id="Sketch.New" class="io.github.francoiscambell.clionarduinoplugin.actions.NewSketchFile"
118126
text="Arduino Sketch" description="New Arduino Sketch File"
119127
icon="/io/github/francoiscambell/clionarduinoplugin/resources/icons/Arduino_Logo.png">
120128
<add-to-group group-id="NewGroup" anchor="last"/>
121129
</action>
122-
<action id="SketchProject.Convert"
123-
class="io.github.francoiscambell.clionarduinoplugin.actions.ConvertToSketchProject"
124-
text="Convert to Arduino Sketch project" description="Converts a CMake project to an Arduino Sketch"
130+
<action id="SketchProject.New"
131+
class="io.github.francoiscambell.clionarduinoplugin.actions.NewArduinoProjectAction"
132+
text="New Arduino Sketch Project" description="Creates a new Arduino sketch project"
125133
icon="/io/github/francoiscambell/clionarduinoplugin/resources/icons/Arduino_Logo.png">
126-
<add-to-group group-id="ProjectViewPopupMenu" anchor="last"/>
134+
<add-to-group group-id="FileMenu" anchor="first"/>
135+
<add-to-group group-id="WelcomeScreen.QuickStart" anchor="first"/>
127136
</action>
128137
</actions>
129138

README.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,17 @@
22

33
This is a JetBrains CLion plugin that integrates [Arduino CMake](https://github.com/queezythegreat/arduino-cmake) into the IDE.
44

5-
The current features are to convert a default CLion project into an Arduino CMake one in one click, and to create new sketch files. When CLion adds the ability to hook into project creation directly, I will be able to make it selectable at project creation time, but for now, we're stuck with having to create a new CLion project and then convert it.
5+
The current features are to create an Arduino CMake project in one click, and to create new sketch files.
66

7-
Future features are to add menu option to easily change the board type, port number, etc.
7+
Future features are to add menu option to easily change the board type, port number, import existing Arduino projects, etc.
8+
9+
**1.2.0**
10+
11+
* Added new project creation to Welcome Screen and File menu
12+
13+
**1.1.0**
14+
15+
* Compatiblity with Arduino SDK 1.6 on Mac OS X
816

917
**1.0.2**
1018

src/io/github/francoiscambell/clionarduinoplugin/ArduinoSketchFileCreator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,6 @@ public void run() {
3939
}
4040

4141
public static void addFileToCMakeLists(final Project project, final VirtualFile file) {
42-
CMakeListsEditor.getInstance(project).set("SOURCE_FILES", file.getName());
42+
CMakeListsEditor.getInstance(project.getBaseDir()).set("SOURCE_FILES", file.getName());
4343
}
4444
}

src/io/github/francoiscambell/clionarduinoplugin/CMakeListsEditor.java

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,33 @@
44
import com.intellij.openapi.command.*;
55
import com.intellij.openapi.editor.*;
66
import com.intellij.openapi.fileEditor.*;
7-
import com.intellij.openapi.project.*;
87
import com.intellij.openapi.vfs.*;
9-
import io.github.francoiscambell.clionarduinoplugin.resources.*;
8+
9+
import java.util.*;
1010

1111
/**
1212
* Created by francois on 15-08-04.
1313
*/
1414
public class CMakeListsEditor {
15-
private static CMakeListsEditor INSTANCE;
16-
private Project project;
15+
private static Map<VirtualFile, CMakeListsEditor> INSTANCES = new WeakHashMap<VirtualFile, CMakeListsEditor>();
16+
private VirtualFile cMakeListsVirtualFile;
1717

18-
private CMakeListsEditor(Project project) {
19-
this.project = project;
18+
private CMakeListsEditor(VirtualFile cMakeLists) {
19+
this.cMakeListsVirtualFile = cMakeLists;
2020
}
2121

22-
public static CMakeListsEditor getInstance(Project project) {
23-
if (INSTANCE == null) {
24-
INSTANCE = new CMakeListsEditor(project);
22+
public static CMakeListsEditor getInstance(VirtualFile cMakeLists) {
23+
if (!INSTANCES.containsKey(cMakeLists)) {
24+
INSTANCES.put(cMakeLists, new CMakeListsEditor(cMakeLists));
2525
}
26-
return INSTANCE;
26+
return INSTANCES.get(cMakeLists);
2727
}
2828

29-
public VirtualFile getCMakeListsVirtualFile() {
30-
return project.getBaseDir().findChild(Strings.CMAKE_LISTS_FILENAME);
29+
private VirtualFile getCMakeListsVirtualFile() {
30+
return cMakeListsVirtualFile;
3131
}
3232

33-
public Document getCMakeListsDocument() {
33+
private Document getCMakeListsDocument() {
3434
return FileDocumentManager.getInstance().getDocument(getCMakeListsVirtualFile());
3535
}
3636

@@ -39,10 +39,11 @@ public void clear() {
3939
ApplicationManager.getApplication().runWriteAction(new Runnable() {
4040
@Override
4141
public void run() {
42-
CommandProcessor.getInstance().executeCommand(project, new Runnable() {
42+
CommandProcessor.getInstance().executeCommand(null, new Runnable() {
4343
@Override
4444
public void run() {
45-
cMakeLists.deleteString(0, getCMakeListsDocument().getTextLength());
45+
cMakeLists.deleteString(0, cMakeLists.getTextLength());
46+
FileDocumentManager.getInstance().saveDocument(cMakeLists);
4647
}
4748
}, null, null, cMakeLists);
4849
}
@@ -56,10 +57,11 @@ public void addLine(int line, final String text) {
5657
ApplicationManager.getApplication().runWriteAction(new Runnable() {
5758
@Override
5859
public void run() {
59-
CommandProcessor.getInstance().executeCommand(project, new Runnable() {
60+
CommandProcessor.getInstance().executeCommand(null, new Runnable() {
6061
@Override
6162
public void run() {
6263
cMakeLists.insertString(lineEndOffset, text + "\n");
64+
FileDocumentManager.getInstance().saveDocument(cMakeLists);
6365
}
6466
}, null, null, cMakeLists);
6567
}

src/io/github/francoiscambell/clionarduinoplugin/actions/ConvertToSketchProject.java

Lines changed: 0 additions & 84 deletions
This file was deleted.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package io.github.francoiscambell.clionarduinoplugin.actions;
2+
3+
import com.intellij.openapi.actionSystem.*;
4+
import com.intellij.openapi.wm.impl.welcomeScreen.*;
5+
import io.github.francoiscambell.clionarduinoplugin.resources.icons.*;
6+
import io.github.francoiscambell.clionarduinoplugin.wizards.*;
7+
8+
/**
9+
* Created by francois on 15-08-14.
10+
*/
11+
public class NewArduinoProjectAction extends AnAction {
12+
public void update(AnActionEvent event) {
13+
Presentation presentation = event.getPresentation();
14+
if (ActionPlaces.isMainMenuOrActionSearch(event.getPlace())) {
15+
presentation.setIcon(null);
16+
}
17+
18+
if (NewWelcomeScreen.isNewWelcomeScreen(event)) {
19+
event.getPresentation().setIcon(ArduinoIcon.ARDUINO_ICON);
20+
}
21+
22+
}
23+
24+
@Override
25+
public void actionPerformed(AnActionEvent e) {
26+
(new NewArduinoProjectWizard()).runWizard();
27+
}
28+
}

src/io/github/francoiscambell/clionarduinoplugin/resources/ArduinoToolchainFiles.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package io.github.francoiscambell.clionarduinoplugin.resources;
22

33
import com.intellij.openapi.application.*;
4-
import com.intellij.openapi.project.*;
54
import com.intellij.openapi.vfs.*;
65
import org.apache.sanselan.util.*;
76

@@ -19,12 +18,12 @@ public static InputStream getArduinoCmake() {
1918
return ArduinoToolchainFiles.class.getResourceAsStream("arduino-cmake/cmake/Platform/Arduino.cmake");
2019
}
2120

22-
public static void copyToProject(final Project project) {
21+
public static void copyToDirectory(final VirtualFile projectRoot) {
2322
ApplicationManager.getApplication().runWriteAction(new Runnable() {
2423
@Override
2524
public void run() {
2625
try {
27-
VirtualFile cmakeDirectory = project.getBaseDir().createChildDirectory(this, "cmake");
26+
VirtualFile cmakeDirectory = projectRoot.createChildDirectory(this, "cmake");
2827
VirtualFile platformDirectory = cmakeDirectory.createChildDirectory(this, "Platform");
2928

3029
VirtualFile arduinoToolchain = cmakeDirectory.createChildData(this, "ArduinoToolchain.cmake");

0 commit comments

Comments
 (0)