View Full Version : How to place an empty between a progress bar and the buttons of a dialog ?
M4v3rick
6 Jan 2011, 6:02 AM
Hello,
I would like place an empty space (a "glue" like in SWING or a "FILL property" for a layout like in SWT) between a progress bar and the buttons in my dialog. (In the ButtonBar)
In my current implementation, I've coded:
// ...
public final class MyDialog
extends Dialog {
// ...
public MyDialog()
{
final Label label = new Label(); // <- new component (? empty space ?)
final ButtonBar buttonBar = getButtonBar(); // <------ the ButtonBar of my dialog
final ProgressBar progressBar = new ProgressBar(); // <- new component (progress bar)
label.setLayoutData(new HorizontalPanel());
label.setAutoWidth(true);
progressBar.setWidth(125);
progressBar.setHeight(20);
progressBar.setVisible(true);
buttonBar.insert(label, buttonBar.getItemCount() - 2);
buttonBar.insert(progressBar, buttonBar.getItemCount() - 3);
buttonBar.layout();
}
// ...
}
Help me, thanks in advance.
Can you draw a picture of what the result should look like?
M4v3rick
6 Jan 2011, 3:21 PM
Sure.
24153
In my current version, the progress bar and buttons are on the "bottom-right" side of my dialog. (It's normal, the layout of the ButtonBar is an alignment to the right)
There is a FillToolItem you can use for this.
M4v3rick
6 Jan 2011, 4:06 PM
Ok, I will test it tomorrow (in runtime).
Note: I've tested the FillToolItem only into my GWT Designer and the render was wrong!? (May be a problem of my plugin GWT Designer to display this component)
I will test and I'll come back to give my feedback
M4v3rick
7 Jan 2011, 2:34 AM
It doesn't work.
The progress bar is displayed after buttons ???
[ [Button1] [Button2] [ProgressBar]]
my code:
final ButtonBar buttonBar = getButtonBar();
buttonBar.setLayoutData(new FillLayout(Orientation.HORIZONTAL));
this.progressBar = new ProgressBar();
this.progressBar.setWidth(125);
this.progressBar.setHeight(20);
this.progressBar.setVisible(true);
buttonBar.insert(new FillToolItem(), buttonBar.getItemCount() - 2); // 2 buttons
buttonBar.insert(this.progressBar, buttonBar.getItemCount() - 3); // 2 buttons and another component (fill tool item)
buttonBar.layout();
Remark: I've added my progress on a "ButtonBar" (com.extjs.gxt.ui.client.widget.toolbar.ToolBar.ButtonBar)
Can you please post a fully working testcase implementing EntryPoint? Also when you change the ButtonBar layout, it wont work anymore.
M4v3rick
7 Jan 2011, 3:34 AM
package com.mycompany.project.client;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.RootPanel;
/**
* Entry point classes define <code>onModuleLoad()</code>.
*
* @author Internal Tools Team
*/
public final class ImageViewer
implements EntryPoint {
/*
* (non-Javadoc)
* @see com.google.gwt.core.client.EntryPoint#onModuleLoad()
*/
@Override public void onModuleLoad() {
final RootPanel rootPanel = RootPanel.get();
final MyProgressDialog dialog = new MyProgressDialog();
rootPanel.add(dialog);
}
}
package com.mycompany.project.client;
import com.extjs.gxt.ui.client.widget.Dialog;
import com.extjs.gxt.ui.client.widget.ProgressBar;
import com.extjs.gxt.ui.client.widget.button.Button;
import com.extjs.gxt.ui.client.widget.button.ButtonBar;
import com.extjs.gxt.ui.client.widget.toolbar.FillToolItem;
/**
* A custom dialog with a progress bar.
*
* @author Internal Tools Team
*/
public final class MyProgressDialog
extends Dialog {
/**
* Creates a new object.
*/
public MyProgressDialog() {
initGUI();
}
/**
* Init GUI.
*/
private void initGUI() {
setSize(520, 340);
setHeading("My Progress Dialog");
setButtons(Dialog.OKCANCEL);
setHideOnButtonClick(true);
setBorders(false);
setBodyBorder(false);
setMaximizable(true);
{
final Button button1 = getButtonById(Dialog.OK);
button1.setText("Button 1");
}
{
final Button button2 = getButtonById(Dialog.CANCEL);
button2.setText("Button 2");
}
{
final ButtonBar buttonBar = getButtonBar();
final ProgressBar progressBar = new ProgressBar();
progressBar.setWidth(125);
progressBar.setHeight(20);
progressBar.setVisible(true);
buttonBar.insert(new FillToolItem(), buttonBar.getItemCount() - 2);
buttonBar.insert(progressBar, buttonBar.getItemCount() - 3);
}
}
}
final class MyProgressDialog extends Dialog {
/**
* Creates a new object.
*/
public MyProgressDialog() {
initGUI();
}
/**
* Init GUI.
*/
private void initGUI() {
setSize(520, 340);
setHeading("My Progress Dialog");
setButtons(Dialog.OKCANCEL);
setHideOnButtonClick(true);
setBorders(false);
setBodyBorder(false);
setMaximizable(true);
setButtonAlign(HorizontalAlignment.LEFT);
{
final Button button1 = getButtonById(Dialog.OK);
button1.setText("Button 1");
}
{
final Button button2 = getButtonById(Dialog.CANCEL);
button2.setText("Button 2");
}
{
final ButtonBar buttonBar = getButtonBar();
final ProgressBar progressBar = new ProgressBar();
progressBar.setWidth(125);
progressBar.setHeight(20);
progressBar.setVisible(true);
buttonBar.insert(progressBar, 0);
buttonBar.insert(new FillToolItem(), 1);
}
}
}
M4v3rick
7 Jan 2011, 5:01 AM
Thanks a lot
Powered by vBulletin® Version 4.1.5 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.