Skip to content

Commit

Permalink
F2 can be started and stopped with the toolbar buttons in the F2 cons…
Browse files Browse the repository at this point in the history
…ole page, F2 CLI works in Eclipse (albeit inclomplete and with some quirks)
  • Loading branch information
koentsje committed Feb 6, 2014
1 parent 885c785 commit 0206cd3
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class AeshConsole {

private AeshInputStream inputStream;
private AeshOutputStream stdOut, stdErr;
private org.jboss.aesh.console.AeshConsole console;
protected org.jboss.aesh.console.AeshConsole console;

public AeshConsole() {
initialize();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ public void start(IProgressMonitor progressMonitor) {

@Override
public void stop(IProgressMonitor progressMonitor) {
ForgeCorePlugin.getDefault().stopFurnace();
setNewState(STATE_NOT_RUNNING);
ForgeCorePlugin.getDefault().stopFurnace();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ protected void createConsole() {
handle.initialize(currentDir, getInputStream(), out, err);
}

public void start() {
createConsole();
}

@Override
public void stop() {
handle.destroy();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.jboss.tools.forge.ui.ext.cli;

import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.jboss.tools.aesh.ui.view.AeshTextViewer;

public class F2TextViewer extends AeshTextViewer {
Expand All @@ -16,11 +17,29 @@ protected void initializeConsole() {
aeshConsole = new F2Console();
}

protected void startConsole() {
if (constructionFinished) {
aeshConsole.start();
}
public void startConsole() {
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
if (constructionFinished) {
setDocument(aeshDocument);
aeshConsole.start();
}
}
});
}

public void stopConsole() {
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
aeshConsole.stop();
aeshDocument.set("");
setDocument(null);
}
});
}


}

Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
public class ForgeConsoleImpl implements ForgeConsole, PropertyChangeListener {

private String label = null;
private F2TextViewer textViewer = null;

public ForgeConsoleImpl() {
getRuntime().addPropertyChangeListener(this);
Expand All @@ -24,7 +25,8 @@ public ForgeConsoleImpl() {

@Override
public Control createControl(Composite parent) {
return new F2TextViewer(parent).getControl();
textViewer = new F2TextViewer(parent);
return textViewer.getControl();
}

@Override
Expand All @@ -47,7 +49,14 @@ public String getLabel() {

@Override
public void propertyChange(PropertyChangeEvent evt) {
System.out.println("property " + evt.getPropertyName() + " changed from " + evt.getOldValue() + " into " + evt.getNewValue());
if (ForgeRuntime.STATE_STARTING.equals(evt.getOldValue())
&& ForgeRuntime.STATE_RUNNING.equals(evt.getNewValue())) {
textViewer.startConsole();
}
if (ForgeRuntime.STATE_RUNNING.equals(evt.getOldValue())
&& ForgeRuntime.STATE_NOT_RUNNING.equals(evt.getNewValue())) {
textViewer.stopConsole();
}
}

}

0 comments on commit 0206cd3

Please sign in to comment.