001: package org.drools.eclipse.rulebuilder.ui;
002:
003: import org.eclipse.jface.dialogs.Dialog;
004: import org.eclipse.jface.dialogs.IDialogConstants;
005: import org.eclipse.swt.SWT;
006: import org.eclipse.swt.graphics.Font;
007: import org.eclipse.swt.graphics.FontData;
008: import org.eclipse.swt.layout.GridData;
009: import org.eclipse.swt.layout.GridLayout;
010: import org.eclipse.swt.widgets.Composite;
011: import org.eclipse.swt.widgets.Control;
012: import org.eclipse.swt.widgets.Label;
013: import org.eclipse.swt.widgets.Shell;
014: import org.eclipse.swt.widgets.Text;
015:
016: public class RuleDialog extends Dialog {
017:
018: private String title;
019: private String hint;
020:
021: public RuleDialog(Shell parent, String title, String hint) {
022: //super(parent,INFOPOPUPRESIZE_SHELLSTYLE,true,true,true,true,title,hint);
023: super ((Shell) parent.getParent());
024: setShellStyle(getShellStyle() | SWT.RESIZE);
025: this .title = title;
026: this .hint = hint;
027: }
028:
029: protected void configureShell(Shell newShell) {
030: super .configureShell(newShell);
031: newShell.setText(title);
032: newShell.setToolTipText(hint);
033: }
034:
035: protected Control createDialogArea(Composite parent) {
036:
037: Composite finalComposite = new Composite(parent, SWT.NONE);
038: finalComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
039: GridLayout finalLayout = new GridLayout();
040: finalComposite.setLayout(finalLayout);
041:
042: Composite titleComposite = new Composite(finalComposite,
043: SWT.NONE);
044: GridLayout layout = new GridLayout();
045: layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
046: layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
047: layout.verticalSpacing = 8;
048: layout.horizontalSpacing = 8;
049: titleComposite.setLayout(layout);
050: titleComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
051: applyDialogFont(titleComposite);
052:
053: Label l = new Label(titleComposite, SWT.CENTER);
054: l.setToolTipText(hint);
055: l.setText(title);
056:
057: Font exFont = l.getFont();
058:
059: FontData[] exfds = l.getFont().getFontData();
060: if (exfds.length > 0) {
061: FontData fd = exfds[0];
062: fd.setHeight(fd.getHeight() + 4);
063: Font f = new Font(exFont.getDevice(), fd);
064: l.setFont(f);
065: }
066:
067: Composite contentComposite = (Composite) super
068: .createDialogArea(finalComposite);
069:
070: return contentComposite;
071: }
072:
073: protected void createButtonsForButtonBar(Composite parent) {
074: // We have only cancel button
075: createButton(parent, IDialogConstants.CANCEL_ID,
076: IDialogConstants.CANCEL_LABEL, false);
077:
078: }
079:
080: /*
081: protected Control createDialogArea(Composite parent) {
082: Composite composite = new Composite(parent, SWT.NONE);
083:
084: GridLayout layout = new GridLayout();
085: layout.marginHeight = 2;
086: layout.marginWidth = 2;
087: layout.verticalSpacing = 2;
088: layout.horizontalSpacing = 2;
089: composite.setLayout(layout);
090:
091: GridData gd = new GridData(GridData.FILL_BOTH);
092: composite.setLayoutData(gd);
093:
094: return composite;
095: }
096: */
097:
098: protected Label createLabel(Composite composite, String string) {
099: Label l = new Label(composite, 0);
100: l.setText(string);
101: return l;
102: }
103:
104: protected Text createText(Composite composite, String string) {
105: Text t = new Text(composite, 0);
106: t.setText(string);
107: return t;
108: }
109:
110: }
|