JFace dialog without Ok/Cancel buttons [message #465672] |
Sun, 18 December 2005 09:25 |
Eclipse User |
|
|
|
Originally posted by: roni.sternberg.attunity.com
When running the following snippet, you get a dialog with no Ok/Cancel
buttons.
when resizing the dialog, the buttons appear (strange, isn't it?).
I've been trying to fix the problem by adding layout(), layout(Control[]),
pack() ,redraw(), or a GridData object in createButtonBar().
Is there a way to make the buttons appear (simulate a resize
programatically?)
thanks in advance.
protected Control createDialogArea(Composite parent) {
int minWidth = 420;
int minHeight = 200;
getShell().setSize(440, 250);
//Create scroller
scrollComposite = new ScrolledComposite(parent, SWT.V_SCROLL);
scrollComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
//Main panel
composite = new Composite(scrollComposite, SWT.NONE);
composite.setLayout(new GridLayout());
// Initialize scroller
scrollComposite.setContent(composite);
scrollComposite.setExpandHorizontal(true);
scrollComposite.setExpandVertical(true);
// create controls
updateControl();
scrollComposite.setSize(minWidth, minHeight);
scrollComposite.setMinWidth(minWidth);
scrollComposite.setMinHeight(minHeight);
scrollComposite.setMinSize(composite.computeSize(SWT.DEFAULT ,
SWT.DEFAULT));
// set dialog to open in center
setCentered();
return scrollComposite;
}
private void setCentered() {
Display display = myShell.getDisplay();
int width = display.getClientArea().width;
int height = display.getClientArea().height;
myShell.setLocation(((width - myShell.getSize().x) / 2) +
display.getClientArea().x, ((height - myShell.getSize().y) / 2) +
display.getClientArea().y);
}
protected Control createButtonBar(Composite parent) {
Control control = super.createButtonBar(parent);
UIUtil.adaptComposite(parent);
return control;
}
public void updateControl() {
updateEditedGroup();
// clear controls
clearControls();
// create contorls
int size = list.size();
ContentFilterGroup group = null;
for (int i = 0; i < size; ++i) {
// create new group
group = new ContentFilterGroup(composite, SWT.NONE, this,
(ContentFilterGroupData) list.get(i));
// if there's only one group , disable Delete
if (size == 1) {
group.getDeleteButton().setEnabled(false);
}
}
// enable last group and set focus on it
group.enable();
scrollComposite.setMinSize(composite.computeSize(SWT.DEFAULT ,
SWT.DEFAULT));
composite.layout();
scrollComposite.setOrigin(group.getLocation());
scrollComposite.layout();
}
private void clearControls() {
Control[] children = composite.getChildren();
for (int i = 0; i < children.length; ++i) {
children[i].dispose();
}
}
|
|
|
|
Re: JFace dialog without Ok/Cancel buttons [message #465939 is a reply to message #465677] |
Fri, 23 December 2005 16:14 |
Eclipse User |
|
|
|
Originally posted by: rony2006.012.net.il
Hi
I may have been dumbstruck by lightning :-) but I can't make this work and
it should be easy...
i tried to override
// same code as in Dialog; no super call
protected void createButtonsForButtonBar(Composite parent) {
// create OK and Cancel buttons by default
createButton(parent, IDialogConstants.OK_ID,
IDialogConstants.OK_LABEL,
true);
createButton(parent, IDialogConstants.CANCEL_ID,
IDialogConstants.CANCEL_LABEL, false);
}
it didn't work.
thanks for any help and suggestions.
Roni
"Allon Moritz" <moa@avaloq.com> wrote in message
news:630b395377d9e3fe04f9cbcbe5557d8b$1@www.eclipse.org...
> Try to override createButtonsForButtonBar(...) and do not make the super
> call. Instead create your own buttons.
>
|
|
|
Powered by
FUDForum. Page generated in 0.03504 seconds