attachfileaction.java

来自「mywork是rcp开发的很好的例子」· Java 代码 · 共 46 行

JAVA
46
字号
/*
 * Created on 2003-4-10
 *
 * To change the template for this generated file go to
 * Window>Preferences>Java>Code Generation>Code and Comments
 */
package net.sf.pim.action;

import java.io.File;

import net.sf.component.simplenote.FileProxy;
import net.sf.component.simplenote.ImageProxy;
import net.sf.component.simplenote.SimpleNote;

import org.eclipse.swt.graphics.ImageData;
import org.eclipse.swt.widgets.FileDialog;


/**
 * @author levin
 * @since 2007-11-7 下午08:33:07
 */
public class AttachFileAction extends UiAction {
    public AttachFileAction() {
        super();
        name = "插入文件或图片...";
        gif = "attach.gif";
    }

    public void run() {
    	super.run();
		FileDialog dialog = new FileDialog(parent.getTv().getTable().getShell());
		String filename = dialog.open();
		if (filename != null) {
			try {
				if(SimpleNote.maybeImageFile(filename))
					parent.getMemoText().addElement(new ImageProxy(new ImageData(filename)));
				else
					parent.getMemoText().addElement(new FileProxy(new File(filename)));
			} catch (Exception ex) {
				ex.printStackTrace();
			}
		}				    	
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?