I've a RibbonControl in a mdiform and another RibbonControl added at design time in a MDIChildForm. Then in runtime, I add a RibbonPage, with a RibbonGroup and a BarButtonItem. Like this:
private void MDIChildForm_Load(object sender, EventArgs e) {
BarButtonItem btn = ribbonControl1.Items.CreateButton("Test Button");
RibbonPageGroup group1 = new RibbonPageGroup("Test Group");
group1.ItemLinks.Add(btn);
RibbonPage page1 = new RibbonPage("Test Page");
page1.Groups.Add(group1);
ribbonControl1.Pages.Add(page1);
}
The "Test Page" isn't visible in the MdiParent. But, when I change the active mdi child form, and the ribbon do the merge, the page appears!
It looks like the page isn't merged until I change the active mdi child form.
Am I missing something?
I've found a solution, but I think is not the most elegant way to solve it:
mainRibbon.UnMergeRibbon();
mainRibbon.MergeRibbon(mdiChildForm.ChildRibbon);
A public property to access the child Ribbon was needed.
Related
What is the best practice with the new GUI Builder, to simply navigate from "form A" to another "form B" by clicking a button in "form A", with use of the action events?
If I create Form B inside Form A like this
public void oncreateAccountActionEvent(com.codename1.ui.events.ActionEvent ev) {
new FormB().show();
}
Then I am obviously not able to modify Form B from inside the main class (start, stop, destroy methods) before I do new FormB().show(). In this case new FormA().show(); is located in the start-method of the main class.
I want to be able to specfiy e.g. a back-button to Form B to navigate back to Form A, but I want to add this inside the start-method of the Main class.
Thanks!
Edit:
I have the Main-class (with start(), stop(), destroy()-methods), in this class I do new FormA().show().
But inside the class of FormA I have the oncreateAccountActionEvent-method (and button) which shows FormB by new FormB().show().
However I want to be able to specify formB.setBackCommand() (into the toolbar of FormB inside the main-class.
So to say I want to specify both forms in the main class with new FormA/B() - then modify the forms like adding buttons to the toolbar - and then tell FormA that FormB should be used inside the action event method.
Use showBack() method to go back to FormA from FormB as shown in the code below. You can just keep a reference to the previous/next form instances.
FormA formA = new FormA();
FormB formB = new FormB();
public void oncreateAccountActionEvent(com.codename1.ui.events.ActionEvent ev) {
formB.show();
}
public void showFormA(){
formA.showBack();
}
I came to an obvious solution to my problem by simply overriding the oncreateAccountActionEvent-method in the Main-class and still being able to create and modify formB before:
Form formB= new FormB();
// Modifying formB
formB.setBackCommand(backCommand);
...
//Create formA and show the modified formB on button click
FormA formA= new FormA() {
#Override
public void oncreateAccountActionEvent(ActionEvent ev) {
//Navigate to FormB
formB.show();
};
};
And for navigating back from formB to formA I found this solution, to keep a reference of the previous form by implementing the show()-method of the class of formB:
private Form previous;
...
public void show() {
previous = Display.getInstance().getCurrent();
super.show();
}
...
//go to the form before
public void goBack(){
previous.showBack();
}
Maybe this helps someone else, too.
I have a ModalWindow which has a form, which has a TabbedPanel, which has two AbstractTabs which, on which there is a DataTable on each of them, with input elements.
So: ModalWindow > Form > TabbedPanel --> Tab1 (Panel) > DataTable (there are two tabs)
Within the ModalWindow, I added to the form 3 buttons, like the following:
// save button
final GbAjaxButton save = new GbAjaxButton("save") {
private static final long serialVersionUID = 1L;
#Override
public void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
System.out.println("Saving something... ");
}
};
I can see the data being sent via POST to the backend, but I can't seem to be able to access any of the fields in the DataTables.
Some parts for the code are:
tabA = new AbstractTab("Tab Name") {
public Panel getPanel() {
return new SomeNewPanel(panelId,<somedata>); // <-- this has the DataTable with inputs
}
}
Form form = new Form("formNameInHtml");
form.add(new TabbedPanel("htmlName", tabs);
I would really appreciate some insight on this problem.
Thanks.
From ModalWindow javadoc, "If you want to use form in modal window component make sure that you put the modal window itself in another form (nesting forms is legal in Wicket) and that the form on modal window is submitted before the window get closed."
Wicket automatically adds a form outside the modal window, so if you want to use a second form inside you should override org.apache.wicket.markup.html.form.Form#isRootForm() and have it return true.
I have a button on ribbon control.When I click it I open a customization form which shows pivotgrid's fields and I drag items from customization form to the pivot grid but when I close and reclick the button to open the customization form the draged fields are not shown in the pivot.I have to reselect the fields to show on the pivot.
How can I avoid this?
Below code is for button click event.
private void barButtonItem10_ItemClick(object sender, ItemClickEventArgs e)
{
pivotGridControl1.RetrieveFields(PivotArea.FilterArea, false);
pivotGridControl1.FieldsCustomization();
}
The PivotGridControl.RetrieveFields method with your parameters are hiding all fields. If you remove this method from your code, then you will avoid your situation.
private void barButtonItem10_ItemClick(object sender, ItemClickEventArgs e)
{
pivotGridControl1.FieldsCustomization();
}
I need some help. I've been reading this site for days, and have read a lot of tips about controlling for example a button's property from another form. There's even a video on Youtube, which works to me as stand alone, but when I implenet it in my application it throws a NullReferenceException.
Let's say that I have a toolstrip menu on Form1. A click on the Kalibracio option opens the second form (also called Kalibracio - not Form2). Then, click on Proba in the menu should disable an ordinary button on the Kalibracio form which propery is set to public. The code on Form1 is as follows:
private void kalibracioToolStripMenuItem_Click(object sender, EventArgs e)
{
Kalibracio Kalibr = new Kalibracio(this);
Kalibr.Owner = this;
Kalibr.Show();
}
private void probaToolStripMenuItem_Click(object sender, EventArgs e)
{
if (Application.OpenForms.OfType<Kalibracio>().Any())
(this.Owner as Kalibracio).button1.Enabled = false;
// the above line throws a NullReferenceExcteption if Kalibracio form is open (Kalibracio is null)
}
What am I missing?
LoL just had to declare globaly an instance of Kalibracio, open it and then access it's properties from all other methods.
I tried this approach at first, but my problem was that I was creating and instance locally, then I had to create another one in some other method because I couldn't address the former one created locally, and ofc it didn't work...
I've built a GUI with a SmartGWT TabSet with Tabs that can be dynamically added and removed.
The Tabs share the same canvas which is moved from Tab to Tab at each tab selection like this:
myTabSet.addTabSelectedHandler(new TabSelectedHandler() {
public void onTabSelected(TabSelectedEvent event) {
[...]
myTabs[myTabSet.getSelectedTabNumber()].setPane(myCanvas);
// Then I fill the contained widgets with the tab-specific data
}
}
This works, but when I try to remove a Tab with
myTabSet.removeTab(iToBeDeletedTab);
The tab is removed but the remaining tabs have a blank pane, I can get the content back only by reloading the page. I found that I have to prevent pane destruction with calls to :
myTabSet.setDestroyPanes(false);
and
myTabSet.updateTab(iToBeDeletedTab, null);
//called right before
myTabSet.removeTab(iToBeDeletedTab);
I understand that the canvas/pane is still destroyed, but I cannot figure out how to prevent this.
Has anyone any hint?
Thank you!
Have you tried to call the redraw() method after removing a tab? This usually helps me when loading/reloading data with smartGWT widgets.
Your calls are correct, but now what you've got is the pane completely unnassociated from the TabSet and not drawn (check the Watch Tab in the Developer Console and you'll see this). Now, call updateTab(someOtherTab, pane) to connect the pane to one of the other tabs where it should be showing.
Ok, I've made some test and got the same as you but had some success with the following code:
1°) in the Javadoc I found:
***public void setPane(Canvas pane)
Specifies the pane associated with this tab. You can change the pane associated with a given tab after the TabSet has been created by calling TabSet.updateTab(int, com.smartgwt.client.widgets.Canvas)***
I tried without setting to null the pane of tab1 , it didn't work.
I think it could be arranged in better way but anyway the point is to use the updatePadmethod
public static void testTabDelete(){
final Canvas theCanvas = new Canvas();
final TabSet theTabs = new TabSet();
theTabs.setWidth("80%");
theTabs.setHeight("80%");
final Tab tab1 = new Tab("Tab1");
final Tab tab2 = new Tab("Tab2");
final Tab tab3 = new Tab("Tab3");
IButton btn1 = new IButton("Btn1");
btn1.setLeft(10);
btn1.setTop(100);
btn1.setWidth(80);
theCanvas.addChild(btn1);
IButton btn2 = new IButton("Delete");
btn2.setLeft(100);
btn2.setTop(100);
btn2.setWidth(80);
btn2.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() {
#Override
public void onClick(com.smartgwt.client.widgets.events.ClickEvent event) {
theTabs.updateTab(0, null);
theTabs.updateTab(1, theCanvas);
theTabs.selectTab(tab2);
theTabs.removeTab(tab1);
}
});
theCanvas.addChild(btn2);
theTabs.addTab(tab1);
theTabs.addTab(tab2);
theTabs.addTab(tab3);
tab1.setPane(theCanvas);
RootPanel.get("container").add(theTabs);
}