/**
* The contents of this file are subject to the license and copyright
* detailed in the LICENSE file at the root of the source
* tree and available online at
*
* https://github.com/keeps/roda
*/
/**
*
*/
package org.roda.wui.client.welcome;
import java.util.Arrays;
import java.util.List;
import org.roda.wui.client.common.UserLogin;
import org.roda.wui.common.client.HistoryResolver;
import org.roda.wui.common.client.tools.HistoryUtils;
import org.roda.wui.common.client.widgets.HTMLWidgetWrapper;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Widget;
/**
* @author Luis Faria
*
*/
public class Help {
public static final HistoryResolver RESOLVER = new HistoryResolver() {
@Override
public void resolve(List<String> historyTokens, AsyncCallback<Widget> callback) {
getInstance().resolve(historyTokens, callback);
}
@Override
public void isCurrentUserPermitted(AsyncCallback<Boolean> callback) {
UserLogin.getInstance().checkRole(this, callback);
}
@Override
public String getHistoryToken() {
return "help";
}
@Override
public List<String> getHistoryPath() {
return Arrays.asList(getHistoryToken());
}
};
private static Help instance = null;
/**
* Get the singleton instance
*
* @return the instance
*/
public static Help getInstance() {
if (instance == null) {
instance = new Help();
}
return instance;
}
private boolean initialized;
private HTMLWidgetWrapper layout;
private Help() {
initialized = false;
}
private void init() {
if (!initialized) {
initialized = true;
layout = new HTMLWidgetWrapper("Help.html");
layout.addStyleName("wui-home");
}
}
public void resolve(List<String> historyTokens, AsyncCallback<Widget> callback) {
if (historyTokens.isEmpty()) {
init();
callback.onSuccess(layout);
} else {
HistoryUtils.newHistory(Help.RESOLVER);
callback.onSuccess(null);
}
}
}