Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1121)

Unified Diff: dart/site/try/src/ui.dart

Issue 214513005: Add CompilationUnit abstraction for tracking "project files". (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address Kasper's comments Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « dart/site/try/src/leap.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/site/try/src/ui.dart
diff --git a/dart/site/try/src/ui.dart b/dart/site/try/src/ui.dart
index 8898f7a88ae7457dbe26cd854310d1873af75099..d8a93a648bd6c70589efdd67e5794df4134b8fed 100644
--- a/dart/site/try/src/ui.dart
+++ b/dart/site/try/src/ui.dart
@@ -11,8 +11,6 @@ import 'dart:async' show
Timer,
scheduleMicrotask;
-import 'dart:convert' show JSON;
-
import 'cache.dart' show
onLoad,
updateCacheStatus;
@@ -39,6 +37,12 @@ import 'user_option.dart';
import 'messages.dart' show messages;
+import 'compilation_unit.dart' show
+ CompilationUnit;
+
+import 'compilation.dart' show
+ currentSource;
+
// TODO(ahe): Make internal to buildUI once all interactions have been moved to
// the manager.
InteractionManager interaction;
@@ -92,6 +96,8 @@ void onCodeChange(Event event) {
buildUI() {
interaction = new InteractionManager();
+ CompilationUnit.onChanged.listen(interaction.onCompilationUnitChanged);
+
window.localStorage['currentSample'] = '$currentSample';
buildCode(interaction);
@@ -208,7 +214,7 @@ buildUI() {
mainEditorPane, childList: true, characterData: true, subtree: true);
scheduleMicrotask(() {
- mainEditorPane.appendText(window.localStorage['currentSource']);
+ mainEditorPane.appendText(currentSource);
});
// You cannot install event handlers on window.applicationCache
@@ -229,27 +235,21 @@ buildCode(InteractionManager interaction) {
var htmlGroup = new OptGroupElement()..label = 'HTML';
var benchmarkGroup = new OptGroupElement()..label = 'Benchmarks';
- new Future(() => HttpRequest.getString('project?list').then(
- (String response) {
+ interaction.projectFileNames().then((List<String> names) {
OptionElement none = new OptionElement()
..appendText('--')
..disabled = true;
- codePicker.append(none);
- for (String projectFile in JSON.decode(response)) {
- codePicker.append(buildTab(projectFile, projectFile, (_) {
- mainEditorPane.contentEditable = 'false';
- HttpRequest.getString('project/$projectFile').then((String text) {
- mainEditorPane
- ..contentEditable = 'true'
- ..nodes.clear();
- observer.takeRecords();
- mainEditorPane.appendText(text);
- });
+ codePicker
+ ..append(none)
+ ..style.visibility = 'visible'
+ ..selectedIndex = 0;
+
+ for (String name in names) {
+ codePicker.append(buildTab(name, name, (event) {
+ interaction.onProjectFileSelected(name);
}));
}
- codePicker.style.visibility = 'visible';
- codePicker.selectedIndex = 0;
- })).catchError((error) {
+ }).catchError((error) {
codePicker.style.visibility = 'visible';
print(error);
OptionElement none = new OptionElement()
« no previous file with comments | « dart/site/try/src/leap.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698