/** {@inheritDoc} */ @Override public void createPartControl(Composite parent, FormToolkit toolkit) { sashForm = new SashForm(parent, sashFormStyle); sashForm.setLayout(new GridLayout(1, false)); List<ISubView> subViews = getSubViews(); for (final ISubView subView : subViews) { subView.createPartControl(sashForm, toolkit); subView.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); subView .getControl() .addFocusListener( new FocusAdapter() { /** {@inheritDoc} */ @Override public void focusGained(FocusEvent e) { getRootEditor().setActiveSubView(subView); } }); if (null != subView.getSelectionProvider()) { ISelectionProvider prov = subView.getSelectionProvider(); prov.addSelectionChangedListener( new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { getRootEditor().setSelection(event.getSelection()); } }); prov.addSelectionChangedListener(getRootEditor().getSelectionChangedListener()); if (prov instanceof IPostSelectionProvider) { ((IPostSelectionProvider) prov) .addPostSelectionChangedListener(getRootEditor().getPostSelectionChangedListener()); } } } if (!weightMapping.isEmpty()) { int[] weights = new int[subViews.size()]; for (int i = 0; i < subViews.size(); i++) { if (weightMapping.containsKey(subViews.get(i))) { weights[i] = weightMapping.get(subViews.get(i)); } } sashForm.setWeights(weights); } }
/** * Create a new ViewerContribution. * * @param selProvider the selection provider */ public ViewerContribution(ISelectionProvider selProvider) { super(); this.selProvider = selProvider; if (selProvider != null) { selProvider.addSelectionChangedListener(this); } }
public CopyHandler(ViewSettings settings, Display display, ISelectionProvider selectionSource) { this.settings = settings; this.converter = new CellTextConverter(settings); this.display = display; this.selectionSource = selectionSource; selectionSource.addSelectionChangedListener(this); }
public void setSelectionProvider(ISelectionProvider selectionProvider) { if (this.selectionProvider != null) { this.selectionProvider.removeSelectionChangedListener(this); } this.selectionProvider = selectionProvider; selectionProvider.addSelectionChangedListener(this); }
/** Creates the actions and action groups for this view. */ protected void createActions() { fGotoInputAction = new GotoInputAction(this); fGotoInputAction.setEnabled(false); fCopyToClipboardAction = new CopyToClipboardAction(getViewSite()); ISelectionProvider provider = getSelectionProvider(); if (provider != null) provider.addSelectionChangedListener(fCopyToClipboardAction); }
private void initialize(ISelectionProvider provider) { ISelection selection = provider.getSelection(); fOpen.update(selection); if (!fIsEditorOwner) { provider.addSelectionChangedListener(fOpen); } }
private void registerSelectionListener( ISelectionProvider provider, ISelectionChangedListener listener) { if (fRegisteredSelectionListeners == null) { fRegisteredSelectionListeners = new ArrayList<ISelectionChangedListener>(20); } provider.addSelectionChangedListener(listener); fRegisteredSelectionListeners.add(listener); }
private void registerAction( SelectionDispatchAction action, ISelectionProvider provider, ISelection selection, ISelectionProvider specialSelectionProvider) { action.update(selection); provider.addSelectionChangedListener(action); if (specialSelectionProvider != null) action.setSpecialSelectionProvider(specialSelectionProvider); }
/** * The <code>CompositeEditorSite</code> implementation of this <code>IWorkbenchPartSite</code> * method remembers the selection provider, and also hooks a listener on it, which calls <code> * handleSelectionChanged</code> when a selection changed event occurs. * * @see #handleSelectionChanged */ public void setSelectionProvider(ISelectionProvider provider) { ISelectionProvider oldSelectionProvider = selectionProvider; selectionProvider = provider; if (oldSelectionProvider != null) { oldSelectionProvider.removeSelectionChangedListener(getSelectionChangedListener()); } if (selectionProvider != null) { selectionProvider.addSelectionChangedListener(getSelectionChangedListener()); } }
private GenerateBuildPathActionGroup(IWorkbenchSite site) { fSite = site; fActions = new ArrayList(); final CreateLinkedSourceFolderAction addLinkedSourceFolderAction = new CreateLinkedSourceFolderAction(); fActions.add(addLinkedSourceFolderAction); final CreateLocalSourceFolderAction addSourceFolderAction = new CreateLocalSourceFolderAction(); fActions.add(addSourceFolderAction); final AddFolderToBuildpathAction addFolder = new AddFolderToBuildpathAction(site); fActions.add(addFolder); final AddSelectedLibraryToBuildpathAction addSelectedLibrary = new AddSelectedLibraryToBuildpathAction(site); fActions.add(addSelectedLibrary); final RemoveFromBuildpathAction remove = new RemoveFromBuildpathAction(site); fActions.add(remove); final AddArchiveToBuildpathAction addArchive = new AddArchiveToBuildpathAction(site); fActions.add(addArchive); final AddLibraryToBuildpathAction addLibrary = new AddLibraryToBuildpathAction(site); fActions.add(addLibrary); if (DLTKCore.DEBUG) { System.err.println("Add Update Zip Action here..."); // $NON-NLS-1$ } final ExcludeFromBuildpathAction exclude = new ExcludeFromBuildpathAction(site); fActions.add(exclude); final IncludeToBuildpathAction include = new IncludeToBuildpathAction(site); fActions.add(include); final EditFilterAction editFilterAction = new EditFilterAction(); fActions.add(editFilterAction); final ConfigureBuildPathAction configure = new ConfigureBuildPathAction(site); fActions.add(configure); final ISelectionProvider provider = fSite.getSelectionProvider(); for (Iterator iter = fActions.iterator(); iter.hasNext(); ) { Action action = (Action) iter.next(); if (action instanceof ISelectionChangedListener) { provider.addSelectionChangedListener((ISelectionChangedListener) action); } } }
public void setDelegate(ISelectionProvider delegate) { if (delegate == this.delegate) return; ISelectionProvider oldDelegate = this.delegate; ISelectionProvider newDelegate = delegate; this.delegate = delegate; if (oldDelegate != null) { oldDelegate.removeSelectionChangedListener(listener); if (oldDelegate instanceof IPostSelectionProvider) { ((IPostSelectionProvider) oldDelegate).removePostSelectionChangedListener(postListener); } } final ISelection newSelection = getSelection(); if (newDelegate != null) { newDelegate.addSelectionChangedListener(listener); delegateSelectionChanged(newSelection); if (newDelegate instanceof IPostSelectionProvider) { ((IPostSelectionProvider) newDelegate).addPostSelectionChangedListener(postListener); } else { newDelegate.addSelectionChangedListener(postListener); } Display.getDefault() .asyncExec( new Runnable() { public void run() { postDelegateSelectionChanged(newSelection); } }); } else { delegateSelectionChanged(newSelection); postDelegateSelectionChanged(newSelection); } }
private void initialize(ISelectionProvider provider) { fSelectionProvider = provider; ISelection selection = provider.getSelection(); fOpenImplementation.update(selection); fOpenSuperImplementation.update(selection); fOpenAttachedJavadoc.update(selection); fOpenTypeHierarchy.update(selection); fOpenCallHierarchy.update(selection); if (!fEditorIsOwner) { if (fShowOpenPropertiesAction) { if (selection instanceof IStructuredSelection) { fOpenPropertiesDialog.selectionChanged((IStructuredSelection) selection); } else { fOpenPropertiesDialog.selectionChanged(selection); } } provider.addSelectionChangedListener(fOpenImplementation); provider.addSelectionChangedListener(fOpenSuperImplementation); provider.addSelectionChangedListener(fOpenAttachedJavadoc); provider.addSelectionChangedListener(fOpenTypeHierarchy); provider.addSelectionChangedListener(fOpenCallHierarchy); // no need to register the open properties dialog action since it registers itself } }
private GenerateIncludePathActionGroup(IWorkbenchSite site) { fSite = site; fActions = new ArrayList(); final RemoveFromIncludepathAction remove = new RemoveFromIncludepathAction(site); fActions.add(remove); final ConfigurePHPIncludePathAction configure = new ConfigurePHPIncludePathAction(site); fActions.add(configure); final ISelectionProvider provider = fSite.getSelectionProvider(); for (Iterator iter = fActions.iterator(); iter.hasNext(); ) { Action action = (Action) iter.next(); if (action instanceof ISelectionChangedListener) { provider.addSelectionChangedListener((ISelectionChangedListener) action); } } }
public ViewActionGroup( int mode, IPropertyChangeListener changeListener, IWorkbenchPartSite site) { fChangeListener = changeListener; fSite = site; if (fChangeListener == null) { fChangeListener = new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) {} }; } fFilterActionGroup = new WorkingSetFilterActionGroup(site, fChangeListener); fShowActionGroup = new WorkingSetShowActionGroup(site); fWorkingSetAssignementAction = new ConfigureWorkingSetAssignementAction(site); ISelectionProvider selectionProvider = site.getSelectionProvider(); selectionProvider.addSelectionChangedListener(fWorkingSetAssignementAction); fMode = mode; if (fMode == SHOW_WORKING_SETS) fActiveActionGroup = fShowActionGroup; else fActiveActionGroup = fFilterActionGroup; }
/** * When the active editor changes, this remembers the change and registers with it as a selection * provider. * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated */ 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())); } } }
/** * Adds this instance as a {@link ISelectionChangedListener} on the given editor. * * @param editor the {@link DialectEditor}. */ private void addSelectionListener(DialectEditor editor) { ISelectionProvider selectionProvider = editor.getEditorSite().getSelectionProvider(); selectionProvider.addSelectionChangedListener(this); }
private void initialize(ISelectionProvider provider) { this.provider = provider; ISelection selection = provider.getSelection(); openExternalDartdocAction.update(selection); provider.addSelectionChangedListener(openExternalDartdocAction); }
public void listenToSelection(ISelectionProvider source) { source.addSelectionChangedListener(selections); }
@Override protected void addPages() { initialize(); // determine factories Set<String> conflictingIds = new HashSet<String>(); ArrayList<AbstractTaskEditorPageFactory> pageFactories = new ArrayList<AbstractTaskEditorPageFactory>(); for (AbstractTaskEditorPageFactory pageFactory : TasksUiPlugin.getDefault().getTaskEditorPageFactories()) { if (pageFactory.canCreatePageFor(getTaskEditorInput()) && WorkbenchUtil.allowUseOf(pageFactory)) { pageFactories.add(pageFactory); String[] ids = pageFactory.getConflictingIds(getTaskEditorInput()); if (ids != null) { conflictingIds.addAll(Arrays.asList(ids)); } } } for (Iterator<AbstractTaskEditorPageFactory> it = pageFactories.iterator(); it.hasNext(); ) { if (conflictingIds.contains(it.next().getId())) { it.remove(); } } // sort by priority Collections.sort( pageFactories, new Comparator<AbstractTaskEditorPageFactory>() { public int compare(AbstractTaskEditorPageFactory o1, AbstractTaskEditorPageFactory o2) { return o1.getPriority() - o2.getPriority(); } }); // create pages for (AbstractTaskEditorPageFactory factory : pageFactories) { try { IFormPage page = factory.createPage(this); int index = addPage(page); setPageImage(index, factory.getPageImage(this, page)); setPageText(index, factory.getPageText(this, page)); if (factory.getPriority() == AbstractTaskEditorPageFactory.PRIORITY_TASK) { setActivePage(index); } if (page instanceof ISelectionProvider) { ((ISelectionProvider) page).addSelectionChangedListener(getActionBarContributor()); } } catch (Exception e) { StatusHandler.log( new Status( IStatus.ERROR, TasksUiPlugin.ID_PLUGIN, "Could not create editor via factory: " + factory, e)); //$NON-NLS-1$ } } updateTitleImage(); updateHeaderToolBar(); installTitleDrag(getHeaderForm().getForm().getForm()); // do this late to allow pages to replace the selection provider getEditorSite().registerContextMenu(menuManager, getEditorSite().getSelectionProvider(), true); }
public void doAddTo(Object source) { ((ISelectionProvider) source).addSelectionChangedListener(this); }