惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

N
News | PayPal Newsroom
Security Archives - TechRepublic
Security Archives - TechRepublic
Hacker News: Ask HN
Hacker News: Ask HN
H
Hacker News: Front Page
Apple Machine Learning Research
Apple Machine Learning Research
TaoSecurity Blog
TaoSecurity Blog
Help Net Security
Help Net Security
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
V
V2EX
Hugging Face - Blog
Hugging Face - Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
人人都是产品经理
人人都是产品经理
博客园 - 三生石上(FineUI控件)
Security Latest
Security Latest
Cloudbric
Cloudbric
WordPress大学
WordPress大学
S
SegmentFault 最新的问题
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Know Your Adversary
Know Your Adversary
A
Arctic Wolf
L
LangChain Blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
The GitHub Blog
The GitHub Blog
P
Proofpoint News Feed
W
WeLiveSecurity
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
M
MIT News - Artificial intelligence
Google DeepMind News
Google DeepMind News
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
The Cloudflare Blog
小众软件
小众软件
NISL@THU
NISL@THU
云风的 BLOG
云风的 BLOG
P
Privacy & Cybersecurity Law Blog
S
Security @ Cisco Blogs
博客园 - 【当耐特】
I
InfoQ
Vercel News
Vercel News
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
P
Proofpoint News Feed
O
OpenAI News
Google DeepMind News
Google DeepMind News
N
News and Events Feed by Topic
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
K
Kaspersky official blog
T
Threat Research - Cisco Blogs
量子位
宝玉的分享
宝玉的分享

博客园 - Android,服务端,移动互联网

每周感悟【2013年7月28日】 每周感悟【2013年7月21日】 Android客户端打包方案分享 转载:Endianness一点通 xmlBeans problem (From xmlBeans FAQ) 转载:JavaSE的线程synchronized关键字的用法 解决 java.lang.NoClassDefFoundError: org /apache/xmlbeans/XmlException 转载:写得蛮好的linux学习笔记 获取EObject对象的反向引用对象 转载两篇文章之二(从程序员到CTO所要培养的六种能力)作者:阿蒙 原文:http://blog.csdn.net/harrymeng/archive/2007/02/07/1503931.aspx 转载两篇文章之一(35 岁前程序员要规划好的四件事)原文:http://blog.csdn.net/oiio/archive/2007/02/12/1508001.aspx 关于解决eclipse中的插件依赖 Eclipse Modeling Projects覆盖的工业标准 Eclipse中加入自己的菜单项和工具栏项 GMF中控制Figure的大小和位置 在eclipse中获得当前所有打开的editor实例列表 关于EMF模型的操作,赶紧记下来 测试一下Windows live writer How to get projects list in eclipse
GMF中定制自己的outline
Android,服务端,移动互联网 · 2007-03-02 · via 博客园 - Android,服务端,移动互联网

GMF默认生成的outline很成问题,只能显示top level的图形,比如在logic例子中,画板中图形元素和outline对应如下:

可见非top level的图形并没有与之对应的Tree Item显示在outline tree上。

其实用过gef的人都很容易知道原因,因为outline上每一个节点对应的也是一个tree editpart,每个tree editpart复用对应画板图形元素相同的数据模型。因此很显然,GMF生成的outline 和TreeEditPart并不能满足具体应用的需求,用户需要自己订制每个图形元素对应的outline 元素,也就是为每个图形元素实现一个TreeEditPart。

如何定制outlinepage:

在LogicNotationEditor中重载方法getOutlineViewEditPartFactory(),不过要注意的是这个方法在gmf1.0.1之后再加入DiagramEditor中,在gmf1.0.0里面没有这个方法,由于DiagramEditor中的内部类DiagramOutlinePage是友好的,无法继承,所以要想在gmf1.0.0中定制自己的outline就只能重写自己的outline page类了。

protected EditPartFactory getOutlineViewEditPartFactory() {
        
return new EditPartFactory() {

            
public EditPart createEditPart(EditPart context, Object model) {
                
if (model instanceof Diagram) {
                    
return new LogicDiagramTreeEditPart(model);
                }
 else {
                    
return this.getRightTreeEditPart(model);
                }

            }

            
private TreeEditPart getRightTreeEditPart(Object view) {
                
if(view instanceof Node &&
                        ((Node) view).getElement() 
instanceof ContainerElement) {
                    
                    
return new LogicContainerTreeEditPart(view);
                }

                
return new LogicChildTreeEditPart(view);
            }

        }
;
    }

LogicDiagramTreeEditPart.java

public class LogicDiagramTreeEditPart extends TreeDiagramEditPart{

    
public LogicDiagramTreeEditPart(Object model) {
        
super(model);
        
// TODO Auto-generated constructor stub
    }


    @Override
    
protected Image getImage() {
        
return LogicDiagramPlugin.getInstance().getBundledImage("icons/logic.gif");
    }


    @Override
    
protected String getText() {
        
return "Logic Diagram";
    }


}

LogicContainerTreeEditPart.java

public class LogicContainerTreeEditPart extends TreeContainerEditPart {

    
public LogicContainerTreeEditPart(Object model) {
        
super(model);
        
// TODO Auto-generated constructor stub
    }


    @Override
    
protected List getModelChildren() {
        List children 
= ((View) this.getModel()).getChildren();
        
return children;
    }


    @Override
    
protected Image getImage() {
        String path 
= "icons/logic.gif";
        String type 
= getType();
        
if("circuit".equalsIgnoreCase(type)) {
            path 
= "icons/circuit16.gif";
        }

        
if("FlowContainer".equalsIgnoreCase(type)) {
            path 
= "icons/logicflow16.gif";
        }

        
return LogicDiagramPlugin.getInstance().getBundledImage(path);
    }


    @Override
    
protected String getText() {
        
// TODO Auto-generated method stub
        return ((View) this.getModel()).getType();
    }

    
private String getType() {
        
return ((View) getModel()).getType();
        
    }

}

LogicChildTreeEditPart.java

public class LogicChildTreeEditPart extends TreeEditPart {

    
public LogicChildTreeEditPart(Object model) {
        
super(model);
        
// TODO Auto-generated constructor stub
    }

    @Override
    
protected Image getImage() {
        String path 
= "icons/logic.gif";
        String type 
= getType();
        
if("LED".equalsIgnoreCase(type)) {
            path 
= "icons/ledicon16.gif";
        }

        
if("AndGate".equalsIgnoreCase(type)) {
            path 
= "icons/and16.gif";
        }

        
if("OrGate".equalsIgnoreCase(type)) {
            path 
= "icons/or16.gif";
        }

        
if("XorGate".equalsIgnoreCase(type)) {
            path 
= "icons/xor16.gif";
        }

        
return LogicDiagramPlugin.getInstance().getBundledImage(path);
    }


    @Override
    
protected String getText() {
        
// TODO Auto-generated method stub
        return ((View) this.getModel()).getType();
    }

    
private String getType() {
        
return ((View) getModel()).getType();
        
    }

}

在LogicDiagramPlugin里面加入如下代码,主要用于获取icon image

    public static ImageDescriptor getBundledImageDescriptor(String path) {
        
return AbstractUIPlugin.imageDescriptorFromPlugin("org.eclipse.gmf.examples.runtime.diagram.logic", path);
    }

    
public Image getBundledImage(String path) {
        Image image 
= getImageRegistry().get(path);
        
if (image == null{
            getImageRegistry().put(path, getBundledImageDescriptor(path));
            image 
= getImageRegistry().get(path);
        }

        
return image;
    }


经过改进后的logic diagram outline page: