List of usage examples for org.eclipse.swt.widgets Composite Composite
public Composite(Composite parent, int style)
From source file:grafici.StatisticheBarChart.java
/** * Creates a new demo instance.// w ww. j av a 2 s . c om * * @param title * the frame title. */ public StatisticheBarChart(Table risultati, Composite parent, int style, int variabile, int valore) { super(parent, style); try { this.titolo = risultati.getColumn(variabile).getText().toUpperCase() + " - " + risultati.getColumn(valore).getText().toUpperCase(); GridData gdThis = new GridData(SWT.FILL); gdThis.horizontalAlignment = SWT.FILL; gdThis.verticalAlignment = SWT.FILL; gdThis.grabExcessHorizontalSpace = true; gdThis.grabExcessVerticalSpace = true; this.setLayoutData(gdThis); this.setLayout(new GridLayout(1, false)); Composite cmp = new Composite(this, SWT.FILL | SWT.EMBEDDED); GridData gdCmp = new GridData(SWT.FILL); gdCmp.horizontalAlignment = SWT.FILL; gdCmp.verticalAlignment = SWT.FILL; gdCmp.grabExcessHorizontalSpace = true; gdCmp.grabExcessVerticalSpace = true; cmp.setLayoutData(gdCmp); cmp.setLayout(new GridLayout(1, false)); CategoryDataset dataset = createDataset(risultati, variabile, valore); JFreeChart chart = createChart(dataset, risultati, variabile, valore); ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setFillZoomRectangle(true); // chartPanel.setMouseWheelEnabled(true); // chartPanel.setPreferredSize(new Dimension(1000, 700)); Frame graphFrame = SWT_AWT.new_Frame(cmp); graphFrame.add(chartPanel); graphFrame.pack(); } catch (Exception e) { alertGraficoNonDisp(); } }
From source file:org.jfree.experimental.chart.swt.editor.SWTChartEditorDialog.java
/** * Creates a new editor.//from w w w . j av a2 s. com * * @param shell2 the display. * @param chart2edit the chart to edit. */ public SWTChartEditorDialog(Shell shell2, final JFreeChart chart2edit) { this.dialog = new Dialog(shell2) { @Override protected Control createDialogArea(Composite parent) { SWTChartEditorDialog.this.chart = chart2edit; GridLayout layout = new GridLayout(2, true); layout.marginLeft = layout.marginTop = layout.marginRight = layout.marginBottom = 5; parent.setLayout(layout); Composite main = new Composite(parent, SWT.NONE); main.setLayout(new FillLayout()); main.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1)); main.setSize(400, 500); TabFolder tab = new TabFolder(main, SWT.BORDER); // build first tab TabItem item1 = new TabItem(tab, SWT.NONE); item1.setText(" " + localizationResources.getString("Title") + " "); SWTChartEditorDialog.this.titleEditor = new SWTTitleEditor(tab, SWT.NONE, SWTChartEditorDialog.this.chart.getTitle()); item1.setControl(SWTChartEditorDialog.this.titleEditor); // build second tab TabItem item2 = new TabItem(tab, SWT.NONE); item2.setText(" " + localizationResources.getString("Plot") + " "); SWTChartEditorDialog.this.plotEditor = new SWTPlotEditor(tab, SWT.NONE, SWTChartEditorDialog.this.chart.getPlot()); item2.setControl(SWTChartEditorDialog.this.plotEditor); // build the third tab TabItem item3 = new TabItem(tab, SWT.NONE); item3.setText(" " + localizationResources.getString("Other") + " "); SWTChartEditorDialog.this.otherEditor = new SWTOtherEditor(tab, SWT.NONE, SWTChartEditorDialog.this.chart); item3.setControl(SWTChartEditorDialog.this.otherEditor); return super.createDialogArea(parent); } @Override protected void buttonPressed(int buttonId) { if (buttonId == 0) { updateChart(SWTChartEditorDialog.this.chart); } this.close(); } }; }
From source file:org.jfree.experimental.chart.swt.editor.SWTChartEditor.java
/** * Creates a new editor./* w w w. j a v a 2 s.c om*/ * * @param shell2 the display. * @param chart2edit the chart to edit. */ public SWTChartEditor(Shell shell2, JFreeChart chart2edit) { this.shell = new Shell(Display.getDefault(), SWT.DIALOG_TRIM); this.shell.setSize(400, 500); this.chart = chart2edit; this.shell.setText( ResourceBundle.getBundle("org.jfree.chart.LocalizationBundle").getString("Chart_Properties")); GridLayout layout = new GridLayout(2, true); layout.marginLeft = layout.marginTop = layout.marginRight = layout.marginBottom = 5; this.shell.setLayout(layout); Composite main = new Composite(this.shell, SWT.NONE); main.setLayout(new FillLayout()); main.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1)); TabFolder tab = new TabFolder(main, SWT.BORDER); // build first tab TabItem item1 = new TabItem(tab, SWT.NONE); item1.setText(" " + localizationResources.getString("Title") + " "); this.titleEditor = new SWTTitleEditor(tab, SWT.NONE, this.chart.getTitle()); item1.setControl(this.titleEditor); // build second tab TabItem item2 = new TabItem(tab, SWT.NONE); item2.setText(" " + localizationResources.getString("Plot") + " "); this.plotEditor = new SWTPlotEditor(tab, SWT.NONE, this.chart.getPlot()); item2.setControl(this.plotEditor); // build the third tab TabItem item3 = new TabItem(tab, SWT.NONE); item3.setText(" " + localizationResources.getString("Other") + " "); this.otherEditor = new SWTOtherEditor(tab, SWT.NONE, this.chart); item3.setControl(this.otherEditor); // ok and cancel buttons Button ok = new Button(this.shell, SWT.PUSH | SWT.OK); ok.setText(" Ok "); ok.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false)); ok.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { updateChart(SWTChartEditor.this.chart); SWTChartEditor.this.shell.dispose(); } }); Button cancel = new Button(this.shell, SWT.PUSH); cancel.setText(" Cancel "); cancel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false)); cancel.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { SWTChartEditor.this.shell.dispose(); } }); }
From source file:org.eclipse.swt.examples.paint.TextTool.java
/** * Handles a mouseDown event.//from w w w . j a v a2 s.c om * * @param event the mouse event detail information */ @Override public void mouseDown(MouseEvent event) { if (event.button == 1) { // draw with left mouse button getPaintSurface().commitRubberbandSelection(); } else { // set text with right mouse button getPaintSurface().clearRubberbandSelection(); Shell shell = getPaintSurface().getShell(); final Shell dialog = new Shell(shell, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL); dialog.setText(PaintExample.getResourceString("tool.Text.dialog.title")); dialog.setLayout(new GridLayout()); Label label = new Label(dialog, SWT.NONE); label.setText(PaintExample.getResourceString("tool.Text.dialog.message")); label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false)); final Text field = new Text(dialog, SWT.SINGLE | SWT.BORDER); field.setText(drawText); field.selectAll(); field.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); Composite buttons = new Composite(dialog, SWT.NONE); GridLayout layout = new GridLayout(2, true); layout.marginWidth = 0; buttons.setLayout(layout); buttons.setLayoutData(new GridData(SWT.END, SWT.CENTER, false, false)); Button ok = new Button(buttons, SWT.PUSH); ok.setText(PaintExample.getResourceString("OK")); ok.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false)); ok.addSelectionListener(widgetSelectedAdapter(e -> { drawText = field.getText(); dialog.dispose(); })); Button cancel = new Button(buttons, SWT.PUSH); cancel.setText(PaintExample.getResourceString("Cancel")); cancel.addSelectionListener(widgetSelectedAdapter(e -> dialog.dispose())); dialog.setDefaultButton(ok); dialog.pack(); dialog.open(); Display display = dialog.getDisplay(); while (!shell.isDisposed() && !dialog.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } } }
From source file:com.rcp.wbw.demo.editor.SWTChartEditor.java
/** * Creates a new editor.//from ww w . ja v a2s . c om * * @param display * the display. * @param chart2edit * the chart to edit. */ public SWTChartEditor(Display display, JFreeChart chart2edit) { this.shell = new Shell(display, SWT.DIALOG_TRIM); this.shell.setSize(400, 500); this.chart = chart2edit; this.shell.setText(ResourceBundleWrapper.getBundle("org.jfree.chart.LocalizationBundle") .getString("Chart_Properties")); GridLayout layout = new GridLayout(2, true); layout.marginLeft = layout.marginTop = layout.marginRight = layout.marginBottom = 5; this.shell.setLayout(layout); Composite main = new Composite(this.shell, SWT.NONE); main.setLayout(new FillLayout()); main.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1)); TabFolder tab = new TabFolder(main, SWT.BORDER); // build first tab TabItem item1 = new TabItem(tab, SWT.NONE); item1.setText(" " + localizationResources.getString("Title") + " "); this.titleEditor = new SWTTitleEditor(tab, SWT.NONE, this.chart.getTitle()); item1.setControl(this.titleEditor); // build second tab TabItem item2 = new TabItem(tab, SWT.NONE); item2.setText(" " + localizationResources.getString("Plot") + " "); this.plotEditor = new SWTPlotEditor(tab, SWT.NONE, this.chart.getPlot()); item2.setControl(this.plotEditor); // build the third tab TabItem item3 = new TabItem(tab, SWT.NONE); item3.setText(" " + localizationResources.getString("Other") + " "); this.otherEditor = new SWTOtherEditor(tab, SWT.NONE, this.chart); item3.setControl(this.otherEditor); // ok and cancel buttons Button ok = new Button(this.shell, SWT.PUSH | SWT.OK); ok.setText(" Ok "); ok.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false)); ok.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { updateChart(SWTChartEditor.this.chart); SWTChartEditor.this.shell.dispose(); } }); Button cancel = new Button(this.shell, SWT.PUSH); cancel.setText(" Cancel "); cancel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false)); cancel.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { SWTChartEditor.this.shell.dispose(); } }); }
From source file:org.amanzi.awe.charts.ui.ChartsView.java
@Override public void createPartControl(final Composite parent) { parent.setLayout(new GridLayout(1, false)); controlsComposite = new Composite(parent, SWT.NONE); controlsComposite.setLayout(new GridLayout(1, false)); controlsComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); Composite buttonsContainer = new Composite(controlsComposite, SWT.NONE); buttonsContainer.setLayout(new GridLayout(4, true)); buttonsContainer.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); createRadioButton(buttonsContainer, "Line", true, ChartType.TIME_CHART); createRadioButton(buttonsContainer, "Bar", false, ChartType.BAR_CHART); createRadioButton(buttonsContainer, "Stacked", false, ChartType.STACKED_CHART); createRadioButton(buttonsContainer, "Pie", false, ChartType.PIE_CHART); Composite filteringContainer = new Composite(controlsComposite, SWT.BORDER); filteringContainer.setLayout(new GridLayout(2, true)); filteringContainer.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); groupSelectorWidget = new ItemsSelectorWidget(filteringContainer, this, GROUPS_LABEL); columnsSelectorWidget = new ItemsSelectorWidget(filteringContainer, this, CELLS_LABEL); groupSelectorWidget.initializeWidget(); columnsSelectorWidget.initializeWidget(); int width = parent.getShell().getSize().x; chartComposite = new ChartComposite(parent, SWT.FILL, null, ChartComposite.DEFAULT_WIDTH, ChartComposite.DEFAULT_HEIGHT, ChartComposite.DEFAULT_MINIMUM_DRAW_WIDTH, ChartComposite.DEFAULT_MINIMUM_DRAW_HEIGHT, width, ChartComposite.DEFAULT_MAXIMUM_DRAW_HEIGHT, true, true, true, true, true, true); chartComposite.setLayoutData(new GridData(GridData.FILL_BOTH)); chartComposite.setVisible(false);//w w w . jav a2 s . com chartComposite.addChartMouseListener(this); }
From source file:CoolBarTest.java
/** * Creates two stacked buttons//from www . ja v a 2s. c om * * @param composite the parent composite * @return Control */ private Control createStackedButtons(Composite composite) { Composite c = new Composite(composite, SWT.NONE); c.setLayout(new GridLayout(1, false)); new Button(c, SWT.PUSH).setText("Button One"); new Button(c, SWT.PUSH).setText("Button Two"); return c; }
From source file:TabComplex.java
/** * Gets the control for tab one//w w w . j a v a 2 s . c o m * * @param tabFolder the parent tab folder * @return Control */ private Control getTabOneControl(TabFolder tabFolder) { // Create a composite and add four buttons to it Composite composite = new Composite(tabFolder, SWT.NONE); composite.setLayout(new FillLayout(SWT.VERTICAL)); new Button(composite, SWT.PUSH).setText("Button one"); new Button(composite, SWT.PUSH).setText("Button two"); new Button(composite, SWT.PUSH).setText("Button three"); new Button(composite, SWT.PUSH).setText("Button four"); return composite; }
From source file:org.mwc.asset.netasset2.sensor2.VSensor.java
/** * Create the composite./*from w ww .ja va2 s . c o m*/ * * @param parent * @param style */ public VSensor(final Composite parent, final int style) { super(parent, style); setLayout(new BorderLayout(0, 0)); final ToolBar toolBar = new ToolBar(this, SWT.FLAT | SWT.RIGHT); toolBar.setLayoutData(BorderLayout.NORTH); // ToolItem testBtn = new ToolItem(toolBar, SWT.NONE); // testBtn.setText("Test 1"); // testBtn.addSelectionListener(new SelectionAdapter() // { // // @Override // public void widgetSelected(SelectionEvent e) // { // doTest(); // } // }); final ToolItem tltmDropdownItem = new ToolItem(toolBar, SWT.DROP_DOWN); tltmDropdownItem.setText("Visible period"); final DropdownSelectionListener drops = new DropdownSelectionListener(tltmDropdownItem); drops.add("5 Mins", 5 * 60); drops.add("15 Mins", 15 * 60); drops.add("60 Mins", 60 * 60); drops.add("All data", 0); tltmDropdownItem.addSelectionListener(drops); final Composite sashForm = new Composite(this, SWT.EMBEDDED); // now we need a Swing object to put our chart into final Frame _plotControl = SWT_AWT.new_Frame(sashForm); // the y axis is common to hi & lo res. Format it here final NumberAxis yAxis = new NumberAxis("Degs"); // yAxis.setRange(0, 360); yAxis.setAutoRange(true); yAxis.setTickUnit(new NumberTickUnit(45)); // create a date-formatting axis _dateAxis = new RelativeDateAxis(); _dateAxis.setStandardTickUnits(DateAxisEditor.createStandardDateTickUnitsAsTickUnits()); _dateAxis.setAutoRange(true); final XYItemRenderer theRenderer = new XYShapeRenderer(); _thePlot = new XYPlot(null, _dateAxis, yAxis, theRenderer); _thePlot.setOrientation(PlotOrientation.HORIZONTAL); _thePlot.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT); _thePlot.setBackgroundPaint(Color.BLACK); theRenderer.setPlot(_thePlot); _dateAxis.setLabelPaint(Color.GREEN); _dateAxis.setTickLabelPaint(Color.GREEN); _dateAxis.setAxisLinePaint(Color.GREEN); yAxis.setLabelPaint(Color.GREEN); yAxis.setTickLabelPaint(Color.GREEN); _thePlotArea = new JFreeChart(null, _thePlot); _thePlotArea.setBackgroundPaint(Color.BLACK); _thePlotArea.setBorderPaint(Color.BLACK); // set the color of the area surrounding the plot // - naah, don't bother. leave it in the application background color. // //////////////////////////////////////////////// // put the holder into one of our special items // //////////////////////////////////////////////// _chartInPanel = new ChartPanel(_thePlotArea, true); _plotControl.add(_chartInPanel); }
From source file:org.eclipse.swt.examples.controlexample.TextTab.java
/** * Creates the "Style" group./*from w w w . ja v a 2 s .c om*/ */ @Override void createStyleGroup() { super.createStyleGroup(); /* Create the extra widgets */ wrapButton = new Button(styleGroup, SWT.CHECK); wrapButton.setText("SWT.WRAP"); readOnlyButton = new Button(styleGroup, SWT.CHECK); readOnlyButton.setText("SWT.READ_ONLY"); passwordButton = new Button(styleGroup, SWT.CHECK); passwordButton.setText("SWT.PASSWORD"); searchButton = new Button(styleGroup, SWT.CHECK); searchButton.setText("SWT.SEARCH"); iconCancelButton = new Button(styleGroup, SWT.CHECK); iconCancelButton.setText("SWT.ICON_CANCEL"); iconSearchButton = new Button(styleGroup, SWT.CHECK); iconSearchButton.setText("SWT.ICON_SEARCH"); Composite alignmentGroup = new Composite(styleGroup, SWT.NONE); GridLayout layout = new GridLayout(); layout.marginWidth = layout.marginHeight = 0; alignmentGroup.setLayout(layout); alignmentGroup.setLayoutData(new GridData(GridData.FILL_BOTH)); leftButton = new Button(alignmentGroup, SWT.RADIO); leftButton.setText("SWT.LEFT"); centerButton = new Button(alignmentGroup, SWT.RADIO); centerButton.setText("SWT.CENTER"); rightButton = new Button(alignmentGroup, SWT.RADIO); rightButton.setText("SWT.RIGHT"); }