Search in sources :

Example 1 with IPerspectiveListener

use of org.eclipse.ui.IPerspectiveListener in project translationstudio8 by heartsome.

the class ApplicationWorkbenchWindowAdvisor method setListenerToPespective.

/**
	 * 给默认透视图添加监听,当透视图发生改变时,触发相关事件	robert	2012-10-18
	 * @param commandService
	 */
private void setListenerToPespective(final ICommandService commandService) {
    final IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    IPerspectiveListener perspectiveListener = new IPerspectiveListener() {

        public void perspectiveChanged(IWorkbenchPage page, IPerspectiveDescriptor perspective, String changeId) {
        }

        public void perspectiveActivated(IWorkbenchPage page, IPerspectiveDescriptor perspective) {
            // 改变透视图时,发出监听去检查品质检查结果视图的状态,从而让 视图 菜单的状态与之保持一致。
            commandService.refreshElements("net.heartsome.cat.ts.ui.qa.handlers.OpenQAResultViewCommand", null);
            // 显示状态栏与工具栏
            IHandlerService handlerService = (IHandlerService) window.getService(IHandlerService.class);
            IPreferenceStore preferenceStore = Activator.getDefault().getPreferenceStore();
            boolean statusVisible = preferenceStore.getBoolean(TsPreferencesConstant.TS_statusBar_status);
            if (!statusVisible) {
                preferenceStore.setValue(TsPreferencesConstant.TS_statusBar_status, false);
                try {
                    handlerService.executeCommand("net.heartsome.cat.ts.command.openStatusBar", null);
                } catch (Exception ex) {
                    throw new RuntimeException("CommandTest.exitcommand not found");
                }
            }
            WorkbenchWindow window_1 = (WorkbenchWindow) window;
            if (!window_1.getCoolBarVisible()) {
                try {
                    window_1.toggleToolbarVisibility();
                    commandService.refreshElements("net.heartsome.cat.ts.command.openToolBar", null);
                } catch (Exception ex) {
                    throw new RuntimeException("CommandTest.exitcommand not found");
                }
            }
        }
    };
    window.addPerspectiveListener(perspectiveListener);
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) WorkbenchWindow(org.eclipse.ui.internal.WorkbenchWindow) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IPerspectiveListener(org.eclipse.ui.IPerspectiveListener) IHandlerService(org.eclipse.ui.handlers.IHandlerService) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IPerspectiveDescriptor(org.eclipse.ui.IPerspectiveDescriptor) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) CoreException(org.eclipse.core.runtime.CoreException) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 2 with IPerspectiveListener

use of org.eclipse.ui.IPerspectiveListener in project yamcs-studio by yamcs.

the class YamcsStudioWorkbenchWindowAdvisor method preWindowOpen.

@Override
public void preWindowOpen() {
    IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
    configurer.setInitialSize(new Point(1920, 1200));
    configurer.setShowMenuBar(true);
    configurer.setShowCoolBar(true);
    configurer.setShowProgressIndicator(true);
    configurer.setShowPerspectiveBar(false);
    configurer.setShowStatusLine(true);
    updateTitle();
    configurer.getWindow().addPerspectiveListener(new IPerspectiveListener() {

        @Override
        public void perspectiveChanged(IWorkbenchPage page, IPerspectiveDescriptor perspective, String changeId) {
            updateTitle();
        }

        @Override
        public void perspectiveActivated(IWorkbenchPage page, IPerspectiveDescriptor perspective) {
            updateTitle();
        }
    });
    // Workaround for text editor DND bug.
    // See http://www.eclipse.org/forums/index.php/m/333816/
    configurer.configureEditorAreaDropListener(new EditorAreaDropAdapter(configurer.getWindow()));
    // Bootstrap DIIRT
    CompositeDataSource defaultDs = (CompositeDataSource) PVManager.getDefaultDataSource();
    defaultDs.putDataSource(new ParameterDataSourceProvider());
    defaultDs.setConfiguration(new CompositeDataSourceConfiguration().defaultDataSource("para").delimiter("://"));
    PVManager.setDefaultDataSource(defaultDs);
}
Also used : IPerspectiveListener(org.eclipse.ui.IPerspectiveListener) ParameterDataSourceProvider(org.yamcs.studio.css.core.pvmanager.ParameterDataSourceProvider) EditorAreaDropAdapter(org.eclipse.ui.internal.ide.EditorAreaDropAdapter) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IWorkbenchWindowConfigurer(org.eclipse.ui.application.IWorkbenchWindowConfigurer) IPerspectiveDescriptor(org.eclipse.ui.IPerspectiveDescriptor) Point(org.eclipse.swt.graphics.Point) CompositeDataSource(org.diirt.datasource.CompositeDataSource) CompositeDataSourceConfiguration(org.diirt.datasource.CompositeDataSourceConfiguration)

Example 3 with IPerspectiveListener

use of org.eclipse.ui.IPerspectiveListener in project watchdog by TestRoots.

the class WindowListener method addPerspectiveListener.

private void addPerspectiveListener(IWorkbenchWindow window) {
    IPerspectiveListener perspectiveListener = new PerspectiveListener();
    window.addPerspectiveListener(perspectiveListener);
    // triggers the event for the currently open perspective, if there is
    // any
    IWorkbenchPage activePage = window.getActivePage();
    if (activePage != null) {
        IPerspectiveDescriptor currentPerspective = window.getActivePage().getPerspective();
        if (currentPerspective != null) {
            perspectiveListener.perspectiveActivated(activePage, currentPerspective);
        }
    }
}
Also used : IPerspectiveListener(org.eclipse.ui.IPerspectiveListener) IPerspectiveListener(org.eclipse.ui.IPerspectiveListener) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IPerspectiveDescriptor(org.eclipse.ui.IPerspectiveDescriptor)

Aggregations

IPerspectiveDescriptor (org.eclipse.ui.IPerspectiveDescriptor)3 IPerspectiveListener (org.eclipse.ui.IPerspectiveListener)3 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 CompositeDataSource (org.diirt.datasource.CompositeDataSource)1 CompositeDataSourceConfiguration (org.diirt.datasource.CompositeDataSourceConfiguration)1 CoreException (org.eclipse.core.runtime.CoreException)1 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)1 Point (org.eclipse.swt.graphics.Point)1 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)1 IWorkbenchWindowConfigurer (org.eclipse.ui.application.IWorkbenchWindowConfigurer)1 IHandlerService (org.eclipse.ui.handlers.IHandlerService)1 WorkbenchWindow (org.eclipse.ui.internal.WorkbenchWindow)1 EditorAreaDropAdapter (org.eclipse.ui.internal.ide.EditorAreaDropAdapter)1 ParameterDataSourceProvider (org.yamcs.studio.css.core.pvmanager.ParameterDataSourceProvider)1