Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » JFace dialog without Ok/Cancel buttons
JFace dialog without Ok/Cancel buttons [message #465672] Sun, 18 December 2005 09:25 Go to next message
Eclipse UserFriend
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 #465677 is a reply to message #465672] Mon, 19 December 2005 02:11 Go to previous messageGo to next message
Allon Moritz is currently offline Allon MoritzFriend
Messages: 6
Registered: July 2009
Junior Member
Try to override createButtonsForButtonBar(...) and do not make the super
call. Instead create your own buttons.
Re: JFace dialog without Ok/Cancel buttons [message #465939 is a reply to message #465677] Fri, 23 December 2005 16:14 Go to previous message
Eclipse UserFriend
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.
>
Previous Topic:JFace Dialog ExceptionInInitializerError
Next Topic:How to implement multiple windows in SWT
Goto Forum:
  


Current Time: Sat Dec 07 02:29:19 GMT 2024

Powered by FUDForum. Page generated in 0.03504 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top