Help: DialogCellEditor does not work properly [message #438119] |
Wed, 16 June 2004 18:08 |
Bryan Hunt Messages: 366 Registered: July 2009 |
Senior Member |
|
|
I have created a custom DialogCellEditor the displays the FontDialog.
When I click in a table cell, the DialogCellEditor appears, I hit return,
and the FontDialog appears just like I expect. I select a font, click
ok, the FontDialog disappears, but the DialogCellEditor is still visible
in the table cell. Clicking another cell will bring up the appropriate
editor for that cell, but the table display becomes corrupted with the
DialogCellEditor. Any ideas on what I might have done wrong, or is this
a bug?
Bryan
Here is my DialogCellEditor:
/*
* Created on Jun 16, 2004
*
* Copyright (c) 2004 International Business Machines
*/
package com.ibm.hdwb.data.ui.tableFormatEditor;
import org.eclipse.jface.viewers.DialogCellEditor;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.FontDialog;
/**
* @author bhunt
*
*/
public class FontCellEditor extends DialogCellEditor
{
/**
* @param parent
*/
public FontCellEditor(Composite parent)
{
super(parent);
} }
/**
* @see org.eclipse.jface.viewers.DialogCellEditor#openDialogBox(org .
eclipse.swt.widgets.Control)
*/
protected Object openDialogBox(Control cellEditorWindow)
{
return new FontDialog(cellEditorWindow.getShell()).open();
} }
}
|
|
|
Re: Help: DialogCellEditor does not work properly [message #441983 is a reply to message #438119] |
Thu, 26 August 2004 22:38 |
Paul E. Keyser Messages: 878 Registered: July 2009 |
Senior Member |
|
|
In case you still need an answer, I had the same problem and solved it by overriding the method
createButton() like this:
protected Button createButton (final Composite parent, Font font) {
final Button button = super.createButton(parent, font);
button.addFocusListener(new FocusAdapter() {
public void focusLost (final FocusEvent e) {
if (!_dialogOpen) {
fireCancelEditor();
// generates "pop-down" when user "clicks out"
}
}
});
return button;
}
Then, in method openDialogBox(), be sure to set and unset the boolean _dialogOpen:
protected Object openDialogBox (final Control cellEditorWindow) {
final Dialog dialog = initialiseDialogHoweverYouNeedTo();
_dialogOpen = true;
final boolean ok = (dialog.open() == WizardDialog.OK);
final String result = getResultHoweverYouNeedTo();
_dialogOpen = false;
return result;
}
HTH,
Paul
Bryan Hunt wrote:
> I have created a custom DialogCellEditor the displays the FontDialog.
> When I click in a table cell, the DialogCellEditor appears, I hit return,
> and the FontDialog appears just like I expect. I select a font, click
> ok, the FontDialog disappears, but the DialogCellEditor is still visible
> in the table cell. Clicking another cell will bring up the appropriate
> editor for that cell, but the table display becomes corrupted with the
> DialogCellEditor. Any ideas on what I might have done wrong, or is this
> a bug?
>
> Bryan
>
>
>
> Here is my DialogCellEditor:
>
> /*
> * Created on Jun 16, 2004
> *
> * Copyright (c) 2004 International Business Machines
> */
> package com.ibm.hdwb.data.ui.tableFormatEditor;
>
> import org.eclipse.jface.viewers.DialogCellEditor;
> import org.eclipse.swt.widgets.Composite;
> import org.eclipse.swt.widgets.Control;
> import org.eclipse.swt.widgets.FontDialog;
>
> /**
> * @author bhunt
> *
> */
> public class FontCellEditor extends DialogCellEditor
> {
>
> /**
> * @param parent
> */
> public FontCellEditor(Composite parent)
> {
> super(parent);
> } }
>
> /**
> * @see org.eclipse.jface.viewers.DialogCellEditor#openDialogBox(org .
> eclipse.swt.widgets.Control)
> */
> protected Object openDialogBox(Control cellEditorWindow)
> {
> return new FontDialog(cellEditorWindow.getShell()).open();
> } }
>
> }
|
|
|
Re: Help: DialogCellEditor does not work properly [message #442152 is a reply to message #441983] |
Fri, 27 August 2004 21:30 |
Genady Beryozkin Messages: 410 Registered: July 2009 |
Senior Member |
|
|
Do you think it is related to
https://bugs.eclipse.org/bugs/show_bug.cgi?id=34819
Genady
Genady Beryozkin
http://www.genady.net/
Paul Keyser wrote:
> In case you still need an answer, I had the same problem and solved it
> by overriding the method createButton() like this:
>
> protected Button createButton (final Composite parent, Font font) {
> final Button button = super.createButton(parent, font);
>
> button.addFocusListener(new FocusAdapter() {
> public void focusLost (final FocusEvent e) {
> if (!_dialogOpen) {
> fireCancelEditor();
> // generates "pop-down" when user "clicks out"
> }
> }
> });
>
> return button;
> }
>
> Then, in method openDialogBox(), be sure to set and unset the boolean
> _dialogOpen:
>
> protected Object openDialogBox (final Control cellEditorWindow) {
> final Dialog dialog = initialiseDialogHoweverYouNeedTo();
> _dialogOpen = true;
>
> final boolean ok = (dialog.open() == WizardDialog.OK);
> final String result = getResultHoweverYouNeedTo();
>
> _dialogOpen = false;
> return result;
> }
>
> HTH,
> Paul
>
> Bryan Hunt wrote:
>
>> I have created a custom DialogCellEditor the displays the
>> FontDialog. When I click in a table cell, the DialogCellEditor
>> appears, I hit return, and the FontDialog appears just like I
>> expect. I select a font, click ok, the FontDialog disappears, but
>> the DialogCellEditor is still visible in the table cell. Clicking
>> another cell will bring up the appropriate editor for that cell, but
>> the table display becomes corrupted with the DialogCellEditor. Any
>> ideas on what I might have done wrong, or is this a bug?
>>
>> Bryan
>>
>>
>>
>> Here is my DialogCellEditor:
>>
>> /*
>> * Created on Jun 16, 2004
>> *
>> * Copyright (c) 2004 International Business Machines
>> */
>> package com.ibm.hdwb.data.ui.tableFormatEditor;
>>
>> import org.eclipse.jface.viewers.DialogCellEditor;
>> import org.eclipse.swt.widgets.Composite;
>> import org.eclipse.swt.widgets.Control;
>> import org.eclipse.swt.widgets.FontDialog;
>>
>> /**
>> * @author bhunt
>> *
>> */
>> public class FontCellEditor extends DialogCellEditor
>> {
>>
>> /**
>> * @param parent
>> */
>> public FontCellEditor(Composite parent)
>> {
>> super(parent);
>> } }
>>
>> /**
>> * @see
>> org.eclipse.jface.viewers.DialogCellEditor#openDialogBox(org .
>> eclipse.swt.widgets.Control)
>> */
>> protected Object openDialogBox(Control cellEditorWindow)
>> {
>> return new FontDialog(cellEditorWindow.getShell()).open();
>> } }
>>
>> }
>
|
|
|
Powered by
FUDForum. Page generated in 0.04686 seconds