List of usage examples for org.eclipse.swt.widgets Button setLayoutData
public void setLayoutData(Object layoutData)
From source file:org.eclipse.swt.examples.paint.TextTool.java
/** * Handles a mouseDown event./*ww w .j av a 2 s.com*/ * * @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:Sample.java
public Sample() { shell.setText("Book Entry Demo"); GridLayout gridLayout = new GridLayout(4, false); gridLayout.verticalSpacing = 8;// w ww .j av a 2 s .c o m shell.setLayout(gridLayout); // Title Label label = new Label(shell, SWT.NULL); label.setText("Title: "); Text title = new Text(shell, SWT.SINGLE | SWT.BORDER); GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL); gridData.horizontalSpan = 3; title.setLayoutData(gridData); // Author(s) label = new Label(shell, SWT.NULL); label.setText("Author(s): "); Text authors = new Text(shell, SWT.SINGLE | SWT.BORDER); gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL); gridData.horizontalSpan = 3; authors.setLayoutData(gridData); // Cover label = new Label(shell, SWT.NULL); label.setText("Cover: "); gridData = new GridData(); gridData.verticalSpan = 3; label.setLayoutData(gridData); CLabel cover = new CLabel(shell, SWT.NULL); gridData = new GridData(GridData.FILL_HORIZONTAL); gridData.horizontalSpan = 1; gridData.verticalSpan = 3; gridData.heightHint = 100; gridData.widthHint = 100; cover.setLayoutData(gridData); // Details. label = new Label(shell, SWT.NULL); label.setText("Pages"); Text pages = new Text(shell, SWT.SINGLE | SWT.BORDER); pages.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); label = new Label(shell, SWT.NULL); label.setText("Publisher"); Text pubisher = new Text(shell, SWT.SINGLE | SWT.BORDER); pubisher.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); label = new Label(shell, SWT.NULL); label.setText("Rating"); Combo rating = new Combo(shell, SWT.READ_ONLY); rating.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); rating.add("5"); rating.add("4"); rating.add("3"); rating.add("2"); rating.add("1"); // Abstract. label = new Label(shell, SWT.NULL); label.setText("Abstract:"); Text bookAbstract = new Text(shell, SWT.WRAP | SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL); gridData.horizontalSpan = 3; gridData.grabExcessVerticalSpace = true; bookAbstract.setLayoutData(gridData); // Button. Button enter = new Button(shell, SWT.PUSH); enter.setText("Enter"); gridData = new GridData(); gridData.horizontalSpan = 4; gridData.horizontalAlignment = GridData.END; enter.setLayoutData(gridData); // Fill information. title.setText("Professional Java Interfaces with SWT/JFace"); authors.setText("Jack Li Guojie"); pages.setText("500pp"); pubisher.setText("John Wiley & Sons"); cover.setBackground(new Image(display, "java2s.gif")); bookAbstract.setText("This book provides a comprehensive guide for \n" + "you to create Java user interfaces with SWT/JFace. "); shell.pack(); shell.open(); // Set up the event loop. while (!shell.isDisposed()) { if (!display.readAndDispatch()) { // If no more entries in event queue display.sleep(); } } display.dispose(); }
From source file:org.eclipse.swt.examples.addressbook.SearchDialog.java
/** * Class constructor that sets the parent shell and the table widget that * the dialog will search./*from ww w . ja v a 2 s . com*/ * * @param parent Shell * The shell that is the parent of the dialog. */ public SearchDialog(Shell parent) { shell = new Shell(parent, SWT.CLOSE | SWT.BORDER | SWT.TITLE); GridLayout layout = new GridLayout(); layout.numColumns = 2; shell.setLayout(layout); shell.setText(resAddressBook.getString("Search_dialog_title")); shell.addShellListener(ShellListener.shellClosedAdapter(e -> { // don't dispose of the shell, just hide it for later use e.doit = false; shell.setVisible(false); })); Label label = new Label(shell, SWT.LEFT); label.setText(resAddressBook.getString("Dialog_find_what")); searchText = new Text(shell, SWT.BORDER); GridData gridData = new GridData(GridData.FILL_HORIZONTAL); gridData.widthHint = 200; searchText.setLayoutData(gridData); searchText.addModifyListener(e -> { boolean enableFind = (searchText.getCharCount() != 0); findButton.setEnabled(enableFind); }); searchAreaLabel = new Label(shell, SWT.LEFT); searchArea = new Combo(shell, SWT.DROP_DOWN | SWT.READ_ONLY); gridData = new GridData(GridData.FILL_HORIZONTAL); gridData.widthHint = 200; searchArea.setLayoutData(gridData); matchCase = new Button(shell, SWT.CHECK); matchCase.setText(resAddressBook.getString("Dialog_match_case")); gridData = new GridData(); gridData.horizontalSpan = 2; matchCase.setLayoutData(gridData); matchWord = new Button(shell, SWT.CHECK); matchWord.setText(resAddressBook.getString("Dialog_match_word")); gridData = new GridData(); gridData.horizontalSpan = 2; matchWord.setLayoutData(gridData); Group direction = new Group(shell, SWT.NONE); gridData = new GridData(); gridData.horizontalSpan = 2; direction.setLayoutData(gridData); direction.setLayout(new FillLayout()); direction.setText(resAddressBook.getString("Dialog_direction")); Button up = new Button(direction, SWT.RADIO); up.setText(resAddressBook.getString("Dialog_dir_up")); up.setSelection(false); down = new Button(direction, SWT.RADIO); down.setText(resAddressBook.getString("Dialog_dir_down")); down.setSelection(true); Composite composite = new Composite(shell, SWT.NONE); gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL); gridData.horizontalSpan = 2; composite.setLayoutData(gridData); layout = new GridLayout(); layout.numColumns = 2; layout.makeColumnsEqualWidth = true; composite.setLayout(layout); findButton = new Button(composite, SWT.PUSH); findButton.setText(resAddressBook.getString("Dialog_find")); findButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); findButton.setEnabled(false); findButton.addSelectionListener(widgetSelectedAdapter(e -> { if (!findHandler.find()) { MessageBox box = new MessageBox(shell, SWT.ICON_INFORMATION | SWT.OK | SWT.PRIMARY_MODAL); box.setText(shell.getText()); box.setMessage(resAddressBook.getString("Cannot_find") + "\"" + searchText.getText() + "\""); box.open(); } })); Button cancelButton = new Button(composite, SWT.PUSH); cancelButton.setText(resAddressBook.getString("Cancel")); cancelButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING)); cancelButton.addSelectionListener(widgetSelectedAdapter(e -> shell.setVisible(false))); shell.pack(); }
From source file:org.mwc.debrief.dis.views.DisListenerView.java
private Button createButton(Composite composite, String label, int horizontalSpan) { Button button = new Button(composite, SWT.PUSH); GridData gd = new GridData(SWT.FILL, SWT.FILL, false, false); gd.horizontalSpan = horizontalSpan;//from w w w. j a v a 2 s . c om button.setLayoutData(gd); button.setText(label); return button; }
From source file:SWT2D.java
private void run() { // Create top level shell final Display display = new Display(); final Shell shell = new Shell(display); shell.setText("Java 2D Example"); // GridLayout for canvas and button shell.setLayout(new GridLayout()); // Create container for AWT canvas final Composite canvasComp = new Composite(shell, SWT.EMBEDDED); // Set preferred size GridData data = new GridData(); data.widthHint = 600;/*from w ww. java 2 s. c om*/ data.heightHint = 500; canvasComp.setLayoutData(data); // Create AWT Frame for Canvas java.awt.Frame canvasFrame = SWT_AWT.new_Frame(canvasComp); // Create Canvas and add it to the Frame final java.awt.Canvas canvas = new java.awt.Canvas(); canvasFrame.add(canvas); // Get graphical context and cast to Java2D final java.awt.Graphics2D g2d = (java.awt.Graphics2D) canvas.getGraphics(); // Enable antialiasing g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); // Remember initial transform final java.awt.geom.AffineTransform origTransform = g2d.getTransform(); // Create Clear button and position it Button clearButton = new Button(shell, SWT.PUSH); clearButton.setText("Clear"); data = new GridData(); data.horizontalAlignment = GridData.CENTER; clearButton.setLayoutData(data); // Event processing for Clear button clearButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { // Delete word list and redraw canvas wordList.clear(); canvasComp.redraw(); } }); // Process canvas mouse clicks canvas.addMouseListener(new java.awt.event.MouseListener() { public void mouseClicked(java.awt.event.MouseEvent e) { } public void mouseEntered(java.awt.event.MouseEvent e) { } public void mouseExited(java.awt.event.MouseEvent e) { } public void mousePressed(java.awt.event.MouseEvent e) { // Manage pop-up editor display.syncExec(new Runnable() { public void run() { if (eShell == null) { // Create new Shell: non-modal! eShell = new Shell(shell, SWT.NO_TRIM | SWT.MODELESS); eShell.setLayout(new FillLayout()); // Text input field eText = new Text(eShell, SWT.BORDER); eText.setText("Text rotation in the SWT?"); eShell.pack(); // Set position (Display coordinates) java.awt.Rectangle bounds = canvas.getBounds(); org.eclipse.swt.graphics.Point pos = canvasComp.toDisplay(bounds.width / 2, bounds.height / 2); Point size = eShell.getSize(); eShell.setBounds(pos.x, pos.y, size.x, size.y); // Open Shell eShell.open(); } else if (!eShell.isVisible()) { // Editor versteckt, sichtbar machen eShell.setVisible(true); } else { // Editor is visible - get text String t = eText.getText(); // set editor invisible eShell.setVisible(false); // Add text to list and redraw canvas wordList.add(t); canvasComp.redraw(); } } }); } public void mouseReleased(java.awt.event.MouseEvent e) { } }); // Redraw the canvas canvasComp.addPaintListener(new PaintListener() { public void paintControl(PaintEvent e) { // Pass the redraw task to AWT event queue java.awt.EventQueue.invokeLater(new Runnable() { public void run() { // Compute canvas center java.awt.Rectangle bounds = canvas.getBounds(); int originX = bounds.width / 2; int originY = bounds.height / 2; // Reset canvas g2d.setTransform(origTransform); g2d.setColor(java.awt.Color.WHITE); g2d.fillRect(0, 0, bounds.width, bounds.height); // Set font g2d.setFont(new java.awt.Font("Myriad", java.awt.Font.PLAIN, 32)); double angle = 0d; // Prepare star shape double increment = Math.toRadians(30); Iterator iter = wordList.iterator(); while (iter.hasNext()) { // Determine text colors in RGB color cycle float red = (float) (0.5 + 0.5 * Math.sin(angle)); float green = (float) (0.5 + 0.5 * Math.sin(angle + Math.toRadians(120))); float blue = (float) (0.5 + 0.5 * Math.sin(angle + Math.toRadians(240))); g2d.setColor(new java.awt.Color(red, green, blue)); // Redraw text String text = (String) iter.next(); g2d.drawString(text, originX + 50, originY); // Rotate for next text output g2d.rotate(increment, originX, originY); angle += increment; } } }); } }); // Finish shell and open it shell.pack(); shell.open(); // SWT event processing while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:org.jfree.experimental.chart.swt.editor.SWTPlotAppearanceEditor.java
SWTPlotAppearanceEditor(Composite parent, int style, Plot plot) { super(parent, style); FillLayout layout = new FillLayout(); layout.marginHeight = layout.marginWidth = 4; this.setLayout(layout); Group general = new Group(this, SWT.NONE); GridLayout groupLayout = new GridLayout(3, false); groupLayout.marginHeight = groupLayout.marginWidth = 4; general.setLayout(groupLayout);//from w w w. j a va 2 s .co m general.setText(localizationResources.getString("General")); // row 1: stroke new Label(general, SWT.NONE).setText(localizationResources.getString("Outline_stroke")); this.strokeCanvas = new SWTStrokeCanvas(general, SWT.NONE); this.strokeCanvas.setStroke(plot.getOutlineStroke()); GridData strokeGridData = new GridData(SWT.FILL, SWT.CENTER, true, false); strokeGridData.heightHint = 20; this.strokeCanvas.setLayoutData(strokeGridData); this.selectStroke = new Spinner(general, SWT.BORDER); this.selectStroke.setMinimum(1); this.selectStroke.setMaximum(3); this.selectStroke.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false)); this.selectStroke.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { int w = SWTPlotAppearanceEditor.this.selectStroke.getSelection(); if (w > 0) { SWTPlotAppearanceEditor.this.strokeCanvas.setStroke(new BasicStroke(w)); SWTPlotAppearanceEditor.this.strokeCanvas.redraw(); } } }); // row 2: outline color new Label(general, SWT.NONE).setText(localizationResources.getString("Outline_Paint")); this.outlinePaintCanvas = new SWTPaintCanvas(general, SWT.NONE, SWTUtils.toSwtColor(getDisplay(), plot.getOutlinePaint())); GridData outlineGridData = new GridData(SWT.FILL, SWT.CENTER, true, false); outlineGridData.heightHint = 20; this.outlinePaintCanvas.setLayoutData(outlineGridData); Button selectOutlineColor = new Button(general, SWT.PUSH); selectOutlineColor.setText(localizationResources.getString("Select...")); selectOutlineColor.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false)); selectOutlineColor.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { ColorDialog dlg = new ColorDialog(getShell()); dlg.setText(localizationResources.getString("Outline_Paint")); dlg.setRGB(SWTPlotAppearanceEditor.this.outlinePaintCanvas.getColor().getRGB()); RGB rgb = dlg.open(); if (rgb != null) { SWTPlotAppearanceEditor.this.outlinePaintCanvas.setColor(new Color(getDisplay(), rgb)); } } }); // row 3: background paint new Label(general, SWT.NONE).setText(localizationResources.getString("Background_paint")); this.backgroundPaintCanvas = new SWTPaintCanvas(general, SWT.NONE, SWTUtils.toSwtColor(getDisplay(), plot.getBackgroundPaint())); GridData bgGridData = new GridData(SWT.FILL, SWT.CENTER, true, false); bgGridData.heightHint = 20; this.backgroundPaintCanvas.setLayoutData(bgGridData); Button selectBgPaint = new Button(general, SWT.PUSH); selectBgPaint.setText(localizationResources.getString("Select...")); selectBgPaint.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false)); selectBgPaint.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { ColorDialog dlg = new ColorDialog(getShell()); dlg.setText(localizationResources.getString("Background_paint")); dlg.setRGB(SWTPlotAppearanceEditor.this.backgroundPaintCanvas.getColor().getRGB()); RGB rgb = dlg.open(); if (rgb != null) { SWTPlotAppearanceEditor.this.backgroundPaintCanvas.setColor(new Color(getDisplay(), rgb)); } } }); // row 4: orientation if (plot instanceof CategoryPlot) { this.plotOrientation = ((CategoryPlot) plot).getOrientation(); } else if (plot instanceof XYPlot) { this.plotOrientation = ((XYPlot) plot).getOrientation(); } if (this.plotOrientation != null) { boolean isVertical = this.plotOrientation.equals(PlotOrientation.VERTICAL); int index = isVertical ? ORIENTATION_VERTICAL : ORIENTATION_HORIZONTAL; new Label(general, SWT.NONE).setText(localizationResources.getString("Orientation")); this.orientation = new Combo(general, SWT.DROP_DOWN); this.orientation.setItems(orientationNames); this.orientation.select(index); this.orientation.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, false, 2, 1)); this.orientation.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { switch (SWTPlotAppearanceEditor.this.orientation.getSelectionIndex()) { case ORIENTATION_VERTICAL: SWTPlotAppearanceEditor.this.plotOrientation = PlotOrientation.VERTICAL; break; case ORIENTATION_HORIZONTAL: SWTPlotAppearanceEditor.this.plotOrientation = PlotOrientation.HORIZONTAL; break; default: SWTPlotAppearanceEditor.this.plotOrientation = PlotOrientation.VERTICAL; } } }); } }
From source file:com.rcp.wbw.demo.editor.SWTPlotAppearanceEditor.java
SWTPlotAppearanceEditor(Composite parent, int style, Plot plot) { super(parent, style); FillLayout layout = new FillLayout(); layout.marginHeight = layout.marginWidth = 4; setLayout(layout);/*from w w w . jav a 2 s .c om*/ Group general = new Group(this, SWT.NONE); GridLayout groupLayout = new GridLayout(3, false); groupLayout.marginHeight = groupLayout.marginWidth = 4; general.setLayout(groupLayout); general.setText(localizationResources.getString("General")); // row 1: stroke new Label(general, SWT.NONE).setText(localizationResources.getString("Outline_stroke")); this.strokeCanvas = new SWTStrokeCanvas(general, SWT.NONE); this.strokeCanvas.setStroke(plot.getOutlineStroke()); GridData strokeGridData = new GridData(SWT.FILL, SWT.CENTER, true, false); strokeGridData.heightHint = 20; this.strokeCanvas.setLayoutData(strokeGridData); this.selectStroke = new Spinner(general, SWT.BORDER); this.selectStroke.setMinimum(1); this.selectStroke.setMaximum(3); this.selectStroke.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false)); this.selectStroke.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { int w = SWTPlotAppearanceEditor.this.selectStroke.getSelection(); if (w > 0) { SWTPlotAppearanceEditor.this.strokeCanvas.setStroke(new BasicStroke(w)); SWTPlotAppearanceEditor.this.strokeCanvas.redraw(); } } }); // row 2: outline color new Label(general, SWT.NONE).setText(localizationResources.getString("Outline_Paint")); this.outlinePaintCanvas = new SWTPaintCanvas(general, SWT.NONE, SWTUtils.toSwtColor(getDisplay(), plot.getOutlinePaint())); GridData outlineGridData = new GridData(SWT.FILL, SWT.CENTER, true, false); outlineGridData.heightHint = 20; this.outlinePaintCanvas.setLayoutData(outlineGridData); Button selectOutlineColor = new Button(general, SWT.PUSH); selectOutlineColor.setText(localizationResources.getString("Select...")); selectOutlineColor.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false)); selectOutlineColor.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { ColorDialog dlg = new ColorDialog(getShell()); dlg.setText(localizationResources.getString("Outline_Paint")); dlg.setRGB(SWTPlotAppearanceEditor.this.outlinePaintCanvas.getColor().getRGB()); RGB rgb = dlg.open(); if (rgb != null) { SWTPlotAppearanceEditor.this.outlinePaintCanvas.setColor(new Color(getDisplay(), rgb)); } } }); // row 3: background paint new Label(general, SWT.NONE).setText(localizationResources.getString("Background_paint")); this.backgroundPaintCanvas = new SWTPaintCanvas(general, SWT.NONE, SWTUtils.toSwtColor(getDisplay(), plot.getBackgroundPaint())); GridData bgGridData = new GridData(SWT.FILL, SWT.CENTER, true, false); bgGridData.heightHint = 20; this.backgroundPaintCanvas.setLayoutData(bgGridData); Button selectBgPaint = new Button(general, SWT.PUSH); selectBgPaint.setText(localizationResources.getString("Select...")); selectBgPaint.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false)); selectBgPaint.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { ColorDialog dlg = new ColorDialog(getShell()); dlg.setText(localizationResources.getString("Background_paint")); dlg.setRGB(SWTPlotAppearanceEditor.this.backgroundPaintCanvas.getColor().getRGB()); RGB rgb = dlg.open(); if (rgb != null) { SWTPlotAppearanceEditor.this.backgroundPaintCanvas.setColor(new Color(getDisplay(), rgb)); } } }); // row 4: orientation if (plot instanceof CategoryPlot) { this.plotOrientation = ((CategoryPlot) plot).getOrientation(); } else if (plot instanceof XYPlot) { this.plotOrientation = ((XYPlot) plot).getOrientation(); } if (this.plotOrientation != null) { boolean isVertical = this.plotOrientation.equals(PlotOrientation.VERTICAL); int index = isVertical ? ORIENTATION_VERTICAL : ORIENTATION_HORIZONTAL; new Label(general, SWT.NONE).setText(localizationResources.getString("Orientation")); this.orientation = new Combo(general, SWT.DROP_DOWN); this.orientation.setItems(orientationNames); this.orientation.select(index); this.orientation.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, false, 2, 1)); this.orientation.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { switch (SWTPlotAppearanceEditor.this.orientation.getSelectionIndex()) { case ORIENTATION_VERTICAL: SWTPlotAppearanceEditor.this.plotOrientation = PlotOrientation.VERTICAL; break; case ORIENTATION_HORIZONTAL: SWTPlotAppearanceEditor.this.plotOrientation = PlotOrientation.HORIZONTAL; break; default: SWTPlotAppearanceEditor.this.plotOrientation = PlotOrientation.VERTICAL; } } }); } }
From source file:org.mwc.debrief.dis.views.DisListenerView.java
@Override public void createPartControl(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); GridData gd = new GridData(SWT.FILL, SWT.FILL, true, false); composite.setLayoutData(gd);/*from w w w.j ava 2s.com*/ GridLayout layout = new GridLayout(1, false); layout.marginWidth = 0; layout.marginHeight = 0; composite.setLayout(layout); Composite buttonComposite = new Composite(composite, SWT.NONE); gd = new GridData(SWT.FILL, SWT.FILL, false, false); gd.widthHint = 300; buttonComposite.setLayoutData(gd); layout = new GridLayout(4, false); layout.marginWidth = 5; layout.marginHeight = 5; buttonComposite.setLayout(layout); connectButton = createButton(buttonComposite, "Connect", 2); connectButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { // FIXME connect } }); disconnectButton = createButton(buttonComposite, "Disconnect", 2); disconnectButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { // FIXME disconnect } }); final Link link = new Link(buttonComposite, SWT.NONE); gd = new GridData(SWT.END, SWT.FILL, false, false); gd.horizontalSpan = 4; link.setLayoutData(gd); link.setText("<a href=\"id\">Server Prefs</a>"); link.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(link.getShell(), DisPrefs.ID, null, null); dialog.open(); } }); link.setToolTipText("Dis Preferences"); stopButton = createButton(buttonComposite, "Stop"); stopButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { // FIXME stop } }); pauseButton = createButton(buttonComposite, "Pause"); pauseButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { // FIXME pause } }); resumeButton = createButton(buttonComposite, "Resume"); resumeButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { // FIXME resume } }); playButton = createButton(buttonComposite, "Play"); playButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { // FIXME play } }); stopButton.setEnabled(false); pauseButton.setEnabled(false); resumeButton.setEnabled(false); disconnectButton.setEnabled(false); Label label = new Label(buttonComposite, SWT.NONE); gd = new GridData(SWT.FILL, SWT.FILL, false, false); label.setLayoutData(gd); label.setText("Path to input file:"); Text text = new Text(buttonComposite, SWT.SINGLE | SWT.BORDER); gd = new GridData(SWT.FILL, SWT.FILL, false, false); gd.horizontalSpan = 2; gd.widthHint = 150; text.setLayoutData(gd); final Button browseButton = new Button(buttonComposite, SWT.PUSH); gd = new GridData(SWT.FILL, SWT.FILL, false, false); browseButton.setLayoutData(gd); browseButton.setText("Browse..."); browseButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { FileDialog dialog = new FileDialog(getSite().getShell(), SWT.SINGLE); String value = pathText.getText(); if (value.trim().length() == 0) { value = Platform.getLocation().toOSString(); } dialog.setFilterPath(value); String result = dialog.open(); if (result == null || result.trim().length() == 0) { return; } pathText.setText(result); } }); Composite chartWrapperComposite = new Composite(composite, SWT.BORDER); gd = new GridData(SWT.FILL, SWT.FILL, true, true); chartWrapperComposite.setLayoutData(gd); layout = new GridLayout(1, false); chartWrapperComposite.setLayout(layout); chartComposite = new ChartComposite(chartWrapperComposite, SWT.NONE, null, 400, 600, 300, 200, 1800, 1800, true, true, true, true, true, true) { @Override public void mouseUp(MouseEvent event) { super.mouseUp(event); JFreeChart c = getChart(); if (c != null) { c.setNotify(true); // force redraw } } }; Composite checkboxComposite = new Composite(composite, SWT.NONE); gd = new GridData(SWT.FILL, SWT.FILL, true, false); checkboxComposite.setLayoutData(gd); layout = new GridLayout(2, false); layout.marginWidth = 5; layout.marginHeight = 5; checkboxComposite.setLayout(layout); newPlotButton = new Button(checkboxComposite, SWT.CHECK); gd = new GridData(SWT.FILL, SWT.FILL, true, false); newPlotButton.setLayoutData(gd); newPlotButton.setText("New plot per replication"); newPlotButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { // FIXME new plot ... } }); liveUpdatesButton = new Button(checkboxComposite, SWT.CHECK); gd = new GridData(SWT.FILL, SWT.FILL, true, false); liveUpdatesButton.setLayoutData(gd); liveUpdatesButton.setText("Live updates"); liveUpdatesButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { // FIXME Live updates. } }); liveUpdatesButton.setSelection(true); }
From source file:org.amanzi.awe.charts.ui.ChartsView.java
/** * Creates radio button with the text specified and assigns the layout data * /* w w w . ja v a2s . c om*/ * @param parent parent composite * @param chartType TODO */ private Button createRadioButton(final Composite parent, final String text, final boolean selected, final ChartType chartType) { Button radioButton = new Button(parent, SWT.RADIO); radioButton.setText(text); radioButton.setSelection(selected); GridData layoutData = new GridData(SWT.FILL, SWT.CENTER, true, false); radioButton.setLayoutData(layoutData); radioButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { type = chartType; onItemSelected(); } }); return radioButton; }
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;/*w w w . j a v a2 s . 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) { } }); }