importaction.java

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

JAVA
53
字号
/*
 * 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 net.sf.component.config.ConfigHelper;
import net.sf.pim.UiUtil;
import net.sf.pim.model.psp.WorkList;
import net.sf.util.persistence.LegacyWorkDataManager;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.FileDialog;

/**
 * @author lzhang
 */
public class ImportAction extends UiAction {
    //记忆上次打开的位置
    private String path = ConfigHelper.getStringProperty("work.importhome");

    public ImportAction() {
        super();
        name = "查看...";
        gif = "import.gif";
    }

    public void run() {
    	super.run();
		if (UiUtil.getActiveTableEditor().getName().equals("日志")) {
	        parent.checkSave();
	        FileDialog fd = new FileDialog(parent.getTv().getTable().getShell(), SWT.OPEN | SWT.MULTI);
	        fd.setText("查看文件中的工作列表");
	        fd.setFilterExtensions(new String[]{"*.xml"});
	        fd.setFilterPath(path);
	        fd.open();
	        String fnames[] = fd.getFileNames();
	        if (fnames == null || fnames.length == 0)
	            return;
	        //记忆位置
	        path=fd.getFilterPath();
	        //处理文件名
	        for (int i = 0; i < fnames.length; i++)
	            fnames[i] = fd.getFilterPath() + "/" + fnames[i];
	        //导入
	        parent.setMulti(true);
	        parent.setData(new WorkList(LegacyWorkDataManager.importWork(fnames)));
		}
    }
}

⌨️ 快捷键说明

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