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:org.locationtech.udig.processingtoolbox.tools.HistogramDialog.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(2, 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.HistogramDialog_InputLayer, EMPTY, image, 2);
    cboLayer = uiBuilder.createCombo(container, 2, true);
    fillLayers(map, cboLayer, VectorLayerType.ALL);

    uiBuilder.createLabel(container, Messages.HistogramDialog_InputField, EMPTY, image, 2);
    cboField = uiBuilder.createCombo(container, 2, true);

    uiBuilder.createLabel(container, Messages.HistogramDialog_BinCount, EMPTY, image, 2);
    spinner = uiBuilder.createSpinner(container, 10, 1, 50, 0, 1, 5, 2);

    // yXais Type
    uiBuilder.createLabel(container, Messages.HistogramDialog_YAxisType, EMPTY, image, 1);
    GridLayout layout = new GridLayout(2, false);
    layout.marginWidth = 0;/*ww w . j a  v  a2s . co m*/

    Composite subCon = new Composite(container, SWT.NONE);
    subCon.setLayout(layout);
    subCon.setLayoutData(new GridData(SWT.LEFT_TO_RIGHT, SWT.CENTER, false, false, 1, 1));
    final Button chkRatio = uiBuilder.createRadioButton(subCon, Messages.HistogramDialog_Ratio, null, 1);
    final Button chkFrequency = uiBuilder.createRadioButton(subCon, Messages.HistogramDialog_Frequency, null,
            1);
    chkFrequency.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent event) {
            if (chkFrequency.getSelection()) {
                histogramType = HistogramType.FREQUENCY;
            }
        }
    });
    chkRatio.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent event) {
            if (chkRatio.getSelection()) {
                histogramType = HistogramType.RELATIVE_FREQUENCY;
            }
        }
    });
    chkRatio.setSelection(true);

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

    // register events
    cboLayer.addModifyListener(new ModifyListener() {
        @Override
        public void modifyText(ModifyEvent e) {
            inputLayer = MapUtils.getLayer(map, cboLayer.getText());
            if (inputLayer != null) {
                fillFields(cboField, 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:MainClass.java

public void createControl(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayout(new FillLayout(SWT.VERTICAL));
    new Label(composite, SWT.CENTER).setText("Welcome to the Address Book Entry Wizard!");
    new Label(composite, SWT.LEFT).setText("This wizard guides you through creating an Address Book entry.");
    new Label(composite, SWT.LEFT).setText("Click Next to continue.");
    setControl(composite);//  w ww .j av a2 s  .c  o  m
}

From source file:org.qsos.radar.GenerateRadar.java

/**
 * This class creates a composite which include a checkboxtreeviewer and a button.
 *  It uses 2 listeners: 1 for the checking if the user has checked a box and 
 * another for the 0K button in order to check the validity of the selected elements.
 * @param parent/*from ww  w.j a v a 2  s  .  c om*/
 *             Composite
 * @return Control
 */

public Control createCheckboxTree(Composite parent) {

    numCat = 0;

    Composite checkTreeComposite = new Composite(parent, SWT.NONE);
    checkTreeComposite.setLayout(new org.eclipse.swt.layout.FormLayout());

    FormData CheckData = new FormData();
    final CheckboxTreeViewer checkboxTreeViewer = new CheckboxTreeViewer(checkTreeComposite);

    checkboxTreeViewer.getTree().setLayoutData(CheckData);
    CheckData.height = 430;
    CheckData.width = 320;

    checkboxTreeViewer.setContentProvider(new SheetCheckContentProvider(window.getCTabFolder()));
    checkboxTreeViewer.setLabelProvider(new SheetCheckLabelProvider());
    checkboxTreeViewer.addFilter(new MyFilter());

    IElement elementToInput = (((SheetCTabItem) window.getCTabFolder().getSelection()).getLibQSOS().getSheet()
            .getRoot());
    checkboxTreeViewer.setInput(elementToInput);
    checkboxTreeViewer.expandToLevel(2);

    checkboxTreeViewer.addCheckStateListener(new ICheckStateListener() {
        //This listeners verifies if the user a checked a box and wether it should be appeared checked or not

        public void checkStateChanged(CheckStateChangedEvent event) {
            if (event.getChecked()) {
                if (numCat < 7) {
                    categories[numCat++] = event.getElement();
                    checkboxTreeViewer.setSubtreeChecked(event.getElement(), true);
                } else {
                    //System.out.println("Erreur"); //$NON-NLS-1$
                    checkboxTreeViewer.setChecked(event.getElement(), false);
                }
            } else if (!event.getChecked()) {
                if (((IElement) event.getElement()).getContainer() != null) {
                    boolean state = checkboxTreeViewer
                            .getChecked(((IElement) event.getElement()).getContainer());
                    if (!state) {
                        checkboxTreeViewer.setSubtreeChecked(event.getElement(), false);
                        numCat--;
                    } else {
                        checkboxTreeViewer.setChecked(event.getElement(), true);
                    }
                }
            }
        }
    });

    checkTreeComposite.pack();

    return checkTreeComposite;
}

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

/**
 * Creates the Web browser toolbar./*from   w  ww. j a va  2  s . co m*/
 */
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:eu.hydrologis.jgrass.charting.datamodels.MultiXYTimeChartCreator.java

/**
 * Make a composite with the plot of the supplied chartdata. There are several HINT* variables
 * that can be set to tweak and configure the plot.
 * //from w w  w.ja  v a  2 s .  c  o  m
 * @param parentComposite
 * @param chartData
 */
public void makePlot(Composite parentComposite, NumericChartData chartData) {
    final int tabNums = chartData.getTabItemNumbers();

    if (tabNums == 0) {
        return;
    }

    Shell dummyShell = null;
    // try {
    // dummyShell = PlatformUI.getWorkbench().getDisplay().getActiveShell();
    // } catch (Exception e) {
    dummyShell = new Shell(Display.getCurrent(), SWT.None);
    // }
    /*
     * wrapping panel needed in the case of hide checks
     */
    TabFolder tabFolder = null;
    if (tabNums > 1) {
        tabFolder = new TabFolder(parentComposite, SWT.BORDER);
        tabFolder.setLayout(new GridLayout());
        tabFolder.setLayoutData(
                new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL));
    }

    for (int i = 0; i < tabNums; i++) {
        NumericChartDataItem chartItem = chartData.getChartDataItem(i);
        int chartNums = chartItem.chartSeriesData.size();
        /*
         * are there data to create the lower chart panel
         */
        List<LinkedHashMap<String, Integer>> series = new ArrayList<LinkedHashMap<String, Integer>>();
        List<XYPlot> plots = new ArrayList<XYPlot>();
        List<JFreeChart> charts = new ArrayList<JFreeChart>();

        for (int j = 0; j < chartNums; j++) {
            final LinkedHashMap<String, Integer> chartSeries = new LinkedHashMap<String, Integer>();
            XYPlot chartPlot = null;
            JGrassChart chart = null;
            double[][][] cLD = chartItem.chartSeriesData.get(j);

            if (M_HINT_CREATE_CHART[i][j]) {

                final String[] cT = chartItem.seriesNames.get(j);
                final String title = chartItem.chartTitles.get(j);
                final String xT = chartItem.chartXLabels.get(j);
                final String yT = chartItem.chartYLabels.get(j);

                if (M_HINT_CHART_TYPE[i][j] == XYLINECHART) {
                    chart = new JGrassXYLineChart(cT, cLD);
                } else if (M_HINT_CHART_TYPE[i][j] == XYBARCHART) {
                    chart = new JGrassXYBarChart(cT, cLD, HINT_barwidth);
                } else if (M_HINT_CHART_TYPE[i][j] == TIMEYLINECHART) {
                    chart = new JGrassXYTimeLineChart(cT, cLD, Minute.class);
                    ((JGrassXYTimeLineChart) chart).setTimeAxisFormat(TIMEFORMAT);
                } else if (M_HINT_CHART_TYPE[i][j] == TIMEYBARCHART) {
                    chart = new JGrassXYTimeBarChart(cT, cLD, Minute.class, HINT_barwidth);
                    ((JGrassXYTimeBarChart) chart).setTimeAxisFormat(TIMEFORMAT);
                } else if (M_HINT_CHART_TYPE[i][j] == XYPOINTCHART) {
                    chart = new JGrassXYLineChart(cT, cLD);
                    ((JGrassXYLineChart) chart).toggleLineShapesDisplay(false, true);
                } else if (M_HINT_CHART_TYPE[i][j] == TIMEXYPOINTCHART) {
                    chart = new JGrassXYTimeLineChart(cT, cLD, Minute.class);
                    ((JGrassXYTimeLineChart) chart).setTimeAxisFormat(TIMEFORMAT);
                    ((JGrassXYTimeLineChart) chart).toggleLineShapesDisplay(false, true);
                } else {
                    chart = new JGrassXYLineChart(cT, cLD);
                }

                final Composite p1Composite = new Composite(dummyShell, SWT.None);
                p1Composite.setLayout(new FillLayout());
                p1Composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
                chart.makeChartPanel(p1Composite, title, xT, yT, null, true, true, true, true);
                chartPlot = (XYPlot) chart.getPlot();
                XYItemRenderer renderer = chartPlot.getRenderer();

                chartPlot.setDomainGridlinesVisible(HINT_doDomainGridVisible);
                chartPlot.setRangeGridlinesVisible(HINT_doRangeGridVisible);

                if (HINT_doDisplayToolTips) {
                    renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
                }

                if (!M_HINT_CHARTORIENTATION_UP[i][j]) {
                    chartPlot.getRangeAxis().setInverted(true);
                }
                if (M_HINT_CHARTSERIESCOLOR != null) {
                    final XYItemRenderer rend = renderer;

                    for (int k = 0; k < cLD.length; k++) {
                        rend.setSeriesPaint(k, M_HINT_CHARTSERIESCOLOR[i][j][k]);
                    }
                }
                chart.toggleFilledShapeDisplay(HINT_doDisplayBaseShapes, HINT_doFillBaseShapes, true);

                for (int k = 0; k < cT.length; k++) {
                    chartSeries.put(cT[k], k);
                }
                series.add(chartSeries);
                chartPlot.setNoDataMessage("No data available");
                chartPlot.setNoDataMessagePaint(Color.red);
                plots.add(chartPlot);

                charts.add(chart.getChart(title, xT, yT, null, true, HINT_doDisplayToolTips, true));
                chartsList.add(chart);

                /*
                 * add annotations?
                 */
                if (chartItem.annotationsOnChart.size() > 0) {
                    LinkedHashMap<String, double[]> annotations = chartItem.annotationsOnChart.get(j);
                    if (annotations.size() > 0) {
                        Set<String> keys = annotations.keySet();
                        for (String key : keys) {
                            double[] c = annotations.get(key);
                            XYPointerAnnotation ann = new XYPointerAnnotation(key, c[0], c[1],
                                    HINT_AnnotationArrowAngle);
                            ann.setTextAnchor(HINT_AnnotationTextAncor);
                            ann.setPaint(HINT_AnnotationTextColor);
                            ann.setArrowPaint(HINT_AnnotationArrowColor);
                            // ann.setArrowLength(15);
                            renderer.addAnnotation(ann);

                            // Marker currentEnd = new ValueMarker(c[0]);
                            // currentEnd.setPaint(Color.red);
                            // currentEnd.setLabel("");
                            // currentEnd.setLabelAnchor(RectangleAnchor.TOP_RIGHT);
                            // currentEnd.setLabelTextAnchor(TextAnchor.TOP_LEFT);
                            // chartPlot.addDomainMarker(currentEnd);

                            // Drawable cd = new LineDrawer(Color.red, new BasicStroke(1.0f));
                            // XYAnnotation bestBid = new XYDrawableAnnotation(c[0], c[1]/2.0,
                            // 0, c[1],
                            // cd);
                            // chartPlot.addAnnotation(bestBid);
                            // pointer.setFont(new Font("SansSerif", Font.PLAIN, 9));
                        }
                    }
                }
            }

        }

        JFreeChart theChart = null;

        if (plots.size() > 1) {

            ValueAxis domainAxis = null;
            if (M_HINT_CHART_TYPE[i][0] == ChartCreator.TIMEYBARCHART
                    || M_HINT_CHART_TYPE[i][0] == ChartCreator.TIMEYLINECHART) {

                domainAxis = (plots.get(0)).getDomainAxis();
            } else {
                domainAxis = new NumberAxis(chartItem.chartXLabels.get(0));
            }

            final CombinedDomainXYPlot plot = new CombinedDomainXYPlot(domainAxis);
            plot.setGap(10.0);
            // add the subplots...
            for (int k = 0; k < plots.size(); k++) {
                XYPlot tmpPlot = plots.get(k);

                if (HINT_labelInsets != null) {
                    tmpPlot.getRangeAxis().setLabelInsets(HINT_labelInsets);
                }

                plot.add(tmpPlot, k + 1);
            }
            plot.setOrientation(PlotOrientation.VERTICAL);

            theChart = new JFreeChart(chartItem.bigTitle, JFreeChart.DEFAULT_TITLE_FONT, plot, true);
        } else if (plots.size() == 1) {
            theChart = new JFreeChart(chartItem.chartTitles.get(0), JFreeChart.DEFAULT_TITLE_FONT, plots.get(0),
                    true);
        } else {
            return;
        }

        /*
         * create the chart composite
         */
        Composite tmp;
        if (tabNums > 1 && tabFolder != null) {
            tmp = new Composite(tabFolder, SWT.None);
        } else {
            tmp = new Composite(parentComposite, SWT.None);
        }
        tmp.setLayoutData(new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL));
        tmp.setLayout(new GridLayout());
        final ChartComposite frame = new ChartComposite(tmp, SWT.None, theChart, 680, 420, 300, 200, 700, 500,
                false, true, // properties
                true, // save
                true, // print
                true, // zoom
                true // tooltips
        );

        // public static final boolean DEFAULT_BUFFER_USED = false;
        // public static final int DEFAULT_WIDTH = 680;
        // public static final int DEFAULT_HEIGHT = 420;
        // public static final int DEFAULT_MINIMUM_DRAW_WIDTH = 300;
        // public static final int DEFAULT_MINIMUM_DRAW_HEIGHT = 200;
        // public static final int DEFAULT_MAXIMUM_DRAW_WIDTH = 800;
        // public static final int DEFAULT_MAXIMUM_DRAW_HEIGHT = 600;
        // public static final int DEFAULT_ZOOM_TRIGGER_DISTANCE = 10;

        frame.setLayoutData(
                new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL));
        frame.setLayout(new FillLayout());
        frame.setDisplayToolTips(HINT_doDisplayToolTips);
        frame.setHorizontalAxisTrace(HINT_doHorizontalAxisTrace);
        frame.setVerticalAxisTrace(HINT_doVerticalAxisTrace);
        frame.setDomainZoomable(HINT_doDomainZoomable);
        frame.setRangeZoomable(HINT_doRangeZoomable);

        if (tabNums > 1 && tabFolder != null) {
            final TabItem item = new TabItem(tabFolder, SWT.NONE);
            item.setText(chartData.getChartDataItem(i).chartStringExtra);
            item.setControl(tmp);
        }

        /*
         * create the hide toggling part
         */
        for (int j = 0; j < plots.size(); j++) {

            if (M_HINT_CREATE_TOGGLEHIDESERIES[i][j]) {
                final LinkedHashMap<Button, Integer> allButtons = new LinkedHashMap<Button, Integer>();
                Group checksComposite = new Group(tmp, SWT.None);
                checksComposite.setText("");
                RowLayout rowLayout = new RowLayout();
                rowLayout.wrap = true;
                rowLayout.type = SWT.HORIZONTAL;
                checksComposite.setLayout(rowLayout);
                checksComposite
                        .setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));

                final XYItemRenderer renderer = plots.get(j).getRenderer();
                Set<String> lTitles = series.get(j).keySet();
                for (final String title : lTitles) {
                    final Button b = new Button(checksComposite, SWT.CHECK);
                    b.setText(title);
                    b.setSelection(true);
                    final int index = series.get(j).get(title);
                    b.addSelectionListener(new SelectionAdapter() {
                        public void widgetSelected(SelectionEvent e) {
                            boolean visible = renderer.getItemVisible(index, 0);
                            renderer.setSeriesVisible(index, new Boolean(!visible));
                        }
                    });
                    allButtons.put(b, index);
                }

                /*
                 * toggle all and none
                 */
                if (HINT_doToggleTuttiButton) {
                    Composite allchecksComposite = new Composite(tmp, SWT.None);
                    RowLayout allrowLayout = new RowLayout();
                    allrowLayout.wrap = true;
                    allrowLayout.type = SWT.HORIZONTAL;
                    allchecksComposite.setLayout(allrowLayout);
                    allchecksComposite
                            .setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));

                    final Button tuttiButton = new Button(allchecksComposite, SWT.BORDER | SWT.PUSH);
                    tuttiButton.setText("Tutti");
                    tuttiButton.addSelectionListener(new SelectionAdapter() {
                        public void widgetSelected(SelectionEvent e) {
                            Set<Button> set = allButtons.keySet();
                            for (Button button : set) {
                                button.setSelection(true);
                                int i = allButtons.get(button);
                                if (renderer != null) {
                                    renderer.setSeriesVisible(i, new Boolean(true));
                                }
                            }
                        }
                    });
                    final Button noneButton = new Button(allchecksComposite, SWT.BORDER | SWT.PUSH);
                    noneButton.setText("Nessuno");
                    noneButton.addSelectionListener(new SelectionAdapter() {
                        public void widgetSelected(SelectionEvent e) {
                            Set<Button> set = allButtons.keySet();
                            for (Button button : set) {
                                button.setSelection(false);
                                int i = allButtons.get(button);
                                if (renderer != null) {
                                    renderer.setSeriesVisible(i, new Boolean(false));
                                }
                            }
                        }
                    });
                }

            }

        }

    }
}

From source file:CustomWidgets.java

protected Control createContents(Composite parent) {
    Composite composite = new Composite(parent, SWT.NULL);
    composite.setLayout(new FillLayout());

    // Sets up the toolkit.
    toolkit = new FormToolkit(getShell().getDisplay());

    // Creates a form instance.
    form = toolkit.createForm(composite);
    form.setLayoutData(new GridData(GridData.FILL_BOTH));

    // Sets title.
    form.setText("Custom Form Widgets Demo");

    // demoHyperlinks();

    // demoFormTextNormal();
    // demoFormTextURL();
    // demoFormTextXML();

    // demoExpandableComposite();
    demoSections();//from www .j  a  v a2  s .  c om

    return composite;
}

From source file:org.emftrace.quarc.ui.views.RatioView.java

/**
 * @param sourcepart//from w w  w  .jav a2 s  .  c  om
 *            a CompareElementsEditorPart
 * @param parent
 *            the parent Composite
 * @param showGoalRatings
 *            true == show ratings to goals; false == show ratings to
 *            principles
 * @param weighted
 *            show weighted ratings
 * @return a composite with the created chart
 */
protected Composite buildSpiderChartForRatings(CompareElementsEditor sourcepart, Composite parent,
        boolean showGoalRatings, boolean weighted) {

    Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayout(new FillLayout());
    final DefaultCategoryDataset dataset = createSpiderDataset(sourcepart.getElements(),
            sourcepart.getAccessLayer(), sourcepart.getCacheManager(), showGoalRatings, weighted);
    JFreeChart chart = createSpiderChart(dataset, weighted);
    ChartComposite chartComposite = new ChartComposite(composite, SWT.NONE, chart, true);
    chartComposite.setVisible(true);
    // composite.layout();
    // parent.layout();
    return composite;
}

From source file:org.ietr.preesm.mapper.ui.GanttPlotter.java

/**
 * Gantt chart plotting function in a given composite
 *///from www . j ava  2s . c o  m
public void plotInComposite(Composite parent) {

    Composite composite = new Composite(parent, SWT.EMBEDDED | SWT.FILL);
    parent.setLayout(new FillLayout());
    Frame frame = SWT_AWT.new_Frame(composite);
    frame.add(getContentPane());

    MouseClickedListener listener = new MouseClickedListener(frame);
    chartPanel.addChartMouseListener(listener);
    chartPanel.addMouseMotionListener(listener);
    chartPanel.addMouseListener(listener);
}

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. j  a v  a 2  s.  c o 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 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.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// www  . j  av a 2s.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();
}