Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interleave editor creation and file loading #3171

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4897,6 +4897,10 @@ String newerVersionComponentException(String componentType, int srcCompVersion,
@Description("")
String createWelcomeDialogButton();

@DefaultMessage("Loading screen {0} ({1} seconds estimated remaining)...")
@Description("")
String loadingScreen(String screenName, int secondsRemaining);

@DefaultMessage("Do Not Show Again")
@Description("")
String doNotShow();
Expand Down Expand Up @@ -4992,6 +4996,18 @@ String newerVersionComponentException(String componentType, int srcCompVersion,
@Description("")
String corruptionDialogText();

@DefaultMessage("Project {0} is missing Screen1. Refusing to continue loading the project.")
@Description("")
String screen1MissingText(String projectName);

@DefaultMessage("Project {0} is missing a designer file for screen {1}.")
@Description("")
String screenMissingDesigner(String projectName, String formName);

@DefaultMessage("Project {0} is missing a blocks file for screen {1}.")
@Description("")
String screenMissingBlocks(String projectName, String formName);

@DefaultMessage("<p><b>We detected errors while reading in your project</b></p>" +
"<p>To protect your project from damage, we have ended this session. You may close this " +
"window.</p>")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
// -*- mode: java; c-basic-offset: 2; -*-
// Copyright 2009-2011 Google, All Rights reserved
// Copyright 2011-2012 MIT, All rights reserved
// Copyright 2011-2019 MIT, All rights reserved
// Released under the Apache License, Version 2.0
// http://www.apache.org/licenses/LICENSE-2.0

package com.google.appinventor.client.editor;

import com.google.appinventor.client.Ode;
import com.google.appinventor.client.editor.simple.palette.DropTargetProvider;
import com.google.appinventor.shared.rpc.project.FileNode;
import com.google.appinventor.shared.rpc.project.ProjectRootNode;
import com.google.gwt.core.client.Callback;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
// -*- mode: java; c-basic-offset: 2; -*-
// Copyright 2009-2011 Google, All Rights reserved
// Copyright 2011-2012 MIT, All rights reserved
// Copyright 2011-2019 MIT, All rights reserved
// Released under the Apache License, Version 2.0
// http://www.apache.org/licenses/LICENSE-2.0

package com.google.appinventor.client.editor.youngandroid;

import com.google.appinventor.client.ErrorReporter;
import com.google.appinventor.client.Ode;
import static com.google.appinventor.client.Ode.MESSAGES;

import com.google.appinventor.client.editor.FileEditor;
import com.google.appinventor.client.editor.ProjectEditor;
import com.google.appinventor.client.editor.youngandroid.actions.SwitchScreenAction;
Expand All @@ -29,8 +31,6 @@
import java.util.Map;
import java.util.logging.Logger;

import static com.google.appinventor.client.Ode.MESSAGES;

/**
* The design toolbar houses command buttons in the Young Android Design
* tab (for the UI designer (a.k.a, Form Editor) and Blocks Editor).
Expand Down Expand Up @@ -70,7 +70,7 @@ public static class DesignProject {
public DesignProject(String name, long projectId) {
this.name = name;
this.projectId = projectId;
screens = Maps.newHashMap();
screens = Maps.newTreeMap();
// Screen1 is initial screen by default
currentScreen = YoungAndroidSourceNode.SCREEN1_FORM_NAME;
// Let BlocklyPanel know which screen to send Yail for
Expand Down Expand Up @@ -245,16 +245,10 @@ private boolean switchToProject(long projectId, String projectName) {
return true;
}
pushedScreens.clear(); // Effectively switching applications; clear stack of screens.
clearDropDownMenu(WIDGET_NAME_SCREENS_DROPDOWN);
LOG.info("DesignToolbar: switching to existing project " + projectName + " with id "
+ projectId);
currentProject = project;

// TODO(sharon): add screens to drop-down menu in the right order
for (Screen screen : currentProject.screens.values()) {
addDropDownButtonItem(WIDGET_NAME_SCREENS_DROPDOWN, new DropDownItem(screen.screenName,
screen.screenName, new SwitchScreenAction(projectId, screen.screenName)));
}
sortScreenList(projectId);
projectNameLabel.setText(projectName);
YaBlocksEditor.resendAssetsAndExtensions(); // Send assets for active project
} else {
Expand All @@ -267,6 +261,17 @@ private boolean switchToProject(long projectId, String projectName) {
return true;
}

public void sortScreenList(long projectId) {
if (currentProject != null) { // We can only sort screens if we have a project.
clearDropDownMenu(WIDGET_NAME_SCREENS_DROPDOWN);
// TODO(sharon): add screens to drop-down menu in the right order
for (Screen screen : currentProject.screens.values()) {
addDropDownButtonItem(WIDGET_NAME_SCREENS_DROPDOWN, new DropDownItem(screen.screenName,
screen.screenName, new SwitchScreenAction(projectId, screen.screenName)));
}
}
}

/*
* Add a screen name to the drop-down for the project with id projectId.
* name is the form name, formEditor is the file editor for the form UI,
Expand All @@ -282,8 +287,7 @@ public void addScreen(long projectId, String name, FileEditor formEditor,
DesignProject project = projectMap.get(projectId);
if (project.addScreen(name, formEditor, blocksEditor)) {
if (currentProject == project) {
addDropDownButtonItem(WIDGET_NAME_SCREENS_DROPDOWN, new DropDownItem(name,
name, new SwitchScreenAction(projectId, name)));
sortScreenList(projectId);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ public void loadFile(final Command afterFileLoaded) {
final String fileId = getFileId();
OdeAsyncCallback<ChecksumedLoadFile> callback = new OdeAsyncCallback<ChecksumedLoadFile>(MESSAGES.loadError()) {
@Override
public void onSuccess(ChecksumedLoadFile result) {
public void onSuccess(final ChecksumedLoadFile result) {
String contents;
try {
contents = result.getContent();
Expand All @@ -229,6 +229,11 @@ public void execute() {
} catch(IllegalArgumentException e) {
return;
}
try {
result.setContent(fileContentHolder.getFileContent());
} catch (ChecksumedFileException e) {
LOG.warning("ChecksumedFileException in YaFormEditor");
}
if (afterFileLoaded != null) {
afterFileLoaded.execute();
}
Expand Down
Loading