Hi,
I'm trying to create a set of attribute class from an handler command.
I'm able to create semantics attributes in the selected class but not in the current class diagram editor.
The code is:
/*
* (non-Javadoc)
*
* @see org.eclipse.gmf.runtime.emf.commands.core.command.
* AbstractTransactionalCommand
* #doExecuteWithResult(org.eclipse.core.runtime.IProgressMonitor ,
* org.eclipse.core.runtime.IAdaptable)
*/
@Override
protected void doExecute() {
if (context instanceof Class) {
// IMultiDiagramEditor multiDiagramEditor =
// EditorUtils.getMultiDiagramEditor();
// if (multiDiagramEditor != null) {
// IEditorPart activeEditor =
// multiDiagramEditor.getActiveEditor();
// if (activeEditor instanceof DiagramEditor) {
// DiagramEditor diagramEditor = (DiagramEditor) activeEditor;
// diagramEditor.getDiagramEditDomain()
// Diagram
// DiagramEditPartsUtil.getEObjectViews(context)
// DiagramEditPart topEditPart =
// diagramEditor.getDiagramEditPart();
// if (topEditPart != null) {
// DiagramHelper.refresh(topEditPart, true);
// }
// }
// }
}
Class createUserType = (Class) context.getModel().getMember(
"Create User");
Class createTimeType = (Class) context.getModel().getMember(
"Create Timestamp");
Class lastUpdateUserType = (Class) context.getModel().getMember(
"Last Update User");
Class lastUpdateTimeType = (Class) context.getModel().getMember(
"Last Update Timestamp");
Property p = context.createOwnedAttribute("createUser",
createUserType);
Stereotype attributeStereotype = p
.getApplicableStereotype("MiceGenProfile::Attribute");
p.applyStereotype(attributeStereotype);
context.createOwnedAttribute("createTimestamp", createTimeType)
.applyStereotype(attributeStereotype);
context.createOwnedAttribute("lastUpdateUser", lastUpdateUserType)
.applyStereotype(attributeStereotype);
context.createOwnedAttribute("lastUpdateTimestamp",
lastUpdateTimeType).applyStereotype(attributeStereotype);
org.eclipse.papyrus.uml.diagram.common.util.DiagramEditPartsUtil.getEObjectViews(context);
}
How to add those just created attributes in the class attributes compartment?
Thanks in advance.