what is the relation between TabHost and TabSpec..Is Tabhost a superclass for TabSpec..Also I want to understand the code given below - android-tabhost

TabHost th=(TabHost) findViewById(R.id.tabhost);
th.setup();
TabSpec ts= th.newTabSpec("tag1");
can anyone please tell me what is the significance of new in newTabSpec and and how th is being used in this code for newTabSpec

Related

How to spawn in item with a tile entity? 1.11.2

I was wondering on how to get my tile entity to spawn an item when it has been taken out of it? for example if it was an ATM and you pressed the button to take out $20. I have the entity set up but the tutorial I'm following uses worldOBj.(stuff)
When I tried to figure it out myself it was only giving me the option to do something like World.spawnEntity() and it only accepts entities not items.
The Tile entity extends minecrafts TileEnity and imports itemStack and tileEntity.
Any help what line of code would accomplish this is appreciated! I'm new to modding

Use eclipse GMF to create read only diagram

I followed the file system example http://gmfsamples.tuxfamily.org/wiki/doku.php?id=gmf_tutorial1
what I wanted to do is not using the generated editor with its palette.
I created a new plugin with one view and I wanted to create a diagram programatically inside this view to show for instance 2 objects connected with link
I came across this answer GMF display diagram example
but it didn't help me a lot.
in createPartControl of my view I did
#Override
public void createPartControl(Composite parent) {
DiagramGraphicalViewer viewer = new DiagramGraphicalViewer();
viewer.createControl(parent);
RootEditPart root = EditPartService.getInstance().createRootEditPart(diagram);
viewer.setRootEditPart(root);
viewer.setEditPartFactory(new EcoreEditPartProvider());
viewer.getControl().setBackground(ColorConstants.listBackground);
viewer.setContents(diagram);
}
as in the answer but I didn't know how to get that "diagram" variable
The easiest would be use the same GraphicalViewer for your view and the same diagram as well. Just get your DiagramEditPart from the viewer and call disableEditMode() on it. (Do the appropriate type casting if necessary).

How to get user's input from WicketStuff's TinyMCE

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

How to add IDs for Tabs in Tabpanel in GWT?

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(...).

Showing an initially selected object in an ObjectAutoCompleteField on page load in Wicket

I've followed the Wicket by Example guide to get the ObjectAutoCompleteField working, and it does so quite nicely.
I have a huge problem, though, and that is to show an initially set object in the field when the page loads. The object is retrieved from a model I use for the form where the ObjectAutoCompleteField is used. Changing the ObjectAutoCompleteField changes the model attribute it is "connected" to, and any subsequent changes in the field shows the appropriate label in its place, just not the initial one when the page loads—the only thing that shows is the edit link (to get to the autocomplete functionality).
I've looked around in the documentation for the ObjectAutoCompleteBuilder but haven't found any corresponding method to even set the initial value explicitly on page load.
I finally managed to find a solution by looking through the classes relating to ObjectAutoCompleteField.
The ObjectAutoCompleteField is constructed by the build method in ObjectAutoCompleteBuilder. So, by calling the readOnlyRenderer method on the builder, creating a new ObjectReadOnlyRenderer creating a label inside its getObjectRenderer, I got the ObjectAutoCompleteField to render a preselected object on page load.
ObjectAutoCompleteBuilder<Author, Long> builder = new ObjectAutoCompleteBuilder<Author, Long>(provider);
builder.readOnlyRenderer(new ObjectReadOnlyRenderer<Long>() {
public Component getObjectRenderer(String id, IModel<Long> pModel, IModel<String> pSearchTextModel) {
return new Label(id, new PropertyModel<Author>(model, "author"));
}
});
One would think that this was the standard behaviour, but now I know for future reference.