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:grafici.PazientiBarChart.java

/**
 * Creates a new demo instance.//from w  w  w .  j a v  a2s.  c om
 * 
 * @param title
 *            the frame title.
 */
public PazientiBarChart(String title, Composite parent, int style, int tipo) {
    super(parent, style);
    try {
        this.titolo = title;
        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(tipo);
        JFreeChart chart = createChart(dataset);
        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:eu.stratosphere.addons.visualization.swt.SWTInstanceToolTip.java

public SWTInstanceToolTip(Shell parent, final SWTToolTipCommandReceiver commandReceiver,
        NetworkNode networkNode, int x, int y) {
    super(parent, x, y);

    this.networkNode = networkNode;

    final Color backgroundColor = getShell().getBackground();
    final Color foregroundColor = getShell().getForeground();

    boolean isProfilingEnabled = false;
    final InstanceVisualizationData instanceVisualizationData = (InstanceVisualizationData) networkNode
            .getAttachment();/* w  ww .j a va 2  s. co  m*/
    if (instanceVisualizationData != null) {
        isProfilingEnabled = instanceVisualizationData.isProfilingEnabledForJob();
    }

    int height;

    // Set the title
    setTitle(networkNode.getName());

    // Only create chart if profiling is enabled
    if (isProfilingEnabled) {
        this.cpuChart = createCPUChart(instanceVisualizationData, backgroundColor);
        this.cpuChart.setLayoutData(new GridData(GridData.FILL_BOTH));
        this.memoryChart = createMemoryChart(instanceVisualizationData, backgroundColor);
        this.memoryChart.setLayoutData(new GridData(GridData.FILL_BOTH));
        this.networkChart = createNetworkChart(instanceVisualizationData, backgroundColor);
        this.networkChart.setLayoutData(new GridData(GridData.FILL_BOTH));
        height = 460;
    } else {
        this.cpuChart = null;
        this.memoryChart = null;
        this.networkChart = null;
        height = 75;
    }

    // Available instance actions
    final Composite instanceActionComposite = new Composite(getShell(), SWT.NONE);
    instanceActionComposite.setLayout(new RowLayout(SWT.HORIZONTAL));
    instanceActionComposite.setBackground(backgroundColor);
    instanceActionComposite.setForeground(foregroundColor);

    final Button killInstanceButton = new Button(instanceActionComposite, SWT.PUSH);
    final String instanceName = this.networkNode.getName();
    killInstanceButton.setText("Kill instance...");
    killInstanceButton.setEnabled(this.networkNode.isLeafNode());
    killInstanceButton.addListener(SWT.Selection, new Listener() {

        @Override
        public void handleEvent(Event arg0) {
            commandReceiver.killInstance(instanceName);
        }

    });

    getShell().setSize(WIDTH, height);

    finishInstantiation(x, y, WIDTH, false);
}

From source file:grafici.StatisticheBarChart3D.java

/**
 * Creates a new demo instance.// w  w w .  j  a va  2 s  .com
 * 
 * @param title
 *            the frame title.
 */
public StatisticheBarChart3D(Table risultati, Composite parent, int style, int variabile1, int variabile2,
        int valore) {
    super(parent, style);
    try {
        this.titolo = risultati.getColumn(variabile1).getText().toUpperCase() + " - "
                + risultati.getColumn(variabile2).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, variabile1, variabile2, valore);
        JFreeChart chart = createChart(dataset, risultati, variabile1, variabile2, 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) {
        alertGraficoNonDisp();
    }
}

From source file:grafici.PrenotazioniBarChart.java

/**
 * Creates a new demo instance./*from   w ww.j a v  a  2  s. c o m*/
 * 
 * @param title
 *            the frame title.
 */
public PrenotazioniBarChart(String title, Composite parent, int style, int tipo) {
    super(parent, style);
    try {
        this.titolo = title;
        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(tipo);
        JFreeChart chart = createChart(dataset);
        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:org.emftrace.quarc.ui.views.RatioView.java

@Override
public void createPartControl(Composite parent) {

    parent.setLayout(new FillLayout());

    parentComposite = new Composite(parent, SWT.NONE);
    parentComposite.setLayout(new FillLayout());

    selectionServiceListener = new ISelectionListener() {
        public void selectionChanged(IWorkbenchPart sourcepart, ISelection selection) {

            if (sourcepart instanceof QUARCModelElementEditor && ((QUARCModelElementEditor) sourcepart)
                    .getModelElement() instanceof SelectedGoalsPriorities) {

                AbstractElementGraphBuilder builder = ((AbstractGSSFormPage) ((QUARCModelElementEditor) sourcepart)
                        .getActivePageInstance()).getBuilder();
                if (builder instanceof SelectedGoalsGraphBuilder)
                    showChart((SelectedGoalsGraphBuilder) builder);

            } else if (sourcepart instanceof CompareElementsEditor) {

                showSpiderChartForElementsToCompare((CompareElementsEditor) sourcepart);
            }//ww w. j a  v a2  s .  com

            else {
                if (composite != null)
                    composite.dispose();
            }

        }

    };

    getSite().getWorkbenchWindow().getSelectionService().addSelectionListener(selectionServiceListener);
}

From source file:grafici.MediciBarChart.java

/**
 * Creates a new demo instance./*from w  ww  . j a  v  a2s  .  c om*/
 * 
 * @param title
 *            the frame title.
 */
public MediciBarChart(String title, Composite parent, int style, int tipo) {
    super(parent, style);
    try {
        this.titolo = title;
        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(tipo);
        JFreeChart chart = createChart(dataset);
        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:grafici.FattureTimeSeriesChart.java

/**
 * A demonstration application showing how to create a simple time series
 * chart. This example uses monthly data.
 * //from  w  w w  .j  a v  a  2 s  .  c  o m
 * @param title
 *            the frame title.
 */
public FattureTimeSeriesChart(String title, Composite parent, int style, int tipo) {
    super(parent, style);
    System.out.println(2);
    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 = createPanel(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.MediciTimeSeriesChart.java

/**
 * A demonstration application showing how to create a simple time series
 * chart. This example uses monthly data.
 * /*from www . j  a  va2 s  .  c o m*/
 * @param title
 *            the frame title.
 */
public MediciTimeSeriesChart(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:eu.stratosphere.addons.visualization.swt.SWTVertexToolTip.java

public SWTVertexToolTip(Shell parent, final SWTToolTipCommandReceiver commandReceiver,
        ManagementVertex managementVertex, int x, int y) {
    super(parent, x, y);

    this.managementVertex = managementVertex;

    final VertexVisualizationData vertexVisualizationData = (VertexVisualizationData) managementVertex
            .getAttachment();/*from   w w w .jav a 2  s.c om*/

    int height;

    final Color backgroundColor = getShell().getBackground();
    final Color foregroundColor = getShell().getForeground();

    // Set the title
    final String taskName = managementVertex.getName() + " (" + (managementVertex.getIndexInGroup() + 1)
            + " of " + managementVertex.getNumberOfVerticesInGroup() + ")";
    setTitle(taskName);

    // Only create chart if profiling is enabled
    if (vertexVisualizationData.isProfilingEnabledForJob()) {
        this.threadChart = createThreadChart(vertexVisualizationData, backgroundColor);
        this.threadChart.setLayoutData(new GridData(GridData.FILL_BOTH));
        height = 240; // should be 265 when cancel button is enabled
    } else {
        this.threadChart = null;
        height = 125;
    }

    final Composite tableComposite = new Composite(getShell(), SWT.NONE);
    tableComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    tableComposite.setBackground(backgroundColor);
    tableComposite.setForeground(foregroundColor);
    final GridLayout tableGridLayout = new GridLayout(3, false);
    tableGridLayout.marginHeight = 0;
    tableGridLayout.marginLeft = 0;
    tableComposite.setLayout(tableGridLayout);

    final GridData gridData1 = new GridData();
    gridData1.horizontalSpan = 2;
    gridData1.grabExcessHorizontalSpace = true;
    gridData1.widthHint = 200;

    final GridData gridData2 = new GridData();
    gridData2.grabExcessHorizontalSpace = true;

    // Instance type
    final Label instanceTypeTextLabel = new Label(tableComposite, SWT.NONE);
    instanceTypeTextLabel.setBackground(backgroundColor);
    instanceTypeTextLabel.setForeground(foregroundColor);
    instanceTypeTextLabel.setText("Instance type:");

    this.instanceTypeLabel = new Label(tableComposite, SWT.NONE);
    this.instanceTypeLabel.setBackground(backgroundColor);
    this.instanceTypeLabel.setForeground(foregroundColor);
    this.instanceTypeLabel.setText(this.managementVertex.getInstanceType());
    this.instanceTypeLabel.setLayoutData(gridData1);

    // Instance ID
    final Label instanceIDTextLabel = new Label(tableComposite, SWT.NONE);
    instanceIDTextLabel.setBackground(backgroundColor);
    instanceIDTextLabel.setForeground(foregroundColor);
    instanceIDTextLabel.setText("Instance ID:");

    this.instanceIDLabel = new Label(tableComposite, SWT.NONE);
    this.instanceIDLabel.setBackground(backgroundColor);
    this.instanceIDLabel.setForeground(foregroundColor);
    this.instanceIDLabel.setText(this.managementVertex.getInstanceName());
    this.instanceIDLabel.setLayoutData(gridData2);

    final Button switchToInstanceButton = new Button(tableComposite, SWT.PUSH);
    switchToInstanceButton.setText("Switch to instance...");
    switchToInstanceButton.setEnabled(vertexVisualizationData.isProfilingEnabledForJob());
    switchToInstanceButton.setVisible(false);

    /*
     * final String instanceName = this.managementVertex.getInstanceName();
     * switchToInstanceButton.addListener(SWT.Selection, new Listener() {
     * @Override
     * public void handleEvent(Event arg0) {
     * commandReceiver.switchToInstance(instanceName);
     * }
     * });
     */

    // Execution state
    final Label executionStateTextLabel = new Label(tableComposite, SWT.NONE);
    executionStateTextLabel.setBackground(backgroundColor);
    executionStateTextLabel.setForeground(foregroundColor);
    executionStateTextLabel.setText("Execution state:");

    this.executionStateLabel = new Label(tableComposite, SWT.NONE);
    this.executionStateLabel.setBackground(backgroundColor);
    this.executionStateLabel.setForeground(foregroundColor);
    this.executionStateLabel.setText(this.managementVertex.getExecutionState().toString());
    this.executionStateLabel.setLayoutData(gridData1);

    final ManagementGroupVertex groupVertex = this.managementVertex.getGroupVertex();
    final GroupVertexVisualizationData groupVertexVisualizationData = (GroupVertexVisualizationData) groupVertex
            .getAttachment();
    if (groupVertexVisualizationData.isCPUBottleneck()) {
        this.warningComposite = createWarningComposite(WARNINGTEXT, SWT.ICON_WARNING);
        height += ICONSIZE;
    } else {
        this.warningComposite = null;
    }

    // Available task actions
    final Composite taskActionComposite = new Composite(getShell(), SWT.NONE);
    taskActionComposite.setLayout(new RowLayout(SWT.HORIZONTAL));
    taskActionComposite.setBackground(backgroundColor);
    taskActionComposite.setForeground(foregroundColor);

    /*
     * final Button cancelTaskButton = new Button(taskActionComposite, SWT.PUSH);
     * final ManagementVertexID vertexID = this.managementVertex.getID();
     * cancelTaskButton.setText("Cancel task");
     * cancelTaskButton.setEnabled(this.managementVertex.getExecutionState() == ExecutionState.RUNNING);
     * cancelTaskButton.addListener(SWT.Selection, new Listener() {
     * @Override
     * public void handleEvent(Event arg0) {
     * commandReceiver.cancelTask(vertexID, taskName);
     * }
     * });
     */

    getShell().setSize(WIDTH, height);

    finishInstantiation(x, y, WIDTH, false);
}

From source file:org.eclipse.swt.examples.controlexample.SashTab.java

/**
 * Creates the "Example" widgets./*from  w  w w  .j a  v  a 2 s.  c  o m*/
 */
@Override
void createExampleWidgets() {
    /*
     * Create the page.  This example does not use layouts.
     */
    int style = getDefaultStyle();
    sashComp = new Composite(sashGroup, SWT.BORDER | style);

    /* Create the list and text widgets */
    list1 = new List(sashComp, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER);
    list1.setItems(ListData0);
    list2 = new List(sashComp, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER);
    list2.setItems(ListData1);
    text = new Text(sashComp, SWT.MULTI | SWT.BORDER);
    text.setText(ControlExample.getResourceString("Multi_line"));

    /* Create the sashes */
    style = smoothButton.getSelection() ? SWT.SMOOTH : SWT.NONE;
    vSash = new Sash(sashComp, SWT.VERTICAL | style);
    hSash = new Sash(sashComp, SWT.HORIZONTAL | style);

    /* Add the listeners */
    hSash.addSelectionListener(widgetSelectedAdapter(event -> {
        Rectangle rect = vSash.getParent().getClientArea();
        event.y = Math.min(Math.max(event.y, SASH_LIMIT), rect.height - SASH_LIMIT);
        if (event.detail != SWT.DRAG) {
            hSash.setBounds(event.x, event.y, event.width, event.height);
            layout();
        }
    }));
    vSash.addSelectionListener(widgetSelectedAdapter(event -> {
        Rectangle rect = vSash.getParent().getClientArea();
        event.x = Math.min(Math.max(event.x, SASH_LIMIT), rect.width - SASH_LIMIT);
        if (event.detail != SWT.DRAG) {
            vSash.setBounds(event.x, event.y, event.width, event.height);
            layout();
        }
    }));
    sashComp.addControlListener(ControlListener.controlResizedAdapter(e -> resized()));
}