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 {
...
@@ -423,6 +423,7 @@ public class Ode implements EntryPoint {
*/
*/
public
void
switchToTrash
()
{
public
void
switchToTrash
()
{
Ode
.
getInstance
().
getTopToolbar
().
updateMoveToTrash
(
"Delete From Trash"
);
hideChaff
();
hideChaff
();
hideTutorials
();
hideTutorials
();
ProjectListBox
.
getProjectListBox
().
loadTrashList
();
ProjectListBox
.
getProjectListBox
().
loadTrashList
();
...
...
appinventor/appengine/src/com/google/appinventor/client/TopPanel.java
View file @
2cb788cc
...
@@ -129,6 +129,7 @@ public class TopPanel extends Composite {
...
@@ -129,6 +129,7 @@ public class TopPanel extends Composite {
myProjects
.
addClickHandler
(
new
ClickHandler
()
{
myProjects
.
addClickHandler
(
new
ClickHandler
()
{
@Override
@Override
public
void
onClick
(
ClickEvent
event
)
{
public
void
onClick
(
ClickEvent
event
)
{
Ode
.
getInstance
().
getTopToolbar
().
updateMoveToTrash
(
"Move To Trash"
);
ode
.
switchToProjectsView
();
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;
...
@@ -67,6 +67,7 @@ import static com.google.appinventor.client.Ode.MESSAGES;
public
class
TopToolbar
extends
Composite
{
public
class
TopToolbar
extends
Composite
{
private
static
final
String
WIDGET_NAME_NEW
=
"New"
;
private
static
final
String
WIDGET_NAME_NEW
=
"New"
;
private
static
final
String
WIDGET_NAME_DELETE
=
"Delete"
;
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_DOWNLOAD_KEYSTORE
=
"DownloadKeystore"
;
private
static
final
String
WIDGET_NAME_UPLOAD_KEYSTORE
=
"UploadKeystore"
;
private
static
final
String
WIDGET_NAME_UPLOAD_KEYSTORE
=
"UploadKeystore"
;
private
static
final
String
WIDGET_NAME_DELETE_KEYSTORE
=
"DeleteKeystore"
;
private
static
final
String
WIDGET_NAME_DELETE_KEYSTORE
=
"DeleteKeystore"
;
...
@@ -183,11 +184,23 @@ public class TopToolbar extends Composite {
...
@@ -183,11 +184,23 @@ public class TopToolbar extends Composite {
initWidget
(
toolbar
);
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
)
{
public
void
updateMenuState
(
int
numSelectedProjects
,
int
numProjects
)
{
boolean
allowDelete
=
!
isReadOnly
&&
numSelectedProjects
>
0
;
boolean
allowDelete
=
!
isReadOnly
&&
numSelectedProjects
>
0
;
boolean
allowExport
=
numSelectedProjects
>
0
;
boolean
allowExport
=
numSelectedProjects
>
0
;
boolean
allowExportAll
=
numProjects
>
0
;
boolean
allowExportAll
=
numProjects
>
0
;
fileDropDown
.
setItemEnabled
(
MESSAGES
.
trashProjectMenuItem
(),
allowDelete
);
fileDropDown
.
setItemEnabled
(
MESSAGES
.
trashProjectMenuItem
(),
allowDelete
);
fileDropDown
.
setItemEnabled
(
MESSAGES
.
deleteFromTrashButton
(),
allowDelete
);
String
exportProjectLabel
=
numSelectedProjects
>
1
?
String
exportProjectLabel
=
numSelectedProjects
>
1
?
MESSAGES
.
exportSelectedProjectsMenuItem
(
numSelectedProjects
)
:
MESSAGES
.
exportProjectMenuItem
();
MESSAGES
.
exportSelectedProjectsMenuItem
(
numSelectedProjects
)
:
MESSAGES
.
exportProjectMenuItem
();
fileDropDown
.
setItemHtmlById
(
WIDGET_NAME_EXPORTPROJECT
,
exportProjectLabel
);
fileDropDown
.
setItemHtmlById
(
WIDGET_NAME_EXPORTPROJECT
,
exportProjectLabel
);
...
@@ -206,6 +219,7 @@ public class TopToolbar extends Composite {
...
@@ -206,6 +219,7 @@ public class TopToolbar extends Composite {
for
(
DropDownItem
i
:
items
)
{
for
(
DropDownItem
i
:
items
)
{
menu
.
addItem
(
i
);
menu
.
addItem
(
i
);
}
}
fileDropDown
.
setItemVisible
(
MESSAGES
.
deleteFromTrashButton
(),
false
);
}
}
private
void
createProjectsMenu
()
{
private
void
createProjectsMenu
()
{
...
@@ -222,6 +236,8 @@ public class TopToolbar extends Composite {
...
@@ -222,6 +236,8 @@ public class TopToolbar extends Composite {
new
ImportTemplateAction
()));
new
ImportTemplateAction
()));
fileItems
.
add
(
new
DropDownItem
(
WIDGET_NAME_DELETE
,
MESSAGES
.
deleteProjectButton
(),
fileItems
.
add
(
new
DropDownItem
(
WIDGET_NAME_DELETE
,
MESSAGES
.
deleteProjectButton
(),
new
DeleteAction
()));
new
DeleteAction
()));
fileItems
.
add
(
new
DropDownItem
(
WIDGET_NAME_DELETE_TRASH
,
MESSAGES
.
deleteFromTrashButton
(),
new
DeleteForeverProjectAction
()));
fileItems
.
add
(
null
);
fileItems
.
add
(
null
);
fileItems
.
add
(
new
DropDownItem
(
WIDGET_NAME_SAVE
,
MESSAGES
.
saveMenuItem
(),
fileItems
.
add
(
new
DropDownItem
(
WIDGET_NAME_SAVE
,
MESSAGES
.
saveMenuItem
(),
new
SaveAction
()));
new
SaveAction
()));
...
@@ -448,6 +464,7 @@ public class TopToolbar extends Composite {
...
@@ -448,6 +464,7 @@ public class TopToolbar extends Composite {
private
static
class
SwitchToProjectAction
implements
Command
{
private
static
class
SwitchToProjectAction
implements
Command
{
@Override
@Override
public
void
execute
()
{
public
void
execute
()
{
Ode
.
getInstance
().
getTopToolbar
().
updateMoveToTrash
(
"Move To Trash"
);
Ode
.
getInstance
().
switchToProjectsView
();
Ode
.
getInstance
().
switchToProjectsView
();
Ode
.
getInstance
().
getTopToolbar
().
updateFileMenuButtons
(
0
);
Ode
.
getInstance
().
getTopToolbar
().
updateFileMenuButtons
(
0
);
}
}
...
@@ -1078,6 +1095,7 @@ public class TopToolbar extends Composite {
...
@@ -1078,6 +1095,7 @@ public class TopToolbar extends Composite {
}
}
if
(
view
==
0
)
{
// We are in the Projects view
if
(
view
==
0
)
{
// We are in the Projects view
fileDropDown
.
setItemEnabled
(
MESSAGES
.
deleteProjectButton
(),
false
);
fileDropDown
.
setItemEnabled
(
MESSAGES
.
deleteProjectButton
(),
false
);
fileDropDown
.
setItemEnabled
(
MESSAGES
.
deleteFromTrashButton
(),
false
);
fileDropDown
.
setItemEnabled
(
MESSAGES
.
trashProjectMenuItem
(),
fileDropDown
.
setItemEnabled
(
MESSAGES
.
trashProjectMenuItem
(),
ProjectListBox
.
getProjectListBox
().
getProjectList
().
getMyProjectsCount
()
==
0
);
ProjectListBox
.
getProjectListBox
().
getProjectList
().
getMyProjectsCount
()
==
0
);
fileDropDown
.
setItemEnabled
(
MESSAGES
.
exportAllProjectsMenuItem
(),
fileDropDown
.
setItemEnabled
(
MESSAGES
.
exportAllProjectsMenuItem
(),
...
@@ -1090,7 +1108,7 @@ public class TopToolbar extends Composite {
...
@@ -1090,7 +1108,7 @@ public class TopToolbar extends Composite {
buildDropDown
.
setItemEnabled
(
MESSAGES
.
downloadToComputerMenuItem
(),
false
);
buildDropDown
.
setItemEnabled
(
MESSAGES
.
downloadToComputerMenuItem
(),
false
);
}
else
{
// We have to be in the Designer/Blocks view
}
else
{
// We have to be in the Designer/Blocks view
fileDropDown
.
setItemEnabled
(
MESSAGES
.
deleteProjectButton
(),
true
);
fileDropDown
.
setItemEnabled
(
MESSAGES
.
deleteProjectButton
(),
true
);
fileDropDown
.
setItemEnabled
(
MESSAGES
.
trashProjectMenuItem
(),
fals
e
);
fileDropDown
.
setItemEnabled
(
MESSAGES
.
trashProjectMenuItem
(),
tru
e
);
fileDropDown
.
setItemEnabled
(
MESSAGES
.
exportAllProjectsMenuItem
(),
fileDropDown
.
setItemEnabled
(
MESSAGES
.
exportAllProjectsMenuItem
(),
ProjectListBox
.
getProjectListBox
().
getProjectList
().
getMyProjectsCount
()
>
0
);
ProjectListBox
.
getProjectListBox
().
getProjectList
().
getMyProjectsCount
()
>
0
);
fileDropDown
.
setItemEnabledById
(
WIDGET_NAME_EXPORTPROJECT
,
true
);
fileDropDown
.
setItemEnabledById
(
WIDGET_NAME_EXPORTPROJECT
,
true
);
...
@@ -1188,6 +1206,48 @@ public class TopToolbar extends Composite {
...
@@ -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
()
/*-{
private
static
native
boolean
isChromeBook
()
/*-{
if (/\bCrOS\b/.test(navigator.userAgent)) {
if (/\bCrOS\b/.test(navigator.userAgent)) {
return true;
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;
...
@@ -9,6 +9,7 @@ package com.google.appinventor.client.explorer.youngandroid;
import
com.google.appinventor.client.ErrorReporter
;
import
com.google.appinventor.client.ErrorReporter
;
import
com.google.appinventor.client.Ode
;
import
com.google.appinventor.client.Ode
;
import
com.google.appinventor.client.OdeAsyncCallback
;
import
com.google.appinventor.client.OdeAsyncCallback
;
import
com.google.appinventor.client.TopToolbar
;
import
com.google.appinventor.client.boxes.ProjectListBox
;
import
com.google.appinventor.client.boxes.ProjectListBox
;
import
com.google.appinventor.client.explorer.project.Project
;
import
com.google.appinventor.client.explorer.project.Project
;
import
com.google.appinventor.client.widgets.Toolbar
;
import
com.google.appinventor.client.widgets.Toolbar
;
...
@@ -61,7 +62,7 @@ public class ProjectToolbar extends Toolbar {
...
@@ -61,7 +62,7 @@ public class ProjectToolbar extends Toolbar {
addButton
(
new
ToolbarItem
(
WIDGET_NAME_RESTORE
,
MESSAGES
.
restoreProjectButton
(),
addButton
(
new
ToolbarItem
(
WIDGET_NAME_RESTORE
,
MESSAGES
.
restoreProjectButton
(),
new
RestoreProjectAction
()));
new
RestoreProjectAction
()));
addButton
(
new
ToolbarItem
(
WIDGET_NAME_DELETE_FROM_TRASH
,
MESSAGES
.
deleteFromTrashButton
(),
addButton
(
new
ToolbarItem
(
WIDGET_NAME_DELETE_FROM_TRASH
,
MESSAGES
.
deleteFromTrashButton
(),
new
DeleteForeverProjectAction
()));
new
TopToolbar
.
DeleteForeverProjectAction
()));
if
(
galleryEnabled
)
{
if
(
galleryEnabled
)
{
addButton
(
new
ToolbarItem
(
WIDGET_NAME_LOGINTOGALLERY
,
MESSAGES
.
loginToGallery
(),
addButton
(
new
ToolbarItem
(
WIDGET_NAME_LOGINTOGALLERY
,
MESSAGES
.
loginToGallery
(),
new
LoginToGalleryAction
()));
new
LoginToGalleryAction
()));
...
@@ -175,6 +176,7 @@ public class ProjectToolbar extends Toolbar {
...
@@ -175,6 +176,7 @@ public class ProjectToolbar extends Toolbar {
Ode
.
getInstance
().
getEditorManager
().
saveDirtyEditors
(
new
Command
()
{
Ode
.
getInstance
().
getEditorManager
().
saveDirtyEditors
(
new
Command
()
{
@Override
@Override
public
void
execute
()
{
public
void
execute
()
{
Ode
.
getInstance
().
getTopToolbar
().
updateMoveToTrash
(
"Move To Trash"
);
Ode
.
getInstance
().
switchToProjectsView
();
Ode
.
getInstance
().
switchToProjectsView
();
}
}
});
});
...
@@ -253,47 +255,21 @@ public class ProjectToolbar extends Toolbar {
...
@@ -253,47 +255,21 @@ public class ProjectToolbar extends Toolbar {
}
}
}
}
//Deleting the projects forever from trash list
private
boolean
deleteConfirmation
(
List
<
Project
>
projects
)
{
private
static
class
DeleteForeverProjectAction
implements
Command
{
String
message
;
@Override
if
(
projects
.
size
()
==
1
)
{
public
void
execute
()
{
message
=
MESSAGES
.
confirmDeleteSingleProject
(
projects
.
get
(
0
).
getProjectName
());
Ode
.
getInstance
().
getEditorManager
().
saveDirtyEditors
(
new
Command
()
{
}
else
{
@Override
StringBuilder
sb
=
new
StringBuilder
();
public
void
execute
()
{
String
separator
=
""
;
List
<
Project
>
deletedProjects
=
ProjectListBox
.
getProjectListBox
().
getProjectList
().
getSelectedProjects
();
for
(
Project
project
:
projects
)
{
if
(
deletedProjects
.
size
()
>
0
)
{
sb
.
append
(
separator
).
append
(
project
.
getProjectName
());
// Show one confirmation window for selected projects.
separator
=
", "
;
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
);
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 {
...
@@ -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
)
{
public
void
replaceLastItem
(
DropDownItem
item
)
{
menu
.
removeItem
(
items
.
get
(
items
.
size
()-
1
));
menu
.
removeItem
(
items
.
get
(
items
.
size
()-
1
));
items
.
remove
(
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