1 package net.mograsim.plugin.launch;
3 import java.io.IOException;
5 import org.eclipse.core.resources.IResourceChangeEvent;
6 import org.eclipse.core.resources.IResourceChangeListener;
7 import org.eclipse.core.resources.ResourcesPlugin;
8 import org.eclipse.core.runtime.CoreException;
9 import org.eclipse.core.runtime.IProgressMonitor;
10 import org.eclipse.debug.core.DebugPlugin;
11 import org.eclipse.debug.core.ILaunch;
12 import org.eclipse.debug.core.ILaunchConfiguration;
13 import org.eclipse.debug.core.model.LaunchConfigurationDelegate;
15 import net.mograsim.plugin.MograsimActivator;
17 public class MachineLaunchConfigType extends LaunchConfigurationDelegate
19 public static final String PROJECT_ATTR = MograsimActivator.PLUGIN_ID + "project";
21 private final IResourceChangeListener resChangedListener;
23 public MachineLaunchConfigType()
25 this.resChangedListener = this::resourceChanged;
29 public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException
31 ResourcesPlugin.getWorkspace().addResourceChangeListener(resChangedListener,
32 IResourceChangeEvent.POST_BUILD | IResourceChangeEvent.POST_CHANGE | IResourceChangeEvent.PRE_BUILD
33 | IResourceChangeEvent.PRE_CLOSE | IResourceChangeEvent.PRE_DELETE | IResourceChangeEvent.PRE_REFRESH);
34 System.out.println("launch");
35 // TODO start a machine
36 ProcessBuilder pb = new ProcessBuilder("cmd", "/c", "\"echo Press Enter... &&pause>NUL && echo finished\"");
39 launch.addProcess(DebugPlugin.newProcess(launch, pb.start(), ""));
47 private void resourceChanged(IResourceChangeEvent event)
49 // TODO react to MPM changes
50 int type = event.getType();
54 case IResourceChangeEvent.POST_BUILD:
55 typeStr = "POST_BUILD";
57 case IResourceChangeEvent.POST_CHANGE:
58 typeStr = "POST_CHANGE";
60 case IResourceChangeEvent.PRE_BUILD:
61 typeStr = "PRE_BUILD";
63 case IResourceChangeEvent.PRE_CLOSE:
64 typeStr = "PRE_CLOSE";
66 case IResourceChangeEvent.PRE_DELETE:
67 typeStr = "PRE_DELETE";
69 case IResourceChangeEvent.PRE_REFRESH:
70 typeStr = "PRE_REFRESH";
73 typeStr = "<unknown: " + type + ">";
75 System.out.println(typeStr + ": " + event);