List of usage examples for org.eclipse.swt.widgets Composite Composite
public Composite(Composite parent, int style)
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 v a2s .c om*/ 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:com.android.ddmuilib.SysinfoPanel.java
/** * Create our controls for the UI panel. *//*from w w w. jav a 2 s . co m*/ @Override protected Control createControl(Composite parent) { Composite top = new Composite(parent, SWT.NONE); top.setLayout(new GridLayout(1, false)); top.setLayoutData(new GridData(GridData.FILL_BOTH)); Composite buttons = new Composite(top, SWT.NONE); buttons.setLayout(new RowLayout()); mDisplayMode = new Combo(buttons, SWT.PUSH); for (String mode : CAPTIONS) { mDisplayMode.add(mode); } mDisplayMode.select(mMode); mDisplayMode.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { mMode = mDisplayMode.getSelectionIndex(); if (mDataFile != null) { generateDataset(mDataFile); } else if (getCurrentDevice() != null) { loadFromDevice(); } } }); final Button loadButton = new Button(buttons, SWT.PUSH); loadButton.setText("Load from File"); loadButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { FileDialog fileDialog = new FileDialog(loadButton.getShell(), SWT.OPEN); fileDialog.setText("Load bugreport"); String filename = fileDialog.open(); if (filename != null) { mDataFile = new File(filename); generateDataset(mDataFile); } } }); mFetchButton = new Button(buttons, SWT.PUSH); mFetchButton.setText("Update from Device"); mFetchButton.setEnabled(false); mFetchButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { loadFromDevice(); } }); mLabel = new Label(top, SWT.NONE); mLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); mDataset = new DefaultPieDataset(); JFreeChart chart = ChartFactory.createPieChart("", mDataset, false /* legend */, true/* tooltips */, false /* urls */); ChartComposite chartComposite = new ChartComposite(top, SWT.BORDER, chart, ChartComposite.DEFAULT_HEIGHT, ChartComposite.DEFAULT_HEIGHT, ChartComposite.DEFAULT_MINIMUM_DRAW_WIDTH, ChartComposite.DEFAULT_MINIMUM_DRAW_HEIGHT, 3000, // max draw width. We don't want it to zoom, so we put a big number 3000, // max draw height. We don't want it to zoom, so we put a big number true, // off-screen buffer true, // properties true, // save true, // print false, // zoom true); chartComposite.setLayoutData(new GridData(GridData.FILL_BOTH)); return top; }
From source file:org.gumtree.vis.hist2d.Hist2D.java
private void createStatusBar() { Composite statusComposite = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(6, false); layout.marginLeft = 6;/*from w ww. j a v a 2 s.com*/ layout.marginRight = 6; layout.marginTop = 1; layout.marginBottom = 1; layout.horizontalSpacing = 3; layout.verticalSpacing = 1; statusComposite.setLayout(layout); GridData gridData = new GridData(SWT.FILL); gridData.grabExcessHorizontalSpace = true; gridData.grabExcessVerticalSpace = false; statusComposite.setLayoutData(gridData); final Label xLabel = new Label(statusComposite, SWT.NONE); xLabel.setText("X:"); gridData = new GridData(SWT.DEFAULT); xLabel.setLayoutData(gridData); // GridDataFactory.swtDefaults().applyTo(xLabel); final Text xText = new Text(statusComposite, SWT.BORDER); gridData = new GridData(SWT.FILL); gridData.widthHint = 50; xText.setLayoutData(gridData); // GridDataFactory.fillDefaults().hint(50, SWT.DEFAULT).applyTo(xText); xText.setEditable(false); final Label yLabel = new Label(statusComposite, SWT.NONE); yLabel.setText("Y:"); gridData = new GridData(SWT.DEFAULT); yLabel.setLayoutData(gridData); // GridDataFactory.swtDefaults().applyTo(yLabel); final Text yText = new Text(statusComposite, SWT.BORDER); gridData = new GridData(SWT.FILL); gridData.widthHint = 50; yText.setLayoutData(gridData); // GridDataFactory.fillDefaults().hint(50, SWT.DEFAULT).applyTo(yText); yText.setEditable(false); final Label zLabel = new Label(statusComposite, SWT.NONE); zLabel.setText("Z:"); gridData = new GridData(SWT.DEFAULT); zLabel.setLayoutData(gridData); // GridDataFactory.swtDefaults().applyTo(zLabel); final Text zText = new Text(statusComposite, SWT.BORDER); gridData = new GridData(SWT.FILL); gridData.widthHint = 50; zText.setLayoutData(gridData); // GridDataFactory.fillDefaults().hint(50, SWT.DEFAULT).applyTo(zText); zText.setEditable(false); final Composite composite = this; panel.addChartMouseListener(new ChartMouseListener() { @Override public void chartMouseMoved(ChartMouseEvent event) { if (event instanceof XYZChartMouseEvent) { final String xString = String.format("%.2f", ((XYZChartMouseEvent) event).getX()); final String yString = String.format("%.2f", ((XYZChartMouseEvent) event).getY()); final String zString = String.format("%.2f", ((XYZChartMouseEvent) event).getZ()); panel.requestFocus(); Display.getDefault().asyncExec(new Runnable() { @Override public void run() { xText.setText(xString); yText.setText(yString); zText.setText(zString); if (!composite.isFocusControl()) { composite.setFocus(); } } }); } } @Override public void chartMouseClicked(ChartMouseEvent event) { // TODO Auto-generated method stub } }); }
From source file:com.android.ddmuilib.net.NetworkPanel.java
@Override protected Control createControl(Composite parent) { mDisplay = parent.getDisplay();/*from w w w . ja va 2 s . c o m*/ mPanel = new Composite(parent, SWT.NONE); final FormLayout formLayout = new FormLayout(); mPanel.setLayout(formLayout); createHeader(); createChart(); createTable(); return mPanel; }
From source file:com.android.ddmuilib.net.NetworkPanel.java
/** * Create header panel with configuration options. *///from w w w . j ava2 s. c o m private void createHeader() { mHeader = new Composite(mPanel, SWT.NONE); final RowLayout layout = new RowLayout(); layout.center = true; mHeader.setLayout(layout); mSpeedLabel = new Label(mHeader, SWT.NONE); mSpeedLabel.setText("Speed:"); mSpeedCombo = new Combo(mHeader, SWT.PUSH); mSpeedCombo.add("Fast (100ms)"); mSpeedCombo.add("Medium (250ms)"); mSpeedCombo.add("Slow (500ms)"); mSpeedCombo.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { updateSpeed(); } }); mSpeedCombo.select(1); updateSpeed(); mRunningButton = new Button(mHeader, SWT.PUSH); mRunningButton.setText("Start"); mRunningButton.setEnabled(false); mRunningButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { final boolean alreadyRunning = mSampleThread != null; updateRunning(!alreadyRunning); } }); mResetButton = new Button(mHeader, SWT.PUSH); mResetButton.setText("Reset"); mResetButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { clearTrackedItems(); } }); final FormData data = new FormData(); data.top = new FormAttachment(0); data.left = new FormAttachment(0); data.right = new FormAttachment(100); mHeader.setLayoutData(data); }
From source file:ClassFigure.java
protected Control createContents(Composite parent) { Composite composite = new Composite(parent, SWT.NULL); composite.setLayout(new FillLayout()); canvas = new Canvas(composite, SWT.NULL); canvas.setBackground(getShell().getDisplay().getSystemColor(SWT.COLOR_WHITE)); LightweightSystem lws = new LightweightSystem(canvas); contents = new Figure(); xyLayout = new XYLayout(); contents.setLayoutManager(xyLayout); lws.setContents(contents);/*from w w w .j a v a 2 s .c o m*/ showClass(this.getClass()); // Creates tool bar items. getToolBarManager().add(new Action("Set class ...") { public void run() { InputDialog dialog = new InputDialog(getShell(), "", "Please enter the class name", "", null); if (dialog.open() != Dialog.OK) return; contents.removeAll(); Class cls = null; try { cls = Class.forName(dialog.getValue()); } catch (ClassNotFoundException e) { e.printStackTrace(); } if (cls != null) { showClass(cls); } } }); getToolBarManager().update(true); return composite; }
From source file:org.eclipse.swt.examples.paint.PaintExample.java
/** * Creates the GUI./*w ww. ja v a 2 s. c o m*/ */ public void createGUI(Composite parent) { GridLayout gridLayout; GridData gridData; /*** Create principal GUI layout elements ***/ Composite displayArea = new Composite(parent, SWT.NONE); gridLayout = new GridLayout(); gridLayout.numColumns = 1; displayArea.setLayout(gridLayout); // Creating these elements here avoids the need to instantiate the GUI elements // in strict layout order. The natural layout ordering is an artifact of using // SWT layouts, but unfortunately it is not the same order as that required to // instantiate all of the non-GUI application elements to satisfy referential // dependencies. It is possible to reorder the initialization to some extent, but // this can be very tedious. // paint canvas final Canvas paintCanvas = new Canvas(displayArea, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.NO_REDRAW_RESIZE | SWT.NO_BACKGROUND); gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL); paintCanvas.setLayoutData(gridData); paintCanvas.setBackground(paintColorWhite); // color selector frame final Composite colorFrame = new Composite(displayArea, SWT.NONE); gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL); colorFrame.setLayoutData(gridData); // tool settings frame final Composite toolSettingsFrame = new Composite(displayArea, SWT.NONE); gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL); toolSettingsFrame.setLayoutData(gridData); // status text final Text statusText = new Text(displayArea, SWT.BORDER | SWT.SINGLE | SWT.READ_ONLY); gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL); statusText.setLayoutData(gridData); /*** Create the remaining application elements inside the principal GUI layout elements ***/ // paintSurface paintSurface = new PaintSurface(paintCanvas, statusText, paintColorWhite); // finish initializing the tool data tools[Pencil_tool].data = new PencilTool(toolSettings, paintSurface); tools[Airbrush_tool].data = new AirbrushTool(toolSettings, paintSurface); tools[Line_tool].data = new LineTool(toolSettings, paintSurface); tools[PolyLine_tool].data = new PolyLineTool(toolSettings, paintSurface); tools[Rectangle_tool].data = new RectangleTool(toolSettings, paintSurface); tools[RoundedRectangle_tool].data = new RoundedRectangleTool(toolSettings, paintSurface); tools[Ellipse_tool].data = new EllipseTool(toolSettings, paintSurface); tools[Text_tool].data = new TextTool(toolSettings, paintSurface); // colorFrame gridLayout = new GridLayout(); gridLayout.numColumns = 3; gridLayout.marginHeight = 0; gridLayout.marginWidth = 0; colorFrame.setLayout(gridLayout); // activeForegroundColorCanvas, activeBackgroundColorCanvas activeForegroundColorCanvas = new Canvas(colorFrame, SWT.BORDER); gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL); gridData.heightHint = 24; gridData.widthHint = 24; activeForegroundColorCanvas.setLayoutData(gridData); activeBackgroundColorCanvas = new Canvas(colorFrame, SWT.BORDER); gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL); gridData.heightHint = 24; gridData.widthHint = 24; activeBackgroundColorCanvas.setLayoutData(gridData); // paletteCanvas final Canvas paletteCanvas = new Canvas(colorFrame, SWT.BORDER | SWT.NO_BACKGROUND); gridData = new GridData(GridData.FILL_HORIZONTAL); gridData.heightHint = 24; paletteCanvas.setLayoutData(gridData); paletteCanvas.addListener(SWT.MouseDown, new Listener() { @Override public void handleEvent(Event e) { Rectangle bounds = paletteCanvas.getClientArea(); Color color = getColorAt(bounds, e.x, e.y); if (e.button == 1) setForegroundColor(color); else setBackgroundColor(color); } private Color getColorAt(Rectangle bounds, int x, int y) { if (bounds.height <= 1 && bounds.width <= 1) return paintColorWhite; final int row = (y - bounds.y) * numPaletteRows / bounds.height; final int col = (x - bounds.x) * numPaletteCols / bounds.width; return paintColors[Math.min(Math.max(row * numPaletteCols + col, 0), paintColors.length - 1)]; } }); Listener refreshListener = e -> { if (e.gc == null) return; Rectangle bounds = paletteCanvas.getClientArea(); for (int row = 0; row < numPaletteRows; ++row) { for (int col = 0; col < numPaletteCols; ++col) { final int x = bounds.width * col / numPaletteCols; final int y = bounds.height * row / numPaletteRows; final int width = Math.max(bounds.width * (col + 1) / numPaletteCols - x, 1); final int height = Math.max(bounds.height * (row + 1) / numPaletteRows - y, 1); e.gc.setBackground(paintColors[row * numPaletteCols + col]); e.gc.fillRectangle(bounds.x + x, bounds.y + y, width, height); } } }; paletteCanvas.addListener(SWT.Resize, refreshListener); paletteCanvas.addListener(SWT.Paint, refreshListener); //paletteCanvas.redraw(); // toolSettingsFrame gridLayout = new GridLayout(); gridLayout.numColumns = 4; gridLayout.marginHeight = 0; gridLayout.marginWidth = 0; toolSettingsFrame.setLayout(gridLayout); Label label = new Label(toolSettingsFrame, SWT.NONE); label.setText(getResourceString("settings.AirbrushRadius.text")); final Scale airbrushRadiusScale = new Scale(toolSettingsFrame, SWT.HORIZONTAL); airbrushRadiusScale.setMinimum(5); airbrushRadiusScale.setMaximum(50); airbrushRadiusScale.setSelection(toolSettings.airbrushRadius); airbrushRadiusScale.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL)); airbrushRadiusScale.addSelectionListener(widgetSelectedAdapter(e -> { toolSettings.airbrushRadius = airbrushRadiusScale.getSelection(); updateToolSettings(); })); label = new Label(toolSettingsFrame, SWT.NONE); label.setText(getResourceString("settings.AirbrushIntensity.text")); final Scale airbrushIntensityScale = new Scale(toolSettingsFrame, SWT.HORIZONTAL); airbrushIntensityScale.setMinimum(1); airbrushIntensityScale.setMaximum(100); airbrushIntensityScale.setSelection(toolSettings.airbrushIntensity); airbrushIntensityScale.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL)); airbrushIntensityScale.addSelectionListener(widgetSelectedAdapter(e -> { toolSettings.airbrushIntensity = airbrushIntensityScale.getSelection(); updateToolSettings(); })); }
From source file:AddressBook.java
/** * Creates the contents of the page//from w w w . j ava 2 s.co m * * @param parent * the parent composite */ public void createControl(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); composite.setLayout(new GridLayout(2, false)); // Create the label and text box to hold email address new Label(composite, SWT.LEFT).setText("E-mail Address:"); final Text ea = new Text(composite, SWT.BORDER); ea.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); // Add handler to update e-mail based on input ea.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent event) { email = ea.getText(); setPageComplete(email.length() > 0); } }); setControl(composite); }
From source file:AddressBookDemo.java
public void createControl(Composite parent) { Composite container = new Composite(parent, SWT.NULL); GridLayout layout = new GridLayout(); container.setLayout(layout);/*from w w w .j a va2 s .co m*/ layout.numColumns = 2; layout.verticalSpacing = 9; Label label = new Label(container, SWT.NULL); label.setText("&Address Line 1:"); addressLine1Text = new Text(container, SWT.BORDER | SWT.MULTI); GridData gd = new GridData(GridData.FILL_HORIZONTAL); addressLine1Text.setLayoutData(gd); addressLine1Text.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { dialogChanged(); } }); label = new Label(container, SWT.NULL); label.setText("&Address Line 2:"); addressLine2Text = new Text(container, SWT.BORDER | SWT.SINGLE); gd = new GridData(GridData.FILL_HORIZONTAL); addressLine2Text.setLayoutData(gd); addressLine2Text.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { dialogChanged(); } }); label = new Label(container, SWT.NULL); label.setText("&City:"); cityText = new Text(container, SWT.BORDER | SWT.SINGLE); gd = new GridData(GridData.FILL_HORIZONTAL); cityText.setLayoutData(gd); label = new Label(container, SWT.NULL); label.setText("&State:"); stateCombo = new Combo(container, SWT.BORDER | SWT.SINGLE); gd = new GridData(GridData.FILL_HORIZONTAL); stateCombo.setLayoutData(gd); stateCombo.setItems(STATES); label = new Label(container, SWT.NULL); label.setText("&Zip Code:"); zipCodeText = new Text(container, SWT.BORDER | SWT.SINGLE); gd = new GridData(GridData.FILL_HORIZONTAL); zipCodeText.setLayoutData(gd); // dialogChanged(); setControl(container); }
From source file:org.eclipse.swt.examples.ole.win32.OLEExample.java
public void open(Display display) { Shell shell = new Shell(display); shell.setText("OLE Example"); shell.setLayout(new FillLayout()); Composite parent = new Composite(shell, SWT.NONE); parent.setLayout(new GridLayout(4, true)); Composite buttons = new Composite(parent, SWT.NONE); buttons.setLayout(new GridLayout()); GridData gridData = new GridData(SWT.BEGINNING, SWT.FILL, false, false); buttons.setLayoutData(gridData);// ww w . ja v a 2 s .c o m Composite displayArea = new Composite(parent, SWT.BORDER); displayArea.setLayout(new FillLayout()); displayArea.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1)); Button excelButton = new Button(buttons, SWT.RADIO); excelButton.setText("New Excel Sheet"); excelButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> { if (((Button) e.widget).getSelection()) newClientSite("Excel.Sheet"); })); Button mediaPlayerButton = new Button(buttons, SWT.RADIO); mediaPlayerButton.setText("New MPlayer"); mediaPlayerButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> { if (((Button) e.widget).getSelection()) newClientSite("MPlayer"); })); Button powerPointButton = new Button(buttons, SWT.RADIO); powerPointButton.setText("New PowerPoint Slide"); powerPointButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> { if (((Button) e.widget).getSelection()) newClientSite("PowerPoint.Slide"); })); Button wordButton = new Button(buttons, SWT.RADIO); wordButton.setText("New Word Document"); wordButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> { if (((Button) e.widget).getSelection()) newClientSite("Word.Document"); })); new Label(buttons, SWT.NONE); Button openButton = new Button(buttons, SWT.RADIO); openButton.setText("Open file..."); openButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> { if (((Button) e.widget).getSelection()) fileOpen(); })); new Label(buttons, SWT.NONE); closeButton = new Button(buttons, SWT.RADIO); closeButton.setText("Close file"); closeButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> { if (((Button) e.widget).getSelection()) disposeClient(); })); closeButton.setSelection(true); oleFrame = new OleFrame(displayArea, SWT.NONE); addFileMenu(oleFrame); shell.setSize(800, 600); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } }