Skip to content

explicit no file option for new sketch #1229

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion io.sloeber.core/src/io/sloeber/core/api/CodeDescriptor.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

public class CodeDescriptor {
public enum CodeTypes {
defaultIno, defaultCPP, CustomTemplate, sample
None, defaultIno, defaultCPP, CustomTemplate, sample
}

static public final String DEFAULT_SKETCH_BASE = "sketch"; //$NON-NLS-1$
Expand Down Expand Up @@ -77,6 +77,10 @@ public void setReplacers(Map<String, String> myReplacers) {
private CodeDescriptor(CodeTypes codeType) {
myCodeType = codeType;
}

public static CodeDescriptor createNone() {
return new CodeDescriptor(CodeTypes.None);
}

public static CodeDescriptor createDefaultIno() {
return new CodeDescriptor(CodeTypes.defaultIno);
Expand Down Expand Up @@ -152,6 +156,8 @@ public Map<String, IPath> createFiles(IProject project, IProgressMonitor monito


switch (myCodeType) {
case None:
break;
case defaultIno:
Helpers.addFileToProject(project, new Path(project.getName() + ".ino"),
Stream.openContentStream("/io/sloeber/core/templates/" + DEFAULT_SKETCH_INO, false,replacers),
Expand Down
1 change: 1 addition & 0 deletions io.sloeber.ui/src/io/sloeber/ui/Messages.java
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ public class Messages extends NLS {
public static String ui_new_sketch_arduino_information_help;
public static String ui_new_sketch_custom_template;
public static String ui_new_sketch_custom_template_location;
public static String ui_new_sketch_none;
public static String ui_new_sketch_default_cpp;
public static String ui_new_sketch_default_ino;
public static String ui_new_sketch_error_failed_to_create_project;
Expand Down
1 change: 1 addition & 0 deletions io.sloeber.ui/src/io/sloeber/ui/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ ui_new_sketch_arduino_information=Arduino information
ui_new_sketch_arduino_information_help=Provide the Arduino information.
ui_new_sketch_custom_template=Custom template
ui_new_sketch_custom_template_location=Custom Template Location
ui_new_sketch_none=No file
ui_new_sketch_default_cpp=Default cpp file
ui_new_sketch_default_ino=Default ino file
ui_new_sketch_error_failed_to_create_project=Failed to create project
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,11 @@ public void handleEvent(Event event) {
*/
protected void SetControls() {
switch (CodeTypes.values()[Math.max(0, myCodeSourceOptionsCombo.getSelectionIndex())]) {
case None:
myTemplateFolderEditor.setEnabled(false, myParentComposite);
myExampleEditor.setEnabled(false);
myCheckBoxUseCurrentLinkSample.setEnabled(false);
break;
case defaultIno:
myTemplateFolderEditor.setEnabled(false, myParentComposite);
myExampleEditor.setEnabled(false);
Expand Down Expand Up @@ -166,9 +171,10 @@ protected void validatePage() {
return;
}
switch (CodeTypes.values()[Math.max(0, myCodeSourceOptionsCombo.getSelectionIndex())]) {
case None:
case defaultIno:
case defaultCPP:
setPageComplete(true);// default always works
setPageComplete(true);// default and no file always works
break;
case CustomTemplate:
IPath templateFolder = new Path(myTemplateFolderEditor.getStringValue());
Expand Down Expand Up @@ -205,6 +211,8 @@ private void restoreAllSelections() {
public CodeDescriptor getCodeDescription() {

switch (CodeTypes.values()[myCodeSourceOptionsCombo.getSelectionIndex()]) {
case None:
return CodeDescriptor.createNone();
case defaultIno:
return CodeDescriptor.createDefaultIno();
case defaultCPP:
Expand All @@ -224,6 +232,8 @@ public CodeDescriptor getCodeDescription() {

public static String getCodeTypeDescription(CodeTypes codeType) {
switch (codeType) {
case None:
return Messages.ui_new_sketch_none;
case defaultIno:
return Messages.ui_new_sketch_default_ino;
case defaultCPP:
Expand Down