Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add setIconPosition method

  • Loading branch information...
commit 339e7bcc8cf0de9e57ddb75c663af5c892f270ba 1 parent 904245a
@soundTricker soundTricker authored
View
9 src/main/java/com/github/gwtbootstrap/client/ui/AccordionGroup.java
@@ -6,6 +6,7 @@
import com.github.gwtbootstrap.client.ui.base.HasVisibleHandlers;
import com.github.gwtbootstrap.client.ui.base.IconAnchor;
import com.github.gwtbootstrap.client.ui.constants.Constants;
+import com.github.gwtbootstrap.client.ui.constants.IconPosition;
import com.github.gwtbootstrap.client.ui.constants.IconSize;
import com.github.gwtbootstrap.client.ui.constants.IconType;
import com.github.gwtbootstrap.client.ui.event.HiddenHandler;
@@ -210,5 +211,13 @@ public void setHeading(String heading) {
public void setCustomIconStyle(String customIconStyle) {
trigger.setCustomIconStyle(customIconStyle);
}
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void setIconPosition(IconPosition position) {
+ trigger.setIconPosition(position);
+ }
}
View
9 src/main/java/com/github/gwtbootstrap/client/ui/Dropdown.java
@@ -17,6 +17,7 @@
import com.github.gwtbootstrap.client.ui.base.DropdownBase;
import com.github.gwtbootstrap.client.ui.base.IconAnchor;
+import com.github.gwtbootstrap.client.ui.constants.IconPosition;
import com.github.gwtbootstrap.client.ui.constants.IconSize;
import com.github.gwtbootstrap.client.ui.constants.IconType;
@@ -103,4 +104,12 @@ public void setCustomIconStyle(String customIconStyle) {
trigger.setCustomIconStyle(customIconStyle);
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void setIconPosition(IconPosition position) {
+ trigger.setIconPosition(position);
+ }
+
}
View
9 src/main/java/com/github/gwtbootstrap/client/ui/DropdownButton.java
@@ -18,6 +18,7 @@
import com.github.gwtbootstrap.client.ui.base.DropdownBase;
import com.github.gwtbootstrap.client.ui.base.IconAnchor;
import com.github.gwtbootstrap.client.ui.constants.ButtonType;
+import com.github.gwtbootstrap.client.ui.constants.IconPosition;
import com.github.gwtbootstrap.client.ui.constants.IconSize;
import com.github.gwtbootstrap.client.ui.constants.IconType;
import com.github.gwtbootstrap.client.ui.resources.ButtonSize;
@@ -134,4 +135,12 @@ public void setIconSize(IconSize size) {
public void setCustomIconStyle(String customIconStyle) {
trigger.setCustomIconStyle(customIconStyle);
}
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void setIconPosition(IconPosition position) {
+ trigger.setIconPosition(position);
+ }
}
View
6 src/main/java/com/github/gwtbootstrap/client/ui/NavWidget.java
@@ -19,6 +19,7 @@
import com.github.gwtbootstrap.client.ui.base.IconAnchor;
import com.github.gwtbootstrap.client.ui.base.ListItem;
import com.github.gwtbootstrap.client.ui.constants.Constants;
+import com.github.gwtbootstrap.client.ui.constants.IconPosition;
import com.github.gwtbootstrap.client.ui.constants.IconSize;
import com.github.gwtbootstrap.client.ui.constants.IconType;
import com.google.gwt.event.dom.client.ClickEvent;
@@ -184,4 +185,9 @@ public String getName() {
public void setCustomIconStyle(String customIconStyle) {
anchor.setCustomIconStyle(customIconStyle);
}
+
+ @Override
+ public void setIconPosition(IconPosition position) {
+ anchor.setIconPosition(position);
+ }
}
View
9 src/main/java/com/github/gwtbootstrap/client/ui/SplitDropdownButton.java
@@ -19,6 +19,7 @@
import com.github.gwtbootstrap.client.ui.base.HasType;
import com.github.gwtbootstrap.client.ui.base.IconAnchor;
import com.github.gwtbootstrap.client.ui.constants.ButtonType;
+import com.github.gwtbootstrap.client.ui.constants.IconPosition;
import com.github.gwtbootstrap.client.ui.constants.IconSize;
import com.github.gwtbootstrap.client.ui.constants.IconType;
import com.github.gwtbootstrap.client.ui.resources.ButtonSize;
@@ -134,4 +135,12 @@ public void setCustomIconStyle(String customIconStyle) {
button.setCustomIconStyle(customIconStyle);
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void setIconPosition(IconPosition position) {
+ button.setIconPosition(position);
+ }
+
}
View
9 src/main/java/com/github/gwtbootstrap/client/ui/Tab.java
@@ -22,6 +22,7 @@
import com.github.gwtbootstrap.client.ui.base.IsResponsive;
import com.github.gwtbootstrap.client.ui.base.Style;
import com.github.gwtbootstrap.client.ui.constants.Device;
+import com.github.gwtbootstrap.client.ui.constants.IconPosition;
import com.github.gwtbootstrap.client.ui.constants.IconSize;
import com.github.gwtbootstrap.client.ui.constants.IconType;
import com.google.gwt.event.dom.client.ClickHandler;
@@ -266,4 +267,12 @@ public void addDecorate(Widget w) {
public void setCustomIconStyle(String customIconStyle) {
link.setCustomIconStyle(customIconStyle);
}
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void setIconPosition(IconPosition position) {
+ link.setIconPosition(position);
+ }
}
View
7 src/main/java/com/github/gwtbootstrap/client/ui/base/AddOn.java
@@ -18,6 +18,7 @@
import com.github.gwtbootstrap.client.ui.Icon;
import com.github.gwtbootstrap.client.ui.InputAddOn;
import com.github.gwtbootstrap.client.ui.constants.Constants;
+import com.github.gwtbootstrap.client.ui.constants.IconPosition;
import com.github.gwtbootstrap.client.ui.constants.IconSize;
import com.github.gwtbootstrap.client.ui.constants.IconType;
import com.google.gwt.uibinder.client.UiChild;
@@ -135,4 +136,10 @@ public void setCustomIconStyle(String customIconStyle) {
icon.addStyleName(customIconStyle);
}
+ @Override
+ @Deprecated
+ public void setIconPosition(IconPosition position) {
+ throw new UnsupportedOperationException("Addon does not support this methods");
+ }
+
}
View
7 src/main/java/com/github/gwtbootstrap/client/ui/base/HasIcon.java
@@ -15,6 +15,7 @@
*/
package com.github.gwtbootstrap.client.ui.base;
+import com.github.gwtbootstrap.client.ui.constants.IconPosition;
import com.github.gwtbootstrap.client.ui.constants.IconSize;
import com.github.gwtbootstrap.client.ui.constants.IconType;
@@ -56,4 +57,10 @@
* @param customIconStyle
*/
public void setCustomIconStyle(String customIconStyle);
+
+ /**
+ * Set icon position , left or right
+ * @param position icon's position
+ */
+ public void setIconPosition(IconPosition position);
}
View
33 src/main/java/com/github/gwtbootstrap/client/ui/base/IconAnchor.java
@@ -17,11 +17,10 @@
import com.github.gwtbootstrap.client.ui.Icon;
import com.github.gwtbootstrap.client.ui.constants.Constants;
+import com.github.gwtbootstrap.client.ui.constants.IconPosition;
import com.github.gwtbootstrap.client.ui.constants.IconSize;
import com.github.gwtbootstrap.client.ui.constants.IconType;
import com.google.gwt.dom.client.AnchorElement;
-import com.google.gwt.dom.client.Document;
-import com.google.gwt.dom.client.Text;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.HasClickHandlers;
@@ -70,7 +69,7 @@
private Icon icon = new Icon();
- private Text text = Document.get().createTextNode("");
+ private TextNode text = new TextNode();
private Caret caret = new Caret();
@@ -81,9 +80,31 @@
public IconAnchor() {
super("a");
super.add(icon);
- super.getElement().appendChild(text);
+ super.add(text);
setEmptyHref();
}
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void setIconPosition(IconPosition position) {
+
+ icon.removeFromParent();
+ text.removeFromParent();
+
+ if(IconPosition.RIGHT == position) {
+ this.insert(text , 0);
+ this.add(icon);
+ return;
+
+ } else if(IconPosition.LEFT == position){
+ this.insert(icon, 0);
+ this.insert(text, 1);
+ return;
+ }
+
+ }
/**
* {@inheritDoc}
@@ -106,14 +127,14 @@ public void setIconSize(IconSize size) {
*/
public void setText(String text) {
- this.text.setData(" " + text + " ");
+ this.text.setText(" " + text + " ");
}
/**
* {@inheritDoc}
*/
public String getText() {
- return text.getData();
+ return text.getText();
}
/**
View
34 src/main/java/com/github/gwtbootstrap/client/ui/base/TextNode.java
@@ -0,0 +1,34 @@
+package com.github.gwtbootstrap.client.ui.base;
+
+import com.google.gwt.dom.client.Document;
+import com.google.gwt.dom.client.Element;
+import com.google.gwt.dom.client.Text;
+import com.google.gwt.user.client.ui.HasText;
+import com.google.gwt.user.client.ui.Widget;
+
+public class TextNode extends Widget implements HasText {
+
+ private Text baseNode;
+
+
+ public TextNode() {
+ baseNode = Document.get().createTextNode("");
+ setElement(baseNode.<Element>cast());
+ }
+
+
+ @Override
+ public String getText() {
+ return baseNode.getData();
+ }
+
+
+ @Override
+ public void setText(String text) {
+ baseNode.setData(text);
+ }
+
+
+
+
+}
View
5 src/main/java/com/github/gwtbootstrap/client/ui/constants/IconPosition.java
@@ -0,0 +1,5 @@
+package com.github.gwtbootstrap.client.ui.constants;
+
+public enum IconPosition {
+ LEFT,RIGHT;
+}
View
12 src/showcase/java/com/github/gwtbootstrap/showcase/client/Buttons.java
@@ -20,6 +20,7 @@
import com.github.gwtbootstrap.client.ui.Button;
import com.github.gwtbootstrap.client.ui.ValueListBox;
import com.github.gwtbootstrap.client.ui.constants.ButtonType;
+import com.github.gwtbootstrap.client.ui.constants.IconPosition;
import com.github.gwtbootstrap.client.ui.constants.IconSize;
import com.github.gwtbootstrap.client.ui.constants.IconType;
import com.github.gwtbootstrap.showcase.client.util.EnumRenderer;
@@ -43,6 +44,9 @@
@UiField(provided=true)
ValueListBox<IconSize> iconSize = new ValueListBox<IconSize>(new EnumRenderer<IconSize>("Choose icon size"));
+ @UiField(provided=true)
+ ValueListBox<IconPosition> iconPosition = new ValueListBox<IconPosition>(new EnumRenderer<IconPosition>("Choose icon position"));
+
private static ButtonsUiBinder uiBinder = GWT.create(ButtonsUiBinder.class);
interface ButtonsUiBinder extends UiBinder<Widget, Buttons> {
@@ -56,6 +60,9 @@ public Buttons() {
iconSize.setValue(null);
iconSize.setAcceptableValues(Arrays.asList(IconSize.values()));
+ iconPosition.setValue(null);
+ iconPosition.setAcceptableValues(Arrays.asList(IconPosition.values()));
+
initWidget(uiBinder.createAndBindUi(this));
}
@@ -98,6 +105,11 @@ void onChangeIconSize(ValueChangeEvent<IconSize> e) {
effectiveButton.setIconSize(e.getValue());
}
+ @UiHandler("iconPosition")
+ void onChangeIconPosition(ValueChangeEvent<IconPosition> e) {
+ effectiveButton.setIconPosition(e.getValue());
+ }
+
@UiHandler("toggle")
void onChangeToggle(ValueChangeEvent<Boolean> e) {
effectiveButton.setToggle(e.getValue());
View
1  src/showcase/java/com/github/gwtbootstrap/showcase/client/Buttons.ui.xml
@@ -288,6 +288,7 @@
<b:Controls>
<b:ValueListBox ui:field="icons"/>
<b:ValueListBox ui:field="iconSize"/>
+ <b:ValueListBox ui:field="iconPosition"/>
</b:Controls>
</b:ControlGroup>
<b:ControlGroup>
View
6 src/showcase/java/com/github/gwtbootstrap/showcase/client/Navigation.ui.xml
@@ -122,6 +122,12 @@
dropdown2
</b:Paragraph>
</b:Tab>
+ <b:Tab icon="GITHUB" iconPosition="RIGHT" heading="Right icon Tab">
+ <b:Heading size="3">Right icon tab</b:Heading>
+ <b:Paragraph>
+ Right icon tab
+ </b:Paragraph>
+ </b:Tab>
</b:DropdownTab>
<b:TabPane heading="prost">
<g:Label>Lalala</g:Label>
Please sign in to comment.
Something went wrong with that request. Please try again.