Creating Modeler usingGraphitiManikantan SubramanyamSAP Labs India
Agenda for this session:           Who Am I?           Introduction to Graphiti           My Business Scenario/data    ...
Some buzzzzzz words:           EMF: Eclipse Modeling            Framework           Domain Model: Your business         ...
What Is Graphiti All About ?“The goal                                                                                     ...
Why Would I Want to Use Graphiti ?      Copyright © 2011 SAP AG, Made available under the Eclipse Public License v
My Business Data     (Domain data)                                          ClubClubInfo                           PlayerI...
Example of My Data:Club: RCBClubInfo: clubName: rcbPlayerInfo: playerName: Daniel VettoriCouncilInfo: councilName: BCCIClu...
DemoCopyright © 2011 SAP AG, Made available under the Eclipse Public License v 1.0
Sequence Flow…   PrepareBusiness Data                                              Define                                 ...
Prepare Business Data(Domain data)Club RCB = createNewClub(factory, "RCB", "Daniel Vettori");Club MI = createNewClub(facto...
How Does Graphiti Work ?      Copyright © 2011 SAP AG, Made available under the Eclipse Public License v 1.0
What about the Diagram Type Agent ?                                                                           Custom      ...
Graphiti’s ExtesntionPoints…Copyright © 2011 SAP AG, Made available under the Eclipse Public License v 1.0
ImageProvider..public class MyDiagramImageProvider extendsAbstractImageProvider implements       IImageProvider {    publi...
ToolBehaviorProvider..public class ToolBehaviorProvider extends CommonToolBehaviorProvider{    public ToolBehaviorProvider...
DiagramTypeProvider..public class MyDiagramTypeProvider extends AbstractDiagramTypeProvider          implements IDiagramTy...
FeatureProvider..public class MyDiagramFeatureProvider extends DefaultFeatureProviderWithPatterns{     ICustomFeature[] cu...
How to draw the RCB Club Logo ?      protected void drawClubInfo(ClubInfo      clubInfo) {               // Create an area...
How is the Club Icon drawn ?public class AddClubInfoFeature extendsAbstractAddShapeFeature{     public AddClubInfoFeature(...
ght © 2011 SAP AG, Made   aAny other Feature apart from AddFeature ?                           Feature                    ...
Graphiti – Where to Get It ?  Graphiti version 0.7.1 is available   www.eclipse.org/graphiti      Information arou...
Thanks 
Upcoming SlideShare
Loading in …5
×

Graphiti presentation

4,073 views

Published on

A presentation I made during the Eclipse Day 2011 in SAP Labs India, Bangalore

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
4,073
On SlideShare
0
From Embeds
0
Number of Embeds
891
Actions
Shares
0
Downloads
0
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Graphiti presentation

  1. 1. Creating Modeler usingGraphitiManikantan SubramanyamSAP Labs India
  2. 2. Agenda for this session:  Who Am I?  Introduction to Graphiti  My Business Scenario/data  Demo  Short Discussion on Architecture  Code snippets  Link to useful resources  Our Modeling ToolsCopyright © 2011 SAP AG, Made available under the Eclipse Public License v 1.0
  3. 3. Some buzzzzzz words:  EMF: Eclipse Modeling Framework  Domain Model: Your business data as Java /EMF Objects  Pictogram Model: Graphiti’s data model  Pictorial Elements: UI Shapes created by GraphitiCopyright © 2011 SAP AG, Made available under the Eclipse Public License v 1.0
  4. 4. What Is Graphiti All About ?“The goal easycreation and editunderlyinggraphical Copyright © 2011 SAP AG, Made available under the Eclipse Public License v 1.0
  5. 5. Why Would I Want to Use Graphiti ? Copyright © 2011 SAP AG, Made available under the Eclipse Public License v
  6. 6. My Business Data (Domain data) ClubClubInfo PlayerInfo CouncilInfo Copyright © 2011 SAP AG, Made available under the Eclipse Public License v 1.0
  7. 7. Example of My Data:Club: RCBClubInfo: clubName: rcbPlayerInfo: playerName: Daniel VettoriCouncilInfo: councilName: BCCIClub: Mumbai IndiansClubInfo: clubName: miPlayerInfo: playerName: The GOD CouncilInfo: councilName: BCCICopyright © 2011 SAP AG, Made available under the Eclipse Public License v 1.0
  8. 8. DemoCopyright © 2011 SAP AG, Made available under the Eclipse Public License v 1.0
  9. 9. Sequence Flow… PrepareBusiness Data Define ImageProvider DefineDiagramTypeProvider Define ToolBehaviorProvider Define FeatureProvider Draw FeatureProvider.add()Pictorial Elements Copyright © 2011 SAP AG, Made available under the Eclipse Public License v 1.0
  10. 10. Prepare Business Data(Domain data)Club RCB = createNewClub(factory, "RCB", "Daniel Vettori");Club MI = createNewClub(factory, "MI", "Sachin Tendulkar");private Club createNewClub(MyIPLFactory factory, StringclubName, String playerName) { Club newClub = factory.createClub(); ClubInfo clubInfo = factory.createClubInfo(); clubInfo.setClubName(clubName); PlayerInfo playerInfo =factory.createPlayerInfo(); playerInfo.setPlayerName(playerName); Council council = factory.createCouncil(); council.setCouncilName("BCCI"); newClub.setClubInfo(clubInfo); newClub.setPlayerInfo(playerInfo); newClub.setCouncilInfo(council); return newClub; }Copyright © 2011 SAP AG, Made available under the Eclipse Public License v 1.0
  11. 11. How Does Graphiti Work ? Copyright © 2011 SAP AG, Made available under the Eclipse Public License v 1.0
  12. 12. What about the Diagram Type Agent ? Custom Features Copyright © 2011 SAP AG, Made available under the Eclipse Public License v 1.0
  13. 13. Graphiti’s ExtesntionPoints…Copyright © 2011 SAP AG, Made available under the Eclipse Public License v 1.0
  14. 14. ImageProvider..public class MyDiagramImageProvider extendsAbstractImageProvider implements IImageProvider { public MyDiagramImageProvider() { } @Override protected void addAvailableImages() { addImageFilePath("rcb", "icons/rcb.jpg"); addImageFilePath("mi", "icons/mi.jpg"); addImageFilePath("rd", "icons/rd.jpg"); addImageFilePath("sd", "icons/sd.jpg"); }} Copyright © 2011 SAP AG, Made available under the Eclipse Public License v 1.0
  15. 15. ToolBehaviorProvider..public class ToolBehaviorProvider extends CommonToolBehaviorProvider{ public ToolBehaviorProvider(IDiagramTypeProviderdiagramTypeProvider) { super(diagramTypeProvider); } // Important Methods of CommonToolBehaviorProvider that can beoverridden getContextButtonPad(); getContextMenu(); getPalette(); getToolTip();} Copyright © 2011 SAP AG, Made available under the Eclipse Public License v 1.0
  16. 16. DiagramTypeProvider..public class MyDiagramTypeProvider extends AbstractDiagramTypeProvider implements IDiagramTypeProvider { private IToolBehaviorProvider[] toolBehaviorProviders; public MyDiagramTypeProvider() { super(); setFeatureProvider(new MyDiagramFeatureProvider(this)); } @Override public IToolBehaviorProvider[] getAvailableToolBehaviorProviders() { if (this.toolBehaviorProviders == null) { this.toolBehaviorProviders = new IToolBehaviorProvider[] { newToolBehaviorProvider(this) }; } return this.toolBehaviorProviders; }} Copyright © 2011 SAP AG, Made available under the Eclipse Public License v 1.0
  17. 17. FeatureProvider..public class MyDiagramFeatureProvider extends DefaultFeatureProviderWithPatterns{ ICustomFeature[] customFeatures = null; public MyDiagramFeatureProvider(IDiagramTypeProvider dtp) { super(dtp); } @Override public IAddFeature getAddFeature(IAddContext context) { if (context.getNewObject() instanceof ClubInfo) return new AddClubInfoFeature(this); else if (context.getNewObject() instanceof PlayerInfo) return new AddPlayerInfoFeature(this); else if (context.getNewObject() instanceof Council) return new AddBCCIFeature(this); return super.getAddFeature(context); }// Important Methods of DefaultFeatureProviderWithPatterns that can beoverridden getCustomFeatures(); getMoveShapeFeature(); getResizeShapeFeature(); getDeleteFeature(); getRemoveFeature();} Copyright © 2011 SAP AG, Made available under the Eclipse Public License v 1.0
  18. 18. How to draw the RCB Club Logo ? protected void drawClubInfo(ClubInfo clubInfo) { // Create an area for the Drawing the Club Logo AreaContext areaContext = new AreaContext(); areaContext.setSize(400, 400); IAddContext myClubContext = new AddContext(areaContext, clubInfo); ((AddContext) myClubContext).setTargetContainer(diagram); IAddFeature addFeature = featureProvider.getAddFeature(myClubContext ); addFeature.add(myClubContext); } Copyright © 2011 SAP AG, Made available under the Eclipse Public License v 1.0
  19. 19. How is the Club Icon drawn ?public class AddClubInfoFeature extendsAbstractAddShapeFeature{ public AddClubInfoFeature(IFeatureProvider fp) { super(fp); } @Override public PictogramElement add(IAddContext context) { // Get the EMF object from the context object ClubInfo addedClubInfo = (ClubInfo) context.getNewObject(); // Get the parent for this Club Icon Diagram parent = (Diagram) context.getTargetContainer(); // Create a container shape using Graphiti utility classes ContainerShape containerShape =Graphiti.getPeCreateService().createContainerShape( parent, true); // Give the imageID which is mentioned in ImageProvider String imageID = addedClubInfo.getClubName(); // Create an Image using Graphiti utility classes Image image =Graphiti.getGaCreateService().createImage(containerShape, imageID); // Set the X, Y, Height and Width of this image gaService.setLocationAndSize(image, 0, 0, 300, 300); } @Override public boolean canAdd(IAddContext arg0) { return true; }} Copyright © 2011 SAP AG, Made available under the Eclipse Public License v 1.0
  20. 20. ght © 2011 SAP AG, Made aAny other Feature apart from AddFeature ? Feature Name Default Class Important Methods create(), Create AbstractCreateFeature canCreate() update(), Update AbstractUpdateFeature canUpdate() remove(), Remove DefaultRemoveFeature canRemove() delete(), Delete DefaultDeleteFeature canDelete() Move DefaultMoveShapeFeature canMoveShape() canResizeShape(), Resize DefaultResizeShapeFeature resizeShape() layout(), Layout AbstractLayoutFeature canLayout() execute(), Custom AbstractCustomFeature canExecute() Copyright © 2011 SAP AG, Made available under the Eclipse Public License v 1.0
  21. 21. Graphiti – Where to Get It ?  Graphiti version 0.7.1 is available   www.eclipse.org/graphiti   Information around the project and framework   Downloads   Framework   Documentation   Tutorial   Forum  Copyright © 2011 SAP AG, Made available under the Eclipse Public License v 1.0
  22. 22. Thanks 

×