List of usage examples for org.eclipse.swt.widgets Label Label
public Label(Composite parent, int style)
From source file:SampleListViewer.java
public SampleListViewer() { RowLayout rowLayout = new RowLayout(); shell.setLayout(rowLayout);/* w w w . ja v a2s.c o m*/ (new Label(shell, SWT.NULL)).setText("What programming languages are you proficient in? "); init(); addButtons(); shell.pack(); shell.open(); //textUser.forceFocus(); // 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:edu.isistan.carcha.plugin.editors.TraceabilityEditor.java
/** * Creates a page to allow users to create a traceability link. *//* w w w . j a v a 2 s.c o m*/ 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:org.gumtree.vis.plot1d.Plot1D.java
private void createStatusBar() { Composite statusComposite = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(6, false); layout.marginLeft = 6;/* w w w. j a v a2 s . c o m*/ 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 Composite composite = this; panel.addChartMouseListener(new ChartMouseListener() { @Override public void chartMouseMoved(ChartMouseEvent event) { if (event instanceof XYChartMouseEvent) { final String xString = String.format("%.2f", ((XYChartMouseEvent) event).getX()); final String yString = String.format("%.2f", ((XYChartMouseEvent) event).getY()); // panel.requestFocus(); Display.getDefault().asyncExec(new Runnable() { @Override public void run() { xText.setText(xString); yText.setText(yString); if (!composite.isFocusControl()) { composite.setFocus(); } } }); } } @Override public void chartMouseClicked(ChartMouseEvent event) { Display.getDefault().asyncExec(new Runnable() { @Override public void run() { if (!composite.isFocusControl()) { composite.setFocus(); } } }); } }); }
From source file:ShowPrefs.java
/** * Change the description label//from www .j av a 2 s . c om */ protected Label createDescriptionLabel(Composite parent) { Label label = null; String description = getDescription(); if (description != null) { // Upper case the description description = description.toUpperCase(); // Right-align the label label = new Label(parent, SWT.RIGHT); label.setText(description); } return label; }
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;/* w w w . j a v a 2 s . c o m*/ 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:gov.redhawk.statistics.ui.views.StatisticsView.java
/** * This is a callback that will allow us to create the viewer and initialize it. *//*from w w w. ja va 2 s. c o m*/ @Override public void createPartControl(Composite comp) { parent = comp; parent.setLayout(GridLayoutFactory.fillDefaults().margins(10, 10).numColumns(1).create()); // Custom Action for the View's Menu CustomAction customAction = new CustomAction() { @Override public void run() { SettingsDialog dialog = new SettingsDialog(parent.getShell(), datalist.length, curIndex, numBars); dialog.create(); if (dialog.open() == Window.OK) { numBars = dialog.getNumBars(); curIndex = dialog.getSelectedIndex(); refreshJob.schedule(); } } }; customAction.setText("Settings"); getViewSite().getActionBars().getMenuManager().add(customAction); // creation of chart composite and selection of associated options Composite chartComposite = new Composite(parent, SWT.EMBEDDED); chartComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create()); chart = ChartFactory.createXYBarChart(null, null, false, null, dataSet, PlotOrientation.VERTICAL, false, true, false); org.eclipse.swt.graphics.Color backgroundColor = chartComposite.getBackground(); chart.setBackgroundPaint( new Color(backgroundColor.getRed(), backgroundColor.getGreen(), backgroundColor.getBlue())); chart.getXYPlot().setBackgroundPaint(ChartColor.WHITE); Frame chartFrame = SWT_AWT.new_Frame(chartComposite); chartFrame.setBackground( new Color(backgroundColor.getRed(), backgroundColor.getGreen(), backgroundColor.getBlue())); chartFrame.setLayout(new GridLayout()); ChartPanel jFreeChartPanel = new ChartPanel(chart); chartFrame.add(jFreeChartPanel); ClusteredXYBarRenderer renderer = new ClusteredXYBarRenderer(); renderer.setBarPainter(new StandardXYBarPainter()); renderer.setMargin(0.05); renderer.setShadowVisible(false); renderer.setBaseItemLabelsVisible(true); renderer.setBaseItemLabelGenerator(new XYItemLabelGenerator() { @Override public String generateLabel(XYDataset dataset, int series, int item) { return String.valueOf((int) (dataset.getYValue(series, item))); } }); renderer.setBasePaint(new Color(139, 0, 0)); renderer.setLegendItemLabelGenerator(new XYSeriesLabelGenerator() { @Override public String generateLabel(XYDataset ds, int i) { if (ds.getSeriesCount() == 2) { if (i == 0) { return "Real"; } else if (i == 1) { return "Imaginary"; } else { return "Complex"; } } else if (ds.getSeriesCount() > 1) { return "Dimension " + i; } return null; } }); chart.getXYPlot().setRenderer(renderer); dataSet.addChangeListener(new DatasetChangeListener() { @Override public void datasetChanged(DatasetChangeEvent event) { chart.getPlot().datasetChanged(event); } }); // creation of the statistics composite FormToolkit toolkit = new FormToolkit(parent.getDisplay()); section = toolkit.createSection(parent, Section.DESCRIPTION | Section.NO_TITLE | Section.CLIENT_INDENT); section.setBackground(parent.getBackground()); section.setDescription(""); section.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); // layout within parent // Composite for storing the data Composite composite = toolkit.createComposite(section, SWT.WRAP); composite.setBackground(parent.getBackground()); composite.setLayout(GridLayoutFactory.fillDefaults().margins(10, 10).numColumns(4).create()); composite.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); // layout within parent toolkit.paintBordersFor(composite); section.setClient(composite); for (int j = 0; j < STAT_PROPS.length; j++) { Label label = new Label(composite, SWT.None); label.setText(STAT_PROPS[j] + ":"); labels[j] = new Label(composite, SWT.None); labels[j].setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); } }
From source file:com.android.ddmuilib.net.NetworkPanel.java
/** * Create header panel with configuration options. *//*from w w w .j av a 2 s. co 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:org.ewhoxford.swt.bloodpressure.ui.MeasurePageTab.java
/** * Creates the control widgets./*from w w w. j av a 2s.c o m*/ */ void createControlWidgets() { /* Controls the type of FillLayout */ Group bpGroup = new Group(controlGroup, SWT.NONE); bpGroup.setText(BPMainWindow.getResourceString("BP_and_HR")); bpGroup.setLayout(new GridLayout(2, true)); bpGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); messageLabel = new Label(controlGroup, SWT.NONE); messageLabel.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false)); messageLabel.setText(""); Label label1 = new Label(bpGroup, SWT.NONE); label1.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false)); label1.setText("SBP"); sbpTextbox = new Text(bpGroup, SWT.SINGLE | SWT.LEAD | SWT.BORDER); sbpTextbox.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); sbpTextbox.setText("0"); sbpTextbox.setEditable(false); Label label2 = new Label(bpGroup, SWT.NONE); label2.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false)); label2.setText("DBP"); dbpTextbox = new Text(bpGroup, SWT.SINGLE | SWT.LEAD | SWT.BORDER); dbpTextbox.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); dbpTextbox.setText("0"); dbpTextbox.setEditable(false); Label label3 = new Label(bpGroup, SWT.NONE); label3.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false)); label3.setText("HR"); hrTextbox = new Text(bpGroup, SWT.SINGLE | SWT.LEAD | SWT.BORDER); hrTextbox.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); hrTextbox.setText("0"); hrTextbox.setEditable(false); Label label5 = new Label(controlGroup, SWT.NONE); label5.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false)); label5.setText(""); Label label4 = new Label(controlGroup, SWT.NONE); label4.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false)); label4.setText("Notes:"); notesText = new Text(controlGroup, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL); notesText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); notesText.setText("Comment on the blood pressure"); notesText.computeSize(100, 500); notesText.setEnabled(true); final Group optionGroup = new Group(controlGroup, SWT.NONE); optionGroup.setText(BPMainWindow.getResourceString("Options")); optionGroup.setLayout(new GridLayout()); optionGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); newMeasure = new Button(optionGroup, SWT.BUTTON1); newMeasure.setText("New Measure"); newMeasure.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); newMeasure.setSelection(true); newMeasure.addSelectionListener(selectionListener); createCSV = new Button(optionGroup, SWT.CHECK); createCSV.setText("create CSV File"); createCSV.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); saveButton = new Button(optionGroup, SWT.BUTTON1); saveButton.setText("Save"); saveButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); saveButton.setEnabled(false); saveButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { String savedFileName = ""; String notes = ""; if (notesText.getText().length() != 0) { notes = notesText.getText(); } Long time = System.currentTimeMillis(); if (createCSV.getSelection()) { try { savedFileName = FileManager.saveFile(bloodPressureValue, arrayPressure, arrayTime, time, notes); } catch (Exception e1) { // TODO Auto-generated catch block e1.printStackTrace(); } finally { addNewMeasureAndFile(savedFileName, bloodPressureValue, notes, time); } } else { addNewMeasureAndFile(savedFileName, bloodPressureValue, notes, time); if (createCSV.getSelection()) { MessageDialog.openInformation(optionGroup.getShell(), "Saved", BPMainWindow.getResourceString("alert_dialog_data_saved_to_database_and_csv")); } else { MessageDialog.openInformation(optionGroup.getShell(), "Saved", BPMainWindow.getResourceString("alert_dialog_data_saved_to_database")); } } } }); // #### End of Set up click listeners for all the buttons }
From source file:org.eclipse.swt.examples.texteditor.TextEditor.java
public Shell open(Display display) { this.display = display; initResources();// w w w . j a va 2s. c om shell = new Shell(display); shell.setText(getResourceString("Window_title")); //$NON-NLS-1$ styledText = new StyledText(shell, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); createMenuBar(); createToolBar(); createPopup(); statusBar = new Label(shell, SWT.NONE); installListeners(); updateToolBar(); updateStatusBar(); shell.setSize(1000, 700); shell.open(); return shell; }
From source file:AddressBook.java
/** * Creates the contents of the page//w ww .jav a 2 s. c o 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); }