首页 > 代码库 > 6.12 xml part5 DiagramEidtor
6.12 xml part5 DiagramEidtor
1 public class DiagramEditor extends GraphicalEditorWithFlyoutPalette implements 2 IPersistableEditor {
?
1 | <span>首先是定义的一些变量:<br></span> |
1 public static final String ID = "ttcn3.gft.editor.editor.DiagramEditor"; 2 3 public static String WARN_FILEEXIST = "diagram file is not exists."; 4 //这是Palette的名字。一共定义了四个Palette。 5 public final static String TTYPE_TST = "testcase"; 6 public final static String TTYPE_ALT = "altstep"; 7 public final static String TTYPE_CNT = "module"; 8 public final static String TTYPE_FUN = "function"; 9 10 private PaletteRoot root; 11 12 private GraphicalViewer viewer; 13 14 private DiagramModel diagram; 15 private ResourceChangeListener resourceChangeListener;//??? 16 private EditorPartListener editorListener;// ?? 17 18 private String type = "";
?
1 | <span style= "background-color: rgb(255, 255, 153);" >看第一个嵌套类:EditorPartListener</span> |
?
1 | IPartListener2的用法参看:<br><a href=http://www.mamicode.com/ "http://www.blogjava.net/raul/archive/2008/01/04/172761.html" >http://www.blogjava.net/raul/archive/2008/01/04/172761.htmlh<br></a><a href=http://www.mamicode.com/ "http://blog.csdn.net/cuser_online/article/details/7947527" >http://blog.csdn.net/cuser_online/article/details/7947527</a><a href=http://www.mamicode.com/ "http://www.blogjava.net/raul/archive/2008/01/04/172761.html" ><br></a>IIPartListener的应用场景?<br>IPartListener监听WorkbenchPart(包括ViewPart和EditorPart)和生命周期(打开,隐藏,关闭等),<br>当我们想在某WorkbenchPart在这些生命周期发生的触发点上做些事情的时候,此接口正好为你所用。<br>IPartListener2是IPartListener的一个替代类,其支持的事件更多一些。 |
1 class EditorPartListener implements IPartListener2 { 2 DiagramEditor editor; 3 4 public EditorPartListener(DiagramEditor editor) { 5 super(); 6 this.editor = editor; 7 } 8 9 // part listener 10 这一段不知道在干吗。将todoitem的viewer的text设为空? 11 public void partActivated(IWorkbenchPartReference partRef) { 12 // TODO Auto-generated method stub 13 if (partRef.getPart(true).equals(editor)) { 14 15 if (ToDoItemTemplate.getWinstate()) { 16 ToDoItemTemplate.getTDIViewer().setText(""); 17 } 18 } 19 } 20 21 public void partBroughtToTop(IWorkbenchPartReference partRef) { 22 // TODO Auto-generated method stub 23 } 24 25 26 public void partClosed(IWorkbenchPartReference partRef) { 27 // TODO Auto-generated method stub 28 if (partRef.getPart(true).equals(editor)) { 29 CoreLangTemplate.removeFileWiter(editor); 30 31 if (ToDoItemTemplate.getWinstate()) { 32 33 } 34 35 } 36 37 } 38 39 @Override 40 public void partDeactivated(IWorkbenchPartReference partRef) { 41 // TODO Auto-generated method stub 42 } 43 44 @Override 45 public void partHidden(IWorkbenchPartReference partRef) { 46 // TODO Auto-generated method stub 47 } 48 49 @Override 50 public void partInputChanged(IWorkbenchPartReference partRef) { 51 // TODO Auto-generated method stub 52 } 53 54 @Override 55 public void partOpened(IWorkbenchPartReference partRef) { 56 // TODO Auto-generated method stub 57 if (partRef.getPart(true).equals(editor)) { 58 59 if (ToDoItemTemplate.getWinstate()) { 60 // add here 61 ToDoItemTemplate.getTDIViewer().setText(""); 62 } 63 64 refreshTitleImage(); 65 } 66 } 67 68 @Override 69 public void partVisible(IWorkbenchPartReference partRef) { 70 // TODO Auto-generated method stub 71 } 72 }
?
1 | <span style= "background-color: rgb(204, 255, 204);" ><strong>第二个嵌套类:EditorDropListener </strong> (实现Palette的拖曳操作。)</span> |
lass EditorDropListener extends TemplateTransferDropTargetListener { public EditorDropListener() { this(getGraphicalViewer()); } public EditorDropListener(EditPartViewer viewer) { super(viewer); // TODO Auto-generated constructor stub } @Override protected CreationFactory getFactory(Object template) { if (template instanceof CreationFactory) { return ((CreationFactory) template); } return null; } };
?
1 | <span>第三个嵌套类:ResourceChangeListener </span> IResourceChangeListener的用法: |
?
1 | <a href=http://www.mamicode.com/ "http://blog.csdn.net/a570056568/article/details/6152961" >http://blog.csdn.net/a570056568/article/details/6152961</a><br><br> |
?
1 | |
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。