GWT-Boostrap3 Dropdown, Dropdownmenu widgets do not have changehandler - gwt-bootstrap

Currently I am using GWT-bootstrap3 dropdown and dropdownmenu widgets. These widgets are in uibinder.xml file. In .java file, I am not able to handle change event on these widgets.
For example, If i select different options from dropdown, I need to have selected option. How to handle onselection change event in GWT-bootstrap3 dropdown widget?? Please share ideas..
Thanks

You can use AnchorListItem inside DropDownMenu, then you can addClickHandler to AnchorListItem objects.
In UI binder XML:
<b:DropDownMenu ui:field="menuUserInfo" addStyleNames="wt-dropdown-menu">
<b:AnchorListItem ui:field="menuItemPreferences" text="Preferences"/>
<b:AnchorListItem ui:field="menuItemLogout" text="Logout"/>
</b:DropDownMenu>
In Java code:
menuItemLogout.addClickHandler(new ClickHandler() {
#Override
public void onClick(ClickEvent clickEvent) {
// Added logout logic
}
});

Related

Android Xml File Button Hidden

In My Android Application, i have to hide button based on some condition,if condition is true than button is hide,otherwise it appear as it is, so for hide facility i'm using button's buttonID.setVisibility(View.INVISIBLE),so that button is hidden but it take space in xml file,so please suggest me to button is hidden and don't take space in xml file
visible - This means visible and it takes space.
invisible- This means invisible and it takes space.
gone- This means invisible and it DOESN'T takes space.
Use it as follows:
Visible tag in XML
android:visibility="visible"
Visible code in java
view.setVisibility(View.VISIBLE);
Invisible tag in XML
android:visibility="invisible"
Invisible code in java
view.setVisibility(View.INVISIBLE);
Gone tag in XML
android:visibility="gone"
Gone tag in java
view.setVisibility(View.GONE);
you should use View.GONE instead of View.INVISIBLE
As what #Tim suggested,you can always change the layout parameters for the elements not just set it's visibility to VISIBLE or GONE
Here the sample. Assume checkBox is clicked
checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
#Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if(isChecked){
buttonID.setVisibility(View.GONE);
}
else{
buttonID.setVisibility(View.VISIBLE);
// now settings the new parameters
AbsoluteLayout.LayoutParams params = ((AbsoluteLayout.LayoutParams) buttonID.getLayoutParams());
params.x = 100; // the new value
params.y = 100; // the new value
buttonID.setLayoutParams(params);
}
});
Source : Android: how to change layout_x, layout_y in an AbsoluteLayout dynamically?

Xpages attach event to partial refresh of pager in Data View

In a previous post I asked how to add a bootstrap class to a Data View. The answer was to add the class to the "table.dataview" in a script block. After the table is created the class is applied and all is well.
But when I use a pager the formatting disappears. I am using a partial refresh on the pager to only refresh the data table but doing so means that the bootstrap class does not get applied to the table.
I believe I need to add an event handler that will attach to the refresh action of the dataView to add the class. However I cannot get the event handler to work.
My code for the event handler is below.
<xp:eventHandler refreshMode="partial" submit="true"
id="applyCSS" refreshId="dataView1" event="parialRefresh"
value="what" loaded="false">
<xp:this.binding><![CDATA[#{javascript:"pager1"}]]></xp:this.binding>
<xp:this.action><![CDATA[#{javascript:("table.dataview").addClass("table-striped table-hover table-bordered table-condensed")}]]></xp:this.action>
</xp:eventHandler>
Oliver, the rendered=false was simply a typo - I was testing something and needed to temporarily suppress that.
Oliver and Paul,
Last night I was able to get the partial refresh to work.
I ran across this post by Mark Roden which explained how to do it. There were two different ways to accomplish this, one less and one more efficient. The code I used is below.
<xp:scriptBlock id="scriptBlock3">
<xp:this.value><![CDATA[$('.dataView1PanelWrapper').on("DOMNodeInserted", function(){
$("table.dataview").addClass("table-striped table-hover table-bordered table-condensed")
})]]></xp:this.value>
</xp:scriptBlock>
However, and isn't there almost always a however in Xpages, I have some sortable columns in the view and clicking on the sort brings up the same problem! I lose the class assignment!
So now I would have to intercept that event too, right?
Concerned where this will end. Don't like the idea of DOM Manipulation, and only want to do it if I have too.
I started by using a simple view. It worked great, but for some reason the spacing was messed up in the pagers. I found that by moving the pagers out of the view itself, I was able to get the alignment issue fixed. I think it would be better just to use a view, as I can assign the class directly and won't have to do all this manipulation. It is however very good to know how to do this for the future.
Is that what you would suggest?
==================================================
I have tried Paul Withers suggestion using an output script. This works on the initial page load, but not on any other changes to the data view - when the pager fires, or sorting or any of that. I am close, but no cigar yet. Any suggestions?
<xp:scriptBlock id="scriptBlock5" loaded="false">
<xp:this.value><![CDATA[dojo.require("dojo.behavior");
Behavior = {
".dataview": {
found: function(node) {
dojo.addClass(node,".table-striped table-hover table-bordered table-condensed");
//node.addClass("table-striped table-hover table-bordered table-condensed");
}
}
}
dojo.ready(function() {
dojo.behavior.add(Behavior);
dojo.behavior.apply();
});
//Make sure that future pagers are also straightened out
dojo.subscribe("partialrefresh-complete", null, function(method, form, refreshId) {
dojo.behavior.apply();
});]]></xp:this.value>
</xp:scriptBlock>
Move your existing xp:scriptBlock with the working code inside a facet of the xe:dataView. Then the styling will get applied on initial load and on all partial refreshes.
You should call your CSJS stuff to add the class in the onComplete property of the event handler - hard to find, just highlight the event handler object in source code or outline and then open "All properties" to find the "onComplete" property. This event allows CSJS to be called.
BTW: why is the loaded property = false? The event will never we rendered.
dojo.behavior, dojo.ready and dojo.subscribe should allow you to manage this. dojo.behavior allows you to define a particular behaviour for a particular collection of elements which will be retrieved via a Dojo query. dojo.ready will (I believe) run the code when the page initially loads and dojo.subscribe("partialrefresh-complete", null, function(method, form, refreshId) {...} will run the code aftedr a partial refresh.
Here's sample code I used for converting a DataView's category column images to Font Awesome icons, so the Behavior = {...} bit will need amending.
Behavior = {
// Convert xp:pagers to Bootstrap
".catColumn a img": {
found: function(img_node) {
var imgSrc = dojo.getNodeProp(img_node, "alt").toLowerCase();
if (imgSrc.indexOf("collapse") >= 0) {
dojo.place('<i class="fa fa-minus-square"></i> ', img_node, 'replace');
} else {
dojo.place('<i class="fa fa-plus-square"></i> ', img_node, 'replace');
}
}
}
}
dojo.ready(function() {
dojo.behavior.add(Behavior);
dojo.behavior.apply();
});
//Make sure that future pagers are also straightened out
dojo.subscribe("partialrefresh-complete", null, function(method, form, refreshId) {
dojo.behavior.apply();
});

Main Menu Navigation Item not linked to a content item but collapsing a sub menu

I have got a multi level navigation in Orchard CMS which shows sub menu items on hovering. When I click, it opens a content menu item. This works well on a PC but not on a mobile device. In case of a mobile device or touch device in general it should collapse the menu instead of jumping to another page.
I am looking for an easy and clean approach to solve this.
Is there a way to create such a menu item only acting as an opener for the sub menu items instead of actually linking to a page?
Some background information: It is actually a theme based on twittter bootstrap 3
You can extend the MenuItem shape (~/Core/Shapes/Views/MenuItem.cshtml) to differentiate between parent and children
So first create under {YourTheme}/Views new view called MenuItem.cshtml and paste in the following code
#{
// odd formatting in this file is to cause more attractive results in the output.
var items = Enumerable.Cast<dynamic>((System.Collections.IEnumerable)Model);
}
#{
if (!HasText(Model.Text))
{
#DisplayChildren(Model)
}
else
{
if ((bool)Model.Selected)
{
Model.Classes.Add("current");
}
#* morphing the shape to keep Model untouched*#
Model.Metadata.Alternates.Clear();
if (items.Any())
{
Model.Classes.Add("dropdown");
Model.Metadata.Type = "MenuItemLinkParent";
}
else
{
Model.Metadata.Type = "MenuItemLink";
}
#* render the menu item only if it has some content *#
var renderedMenuItemLink = Display(Model);
if (HasText(renderedMenuItemLink))
{
var tag = Tag(Model, "li");
#tag.StartElement
#renderedMenuItemLink
if (items.Any())
{
<ul>
#DisplayChildren(Model)
</ul>
}
#tag.EndElement
}
}
}
Now just create another view called MenuItemLinkParent.cshtml and create simple hyperlink placeholder that doesn't link anywhere
<a>#Model.Text</a>
Now any MenuItem which becomes parent will lose it's href link (you can also edit html structure and classes this way, if necessary for bootstrap). Easy and clean enough? :)

How to add custom menu after sub-Window menu in Eclipse RCP?

I have a sub-menu under the "Window" menu and I want to add my custom menu under it.
I can add my custom menu under "Window" menu with menuContribution's LocationURI:menu:window?after=additions.
The problem is that sub-menu is generated on ActionBarAdvisor class with this lines
#Override
protected void fillWindowMenu(IMenuManager windowMenu) {
IWorkbenchWindow window = getActionBarConfigurer().getWindowConfigurer().getWindow();
windowMenu.add(new GroupMarker(IWorkbenchActionConstants.WB_START));
IMenuManager perspectiveMenu = new MenuManager(
lineer.toplulastirma.Messages.ToplulastirmaActionBarAdvisor_4,
ContributionItemFactory.PERSPECTIVES_SHORTLIST.getId());
perspectiveMenu.add(ContributionItemFactory.PERSPECTIVES_SHORTLIST.create(window));
windowMenu.add(perspectiveMenu);
IMenuManager viewMenu = new MenuManager(lineer.toplulastirma.Messages.ToplulastirmaActionBarAdvisor_5,
ContributionItemFactory.VIEWS_SHORTLIST.getId());
viewMenu.add(ContributionItemFactory.VIEWS_SHORTLIST.create(window));
windowMenu.add(viewMenu);
windowMenu.add( new Separator());
}
So I don't know how to access its id to edit my LocationURI.
I tried these:
menu:window?after=lineer.toplulastirma.Messages.ToplulastirmaActionBarAdvisor_5
menu:lineer.toplulastirma.Messages.ToplulastirmaActionBarAdvisor_5?after=additions
menu:viewMenu?after=additions
menu:window?after=viewMenu
They didn't work.

dijit menu onmouseover

I am using menu using dijit.menu and Its work with right click and left click.
How I open the menu on mouse over and close on onmouseout?
dijitActionMenu = new dijit.Menu({
targetNodeIds:[actionMenuId],
leftClickToOpen:"true"
});
Have you tried something like
// Create a new Tooltip
var tip = new dijit.Tooltip({
// Label - the HTML or text to be placed within the Tooltip
label: '<div class="myTipType">This is the content of my Tooltip!</div>',
// Delay before showing the Tooltip (in milliseconds)
showDelay: 250,
// The nodes to attach the Tooltip to
// Can be an array of strings or domNodes
connectId: ["myElement1","myElement2"]
});
More details are here dialogs_tooltips.Even dijit.Menu have onMouseOver even.
onMouseOver Event
I am able to get the dijit/Menu onmouseover.
Create an element which will invoke onmouseover event.
Element
show() will call custom widget which will create menu for you.
E.g.,
show = function() {
var roll = new rollover()
}
And rollover.js will be the custom widget.
From the constructor of it, you can invoke the function and create the menu.
pMenu = new Menu({ class: "rollovermenu", id: "rolloverid" });

Resources