Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
kernel
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
af3
kernel
Commits
3ad6dbe0
Commit
3ad6dbe0
authored
8 years ago
by
Vincent Aravantinos
Browse files
Options
Downloads
Patches
Plain Diff
GREEN
refs 2490
parent
d7a74242
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/storage/eclipse/ModelContext.java
+26
-27
26 additions, 27 deletions
...tooling/kernel/internal/storage/eclipse/ModelContext.java
with
26 additions
and
27 deletions
org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/storage/eclipse/ModelContext.java
+
26
−
27
View file @
3ad6dbe0
...
...
@@ -69,7 +69,7 @@ import org.fortiss.tooling.kernel.utils.UniqueIDUtils;
* @author hummel
* @author $Author$
* @version $Rev$
* @ConQAT.Rating
YELLOW
Hash:
88D7CDE2835FBBC5D6D158B4B75D8AD9
* @ConQAT.Rating
GREEN
Hash:
D2DD5730F29EF8C125811F8C1B4B8D7F
*/
class
ModelContext
implements
ITopLevelElement
,
CommandStackListener
{
...
...
@@ -115,15 +115,16 @@ class ModelContext implements ITopLevelElement, CommandStackListener {
editingDomain
=
TransactionalEditingDomain
.
Factory
.
INSTANCE
.
createEditingDomain
();
rset
=
editingDomain
.
getResourceSet
();
resource
=
getResourceSet
().
createResource
(
URI
.
createPlatformResourceURI
(
file
.
getFullPath
().
toString
(),
true
));
URI
uri
=
URI
.
createPlatformResourceURI
(
file
.
getFullPath
().
toString
(),
true
);
resource
=
getResourceSet
().
createResource
(
uri
);
resource
.
load
(
buildOptionsMap
());
unknownFeatures
=
resource
instanceof
XMIResource
?
((
XMIResource
)
resource
)
.
getEObjectToExtensionMap
()
:
new
HashMap
<
EObject
,
AnyType
>();
if
(
resource
instanceof
XMIResource
)
{
unknownFeatures
=
((
XMIResource
)
resource
).
getEObjectToExtensionMap
();
}
else
{
unknownFeatures
=
new
HashMap
<
EObject
,
AnyType
>();
}
transactionalCommandStack
=
new
AutoUndoCommandStack
(
editingDomain
);
transactionalCommandStack
.
addCommandStackListener
(
this
);
...
...
@@ -137,15 +138,15 @@ class ModelContext implements ITopLevelElement, CommandStackListener {
int
eventType
=
notification
.
getEventType
();
Object
feature
=
notification
.
getFeature
();
if
(
eventType
==
Notification
.
SET
&&
feature
==
FortissToolingKernelPackage
.
Literals
.
IID_LABELED__ID
)
{
boolean
featureOk
=
feature
==
FortissToolingKernelPackage
.
Literals
.
IID_LABELED__ID
;
if
(
eventType
==
Notification
.
SET
&&
featureOk
)
{
// Update XMI IDs when Kernel IDs are changed by calls of IdLabled.setId()
Object
notifier
=
notification
.
getNotifier
();
if
(
resource
instanceof
XMIResource
&&
notifier
instanceof
EObject
)
{
((
XMIResource
)
resource
).
setID
((
EObject
)
notifier
,
notification
.
getNewStringValue
()
);
String
newVal
=
notification
.
getNewStringValue
();
((
XMIResource
)
resource
).
setID
((
EObject
)
notifier
,
newVal
);
}
}
}
...
...
@@ -157,11 +158,7 @@ class ModelContext implements ITopLevelElement, CommandStackListener {
/** {@inheritDoc} */
@Override
public
String
getId
(
EObject
modelElement
)
{
if
(
resource
instanceof
XMIResource
)
{
return
((
XMIResource
)
resource
).
getID
(
modelElement
);
}
return
null
;
return
resource
instanceof
XMIResource
?
((
XMIResource
)
resource
).
getID
(
modelElement
)
:
null
;
}
/** {@inheritDoc} */
...
...
@@ -235,9 +232,10 @@ class ModelContext implements ITopLevelElement, CommandStackListener {
}
if
(
hadDuplicates
)
{
error
(
ToolingKernelActivator
.
getDefault
(),
"Duplicate IDs have been removed from \""
+
resource
.
getURI
().
lastSegment
()
+
"\". Please report this incident since it could result in corrupted model files."
);
String
msg
=
"Duplicate IDs have been removed from \""
;
msg
+=
resource
.
getURI
().
lastSegment
()
+
"\". "
;
msg
+=
"Please report this incident since it could result in corrupted model files."
;
error
(
ToolingKernelActivator
.
getDefault
(),
msg
);
}
}
...
...
@@ -308,8 +306,8 @@ class ModelContext implements ITopLevelElement, CommandStackListener {
try
{
// Step 3: write file content to disk (for resource managed by kernel)
file
.
setContents
(
new
ByteArrayInputStream
(
bytes
.
toByteArray
())
,
false
,
true
,
monitor
);
ByteArrayInputStream
stream
=
new
ByteArrayInputStream
(
bytes
.
toByteArray
())
;
file
.
setContents
(
stream
,
false
,
true
,
monitor
);
}
catch
(
CoreException
e
)
{
if
(
exception
==
null
)
{
exception
=
e
;
...
...
@@ -452,8 +450,8 @@ class ModelContext implements ITopLevelElement, CommandStackListener {
});
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
error
(
ToolingKernelActivator
.
getDefault
(),
"Problem with synchronizing library and model!"
,
e
);
String
msg
=
"Problem with synchronizing library and model!"
;
error
(
ToolingKernelActivator
.
getDefault
(),
msg
,
e
);
}
}
...
...
@@ -533,8 +531,8 @@ class ModelContext implements ITopLevelElement, CommandStackListener {
try
{
getFile
().
delete
(
false
,
null
);
}
catch
(
CoreException
e
)
{
error
(
ToolingKernelActivator
.
getDefault
(),
"Error during deletion of model file "
+
getFile
().
getName
()
+
"."
);
String
msg
=
"Error during deletion of model file "
+
getFile
().
getName
()
+
"."
;
error
(
ToolingKernelActivator
.
getDefault
(),
msg
);
rval
=
false
;
}
...
...
@@ -543,8 +541,9 @@ class ModelContext implements ITopLevelElement, CommandStackListener {
try
{
currentResource
.
delete
(
null
);
}
catch
(
IOException
e
)
{
error
(
ToolingKernelActivator
.
getDefault
(),
"Error during deletion of model file "
+
currentResource
.
getURI
().
lastSegment
()
+
"."
);
String
msg
=
"Error during deletion of model file "
;
msg
+=
currentResource
.
getURI
().
lastSegment
()
+
"."
;
error
(
ToolingKernelActivator
.
getDefault
(),
msg
);
rval
=
false
;
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment