this.productConfig = prodConfig;
}
public Widget asWidget() {
final LayoutPanel layout = new LayoutPanel();
layout.setStyleName("footer-panel");
final PopupPanel toolsPopup = new DefaultPopup(DefaultPopup.Arrow.BOTTOM);
final List<String[]> toolReference = new ArrayList<String[]>();
toolReference.add(new String[]{"Management Model", "browser"});
toolReference.add(new String[]{"Expression Resolver", "expressions"});
if(diagnostics.isEnabled())
{
toolReference.add(new String[]{"Diagnostics", "debug-panel"});
}
// only enabled in dev mode
if(!GWT.isScript())
{
toolReference.add(new String[] {"Modelling", "mbui-workbench"});
toolReference.add(new String[] {"Resource Access", "access-log"});
StringBuilder runAsRole = new StringBuilder("Run as");
if (Preferences.has(RUN_AS_ROLE)) {
runAsRole.append(" ").append(Preferences.get(RUN_AS_ROLE));
} else {
runAsRole.append("...");
}
toolReference.add(new String[] {runAsRole.toString(), "run-as-role"});
}
final VerticalPanel toolsList = new VerticalPanel();
toolsList.getElement().setAttribute("width", "160px");
for(final String[] tool : toolReference)
{
InlineLink browser = new InlineLink(tool[0]);
browser.getElement().setAttribute("style", "margin:4px");
browser.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
toolsPopup.hide();
placeManager.revealPlace(
new PlaceRequest(NameTokens.ToolsPresenter).with("name", tool[1])
);
}
});
toolsList.add(browser);
}
toolsPopup.setWidget(toolsList);
final HTML toolsLink = new HTML("<i class='icon-caret-up'></i> "+"Tools");
toolsLink.addStyleName("footer-link");
toolsLink.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
int listHeight = toolsList.getWidgetCount() * 25;
toolsPopup.setPopupPosition(
toolsLink.getAbsoluteLeft()-45,
toolsLink.getAbsoluteTop()-(listHeight-25)-50
);
toolsPopup.setWidth("165");
toolsPopup.setHeight(listHeight +"");
toolsPopup.show();
}
});
HTML settings = new HTML("<i class='icon-wrench'></i> "+Console.CONSTANTS.common_label_settings());
settings.addStyleName("footer-link");
settings.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
placeManager.revealPlace(
new PlaceRequest(NameTokens.SettingsPresenter)
);
}
});
HTML logout = new HTML("<i class='icon-signout'></i> "+Console.CONSTANTS.common_label_logout());
logout.addStyleName("footer-link");
logout.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
Feedback.confirm(
Console.CONSTANTS.common_label_logout(),
Console.CONSTANTS.logout_confirm(),
new Feedback.ConfirmationHandler() {
@Override
public void onConfirmation(boolean isConfirmed) {
if(isConfirmed)
{
new LogoutCmd().execute();
}
}
}
);
}
});
HorizontalPanel tools = new HorizontalPanel();
tools.add(toolsLink);
tools.add(settings);
tools.add(logout);
layout.add(tools);
HTML version = new HTML(productConfig.getCoreVersion());
version.getElement().setAttribute("style", "color:#ffffff;font-size:11px; align:left");
layout.add(version);
String userHtml = "<i class='icon-user'></i> "+Console.getBootstrapContext().getPrincipal();
String roleHtml = "<i class='icon-tag'></i> "+Console.getBootstrapContext().getRole();
HTML principal = new HTML(userHtml+" | "+roleHtml);
principal.getElement().setAttribute("style", "color:#ffffff;font-size:11px; align:left");
layout.add(principal);
layout.setWidgetLeftWidth(version, 20, Style.Unit.PX, 200, Style.Unit.PX);
layout.setWidgetTopHeight(version, 3, Style.Unit.PX, 16, Style.Unit.PX);
layout.setWidgetLeftWidth(principal, 210, Style.Unit.PX, 300, Style.Unit.PX);
layout.setWidgetTopHeight(principal, 3, Style.Unit.PX, 16, Style.Unit.PX);
layout.setWidgetRightWidth(tools, 5, Style.Unit.PX, 500, Style.Unit.PX);
layout.setWidgetTopHeight(tools, 2, Style.Unit.PX, 28, Style.Unit.PX);
layout.setWidgetHorizontalPosition(tools, Layout.Alignment.END);
layout.getElement().setAttribute("role", "complementary");
return layout;
}