diff --git a/.DS_Store b/.DS_Store index 8de54037..78e2070c 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/RCaNconstructor/src/main/java/fr/cm/Main/Context.java b/RCaNconstructor/src/main/java/fr/cm/Main/Context.java index cf923f37..b7e90ddc 100644 --- a/RCaNconstructor/src/main/java/fr/cm/Main/Context.java +++ b/RCaNconstructor/src/main/java/fr/cm/Main/Context.java @@ -16,16 +16,12 @@ public class Context { private static String fileName; // le nom du fichier projet private static String dirName; // le nom du répertoire du fichier projet - // private static File workingDirectory; private static int firstYear, lastYear; - // etats du systeme private static String howConnected; private static boolean started, connectedR, builtR, sampledR; - static double windowWidth = 1500.0, windowHeight = 1000.0; - static double insideMin = 0.2, insideMax = 0.8; + static double windowWidth = 1500.0, windowHeight = 1000.0, insideMin = 0.2, insideMax = 0.8; static final double radiusComponent = 20.0f, radiusInternalLink = 25.0f; static String textAreaContent =""; - public static void init() { firstYear = 4000; lastYear = -1000; @@ -38,174 +34,59 @@ public static void init() { double screenHeight = rect.getHeight(); setWindowWidth(0.9 * screenWidth); setWindowHeight(0.9 * screenHeight); - } - public static void initRCaN() { connectedR = false; builtR = false; sampledR = false; } - // ------------------------------------------------------------------------ - public static String getTextAreaContent() { - - return textAreaContent; - } - - public static void setTextAreaContent(String textAreaContent) { - - Context.textAreaContent = textAreaContent; - } + public static String getTextAreaContent() {return textAreaContent;} + public static void setTextAreaContent(String textAreaContent) {Context.textAreaContent = textAreaContent;} // ------------------------------------------------------------------------ - public static boolean isWithWarnings() { - - return false; - } - - public static String getFileName() { - - return fileName; - } - + public static boolean isWithWarnings() {return false;} + public static String getFileName() {return fileName;} public static void setFileName(String fileName) { Context.fileName = fileName; } - - public static String getDirName() { - - return dirName; - } - - public static void setDirName(String dirName) { - - Context.dirName = dirName; - } - public static String getFullFileName() { - return (Context.dirName + "/" + Context.fileName); - } - - public static int getFirstYear() { - - return firstYear; - } - - public static int getLastYear() { - - return lastYear; - } - - public static void setFirstYear(int firstYear) { - - Context.firstYear = firstYear; - } - - public static void setLastYear(int lastYear) { - - Context.lastYear = lastYear; - } - - public static int getNbYears() { - - return lastYear - firstYear + 1; - } - + public static String getDirName() {return dirName;} + public static void setDirName(String dirName) {Context.dirName = dirName;} + public static String getFullFileName() {return (Context.dirName + "/" + Context.fileName);} + public static int getFirstYear() {return firstYear;} + public static int getLastYear() {return lastYear;} + public static void setFirstYear(int firstYear) {Context.firstYear = firstYear;} + public static void setLastYear(int lastYear) {Context.lastYear = lastYear;} + public static int getNbYears() {return lastYear - firstYear + 1;} public static String getHowConnected() { return howConnected; } - public static void setHowConnected(String howConnected) { Context.howConnected = howConnected; } - - public static boolean isConnectedR() { - - return connectedR; - } - - public static void setConnectedR(boolean connectedR) { - - Context.connectedR = connectedR; - } - - public static boolean isBuiltR() { - - return builtR; - } - - public static void setBuiltR(boolean builtR) { - - Context.builtR = builtR; - } - - public static boolean isSampledR() { - - return sampledR; - } - - public static void setSampledR(boolean sampledR) { - - Context.sampledR = sampledR; - } - - public static boolean isStarted() { - - return started; - } - - public static void setStarted(boolean started) { - - Context.started = started; - } - - public static double getWindowWidth() { - - return windowWidth; - } - - public static void setWindowWidth(double w) { - - windowWidth = w; - } - - public static double getWindowHeight() { - - return windowHeight; - } - + public static boolean isConnectedR() {return connectedR;} + public static void setConnectedR(boolean connectedR) {Context.connectedR = connectedR;} + public static boolean isBuiltR() {return builtR;} + public static void setBuiltR(boolean builtR) {Context.builtR = builtR;} + public static boolean isSampledR() {return sampledR;} + public static void setSampledR(boolean sampledR) {Context.sampledR = sampledR;} + public static boolean isStarted() {return started;} + public static void setStarted(boolean started) {Context.started = started;} + // ------------------------------------------------------------------------ + public static double getWindowWidth() {return windowWidth;} + public static void setWindowWidth(double w) {windowWidth = w;} + public static double getWindowHeight() {return windowHeight;} public static void setWindowHeight(double h) { windowHeight = h; } - - public static double getInsideMin() { - - return insideMin; - } - - public static double getInsideMax() { - - return insideMax; - } - - public static double getBackgroundWidth() { - - return windowWidth; - } - - public static double getBackgroundHeight() { - - return (0.9 * windowHeight); - } - - public static double getRadiusComponent() { - - return radiusComponent; - } - + public static double getInsideMin() {return insideMin;} + public static double getInsideMax() {return insideMax;} + public static double getBackgroundWidth() {return windowWidth;} + public static double getBackgroundHeight() {return (0.9 * windowHeight);} + public static double getRadiusComponent() {return radiusComponent;} public static double getRadiusInternalLink() { return radiusInternalLink; } - + // ------------------------------------------------------------------------ public static String getDate(){ Date date = new Date(); SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss"); @@ -219,6 +100,5 @@ public static List getObservationsYears() { } return (liste); } - - + // ---------------------------------------------------------------------------------- } diff --git a/RCaNconstructor/src/main/java/fr/cm/Main/FirstPage.java b/RCaNconstructor/src/main/java/fr/cm/Main/FirstPage.java index 16879194..e6e2d4d7 100644 --- a/RCaNconstructor/src/main/java/fr/cm/Main/FirstPage.java +++ b/RCaNconstructor/src/main/java/fr/cm/Main/FirstPage.java @@ -4,7 +4,6 @@ import javafx.scene.image.ImageView; import javafx.scene.layout.Pane; - public class FirstPage extends Pane { public FirstPage(){ ImageView imageView = new ImageView(); diff --git a/RCaNconstructor/src/main/java/fr/cm/Main/Logg.java b/RCaNconstructor/src/main/java/fr/cm/Main/Logg.java new file mode 100644 index 00000000..0e9ac95f --- /dev/null +++ b/RCaNconstructor/src/main/java/fr/cm/Main/Logg.java @@ -0,0 +1,33 @@ +package fr.cm.Main; + +import java.io.IOException; +import java.util.logging.FileHandler; +import java.util.logging.Logger; +import java.util.logging.SimpleFormatter; + +public class Logg { + static Logger logger = Logger.getLogger("MyLog"); + static void createLog(){ + FileHandler fileHandler; + try { + // This block configure the logger with handler and formatter + fileHandler = new FileHandler("rCaNlog.txt"); + logger.addHandler(fileHandler); + SimpleFormatter formatter = new SimpleFormatter(); + fileHandler.setFormatter(formatter); + } catch (SecurityException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + + } + public static void addLog(String msg){ + try { + logger.info(msg); + } catch (SecurityException e) { + e.printStackTrace(); + } + } + +} diff --git a/RCaNconstructor/src/main/java/fr/cm/Main/MainApplication.java b/RCaNconstructor/src/main/java/fr/cm/Main/MainApplication.java index a37a899b..62f5598b 100644 --- a/RCaNconstructor/src/main/java/fr/cm/Main/MainApplication.java +++ b/RCaNconstructor/src/main/java/fr/cm/Main/MainApplication.java @@ -1,7 +1,6 @@ package fr.cm.Main; -import fr.cm.project.ProjectListsManager; import fr.cm.preferences.ColorsAndFormats; import fr.cm.rCaller.RCaNCaller; import fr.cm.xmlFiles.HelpListXML; @@ -17,6 +16,7 @@ import javafx.stage.Stage; import javafx.stage.WindowEvent; +import java.io.FileWriter; import java.util.Timer; import java.util.TimerTask; @@ -34,21 +34,20 @@ public static void main(String[] args) { public static Stage stage; static BorderPane borderPaneRacine; static FirstPage firstPage; - + FileWriter logWriter; @Override public void start(Stage primaryStage) { RCaNCaller.initRCaN(); - + Logg.createLog(); stage = primaryStage; stage.widthProperty().addListener(changeSizelistener); stage.heightProperty().addListener(changeSizelistener); setOnClose(); - RCommandListXML.init(); HelpListXML.init(); Context.init(); - ProjectListsManager.init(); - ProjectListsManager.getNetworkView().update(); + ObjectsManager.init(); + ObjectsManager.getNetworkView().update(); borderPaneRacine = new BorderPane(); @@ -63,27 +62,27 @@ public void start(Stage primaryStage) { primaryStage.setY(0.05 * Context.getWindowHeight()); primaryStage.setScene(scene); primaryStage.show(); - } + static void setFirstPage(){ firstPage = new FirstPage(); borderPaneRacine.setCenter(firstPage); } public static void updateMenus() { MenuFile.updateMenus(); - MenuSetUp.updateMenus(); + MenuTrophicNetwork.updateMenus(); MenuDocument.updateMenus(); MenuRCaNBuild.updateMenus(); MenuRCaNSample.updateMenus(); } static MenuBar setMenus() { + new MenuFile(borderPaneRacine); new MenuRCaNBuild(borderPaneRacine); new MenuRCaNSample(borderPaneRacine); - new MenuFile(borderPaneRacine); new MenuHelp(borderPaneRacine); - new MenuSetUp(borderPaneRacine); + new MenuTrophicNetwork(borderPaneRacine); new MenuDocument(borderPaneRacine); MenuBar menuBar = new MenuBar(); @@ -95,34 +94,30 @@ static MenuBar setMenus() { Menu helpMenu = new Menu("Information and help"); fileMenu.getItems().addAll(MenuFile.getMenuItems()); - viewMenu.getItems().addAll(MenuSetUp.getMenuItems()); + viewMenu.getItems().addAll(MenuTrophicNetwork.getMenuItems()); documentMenu.getItems().addAll(MenuDocument.getMenuItems()); rcanMenuBuild.getItems().addAll(MenuRCaNBuild.getMenuItems()); rcanMenuSample.getItems().addAll(MenuRCaNSample.getMenuItems()); helpMenu.getItems().addAll(MenuHelp.getMenus()); - menuBar.getMenus().addAll(fileMenu, viewMenu, documentMenu, rcanMenuBuild, rcanMenuSample, helpMenu); + menuBar.getMenus().addAll(fileMenu, viewMenu, rcanMenuBuild, rcanMenuSample, documentMenu, helpMenu); updateMenus(); return menuBar; } - public static void exit() { Platform.exit(); System.exit(0); } - static void setOnClose() { - + Logg.addLog("Exit"); stage.setOnCloseRequest((WindowEvent t) -> exit()); } - // ------------------------------------------------------------------------------------- final ChangeListener changeSizelistener = new ChangeListener<>() { // on observe si l'utilisateur est en train de changer la taille de la fenetre principale final Timer timer = new Timer(); TimerTask task = null; final long delayTime = 100; - @Override public void changed(ObservableValue observable, Number oldValue, final Number newValue) { if (task != null) { @@ -136,20 +131,17 @@ public void run() { Context.setWindowWidth(nw); Context.setWindowHeight(nh); if (nw > 1.0 && nh > 1.0) { - Platform.runLater(() -> ProjectListsManager.getNetworkView().redrawChangingSize()); + Platform.runLater(() -> ObjectsManager.getNetworkView().redrawChangingSize()); } } }; timer.schedule(task, delayTime); } }; - // ------------------------------------------------------------------------ public static void setTitle(String fileName) { - stage.setTitle(" RCaN - " + fileName.replace(".xlsx", " ")); } - public static Stage getStage() { return stage; } diff --git a/RCaNconstructor/src/main/java/fr/cm/Main/MenuDocument.java b/RCaNconstructor/src/main/java/fr/cm/Main/MenuDocument.java index bad6b857..51ac9628 100644 --- a/RCaNconstructor/src/main/java/fr/cm/Main/MenuDocument.java +++ b/RCaNconstructor/src/main/java/fr/cm/Main/MenuDocument.java @@ -1,13 +1,7 @@ package fr.cm.Main; import fr.cm.objects.TimeLineTable; -import fr.cm.objects.ComponentTable; -import fr.cm.objects.ConstraintTable; -import fr.cm.objects.DataFileTable; -import fr.cm.objects.FluxTable; import fr.cm.objects.MetaInformationTable; -import fr.cm.objects.ObservationTable; -import fr.cm.project.ProjectListsManager; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.scene.control.MenuItem; @@ -18,14 +12,10 @@ public class MenuDocument { // --------------------------------- - static final MenuItem metaTableItem = new MenuItem("Project information"); static final MenuItem timeLinesItem = new MenuItem("Project tracking"); - static List menuItems = null; - static BorderPane borderPaneRacine; - public MenuDocument(BorderPane borderPaneRacine) { MenuDocument.borderPaneRacine = borderPaneRacine; menuItems = Arrays.asList( timeLinesItem, metaTableItem); @@ -33,20 +23,16 @@ public MenuDocument(BorderPane borderPaneRacine) { menuItem.setOnAction(ViewListener); } } - static void updateMenus() { boolean notStarted = !Context.isStarted(); for (MenuItem menuItem : menuItems) { menuItem.setDisable(notStarted); } } - public static List getMenuItems() { return menuItems; } - static final EventHandler ViewListener = MenuDocument::handle; - private static void handle(ActionEvent e) { MenuItem menuItem = (MenuItem) e.getSource(); int numItem = menuItems.indexOf(menuItem); diff --git a/RCaNconstructor/src/main/java/fr/cm/Main/MenuFile.java b/RCaNconstructor/src/main/java/fr/cm/Main/MenuFile.java index a2cdf934..db304dc1 100644 --- a/RCaNconstructor/src/main/java/fr/cm/Main/MenuFile.java +++ b/RCaNconstructor/src/main/java/fr/cm/Main/MenuFile.java @@ -1,7 +1,6 @@ package fr.cm.Main; import fr.cm.project.ProjectCreateNew; -import fr.cm.project.ProjectListsManager; import fr.cm.project.ProjectOpenExisting; import fr.cm.project.ProjectSaveAs; import javafx.event.ActionEvent; @@ -14,17 +13,14 @@ public class MenuFile { // --------------------------------- - - static final MenuItem newItem = new MenuItem("New"); - static final MenuItem openFileItem = new MenuItem("Open"); - static final MenuItem saveFileItem = new MenuItem("Save"); - static final MenuItem saveAsFileItem = new MenuItem("Save as ..."); - static final MenuItem closeFileItem = new MenuItem("Close"); - static final MenuItem exitItem = new MenuItem("Exit"); + static final MenuItem newItem = new MenuItem("New"), + openFileItem = new MenuItem("Open"), + saveFileItem = new MenuItem("Save"), + saveAsFileItem = new MenuItem("Save as ..."), + closeFileItem = new MenuItem("Close"), + exitItem = new MenuItem("Exit"); static BorderPane borderPaneRacine; - static List menuItems = null; - public MenuFile(BorderPane borderPaneRacine) { MenuFile.borderPaneRacine = borderPaneRacine; menuItems = Arrays.asList(newItem, openFileItem, closeFileItem, saveFileItem, saveAsFileItem, exitItem); @@ -32,7 +28,6 @@ public MenuFile(BorderPane borderPaneRacine) { menuItem.setOnAction(FileListener); } } - public static void updateMenus() { boolean started = Context.isStarted(); newItem.setDisable(started); @@ -42,13 +37,10 @@ public static void updateMenus() { saveAsFileItem.setDisable(! started); exitItem.setDisable(false); } - public static List getMenuItems() { return menuItems; } - static final EventHandler FileListener = MenuFile::handle; - private static void handle(ActionEvent e) { MenuItem menuItem = (MenuItem) e.getSource(); int numItem = menuItems.indexOf(menuItem); @@ -57,26 +49,26 @@ private static void handle(ActionEvent e) { new ProjectCreateNew(); if (Context.isStarted()) { Context.initRCaN(); - ProjectListsManager.init(); - ProjectListsManager.makeMetaElementsList(); + ObjectsManager.init(); + ObjectsManager.makeMetaElementsList(); MainApplication.updateMenus(); - ProjectListsManager.addTimeLine("Project creation "+ Context.getFileName(),true); - ProjectListsManager.saveExcel(); - borderPaneRacine.setCenter(ProjectListsManager.getNetworkView()); + ObjectsManager.addTimeLine("Project creation "+ Context.getFileName(),true); + ObjectsManager.saveExcel(); + borderPaneRacine.setCenter(ObjectsManager.getNetworkView()); } break; case 1: new ProjectOpenExisting(); if (Context.isStarted()) { Context.initRCaN(); - ProjectListsManager.init(); + ObjectsManager.init(); MainApplication.updateMenus(); - ProjectListsManager.getExcel(); - borderPaneRacine.setCenter(ProjectListsManager.getNetworkView()); + ObjectsManager.getExcel(); + borderPaneRacine.setCenter(ObjectsManager.getNetworkView()); } break; case 2: - ProjectListsManager.init(); + ObjectsManager.init(); Context.setStarted(false); MainApplication.updateMenus(); MainApplication.setFirstPage(); @@ -86,14 +78,14 @@ private static void handle(ActionEvent e) { if(Context.getDirName().length() == 0){ new ProjectSaveAs(); } - ProjectListsManager.saveExcel(); + ObjectsManager.saveExcel(); } break; case 4: if (Context.isStarted()) { new ProjectSaveAs(); - ProjectListsManager.saveExcel(); - ProjectListsManager.addTimeLine("Project saved as "+ Context.getFileName(),true); + ObjectsManager.saveExcel(); + ObjectsManager.addTimeLine("Project saved as "+ Context.getFileName(),true); } break; case 5 : diff --git a/RCaNconstructor/src/main/java/fr/cm/Main/MenuHelp.java b/RCaNconstructor/src/main/java/fr/cm/Main/MenuHelp.java index b29fcf75..0b073be1 100644 --- a/RCaNconstructor/src/main/java/fr/cm/Main/MenuHelp.java +++ b/RCaNconstructor/src/main/java/fr/cm/Main/MenuHelp.java @@ -19,18 +19,15 @@ public class MenuHelp { static List menuItems = null; - static final Menu what = new Menu("What"); - static final Menu how = new Menu("How"); - static final Menu parameters = new Menu("Parameters"); - static final Menu rCommands = new Menu("R Commands"); + static final Menu what = new Menu("What"), + how = new Menu("How"), + parameters = new Menu("Parameters"), + rCommands = new Menu("R Commands"); static List menus = Arrays.asList(what, how, parameters, rCommands); - static BorderPane borderPaneRacine; - List helpsXML = null; List RCaNScriptXMLS = null; - public MenuHelp(BorderPane borderPaneRacine) { MenuHelp.borderPaneRacine = borderPaneRacine; menuItems = new ArrayList<>(); @@ -59,23 +56,18 @@ public MenuHelp(BorderPane borderPaneRacine) { menuItems.add(menuItem); menuItem.setOnAction(MenuListenerR); } - } public static List getMenus() { return menus; } - static final EventHandler MenuListener = e -> handle(e); - static final EventHandler MenuListenerR = e -> handleR(e); - private static void handle(ActionEvent e) { MenuItem menuItem = (MenuItem) e.getSource(); HelpXML helpXML = HelpListXML.getHelpByTextMenu(menuItem.getText()); new HelpDialog(helpXML); } - private static void handleR(ActionEvent e) { MenuItem menuItem = (MenuItem) e.getSource(); RCaNScript rCaNScriptXML = RCommandListXML.getRCommandByMenu(menuItem.getText()); diff --git a/RCaNconstructor/src/main/java/fr/cm/Main/MenuRCaNBuild.java b/RCaNconstructor/src/main/java/fr/cm/Main/MenuRCaNBuild.java index 48a514a2..b30a2e73 100644 --- a/RCaNconstructor/src/main/java/fr/cm/Main/MenuRCaNBuild.java +++ b/RCaNconstructor/src/main/java/fr/cm/Main/MenuRCaNBuild.java @@ -1,7 +1,5 @@ package fr.cm.Main; -import fr.cm.dialogs.HelpDialog; -import fr.cm.project.ProjectListsManager; import fr.cm.rCaller.RCaNDialog; import fr.cm.rCaller.RCaNCaller; import fr.cm.xmlFiles.RCommandListXML; @@ -16,14 +14,13 @@ import java.util.List; public class MenuRCaNBuild { - static List menuItems = null; static BorderPane borderPaneRacine; - - public MenuRCaNBuild(BorderPane borderPaneRacine) { MenuRCaNBuild.borderPaneRacine = borderPaneRacine; menuItems = new ArrayList<>(); + MenuItem test = new MenuItem("TEST BUILD"); + menuItems.add(test); for (RCaNScript rCaNScriptXML : RCommandListXML.getListOfRCommandXML()) { if (rCaNScriptXML.getMenu().equals("build")) { MenuItem menuItem = new MenuItem(rCaNScriptXML.getTextMenu()); @@ -36,28 +33,17 @@ public MenuRCaNBuild(BorderPane borderPaneRacine) { static void updateMenus() { boolean notStarted = (!Context.isStarted()) && (!Context.isConnectedR()); for (MenuItem menuItem : menuItems) { - if (notStarted) menuItem.setDisable(notStarted); - else { - RCaNScript rCaNScriptXML = RCommandListXML.getRCommandByMenu(menuItem.getText()); - menuItem.setDisable(!rCaNScriptXML.conditionOK()); + if(! menuItem.getText().equals("TEST BUILD")) { + if (notStarted) menuItem.setDisable(notStarted); + else { + RCaNScript rCaNScript = RCommandListXML.getRCommandByMenu(menuItem.getText()); + menuItem.setDisable(!rCaNScript.conditionOK()); + } } } } - - public static List getMenuItems() { - - return menuItems; - } - - static final EventHandler StatusListener = e -> statusConnection(e); - - private static void statusConnection(ActionEvent e) { - String howConnected = Context.getHowConnected(); - HelpDialog.warning(howConnected, "Connection with R"); - } - + public static List getMenuItems() {return menuItems;} static final EventHandler MenuListener = e -> handle(e); - private static void handle(ActionEvent e) { MenuItem menuItem = (MenuItem) e.getSource(); RCaNScript rCaNScript = RCommandListXML.getRCommandByMenu(menuItem.getText()); @@ -67,7 +53,7 @@ private static void handle(ActionEvent e) { borderPaneRacine.setCenter(hboxResultsR); } else { - borderPaneRacine.setCenter(ProjectListsManager.getNetworkView()); + borderPaneRacine.setCenter(ObjectsManager.getNetworkView()); } } diff --git a/RCaNconstructor/src/main/java/fr/cm/Main/MenuRCaNSample.java b/RCaNconstructor/src/main/java/fr/cm/Main/MenuRCaNSample.java index 94d78401..89eb0aab 100644 --- a/RCaNconstructor/src/main/java/fr/cm/Main/MenuRCaNSample.java +++ b/RCaNconstructor/src/main/java/fr/cm/Main/MenuRCaNSample.java @@ -1,7 +1,6 @@ package fr.cm.Main; import fr.cm.dialogs.HelpDialog; -import fr.cm.project.ProjectListsManager; import fr.cm.rCaller.RCaNDialog; import fr.cm.rCaller.RCaNCaller; import fr.cm.xmlFiles.RCommandListXML; @@ -16,13 +15,13 @@ import java.util.List; public class MenuRCaNSample { - static List menuItems = null; static BorderPane borderPaneRacine; - public MenuRCaNSample(BorderPane borderPaneRacine) { MenuRCaNSample.borderPaneRacine = borderPaneRacine; menuItems = new ArrayList<>(); + MenuItem test = new MenuItem("TEST SAMPLE"); + menuItems.add(test); for (RCaNScript rCaNScript : RCommandListXML.getListOfRCommandXML()) { if (rCaNScript.getMenu().equals("sample")) { MenuItem menuItem = new MenuItem(rCaNScript.getTextMenu()); @@ -31,32 +30,25 @@ public MenuRCaNSample(BorderPane borderPaneRacine) { } } } - static void updateMenus() { boolean notStarted = (!Context.isStarted()) && (!Context.isConnectedR()); for (MenuItem menuItem : menuItems) { if (notStarted) menuItem.setDisable(notStarted); else { - RCaNScript rCaNScript = RCommandListXML.getRCommandByMenu(menuItem.getText()); - menuItem.setDisable(!rCaNScript.conditionOK()); + if (!menuItem.getText().equals("TEST SAMPLE")) { + RCaNScript rCaNScript = RCommandListXML.getRCommandByMenu(menuItem.getText()); + menuItem.setDisable(!rCaNScript.conditionOK()); + } } } } - - public static List getMenuItems() { - - return menuItems; - } - + public static List getMenuItems() {return menuItems;} static final EventHandler StatusListener = e -> statusConnection(e); - private static void statusConnection(ActionEvent e) { String howConnected = Context.getHowConnected(); HelpDialog.warning(howConnected, "Connection with R"); } - static final EventHandler MenuListener = e -> handle(e); - private static void handle(ActionEvent e) { MenuItem menuItem = (MenuItem) e.getSource(); RCaNScript rCaNScript = RCommandListXML.getRCommandByMenu(menuItem.getText()); @@ -66,7 +58,7 @@ private static void handle(ActionEvent e) { borderPaneRacine.setCenter(hboxResultsR); } else { - borderPaneRacine.setCenter(ProjectListsManager.getNetworkView()); + borderPaneRacine.setCenter(ObjectsManager.getNetworkView()); } } diff --git a/RCaNconstructor/src/main/java/fr/cm/Main/MenuSetUp.java b/RCaNconstructor/src/main/java/fr/cm/Main/MenuTrophicNetwork.java similarity index 70% rename from RCaNconstructor/src/main/java/fr/cm/Main/MenuSetUp.java rename to RCaNconstructor/src/main/java/fr/cm/Main/MenuTrophicNetwork.java index 5ed260fe..580974ce 100644 --- a/RCaNconstructor/src/main/java/fr/cm/Main/MenuSetUp.java +++ b/RCaNconstructor/src/main/java/fr/cm/Main/MenuTrophicNetwork.java @@ -1,13 +1,10 @@ package fr.cm.Main; -import fr.cm.objects.TimeLineTable; import fr.cm.objects.ComponentTable; import fr.cm.objects.ConstraintTable; import fr.cm.objects.DataFileTable; import fr.cm.objects.FluxTable; -import fr.cm.objects.MetaInformationTable; import fr.cm.objects.ObservationTable; -import fr.cm.project.ProjectListsManager; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.scene.control.MenuItem; @@ -16,47 +13,41 @@ import java.util.Arrays; import java.util.List; -public class MenuSetUp { +public class MenuTrophicNetwork { // --------------------------------- - static final MenuItem networkItem = new MenuItem("Network"); - static final MenuItem groupsItem = new MenuItem("Components"); - static final MenuItem linksItem = new MenuItem("Fluxes"); - static final MenuItem constraintsItem = new MenuItem("Constraints"); - static final MenuItem observationsItem = new MenuItem("Observations"); - static final MenuItem dataFileItem = new MenuItem("Data Files"); + static final MenuItem networkItem = new MenuItem("Network"), + groupsItem = new MenuItem("Components"), + linksItem = new MenuItem("Fluxes"), + constraintsItem = new MenuItem("Constraints"), + observationsItem = new MenuItem("Observations"), + dataFileItem = new MenuItem("Data Files"); static List menuItems = null; - static BorderPane borderPaneRacine; - - public MenuSetUp(BorderPane borderPaneRacine) { - MenuSetUp.borderPaneRacine = borderPaneRacine; + public MenuTrophicNetwork(BorderPane borderPaneRacine) { + MenuTrophicNetwork.borderPaneRacine = borderPaneRacine; menuItems = Arrays.asList(networkItem, groupsItem, linksItem, dataFileItem, observationsItem, constraintsItem); for (MenuItem menuItem : menuItems) { menuItem.setOnAction(ViewListener); } } - static void updateMenus() { boolean notStarted = !Context.isStarted(); for (MenuItem menuItem : menuItems) { menuItem.setDisable(notStarted); } } - public static List getMenuItems() { return menuItems; } - - static final EventHandler ViewListener = MenuSetUp::handle; - + static final EventHandler ViewListener = MenuTrophicNetwork::handle; private static void handle(ActionEvent e) { MenuItem menuItem = (MenuItem) e.getSource(); int numItem = menuItems.indexOf(menuItem); switch (numItem) { case 0 -> { - ProjectListsManager.getNetworkView().update(); - borderPaneRacine.setCenter(ProjectListsManager.getNetworkView()); + ObjectsManager.getNetworkView().update(); + borderPaneRacine.setCenter(ObjectsManager.getNetworkView()); } case 1 -> { ComponentTable componentTable = new ComponentTable(); diff --git a/RCaNconstructor/src/main/java/fr/cm/project/ProjectListsManager.java b/RCaNconstructor/src/main/java/fr/cm/Main/ObjectsManager.java similarity index 93% rename from RCaNconstructor/src/main/java/fr/cm/project/ProjectListsManager.java rename to RCaNconstructor/src/main/java/fr/cm/Main/ObjectsManager.java index ff0d2e29..2c9578d5 100644 --- a/RCaNconstructor/src/main/java/fr/cm/project/ProjectListsManager.java +++ b/RCaNconstructor/src/main/java/fr/cm/Main/ObjectsManager.java @@ -1,4 +1,4 @@ -package fr.cm.project; +package fr.cm.Main; import fr.cm.network.NetworkView; import fr.cm.dialogs.HelpDialog; @@ -20,7 +20,7 @@ import java.util.Iterator; import java.util.List; -public class ProjectListsManager { +public class ObjectsManager { // --------------------------------- private static List listOfComponents; @@ -46,45 +46,32 @@ public static void init() { } // ------------------------------------------------------------------------------ // ACTIONS - public static void addTimeLine(TimeLine timeLine, boolean save) { - listOfTimeLines.add(timeLine); if(save) saveExcel(); - } public static void addTimeLine(String comment, boolean save) { TimeLine timeLine = new TimeLine(comment); listOfTimeLines.add(timeLine); if(save) saveExcel(); } - public static List getListOfTimeLines() { - return listOfTimeLines; } - public static void initListOfTimeLines() { - listOfTimeLines = new ArrayList<>(); } - - public static void setListOfTimeLines(List listOfTimeLines) { - ProjectListsManager.listOfTimeLines = listOfTimeLines; - } - public static void updateAction(int nu, String comment) { TimeLine timeLine = listOfTimeLines.get(nu); timeLine.setCommentAuthor(comment); saveExcel(); } - // ------------------------------------------------------------------------------ // META INFORMATION public static void makeMetaElementsList(){ listOfMetaElements = new ArrayList<>(); String fileName = "project/Project.txt"; - InputStream inst = ProjectListsManager.class.getClassLoader().getResourceAsStream(fileName); + InputStream inst = ObjectsManager.class.getClassLoader().getResourceAsStream(fileName); if(inst != null){ List elementsResource = new ArrayList<>(); try { @@ -104,7 +91,7 @@ public static List getListOfMetaElements() { } public static void setListOfMetaElements(List listOfMetaElements) { - ProjectListsManager.listOfMetaElements = listOfMetaElements; + ObjectsManager.listOfMetaElements = listOfMetaElements; } public static void updateMetaElement(int nu, String comment) { @@ -136,6 +123,7 @@ public static void addComponent(Component component, boolean save) { listOfComponents.add(component); } addTimeLine("Added component: "+component.getName(),save); + Logg.addLog("Added component: "+component.getName()); } public static void removeComponent(Component component) { listOfConstraints.removeIf(constraint -> constraint.involve(component)); @@ -149,6 +137,7 @@ public static void removeComponent(Component component) { } listOfComponents.remove(component); addTimeLine("Removed component: "+component.getName(),true); + Logg.addLog("Removed component: "+component.getName()); } public static boolean containsComponent(String groupName) { boolean contain = false; @@ -215,6 +204,7 @@ public static void addLink(Flux flux, boolean save) { flux.define(networkView.getMouseDoubleClickOnLineEventHandler()); listOfFluxes.add(flux); addTimeLine("Added Flux: "+ flux.getName(),save); + Logg.addLog("Added Flux: "+flux.getName()); } } public static List getNamesOfLinks() { @@ -237,6 +227,7 @@ public static void removeLink(Flux flux) { listOfConstraints.removeIf(constraint -> constraint.involve(flux)); listOfFluxes.remove(flux); addTimeLine("Removed Flux: "+ flux.getName(),true); + Logg.addLog("Removed Flux: "+flux.getName()); } public static void permuteListOfLinks(int rowA, int rowB) { Flux fluxA = listOfFluxes.get(rowA); @@ -271,6 +262,7 @@ public static void addObservation(Observation observation, boolean save) { else { listOfObservations.add(observation); addTimeLine("Added Observation: "+ observation.getObsName(),save); + Logg.addLog("Added Observation: "+observation.getObsName()); } } public static void removeObservation(String observationName){ @@ -278,6 +270,7 @@ public static void removeObservation(String observationName){ if (observationName.equals(observation.getObsName())) { listOfObservations.remove(observation); addTimeLine("Removed Observation: "+ observation.getObsName(),true); + Logg.addLog("Removed Observation: "+observation.getObsName()); break; } } @@ -317,7 +310,7 @@ public static List getListOfObservations() { } public static void setListOfObservations(List listOfObservations) { - ProjectListsManager.listOfObservations = listOfObservations; + ObjectsManager.listOfObservations = listOfObservations; } // ------------------------------------------------------------------------------ @@ -325,15 +318,18 @@ public static void setListOfObservations(List listOfObservations) { public static void addConstraint(Constraint constraint, boolean save) { listOfConstraints.add(constraint); addTimeLine("Added Constraint: "+ constraint.getName(),save); + Logg.addLog("Added constraint: "+constraint.getName()+ ": "+ constraint.getFormula()); } public static void removeConstraints(Constraint constraint) { listOfConstraints.remove(constraint); addTimeLine("Removed Constraint: "+ constraint.getName(),true); + Logg.addLog("Removed constraint: "+constraint.getName()+ ": "+ constraint.getFormula()); } public static void updateConstraint(Constraint oldC, Constraint newC) { int pos = listOfConstraints.indexOf(oldC); listOfConstraints.set(pos,newC); - addTimeLine("Updated Constraint: "+ oldC.getName()+ "-W" + newC.getName(),true); + addTimeLine("Updated Constraint: "+ oldC.getFormula()+ " -> " + newC.getFormula(),true); + Logg.addLog("Updated Constraint: "+ oldC.getFormula()+ " -> " + newC.getFormula()); } public static void upConstraint(Constraint constraint) { int numConstraint = listOfConstraints.indexOf(constraint); @@ -370,6 +366,7 @@ public static void addDataFile(DataFile newDataFile, boolean save) { if(! in) { listOfDataFiles.add(newDataFile); addTimeLine("Added Data File: "+ newDataFile.getShortName(),save); + Logg.addLog("Added Data File: "+ newDataFile.getShortName()); } else { HelpDialog.warning("File has already been introduced","Warning"); diff --git a/RCaNconstructor/src/main/java/fr/cm/Main/SystemInfo.java b/RCaNconstructor/src/main/java/fr/cm/Main/SystemInfo.java index 85416e4f..71bfa196 100644 --- a/RCaNconstructor/src/main/java/fr/cm/Main/SystemInfo.java +++ b/RCaNconstructor/src/main/java/fr/cm/Main/SystemInfo.java @@ -5,7 +5,6 @@ public class SystemInfo { public static String javaVersion() { return System.getProperty("java.version"); } - public static String javafxVersion() { return System.getProperty("javafx.version"); } diff --git a/RCaNconstructor/src/main/java/fr/cm/excel/ComponentExcel.java b/RCaNconstructor/src/main/java/fr/cm/excel/ComponentExcel.java index 37c0acd6..a2888eac 100644 --- a/RCaNconstructor/src/main/java/fr/cm/excel/ComponentExcel.java +++ b/RCaNconstructor/src/main/java/fr/cm/excel/ComponentExcel.java @@ -2,7 +2,7 @@ import fr.cm.objects.Component; import fr.cm.preferences.Strings; -import fr.cm.project.ProjectListsManager; +import fr.cm.Main.ObjectsManager; import org.apache.poi.ss.usermodel.*; import java.util.ArrayList; @@ -35,7 +35,7 @@ public static void saveExcelComponents(Workbook workbook) { cell = row.createCell(np + 3); cell.setCellValue("Y"); - for (Component component : ProjectListsManager.getListOfComponents()) { + for (Component component : ObjectsManager.getListOfComponents()) { row = sheet.createRow(liP); liP++; cell = row.createCell(0); @@ -103,7 +103,7 @@ public static void getExcelComponents(Workbook workbook) { y = 0.2 + 0.4 * Math.random(); } Component component = new Component(nameComponent, parameters, typeComponent, x, y); - ProjectListsManager.addComponent(component, false); + ObjectsManager.addComponent(component, false); } } static boolean getBoolean(Cell cell){ diff --git a/RCaNconstructor/src/main/java/fr/cm/excel/ConstraintExcel.java b/RCaNconstructor/src/main/java/fr/cm/excel/ConstraintExcel.java index 63e0d993..3de3c449 100644 --- a/RCaNconstructor/src/main/java/fr/cm/excel/ConstraintExcel.java +++ b/RCaNconstructor/src/main/java/fr/cm/excel/ConstraintExcel.java @@ -1,7 +1,7 @@ package fr.cm.excel; import fr.cm.objects.Constraint; -import fr.cm.project.ProjectListsManager; +import fr.cm.Main.ObjectsManager; import org.apache.poi.ss.usermodel.*; import java.util.Iterator; @@ -26,8 +26,8 @@ public static void saveExcelConstraints(Workbook workbook) { cell = row.createCell(4); cell.setCellValue("Comment"); lig++; - for (int c = 0; c < ProjectListsManager.getListOfConstraints().size(); c++) { - Constraint constraint = ProjectListsManager.getListOfConstraints().get(c); + for (int c = 0; c < ObjectsManager.getListOfConstraints().size(); c++) { + Constraint constraint = ObjectsManager.getListOfConstraints().get(c); row = sheet.createRow(lig); cell = row.createCell(0); cell.setCellValue(constraint.getName()); @@ -73,7 +73,7 @@ public static void getExcelConstraints(Workbook workbook) { comment = cell.getStringCellValue(); } Constraint constraint = new Constraint(name, formula, years, active, comment); - ProjectListsManager.addConstraint(constraint, false); + ObjectsManager.addConstraint(constraint, false); } catch (Exception e) { // le champ active n'existe pas encore } diff --git a/RCaNconstructor/src/main/java/fr/cm/excel/DataFileExcel.java b/RCaNconstructor/src/main/java/fr/cm/excel/DataFileExcel.java index f3d9da5e..44d646c2 100644 --- a/RCaNconstructor/src/main/java/fr/cm/excel/DataFileExcel.java +++ b/RCaNconstructor/src/main/java/fr/cm/excel/DataFileExcel.java @@ -3,7 +3,7 @@ import fr.cm.dialogs.HelpDialog; import fr.cm.objects.DataFile; import fr.cm.objects.Observation; -import fr.cm.project.ProjectListsManager; +import fr.cm.Main.ObjectsManager; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Sheet; @@ -59,8 +59,8 @@ public static void saveExcelFileWithObservation(Workbook workbook) { cell = row.createCell(5); cell.setCellValue("Selected columns"); lig++; - for (int c = 0; c < ProjectListsManager.getListOfDataFiles().size(); c++) { - DataFile dataFile = ProjectListsManager.getListOfDataFiles().get(c); + for (int c = 0; c < ObjectsManager.getListOfDataFiles().size(); c++) { + DataFile dataFile = ObjectsManager.getListOfDataFiles().get(c); row = sheet.createRow(lig); cell = row.createCell(0); cell.setCellValue(dataFile.getId()); @@ -103,7 +103,7 @@ public static void getExcelFileWithObservation(Workbook workbook) { List addedObservations = decodeAddedObservations(codeObservations); DataFile dataFile = new DataFile(id, shortName, fullFileName, metaInformation, owner, addedObservations); if(dataFile.isCorrectlyRead()){ - ProjectListsManager.addDataFile(dataFile, false); + ObjectsManager.addDataFile(dataFile, false); } } } @@ -115,7 +115,7 @@ public static void getExcelFileWithObservation(Workbook workbook) { private static void oldGetExcelFileWithObservation(Workbook workbook) { try { - String id = ProjectListsManager.getDataFileId(); + String id = ObjectsManager.getDataFileId(); Sheet sheet = workbook.getSheet("FileWithObservation"); Row row; Cell cell; @@ -137,7 +137,7 @@ private static void oldGetExcelFileWithObservation(Workbook workbook) { List addedObservations = decodeAddedObservations(codeObservations); DataFile dataFile = new DataFile(id, shortName, fullFileName, metaInformation, owner, addedObservations); if(dataFile.isCorrectlyRead()){ - ProjectListsManager.addDataFile(dataFile, false); + ObjectsManager.addDataFile(dataFile, false); } } } diff --git a/RCaNconstructor/src/main/java/fr/cm/excel/FluxExcel.java b/RCaNconstructor/src/main/java/fr/cm/excel/FluxExcel.java index 37a92935..c8024408 100644 --- a/RCaNconstructor/src/main/java/fr/cm/excel/FluxExcel.java +++ b/RCaNconstructor/src/main/java/fr/cm/excel/FluxExcel.java @@ -1,7 +1,7 @@ package fr.cm.excel; import fr.cm.objects.Flux; -import fr.cm.project.ProjectListsManager; +import fr.cm.Main.ObjectsManager; import org.apache.poi.ss.usermodel.*; import java.util.Iterator; @@ -25,7 +25,7 @@ public static void saveExcelLinks(Workbook workbook) { cell.setCellValue("To"); cell = row.createCell(3); cell.setCellValue("Trophic"); - for (Flux flux : ProjectListsManager.getListOfFluxes()) { + for (Flux flux : ObjectsManager.getListOfFluxes()) { row = sheet.createRow(liL); liL++; cell = row.createCell(0); @@ -57,7 +57,7 @@ public static void getExcelLinks(Workbook workbook) { cell = row.getCell(3); boolean stype = getBoolean(cell); Flux newFlux = new Flux(in, out, stype); - ProjectListsManager.addLink(newFlux, false); + ObjectsManager.addLink(newFlux, false); } } diff --git a/RCaNconstructor/src/main/java/fr/cm/excel/MetaExcel.java b/RCaNconstructor/src/main/java/fr/cm/excel/MetaExcel.java index c3d8a7c3..51c833ae 100644 --- a/RCaNconstructor/src/main/java/fr/cm/excel/MetaExcel.java +++ b/RCaNconstructor/src/main/java/fr/cm/excel/MetaExcel.java @@ -2,7 +2,7 @@ import fr.cm.Main.Context; import fr.cm.objects.MetaElement; -import fr.cm.project.ProjectListsManager; +import fr.cm.Main.ObjectsManager; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Sheet; @@ -27,7 +27,7 @@ public static void saveExcelMetaInformation(Workbook workbook) { cell = row.createCell(1); cell.setCellValue("Value"); - List elements = ProjectListsManager.getListOfMetaElements(); + List elements = ObjectsManager.getListOfMetaElements(); for (int c = 0; c < elements.size(); c++) { MetaElement element = elements.get(c); row = sheet.createRow(c + 2); @@ -45,8 +45,8 @@ public static void getExcelMetaInformation(Workbook workbook) { Sheet sheet = workbook.getSheet("INFO"); Row row; Cell cell; - ProjectListsManager.makeMetaElementsList(); - List elements = ProjectListsManager.getListOfMetaElements(); + ObjectsManager.makeMetaElementsList(); + List elements = ObjectsManager.getListOfMetaElements(); try { for (int r = 0; r < elements.size(); r++) { row = sheet.getRow(r + 2); @@ -54,9 +54,9 @@ public static void getExcelMetaInformation(Workbook workbook) { String content = cell.getStringCellValue(); elements.get(r).setMetaContent(content); } - ProjectListsManager.setListOfMetaElements(elements); + ObjectsManager.setListOfMetaElements(elements); } catch (Exception e) { - ProjectListsManager.makeMetaElementsList(); + ObjectsManager.makeMetaElementsList(); } } diff --git a/RCaNconstructor/src/main/java/fr/cm/excel/ObservationExcel.java b/RCaNconstructor/src/main/java/fr/cm/excel/ObservationExcel.java index 4d18d575..87640465 100644 --- a/RCaNconstructor/src/main/java/fr/cm/excel/ObservationExcel.java +++ b/RCaNconstructor/src/main/java/fr/cm/excel/ObservationExcel.java @@ -2,7 +2,7 @@ import fr.cm.Main.Context; import fr.cm.objects.Observation; -import fr.cm.project.ProjectListsManager; +import fr.cm.Main.ObjectsManager; import org.apache.poi.ss.usermodel.*; import java.util.ArrayList; @@ -25,7 +25,7 @@ public static void saveExcelObservations(Workbook workbook) { cell = row.createCell(0); cell.setCellValue("Year"); o = 0; - for (Observation observation : ProjectListsManager.getListOfObservations()) { + for (Observation observation : ObjectsManager.getListOfObservations()) { o++; cell = row.createCell(o); cell.setCellValue(observation.getObsName()); @@ -36,7 +36,7 @@ public static void saveExcelObservations(Workbook workbook) { row = sheet.createRow(y + 1); cell = row.createCell(0); cell.setCellValue(y + first); - for (Observation observation : ProjectListsManager.getListOfObservations()) { + for (Observation observation : ObjectsManager.getListOfObservations()) { o++; double val = observation.getValues()[y]; if (val >= 0.0) { @@ -121,7 +121,7 @@ public static void getExcelObservations(Workbook workbook) { } for (int o = 0; o < nbo; o++) { Observation observation = new Observation(idObs.get(o), values[o]); - ProjectListsManager.addObservation(observation, false); + ObjectsManager.addObservation(observation, false); } } } diff --git a/RCaNconstructor/src/main/java/fr/cm/excel/TimeLineExcel.java b/RCaNconstructor/src/main/java/fr/cm/excel/TimeLineExcel.java index 18e1f428..f05aa6a9 100644 --- a/RCaNconstructor/src/main/java/fr/cm/excel/TimeLineExcel.java +++ b/RCaNconstructor/src/main/java/fr/cm/excel/TimeLineExcel.java @@ -2,7 +2,7 @@ import fr.cm.dialogs.HelpDialog; import fr.cm.objects.TimeLine; -import fr.cm.project.ProjectListsManager; +import fr.cm.Main.ObjectsManager; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Sheet; @@ -27,7 +27,7 @@ public static void saveExcelFileTimeLines(Workbook workbook) { cell = row.createCell(2); cell.setCellValue("Annotation"); - List listOfTimeLines = ProjectListsManager.getListOfTimeLines(); + List listOfTimeLines = ObjectsManager.getListOfTimeLines(); int c = 0; for (TimeLine timeLine : listOfTimeLines) { c++; @@ -44,7 +44,7 @@ public static void saveExcelFileTimeLines(Workbook workbook) { // ------------------------------------------------------------------------- public static void getExcelFileTimeLines(Workbook workbook) { try { - ProjectListsManager.initListOfTimeLines(); + ObjectsManager.initListOfTimeLines(); Sheet sheet = workbook.getSheet("TimeLines"); Row row; Cell cell; @@ -59,7 +59,7 @@ public static void getExcelFileTimeLines(Workbook workbook) { cell = row.getCell(2); String commentAuthor = cell.getStringCellValue(); TimeLine newTimeLine = new TimeLine(date, comment, commentAuthor); - ProjectListsManager.addTimeLine(newTimeLine, false); + ObjectsManager.addTimeLine(newTimeLine, false); } } catch (Exception ex) { HelpDialog.warning("Sheet TimeLine does not exist", "Warning ", ex); diff --git a/RCaNconstructor/src/main/java/fr/cm/network/ComponentGroup.java b/RCaNconstructor/src/main/java/fr/cm/network/ComponentGroup.java index ccf2b41e..c1d0b680 100644 --- a/RCaNconstructor/src/main/java/fr/cm/network/ComponentGroup.java +++ b/RCaNconstructor/src/main/java/fr/cm/network/ComponentGroup.java @@ -1,6 +1,6 @@ package fr.cm.network; -import fr.cm.project.ProjectListsManager; +import fr.cm.Main.ObjectsManager; import fr.cm.Main.Context; import fr.cm.preferences.ColorsAndFormats; import javafx.event.EventHandler; @@ -183,13 +183,13 @@ public double getY() { // -------------------------------------------- public void changeName(String newName){ if(!name.equals(newName)){ - ProjectListsManager.addTimeLine("Change component name : " + name + " -> "+ newName, true); + ObjectsManager.addTimeLine("Change component name : " + name + " -> "+ newName, true); name = newName; } } public void changeInside(boolean newInside){ if(!inside==newInside){ - ProjectListsManager.addTimeLine( + ObjectsManager.addTimeLine( "Change position of component " + name + " : inside "+ inside +" -> "+ newInside,true); inside = newInside; } diff --git a/RCaNconstructor/src/main/java/fr/cm/network/FluxGroup.java b/RCaNconstructor/src/main/java/fr/cm/network/FluxGroup.java index 84280dff..e6ed7bfb 100644 --- a/RCaNconstructor/src/main/java/fr/cm/network/FluxGroup.java +++ b/RCaNconstructor/src/main/java/fr/cm/network/FluxGroup.java @@ -1,6 +1,6 @@ package fr.cm.network; -import fr.cm.project.ProjectListsManager; +import fr.cm.Main.ObjectsManager; import fr.cm.Main.Context; import fr.cm.objects.Component; import fr.cm.preferences.ColorsAndFormats; @@ -19,18 +19,16 @@ public class FluxGroup extends Group { // Group : javafx class pour les objets graphiques - Component in; - Component out; + Component in, out; Color col; - Path arrow; - Path path; + Path arrow, path; Circle circle; boolean typeTrophic; // -------------------------------------------- public FluxGroup(String i, String o, boolean t) { - in = ProjectListsManager.whichComponent(i); - out = ProjectListsManager.whichComponent(o); + in = ObjectsManager.whichComponent(i); + out = ObjectsManager.whichComponent(o); typeTrophic = t; } @@ -216,7 +214,7 @@ protected double computeValue() { // -------------------------------------------- public void changeTypeTrophic(boolean newTypeTrophic){ if(!typeTrophic==newTypeTrophic){ - ProjectListsManager.addTimeLine( + ObjectsManager.addTimeLine( "Change type of flux " + getName() + " : trophic "+ typeTrophic +" -> "+ newTypeTrophic, false); typeTrophic = newTypeTrophic; } diff --git a/RCaNconstructor/src/main/java/fr/cm/network/NetworkView.java b/RCaNconstructor/src/main/java/fr/cm/network/NetworkView.java index 27c2ac2c..f6890dfb 100644 --- a/RCaNconstructor/src/main/java/fr/cm/network/NetworkView.java +++ b/RCaNconstructor/src/main/java/fr/cm/network/NetworkView.java @@ -5,7 +5,7 @@ import fr.cm.objects.FluxEditDialog; import fr.cm.objects.Component; import fr.cm.objects.Flux; -import fr.cm.project.ProjectListsManager; +import fr.cm.Main.ObjectsManager; import fr.cm.Main.Context; import fr.cm.preferences.ColorsAndFormats; @@ -17,7 +17,6 @@ import javafx.scene.Node; import javafx.scene.input.MouseEvent; import javafx.scene.layout.Pane; -import javafx.scene.layout.StackPane; import javafx.scene.paint.Color; import javafx.scene.shape.Circle; import javafx.scene.shape.Rectangle; @@ -82,11 +81,11 @@ private Rectangle inside() { public void update() { ObservableList components = this.getChildren(); this.getChildren().removeAll(components); - List listOfComponents = ProjectListsManager.getListOfComponents(); + List listOfComponents = ObjectsManager.getListOfComponents(); for(Component component: listOfComponents){ component.setPos(); } - List listOfFluxes = ProjectListsManager.getListOfFluxes(); + List listOfFluxes = ObjectsManager.getListOfFluxes(); fond = background(); interieur = inside(); this.getChildren().addAll(fond, interieur); @@ -162,13 +161,13 @@ public void redrawChangingSize() { } else { if (addingTrophicLink) { Flux flux = new Flux(originOfLink, clickedComponent, true); - ProjectListsManager.addLink(flux, true); + ObjectsManager.addLink(flux, true); resetLink(); update(); } if (addingNonTrophicLink) { Flux flux = new Flux(originOfLink, clickedComponent, false); - ProjectListsManager.addLink(flux, true); + ObjectsManager.addLink(flux, true); resetLink(); update(); } @@ -200,9 +199,5 @@ public void setAddingNonTrophicLink(boolean addingNonTrophicLink) { originOfLink = clickedComponent; this.addingNonTrophicLink = addingNonTrophicLink; } - // ------------------------------------------------------------------------------------- - public void setOriginOfLink(Component origin) { - this.originOfLink = origin; - } - // ------------------------------------------------------------------------------------- + // ------------------------------------------------------------------------------------- } diff --git a/RCaNconstructor/src/main/java/fr/cm/objects/Component.java b/RCaNconstructor/src/main/java/fr/cm/objects/Component.java index 49a4a10a..88a4c623 100644 --- a/RCaNconstructor/src/main/java/fr/cm/objects/Component.java +++ b/RCaNconstructor/src/main/java/fr/cm/objects/Component.java @@ -6,7 +6,7 @@ package fr.cm.objects; import fr.cm.network.ComponentGroup; -import fr.cm.project.ProjectListsManager; +import fr.cm.Main.ObjectsManager; import fr.cm.preferences.Strings; @@ -39,30 +39,25 @@ public void xsetParameters(int p, String newV) { public double[] getParameters() { return (parameters); } - public double getParameters(int p) { return (parameters[p]); } - public void setParameters(double[] param) { System.arraycopy(param,0,parameters,0,np); } - // -------------------------------------------- - public void changeParameters(int p, String newVal){ double nVal; try { nVal = Double.parseDouble(newVal); if ((Math.abs(nVal - parameters[p]) > 0.0000001) && nVal>=0.0) { - ProjectListsManager.addTimeLine("Change value of parameter " + ObjectsManager.addTimeLine("Change value of parameter " + Strings.getParametersNames(p)+ " for component " + this.getName() + " : " + parameters[p] + " -> " + newVal, true); parameters[p] = nVal; } } catch (NumberFormatException e) { - } } } diff --git a/RCaNconstructor/src/main/java/fr/cm/objects/ComponentClicDialog.java b/RCaNconstructor/src/main/java/fr/cm/objects/ComponentClicDialog.java index 93956954..a05198a0 100644 --- a/RCaNconstructor/src/main/java/fr/cm/objects/ComponentClicDialog.java +++ b/RCaNconstructor/src/main/java/fr/cm/objects/ComponentClicDialog.java @@ -1,7 +1,7 @@ package fr.cm.objects; import fr.cm.network.NetworkView; -import fr.cm.project.ProjectListsManager; +import fr.cm.Main.ObjectsManager; import java.util.Optional; @@ -20,9 +20,7 @@ * @author christianmullon */ public class ComponentClicDialog extends Dialog { - final Window window; - public ComponentClicDialog(Component component, NetworkView networkView) { window = this.getDialogPane().getScene().getWindow(); window.setOnCloseRequest(event -> window.hide()); @@ -43,7 +41,7 @@ public ComponentClicDialog(Component component, NetworkView networkView) { new ComponentEditDialog(component); } if (result.get() == buttonTypeDelete) { - ProjectListsManager.removeComponent(component); + ObjectsManager.removeComponent(component); } if (result.get() == buttonTypeNewTrophicLink) { networkView.setAddingTrophicLink(true); diff --git a/RCaNconstructor/src/main/java/fr/cm/objects/ComponentEditDialog.java b/RCaNconstructor/src/main/java/fr/cm/objects/ComponentEditDialog.java index d8551aff..9e78c1a0 100644 --- a/RCaNconstructor/src/main/java/fr/cm/objects/ComponentEditDialog.java +++ b/RCaNconstructor/src/main/java/fr/cm/objects/ComponentEditDialog.java @@ -1,7 +1,7 @@ package fr.cm.objects; import fr.cm.dialogs.HelpDialog; -import fr.cm.project.ProjectListsManager; +import fr.cm.Main.ObjectsManager; import fr.cm.preferences.Strings; import javafx.geometry.Insets; import javafx.scene.control.*; @@ -22,10 +22,8 @@ */ public class ComponentEditDialog extends Dialog { - final TextField[] fieldCaracteristiques; final Window window; - public ComponentEditDialog(Component component) { window = this.getDialogPane().getScene().getWindow(); window.setOnCloseRequest(event -> window.hide()); @@ -103,7 +101,7 @@ public ComponentEditDialog(Component component) { } } if (result.get() == buttonTypeDelete) { - ProjectListsManager.removeComponent(component); + ObjectsManager.removeComponent(component); } } } diff --git a/RCaNconstructor/src/main/java/fr/cm/objects/ComponentNewDialog.java b/RCaNconstructor/src/main/java/fr/cm/objects/ComponentNewDialog.java index 65a2b632..8a671155 100644 --- a/RCaNconstructor/src/main/java/fr/cm/objects/ComponentNewDialog.java +++ b/RCaNconstructor/src/main/java/fr/cm/objects/ComponentNewDialog.java @@ -2,7 +2,7 @@ import java.util.Optional; -import fr.cm.project.ProjectListsManager; +import fr.cm.Main.ObjectsManager; import fr.cm.preferences.Strings; import javafx.collections.FXCollections; import javafx.collections.ObservableList; @@ -26,9 +26,7 @@ * @author christianmullon */ public class ComponentNewDialog extends Dialog{ - final Window window; - public ComponentNewDialog(double wx, double hy) { window = this.getDialogPane().getScene().getWindow(); window.setOnCloseRequest(event -> window.hide()); @@ -70,7 +68,7 @@ public ComponentNewDialog(double wx, double hy) { component.setInside(type); component.setText(); component.setWH(wx, hy); - ProjectListsManager.addComponent(component, true); + ObjectsManager.addComponent(component, true); } } } diff --git a/RCaNconstructor/src/main/java/fr/cm/objects/ComponentTable.java b/RCaNconstructor/src/main/java/fr/cm/objects/ComponentTable.java index b7954747..f5f1d15a 100644 --- a/RCaNconstructor/src/main/java/fr/cm/objects/ComponentTable.java +++ b/RCaNconstructor/src/main/java/fr/cm/objects/ComponentTable.java @@ -5,7 +5,7 @@ */ package fr.cm.objects; -import fr.cm.project.ProjectListsManager; +import fr.cm.Main.ObjectsManager; import fr.cm.Main.Context; import fr.cm.preferences.ColorsAndFormats; import fr.cm.preferences.Strings; @@ -28,13 +28,9 @@ */ public class ComponentTable extends Pane { // --------------------------------- - - double width = Context.getWindowWidth(); - double height = Context.getWindowHeight(); - + double width = Context.getWindowWidth(), height = Context.getWindowHeight(); final TableView table; ObservableList list; - public ComponentTable() { super(); int nbParameters = Strings.getNumberOfParameters(); @@ -91,7 +87,7 @@ public ComponentTable() { table.getColumns().add(col); } - list = FXCollections.observableArrayList(ProjectListsManager.getListOfComponents()); + list = FXCollections.observableArrayList(ObjectsManager.getListOfComponents()); table.setItems(list); table.getSelectionModel().selectFirst(); table.setPrefWidth(0.8*width); @@ -101,7 +97,7 @@ public ComponentTable() { deleteG.setOnAction((ActionEvent e) -> { if (table.getSelectionModel().getSelectedItem() != null) { Component component = table.getSelectionModel().getSelectedItem(); - ProjectListsManager.removeComponent(component); + ObjectsManager.removeComponent(component); list.removeAll(component); updateTable(); } @@ -110,14 +106,14 @@ public ComponentTable() { final Button buttonUp = new Button("Up"); buttonUp.setOnAction((ActionEvent e) -> { Component component = table.getSelectionModel().getSelectedItem(); - ProjectListsManager.upComponent(component); + ObjectsManager.upComponent(component); updateTable(); }); final Button buttonDown = new Button("Down"); buttonDown.setOnAction((ActionEvent e) -> { Component component = table.getSelectionModel().getSelectedItem(); - ProjectListsManager.downComponent(component); + ObjectsManager.downComponent(component); updateTable(); }); @@ -140,7 +136,7 @@ public ComponentTable() { public void updateTable() { Component component = table.getSelectionModel().getSelectedItem(); table.getItems().removeAll(list); - list = FXCollections.observableArrayList(ProjectListsManager.getListOfComponents()); + list = FXCollections.observableArrayList(ObjectsManager.getListOfComponents()); table.setItems(list); table.getSelectionModel().select(component); } diff --git a/RCaNconstructor/src/main/java/fr/cm/objects/Constraint.java b/RCaNconstructor/src/main/java/fr/cm/objects/Constraint.java index 49cd1962..4bbc2b9e 100644 --- a/RCaNconstructor/src/main/java/fr/cm/objects/Constraint.java +++ b/RCaNconstructor/src/main/java/fr/cm/objects/Constraint.java @@ -5,15 +5,15 @@ */ package fr.cm.objects; -import fr.cm.project.ProjectListsManager; +import fr.cm.Main.ObjectsManager; import javafx.beans.property.SimpleStringProperty; public class Constraint { - final SimpleStringProperty formula = new SimpleStringProperty(); - final SimpleStringProperty name = new SimpleStringProperty(); - final SimpleStringProperty years = new SimpleStringProperty(); - final SimpleStringProperty comment = new SimpleStringProperty(); + final SimpleStringProperty formula = new SimpleStringProperty(), + name = new SimpleStringProperty(), + years = new SimpleStringProperty(), + comment = new SimpleStringProperty(); boolean active; public Constraint(String name, String formula, String years, @@ -47,13 +47,13 @@ public Constraint(String name, String formula, String years, public void changeName(String newName){ if(! this.getName().equals(newName)){ - ProjectListsManager.addTimeLine("Change constraint name : " + name + " -> "+ newName, true); + ObjectsManager.addTimeLine("Change constraint name : " + name + " -> "+ newName, true); setName(newName); } } public void changeActive(boolean newActive){ if(!active==newActive){ - ProjectListsManager.addTimeLine("Change position of component " + name + " : active "+ active +" -> "+ newActive, true); + ObjectsManager.addTimeLine("Change position of component " + name + " : active "+ active +" -> "+ newActive, true); active = newActive; } } diff --git a/RCaNconstructor/src/main/java/fr/cm/objects/ConstraintFormula.java b/RCaNconstructor/src/main/java/fr/cm/objects/ConstraintFormula.java index 66183bd3..208df5de 100644 --- a/RCaNconstructor/src/main/java/fr/cm/objects/ConstraintFormula.java +++ b/RCaNconstructor/src/main/java/fr/cm/objects/ConstraintFormula.java @@ -9,39 +9,23 @@ public class ConstraintFormula { List tokens = new ArrayList<>(); - // -------------------------------------------- - public static List nombres = new ArrayList<>(Arrays.asList( - ".", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9",":" - )); + static List nombres = new ArrayList<>(Arrays.asList(".", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9",":")); // -------------------------------------------- - public static List operatorsArithmetiques = new ArrayList<>(Arrays.asList( - "+", "-", "*", "/" - )); - + static List operatorsArithmetiques = new ArrayList<>(Arrays.asList("+", "-", "*", "/")); // -------------------------------------------- - public static List operatorsUnaires = new ArrayList<>(Arrays.asList( - "sum", "mean" - )); - + static List operatorsUnaires = new ArrayList<>(Arrays.asList("sum", "mean","survey")); // -------------------------------------------- - public static List operatorsComparaison = new ArrayList<>(Arrays.asList( - "<=", ">=","=" - )); - + static List operatorsComparaison = new ArrayList<>(Arrays.asList("<=", ">=","=")); + static List shortcuts = new ArrayList<>(Arrays.asList("Outflows","Inflows","TrophicInflows","TrophicOuflows","TrophicAllFlows", "After","Before","Delta","Ratio")); // -------------------------------------------- - public static List symbolsAndOperators = new ArrayList<>(Arrays.asList( - "(", ")","[", "]", "+", "-", "*", "/", "<=", ">=","=","sum", "mean")); - + static List symbolsAndOperators = new ArrayList<>(Arrays.asList("(", ")","[", "]", "+", "-", "*", "/", "<=", ">=","=","sum", "mean","survey")); // -------------------------------------------- - public static List symbolsAndOperatorsD = new ArrayList<>(Arrays.asList( - "(", ")", "[", "]", "+", "-", "*", "/", "&", "#","=","!", "?")); - + static List symbolsAndOperatorsD = new ArrayList<>(Arrays.asList("(", ")", "[", "]", "+", "-", "*", "/", "&", "#","=","!", "?")); // -------------------------------------------- List operatorsBinaires = new ArrayList<>(); boolean previousTokenIsNumeric; int pos; - // -------------------------------------------- public ConstraintFormula() { operatorsBinaires.addAll(operatorsArithmetiques); @@ -200,7 +184,7 @@ public String check() { newTokens.add(s); } } - // on vérifie la validité de la formule par élimination successive des bloc corrects + // on vérifie la validité de la formule par élimination successive des blocs corrects // un bloc correct est obtenu a partir des transformations // ok [ok] -> ok // operateur unaire ( ok ) -> ok @@ -278,7 +262,7 @@ public String check() { } } } - tokensOld = newTokens; + tokensOld = newTokens; // - ok -> ok (- en première position) newTokens = new ArrayList<>(); for (int t = 0; t < tokensOld.size(); t++) { @@ -288,23 +272,19 @@ public String check() { newTokens.add(tokensOld.get(t)); } } - tokensOld = newTokens; - + tokensOld = newTokens; int nf = tokensOld.size(); changes = !(nf == nd); } if(tokensOld.size() != 1){ - return ("Unbalanced formula)"); + return ("Unbalanced formula"); } return ("Ok"); } // ---------------------------------------------------------------------------------- public int getPos() { return pos; } - public void setPos(int pos) { this.pos = Math.min(pos, tokens.size() - 1); } - public int getNbTokens() { return (tokens.size()); } - public String getToken(int t) { return (tokens.get(t)); } // ---------------------------------------------------------------------------------- diff --git a/RCaNconstructor/src/main/java/fr/cm/objects/ConstraintNewOrEditDialog.java b/RCaNconstructor/src/main/java/fr/cm/objects/ConstraintNewOrEditDialog.java index 6d4e1abb..2a35edef 100644 --- a/RCaNconstructor/src/main/java/fr/cm/objects/ConstraintNewOrEditDialog.java +++ b/RCaNconstructor/src/main/java/fr/cm/objects/ConstraintNewOrEditDialog.java @@ -5,12 +5,13 @@ */ package fr.cm.objects; -import fr.cm.project.ProjectListsManager; +import fr.cm.Main.ObjectsManager; import fr.cm.Main.Context; import fr.cm.preferences.ColorsAndFormats; import fr.cm.preferences.Strings; import javafx.event.ActionEvent; import javafx.geometry.Insets; +import javafx.geometry.Pos; import javafx.scene.control.*; import javafx.scene.layout.*; import javafx.scene.paint.Color; @@ -27,55 +28,19 @@ public class ConstraintNewOrEditDialog extends Dialog { ConstraintFormula formula ; List