List of usage examples for org.eclipse.swt.widgets Label setText
public void setText(String text)
From source file:ShowPrograms.java
/** * Creates the main window's contents/*from ww w . jav a2s . c o m*/ * * @param shell the main window */ private void createContents(Shell shell) { shell.setLayout(new GridLayout(2, false)); // Create the label and combo for the extensions new Label(shell, SWT.NONE).setText("Extension:"); Combo extensionsCombo = new Combo(shell, SWT.BORDER | SWT.READ_ONLY); extensionsCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); // Create the label and the new Label(shell, SWT.NONE).setText("Program:"); final Label programName = new Label(shell, SWT.NONE); programName.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); // Fill the combo with the extensions on the system String[] extensions = Program.getExtensions(); for (int i = 0, n = extensions.length; i < n; i++) { extensionsCombo.add(extensions[i]); } // Add a handler to get the selected extension, look up the associated // program, and display the program's name extensionsCombo.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { Combo combo = (Combo) event.widget; // Get the program for the extension Program program = Program.findProgram(combo.getText()); // Display the program's name programName.setText(program == null ? "(None)" : program.getName()); } }); // Create a list box to show all the programs on the system List allPrograms = new List(shell, SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); GridData data = new GridData(GridData.FILL_BOTH); data.horizontalSpan = 2; allPrograms.setLayoutData(data); // Put all the known programs into the list box Program[] programs = Program.getPrograms(); for (int i = 0, n = programs.length; i < n; i++) { String name = programs[i].getName(); allPrograms.add(name); allPrograms.setData(name, programs[i]); } // Add a field for a data file new Label(shell, SWT.NONE).setText("Data File:"); final Text dataFile = new Text(shell, SWT.BORDER); dataFile.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); // Double-clicking a program in the list launches the program allPrograms.addMouseListener(new MouseAdapter() { public void mouseDoubleClick(MouseEvent event) { List list = (List) event.widget; if (list.getSelectionCount() > 0) { String programName = list.getSelection()[0]; Program program = (Program) list.getData(programName); program.execute(dataFile.getText()); } } }); // Let them use launch instead of execute Button launch = new Button(shell, SWT.PUSH); data = new GridData(GridData.FILL_HORIZONTAL); data.horizontalSpan = 2; launch.setLayoutData(data); launch.setText("Use Program.launch() instead of Program.execute()"); launch.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { // Use launch Program.launch(dataFile.getText()); } }); }
From source file:code.google.gclogviewer.GCLogViewer.java
private void createShell() { shell = new Shell(SWT.SHELL_TRIM | SWT.APPLICATION_MODAL); shell.setText(SHELL_TITLE);//w w w . j av a 2s.c om shell.setBackground(new Color(Display.getCurrent(), 255, 255, 255)); shell.setMaximized(false); shell.setToolTipText( "A free open source tool to visualize data produced by the Java VM options -Xloggc:<file>"); Monitor primary = shell.getDisplay().getPrimaryMonitor(); Rectangle bounds = primary.getBounds(); shell.setSize(new Point(bounds.width - 100, bounds.height - 100)); Rectangle rect = shell.getBounds(); int x = bounds.x + (bounds.width - rect.width) / 2; int y = bounds.y + (bounds.height - rect.height) / 2; shell.setLocation(x, y); GridLayout layout = new GridLayout(); layout.numColumns = 1; shell.setLayout(layout); menuBar = new Menu(shell, SWT.BAR); fileMenuHeader = new MenuItem(menuBar, SWT.CASCADE); fileMenuHeader.setText("&File"); toolsMenuItem = new MenuItem(menuBar, SWT.CASCADE); toolsMenuItem.setText("&Tools"); backToHomeMenuItem = new MenuItem(menuBar, SWT.CASCADE); backToHomeMenuItem.setText("Back To Home"); backToHomeMenuItem.setEnabled(false); backToHomeMenuItem.addSelectionListener(new BackToHomeListener()); exitMenuItem = new MenuItem(menuBar, SWT.CASCADE); exitMenuItem.setText("&Exit"); exitMenuItem.addSelectionListener(new ExitListener()); fileMenu = new Menu(shell, SWT.DROP_DOWN); fileMenuHeader.setMenu(fileMenu); fileOpenMenuItem = new MenuItem(fileMenu, SWT.PUSH); fileOpenMenuItem.setText("&Open log file..."); fileOpenMenuItem.addSelectionListener(new OpenFileListener()); toolsMenu = new Menu(shell, SWT.DROP_DOWN); toolsMenuItem.setMenu(toolsMenu); compareLogMenuItem = new MenuItem(toolsMenu, SWT.PUSH); compareLogMenuItem.setText("Compare GC Log"); compareLogMenuItem.setEnabled(false); compareLogMenuItem.addSelectionListener(new CompareLogListener()); memoryLeakDetectionMenuItem = new MenuItem(toolsMenu, SWT.PUSH); memoryLeakDetectionMenuItem.setText("Memory Leak Detection"); memoryLeakDetectionMenuItem.setEnabled(false); memoryLeakDetectionMenuItem.addSelectionListener(new MemoryLeakDetectionListener()); gcTuningMenuItem = new MenuItem(toolsMenu, SWT.PUSH); gcTuningMenuItem.setText("Data for GC Tuning"); gcTuningMenuItem.setEnabled(false); gcTuningMenuItem.addSelectionListener(new DataForGCTuningListener()); exportToPDFMenuItem = new MenuItem(toolsMenu, SWT.PUSH); exportToPDFMenuItem.setText("Export to PDF"); exportToPDFMenuItem.setEnabled(false); shell.setMenuBar(menuBar); createSummary(); createGCTrendGroup(); createMemoryTrendGroup(); createProgressBar(); // Info Grid GridData infoGrid = new GridData(GridData.FILL_BOTH); final Label runtimeLabel = new Label(summary, SWT.NONE); runtimeLabel.setText("Run time: "); runtimeLabel.setLayoutData(infoGrid); runtimedataLabel = new Label(summary, SWT.NONE); runtimedataLabel.setText("xxx seconds"); runtimedataLabel.setLayoutData(infoGrid); final Label gctypeLabel = new Label(summary, SWT.NONE); gctypeLabel.setText("GC Type: "); gctypeLabel.setLayoutData(infoGrid); gctypedataLabel = new Label(summary, SWT.NONE); gctypedataLabel.setText("xxx"); gctypedataLabel.setLayoutData(infoGrid); final Label throughputLabel = new Label(summary, SWT.NONE); throughputLabel.setText("Throughput: "); throughputLabel.setLayoutData(infoGrid); throughputdataLabel = new Label(summary, SWT.NONE); throughputdataLabel.setText("xx%"); throughputdataLabel.setLayoutData(infoGrid); final Label emptyLabel = new Label(summary, SWT.NONE); emptyLabel.setText(" "); emptyLabel.setLayoutData(infoGrid); final Label emptyDataLabel = new Label(summary, SWT.NONE); emptyDataLabel.setText(" "); emptyDataLabel.setLayoutData(infoGrid); // YGC Grid GridData ygcInfoGrid = new GridData(GridData.FILL_BOTH); final Label ygcLabel = new Label(summary, SWT.NONE); ygcLabel.setText("YGC: "); ygcLabel.setLayoutData(ygcInfoGrid); ygcDataLabel = new Label(summary, SWT.NONE); ygcDataLabel.setText("xxx"); ygcDataLabel.setLayoutData(ygcInfoGrid); final Label ygctLabel = new Label(summary, SWT.NONE); ygctLabel.setText("YGCT: "); ygctLabel.setLayoutData(ygcInfoGrid); ygctDataLabel = new Label(summary, SWT.NONE); ygctDataLabel.setText("xxx seconds"); ygctDataLabel.setLayoutData(ygcInfoGrid); final Label avgYGCTLabel = new Label(summary, SWT.NONE); avgYGCTLabel.setText("Avg YGCT: "); avgYGCTLabel.setLayoutData(ygcInfoGrid); avgYGCTDataLabel = new Label(summary, SWT.NONE); avgYGCTDataLabel.setText("xxx seconds"); avgYGCTDataLabel.setLayoutData(ygcInfoGrid); final Label avgYGCRateLabel = new Label(summary, SWT.NONE); avgYGCRateLabel.setText("Avg YGCRate: "); avgYGCRateLabel.setLayoutData(ygcInfoGrid); avgYGCRateDataLabel = new Label(summary, SWT.NONE); avgYGCRateDataLabel.setText("xxx seconds"); avgYGCRateDataLabel.setLayoutData(ygcInfoGrid); // CMS Grid GridData cmsgcInfoGrid = new GridData(GridData.FILL_BOTH); cmsgcInfoGrid.exclude = true; final Label cmsgcLabel = new Label(summary, SWT.NONE); cmsgcLabel.setText("CMSGC: "); cmsgcLabel.setLayoutData(cmsgcInfoGrid); cmsgcDataLabel = new Label(summary, SWT.NONE); cmsgcDataLabel.setText("xxx"); cmsgcDataLabel.setLayoutData(cmsgcInfoGrid); final Label cmsgctLabel = new Label(summary, SWT.NONE); cmsgctLabel.setText("CMSGCT: "); cmsgctLabel.setLayoutData(cmsgcInfoGrid); cmsgctDataLabel = new Label(summary, SWT.NONE); cmsgctDataLabel.setText("xxx seconds"); cmsgctDataLabel.setLayoutData(cmsgcInfoGrid); final Label avgCMSGCTLabel = new Label(summary, SWT.NONE); avgCMSGCTLabel.setText("Avg CMSGCT: "); avgCMSGCTLabel.setLayoutData(cmsgcInfoGrid); avgCMSGCTDataLabel = new Label(summary, SWT.NONE); avgCMSGCTDataLabel.setText("xxx seconds"); avgCMSGCTDataLabel.setLayoutData(cmsgcInfoGrid); final Label avgCMSGCRateLabel = new Label(summary, SWT.NONE); avgCMSGCRateLabel.setText("Avg CMSGCRate: "); avgCMSGCRateLabel.setLayoutData(cmsgcInfoGrid); avgCMSGCRateDataLabel = new Label(summary, SWT.NONE); avgCMSGCRateDataLabel.setText("xxx seconds"); avgCMSGCRateDataLabel.setLayoutData(cmsgcInfoGrid); // LDS & PTOS Grid GridData ldsAndPTOSGrid = new GridData(GridData.FILL_BOTH); ldsAndPTOSGrid.exclude = true; final Label avgYGCLDSLabel = new Label(summary, SWT.NONE); avgYGCLDSLabel.setText("AVG YGCLDS: "); avgYGCLDSLabel.setLayoutData(ldsAndPTOSGrid); avgYGCLDSDataLabel = new Label(summary, SWT.NONE); avgYGCLDSDataLabel.setText("xxx(K)"); avgYGCLDSDataLabel.setLayoutData(ldsAndPTOSGrid); final Label avgFGCLDSLabel = new Label(summary, SWT.NONE); avgFGCLDSLabel.setText("AVG FGCLDS: "); avgFGCLDSLabel.setLayoutData(ldsAndPTOSGrid); avgFGCLDSDataLabel = new Label(summary, SWT.NONE); avgFGCLDSDataLabel.setText("xxx(K)"); avgFGCLDSDataLabel.setLayoutData(ldsAndPTOSGrid); final Label avgPTOSLabel = new Label(summary, SWT.NONE); avgPTOSLabel.setText("AVG PTOS: "); avgPTOSLabel.setLayoutData(ldsAndPTOSGrid); avgPTOSDataLabel = new Label(summary, SWT.NONE); avgPTOSDataLabel.setText("xx%"); avgPTOSDataLabel.setLayoutData(ldsAndPTOSGrid); final Label emptyLabel2 = new Label(summary, SWT.NONE); emptyLabel2.setText(" "); emptyLabel2.setLayoutData(ldsAndPTOSGrid); final Label emptyDataLabel2 = new Label(summary, SWT.NONE); emptyDataLabel2.setText(" "); emptyDataLabel2.setLayoutData(ldsAndPTOSGrid); // FGC Grid GridData fgcInfoGrid = new GridData(GridData.FILL_BOTH); final Label fgcLabel = new Label(summary, SWT.NONE); fgcLabel.setText("FGC: "); fgcLabel.setLayoutData(fgcInfoGrid); fgcDataLabel = new Label(summary, SWT.NONE); fgcDataLabel.setText("xxx"); fgcDataLabel.setLayoutData(fgcInfoGrid); final Label fgctLabel = new Label(summary, SWT.NONE); fgctLabel.setText("FGCT: "); fgctLabel.setLayoutData(fgcInfoGrid); fgctDataLabel = new Label(summary, SWT.NONE); fgctDataLabel.setText("xxx seconds"); fgctDataLabel.setLayoutData(fgcInfoGrid); final Label avgFGCTLabel = new Label(summary, SWT.NONE); avgFGCTLabel.setText("Avg FGCT: "); avgFGCTLabel.setLayoutData(fgcInfoGrid); avgFGCTDataLabel = new Label(summary, SWT.NONE); avgFGCTDataLabel.setText("xxx seconds"); avgFGCTDataLabel.setLayoutData(fgcInfoGrid); final Label avgFGCRateLabel = new Label(summary, SWT.NONE); avgFGCRateLabel.setText("Avg FGCRate: "); avgFGCRateLabel.setLayoutData(fgcInfoGrid); avgFGCRateDataLabel = new Label(summary, SWT.NONE); avgFGCRateDataLabel.setText("xxx seconds"); avgFGCRateDataLabel.setLayoutData(fgcInfoGrid); }
From source file:au.gov.ansto.bragg.kakadu.ui.plot.FitPlotPropertiesComposite.java
private void updateParameterGroup(Map<String, Double> parameters, Double quality) { inverseButton.setSelection(fitter.isInverse()); inverseButton.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent arg0) { }//from w ww . j a v a 2s. c om public void widgetSelected(SelectionEvent arg0) { if (fitter.isInverseAllowed()) inverseButton.setEnabled(isEnabled()); if (inverseButton.getSelection() != fitter.isInverse()) setInverseValue(inverseButton.getSelection()); } }); parameterList.clear(); GridData data; parameterGroup.dispose(); if (removeButton != null) removeButton.dispose(); parameterGroup = new Group(this, SWT.NONE); parameterGroup.setText("Parameters"); GridLayout propertiesGridLayout = new GridLayout(); propertiesGridLayout.numColumns = 2; propertiesGridLayout.marginHeight = 3; propertiesGridLayout.marginWidth = 3; propertiesGridLayout.horizontalSpacing = 3; propertiesGridLayout.verticalSpacing = 3; parameterGroup.setLayout(propertiesGridLayout); data = new GridData(); data.horizontalAlignment = GridData.FILL; data.horizontalSpan = 2; data.grabExcessHorizontalSpace = true; parameterGroup.setLayoutData(data); Label functionLabel = new Label(parameterGroup, SWT.NONE); functionLabel.setText("Function"); data = new GridData(); data.verticalAlignment = GridData.BEGINNING; data.verticalIndent = 3; functionLabel.setLayoutData(data); Text functionText = new Text(parameterGroup, SWT.NONE); functionText.setText(fitter.getFunctionText()); data = new GridData(); data.horizontalAlignment = GridData.FILL; data.grabExcessHorizontalSpace = true; functionText.setLayoutData(data); functionText.setEditable(false); for (Entry<String, Double> entry : parameters.entrySet()) { Label label = new Label(parameterGroup, SWT.NONE); label.setText(entry.getKey()); data = new GridData(); data.verticalAlignment = GridData.BEGINNING; data.verticalIndent = 3; label.setLayoutData(data); Text text = new Text(parameterGroup, SWT.BORDER); text.setData(entry.getKey()); text.setText(String.valueOf(entry.getValue())); data = new GridData(); data.horizontalAlignment = GridData.FILL; data.grabExcessHorizontalSpace = true; text.setLayoutData(data); parameterList.add(text); } Label resolutionlabel = new Label(parameterGroup, SWT.NONE); resolutionlabel.setText("resolution"); data = new GridData(); data.verticalAlignment = GridData.BEGINNING; data.verticalIndent = 3; resolutionlabel.setLayoutData(data); resolutionText = new Text(parameterGroup, SWT.BORDER); resolutionText.setText(String.valueOf(fitter.getResolutionMultiple())); // resolutionText. data = new GridData(); data.horizontalAlignment = GridData.FILL; data.grabExcessHorizontalSpace = true; resolutionText.setLayoutData(data); if (!quality.isNaN()) { Label label = new Label(parameterGroup, SWT.NONE); label.setText("Quality(" + fitter.getFitterType().getValue() + ")"); data = new GridData(); data.verticalAlignment = GridData.BEGINNING; data.verticalIndent = 3; label.setLayoutData(data); Text text = new Text(parameterGroup, SWT.BORDER); text.setText(String.valueOf(quality)); data = new GridData(); data.horizontalAlignment = GridData.FILL; data.grabExcessHorizontalSpace = true; text.setLayoutData(data); } if (fitter.getFunctionType() == FunctionType.AddFunction) { removeButton = new Button(this, SWT.PUSH); removeButton .setText("Remove Function " + fitFunctionCombo.getItem(fitFunctionCombo.getSelectionIndex())); data = new GridData(); data.horizontalAlignment = GridData.FILL; data.verticalAlignment = GridData.FILL; data.horizontalSpan = 2; data.grabExcessHorizontalSpace = true; data.grabExcessVerticalSpace = true; removeButton.setLayoutData(data); removeButton.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent arg0) { } public void widgetSelected(SelectionEvent arg0) { try { removeFunction(fitFunctionCombo.getItem(fitFunctionCombo.getSelectionIndex())); } catch (Exception e) { plot.handleException(e); } } }); } // parameterGroup.redraw(); // this.redraw(); // parent.redraw(); // redraw(); layout(); if (expandItem != null) { expandItem.setHeight(this.computeSize(SWT.DEFAULT, SWT.DEFAULT).y); } parent.update(); parent.redraw(); // parent.layout(); }
From source file:WordJumbles.java
public void setDropTarget(final Label label) { int operations = DND.DROP_MOVE; final DropTarget dropTarget = new DropTarget(label, operations); // Data should be transfered in plain text format. Transfer[] formats = new Transfer[] { TextTransfer.getInstance() }; dropTarget.setTransfer(formats);/* w w w . ja v a 2 s.c om*/ dropTarget.addDropListener(new DropTargetListener() { public void dragEnter(DropTargetEvent event) { // Does not accept any drop if the label has text on it. if (label.getText().length() != 0) event.detail = DND.DROP_NONE; } public void dragLeave(DropTargetEvent event) { } public void dragOperationChanged(DropTargetEvent event) { } public void dragOver(DropTargetEvent event) { } public void drop(DropTargetEvent event) { if (TextTransfer.getInstance().isSupportedType(event.currentDataType)) { String text = (String) event.data; label.setText(text); // Checks the result. check(); } } public void dropAccept(DropTargetEvent event) { } }); label.addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent e) { dropTarget.dispose(); } }); }
From source file:WordJumbles.java
public void setDragSource(final Label label) { // Allows text to be moved only. int operations = DND.DROP_MOVE; final DragSource dragSource = new DragSource(label, operations); // Data should be transfered in plain text format. Transfer[] formats = new Transfer[] { TextTransfer.getInstance() }; dragSource.setTransfer(formats);/*from w w w . j ava2 s. c o m*/ dragSource.addDragListener(new DragSourceListener() { public void dragStart(DragSourceEvent event) { // Disallows drags if text is not available. if (label.getText().length() == 0) event.doit = false; } public void dragSetData(DragSourceEvent event) { // Provides the text data. if (TextTransfer.getInstance().isSupportedType(event.dataType)) event.data = label.getText(); } public void dragFinished(DragSourceEvent event) { // Removes the text after the move operation. if (event.doit == true || event.detail == DND.DROP_MOVE) { label.setText(""); } } }); label.addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent e) { dragSource.dispose(); } }); }
From source file:SWTAddressBook.java
private void createTextWidgets() { if (labels == null) return;/* w ww. j a va2 s. co m*/ Composite composite = new Composite(shell, SWT.NULL); composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); GridLayout layout = new GridLayout(); layout.numColumns = 2; composite.setLayout(layout); if (values == null) values = new String[labels.length]; for (int i = 0; i < labels.length; i++) { Label label = new Label(composite, SWT.RIGHT); label.setText(labels[i]); Text text = new Text(composite, SWT.BORDER); GridData gridData = new GridData(); gridData.widthHint = 400; text.setLayoutData(gridData); if (values[i] != null) { text.setText(values[i]); } text.setData("index", new Integer(i)); addTextListener(text); } }
From source file:org.eclipse.swt.snippets.SnippetExplorer.java
/** Initialize the SnippetExplorer controls. * * @param shell parent shell/*from w w w . j a va 2 s . c o m*/ */ private void createControls(Shell shell) { shell.setLayout(new FormLayout()); if (listUpdater == null) { listUpdater = new ListUpdater(); listUpdater.start(); } final Composite leftContainer = new Composite(shell, SWT.NONE); leftContainer.setLayout(new GridLayout()); final Sash splitter = new Sash(shell, SWT.BORDER | SWT.VERTICAL); final int splitterWidth = 3; splitter.addListener(SWT.Selection, e -> splitter.setBounds(e.x, e.y, e.width, e.height)); final Composite rightContainer = new Composite(shell, SWT.NONE); rightContainer.setLayout(new GridLayout()); FormData formData = new FormData(); formData.left = new FormAttachment(0, 0); formData.right = new FormAttachment(splitter, 0); formData.top = new FormAttachment(0, 0); formData.bottom = new FormAttachment(100, 0); leftContainer.setLayoutData(formData); formData = new FormData(); formData.left = new FormAttachment(50, 0); formData.right = new FormAttachment(50, splitterWidth); formData.top = new FormAttachment(0, 0); formData.bottom = new FormAttachment(100, 0); splitter.setLayoutData(formData); splitter.addListener(SWT.Selection, event -> { final FormData splitterFormData = (FormData) splitter.getLayoutData(); splitterFormData.left = new FormAttachment(0, event.x); splitterFormData.right = new FormAttachment(0, event.x + splitterWidth); shell.layout(); }); formData = new FormData(); formData.left = new FormAttachment(splitter, 0); formData.right = new FormAttachment(100, 0); formData.top = new FormAttachment(0, 0); formData.bottom = new FormAttachment(100, 0); rightContainer.setLayoutData(formData); filterField = new Text(leftContainer, SWT.SINGLE | SWT.BORDER | SWT.SEARCH | SWT.ICON_SEARCH | SWT.ICON_CANCEL); filterField.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); filterField.setMessage(FILTER_HINT); filterField.addListener(SWT.Modify, event -> { listUpdater.updateInMs(FILTER_DELAY_MS); }); snippetTable = new Table(leftContainer, SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION); snippetTable.setLinesVisible(true); snippetTable.setHeaderVisible(true); final GridData data = new GridData(SWT.FILL, SWT.FILL, true, true); data.heightHint = 500; snippetTable.setLayoutData(data); snippetTable.addListener(SWT.MouseDoubleClick, event -> { final Point clickPoint = new Point(event.x, event.y); launchSnippet(snippetTable.getItem(clickPoint)); }); snippetTable.addListener(SWT.KeyUp, event -> { if (event.keyCode == '\r' || event.keyCode == '\n') { launchSnippet(snippetTable.getSelection()); } }); final Composite buttonRow = new Composite(leftContainer, SWT.NONE); buttonRow.setLayout(new GridLayout(3, false)); buttonRow.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); startSelectedButton = new Button(buttonRow, SWT.LEAD); startSelectedButton.setText(" Start &selected Snippets"); snippetTable.addListener(SWT.Selection, event -> { startSelectedButton.setEnabled(snippetTable.getSelectionCount() > 0); updateInfoTab(snippetTable.getSelection()); }); startSelectedButton.setEnabled(snippetTable.getSelectionCount() > 0); startSelectedButton.addListener(SWT.Selection, event -> { launchSnippet(snippetTable.getSelection()); }); final Label runnerLabel = new Label(buttonRow, SWT.NONE); runnerLabel.setText("Snippet Runner:"); runnerLabel.setLayoutData(new GridData(SWT.TRAIL, SWT.CENTER, true, false)); runnerCombo = new Combo(buttonRow, SWT.TRAIL | SWT.DROP_DOWN | SWT.READ_ONLY); runnerMapping.clear(); if (multiDisplaySupport) { runnerCombo.add("Thread"); runnerMapping.add(THREAD_RUNNER); } if (javaCommand != null) { runnerCombo.add("Process"); runnerMapping.add(PROCESS_RUNNER); } runnerCombo.add("Serial"); runnerMapping.add(null); runnerCombo.setData(runnerMapping); runnerCombo.addListener(SWT.Modify, event -> { if (runnerMapping.size() > runnerCombo.getSelectionIndex()) { snippetRunner = runnerMapping.get(runnerCombo.getSelectionIndex()); } else { System.err.println("Unknown runner index " + runnerCombo.getSelectionIndex()); } }); runnerCombo.select(0); infoTabs = new TabFolder(rightContainer, SWT.TOP); infoTabs.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); descriptionView = new StyledText(infoTabs, SWT.MULTI | SWT.WRAP | SWT.READ_ONLY | SWT.V_SCROLL); sourceView = new StyledText(infoTabs, SWT.MULTI | SWT.READ_ONLY | SWT.V_SCROLL | SWT.H_SCROLL); setMonospaceFont(sourceView); final ScrolledComposite previewContainer = new ScrolledComposite(infoTabs, SWT.V_SCROLL | SWT.H_SCROLL); previewImageLabel = new Label(previewContainer, SWT.NONE); previewContainer.setContent(previewImageLabel); final TabItem descriptionTab = new TabItem(infoTabs, SWT.NONE); descriptionTab.setText("Description"); descriptionTab.setControl(descriptionView); final TabItem sourceTab = new TabItem(infoTabs, SWT.NONE); sourceTab.setText("Source"); sourceTab.setControl(sourceView); final TabItem previewTab = new TabItem(infoTabs, SWT.NONE); previewTab.setText("Preview"); previewTab.setControl(previewContainer); updateInfoTab(null, true); updateInfoTab(snippetTable.getSelection()); }
From source file:com.android.ddmuilib.HeapPanel.java
private void createLegend(Composite parent) { mLegend = new Group(parent, SWT.NONE); mLegend.setText(getLegendText(0));/*from w w w .ja va 2 s .c o m*/ mLegend.setLayout(new GridLayout(2, false)); RGB[] colors = mMapPalette.colors; for (int i = 0; i < NUM_PALETTE_ENTRIES; i++) { Image tmpImage = createColorRect(parent.getDisplay(), colors[i]); Label l = new Label(mLegend, SWT.NONE); l.setImage(tmpImage); l = new Label(mLegend, SWT.NONE); l.setText(mMapLegend[i]); } }
From source file:com.bdaum.zoom.report.internal.wizards.ReportComponent.java
public ReportComponent(Composite parent, int style, int preview) { super(parent, style); this.preview = preview; setLayout(new FillLayout()); stack = new Composite(this, SWT.NONE); stackLayout = new StackLayout(); stack.setLayout(stackLayout);//from w ww. ja v a 2 s. c o m chartComposite = new ChartComposite(stack, SWT.NONE, null, preview == Integer.MAX_VALUE, preview == Integer.MAX_VALUE, preview == Integer.MAX_VALUE, preview == Integer.MAX_VALUE, preview == Integer.MAX_VALUE); chartComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); pendingComp = new Composite(stack, SWT.NONE); pendingComp.setLayout(new GridLayout(1, false)); Label label = new Label(pendingComp, SWT.NONE); label.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, true)); label.setText(Messages.ReportPage_pending); if (preview == Integer.MAX_VALUE) { progressBar = new ProgressIndicator(pendingComp, SWT.BORDER); GridData data = new GridData(SWT.FILL, SWT.BEGINNING, true, false); data.heightHint = PROGRESS_THICKNESS; progressBar.setLayoutData(data); } stackLayout.topControl = pendingComp; }
From source file:SWTAddressBook.java
/** * Class constructor that sets the parent shell and the table widget that * the dialog will search./*from w w w.j a va2 s. c om*/ * * @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("Search"); shell.addShellListener(new ShellAdapter() { public void shellClosed(ShellEvent 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("Dialog_find_what"); searchText = new Text(shell, SWT.BORDER); GridData gridData = new GridData(GridData.FILL_HORIZONTAL); gridData.widthHint = 200; searchText.setLayoutData(gridData); searchText.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent 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("Dialog_match_case"); gridData = new GridData(); gridData.horizontalSpan = 2; matchCase.setLayoutData(gridData); matchWord = new Button(shell, SWT.CHECK); matchWord.setText("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("Dialog_direction"); Button up = new Button(direction, SWT.RADIO); up.setText("Dialog_dir_up"); up.setSelection(false); down = new Button(direction, SWT.RADIO); down.setText("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("Dialog_find"); findButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); findButton.setEnabled(false); findButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { if (!findHandler.find()) { MessageBox box = new MessageBox(shell, SWT.ICON_INFORMATION | SWT.OK | SWT.PRIMARY_MODAL); box.setText(shell.getText()); box.setMessage("Cannot_find" + "\"" + searchText.getText() + "\""); box.open(); } } }); Button cancelButton = new Button(composite, SWT.PUSH); cancelButton.setText("Cancel"); cancelButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING)); cancelButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { shell.setVisible(false); } }); shell.pack(); }