I am using a TabLayoutPanel in GWT and I want to have the last tab show up on the right side of the page. Is it possible to do this?
Common idea:
set tab container width to "auto" instead of predefined "16384px"
set "float: right" css property to last tab
move last tab to firts position
public void onModuleLoad() {
.....
// init TabLayoutPanel
.....
Widget rightTab = tabPanel.getTabWidget(0).getParent();
DOM.setStyleAttribute(rightTab.getElement(), "float", "right");
Widget tabBar = rightTab.getParent();
tabBar.setWidth("auto");
tabPanel.selectTab(1);
}
If you want to align all tabs to right try this:
.gwt-TabBar .gwt-TabBarFirst {
width: 100%;
}
.gwt-TabBar .gwt-TabBarRest {
width: 4px;
}
.gwt-TabBar .gwt-TabBarFirst-wrapper {
width: 100%;
}
Short Answer - NO.
I drilled down to the source at GWT 2.3 and AFAIK it easier to build your own composite from TabBar and StackLayoutPanel than start fighting this implementation.
Just to save you an effort it cannot be centered easily too.
I am sorry it is like this.
it all hardcoded...
private static final int BIG_ENOUGH_TO_NOT_WRAP = 16384;
private final FlowPanel tabBar = new FlowPanel();
...
tabBar.getElement().getStyle().setWidth(BIG_ENOUGH_TO_NOT_WRAP, Unit.PX);
Why not pure CSS solution ? It is good practice to separate your code from design.
.gwt-TabLayoutPanelTabs {
width: auto!important;
}
.gwt-TabLayoutPanelTab {
float: right;
}
Remember that your tabs will come in reverse order (first added will be first on the right)
It is possible and will be very easy if you create your own tab.Just create an png image of tab shape (which is having rounded corner at top).Write one css rule.Take one FlextTable and apply that css to each cell that will be your tabs and then add that FlexTable into another mainTable. So in your mainTable in first row there will be tabFlexTable and in second row whatever you want to display after selecting particular tab.So for the first row apply horizontal alignment to right. This the way and same way I am also using in my professional projects.
Related
Demo
I have 2 + 5 blocks here, in small screen, each panel in blocks are in full width.
But in large screen, blocks are in 3:3:3 or 6:3. I want them all in a single row.
each section is contained in <div class="sapUiRespGridSpanL4 sapUiRespGridSpanM6 sapUiRespGridSpanS12 sapUiRespGridSpanXL3">
How to change it to class="sapUiRespGridSpanL12 sapUiRespGridSpanM12 sapUiRespGridSpanS12 sapUiRespGridSpanXL12" ?
I've tried to add layout in Panel, but not working.
Refrence:
sap.uxap.ObjectPageLayout Documentation
layout of blocks, blocks are in the same color, hard to specify
Finally after 1.5 hours figured out
Reason: Blocks will have to be extended from BlockBase to apply columnLayout.
Extending the BlockBase:
sap.ui.define(["sap/uxap/BlockBase"], function (BlockBase) {
"use strict";
var BlockPanel = BlockBase.extend("sap.uxap.sample.ObjectPageSubSectionSized.blocks.BlockPanel", {
metadata: {
/* no additional views provided */
}
});
return BlockPanel;
});
Then create a view and controller using the above new ui5 extended control. Use that in your page with columnLayout
xmlns:sample="sap.uxap.sample.ObjectPageSubSectionSized.blocks"
...
...
<uxap:blocks>
<sample:BlockPanel columnLayout="4"/>
</uxap:blocks>
columnLayout can't be applied if you don't extend block base. (which is really pathetic design). Nevertheless, values range from 1-4 and "auto".
Created working plnkr here
How to build custom SAPUI control?
You can wrap the target controls up with sap.uxap.BlockBase[API]. BlockBase controls are intended to be used inside sap.uxap.ObjectPageSubSection (hence the name <blocks>) and support customizing the grid spans with the property columnLayout.
Here is a demo: https://embed.plnkr.co/lSrDk9/?show=view%2FHome.view.xml,preview
<uxap:ObjectPageSubSection>
<block:MyBlock columnLayout="4"/>
<block:MyBlock columnLayout="4"/>
</uxap:ObjectPageSubSection>
Provide a not elegant, but very fast way: Overwrite CSS
<uxap:ObjectPageSubSection class="fullWidthPanel">
/* CSS specificity */
.fullWidthPanel .sapUiRespGrid.sapUiRespGridHSpace1 > div {
width: 98.88888889%;
width: -webkit-calc(100% - 1rem);
width: calc(100% - 1rem)
}
the button is automatically generated by the ActionCell in gwt, I want to change the width and height of the generated button, any method?
I chekced the ActionCell has no any addStyleName to allow me to change the css of the button.
You have several options.
If you use this cell in a CellTable or DataGrid, set the style on a column which is built using ActionCell:
myColumn.setCellStyleNames("myButtonStyle");
You can also set this style on the parent element which includes ActionCell:
.myButtonStyle button {
background: red;
}
or, even more specific, if necessary:
.myButtonStyle td button {
background: red;
}
I want to use the CaptionPanel inside a Layout Panel (DockLayoutPanel) .
The problem is that there is no CaptionLayoutPanel(like SimpleLayoutPanel) implementation and therefore if I want to use
this panel inside a Layout Panel, all childs will loose the resize events because the "resize-chain" is broken through the CaptionPanel.
Is there any workaround?
Extend CaptionPanel and implement the ProvidesResize and RequiresResize interfaces
CustomCaptionPanel extends CaptionPanel implements RequiresResize,ProvidesResize {
public void onResize() {
if (getContentWidget() instanceof RequiresResize) {
((RequiresResize) getContentWidget()).onResize();
}
}
The easiest solution is not to use CaptionPanel.
If you want children to respond to resize events, add a layer to your LayoutPanel that will hold a caption (Label), and another layer that will contain a child widget that you want to respond to resize. You can style these widgets any way you like (e.g. a Label can look like a tab or a panel with some background and rounded corners, etc.)
An alternative solution is style your CaptionPanel as Roddy of the Frozen Peas suggested, and then add a ResizeHandler to your window. When triggered, you can set the size of a child widget to
myChildWidget.setSize(myCaptionPanel.getOffsetWidth() + "px", myCaptionPanel.getOffsetHeight() + "px");
I am implementing multiple themes in our GWT applications.
The problem is when a DataGrid is constructed, I can't find a way to change the style resource that has been passed to it. Does anybody know how to solve the problem. Or on every theme change, do we have to reconstruct the grid?
Any other new idea to solve the problem (having multiple themes on these widgets) is appreciated.
Thanks.
You could use uibinder.
At this page
https://developers.google.com/web-toolkit/doc/latest/DevGuideUiBinder#Programmatic_access,
search for the section
Programmatic access to inline Styles
However, you need to be familiar with uibinder.
I was able to do this using -
cellTable.setRowStyles(new RowStyles>() {
#Override
public String getStyleNames(Map<String, String> row, int rowIndex) {
if (rowIndex % 2 == 0) {
return "cellTableEvenRow";
} else {
return "cellTableOddRow";
}
}
});
Since, I had to provide the user 3 color themes, I used 3 style sheets for each color and specified the below style with different colors in each style sheet.
.cellTableEvenRow {
background: #fffff !important;
}
.cellTableOddRow {
background: #E9FDE4 !important;
}
Hope it helps!
In my page I have a Gxt ContentPanel with a white background. However, when the user mouses over the Header of the ContentPanel, I would like the background to change colors.
I tried achieving this by using the protected addStyleOnOver method of Gxt Component, but it doesn't have any effect. Is there anything else I need to do to use that methods (I'm already sinking the ONMOUSEOVER and ONMOUSEOUT events), or a better way to change the background?
you can do this using below code its working
ContentPanel contentPanel = new ContentPanel();
contentPanel.setStyleName("background");
and write below code in your css
.background:hover .x-panel-body {background-color: red !important;}
i'm not sure if this works, but you can test it...
final ContentPanel test = new ContentPanel();
test.getHeader().addListener(Events.OnMouseOver, new Listener<BaseEvent>() {
#Override
public void handleEvent(BaseEvent be) {
test.getHeader().setStyleName("your_new_style");
// or test.setStyleName("your_new_style");
}
});
You could simply add a style to the header, then add some css to change the color.
test.getHeader().addStyleName("my_style")
# css
my_style:hover { background-color: yellow; }
This is a bit trickier if you want to change the bg of the whole ContentPanel during onMouseOver of the header, in which case, add the mouse over event to the header where handle event adds style to the content panel (or content panel body depending on what you want), then add the appropriate styles to you css.
# css
my_style { background-color: yellow; }