I'm using GWT 2.3.0 and Sencha EXT 2.3.1. I can not upgrade due to software requirements.
I've got a combobox, in a form, with some values.
A few of these values cannont be entirely displayer because the width of the combobox is too short. But I'm not allowed to enlarge this field.
Is there a solution to add a tooltip, or show the entire value when you are hovering the value in the list ?
Or make the displayed list larger than the display field ?
Thx,
Q.
Actually it's pretty simple. Sencha Gxt 2.3 Examples has already provide a quite good example on how to add tooltip to combobox. But I will post it again for you in here, so here it goes:
public void onModuleLoad() {
VerticalPanel vp = new VerticalPanel();
vp.setSpacing(10);
ListStore<State> states = new ListStore<State>();
states.add(getStates());
ComboBox<State> combo = new ComboBox<State>();
combo.setEmptyText("Select a state...");
combo.setDisplayField("name");
combo.setTemplate(getTemplate());
combo.setWidth(150);
combo.setStore(states);
combo.setTypeAhead(true);
combo.setTriggerAction(TriggerAction.ALL);
vp.add(combo);
RootPanel.get().add(vp);
}
private native String getTemplate() /*-{
return [
'<tpl for=".">',
'<div class="x-combo-list-item" qtip="{slogan}" qtitle="State Slogan">{name}</div>',
'</tpl>' ].join("");
}-*/;
The key is to use a template to render the combobox value with qtip added to each one of the value div. You can read more about it in here
If you want to see the result, it will looks like in sencha gxt 2 examples in here, just take a look at the second combobox, it will show you tooltip every time you hover the combobox item.
That's it, hope it will help you. Thanks & Regards.
Related
To set number of visible Items in GWT ListBox we have ListBox.setVisibleItemCount() API but I didn't find any way to achieve the same in SmartGWT's SelectItem. My requirement is to display an image and text in SelectItem list and like in GWT we should be able to display multiple items at a time.
There is an option to set mutiselect using selectItem.setMultiple(true); and
selectItem.setMultipleAppearance(MultipleAppearance.GRID); but if we set multiselect in this way, image is not displaying in the list box only text is coming.
I am not getting whether displaying multiple items is possible in SmartGWT's SelectItem (with image) or not, or Am i missing something here.
This should be possible. Here is the example from the official SmartGWT showcase.
final SelectItem selectItemWithIcons = new SelectItem();
selectItemWithIcons.setMultiple(true);
selectItemWithIcons.setTitle("Select");
selectItemWithIcons.setHint("<nobr>Multi Select with icons</nobr>");
selectItemWithIcons.setValueMap(valueMap);
selectItemWithIcons.setImageURLPrefix("flags/16/");
selectItemWithIcons.setImageURLSuffix(".png");
LinkedHashMap<String, String> valueIcons = new LinkedHashMap<String, String>();
valueIcons.put("US", "US");
valueIcons.put("CH", "CH");
valueIcons.put("JA", "JA");
valueIcons.put("IN", "IN");
valueIcons.put("GM", "GM");
valueIcons.put("FR", "FR");
valueIcons.put("IT", "IT");
valueIcons.put("RS", "RS");
valueIcons.put("BR", "BR");
valueIcons.put("CA", "CA");
valueIcons.put("MX", "MX");
valueIcons.put("SP", "SP");
selectItemWithIcons.setValueIcons(valueIcons);
If you have some images called US.png, CH.png, etc, at GWT.getHostPageBaseURL() + /flags/16/ this should work.
https://www.smartclient.com/smartgwt/showcase/#multi_select_combobox_category
Pretty straight-forward question, but I can't find this anywhere. I'm using WicketStuff's TinyMCE to make a Rich Text Editor in my application, and can't find anywhere how to get the input from the text area. For brevity's sake, the following is a simplified version of the code I'm using.
private String input;
...
TinyMCESettings settings = new TinyMCESettings(TinyMCESettings.Theme.simple);
TextArea<String> textArea = new TextArea<String>("editor", new PropertyModel<String>(this, "input"));
textArea.add(new TinyMceBehavior(settings));
form.add(textArea);
Using this, I would expect the usual manner to simply use my String 'input' since it's set as the model. This always results in null as the model isn't being updated.
I tried using the auto-save plugin in case it was expecting the save button to be clicked (which doesn't update the model either), and neither worked. The only thing I've been able to do to get the user's input is to add a HiddenField, with a new model, and make a JavaScript call like
document.getElementById('hiddenField').value = tinyMCE.get('editor').getContent();
but this has led to other problems with trying to call the JS in the desired place and to get it to work properly. I feel this shouldn't be necessary anyways, as surely someone must have implemented a method to get the contents of the text area being used.
Any help would be greatly appreciated.
Thanks to a blog post at Nevermind Solutions, the way to get the model updated is to add the following JavaScript to the form's submitting button:
onclick="tinyMCE.triggerSave(true,true);"
My text area is inside a panel with the button outside of the panel, so it doesn't directly work for me. The trick was to add the JavaScript call to the button's onSubmit, move the logic into the onAfterSubmit, and to make the button MultiPart so that it could call the save trigger before doing the other logic associated to the model.
Hope this might help some others in the future.
You have to add a modifier to the submit button so that the model can update.
AjaxButton btnSubmit = new AjaxButton("btnSubmit", new Model()) {
#Override
public void onSubmit(AjaxRequestTarget target, Form<?> form) {
doSomething();
}
};
btnSubmit.add(new TinyMceAjaxSubmitModifier());
Have a look here for more info
I want to add a datebox similar to the one in give link
http://www.jeasyui.com/demo/main/index.php?plugin=DateBox&theme=default&dir=ltr&pitem=
in my web aplication project(smartgwt).
In short I want the datebox(jquery) equivalent in smartGwt.
when i googled i found out there is something called dateChooser in smartGwt but it works like a calendar i want something like the one in above link textfield with a button which on clicking displays the calendar and the selected date appears on the textbox.
please give any suggestions i am using smartGwt LGPL.
You can use a DateItem with useTextField=true to get the required behavior.
DateItem dateItem2 = new DateItem();
dateItem2.setTitle("Date");
dateItem2.setUseTextField(true);
dateItem2.setHint("<nobr>Direct date input</nobr>");
Check 'Date Controls' section in http://www.smartclient.com/smartgwt/showcase/#form_controls_various.
DateItem is a FormItem, meaning you need to put it in a form, and will work just like other form controls.
DateChooser on the other hand is a standalone widget that you can embed among other widgets on its own.
I haven't seen such a component in smartgwt showcase but there is something called PickerIcon which can be coupled to a TextItem to achieve what you want.
PickerIcon datePicker = new PickerIcon(PickerIcon.DATE, new FormItemClickHandler() {
public void onFormItemClick(FormItemIconClickEvent event) {
SC.say("Date Picker clicked"); // or show a dateChooser component
}
});
TextItem datePickerControl = new TextItem("datePicker", "Date Picker");
datePickerControl.setIcons(datePicker);
http://www.smartclient.com/smartgwt/showcase/#form_category_picker_icons
Hope this can help !
I am trying to set ids for tabs in the tabpanel. The code that I have written is:
Panel dateTab = new VerticalPanel();
queryTabPanel.addTab("Date", dateTab);
where queryTabPanel is another TabPanel.
My Problem: is to set Ids for the Tabs. So that I can click on the 'Date' tab in the tabpanel.
What I have tried : is by manipulating DOM like :
DOM.setElementAttribute(productTab.getElement(), "id", "Swagatika");
But that does not seem to be working. :(
Has anyone any idea if that is possible, if so How difficult is to add IDs.
Thanks in advance.
For testing using WebDriver, you're supposed to use a special module that <inherits name="com.google.gwt.user.Debug"/> (see "Renaming module" in the GWT DevGuide), and call ensureDebugId on your widgets.
In your case, after calling queryTabPanel.ensureDebugId("queryTabPanel"), the first tab would have an ID of gwt-debug-queryTabPanel-bar-tab1 (see TabPanel.html#onEnsureDebugId for the details).
In addition to the Debug flag you need to use TabLayoutPanel.getTabWidget(...) and use ensureDebugId on it like the following:
SimpleLayoutPanel newTabPanel = new SimpleLayoutPanel();
tabLayoutPanel.add(newTabPanel, "Date Tab");
tabLayoutPanel.getTabWidget(newTabPanel).ensureDebugId("MyDateTab");
Notice that setting the debug ID before adding the Widget to the tabLayoutPanel won't have any effect. Also make sure to use getTabWidget(..) and not getWidget(...).
I'm looking for a Combo(Viewer) in SWT/JFace which supports autocomplete / type-ahead, i.e. the user can enter a couple of characters and the drop down list should show all matching elements.
You can also check out the org.eclipse.jface.fieldassist.AutoCompleteField class. It's not a combo, just a text field, but it adds auto complete functionality as if it were a combo very easily. You can do something as simple as this:
Text textField = new Text(parentComposite, SWT.BORDER);
new AutoCompleteField(textField, new TextContentAdapter(), new String[]
{"autocomplete option 1", "autocomplete option 2"});
I don't think there is anything like this built into either Combo or ComboViewer.
As thehiatus suggests org.eclipse.jface.fieldassist.AutoCompleteField is probably the best place to look for this, however, there is support for Combos:
new AutoCompleteField(combo, new ComboContentAdapter(), new String[]
{"item0", "item1"});
You may be interested in Eclipse's "Content Assist" feature. You can see it in action when using the Eclipse IDE's Java editor. As you edit source code, you will sometimes see a drop-down menu with phrases that complete what you were typing. (Note that you can press Ctrl+Space to force the drop-down menu to be displayed.)
You can implement this in your own SWT/JFace application as well. The "Java Developer's Guide to Eclipse" has an sample application that implements Content Assist. The sample application is a SQL editor, and it is described in Chapter 26, "Building a Custom Text Editor with JFace Text." There's actually an online overview of the chapter here. The sample SQL editor project, com.ibm.jdg2e.editor.jfacetext.sql, can be found here.
On the other hand, if you want to create your own Combo widget and auto-populate it based on input that is being entered, then this might not be very applicable. I'm thinking the org.eclipse.jface.viewers.ComboViewer might be helpful (though I'm not positive).
Check out: http://sourceforge.net/projects/swtaddons/
I use it in my project (with a little tweak).
It's really dead easy to set this up.
As thanks to paz117's comment, thought I'd share the code to make this work:
String[] proposals = new String[controller.model().size()];
for (int i = 0; i < controller.model().size(); i++)
proposals[i] = controller.model().get(i).getAppropriateName();
comboViewer = new ComboViewer(parent, SWT.NONE);
comboViewer.setContentProvider(new ArrayContentProvider());
comboViewer.setLabelProvider(new AppropriateLabelProvider());
comboViewer.setInput(_controller.model());
// additionally, configure the comboViewer arbitrary
new AutoCompleteField(comboViewer.getCombo(), new ComboContentAdapter(), proposals);
The only minor nuisance is that you have to separately populate the model of ComboViewer and AutoCompleteField separately, but that can be at least automated via a static utility method or something similar.
As reference for future visitors, the AutocompleteComboInput (SWT Add-on), can also be a way to achieve this.
Code snippet for screenshot (refer to documentation link above for the code template):
import net.sf.swtaddons.autocomplete.combo.AutocompleteComboInput;
...
subjectCodeCombo = new Combo(tab3Composite, SWT.DROP_DOWN);
// other code modifying Combo appearance here...
// returns a String[] of items retrieved from database
String[] subjectCodeArray = dbQuery.subjectsToArray();
subjectCodeCombo.setItems(subjectCodeArray);
subjectCodeCombo.setText("- SELECT -");
new AutocompleteComboInput(subjectCodeCombo);
The add-on requires all JARs below to be added to the Library: (more info)
eclipse-equinox-common-3.5.0.jar
net.sf.swtaddons_0.1.1_bin_src.jar (sourceforge)
org.eclipse.core.commands.jar
org.eclipse.jface-3.6.0.jar
Click here for JAR pack.