今天开始做些小的总结,因为Eclipse插件方面做了不少东西了,也该总结总结学习到的东西了!
为了增加普遍性,例子使用的Editor继承自最简单的EditorPart来制作。
程序里的说明,作为帮助吧!
package ztestpluginproject.editors.zeditors;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorSite;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.forms.widgets.ColumnLayout;
import org.eclipse.ui.forms.widgets.ColumnLayoutData;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.Section;
import org.eclipse.ui.part.EditorPart;
public class ZTestEditor extends EditorPart {
// 简单情况下可以自己制作一个标志来记录当前编辑器状况
public boolean isDirty = false;
@Override
public void doSave(IProgressMonitor monitor) {
this.isDirty = false; // 先将标志设置为false
this.firePropertyChange(PROP_DIRTY); // 通知编辑器要修改状态了
}
@Override
public void doSaveAs() {
}
@Override
public void init(IEditorSite site, IEditorInput input)
throws PartInitException {
this.setInput(input);
this.setSite(site);
this.setPartName(input.getName());//设置标签为 文件名
}
@Override
public boolean isDirty() {
//firePropertyChange(PROP_DIRTY) 将根据这里返回的值,来修改编辑器状态(保存或者未保存<*>)
return this.isDirty;
}
@Override
public boolean isSaveAsAllowed() {
return false;
}
@Override
public void createPartControl(Composite parent) {
// 这里新建了一个表单 放了三个文本框
final FormToolkit toolkit = new FormToolkit(parent.getDisplay());
ColumnLayout layout = new ColumnLayout();
layout.horizontalSpacing = 5;
layout.verticalSpacing = 5;
parent.setLayout(layout);
Section section = toolkit.createSection(parent, Section.TWISTIE|Section.TITLE_BAR);
Composite compo = toolkit.createComposite(section, SWT.NONE);
ColumnLayout layoutSection = new ColumnLayout();
compo.setLayout(layoutSection);
section.setClient(compo);
section.setExpanded(true);
// 文本框内容变动监听器
TxtChangeListener listener = new TxtChangeListener();
Text txtName = toolkit.createText(compo, "Mike", SWT.NONE);
ColumnLayoutData td = new ColumnLayoutData();
txtName.setLayoutData(td);
txtName.addModifyListener(listener);
Text txtAge = toolkit.createText(compo, "22", SWT.NONE);
td = new ColumnLayoutData();
txtAge.setLayoutData(td);
txtAge.addModifyListener(listener);
Text txtSex = toolkit.createText(compo, "m", SWT.NONE);
td = new ColumnLayoutData();
txtSex.setLayoutData(td);
txtSex.addModifyListener(listener);
}
// 制作监听器 ,这里是对Text进行监听使用ModifyListener
//如果是TextField(awt包下)之类的有DocumentListener,此处不再赘述
class TxtChangeListener implements ModifyListener {
@Override
public void modifyText(ModifyEvent e) {
System.out.println("ok");
isDirty = true;
ZTestEditor.this.firePropertyChange(PROP_DIRTY);
}
}
@Override
public void setFocus() {
}
}
分享到:
相关推荐
dirty
Dirty Ames
dirty_liar
Unity 脏镜头光晕效果Dirty Lens Effect;Unity 脏镜头光晕效果Dirty Lens Effect;
unity中的SE Natural Bloom Dirty Lens 绚丽的特效镜头插件
Jim Blinn - Jim Blinn's Corner_ Dirty Pixels (The Morgan Kaufmann Series in Computer Graphics)-Morgan Kaufmann (1998).djvu
However, time is an important data dimension with distinct characteristics which affords special consideration in the context of dirty data. Building upon existing taxonomies of general data quality ...
Get Your Hands Dirty on Clean Architecture starts with a discussion about the conventional layered architecture style and its disadvantages. It also talks about the advantages of the domain-centric ...
Unity3d特效插件 脏镜头光晕效果Dirty Lens Effect. 请勿商用
MAX H. M. COSTA Writing on dirty paper
安装npm install dirty-chai --save-dev用法dirty-chai是一个chai。 var chai = require ( 'chai' ) ;var dirtyChai = require ( 'dirty-chai' ) ;var expect = chai . expectchai . use ( dirtyChai ) ;// ......
Dirty Headline
提示Volume is dirty来源于网络知识
webrtc-streamer-v0.8.1-dirty-Windows-AMD64-Release.zip
资源名称 Dirty Pop 上传者:C996387762 (C)
Dirty paper trellis code for watermarking
复旦大学_软件安全_SEED labs_5-Dirty_Cow实验 是从雪城大学SEED labs上找的实验 资源包括: 攻击修改代码、实验报告详细版、实验指导书、参考链接