List of usage examples for org.eclipse.swt.widgets Composite setLayout
public void setLayout(Layout layout)
From source file:org.emftrace.quarc.ui.views.RatioView.java
@Override public void createPartControl(Composite parent) { parent.setLayout(new FillLayout()); parentComposite = new Composite(parent, SWT.NONE); parentComposite.setLayout(new FillLayout()); selectionServiceListener = new ISelectionListener() { public void selectionChanged(IWorkbenchPart sourcepart, ISelection selection) { if (sourcepart instanceof QUARCModelElementEditor && ((QUARCModelElementEditor) sourcepart) .getModelElement() instanceof SelectedGoalsPriorities) { AbstractElementGraphBuilder builder = ((AbstractGSSFormPage) ((QUARCModelElementEditor) sourcepart) .getActivePageInstance()).getBuilder(); if (builder instanceof SelectedGoalsGraphBuilder) showChart((SelectedGoalsGraphBuilder) builder); } else if (sourcepart instanceof CompareElementsEditor) { showSpiderChartForElementsToCompare((CompareElementsEditor) sourcepart); }//from ww w .j a va 2 s .c o m else { if (composite != null) composite.dispose(); } } }; getSite().getWorkbenchWindow().getSelectionService().addSelectionListener(selectionServiceListener); }
From source file:MailDialog.java
/** * @see org.eclipse.jface.dialogs.Dialog# * createDialogArea(org.eclipse.swt.widgets.Composite) Here we fill the * center area of the dialog/*from w ww . j a va 2s . co m*/ */ protected Control createDialogArea(Composite parent) { // Create new composite as container final Composite area = new Composite(parent, SWT.NULL); // We use a grid layout and set the size of the margins final GridLayout gridLayout = new GridLayout(); gridLayout.marginWidth = 15; gridLayout.marginHeight = 10; area.setLayout(gridLayout); // Now we create the list widget list = new List(area, SWT.BORDER | SWT.MULTI); // We define a minimum width for the list final GridData gridData = new GridData(); gridData.widthHint = 200; list.setLayoutData(gridData); // We add a SelectionListener list.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { // When the selection changes, we re-validate the list validate(); } }); // We add the initial mail messages to the list for (int i = 0; i < items.length; i++) { list.add(items[i]); } return area; }
From source file:net.sf.smbt.ui.btc.views.AbstractBTCMarketView.java
@Override public void createPartControl(Composite parent) { contributeToActionBars();/*from w ww .ja va2 s .c om*/ Composite container = new Composite(parent, SWT.NONE); container.setLayout(new FillLayout()); container.setLayoutData(GridDataFactory.fillDefaults().create()); addCharts(container); }
From source file:org.eclipse.swt.examples.graphics.ImageTransformTab.java
/** * This method creates the controls specific to the tab. The call to the * createControlPanel method in the super class create the controls that are * defined in the super class./*from w w w. j av a 2s . co m*/ * * @param parent The parent composite */ @Override public void createControlPanel(Composite parent) { Composite comp; GridLayout gridLayout = new GridLayout(2, false); // create spinner for the rotation angle comp = new Composite(parent, SWT.NONE); comp.setLayout(gridLayout); new Label(comp, SWT.CENTER).setText(GraphicsExample.getResourceString("Rotate")); //$NON-NLS-1$ rotateSpinner = new Spinner(comp, SWT.BORDER | SWT.WRAP); GC gc = new GC(rotateSpinner); int width = (int) (gc.getFontMetrics().getAverageCharacterWidth() * 5); gc.dispose(); rotateSpinner.setLayoutData(new GridData(width, SWT.DEFAULT)); rotateSpinner.setSelection(0); rotateSpinner.setMinimum(-720); rotateSpinner.setMaximum(720); rotateSpinner.setIncrement(30); rotateSpinner.addListener(SWT.Selection, event -> example.redraw()); // create a spinner for translating along the x axis comp = new Composite(parent, SWT.NONE); comp.setLayout(gridLayout); new Label(comp, SWT.CENTER).setText(GraphicsExample.getResourceString("xtranslate")); //$NON-NLS-1$ translateSpinnerX = new Spinner(comp, SWT.BORDER | SWT.WRAP); translateSpinnerX.setLayoutData(new GridData(width, SWT.DEFAULT)); translateSpinnerX.setMinimum(-100); translateSpinnerX.setMaximum(500); translateSpinnerX.setSelection(0); translateSpinnerX.setIncrement(10); translateSpinnerX.addListener(SWT.Selection, event -> example.redraw()); // create a spinner for translating along the y axis comp = new Composite(parent, SWT.NONE); comp.setLayout(gridLayout); new Label(comp, SWT.CENTER).setText(GraphicsExample.getResourceString("ytranslate")); //$NON-NLS-1$ translateSpinnerY = new Spinner(comp, SWT.BORDER | SWT.WRAP); translateSpinnerY.setLayoutData(new GridData(width, SWT.DEFAULT)); translateSpinnerY.setMinimum(-100); translateSpinnerY.setMaximum(500); translateSpinnerY.setSelection(0); translateSpinnerY.setIncrement(10); translateSpinnerY.addListener(SWT.Selection, event -> example.redraw()); // create a spinner for scaling along the x axis comp = new Composite(parent, SWT.NONE); comp.setLayout(gridLayout); new Label(comp, SWT.CENTER).setText(GraphicsExample.getResourceString("xscale")); //$NON-NLS-1$ scaleSpinnerX = new Spinner(comp, SWT.BORDER | SWT.WRAP); scaleSpinnerX.setLayoutData(new GridData(width, SWT.DEFAULT)); scaleSpinnerX.setDigits(2); scaleSpinnerX.setMinimum(1); scaleSpinnerX.setMaximum(400); scaleSpinnerX.setSelection(100); scaleSpinnerX.setIncrement(10); scaleSpinnerX.addListener(SWT.Selection, event -> example.redraw()); // create a spinner for scaling along the y axis comp = new Composite(parent, SWT.NONE); comp.setLayout(gridLayout); new Label(comp, SWT.CENTER).setText(GraphicsExample.getResourceString("yscale")); //$NON-NLS-1$ scaleSpinnerY = new Spinner(comp, SWT.BORDER | SWT.WRAP); scaleSpinnerY.setLayoutData(new GridData(width, SWT.DEFAULT)); scaleSpinnerY.setDigits(2); scaleSpinnerY.setMinimum(1); scaleSpinnerY.setMaximum(400); scaleSpinnerY.setSelection(100); scaleSpinnerY.setIncrement(10); scaleSpinnerY.addListener(SWT.Selection, event -> example.redraw()); // create a button for inverting the transform matrix comp = new Composite(parent, SWT.NONE); comp.setLayout(new GridLayout()); invertButton = new Button(comp, SWT.TOGGLE); invertButton.setText(GraphicsExample.getResourceString("Invert")); //$NON-NLS-1$ invertButton.addListener(SWT.Selection, event -> example.redraw()); }
From source file:org.ietr.preesm.mapper.ui.BestCostPlotter.java
public void display(Composite parentComposite) { Composite composite = new Composite(parentComposite, SWT.EMBEDDED | SWT.FILL); parentComposite.setLayout(new FillLayout()); Frame frame = SWT_AWT.new_Frame(composite); frame.add(this.getContentPane()); MouseClickedListener listener = new MouseClickedListener(frame); chartPanel.addChartMouseListener(listener); chartPanel.addMouseMotionListener(listener); chartPanel.addMouseListener(listener); }
From source file:org.emftrace.quarc.ui.views.RatioView.java
/** * @param sourcepart//from ww w . j av a 2 s . co m * a CompareElementsEditorPart * @param parent * the parent Composite * @param showGoalRatings * true == show ratings to goals; false == show ratings to * principles * @param weighted * show weighted ratings * @return a composite with the created chart */ protected Composite buildSpiderChartForRatings(CompareElementsEditor sourcepart, Composite parent, boolean showGoalRatings, boolean weighted) { Composite composite = new Composite(parent, SWT.NONE); composite.setLayout(new FillLayout()); final DefaultCategoryDataset dataset = createSpiderDataset(sourcepart.getElements(), sourcepart.getAccessLayer(), sourcepart.getCacheManager(), showGoalRatings, weighted); JFreeChart chart = createSpiderChart(dataset, weighted); ChartComposite chartComposite = new ChartComposite(composite, SWT.NONE, chart, true); chartComposite.setVisible(true); // composite.layout(); // parent.layout(); return composite; }
From source file:BackupFiles.java
/** * Helper method to create the label/text/button for a directory * //w ww .j a va 2 s.c o m * @param composite * the parent composite * @param label * the text for the label * @return Text */ private Text createFilePanelHelper(Composite composite, String label) { // Create the composite to hold the controls Composite panel = new Composite(composite, SWT.BORDER); panel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); panel.setLayout(new GridLayout(3, false)); // Create the controls new Label(panel, SWT.LEFT).setText(label); Text text = new Text(panel, SWT.BORDER); text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); Button browse = new Button(panel, SWT.PUSH); // Add browsing browse.setText("..."); browse.addSelectionListener(new DirectoryBrowser(text)); // Return the Text that holds the directory return text; }
From source file:org.jfree.experimental.chart.swt.editor.SWTChartEditorDialog.java
/** * Creates a new editor.//w w w . j ava 2s .c o m * * @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.eclipse.swt.examples.graphics.CountDownTab.java
/** * This method creates the controls specific to the tab. The call to the * createControlPanel method in the super class create the controls that are * defined in the super class.//from ww w . j ava 2 s. c o m * * @param parent * The parent composite */ @Override public void createControlPanel(Composite parent) { super.createControlPanel(parent); if (nextNumber < 1) nextNumber = startNumber; // add selection listener to reset nextNumber after // the sequence has completed playItem.addListener(SWT.Selection, event -> { if (nextNumber < 1) nextNumber = startNumber; }); Composite comp; GridLayout gridLayout = new GridLayout(2, false); // create spinner for line width comp = new Composite(parent, SWT.NONE); comp.setLayout(gridLayout); new Label(comp, SWT.CENTER).setText(GraphicsExample.getResourceString("LineWidth")); //$NON-NLS-1$ lineWidthSpinner = new Spinner(comp, SWT.BORDER | SWT.WRAP); lineWidthSpinner.setSelection(20); lineWidthSpinner.setMinimum(1); lineWidthSpinner.setMaximum(100); lineWidthSpinner.addListener(SWT.Selection, event -> { if (!pauseItem.isEnabled()) { example.redraw(); } }); // create drop down combo for antialiasing comp = new Composite(parent, SWT.NONE); comp.setLayout(gridLayout); new Label(comp, SWT.CENTER).setText(GraphicsExample.getResourceString("Antialiasing")); //$NON-NLS-1$ aliasCombo = new Combo(comp, SWT.DROP_DOWN); aliasCombo.add("DEFAULT"); aliasCombo.add("OFF"); aliasCombo.add("ON"); aliasCombo.select(0); antialias = aliasValues[0]; aliasCombo.addListener(SWT.Selection, event -> { antialias = aliasValues[aliasCombo.getSelectionIndex()]; if (!pauseItem.isEnabled()) { example.redraw(); } }); // create drop down combo for line cap comp = new Composite(parent, SWT.NONE); comp.setLayout(gridLayout); new Label(comp, SWT.CENTER).setText(GraphicsExample.getResourceString("LineCap")); //$NON-NLS-1$ lineCapCombo = new Combo(comp, SWT.DROP_DOWN); lineCapCombo.add("FLAT"); lineCapCombo.add("SQUARE"); lineCapCombo.add("ROUND"); lineCapCombo.select(0); lineCap = capValues[0]; lineCapCombo.addListener(SWT.Selection, event -> { lineCap = capValues[lineCapCombo.getSelectionIndex()]; if (!pauseItem.isEnabled()) { example.redraw(); } }); }
From source file:org.qsos.radar.GenerateRadar.java
/** * This class creates a composite which include a checkboxtreeviewer and a button. * It uses 2 listeners: 1 for the checking if the user has checked a box and * another for the 0K button in order to check the validity of the selected elements. * @param parent/*from w ww. j a va2 s. co m*/ * Composite * @return Control */ public Control createCheckboxTree(Composite parent) { numCat = 0; Composite checkTreeComposite = new Composite(parent, SWT.NONE); checkTreeComposite.setLayout(new org.eclipse.swt.layout.FormLayout()); FormData CheckData = new FormData(); final CheckboxTreeViewer checkboxTreeViewer = new CheckboxTreeViewer(checkTreeComposite); checkboxTreeViewer.getTree().setLayoutData(CheckData); CheckData.height = 430; CheckData.width = 320; checkboxTreeViewer.setContentProvider(new SheetCheckContentProvider(window.getCTabFolder())); checkboxTreeViewer.setLabelProvider(new SheetCheckLabelProvider()); checkboxTreeViewer.addFilter(new MyFilter()); IElement elementToInput = (((SheetCTabItem) window.getCTabFolder().getSelection()).getLibQSOS().getSheet() .getRoot()); checkboxTreeViewer.setInput(elementToInput); checkboxTreeViewer.expandToLevel(2); checkboxTreeViewer.addCheckStateListener(new ICheckStateListener() { //This listeners verifies if the user a checked a box and wether it should be appeared checked or not public void checkStateChanged(CheckStateChangedEvent event) { if (event.getChecked()) { if (numCat < 7) { categories[numCat++] = event.getElement(); checkboxTreeViewer.setSubtreeChecked(event.getElement(), true); } else { //System.out.println("Erreur"); //$NON-NLS-1$ checkboxTreeViewer.setChecked(event.getElement(), false); } } else if (!event.getChecked()) { if (((IElement) event.getElement()).getContainer() != null) { boolean state = checkboxTreeViewer .getChecked(((IElement) event.getElement()).getContainer()); if (!state) { checkboxTreeViewer.setSubtreeChecked(event.getElement(), false); numCat--; } else { checkboxTreeViewer.setChecked(event.getElement(), true); } } } } }); checkTreeComposite.pack(); return checkTreeComposite; }