类org.eclipse.ui.IPartListener源码实例Demo

下面列出了怎么用org.eclipse.ui.IPartListener的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: birt   文件: GraphicalEditorWithFlyoutPalette.java
public void shellActivated( ShellEvent e )
{
	if ( !shellActiveFlag )
	{
		shellActiveFlag = true;
		// Pre-fetch shell from site in case it could be disposed before async execution
		final Shell siteShell = getSite( ).getShell( );
		Display.getCurrent( ).asyncExec( new Runnable( ) {

			public void run( )
			{
				if ( lastActiveShell == siteShell )
				{
					// don't active the current active editor
					shellActiveFlag = false;
					return;
				}
				else
				{
					lastActiveShell = getSite( ).getShell( );
					IEditorPart editor = UIUtil.getActiveEditor( true );
					if ( editor instanceof IPartListener )
					{
						// update the SessionHandleAdapter's model.
						// If old selection is dataset or datasource,
						// the selection status will lost.
						( (IPartListener) editor ).partActivated( editor );
					}
					shellActiveFlag = false;
				}
			}
		} );
	}
}
 
源代码2 项目: bonita-studio   文件: CoolbarToolControl.java
private void loadContributions(IWorkbenchPage page) {
    contributions.stream().map(CustomToolItem::getContributionItem).filter(IPartListener.class::isInstance)
            .forEach(partListener -> page.removePartListener((IPartListener) partListener));
    contributions.clear();

    final IConfigurationElement[] elements = BonitaStudioExtensionRegistryManager.getInstance()
            .getConfigurationElements(
                    "org.bonitasoft.studio.coolbarContributionItem");
    if (elements.length >= MAX_CONTRIBUTION_SIZE) {
        throw new RuntimeException("Too many coolbar contributions defined");
    }
    for (int i = 0; i < MAX_CONTRIBUTION_SIZE; i++) {
        final IConfigurationElement element = findContributionForPosition(i, elements);
        if (element != null) {
            try {
                final IBonitaContributionItem item = (IBonitaContributionItem) element
                        .createExecutableExtension(CLASS);
                if (contributions.size() > i && item instanceof SeparatorCoolbarItem) {
                    final IBonitaContributionItem previousItem = contributions.get(i - 1).getContributionItem();
                    if (previousItem instanceof SeparatorCoolbarItem) {
                        item.setVisible(false);
                    }
                }
                if (item.isVisible()) {
                    if (item instanceof SaveCoolbarItem) {
                        page.addPartListener((IPartListener) item);
                        ((SaveCoolbarItem) item).partOpened(page.getActivePart());
                    }
                    contributions.add(new CustomToolItem(item));
                }
            } catch (final CoreException e) {
                BonitaStudioLog.error(e);
            }
        }
    }
}
 
 类所在包
 同包方法