List of usage examples for org.eclipse.jface.action ActionContributionItem fill
@Override public void fill(Composite parent)
ActionContributionItem implementation of this IContributionItem method creates an SWT Button for the action using the action's style. From source file:org.dawnsci.algorithm.ui.datareduction.DataReductionFileSelectionPage.java
License:Open Source License
@Override public Composite createPartControl(Composite parent) { createPersistenceActions(algorithmViewPart.getViewSite()); mainComposite = new Composite(parent, SWT.NONE); mainComposite.setLayout(new GridLayout(1, true)); GridUtils.removeMargins(mainComposite); SashForm mainSash = new SashForm(mainComposite, SWT.HORIZONTAL); mainSash.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); SashForm leftSash = new SashForm(mainSash, SWT.VERTICAL); leftSash.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); SashForm middleSash = new SashForm(mainSash, SWT.VERTICAL); middleSash.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); SashForm rightSash = new SashForm(mainSash, SWT.VERTICAL); rightSash.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); // Composite to put the main controls in Composite mainRecapComp = new Composite(leftSash, SWT.BORDER); mainRecapComp.setLayout(new GridLayout(1, false)); mainRecapComp.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, true, false)); Label helpLabel = new Label(mainRecapComp, SWT.WRAP); helpLabel.setText("Select a file in the Project Explorer and lock the type. " + "Make sure that all your selected data has the same shape."); helpLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, true)); recapComp = new Composite(mainRecapComp, SWT.NONE); recapComp.setLayout(new GridLayout(1, false)); recapComp.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, true, true)); viewer = new TableViewer(recapComp, SWT.FULL_SELECTION | SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER); createColumns(viewer);//w w w . jav a2 s. c om viewer.getTable().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); viewer.getTable().setLinesVisible(true); viewer.getTable().setHeaderVisible(true); algorithmViewPart.getSite().setSelectionProvider(viewer); rows = createSelectedDataRows(); viewer.setContentProvider(new IStructuredContentProvider() { @Override public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { // TODO Auto-generated method stub } @Override public void dispose() { // TODO Auto-generated method stub } @Override public Object[] getElements(Object inputElement) { return rows.toArray(new SelectedData[rows.size()]); } }); viewer.setInput(rows); // add the Run workflow action as a button ActionContributionItem aci = (ActionContributionItem) algorithmViewPart.getViewSite().getActionBars() .getToolBarManager().find(IAlgorithmProcessContext.RUN_ID_STUB + getTitle()); aci = new ActionContributionItem(aci.getAction()); aci.fill(mainRecapComp); Button runWorkflowButton = (Button) aci.getWidget(); runWorkflowButton.setText("Run Data Reduction Process"); runWorkflowButton.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false)); plottingSystems.get(1).createPlotPart(leftSash, types[1], null, PlotType.IMAGE, algorithmViewPart.getSite().getPart()); plottingSystems.get(1).setTitle(titles[1]); plottingSystems.get(0).createPlotPart(middleSash, types[0], null, PlotType.IMAGE, algorithmViewPart.getSite().getPart()); plottingSystems.get(0).setTitle(titles[0]); plottingSystems.get(3).createPlotPart(middleSash, types[3], null, PlotType.IMAGE, algorithmViewPart.getSite().getPart()); plottingSystems.get(3).setTitle(titles[3]); plottingSystems.get(2).createPlotPart(rightSash, types[2], null, PlotType.IMAGE, algorithmViewPart.getSite().getPart()); plottingSystems.get(2).setTitle(titles[2]); plottingSystems.get(4).createPlotPart(rightSash, types[4], null, PlotType.IMAGE, algorithmViewPart.getSite().getPart()); plottingSystems.get(4).setTitle(titles[4]); algorithmViewPart.getSite().getWorkbenchWindow().getSelectionService() .addSelectionListener(fileSelectionListener); // try to load the previous data saved in the memento for (int i = 0; i < keys.length; i++) { if (filePaths[i] != null) loadAndPlotData(plottingSystems.get(i), keys[i], filePaths[i], titles[i], true, locks[i], i); } viewer.refresh(); return mainComposite; }
From source file:org.eclipse.osee.framework.ui.skynet.blam.sections.BlamOutputSection.java
License:Open Source License
@Override public void initialize(IManagedForm form) { super.initialize(form); Section section = getSection();/*from ww w. java2 s . c o m*/ section.setText("Execute"); section.setLayout(new GridLayout()); section.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); final FormToolkit toolkit = getManagedForm().getToolkit(); Composite composite = toolkit.createComposite(getSection(), toolkit.getBorderStyle() | SWT.WRAP); composite.setLayout(new GridLayout()); composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); if (executBlamAction != null) { ActionContributionItem contributionItem = new ActionContributionItem(executBlamAction); contributionItem.setMode(ActionContributionItem.MODE_FORCE_TEXT); contributionItem.fill(composite); } formText = toolkit.createText(composite, "BLAM has not yet run\n", SWT.WRAP); GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true); gd.heightHint = 500; gd.widthHint = 200; formText.setLayoutData(gd); getSection().setClient(composite); toolkit.paintBordersFor(composite); section.layout(true); form.getForm().getBody().layout(true); }
From source file:org.fusesource.ide.foundation.ui.util.Widgets.java
License:Open Source License
public static Button createActionButton(Composite parent, Action action) { ActionContributionItem aci = new ActionContributionItem(action); aci.fill(parent); Button button = (Button) aci.getWidget(); if (button != null) { // lets try make sure we get the text and the image button.setText(action.getText()); }/*w w w. j a v a2 s . c om*/ return button; }
From source file:org.pwsafe.passwordsafeswt.dialog.AboutDialog.java
License:Open Source License
@Override protected void createButtonsForButtonBar(Composite parent) { // create buttons ((GridLayout) parent.getLayout()).numColumns++;// for layout ActionContributionItem licenceContrib = new ActionContributionItem(new LicenseAction()); licenceContrib.fill(parent); Button okBtn = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true); }
From source file:uk.ac.diamond.scisoft.feedback.FeedbackView.java
License:Open Source License
/** * This is a callback that will allow us to create the viewer and initialise it. *//*www . j a v a 2 s .c o m*/ @Override public void createPartControl(Composite parent) { final ScrolledComposite scrollComposite = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL); final Composite content = new Composite(scrollComposite, SWT.NONE); content.setLayout(new GridLayout(1, false)); content.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); makeActions(); Composite radioSelection = new Composite(content, SWT.NONE); radioSelection.setLayout(new GridLayout(3, false)); Label label = new Label(radioSelection, SWT.NONE); label.setText("Send Feedback to :"); RadioGroupWidget mailToRadios = new RadioGroupWidget(radioSelection); mailToRadios.setActions(createEmailRadioActions()); Label lblEmailAddress = new Label(content, SWT.NONE); lblEmailAddress.setText("Your email address for Feedback"); emailAddress = new Text(content, SWT.BORDER | SWT.SINGLE); emailAddress.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); final String email = Activator.getDefault() != null ? Activator.getDefault().getPreferenceStore().getString(FeedbackConstants.FROM_PREF) : null; if (email != null && !"".equals(email)) emailAddress.setText(email); Label lblSubject = new Label(content, SWT.NONE); lblSubject.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false, 1, 1)); lblSubject.setText("Summary"); subjectText = new Text(content, SWT.BORDER | SWT.SINGLE); subjectText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); final String subject = Activator.getDefault() != null ? Activator.getDefault().getPreferenceStore().getString(FeedbackConstants.SUBJ_PREF) : null; if (subject != null && !"".equals(subject)) subjectText.setText(subject); Label lblComment = new Label(content, SWT.NONE); lblComment.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false, 1, 1)); lblComment.setText("Comment"); messageText = new Text(content, SWT.BORDER | SWT.MULTI | SWT.WRAP | SWT.V_SCROLL); GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true); gd.minimumHeight = 200; messageText.setLayoutData(gd); attachLabel = new Label(content, SWT.NONE); attachLabel.setText("Attached Files"); tableViewer = new TableViewer(content, SWT.FULL_SELECTION | SWT.SINGLE | SWT.BORDER); createColumns(tableViewer); // tableViewer.getTable().setLinesVisible(true); tableViewer.getTable().setToolTipText("Delete the file by clicking on the X"); tableViewer.setContentProvider(new AttachedFileContentProvider()); tableViewer.setLabelProvider(new AttachedFileLabelProvider()); tableViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); attachedFiles = new ArrayList<File>(); tableViewer.setInput(attachedFiles); tableViewer.refresh(); Composite actionComp = new Composite(content, SWT.NONE); actionComp.setLayout(new GridLayout(3, false)); actionComp.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); ActionContributionItem attachAci = new ActionContributionItem(attachAction); attachAci = new ActionContributionItem(attachAci.getAction()); attachAci.fill(actionComp); Button btnBrowseFile = (Button) attachAci.getWidget(); btnBrowseFile.setText("Attach Files"); btnBrowseFile.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1)); Label emptyLabel = new Label(actionComp, SWT.SINGLE); emptyLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); ActionContributionItem sendAci = new ActionContributionItem(feedbackAction); sendAci = new ActionContributionItem(sendAci.getAction()); sendAci.fill(actionComp); btnSendFeedback = (Button) sendAci.getWidget(); btnSendFeedback.setText("Send Feedback"); btnSendFeedback.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); scrollComposite.setContent(content); scrollComposite.setExpandVertical(true); scrollComposite.setExpandHorizontal(true); scrollComposite.addControlListener(new ControlAdapter() { @Override public void controlResized(ControlEvent e) { Rectangle r = scrollComposite.getClientArea(); int height = content.computeSize(r.width, SWT.DEFAULT).y; scrollComposite.setMinHeight(height); scrollComposite.setMinWidth(content.computeSize(SWT.DEFAULT, r.height).x); } }); hookContextMenu(); contributeToActionBars(); getSite().getPage().addPartListener(this); }
From source file:uk.ac.diamond.scisoft.ncd.rcp.edna.views.NcdModelBuilderParametersView.java
License:Apache License
@Override public Composite createPartControl(final Composite parent) { this.parent = parent; parent.setLayout(new GridLayout(1, false)); parent.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); try {// www.j a v a2 s . c o m qIntensityPlot = PlottingFactory.createPlottingSystem(); } catch (Exception ne) { logger.error("Cannot locate any plotting systems!", ne); } // Data parameters Group dataParametersGroup = new Group(parent, SWT.NONE); dataParametersGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); dataParametersGroup.setLayout(new GridLayout()); dataParametersGroup.setText("Data parameters"); scrolledComposite = new ScrolledComposite(dataParametersGroup, SWT.H_SCROLL | SWT.V_SCROLL); scrolledComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); scrolledComposite.setLayout(new GridLayout()); dataParameters = new Composite(scrolledComposite, SWT.NONE); dataParameters.setLayout(new GridLayout()); dataParameters.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); final Group dataFileGroup = new Group(dataParameters, SWT.NONE); dataFileGroup.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); dataFileGroup.setLayout(new GridLayout(3, false)); new Label(dataFileGroup, SWT.NONE).setText("Data file"); dataFile = new Text(dataFileGroup, SWT.BORDER); dataFile.setLayoutData(new GridData(GridData.FILL, SWT.CENTER, true, false)); dataFile.setText(dataFilename); dataFile.setToolTipText("Location of input file"); dataFile.addListener(SWT.KeyUp, new Listener() { Color red = new Color(dataFileGroup.getDisplay(), 255, 0, 0); Color white = new Color(dataFileGroup.getDisplay(), 255, 255, 255); @Override public void handleEvent(Event event) { if (fileNameIsNotEmptyAndFileExists(dataFile.getText())) { dataFile.setBackground(white); fileSelected = true; } else { dataFile.setBackground(red); fileSelected = false; } String filename = dataFile.getText(); boolean dataFileIsNxsFile = isNxsFile(filename); if (dataFileIsNxsFile) { findQAndDataPaths(); } enableNexusPathCombos(dataFileIsNxsFile); captureGUIInformation(); checkWhetherPathsAreEmpty(); refreshRunButton(true); checkFilenameAndColorDataFileBox(dataFileGroup.getDisplay()); updateGuiParameters(); } }); int style = DND.DROP_COPY | DND.DROP_DEFAULT; DropTarget target = new org.eclipse.swt.dnd.DropTarget(dataParameters, style); final TextTransfer textTransfer = TextTransfer.getInstance(); final FileTransfer fileTransfer = FileTransfer.getInstance(); Transfer[] types = new Transfer[] { fileTransfer, textTransfer }; target.setTransfer(types); target.addDropListener(new DropTargetListener() { public void dragEnter(DropTargetEvent event) { if (event.detail == DND.DROP_DEFAULT) { if ((event.operations & DND.DROP_COPY) != 0) { event.detail = DND.DROP_COPY; } else { event.detail = DND.DROP_NONE; } } // will accept text but prefer to have files dropped for (int i = 0; i < event.dataTypes.length; i++) { if (fileTransfer.isSupportedType(event.dataTypes[i])) { event.currentDataType = event.dataTypes[i]; // files should only be copied if (event.detail != DND.DROP_COPY) { event.detail = DND.DROP_NONE; } break; } } } public void dragOver(DropTargetEvent event) { event.feedback = DND.FEEDBACK_SELECT | DND.FEEDBACK_SCROLL; if (textTransfer.isSupportedType(event.currentDataType)) { // NOTE: on unsupported platforms this will return null Object o = textTransfer.nativeToJava(event.currentDataType); String t = (String) o; if (t != null) System.out.println(t); } } public void dragOperationChanged(DropTargetEvent event) { if (event.detail == DND.DROP_DEFAULT) { if ((event.operations & DND.DROP_COPY) != 0) { event.detail = DND.DROP_COPY; } else { event.detail = DND.DROP_NONE; } } // allow text to be moved but files should only be copied if (fileTransfer.isSupportedType(event.currentDataType)) { if (event.detail != DND.DROP_COPY) { event.detail = DND.DROP_NONE; } } } public void dragLeave(DropTargetEvent event) { } public void dropAccept(DropTargetEvent event) { } public void drop(DropTargetEvent event) { if (textTransfer.isSupportedType(event.currentDataType)) { String[] files = (String[]) event.data; for (int i = 0; i < files.length; i++) { if (files[i].toLowerCase().endsWith(DATA_TYPES[0]) || files[i].toLowerCase().endsWith(DATA_TYPES[1])) setFilenameString(files[i]); } } if (fileTransfer.isSupportedType(event.currentDataType)) { String[] files = (String[]) event.data; for (int i = 0; i < files.length; i++) { if (files[i].toLowerCase().endsWith(DATA_TYPES[0]) || files[i].toLowerCase().endsWith(DATA_TYPES[1])) setFilenameString(files[i]); } } } }); FileContentProposalProvider prov = new FileContentProposalProvider(); ContentProposalAdapter ad2 = new ContentProposalAdapter(dataFile, new TextContentAdapter(), prov, null, null); ad2.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE); ad2.addContentProposalListener(new IContentProposalListener() { @Override public void proposalAccepted(IContentProposal proposal) { setFilenameString(proposal.getContent()); } }); browseDataFile = new Button(dataFileGroup, SWT.NONE); browseDataFile.setText("..."); browseDataFile.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { FileDialog fChooser = new FileDialog(Display.getDefault().getActiveShell()); fChooser.setText("Choose NXS or DAT file"); fChooser.setFilterPath(dataFilename); String extensions[] = { "*.nxs;*.dat", "*.*" }; fChooser.setFilterExtensions(extensions); String fileStr = fChooser.open(); if (fileStr != null) { final File file = new File(fileStr); if (file.isFile()) { setFilenameString(file.toString()); isGuiInResetState = false; } } } }); Composite dataParametersComposite = new Composite(dataParameters, SWT.NONE); dataParametersComposite.setLayout(new GridLayout(2, false)); GridData dataParametersGridData = new GridData(SWT.FILL, SWT.CENTER, true, false); dataParametersComposite.setLayoutData(dataParametersGridData); new Label(dataParametersComposite, SWT.NONE).setText("Working directory"); workingDirectory = new Text(dataParametersComposite, SWT.NONE); workingDirectory.setToolTipText( "Directory where programs leave their files. Must be network accessible (not /scratch or /tmp)"); workingDirectory.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); ExpandableComposite dataPathAndColumnParametersExpandableComposite = new ExpandableComposite(dataParameters, SWT.NONE); dataPathAndColumnParametersExpandableComposite.setLayout(new GridLayout()); dataPathAndColumnParametersExpandableComposite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); dataPathAndColumnParametersExpandableComposite.setText("Data path and column parameters"); Composite dataPathAndColumnParametersComposite = new Composite( dataPathAndColumnParametersExpandableComposite, SWT.NONE); dataPathAndColumnParametersComposite.setLayout(new GridLayout(2, false)); dataPathAndColumnParametersComposite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); new Label(dataPathAndColumnParametersComposite, SWT.NONE).setText("Nexus path to q"); pathToQCombo = new Combo(dataPathAndColumnParametersComposite, SWT.READ_ONLY); pathToQCombo.setToolTipText("Path to q data (only used in Nexus file)"); pathToQCombo.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); pathToQCombo.addListener(SWT.KeyUp, pathListener); pathToQCombo.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { currentPathToQ = pathToQCombo.getText(); } }); new Label(dataPathAndColumnParametersComposite, SWT.NONE).setText("Nexus path to data"); pathToDataCombo = new Combo(dataPathAndColumnParametersComposite, SWT.READ_ONLY); pathToDataCombo.setToolTipText("Path to data (only used in Nexus file)"); pathToDataCombo.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); pathToDataCombo.addListener(SWT.KeyUp, pathListener); pathToDataCombo.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { currentPathToData = pathToDataCombo.getText(); } }); new Label(dataPathAndColumnParametersComposite, SWT.NONE).setText("Number of data columns"); numberOfFrames = new Text(dataPathAndColumnParametersComposite, SWT.NONE); numberOfFrames.setToolTipText("Number of data columns to use in analysis. For reduced data, this is 1"); numberOfFrames.addListener(SWT.Verify, verifyInt); numberOfFrames.setLayoutData(new GridData(GridData.FILL, SWT.CENTER, true, false)); dataPathAndColumnParametersExpandableComposite.setClient(dataPathAndColumnParametersComposite); dataPathAndColumnParametersExpandableComposite.addExpansionListener(expansionAdapter); ExpandableComposite dataChoiceExpanderComposite = new ExpandableComposite(dataParameters, SWT.NONE); dataChoiceExpanderComposite.setLayout(new GridLayout()); dataChoiceExpanderComposite.setLayoutData(new GridData(GridData.FILL, SWT.TOP, true, false)); dataChoiceExpanderComposite.setText("Data range"); Composite dataChoiceParameters = new Composite(dataChoiceExpanderComposite, SWT.NONE); dataChoiceParameters.setLayout(new GridLayout()); dataChoiceParameters.setLayoutData(new GridData(GridData.FILL, SWT.FILL, true, true)); SashForm pointsSash = new SashForm(dataChoiceParameters, SWT.HORIZONTAL); pointsSash.setLayout(new GridLayout(2, false)); pointsSash.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); Group pointsComposite = new Group(pointsSash, SWT.NONE); pointsComposite.setLayout(new GridLayout()); GridData pointsGroupLayout = new GridData(GridData.FILL, SWT.CENTER, true, false); pointsComposite.setLayoutData(pointsGroupLayout); Composite firstPointComposite = new Composite(pointsComposite, SWT.NONE); firstPointComposite.setLayout(new GridLayout(2, false)); firstPointComposite.setLayoutData(new GridData(GridData.FILL, SWT.CENTER, true, false)); new Label(firstPointComposite, SWT.NONE).setText("First point"); startPoint = new Text(firstPointComposite, SWT.NONE); startPoint.setToolTipText("First point of data to be used for calculations."); startPoint.addListener(SWT.Verify, verifyInt); startPoint.addListener(SWT.DefaultSelection, pointsQKeyListener); startPoint.addFocusListener(pointsQFocusListener); startPoint.setLayoutData(new GridData(GridData.FILL, SWT.CENTER, true, false)); final String[] qOptionUnits = new String[] { "Angstrom\u207b\u00b9", "nm\u207b\u00b9" }; final String[] gnomUnits = new String[] { "Angstrom", "nm" }; Composite qMinComposite = new Composite(pointsComposite, SWT.NONE); new Label(qMinComposite, SWT.NONE).setText("q minimum"); qMinComposite.setLayout(new GridLayout(3, false)); qMinComposite.setLayoutData(new GridData(GridData.FILL, SWT.CENTER, true, false)); qMin = new Text(qMinComposite, SWT.NONE); qMin.addListener(SWT.Verify, verifyDouble); qMin.setToolTipText("Minimum q value to be used for GNOM/DAMMIF"); qMin.setLayoutData(new GridData(GridData.FILL, SWT.CENTER, true, false)); qMin.addListener(SWT.DefaultSelection, pointsQKeyListener); qMin.addFocusListener(pointsQFocusListener); qMinUnits = new Combo(qMinComposite, SWT.READ_ONLY); qMinUnits.setItems(qOptionUnits); Group pointsGroup2 = new Group(pointsSash, SWT.NONE); pointsGroup2.setLayout(new GridLayout()); pointsGroup2.setLayoutData(new GridData(GridData.FILL, SWT.CENTER, true, false)); Composite lastPointComposite = new Composite(pointsGroup2, SWT.NONE); lastPointComposite.setLayout(new GridLayout(2, false)); lastPointComposite.setLayoutData(new GridData(GridData.FILL, SWT.CENTER, true, false)); new Label(lastPointComposite, SWT.NONE).setText("Last point"); endPoint = new Text(lastPointComposite, SWT.NONE); endPoint.setToolTipText("Last point of data to be used for calculations"); endPoint.addListener(SWT.Verify, verifyInt); endPoint.addListener(SWT.DefaultSelection, pointsQKeyListener); endPoint.addFocusListener(pointsQFocusListener); endPoint.setLayoutData(new GridData(GridData.FILL, SWT.CENTER, true, false)); GridData data = new GridData(GridData.FILL, SWT.CENTER, true, false); pointsComposite.setLayoutData(data); pointsComposite.setLayout(new GridLayout()); pointsGroup2.setLayoutData(data); pointsGroup2.setLayout(new GridLayout()); final Composite qMaxComposite = new Composite(pointsGroup2, SWT.NONE); new Label(qMaxComposite, SWT.NONE).setText("q maximum"); qMaxComposite.setLayout(new GridLayout(3, false)); qMaxComposite.setLayoutData(new GridData(GridData.FILL, SWT.CENTER, true, false)); qMax = new Text(qMaxComposite, SWT.NONE); qMax.addListener(SWT.Verify, verifyDouble); qMax.addListener(SWT.DefaultSelection, pointsQKeyListener); qMax.addFocusListener(pointsQFocusListener); qMax.setToolTipText("Maximum q value to be used for GNOM/DAMMIF"); qMax.setLayoutData(new GridData(GridData.FILL, SWT.CENTER, true, false)); qMaxUnits = new Label(qMaxComposite, SWT.NONE); startPointBounds = new IntegerDecorator(startPoint); startPointBounds.setMinimum(1); endPointBounds = new IntegerDecorator(endPoint); startPointBounds.addValueChangeListener(valueChangeListener); endPointBounds.addValueChangeListener(valueChangeListener); qMinBounds = new FloatDecorator(qMin); doubleNumberFormat.setMinimumFractionDigits(4); qMinBounds.setNumberFormat(null, doubleNumberFormat); qMinBounds.setMinimum(0); qMaxBounds = new FloatDecorator(qMax); qMaxBounds.setNumberFormat(null, doubleNumberFormat); qMinBounds.addValueChangeListener(valueChangeListener); qMaxBounds.addValueChangeListener(valueChangeListener); dataChoiceExpanderComposite.setClient(dataChoiceParameters); dataChoiceExpanderComposite.addExpansionListener(expansionAdapter); dataChoiceExpanderComposite.setExpanded(true); ExpandableComposite plotScrolledExpandableComposite = new ExpandableComposite(dataParameters, SWT.NONE); plotScrolledExpandableComposite.setLayout(new GridLayout()); plotScrolledExpandableComposite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); plotScrolledExpandableComposite.setText("Data plot"); plotComposite = new Composite(plotScrolledExpandableComposite, SWT.NONE); plotComposite.setLayout(new GridLayout()); plotComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); Composite plotAndOptionComposite = new Composite(plotComposite, SWT.NONE); plotAndOptionComposite.setLayout(new GridLayout(2, false)); plotAndOptionComposite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); final String[] plotOptionNames = new String[] { "logI/logq", "logI/q" }; plotOptions = new Combo(plotAndOptionComposite, SWT.READ_ONLY); plotOptions.setItems(plotOptionNames); plotOptions.setToolTipText("Choice of plots to show - logI vs. logq or logI vs. q"); plotOptions.addSelectionListener(new SelectionListener() { @Override public void widgetSelected(SelectionEvent e) { if (plotOptions.getText().equals(plotOptionNames[0])) { xAxisIsLog = true; } else { xAxisIsLog = false; } updatePlot(); } @Override public void widgetDefaultSelected(SelectionEvent e) { //do nothing } }); plotOptions.select(1); //default is logI/q GridData plotOptionsLayout = new GridData(SWT.RIGHT, SWT.CENTER, true, false); plotOptions.setLayoutData(plotOptionsLayout); btnResetDataRange = new Button(plotAndOptionComposite, SWT.NONE); btnResetDataRange.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false)); btnResetDataRange.setText("Reset data range"); btnResetDataRange.setToolTipText("Reset the data range to include all of the data"); btnResetDataRange.addSelectionListener(new SelectionListener() { @Override public void widgetSelected(SelectionEvent e) { if (currentQDataset != null) { resetRoi(); } } @Override public void widgetDefaultSelected(SelectionEvent e) { //do nothing } }); ToolBarManager man = new ToolBarManager(SWT.FLAT | SWT.LEFT | SWT.WRAP); ToolBar toolBar = man.createControl(plotComposite); toolBar.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false)); plotScrollComposite = new ScrolledComposite(plotComposite, SWT.H_SCROLL | SWT.V_SCROLL); plotScrollComposite.setLayout(new FillLayout(SWT.FILL)); Composite child = new Composite(plotScrollComposite, SWT.NONE); child.setLayout(new FillLayout(SWT.FILL)); qIntensityPlot.createPlotPart(child, getTitle(), null, PlotType.XY, null); //qIntensityPlot.getPlotActionSystem().fillZoomActions(man); qIntensityPlot.getPlotActionSystem().fillPrintActions(man); plotScrollComposite.setMinHeight(400); plotScrollComposite.setExpandHorizontal(true); plotScrollComposite.setExpandVertical(true); plotScrollComposite.setContent(child); plotScrolledExpandableComposite.setClient(plotComposite); plotScrolledExpandableComposite.addExpansionListener(expansionAdapter); plotScrolledExpandableComposite.setExpanded(true); ExpandableComposite pipelineOptionsExpandableComposite = new ExpandableComposite(dataParameters, SWT.NONE); pipelineOptionsExpandableComposite.setLayout(new GridLayout()); pipelineOptionsExpandableComposite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); pipelineOptionsExpandableComposite.setText("Pipeline parameters"); Composite otherOptionsComposite = new Composite(pipelineOptionsExpandableComposite, SWT.NONE); otherOptionsComposite.setLayout(new GridLayout(2, false)); GridData otherOptionsGridData = new GridData(SWT.FILL, SWT.CENTER, true, false); otherOptionsComposite.setLayoutData(otherOptionsGridData); new Label(otherOptionsComposite, SWT.NONE).setText("Number of parallel processes"); numberOfThreads = new Text(otherOptionsComposite, SWT.NONE); numberOfThreads.addListener(SWT.Verify, verifyInt); numberOfThreads.setToolTipText("The maximum number of cluster processes used to run DAMMIF"); numberOfThreads.setLayoutData(new GridData(GridData.FILL, SWT.CENTER, true, false)); String[] builderOptionsNames = new String[] { "GNOM", "GNOM+DAMMIF" }; new Label(otherOptionsComposite, SWT.NONE).setText("Pipeline processes"); builderOptions = new Combo(otherOptionsComposite, SWT.READ_ONLY); builderOptions.setItems(builderOptionsNames); builderOptions.setToolTipText("Choice of analysis to run - GNOM only or GNOM followed by DAMMIF"); pipelineOptionsExpandableComposite.setClient(otherOptionsComposite); pipelineOptionsExpandableComposite.addExpansionListener(expansionAdapter); ExpandableComposite gnomParametersExpandableComposite = new ExpandableComposite(dataParameters, SWT.NONE); gnomParametersExpandableComposite.setLayout(new GridLayout()); gnomParametersExpandableComposite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); gnomParametersExpandableComposite.setText("GNOM parameters"); final Composite gnomParameters = new Composite(gnomParametersExpandableComposite, SWT.NONE); GridData gnomLayout = new GridData(SWT.FILL, SWT.TOP, true, false); gnomLayout.horizontalSpan = 2; gnomParameters.setLayoutData(gnomLayout); gnomParameters.setLayout(new GridLayout(3, false)); new Label(gnomParameters, SWT.NONE).setText("Dmax search point start"); minDistanceSearch = new Text(gnomParameters, SWT.NONE); minDistanceSearch .setToolTipText("Initial value for the GNOM program, e.g. minimum possible size of protein"); minDistanceSearch.addListener(SWT.Verify, verifyDouble); minDistanceSearch.setLayoutData(new GridData(GridData.FILL, SWT.CENTER, true, false)); minDistanceSearch.addListener(SWT.DefaultSelection, distanceKeyListener); minDistanceSearch.addFocusListener(distanceFocusListener); minDistanceBounds = new FloatDecorator(minDistanceSearch); minDistanceUnits = new Label(gnomParameters, SWT.NONE); new Label(gnomParameters, SWT.NONE).setText("Dmax search point end"); maxDistanceSearch = new Text(gnomParameters, SWT.NONE); maxDistanceSearch.addListener(SWT.Verify, verifyDouble); maxDistanceSearch.setToolTipText("Final value for the GNOM program, e.g. maximum possible size of protein"); maxDistanceSearch.setLayoutData(new GridData(GridData.FILL, SWT.CENTER, true, false)); maxDistanceSearch.addListener(SWT.DefaultSelection, distanceKeyListener); maxDistanceSearch.addFocusListener(distanceFocusListener); maxDistanceBounds = new FloatDecorator(maxDistanceSearch); maxDistanceUnits = new Label(gnomParameters, SWT.NONE); minDistanceBounds.setMinimum(0); maxDistanceBounds.setMaximum(Integer.MAX_VALUE); minDistanceBounds.addValueChangeListener(valueChangeListener); maxDistanceBounds.addValueChangeListener(valueChangeListener); qMinUnits.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { modelBuildingParameters.setMainUnitAngstrom(qMinUnits.getText().equals(qOptionUnits[0])); qMaxUnits.setText(qMinUnits.getText()); if (qIntensityPlot.getRegion(Q_REGION_NAME) != null) { RectangularROI currentROI = (RectangularROI) qIntensityPlot.getRegion(Q_REGION_NAME).getROI(); setDoubleBox(qMin, currentROI.getPointX() * getAngstromNmFactor()); setDoubleBox(qMax, (currentROI.getPointX() + currentROI.getLength(0)) * getAngstromNmFactor()); qMinBounds.setMinimum(getDatasetMinimumInCurrentUnits() - Math.pow(10, -ROUND_DOUBLES_DIGITS)); qMinBounds .setMaximum((currentROI.getPointX() + currentROI.getLength(0)) * getAngstromNmFactor()); qMaxBounds.setMaximum(getDatasetMaximumInCurrentUnits() + Math.pow(10, -ROUND_DOUBLES_DIGITS)); qMaxBounds.setMinimum(currentROI.getPointX() * getAngstromNmFactor()); } resetDmaxParameters(); String newUnits = modelBuildingParameters.isMainUnitAngstrom() ? gnomUnits[0] : gnomUnits[1]; minDistanceUnits.setText(newUnits); maxDistanceUnits.setText(newUnits); qMaxComposite.layout(); gnomParameters.layout(); } }); new Label(gnomParameters, SWT.NONE).setText("Number of iterations"); numberOfSearch = new Text(gnomParameters, SWT.NONE); numberOfSearch.addListener(SWT.Verify, verifyInt); GridData searchLayout = new GridData(); searchLayout.horizontalSpan = 2; searchLayout.grabExcessHorizontalSpace = true; numberOfSearch.setLayoutData(searchLayout); numberOfSearch.setToolTipText("Maximum number of iterations for GNOM to calculate Dmax"); new Label(gnomParameters, SWT.NONE).setText("Iteration tolerance"); tolerance = new Text(gnomParameters, SWT.NONE); tolerance.addListener(SWT.Verify, verifyDouble); tolerance.setToolTipText("Tolerance criteria for completion of GNOM"); tolerance.setLayoutData(new GridData(GridData.FILL, SWT.CENTER, true, false)); gnomParametersExpandableComposite.setClient(gnomParameters); gnomParametersExpandableComposite.addExpansionListener(expansionAdapter); gnomParametersExpandableComposite.setExpanded(true); ExpandableComposite dammifParametersExpandableComposite = new ExpandableComposite(dataParameters, SWT.NONE); dammifParametersExpandableComposite.setLayout(new GridLayout()); dammifParametersExpandableComposite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); dammifParametersExpandableComposite.setText("DAMMIF parameters"); Composite dammifParameters = new Composite(dammifParametersExpandableComposite, SWT.NONE); dammifParameters.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 2, 1)); dammifParameters.setLayout(new GridLayout(2, true)); String[] dammifModeOptions = new String[] { "Fast", "Slow" }; String[] symmetryOptions = getSymmetryOptions(); new Label(dammifParameters, SWT.NONE).setText("Symmetry"); symmetry = new Combo(dammifParameters, SWT.READ_ONLY); symmetry.setItems(symmetryOptions); symmetry.setToolTipText("Symmetry of particle in DAMMIF."); new Label(dammifParameters, SWT.NONE).setText("Speed"); dammifMode = new Combo(dammifParameters, SWT.READ_ONLY); dammifMode.setItems(dammifModeOptions); dammifMode.setToolTipText("Run DAMMIF analysis in either fast or slow mode"); dammifParametersExpandableComposite.setClient(dammifParameters); dammifParametersExpandableComposite.addExpansionListener(expansionAdapter); btnResetParams = new Button(dataParameters, SWT.NONE); btnResetParams.setText("Reset all parameters to defaults"); btnResetParams.setLayoutData(new GridData(GridData.CENTER, SWT.CENTER, false, false)); btnResetParams.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { resetGUI(); } }); ActionContributionItem runModelBuilderAction = (ActionContributionItem) algorithmViewPart.getViewSite() .getActionBars().getToolBarManager() .find(IAlgorithmProcessContext.RUN_ID_STUB + "NCD model building"); runModelBuilderAction = new ActionContributionItem(runModelBuilderAction.getAction()); runModelBuilderAction.fill(dataParameters); btnRunNcdModelBuilderJob = (Button) runModelBuilderAction.getWidget(); btnRunNcdModelBuilderJob.setText("Run NCD model building"); btnRunNcdModelBuilderJob.setLayoutData(new GridData(GridData.CENTER, SWT.CENTER, false, false)); btnRunNcdModelBuilderJob.setEnabled(false); ActionContributionItem stopModelBuilderAction = (ActionContributionItem) algorithmViewPart.getViewSite() .getActionBars().getToolBarManager() .find(IAlgorithmProcessContext.STOP_ID_STUB + "NCD model building"); stopModelBuilderAction.setVisible(false); scrolledComposite.setContent(dataParameters); scrolledComposite.setExpandHorizontal(true); scrolledComposite.setExpandVertical(true); scrolledComposite.setMinSize(scrollWidth, scrollHeight); scrolledComposite.addControlListener(new ControlAdapter() { @Override public void controlResized(ControlEvent e) { scrolledComposite.setMinSize(dataParameters.computeSize(scrollWidth, SWT.DEFAULT)); plotScrollComposite.setMinWidth(plotComposite.getBounds().width); dataParameters.layout(); } }); if (modelBuildingParameters == null) modelBuildingParameters = new ModelBuildingParameters(); if (memento == null) { updatePlot(); } if (memento != null) { modelBuildingParameters.loadMementoParameters(memento); PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() { @Override public void run() { try { restoreState(); } catch (Exception e) { logger.error("Problem while trying to restore the state", e); resetGUI(); } } }); Job job = new Job("Retrieving q values and paths from data file") { @Override protected IStatus run(IProgressMonitor monitor) { final IDataHolder holder; try { holder = loadDataFile(); Display.getDefault().syncExec(new Runnable() { @Override public void run() { boolean dataFileIsNxsFile = isNxsFile(modelBuildingParameters.getDataFilename()); if (dataFileIsNxsFile) { findQAndDataPaths(); retrieveQFromHierarchicalData(holder); } else { retrieveQFromData(holder); } enableNexusPathCombos(dataFileIsNxsFile); captureGUIInformation(); try { updatePlot(modelBuildingParameters.getDataFilename()); } catch (Exception e) { logger.error("exception while updating plot"); } qMinBounds.setMinimum( getDatasetMinimumInCurrentUnits() - Math.pow(10, -ROUND_DOUBLES_DIGITS)); qMaxBounds.setMaximum( getDatasetMaximumInCurrentUnits() + Math.pow(10, -ROUND_DOUBLES_DIGITS)); endPointBounds.setMaximum(currentQDataset.getSize()); IRegion region = qIntensityPlot.getRegion(Q_REGION_NAME); if (region != null) { RectangularROI roi = (RectangularROI) region.getROI(); qMinBounds.setMaximum(roi.getEndPoint()[0] * getAngstromNmFactor()); qMaxBounds.setMinimum(roi.getPoint()[0] * getAngstromNmFactor()); } } }); if (isNxsFile(modelBuildingParameters.getDataFilename())) { checkWhetherPathsAreEmpty(); } refreshRunButton(true); } catch (Exception e1) { logger.error("Exception while retrieving Q values from data file", e1); } return Status.OK_STATUS; } }; job.schedule(); isGuiInResetState = false; } else { resetGUI(); } checkFilenameAndColorDataFileBox(algorithmViewPart.getSite().getShell().getDisplay()); qIntensityRegionListener = new IROIListener.Stub() { @Override public void roiDragged(ROIEvent evt) { //do nothing here - updating while dragging was slowing things down in HistogramToolPage } @Override public void roiChanged(ROIEvent evt) { if (evt.getROI() instanceof RectangularROI) { regionDragging = true; RectangularROI roi = (RectangularROI) evt.getROI(); setDoubleBox(qMin, roi.getPoint()[0] * getAngstromNmFactor()); updatePoint(startPoint, String.valueOf(roi.getPoint()[0] * getAngstromNmFactor())); setDoubleBox(qMax, roi.getEndPoint()[0] * getAngstromNmFactor()); updatePoint(endPoint, String.valueOf(roi.getEndPoint()[0] * getAngstromNmFactor())); updateInternalBounds(roi.getPoint()[0], roi.getEndPoint()[0], Integer.parseInt(startPoint.getText()), Integer.parseInt(endPoint.getText())); regionDragging = false; } } }; updatePlot(); algorithmViewPart.getSite().getWorkbenchWindow().getSelectionService() .addSelectionListener(selectionListener); // Compute the minimum width size for the first time plotScrollComposite.setMinWidth(scrolledComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT).x); return parent; }