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: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.
 * /* ww w . j av a  2 s  . co  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:SimpleBrowser.java

/**
 * Creates the main window's contents/*from  w w w  .ja  v a  2s . co  m*/
 * 
 * @param shell the main window
 */
private void createContents(Shell shell) {
    shell.setLayout(new FormLayout());

    // Create the composite to hold the buttons and text field
    Composite controls = new Composite(shell, SWT.NONE);
    FormData data = new FormData();
    data.top = new FormAttachment(0, 0);
    data.left = new FormAttachment(0, 0);
    data.right = new FormAttachment(100, 0);
    controls.setLayoutData(data);

    // Create the web browser
    final Browser browser = new Browser(shell, SWT.NONE);
    data = new FormData();
    data.top = new FormAttachment(controls);
    data.bottom = new FormAttachment(100, 0);
    data.left = new FormAttachment(0, 0);
    data.right = new FormAttachment(100, 0);
    browser.setLayoutData(data);

    // Create the controls and wire them to the browser
    controls.setLayout(new GridLayout(6, false));

    // Create the back button
    Button button = new Button(controls, SWT.PUSH);
    button.setText("Back");
    button.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            browser.back();
        }
    });

    // Create the forward button
    button = new Button(controls, SWT.PUSH);
    button.setText("Forward");
    button.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            browser.forward();
        }
    });

    // Create the refresh button
    button = new Button(controls, SWT.PUSH);
    button.setText("Refresh");
    button.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            browser.refresh();
        }
    });

    // Create the stop button
    button = new Button(controls, SWT.PUSH);
    button.setText("Stop");
    button.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            browser.stop();
        }
    });

    // Create the address entry field and set focus to it
    final Text url = new Text(controls, SWT.BORDER);
    url.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    url.setFocus();

    // Create the go button
    button = new Button(controls, SWT.PUSH);
    button.setText("Go");
    button.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            browser.setUrl(url.getText());
        }
    });

    // Allow users to hit enter to go to the typed URL
    shell.setDefaultButton(button);
}

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

/**
 * Creates the impact Pie Chart page. It allows users to select a Crosscutting Concern and see Design Decision type distribution
 *///from w  ww  . j a v  a2  s  .co m
void impactPieChartPage() {

    ddDataset = new DefaultPieDataset();
    impactDataset = new DefaultPieDataset();
    JFreeChart ddChart = ChartFactory.createPieChart("Crosscutting Concerns", ddDataset, true, true, false);
    JFreeChart impactChart = ChartFactory.createPieChart("Design Decisions", impactDataset, true, true, false);

    PiePlot ddPlot = (PiePlot) ddChart.getPlot();
    ddPlot.setStartAngle(290);
    ddPlot.setDirection(Rotation.CLOCKWISE);
    ddPlot.setForegroundAlpha(0.5f);

    PiePlot impactPlot = (PiePlot) impactChart.getPlot();
    impactPlot.setStartAngle(290);
    impactPlot.setDirection(Rotation.CLOCKWISE);
    impactPlot.setForegroundAlpha(0.5f);

    PieSectionLabelGenerator gen = new StandardPieSectionLabelGenerator("{0}  ({2})");
    ddPlot.setLabelGenerator(gen);
    impactPlot.setLabelGenerator(gen);

    Composite composite = new Composite(getContainer(), SWT.NONE);
    FillLayout layout = new FillLayout();
    composite.setLayout(layout);
    final ChartComposite cComposite = new ChartComposite(composite, SWT.NONE, ddChart, true);
    cComposite.addChartMouseListener(new ChartMouseListener() {

        @Override
        public void chartMouseClicked(ChartMouseEvent event) {
            String[] parts = event.getEntity().getToolTipText().split(":");
            HashMap<String, Integer> values = PluginUtil.getDDDistributionForCrossCuttingConcern(cp, parts[0]);
            logger.info("Impact Pie Chart for: " + parts[0]);
            impactDataset.clear();
            for (String key : values.keySet()) {
                impactDataset.setValue(key, values.get(key));
            }
        }

        @Override
        public void chartMouseMoved(ChartMouseEvent event) {
        }
    });
    new ChartComposite(composite, SWT.NONE, impactChart, true);
    int index = addPage(composite);
    setPageText(index, "Graph");
}

From source file:at.ac.tuwien.inso.subcat.ui.widgets.TimeChartControlPanel.java

public TimeChartControlPanel(Composite parent, int style) {
    super(parent, SWT.NONE);
    setLayout(new GridLayout(3, false));

    Composite composite = new Composite(this, SWT.NONE);
    composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1));
    GridLayout gl_composite = new GridLayout(3, false);
    gl_composite.verticalSpacing = 0;//  ww  w.j a v a 2s .co m
    gl_composite.marginWidth = 0;
    gl_composite.marginHeight = 0;
    gl_composite.horizontalSpacing = 0;
    composite.setLayout(gl_composite);

    // Chart, Top Panel:
    new Label(composite, SWT.NONE);
    ;

    Composite chartTopComposite = new Composite(composite, SWT.NONE);
    GridLayout chartBottomLayout = new GridLayout(3, true);
    chartTopComposite.setLayout(chartBottomLayout);
    chartBottomLayout.verticalSpacing = 0;
    chartBottomLayout.marginWidth = 0;
    chartBottomLayout.marginHeight = 0;
    chartBottomLayout.horizontalSpacing = 0;

    chartTopComposite.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1));
    yearSelector = new Combo(chartTopComposite, SWT.READ_ONLY);

    chartTopComposite.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1));
    chartSelector = new Combo(chartTopComposite, SWT.READ_ONLY);
    chartSelector.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1));

    chartTopComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
    Button saveButton = new Button(chartTopComposite, SWT.NONE);
    saveButton.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, false, 1, 1));
    saveButton.setText("Save");

    new Label(composite, SWT.NONE);

    // Chart Row:
    btnPrev = new Button(composite, SWT.NONE);
    btnPrev.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true, 1, 1));
    btnPrev.setText("<");

    // TODO: drop scrolledComposite 
    scrolledComposite = new ScrolledComposite(composite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
    scrolledComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    scrolledComposite.setExpandHorizontal(true);
    scrolledComposite.setExpandVertical(true);
    scrolledComposite.setLayout(new FillLayout());

    chartComposite = new ChartComposite(scrolledComposite, SWT.NONE, null);
    chartComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
    chartComposite.setLayout(new FillLayout(SWT.HORIZONTAL));
    scrolledComposite.setContent(chartComposite);

    btnNext = new Button(composite, SWT.NONE);
    btnNext.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true, 1, 1));
    btnNext.setText(">");

    // ** Event handling:

    chartSelector.addSelectionListener(new SelectionListener() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            for (TimeChartControlPanelListener listener : listeners) {
                listener.chartSelectionChanged();
            }
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
        }
    });

    // *** Year Setting:
    yearSelector.addSelectionListener(new SelectionListener() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            btnPrev.setEnabled(hasPrevChart());
            btnNext.setEnabled(hasNextChart());

            triggerChartSelected();
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
        }
    });

    btnPrev.addSelectionListener(new SelectionListener() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            yearSelector.select(yearSelector.getSelectionIndex() - 1);
            btnPrev.setEnabled(hasPrevChart());
            btnNext.setEnabled(hasNextChart());

            triggerChartSelected();
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
        }
    });

    btnNext.addSelectionListener(new SelectionListener() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            yearSelector.select(yearSelector.getSelectionIndex() + 1);
            btnPrev.setEnabled(hasPrevChart());
            btnNext.setEnabled(hasNextChart());

            triggerChartSelected();
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
        }
    });

    saveButton.addSelectionListener(new SelectionListener() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            FileDialog fd = new FileDialog(TimeChartControlPanel.this.getShell(), SWT.SAVE);
            fd.setText("Save Chart");
            String[] filterExt = { "*.png", "*.jpg" };
            fd.setFilterExtensions(filterExt);
            String selectedPath = fd.open();
            if (selectedPath == null) {
                return;
            }

            for (TimeChartControlPanelListener listener : listeners) {
                listener.chartSaveRequest(selectedPath);
            }
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
        }
    });
}

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

/**
 * Creates a page to allow users to create a traceability link.
 *///from  w ww.  j a  va2 s .  com
void createTraceabilityLinkPage() {
    final Composite composite = new Composite(getContainer(), SWT.NONE);
    composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 5));
    composite.setLayout(new GridLayout());

    Label concernLabel = new Label(composite, SWT.BORDER);
    concernLabel.setText("Crosscuttings Concerns(CCC)");
    concernLabel.setToolTipText("This are the Crosscuttings Concerns detected on the requierement document");
    GridData gridData = new GridData(SWT.LEFT, SWT.TOP, false, false);
    concernLabel.setLayoutData(gridData);

    topNewLink = new TableViewer(composite, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
    createColumns(composite, topNewLink);

    final Table table = topNewLink.getTable();
    table.setHeaderVisible(true);
    table.setLinesVisible(true);

    topNewLink.setContentProvider(new ArrayContentProvider());
    getSite().setSelectionProvider(topNewLink);
    // define layout for the viewer
    gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
    topNewLink.getControl().setLayoutData(gridData);

    Button button = new Button(composite, SWT.PUSH);
    button.setText("Link");
    button.addSelectionListener(new SelectionListener() {
        public void widgetDefaultSelected(SelectionEvent event) {
        }

        public void widgetSelected(SelectionEvent event) {
            IStructuredSelection topSelection = (IStructuredSelection) topNewLink.getSelection();
            IStructuredSelection bottomSelection = (IStructuredSelection) bottomNewLink.getSelection();

            String[] crosscuttingConcern = (String[]) topSelection.getFirstElement();
            String[] designDecision = (String[]) bottomSelection.getFirstElement();

            if ((crosscuttingConcern != null) && (designDecision != null)) {
                // create dialog with ok and cancel button and info icon
                MessageBox dialog = new MessageBox(composite.getShell(),
                        SWT.ICON_QUESTION | SWT.OK | SWT.CANCEL);
                dialog.setText("Link confirmation");
                dialog.setMessage("Do you want to link the selected items?");

                // open dialog and await user selection
                int response = dialog.open();
                if (response == SWT.OK) {
                    PluginUtil.createNewLink(crosscuttingConcern, designDecision, cp);
                    dirty = true;
                    firePropertyChange(IEditorPart.PROP_DIRTY);
                }
            } else {
                MessageDialog.openError(composite.getShell(), "Error", "Please select item(s) to link");
            }
        }
    });

    gridData = new GridData(SWT.CENTER, SWT.TOP, false, false, 2, 1);
    button.setLayoutData(gridData);

    Label ddsLabel = new Label(composite, SWT.BORDER);
    ddsLabel.setText("Architectural design decisions");
    ddsLabel.setToolTipText("This are the design decisions detected in the architectural document");
    gridData = new GridData(SWT.LEFT, SWT.TOP, false, false);
    ddsLabel.setLayoutData(gridData);
    bottomNewLink = new TableViewer(composite, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
    createColumns(composite, bottomNewLink);

    Table table2 = bottomNewLink.getTable();
    table2.setHeaderVisible(true);
    table2.setLinesVisible(true);

    bottomNewLink.setContentProvider(new ArrayContentProvider());

    getSite().setSelectionProvider(bottomNewLink);
    gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
    bottomNewLink.getControl().setLayoutData(gridData);

    int index = addPage(composite);
    setPageText(index, "New Link");
}

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

/**
 * Creates the impact list page./*from   w  w w.j  a  va 2 s . c  o m*/
 */
void impactListPage() {
    final Composite composite = new Composite(getContainer(), SWT.NONE);
    composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1));
    composite.setLayout(new GridLayout());

    Label concernLabel = new Label(composite, SWT.BORDER);
    concernLabel.setText("Crosccuting Concerns(CCC)");
    concernLabel.setToolTipText("This are the concern detected on the requierement document.");
    GridData gridData = new GridData(SWT.LEFT, SWT.TOP, false, false);
    concernLabel.setLayoutData(gridData);

    /////////////////////
    ScrolledComposite sc = new ScrolledComposite(composite, SWT.H_SCROLL | SWT.V_SCROLL);
    Composite parent = new Composite(sc, SWT.NONE);
    parent.setLayout(new GridLayout());

    topViewLink = new TableViewer(parent, SWT.BORDER);
    createColumns(parent, topViewLink);

    final Table table = topViewLink.getTable();
    table.setHeaderVisible(true);
    table.setLinesVisible(true);

    topViewLink.setContentProvider(new ArrayContentProvider());

    getSite().setSelectionProvider(topViewLink);
    GridData data = new GridData(SWT.FILL, SWT.FILL, true, false);
    data.heightHint = 10 * table.getItemHeight();
    table.setLayoutData(data);

    sc.setContent(parent);
    sc.setExpandHorizontal(true);
    sc.setExpandVertical(true);
    sc.setMinSize(parent.computeSize(SWT.DEFAULT, SWT.DEFAULT));

    /////////////////////

    Button button = new Button(composite, SWT.PUSH);
    button.setText("Remove");
    button.addSelectionListener(new SelectionListener() {
        public void widgetDefaultSelected(SelectionEvent event) {
        }

        public void widgetSelected(SelectionEvent event) {
            IStructuredSelection topSelection = (IStructuredSelection) topViewLink.getSelection();
            IStructuredSelection bottomSelection = (IStructuredSelection) bottomViewLink.getSelection();

            String[] crosscuttingConcern = (String[]) topSelection.getFirstElement();
            String[] designDecision = (String[]) bottomSelection.getFirstElement();
            if (topSelection.size() > 1) {
                MessageDialog.openError(composite.getShell(), "Error",
                        "Please select one crosscutting concern");
            } else {
                if ((crosscuttingConcern != null) && (designDecision != null)) {
                    // create dialog with ok and cancel button and info icon
                    MessageBox dialog = new MessageBox(composite.getShell(),
                            SWT.ICON_QUESTION | SWT.OK | SWT.CANCEL);
                    dialog.setText("Link confirmation");
                    dialog.setMessage("Do you want to remove the link between the selected items?");

                    // open dialog and await user selection
                    int response = dialog.open();
                    if (response == SWT.OK) {
                        PluginUtil.removeLink(crosscuttingConcern, designDecision, cp);
                        dirty = true;
                        firePropertyChange(IEditorPart.PROP_DIRTY);
                        // update the list after the remove
                        generateLinkViewData();
                        bottomViewLink.getTable().clearAll();
                    }
                } else {
                    MessageDialog.openError(composite.getShell(), "Error",
                            "Please select a crosscutting concern and a design decision to remove a traceability link");
                }
            }
        }
    });
    gridData = new GridData(SWT.CENTER, SWT.TOP, false, false, 2, 1);
    button.setLayoutData(gridData);

    Label ddsLabel = new Label(composite, SWT.BORDER);
    ddsLabel.setText("Architectural design decisions");
    ddsLabel.setToolTipText("This are the design decisions detected on the architectural document");

    gridData = new GridData(SWT.LEFT, SWT.TOP, false, false);
    ddsLabel.setLayoutData(gridData);

    bottomViewLink = new TableViewer(composite,
            SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
    createColumns(composite, bottomViewLink);
    Table table2 = bottomViewLink.getTable();
    table2.setHeaderVisible(true);
    table2.setLinesVisible(true);
    bottomViewLink.setContentProvider(new ArrayContentProvider());
    topViewLink.addSelectionChangedListener(new ISelectionChangedListener() {
        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection selection = (IStructuredSelection) event.getSelection();
            if (!selection.isEmpty()) {
                String[] cccs = (String[]) selection.getFirstElement();
                List<DesignDecision> dds = PluginUtil.getDesignDecisionsForCrossCuttingConcern(cp, cccs[1],
                        cccs[0]);
                logger.info("Impact List for CCC (" + dds.size() + " DDD): " + cccs[0] + " - " + cccs[1]);
                List<String[]> designDecisions = new ArrayList<String[]>();

                for (DesignDecision dd : dds) {
                    String[] designDecision = { dd.getKind(), dd.getName() };
                    designDecisions.add(designDecision);
                }
                bottomViewLink.setInput(designDecisions);
            }
        }
    });
    getSite().setSelectionProvider(bottomViewLink);
    gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
    bottomViewLink.getControl().setLayoutData(gridData);

    int index = addPage(composite);
    setPageText(index, "Links");
}

From source file:ConnectionInfo.java

protected Control createDialogArea(Composite parent) {
    getShell().setText("Connection Settings");

    Composite composite = (Composite) super.createDialogArea(parent);
    composite.setLayout(new GridLayout(2, false));

    new Label(composite, SWT.NULL).setText("Host: ");
    textHost = new Text(composite, SWT.BORDER);
    textHost.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    new Label(composite, SWT.NULL).setText("Port: ");
    textPort = new Text(composite, SWT.BORDER);
    textPort.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    new Label(composite, SWT.NULL).setText("Username: ");
    textUsername = new Text(composite, SWT.BORDER);
    textUsername.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    new Label(composite, SWT.NULL).setText("Password: ");
    textPassword = new Text(composite, SWT.PASSWORD | SWT.BORDER);
    textPassword.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    // sets initial values.
    try {/*from  w w w  .  j  a v a  2s.  com*/
        textHost.setText(dialogSettings.get(KEY_HOST));
        textPort.setText(dialogSettings.getInt(KEY_PORT) + "");
        textUsername.setText(dialogSettings.get(KEY_USERNAME));
        textPassword.setText(dialogSettings.get(KEY_PASSWORD));
    } catch (Exception e) {
        // ignore.
    }

    return composite;
}

From source file:org.testeditor.dashboard.TableDurationTrend.java

/**
 * designs and creates graph from data sets.
 * /*from ww  w . j  a va 2  s  . c  o  m*/
 * @param objektList
 *            list of all suite GoogleSucheSuite runs <AllRunsResult>
 * @param parent
 *            composite parent
 * @param modelService
 *            to find part label
 * @param window
 *            trimmed window
 * @param app
 *            org.eclipse.e4.ide.application
 */
@SuppressWarnings({ "serial" })
@Inject
@Optional
public void createControls(@UIEventTopic("Testobjektlist") List<AllRunsResult> objektList, Composite parent,
        EModelService modelService, MWindow window, MApplication app) {
    MPart mPart = (MPart) modelService.find("org.testeditor.ui.part.2", app);
    String[] arr = objektList.get(0).getFilePath().getName().split("\\.");
    String filenameSplitted = arr[arr.length - 1];
    mPart.setLabel(translationService.translate("%dashboard.table.label.duration", CONTRIBUTOR_URI) + " "
            + filenameSplitted);
    mPart.setTooltip(translationService.translate("%dashboard.table.label.duration", CONTRIBUTOR_URI) + " "
            + objektList.get(0).getFilePath().getName());
    parent.setLayout(new FillLayout());

    // create the chart...
    chart = ChartFactory.createBarChart3D(null, // chart
            // title
            translationService.translate("%dashboard.table.label.duration.axis.dates", CONTRIBUTOR_URI), // domain
            // X axis
            // label
            translationService.translate("%dashboard.table.label.duration.axis.duration", CONTRIBUTOR_URI)
                    + " h:m:s:ms", // range
            // Y axis
            // label
            createDataset(objektList), // data
            PlotOrientation.VERTICAL, // orientation
            false, // include legend
            true, // tooltips?
            false // URLs?
    );

    // get a reference to the plot for further customisation...
    final CategoryPlot plot = chart.getCategoryPlot();
    // y axis right
    plot.setRangeAxisLocation(0, AxisLocation.BOTTOM_OR_RIGHT);
    // set the range axis to display integers only...
    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setNumberFormatOverride(new NumberFormat() { // show duration
        // values in
        // h:m:s:ms
        @Override
        public StringBuffer format(double number, StringBuffer toAppendTo, FieldPosition pos) {
            // return new StringBuffer(String.format("%f", number));
            return new StringBuffer(String.format(formatDuration(number)));
        }

        @Override
        public StringBuffer format(long number, StringBuffer toAppendTo, FieldPosition pos) {
            // return new StringBuffer(String.format("%f", number));
            return new StringBuffer(String.format(formatDuration(number)));
        }

        @Override
        public Number parse(String source, ParsePosition parsePosition) {
            return null;
        }
    });

    // disable bar outlines...
    final BarRenderer renderer = (BarRenderer) plot.getRenderer();
    renderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator("{1} "
            + translationService.translate("%dashboard.table.label.duration.axis.duration", CONTRIBUTOR_URI)
            + ": {2}ms", NumberFormat.getInstance()));
    renderer.setDrawBarOutline(false);
    renderer.setMaximumBarWidth(.15);
    final CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(1.57));

    Color color = toAwtColor(ColorConstants.COLOR_BLUE);
    final GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, color, 0, 0, color);
    renderer.setSeriesPaint(0, gp0);

    chartComposite = new ChartComposite(parent, SWT.EMBEDDED);
    chartComposite.setSize(800, 800);
    GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
    chartComposite.setLayoutData(data);
    chartComposite.setHorizontalAxisTrace(false);
    chartComposite.setVerticalAxisTrace(false);
    chartComposite.setChart(chart);
    chartComposite.pack(true);
    chartComposite.setVisible(true);
    chartComposite.forceRedraw();
    parent.layout();
}

From source file:net.sf.eclipsecs.ui.stats.views.GraphStatsView.java

/**
 * {@inheritDoc}//www  .  ja  v  a2 s . c om
 * 
 * @see org.eclipse.ui.IWorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
 */
public void createPartControl(Composite parent) {

    super.createPartControl(parent);

    // set up the main layout
    GridLayout layout = new GridLayout(1, false);
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    parent.setLayout(layout);

    // the label
    mLabelDesc = new Label(parent, SWT.NONE);
    GridData gridData = new GridData();
    gridData.horizontalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    mLabelDesc.setLayoutData(gridData);

    // the main section
    mMainSection = new Composite(parent, SWT.NONE);
    mStackLayout = new StackLayout();
    mStackLayout.marginHeight = 0;
    mStackLayout.marginWidth = 0;
    mMainSection.setLayout(mStackLayout);
    mMainSection.setLayoutData(new GridData(GridData.FILL_BOTH));

    // create the master viewer
    mMasterComposite = createMasterView(mMainSection);

    // create the detail viewer
    mDetailViewer = createDetailView(mMainSection);

    mStackLayout.topControl = mMasterComposite;

    updateActions();

    // initialize the view data
    refresh();
}

From source file:com.tocea.scertify.eclipse.scertifycode.ui.stats.views.GraphStatsView.java

/**
 * {@inheritDoc}/*from  w ww .  j  a  va  2  s .com*/
 * 
 * @see org.eclipse.ui.IWorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
 */

public void createPartControl(final Composite parent) {

    super.createPartControl(parent);

    // set up the main layout
    final GridLayout layout = new GridLayout(1, false);
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    parent.setLayout(layout);

    // the label
    this.mLabelDesc = new Label(parent, SWT.NONE);
    final GridData gridData = new GridData();
    gridData.horizontalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    this.mLabelDesc.setLayoutData(gridData);

    // the main section
    this.mMainSection = new Composite(parent, SWT.NONE);
    this.mStackLayout = new StackLayout();
    this.mStackLayout.marginHeight = 0;
    this.mStackLayout.marginWidth = 0;
    this.mMainSection.setLayout(this.mStackLayout);
    this.mMainSection.setLayoutData(new GridData(GridData.FILL_BOTH));

    // create the master viewer
    this.mMasterComposite = createMasterView(this.mMainSection);

    // create the detail viewer
    this.mDetailViewer = createDetailView(this.mMainSection);

    this.mStackLayout.topControl = this.mMasterComposite;

    updateActions();

    // initialize the view data
    refresh(Job.DECORATE);
}