Java Code Examples for org.eclipse.jface.viewers.SelectionChangedEvent#getSelection()
The following examples show how to use
org.eclipse.jface.viewers.SelectionChangedEvent#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: MSyncWizardFilePage.java From slr-toolkit with Eclipse Public License 1.0 | 6 votes |
/** * Creates a listener for listening the comboviewer. * Sets input of TreeViewer when Project gets selected * @return the listener */ private ISelectionChangedListener createProjectListener() { ISelectionChangedListener result = new ISelectionChangedListener() { private IProject lastProject = null; @Override public void selectionChanged(SelectionChangedEvent event) { if (event.getSelection() == null || event.getSelection().isEmpty()) { return; } if (event.getSelection() instanceof StructuredSelection) { if(((StructuredSelection) event.getSelection()).getFirstElement() instanceof IProject){ selectedProject = (IProject) ((StructuredSelection) event.getSelection()).getFirstElement(); treeViewer.setInput(wm.getBibEntriesByProject(selectedProject)); } } } }; return result; }
Example 2
Source File: ContactSelectorView.java From elexis-3-core with Eclipse Public License 1.0 | 6 votes |
@Override public void selectionChanged(SelectionChangedEvent event){ ISelection selection = event.getSelection(); if (selection == null) return; IStructuredSelection strucSelection = (IStructuredSelection) selection; Object selectedObject = strucSelection.getFirstElement(); if (selectedObject == null) return; if (selectedObject instanceof IContact) { IContact contact = (IContact) selectedObject; if (contact.isPatient()) { ElexisEventDispatcher.fireSelectionEvent(Patient.load(contact.getId())); } } }
Example 3
Source File: WhiteSpaceTabPage.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
public void selectionChanged(SelectionChangedEvent event) { final IStructuredSelection selection= (IStructuredSelection)event.getSelection(); if (selection.isEmpty() || !(selection.getFirstElement() instanceof Node)) return; final Node selected= (Node)selection.getFirstElement(); if (selected == null || selected == fLastSelected) return; if (event.getSource() == fInnerViewer && selected instanceof InnerNode) { fLastSelected= (InnerNode)selected; fDialogSettings.put(PREF_INNER_INDEX, selected.index); innerViewerChanged((InnerNode)selected); } else if (event.getSource() == fOptionsViewer && selected instanceof OptionNode) fDialogSettings.put(PREF_OPTION_INDEX, selected.index); }
Example 4
Source File: BibOutlinePage.java From texlipse with Eclipse Public License 1.0 | 6 votes |
public void selectionChanged(SelectionChangedEvent event) { super.selectionChanged(event); ISelection selection = event.getSelection(); if (selection.isEmpty()) { editor.resetHighlightRange(); } else { try { ReferenceEntry be = (ReferenceEntry) ((IStructuredSelection) selection).getFirstElement(); Position position = be.position; editor.setHighlightRange(position.getOffset(), position.getLength(), true); // editor.setHighlightRange(start, length, true); } catch (IllegalArgumentException x) { editor.resetHighlightRange(); } catch (ClassCastException y) { editor.resetHighlightRange(); } catch (NullPointerException z) { editor.resetHighlightRange(); } } }
Example 5
Source File: CrosstabSortKeyBuilder.java From birt with Eclipse Public License 1.0 | 6 votes |
public void selectionChanged( SelectionChangedEvent event ) { // TODO Auto-generated method stub ISelection selection = event.getSelection( ); if ( selection instanceof StructuredSelection ) { Object obj = ( (StructuredSelection) selection ).getFirstElement( ); if ( obj != null && obj instanceof MemberValueHandle && editor != null ) { editor.setMemberValue( (MemberValueHandle) obj ); } } }
Example 6
Source File: SelectExamplePage.java From statecharts with Eclipse Public License 1.0 | 5 votes |
@Override public void selectionChanged(SelectionChangedEvent event) { StructuredSelection structuredSelection = (StructuredSelection) event.getSelection(); Iterator<?> iter = structuredSelection.iterator(); List<IExampleData> selectedItems = Lists.newArrayList(); while(iter.hasNext()) { Object next = iter.next(); if (next instanceof IExampleData) { selectedItems.add((IExampleData)next); } } updateSelection(selectedItems); }
Example 7
Source File: ServicesButtonPart.java From tesb-studio-se with Apache License 2.0 | 5 votes |
@Override protected void buttonSelected(SelectionEvent e) { RepositoryReviewDialog dialog = new RepositoryReviewDialog(getShell(), ERepositoryObjectType.METADATA, "SERVICES:OPERATION") { @Override protected boolean isSelectionValid(SelectionChangedEvent event) { IStructuredSelection selection = (IStructuredSelection) event.getSelection(); if (selection.size() == 1) { return true; } return false; } @Override protected Control createDialogArea(Composite parent) { return createDialogArea(parent, "org.talend.rcp.perspective"); } }; int open = dialog.open(); if (open == Dialog.OK) { RepositoryNode result = dialog.getResult(); if (result != null) { listener.serviceNodeSelected(result); } } }
Example 8
Source File: ReportMultiBookPage.java From birt with Eclipse Public License 1.0 | 5 votes |
public void selectionChanged( SelectionChangedEvent event ) { setSelection( event.getSelection( ) ); StructuredSelection selection = (StructuredSelection) event.getSelection( ); Object obj = selection.getFirstElement( ); if ( obj instanceof IFormPage ) { Object palette = ( (IFormPage) obj ).getAdapter( PalettePage.class ); setActivePage( (IPageBookViewPage) palette ); } }
Example 9
Source File: GamaNavigator.java From gama with GNU General Public License v3.0 | 5 votes |
/** * Method selectionChanged() * * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent) */ @Override public void selectionChanged(final SelectionChangedEvent event) { final IStructuredSelection currentSelection = (IStructuredSelection) event.getSelection(); VirtualContent<?> element; if (currentSelection == null || currentSelection.isEmpty()) { element = NavigatorRoot.getInstance(); } else { element = (VirtualContent<?>) currentSelection.getFirstElement(); } element.handleSingleClick(); showStatus(element); }
Example 10
Source File: WriteAttributesOperationWizardValuePage.java From neoscada with Eclipse Public License 1.0 | 4 votes |
@Override public void selectionChanged ( final SelectionChangedEvent event ) { this.selection = event.getSelection (); }
Example 11
Source File: ChartActionBarContributor.java From neoscada with Eclipse Public License 1.0 | 4 votes |
/** * This implements {@link org.eclipse.jface.viewers.ISelectionChangedListener}, handling {@link org.eclipse.jface.viewers.SelectionChangedEvent}s by querying for the children and siblings that can * be added to the selected object and updating the menus accordingly. <!-- begin-user-doc --> <!-- end-user-doc --> * * @generated */ @Override public void selectionChanged ( final SelectionChangedEvent event ) { // Remove any menu items for old selection. // if ( this.createChildMenuManager != null ) { depopulateManager ( this.createChildMenuManager, this.createChildActions ); } if ( this.createSiblingMenuManager != null ) { depopulateManager ( this.createSiblingMenuManager, this.createSiblingActions ); } // Query the new selection for appropriate new child/sibling descriptors // Collection<?> newChildDescriptors = null; Collection<?> newSiblingDescriptors = null; final ISelection selection = event.getSelection (); if ( selection instanceof IStructuredSelection && ( (IStructuredSelection)selection ).size () == 1 ) { final Object object = ( (IStructuredSelection)selection ).getFirstElement (); final EditingDomain domain = ( (IEditingDomainProvider)this.activeEditorPart ).getEditingDomain (); newChildDescriptors = domain.getNewChildDescriptors ( object, null ); newSiblingDescriptors = domain.getNewChildDescriptors ( null, object ); } // Generate actions for selection; populate and redraw the menus. // this.createChildActions = generateCreateChildActions ( newChildDescriptors, selection ); this.createSiblingActions = generateCreateSiblingActions ( newSiblingDescriptors, selection ); if ( this.createChildMenuManager != null ) { populateManager ( this.createChildMenuManager, this.createChildActions, null ); this.createChildMenuManager.update ( true ); } if ( this.createSiblingMenuManager != null ) { populateManager ( this.createSiblingMenuManager, this.createSiblingActions, null ); this.createSiblingMenuManager.update ( true ); } }
Example 12
Source File: ItemActionBarContributor.java From neoscada with Eclipse Public License 1.0 | 4 votes |
/** * This implements {@link org.eclipse.jface.viewers.ISelectionChangedListener}, * handling {@link org.eclipse.jface.viewers.SelectionChangedEvent}s by querying for the children and siblings * that can be added to the selected object and updating the menus accordingly. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void selectionChanged ( SelectionChangedEvent event ) { // Remove any menu items for old selection. // if ( createChildMenuManager != null ) { depopulateManager ( createChildMenuManager, createChildSubmenuActions ); depopulateManager ( createChildMenuManager, createChildActions ); } if ( createSiblingMenuManager != null ) { depopulateManager ( createSiblingMenuManager, createSiblingSubmenuActions ); depopulateManager ( createSiblingMenuManager, createSiblingActions ); } // Query the new selection for appropriate new child/sibling descriptors // Collection<?> newChildDescriptors = null; Collection<?> newSiblingDescriptors = null; ISelection selection = event.getSelection (); if ( selection instanceof IStructuredSelection && ( (IStructuredSelection)selection ).size () == 1 ) { Object object = ( (IStructuredSelection)selection ).getFirstElement (); EditingDomain domain = ( (IEditingDomainProvider)activeEditorPart ).getEditingDomain (); newChildDescriptors = domain.getNewChildDescriptors ( object, null ); newSiblingDescriptors = domain.getNewChildDescriptors ( null, object ); } // Generate actions for selection; populate and redraw the menus. // createChildActions = generateCreateChildActions ( newChildDescriptors, selection ); createChildSubmenuActions = extractSubmenuActions ( createChildActions ); createSiblingActions = generateCreateSiblingActions ( newSiblingDescriptors, selection ); createSiblingSubmenuActions = extractSubmenuActions ( createSiblingActions ); if ( createChildMenuManager != null ) { populateManager ( createChildMenuManager, createChildSubmenuActions, null ); populateManager ( createChildMenuManager, createChildActions, null ); createChildMenuManager.update ( true ); } if ( createSiblingMenuManager != null ) { populateManager ( createSiblingMenuManager, createSiblingSubmenuActions, null ); populateManager ( createSiblingMenuManager, createSiblingActions, null ); createSiblingMenuManager.update ( true ); } }
Example 13
Source File: VisualInterfaceActionBarContributor.java From neoscada with Eclipse Public License 1.0 | 4 votes |
/** * This implements {@link org.eclipse.jface.viewers.ISelectionChangedListener}, * handling {@link org.eclipse.jface.viewers.SelectionChangedEvent}s by querying for the children and siblings * that can be added to the selected object and updating the menus accordingly. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void selectionChanged ( SelectionChangedEvent event ) { // Remove any menu items for old selection. // if ( createChildMenuManager != null ) { depopulateManager ( createChildMenuManager, createChildActions ); } if ( createSiblingMenuManager != null ) { depopulateManager ( createSiblingMenuManager, createSiblingActions ); } // Query the new selection for appropriate new child/sibling descriptors // Collection<?> newChildDescriptors = null; Collection<?> newSiblingDescriptors = null; ISelection selection = event.getSelection (); if ( selection instanceof IStructuredSelection && ( (IStructuredSelection)selection ).size () == 1 ) { Object object = ( (IStructuredSelection)selection ).getFirstElement (); EditingDomain domain = ( (IEditingDomainProvider)activeEditorPart ).getEditingDomain (); newChildDescriptors = domain.getNewChildDescriptors ( object, null ); newSiblingDescriptors = domain.getNewChildDescriptors ( null, object ); } // Generate actions for selection; populate and redraw the menus. // createChildActions = generateCreateChildActions ( newChildDescriptors, selection ); createSiblingActions = generateCreateSiblingActions ( newSiblingDescriptors, selection ); if ( createChildMenuManager != null ) { populateManager ( createChildMenuManager, createChildActions, null ); createChildMenuManager.update ( true ); } if ( createSiblingMenuManager != null ) { populateManager ( createSiblingMenuManager, createSiblingActions, null ); createSiblingMenuManager.update ( true ); } }
Example 14
Source File: DeploymentActionBarContributor.java From neoscada with Eclipse Public License 1.0 | 4 votes |
/** * This implements {@link org.eclipse.jface.viewers.ISelectionChangedListener}, * handling {@link org.eclipse.jface.viewers.SelectionChangedEvent}s by querying for the children and siblings * that can be added to the selected object and updating the menus accordingly. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void selectionChanged ( SelectionChangedEvent event ) { // Remove any menu items for old selection. // if ( createChildMenuManager != null ) { depopulateManager ( createChildMenuManager, createChildSubmenuActions ); depopulateManager ( createChildMenuManager, createChildActions ); } if ( createSiblingMenuManager != null ) { depopulateManager ( createSiblingMenuManager, createSiblingSubmenuActions ); depopulateManager ( createSiblingMenuManager, createSiblingActions ); } // Query the new selection for appropriate new child/sibling descriptors // Collection<?> newChildDescriptors = null; Collection<?> newSiblingDescriptors = null; ISelection selection = event.getSelection (); if ( selection instanceof IStructuredSelection && ( (IStructuredSelection)selection ).size () == 1 ) { Object object = ( (IStructuredSelection)selection ).getFirstElement (); EditingDomain domain = ( (IEditingDomainProvider)activeEditorPart ).getEditingDomain (); newChildDescriptors = domain.getNewChildDescriptors ( object, null ); newSiblingDescriptors = domain.getNewChildDescriptors ( null, object ); } // Generate actions for selection; populate and redraw the menus. // createChildActions = generateCreateChildActions ( newChildDescriptors, selection ); createChildSubmenuActions = extractSubmenuActions ( createChildActions ); createSiblingActions = generateCreateSiblingActions ( newSiblingDescriptors, selection ); createSiblingSubmenuActions = extractSubmenuActions ( createSiblingActions ); if ( createChildMenuManager != null ) { populateManager ( createChildMenuManager, createChildSubmenuActions, null ); populateManager ( createChildMenuManager, createChildActions, null ); createChildMenuManager.update ( true ); } if ( createSiblingMenuManager != null ) { populateManager ( createSiblingMenuManager, createSiblingSubmenuActions, null ); populateManager ( createSiblingMenuManager, createSiblingActions, null ); createSiblingMenuManager.update ( true ); } }
Example 15
Source File: JSEditor.java From birt with Eclipse Public License 1.0 | 4 votes |
public void handleSelectionChanged( SelectionChangedEvent event ) { ISelection selection = event.getSelection( ); handleSelectionChanged( selection ); }
Example 16
Source File: JSEditor.java From birt with Eclipse Public License 1.0 | 4 votes |
public void selectionChanged( SelectionChangedEvent event ) { ISelection selection = event.getSelection( ); if ( selection != null ) { Object[] sel = ( (IStructuredSelection) selection ).toArray( ); if ( sel.length == 1 ) { if ( sel[0] instanceof IPropertyDefn ) { // Save the current expression into the DE using DE API DesignElementHandle desHandle = (DesignElementHandle) cmbExprListViewer.getInput( ); saveModel( ); // Update the editor to display the expression // corresponding to the selected combo item ( method // name/ expression name ) IPropertyDefn elePropDefn = (IPropertyDefn) sel[0]; cmbItemLastSelected = elePropDefn; setEditorText( desHandle.getStringProperty( elePropDefn.getName( ) ) ); if ( event.getSource( ) == cmbExprListViewer ) { // Store the main selection state only selectionMap.put( getModel( ), selection ); } else if ( event.getSource( ) == cmbSubFunctionsViewer ) { // Store both the main and sub selection state here. List<Object> selectionList = new ArrayList<Object>( ); selectionList.add( ( (StructuredSelection) cmbExprListViewer.getSelection( ) ).getFirstElement( ) ); selectionList.add( ( (StructuredSelection) selection ).getFirstElement( ) ); selectionMap.put( getModel( ), new StructuredSelection( selectionList ) ); } String method = cmbItemLastSelected.getName( ); updateScriptContext( desHandle, method ); updateMethodDescription( method ); refreshAll( ); } } } }
Example 17
Source File: MemoryActionBarContributor.java From neoscada with Eclipse Public License 1.0 | 4 votes |
/** * This implements {@link org.eclipse.jface.viewers.ISelectionChangedListener}, * handling {@link org.eclipse.jface.viewers.SelectionChangedEvent}s by querying for the children and siblings * that can be added to the selected object and updating the menus accordingly. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void selectionChanged ( SelectionChangedEvent event ) { // Remove any menu items for old selection. // if ( createChildMenuManager != null ) { depopulateManager ( createChildMenuManager, createChildSubmenuActions ); depopulateManager ( createChildMenuManager, createChildActions ); } if ( createSiblingMenuManager != null ) { depopulateManager ( createSiblingMenuManager, createSiblingSubmenuActions ); depopulateManager ( createSiblingMenuManager, createSiblingActions ); } // Query the new selection for appropriate new child/sibling descriptors // Collection<?> newChildDescriptors = null; Collection<?> newSiblingDescriptors = null; ISelection selection = event.getSelection (); if ( selection instanceof IStructuredSelection && ( (IStructuredSelection)selection ).size () == 1 ) { Object object = ( (IStructuredSelection)selection ).getFirstElement (); EditingDomain domain = ( (IEditingDomainProvider)activeEditorPart ).getEditingDomain (); newChildDescriptors = domain.getNewChildDescriptors ( object, null ); newSiblingDescriptors = domain.getNewChildDescriptors ( null, object ); } // Generate actions for selection; populate and redraw the menus. // createChildActions = generateCreateChildActions ( newChildDescriptors, selection ); createChildSubmenuActions = extractSubmenuActions ( createChildActions ); createSiblingActions = generateCreateSiblingActions ( newSiblingDescriptors, selection ); createSiblingSubmenuActions = extractSubmenuActions ( createSiblingActions ); if ( createChildMenuManager != null ) { populateManager ( createChildMenuManager, createChildSubmenuActions, null ); populateManager ( createChildMenuManager, createChildActions, null ); createChildMenuManager.update ( true ); } if ( createSiblingMenuManager != null ) { populateManager ( createSiblingMenuManager, createSiblingSubmenuActions, null ); populateManager ( createSiblingMenuManager, createSiblingActions, null ); createSiblingMenuManager.update ( true ); } }
Example 18
Source File: FilterBugsDialog.java From spotbugs with GNU Lesser General Public License v2.1 | 4 votes |
@Override public void selectionChanged(SelectionChangedEvent event) { IStructuredSelection selection = (IStructuredSelection) event.getSelection(); updateDescription(selection); }
Example 19
Source File: InfrastructureActionBarContributor.java From neoscada with Eclipse Public License 1.0 | 4 votes |
/** * This implements {@link org.eclipse.jface.viewers.ISelectionChangedListener}, * handling {@link org.eclipse.jface.viewers.SelectionChangedEvent}s by querying for the children and siblings * that can be added to the selected object and updating the menus accordingly. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void selectionChanged ( SelectionChangedEvent event ) { // Remove any menu items for old selection. // if ( createChildMenuManager != null ) { depopulateManager ( createChildMenuManager, createChildSubmenuActions ); depopulateManager ( createChildMenuManager, createChildActions ); } if ( createSiblingMenuManager != null ) { depopulateManager ( createSiblingMenuManager, createSiblingSubmenuActions ); depopulateManager ( createSiblingMenuManager, createSiblingActions ); } // Query the new selection for appropriate new child/sibling descriptors // Collection<?> newChildDescriptors = null; Collection<?> newSiblingDescriptors = null; ISelection selection = event.getSelection (); if ( selection instanceof IStructuredSelection && ( (IStructuredSelection)selection ).size () == 1 ) { Object object = ( (IStructuredSelection)selection ).getFirstElement (); EditingDomain domain = ( (IEditingDomainProvider)activeEditorPart ).getEditingDomain (); newChildDescriptors = domain.getNewChildDescriptors ( object, null ); newSiblingDescriptors = domain.getNewChildDescriptors ( null, object ); } // Generate actions for selection; populate and redraw the menus. // createChildActions = generateCreateChildActions ( newChildDescriptors, selection ); createChildSubmenuActions = extractSubmenuActions ( createChildActions ); createSiblingActions = generateCreateSiblingActions ( newSiblingDescriptors, selection ); createSiblingSubmenuActions = extractSubmenuActions ( createSiblingActions ); if ( createChildMenuManager != null ) { populateManager ( createChildMenuManager, createChildSubmenuActions, null ); populateManager ( createChildMenuManager, createChildActions, null ); createChildMenuManager.update ( true ); } if ( createSiblingMenuManager != null ) { populateManager ( createSiblingMenuManager, createSiblingSubmenuActions, null ); populateManager ( createSiblingMenuManager, createSiblingActions, null ); createSiblingMenuManager.update ( true ); } }
Example 20
Source File: ExpressionBuilder.java From birt with Eclipse Public License 1.0 | 4 votes |
public void selectionChanged( SelectionChangedEvent event ) { IStructuredSelection selection = (IStructuredSelection) event.getSelection( ); Viewer target = null; if ( event.getSource( ) == categoryTable ) { target = subCategoryTable; } else if ( event.getSource( ) == subCategoryTable ) { target = functionTable; } if ( target != null ) { target.setInput( selection == null ? null : selection.getFirstElement( ) ); } if ( event.getSource( ) == functionTable ) { Table table = functionTable.getTable( ); if ( table.getSelectionCount( ) == 1 ) { messageLine.getParent( ).setVisible( true ); String message = provider.getDisplayText( table.getSelection( )[0].getData( ) ); message = message.replaceAll( "&", "&" ); //$NON-NLS-1$//$NON-NLS-2$ message = message.replaceAll( "<", "<" ); //$NON-NLS-1$ //$NON-NLS-2$ message = message.replaceAll( ">", ">" ); //$NON-NLS-1$//$NON-NLS-2$ messageLine.setText( "<form><p> <b>" //$NON-NLS-1$ + Messages.getString( "ExpressionBuilder.Label.Hint" ) //$NON-NLS-1$ + "</b>: " //$NON-NLS-1$ + message + "</p></form>", true, false ); //$NON-NLS-1$ messageLine.getParent( ).layout( ); } else { messageLine.getParent( ).setVisible( false ); } } }