Example usage for org.eclipse.swt.widgets Composite setLayout

List of usage examples for org.eclipse.swt.widgets Composite setLayout

Introduction

In this page you can find the example usage for org.eclipse.swt.widgets Composite setLayout.

Prototype

public void setLayout(Layout layout) 

Source Link

Document

Sets the layout which is associated with the receiver to be the argument which may be null.

Usage

From source file:ProgressBarDialog.java

protected void createContents() {
    shell = new Shell(getParent(), SWT.TITLE | SWT.PRIMARY_MODAL);
    display = shell.getDisplay();//from   www  .j a  v a  2s. com
    final GridLayout gridLayout = new GridLayout();
    gridLayout.verticalSpacing = 10;

    shell.setLayout(gridLayout);
    shell.setSize(483, 181);
    shell.setText(shellTitle);

    final Composite composite = new Composite(shell, SWT.NONE);
    composite.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
    composite.setLayout(new GridLayout());

    message = new CLabel(composite, SWT.NONE);
    message.setImage(processImage);
    message.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
    message.setText(processMessage);

    progressBarComposite = new Composite(shell, SWT.NONE);
    progressBarComposite.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, false, false));
    progressBarComposite.setLayout(new FillLayout());

    progressBar = new ProgressBar(progressBarComposite, processBarStyle);
    progressBar.setMaximum(executeTime);

    processMessageLabel = new Label(shell, SWT.NONE);
    processMessageLabel.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, false, false));
    lineLabel = new Label(shell, SWT.HORIZONTAL | SWT.SEPARATOR);
    lineLabel.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, false, false));

    cancelComposite = new Composite(shell, SWT.NONE);
    cancelComposite.setLayoutData(new GridData(GridData.END, GridData.CENTER, false, false));
    final GridLayout gridLayout_1 = new GridLayout();
    gridLayout_1.numColumns = 2;
    cancelComposite.setLayout(gridLayout_1);

    cancelButton = new Button(cancelComposite, SWT.NONE);
    cancelButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            isClosed = true;
            //System.out.println(isClosed);
        }
    });
    cancelButton.setLayoutData(new GridData(78, SWT.DEFAULT));
    cancelButton.setText("cancel");
    cancelButton.setEnabled(this.mayCancel);

}

From source file:MainClass.java

protected Control createContents(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayout(new GridLayout(1, false));

    Combo combo = new Combo(composite, SWT.READ_ONLY);
    combo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    tv = new TableViewer(composite);

    tv.setContentProvider(new PlayerContentProvider());
    tv.setLabelProvider(new PlayerLabelProvider());
    tv.setSorter(new StudentViewerSorter());

    Table table = tv.getTable();/* w w w .  j a v a  2  s . c o m*/
    table.setLayoutData(new GridData(GridData.FILL_BOTH));

    TableColumn tc = new TableColumn(table, SWT.LEFT);
    tc.setText("First Name");
    tc.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            ((StudentViewerSorter) tv.getSorter()).doSort(Const.COLUMN_FIRST_NAME);
            tv.refresh();
        }
    });

    tc = new TableColumn(table, SWT.LEFT);
    tc.setText("Last Name");
    tc.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            ((StudentViewerSorter) tv.getSorter()).doSort(Const.COLUMN_LAST_NAME);
            tv.refresh();
        }
    });

    tc = new TableColumn(table, SWT.RIGHT);
    tc.setText("Math");
    tc.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            ((StudentViewerSorter) tv.getSorter()).doSort(Const.COLUMN_MATH);
            tv.refresh();
        }
    });

    tc = new TableColumn(table, SWT.RIGHT);
    tc.setText("CHEM");
    tc.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            ((StudentViewerSorter) tv.getSorter()).doSort(Const.COLUMN_CHEM);
            tv.refresh();
        }
    });

    tc = new TableColumn(table, SWT.RIGHT);
    tc.setText("AVE");
    tc.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            ((StudentViewerSorter) tv.getSorter()).doSort(Const.COLUMN_AVE);
            tv.refresh();
        }
    });

    for (int i = 0, n = model.teams.length; i < n; i++) {
        combo.add(model.teams[i].getName());
    }

    combo.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            update(model.teams[((Combo) event.widget).getSelectionIndex()]);
        }
    });

    combo.select(0);
    update(model.teams[0]);

    for (int i = 0, n = table.getColumnCount(); i < n; i++) {
        table.getColumn(i).pack();
    }
    table.setHeaderVisible(true);
    table.setLinesVisible(true);
    return composite;
}

From source file:edu.isistan.carcha.plugin.editors.DXMIEditor.java

/**
 * Creates the PieChart page.// w w  w .  ja v a2  s .  com
 */
void createPieChartPage() {
    result = new DefaultPieDataset();

    JFreeChart chart = ChartFactory.createPieChart("Design Decisions", result, true, true, false);
    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setStartAngle(290);
    plot.setDirection(Rotation.CLOCKWISE);
    plot.setForegroundAlpha(0.5f);

    Composite composite = new Composite(getContainer(), SWT.NONE);
    FillLayout layout = new FillLayout();
    composite.setLayout(layout);
    new ChartComposite(composite, SWT.NONE, chart, true);
    int index = addPage(composite);
    setPageText(index, "Graph");

}

From source file:grafici.PazientiPieChart.java

/**
 * Default constructor./*from   www. j a v a2 s . c o  m*/
 * 
 * @param title
 *            the frame title.
 */
public PazientiPieChart(String title, Composite parent, int style, int tipo) {
    super(parent, style);
    titolo = title;
    Composite cmp = new Composite(this, SWT.FILL | SWT.EMBEDDED);
    GridData gdCmp = new GridData(SWT.FILL);
    gdCmp.horizontalAlignment = SWT.FILL;
    gdCmp.verticalAlignment = SWT.FILL;
    gdCmp.grabExcessHorizontalSpace = true;
    gdCmp.grabExcessVerticalSpace = true;
    cmp.setLayoutData(gdCmp);
    cmp.setLayout(new GridLayout(1, false));

    JPanel chartPanel = createDemoPanel(tipo);
    Frame graphFrame = SWT_AWT.new_Frame(cmp);
    graphFrame.add(chartPanel);
    graphFrame.pack();

    GridData gdThis = new GridData(SWT.FILL);
    gdThis.horizontalAlignment = SWT.FILL;
    gdThis.verticalAlignment = SWT.FILL;
    gdThis.grabExcessHorizontalSpace = true;
    gdThis.grabExcessVerticalSpace = true;

    this.setLayoutData(gdThis);
    this.setLayout(new GridLayout(1, false));
}

From source file:grafici.MediciPieChart.java

/**
 * Default constructor./*  w w w . j a v  a  2s.com*/
 * 
 * @param title
 *            the frame title.
 */
public MediciPieChart(String title, Composite parent, int style, int tipo) {
    super(parent, style);
    titolo = title;
    Composite cmp = new Composite(this, SWT.FILL | SWT.EMBEDDED);
    GridData gdCmp = new GridData(SWT.FILL);
    gdCmp.horizontalAlignment = SWT.FILL;
    gdCmp.verticalAlignment = SWT.FILL;
    gdCmp.grabExcessHorizontalSpace = true;
    gdCmp.grabExcessVerticalSpace = true;
    cmp.setLayoutData(gdCmp);
    cmp.setLayout(new GridLayout(1, false));

    JPanel chartPanel = createDemoPanel(tipo);
    Frame graphFrame = SWT_AWT.new_Frame(cmp);
    graphFrame.add(chartPanel);
    graphFrame.pack();

    GridData gdThis = new GridData(SWT.FILL);
    gdThis.horizontalAlignment = SWT.FILL;
    gdThis.verticalAlignment = SWT.FILL;
    gdThis.grabExcessHorizontalSpace = true;
    gdThis.grabExcessVerticalSpace = true;

    this.setLayoutData(gdThis);
    this.setLayout(new GridLayout(1, false));
}

From source file:org.jfree.experimental.chart.swt.editor.SWTAxisEditor.java

/**
 * Standard constructor: builds a composite for displaying/editing 
 * the properties of the specified axis.
 *
 * @param parent The parent composite.//from w  w w  .  j  a  va  2  s . co  m
 * @param style The SWT style of the SwtAxisEditor.
 * @param axis  the axis whose properties are to be displayed/edited  
 *              in the composite.
 */
public SWTAxisEditor(Composite parent, int style, Axis axis) {
    super(parent, style);
    this.labelFont = SWTUtils.toSwtFontData(getDisplay(), axis.getLabelFont(), true);
    this.labelPaintColor = SWTUtils.toSwtColor(getDisplay(), axis.getLabelPaint());
    this.tickLabelFont = SWTUtils.toSwtFontData(getDisplay(), axis.getTickLabelFont(), true);
    this.tickLabelPaintColor = SWTUtils.toSwtColor(getDisplay(), axis.getTickLabelPaint());

    FillLayout layout = new FillLayout(SWT.VERTICAL);
    layout.marginHeight = layout.marginWidth = 4;
    this.setLayout(layout);
    Group general = new Group(this, SWT.NONE);
    general.setLayout(new GridLayout(3, false));
    general.setText(localizationResources.getString("General"));
    // row 1
    new Label(general, SWT.NONE).setText(localizationResources.getString("Label"));
    this.label = new Text(general, SWT.BORDER);
    if (axis.getLabel() != null) {
        this.label.setText(axis.getLabel());
    }
    this.label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    new Label(general, SWT.NONE).setText(""); //empty cell
    // row 2
    new Label(general, SWT.NONE).setText(localizationResources.getString("Font"));
    this.labelFontField = new Text(general, SWT.BORDER);
    this.labelFontField.setText(this.labelFont.toString());
    this.labelFontField.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    Button selectFontButton = new Button(general, SWT.PUSH);
    selectFontButton.setText(localizationResources.getString("Select..."));
    selectFontButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            // Create the color-change dialog
            FontDialog dlg = new FontDialog(getShell());
            dlg.setText(localizationResources.getString("Font_Selection"));
            dlg.setFontList(new FontData[] { SWTAxisEditor.this.labelFont });
            if (dlg.open() != null) {
                // Dispose of any fonts we have created
                if (SWTAxisEditor.this.font != null) {
                    SWTAxisEditor.this.font.dispose();
                }
                // Create the new font and set it into the title 
                // label
                SWTAxisEditor.this.font = new Font(getShell().getDisplay(), dlg.getFontList());
                //label.setFont( font );
                SWTAxisEditor.this.labelFontField.setText(SWTAxisEditor.this.font.getFontData()[0].toString());
                SWTAxisEditor.this.labelFont = SWTAxisEditor.this.font.getFontData()[0];
            }
        }
    });
    // row 3
    new Label(general, SWT.NONE).setText(localizationResources.getString("Paint"));
    // Use a colored text field to show the color
    final SWTPaintCanvas colorCanvas = new SWTPaintCanvas(general, SWT.NONE, this.labelPaintColor);
    GridData canvasGridData = new GridData(SWT.FILL, SWT.CENTER, true, false);
    canvasGridData.heightHint = 20;
    colorCanvas.setLayoutData(canvasGridData);
    Button selectColorButton = new Button(general, SWT.PUSH);
    selectColorButton.setText(localizationResources.getString("Select..."));
    selectColorButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            // Create the color-change dialog
            ColorDialog dlg = new ColorDialog(getShell());
            dlg.setText(localizationResources.getString("Title_Color"));
            dlg.setRGB(SWTAxisEditor.this.labelPaintColor.getRGB());
            RGB rgb = dlg.open();
            if (rgb != null) {
                // create the new color and set it to the 
                // SwtPaintCanvas
                SWTAxisEditor.this.labelPaintColor = new Color(getDisplay(), rgb);
                colorCanvas.setColor(SWTAxisEditor.this.labelPaintColor);
            }
        }
    });
    Group other = new Group(this, SWT.NONE);
    FillLayout tabLayout = new FillLayout();
    tabLayout.marginHeight = tabLayout.marginWidth = 4;
    other.setLayout(tabLayout);
    other.setText(localizationResources.getString("Other"));

    this.otherTabs = new TabFolder(other, SWT.NONE);
    TabItem item1 = new TabItem(this.otherTabs, SWT.NONE);
    item1.setText(" " + localizationResources.getString("Ticks") + " ");
    Composite ticks = new Composite(this.otherTabs, SWT.NONE);
    ticks.setLayout(new GridLayout(3, false));
    this.showTickLabelsCheckBox = new Button(ticks, SWT.CHECK);
    this.showTickLabelsCheckBox.setText(localizationResources.getString("Show_tick_labels"));
    this.showTickLabelsCheckBox.setSelection(axis.isTickLabelsVisible());
    this.showTickLabelsCheckBox.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1));
    new Label(ticks, SWT.NONE).setText(localizationResources.getString("Tick_label_font"));
    this.tickLabelFontField = new Text(ticks, SWT.BORDER);
    this.tickLabelFontField.setText(this.tickLabelFont.toString());
    //tickLabelFontField.setFont(SwtUtils.toSwtFontData(getDisplay(), 
    // axis.getTickLabelFont()));
    this.tickLabelFontField.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    Button selectTickLabelFontButton = new Button(ticks, SWT.PUSH);
    selectTickLabelFontButton.setText(localizationResources.getString("Select..."));
    selectTickLabelFontButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            // Create the font-change dialog
            FontDialog dlg = new FontDialog(getShell());
            dlg.setText(localizationResources.getString("Font_Selection"));
            dlg.setFontList(new FontData[] { SWTAxisEditor.this.tickLabelFont });
            if (dlg.open() != null) {
                // Dispose of any fonts we have created
                if (SWTAxisEditor.this.font != null) {
                    SWTAxisEditor.this.font.dispose();
                }
                // Create the new font and set it into the title 
                // label
                SWTAxisEditor.this.font = new Font(getShell().getDisplay(), dlg.getFontList());
                //tickLabelFontField.setFont(font);
                SWTAxisEditor.this.tickLabelFontField
                        .setText(SWTAxisEditor.this.font.getFontData()[0].toString());
                SWTAxisEditor.this.tickLabelFont = SWTAxisEditor.this.font.getFontData()[0];
            }
        }
    });
    this.showTickMarksCheckBox = new Button(ticks, SWT.CHECK);
    this.showTickMarksCheckBox.setText(localizationResources.getString("Show_tick_marks"));
    this.showTickMarksCheckBox.setSelection(axis.isTickMarksVisible());
    this.showTickMarksCheckBox.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1));
    item1.setControl(ticks);
}

From source file:grafici.PrenotazioniPieChart.java

/**
 * Default constructor./*from   w w w.  j a v  a  2  s  . c  om*/
 * 
 * @param title
 *            the frame title.
 */
public PrenotazioniPieChart(String title, Composite parent, int style, int tipo) {
    super(parent, style);
    titolo = title;
    Composite cmp = new Composite(this, SWT.FILL | SWT.EMBEDDED);
    GridData gdCmp = new GridData(SWT.FILL);
    gdCmp.horizontalAlignment = SWT.FILL;
    gdCmp.verticalAlignment = SWT.FILL;
    gdCmp.grabExcessHorizontalSpace = true;
    gdCmp.grabExcessVerticalSpace = true;
    cmp.setLayoutData(gdCmp);
    cmp.setLayout(new GridLayout(1, false));

    JPanel chartPanel = createDemoPanel(tipo);
    Frame graphFrame = SWT_AWT.new_Frame(cmp);
    graphFrame.add(chartPanel);
    graphFrame.pack();

    GridData gdThis = new GridData(SWT.FILL);
    gdThis.horizontalAlignment = SWT.FILL;
    gdThis.verticalAlignment = SWT.FILL;
    gdThis.grabExcessHorizontalSpace = true;
    gdThis.grabExcessVerticalSpace = true;

    this.setLayoutData(gdThis);
    this.setLayout(new GridLayout(1, false));
}

From source file:grafici.FatturePieChart.java

/**
 * Default constructor./*from  w w  w  .jav  a  2 s.c  om*/
 * 
 * @param title
 *            the frame title.
 */
public FatturePieChart(String title, Composite parent, int style, int tipo) {
    super(parent, style);
    titolo = title;
    Composite cmp = new Composite(this, SWT.FILL | SWT.EMBEDDED);
    GridData gdCmp = new GridData(SWT.FILL);
    gdCmp.horizontalAlignment = SWT.FILL;
    gdCmp.verticalAlignment = SWT.FILL;
    gdCmp.grabExcessHorizontalSpace = true;
    gdCmp.grabExcessVerticalSpace = true;
    cmp.setLayoutData(gdCmp);
    cmp.setLayout(new GridLayout(1, false));

    JPanel chartPanel = createDemoPanel(tipo);
    Frame graphFrame = SWT_AWT.new_Frame(cmp);
    graphFrame.add(chartPanel);
    graphFrame.pack();

    GridData gdThis = new GridData(SWT.FILL);
    gdThis.horizontalAlignment = SWT.FILL;
    gdThis.verticalAlignment = SWT.FILL;
    gdThis.grabExcessHorizontalSpace = true;
    gdThis.grabExcessVerticalSpace = true;

    this.setLayoutData(gdThis);
    this.setLayout(new GridLayout(1, false));
}

From source file:com.rcp.wbw.demo.editor.SWTAxisEditor.java

/**
 * Standard constructor: builds a composite for displaying/editing
 * the properties of the specified axis.
 * //w  w  w  . j  av a  2  s . c om
 * @param parent
 *            The parent composite.
 * @param style
 *            The SWT style of the SwtAxisEditor.
 * @param axis
 *            the axis whose properties are to be displayed/edited
 *            in the composite.
 */
public SWTAxisEditor(Composite parent, int style, Axis axis) {
    super(parent, style);
    this.labelFont = SWTUtils.toSwtFontData(getDisplay(), axis.getLabelFont(), true);
    this.labelPaintColor = SWTUtils.toSwtColor(getDisplay(), axis.getLabelPaint());
    this.tickLabelFont = SWTUtils.toSwtFontData(getDisplay(), axis.getTickLabelFont(), true);
    this.tickLabelPaintColor = SWTUtils.toSwtColor(getDisplay(), axis.getTickLabelPaint());

    FillLayout layout = new FillLayout(SWT.VERTICAL);
    layout.marginHeight = layout.marginWidth = 4;
    setLayout(layout);
    Group general = new Group(this, SWT.NONE);
    general.setLayout(new GridLayout(3, false));
    general.setText(localizationResources.getString("General"));
    // row 1
    new Label(general, SWT.NONE).setText(localizationResources.getString("Label"));
    this.label = new Text(general, SWT.BORDER);
    if (axis.getLabel() != null) {
        this.label.setText(axis.getLabel());
    }
    this.label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    new Label(general, SWT.NONE).setText(""); // empty cell
    // row 2
    new Label(general, SWT.NONE).setText(localizationResources.getString("Font"));
    this.labelFontField = new Text(general, SWT.BORDER);
    this.labelFontField.setText(this.labelFont.toString());
    this.labelFontField.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    Button selectFontButton = new Button(general, SWT.PUSH);
    selectFontButton.setText(localizationResources.getString("Select..."));
    selectFontButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            // Create the color-change dialog
            FontDialog dlg = new FontDialog(getShell());
            dlg.setText(localizationResources.getString("Font_Selection"));
            dlg.setFontList(new FontData[] { SWTAxisEditor.this.labelFont });
            if (dlg.open() != null) {
                // Dispose of any fonts we have created
                if (SWTAxisEditor.this.font != null) {
                    SWTAxisEditor.this.font.dispose();
                }
                // Create the new font and set it into the title
                // label
                SWTAxisEditor.this.font = new Font(getShell().getDisplay(), dlg.getFontList());
                // label.setFont(font);
                SWTAxisEditor.this.labelFontField.setText(SWTAxisEditor.this.font.getFontData()[0].toString());
                SWTAxisEditor.this.labelFont = SWTAxisEditor.this.font.getFontData()[0];
            }
        }
    });
    // row 3
    new Label(general, SWT.NONE).setText(localizationResources.getString("Paint"));
    // Use a colored text field to show the color
    final SWTPaintCanvas colorCanvas = new SWTPaintCanvas(general, SWT.NONE, this.labelPaintColor);
    GridData canvasGridData = new GridData(SWT.FILL, SWT.CENTER, true, false);
    canvasGridData.heightHint = 20;
    colorCanvas.setLayoutData(canvasGridData);
    Button selectColorButton = new Button(general, SWT.PUSH);
    selectColorButton.setText(localizationResources.getString("Select..."));
    selectColorButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            // Create the color-change dialog
            ColorDialog dlg = new ColorDialog(getShell());
            dlg.setText(localizationResources.getString("Title_Color"));
            dlg.setRGB(SWTAxisEditor.this.labelPaintColor.getRGB());
            RGB rgb = dlg.open();
            if (rgb != null) {
                // create the new color and set it to the
                // SwtPaintCanvas
                SWTAxisEditor.this.labelPaintColor = new Color(getDisplay(), rgb);
                colorCanvas.setColor(SWTAxisEditor.this.labelPaintColor);
            }
        }
    });
    Group other = new Group(this, SWT.NONE);
    FillLayout tabLayout = new FillLayout();
    tabLayout.marginHeight = tabLayout.marginWidth = 4;
    other.setLayout(tabLayout);
    other.setText(localizationResources.getString("Other"));

    this.otherTabs = new TabFolder(other, SWT.NONE);
    TabItem item1 = new TabItem(this.otherTabs, SWT.NONE);
    item1.setText(" " + localizationResources.getString("Ticks") + " ");
    Composite ticks = new Composite(this.otherTabs, SWT.NONE);
    ticks.setLayout(new GridLayout(3, false));
    this.showTickLabelsCheckBox = new Button(ticks, SWT.CHECK);
    this.showTickLabelsCheckBox.setText(localizationResources.getString("Show_tick_labels"));
    this.showTickLabelsCheckBox.setSelection(axis.isTickLabelsVisible());
    this.showTickLabelsCheckBox.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1));
    new Label(ticks, SWT.NONE).setText(localizationResources.getString("Tick_label_font"));
    this.tickLabelFontField = new Text(ticks, SWT.BORDER);
    this.tickLabelFontField.setText(this.tickLabelFont.toString());
    // tickLabelFontField.setFont(SwtUtils.toSwtFontData(getDisplay(),
    // axis.getTickLabelFont()));
    this.tickLabelFontField.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    Button selectTickLabelFontButton = new Button(ticks, SWT.PUSH);
    selectTickLabelFontButton.setText(localizationResources.getString("Select..."));
    selectTickLabelFontButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            // Create the font-change dialog
            FontDialog dlg = new FontDialog(getShell());
            dlg.setText(localizationResources.getString("Font_Selection"));
            dlg.setFontList(new FontData[] { SWTAxisEditor.this.tickLabelFont });
            if (dlg.open() != null) {
                // Dispose of any fonts we have created
                if (SWTAxisEditor.this.font != null) {
                    SWTAxisEditor.this.font.dispose();
                }
                // Create the new font and set it into the title
                // label
                SWTAxisEditor.this.font = new Font(getShell().getDisplay(), dlg.getFontList());
                // tickLabelFontField.setFont(font);
                SWTAxisEditor.this.tickLabelFontField
                        .setText(SWTAxisEditor.this.font.getFontData()[0].toString());
                SWTAxisEditor.this.tickLabelFont = SWTAxisEditor.this.font.getFontData()[0];
            }
        }
    });
    this.showTickMarksCheckBox = new Button(ticks, SWT.CHECK);
    this.showTickMarksCheckBox.setText(localizationResources.getString("Show_tick_marks"));
    this.showTickMarksCheckBox.setSelection(axis.isTickMarksVisible());
    this.showTickMarksCheckBox.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1));
    item1.setControl(ticks);
}

From source file:tools.descartes.bungee.viewer.RunResultView.java

@Override
public void createPartControl(final Composite parent) {
    VerifyListener numberVerifier = new VerifyListener() {
        @Override// w w  w  .  ja v a 2 s  .  c o m
        public void verifyText(VerifyEvent event) {
            switch (event.keyCode) {
            case SWT.BS: // Backspace  
            case SWT.DEL: // Delete  
            case SWT.HOME: // Home  
            case SWT.END: // End  
            case SWT.ARROW_LEFT: // Left arrow  
            case SWT.ARROW_RIGHT: // Right arrow  
                return;
            }

            if (!Character.isDigit(event.character)) {
                event.doit = false; // disallow the action  
            }
        }
    };

    Composite composite = new Composite(parent, SWT.NONE);
    GridData gridData = new GridData();
    gridData.verticalAlignment = GridData.FILL;
    gridData.grabExcessVerticalSpace = true;
    gridData.horizontalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    Composite compositeChecks1 = new Composite(composite, SWT.NONE);
    compositeChecks1.setLayout(new GridLayout(2, false));
    Text sanityText = new Text(compositeChecks1, SWT.NONE);
    sanityText.setText("Passed Sanity Check:");
    sanityCheckValue = new Button(compositeChecks1, SWT.CHECK);
    sanityCheckValue.setEnabled(false);
    Composite compositeSChecks2 = new Composite(composite, SWT.NONE);
    compositeSChecks2.setLayout(new GridLayout(2, false));
    Text scheduleText = new Text(compositeSChecks2, SWT.NONE);
    scheduleText.setText("Passed Schedule Check:");
    scheduleCheckValue = new Button(compositeSChecks2, SWT.CHECK);
    scheduleCheckValue.setEnabled(false);
    Text completedText = new Text(compositeChecks1, SWT.NONE);
    completedText.setText("Run completed:");
    completedCheckValue = new Button(compositeChecks1, SWT.CHECK);
    completedCheckValue.setEnabled(false);
    Text successText = new Text(compositeSChecks2, SWT.NONE);
    successText.setText("Run successful:");
    successCheckValue = new Button(compositeSChecks2, SWT.CHECK);
    successCheckValue.setEnabled(false);
    Text timingMeanText = new Text(composite, SWT.NONE);
    timingMeanText.setText("Schedule deviation mean: ");
    timingMeanValue = new Text(composite, SWT.SINGLE);
    timingMeanValue.setText("");
    Text timingStdText = new Text(composite, SWT.NONE);
    timingStdText.setText("Schedule deviation std: ");
    timingStdValue = new Text(composite, SWT.SINGLE);
    timingStdValue.setText("");
    Text responseTimeMeanText = new Text(composite, SWT.NONE);
    responseTimeMeanText.setText("Responsetime mean: ");
    responseTimeMeanValue = new Text(composite, SWT.SINGLE);
    responseTimeMeanValue.setText("");
    Text responseTimeStdText = new Text(composite, SWT.NONE);
    responseTimeStdText.setText("Responsetime std: ");
    responseTimeStdValue = new Text(composite, SWT.SINGLE);
    responseTimeStdValue.setText("");
    Text chartWidthText = new Text(composite, SWT.NONE);
    chartWidthText.setText("Chart width: ");
    final Text chartWidthValue = new Text(composite, SWT.BORDER);
    chartWidthValue.setText("800");
    chartWidthValue.addVerifyListener(numberVerifier);
    Text chartHeightText = new Text(composite, SWT.NONE);
    chartHeightText.setText("Chart height: ");
    final Text chartHeightValue = new Text(composite, SWT.BORDER);
    chartHeightValue.setText("400");
    chartHeightValue.addVerifyListener(numberVerifier);
    showScheduleChartButton = new Button(composite, SWT.NONE);
    showScheduleChartButton.setText("Show Schedule Chart");
    showScheduleChartButton.addListener(SWT.Selection, new Listener() {
        public void handleEvent(Event e) {
            switch (e.type) {
            case SWT.Selection:
                showScheduleChart(Integer.parseInt(chartWidthValue.getText()),
                        Integer.parseInt(chartHeightValue.getText()));
                break;
            }
        }
    });
    saveScheduleChartButton = new Button(composite, SWT.NONE);
    saveScheduleChartButton.setText("Save Schedule Chart");
    saveScheduleChartButton.addListener(SWT.Selection, new Listener() {
        public void handleEvent(Event e) {
            //            optional window
            Display display = Display.getDefault();
            Shell dialogShell = new Shell(display, SWT.APPLICATION_MODAL);
            MessageBox dialog = new MessageBox(dialogShell, SWT.ICON_WARNING | SWT.OK);
            dialog.setText("Licence Problem");
            dialog.setMessage(
                    "This feature is currently disabled! \n If you want to reenable it, check out the code.");
            dialog.open();
            //            end of optional window
            switch (e.type) {
            case SWT.Selection:
                saveScheduleChart(Integer.parseInt(chartWidthValue.getText()),
                        Integer.parseInt(chartHeightValue.getText()));
                break;
            }
        }
    });
    showResponseChartButton = new Button(composite, SWT.NONE);
    showResponseChartButton.setText("Show Response Chart");
    showResponseChartButton.addListener(SWT.Selection, new Listener() {
        public void handleEvent(Event e) {
            switch (e.type) {
            case SWT.Selection:
                showResponseChart(Integer.parseInt(chartWidthValue.getText()),
                        Integer.parseInt(chartHeightValue.getText()));
                break;
            }
        }
    });
    saveResponseChartButton = new Button(composite, SWT.NONE);
    saveResponseChartButton.setText("Save Response Chart");
    saveResponseChartButton.addListener(SWT.Selection, new Listener() {
        public void handleEvent(Event e) {
            //            optional window
            Display display = Display.getDefault();
            Shell dialogShell = new Shell(display, SWT.APPLICATION_MODAL);
            MessageBox dialog = new MessageBox(dialogShell, SWT.ICON_WARNING | SWT.OK);
            dialog.setText("Licence problem");
            dialog.setMessage(
                    "This feature is currently disabled! \n If you want to reenable it, check out the code.");
            dialog.open();
            //            end of optional window
            switch (e.type) {
            case SWT.Selection:
                saveResponseChart(Integer.parseInt(chartWidthValue.getText()),
                        Integer.parseInt(chartHeightValue.getText()));
                break;
            }
        }
    });
    getSite().getWorkbenchWindow().getSelectionService().addSelectionListener(this);
    composite.setLayout(new GridLayout(2, false));
    this.parent = parent;
}