|
|
|
@ -22,6 +22,46 @@ import java.util.concurrent.ExecutorService;
|
|
|
|
|
*/ |
|
|
|
|
public class DesignerWorkspaceActivator extends Activator { |
|
|
|
|
|
|
|
|
|
private final Listener<Workspace> stopModuleAction = new Listener<Workspace>(Integer.MIN_VALUE) { |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void on(Event event, Workspace current) { |
|
|
|
|
|
|
|
|
|
stopSub(EnvBasedModule.class); |
|
|
|
|
recordModuleStop(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void recordModuleStop() { |
|
|
|
|
|
|
|
|
|
WorkspaceSwitchProcess process = WorkContext.getSwitcher().getProgress(); |
|
|
|
|
Optional.ofNullable(process) |
|
|
|
|
.ifPresent((e) -> e.recordModuleStopUsed(() -> { |
|
|
|
|
FineModule module = (FineModule) ModuleContext.getModule(EnvBasedModule.class); |
|
|
|
|
return module.profileStop(); |
|
|
|
|
})); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
private final Listener<Workspace> startModuleAction = new Listener<Workspace>(Integer.MAX_VALUE) { |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void on(Event event, Workspace current) { |
|
|
|
|
|
|
|
|
|
startSub(EnvBasedModule.class); |
|
|
|
|
recordModuleStart(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void recordModuleStart() { |
|
|
|
|
|
|
|
|
|
WorkspaceSwitchProcess process = WorkContext.getSwitcher().getProgress(); |
|
|
|
|
Optional.ofNullable(process) |
|
|
|
|
.ifPresent((e) -> e.recordModuleStartUsed(() -> { |
|
|
|
|
FineModule module = (FineModule) ModuleContext.getModule(EnvBasedModule.class); |
|
|
|
|
return module.profile(); |
|
|
|
|
})); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void start() { |
|
|
|
|
|
|
|
|
@ -34,45 +74,9 @@ public class DesignerWorkspaceActivator extends Activator {
|
|
|
|
|
private void registerEnvListener() { |
|
|
|
|
|
|
|
|
|
/*切换环境前,关闭所有相关模块,最后执行*/ |
|
|
|
|
listenEvent(WorkspaceEvent.BeforeSwitch, new Listener<Workspace>(Integer.MIN_VALUE) { |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void on(Event event, Workspace current) { |
|
|
|
|
|
|
|
|
|
stopSub(EnvBasedModule.class); |
|
|
|
|
recordModuleStop(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void recordModuleStop() { |
|
|
|
|
|
|
|
|
|
WorkspaceSwitchProcess process = WorkContext.getSwitcher().getProgress(); |
|
|
|
|
Optional.ofNullable(process) |
|
|
|
|
.ifPresent((e) -> e.recordModuleStopUsed(() -> { |
|
|
|
|
FineModule module = (FineModule) ModuleContext.getModule(EnvBasedModule.class); |
|
|
|
|
return module.profileStop(); |
|
|
|
|
})); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
listenEvent(WorkspaceEvent.BeforeSwitch, stopModuleAction); |
|
|
|
|
/*切换环境后,重新启动所有相关模块,最先执行*/ |
|
|
|
|
listenEvent(WorkspaceEvent.AfterSwitch, new Listener<Workspace>(Integer.MAX_VALUE) { |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void on(Event event, Workspace current) { |
|
|
|
|
|
|
|
|
|
startSub(EnvBasedModule.class); |
|
|
|
|
recordModuleStart(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void recordModuleStart() { |
|
|
|
|
|
|
|
|
|
WorkspaceSwitchProcess process = WorkContext.getSwitcher().getProgress(); |
|
|
|
|
Optional.ofNullable(process) |
|
|
|
|
.ifPresent((e) -> e.recordModuleStartUsed(() -> { |
|
|
|
|
FineModule module = (FineModule) ModuleContext.getModule(EnvBasedModule.class); |
|
|
|
|
return module.profile(); |
|
|
|
|
})); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
listenEvent(WorkspaceEvent.AfterSwitch, startModuleAction); |
|
|
|
|
/*切换环境前,存储一下打开的所有文件对象,要先于 关闭相关模块部分 被触发*/ |
|
|
|
|
listenEvent(WorkspaceEvent.BeforeSwitch, new Listener<Workspace>(Integer.MAX_VALUE) { |
|
|
|
|
|
|
|
|
|