我正在使用提供的 API 为 Netbeans 开发一个插件模块,以便为新的编程语言提供支持。
我使用文件类型中定义的 MIME 类型在上下文菜单中创建了一个操作。
我正在寻找一种方法来保存正在选择的文件。最好只有当它发生变化时。
是否可以保存项目所有文件中的所有更改?
来自 Action Listener 类的部分代码:
@Override
public void actionPerformed(ActionEvent ev) {
FileObject f = context.getPrimaryFile();
String path = f.getPath();
String name = f.getName();
//Save file here
ExecutionDescriptor descriptor = new ExecutionDescriptor()
.controllable(true)
.frontWindow(true)
.preExecution(before)
.postExecution(after);
ExecutionService exeService = ExecutionService.newService(
new ProcessLaunch(cmdLine),
descriptor, "Run " + name);
Future<Integer> exitCode = exeService.run();
}
最佳答案
LifecycleManager.getDefault().saveAll();
这将保存项目中的所有对象。
关于java - Netbeans API : How to save a file, 或当前项目中的所有文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15098644/