Skip to content

Commit

Permalink
reset the console when Forge1 stops
Browse files Browse the repository at this point in the history
  • Loading branch information
koentsje committed Feb 5, 2014
1 parent 8dd340f commit 88a29e1
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,27 +1,42 @@
package org.jboss.tools.forge.ui.console.f1;

import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;

import org.eclipse.jface.action.IAction;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.jboss.tools.forge.core.preferences.ForgeRuntimesPreferences;
import org.jboss.tools.forge.core.process.ForgeRuntime;
import org.jboss.tools.forge.ui.actions.f1.GoToAction;
import org.jboss.tools.forge.ui.actions.f1.LinkAction;
import org.jboss.tools.forge.ui.actions.f1.StartF1Action;
import org.jboss.tools.forge.ui.actions.f1.StopF1Action;
import org.jboss.tools.forge.ui.console.ForgeConsole;
import org.jboss.tools.forge.ui.document.ForgeDocument;
import org.jboss.tools.forge.ui.part.ForgeTextViewer;

public class ForgeConsoleImpl implements ForgeConsole {
public class ForgeConsoleImpl implements ForgeConsole, PropertyChangeListener {

private ForgeTextViewer forgeTextViewer = null;
private ForgeRuntime forgeRuntime = ForgeRuntimesPreferences.INSTANCE.getDefaultRuntime();

public ForgeConsoleImpl() {
getRuntime().addPropertyChangeListener(this);
}

@Override
public String getName() {
return "Forge One";
}

@Override
public Control createControl(Composite parent) {
return new ForgeTextViewer(parent).getControl();
if (forgeTextViewer == null) {
forgeTextViewer = new ForgeTextViewer(parent);
}
return forgeTextViewer.getControl();
}

@Override
Expand All @@ -36,7 +51,24 @@ public IAction[] createActions() {

@Override
public ForgeRuntime getRuntime() {
return ForgeRuntimesPreferences.INSTANCE.getDefaultRuntime();
return forgeRuntime;
}

@Override
public void propertyChange(PropertyChangeEvent evt) {
if (!ForgeRuntime.PROPERTY_STATE.equals(evt.getPropertyName())) return;
if (ForgeRuntime.STATE_NOT_RUNNING.equals(evt.getNewValue())) {
resetForgeDocument();
}
}

private void resetForgeDocument() {
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
ForgeDocument.INSTANCE.reset();
}
});
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ private void clearCurrentScreenPage(String command) {
}
}

private void reset() {
public void reset() {
set("");
moveCursorTo(0);
styleRanges.clear();
Expand Down

0 comments on commit 88a29e1

Please sign in to comment.