Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
appinventor-sources
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
appinventor-sources
Commits
2cb788cc
Unverified
Commit
2cb788cc
authored
Dec 01, 2020
by
Chetan Patil
Committed by
GitHub
Dec 01, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move to Trash menu item changes to Delete from Trash (#2116)
parent
f2970881
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
93 additions
and
41 deletions
+93
-41
appinventor/appengine/src/com/google/appinventor/client/Ode.java
...ntor/appengine/src/com/google/appinventor/client/Ode.java
+1
-0
appinventor/appengine/src/com/google/appinventor/client/TopPanel.java
...appengine/src/com/google/appinventor/client/TopPanel.java
+1
-0
appinventor/appengine/src/com/google/appinventor/client/TopToolbar.java
...pengine/src/com/google/appinventor/client/TopToolbar.java
+61
-1
appinventor/appengine/src/com/google/appinventor/client/explorer/youngandroid/ProjectToolbar.java
...inventor/client/explorer/youngandroid/ProjectToolbar.java
+16
-40
appinventor/appengine/src/com/google/appinventor/client/widgets/DropDownButton.java
...com/google/appinventor/client/widgets/DropDownButton.java
+14
-0
No files found.
appinventor/appengine/src/com/google/appinventor/client/Ode.java
View file @
2cb788cc
...
...
@@ -423,6 +423,7 @@ public class Ode implements EntryPoint {
*/
public
void
switchToTrash
()
{
Ode
.
getInstance
().
getTopToolbar
().
updateMoveToTrash
(
"Delete From Trash"
);
hideChaff
();
hideTutorials
();
ProjectListBox
.
getProjectListBox
().
loadTrashList
();
...
...
appinventor/appengine/src/com/google/appinventor/client/TopPanel.java
View file @
2cb788cc
...
...
@@ -129,6 +129,7 @@ public class TopPanel extends Composite {
myProjects
.
addClickHandler
(
new
ClickHandler
()
{
@Override
public
void
onClick
(
ClickEvent
event
)
{
Ode
.
getInstance
().
getTopToolbar
().
updateMoveToTrash
(
"Move To Trash"
);
ode
.
switchToProjectsView
();
}
});
...
...
appinventor/appengine/src/com/google/appinventor/client/TopToolbar.java
View file @
2cb788cc
...
...
@@ -67,6 +67,7 @@ import static com.google.appinventor.client.Ode.MESSAGES;
public
class
TopToolbar
extends
Composite
{
private
static
final
String
WIDGET_NAME_NEW
=
"New"
;
private
static
final
String
WIDGET_NAME_DELETE
=
"Delete"
;
private
static
final
String
WIDGET_NAME_DELETE_TRASH
=
"Delete Trash"
;
private
static
final
String
WIDGET_NAME_DOWNLOAD_KEYSTORE
=
"DownloadKeystore"
;
private
static
final
String
WIDGET_NAME_UPLOAD_KEYSTORE
=
"UploadKeystore"
;
private
static
final
String
WIDGET_NAME_DELETE_KEYSTORE
=
"DeleteKeystore"
;
...
...
@@ -183,11 +184,23 @@ public class TopToolbar extends Composite {
initWidget
(
toolbar
);
}
public
void
updateMoveToTrash
(
String
menu_item
){
if
(
menu_item
.
equals
(
"Move To Trash"
)){
fileDropDown
.
setItemVisible
(
MESSAGES
.
trashProjectMenuItem
(),
true
);
fileDropDown
.
setItemVisible
(
MESSAGES
.
deleteFromTrashButton
(),
false
);
}
else
{
fileDropDown
.
setItemVisible
(
MESSAGES
.
trashProjectMenuItem
(),
false
);
fileDropDown
.
setItemVisible
(
MESSAGES
.
deleteFromTrashButton
(),
true
);
}
}
public
void
updateMenuState
(
int
numSelectedProjects
,
int
numProjects
)
{
boolean
allowDelete
=
!
isReadOnly
&&
numSelectedProjects
>
0
;
boolean
allowExport
=
numSelectedProjects
>
0
;
boolean
allowExportAll
=
numProjects
>
0
;
fileDropDown
.
setItemEnabled
(
MESSAGES
.
trashProjectMenuItem
(),
allowDelete
);
fileDropDown
.
setItemEnabled
(
MESSAGES
.
deleteFromTrashButton
(),
allowDelete
);
String
exportProjectLabel
=
numSelectedProjects
>
1
?
MESSAGES
.
exportSelectedProjectsMenuItem
(
numSelectedProjects
)
:
MESSAGES
.
exportProjectMenuItem
();
fileDropDown
.
setItemHtmlById
(
WIDGET_NAME_EXPORTPROJECT
,
exportProjectLabel
);
...
...
@@ -206,6 +219,7 @@ public class TopToolbar extends Composite {
for
(
DropDownItem
i
:
items
)
{
menu
.
addItem
(
i
);
}
fileDropDown
.
setItemVisible
(
MESSAGES
.
deleteFromTrashButton
(),
false
);
}
private
void
createProjectsMenu
()
{
...
...
@@ -222,6 +236,8 @@ public class TopToolbar extends Composite {
new
ImportTemplateAction
()));
fileItems
.
add
(
new
DropDownItem
(
WIDGET_NAME_DELETE
,
MESSAGES
.
deleteProjectButton
(),
new
DeleteAction
()));
fileItems
.
add
(
new
DropDownItem
(
WIDGET_NAME_DELETE_TRASH
,
MESSAGES
.
deleteFromTrashButton
(),
new
DeleteForeverProjectAction
()));
fileItems
.
add
(
null
);
fileItems
.
add
(
new
DropDownItem
(
WIDGET_NAME_SAVE
,
MESSAGES
.
saveMenuItem
(),
new
SaveAction
()));
...
...
@@ -448,6 +464,7 @@ public class TopToolbar extends Composite {
private
static
class
SwitchToProjectAction
implements
Command
{
@Override
public
void
execute
()
{
Ode
.
getInstance
().
getTopToolbar
().
updateMoveToTrash
(
"Move To Trash"
);
Ode
.
getInstance
().
switchToProjectsView
();
Ode
.
getInstance
().
getTopToolbar
().
updateFileMenuButtons
(
0
);
}
...
...
@@ -1078,6 +1095,7 @@ public class TopToolbar extends Composite {
}
if
(
view
==
0
)
{
// We are in the Projects view
fileDropDown
.
setItemEnabled
(
MESSAGES
.
deleteProjectButton
(),
false
);
fileDropDown
.
setItemEnabled
(
MESSAGES
.
deleteFromTrashButton
(),
false
);
fileDropDown
.
setItemEnabled
(
MESSAGES
.
trashProjectMenuItem
(),
ProjectListBox
.
getProjectListBox
().
getProjectList
().
getMyProjectsCount
()
==
0
);
fileDropDown
.
setItemEnabled
(
MESSAGES
.
exportAllProjectsMenuItem
(),
...
...
@@ -1090,7 +1108,7 @@ public class TopToolbar extends Composite {
buildDropDown
.
setItemEnabled
(
MESSAGES
.
downloadToComputerMenuItem
(),
false
);
}
else
{
// We have to be in the Designer/Blocks view
fileDropDown
.
setItemEnabled
(
MESSAGES
.
deleteProjectButton
(),
true
);
fileDropDown
.
setItemEnabled
(
MESSAGES
.
trashProjectMenuItem
(),
fals
e
);
fileDropDown
.
setItemEnabled
(
MESSAGES
.
trashProjectMenuItem
(),
tru
e
);
fileDropDown
.
setItemEnabled
(
MESSAGES
.
exportAllProjectsMenuItem
(),
ProjectListBox
.
getProjectListBox
().
getProjectList
().
getMyProjectsCount
()
>
0
);
fileDropDown
.
setItemEnabledById
(
WIDGET_NAME_EXPORTPROJECT
,
true
);
...
...
@@ -1188,6 +1206,48 @@ public class TopToolbar extends Composite {
}
}
public
static
class
DeleteForeverProjectAction
implements
Command
{
@Override
public
void
execute
()
{
Ode
.
getInstance
().
getEditorManager
().
saveDirtyEditors
(
new
Command
()
{
@Override
public
void
execute
()
{
List
<
Project
>
deletedProjects
=
ProjectListBox
.
getProjectListBox
().
getProjectList
().
getSelectedProjects
();
if
(
deletedProjects
.
size
()
>
0
)
{
// Show one confirmation window for selected projects.
if
(
deleteConfirmation
(
deletedProjects
))
{
for
(
Project
project
:
deletedProjects
)
{
project
.
deleteFromTrash
();
}
}
Ode
.
getInstance
().
switchToTrash
();
}
else
{
// The user can select a project to resolve the
// error.
ErrorReporter
.
reportInfo
(
MESSAGES
.
noProjectSelectedForDelete
());
}
}
});
}
private
boolean
deleteConfirmation
(
List
<
Project
>
projects
)
{
String
message
;
if
(
projects
.
size
()
==
1
)
{
message
=
MESSAGES
.
confirmDeleteSingleProject
(
projects
.
get
(
0
).
getProjectName
());
}
else
{
StringBuilder
sb
=
new
StringBuilder
();
String
separator
=
""
;
for
(
Project
project
:
projects
)
{
sb
.
append
(
separator
).
append
(
project
.
getProjectName
());
separator
=
", "
;
}
String
projectNames
=
sb
.
toString
();
message
=
MESSAGES
.
confirmDeleteManyProjects
(
projectNames
);
}
return
Window
.
confirm
(
message
);
}
}
private
static
native
boolean
isChromeBook
()
/*-{
if (/\bCrOS\b/.test(navigator.userAgent)) {
return true;
...
...
appinventor/appengine/src/com/google/appinventor/client/explorer/youngandroid/ProjectToolbar.java
View file @
2cb788cc
...
...
@@ -9,6 +9,7 @@ package com.google.appinventor.client.explorer.youngandroid;
import
com.google.appinventor.client.ErrorReporter
;
import
com.google.appinventor.client.Ode
;
import
com.google.appinventor.client.OdeAsyncCallback
;
import
com.google.appinventor.client.TopToolbar
;
import
com.google.appinventor.client.boxes.ProjectListBox
;
import
com.google.appinventor.client.explorer.project.Project
;
import
com.google.appinventor.client.widgets.Toolbar
;
...
...
@@ -61,7 +62,7 @@ public class ProjectToolbar extends Toolbar {
addButton
(
new
ToolbarItem
(
WIDGET_NAME_RESTORE
,
MESSAGES
.
restoreProjectButton
(),
new
RestoreProjectAction
()));
addButton
(
new
ToolbarItem
(
WIDGET_NAME_DELETE_FROM_TRASH
,
MESSAGES
.
deleteFromTrashButton
(),
new
DeleteForeverProjectAction
()));
new
TopToolbar
.
DeleteForeverProjectAction
()));
if
(
galleryEnabled
)
{
addButton
(
new
ToolbarItem
(
WIDGET_NAME_LOGINTOGALLERY
,
MESSAGES
.
loginToGallery
(),
new
LoginToGalleryAction
()));
...
...
@@ -175,6 +176,7 @@ public class ProjectToolbar extends Toolbar {
Ode
.
getInstance
().
getEditorManager
().
saveDirtyEditors
(
new
Command
()
{
@Override
public
void
execute
()
{
Ode
.
getInstance
().
getTopToolbar
().
updateMoveToTrash
(
"Move To Trash"
);
Ode
.
getInstance
().
switchToProjectsView
();
}
});
...
...
@@ -253,47 +255,21 @@ public class ProjectToolbar extends Toolbar {
}
}
//Deleting the projects forever from trash list
private
static
class
DeleteForeverProjectAction
implements
Command
{
@Override
public
void
execute
()
{
Ode
.
getInstance
().
getEditorManager
().
saveDirtyEditors
(
new
Command
()
{
@Override
public
void
execute
()
{
List
<
Project
>
deletedProjects
=
ProjectListBox
.
getProjectListBox
().
getProjectList
().
getSelectedProjects
();
if
(
deletedProjects
.
size
()
>
0
)
{
// Show one confirmation window for selected projects.
if
(
deleteConfirmation
(
deletedProjects
))
{
for
(
Project
project
:
deletedProjects
)
{
project
.
deleteFromTrash
();
}
}
Ode
.
getInstance
().
switchToTrash
();
}
else
{
// The user can select a project to resolve the
// error.
ErrorReporter
.
reportInfo
(
MESSAGES
.
noProjectSelectedForDelete
());
}
}
});
}
private
boolean
deleteConfirmation
(
List
<
Project
>
projects
)
{
String
message
;
if
(
projects
.
size
()
==
1
)
{
message
=
MESSAGES
.
confirmDeleteSingleProject
(
projects
.
get
(
0
).
getProjectName
());
}
else
{
StringBuilder
sb
=
new
StringBuilder
();
String
separator
=
""
;
for
(
Project
project
:
projects
)
{
sb
.
append
(
separator
).
append
(
project
.
getProjectName
());
separator
=
", "
;
}
String
projectNames
=
sb
.
toString
();
message
=
MESSAGES
.
confirmDeleteManyProjects
(
projectNames
);
private
boolean
deleteConfirmation
(
List
<
Project
>
projects
)
{
String
message
;
if
(
projects
.
size
()
==
1
)
{
message
=
MESSAGES
.
confirmDeleteSingleProject
(
projects
.
get
(
0
).
getProjectName
());
}
else
{
StringBuilder
sb
=
new
StringBuilder
();
String
separator
=
""
;
for
(
Project
project
:
projects
)
{
sb
.
append
(
separator
).
append
(
project
.
getProjectName
());
separator
=
", "
;
}
return
Window
.
confirm
(
message
);
String
projectNames
=
sb
.
toString
();
message
=
MESSAGES
.
confirmDeleteManyProjects
(
projectNames
);
}
return
Window
.
confirm
(
message
);
}
/**
...
...
appinventor/appengine/src/com/google/appinventor/client/widgets/DropDownButton.java
View file @
2cb788cc
...
...
@@ -241,6 +241,20 @@ public class DropDownButton extends TextButton {
}
}
public
void
setItemVisible
(
String
itemName
,
boolean
enabled
)
{
for
(
MenuItem
item
:
items
)
{
if
(
item
.
getText
().
equals
(
itemName
))
{
if
(
enabled
==
true
)
{
item
.
setVisible
(
true
);
}
else
{
item
.
setVisible
(
false
);
}
break
;
}
}
}
public
void
replaceLastItem
(
DropDownItem
item
)
{
menu
.
removeItem
(
items
.
get
(
items
.
size
()-
1
));
items
.
remove
(
items
.
size
()-
1
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment