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

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

Introduction

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

Prototype

public Composite(Composite parent, int style) 

Source Link

Document

Constructs a new instance of this class given its parent and a style value describing its behavior and appearance.

Usage

From source file:PersonEditor.java

/**
 * Creates the main window's contents/* w ww  .java2  s.  c o  m*/
 * 
 * @param parent
 *            the main window
 * @return Control
 */
protected Control createContents(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayout(new GridLayout(1, false));

    // Add a button to create the new person
    Button newPerson = new Button(composite, SWT.PUSH);
    newPerson.setText("Create New Person");

    // Add the TableViewer
    final TableViewer tv = new TableViewer(composite, SWT.FULL_SELECTION);
    tv.setContentProvider(new PersonContentProvider());
    tv.setLabelProvider(new PersonLabelProvider());
    tv.setInput(people);

    // Set up the table
    Table table = tv.getTable();
    table.setLayoutData(new GridData(GridData.FILL_BOTH));

    new TableColumn(table, SWT.CENTER).setText(NAME);
    new TableColumn(table, SWT.CENTER).setText(MALE);
    new TableColumn(table, SWT.CENTER).setText(AGE);
    new TableColumn(table, SWT.CENTER).setText(SHIRT_COLOR);

    for (int i = 0, n = table.getColumnCount(); i < n; i++) {
        table.getColumn(i).pack();
    }

    table.setHeaderVisible(true);
    table.setLinesVisible(true);

    // Add a new person when the user clicks button
    newPerson.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            Person p = new Person();
            p.setName("Name");
            p.setMale(true);
            p.setAgeRange(Integer.valueOf("0"));
            p.setShirtColor(new RGB(255, 0, 0));
            people.add(p);
            tv.refresh();
        }
    });

    // Create the cell editors
    CellEditor[] editors = new CellEditor[4];
    editors[0] = new TextCellEditor(table);
    editors[1] = new CheckboxCellEditor(table);
    editors[2] = new ComboBoxCellEditor(table, AgeRange.INSTANCES, SWT.READ_ONLY);
    editors[3] = new ColorCellEditor(table);

    // Set the editors, cell modifier, and column properties
    tv.setColumnProperties(PROPS);
    tv.setCellModifier(new PersonCellModifier(tv));
    tv.setCellEditors(editors);

    return composite;
}

From source file:DumbUser.java

/**
 * Creates the dialog area//w ww .j a v  a2s. co m
 * 
 * @param parent the parent composite
 * @return Control
 */
protected Control createDialogArea(Composite parent) {
    createMessageArea(parent);

    // Create a composite to hold the label
    Composite composite = new Composite(parent, SWT.NONE);
    GridData data = new GridData(GridData.FILL_BOTH);
    data.horizontalSpan = 2;
    composite.setLayoutData(data);
    composite.setLayout(new FillLayout());

    // Create the label for the "hidden" message
    label = new Label(composite, SWT.LEFT);

    return composite;
}

From source file:grafici.StatistichePieChart.java

/**
 * Default constructor.//from   w  w  w.j av a  2s . co m
 * 
 * @param title the frame title.
 */
public StatistichePieChart(Table result, Composite parent, int style, int indexVariabile, int indexValore) {
    super(parent, style);
    try {

        titolo = result.getColumn(indexVariabile).getText().toUpperCase() + " - "
                + result.getColumn(indexValore).getText().toUpperCase();
        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(result, indexVariabile, indexValore);
        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));
    } catch (Exception e) {
        alertGraficoNonDisp();
    }
}

From source file:net.bioclipse.seneca.views.BestStructureView.java

public void createPartControl(Composite parent) {
    SashForm sash = new SashForm(parent, SWT.VERTICAL);
    jcpwidget = new JChemPaintEditorWidget(sash, SWT.PUSH);
    Composite contChartcomposite = new Composite(sash, SWT.EMBEDDED);
    FillLayout layout = new FillLayout(SWT.VERTICAL);
    contChartcomposite.setLayout(layout);
    fileTableFrame = SWT_AWT.new_Frame(contChartcomposite);

    String xAxisLabel = "Steps";
    String yAxisLabel = "Temperature/Score";
    String title = "Annealing progress";
    XYSeries series = new XYSeries("Signal");
    for (int i = 0; i < (maxSteps != 0 ? maxSteps : temps.size()); i++) {
        if (i < temps.size())
            series.add(i, temps.get(i));
        else//w  w w.j  a va 2s.co  m
            series.add(i, 0);
    }

    XYDataset xyDataset = new XYSeriesCollection(series);
    continuousChart = ChartFactory.createXYAreaChart(title, xAxisLabel, yAxisLabel, xyDataset,
            PlotOrientation.VERTICAL, false, true, false);
    continuousChart.setAntiAlias(false);

    XYPlot continuousPlot = continuousChart.getXYPlot();

    continuousPlot.setRenderer(new StandardXYItemRenderer());
    ChartPanel chart = new ChartPanel(continuousChart);
    fileTableFrame.add(chart);
    //fileTableFrame.validate();
    //fileTableFrame.repaint();

}

From source file:Survey.java

/**
 * Creates the controls for this page// www  .  j ava2s .  c  o  m
 */
public void createControl(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayout(new GridLayout(1, false));

    new Label(composite, SWT.LEFT).setText("Please enter your complaints");
    Text text = new Text(composite, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL);
    text.setLayoutData(new GridData(GridData.FILL_BOTH));

    setControl(composite);
}

From source file:grafici.StatisticheLineChart.java

/**
 * Creates a new demo instance.// w ww.  j a  va 2  s .  co  m
 * 
 * @param title
 *            the frame title.
 */
public StatisticheLineChart(Table risultati, Composite parent, int style, int variabile, int valore) {
    super(parent, style);
    try {
        this.titolo = risultati.getColumn(variabile).getText().toUpperCase() + " - "
                + risultati.getColumn(valore).getText().toUpperCase();
        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));
        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));

        CategoryDataset dataset = createDataset(risultati, variabile, valore);
        JFreeChart chart = createChart(dataset, risultati, variabile, valore);
        ChartPanel chartPanel = new ChartPanel(chart);
        chartPanel.setFillZoomRectangle(true);
        // chartPanel.setMouseWheelEnabled(true);
        // chartPanel.setPreferredSize(new Dimension(1000, 700));
        Frame graphFrame = SWT_AWT.new_Frame(cmp);
        graphFrame.add(chartPanel);
        graphFrame.pack();

    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:CoolBarTest.java

/**
 * Creates the Combo/*  w  w w  .j  a  v  a 2 s.c om*/
 * 
 * @param composite the parent composite
 * @return Control
 */
private Control createCombo(Composite composite) {
    // A bug with Windows causes the Combo not to drop
    // down if you add it directly to the CoolBar.
    // To work around this, create a Composite, add the
    // Combo to it, and add the Composite to the CoolBar.
    // This should work both on Windows and on all other
    // platforms.
    Composite c = new Composite(composite, SWT.NONE);
    c.setLayout(new FillLayout());
    Combo combo = new Combo(c, SWT.DROP_DOWN);
    combo.add("Option One");
    combo.add("Option Two");
    combo.add("Option Three");
    return c;
}

From source file:ProgressBarDialog.java

protected void createContents() {
    shell = new Shell(getParent(), SWT.TITLE | SWT.PRIMARY_MODAL);
    display = shell.getDisplay();/*from   w  w w.j  a  va2s  . co m*/
    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:grafici.PazientiTimeSeriesChart.java

/**
 * A demonstration application showing how to create a simple time series
 * chart.  This example uses monthly data.
 *
 * @param title  the frame title./*  w  w w  .j a v a2  s  .  c  om*/
 */
public PazientiTimeSeriesChart(String title, Composite parent, int style, int tipo) {
    super(parent, style);

    Label titolo = new Label(this, SWT.NONE);
    titolo.setFont(new Font(titolo.getDisplay(), "arial", 15, SWT.BOLD));
    titolo.setText(title);
    GridData gdLbl = new GridData(SWT.FILL);
    titolo.setLayoutData(gdLbl);
    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.eclipse.swt.examples.graphics.AnimatedGraphicsTab.java

/**
 * Creates the toolbar controls: play, pause and animation timer.
 *
 * @param parent A composite/*from   w  w w . j av  a2s.c  o m*/
 */
void createToolBar(final Composite parent) {
    final Display display = parent.getDisplay();

    toolBar = new ToolBar(parent, SWT.FLAT);
    Listener toolBarListener = event -> {
        switch (event.type) {
        case SWT.Selection: {
            if (event.widget == playItem) {
                animate = true;
                playItem.setEnabled(!animate);
                pauseItem.setEnabled(animate);
            } else if (event.widget == pauseItem) {
                animate = false;
                playItem.setEnabled(!animate);
                pauseItem.setEnabled(animate);
            }
        }
            break;
        }
    };

    // play tool item
    playItem = new ToolItem(toolBar, SWT.PUSH);
    playItem.setText(GraphicsExample.getResourceString("Play")); //$NON-NLS-1$
    playItem.setImage(example.loadImage(display, "play.gif")); //$NON-NLS-1$
    playItem.addListener(SWT.Selection, toolBarListener);

    // pause tool item
    pauseItem = new ToolItem(toolBar, SWT.PUSH);
    pauseItem.setText(GraphicsExample.getResourceString("Pause")); //$NON-NLS-1$
    pauseItem.setImage(example.loadImage(display, "pause.gif")); //$NON-NLS-1$
    pauseItem.addListener(SWT.Selection, toolBarListener);

    // timer spinner
    Composite comp = new Composite(parent, SWT.NONE);
    GridLayout gridLayout = new GridLayout(2, false);
    comp.setLayout(gridLayout);

    Label label = new Label(comp, SWT.CENTER);
    label.setText(GraphicsExample.getResourceString("Animation")); //$NON-NLS-1$
    timerSpinner = new Spinner(comp, SWT.BORDER | SWT.WRAP);
    timerSpinner.setMaximum(1000);

    playItem.setEnabled(false);
    animate = true;

    timerSpinner.setSelection(getInitialAnimationTime());
}