Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
bonita
bonita-studio
Commits
7f38ff0c
Commit
7f38ff0c
authored
Oct 29, 2018
by
Romain Bioteau
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(delete) support multiple delete
parent
4f43124e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
30 deletions
+46
-30
bundles/plugins/org.bonitasoft.studio.application/src/org/bonitasoft/studio/application/handler/DeleteHandler.java
.../bonitasoft/studio/application/handler/DeleteHandler.java
+45
-29
bundles/plugins/org.bonitasoft.studio.la/messages.properties
bundles/plugins/org.bonitasoft.studio.la/messages.properties
+1
-1
No files found.
bundles/plugins/org.bonitasoft.studio.application/src/org/bonitasoft/studio/application/handler/DeleteHandler.java
View file @
7f38ff0c
...
...
@@ -14,6 +14,8 @@
*/
package
org.bonitasoft.studio.application.handler
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Objects
;
import
org.bonitasoft.studio.common.jface.FileActionDialog
;
...
...
@@ -31,6 +33,8 @@ import org.eclipse.core.runtime.CoreException;
import
org.eclipse.core.runtime.IAdaptable
;
import
org.eclipse.jface.viewers.ISelection
;
import
org.eclipse.jface.viewers.IStructuredSelection
;
import
org.eclipse.osgi.util.NLS
;
import
org.eclipse.ui.internal.ide.IDEWorkbenchMessages
;
public
class
DeleteHandler
extends
AbstractHandler
{
...
...
@@ -38,30 +42,36 @@ public class DeleteHandler extends AbstractHandler {
@Override
public
Object
execute
(
ExecutionEvent
event
)
throws
ExecutionException
{
ISelection
selection
=
selectionFinder
.
getSelectionInExplorer
();
IResource
resource
=
((
IAdaptable
)
((
IStructuredSelection
)
selection
).
getFirstElement
()).
getAdapter
(
IResource
.
class
);
IRepositoryFileStore
fileStore
=
RepositoryManager
.
getInstance
().
getCurrentRepository
()
.
getFileStore
(
resource
);
if
(
FileActionDialog
.
confirmDeletionQuestion
(
resource
.
getName
()))
{
if
(
fileStore
!=
null
)
{
fileStore
.
delete
();
}
else
{
try
{
resource
.
delete
(
false
,
null
);
AbstractFileStore
.
refreshExplorerView
();
}
catch
(
CoreException
e
)
{
BonitaStudioLog
.
error
(
e
);
IStructuredSelection
selection
=
(
IStructuredSelection
)
selectionFinder
.
getSelectionInExplorer
();
List
<
IResource
>
selectedResources
=
new
ArrayList
<>();
for
(
Object
sel
:
selection
.
toList
())
{
selectedResources
.
add
(((
IAdaptable
)
sel
).
getAdapter
(
IResource
.
class
));
}
Repository
currentRepository
=
RepositoryManager
.
getInstance
().
getCurrentRepository
();
if
((
selectedResources
.
size
()
==
1
&&
FileActionDialog
.
confirmDeletionQuestion
(
selectedResources
.
get
(
0
).
getName
()))
||
FileActionDialog
.
confirmDeletionQuestionWithCustomMessage
(
NLS
.
bind
(
IDEWorkbenchMessages
.
DeleteResourceAction_confirmN
,
selectedResources
.
size
())))
{
for
(
IResource
res
:
selectedResources
)
{
IRepositoryFileStore
fileStore
=
currentRepository
.
getFileStore
(
res
);
if
(
fileStore
!=
null
)
{
fileStore
.
delete
();
}
else
{
try
{
res
.
delete
(
false
,
null
);
}
catch
(
CoreException
e
)
{
BonitaStudioLog
.
error
(
e
);
}
}
}
AbstractFileStore
.
refreshExplorerView
();
}
return
null
;
}
/*
* (non-Javadoc)
* @see org.eclipse.core.commands.AbstractHandler#isEnabled()
*/
@Override
public
boolean
isEnabled
()
{
ISelection
selection
=
selectionFinder
.
getSelectionInExplorer
();
...
...
@@ -72,21 +82,27 @@ public class DeleteHandler extends AbstractHandler {
}
protected
boolean
selectionCanBeDeleted
(
IStructuredSelection
selection
,
Repository
currentRepository
)
{
if
(
selection
.
size
()
==
1
&&
selection
.
getFirstElement
()
instanceof
IAdaptable
)
{
IAdaptable
sel
=
(
IAdaptable
)
selection
.
getFirstElement
();
IResource
adapter
=
sel
.
getAdapter
(
IResource
.
class
);
if
(
adapter
!=
null
)
{
if
(
Objects
.
equals
(
currentRepository
.
getProject
(),
adapter
))
{
for
(
Object
sel
:
selection
.
toList
())
{
if
(
sel
instanceof
IAdaptable
)
{
IResource
adapter
=
((
IAdaptable
)
sel
).
getAdapter
(
IResource
.
class
);
if
(
adapter
!=
null
)
{
if
(
Objects
.
equals
(
currentRepository
.
getProject
(),
adapter
))
{
return
false
;
}
IRepositoryFileStore
fileStore
=
currentRepository
.
getFileStore
(
adapter
);
if
(
fileStore
!=
null
&&
!
fileStore
.
canBeDeleted
())
{
return
false
;
}
if
(
currentRepository
.
getRepositoryStore
(
adapter
)
==
null
)
{
continue
;
}
return
false
;
}
IRepositoryFileStore
fileStore
=
currentRepository
.
getFileStore
(
adapter
);
if
(
fileStore
!=
null
)
{
return
fileStore
.
canBeDeleted
();
}
return
currentRepository
.
getRepositoryStore
(
adapter
)
==
null
;
}
else
{
return
false
;
}
}
return
false
;
return
selection
.
size
()
>
0
;
}
}
bundles/plugins/org.bonitasoft.studio.la/messages.properties
View file @
7f38ff0c
...
...
@@ -20,7 +20,7 @@ exportDoneMessage=Application file has been exported successfully to '%s'.
importApplicationDescriptorLabel
=
Select an application file
importApplicationDescriptor
=
Import application file
browse
=
Browse...
importConflictWarning
=
A
n
file with the same name already exists
importConflictWarning
=
A file with the same name already exists
importLabel
=
Import
notAnApplicationError
=
Invalid application file
importApplicationDescriptorDesc
=
Select a valid application file to import.
\n
You can export application file from the Portal or from the Studio.
...
...
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