/*
* Created on 2005-1-24
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package com.example.ui;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.gef.DefaultEditDomain;
import org.eclipse.gef.dnd.TemplateTransferDragSourceListener;
import org.eclipse.gef.editparts.ScalableFreeformRootEditPart;
import org.eclipse.gef.palette.PaletteRoot;
import org.eclipse.gef.ui.actions.ActionRegistry;
import org.eclipse.gef.ui.parts.ContentOutlinePage;
import org.eclipse.gef.ui.parts.GraphicalEditorWithPalette;
import org.eclipse.gef.ui.parts.TreeViewer;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IWorkbenchActionConstants;
import org.eclipse.ui.part.IPageSite;
import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
import com.example.dnd.DiagramTemplateTransferDropTargetListener;
import com.example.model.Diagram;
import com.example.parts.PartFactory;
import com.example.parts.TreePartFactory;
import com.example.tools.PaletteFactory;
/**
* @author zhanghao
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class PracticeEditor extends GraphicalEditorWithPalette {
private Diagram diagram = new Diagram();
private PaletteRoot paletteRoot;
public Diagram getDiagram() {
return this.diagram;
}
public PracticeEditor() {
setEditDomain(new DefaultEditDomain(this));
}
protected void configureGraphicalViewer() {
super.configureGraphicalViewer();
getGraphicalViewer().setRootEditPart(new ScalableFreeformRootEditPart());
getGraphicalViewer().setEditPartFactory(new PartFactory());
}
protected void initializeGraphicalViewer() {
getGraphicalViewer().setContents(this.diagram);
getGraphicalViewer().addDropTargetListener(new DiagramTemplateTransferDropTargetListener(getGraphicalViewer()));
}
public void doSave(IProgressMonitor monitor) {
}
public void doSaveAs() {
}
public boolean isDirty() {
return getCommandStack().isDirty();
}
public boolean isSaveAsAllowed() {
return true;
}
protected void setInput(IEditorInput input) {
super.setInput(input);
// IFile file = ((IFileEditorInput) input).getFile();
diagram = new Diagram();
// try { // attempt to read from a file
// InputStream istream = file.getContents(false);
// diagram = Diagram.makeFromStream(istream);
// } catch (Exception e) { // but if there's an error, create a new diagram
// e.printStackTrace();
// diagram = new Diagram();
// }
}
public Object getAdapter(Class type) {
if (type == IContentOutlinePage.class)
return new OutlinePage();
return super.getAdapter(type);
}
protected PaletteRoot getPaletteRoot() {
if (this.paletteRoot == null) {
this.paletteRoot = PaletteFactory.createPalette();
}
return this.paletteRoot;
}
protected void initializePaletteViewer() {
super.initializePaletteViewer();
getPaletteViewer().addDragSourceListener(new TemplateTransferDragSourceListener(getPaletteViewer()));
}
class OutlinePage extends ContentOutlinePage {
// private PageBook pageBook;
private Control outline;
public OutlinePage() {
super(new TreeViewer());
}
public void init(IPageSite pageSite) {
super.init(pageSite);
ActionRegistry registry = getActionRegistry();
IActionBars bars = pageSite.getActionBars();
String id = IWorkbenchActionConstants.UNDO;
bars.setGlobalActionHandler(id, registry.getAction(id));
id = IWorkbenchActionConstants.REDO;
bars.setGlobalActionHandler(id, registry.getAction(id));
id = IWorkbenchActionConstants.DELETE;
bars.setGlobalActionHandler(id, registry.getAction(id));
bars.updateActionBars();
}
public void createControl(Composite parent) {
// pageBook = new PageBook(parent, SWT.NONE);
// outline = getViewer().createControl(pageBook);
// pageBook.showPage(outline);
outline = getViewer().createControl(parent);
getSelectionSynchronizer().addViewer(getViewer());
getViewer().setEditDomain(getEditDomain());
getViewer().setEditPartFactory(new TreePartFactory());
// getViewer().setKeyHandler(getCommonKeyHandler());
getViewer().setContents(getDiagram());
}
public Control getControl() {
// return pageBook;
return outline;
}
public void dispose() {
getSelectionSynchronizer().removeViewer(getViewer());
super.dispose();
}
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
RCP实例程序,可画层次结构图
共82个文件
class:38个
java:37个
gif:1个
4星 · 超过85%的资源 需积分: 9 29 下载量 158 浏览量
2011-01-13
15:56:11
上传
评论 1
收藏 68KB ZIP 举报
温馨提示
RCP实例程序,可画层次结构图,阅读代码可参看http://bjzhanghao.cnblogs.com/archive/2005/02/19/106000.html
资源推荐
资源详情
资源评论
收起资源包目录
gefpractice31-rcp.zip (82个子文件)
GefPractice-RCP
.project 648B
bin
com
example
actions
DiagramActionBarContributor.class 1KB
GefPracticePlugin.class 2KB
model
Node.class 4KB
Connection.class 983B
Element.class 1KB
Diagram.class 2KB
figures
NodeFigure.class 1KB
application
MyActionBarAdvisor.class 2KB
MyWorkbenchWindowAdvisor.class 1KB
MyWorkbenchAdvisor.class 1KB
MyApplication.class 1KB
ui
MyPerspective.class 1KB
PracticeEditor.class 4KB
PracticeEditor$OutlinePage.class 3KB
tools
ElementFactory.class 757B
PaletteFactory.class 3KB
commands
CreateConnectionCommand.class 2KB
DeleteNodeCommand.class 1KB
DeleteConnectionCommand.class 1KB
CreateNodeCommand.class 1KB
ReconnectSourceCommand.class 1KB
RenameNodeCommand.class 1KB
MoveNodeCommand.class 1KB
dnd
DiagramTemplateTransferDropTargetListener.class 766B
parts
NodeTreeEditPart.class 1KB
PartFactory.class 929B
DiagramPart.class 2KB
NodePart.class 5KB
ConnectionPart.class 1KB
NodeDirectEditManager.class 2KB
TreePartFactory.class 812B
DiagramTreeEditPart.class 1KB
NodeCellEditorLocator.class 1KB
policies
NodeGraphicalNodeEditPolicy.class 2KB
NodeEditPolicy.class 1KB
ConnectionEditPolicy.class 1KB
DiagramLayoutEditPolicy.class 2KB
NodeDirectEditPolicy.class 1KB
META-INF
MANIFEST.MF 695B
my.product 1KB
logo.gif 125B
src
com
example
actions
DiagramActionBarContributor.java 1KB
GefPracticePlugin.java 2KB
model
Element.java 1KB
Diagram.java 2KB
Node.java 4KB
Connection.java 1KB
figures
NodeFigure.java 1KB
application
MyActionBarAdvisor.java 2KB
MyWorkbenchAdvisor.java 869B
MyApplication.java 596B
MyWorkbenchWindowAdvisor.java 880B
ui
PracticeEditor.java 5KB
MyPerspective.java 774B
tools
PaletteFactory.java 2KB
ElementFactory.java 860B
commands
DeleteConnectionCommand.java 1KB
CreateNodeCommand.java 1KB
CreateConnectionCommand.java 2KB
MoveNodeCommand.java 1KB
ReconnectSourceCommand.java 1KB
RenameNodeCommand.java 1KB
DeleteNodeCommand.java 1KB
dnd
DiagramTemplateTransferDropTargetListener.java 927B
parts
NodeCellEditorLocator.java 2KB
DiagramPart.java 2KB
TreePartFactory.java 912B
DiagramTreeEditPart.java 1KB
NodeDirectEditManager.java 4KB
NodeTreeEditPart.java 1KB
PartFactory.java 948B
NodePart.java 4KB
ConnectionPart.java 2KB
policies
NodeEditPolicy.java 1006B
DiagramLayoutEditPolicy.java 2KB
NodeDirectEditPolicy.java 1KB
ConnectionEditPolicy.java 1020B
NodeGraphicalNodeEditPolicy.java 2KB
.classpath 307B
plugin.xml 956B
build.properties 178B
共 82 条
- 1
资源评论
- shanehust2016-01-27可以参考学习,RCP的资料不多
sangeyuan1
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功