So, I thought that I would answer this myself, since, finally, I was able to execute the console. This is still a working prototype, but I think as you keep adding things, you can clear the code more and more. For my current purposes, this is how it worked.
If you want a short version, I basically mimicked the ProcessConsole
provided by Eclipse, as that was what I needed: a console where I can hook the process, but since the ProcessConsole
is internal, I like to avoid extending these classes.
The following is a diagram of the classes that I used to interact with my console. I am not going to give an excuse where MyConsole
was created. Basically, instead of using DebugUITools.getConsole(myProcess)
I used my own method myProcess.getConsole()
. MyProcess
extends RuntimeProcess
.
class MyConsole extends IOConsole { private IOConsoleInputStream fInput; private IOConsoleOutputStream fOutput; private IStreamsProxy fStreamsProxy; private ConsoleHistory history;
This is the code for ProcessConsole
. This is the code for IOConsoleViewer
.
The ConsoleHistory
class I ConsoleHistory
consisted of only a double-linked list of strings to save all the commands entered by the user. A fairly simple class to create.
As soon as you look at the Eclipse classes ( ProcessConsole
and IOConsoleViewer
), this is actually all clear. I have not added a lot of code here because there is quite a bit. But hopefully this gives some direction as I was completely lost when I started.
I am happy to answer questions and add more specific code if someone asks.
source share