I want to add a Multiline InputDialog to my Ruble
Ok so I would really like to be able to add a multiline (textarea) InputDialog to my ruble.
I've worked around the limitations in Ruble::UI and created my own module that I load with my ruble when I want more then the default dialogs the Ruble::UI provides. Because of this I've been able to add multiselect dialogs and even gotten the Multiline InputDialog to work by creating a override class and then passing the getTextStyle method my own values to make it multiline.
The problem comes in that the dialog displays a multiline text box but it's height is still set to one line, so it essentially still just a single line box. I know from Eclipse plugin dev how to create the multiline dialog in Java, I just can't figure out how to make it happen in a ruble using jruby.
Here is my current code in ruby
Used to request a Multi Dialog
class MultiInputDialog < org.eclipse.jface.dialogs.InputDialog
def getInputTextStyle
org.eclipse.swt.SWT::MULTI | org.eclipse.swt.SWT::BORDER | org.eclipse.swt.SWT::V_SCROLL
end
end
And here is what the code to do it in Java would like.
Java override
InputDialog dlg = new InputDialog(Display.getCurrent().getActiveShell(), "Test", "Please input text.",
"Test-Text&q开发者_C百科uot;, null) {
/**
* Override this method to make the text field multilined
* and give it a scroll bar. But...
*/
@Override
protected int getInputTextStyle() {
return SWT.MULTI | SWT.BORDER | SWT.V_SCROLL;
}
/**
* ...it still is just one line high.
* This hack is not very nice, but at least it gets the job done... ;o)
*/
@Override
protected Control createDialogArea(Composite parent) {
Control res = super.createDialogArea(parent);
((GridData) this.getText().getLayoutData()).heightHint = 100;
return res;
}
};
dlg.open();
So you can see I've figured out how to override the getInputTextStyle, but everthing I've tried to mimic the override of createDialogArea() has falied. Any suggestions or help would be greatly appreciated
Try this:
class MultiInputDialog < org.eclipse.jface.dialogs.InputDialog
def getInputTextStyle
org.eclipse.swt.SWT::MULTI | org.eclipse.swt.SWT::BORDER | org.eclipse.swt.SWT::V_SCROLL
end
def createDialogArea(parent)
control = super(parent)
getText.getLayoutData.heightHint = 100;
control
end
end
Cheers, Max
精彩评论