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
f6923e3a
Commit
f6923e3a
authored
Oct 29, 2018
by
Romain Bioteau
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix rename operation
parent
ed39ca54
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
42 additions
and
60 deletions
+42
-60
bundles/plugins/org.bonitasoft.studio.properties/src/org/bonitasoft/studio/properties/operation/RenameDiagramOperation.java
...t/studio/properties/operation/RenameDiagramOperation.java
+15
-14
bundles/plugins/org.bonitasoft.studio.validation.common/src/org/bonitasoft/studio/validation/common/operation/BatchValidationOperation.java
...validation/common/operation/BatchValidationOperation.java
+26
-40
bundles/plugins/org.bonitasoft.studio.validation.common/src/org/bonitasoft/studio/validation/common/operation/FindDiagramRunnable.java
...udio/validation/common/operation/FindDiagramRunnable.java
+0
-3
bundles/plugins/org.bonitasoft.studio.validation/src/org/bonitasoft/studio/validation/BatchValidationHandler.java
.../bonitasoft/studio/validation/BatchValidationHandler.java
+1
-3
No files found.
bundles/plugins/org.bonitasoft.studio.properties/src/org/bonitasoft/studio/properties/operation/RenameDiagramOperation.java
View file @
f6923e3a
...
...
@@ -41,7 +41,6 @@ import org.eclipse.emf.transaction.TransactionalEditingDomain;
import
org.eclipse.emf.transaction.util.TransactionUtil
;
import
org.eclipse.jface.operation.IRunnableWithProgress
;
public
class
RenameDiagramOperation
implements
IRunnableWithProgress
{
private
MainProcess
diagram
;
...
...
@@ -62,24 +61,27 @@ public class RenameDiagramOperation implements IRunnableWithProgress {
final
DiagramRepositoryStore
diagramStore
=
RepositoryManager
.
getInstance
()
.
getRepositoryStore
(
DiagramRepositoryStore
.
class
);
DiagramFileStore
diagramFileStore
=
diagramStore
.
getDiagram
(
oldName
,
oldVersion
);
IFile
resource
=
diagramFileStore
.
getResource
();
try
{
resource
.
move
(
Path
.
fromOSString
(
NamingUtils
.
toDiagramFilename
(
diagramName
,
diagramVersion
)),
true
,
monitor
);
}
catch
(
CoreException
e
)
{
throw
new
InvocationTargetException
(
e
);
}
try
{
resource
.
getParent
().
refreshLocal
(
IResource
.
DEPTH_ONE
,
monitor
);
}
catch
(
CoreException
e
)
{
throw
new
InvocationTargetException
(
e
);
if
(!(
oldName
.
equals
(
diagramName
)
&&
oldVersion
.
equals
(
diagramVersion
)))
{
IFile
resource
=
diagramFileStore
.
getResource
();
try
{
resource
.
move
(
Path
.
fromOSString
(
NamingUtils
.
toDiagramFilename
(
diagramName
,
diagramVersion
)),
true
,
monitor
);
}
catch
(
CoreException
e
)
{
throw
new
InvocationTargetException
(
e
);
}
try
{
resource
.
getParent
().
refreshLocal
(
IResource
.
DEPTH_ONE
,
monitor
);
}
catch
(
CoreException
e
)
{
throw
new
InvocationTargetException
(
e
);
}
}
diagramFileStore
=
diagramStore
.
getChild
(
NamingUtils
.
toDiagramFilename
(
diagramName
,
diagramVersion
));
diagram
=
diagramFileStore
.
getContent
();
TransactionalEditingDomain
editingDomain
=
TransactionUtil
.
getEditingDomain
(
diagram
);
CompoundCommand
compoundCommand
=
new
CompoundCommand
();
changeProcessNameAndVersion
(
diagram
,
compoundCommand
,
diagramName
,
diagramVersion
,
editingDomain
);
if
(!(
oldName
.
equals
(
diagramName
)
&&
oldVersion
.
equals
(
diagramVersion
)))
{
changeProcessNameAndVersion
(
diagram
,
compoundCommand
,
diagramName
,
diagramVersion
,
editingDomain
);
}
for
(
final
ProcessesNameVersion
pnv
:
pools
)
{
final
AbstractProcess
fromPool
=
pnv
.
getAbstractProcess
();
final
String
fromPoolName
=
fromPool
.
getName
();
...
...
@@ -111,7 +113,6 @@ public class RenameDiagramOperation implements IRunnableWithProgress {
newProcessVersion
));
}
public
void
setDiagramToDuplicate
(
final
MainProcess
diagram
)
{
this
.
diagram
=
diagram
;
}
...
...
bundles/plugins/org.bonitasoft.studio.validation.common/src/org/bonitasoft/studio/validation/common/operation/BatchValidationOperation.java
View file @
f6923e3a
...
...
@@ -60,52 +60,39 @@ import org.eclipse.ui.actions.WorkspaceModifyOperation;
*/
public
class
BatchValidationOperation
extends
WorkspaceModifyOperation
{
private
final
Map
<
Diagram
,
DiagramEditPart
>
diagramsToDiagramEditPart
=
new
HashMap
<
Diagram
,
DiagramEditPart
>();
private
final
List
<
IFile
>
fileProcessed
=
new
ArrayList
<
IFile
>();
//Avoid duplicate
private
final
Map
<
Diagram
,
DiagramEditPart
>
diagramsToDiagramEditPart
=
new
HashMap
<>();
private
final
List
<
IFile
>
fileProcessed
=
new
ArrayList
<>();
//Avoid duplicate
private
final
OffscreenEditPartFactory
offscreenEditPartFactory
;
private
final
ValidationMarkerProvider
validationMarkerProvider
;
public
BatchValidationOperation
(
final
OffscreenEditPartFactory
offscreenEditPartFactory
,
final
ValidationMarkerProvider
validationMarkerProvider
)
{
public
BatchValidationOperation
(
final
OffscreenEditPartFactory
offscreenEditPartFactory
,
final
ValidationMarkerProvider
validationMarkerProvider
)
{
this
.
offscreenEditPartFactory
=
offscreenEditPartFactory
;
this
.
validationMarkerProvider
=
validationMarkerProvider
;
}
/*
* (non-Javadoc)
* @see org.eclipse.ui.actions.WorkspaceModifyOperation#execute(org.eclipse.core.runtime.IProgressMonitor)
*/
@Override
protected
void
execute
(
final
IProgressMonitor
monitor
)
throws
CoreException
,
InvocationTargetException
,
InterruptedException
{
protected
void
execute
(
final
IProgressMonitor
monitor
)
throws
CoreException
,
InvocationTargetException
,
InterruptedException
{
Assert
.
isLegal
(!
diagramsToDiagramEditPart
.
isEmpty
());
buildEditPart
();
validationMarkerProvider
.
clearMarkers
(
diagramsToDiagramEditPart
);
for
(
final
Entry
<
Diagram
,
DiagramEditPart
>
entry
:
diagramsToDiagramEditPart
.
entrySet
())
{
final
DiagramEditPart
diagramEp
=
entry
.
getValue
();
final
Diagram
diagram
=
entry
.
getKey
();
if
(
diagramEp
!=
null
)
{
if
(!
monitor
.
isCanceled
())
{
monitor
.
setTaskName
(
Messages
.
bind
(
Messages
.
validatingProcess
,
((
MainProcess
)
diagramEp
.
resolveSemanticElement
()).
getName
(),
((
MainProcess
)
diagramEp
.
resolveSemanticElement
()).
getVersion
()));
final
TransactionalEditingDomain
txDomain
=
TransactionUtil
.
getEditingDomain
(
diagram
);
runWithConstraints
(
txDomain
,
new
Runnable
()
{
@Override
public
void
run
()
{
validate
(
diagramEp
,
diagram
,
monitor
);
}
});
monitor
.
worked
(
1
);
}
if
(
diagramEp
!=
null
&&
!
monitor
.
isCanceled
())
{
monitor
.
setTaskName
(
Messages
.
bind
(
Messages
.
validatingProcess
,
((
MainProcess
)
diagramEp
.
resolveSemanticElement
()).
getName
(),
((
MainProcess
)
diagramEp
.
resolveSemanticElement
()).
getVersion
()));
final
TransactionalEditingDomain
txDomain
=
TransactionUtil
.
getEditingDomain
(
diagram
);
runWithConstraints
(
txDomain
,
()
->
validate
(
diagramEp
,
diagram
,
monitor
));
monitor
.
worked
(
1
);
}
}
offscreenEditPartFactory
.
dispose
();
}
private
void
buildEditPart
()
{
for
(
final
Diagram
diagram
:
diagramsToDiagramEditPart
.
keySet
())
{
diagramsToDiagramEditPart
.
put
(
diagram
,
getDiagramEditPart
(
diagram
));
...
...
@@ -114,14 +101,11 @@ public class BatchValidationOperation extends WorkspaceModifyOperation {
}
protected
void
validate
(
final
DiagramEditPart
diagramEditPart
,
final
View
view
,
final
IProgressMonitor
monitor
)
{
final
IFile
target
=
view
.
eResource
()
!=
null
?
WorkspaceSynchronizer
.
getFile
(
view
.
eResource
())
:
null
;
final
IFile
target
=
view
.
eResource
()
!=
null
?
WorkspaceSynchronizer
.
getFile
(
view
.
eResource
())
:
null
;
final
Diagnostic
diagnostic
=
validationMarkerProvider
.
runEMFValidator
(
view
);
validationMarkerProvider
.
createMarkers
(
target
,
diagnostic
,
diagramEditPart
);
final
IBatchValidator
validator
=
(
IBatchValidator
)
ModelValidationService
.
getInstance
().
newValidator
(
EvaluationMode
.
BATCH
);
final
IBatchValidator
validator
=
(
IBatchValidator
)
ModelValidationService
.
getInstance
().
newValidator
(
EvaluationMode
.
BATCH
);
validator
.
setIncludeLiveConstraints
(
true
);
if
(
view
.
isSetElement
()
&&
view
.
getElement
()
!=
null
&&
view
.
getElement
().
eResource
()
!=
null
)
{
final
IStatus
status
=
validator
.
validate
(
view
.
getElement
(),
monitor
);
...
...
@@ -142,11 +126,11 @@ public class BatchValidationOperation extends WorkspaceModifyOperation {
if
(
activePage
!=
null
)
{
for
(
final
IEditorReference
ep
:
activePage
.
getEditorReferences
())
{
final
IEditorPart
editor
=
ep
.
getEditor
(
false
);
if
(
editor
instanceof
DiagramEditor
)
{
if
(((
DiagramEditor
)
editor
).
getDiagram
().
equals
(
d
)
&&
((
DiagramEditor
)
editor
).
getDiagramEditPart
()
!=
null
)
{
if
(
editor
instanceof
DiagramEditor
&&
((
DiagramEditor
)
editor
).
getDiagram
().
equals
(
d
)
&&
((
DiagramEditor
)
editor
).
getDiagramEditPart
()
!=
null
)
{
return
((
DiagramEditor
)
editor
).
getDiagramEditPart
();
}
}
}
}
return
null
;
...
...
@@ -196,14 +180,17 @@ public class BatchValidationOperation extends WorkspaceModifyOperation {
String
fileName
=
target
.
getName
();
fileName
=
fileName
.
substring
(
0
,
fileName
.
lastIndexOf
(
"."
));
addStatusForMarkerType
(
target
,
result
,
fileName
,
ProcessMarkerNavigationProvider
.
MARKER_TYPE
);
addStatusForMarkerType
(
target
,
result
,
fileName
,
org
.
bonitasoft
.
studio
.
model
.
process
.
diagram
.
providers
.
ProcessMarkerNavigationProvider
.
MARKER_TYPE
);
addStatusForMarkerType
(
target
,
result
,
fileName
,
org
.
bonitasoft
.
studio
.
model
.
process
.
diagram
.
providers
.
ProcessMarkerNavigationProvider
.
MARKER_TYPE
);
fileProcessed
.
add
(
target
);
}
private
void
addStatusForMarkerType
(
final
IFile
target
,
final
MultiStatus
result
,
final
String
fileName
,
final
String
markerType
)
throws
CoreException
{
private
void
addStatusForMarkerType
(
final
IFile
target
,
final
MultiStatus
result
,
final
String
fileName
,
final
String
markerType
)
throws
CoreException
{
for
(
final
IMarker
m
:
target
.
findMarkers
(
markerType
,
true
,
IResource
.
DEPTH_ZERO
))
{
final
int
severity
=
(
Integer
)
m
.
getAttribute
(
IMarker
.
SEVERITY
);
if
(
severity
==
IMarker
.
SEVERITY_WARNING
||
severity
==
IMarker
.
SEVERITY_INFO
||
severity
==
IMarker
.
SEVERITY_ERROR
)
{
if
(
severity
==
IMarker
.
SEVERITY_WARNING
||
severity
==
IMarker
.
SEVERITY_INFO
||
severity
==
IMarker
.
SEVERITY_ERROR
)
{
final
String
fullMessage
=
computeMarkerMessage
(
fileName
,
m
);
if
(!
statusExists
(
result
,
fullMessage
))
{
result
.
add
(
new
Status
(
toStatusSeverity
(
severity
),
ValidationCommonPlugin
.
PLUGIN_ID
,
fullMessage
));
...
...
@@ -215,8 +202,7 @@ public class BatchValidationOperation extends WorkspaceModifyOperation {
private
String
computeMarkerMessage
(
final
String
fileName
,
final
IMarker
m
)
throws
CoreException
{
final
String
location
=
(
String
)
m
.
getAttribute
(
IMarker
.
LOCATION
);
final
String
message
=
(
String
)
m
.
getAttribute
(
IMarker
.
MESSAGE
);
final
String
fullMessage
=
fileName
+
":"
+
location
+
" : "
+
message
;
return
fullMessage
;
return
fileName
+
":"
+
location
+
" : "
+
message
;
}
private
int
toStatusSeverity
(
final
int
markerSeverity
)
{
...
...
bundles/plugins/org.bonitasoft.studio.validation.common/src/org/bonitasoft/studio/validation/common/operation/FindDiagramRunnable.java
View file @
f6923e3a
...
...
@@ -19,9 +19,6 @@ import org.eclipse.emf.ecore.EObject;
import
org.eclipse.emf.ecore.resource.Resource
;
import
org.eclipse.gmf.runtime.notation.Diagram
;
/**
* @author Romain Bioteau
*/
public
class
FindDiagramRunnable
implements
Runnable
{
private
final
BatchValidationOperation
validateOperation
;
...
...
bundles/plugins/org.bonitasoft.studio.validation/src/org/bonitasoft/studio/validation/BatchValidationHandler.java
View file @
f6923e3a
...
...
@@ -169,9 +169,7 @@ public class BatchValidationHandler extends AbstractHandler {
}
protected
String
[]
toFileNames
(
String
files
)
{
files
=
files
.
substring
(
1
,
files
.
length
()
-
1
);
final
String
[]
allFiles
=
files
.
split
(
","
);
return
allFiles
;
return
files
.
trim
().
split
(
","
);
}
private
void
showReport
(
final
BatchValidationOperation
validateOperation
)
{
...
...
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