Java Code Examples for org.eclipse.jface.viewers.OpenEvent#getSelection()
The following examples show how to use
org.eclipse.jface.viewers.OpenEvent#getSelection() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NavigationService.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
public void open(OpenEvent openEvent, boolean select) { ISelection selection = openEvent.getSelection(); if (selection instanceof IStructuredSelection) { Iterator<?> iterator = ((IStructuredSelection) selection).iterator(); while (iterator.hasNext()) { Object element = iterator.next(); if (element instanceof INavigatable) { open((INavigatable) element, select); } } } }
Example 2
Source File: LibraryExplorerTreeViewPage.java From birt with Eclipse Public License 1.0 | 4 votes |
/** * Handles an open event from the viewer. Opens an editor on the selected * library. * * @param event * the open event * @throws IOException * if an I/O error occurs. */ protected void handleOpen( OpenEvent event ) throws IOException { IStructuredSelection selection = (IStructuredSelection) event.getSelection( ); Object element = selection.getFirstElement( ); if ( element instanceof ResourceEntryWrapper && ( (ResourceEntryWrapper) element ).isFile( ) ) { switch ( ( (ResourceEntryWrapper) element ).getType( ) ) { case ResourceEntryWrapper.RPTDESIGN : case ResourceEntryWrapper.LIBRARY : File file = null; URL url = ( (ResourceEntryWrapper) element ).getURL( ); if ( ( (ResourceEntryWrapper) element ).getEntry( ) instanceof FragmentResourceEntry ) { file = ResourceAction.convertToFile( Platform.getBundle( IResourceLocator.FRAGMENT_RESOURCE_HOST ) .getEntry( url.getPath( ) ) ); } else { file = ResourceAction.convertToFile( url ); } if ( file != null && file.exists( ) && file.isFile( ) ) { if ( ( (ResourceEntryWrapper) element ).getType( ) == ResourceEntryWrapper.LIBRARY ) { ResourceAction.openLibrary( this, file, false ); } else if ( ( (ResourceEntryWrapper) element ).getType( ) == ResourceEntryWrapper.RPTDESIGN ) { ResourceAction.openDesigner( this, file, false ); } } else { if ( ( (ResourceEntryWrapper) element ).getType( ) == ResourceEntryWrapper.LIBRARY ) { if ( MessageDialog.openConfirm( getSite( ).getShell( ), Messages.getString( "LibraryNotExist.Dialog.Title" ), //$NON-NLS-1$ Messages.getString( "LibraryNotExist.Dialog.Message" ) ) ) //$NON-NLS-1$ { refreshRoot( ); } } else if ( ( (ResourceEntryWrapper) element ).getType( ) == ResourceEntryWrapper.RPTDESIGN ) { if ( MessageDialog.openConfirm( getSite( ).getShell( ), Messages.getString( "DesignerNotExist.Dialog.Title" ), //$NON-NLS-1$ Messages.getString( "DesignerNotExist.Dialog.Message" ) ) ) //$NON-NLS-1$ { refreshRoot( ); } } } break; case ResourceEntryWrapper.CSS_STYLE_SHEET : default : break; } } }