Search in sources :

Example 1 with EmbeddedPlatform

use of com.thecoderscorner.menu.editorui.generator.plugin.EmbeddedPlatform in project tcMenu by davetcc.

the class PluginEmbeddedPlatformsImplTest method testEmbeddedPlatforms.

@Test
void testEmbeddedPlatforms() {
    PluginEmbeddedPlatformsImpl platforms = new PluginEmbeddedPlatformsImpl();
    platforms.setInstallerConfiguration(mock(ArduinoLibraryInstaller.class), mock(ConfigurationStorage.class));
    assertThat(platforms.getEmbeddedPlatforms()).containsExactly(ARDUINO_AVR, ARDUINO32, ARDUINO_ESP8266, ARDUINO_ESP32, STM32DUINO, RASPBERRY_PIJ, MBED_RTOS);
    assertEquals(ARDUINO_AVR, platforms.getEmbeddedPlatformFromId(ARDUINO_AVR.getBoardId()));
    assertEquals(ARDUINO32, platforms.getEmbeddedPlatformFromId(ARDUINO32.getBoardId()));
    assertEquals(ARDUINO_ESP8266, platforms.getEmbeddedPlatformFromId(ARDUINO_ESP8266.getBoardId()));
    assertEquals(ARDUINO_ESP32, platforms.getEmbeddedPlatformFromId(ARDUINO_ESP32.getBoardId()));
    assertEquals(MBED_RTOS, platforms.getEmbeddedPlatformFromId(MBED_RTOS.getBoardId()));
    assertEquals(STM32DUINO, platforms.getEmbeddedPlatformFromId(STM32DUINO.getBoardId()));
    assertEquals(RASPBERRY_PIJ, platforms.getEmbeddedPlatformFromId(RASPBERRY_PIJ.getBoardId()));
    assertThrows(IllegalArgumentException.class, () -> platforms.getEmbeddedPlatformFromId("invalidId"));
    assertTrue(ARDUINO_AVR.isUsesProgmem());
    assertFalse(ARDUINO32.isUsesProgmem());
    assertTrue(ARDUINO_ESP32.isUsesProgmem());
    assertTrue(ARDUINO_ESP8266.isUsesProgmem());
    assertFalse(STM32DUINO.isUsesProgmem());
    assertFalse(MBED_RTOS.isUsesProgmem());
    assertFalse(RASPBERRY_PIJ.isUsesProgmem());
    assertTrue(platforms.isJava(RASPBERRY_PIJ));
    assertFalse(platforms.isJava(ARDUINO_ESP32));
    assertTrue(platforms.isArduino(ARDUINO_ESP32));
    assertTrue(platforms.isArduino(ARDUINO_ESP8266));
    assertTrue(platforms.isArduino(STM32DUINO));
    assertTrue(platforms.isArduino(ARDUINO_AVR));
    assertFalse(platforms.isArduino(MBED_RTOS));
    assertTrue(platforms.isMbed(MBED_RTOS));
    CodeGeneratorOptions standardOptions = new CodeGeneratorOptions();
    var generator = platforms.getCodeGeneratorFor(ARDUINO_AVR, standardOptions);
    assertThat(generator).isOfAnyClassIn(ArduinoGenerator.class);
    assertThrows(IllegalArgumentException.class, () -> {
        EmbeddedPlatform invalidPlatform = new EmbeddedPlatform("", "Invalid", false);
        platforms.getCodeGeneratorFor(invalidPlatform, standardOptions);
    });
}
Also used : EmbeddedPlatform(com.thecoderscorner.menu.editorui.generator.plugin.EmbeddedPlatform) CodeGeneratorOptions(com.thecoderscorner.menu.editorui.generator.CodeGeneratorOptions) ConfigurationStorage(com.thecoderscorner.menu.editorui.storage.ConfigurationStorage) ArduinoLibraryInstaller(com.thecoderscorner.menu.editorui.generator.arduino.ArduinoLibraryInstaller) Test(org.junit.jupiter.api.Test)

Example 2 with EmbeddedPlatform

use of com.thecoderscorner.menu.editorui.generator.plugin.EmbeddedPlatform in project tcMenu by davetcc.

the class GenerateCodeDialog method placeDirectoryAndEmbeddedPanels.

private void placeDirectoryAndEmbeddedPanels(BorderPane pane) {
    GridPane embeddedPane = new GridPane();
    embeddedPane.setHgap(5);
    embeddedPane.setVgap(3);
    embeddedPane.add(new Label("Embedded Platform"), 0, 0);
    embeddedPane.add(new Label("Application Details"), 0, 2);
    embeddedPane.add(new Label("EEPROM Support"), 0, 3);
    embeddedPane.add(new Label("Pin & Authenticator"), 0, 4);
    platformCombo = new ComboBox<>(observableArrayList(platforms.getEmbeddedPlatforms()));
    embeddedPane.add(platformCombo, 1, 0, 2, 1);
    EmbeddedPlatform platform = getLastEmbeddedPlatform();
    platformCombo.getSelectionModel().select(platform);
    platformCombo.setId("platformCombo");
    platformCombo.getSelectionModel().selectedItemProperty().addListener((observable, oldVal, newVal) -> filterChoicesByPlatform(newVal));
    var appName = project.getGeneratorOptions().getApplicationName();
    var appUuid = project.getGeneratorOptions().getApplicationUUID();
    if (appName == null || appName.isEmpty()) {
        appName = "New app";
    }
    Label appNameLabel = new Label(appName + " - " + appUuid);
    appNameLabel.setId("appNameLabel");
    embeddedPane.add(appNameLabel, 1, 2);
    eepromTypeLabel = new Label(project.getGeneratorOptions().getEepromDefinition().toString());
    eepromTypeLabel.setId("eepromTypeLabel");
    eepromTypeButton = new Button("Change EEPROM");
    eepromTypeButton.setOnAction(this::onEepromButtonPressed);
    eepromTypeButton.setPrefWidth(120);
    eepromTypeButton.setId("eepromTypeButton");
    embeddedPane.add(eepromTypeLabel, 1, 3);
    embeddedPane.add(eepromTypeButton, 2, 3);
    authModeLabel = new Label(project.getGeneratorOptions().getAuthenticatorDefinition().toString());
    authModeLabel.setId("authModeLabel");
    var authModeButton = new Button("Change Auth");
    authModeButton.setId("authModeButton");
    authModeButton.setPrefWidth(120);
    authModeButton.setOnAction(this::onAuthenticatorButtonPressed);
    embeddedPane.add(authModeLabel, 1, 4);
    embeddedPane.add(authModeButton, 2, 4);
    var appNamespace = project.getGeneratorOptions().getPackageNamespace();
    Label namespaceLabel = new Label("Namespace");
    embeddedPane.add(namespaceLabel, 0, 5);
    namespaceField = new TextField(appNamespace);
    embeddedPane.add(namespaceField, 1, 5, 2, 1);
    ColumnConstraints column1 = new ColumnConstraints(120);
    ColumnConstraints column2 = new ColumnConstraints(400, 500, 999, Priority.ALWAYS, HPos.LEFT, true);
    ColumnConstraints column3 = new ColumnConstraints(120);
    embeddedPane.getColumnConstraints().add(column1);
    embeddedPane.getColumnConstraints().add(column2);
    embeddedPane.getColumnConstraints().add(column3);
    pane.setTop(embeddedPane);
}
Also used : EmbeddedPlatform(com.thecoderscorner.menu.editorui.generator.plugin.EmbeddedPlatform)

Aggregations

EmbeddedPlatform (com.thecoderscorner.menu.editorui.generator.plugin.EmbeddedPlatform)2 CodeGeneratorOptions (com.thecoderscorner.menu.editorui.generator.CodeGeneratorOptions)1 ArduinoLibraryInstaller (com.thecoderscorner.menu.editorui.generator.arduino.ArduinoLibraryInstaller)1 ConfigurationStorage (com.thecoderscorner.menu.editorui.storage.ConfigurationStorage)1 Test (org.junit.jupiter.api.Test)1