On 11/13/2009 04:10 PM, Jamison Hope wrote:
Is there a way to construct two instances of ReplDocument which share
an environment, without having access to package-visible fields?
After a little bit of thought, I think adding a "copy constructor"
for ReplDocument might make sense:
public ReplDocument (ReplDocument old)
{
this(new SwingContent(), old.language, old.environment, true);
}
and add a GuiConsole method to take a ReplDocument:
public GuiConsole(ReplDocument rdoc)
{
super("Kawa");
repl.getLanguage(); // In case a new GuiConsole is created from
Java.
init(doc);
}
public GuiConsole(Language language, Environment penvironment,
boolean shared)
{
this(new ReplDocument(language, penvironment, shared));
}
Then the shared action becomes:
else if (cmd.equals(NEW_SHARED))
new GuiConsole(new ReplDocument(document));
Could you this approach, and see how it works, both for the
existing GuiConsole, and your application?