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:org.locationtech.udig.processingtoolbox.tools.BubbleChartDialog.java

private void createInputTab(final CTabFolder parentTabFolder) {
    inputTab = new CTabItem(parentTabFolder, SWT.NONE);
    inputTab.setText(Messages.ProcessExecutionDialog_tabparameters);

    ScrolledComposite scroller = new ScrolledComposite(parentTabFolder, SWT.NONE | SWT.V_SCROLL | SWT.H_SCROLL);
    scroller.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    Composite container = new Composite(scroller, SWT.NONE);
    container.setLayout(new GridLayout(1, false));
    container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    // local moran's i
    Image image = ToolboxPlugin.getImageDescriptor("icons/public_co.gif").createImage(); //$NON-NLS-1$
    uiBuilder.createLabel(container, Messages.ScatterPlotDialog_InputLayer, EMPTY, image, 1);
    cboLayer = uiBuilder.createCombo(container, 1, true);
    fillLayers(map, cboLayer, VectorLayerType.ALL);

    uiBuilder.createLabel(container, Messages.BubbleChartDialog_XField, EMPTY, image, 1);
    cboXField = uiBuilder.createCombo(container, 1, true);

    uiBuilder.createLabel(container, Messages.BubbleChartDialog_YField, EMPTY, image, 1);
    cboYField = uiBuilder.createCombo(container, 1, true);

    uiBuilder.createLabel(container, Messages.BubbleChartDialog_SizeField, EMPTY, image, 1);
    cboSize = uiBuilder.createCombo(container, 1, true);

    uiBuilder.createLabel(container, null, null, 1);
    chkStatistics = uiBuilder.createCheckbox(container, Messages.ScatterPlotDialog_BasicStatistics, null, 1);

    // register events
    cboLayer.addModifyListener(new ModifyListener() {
        @Override//from  ww w .  j  a v a 2s . c  om
        public void modifyText(ModifyEvent e) {
            inputLayer = MapUtils.getLayer(map, cboLayer.getText());
            if (inputLayer != null) {
                fillFields(cboXField, inputLayer.getSchema(), FieldType.Number);
                fillFields(cboYField, inputLayer.getSchema(), FieldType.Number);
                fillFields(cboSize, inputLayer.getSchema(), FieldType.Number);
            }
        }
    });

    // finally
    scroller.setContent(container);
    inputTab.setControl(scroller);

    scroller.setMinSize(450, container.getSize().y - 2);
    scroller.setExpandVertical(true);
    scroller.setExpandHorizontal(true);

    scroller.pack();
    container.pack();
}

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  .j  av a2s  .  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.gumtree.vis.plot1d.Plot1D.java

private void createStatusBar() {
    Composite statusComposite = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout(6, false);
    layout.marginLeft = 6;//  w  w w. ja va  2 s.com
    layout.marginRight = 6;
    layout.marginTop = 1;
    layout.marginBottom = 1;
    layout.horizontalSpacing = 3;
    layout.verticalSpacing = 1;
    statusComposite.setLayout(layout);

    GridData gridData = new GridData(SWT.FILL);
    gridData.grabExcessHorizontalSpace = true;
    gridData.grabExcessVerticalSpace = false;
    statusComposite.setLayoutData(gridData);

    final Label xLabel = new Label(statusComposite, SWT.NONE);
    xLabel.setText("X:");
    gridData = new GridData(SWT.DEFAULT);
    xLabel.setLayoutData(gridData);
    //      GridDataFactory.swtDefaults().applyTo(xLabel);
    final Text xText = new Text(statusComposite, SWT.BORDER);
    gridData = new GridData(SWT.FILL);
    gridData.widthHint = 50;
    xText.setLayoutData(gridData);
    //      GridDataFactory.fillDefaults().hint(50, SWT.DEFAULT).applyTo(xText);
    xText.setEditable(false);

    final Label yLabel = new Label(statusComposite, SWT.NONE);
    yLabel.setText("Y:");
    gridData = new GridData(SWT.DEFAULT);
    yLabel.setLayoutData(gridData);
    //      GridDataFactory.swtDefaults().applyTo(yLabel);
    final Text yText = new Text(statusComposite, SWT.BORDER);
    gridData = new GridData(SWT.FILL);
    gridData.widthHint = 50;
    yText.setLayoutData(gridData);
    //      GridDataFactory.fillDefaults().hint(50, SWT.DEFAULT).applyTo(yText);
    yText.setEditable(false);

    final Composite composite = this;
    panel.addChartMouseListener(new ChartMouseListener() {

        @Override
        public void chartMouseMoved(ChartMouseEvent event) {
            if (event instanceof XYChartMouseEvent) {
                final String xString = String.format("%.2f", ((XYChartMouseEvent) event).getX());
                final String yString = String.format("%.2f", ((XYChartMouseEvent) event).getY());
                //                  panel.requestFocus();

                Display.getDefault().asyncExec(new Runnable() {

                    @Override
                    public void run() {
                        xText.setText(xString);
                        yText.setText(yString);
                        if (!composite.isFocusControl()) {
                            composite.setFocus();
                        }
                    }
                });
            }
        }

        @Override
        public void chartMouseClicked(ChartMouseEvent event) {
            Display.getDefault().asyncExec(new Runnable() {

                @Override
                public void run() {
                    if (!composite.isFocusControl()) {
                        composite.setFocus();
                    }
                }
            });
        }
    });
}

From source file:org.eclipse.swt.examples.ole.win32.OleBrowserView.java

/**
 * Creates the Web browser toolbar./*from  www  .j a v a2s.c  om*/
 */
private void createToolbar() {
    // Add a toolbar
    ToolBar bar = new ToolBar(displayArea, SWT.NONE);
    GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.horizontalSpan = 3;
    bar.setLayoutData(gridData);

    // Add a button to navigate backwards through previously visited web sites
    webCommandBackward = new ToolItem(bar, SWT.NONE);
    webCommandBackward.setToolTipText(OlePlugin.getResourceString("browser.Back.tooltip"));
    webCommandBackward.setText(OlePlugin.getResourceString("browser.Back.text"));
    webCommandBackward.setImage(OlePlugin.images[OlePlugin.biBack]);
    webCommandBackward.setEnabled(false);
    webCommandBackward.addListener(SWT.Selection, e -> {
        if (webBrowser == null)
            return;
        webBrowser.GoBack();
    });

    // Add a button to navigate forward through previously visited web sites
    webCommandForward = new ToolItem(bar, SWT.NONE);
    webCommandForward.setToolTipText(OlePlugin.getResourceString("browser.Forward.tooltip"));
    webCommandForward.setText(OlePlugin.getResourceString("browser.Forward.text"));
    webCommandForward.setImage(OlePlugin.images[OlePlugin.biForward]);
    webCommandForward.setEnabled(false);
    webCommandForward.addListener(SWT.Selection, e -> {
        if (webBrowser == null)
            return;
        webBrowser.GoForward();
    });

    // Add a separator
    new ToolItem(bar, SWT.SEPARATOR);

    // Add a button to navigate to the Home page
    webCommandHome = new ToolItem(bar, SWT.NONE);
    webCommandHome.setToolTipText(OlePlugin.getResourceString("browser.Home.tooltip"));
    webCommandHome.setText(OlePlugin.getResourceString("browser.Home.text"));
    webCommandHome.setImage(OlePlugin.images[OlePlugin.biHome]);
    webCommandHome.setEnabled(false);
    webCommandHome.addListener(SWT.Selection, e -> {
        if (webBrowser == null)
            return;
        webBrowser.GoHome();
    });

    // Add a button to abort web page loading
    webCommandStop = new ToolItem(bar, SWT.NONE);
    webCommandStop.setToolTipText(OlePlugin.getResourceString("browser.Stop.tooltip"));
    webCommandStop.setText(OlePlugin.getResourceString("browser.Stop.text"));
    webCommandStop.setImage(OlePlugin.images[OlePlugin.biStop]);
    webCommandStop.setEnabled(false);
    webCommandStop.addListener(SWT.Selection, e -> {
        if (webBrowser == null)
            return;
        webBrowser.Stop();
    });

    // Add a button to refresh the current web page
    webCommandRefresh = new ToolItem(bar, SWT.NONE);
    webCommandRefresh.setToolTipText(OlePlugin.getResourceString("browser.Refresh.tooltip"));
    webCommandRefresh.setText(OlePlugin.getResourceString("browser.Refresh.text"));
    webCommandRefresh.setImage(OlePlugin.images[OlePlugin.biRefresh]);
    webCommandRefresh.setEnabled(false);
    webCommandRefresh.addListener(SWT.Selection, e -> {
        if (webBrowser == null)
            return;
        webBrowser.Refresh();
    });

    // Add a separator
    new ToolItem(bar, SWT.SEPARATOR);

    // Add a button to search the web
    webCommandSearch = new ToolItem(bar, SWT.NONE);
    webCommandSearch.setToolTipText(OlePlugin.getResourceString("browser.Search.tooltip"));
    webCommandSearch.setText(OlePlugin.getResourceString("browser.Search.text"));
    webCommandSearch.setImage(OlePlugin.images[OlePlugin.biSearch]);
    webCommandSearch.setEnabled(false);
    webCommandSearch.addListener(SWT.Selection, e -> {
        if (webBrowser == null)
            return;
        webBrowser.GoSearch();
    });

    // Add a text area for Users to enter a url
    Composite addressBar = new Composite(displayArea, SWT.NONE);
    gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL);
    gridData.horizontalSpan = 3;
    addressBar.setLayoutData(gridData);
    GridLayout gridLayout = new GridLayout();
    gridLayout.numColumns = 3;
    addressBar.setLayout(gridLayout);

    Label addressLabel = new Label(addressBar, SWT.NONE);
    gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL);
    addressLabel.setLayoutData(gridData);
    addressLabel.setText(OlePlugin.getResourceString("browser.Address.label"));
    addressLabel.setFont(OlePlugin.browserFont);

    webUrl = new Text(addressBar, SWT.SINGLE | SWT.BORDER);
    webUrl.setFont(OlePlugin.browserFont);
    gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL);
    webUrl.setLayoutData(gridData);
    webUrl.addFocusListener(FocusListener
            .focusGainedAdapter(e -> webNavigateButton.getShell().setDefaultButton(webNavigateButton)));

    // Add a button to navigate to the web site specified in the Text area defined above
    webNavigateButton = new Button(addressBar, SWT.PUSH);
    gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL);
    webNavigateButton.setLayoutData(gridData);
    webNavigateButton.setText(OlePlugin.getResourceString("browser.Go.text"));
    webNavigateButton.setFont(OlePlugin.browserFont);
    webNavigateButton.addListener(SWT.Selection, event -> {
        if (webBrowser == null)
            return;
        webBrowser.Navigate(webUrl.getText());
    });
}

From source file:org.locationtech.udig.processingtoolbox.tools.MoranScatterPlotDialog.java

private void createInputTab(final CTabFolder parentTabFolder) {
    inputTab = new CTabItem(parentTabFolder, SWT.NONE);
    inputTab.setText(Messages.ProcessExecutionDialog_tabparameters);

    ScrolledComposite scroller = new ScrolledComposite(parentTabFolder, SWT.NONE | SWT.V_SCROLL | SWT.H_SCROLL);
    scroller.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    Composite container = new Composite(scroller, SWT.NONE);
    container.setLayout(new GridLayout(1, false));
    container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    // local moran's i
    Image image = ToolboxPlugin.getImageDescriptor("icons/public_co.gif").createImage(); //$NON-NLS-1$
    uiBuilder.createLabel(container, Messages.MoranScatterPlotDialog_InputLayer, EMPTY, image, 1);
    cboLayer = uiBuilder.createCombo(container, 1, true);
    fillLayers(map, cboLayer, VectorLayerType.ALL);

    uiBuilder.createLabel(container, Messages.MoranScatterPlotDialog_InputField, EMPTY, image, 1);
    cboField = uiBuilder.createCombo(container, 1, true);

    uiBuilder.createLabel(container, Messages.MoranScatterPlotDialog_Conceptualization, EMPTY, 1);
    cboConcept = uiBuilder.createCombo(container, 1, true);
    cboConcept.addModifyListener(new ModifyListener() {
        @Override/*from w w w  .  java2  s .  c o  m*/
        public void modifyText(ModifyEvent e) {
            for (Object enumVal : SpatialConcept.class.getEnumConstants()) {
                if (enumVal.toString().equalsIgnoreCase(cboConcept.getText())) {
                    params.put(GlobalMoransIProcessFactory.spatialConcept.key, enumVal);
                    break;
                }
            }
        }
    });
    fillEnum(cboConcept, SpatialConcept.class);

    uiBuilder.createLabel(container, Messages.MoranScatterPlotDialog_DistanceMethod, EMPTY, 1);
    cboDistance = uiBuilder.createCombo(container, 1, true);
    cboDistance.addModifyListener(new ModifyListener() {
        @Override
        public void modifyText(ModifyEvent e) {
            for (Object enumVal : DistanceMethod.class.getEnumConstants()) {
                if (enumVal.toString().equalsIgnoreCase(cboDistance.getText())) {
                    params.put(GlobalMoransIProcessFactory.distanceMethod.key, enumVal);
                    break;
                }
            }
        }
    });
    fillEnum(cboDistance, DistanceMethod.class);

    uiBuilder.createLabel(container, Messages.MoranScatterPlotDialog_Standardization, EMPTY, 1);
    cboStandard = uiBuilder.createCombo(container, 1, true);
    cboStandard.addModifyListener(new ModifyListener() {
        @Override
        public void modifyText(ModifyEvent e) {
            for (Object enumVal : StandardizationMethod.class.getEnumConstants()) {
                if (enumVal.toString().equalsIgnoreCase(cboStandard.getText())) {
                    params.put(GlobalMoransIProcessFactory.standardization.key, enumVal);
                    break;
                }
            }
        }
    });
    fillEnum(cboStandard, StandardizationMethod.class);

    uiBuilder.createLabel(container, Messages.MoranScatterPlotDialog_DistanceBand, EMPTY, 1);
    final Text txtDistance = uiBuilder.createText(container, EMPTY, 1, true);
    txtDistance.addModifyListener(new ModifyListener() {
        @Override
        public void modifyText(ModifyEvent e) {
            Object obj = Converters.convert(txtDistance.getText(), Double.class);
            if (obj == null) {
                params.put(GlobalMoransIProcessFactory.searchDistance.key, Double.valueOf(0d));
            } else {
                params.put(GlobalMoransIProcessFactory.searchDistance.key, obj);
            }
        }
    });

    // register events
    cboLayer.addModifyListener(new ModifyListener() {
        @Override
        public void modifyText(ModifyEvent e) {
            inputLayer = MapUtils.getLayer(map, cboLayer.getText());
            if (inputLayer == null) {
                return;
            }
            SimpleFeatureCollection features = MapUtils.getFeatures(inputLayer);
            params.put(GlobalMoransIProcessFactory.inputFeatures.key, features);
            fillFields(cboField, inputLayer.getSchema(), FieldType.Number);
        }
    });

    cboField.addModifyListener(new ModifyListener() {
        @Override
        public void modifyText(ModifyEvent e) {
            params.put(GlobalMoransIProcessFactory.inputField.key, cboField.getText());
        }
    });

    // finally
    scroller.setContent(container);
    inputTab.setControl(scroller);

    scroller.setMinSize(450, container.getSize().y - 2);
    scroller.setExpandVertical(true);
    scroller.setExpandHorizontal(true);

    scroller.pack();
    container.pack();
}

From source file:eu.stratosphere.nephele.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  ww.  j  av  a  2s.  c o m*/

    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);

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

    this.checkpointStateLabel = new Label(tableComposite, SWT.NONE);
    this.checkpointStateLabel.setBackground(backgroundColor);
    this.checkpointStateLabel.setForeground(foregroundColor);
    this.checkpointStateLabel.setText(this.managementVertex.getCheckpointState().toString());
    this.checkpointStateLabel.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.gumtree.vis.hist2d.Hist2D.java

private void createStatusBar() {
    Composite statusComposite = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout(6, false);
    layout.marginLeft = 6;/*from  w  w w . j  a v a  2  s  . co m*/
    layout.marginRight = 6;
    layout.marginTop = 1;
    layout.marginBottom = 1;
    layout.horizontalSpacing = 3;
    layout.verticalSpacing = 1;
    statusComposite.setLayout(layout);

    GridData gridData = new GridData(SWT.FILL);
    gridData.grabExcessHorizontalSpace = true;
    gridData.grabExcessVerticalSpace = false;
    statusComposite.setLayoutData(gridData);

    final Label xLabel = new Label(statusComposite, SWT.NONE);
    xLabel.setText("X:");
    gridData = new GridData(SWT.DEFAULT);
    xLabel.setLayoutData(gridData);
    //      GridDataFactory.swtDefaults().applyTo(xLabel);
    final Text xText = new Text(statusComposite, SWT.BORDER);
    gridData = new GridData(SWT.FILL);
    gridData.widthHint = 50;
    xText.setLayoutData(gridData);
    //      GridDataFactory.fillDefaults().hint(50, SWT.DEFAULT).applyTo(xText);
    xText.setEditable(false);

    final Label yLabel = new Label(statusComposite, SWT.NONE);
    yLabel.setText("Y:");
    gridData = new GridData(SWT.DEFAULT);
    yLabel.setLayoutData(gridData);
    //      GridDataFactory.swtDefaults().applyTo(yLabel);
    final Text yText = new Text(statusComposite, SWT.BORDER);
    gridData = new GridData(SWT.FILL);
    gridData.widthHint = 50;
    yText.setLayoutData(gridData);
    //      GridDataFactory.fillDefaults().hint(50, SWT.DEFAULT).applyTo(yText);
    yText.setEditable(false);

    final Label zLabel = new Label(statusComposite, SWT.NONE);
    zLabel.setText("Z:");
    gridData = new GridData(SWT.DEFAULT);
    zLabel.setLayoutData(gridData);
    //      GridDataFactory.swtDefaults().applyTo(zLabel);
    final Text zText = new Text(statusComposite, SWT.BORDER);
    gridData = new GridData(SWT.FILL);
    gridData.widthHint = 50;
    zText.setLayoutData(gridData);
    //      GridDataFactory.fillDefaults().hint(50, SWT.DEFAULT).applyTo(zText);
    zText.setEditable(false);

    final Composite composite = this;
    panel.addChartMouseListener(new ChartMouseListener() {

        @Override
        public void chartMouseMoved(ChartMouseEvent event) {
            if (event instanceof XYZChartMouseEvent) {
                final String xString = String.format("%.2f", ((XYZChartMouseEvent) event).getX());
                final String yString = String.format("%.2f", ((XYZChartMouseEvent) event).getY());
                final String zString = String.format("%.2f", ((XYZChartMouseEvent) event).getZ());
                panel.requestFocus();

                Display.getDefault().asyncExec(new Runnable() {

                    @Override
                    public void run() {
                        xText.setText(xString);
                        yText.setText(yString);
                        zText.setText(zString);
                        if (!composite.isFocusControl()) {
                            composite.setFocus();
                        }
                    }
                });
            }
        }

        @Override
        public void chartMouseClicked(ChartMouseEvent event) {
            // TODO Auto-generated method stub

        }
    });
}

From source file:org.eclipse.swt.examples.paint.PaintExample.java

/**
 * Creates the GUI./*ww w  .jav a 2s.c o  m*/
 */
public void createGUI(Composite parent) {
    GridLayout gridLayout;
    GridData gridData;

    /*** Create principal GUI layout elements ***/
    Composite displayArea = new Composite(parent, SWT.NONE);
    gridLayout = new GridLayout();
    gridLayout.numColumns = 1;
    displayArea.setLayout(gridLayout);

    // Creating these elements here avoids the need to instantiate the GUI elements
    // in strict layout order.  The natural layout ordering is an artifact of using
    // SWT layouts, but unfortunately it is not the same order as that required to
    // instantiate all of the non-GUI application elements to satisfy referential
    // dependencies.  It is possible to reorder the initialization to some extent, but
    // this can be very tedious.

    // paint canvas
    final Canvas paintCanvas = new Canvas(displayArea,
            SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.NO_REDRAW_RESIZE | SWT.NO_BACKGROUND);
    gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL);
    paintCanvas.setLayoutData(gridData);
    paintCanvas.setBackground(paintColorWhite);

    // color selector frame
    final Composite colorFrame = new Composite(displayArea, SWT.NONE);
    gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL);
    colorFrame.setLayoutData(gridData);

    // tool settings frame
    final Composite toolSettingsFrame = new Composite(displayArea, SWT.NONE);
    gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL);
    toolSettingsFrame.setLayoutData(gridData);

    // status text
    final Text statusText = new Text(displayArea, SWT.BORDER | SWT.SINGLE | SWT.READ_ONLY);
    gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL);
    statusText.setLayoutData(gridData);

    /*** Create the remaining application elements inside the principal GUI layout elements ***/
    // paintSurface
    paintSurface = new PaintSurface(paintCanvas, statusText, paintColorWhite);

    // finish initializing the tool data
    tools[Pencil_tool].data = new PencilTool(toolSettings, paintSurface);
    tools[Airbrush_tool].data = new AirbrushTool(toolSettings, paintSurface);
    tools[Line_tool].data = new LineTool(toolSettings, paintSurface);
    tools[PolyLine_tool].data = new PolyLineTool(toolSettings, paintSurface);
    tools[Rectangle_tool].data = new RectangleTool(toolSettings, paintSurface);
    tools[RoundedRectangle_tool].data = new RoundedRectangleTool(toolSettings, paintSurface);
    tools[Ellipse_tool].data = new EllipseTool(toolSettings, paintSurface);
    tools[Text_tool].data = new TextTool(toolSettings, paintSurface);

    // colorFrame
    gridLayout = new GridLayout();
    gridLayout.numColumns = 3;
    gridLayout.marginHeight = 0;
    gridLayout.marginWidth = 0;
    colorFrame.setLayout(gridLayout);

    // activeForegroundColorCanvas, activeBackgroundColorCanvas
    activeForegroundColorCanvas = new Canvas(colorFrame, SWT.BORDER);
    gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    gridData.heightHint = 24;
    gridData.widthHint = 24;
    activeForegroundColorCanvas.setLayoutData(gridData);

    activeBackgroundColorCanvas = new Canvas(colorFrame, SWT.BORDER);
    gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    gridData.heightHint = 24;
    gridData.widthHint = 24;
    activeBackgroundColorCanvas.setLayoutData(gridData);

    // paletteCanvas
    final Canvas paletteCanvas = new Canvas(colorFrame, SWT.BORDER | SWT.NO_BACKGROUND);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.heightHint = 24;
    paletteCanvas.setLayoutData(gridData);
    paletteCanvas.addListener(SWT.MouseDown, new Listener() {
        @Override
        public void handleEvent(Event e) {
            Rectangle bounds = paletteCanvas.getClientArea();
            Color color = getColorAt(bounds, e.x, e.y);

            if (e.button == 1)
                setForegroundColor(color);
            else
                setBackgroundColor(color);
        }

        private Color getColorAt(Rectangle bounds, int x, int y) {
            if (bounds.height <= 1 && bounds.width <= 1)
                return paintColorWhite;
            final int row = (y - bounds.y) * numPaletteRows / bounds.height;
            final int col = (x - bounds.x) * numPaletteCols / bounds.width;
            return paintColors[Math.min(Math.max(row * numPaletteCols + col, 0), paintColors.length - 1)];
        }
    });
    Listener refreshListener = e -> {
        if (e.gc == null)
            return;
        Rectangle bounds = paletteCanvas.getClientArea();
        for (int row = 0; row < numPaletteRows; ++row) {
            for (int col = 0; col < numPaletteCols; ++col) {
                final int x = bounds.width * col / numPaletteCols;
                final int y = bounds.height * row / numPaletteRows;
                final int width = Math.max(bounds.width * (col + 1) / numPaletteCols - x, 1);
                final int height = Math.max(bounds.height * (row + 1) / numPaletteRows - y, 1);
                e.gc.setBackground(paintColors[row * numPaletteCols + col]);
                e.gc.fillRectangle(bounds.x + x, bounds.y + y, width, height);
            }
        }
    };
    paletteCanvas.addListener(SWT.Resize, refreshListener);
    paletteCanvas.addListener(SWT.Paint, refreshListener);
    //paletteCanvas.redraw();

    // toolSettingsFrame
    gridLayout = new GridLayout();
    gridLayout.numColumns = 4;
    gridLayout.marginHeight = 0;
    gridLayout.marginWidth = 0;
    toolSettingsFrame.setLayout(gridLayout);

    Label label = new Label(toolSettingsFrame, SWT.NONE);
    label.setText(getResourceString("settings.AirbrushRadius.text"));

    final Scale airbrushRadiusScale = new Scale(toolSettingsFrame, SWT.HORIZONTAL);
    airbrushRadiusScale.setMinimum(5);
    airbrushRadiusScale.setMaximum(50);
    airbrushRadiusScale.setSelection(toolSettings.airbrushRadius);
    airbrushRadiusScale.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL));
    airbrushRadiusScale.addSelectionListener(widgetSelectedAdapter(e -> {
        toolSettings.airbrushRadius = airbrushRadiusScale.getSelection();
        updateToolSettings();
    }));

    label = new Label(toolSettingsFrame, SWT.NONE);
    label.setText(getResourceString("settings.AirbrushIntensity.text"));

    final Scale airbrushIntensityScale = new Scale(toolSettingsFrame, SWT.HORIZONTAL);
    airbrushIntensityScale.setMinimum(1);
    airbrushIntensityScale.setMaximum(100);
    airbrushIntensityScale.setSelection(toolSettings.airbrushIntensity);
    airbrushIntensityScale.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL));
    airbrushIntensityScale.addSelectionListener(widgetSelectedAdapter(e -> {
        toolSettings.airbrushIntensity = airbrushIntensityScale.getSelection();
        updateToolSettings();
    }));
}

From source file:com.android.ddmuilib.SysinfoPanel.java

/**
 * Create our controls for the UI panel.
 *///from  w w  w . j  ava2  s .c o m
@Override
protected Control createControl(Composite parent) {
    Composite top = new Composite(parent, SWT.NONE);
    top.setLayout(new GridLayout(1, false));
    top.setLayoutData(new GridData(GridData.FILL_BOTH));

    Composite buttons = new Composite(top, SWT.NONE);
    buttons.setLayout(new RowLayout());

    mDisplayMode = new Combo(buttons, SWT.PUSH);
    for (String mode : CAPTIONS) {
        mDisplayMode.add(mode);
    }
    mDisplayMode.select(mMode);
    mDisplayMode.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            mMode = mDisplayMode.getSelectionIndex();
            if (mDataFile != null) {
                generateDataset(mDataFile);
            } else if (getCurrentDevice() != null) {
                loadFromDevice();
            }
        }
    });

    final Button loadButton = new Button(buttons, SWT.PUSH);
    loadButton.setText("Load from File");
    loadButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            FileDialog fileDialog = new FileDialog(loadButton.getShell(), SWT.OPEN);
            fileDialog.setText("Load bugreport");
            String filename = fileDialog.open();
            if (filename != null) {
                mDataFile = new File(filename);
                generateDataset(mDataFile);
            }
        }
    });

    mFetchButton = new Button(buttons, SWT.PUSH);
    mFetchButton.setText("Update from Device");
    mFetchButton.setEnabled(false);
    mFetchButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            loadFromDevice();
        }
    });

    mLabel = new Label(top, SWT.NONE);
    mLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    mDataset = new DefaultPieDataset();
    JFreeChart chart = ChartFactory.createPieChart("", mDataset, false
    /* legend */, true/* tooltips */, false /* urls */);

    ChartComposite chartComposite = new ChartComposite(top, SWT.BORDER, chart, ChartComposite.DEFAULT_HEIGHT,
            ChartComposite.DEFAULT_HEIGHT, ChartComposite.DEFAULT_MINIMUM_DRAW_WIDTH,
            ChartComposite.DEFAULT_MINIMUM_DRAW_HEIGHT, 3000,
            // max draw width. We don't want it to zoom, so we put a big number
            3000,
            // max draw height. We don't want it to zoom, so we put a big number
            true, // off-screen buffer
            true, // properties
            true, // save
            true, // print
            false, // zoom
            true);
    chartComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
    return top;
}

From source file:widgetTest3.java

/** * StackLayout ** */

public static void createStackLayout(Composite composite) {
    //       Neues Composite erzeugen
    final Composite stackComposite = new Composite(composite, SWT.NULL);
    final StackLayout stackLayout = new StackLayout();
    //       Text-Buttons erzeugen
    final Button buttonA = new Button(stackComposite, SWT.PUSH);
    buttonA.setText("Taste A");
    final Button buttonB = new Button(stackComposite, SWT.PUSH);
    buttonB.setText("Taste B");
    //       Auf Klickereignisse reagieren
    buttonA.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            stackLayout.topControl = buttonB;
            //       Neues Layout erzwingen
            stackComposite.layout();//from   w  ww .  j a va 2s.c om
            //       Fokus auf sichtbare Taste setzen
            buttonB.setFocus();
        }
    });
    buttonB.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            stackLayout.topControl = buttonA;
            //       Neues Layout erzwingen
            stackComposite.layout();
            //       Fokus auf sichtbare Taste setzen
            buttonA.setFocus();
        }
    });
    //       Layout initialisieren
    stackLayout.topControl = buttonA;
    stackLayout.marginWidth = 10;
    stackLayout.marginHeight = 5;
    //       Layout setzen
    stackComposite.setLayout(stackLayout);
}