List of usage examples for org.eclipse.swt.widgets Composite setLayout
public void setLayout(Layout layout)
From source file:org.eclipse.swt.examples.dnd.DNDExample.java
private void createDropTypes(Composite parent) { parent.setLayout(new RowLayout(SWT.VERTICAL)); Button textButton = new Button(parent, SWT.CHECK); textButton.setText("Text Transfer"); textButton.addSelectionListener(widgetSelectedAdapter(e -> { Button b = (Button) e.widget; if (b.getSelection()) { addDropTransfer(TextTransfer.getInstance()); } else {// w w w.ja v a2 s. c o m removeDropTransfer(TextTransfer.getInstance()); } })); Button b = new Button(parent, SWT.CHECK); b.setText("RTF Transfer"); b.addSelectionListener(widgetSelectedAdapter(e -> { Button eb = (Button) e.widget; if (eb.getSelection()) { addDropTransfer(RTFTransfer.getInstance()); } else { removeDropTransfer(RTFTransfer.getInstance()); } })); b = new Button(parent, SWT.CHECK); b.setText("HTML Transfer"); b.addSelectionListener(widgetSelectedAdapter(e -> { Button eb = (Button) e.widget; if (eb.getSelection()) { addDropTransfer(HTMLTransfer.getInstance()); } else { removeDropTransfer(HTMLTransfer.getInstance()); } })); b = new Button(parent, SWT.CHECK); b.setText("URL Transfer"); b.addSelectionListener(widgetSelectedAdapter(e -> { Button eb = (Button) e.widget; if (eb.getSelection()) { addDropTransfer(URLTransfer.getInstance()); } else { removeDropTransfer(URLTransfer.getInstance()); } })); b = new Button(parent, SWT.CHECK); b.setText("File Transfer"); b.addSelectionListener(widgetSelectedAdapter(e -> { Button eb = (Button) e.widget; if (eb.getSelection()) { addDropTransfer(FileTransfer.getInstance()); } else { removeDropTransfer(FileTransfer.getInstance()); } })); // initialize state textButton.setSelection(true); addDropTransfer(TextTransfer.getInstance()); }
From source file:org.eclipse.swt.examples.dnd.DNDExample.java
private void createDragOperations(Composite parent) { parent.setLayout(new RowLayout(SWT.VERTICAL)); final Button moveButton = new Button(parent, SWT.CHECK); moveButton.setText("DND.DROP_MOVE"); moveButton.addSelectionListener(widgetSelectedAdapter(e -> { Button b = (Button) e.widget; if (b.getSelection()) { dragOperation |= DND.DROP_MOVE; } else {// w ww.java 2 s .c om dragOperation = dragOperation & ~DND.DROP_MOVE; if (dragOperation == 0) { dragOperation = DND.DROP_MOVE; moveButton.setSelection(true); } } if (dragEnabled) { createDragSource(); } })); Button copyButton = new Button(parent, SWT.CHECK); copyButton.setText("DND.DROP_COPY"); copyButton.addSelectionListener(widgetSelectedAdapter(e -> { Button b = (Button) e.widget; if (b.getSelection()) { dragOperation |= DND.DROP_COPY; } else { dragOperation = dragOperation & ~DND.DROP_COPY; if (dragOperation == 0) { dragOperation = DND.DROP_MOVE; moveButton.setSelection(true); } } if (dragEnabled) { createDragSource(); } })); Button linkButton = new Button(parent, SWT.CHECK); linkButton.setText("DND.DROP_LINK"); linkButton.addSelectionListener(widgetSelectedAdapter(e -> { Button b = (Button) e.widget; if (b.getSelection()) { dragOperation |= DND.DROP_LINK; } else { dragOperation = dragOperation & ~DND.DROP_LINK; if (dragOperation == 0) { dragOperation = DND.DROP_MOVE; moveButton.setSelection(true); } } if (dragEnabled) { createDragSource(); } })); //initialize state moveButton.setSelection(true); copyButton.setSelection(true); linkButton.setSelection(true); dragOperation |= DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK; }
From source file:org.eclipse.swt.examples.dnd.DNDExample.java
private void createDragTypes(Composite parent) { parent.setLayout(new GridLayout()); Button textButton = new Button(parent, SWT.CHECK); textButton.setText("Text Transfer"); textButton.addSelectionListener(widgetSelectedAdapter(e -> { Button b = (Button) e.widget; if (b.getSelection()) { addDragTransfer(TextTransfer.getInstance()); } else {/*from ww w. j av a 2 s .c om*/ removeDragTransfer(TextTransfer.getInstance()); } })); Button b = new Button(parent, SWT.CHECK); b.setText("RTF Transfer"); b.addSelectionListener(widgetSelectedAdapter(e -> { Button b1 = (Button) e.widget; if (b1.getSelection()) { addDragTransfer(RTFTransfer.getInstance()); } else { removeDragTransfer(RTFTransfer.getInstance()); } })); b = new Button(parent, SWT.CHECK); b.setText("HTML Transfer"); b.addSelectionListener(widgetSelectedAdapter(e -> { Button b2 = (Button) e.widget; if (b2.getSelection()) { addDragTransfer(HTMLTransfer.getInstance()); } else { removeDragTransfer(HTMLTransfer.getInstance()); } })); b = new Button(parent, SWT.CHECK); b.setText("URL Transfer"); b.addSelectionListener(widgetSelectedAdapter(e -> { Button b3 = (Button) e.widget; if (b3.getSelection()) { addDragTransfer(URLTransfer.getInstance()); } else { removeDragTransfer(URLTransfer.getInstance()); } })); b = new Button(parent, SWT.CHECK); b.setText("File Transfer"); b.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); b.addSelectionListener(widgetSelectedAdapter(e -> { Button b4 = (Button) e.widget; if (b4.getSelection()) { addDragTransfer(FileTransfer.getInstance()); } else { removeDragTransfer(FileTransfer.getInstance()); } })); b = new Button(parent, SWT.PUSH); b.setText("Select File(s)"); b.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); b.addSelectionListener(widgetSelectedAdapter(e -> { FileDialog dialog = new FileDialog(fileList.getShell(), SWT.OPEN | SWT.MULTI); String result = dialog.open(); if (result != null && result.length() > 0) { fileList.removeAll(); String path = dialog.getFilterPath(); String[] names = dialog.getFileNames(); for (String name : names) { fileList.add(path + File.separatorChar + name); } } })); fileList = new List(parent, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); GridData data = new GridData(); data.grabExcessHorizontalSpace = true; data.horizontalAlignment = GridData.FILL; data.verticalAlignment = GridData.BEGINNING; fileList.setLayoutData(data); // initialize state textButton.setSelection(true); addDragTransfer(TextTransfer.getInstance()); }
From source file:com.android.ddmuilib.HeapPanel.java
/** * Create our control(s)./* w w w. ja va2s . c o m*/ */ @Override protected Control createControl(Composite parent) { mDisplay = parent.getDisplay(); GridLayout gl; mTop = new Composite(parent, SWT.NONE); mTop.setLayout(new GridLayout(1, false)); mTop.setLayoutData(new GridData(GridData.FILL_BOTH)); mUpdateStatus = new Label(mTop, SWT.NONE); setUpdateStatus(NOT_SELECTED); Composite summarySection = new Composite(mTop, SWT.NONE); summarySection.setLayout(gl = new GridLayout(2, false)); gl.marginHeight = gl.marginWidth = 0; mHeapSummary = createSummaryTable(summarySection); mGcButton = new Button(summarySection, SWT.PUSH); mGcButton.setText("Cause GC"); mGcButton.setEnabled(false); mGcButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { Client client = getCurrentClient(); if (client != null) { client.executeGarbageCollector(); } } }); Composite comboSection = new Composite(mTop, SWT.NONE); gl = new GridLayout(2, false); gl.marginHeight = gl.marginWidth = 0; comboSection.setLayout(gl); Label displayLabel = new Label(comboSection, SWT.NONE); displayLabel.setText("Display: "); mDisplayMode = new Combo(comboSection, SWT.READ_ONLY); mDisplayMode.setEnabled(false); mDisplayMode.add("Stats"); if (DISPLAY_HEAP_BITMAP) { mDisplayMode.add("Linear"); if (DISPLAY_HILBERT_BITMAP) { mDisplayMode.add("Hilbert"); } } // the base of the displays. mDisplayBase = new Composite(mTop, SWT.NONE); mDisplayBase.setLayoutData(new GridData(GridData.FILL_BOTH)); mDisplayStack = new StackLayout(); mDisplayBase.setLayout(mDisplayStack); // create the statistics display mStatisticsBase = new Composite(mDisplayBase, SWT.NONE); //mStatisticsBase.setLayoutData(new GridData(GridData.FILL_BOTH)); mStatisticsBase.setLayout(gl = new GridLayout(1, false)); gl.marginHeight = gl.marginWidth = 0; mDisplayStack.topControl = mStatisticsBase; mStatisticsTable = createDetailedTable(mStatisticsBase); mStatisticsTable.setLayoutData(new GridData(GridData.FILL_BOTH)); createChart(); //create the linear composite mLinearBase = new Composite(mDisplayBase, SWT.NONE); //mLinearBase.setLayoutData(new GridData()); gl = new GridLayout(1, false); gl.marginHeight = gl.marginWidth = 0; mLinearBase.setLayout(gl); { mLinearHeapImage = new Label(mLinearBase, SWT.NONE); mLinearHeapImage.setLayoutData(new GridData()); mLinearHeapImage.setImage(ImageLoader.createPlaceHolderArt(mDisplay, PLACEHOLDER_LINEAR_H_SIZE, PLACEHOLDER_LINEAR_V_SIZE, mDisplay.getSystemColor(SWT.COLOR_BLUE))); // create a composite to contain the bottom part (legend) Composite bottomSection = new Composite(mLinearBase, SWT.NONE); gl = new GridLayout(1, false); gl.marginHeight = gl.marginWidth = 0; bottomSection.setLayout(gl); createLegend(bottomSection); } /* mScrolledComposite = new ScrolledComposite(mTop, SWT.H_SCROLL | SWT.V_SCROLL); mScrolledComposite.setLayoutData(new GridData(GridData.FILL_BOTH)); mScrolledComposite.setExpandHorizontal(true); mScrolledComposite.setExpandVertical(true); mScrolledComposite.setContent(mDisplayBase); */ // create the hilbert display. mHilbertBase = new Composite(mDisplayBase, SWT.NONE); //mHilbertBase.setLayoutData(new GridData()); gl = new GridLayout(2, false); gl.marginHeight = gl.marginWidth = 0; mHilbertBase.setLayout(gl); if (DISPLAY_HILBERT_BITMAP) { mHilbertHeapImage = new Label(mHilbertBase, SWT.NONE); mHilbertHeapImage.setLayoutData(new GridData()); mHilbertHeapImage.setImage(ImageLoader.createPlaceHolderArt(mDisplay, PLACEHOLDER_HILBERT_SIZE, PLACEHOLDER_HILBERT_SIZE, mDisplay.getSystemColor(SWT.COLOR_BLUE))); // create a composite to contain the right part (legend + zoom) Composite rightSection = new Composite(mHilbertBase, SWT.NONE); gl = new GridLayout(1, false); gl.marginHeight = gl.marginWidth = 0; rightSection.setLayout(gl); Composite zoomComposite = new Composite(rightSection, SWT.NONE); gl = new GridLayout(2, false); zoomComposite.setLayout(gl); Label l = new Label(zoomComposite, SWT.NONE); l.setText("Zoom:"); mZoom = new Combo(zoomComposite, SWT.READ_ONLY); for (int z : ZOOMS) { mZoom.add(String.format("%1$d%%", z)); //$NON-NLS-1$ } mZoom.select(0); mZoom.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { setLegendText(mZoom.getSelectionIndex()); Client client = getCurrentClient(); if (client != null) { renderHeapData(client.getClientData(), 1, true); mTop.pack(); } } }); createLegend(rightSection); } mHilbertBase.pack(); mLayout = new Composite[] { mStatisticsBase, mLinearBase, mHilbertBase }; mDisplayMode.select(0); mDisplayMode.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { int index = mDisplayMode.getSelectionIndex(); Client client = getCurrentClient(); if (client != null) { if (index == 0) { fillDetailedTable(client, true /* forceRedraw */); } else { renderHeapData(client.getClientData(), index - 1, true /* forceRedraw */); } } mDisplayStack.topControl = mLayout[index]; //mScrolledComposite.setMinSize(mDisplayStack.topControl.computeSize(SWT.DEFAULT, // SWT.DEFAULT)); mDisplayBase.layout(); //mScrolledComposite.redraw(); } }); //mScrolledComposite.setMinSize(mDisplayStack.topControl.computeSize(SWT.DEFAULT, // SWT.DEFAULT)); mDisplayBase.layout(); //mScrolledComposite.redraw(); return mTop; }
From source file:SWTAddressBook.java
private void createTextWidgets() { if (labels == null) return;// w w w . j a v a2 s .c o m Composite composite = new Composite(shell, SWT.NULL); composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); GridLayout layout = new GridLayout(); layout.numColumns = 2; composite.setLayout(layout); if (values == null) values = new String[labels.length]; for (int i = 0; i < labels.length; i++) { Label label = new Label(composite, SWT.RIGHT); label.setText(labels[i]); Text text = new Text(composite, SWT.BORDER); GridData gridData = new GridData(); gridData.widthHint = 400; text.setLayoutData(gridData); if (values[i] != null) { text.setText(values[i]); } text.setData("index", new Integer(i)); addTextListener(text); } }
From source file:DNDExample.java
private void createDropOperations(Composite parent) { parent.setLayout(new RowLayout(SWT.VERTICAL)); final Button moveButton = new Button(parent, SWT.CHECK); moveButton.setText("DND.DROP_MOVE"); moveButton.setSelection(true);//from w w w . j a v a 2 s . co m dropOperation = DND.DROP_MOVE; moveButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { Button b = (Button) e.widget; if (b.getSelection()) { dropOperation |= DND.DROP_MOVE; } else { dropOperation = dropOperation & ~DND.DROP_MOVE; if (dropOperation == 0 || (dropDefaultOperation & DND.DROP_MOVE) != 0) { dropOperation |= DND.DROP_MOVE; moveButton.setSelection(true); } } if (dropEnabled) { createDropTarget(); } } }); final Button copyButton = new Button(parent, SWT.CHECK); copyButton.setText("DND.DROP_COPY"); copyButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { Button b = (Button) e.widget; if (b.getSelection()) { dropOperation |= DND.DROP_COPY; } else { dropOperation = dropOperation & ~DND.DROP_COPY; if (dropOperation == 0 || (dropDefaultOperation & DND.DROP_COPY) != 0) { dropOperation = DND.DROP_COPY; copyButton.setSelection(true); } } if (dropEnabled) { createDropTarget(); } } }); final Button linkButton = new Button(parent, SWT.CHECK); linkButton.setText("DND.DROP_LINK"); linkButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { Button b = (Button) e.widget; if (b.getSelection()) { dropOperation |= DND.DROP_LINK; } else { dropOperation = dropOperation & ~DND.DROP_LINK; if (dropOperation == 0 || (dropDefaultOperation & DND.DROP_LINK) != 0) { dropOperation = DND.DROP_LINK; linkButton.setSelection(true); } } if (dropEnabled) { createDropTarget(); } } }); Button b = new Button(parent, SWT.CHECK); b.setText("DND.DROP_DEFAULT"); defaultParent = new Composite(parent, SWT.NONE); b.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { Button b = (Button) e.widget; if (b.getSelection()) { dropOperation |= DND.DROP_DEFAULT; defaultParent.setVisible(true); } else { dropOperation = dropOperation & ~DND.DROP_DEFAULT; defaultParent.setVisible(false); } if (dropEnabled) { createDropTarget(); } } }); defaultParent.setVisible(false); GridLayout layout = new GridLayout(); layout.marginWidth = 20; defaultParent.setLayout(layout); Label label = new Label(defaultParent, SWT.NONE); label.setText("Value for default operation is:"); b = new Button(defaultParent, SWT.RADIO); b.setText("DND.DROP_MOVE"); b.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { Button b = (Button) e.widget; if (b.getSelection()) { dropDefaultOperation = DND.DROP_MOVE; dropOperation |= DND.DROP_MOVE; moveButton.setSelection(true); if (dropEnabled) { createDropTarget(); } } } }); b = new Button(defaultParent, SWT.RADIO); b.setText("DND.DROP_COPY"); b.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { Button b = (Button) e.widget; if (b.getSelection()) { dropDefaultOperation = DND.DROP_COPY; dropOperation |= DND.DROP_COPY; copyButton.setSelection(true); if (dropEnabled) { createDropTarget(); } } } }); b = new Button(defaultParent, SWT.RADIO); b.setText("DND.DROP_LINK"); b.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { Button b = (Button) e.widget; if (b.getSelection()) { dropDefaultOperation = DND.DROP_LINK; dropOperation |= DND.DROP_LINK; linkButton.setSelection(true); if (dropEnabled) { createDropTarget(); } } } }); b = new Button(defaultParent, SWT.RADIO); b.setText("DND.DROP_NONE"); b.setSelection(true); b.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { Button b = (Button) e.widget; if (b.getSelection()) { dropDefaultOperation = DND.DROP_NONE; dropOperation &= ~DND.DROP_DEFAULT; if (dropEnabled) { createDropTarget(); } } } }); }
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 w w w . j av a2s . c o m*/ 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: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;// ww w . j ava2 s . c om 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:ummisco.gama.ui.views.displays.SWTChartEditor.java
/** * Creates a new editor./* ww w . ja va 2 s . c om*/ * * @param display * the display. * @param chart2edit * the chart to edit. */ public SWTChartEditor(final Display display, final JFreeChart chart2edit, final Point position) { this.shell = new Shell(display, SWT.APPLICATION_MODAL | SWT.NO_TRIM); this.shell.setSize(400, 500); this.shell.setBackground(WorkbenchHelper.getDisplay().getSystemColor(SWT.COLOR_BLACK)); // this.shell.setAlpha(140); this.chart = chart2edit; this.shell.setText("Chart properties"); this.shell.setLocation(position); final GridLayout layout = new GridLayout(2, false); layout.marginLeft = layout.marginTop = layout.marginRight = layout.marginBottom = 5; this.shell.setLayout(layout); final Composite main = new Composite(this.shell, SWT.NONE); main.setLayout(new FillLayout()); main.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1)); final TabFolder tab = new TabFolder(main, SWT.BORDER); // build first tab final TabItem item1 = new TabItem(tab, SWT.NONE); item1.setText(" " + "Title" + " "); this.titleEditor = new SWTTitleEditor(tab, SWT.NONE, this.chart.getTitle()); item1.setControl(this.titleEditor); // build second tab final TabItem item2 = new TabItem(tab, SWT.NONE); item2.setText(" " + "Plot" + " "); this.plotEditor = new SWTPlotEditor(tab, SWT.NONE, this.chart.getPlot()); item2.setControl(this.plotEditor); // build the third tab final TabItem item3 = new TabItem(tab, SWT.NONE); item3.setText(" " + "Other" + " "); this.otherEditor = new SWTOtherEditor(tab, SWT.NONE, this.chart); item3.setControl(this.otherEditor); // ok and cancel buttons final Button cancel = new Button(this.shell, SWT.PUSH); cancel.setText(" Cancel "); cancel.setLayoutData(new GridData(SWT.RIGHT, SWT.FILL, false, false)); cancel.pack(); cancel.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { SWTChartEditor.this.shell.dispose(); } }); final Button ok = new Button(this.shell, SWT.PUSH | SWT.OK); ok.setText(" Ok "); ok.setLayoutData(new GridData(SWT.RIGHT, SWT.FILL, false, false)); ok.pack(); ok.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { updateChart(SWTChartEditor.this.chart); SWTChartEditor.this.shell.dispose(); } }); }
From source file:org.eclipse.swt.examples.dnd.DNDExample.java
private void createDropOperations(Composite parent) { parent.setLayout(new RowLayout(SWT.VERTICAL)); final Button moveButton = new Button(parent, SWT.CHECK); moveButton.setText("DND.DROP_MOVE"); moveButton.addSelectionListener(widgetSelectedAdapter(e -> { Button b = (Button) e.widget; if (b.getSelection()) { dropOperation |= DND.DROP_MOVE; } else {/* w ww. java 2 s. co m*/ dropOperation = dropOperation & ~DND.DROP_MOVE; if (dropOperation == 0 || (dropDefaultOperation & DND.DROP_MOVE) != 0) { dropOperation |= DND.DROP_MOVE; moveButton.setSelection(true); } } if (dropEnabled) { createDropTarget(); } })); final Button copyButton = new Button(parent, SWT.CHECK); copyButton.setText("DND.DROP_COPY"); copyButton.addSelectionListener(widgetSelectedAdapter(e -> { Button b = (Button) e.widget; if (b.getSelection()) { dropOperation |= DND.DROP_COPY; } else { dropOperation = dropOperation & ~DND.DROP_COPY; if (dropOperation == 0 || (dropDefaultOperation & DND.DROP_COPY) != 0) { dropOperation = DND.DROP_COPY; copyButton.setSelection(true); } } if (dropEnabled) { createDropTarget(); } })); final Button linkButton = new Button(parent, SWT.CHECK); linkButton.setText("DND.DROP_LINK"); linkButton.addSelectionListener(widgetSelectedAdapter(e -> { Button eb = (Button) e.widget; if (eb.getSelection()) { dropOperation |= DND.DROP_LINK; } else { dropOperation = dropOperation & ~DND.DROP_LINK; if (dropOperation == 0 || (dropDefaultOperation & DND.DROP_LINK) != 0) { dropOperation = DND.DROP_LINK; linkButton.setSelection(true); } } if (dropEnabled) { createDropTarget(); } })); Button b = new Button(parent, SWT.CHECK); b.setText("DND.DROP_DEFAULT"); defaultParent = new Composite(parent, SWT.NONE); b.addSelectionListener(widgetSelectedAdapter(e -> { Button eb = (Button) e.widget; if (eb.getSelection()) { dropOperation |= DND.DROP_DEFAULT; defaultParent.setVisible(true); } else { dropOperation = dropOperation & ~DND.DROP_DEFAULT; defaultParent.setVisible(false); } if (dropEnabled) { createDropTarget(); } })); defaultParent.setVisible(false); GridLayout layout = new GridLayout(); layout.marginWidth = 20; defaultParent.setLayout(layout); Label label = new Label(defaultParent, SWT.NONE); label.setText("Value for default operation is:"); b = new Button(defaultParent, SWT.RADIO); b.setText("DND.DROP_MOVE"); b.addSelectionListener(widgetSelectedAdapter(e -> { Button eb = (Button) e.widget; if (eb.getSelection()) { dropDefaultOperation = DND.DROP_MOVE; dropOperation |= DND.DROP_MOVE; moveButton.setSelection(true); if (dropEnabled) { createDropTarget(); } } })); b = new Button(defaultParent, SWT.RADIO); b.setText("DND.DROP_COPY"); b.addSelectionListener(widgetSelectedAdapter(e -> { Button eb = (Button) e.widget; if (eb.getSelection()) { dropDefaultOperation = DND.DROP_COPY; dropOperation |= DND.DROP_COPY; copyButton.setSelection(true); if (dropEnabled) { createDropTarget(); } } })); b = new Button(defaultParent, SWT.RADIO); b.setText("DND.DROP_LINK"); b.addSelectionListener(widgetSelectedAdapter(e -> { Button eb = (Button) e.widget; if (eb.getSelection()) { dropDefaultOperation = DND.DROP_LINK; dropOperation |= DND.DROP_LINK; linkButton.setSelection(true); if (dropEnabled) { createDropTarget(); } } })); b = new Button(defaultParent, SWT.RADIO); b.setText("DND.DROP_NONE"); b.setSelection(true); b.addSelectionListener(widgetSelectedAdapter(e -> { Button eb = (Button) e.widget; if (eb.getSelection()) { dropDefaultOperation = DND.DROP_NONE; dropOperation &= ~DND.DROP_DEFAULT; if (dropEnabled) { createDropTarget(); } } })); // initialize state moveButton.setSelection(true); copyButton.setSelection(true); linkButton.setSelection(true); dropOperation = DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK; }