🐛 finish copying and adapting exam2's correction

main
Alexis Drai 3 years ago
parent 029d0b957f
commit 1abd99db46

8
.idea/.gitignore vendored

@ -0,0 +1,8 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" project-jdk-name="18" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
<component name="ProjectType">
<option name="id" value="jpab" />
</component>
</project>

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/Butterflies2.iml" filepath="$PROJECT_DIR$/Butterflies2.iml" />
</modules>
</component>
</project>

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_X" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="jfx-18.0.1" level="application" />
</component>
</module>

@ -27,7 +27,7 @@
</AnchorPane>
<HBox spacing="5">
<ColorPicker fx:id="colorPicker"/>
<Button disable="${colorsLV.selectionModel.selectedIndex == minus1}"
<Button disable="${colorsLV.selectionModel.selectedIndex != minus1}"
onAction="#clickAddColors" text="Add colors"/>
<Button disable="${colorsLV.selectionModel.selectedIndex == minus1}"
onAction="#clickUnselectColor" text="Unselect"/>
@ -44,7 +44,8 @@
<MenuBar>
<Menu text="Butterflies">
<MenuItem onAction="#clickAddButterfly" text="Add"/>
<MenuItem onAction="#clickRemoveButterfly" text="Delete"/>
<MenuItem disable="${butterfliesLV.selectionModel.selectedIndex == minus1}"
onAction="#clickRemoveButterfly" text="Delete"/>
<SeparatorMenuItem/>
<MenuItem onAction="#clickQuit" text="Quit"/>
</Menu>

@ -1,5 +1,5 @@
package data;
public interface Loadable<T> {
public T load();
T load();
}

@ -9,15 +9,6 @@ public class Stub implements Loadable<ButterflyManager> {
public ButterflyManager load() {
ButterflyManager result = new ButterflyManager();
Butterfly jerry = new Butterfly("Jerry");
jerry.addColor(50, 100, 150);
jerry.addColor(20, 0, 240);
Butterfly tony = new Butterfly("Tony");
tony.addColor(50, 100, 150);
tony.addColor(150, 0, 150);
tony.addColor(0, 100, 0);
result.addButterfly("Jerry");
result.getButterflies().get(0).addColor(50, 100, 150);
result.getButterflies().get(0).addColor(150, 0, 150);

@ -11,7 +11,7 @@ import java.util.Objects;
public class Launcher extends Application {
@Override
public void start(Stage primaryStage) throws Exception {
Parent root = FXMLLoader.load(getClass().getResource("/fxml/MainWindow.fxml"));
Parent root = FXMLLoader.load(Objects.requireNonNull(getClass().getResource("/fxml/MainWindow.fxml")));
Scene scene = new Scene(root);
primaryStage.setScene(scene);
primaryStage.show();

@ -27,6 +27,6 @@ public class CreationWindow {
}
public String getButterflyName() {
return null;
return butterflyName;
}
}

@ -33,9 +33,9 @@ public class MainWindow {
if (colorPicker.getValue() != null) {
butterfliesLV.getSelectionModel()
.getSelectedItem()
.addColor((int) (colorPicker.getValue().getRed()),
(int) (colorPicker.getValue().getGreen()),
(int) (colorPicker.getValue().getBlue()));
.addColor((int) (colorPicker.getValue().getRed() * 255),
(int) (colorPicker.getValue().getGreen() * 255),
(int) (colorPicker.getValue().getBlue()) * 255);
}
}
@ -61,13 +61,10 @@ public class MainWindow {
Stage creationWindowStage = new Stage();
creationWindowStage.initOwner(butterfliesLV.getScene().getWindow());
creationWindowStage.initModality(Modality.WINDOW_MODAL);
CreationWindow controller = initCreationWindow(creationWindowStage);
if (controller.getButterflyName() != null) {
mgr.addButterfly(controller.getButterflyName());
}
}
private CreationWindow initCreationWindow(Stage creationWindowStage) {
@ -76,10 +73,9 @@ public class MainWindow {
loader.setController(controller);
try {
creationWindowStage.setScene(new Scene(loader.load()));
creationWindowStage.showAndWait();
} catch (IOException ex) {
new Alert(Alert.AlertType.ERROR,
"error while opening creation window",
ButtonType.OK).setHeaderText(null);
new Alert(Alert.AlertType.ERROR, "error while opening creation window", ButtonType.OK).setHeaderText(null);
}
return controller;
}

Loading…
Cancel
Save