Search in sources :

Example 6 with WorkbenchWindow

use of org.eclipse.ui.internal.WorkbenchWindow in project cubrid-manager by CUBRID.

the class PerspectiveChangedListener method hidePerspectiveHide.

public void hidePerspectiveHide(PerspectiveChangeEvent event) {
    WorkbenchWindow window = (WorkbenchWindow) PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (window != null) {
        ICoolBarManager coolBarManager = window.getCoolBarManager2();
        IMenuManager menuManager = window.getMenuBarManager();
        ActionAdvisor.getInstance().hideToolbar(coolBarManager);
        ActionAdvisor.getInstance().hideMenu(menuManager);
    }
}
Also used : WorkbenchWindow(org.eclipse.ui.internal.WorkbenchWindow) IMenuManager(org.eclipse.jface.action.IMenuManager) ICoolBarManager(org.eclipse.jface.action.ICoolBarManager)

Example 7 with WorkbenchWindow

use of org.eclipse.ui.internal.WorkbenchWindow 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 8 with WorkbenchWindow

use of org.eclipse.ui.internal.WorkbenchWindow in project cubrid-manager by CUBRID.

the class ActionManager method changeActionMenu.

/**
	 * 
	 * Change action menu
	 * 
	 */
private void changeActionMenu() {
    WorkbenchWindow window = (WorkbenchWindow) PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (window == null) {
        return;
    }
    IMenuManager menuBarManager = window.getMenuBarManager();
    if (menuBarManager == null) {
        return;
    }
    IMenuManager actionMenuManager = menuBarManager.findMenuUsingPath(IActionConstants.MENU_ACTION);
    if (actionMenuManager != null) {
        actionMenuManager.removeAll();
        setActionsMenu(actionMenuManager);
        menuBarManager.update(true);
    }
}
Also used : WorkbenchWindow(org.eclipse.ui.internal.WorkbenchWindow) IMenuManager(org.eclipse.jface.action.IMenuManager)

Example 9 with WorkbenchWindow

use of org.eclipse.ui.internal.WorkbenchWindow in project cubrid-manager by CUBRID.

the class StatusLineContrItem method changeStuatusLineForViewOrEditPart.

/**
	 *
	 * When selection changed,change status line message for view part or editor
	 * part
	 *
	 * @param node the ICubridNode object
	 * @param workbenchPart the IWorkbenchPart object
	 */
public void changeStuatusLineForViewOrEditPart(ICubridNode node, IWorkbenchPart workbenchPart) {
    WorkbenchWindow window = (WorkbenchWindow) PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (window == null) {
        return;
    }
    String nodePath = "";
    if (workbenchPart == null) {
        if (null != node.getViewId()) {
            IViewPart viewPart = LayoutUtil.getViewPart(node, node.getViewId());
            if (viewPart != null) {
                nodePath = viewPart.getTitle();
            }
        }
        if (null != node.getEditorId()) {
            IEditorPart editorPart = LayoutUtil.getEditorPart(node, node.getEditorId());
            if (editorPart != null) {
                nodePath = editorPart.getTitle();
            }
        }
    } else {
        nodePath = workbenchPart.getTitle();
    }
//window.setStatus(nodePath == null ? "" : nodePath);
}
Also used : WorkbenchWindow(org.eclipse.ui.internal.WorkbenchWindow) IViewPart(org.eclipse.ui.IViewPart) IEditorPart(org.eclipse.ui.IEditorPart)

Example 10 with WorkbenchWindow

use of org.eclipse.ui.internal.WorkbenchWindow in project cubrid-manager by CUBRID.

the class CubridStatusLineContrItem method updateStatusLineForRestoreQueryEditor.

private void updateStatusLineForRestoreQueryEditor() {
    final int countOfRestorableQueryEditors = ApplicationPersistUtil.getInstance().countOfRestorableQueryEditorsAtLastSession();
    if (countOfRestorableQueryEditors <= 0) {
        return;
    }
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    StatusLineManager statusLineManager = null;
    if (window instanceof WorkbenchWindow) {
        statusLineManager = ((WorkbenchWindow) window).getStatusLineManager();
    }
    if (statusLineManager == null) {
        return;
    }
    IContributionItem scaleItem = new ControlContribution(RESTORE_QUERY_EDITORS_CONTR_ID) {

        protected Control createControl(Composite parent) {
            Button btn = new Button(parent, SWT.None);
            String buttonTitle = Messages.bind(com.cubrid.common.ui.common.Messages.restoreQueryEditorTitle, countOfRestorableQueryEditors);
            btn.setText(buttonTitle);
            btn.addSelectionListener(new SelectionAdapter() {

                public void widgetSelected(SelectionEvent e) {
                    ActionManager manager = ActionManager.getInstance();
                    IAction action = manager.getAction(RestoreQueryEditorAction.ID);
                    if (action != null && action instanceof RestoreQueryEditorAction) {
                        action.run();
                    }
                }
            });
            return btn;
        }

        ;
    };
    statusLineManager.add(scaleItem);
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) WorkbenchWindow(org.eclipse.ui.internal.WorkbenchWindow) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) Composite(org.eclipse.swt.widgets.Composite) IAction(org.eclipse.jface.action.IAction) StatusLineManager(org.eclipse.jface.action.StatusLineManager) IContributionItem(org.eclipse.jface.action.IContributionItem) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ControlContribution(org.eclipse.jface.action.ControlContribution) ActionManager(com.cubrid.common.ui.spi.action.ActionManager) RestoreQueryEditorAction(com.cubrid.common.ui.common.action.RestoreQueryEditorAction) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Aggregations

WorkbenchWindow (org.eclipse.ui.internal.WorkbenchWindow)15 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)8 StatusLineManager (org.eclipse.jface.action.StatusLineManager)6 IMenuManager (org.eclipse.jface.action.IMenuManager)5 CubridNavigatorView (com.cubrid.common.ui.common.navigator.CubridNavigatorView)4 ICoolBarManager (org.eclipse.jface.action.ICoolBarManager)4 RestoreQueryEditorAction (com.cubrid.common.ui.common.action.RestoreQueryEditorAction)2 ActionManager (com.cubrid.common.ui.spi.action.ActionManager)2 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)2 ControlContribution (org.eclipse.jface.action.ControlContribution)2 IAction (org.eclipse.jface.action.IAction)2 IContributionItem (org.eclipse.jface.action.IContributionItem)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2 Button (org.eclipse.swt.widgets.Button)2 Composite (org.eclipse.swt.widgets.Composite)2 CubridServer (com.cubrid.common.ui.spi.model.CubridServer)1 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1