Skip to content

Commit

Permalink
fix diagram wizard
Browse files Browse the repository at this point in the history
fix diagram wizard
  • Loading branch information
etiennebrosse committed Jan 14, 2021
1 parent 466908a commit bb61022
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import org.modelio.api.module.context.IModuleContext;
import org.modelio.api.module.contributor.AbstractWizardContributor;
import org.modelio.api.module.contributor.ElementDescriptor;
import org.modelio.api.module.contributor.diagramcreation.IDiagramWizardContributor;
import org.modelio.metamodel.diagrams.AbstractDiagram;
import org.modelio.metamodel.diagrams.StaticDiagram;
import org.modelio.metamodel.mmextensions.infrastructure.ExtensionNotFoundException;
Expand All @@ -32,37 +31,37 @@
/**
* @author ebrosse
*/
public class AttackTreeDiagramWizard extends AbstractWizardContributor implements IDiagramWizardContributor {
public class AttackTreeDiagramWizard extends AbstractWizardContributor {
@Override
public AbstractDiagram actionPerformed(ModelElement owner, String diagramName, String description) {
IModuleContext moduleContext = AttackTreeDesignerModule.getInstance().getModuleContext();
IModelingSession session = moduleContext.getModelingSession();
String name = Messages.getString ("Ui.Command.AttackTreeDiagramExplorerCommand.Label");
StaticDiagram diagram = null;

try( ITransaction transaction = session.createTransaction(Messages.getString ("Info.Session.Create", "AttackTree Diagram"))){

diagram = session.getModel().createStaticDiagram(name, owner, IAttackTreeDesignerPeerModule.MODULE_NAME, AttackTreeStereotypes.ATTACK_TREE_DIAGRAM);

if (diagram != null) {
IDiagramService ds = moduleContext.getModelioServices().getDiagramService();
try( IDiagramHandle handler = ds.getDiagramHandle(diagram);){
IDiagramDG dg = handler.getDiagramNode();

for (IStyleHandle style : ds.listStyles()){
if (style.getName().equals("sysml")){
dg.setStyle(style);
break;
}
}

handler.save();
handler.close();
}

moduleContext.getModelioServices().getEditionService().openEditor(diagram);
}

transaction.commit ();
} catch (ExtensionNotFoundException e) {
moduleContext.getLogService().error(e);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@

AttackTreePaletteGroup.AttackTree = Attack Tree
AttackTreePaletteGroup.Freedrawing = Free Drawing
AttackTreePaletteGroup.NotesAndConstraints = Notes and Constraints

Info.Session.Create = Create {0}
Info.Session.UpdateModel = Update Model
Info.Session.Delete = Delete {0}

Ui.Command.AttackTreeDiagramExplorerCommand.Label = Attack Tree Diagram
Ui.Command.AttackTreeDiagramExplorerCommand.Name = Attack Tree Diagram
Ui.Property.Name.Name = Name
Ui.Property.Reference.Name = Reference
Ui.Property.TypeCondition.Name = Type


Ui.Dialog.SelectXMLFileImport.Label = Select an XML file to import
Ui.Dialog.SelectDirectoryImport.Label = Select a directory to import
Ui.Dialog.SelectDirectoryExport.Label = Select a directory to export
Ui.Dialog.NoSelectedElement.Label = No selected element!
Ui.Dialog.NoSelectedElementAdd.Message = No element has been selected to add custom tag
Ui.Dialog.EmptyName.Label = Empty name field!
Ui.Dialog.EmptyName.Message = The property name field is empty
Ui.Dialog.EmptyValue.Label = Empty value field!
Ui.Dialog.EmptyValue.Message = The property value field is empty
Ui.Dialog.AddCustomTag.Label = Add a new Custom Tag property
Ui.Dialog.CustomTagName.Label = Provide the name and the value of your property
Ui.Field.CustomTagName.Label = Property name:
Ui.Field.CustomTagValue.Label = Property value:
Ui.Button.Cancel.Label = Cancel
Ui.Button.OK.Label = OK
Ui.Dialog.existingName.Label = Already existing name!
Ui.Dialog.existingName.Message = This property name is already existing
Ui.Dialog.noSelectedElement.Message = No element has been selected to remove custom tag
Ui.Dialog.NoSelectedTagRemove.Message = No element has been selected to remove from custom properties list
Ui.Dialog.NoDiagramFound.Label = No Diagram Found!
Ui.Dialog.NoDiagramFound.Message = Sorry! We could not find the diagram of the referenced tree
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@

AttackTreePaletteGroup.AttackTree = Attack Tree
AttackTreePaletteGroup.Freedrawing = Free Drawing
AttackTreePaletteGroup.NotesAndConstraints = Notes and Constraints

Info.Session.Create = Create {0}
Info.Session.UpdateModel = Update Model
Info.Session.Delete = Delete {0}

Ui.Command.AttackTreeDiagramExplorerCommand.Label = Attack Tree Diagram
Ui.Command.AttackTreeDiagramExplorerCommand.Name = Attack Tree Diagram
Ui.Property.Name.Name = Name
Ui.Property.Reference.Name = Reference
Ui.Property.TypeCondition.Name = Type


Ui.Dialog.SelectXMLFileImport.Label = Select an XML file to import
Ui.Dialog.SelectDirectoryImport.Label = Select a directory to import
Ui.Dialog.SelectDirectoryExport.Label = Select a directory to export
Ui.Dialog.NoSelectedElement.Label = No selected element!
Ui.Dialog.NoSelectedElementAdd.Message = No element has been selected to add custom tag
Ui.Dialog.EmptyName.Label = Empty name field!
Ui.Dialog.EmptyName.Message = The property name field is empty
Ui.Dialog.EmptyValue.Label = Empty value field!
Ui.Dialog.EmptyValue.Message = The property value field is empty
Ui.Dialog.AddCustomTag.Label = Add a new Custom Tag property
Ui.Dialog.CustomTagName.Label = Provide the name and the value of your property
Ui.Field.CustomTagName.Label = Property name:
Ui.Field.CustomTagValue.Label = Property value:
Ui.Button.Cancel.Label = Cancel
Ui.Button.OK.Label = OK
Ui.Dialog.existingName.Label = Already existing name!
Ui.Dialog.existingName.Message = This property name is already existing
Ui.Dialog.noSelectedElement.Message = No element has been selected to remove custom tag
Ui.Dialog.NoSelectedTagRemove.Message = No element has been selected to remove from custom properties list
Ui.Dialog.NoDiagramFound.Label = No Diagram Found!
Ui.Dialog.NoDiagramFound.Message = Sorry! We could not find the diagram of the referenced tree

0 comments on commit bb61022

Please sign in to comment.