List of usage examples for org.eclipse.swt.widgets Label Label
public Label(Composite parent, int style)
From source file:org.jfree.experimental.chart.swt.editor.SWTPlotAppearanceEditor.java
SWTPlotAppearanceEditor(Composite parent, int style, Plot plot) { super(parent, style); FillLayout layout = new FillLayout(); layout.marginHeight = layout.marginWidth = 4; this.setLayout(layout); Group general = new Group(this, SWT.NONE); GridLayout groupLayout = new GridLayout(3, false); groupLayout.marginHeight = groupLayout.marginWidth = 4; general.setLayout(groupLayout);//from w w w . j ava 2s.c o m general.setText(localizationResources.getString("General")); // row 1: stroke new Label(general, SWT.NONE).setText(localizationResources.getString("Outline_stroke")); this.strokeCanvas = new SWTStrokeCanvas(general, SWT.NONE); this.strokeCanvas.setStroke(plot.getOutlineStroke()); GridData strokeGridData = new GridData(SWT.FILL, SWT.CENTER, true, false); strokeGridData.heightHint = 20; this.strokeCanvas.setLayoutData(strokeGridData); this.selectStroke = new Spinner(general, SWT.BORDER); this.selectStroke.setMinimum(1); this.selectStroke.setMaximum(3); this.selectStroke.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false)); this.selectStroke.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { int w = SWTPlotAppearanceEditor.this.selectStroke.getSelection(); if (w > 0) { SWTPlotAppearanceEditor.this.strokeCanvas.setStroke(new BasicStroke(w)); SWTPlotAppearanceEditor.this.strokeCanvas.redraw(); } } }); // row 2: outline color new Label(general, SWT.NONE).setText(localizationResources.getString("Outline_Paint")); this.outlinePaintCanvas = new SWTPaintCanvas(general, SWT.NONE, SWTUtils.toSwtColor(getDisplay(), plot.getOutlinePaint())); GridData outlineGridData = new GridData(SWT.FILL, SWT.CENTER, true, false); outlineGridData.heightHint = 20; this.outlinePaintCanvas.setLayoutData(outlineGridData); Button selectOutlineColor = new Button(general, SWT.PUSH); selectOutlineColor.setText(localizationResources.getString("Select...")); selectOutlineColor.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false)); selectOutlineColor.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { ColorDialog dlg = new ColorDialog(getShell()); dlg.setText(localizationResources.getString("Outline_Paint")); dlg.setRGB(SWTPlotAppearanceEditor.this.outlinePaintCanvas.getColor().getRGB()); RGB rgb = dlg.open(); if (rgb != null) { SWTPlotAppearanceEditor.this.outlinePaintCanvas.setColor(new Color(getDisplay(), rgb)); } } }); // row 3: background paint new Label(general, SWT.NONE).setText(localizationResources.getString("Background_paint")); this.backgroundPaintCanvas = new SWTPaintCanvas(general, SWT.NONE, SWTUtils.toSwtColor(getDisplay(), plot.getBackgroundPaint())); GridData bgGridData = new GridData(SWT.FILL, SWT.CENTER, true, false); bgGridData.heightHint = 20; this.backgroundPaintCanvas.setLayoutData(bgGridData); Button selectBgPaint = new Button(general, SWT.PUSH); selectBgPaint.setText(localizationResources.getString("Select...")); selectBgPaint.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false)); selectBgPaint.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { ColorDialog dlg = new ColorDialog(getShell()); dlg.setText(localizationResources.getString("Background_paint")); dlg.setRGB(SWTPlotAppearanceEditor.this.backgroundPaintCanvas.getColor().getRGB()); RGB rgb = dlg.open(); if (rgb != null) { SWTPlotAppearanceEditor.this.backgroundPaintCanvas.setColor(new Color(getDisplay(), rgb)); } } }); // row 4: orientation if (plot instanceof CategoryPlot) { this.plotOrientation = ((CategoryPlot) plot).getOrientation(); } else if (plot instanceof XYPlot) { this.plotOrientation = ((XYPlot) plot).getOrientation(); } if (this.plotOrientation != null) { boolean isVertical = this.plotOrientation.equals(PlotOrientation.VERTICAL); int index = isVertical ? ORIENTATION_VERTICAL : ORIENTATION_HORIZONTAL; new Label(general, SWT.NONE).setText(localizationResources.getString("Orientation")); this.orientation = new Combo(general, SWT.DROP_DOWN); this.orientation.setItems(orientationNames); this.orientation.select(index); this.orientation.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, false, 2, 1)); this.orientation.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { switch (SWTPlotAppearanceEditor.this.orientation.getSelectionIndex()) { case ORIENTATION_VERTICAL: SWTPlotAppearanceEditor.this.plotOrientation = PlotOrientation.VERTICAL; break; case ORIENTATION_HORIZONTAL: SWTPlotAppearanceEditor.this.plotOrientation = PlotOrientation.HORIZONTAL; break; default: SWTPlotAppearanceEditor.this.plotOrientation = PlotOrientation.VERTICAL; } } }); } }
From source file:com.rcp.wbw.demo.editor.SWTNumberAxisEditor.java
/** * Creates a new editor.// ww w .j av a2 s. c o m * * @param parent * the parent. * @param style * the style. * @param axis * the axis. */ public SWTNumberAxisEditor(Composite parent, int style, NumberAxis axis) { super(parent, style, axis); this.autoRange = axis.isAutoRange(); this.minimumValue = axis.getLowerBound(); this.maximumValue = axis.getUpperBound(); TabItem item2 = new TabItem(getOtherTabs(), SWT.NONE); item2.setText(" " + localizationResources.getString("Range") + " "); Composite range = new Composite(getOtherTabs(), SWT.NONE); range.setLayout(new GridLayout(2, true)); item2.setControl(range); this.autoRangeCheckBox = new Button(range, SWT.CHECK); this.autoRangeCheckBox.setText(localizationResources.getString("Auto-adjust_range")); this.autoRangeCheckBox.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1)); this.autoRangeCheckBox.setSelection(this.autoRange); this.autoRangeCheckBox.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { toggleAutoRange(); } }); new Label(range, SWT.NONE).setText(localizationResources.getString("Minimum_range_value")); this.minimumRangeValue = new Text(range, SWT.BORDER); this.minimumRangeValue.setText(String.valueOf(this.minimumValue)); this.minimumRangeValue.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); this.minimumRangeValue.setEnabled(!this.autoRange); // this.minimumRangeValue.addModifyListener(this); // this.minimumRangeValue.addVerifyListener(this); this.minimumRangeValue.addFocusListener(this); new Label(range, SWT.NONE).setText(localizationResources.getString("Maximum_range_value")); this.maximumRangeValue = new Text(range, SWT.BORDER); this.maximumRangeValue.setText(String.valueOf(this.maximumValue)); this.maximumRangeValue.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); this.maximumRangeValue.setEnabled(!this.autoRange); // this.maximumRangeValue.addModifyListener(this); // this.maximumRangeValue.addVerifyListener(this); this.maximumRangeValue.addFocusListener(this); }
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();//w w w.j av a 2 s . 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:net.bioclipse.chembl.moss.ui.wizard.ChemblMossWizardPage1.java
@Override public void createControl(Composite parent) { final Composite container = new Composite(parent, SWT.NONE); final GridLayout layout = new GridLayout(4, false); layout.marginRight = 2;//w ww .ja va2 s .co m layout.marginLeft = 2; layout.marginBottom = -2; layout.marginTop = 10; layout.marginWidth = 2; layout.marginHeight = 2; layout.verticalSpacing = 5; layout.horizontalSpacing = 5; container.setLayout(layout); PlatformUI.getWorkbench().getHelpSystem().setHelp(container, "net.bioclipse.moss.business.helpmessage"); setControl(container); setMessage("Select the first protein family to compare with substructure mining."); setPageComplete(false); label = new Label(container, SWT.NONE); gridData = new GridData(GridData.FILL); gridData.grabExcessHorizontalSpace = true; gridData.horizontalSpan = 2; label.setLayoutData(gridData); label.setText("Choose a Kinase Protein Family"); cbox = new Combo(container, SWT.READ_ONLY); cbox.setToolTipText("Kinase family"); gridData = new GridData(); gridData.grabExcessHorizontalSpace = true; gridData.horizontalSpan = 2; gridData.widthHint = 100; cbox.setLayoutData(gridData); String[] items = { "TK", "TKL", "STE", "CK1", "CMGC", "AGC", "CAMK" }; cbox.setItems(items); cbox.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { final String selected = cbox.getItem(cbox.getSelectionIndex()); try { table.clearAll(); table.removeAll(); setErrorMessage(null); List<String> list = chembl.mossAvailableActivities(selected); if (list.size() > 0) { String[] item = new String[list.size()]; for (int i = 0; i < list.size(); i++) { item[i] = list.get(i); } if (cboxAct.isEnabled()) { if (cboxAct.getSelection().x == cboxAct.getSelection().y) { cboxAct.setItems(item); } else { //Solves the problem involving changing the protein family... //Brings the current activities to an array String oldItems[] = cboxAct.getItems(); // Takes that array and makes it a list for (int i = 0; i < list.size(); i++) { cboxAct.add(item[i]); } //Remove the old items in the combobox int oldlistsize = cboxAct.getItemCount() - list.size(); index = cboxAct.getText();//cboxAct.getItem(cboxAct.getSelectionIndex()); cboxAct.remove(0, oldlistsize - 1); //Adds new items to the comboboxlist List<String> oldItemsList = new ArrayList<String>(); for (int i = 0; i < oldItems.length; i++) { oldItemsList.add(oldItems[i]); } //New query with the given settings //if(oldItemsList.contains((index))==true){ if (list.contains((index)) == true) { spinn.setSelection(50); IStringMatrix matrix, matrix2; try { matrix = chembl.mossGetCompoundsFromProteinFamilyWithActivity(selected, index, spinn.getSelection()); matrix2 = chembl.mossGetCompoundsFromProteinFamily(selected, index); helpToHistogram(chembl .mossGetCompoundsFromProteinFamilyWithActivity(selected, index)); cboxAct.setText(index); info.setText("Distinct compunds: " + matrix2.getRowCount()); addToTable(matrix); //adds info about target, activities and compounds to a file ((ChemblMossWizard) getWizard()).data.matrix3 = chembl .mossGetCompoundsFromProteinFamilyWithActivityTarget( cbox.getItem(cbox.getSelectionIndex()), cboxAct.getItem(cboxAct.getSelectionIndex()), spinn.getSelection()); //adds the query to a file ((ChemblMossWizard) getWizard()).data.query = chembl .mossGetCompoundsFromProteinFamilyWithActivitySPARQL(selected, index); } catch (BioclipseException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } else { setErrorMessage("The activity " + index + " does not exist for the protein family " + selected + "."); info.setText("Total compund hit:"); setPageComplete(false); } } } else { cboxAct.setItems(item); cboxAct.setEnabled(true); } } } catch (BioclipseException e1) { e1.printStackTrace(); } } }); /*Returns the available compunds for the family*/ label = new Label(container, SWT.NONE); gridData = new GridData(GridData.FILL); gridData.grabExcessHorizontalSpace = true; gridData.horizontalSpan = 2; label.setLayoutData(gridData); label.setText("Choose one available activity"); cboxAct = new Combo(container, SWT.READ_ONLY); gridData = new GridData(GridData.FILL); gridData.grabExcessHorizontalSpace = true; gridData.horizontalSpan = 2; gridData.widthHint = 100; String[] item = { "No available activity" }; cboxAct.setItems(item); cboxAct.setLayoutData(gridData); cboxAct.setEnabled(false); cboxAct.setToolTipText("These activities are only accurate for chosen protein"); //Listener for available activities(IC50, Ki etc) cboxAct.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { String selected = cboxAct.getItem(cboxAct.getSelectionIndex()); try { setErrorMessage(null); table.clearAll(); table.removeAll(); spinn.setSelection(50); check.setSelection(false); spinnLow.setEnabled(false); spinnHigh.setEnabled(false); spinnLow.setSelection(0); spinnHigh.setSelection(1000); //SPARQL queries for fetching compounds and activities IStringMatrix matrix = chembl.mossGetCompoundsFromProteinFamilyWithActivity( cbox.getItem(cbox.getSelectionIndex()), selected, spinn.getSelection()); addToTable(matrix); //Count the amount of compounds there is for one hit, i.e. same query without limit. IStringMatrix matrix2 = chembl.mossGetCompoundsFromProteinFamily( cbox.getItem(cbox.getSelectionIndex()), cboxAct.getItem(cboxAct.getSelectionIndex())); info.setText("Distinct compounds: " + matrix2.getRowCount()); //Query for activities. Adds them to the plot series. matrixAct = chembl.mossGetCompoundsFromProteinFamilyWithActivity( cbox.getItem(cbox.getSelectionIndex()), selected); //IStringMatrix matrix = chembl.MossProtFamilyCompounds(cbox.getItem(cbox.getSelectionIndex()), selected,50); //IStringMatrix matrix = chembl.MossProtFamilyCompounds(cbox.getItem(cbox.getSelectionIndex()), selected, spinn.getSelection()); ((ChemblMossWizard) getWizard()).data.matrix3 = chembl .mossGetCompoundsFromProteinFamilyWithActivityTarget( cbox.getItem(cbox.getSelectionIndex()), selected, spinn.getSelection()); ((ChemblMossWizard) getWizard()).data.query = chembl .mossGetCompoundsFromProteinFamilyWithActivitySPARQL( cbox.getItem(cbox.getSelectionIndex()), selected); //Adds activity to histogram series helpToHistogram(matrixAct); // series = new XYSeries("Activity for compounds"); // histogramSeries = new HistogramDataset(); // histogramSeries.setType(HistogramType.FREQUENCY); // ArrayList<Double> activites = new ArrayList<Double>(); // double value; // int cnt =1; // double[] histact = new double[matrixAct.getRowCount()+1]; // for(int i = 1; i< matrixAct.getRowCount()+1;i++){ // if(matrixAct.get(i,"actval").equals("")){ value =0;} // else{value = Double.parseDouble(matrixAct.get(i,"actval"));} // activites.add(value); // } // //Sort list to increasing order of activities and adds them to histogram // Collections.sort(activites); // for(int i=0; i< activites.size(); i++){ // double d=activites.get(i); // histact[i]=d; // int t= activites.size()-1; // if(i == t){ // series.add(d,cnt); // }else{ // double dd= activites.get(i+1); // // if(d==dd){ // cnt++; // } // else{ // histact[i]=d; // series.add(d,cnt); // cnt =1; // } // } // } // histogramSeries.addSeries("Histogram",histact,matrixAct.getRowCount()); button.setEnabled(true); spinn.setEnabled(true); check.setEnabled(true); //cboxAct.setEnabled(true); //buttonH.setEnabled(true); } catch (BioclipseException e1) { e1.printStackTrace(); } setPageComplete(true); } }); label = new Label(container, SWT.NONE); gridData = new GridData(); gridData.grabExcessHorizontalSpace = true; gridData.horizontalSpan = 2; label.setLayoutData(gridData); label.setText("Limit"); spinn = new Spinner(container, SWT.BORDER); gridData = new GridData(); spinn.setLayoutData(gridData); spinn.setSelection(50); spinn.setMaximum(10000000); spinn.setIncrement(50); spinn.setEnabled(false); gridData.widthHint = 100; gridData.horizontalSpan = 1; spinn.setToolTipText("Limits the search, increases by 50"); spinn.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { int selected = spinn.getSelection(); try { table.clearAll(); table.removeAll(); IStringMatrix matrix = chembl.mossGetCompounds(cbox.getItem(cbox.getSelectionIndex()), cboxAct.getItem(cboxAct.getSelectionIndex()), selected); table.setVisible(true); addToTable(matrix); } catch (BioclipseException e1) { e1.printStackTrace(); } } }); //Button that adds all hits to the limit button = new Button(container, SWT.PUSH); button.setToolTipText("Add all compounds to the table"); button.setText("Display all"); button.setEnabled(false); button.setLayoutData(gridData); gridData = new GridData(); gridData.horizontalSpan = 1; button.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { //try { table.removeAll(); // ProgressMonitorDialog dialog = new ProgressMonitorDialog(container.getShell()); // // try { // dialog.run(true, true, new IRunnableWithProgress(){ // public void run(IProgressMonitor monitor) { // monitor.beginTask("Searching for compounds", IProgressMonitor.UNKNOWN); try { IStringMatrix matrix = chembl.mossGetCompoundsFromProteinFamilyWithActivity( cbox.getItem(cbox.getSelectionIndex()), cboxAct.getItem(cboxAct.getSelectionIndex())); // final IStringMatrix matrix = chembl.MossProtFamilyCompoundsAct("TK", "Ki"); addToTable(matrix); info.setText("Total hit(not always distinct compounds): " + matrix.getRowCount()); spinn.setSelection(matrix.getRowCount()); } catch (BioclipseException eb) { // TODO Auto-generated catch block eb.printStackTrace(); } // // monitor.done(); // } // }); // } catch (InvocationTargetException e1) { // // TODO Auto-generated catch block // e1.printStackTrace(); // } catch (InterruptedException e1) { // // TODO Auto-generated catch block // e1.printStackTrace(); // } // } catch (BioclipseException e1) { // // TODO Auto-generated catch block // e1.printStackTrace(); // } } }); // label = new Label(container, SWT.NONE); // label.setText("Optional: Modify activity values."); // gridData = new GridData(); // gridData.horizontalSpan=4; // gridData.verticalSpan=5; // label.setLayoutData(gridData); check = new Button(container, SWT.CHECK); check.setText("Modify activities (optional)"); check.setToolTipText("Modify data by specifying upper and lower activity limit"); check.setEnabled(false); gridData = new GridData(GridData.BEGINNING); gridData.horizontalSpan = 2; check.setLayoutData(gridData); check.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { boolean selected = check.getSelection(); if (selected == true) { spinnLow.setEnabled(true); spinnHigh.setEnabled(true); buttonUpdate.setEnabled(true); labelHigh.setEnabled(true); labelLow.setEnabled(true); buttonH.setEnabled(true); } else if (selected == false) { spinnLow.setEnabled(false); spinnHigh.setEnabled(false); buttonUpdate.setEnabled(false); labelHigh.setEnabled(false); labelLow.setEnabled(false); buttonH.setEnabled(false); } } }); label = new Label(container, SWT.NONE); label.setText("Look at activity span: "); label.setToolTipText("The graph don't consider limited search, will display for all available compounds"); gridData = new GridData(); gridData.horizontalSpan = 1; label.setLayoutData(gridData); buttonH = new Button(container, SWT.PUSH); buttonH.setText("Graph"); buttonH.setToolTipText("Shows activity in a graph(for all compounds)"); buttonH.setEnabled(false); gridData = new GridData(); gridData.horizontalSpan = 1; buttonH.setLayoutData(gridData); buttonH.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { JFreeChart jfreechart = ChartFactory.createXYLineChart("Histogram Demo", "Activity values", "Number of compounds", histogramSeries, PlotOrientation.VERTICAL, true, false, false); // final XYSeriesCollection dataset = new XYSeriesCollection(series); // JFreeChart chart = ChartFactory.createXYBarChart( // "Activity chart", // "Activity value", // false, // "Number of Compounds", // dataset, // PlotOrientation.VERTICAL, // true, // true, // false // ); ChartFrame frame = new ChartFrame("Activities", jfreechart); frame.pack(); frame.setVisible(true); } }); // Lower activity bound for updating table labelLow = new Label(container, SWT.NONE); labelLow.setText("Lower activity limit"); labelLow.setEnabled(false); gridData = new GridData(); gridData.horizontalSpan = 1; labelLow.setLayoutData(gridData); spinnLow = new Spinner(container, SWT.NONE); spinnLow.setSelection(1); spinnLow.setMaximum(10000000); spinnLow.setIncrement(50); spinnLow.setEnabled(false); spinnLow.setToolTipText("Specify lower activity limit"); gridData = new GridData(); gridData.widthHint = 100; gridData.horizontalSpan = 1; spinnLow.setLayoutData(gridData); buttonUpdate = new Button(container, SWT.PUSH); buttonUpdate.setText("Update table"); buttonUpdate.setToolTipText("Update the table with the specified activity limits"); buttonUpdate.setEnabled(false); gridData = new GridData(); gridData.horizontalSpan = 2; buttonUpdate.setLayoutData(gridData); buttonUpdate.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { table.clearAll(); table.removeAll(); try { IStringMatrix mmatrixAct = chembl.mossGetCompoundsFromProteinFamilyWithActivity( cbox.getItem(cbox.getSelectionIndex()), cboxAct.getText()); IStringMatrix matrix = chembl.mossSetActivityBound(mmatrixAct, spinnLow.getSelection(), spinnHigh.getSelection()); // IStringMatrix m = chembl.mossSetActivityOutsideBound(matrixAct, spinnLow.getSelection(), spinnHigh.getSelection()); addToTable(matrix); int yes = 0, no = 0; for (int index = 1; index < matrix.getRowCount() + 1; index++) { if (matrix.get(index, "active").equals("yes")) { yes++; } else no++; } spinn.setSelection(matrix.getRowCount()); info.setText("Total compound hit: " + matrix.getRowCount() + ": active: " + yes + ", inactive: " + no); } catch (BioclipseException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } }); //Upper activity bound for updating table labelHigh = new Label(container, SWT.NONE); labelHigh.setText("Upper activity limit"); labelHigh.setEnabled(false); gridData = new GridData(); gridData.horizontalSpan = 1; labelHigh.setLayoutData(gridData); spinnHigh = new Spinner(container, SWT.BORDER); spinnHigh.setSelection(1000); spinnHigh.setMaximum(1000000000); spinnHigh.setIncrement(50); spinnHigh.setEnabled(false); spinnHigh.setToolTipText("Specify upper activity limit"); gridData = new GridData(); gridData.widthHint = 100; gridData.horizontalSpan = 3; spinnHigh.setLayoutData(gridData); //Label for displaying compound hits info = new Label(container, SWT.NONE); gridData = new GridData(); info.setLayoutData(gridData); gridData.horizontalSpan = 4; gridData.verticalSpan = 6; gridData.widthHint = 350; info.setText("Total compound hit:"); //Table displaying contents table = new Table(container, SWT.BORDER); table.setHeaderVisible(true); table.setLinesVisible(true); gridData = new GridData(); gridData.horizontalAlignment = GridData.FILL; gridData.verticalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; gridData.grabExcessVerticalSpace = true; gridData.widthHint = 300; gridData.heightHint = 300; gridData.horizontalSpan = 4; table.setLayoutData(gridData); column1 = new TableColumn(table, SWT.NONE); column1.setText("Index"); column2 = new TableColumn(table, SWT.NONE); column2.setText("Activity value"); column3 = new TableColumn(table, SWT.NONE); column3.setText("Active?"); column4 = new TableColumn(table, SWT.NONE); column4.setText("Compounds (SMILES)"); }
From source file:com.rcp.wbw.demo.editor.SWTPlotAppearanceEditor.java
SWTPlotAppearanceEditor(Composite parent, int style, Plot plot) { super(parent, style); FillLayout layout = new FillLayout(); layout.marginHeight = layout.marginWidth = 4; setLayout(layout);/*from ww w .jav a 2 s. c o m*/ Group general = new Group(this, SWT.NONE); GridLayout groupLayout = new GridLayout(3, false); groupLayout.marginHeight = groupLayout.marginWidth = 4; general.setLayout(groupLayout); general.setText(localizationResources.getString("General")); // row 1: stroke new Label(general, SWT.NONE).setText(localizationResources.getString("Outline_stroke")); this.strokeCanvas = new SWTStrokeCanvas(general, SWT.NONE); this.strokeCanvas.setStroke(plot.getOutlineStroke()); GridData strokeGridData = new GridData(SWT.FILL, SWT.CENTER, true, false); strokeGridData.heightHint = 20; this.strokeCanvas.setLayoutData(strokeGridData); this.selectStroke = new Spinner(general, SWT.BORDER); this.selectStroke.setMinimum(1); this.selectStroke.setMaximum(3); this.selectStroke.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false)); this.selectStroke.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { int w = SWTPlotAppearanceEditor.this.selectStroke.getSelection(); if (w > 0) { SWTPlotAppearanceEditor.this.strokeCanvas.setStroke(new BasicStroke(w)); SWTPlotAppearanceEditor.this.strokeCanvas.redraw(); } } }); // row 2: outline color new Label(general, SWT.NONE).setText(localizationResources.getString("Outline_Paint")); this.outlinePaintCanvas = new SWTPaintCanvas(general, SWT.NONE, SWTUtils.toSwtColor(getDisplay(), plot.getOutlinePaint())); GridData outlineGridData = new GridData(SWT.FILL, SWT.CENTER, true, false); outlineGridData.heightHint = 20; this.outlinePaintCanvas.setLayoutData(outlineGridData); Button selectOutlineColor = new Button(general, SWT.PUSH); selectOutlineColor.setText(localizationResources.getString("Select...")); selectOutlineColor.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false)); selectOutlineColor.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { ColorDialog dlg = new ColorDialog(getShell()); dlg.setText(localizationResources.getString("Outline_Paint")); dlg.setRGB(SWTPlotAppearanceEditor.this.outlinePaintCanvas.getColor().getRGB()); RGB rgb = dlg.open(); if (rgb != null) { SWTPlotAppearanceEditor.this.outlinePaintCanvas.setColor(new Color(getDisplay(), rgb)); } } }); // row 3: background paint new Label(general, SWT.NONE).setText(localizationResources.getString("Background_paint")); this.backgroundPaintCanvas = new SWTPaintCanvas(general, SWT.NONE, SWTUtils.toSwtColor(getDisplay(), plot.getBackgroundPaint())); GridData bgGridData = new GridData(SWT.FILL, SWT.CENTER, true, false); bgGridData.heightHint = 20; this.backgroundPaintCanvas.setLayoutData(bgGridData); Button selectBgPaint = new Button(general, SWT.PUSH); selectBgPaint.setText(localizationResources.getString("Select...")); selectBgPaint.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false)); selectBgPaint.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { ColorDialog dlg = new ColorDialog(getShell()); dlg.setText(localizationResources.getString("Background_paint")); dlg.setRGB(SWTPlotAppearanceEditor.this.backgroundPaintCanvas.getColor().getRGB()); RGB rgb = dlg.open(); if (rgb != null) { SWTPlotAppearanceEditor.this.backgroundPaintCanvas.setColor(new Color(getDisplay(), rgb)); } } }); // row 4: orientation if (plot instanceof CategoryPlot) { this.plotOrientation = ((CategoryPlot) plot).getOrientation(); } else if (plot instanceof XYPlot) { this.plotOrientation = ((XYPlot) plot).getOrientation(); } if (this.plotOrientation != null) { boolean isVertical = this.plotOrientation.equals(PlotOrientation.VERTICAL); int index = isVertical ? ORIENTATION_VERTICAL : ORIENTATION_HORIZONTAL; new Label(general, SWT.NONE).setText(localizationResources.getString("Orientation")); this.orientation = new Combo(general, SWT.DROP_DOWN); this.orientation.setItems(orientationNames); this.orientation.select(index); this.orientation.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, false, 2, 1)); this.orientation.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { switch (SWTPlotAppearanceEditor.this.orientation.getSelectionIndex()) { case ORIENTATION_VERTICAL: SWTPlotAppearanceEditor.this.plotOrientation = PlotOrientation.VERTICAL; break; case ORIENTATION_HORIZONTAL: SWTPlotAppearanceEditor.this.plotOrientation = PlotOrientation.HORIZONTAL; break; default: SWTPlotAppearanceEditor.this.plotOrientation = PlotOrientation.VERTICAL; } } }); } }
From source file:Ch11WizardComposite.java
public void createControl(Composite parent) { Composite topLevel = new Composite(parent, SWT.NONE); topLevel.setLayout(new GridLayout(2, false)); Label l = new Label(topLevel, SWT.CENTER); l.setText("Use default directory?"); button = new Button(topLevel, SWT.CHECK); setControl(topLevel);/*from w w w . ja va 2s . c o m*/ setPageComplete(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();//w w w . ja v a 2 s .com 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.jcryptool.visual.verifiablesecretsharing.views.ReconstructionChartComposite.java
/** * Generates the head of the tab. The head has a title and a description. *///from w w w .j av a 2 s.co m private void createHead() { final Composite head = new Composite(this, SWT.NONE); head.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); head.setLayout(new GridLayout()); final Label label = new Label(head, SWT.NONE); label.setFont(FontService.getHeaderFont()); label.setText(Messages.VerifiableSecretSharingComposite_tab_title); stDescription = new StyledText(head, SWT.READ_ONLY | SWT.MULTI | SWT.WRAP); stDescription.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); if (reconstructedPolynom.toString().compareTo("0") == 0) { stDescription.setText(Messages.ChartComposite_noGraph); } else { stDescription.setText(reconstructedPolynom.toString()); } }
From source file:MainClass.java
public void createControl(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); composite.setLayout(new GridLayout(2, false)); new Label(composite, SWT.LEFT).setText("E-mail Address:"); final Text ea = new Text(composite, SWT.BORDER); ea.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); ea.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent event) { email = ea.getText();//w ww. j a v a 2s. co m setPageComplete(email.length() > 0); } }); setControl(composite); }
From source file:org.jfree.experimental.chart.swt.editor.SWTTitleEditor.java
/** * Standard constructor: builds a panel for displaying/editing the * properties of the specified title./*w w w .ja va2 s.c om*/ * * @param title the title, which should be changed. */ SWTTitleEditor(Composite parent, int style, Title title) { super(parent, style); FillLayout layout = new FillLayout(); layout.marginHeight = layout.marginWidth = 4; setLayout(layout); TextTitle t = (title != null ? (TextTitle) title : new TextTitle(localizationResources.getString("Title"))); this.showTitle = (title != null); this.titleFont = SWTUtils.toSwtFontData(getDisplay(), t.getFont(), true); this.titleColor = SWTUtils.toSwtColor(getDisplay(), t.getPaint()); Group general = new Group(this, SWT.NONE); general.setLayout(new GridLayout(3, false)); general.setText(localizationResources.getString("General")); // row 1 Label label = new Label(general, SWT.NONE); label.setText(localizationResources.getString("Show_Title")); GridData gridData = new GridData(); gridData.horizontalSpan = 2; label.setLayoutData(gridData); this.showTitleCheckBox = new Button(general, SWT.CHECK); this.showTitleCheckBox.setSelection(this.showTitle); this.showTitleCheckBox.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false)); this.showTitleCheckBox.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { SWTTitleEditor.this.showTitle = SWTTitleEditor.this.showTitleCheckBox.getSelection(); } }); // row 2 new Label(general, SWT.NONE).setText(localizationResources.getString("Text")); this.titleField = new Text(general, SWT.BORDER); this.titleField.setText(t.getText()); this.titleField.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); new Label(general, SWT.NONE).setText(""); // row 3 new Label(general, SWT.NONE).setText(localizationResources.getString("Font")); this.fontField = new Text(general, SWT.BORDER); this.fontField.setText(this.titleFont.toString()); this.fontField.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); this.selectFontButton = new Button(general, SWT.PUSH); this.selectFontButton.setText(localizationResources.getString("Select...")); this.selectFontButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { // Create the font-change dialog FontDialog dlg = new FontDialog(getShell()); dlg.setText(localizationResources.getString("Font_Selection")); dlg.setFontList(new FontData[] { SWTTitleEditor.this.titleFont }); if (dlg.open() != null) { // Dispose of any fonts we have created if (SWTTitleEditor.this.font != null) { SWTTitleEditor.this.font.dispose(); } // Create the new font and set it into the title // label SWTTitleEditor.this.font = new Font(getShell().getDisplay(), dlg.getFontList()); //titleField.setFont(font); SWTTitleEditor.this.fontField.setText(SWTTitleEditor.this.font.getFontData()[0].toString()); SWTTitleEditor.this.titleFont = SWTTitleEditor.this.font.getFontData()[0]; } } }); // row 4 new Label(general, SWT.NONE).setText(localizationResources.getString("Color")); // Use a SwtPaintCanvas to show the color, note that we must set the // heightHint. final SWTPaintCanvas colorCanvas = new SWTPaintCanvas(general, SWT.NONE, this.titleColor); GridData canvasGridData = new GridData(SWT.FILL, SWT.CENTER, true, false); canvasGridData.heightHint = 20; colorCanvas.setLayoutData(canvasGridData); this.selectColorButton = new Button(general, SWT.PUSH); this.selectColorButton.setText(localizationResources.getString("Select...")); this.selectColorButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { // Create the color-change dialog ColorDialog dlg = new ColorDialog(getShell()); dlg.setText(localizationResources.getString("Title_Color")); dlg.setRGB(SWTTitleEditor.this.titleColor.getRGB()); RGB rgb = dlg.open(); if (rgb != null) { // create the new color and set it to the // SwtPaintCanvas SWTTitleEditor.this.titleColor = new Color(getDisplay(), rgb); colorCanvas.setColor(SWTTitleEditor.this.titleColor); } } }); }