Commit 9048ac1d authored by Evan W. Patton's avatar Evan W. Patton Committed by Jeffrey Schiller

Fix delete assets not working in nb183a

Change-Id: I7aef0856d098b490d36d36d410dc9763ccb5a034
parent 923cc0d0
// -*- mode: java; c-basic-offset: 2; -*- // -*- mode: java; c-basic-offset: 2; -*-
// Copyright 2009-2011 Google, All Rights reserved // Copyright 2009-2011 Google, All Rights reserved
// Copyright 2011-2019 MIT, All rights reserved // Copyright 2011-2020 MIT, All rights reserved
// Released under the Apache License, Version 2.0 // Released under the Apache License, Version 2.0
// http://www.apache.org/licenses/LICENSE-2.0 // http://www.apache.org/licenses/LICENSE-2.0
...@@ -117,7 +117,7 @@ public interface OdeMessages extends Messages, AutogeneratedOdeMessages { ...@@ -117,7 +117,7 @@ public interface OdeMessages extends Messages, AutogeneratedOdeMessages {
@DefaultMessage("Checkpoint ...") @DefaultMessage("Checkpoint ...")
@Description("Label of the button for checkpoint") @Description("Label of the button for checkpoint")
String checkpointButton(); String checkpointButton();
@DefaultMessage("Create checkpoint before deleting") @DefaultMessage("Create checkpoint before deleting")
@Description("Label of the CheckBox for checkpoint") @Description("Label of the CheckBox for checkpoint")
String checkBoxButton(); String checkBoxButton();
...@@ -143,7 +143,7 @@ public interface OdeMessages extends Messages, AutogeneratedOdeMessages { ...@@ -143,7 +143,7 @@ public interface OdeMessages extends Messages, AutogeneratedOdeMessages {
"There is no undo.\nAre you sure you want to delete {0}?") "There is no undo.\nAre you sure you want to delete {0}?")
@Description("Confirmation query for removing a screen") @Description("Confirmation query for removing a screen")
String reallyDeleteForm(String formName); String reallyDeleteForm(String formName);
@DefaultMessage("Warning: You are deleting a screen.\nThis operation cannot be undone.\n" + @DefaultMessage("Warning: You are deleting a screen.\nThis operation cannot be undone.\n" +
"Please type the name of the screen {0} into the box below to confirm you really want to do this.") "Please type the name of the screen {0} into the box below to confirm you really want to do this.")
@Description("Confirmation query for removing a screen") @Description("Confirmation query for removing a screen")
......
// -*- mode: java; c-basic-offset: 2; -*- // -*- mode: java; c-basic-offset: 2; -*-
// Copyright 2009-2011 Google, All Rights reserved // Copyright 2020 MIT, All rights reserved
// Copyright 2011-2012 MIT, All rights reserved
// Released under the Apache License, Version 2.0 // Released under the Apache License, Version 2.0
// http://www.apache.org/licenses/LICENSE-2.0 // http://www.apache.org/licenses/LICENSE-2.0
package com.google.appinventor.client.explorer.commands; package com.google.appinventor.client.explorer.commands;
import com.google.appinventor.client.Ode;
import static com.google.appinventor.client.Ode.MESSAGES; import static com.google.appinventor.client.Ode.MESSAGES;
import com.google.appinventor.client.Ode;
import com.google.appinventor.client.OdeAsyncCallback; import com.google.appinventor.client.OdeAsyncCallback;
import com.google.appinventor.client.explorer.project.Project; import com.google.appinventor.client.explorer.project.Project;
import com.google.appinventor.client.explorer.project.ProjectComparators;
import com.google.appinventor.shared.rpc.project.youngandroid.YoungAndroidFormNode;
import com.google.appinventor.shared.rpc.project.youngandroid.YoungAndroidSourceNode;
import com.google.appinventor.client.widgets.LabeledTextBox;
import com.google.appinventor.client.youngandroid.TextValidators;
import com.google.appinventor.shared.rpc.project.ProjectNode; import com.google.appinventor.shared.rpc.project.ProjectNode;
import com.google.appinventor.shared.rpc.project.ProjectRootNode; import com.google.appinventor.shared.rpc.project.ProjectRootNode;
import com.google.appinventor.shared.rpc.project.UserProject; import com.google.appinventor.shared.rpc.project.UserProject;
import com.google.appinventor.client.widgets.Validator;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.KeyCodes;
import com.google.gwt.event.dom.client.KeyUpEvent;
import com.google.gwt.event.dom.client.KeyUpHandler;
import com.google.gwt.i18n.client.DateTimeFormat;
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.DeferredCommand;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.Grid;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.ScrollPanel;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;
import java.util.Collections;
import java.util.Date;
import java.util.List; import java.util.List;
/** /**
...@@ -46,34 +21,35 @@ import java.util.List; ...@@ -46,34 +21,35 @@ import java.util.List;
* @author lizlooney@google.com (Liz Looney) * @author lizlooney@google.com (Liz Looney)
*/ */
public final class SaveScreenCheckpointCommand extends ChainableCommand { public final class SaveScreenCheckpointCommand extends ChainableCommand {
private boolean checkpoint; private final boolean checkpoint;
/** /**
* Creates a new command for copying a project. * Creates a new command for copying a project.
* *
* @param checkpoint whether the copy is a checkpoint * @param checkpoint whether the copy is a checkpoint
*/ */
public SaveScreenCheckpointCommand(boolean checkpoint) { public SaveScreenCheckpointCommand(boolean checkpoint, ChainableCommand next) {
super(next);
this.checkpoint = checkpoint; this.checkpoint = checkpoint;
} }
@Override @Override
public boolean willCallExecuteNextCommand() { public boolean willCallExecuteNextCommand() {
return false; // Is there a way to do this for this command? return true;
} }
@Override @Override
public void execute(final ProjectNode node) { public void execute(final ProjectNode node) {
handleOkClick(node.getProjectRoot()); handleOkClick(node.getProjectRoot());
} }
private void handleOkClick(ProjectRootNode oldProjectNode) { private void handleOkClick(ProjectRootNode oldProjectNode) {
String oldName = oldProjectNode.getName()+"_Screen"; String oldName = oldProjectNode.getName() + "_Screen";
String defaultNewName; String defaultNewName;
if (checkpoint) { if (checkpoint) {
String prefix = MESSAGES.defaultCheckpointProjectName(oldName, ""); String prefix = MESSAGES.defaultCheckpointProjectName(oldName, "");
List<Project> checkpointProjects = List<Project> checkpointProjects =
Ode.getInstance().getProjectManager().getProjects(prefix); Ode.getInstance().getProjectManager().getProjects(prefix);
String nextSuffix; String nextSuffix;
if (checkpointProjects.isEmpty()) { if (checkpointProjects.isEmpty()) {
...@@ -81,37 +57,39 @@ public final class SaveScreenCheckpointCommand extends ChainableCommand { ...@@ -81,37 +57,39 @@ public final class SaveScreenCheckpointCommand extends ChainableCommand {
} else { } else {
// Find the highest number in the checkpoint projects' names. // Find the highest number in the checkpoint projects' names.
int highestNumber = 0; int highestNumber = 0;
int prefixLength = prefix.length(); int prefixLength = prefix.length();
for (Project checkpointProject : checkpointProjects) { for (Project checkpointProject : checkpointProjects) {
String checkpointName = checkpointProject.getProjectName(); String checkpointName = checkpointProject.getProjectName();
try { try {
highestNumber = Math.max(highestNumber, highestNumber = Math.max(highestNumber,
Integer.parseInt(checkpointName.substring(prefixLength))); Integer.parseInt(checkpointName.substring(prefixLength)));
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
continue; continue;
} }
} }
nextSuffix = Integer.toString(highestNumber + 1); nextSuffix = Integer.toString(highestNumber + 1);
} }
defaultNewName = MESSAGES.defaultCheckpointProjectName(oldName, nextSuffix); defaultNewName = MESSAGES.defaultCheckpointProjectName(oldName, nextSuffix);
} else { } else {
// Save As // Save As
defaultNewName = MESSAGES.defaultSaveAsProjectName(oldName); defaultNewName = MESSAGES.defaultSaveAsProjectName(oldName);
} }
copyProjectAction(oldProjectNode, defaultNewName); copyProjectAction(oldProjectNode, defaultNewName);
} }
protected void copyProjectAction(ProjectRootNode oldProjectNode, String newName) {
protected void copyProjectAction(final ProjectRootNode oldProjectNode, String newName) {
final Ode ode = Ode.getInstance(); final Ode ode = Ode.getInstance();
OdeAsyncCallback<UserProject> callback = new OdeAsyncCallback<UserProject>( OdeAsyncCallback<UserProject> callback = new OdeAsyncCallback<UserProject>(
// failure message // failure message
MESSAGES.copyProjectError()) { MESSAGES.copyProjectError()) {
@Override @Override
public void onSuccess(UserProject newProjectInfo) { public void onSuccess(UserProject newProjectInfo) {
// Update project list // Update project list
Project newProject = ode.getProjectManager().addProject(newProjectInfo); Project newProject = ode.getProjectManager().addProject(newProjectInfo);
if (!checkpoint) { if (!checkpoint) {
ode.openYoungAndroidProjectInDesigner(newProject); ode.openYoungAndroidProjectInDesigner(newProject);
} }
executeNextCommand(oldProjectNode);
} }
}; };
// Create new copy on the backend // Create new copy on the backend
......
// -*- mode: java; c-basic-offset: 2; -*- // -*- mode: java; c-basic-offset: 2; -*-
// Copyright 2009-2011 Google, All Rights reserved // Copyright 2009-2011 Google, All Rights reserved
// Copyright 2011-2018 MIT, All rights reserved // Copyright 2011-2020 MIT, All rights reserved
// Released under the Apache License, Version 2.0 // Released under the Apache License, Version 2.0
// http://www.apache.org/licenses/LICENSE-2.0 // http://www.apache.org/licenses/LICENSE-2.0
...@@ -155,9 +155,9 @@ public class LabeledTextBox extends Composite { ...@@ -155,9 +155,9 @@ public class LabeledTextBox extends Composite {
public void setErrorMessage(String errorMessage) { public void setErrorMessage(String errorMessage) {
this.errorMessage = errorMessage; this.errorMessage = errorMessage;
} }
public void setColor(String color) { public void setColor(String color) {
textbox.getElement().getStyle().setBorderColor(color); textbox.getElement().getStyle().setBorderColor(color);
} }
/** /**
......
...@@ -748,6 +748,12 @@ body { ...@@ -748,6 +748,12 @@ body {
text-shadow: none; text-shadow: none;
} }
.destructive-action[disabled],
.destructive-action[disabled]:hover {
background: #faa;
color: #888;
}
.ya-Toolbar .ode-TextButton { .ya-Toolbar .ode-TextButton {
font-size: 11px; font-size: 11px;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment