List of usage examples for org.eclipse.swt.widgets Label setText
public void setText(String text)
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. *//* w ww .jav a 2s .co 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: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;/*from w w w. j a va2 s .c om*/ 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 w ww . j ava 2s. 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:BrowserExample.java
/** * Creates an instance of a ControlExample embedded inside the supplied * parent Composite./*from w w w.ja va 2 s . c o m*/ * * @param parent * the container of the example */ public BrowserExample(Composite parent) { final Display display = parent.getDisplay(); FormLayout layout = new FormLayout(); parent.setLayout(layout); ToolBar toolbar = new ToolBar(parent, SWT.NONE); final ToolItem itemBack = new ToolItem(toolbar, SWT.PUSH); itemBack.setText(getResourceString("Back")); final ToolItem itemForward = new ToolItem(toolbar, SWT.PUSH); itemForward.setText(getResourceString("Forward")); final ToolItem itemStop = new ToolItem(toolbar, SWT.PUSH); itemStop.setText(getResourceString("Stop")); final ToolItem itemRefresh = new ToolItem(toolbar, SWT.PUSH); itemRefresh.setText(getResourceString("Refresh")); final ToolItem itemGo = new ToolItem(toolbar, SWT.PUSH); itemGo.setText(getResourceString("Go")); location = new Text(parent, SWT.BORDER); images = new Image[] { new Image(display, "java2s.gif") }; final Canvas canvas = new Canvas(parent, SWT.NO_BACKGROUND); final Rectangle rect = images[0].getBounds(); canvas.addListener(SWT.Paint, new Listener() { public void handleEvent(Event e) { Point pt = canvas.getSize(); e.gc.drawImage(images[index], 0, 0, rect.width, rect.height, 0, 0, pt.x, pt.y); } }); canvas.addListener(SWT.MouseDown, new Listener() { public void handleEvent(Event e) { browser.setUrl(getResourceString("Startup")); } }); display.asyncExec(new Runnable() { public void run() { if (canvas.isDisposed()) return; if (busy) { index++; if (index == images.length) index = 0; canvas.redraw(); } display.timerExec(150, this); } }); final Label status = new Label(parent, SWT.NONE); final ProgressBar progressBar = new ProgressBar(parent, SWT.NONE); FormData data = new FormData(); data.top = new FormAttachment(0, 5); toolbar.setLayoutData(data); data = new FormData(); data.left = new FormAttachment(0, 0); data.right = new FormAttachment(100, 0); data.top = new FormAttachment(canvas, 5, SWT.DEFAULT); data.bottom = new FormAttachment(status, -5, SWT.DEFAULT); try { browser = new Browser(parent, SWT.NONE); browser.setLayoutData(data); } catch (SWTError e) { /* Browser widget could not be instantiated */ Label label = new Label(parent, SWT.CENTER | SWT.WRAP); label.setText(getResourceString("BrowserNotCreated")); label.setLayoutData(data); } data = new FormData(); data.width = 24; data.height = 24; data.top = new FormAttachment(0, 5); data.right = new FormAttachment(100, -5); canvas.setLayoutData(data); data = new FormData(); data.top = new FormAttachment(toolbar, 0, SWT.TOP); data.left = new FormAttachment(toolbar, 5, SWT.RIGHT); data.right = new FormAttachment(canvas, -5, SWT.DEFAULT); location.setLayoutData(data); data = new FormData(); data.left = new FormAttachment(0, 5); data.right = new FormAttachment(progressBar, 0, SWT.DEFAULT); data.bottom = new FormAttachment(100, -5); status.setLayoutData(data); data = new FormData(); data.right = new FormAttachment(100, -5); data.bottom = new FormAttachment(100, -5); progressBar.setLayoutData(data); if (browser != null) { itemBack.setEnabled(browser.isBackEnabled()); itemForward.setEnabled(browser.isForwardEnabled()); Listener listener = new Listener() { public void handleEvent(Event event) { ToolItem item = (ToolItem) event.widget; if (item == itemBack) browser.back(); else if (item == itemForward) browser.forward(); else if (item == itemStop) browser.stop(); else if (item == itemRefresh) browser.refresh(); else if (item == itemGo) browser.setUrl(location.getText()); } }; browser.addLocationListener(new LocationListener() { public void changed(LocationEvent event) { busy = true; if (event.top) location.setText(event.location); } public void changing(LocationEvent event) { } }); browser.addProgressListener(new ProgressListener() { public void changed(ProgressEvent event) { if (event.total == 0) return; int ratio = event.current * 100 / event.total; progressBar.setSelection(ratio); busy = event.current != event.total; if (!busy) { index = 0; canvas.redraw(); } } public void completed(ProgressEvent event) { itemBack.setEnabled(browser.isBackEnabled()); itemForward.setEnabled(browser.isForwardEnabled()); progressBar.setSelection(0); busy = false; index = 0; canvas.redraw(); } }); browser.addStatusTextListener(new StatusTextListener() { public void changed(StatusTextEvent event) { status.setText(event.text); } }); if (parent instanceof Shell) { final Shell shell = (Shell) parent; browser.addTitleListener(new TitleListener() { public void changed(TitleEvent event) { shell.setText(event.title + " - " + getResourceString("window.title")); } }); } itemBack.addListener(SWT.Selection, listener); itemForward.addListener(SWT.Selection, listener); itemStop.addListener(SWT.Selection, listener); itemRefresh.addListener(SWT.Selection, listener); itemGo.addListener(SWT.Selection, listener); location.addListener(SWT.DefaultSelection, new Listener() { public void handleEvent(Event e) { browser.setUrl(location.getText()); } }); initialize(display, browser); browser.setUrl(getResourceString("Startup")); } }
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 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:ShowInputDialog.java
private void createContents(final Shell parent) { parent.setLayout(new FillLayout(SWT.VERTICAL)); final Label label = new Label(parent, SWT.NONE); Button button = new Button(parent, SWT.PUSH); button.setText("Push Me"); button.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { // Create and display the InputDialog InputDialog dlg = new InputDialog(parent); String input = dlg.open(); if (input != null) { // User clicked OK; set the text into the label label.setText(input); label.getParent().pack(); }// ww w .j a v a2 s .c o m } }); }
From source file:eu.stratosphere.addons.visualization.swt.SWTVertexToolTip.java
public SWTVertexToolTip(Shell parent, final SWTToolTipCommandReceiver commandReceiver, ManagementVertex managementVertex, int x, int y) { super(parent, x, y); this.managementVertex = managementVertex; final VertexVisualizationData vertexVisualizationData = (VertexVisualizationData) managementVertex .getAttachment();/*from www.j a v a2s . co m*/ int height; final Color backgroundColor = getShell().getBackground(); final Color foregroundColor = getShell().getForeground(); // Set the title final String taskName = managementVertex.getName() + " (" + (managementVertex.getIndexInGroup() + 1) + " of " + managementVertex.getNumberOfVerticesInGroup() + ")"; setTitle(taskName); // Only create chart if profiling is enabled if (vertexVisualizationData.isProfilingEnabledForJob()) { this.threadChart = createThreadChart(vertexVisualizationData, backgroundColor); this.threadChart.setLayoutData(new GridData(GridData.FILL_BOTH)); height = 240; // should be 265 when cancel button is enabled } else { this.threadChart = null; height = 125; } final Composite tableComposite = new Composite(getShell(), SWT.NONE); tableComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); tableComposite.setBackground(backgroundColor); tableComposite.setForeground(foregroundColor); final GridLayout tableGridLayout = new GridLayout(3, false); tableGridLayout.marginHeight = 0; tableGridLayout.marginLeft = 0; tableComposite.setLayout(tableGridLayout); final GridData gridData1 = new GridData(); gridData1.horizontalSpan = 2; gridData1.grabExcessHorizontalSpace = true; gridData1.widthHint = 200; final GridData gridData2 = new GridData(); gridData2.grabExcessHorizontalSpace = true; // Instance type final Label instanceTypeTextLabel = new Label(tableComposite, SWT.NONE); instanceTypeTextLabel.setBackground(backgroundColor); instanceTypeTextLabel.setForeground(foregroundColor); instanceTypeTextLabel.setText("Instance type:"); this.instanceTypeLabel = new Label(tableComposite, SWT.NONE); this.instanceTypeLabel.setBackground(backgroundColor); this.instanceTypeLabel.setForeground(foregroundColor); this.instanceTypeLabel.setText(this.managementVertex.getInstanceType()); this.instanceTypeLabel.setLayoutData(gridData1); // Instance ID final Label instanceIDTextLabel = new Label(tableComposite, SWT.NONE); instanceIDTextLabel.setBackground(backgroundColor); instanceIDTextLabel.setForeground(foregroundColor); instanceIDTextLabel.setText("Instance ID:"); this.instanceIDLabel = new Label(tableComposite, SWT.NONE); this.instanceIDLabel.setBackground(backgroundColor); this.instanceIDLabel.setForeground(foregroundColor); this.instanceIDLabel.setText(this.managementVertex.getInstanceName()); this.instanceIDLabel.setLayoutData(gridData2); final Button switchToInstanceButton = new Button(tableComposite, SWT.PUSH); switchToInstanceButton.setText("Switch to instance..."); switchToInstanceButton.setEnabled(vertexVisualizationData.isProfilingEnabledForJob()); switchToInstanceButton.setVisible(false); /* * final String instanceName = this.managementVertex.getInstanceName(); * switchToInstanceButton.addListener(SWT.Selection, new Listener() { * @Override * public void handleEvent(Event arg0) { * commandReceiver.switchToInstance(instanceName); * } * }); */ // Execution state final Label executionStateTextLabel = new Label(tableComposite, SWT.NONE); executionStateTextLabel.setBackground(backgroundColor); executionStateTextLabel.setForeground(foregroundColor); executionStateTextLabel.setText("Execution state:"); this.executionStateLabel = new Label(tableComposite, SWT.NONE); this.executionStateLabel.setBackground(backgroundColor); this.executionStateLabel.setForeground(foregroundColor); this.executionStateLabel.setText(this.managementVertex.getExecutionState().toString()); this.executionStateLabel.setLayoutData(gridData1); final ManagementGroupVertex groupVertex = this.managementVertex.getGroupVertex(); final GroupVertexVisualizationData groupVertexVisualizationData = (GroupVertexVisualizationData) groupVertex .getAttachment(); if (groupVertexVisualizationData.isCPUBottleneck()) { this.warningComposite = createWarningComposite(WARNINGTEXT, SWT.ICON_WARNING); height += ICONSIZE; } else { this.warningComposite = null; } // Available task actions final Composite taskActionComposite = new Composite(getShell(), SWT.NONE); taskActionComposite.setLayout(new RowLayout(SWT.HORIZONTAL)); taskActionComposite.setBackground(backgroundColor); taskActionComposite.setForeground(foregroundColor); /* * final Button cancelTaskButton = new Button(taskActionComposite, SWT.PUSH); * final ManagementVertexID vertexID = this.managementVertex.getID(); * cancelTaskButton.setText("Cancel task"); * cancelTaskButton.setEnabled(this.managementVertex.getExecutionState() == ExecutionState.RUNNING); * cancelTaskButton.addListener(SWT.Selection, new Listener() { * @Override * public void handleEvent(Event arg0) { * commandReceiver.cancelTask(vertexID, taskName); * } * }); */ getShell().setSize(WIDTH, height); finishInstantiation(x, y, WIDTH, false); }
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);/*w ww .ja v a2 s .c o m*/ 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:eu.stratosphere.nephele.visualization.swt.SWTVertexToolTip.java
public SWTVertexToolTip(Shell parent, final SWTToolTipCommandReceiver commandReceiver, ManagementVertex managementVertex, int x, int y) { super(parent, x, y); this.managementVertex = managementVertex; final VertexVisualizationData vertexVisualizationData = (VertexVisualizationData) managementVertex .getAttachment();//from w w w . j a v a 2 s . c o m int height; final Color backgroundColor = getShell().getBackground(); final Color foregroundColor = getShell().getForeground(); // Set the title final String taskName = managementVertex.getName() + " (" + (managementVertex.getIndexInGroup() + 1) + " of " + managementVertex.getNumberOfVerticesInGroup() + ")"; setTitle(taskName); // Only create chart if profiling is enabled if (vertexVisualizationData.isProfilingEnabledForJob()) { this.threadChart = createThreadChart(vertexVisualizationData, backgroundColor); this.threadChart.setLayoutData(new GridData(GridData.FILL_BOTH)); height = 240; // should be 265 when cancel button is enabled } else { this.threadChart = null; height = 125; } final Composite tableComposite = new Composite(getShell(), SWT.NONE); tableComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); tableComposite.setBackground(backgroundColor); tableComposite.setForeground(foregroundColor); final GridLayout tableGridLayout = new GridLayout(3, false); tableGridLayout.marginHeight = 0; tableGridLayout.marginLeft = 0; tableComposite.setLayout(tableGridLayout); final GridData gridData1 = new GridData(); gridData1.horizontalSpan = 2; gridData1.grabExcessHorizontalSpace = true; gridData1.widthHint = 200; final GridData gridData2 = new GridData(); gridData2.grabExcessHorizontalSpace = true; // Instance type final Label instanceTypeTextLabel = new Label(tableComposite, SWT.NONE); instanceTypeTextLabel.setBackground(backgroundColor); instanceTypeTextLabel.setForeground(foregroundColor); instanceTypeTextLabel.setText("Instance type:"); this.instanceTypeLabel = new Label(tableComposite, SWT.NONE); this.instanceTypeLabel.setBackground(backgroundColor); this.instanceTypeLabel.setForeground(foregroundColor); this.instanceTypeLabel.setText(this.managementVertex.getInstanceType()); this.instanceTypeLabel.setLayoutData(gridData1); // Instance ID final Label instanceIDTextLabel = new Label(tableComposite, SWT.NONE); instanceIDTextLabel.setBackground(backgroundColor); instanceIDTextLabel.setForeground(foregroundColor); instanceIDTextLabel.setText("Instance ID:"); this.instanceIDLabel = new Label(tableComposite, SWT.NONE); this.instanceIDLabel.setBackground(backgroundColor); this.instanceIDLabel.setForeground(foregroundColor); this.instanceIDLabel.setText(this.managementVertex.getInstanceName()); this.instanceIDLabel.setLayoutData(gridData2); final Button switchToInstanceButton = new Button(tableComposite, SWT.PUSH); switchToInstanceButton.setText("Switch to instance..."); switchToInstanceButton.setEnabled(vertexVisualizationData.isProfilingEnabledForJob()); switchToInstanceButton.setVisible(false); /* * final String instanceName = this.managementVertex.getInstanceName(); * switchToInstanceButton.addListener(SWT.Selection, new Listener() { * @Override * public void handleEvent(Event arg0) { * commandReceiver.switchToInstance(instanceName); * } * }); */ // Execution state final Label executionStateTextLabel = new Label(tableComposite, SWT.NONE); executionStateTextLabel.setBackground(backgroundColor); executionStateTextLabel.setForeground(foregroundColor); executionStateTextLabel.setText("Execution state:"); this.executionStateLabel = new Label(tableComposite, SWT.NONE); this.executionStateLabel.setBackground(backgroundColor); this.executionStateLabel.setForeground(foregroundColor); this.executionStateLabel.setText(this.managementVertex.getExecutionState().toString()); this.executionStateLabel.setLayoutData(gridData1); // Checkpoint state final Label checkpointStateTextLabel = new Label(tableComposite, SWT.NONE); checkpointStateTextLabel.setBackground(backgroundColor); checkpointStateTextLabel.setForeground(foregroundColor); checkpointStateTextLabel.setText("Checkpoint state:"); this.checkpointStateLabel = new Label(tableComposite, SWT.NONE); this.checkpointStateLabel.setBackground(backgroundColor); this.checkpointStateLabel.setForeground(foregroundColor); this.checkpointStateLabel.setText(this.managementVertex.getCheckpointState().toString()); this.checkpointStateLabel.setLayoutData(gridData1); final ManagementGroupVertex groupVertex = this.managementVertex.getGroupVertex(); final GroupVertexVisualizationData groupVertexVisualizationData = (GroupVertexVisualizationData) groupVertex .getAttachment(); if (groupVertexVisualizationData.isCPUBottleneck()) { this.warningComposite = createWarningComposite(WARNINGTEXT, SWT.ICON_WARNING); height += ICONSIZE; } else { this.warningComposite = null; } // Available task actions final Composite taskActionComposite = new Composite(getShell(), SWT.NONE); taskActionComposite.setLayout(new RowLayout(SWT.HORIZONTAL)); taskActionComposite.setBackground(backgroundColor); taskActionComposite.setForeground(foregroundColor); /* * final Button cancelTaskButton = new Button(taskActionComposite, SWT.PUSH); * final ManagementVertexID vertexID = this.managementVertex.getID(); * cancelTaskButton.setText("Cancel task"); * cancelTaskButton.setEnabled(this.managementVertex.getExecutionState() == ExecutionState.RUNNING); * cancelTaskButton.addListener(SWT.Selection, new Listener() { * @Override * public void handleEvent(Event arg0) { * commandReceiver.cancelTask(vertexID, taskName); * } * }); */ getShell().setSize(WIDTH, height); finishInstantiation(x, y, WIDTH, false); }
From source file:org.eclipse.swt.examples.ole.win32.OleBrowserView.java
/** * Creates Web browser control.//from w ww. j av a 2 s. co m */ private void createBrowserControl() { try { // Create an Automation object for access to extended capabilities webControlSite = new OleControlSite(webFrame, SWT.NONE, "Shell.Explorer"); Variant download = new Variant(DLCTL_NO_SCRIPTS); webControlSite.setSiteProperty(DISPID_AMBIENT_DLCONTROL, download); OleAutomation oleAutomation = new OleAutomation(webControlSite); webBrowser = new OleWebBrowser(oleAutomation); } catch (SWTException ex) { // Creation may have failed because control is not installed on machine Label label = new Label(webFrame, SWT.BORDER); OlePlugin.logError(OlePlugin.getResourceString("error.CouldNotCreateBrowserControl"), ex); label.setText(OlePlugin.getResourceString("error.CouldNotCreateBrowserControl")); return; } // Respond to ProgressChange events by updating the Progress bar webControlSite.addEventListener(OleWebBrowser.ProgressChange, event -> { Variant progress = event.arguments[0]; Variant maxProgress = event.arguments[1]; if (progress == null || maxProgress == null) return; webProgress.setMaximum(maxProgress.getInt()); webProgress.setSelection(progress.getInt()); }); // Respond to StatusTextChange events by updating the Status Text label webControlSite.addEventListener(OleWebBrowser.StatusTextChange, event -> { Variant statusText = event.arguments[0]; if (statusText == null) return; String text = statusText.getString(); if (text != null) webStatus.setText(text); }); // Listen for changes to the ready state and print out the current state webControlSite.addPropertyListener(OleWebBrowser.DISPID_READYSTATE, event -> { if (event.detail == OLE.PROPERTY_CHANGING) return; int state = webBrowser.getReadyState(); switch (state) { case OleWebBrowser.READYSTATE_UNINITIALIZED: webStatus.setText(OlePlugin.getResourceString("browser.State.Uninitialized.text")); webCommandBackward.setEnabled(false); webCommandForward.setEnabled(false); webCommandHome.setEnabled(false); webCommandRefresh.setEnabled(false); webCommandStop.setEnabled(false); webCommandSearch.setEnabled(false); break; case OleWebBrowser.READYSTATE_LOADING: webStatus.setText(OlePlugin.getResourceString("browser.State.Loading.text")); webCommandHome.setEnabled(true); webCommandRefresh.setEnabled(true); webCommandStop.setEnabled(true); webCommandSearch.setEnabled(true); break; case OleWebBrowser.READYSTATE_LOADED: webStatus.setText(OlePlugin.getResourceString("browser.State.Loaded.text")); webCommandStop.setEnabled(true); break; case OleWebBrowser.READYSTATE_INTERACTIVE: webStatus.setText(OlePlugin.getResourceString("browser.State.Interactive.text")); webCommandStop.setEnabled(true); break; case OleWebBrowser.READYSTATE_COMPLETE: webStatus.setText(OlePlugin.getResourceString("browser.State.Complete.text")); webCommandStop.setEnabled(false); break; } }); // Listen for changes to the active command states webControlSite.addEventListener(OleWebBrowser.CommandStateChange, event -> { if (event.type != OleWebBrowser.CommandStateChange) return; final int commandID = (event.arguments[0] != null) ? event.arguments[0].getInt() : 0; final boolean commandEnabled = (event.arguments[1] != null) ? event.arguments[1].getBoolean() : false; switch (commandID) { case OleWebBrowser.CSC_NAVIGATEBACK: webCommandBackward.setEnabled(commandEnabled); break; case OleWebBrowser.CSC_NAVIGATEFORWARD: webCommandForward.setEnabled(commandEnabled); break; } }); // in place activate the ActiveX control activated = (webControlSite.doVerb(OLE.OLEIVERB_INPLACEACTIVATE) == OLE.S_OK); if (activated) webBrowser.GoHome(); }