Skip to content

Commit

Permalink
use a label for ForgeConsole and display it in the status line
Browse files Browse the repository at this point in the history
  • Loading branch information
koentsje committed Feb 6, 2014
1 parent e6c36d3 commit 98c7050
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@
import org.jboss.tools.forge.ui.ext.actions.StopF2Action;

public class ForgeConsoleImpl implements ForgeConsole {

private String label = null;

public ForgeConsoleImpl() {
label = "Forge " + getRuntime().getVersion() + " - " + getRuntime().getType();
}

@Override
public Control createControl(Composite parent) {
Expand All @@ -30,4 +36,9 @@ public ForgeRuntime getRuntime() {
return FurnaceRuntime.INSTANCE;
}

@Override
public String getLabel() {
return label;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import org.eclipse.jface.action.Action;
import org.eclipse.jface.resource.ImageDescriptor;
import org.jboss.tools.forge.core.process.ForgeRuntime;
import org.jboss.tools.forge.ui.ForgeUIPlugin;
import org.jboss.tools.forge.ui.console.ForgeConsole;
import org.jboss.tools.forge.ui.part.ForgeConsoleView;
Expand All @@ -15,21 +14,12 @@ public class ForgeConsoleShowAction extends Action {
private ForgeConsole forgeConsole = null;

public ForgeConsoleShowAction(ForgeConsoleView forgeConsoleView, ForgeConsole forgeConsole) {
super(createLabel(forgeConsole), AS_RADIO_BUTTON);
super(forgeConsole.getLabel(), AS_RADIO_BUTTON);
this.forgeConsoleView = forgeConsoleView;
this.forgeConsole = forgeConsole;
setImageDescriptor(createImageDescriptor());
}

private static String createLabel(ForgeConsole forgeConsole) {
String result = "Unnamed Forge Runtime";
ForgeRuntime runtime = forgeConsole.getRuntime();
if (runtime != null) {
result = runtime.getName();
}
return result;
}

@Override
public void run() {
forgeConsoleView.showForgeConsole(forgeConsole);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

public interface ForgeConsole {

String getLabel();
Control createControl(Composite parent);
IAction[] createActions();
ForgeRuntime getRuntime();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ public class ForgeConsoleImpl implements ForgeConsole, PropertyChangeListener {

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

private String label = null;

public ForgeConsoleImpl() {
getRuntime().addPropertyChangeListener(this);
label = "Forge " + getRuntime().getVersion() + " - " + getRuntime().getType();
}

@Override
Expand Down Expand Up @@ -66,4 +68,9 @@ public void run() {
});
}

@Override
public String getLabel() {
return label;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ public class ForgeConsolePage implements IPage, PropertyChangeListener {
private Control control = null;
private IPageSite pageSite = null;
private SubActionBars actionBars = null;
private String baseStatusMessage = null;

public ForgeConsolePage(ForgeConsolePageBook forgeConsolePageBook, ForgeConsole forgeConsole) {
this.forgeConsolePageBook = forgeConsolePageBook;
Expand Down Expand Up @@ -95,16 +94,8 @@ void show() {
forgeConsolePageBook.updateStatusMessage(getStatusMessage());
}

private void initBaseStatusMessage() {
ForgeRuntime runtime = forgeConsole.getRuntime();
baseStatusMessage = "Forge " + runtime.getVersion() + " - " + runtime.getType();
}

String getStatusMessage() {
if (baseStatusMessage == null) {
initBaseStatusMessage();
}
return baseStatusMessage;
return forgeConsole.getLabel();
}

private void updateActionBars() {
Expand Down

0 comments on commit 98c7050

Please sign in to comment.