/** * initialize the main screen * * @param screen */ public void setScreen(final MainScreen screen) { this._screen = screen; addActions(); /* * wire panels */ // Tables panel DatasourcesPresenter ds = new DatasourcesPresenter(_eventBus); ds.setSources(_model.getSources()); ds.setTables(_model.getTables()); ds.setPanel(screen.getDatasourcesPanel()); // Schema panel SchemaPresenter sp = new SchemaPresenter(_eventBus); sp.setPanels(screen.getDimensionPanel(), screen.getMeauresPanel()); // ToolsLibrary panel ToolsPresenter tp = new ToolsPresenter(_eventBus); tp.setPanel(screen.getToolsPanel()); tp.setFactories(Arrays.asList(ToolsLibrary.factories)); // set up the main workspace Workspace workspace = new Workspace(); screen.setWorkspace(workspace); WorkspacePresenter presenter = new WorkspacePresenter(_eventBus, _model); presenter.setView(workspace); // do something? // selectWorkspace(); }
private void save() { // If the save directory does not exist, create it File saveDir = new File(SAVE_DIR); if (!saveDir.exists()) saveDir.mkdir(); // The save file File saveFile = new File(SAVE_FILE); // Create the root memento XMLMemento memento = XMLMemento.createWriteRoot("root"); // Save the data sources for (CyclistDatasource source : _model.getSources()) { source.save(memento.createChild("CyclistDatasource")); } // Save the data tables for (Table table : _model.getTables()) { table.save(memento.createChild("Table")); } try { memento.save(new PrintWriter(saveFile)); } catch (IOException e) { e.printStackTrace(); } }
// Load saved properties private void load() { // Check if the save file exists File saveFile = new File(SAVE_FILE); // If we have a save file, read it in if (saveFile.exists()) { Reader reader; try { reader = new FileReader(saveFile); try { // Create the root memento XMLMemento memento = XMLMemento.createReadRoot(reader); // Read in the data sources IMemento[] sources = memento.getChildren("CyclistDatasource"); for (IMemento source : sources) { CyclistDatasource datasource = new CyclistDatasource(); datasource.restore(source); _model.getSources().add(datasource); } // Read in the tables IMemento[] tables = memento.getChildren("Table"); // System.out.println("tables " + tables.length); for (IMemento table : tables) { Table tbl = new Table(); tbl.restore(table, _model.getSources()); _model.getTables().add(tbl); } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } catch (FileNotFoundException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } }