Version 1 (modified by 3 years ago) (diff) | ,
---|
This page describes the process of accessing the MS Entry and its associated files from a new annotation entry (similar to GELATO).
The following is a sample handler (see org.grits.toolbox.importer.ms.annotation.glycan.simiansearch.handler.OpenGelatoWizard) method and shows how to get the selected MS Entry (clicked on project explorer pane) from a handler (to create a new annotation entry):
public class OpenGelatoWizard { //log4J Logger private static final Logger logger = Logger.getLogger(OpenGelatoWizard.class); @Inject private static IGritsDataModelService gritsDataModelService = null; @Inject static IGritsUIService gritsUIService = null; @Inject MApplication application; @Execute public Object execute(@Named(IServiceConstants.ACTIVE_SELECTION) Object object, IEventBroker eventBroker, @Named (IServiceConstants.ACTIVE_SHELL) Shell shell, EPartService partService) { try { List<Entry> msEntries = getMSEntries(object); ..... } /** * @param object - an Entry or a StructuredSelection item * @return List<Entry> - List of MS Entries to annotation */ private List<Entry> getMSEntries(Object object) { List<Entry> entries = new ArrayList<Entry>(); StructuredSelection to = null; Entry selectedEntry = null; if(object instanceof Entry) { selectedEntry = (Entry) object; } else if (object instanceof StructuredSelection) { if(((StructuredSelection) object).getFirstElement() instanceof Entry) { to = (StructuredSelection) object; } } if (selectedEntry != null) { if(selectedEntry.getProperty().getType().equals(MassSpecProperty.TYPE)) { entries.add(selectedEntry); } } // try getting the last selection from the data model if(gritsDataModelService.getLastSelection() != null && gritsDataModelService.getLastSelection().getFirstElement() instanceof Entry) { to = gritsDataModelService.getLastSelection(); } if(to != null) { List<Entry> selList = to.toList(); for(int i=0; i < selList.size(); i++) { Entry msEntry = selList.get(i); //if the right property if(msEntry.getProperty().getType().equals(MassSpecProperty.TYPE)) { if (!entries.contains(msEntry)) entries.add(msEntry); } } } return entries; } }
getMSEntries method shown above is a typical method for trying to find the selected item. This method specifically looks for MS Entries not just any Entry. This is done with this line:
if(selectedEntry.getProperty().getType().equals(MassSpecProperty.TYPE))
If there are no selections then the wizard or dialog to be opened for creation of the new annotation entry should provide an option for browsing the current entries and make a selection there. A sample selection dialog (see org.grits.toolbox.importer.ms.annotation.glycan.simiansearch.wizard.MassSpecChooserDialog) is shown below:
ProjectExplorerDialog dlg = new ProjectExplorerDialog(newShell); // Set an entry type as a filter dlg.addFilter(MassSpecProperty.TYPE); // Change the title bar text dlg.setTitle("Mass Spec Selection"); // Customizable message displayed in the dialog dlg.setMessage("Choose an MS Experiment to add"); // Calling open() will open and run the dialog. if (dlg.open() == Window.OK) { Entry entry = dlg.getEntry(); if (entry != null) { .... }
This generic ProjectExplorerDialog can be used anywhere to allow users to select a specific type of Entry. It is generally linked to a "Browse" button to let the users choose an Entry.