Created
December 18, 2013 15:30
-
-
Save mastersobg/8024273 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package one.app.community.dk.states.user.presents; | |
import one.app.community.dk.IWebDkFacade; | |
import one.app.community.dk.blocks.BlockWithId; | |
import one.app.community.dk.conf.AchievementsTopConfiguration; | |
import one.app.community.dk.gwt.desktop.server.BlockId; | |
import one.app.community.dk.rdk.block.AppBlock; | |
import one.app.community.dk.rdk.block.AppRequestCtx; | |
import one.app.community.dk.rdk.block.AppRequestCtxWrapper; | |
import one.app.community.dk.rdk.blockgui.GUIFactory; | |
import one.app.desktop.rdk.render.IHttpCtx; | |
import one.desktop.control.IModelSupplier; | |
import one.desktop.control.flow.IfCondition; | |
import org.springframework.beans.factory.annotation.Autowired; | |
import two.standard.tabs.Tabs; | |
/** | |
* @author Ivan Gorbachev <[email protected]> | |
*/ | |
@BlockWithId(value = BlockId.AchievementsNavBlock, description = "Табы в достижениях") | |
public class AchievementsNavBlock extends AppBlock { | |
@Autowired | |
private IWebDkFacade webDkFacade; | |
@Autowired | |
private AchievementsTopConfiguration conf; | |
@Override | |
protected void buildBlockGUI(GUIFactory gui) { | |
IfCondition<AppRequestCtx> condition = new IfCondition<AppRequestCtx>( | |
new IModelSupplier<Boolean, AppRequestCtx>() { | |
@Override | |
public Boolean getModel(AppRequestCtx context) { | |
Long user = context.getCurrentUserIdSafe(); | |
return user != null && conf.getNewTabsEnabled().isPartition(user); | |
} | |
}, | |
webDkFacade.getTemplateEngine().create( | |
webDkFacade.getTemplateEngine().createInstance("standard.tabs.tabs").bindSupplier("tabs", | |
new IModelSupplier<Object, Object>() { | |
@Override | |
public Object getModel(Object context) { | |
BlockCtx ctx = (BlockCtx) context; | |
return ctx.tabs; | |
} | |
}) | |
) | |
); | |
addChild(condition); | |
} | |
@Override | |
protected IHttpCtx getRenderCtx(AppRequestCtx ctx, boolean isParentRendering) { | |
return new BlockCtx(ctx); | |
} | |
@Override | |
protected boolean isIntentionForRendering(AppRequestCtx ctx) { | |
return true; | |
} | |
public class BlockCtx extends AppRequestCtxWrapper { | |
public final Tabs tabs; | |
public BlockCtx(AppRequestCtx ctx) { | |
super(ctx); | |
tabs = new Tabs(); | |
tabs.addTab(new Tabs.Tab("sadf", "sdf", true)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment