List of usage examples for org.eclipse.swt.widgets Composite setLayoutData
public void setLayoutData(Object layoutData)
From source file:com.android.ddmuilib.SysinfoPanel.java
/** * Create our controls for the UI panel. *///from ww w. j a v a 2s.c o m @Override protected Control createControl(Composite parent) { Composite top = new Composite(parent, SWT.NONE); top.setLayout(new GridLayout(1, false)); top.setLayoutData(new GridData(GridData.FILL_BOTH)); Composite buttons = new Composite(top, SWT.NONE); buttons.setLayout(new RowLayout()); mDisplayMode = new Combo(buttons, SWT.PUSH); for (String mode : CAPTIONS) { mDisplayMode.add(mode); } mDisplayMode.select(mMode); mDisplayMode.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { mMode = mDisplayMode.getSelectionIndex(); if (mDataFile != null) { generateDataset(mDataFile); } else if (getCurrentDevice() != null) { loadFromDevice(); } } }); final Button loadButton = new Button(buttons, SWT.PUSH); loadButton.setText("Load from File"); loadButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { FileDialog fileDialog = new FileDialog(loadButton.getShell(), SWT.OPEN); fileDialog.setText("Load bugreport"); String filename = fileDialog.open(); if (filename != null) { mDataFile = new File(filename); generateDataset(mDataFile); } } }); mFetchButton = new Button(buttons, SWT.PUSH); mFetchButton.setText("Update from Device"); mFetchButton.setEnabled(false); mFetchButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { loadFromDevice(); } }); mLabel = new Label(top, SWT.NONE); mLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); mDataset = new DefaultPieDataset(); JFreeChart chart = ChartFactory.createPieChart("", mDataset, false /* legend */, true/* tooltips */, false /* urls */); ChartComposite chartComposite = new ChartComposite(top, SWT.BORDER, chart, ChartComposite.DEFAULT_HEIGHT, ChartComposite.DEFAULT_HEIGHT, ChartComposite.DEFAULT_MINIMUM_DRAW_WIDTH, ChartComposite.DEFAULT_MINIMUM_DRAW_HEIGHT, 3000, // max draw width. We don't want it to zoom, so we put a big number 3000, // max draw height. We don't want it to zoom, so we put a big number true, // off-screen buffer true, // properties true, // save true, // print false, // zoom true); chartComposite.setLayoutData(new GridData(GridData.FILL_BOTH)); return top; }
From source file:edu.isistan.carcha.plugin.editors.TraceabilityEditor.java
/** * Creates the impact list page.//from w ww . ja va 2 s. c o m */ void impactListPage() { final Composite composite = new Composite(getContainer(), SWT.NONE); composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1)); composite.setLayout(new GridLayout()); Label concernLabel = new Label(composite, SWT.BORDER); concernLabel.setText("Crosccuting Concerns(CCC)"); concernLabel.setToolTipText("This are the concern detected on the requierement document."); GridData gridData = new GridData(SWT.LEFT, SWT.TOP, false, false); concernLabel.setLayoutData(gridData); ///////////////////// ScrolledComposite sc = new ScrolledComposite(composite, SWT.H_SCROLL | SWT.V_SCROLL); Composite parent = new Composite(sc, SWT.NONE); parent.setLayout(new GridLayout()); topViewLink = new TableViewer(parent, SWT.BORDER); createColumns(parent, topViewLink); final Table table = topViewLink.getTable(); table.setHeaderVisible(true); table.setLinesVisible(true); topViewLink.setContentProvider(new ArrayContentProvider()); getSite().setSelectionProvider(topViewLink); GridData data = new GridData(SWT.FILL, SWT.FILL, true, false); data.heightHint = 10 * table.getItemHeight(); table.setLayoutData(data); sc.setContent(parent); sc.setExpandHorizontal(true); sc.setExpandVertical(true); sc.setMinSize(parent.computeSize(SWT.DEFAULT, SWT.DEFAULT)); ///////////////////// Button button = new Button(composite, SWT.PUSH); button.setText("Remove"); button.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent event) { } public void widgetSelected(SelectionEvent event) { IStructuredSelection topSelection = (IStructuredSelection) topViewLink.getSelection(); IStructuredSelection bottomSelection = (IStructuredSelection) bottomViewLink.getSelection(); String[] crosscuttingConcern = (String[]) topSelection.getFirstElement(); String[] designDecision = (String[]) bottomSelection.getFirstElement(); if (topSelection.size() > 1) { MessageDialog.openError(composite.getShell(), "Error", "Please select one crosscutting concern"); } else { 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 remove the link between the selected items?"); // open dialog and await user selection int response = dialog.open(); if (response == SWT.OK) { PluginUtil.removeLink(crosscuttingConcern, designDecision, cp); dirty = true; firePropertyChange(IEditorPart.PROP_DIRTY); // update the list after the remove generateLinkViewData(); bottomViewLink.getTable().clearAll(); } } else { MessageDialog.openError(composite.getShell(), "Error", "Please select a crosscutting concern and a design decision to remove a traceability 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 on the architectural document"); gridData = new GridData(SWT.LEFT, SWT.TOP, false, false); ddsLabel.setLayoutData(gridData); bottomViewLink = new TableViewer(composite, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER); createColumns(composite, bottomViewLink); Table table2 = bottomViewLink.getTable(); table2.setHeaderVisible(true); table2.setLinesVisible(true); bottomViewLink.setContentProvider(new ArrayContentProvider()); topViewLink.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { IStructuredSelection selection = (IStructuredSelection) event.getSelection(); if (!selection.isEmpty()) { String[] cccs = (String[]) selection.getFirstElement(); List<DesignDecision> dds = PluginUtil.getDesignDecisionsForCrossCuttingConcern(cp, cccs[1], cccs[0]); logger.info("Impact List for CCC (" + dds.size() + " DDD): " + cccs[0] + " - " + cccs[1]); List<String[]> designDecisions = new ArrayList<String[]>(); for (DesignDecision dd : dds) { String[] designDecision = { dd.getKind(), dd.getName() }; designDecisions.add(designDecision); } bottomViewLink.setInput(designDecisions); } } }); getSite().setSelectionProvider(bottomViewLink); gridData = new GridData(SWT.FILL, SWT.FILL, true, true); bottomViewLink.getControl().setLayoutData(gridData); int index = addPage(composite); setPageText(index, "Links"); }
From source file:eu.hydrologis.jgrass.charting.datamodels.MultiXYTimeChartCreator.java
/** * Make a composite with the plot of the supplied chartdata. There are several HINT* variables * that can be set to tweak and configure the plot. * //from w ww . ja v a 2 s . co m * @param parentComposite * @param chartData */ public void makePlot(Composite parentComposite, NumericChartData chartData) { final int tabNums = chartData.getTabItemNumbers(); if (tabNums == 0) { return; } Shell dummyShell = null; // try { // dummyShell = PlatformUI.getWorkbench().getDisplay().getActiveShell(); // } catch (Exception e) { dummyShell = new Shell(Display.getCurrent(), SWT.None); // } /* * wrapping panel needed in the case of hide checks */ TabFolder tabFolder = null; if (tabNums > 1) { tabFolder = new TabFolder(parentComposite, SWT.BORDER); tabFolder.setLayout(new GridLayout()); tabFolder.setLayoutData( new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL)); } for (int i = 0; i < tabNums; i++) { NumericChartDataItem chartItem = chartData.getChartDataItem(i); int chartNums = chartItem.chartSeriesData.size(); /* * are there data to create the lower chart panel */ List<LinkedHashMap<String, Integer>> series = new ArrayList<LinkedHashMap<String, Integer>>(); List<XYPlot> plots = new ArrayList<XYPlot>(); List<JFreeChart> charts = new ArrayList<JFreeChart>(); for (int j = 0; j < chartNums; j++) { final LinkedHashMap<String, Integer> chartSeries = new LinkedHashMap<String, Integer>(); XYPlot chartPlot = null; JGrassChart chart = null; double[][][] cLD = chartItem.chartSeriesData.get(j); if (M_HINT_CREATE_CHART[i][j]) { final String[] cT = chartItem.seriesNames.get(j); final String title = chartItem.chartTitles.get(j); final String xT = chartItem.chartXLabels.get(j); final String yT = chartItem.chartYLabels.get(j); if (M_HINT_CHART_TYPE[i][j] == XYLINECHART) { chart = new JGrassXYLineChart(cT, cLD); } else if (M_HINT_CHART_TYPE[i][j] == XYBARCHART) { chart = new JGrassXYBarChart(cT, cLD, HINT_barwidth); } else if (M_HINT_CHART_TYPE[i][j] == TIMEYLINECHART) { chart = new JGrassXYTimeLineChart(cT, cLD, Minute.class); ((JGrassXYTimeLineChart) chart).setTimeAxisFormat(TIMEFORMAT); } else if (M_HINT_CHART_TYPE[i][j] == TIMEYBARCHART) { chart = new JGrassXYTimeBarChart(cT, cLD, Minute.class, HINT_barwidth); ((JGrassXYTimeBarChart) chart).setTimeAxisFormat(TIMEFORMAT); } else if (M_HINT_CHART_TYPE[i][j] == XYPOINTCHART) { chart = new JGrassXYLineChart(cT, cLD); ((JGrassXYLineChart) chart).toggleLineShapesDisplay(false, true); } else if (M_HINT_CHART_TYPE[i][j] == TIMEXYPOINTCHART) { chart = new JGrassXYTimeLineChart(cT, cLD, Minute.class); ((JGrassXYTimeLineChart) chart).setTimeAxisFormat(TIMEFORMAT); ((JGrassXYTimeLineChart) chart).toggleLineShapesDisplay(false, true); } else { chart = new JGrassXYLineChart(cT, cLD); } final Composite p1Composite = new Composite(dummyShell, SWT.None); p1Composite.setLayout(new FillLayout()); p1Composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); chart.makeChartPanel(p1Composite, title, xT, yT, null, true, true, true, true); chartPlot = (XYPlot) chart.getPlot(); XYItemRenderer renderer = chartPlot.getRenderer(); chartPlot.setDomainGridlinesVisible(HINT_doDomainGridVisible); chartPlot.setRangeGridlinesVisible(HINT_doRangeGridVisible); if (HINT_doDisplayToolTips) { renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); } if (!M_HINT_CHARTORIENTATION_UP[i][j]) { chartPlot.getRangeAxis().setInverted(true); } if (M_HINT_CHARTSERIESCOLOR != null) { final XYItemRenderer rend = renderer; for (int k = 0; k < cLD.length; k++) { rend.setSeriesPaint(k, M_HINT_CHARTSERIESCOLOR[i][j][k]); } } chart.toggleFilledShapeDisplay(HINT_doDisplayBaseShapes, HINT_doFillBaseShapes, true); for (int k = 0; k < cT.length; k++) { chartSeries.put(cT[k], k); } series.add(chartSeries); chartPlot.setNoDataMessage("No data available"); chartPlot.setNoDataMessagePaint(Color.red); plots.add(chartPlot); charts.add(chart.getChart(title, xT, yT, null, true, HINT_doDisplayToolTips, true)); chartsList.add(chart); /* * add annotations? */ if (chartItem.annotationsOnChart.size() > 0) { LinkedHashMap<String, double[]> annotations = chartItem.annotationsOnChart.get(j); if (annotations.size() > 0) { Set<String> keys = annotations.keySet(); for (String key : keys) { double[] c = annotations.get(key); XYPointerAnnotation ann = new XYPointerAnnotation(key, c[0], c[1], HINT_AnnotationArrowAngle); ann.setTextAnchor(HINT_AnnotationTextAncor); ann.setPaint(HINT_AnnotationTextColor); ann.setArrowPaint(HINT_AnnotationArrowColor); // ann.setArrowLength(15); renderer.addAnnotation(ann); // Marker currentEnd = new ValueMarker(c[0]); // currentEnd.setPaint(Color.red); // currentEnd.setLabel(""); // currentEnd.setLabelAnchor(RectangleAnchor.TOP_RIGHT); // currentEnd.setLabelTextAnchor(TextAnchor.TOP_LEFT); // chartPlot.addDomainMarker(currentEnd); // Drawable cd = new LineDrawer(Color.red, new BasicStroke(1.0f)); // XYAnnotation bestBid = new XYDrawableAnnotation(c[0], c[1]/2.0, // 0, c[1], // cd); // chartPlot.addAnnotation(bestBid); // pointer.setFont(new Font("SansSerif", Font.PLAIN, 9)); } } } } } JFreeChart theChart = null; if (plots.size() > 1) { ValueAxis domainAxis = null; if (M_HINT_CHART_TYPE[i][0] == ChartCreator.TIMEYBARCHART || M_HINT_CHART_TYPE[i][0] == ChartCreator.TIMEYLINECHART) { domainAxis = (plots.get(0)).getDomainAxis(); } else { domainAxis = new NumberAxis(chartItem.chartXLabels.get(0)); } final CombinedDomainXYPlot plot = new CombinedDomainXYPlot(domainAxis); plot.setGap(10.0); // add the subplots... for (int k = 0; k < plots.size(); k++) { XYPlot tmpPlot = plots.get(k); if (HINT_labelInsets != null) { tmpPlot.getRangeAxis().setLabelInsets(HINT_labelInsets); } plot.add(tmpPlot, k + 1); } plot.setOrientation(PlotOrientation.VERTICAL); theChart = new JFreeChart(chartItem.bigTitle, JFreeChart.DEFAULT_TITLE_FONT, plot, true); } else if (plots.size() == 1) { theChart = new JFreeChart(chartItem.chartTitles.get(0), JFreeChart.DEFAULT_TITLE_FONT, plots.get(0), true); } else { return; } /* * create the chart composite */ Composite tmp; if (tabNums > 1 && tabFolder != null) { tmp = new Composite(tabFolder, SWT.None); } else { tmp = new Composite(parentComposite, SWT.None); } tmp.setLayoutData(new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL)); tmp.setLayout(new GridLayout()); final ChartComposite frame = new ChartComposite(tmp, SWT.None, theChart, 680, 420, 300, 200, 700, 500, false, true, // properties true, // save true, // print true, // zoom true // tooltips ); // public static final boolean DEFAULT_BUFFER_USED = false; // public static final int DEFAULT_WIDTH = 680; // public static final int DEFAULT_HEIGHT = 420; // public static final int DEFAULT_MINIMUM_DRAW_WIDTH = 300; // public static final int DEFAULT_MINIMUM_DRAW_HEIGHT = 200; // public static final int DEFAULT_MAXIMUM_DRAW_WIDTH = 800; // public static final int DEFAULT_MAXIMUM_DRAW_HEIGHT = 600; // public static final int DEFAULT_ZOOM_TRIGGER_DISTANCE = 10; frame.setLayoutData( new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL)); frame.setLayout(new FillLayout()); frame.setDisplayToolTips(HINT_doDisplayToolTips); frame.setHorizontalAxisTrace(HINT_doHorizontalAxisTrace); frame.setVerticalAxisTrace(HINT_doVerticalAxisTrace); frame.setDomainZoomable(HINT_doDomainZoomable); frame.setRangeZoomable(HINT_doRangeZoomable); if (tabNums > 1 && tabFolder != null) { final TabItem item = new TabItem(tabFolder, SWT.NONE); item.setText(chartData.getChartDataItem(i).chartStringExtra); item.setControl(tmp); } /* * create the hide toggling part */ for (int j = 0; j < plots.size(); j++) { if (M_HINT_CREATE_TOGGLEHIDESERIES[i][j]) { final LinkedHashMap<Button, Integer> allButtons = new LinkedHashMap<Button, Integer>(); Group checksComposite = new Group(tmp, SWT.None); checksComposite.setText(""); RowLayout rowLayout = new RowLayout(); rowLayout.wrap = true; rowLayout.type = SWT.HORIZONTAL; checksComposite.setLayout(rowLayout); checksComposite .setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL)); final XYItemRenderer renderer = plots.get(j).getRenderer(); Set<String> lTitles = series.get(j).keySet(); for (final String title : lTitles) { final Button b = new Button(checksComposite, SWT.CHECK); b.setText(title); b.setSelection(true); final int index = series.get(j).get(title); b.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { boolean visible = renderer.getItemVisible(index, 0); renderer.setSeriesVisible(index, new Boolean(!visible)); } }); allButtons.put(b, index); } /* * toggle all and none */ if (HINT_doToggleTuttiButton) { Composite allchecksComposite = new Composite(tmp, SWT.None); RowLayout allrowLayout = new RowLayout(); allrowLayout.wrap = true; allrowLayout.type = SWT.HORIZONTAL; allchecksComposite.setLayout(allrowLayout); allchecksComposite .setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL)); final Button tuttiButton = new Button(allchecksComposite, SWT.BORDER | SWT.PUSH); tuttiButton.setText("Tutti"); tuttiButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { Set<Button> set = allButtons.keySet(); for (Button button : set) { button.setSelection(true); int i = allButtons.get(button); if (renderer != null) { renderer.setSeriesVisible(i, new Boolean(true)); } } } }); final Button noneButton = new Button(allchecksComposite, SWT.BORDER | SWT.PUSH); noneButton.setText("Nessuno"); noneButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { Set<Button> set = allButtons.keySet(); for (Button button : set) { button.setSelection(false); int i = allButtons.get(button); if (renderer != null) { renderer.setSeriesVisible(i, new Boolean(false)); } } } }); } } } } }
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 ww . 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 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: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 . ja v a 2s . 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 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:SWTAddressBook.java
private void createControlButtons() { Composite composite = new Composite(shell, SWT.NULL); composite.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER)); GridLayout layout = new GridLayout(); layout.numColumns = 2;/*from www . j a v a 2 s .c om*/ composite.setLayout(layout); Button okButton = new Button(composite, SWT.PUSH); okButton.setText("OK"); okButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { shell.close(); } }); Button cancelButton = new Button(composite, SWT.PUSH); cancelButton.setText("Cancel"); cancelButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { values = null; shell.close(); } }); shell.setDefaultButton(okButton); }
From source file:SWTAddressBook.java
private void createTextWidgets() { if (labels == null) return;// w w w . j av a 2 s .c om 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:SWTAddressBook.java
/** * Class constructor that sets the parent shell and the table widget that * the dialog will search.//from w w w . j a v a2 s . co m * * @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(); }
From source file:org.eclipse.swt.examples.browser.demos.views.EditorTab.java
public EditorTab(TabItem item) { final Composite parent = new Composite(item.getParent(), SWT.NONE); item.setText("Editor"); item.setControl(parent);/*from w ww . j a v a2 s . com*/ try { browser = new Browser(parent, SWT.NONE); } catch (SWTError e) { e.printStackTrace(); return; } final Sash sash = new Sash(parent, SWT.VERTICAL); Composite panel = new Composite(parent, SWT.NONE); final FormLayout form = new FormLayout(); parent.setLayout(form); FormData data = new FormData(); data.left = new FormAttachment(0, 0); data.right = new FormAttachment(sash, 0); data.top = new FormAttachment(0, 0); data.bottom = new FormAttachment(100, 0); browser.setLayoutData(data); final FormData sashData = new FormData(); sashData.left = new FormAttachment(50, 0); sashData.top = new FormAttachment(0, 0); sashData.bottom = new FormAttachment(100, 0); sash.setLayoutData(sashData); sash.addListener(SWT.Selection, e -> { Rectangle rect = sash.getBounds(); Rectangle parentRect = sash.getParent().getClientArea(); int right = parentRect.width - rect.width - 20; e.x = Math.max(Math.min(e.x, right), 20); if (e.x != rect.x) { sashData.left = new FormAttachment(0, e.x); parent.layout(); } }); data = new FormData(); data.left = new FormAttachment(sash, 0); data.right = new FormAttachment(100, 0); data.top = new FormAttachment(0, 0); data.bottom = new FormAttachment(100, 0); panel.setLayoutData(data); /* Initialize Panel */ panel.setLayout(new FillLayout(SWT.VERTICAL)); Group htmlGroup = new Group(panel, SWT.NONE); htmlGroup.setText("setText"); htmlText = new Text(htmlGroup, SWT.MULTI); htmlButton = new Button(htmlGroup, SWT.PUSH); htmlButton.setText("setText"); GridLayout gridLayout = new GridLayout(); htmlGroup.setLayout(gridLayout); GridData gridData = new GridData(); gridData.horizontalAlignment = GridData.FILL; gridData.verticalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; gridData.grabExcessVerticalSpace = true; htmlText.setLayoutData(gridData); gridData = new GridData(); gridData.horizontalAlignment = GridData.END; htmlButton.setLayoutData(gridData); htmlGroup.layout(); Group scriptGroup = new Group(panel, SWT.NONE); scriptGroup.setText("execute"); scriptText = new Text(scriptGroup, SWT.MULTI); scriptButton = new Button(scriptGroup, SWT.PUSH); scriptButton.setText("execute"); gridLayout = new GridLayout(); scriptGroup.setLayout(gridLayout); gridData = new GridData(); gridData.horizontalAlignment = GridData.FILL; gridData.verticalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; gridData.grabExcessVerticalSpace = true; scriptText.setLayoutData(gridData); gridData = new GridData(); gridData.horizontalAlignment = GridData.END; scriptButton.setLayoutData(gridData); scriptGroup.layout(); browser.setText(html); htmlText.setText(html); scriptText.setText(script); parent.layout(); Listener listener = e -> { Widget w = e.widget; if (w == htmlButton) browser.setText(htmlText.getText()); if (w == scriptButton) browser.execute(scriptText.getText()); }; htmlButton.addListener(SWT.Selection, listener); scriptButton.addListener(SWT.Selection, listener); }
From source file:au.gov.ansto.bragg.kakadu.ui.plot.FitPlotPropertiesComposite.java
private void initialise() { GridLayout gridLayout = new GridLayout(); gridLayout.numColumns = 2;/* w ww . ja v a2s . c o m*/ gridLayout.marginHeight = 3; gridLayout.marginWidth = 3; gridLayout.horizontalSpacing = 3; gridLayout.verticalSpacing = 3; setLayout(gridLayout); fitEnabledButton = new Button(this, SWT.CHECK); fitEnabledButton.setText("Fitting Enabled"); GridData data = new GridData(); data.horizontalAlignment = GridData.FILL; data.verticalAlignment = GridData.BEGINNING; data.horizontalSpan = 2; data.grabExcessHorizontalSpace = true; fitEnabledButton.setLayoutData(data); fitFunctionCombo = new Combo(this, SWT.READ_ONLY); fitFunctionCombo.setEnabled(false); data = new GridData(); data.horizontalAlignment = GridData.FILL; data.verticalAlignment = GridData.BEGINNING; data.verticalIndent = 3; data.grabExcessHorizontalSpace = true; fitFunctionCombo.setLayoutData(data); // inverseLabel = new Label(this, SWT.NONE); // inverseLabel.setText("inverse function"); // data = new GridData (); // data.verticalAlignment = GridData.BEGINNING; // data.verticalIndent = 3; // inverseLabel.setLayoutData(data); // inverseLabel.setEnabled(false); inverseButton = new Button(this, SWT.CHECK); inverseButton.setText("Inverted Model"); data = new GridData(); data.horizontalAlignment = GridData.FILL; data.verticalIndent = 3; data.grabExcessHorizontalSpace = true; inverseButton.setLayoutData(data); inverseButton.setEnabled(false); // fitFunctionCombo.setLayoutData (data); Composite xComposite = new Composite(this, SWT.NULL); gridLayout = new GridLayout(); gridLayout.numColumns = 4; // gridLayout.marginHeight = 3; gridLayout.marginWidth = 0; // gridLayout.horizontalSpacing = 3; // gridLayout.verticalSpacing = 3; xComposite.setLayout(gridLayout); data = new GridData(); data.horizontalAlignment = GridData.FILL; data.horizontalSpan = 2; data.grabExcessHorizontalSpace = true; xComposite.setLayoutData(data); minXButton = new Button(xComposite, SWT.TOGGLE); minXButton.setText("X min"); minXButton.setToolTipText("Click to enable grabing a point from the plot as the beginning of fitting data"); data = new GridData(); // data.horizontalAlignment = GridData.FILL; data.verticalAlignment = GridData.BEGINNING; // data.grabExcessHorizontalSpace = true; // data.grabExcessVerticalSpace = true; minXButton.setLayoutData(data); minXButton.setEnabled(false); minXText = new Text(xComposite, SWT.BORDER); data = new GridData(); data.horizontalAlignment = GridData.FILL; data.verticalAlignment = GridData.BEGINNING; data.grabExcessHorizontalSpace = true; // data.grabExcessVerticalSpace = true; minXText.setLayoutData(data); minXText.setEnabled(false); maxXButton = new Button(xComposite, SWT.TOGGLE); maxXButton.setText("X max"); maxXButton.setToolTipText("Click to enable grabing a point from the plot as the end of fitting data"); data = new GridData(); // data.horizontalAlignment = GridData.FILL; data.verticalAlignment = GridData.BEGINNING; // data.grabExcessHorizontalSpace = true; // data.grabExcessVerticalSpace = true; maxXButton.setLayoutData(data); maxXButton.setEnabled(false); maxXText = new Text(xComposite, SWT.BORDER); data = new GridData(); data.horizontalAlignment = GridData.FILL; data.verticalAlignment = GridData.BEGINNING; data.grabExcessHorizontalSpace = true; // data.grabExcessVerticalSpace = true; maxXText.setLayoutData(data); maxXText.setEnabled(false); doFitButton = new Button(this, SWT.PUSH); doFitButton.setText("Fit"); data = new GridData(); data.horizontalAlignment = GridData.FILL; data.verticalAlignment = GridData.BEGINNING; data.grabExcessHorizontalSpace = true; // data.grabExcessVerticalSpace = true; doFitButton.setLayoutData(data); doFitButton.setEnabled(false); resetButton = new Button(this, SWT.PUSH); resetButton.setText("Reset"); data = new GridData(); data.horizontalAlignment = GridData.FILL; data.verticalAlignment = GridData.BEGINNING; data.grabExcessHorizontalSpace = true; resetButton.setLayoutData(data); resetButton.setEnabled(false); 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; data.verticalAlignment = GridData.BEGINNING; parameterGroup.setLayoutData(data); }