org.eclipse.jface.viewers.SelectionChangedEvent Java Examples

The following examples show how to use org.eclipse.jface.viewers.SelectionChangedEvent. 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: CustomTxtParserInputWizardPage.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public void selectionChanged(SelectionChangedEvent event) {
    if (selectedLine != null) {
        selectedLine.dispose();
    }
    if (!(event.getSelection().isEmpty()) && event.getSelection() instanceof IStructuredSelection) {
        IStructuredSelection sel = (IStructuredSelection) event.getSelection();
        InputLine inputLine = (InputLine) sel.getFirstElement();
        selectedLine = new Line(lineContainer, getName(inputLine), inputLine);
        lineContainer.layout();
        lineScrolledComposite.setMinSize(lineContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).x, lineContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y - 1);
        container.layout();
        validate();
        updatePreviews();
    }
}
 
Example #2
Source File: ContractInputExpressionEditor.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Override
public Control createExpressionEditor(final Composite parent, final EMFDataBindingContext ctx) {
    final Composite mainComposite = new Composite(parent, SWT.NONE);
    mainComposite.setLayoutData(GridDataFactory.fillDefaults()
            .grab(true, true).create());
    mainComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(1).create());
    new Label(mainComposite, SWT.NONE)
            .setLayoutData(GridDataFactory.fillDefaults().indent(0, -LayoutConstants.getSpacing().y + 1).create()); // Filler

    viewer = new ContractInputTableViewer(mainComposite, SWT.FULL_SELECTION | SWT.BORDER
            | SWT.SINGLE | SWT.V_SCROLL);
    viewer.getTable().setLayoutData(
            GridDataFactory.fillDefaults().grab(true, true).create());
    viewer.initialize();
    viewer.addPostSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(final SelectionChangedEvent event) {
            if (!event.getSelection().isEmpty()) {
                ContractInputExpressionEditor.this.fireSelectionChanged();
            }
        }
    });
    createReturnTypeComposite(parent);
    return mainComposite;
}
 
Example #3
Source File: ConnectionSelectionPage.java    From codewind-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public void createControl(Composite parent) {
	Composite composite = new Composite(parent, SWT.NONE);
	GridLayout layout = new GridLayout();
	layout.numColumns = 1;
	layout.horizontalSpacing = 5;
	layout.verticalSpacing = 7;
	composite.setLayout(layout);
	GridData data = new GridData(GridData.FILL_HORIZONTAL);
	composite.setLayoutData(data);
	
	connViewer = new TableViewer(composite, SWT.BORDER | SWT.SINGLE | SWT.V_SCROLL);
	connViewer.setContentProvider(ArrayContentProvider.getInstance());
	connViewer.setLabelProvider(new ConnLabelProvider());
	connViewer.setInput(connections);
	connViewer.getTable().setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
	connViewer.addSelectionChangedListener((SelectionChangedEvent event) -> {
		connection = (CodewindConnection)connViewer.getStructuredSelection().getFirstElement();
		validate();
	});
	
	// Add Context Sensitive Help
	PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, CodewindUIPlugin.MAIN_CONTEXTID);

	setControl(composite);
}
 
Example #4
Source File: ExtensionsActionBarContributor.java    From ifml-editor with MIT License 6 votes vote down vote up
/**
 * When the active editor changes, this remembers the change and registers with it as a selection provider.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public void setActiveEditor(IEditorPart part) {
	super.setActiveEditor(part);
	activeEditorPart = part;

	// Switch to the new selection provider.
	//
	if (selectionProvider != null) {
		selectionProvider.removeSelectionChangedListener(this);
	}
	if (part == null) {
		selectionProvider = null;
	}
	else {
		selectionProvider = part.getSite().getSelectionProvider();
		selectionProvider.addSelectionChangedListener(this);

		// Fake a selection changed event to update the menus.
		//
		if (selectionProvider.getSelection() != null) {
			selectionChanged(new SelectionChangedEvent(selectionProvider, selectionProvider.getSelection()));
		}
	}
}
 
Example #5
Source File: ExecuteCommandHandler.java    From e4macs with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Call execute on checkers with an additional listener for selection change during execution
 *  
 * @param editor
 * @param checkers
 */
protected void executeWithSelectionCheck(final ITextEditor editor, IWithSelectionCheck checkers) {

	ISelectionChangedListener listener = new ISelectionChangedListener() {
		public void selectionChanged(SelectionChangedEvent event) {
			ExecuteCommandHandler.this.showResultMessage(editor);
			removeListener(event.getSelectionProvider(),this);
		}
	};
	ITextSelection before = getCurrentSelection(editor);
	try {
		addListener(editor.getSelectionProvider(),listener);
		checkers.execute();
	} finally {
		if (before.equals(getCurrentSelection(editor))) {
			// remove it if the selection did not change
			removeListener(editor.getSelectionProvider(),listener);
		}
	}
}
 
Example #6
Source File: ZestContentViewerTests.java    From gef with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void test_selectionModel() {
	final List<Object> expectation = new ArrayList<>();
	ISelectionChangedListener expectingSelectionListener = new ISelectionChangedListener() {
		@Override
		public void selectionChanged(SelectionChangedEvent event) {
			StructuredSelection structuredSelection = (StructuredSelection) event.getSelection();
			assertEquals(expectation, structuredSelection.toList());
			expectation.clear();
		}
	};
	viewer.addSelectionChangedListener(expectingSelectionListener);
	viewer.setInput(new Object());

	// determine "First" node
	IViewer fxViewer = viewer.getContentViewer();
	org.eclipse.gef.graph.Node firstNode = viewer.getContentNodeMap().get(MyContentProvider.first());

	// select "First" node
	expectation.add(firstNode);
	IContentPart<? extends Node> firstPart = fxViewer.getContentPartMap().get(firstNode);
	fxViewer.getAdapter(SelectionModel.class).prependToSelection(Collections.singletonList(firstPart));
}
 
Example #7
Source File: ChangeTypeWizard.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Tree-viewer that shows the allowable types in a tree view.
 * @param parent the parent
 */
private void addTreeComponent(Composite parent) {
	fTreeViewer= new TreeViewer(parent, SWT.SINGLE | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
	
	GridData gd= new GridData(GridData.FILL_BOTH);
	gd.grabExcessHorizontalSpace= true;
	gd.grabExcessVerticalSpace= true;
	Tree tree= fTreeViewer.getTree();
	Dialog.applyDialogFont(tree);
	gd.heightHint= tree.getItemHeight() * 12;
	tree.setLayoutData(gd);

	fTreeViewer.setContentProvider(new ChangeTypeContentProvider(((ChangeTypeRefactoring)getRefactoring())));
	fLabelProvider= new ChangeTypeLabelProvider();
	fTreeViewer.setLabelProvider(fLabelProvider);
	ISelectionChangedListener listener= new ISelectionChangedListener(){
		public void selectionChanged(SelectionChangedEvent event) {
			IStructuredSelection selection= (IStructuredSelection)event.getSelection();
			typeSelected((ITypeBinding)selection.getFirstElement());
		}
	};
	fTreeViewer.addSelectionChangedListener(listener);
	fTreeViewer.setInput(new ChangeTypeContentProvider.RootType(getGeneralizeTypeRefactoring().getOriginalType()));
	fTreeViewer.expandToLevel(10);
}
 
Example #8
Source File: TypeScriptEditor.java    From typescript.java with MIT License 6 votes vote down vote up
public void selectionChanged(SelectionChangedEvent event) {
	// TypeScriptEditor.this.selectionChanged();

	ISelection selection = event.getSelection();
	if (selection instanceof ITextSelection) {
		// Update occurrences
		ITextSelection textSelection = (ITextSelection) selection;
		updateOccurrenceAnnotations(textSelection);

		TypeScriptContentOutlinePage outlinePage = getOutlinePage();
		if (outlinePage != null && outlinePage.isLinkingEnabled()) {
			fOutlineSelectionChangedListener.uninstall(outlinePage);
			outlinePage.setSelection(selection);
			fOutlineSelectionChangedListener.install(outlinePage);
		}
	}
}
 
Example #9
Source File: TransitionOrderingPropertySection.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
protected void createList(final Composite mainComposite) {
    final List list = getWidgetFactory().createList(mainComposite, SWT.BORDER | SWT.V_SCROLL);
    list.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(SWT.DEFAULT, 90).create());
    listViewer = new ListViewer(list);
    listViewer.setContentProvider(new ObservableListContentProvider<Element>());
    listViewer.setLabelProvider(new LabelProvider(){
        @Override
        public String getText(final Object element) {
            if(element != null && element instanceof Connection){
                final String transitionName = ((Connection) element).getName();
                return transitionName +" -- "+((Connection) element).getTarget().getName();
            }
            return super.getText(element);
        }
    });
    listViewer.addSelectionChangedListener(new ISelectionChangedListener() {
        @Override
        public void selectionChanged(final SelectionChangedEvent event) {
            updateButtonsEnablement();
        }
    });
}
 
Example #10
Source File: BreadcrumbViewer.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Set a single selection to the given item. <code>null</code> to deselect
 * all.
 * 
 * @param item the item to select or <code>null</code>
 */
void selectItem(BreadcrumbItem item) {
  if (fSelectedItem != null)
    fSelectedItem.setSelected(false);

  fSelectedItem = item;
  setSelectionToWidget(getSelection(), false);

  if (item != null) {
    setFocus();
  } else {
    for (int i = 0, size = fBreadcrumbItems.size(); i < size; i++) {
      BreadcrumbItem listItem = (BreadcrumbItem) fBreadcrumbItems.get(i);
      listItem.setFocus(false);
    }
  }

  fireSelectionChanged(new SelectionChangedEvent(this, getSelection()));
}
 
Example #11
Source File: PullUpMemberPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private void setupCellEditors(final Table table) {
	final ComboBoxCellEditor editor= new ComboBoxCellEditor();
	editor.setStyle(SWT.READ_ONLY);
	fTableViewer.setCellEditors(new CellEditor[] { null, editor});
	fTableViewer.addSelectionChangedListener(new ISelectionChangedListener() {

		public void selectionChanged(final SelectionChangedEvent event) {
			if (editor.getControl() == null & !table.isDisposed())
				editor.create(table);
			final ISelection sel= event.getSelection();
			if (!(sel instanceof IStructuredSelection))
				return;
			final IStructuredSelection structured= (IStructuredSelection) sel;
			if (structured.size() != 1)
				return;
			final MemberActionInfo info= (MemberActionInfo) structured.getFirstElement();
			editor.setItems(info.getAllowedLabels());
			editor.setValue(new Integer(info.getAction()));
		}
	});

	final ICellModifier cellModifier= new MemberActionCellModifier();
	fTableViewer.setCellModifier(cellModifier);
	fTableViewer.setColumnProperties(new String[] { MEMBER_PROPERTY, ACTION_PROPERTY});
}
 
Example #12
Source File: CListTable.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
private void createTable(Composite parent)
{
	tableViewer = new TableViewer(parent, SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION);
	tableViewer.getControl().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());

	tableViewer.setContentProvider(ArrayContentProvider.getInstance());
	tableViewer.setLabelProvider(new LabelProvider());
	tableViewer.setComparator(new ViewerComparator());
	tableViewer.setInput(items);
	tableViewer.addSelectionChangedListener(new ISelectionChangedListener()
	{

		public void selectionChanged(SelectionChangedEvent event)
		{
			updateStates();
		}

	});
	updateStates();
}
 
Example #13
Source File: CommonViewer.java    From elexis-3-core with Eclipse Public License 1.0 6 votes vote down vote up
public void selectionChanged(SelectionChangedEvent event){
	Object[] sel = getSelection();
	if (sel != null && sel.length != 0) {
		if (sel[0] instanceof Tree<?>) {
			sel[0] = ((Tree<?>) sel[0]).contents;
		}
		if (sel[0] instanceof PersistentObject) {
			ElexisEventDispatcher.fireSelectionEvent((PersistentObject) sel[0]);
		} else {
			if (StringUtils.isNotBlank(namedSelection)) {
				ContextServiceHolder.get().getRootContext().setNamed(namedSelection,
					sel[0]);
			} else {
				ContextServiceHolder.get().getRootContext().setTyped(sel[0]);
			}
		}
	}
	if (selChangeListener != null)
		selChangeListener.selectionChanged(event);
}
 
Example #14
Source File: SelectConnectorImplementationWizardPage.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void selectionChanged(SelectionChangedEvent event) {
    Object selection = ((IStructuredSelection) event.getSelection()).getFirstElement();
    if (removeButton != null && selection instanceof ConnectorImplementation) {
        removeButton.setEnabled(true);
    }
}
 
Example #15
Source File: ValidateableTableSectionPart.java    From tlaplus with MIT License 5 votes vote down vote up
public void selectionChanged(SelectionChangedEvent event)
{
    Object source = event.getSource();
    if (source == tableViewer)
    {
        changeButtonEnablement();
    }
}
 
Example #16
Source File: TmfEventsEditor.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Notifies any selection changed listeners that the viewer's selection has changed.
 * Only listeners registered at the time this method is called are notified.
 *
 * @param event a selection changed event
 *
 * @see ISelectionChangedListener#selectionChanged
 */
protected void fireSelectionChanged(final SelectionChangedEvent event) {
    Object[] listeners = fSelectionChangedListeners.getListeners();
    for (int i = 0; i < listeners.length; ++i) {
        final ISelectionChangedListener l = (ISelectionChangedListener) listeners[i];
        SafeRunnable.run(new SafeRunnable() {
            @Override
            public void run() {
                l.selectionChanged(event);
            }
        });
    }
}
 
Example #17
Source File: ConfigConversionDialog.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 创建文件类型列表
 * @param title
 * @param composite
 * @return ;
 */
private ComboViewer createConvertControl(String title, Composite composite) {
	Label positiveConvertLabel = new Label(composite, SWT.NONE);
	GridData positiveConvertLabelData = new GridData();
	positiveConvertLabelData.horizontalSpan = 2;
	positiveConvertLabelData.horizontalAlignment = SWT.CENTER;
	positiveConvertLabelData.grabExcessHorizontalSpace = true;
	positiveConvertLabel.setLayoutData(positiveConvertLabelData);
	positiveConvertLabel.setText(title);

	Label suportFormat = new Label(composite, SWT.NONE);
	suportFormat.setText("Suport Format");

	ComboViewer supportList = new ComboViewer(composite, SWT.READ_ONLY);
	GridData gridData = new GridData();
	gridData.horizontalAlignment = SWT.FILL;
	gridData.grabExcessHorizontalSpace = true;
	supportList.getCombo().setLayoutData(gridData);
	supportList.addSelectionChangedListener(new ISelectionChangedListener() {

		public void selectionChanged(SelectionChangedEvent event) {
			ISelection selection = event.getSelection();
			if (selection.isEmpty()) {
				okButton.setEnabled(false);
			} else {
				okButton.setEnabled(true);
			}
		}
	});

	return supportList;
}
 
Example #18
Source File: ServicesButtonPart.java    From tesb-studio-se with Apache License 2.0 5 votes vote down vote up
@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 #19
Source File: KontaktSelectionComposite.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
private void callSelectionListeners(){
	Object[] listeners = selectionListeners.getListeners();
	if (listeners != null && listeners.length > 0) {
		for (Object object : listeners) {
			((ISelectionChangedListener) object)
				.selectionChanged(new SelectionChangedEvent(this, getSelection()));
		}
	}
}
 
Example #20
Source File: JFaceTooltipExample.java    From gef with Eclipse Public License 2.0 5 votes vote down vote up
public static void main(String[] args) {
	Display d = new Display();
	Shell shell = new Shell(d);
	shell.setLayout(new FillLayout(SWT.VERTICAL));
	shell.setSize(400, 400);
	Button button = new Button(shell, SWT.PUSH);
	button.setText("Reload");
	button.addSelectionListener(new SelectionAdapter() {
		public void widgetSelected(SelectionEvent e) {
			viewer.setInput(null);
			viewer.setInput(new Object());
		}
	});

	viewer = new ZestContentViewer(new ZestFxJFaceModule());
	viewer.createControl(shell, SWT.NONE);
	viewer.setContentProvider(new MyContentProvider());
	viewer.setLabelProvider(new MyLabelProvider());
	viewer.setLayoutAlgorithm(new SpringLayoutAlgorithm());
	viewer.addSelectionChangedListener(new ISelectionChangedListener() {
		public void selectionChanged(SelectionChangedEvent event) {
			System.out.println(
					"Selection changed: " + (event.getSelection()));
		}
	});
	viewer.setInput(new Object());

	shell.open();
	while (!shell.isDisposed()) {
		while (!d.readAndDispatch()) {
			d.sleep();
		}
	}
}
 
Example #21
Source File: TabbedPropertySynchronizerListener.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void selectionChanged(final SelectionChangedEvent event) {
    final ISelection selection = event.getSelection();
    if (selection.isEmpty()) {
        return;
    }
    final EObject element = unwrap(selection);
    final IEditorReference activeEditorReference = activeEditorReference(activePage);
    final IWorkbenchPart editorPart = activeEditorReference.getPart(false);
    if (editorPart instanceof DiagramEditor) {
        final DiagramEditor diagramEditor = (DiagramEditor) editorPart;
        try {
            final IGraphicalEditPart editPart = editPartResolver.findEditPart(diagramEditor.getDiagramEditPart(), element);
            final ITabbedPropertySelectionProvider defaultProvider = findDefaultProvider(editorPart, editPart);
            updateDiagramSelection(diagramEditor, editPart);
            final ITabbedPropertySelectionProvider selectionProvider = registry.findSelectionProvider(element, activeEditorReference, defaultProvider);
            IViewPart part = null;
            try {
                part = activePage.showView(selectionProvider.viewId());
            } catch (final PartInitException e1) {
                return;
            }
            if (part != null) {
                updateSelectedTabInPage(element, selectionProvider, part);
            }
        } catch (final EditPartNotFoundException e) {
            BonitaStudioLog.debug("No edit part found for semantic element: " + element, Activator.PLUGIN_ID);
        }
    }
}
 
Example #22
Source File: ProtocolEditor.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * This implements {@link org.eclipse.jface.viewers.ISelectionProvider} to set this editor's overall selection.
 * Calling this result will notify the listeners.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public void setSelection ( ISelection selection )
{
    editorSelection = selection;

    for ( ISelectionChangedListener listener : selectionChangedListeners )
    {
        listener.selectionChanged ( new SelectionChangedEvent ( this, selection ) );
    }
    setStatusLineManager ( selection );
}
 
Example #23
Source File: ReplaceWithRevisionAction.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Add the replace button to the dialog.
 */
protected void createButtonsForButtonBar(Composite parent) {
	replaceButton = createButton(parent, REPLACE_ID, Policy.bind("ReplaceWithRevisionAction.replace"), true); //$NON-NLS-1$
	replaceButton.setEnabled(false);
	input.getViewer().addSelectionChangedListener(
		new ISelectionChangedListener() {
			public void selectionChanged(SelectionChangedEvent e) {
				ISelection s= e.getSelection();
				replaceButton.setEnabled(s != null && ! s.isEmpty());
			}
		}
	);
	createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); //$NON-NLS-1$
	// Don't call super because we don't want the OK button to appear
}
 
Example #24
Source File: DeploymentEditor.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * This implements {@link org.eclipse.jface.viewers.ISelectionProvider} to set this editor's overall selection.
 * Calling this result will notify the listeners.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public void setSelection ( ISelection selection )
{
    editorSelection = selection;

    for ( ISelectionChangedListener listener : selectionChangedListeners )
    {
        listener.selectionChanged ( new SelectionChangedEvent ( this, selection ) );
    }
    setStatusLineManager ( selection );
}
 
Example #25
Source File: DeploymentActionBarContributor.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * When the active editor changes, this remembers the change and registers with it as a selection provider.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public void setActiveEditor ( IEditorPart part )
{
    super.setActiveEditor ( part );
    activeEditorPart = part;

    // Switch to the new selection provider.
    //
    if ( selectionProvider != null )
    {
        selectionProvider.removeSelectionChangedListener ( this );
    }
    if ( part == null )
    {
        selectionProvider = null;
    }
    else
    {
        selectionProvider = part.getSite ().getSelectionProvider ();
        selectionProvider.addSelectionChangedListener ( this );

        // Fake a selection changed event to update the menus.
        //
        if ( selectionProvider.getSelection () != null )
        {
            selectionChanged ( new SelectionChangedEvent ( selectionProvider, selectionProvider.getSelection () ) );
        }
    }
}
 
Example #26
Source File: GenconfEditor.java    From M2Doc with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * This makes sure that one content viewer, either for the current page or the outline view, if it has focus,
 * is the current one.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * 
 * @generated
 */
public void setCurrentViewer(Viewer viewer) {
    // If it is changing...
    //
    if (currentViewer != viewer) {
        if (selectionChangedListener == null) {
            // Create the listener on demand.
            //
            selectionChangedListener = new ISelectionChangedListener() {
                // This just notifies those things that are affected by the section.
                //
                public void selectionChanged(SelectionChangedEvent selectionChangedEvent) {
                    setSelection(selectionChangedEvent.getSelection());
                }
            };
        }

        // Stop listening to the old one.
        //
        if (currentViewer != null) {
            currentViewer.removeSelectionChangedListener(selectionChangedListener);
        }

        // Start listening to the new one.
        //
        if (viewer != null) {
            viewer.addSelectionChangedListener(selectionChangedListener);
        }

        // Remember it.
        //
        currentViewer = viewer;

        // Set the editors selection based on the current viewer's selection.
        //
        setSelection(currentViewer == null ? StructuredSelection.EMPTY : currentViewer.getSelection());
    }
}
 
Example #27
Source File: XtextElementSelectionListener.java    From dsl-devkit with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Notify all ISelectionChangedListener.
 */
private void fireSelectionChanged() {
  SelectionChangedEvent event = new SelectionChangedEvent(this, getSelection());
  for (Object listener : listenerList.getListeners()) {
    ((ISelectionChangedListener) listener).selectionChanged(event);
  }
}
 
Example #28
Source File: MenuBar.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
void updateButtons(SelectionChangedEvent e) {
	List<JsonNode> nodes = getSelection(e);
	updateSelectionButtons(nodes);
	boolean rootsEqual = areRootsEqual();
	copyAllButton.setEnabled(!rootsEqual);
	resetAllButton.setEnabled(root.hadDifferences());
	nextChangeButton.setEnabled(!rootsEqual);
	previousChangeButton.setEnabled(!rootsEqual);
}
 
Example #29
Source File: TabbedPropertySynchronizerListenerTest.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void should_update_diagram_selection_when_handling_selection_change_event() throws Exception {
    when(registry.findSelectionProvider(notNull(EObject.class), eq(processEditorReference), any(ITabbedPropertySelectionProvider.class))).thenReturn(
            selectionProvider);
    final TabbedPropertySynchronizerListener listener = newFixture();

    listener.selectionChanged(new SelectionChangedEvent(source, new StructuredSelection(aTask().build())));

    verify(viewer).select(editPart);
    verify(viewer).reveal(editPart);
    verify(display).asyncExec(notNull(RefreshPropertyViewsSelection.class));
}
 
Example #30
Source File: RecipeEditor.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * This implements {@link org.eclipse.jface.viewers.ISelectionProvider} to set this editor's overall selection.
 * Calling this result will notify the listeners.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public void setSelection ( ISelection selection )
{
    editorSelection = selection;

    for ( ISelectionChangedListener listener : selectionChangedListeners )
    {
        listener.selectionChanged ( new SelectionChangedEvent ( this, selection ) );
    }
    setStatusLineManager ( selection );
}