--- modules/damieng/graphical_editor/daxe/lib/daxe.dart 2015/05/11 15:17:54 1.2 +++ modules/damieng/graphical_editor/daxe/lib/daxe.dart 2015/08/07 21:06:57 1.5 @@ -49,7 +49,6 @@ part 'src/daxe_exception.dart'; part 'src/config.dart'; part 'src/daxe_node.dart'; part 'src/daxe_attr.dart'; -//part 'src/file_open_dialog.dart'; part 'src/find_dialog.dart'; part 'src/help_dialog.dart'; part 'src/insert_panel.dart'; @@ -59,11 +58,13 @@ part 'src/menu.dart'; part 'src/menubar.dart'; part 'src/menu_item.dart'; part 'src/node_factory.dart'; +part 'src/file_chooser.dart'; part 'src/position.dart'; part 'src/node_offset_position.dart'; part 'src/left_offset_position.dart'; part 'src/right_offset_position.dart'; part 'src/source_window.dart'; +part 'src/symbol_dialog.dart'; part 'src/tag.dart'; part 'src/toolbar.dart'; part 'src/toolbar_item.dart'; @@ -91,43 +92,59 @@ void main() { NodeFactory.addCoreDisplayTypes(); Strings.load().then((bool b) { - doc = new DaxeDocument(); - page = new WebPage(); - - // check parameters for a config and file to open - String file = null; - String config = null; - String saveURL = null; - h.Location location = h.window.location; - String search = location.search; - if (search.startsWith('?')) - search = search.substring(1); - List parameters = search.split('&'); - for (String param in parameters) { - List lparam = param.split('='); - if (lparam.length != 2) - continue; - if (lparam[0] == 'config') - config = lparam[1]; - else if (lparam[0] == 'file') - file = Uri.decodeComponent(lparam[1]); - else if (lparam[0] == 'save') - saveURL = lparam[1]; - } - if (saveURL != null) - doc.saveURL = saveURL; - if (config != null && file != null) - page.openDocument(file, config); - else if (config != null) - page.newDocument(config); - else - h.window.alert(Strings.get('daxe.missing_config')); + initDaxe(); }).catchError((e) { h.document.body.appendText('Error when loading the strings in LocalStrings_en.properties.'); }); } /** + * This Future can be used to initialize Daxe and customize the user interface afterwards. + * The display types and the strings have to be loaded before this method is called. + * In the Daxe application, the results of the Future are not used. + */ +Future initDaxe() { + Completer completer = new Completer(); + + // check parameters for a config and file to open + String file = null; + String config = null; + String saveURL = null; // URL for saving file, will trigger the display of the save menu + bool application = false; // Desktop application (open and quit menus) + h.Location location = h.window.location; + String search = location.search; + if (search.startsWith('?')) + search = search.substring(1); + List parameters = search.split('&'); + for (String param in parameters) { + List lparam = param.split('='); + if (lparam.length != 2) + continue; + if (lparam[0] == 'config') + config = lparam[1]; + else if (lparam[0] == 'file') + file = Uri.decodeComponent(lparam[1]); + else if (lparam[0] == 'save') + saveURL = lparam[1]; + else if (lparam[0] == 'application' && lparam[1] == 'true') + application = true; + } + doc = new DaxeDocument(); + page = new WebPage(application:application); + if (saveURL != null) + doc.saveURL = saveURL; + if (config != null && file != null) + page.openDocument(file, config).then((v) => completer.complete()); + else if (config != null) + page.newDocument(config).then((v) => completer.complete()); + else { + h.window.alert(Strings.get('daxe.missing_config')); + completer.completeError(Strings.get('daxe.missing_config')); + } + return(completer.future); +} + +/** * Adds a custom display type. Two constructors are required to define the display type: * * * one to create a new node, with the element reference in the schema as a parameter;