Example usage for org.eclipse.jface.action IContributionManager prependToGroup

List of usage examples for org.eclipse.jface.action IContributionManager prependToGroup

Introduction

In this page you can find the example usage for org.eclipse.jface.action IContributionManager prependToGroup.

Prototype

void prependToGroup(String groupName, IContributionItem item);

Source Link

Document

Adds a contribution item to this manager at the beginning of the group with the given name.

Usage

From source file:com.nokia.carbide.cpp.pi.address.GenericAddrTable.java

License:Open Source License

public void setIsDrilldown(boolean isDrilldown) {
    this.isDrilldown = isDrilldown;
    copyDrilldownAction.setEnabled(isDrilldown);
    saveDrilldownAction.setEnabled(isDrilldown);

    // may need to clean up stale Edit & File menu entry for PICopyDrilldown and PISaveDrilldown 
    if (!isDrilldown) {
        IMenuManager editMenuManager = PIPageEditor.getActionBars().getMenuManager()
                .findMenuUsingPath(IIDEActionConstants.M_EDIT);

        if (editMenuManager instanceof SubMenuManager) {
            IContributionManager editManager = ((SubMenuManager) editMenuManager).getParent();
            ActionContributionItem item;

            editMenuManager.remove("PICopyDrilldown"); //$NON-NLS-1$
            item = new ActionContributionItem(copyDrilldownAction);
            item.setVisible(true);/*from w  w w.j  a  va 2  s. c  o m*/
            editManager.prependToGroup(IIDEActionConstants.CUT_EXT, item);

            editMenuManager.remove("PICopyTable"); //$NON-NLS-1$
            copyTableAction.setEnabled(table.getItemCount() > 0);
            item = new ActionContributionItem(copyTableAction);
            item.setVisible(true);
            editManager.prependToGroup(IIDEActionConstants.CUT_EXT, item);
        }

        IMenuManager fileMenuManager = PIPageEditor.getActionBars().getMenuManager()
                .findMenuUsingPath(IIDEActionConstants.M_FILE);

        if (fileMenuManager instanceof SubMenuManager) {
            IContributionManager fileManager = ((SubMenuManager) fileMenuManager).getParent();
            ActionContributionItem item;

            fileMenuManager.remove("PISaveTable"); //$NON-NLS-1$
            saveTableAction.setEnabled(table.getItemCount() > 0);
            item = new ActionContributionItem(saveTableAction);
            item.setVisible(true);
            fileManager.insertAfter("saveAll", item); //$NON-NLS-1$

            fileMenuManager.remove("PISaveDrilldown"); //$NON-NLS-1$
            item = new ActionContributionItem(saveDrilldownAction);
            item.setVisible(true);
            fileManager.insertAfter("PISaveTable", item); //$NON-NLS-1$
            fileManager.update(true);
        }
    }
}

From source file:com.nokia.carbide.cpp.pi.call.CallVisualiser.java

License:Open Source License

private void createCurrentFunctionTableViewer(SashForm sashForm) {
    /*/*from  www.java2  s . co m*/
     * Functions (one checkbox selectable at a time)
     *
     *       selected checkbox
     *      percent load
     *     function name
     *      function start address
     *      binary containing function
     *      sample count
     */
    Label label;
    Composite holder;
    Table table;
    TableColumn column;

    // middle functionTable and title
    holder = new Composite(sashForm, SWT.NONE);
    GridLayout gridLayout = new GridLayout(1, true);
    gridLayout.marginWidth = 0;
    gridLayout.marginHeight = 0;
    holder.setLayout(gridLayout);

    label = new Label(holder, SWT.CENTER | SWT.BORDER);
    label.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_YELLOW));
    label.setFont(PIPageEditor.helvetica_10);
    label.setText(Messages.getString("CallVisualiser.selectFunction")); //$NON-NLS-1$
    label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    this.currentFunctionTableViewer = new TableViewer(holder,
            SWT.BORDER | SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);
    this.currentFunctionTable = currentFunctionTableViewer.getTable();

    // add the label provider and content provider
    this.currentFunctionTableViewer.setLabelProvider(new SharedLabelProvider(this.currentFunctionTable));
    this.currentFunctionTableViewer.setContentProvider(new ArrayContentProvider());
    this.currentFunctionTableViewer.setSorter(new SharedSorter());

    table = this.currentFunctionTable;
    table.setRedraw(false);

    // give the table a heading for use in copying and exported
    table.setData(Messages.getString("CallVisualiser.selectedFunction")); //$NON-NLS-1$

    // create the other table entries when a row in this table is selected
    table.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent event) {

            if (!(event.item instanceof TableItem))
                return;

            // set the other tables based on this selection
            if (!(event.item.getData() instanceof GfcFunctionItem))
                return;

            updateCallerCalleeTables((GfcFunctionItem) event.item.getData());
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }
    });

    // data associated with the TableViewer will note which columns contain hex values
    // Keep this in the order in which columns have been created
    boolean[] isHex = { false, false, false, true, false, false, false };
    this.currentFunctionTable.setData("isHex", isHex); //$NON-NLS-1$

    // is called percent column
    column = new TableColumn(table, SWT.RIGHT);
    column.setText(COLUMN_HEAD_IS_CALLED);
    column.setWidth(COLUMN_WIDTH_IS_CALLED);
    column.setData(Integer.valueOf(COLUMN_ID_IS_CALLED));
    column.setMoveable(true);
    column.setResizable(true);
    column.addSelectionListener(new CheckboxColumnSelectionHandler());

    // is caller percent column
    column = new TableColumn(table, SWT.RIGHT);
    column.setText(COLUMN_HEAD_IS_CALLER);
    column.setWidth(COLUMN_WIDTH_IS_CALLER);
    column.setData(Integer.valueOf(COLUMN_ID_IS_CALLER));
    column.setMoveable(true);
    column.setResizable(true);
    column.addSelectionListener(new CheckboxColumnSelectionHandler());

    // function name column
    column = new TableColumn(table, SWT.LEFT);
    column.setText(COLUMN_HEAD_FUNCTION);
    column.setWidth(COLUMN_WIDTH_FUNCTION_NAME);
    column.setData(Integer.valueOf(COLUMN_ID_FUNCTION));
    column.setMoveable(true);
    column.setResizable(true);
    column.addSelectionListener(new CheckboxColumnSelectionHandler());

    // function start address column
    column = new TableColumn(table, SWT.CENTER);
    column.setText(COLUMN_HEAD_START_ADDR);
    column.setWidth(COLUMN_WIDTH_START_ADDRESS);
    column.setData(Integer.valueOf(COLUMN_ID_START_ADDR));
    column.setMoveable(true);
    column.setResizable(true);
    column.addSelectionListener(new CheckboxColumnSelectionHandler());

    // binary containing function column
    column = new TableColumn(table, SWT.LEFT);
    column.setText(COLUMN_HEAD_IN_BINARY);
    column.setWidth(COLUMN_WIDTH_IN_BINARY);
    column.setData(Integer.valueOf(COLUMN_ID_IN_BINARY));
    column.setMoveable(true);
    column.setResizable(true);
    column.addSelectionListener(new CheckboxColumnSelectionHandler());

    // path to binary containing function column
    column = new TableColumn(table, SWT.LEFT);
    column.setText(COLUMN_HEAD_IN_BINARY_PATH);
    column.setWidth(COLUMN_WIDTH_IN_BINARY_PATH);
    column.setData(Integer.valueOf(COLUMN_ID_IN_BINARY_PATH));
    column.setMoveable(true);
    column.setResizable(true);
    column.addSelectionListener(new CheckboxColumnSelectionHandler());

    // sample count column
    column = new TableColumn(table, SWT.CENTER);
    column.setText(COLUMN_HEAD_IS_CALLED_COUNT);
    column.setWidth(COLUMN_WIDTH_IS_CALLED_COUNT);
    column.setData(Integer.valueOf(COLUMN_ID_IS_CALLED_COUNT));
    column.setMoveable(true);
    column.setResizable(true);
    column.addSelectionListener(new CheckboxColumnSelectionHandler());

    // set the default sort column to COLUMN_ID_IS_CALLED_COUNT
    currentFunctionDefaultColumn = column;

    // sample count column
    column = new TableColumn(table, SWT.CENTER);
    column.setText(COLUMN_HEAD_IS_CALLER_COUNT);
    column.setWidth(COLUMN_WIDTH_IS_CALLER_COUNT);
    column.setData(Integer.valueOf(COLUMN_ID_IS_CALLER_COUNT));
    column.setMoveable(true);
    column.setResizable(true);
    column.addSelectionListener(new CheckboxColumnSelectionHandler());

    table.setLayoutData(new GridData(GridData.FILL_BOTH));
    table.setHeaderVisible(true);
    table.setLinesVisible(true);
    table.setRedraw(true);

    // listen for mouse clicks: to select a row, pop up a menu, etc.
    table.addMouseListener(new CurrentFunctionMouseListener());

    table.addFocusListener(new FocusListener() {
        IAction oldCopyAction = null;

        public void focusGained(org.eclipse.swt.events.FocusEvent arg0) {
            IActionBars bars = PIPageEditor.getActionBars();

            // modify what is executed when Copy is called from the Edit menu
            oldCopyAction = bars.getGlobalActionHandler(ActionFactory.COPY.getId());

            bars.setGlobalActionHandler(ActionFactory.COPY.getId(), copyAction);

            copyAction.setEnabled(currentFunctionTable.getSelectionCount() > 0);
            bars.updateActionBars();

            // add to the Edit menu
            IMenuManager editMenuManager = bars.getMenuManager().findMenuUsingPath(IIDEActionConstants.M_EDIT);

            if (editMenuManager instanceof SubMenuManager) {
                IContributionManager editManager = ((SubMenuManager) editMenuManager).getParent();
                ActionContributionItem item;

                editMenuManager.remove("PICopyFunction"); //$NON-NLS-1$
                functionCopyFunctionAction.setEnabled(currentFunctionTable.getSelectionCount() > 0);
                item = new ActionContributionItem(functionCopyFunctionAction);
                item.setVisible(true);
                editManager.prependToGroup(IIDEActionConstants.CUT_EXT, item);

                editMenuManager.remove("PICopyTable"); //$NON-NLS-1$
                copyTableAction.setEnabled(currentFunctionTable.getItemCount() > 0);
                item = new ActionContributionItem(copyTableAction);
                item.setVisible(true);
                editManager.prependToGroup(IIDEActionConstants.CUT_EXT, item);
            }

            // add to the File menu
            IMenuManager fileMenuManager = bars.getMenuManager().findMenuUsingPath(IIDEActionConstants.M_FILE);

            if (fileMenuManager instanceof SubMenuManager) {
                IContributionManager fileManager = ((SubMenuManager) fileMenuManager).getParent();
                ActionContributionItem item;

                fileMenuManager.remove("PISaveTable"); //$NON-NLS-1$
                saveTableAction.setEnabled(currentFunctionTable.getItemCount() > 0);
                item = new ActionContributionItem(saveTableAction);
                item.setVisible(true);
                fileManager.insertAfter("saveAll", item); //$NON-NLS-1$

                fileMenuManager.remove("PISaveFunction"); //$NON-NLS-1$
                functionSaveFunctionAction.setEnabled(currentFunctionTable.getSelectionCount() > 0);
                item = new ActionContributionItem(functionSaveFunctionAction);
                item.setVisible(true);
                fileManager.insertAfter("PISaveTable", item); //$NON-NLS-1$
            }
        }

        public void focusLost(org.eclipse.swt.events.FocusEvent arg0) {
            IActionBars bars = PIPageEditor.getActionBars();
            bars.setGlobalActionHandler(ActionFactory.COPY.getId(), oldCopyAction);
            bars.updateActionBars();

            SubMenuManager editMenuManager = (SubMenuManager) PIPageEditor.getMenuManager()
                    .find(IIDEActionConstants.M_EDIT);
            editMenuManager.remove("PICopyTable"); //$NON-NLS-1$
            editMenuManager.remove("PICopyFunction"); //$NON-NLS-1$

            SubMenuManager fileMenuManager = (SubMenuManager) PIPageEditor.getMenuManager()
                    .find(IIDEActionConstants.M_FILE);
            fileMenuManager.remove("PISaveTable"); //$NON-NLS-1$
            fileMenuManager.remove("PISaveFunction"); //$NON-NLS-1$
        }
    });
}

From source file:com.nokia.carbide.cpp.pi.call.CallVisualiser.java

License:Open Source License

private void createCallerTableViewer(SashForm sashForm) {
    /*//from www  .ja va2  s.  c om
     * Functions called by
     * 
     *      percent of calls
     *      total percent
     *      caller percent
     *     function name
     *      function start address
     *      binary containing function
     *      sample count
     */
    Label label;
    Composite holder;
    Table table;
    TableColumn column;

    // top functionTable and title
    holder = new Composite(sashForm, SWT.NONE);
    //      holder.setLayout(new FillLayout(SWT.VERTICAL));
    GridLayout gridLayout = new GridLayout(1, true);
    gridLayout.marginWidth = 0;
    gridLayout.marginHeight = 0;
    holder.setLayout(gridLayout);

    label = new Label(holder, SWT.CENTER | SWT.BORDER);
    label.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_CYAN));
    label.setFont(PIPageEditor.helvetica_10);
    label.setText(Messages.getString("CallVisualiser.callingSelectedFunction")); //$NON-NLS-1$
    label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    this.callerTableViewer = new TableViewer(holder,
            SWT.BORDER | SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);
    this.callerTable = callerTableViewer.getTable();

    // add the label provider and content provider
    this.callerTableViewer.setLabelProvider(new SharedLabelProvider(this.callerTable));
    this.callerTableViewer.setContentProvider(new ArrayContentProvider());
    this.callerTableViewer.setSorter(new SharedSorter());

    table = this.callerTable;
    table.setRedraw(false);

    // give the table a heading for possible use in copying and exported
    table.setData(Messages.getString("CallVisualiser.callerFunctions")); //$NON-NLS-1$

    // data associated with the TableViewer will note which columns contain hex values
    // Keep this in the order in which columns have been created
    boolean[] isHex = { false, false, false, true, false, false, false };
    this.callerTable.setData("isHex", isHex); //$NON-NLS-1$

    // percent of calls column
    column = new TableColumn(table, SWT.RIGHT);
    column.setText(COLUMN_HEAD_CALLER_PERCENT);
    column.setWidth(COLUMN_WIDTH_CALLER_PERCENT);
    column.setData(Integer.valueOf(COLUMN_ID_CALLER_PERCENT));
    column.setMoveable(true);
    column.setResizable(true);
    column.addSelectionListener(new CalledByColumnSelectionHandler());

    // sample count column
    column = new TableColumn(table, SWT.CENTER);
    column.setText(COLUMN_HEAD_IS_CALLER_COUNT2);
    column.setWidth(COLUMN_WIDTH_IS_CALLER_COUNT2);
    column.setData(Integer.valueOf(COLUMN_ID_IS_CALLER_COUNT));
    column.setMoveable(true);
    column.setResizable(true);
    column.addSelectionListener(new CalledByColumnSelectionHandler());

    // function name column
    column = new TableColumn(table, SWT.LEFT);
    column.setText(COLUMN_HEAD_FUNCTION);
    column.setWidth(COLUMN_WIDTH_FUNCTION_NAME);
    column.setData(Integer.valueOf(COLUMN_ID_FUNCTION));
    column.setMoveable(true);
    column.setResizable(true);
    column.addSelectionListener(new CalledByColumnSelectionHandler());

    // function start address column
    column = new TableColumn(table, SWT.CENTER);
    column.setText(COLUMN_HEAD_START_ADDR);
    column.setWidth(COLUMN_WIDTH_START_ADDRESS);
    column.setData(Integer.valueOf(COLUMN_ID_START_ADDR));
    column.setMoveable(true);
    column.setResizable(true);
    column.addSelectionListener(new CalledByColumnSelectionHandler());

    // binary containing function column
    column = new TableColumn(table, SWT.LEFT);
    column.setText(COLUMN_HEAD_IN_BINARY);
    column.setWidth(COLUMN_WIDTH_IN_BINARY);
    column.setData(Integer.valueOf(COLUMN_ID_IN_BINARY));
    column.setMoveable(true);
    column.setResizable(true);
    column.addSelectionListener(new CalledByColumnSelectionHandler());

    // path to binary containing function column
    column = new TableColumn(table, SWT.LEFT);
    column.setText(COLUMN_HEAD_IN_BINARY_PATH);
    column.setWidth(COLUMN_WIDTH_IN_BINARY_PATH);
    column.setData(Integer.valueOf(COLUMN_ID_IN_BINARY_PATH));
    column.setMoveable(true);
    column.setResizable(true);
    column.addSelectionListener(new CalledByColumnSelectionHandler());

    // is caller percent column
    column = new TableColumn(table, SWT.RIGHT);
    column.setText(COLUMN_HEAD_IS_CALLER);
    column.setWidth(COLUMN_WIDTH_IS_CALLER);
    column.setData(Integer.valueOf(COLUMN_ID_IS_CALLER));
    column.setMoveable(true);
    column.setResizable(true);
    column.addSelectionListener(new CalledByColumnSelectionHandler());

    table.setLayoutData(new GridData(GridData.FILL_BOTH));
    //      table.setLayout(new FillLayout());
    table.setHeaderVisible(true);
    table.setLinesVisible(true);
    table.setRedraw(true);

    // when a row is selected, allow the user to double-click or right click and make that function the selected function
    table.addSelectionListener(new SelectionAdapter() {

        public void widgetDefaultSelected(SelectionEvent se) {
            TableItem item = (TableItem) se.item;
            Table table = (Table) se.widget;
            CallerCalleeItem callerCalleeItem = (CallerCalleeItem) item.getData();

            // deselect this line
            table.deselectAll();

            // choose this row's function
            chooseNewFunction(callerCalleeItem);
        }
    });

    table.addMouseListener(new CallerMouseListener());

    table.addFocusListener(new FocusListener() {
        IAction oldCopyAction = null;

        public void focusGained(org.eclipse.swt.events.FocusEvent arg0) {
            IActionBars bars = PIPageEditor.getActionBars();

            // modify what is executed when Copy is called from the Edit menu
            oldCopyAction = bars.getGlobalActionHandler(ActionFactory.COPY.getId());

            bars.setGlobalActionHandler(ActionFactory.COPY.getId(), copyAction);

            copyAction.setEnabled(callerTable.getSelectionCount() > 0);
            bars.updateActionBars();

            // add to the Edit menu
            IMenuManager editMenuManager = bars.getMenuManager().findMenuUsingPath(IIDEActionConstants.M_EDIT);

            if (editMenuManager instanceof SubMenuManager) {
                IContributionManager editManager = ((SubMenuManager) editMenuManager).getParent();
                ActionContributionItem item;

                editMenuManager.remove("PICopyTable"); //$NON-NLS-1$
                copyTableAction.setEnabled(callerTable.getItemCount() > 0);
                item = new ActionContributionItem(copyTableAction);
                item.setVisible(true);
                editManager.prependToGroup(IIDEActionConstants.CUT_EXT, item);
            }

            // add to the File menu
            IMenuManager fileMenuManager = bars.getMenuManager().findMenuUsingPath(IIDEActionConstants.M_FILE);

            if (fileMenuManager instanceof SubMenuManager) {
                IContributionManager fileManager = ((SubMenuManager) fileMenuManager).getParent();
                ActionContributionItem item;

                fileMenuManager.remove("PISaveTable"); //$NON-NLS-1$
                saveTableAction.setEnabled(callerTable.getItemCount() > 0);
                item = new ActionContributionItem(saveTableAction);
                item.setVisible(true);
                fileManager.insertAfter("saveAll", item); //$NON-NLS-1$
            }
        }

        public void focusLost(org.eclipse.swt.events.FocusEvent arg0) {
            IActionBars bars = PIPageEditor.getActionBars();
            bars.setGlobalActionHandler(ActionFactory.COPY.getId(), oldCopyAction);
            bars.updateActionBars();

            SubMenuManager editMenuManager = (SubMenuManager) PIPageEditor.getMenuManager()
                    .find(IIDEActionConstants.M_EDIT);
            editMenuManager.remove("PICopyTable"); //$NON-NLS-1$

            SubMenuManager fileMenuManager = (SubMenuManager) PIPageEditor.getMenuManager()
                    .find(IIDEActionConstants.M_FILE);
            fileMenuManager.remove("PISaveTable"); //$NON-NLS-1$
        }
    });
}

From source file:com.nokia.carbide.cpp.pi.call.CallVisualiser.java

License:Open Source License

private void createCalleeTableViewer(SashForm sashForm) {
    /*//from w w  w  .j av a 2  s .c o m
     * Functions called
     * 
     *      percent of calls
     *      total percent
     *      caller percent
     *     function name
     *      function start address
     *      binary containing function
     *      sample count
     */
    Label label;
    Composite holder;
    Table table;
    TableColumn column;

    // bottom functionTable and title
    holder = new Composite(sashForm, SWT.NONE);
    //      holder.setLayout(new FillLayout(SWT.VERTICAL));
    GridLayout gridLayout = new GridLayout(1, true);
    gridLayout.marginWidth = 0;
    gridLayout.marginHeight = 0;
    holder.setLayout(gridLayout);

    label = new Label(holder, SWT.CENTER | SWT.BORDER);
    label.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_CYAN));
    label.setFont(PIPageEditor.helvetica_10);
    label.setText(Messages.getString("CallVisualiser.calledBySelectedFunction")); //$NON-NLS-1$
    label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    this.calleeTableViewer = new TableViewer(holder,
            SWT.BORDER | SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);
    this.calleeTable = calleeTableViewer.getTable();

    // add the label provider and content provider
    this.calleeTableViewer.setLabelProvider(new SharedLabelProvider(this.calleeTable));
    this.calleeTableViewer.setContentProvider(new ArrayContentProvider());
    this.calleeTableViewer.setSorter(new SharedSorter());

    table = this.calleeTable;
    table.setRedraw(false);

    // give the table a heading for possible use in copying and exported
    table.setData(Messages.getString("CallVisualiser.calleeFunctions")); //$NON-NLS-1$

    // data associated with the TableViewer will note which columns contain hex values
    // Keep this in the order in which columns have been created
    boolean[] isHex = { false, false, false, true, false, false, false };
    this.calleeTable.setData("isHex", isHex); //$NON-NLS-1$

    // percent of calls column
    column = new TableColumn(table, SWT.RIGHT);
    column.setText(COLUMN_HEAD_CALLEE_PERCENT);
    column.setWidth(COLUMN_WIDTH_CALLEE_PERCENT);
    column.setData(Integer.valueOf(COLUMN_ID_CALLEE_PERCENT));
    column.setMoveable(true);
    column.setResizable(true);
    column.addSelectionListener(new CalledColumnSelectionHandler());

    // sample count column
    column = new TableColumn(table, SWT.CENTER);
    column.setText(COLUMN_HEAD_IS_CALLED_COUNT2);
    column.setWidth(COLUMN_WIDTH_IS_CALLED_COUNT2);
    column.setData(Integer.valueOf(COLUMN_ID_IS_CALLED_COUNT));
    column.setMoveable(true);
    column.setResizable(true);
    column.addSelectionListener(new CalledColumnSelectionHandler());

    // function name column
    column = new TableColumn(table, SWT.LEFT);
    column.setText(COLUMN_HEAD_FUNCTION);
    column.setWidth(COLUMN_WIDTH_FUNCTION_NAME);
    column.setData(Integer.valueOf(COLUMN_ID_FUNCTION));
    column.setMoveable(true);
    column.setResizable(true);
    column.addSelectionListener(new CalledColumnSelectionHandler());

    // function start address column
    column = new TableColumn(table, SWT.CENTER);
    column.setText(COLUMN_HEAD_START_ADDR);
    column.setWidth(COLUMN_WIDTH_START_ADDRESS);
    //      column.setData(Integer.valueOf(COLUMN_ID_START_ADDR3));
    column.setData(Integer.valueOf(COLUMN_ID_START_ADDR));
    column.setMoveable(true);
    column.setResizable(true);
    column.addSelectionListener(new CalledColumnSelectionHandler());

    // binary containing function column
    column = new TableColumn(table, SWT.LEFT);
    column.setText(COLUMN_HEAD_IN_BINARY);
    column.setWidth(COLUMN_WIDTH_IN_BINARY);
    //      column.setData(Integer.valueOf(COLUMN_ID_IN_BINARY3));
    column.setData(Integer.valueOf(COLUMN_ID_IN_BINARY));
    column.setMoveable(true);
    column.setResizable(true);
    column.addSelectionListener(new CalledColumnSelectionHandler());

    // path to binary containing function column
    column = new TableColumn(table, SWT.LEFT);
    column.setText(COLUMN_HEAD_IN_BINARY_PATH);
    column.setWidth(COLUMN_WIDTH_IN_BINARY_PATH);
    //      column.setData(Integer.valueOf(COLUMN_ID_IN_BINARY_PATH3));
    column.setData(Integer.valueOf(COLUMN_ID_IN_BINARY_PATH));
    column.setMoveable(true);
    column.setResizable(true);
    column.addSelectionListener(new CalledColumnSelectionHandler());

    // percent of calls column
    column = new TableColumn(table, SWT.RIGHT);
    column.setText(COLUMN_HEAD_IS_CALLED);
    column.setWidth(COLUMN_WIDTH_IS_CALLED);
    //      column.setData(Integer.valueOf(COLUMN_ID_IS_CALLED3));
    column.setData(Integer.valueOf(COLUMN_ID_IS_CALLED));
    column.setMoveable(true);
    column.setResizable(true);
    column.addSelectionListener(new CalledColumnSelectionHandler());

    table.setLayoutData(new GridData(GridData.FILL_BOTH));
    //      table.setLayout(new FillLayout());
    table.setHeaderVisible(true);
    table.setLinesVisible(true);
    table.setRedraw(true);

    // when a row is selected, allow the user to double-click or right click and make that function the selected function
    table.addSelectionListener(new SelectionAdapter() {

        public void widgetDefaultSelected(SelectionEvent se) {
            TableItem item = (TableItem) se.item;
            Table table = (Table) se.widget;
            CallerCalleeItem callerCallee = (CallerCalleeItem) item.getData();

            // deselect this row
            table.deselectAll();

            // choose this row's function
            chooseNewFunction(callerCallee);
        }
    });

    table.addMouseListener(new CalleeMouseListener());

    table.addFocusListener(new FocusListener() {
        IAction oldCopyAction = null;

        public void focusGained(org.eclipse.swt.events.FocusEvent arg0) {
            IActionBars bars = PIPageEditor.getActionBars();

            // modify what is executed when Copy is called from the Edit menu
            oldCopyAction = bars.getGlobalActionHandler(ActionFactory.COPY.getId());

            bars.setGlobalActionHandler(ActionFactory.COPY.getId(), copyAction);

            copyAction.setEnabled(calleeTable.getSelectionCount() > 0);
            bars.updateActionBars();

            // add to the Edit menu
            IMenuManager editMenuManager = bars.getMenuManager().findMenuUsingPath(IIDEActionConstants.M_EDIT);

            if (editMenuManager instanceof SubMenuManager) {
                IContributionManager editManager = ((SubMenuManager) editMenuManager).getParent();
                ActionContributionItem item;

                editMenuManager.remove("PICopyTable"); //$NON-NLS-1$
                copyTableAction.setEnabled(calleeTable.getItemCount() > 0);
                item = new ActionContributionItem(copyTableAction);
                item.setVisible(true);
                editManager.prependToGroup(IIDEActionConstants.CUT_EXT, item);
            }

            // add to the File menu
            IMenuManager fileMenuManager = bars.getMenuManager().findMenuUsingPath(IIDEActionConstants.M_FILE);

            if (fileMenuManager instanceof SubMenuManager) {
                IContributionManager fileManager = ((SubMenuManager) fileMenuManager).getParent();
                ActionContributionItem item;

                fileMenuManager.remove("PISaveTable"); //$NON-NLS-1$
                saveTableAction.setEnabled(calleeTable.getItemCount() > 0);
                item = new ActionContributionItem(saveTableAction);
                item.setVisible(true);
                fileManager.insertAfter("saveAll", item); //$NON-NLS-1$
            }
        }

        public void focusLost(org.eclipse.swt.events.FocusEvent arg0) {
            IActionBars bars = PIPageEditor.getActionBars();
            bars.setGlobalActionHandler(ActionFactory.COPY.getId(), oldCopyAction);
            bars.updateActionBars();

            SubMenuManager editMenuManager = (SubMenuManager) PIPageEditor.getMenuManager()
                    .find(IIDEActionConstants.M_EDIT);
            editMenuManager.remove("PICopyTable"); //$NON-NLS-1$

            SubMenuManager fileMenuManager = (SubMenuManager) PIPageEditor.getMenuManager()
                    .find(IIDEActionConstants.M_FILE);
            fileMenuManager.remove("PISaveTable"); //$NON-NLS-1$
        }
    });
}

From source file:com.nokia.carbide.cpp.pi.graphicsmemory.GraphicsMemoryProcessTable.java

License:Open Source License

public GraphicsMemoryProcessTable(GraphicsMemoryTraceGraph myGraph, Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    GridLayout gl = new GridLayout();
    gl.marginHeight = 0;//from www  . j a v a2  s .  c  o  m
    gl.marginWidth = 0;
    gl.marginLeft = 0;
    gl.marginRight = 0;
    composite.setLayout(gl);
    this.myGraph = myGraph;
    this.parent = composite;

    Label label = new Label(composite, SWT.CENTER);
    label.setBackground(composite.getDisplay().getSystemColor(SWT.COLOR_WHITE));
    label.setFont(PIPageEditor.helvetica_8);
    label.setText(Messages.getString("GraphicsMemoryProcessTable.title")); //$NON-NLS-1$

    label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    this.tableViewer = CheckboxTableViewer.newCheckList(composite,
            SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);
    this.table = this.tableViewer.getTable();
    this.table.setLayoutData(new GridData(GridData.FILL_BOTH));

    // add the check state handler, label provider and content provider
    this.tableViewer.addCheckStateListener(new CheckHandler());
    this.tableViewer.setLabelProvider(new SharedLabelProvider(this.table));
    this.tableViewer.setContentProvider(new MemoryTableContentProvider());
    this.tableViewer.setSorter(new SharedSorter());

    // give the table a heading for possible use in copying and exported
    this.table.setData(Messages.getString("GraphicsMemoryProcessTable.memory")); //$NON-NLS-1$

    // create the columns
    TableColumn column;

    // data associated with the TableViewer will note which columns contain
    // hex values
    // Keep this in the order in which columns have been created
    boolean[] isHex = { false, false, false, false };
    this.table.setData("isHex", isHex); //$NON-NLS-1$

    // select/deselect column
    column = new TableColumn(this.table, SWT.CENTER);
    column.setText(COLUMN_HEAD_GRAPHICS_MEMORY_NAME);
    column.setWidth(COLUMN_WIDTH_GRAPHICS_MEMORY_NAME);
    column.setData(Integer.valueOf(COLUMN_ID_GRAPHICS_MEMORY_NAME));
    column.setMoveable(true);
    column.setResizable(true);
    column.addSelectionListener(new ColumnSelectionHandler());

    column = new TableColumn(tableViewer.getTable(), SWT.RIGHT);
    column.setText(COLUMN_HEAD_GRAPHICS_MEMORY_PRIVATE);
    column.setWidth(COLUMN_WIDTH_GRAPHICS_MEMORY_PRIVATE);
    column.setData(Integer.valueOf(COLUMN_ID_GRAPHICS_MEMORY_PRIVATE));
    column.setMoveable(true);
    column.setResizable(true);
    column.addSelectionListener(new ColumnSelectionHandler());

    column = new TableColumn(tableViewer.getTable(), SWT.RIGHT);
    column.setText(COLUMN_HEAD_GRAPHICS_MEMORY_SHARED);
    column.setWidth(COLUMN_WIDTH_GRAPHICS_MEMORY_SHARED);
    column.setData(Integer.valueOf(COLUMN_ID_GRAPHICS_MEMORY_SHARED));
    column.setMoveable(true);
    column.setResizable(true);
    column.addSelectionListener(new ColumnSelectionHandler());

    column = new TableColumn(tableViewer.getTable(), SWT.RIGHT);
    column.setText(COLUMN_HEAD_MEMORY_TOTAL);
    column.setWidth(COLUMN_WIDTH_MEMORY_TOTAL);
    column.setData(Integer.valueOf(COLUMN_ID_GRAPHICS_MEMORY_TOTAL));
    column.setMoveable(true);
    column.setResizable(true);
    column.addSelectionListener(new ColumnSelectionHandler());

    // initially, all rows are checked
    this.tableViewer.setAllChecked(true);

    this.table.addMouseListener(new TableMouseListener());
    this.table.setHeaderVisible(true);
    this.table.setLinesVisible(true);
    this.table.setRedraw(true);

    updateItemData(true);
    ((SharedSorter) tableViewer.getSorter()).doSort(COLUMN_ID_GRAPHICS_MEMORY_NAME);

    // initially, all rows are checked
    this.tableViewer.setAllChecked(true);

    createDefaultActions();

    // listen for key sequences such as Ctrl-A and Ctrl-C
    table.addKeyListener(new TableKeyListener());

    table.addFocusListener(new FocusListener() {
        IAction oldSelectAllAction = null;
        IAction oldCopyAction = null;

        public void focusGained(org.eclipse.swt.events.FocusEvent arg0) {
            IActionBars bars = PIPageEditor.getActionBars();

            oldSelectAllAction = PIPageEditor.getActionBars()
                    .getGlobalActionHandler(ActionFactory.SELECT_ALL.getId());
            oldCopyAction = PIPageEditor.getActionBars().getGlobalActionHandler(ActionFactory.COPY.getId());

            bars.setGlobalActionHandler(ActionFactory.COPY.getId(), copyAction);
            bars.setGlobalActionHandler(ActionFactory.SELECT_ALL.getId(), selectAllAction);

            copyAction.setEnabled(table.getSelectionCount() > 0);
            selectAllAction.setEnabled(table.getItemCount() > 0);
            bars.updateActionBars();

            // add to the Edit menu
            IMenuManager editMenuManager = bars.getMenuManager().findMenuUsingPath(IIDEActionConstants.M_EDIT);

            if (editMenuManager instanceof SubMenuManager) {
                IContributionManager editManager = ((SubMenuManager) editMenuManager).getParent();
                ActionContributionItem item;

                editMenuManager.remove("PICopyTable"); //$NON-NLS-1$
                copyTableAction.setEnabled(table.getItemCount() > 0);
                item = new ActionContributionItem(copyTableAction);
                item.setVisible(true);
                editManager.prependToGroup(IIDEActionConstants.CUT_EXT, item);
            }

            // add to the File menu
            IMenuManager fileMenuManager = bars.getMenuManager().findMenuUsingPath(IIDEActionConstants.M_FILE);

            if (fileMenuManager instanceof SubMenuManager) {
                IContributionManager fileManager = ((SubMenuManager) fileMenuManager).getParent();
                ActionContributionItem item;

                fileMenuManager.remove("PISaveTable"); //$NON-NLS-1$
                saveTableAction.setEnabled(table.getItemCount() > 0);
                item = new ActionContributionItem(saveTableAction);
                item.setVisible(true);
                fileManager.insertAfter("saveAll", item); //$NON-NLS-1$
            }
        }

        public void focusLost(org.eclipse.swt.events.FocusEvent arg0) {
            IActionBars bars = PIPageEditor.getActionBars();
            bars.setGlobalActionHandler(ActionFactory.COPY.getId(), oldCopyAction);
            bars.setGlobalActionHandler(ActionFactory.SELECT_ALL.getId(), oldSelectAllAction);
            bars.updateActionBars();

            SubMenuManager editMenuManager = (SubMenuManager) PIPageEditor.getMenuManager()
                    .find(IIDEActionConstants.M_EDIT);
            editMenuManager.remove("PICopyTable"); //$NON-NLS-1$
            editMenuManager.update();

            SubMenuManager fileMenuManager = (SubMenuManager) PIPageEditor.getMenuManager()
                    .find(IIDEActionConstants.M_FILE);
            fileMenuManager.remove("PISaveTable"); //$NON-NLS-1$
            fileMenuManager.update();
        }
    });

    tableViewer.refresh();
    table.redraw();
}

From source file:com.nokia.carbide.cpp.pi.memory.MemLibraryEventTable.java

License:Open Source License

public MemLibraryEventTable(MemTraceGraph myGraph, Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    GridLayout gl = new GridLayout();
    gl.marginHeight = 0;//from   w ww .  java 2s  .  co  m
    gl.marginWidth = 0;
    gl.marginLeft = 0;
    gl.marginRight = 0;
    composite.setLayout(gl);
    this.myGraph = myGraph;
    this.parent = composite;

    Label label = new Label(composite, SWT.CENTER);
    label.setBackground(composite.getDisplay().getSystemColor(SWT.COLOR_WHITE));
    label.setFont(PIPageEditor.helvetica_8);
    label.setText(Messages.getString("MemLibraryEventTable.title")); //$NON-NLS-1$

    label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    this.tableViewer = CheckboxTableViewer.newCheckList(composite,
            SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);
    this.table = this.tableViewer.getTable();
    this.table.setLayoutData(new GridData(GridData.FILL_BOTH));

    // add the check state handler, label provider and content provider
    this.tableViewer.addCheckStateListener(new CheckHandler());
    this.tableViewer.setLabelProvider(new SharedLabelProvider(this.table));
    this.tableViewer.setContentProvider(new MemoryTableContentProvider());
    this.tableViewer.setSorter(new SharedSorter());

    // give the table a heading for possible use in copying and exported
    this.table.setData(Messages.getString("MemLibraryEventTable.library")); //$NON-NLS-1$

    // create the columns
    TableColumn column;

    // data associated with the TableViewer will note which columns contain hex values
    // Keep this in the order in which columns have been created
    boolean[] isHex = { false, false, false, false };
    this.table.setData("isHex", isHex); //$NON-NLS-1$

    // select/deselect column
    column = new TableColumn(this.table, SWT.CENTER);
    column.setText(COLUMN_HEAD_SHOW);
    column.setWidth(COLUMN_WIDTH_SHOW);
    column.setData(Integer.valueOf(COLUMN_ID_SHOW));
    column.setMoveable(true);
    column.setResizable(true);
    column.addSelectionListener(new ColumnSelectionHandler());

    column = new TableColumn(this.table, SWT.LEFT);
    column.setText(COLUMN_HEAD_LIBRARY_NAME);
    column.setWidth(COLUMN_WIDTH_LIBRARY_NAME);
    column.setData(Integer.valueOf(COLUMN_ID_LIB_NAME));
    column.setMoveable(true);
    column.setResizable(true);
    column.addSelectionListener(new ColumnSelectionHandler());

    column = new TableColumn(tableViewer.getTable(), SWT.RIGHT);
    column.setText(COLUMN_HEAD_LIBRARY_LOAD_SIZE);
    column.setWidth(COLUMN_WIDTH_LIBRARY_LOAD_SIZE);
    column.setData(Integer.valueOf(COLUMN_ID_LIB_LOAD_SIZE));
    column.setMoveable(true);
    column.setResizable(true);
    column.addSelectionListener(new ColumnSelectionHandler());

    column = new TableColumn(tableViewer.getTable(), SWT.RIGHT);
    column.setText(COLUMN_HEAD_LIBRARY_SELECTION_LOAD_COUNT);
    column.setWidth(COLUMN_WIDTH_LIBRARY_SELECTION_COUNT);
    column.setData(Integer.valueOf(COLUMN_ID_LIB_SELECTION_COUNT));
    column.setMoveable(true);
    column.setResizable(true);
    column.addSelectionListener(new ColumnSelectionHandler());

    // initially, all rows are checked
    this.tableViewer.setAllChecked(true);

    this.table.addMouseListener(new TableMouseListener());

    // set background color for the first column
    this.table.addListener(SWT.EraseItem, new Listener() {
        public void handleEvent(Event event) {
            TableItem item = (TableItem) event.item;
            ProfiledLibraryEvent ple = (ProfiledLibraryEvent) item.getData();
            GC gc = event.gc;
            gc.setForeground(ple.getColor());
            gc.setBackground(ple.getColor());
            gc.fillRectangle(item.getBounds(COLOR_COLUMN_INDEX));
        }
    });

    this.table.setHeaderVisible(true);
    this.table.setLinesVisible(true);
    this.table.setRedraw(true);
    updateItemData(true);
    ((SharedSorter) tableViewer.getSorter()).doSort(COLUMN_ID_LIB_NAME);

    // initially, all rows are checked
    this.tableViewer.setAllChecked(true);

    createDefaultActions();

    // listen for key sequences such as Ctrl-A and Ctrl-C
    table.addKeyListener(new TableKeyListener());

    table.addFocusListener(new FocusListener() {
        IAction oldSelectAllAction = null;
        IAction oldCopyAction = null;

        public void focusGained(org.eclipse.swt.events.FocusEvent arg0) {
            IActionBars bars = PIPageEditor.getActionBars();

            oldSelectAllAction = PIPageEditor.getActionBars()
                    .getGlobalActionHandler(ActionFactory.SELECT_ALL.getId());
            oldCopyAction = PIPageEditor.getActionBars().getGlobalActionHandler(ActionFactory.COPY.getId());

            bars.setGlobalActionHandler(ActionFactory.COPY.getId(), copyAction);
            bars.setGlobalActionHandler(ActionFactory.SELECT_ALL.getId(), selectAllAction);

            copyAction.setEnabled(table.getSelectionCount() > 0);
            selectAllAction.setEnabled(table.getItemCount() > 0);
            bars.updateActionBars();

            // add to the Edit menu
            IMenuManager editMenuManager = bars.getMenuManager().findMenuUsingPath(IIDEActionConstants.M_EDIT);

            if (editMenuManager instanceof SubMenuManager) {
                IContributionManager editManager = ((SubMenuManager) editMenuManager).getParent();
                ActionContributionItem item;

                editMenuManager.remove("PICopyTable"); //$NON-NLS-1$
                copyTableAction.setEnabled(table.getItemCount() > 0);
                item = new ActionContributionItem(copyTableAction);
                item.setVisible(true);
                editManager.prependToGroup(IIDEActionConstants.CUT_EXT, item);
            }

            // add to the File menu
            IMenuManager fileMenuManager = bars.getMenuManager().findMenuUsingPath(IIDEActionConstants.M_FILE);

            if (fileMenuManager instanceof SubMenuManager) {
                IContributionManager fileManager = ((SubMenuManager) fileMenuManager).getParent();
                ActionContributionItem item;

                fileMenuManager.remove("PISaveTable"); //$NON-NLS-1$
                saveTableAction.setEnabled(table.getItemCount() > 0);
                item = new ActionContributionItem(saveTableAction);
                item.setVisible(true);
                fileManager.insertAfter("saveAll", item); //$NON-NLS-1$
            }
        }

        public void focusLost(org.eclipse.swt.events.FocusEvent arg0) {
            IActionBars bars = PIPageEditor.getActionBars();
            bars.setGlobalActionHandler(ActionFactory.COPY.getId(), oldCopyAction);
            bars.setGlobalActionHandler(ActionFactory.SELECT_ALL.getId(), oldSelectAllAction);
            bars.updateActionBars();

            SubMenuManager editMenuManager = (SubMenuManager) PIPageEditor.getMenuManager()
                    .find(IIDEActionConstants.M_EDIT);
            editMenuManager.remove("PICopyTable"); //$NON-NLS-1$
            editMenuManager.update();

            SubMenuManager fileMenuManager = (SubMenuManager) PIPageEditor.getMenuManager()
                    .find(IIDEActionConstants.M_FILE);
            fileMenuManager.remove("PISaveTable"); //$NON-NLS-1$
            fileMenuManager.update();
        }
    });
    tableViewer.refresh();
    table.redraw();
}

From source file:com.nokia.carbide.cpp.pi.memory.MemThreadTable.java

License:Open Source License

public MemThreadTable(MemTraceGraph myGraph, Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    GridLayout gl = new GridLayout();
    gl.marginHeight = 0;//from  w ww.  j  ava2 s . c  o  m
    gl.marginWidth = 0;
    gl.marginLeft = 0;
    gl.marginRight = 0;
    composite.setLayout(gl);
    this.myGraph = myGraph;
    this.parent = composite;

    Label label = new Label(composite, SWT.CENTER);
    label.setBackground(composite.getDisplay().getSystemColor(SWT.COLOR_WHITE));
    label.setFont(PIPageEditor.helvetica_8);
    label.setText(Messages.getString("MemThreadTable.title")); //$NON-NLS-1$

    label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    this.tableViewer = CheckboxTableViewer.newCheckList(composite,
            SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);
    this.table = this.tableViewer.getTable();
    this.table.setLayoutData(new GridData(GridData.FILL_BOTH));

    // add the check state handler, label provider and content provider
    this.tableViewer.addCheckStateListener(new CheckHandler());
    this.tableViewer.setLabelProvider(new SharedLabelProvider(this.table));
    this.tableViewer.setContentProvider(new MemoryTableContentProvider());
    this.tableViewer.setSorter(new SharedSorter());

    // give the table a heading for possible use in copying and exported
    this.table.setData(Messages.getString("MemThreadTable.memory")); //$NON-NLS-1$

    // create the columns
    TableColumn column;

    // data associated with the TableViewer will note which columns contain hex values
    // Keep this in the order in which columns have been created
    boolean[] isHex = { false, false, false, false };
    this.table.setData("isHex", isHex); //$NON-NLS-1$

    // select/deselect column
    column = new TableColumn(this.table, SWT.CENTER);
    column.setText(COLUMN_HEAD_MEMORY_NAME);
    column.setWidth(COLUMN_WIDTH_MEMORY_NAME + 15); // extra space for the checkbox
    column.setData(Integer.valueOf(COLUMN_ID_MEMORY_NAME));
    column.setMoveable(true);
    column.setResizable(true);
    column.addSelectionListener(new ColumnSelectionHandler());

    column = new TableColumn(tableViewer.getTable(), SWT.RIGHT);
    column.setText(COLUMN_HEAD_MEMORY_CHUNKS);
    column.setWidth(COLUMN_WIDTH_MEMORY_CHUNKS);
    column.setData(Integer.valueOf(COLUMN_ID_MEMORY_CHUNKS));
    column.setMoveable(true);
    column.setResizable(true);
    column.addSelectionListener(new ColumnSelectionHandler());

    column = new TableColumn(tableViewer.getTable(), SWT.RIGHT);
    column.setText(COLUMN_HEAD_MEMORY_STACK);
    column.setWidth(COLUMN_WIDTH_MEMORY_STACK);
    column.setData(Integer.valueOf(COLUMN_ID_MEMORY_STACK));
    column.setMoveable(true);
    column.setResizable(true);
    column.addSelectionListener(new ColumnSelectionHandler());

    column = new TableColumn(tableViewer.getTable(), SWT.RIGHT);
    column.setText(COLUMN_HEAD_MEMORY_TOTAL);
    column.setWidth(COLUMN_WIDTH_MEMORY_TOTAL);
    column.setData(Integer.valueOf(COLUMN_ID_MEMORY_TOTAL));
    column.setMoveable(true);
    column.setResizable(true);
    column.addSelectionListener(new ColumnSelectionHandler());

    // initially, all rows are checked
    this.tableViewer.setAllChecked(true);

    this.table.addMouseListener(new TableMouseListener());
    this.table.setHeaderVisible(true);
    this.table.setLinesVisible(true);
    this.table.setRedraw(true);

    updateItemData(true);
    ((SharedSorter) tableViewer.getSorter()).doSort(COLUMN_ID_MEMORY_NAME);

    // initially, all rows are checked
    this.tableViewer.setAllChecked(true);

    createDefaultActions();

    // listen for key sequences such as Ctrl-A and Ctrl-C
    table.addKeyListener(new TableKeyListener());

    table.addFocusListener(new FocusListener() {
        IAction oldSelectAllAction = null;
        IAction oldCopyAction = null;

        public void focusGained(org.eclipse.swt.events.FocusEvent arg0) {
            IActionBars bars = PIPageEditor.getActionBars();

            oldSelectAllAction = PIPageEditor.getActionBars()
                    .getGlobalActionHandler(ActionFactory.SELECT_ALL.getId());
            oldCopyAction = PIPageEditor.getActionBars().getGlobalActionHandler(ActionFactory.COPY.getId());

            bars.setGlobalActionHandler(ActionFactory.COPY.getId(), copyAction);
            bars.setGlobalActionHandler(ActionFactory.SELECT_ALL.getId(), selectAllAction);

            copyAction.setEnabled(table.getSelectionCount() > 0);
            selectAllAction.setEnabled(table.getItemCount() > 0);
            bars.updateActionBars();

            // add to the Edit menu
            IMenuManager editMenuManager = bars.getMenuManager().findMenuUsingPath(IIDEActionConstants.M_EDIT);

            if (editMenuManager instanceof SubMenuManager) {
                IContributionManager editManager = ((SubMenuManager) editMenuManager).getParent();
                ActionContributionItem item;

                editMenuManager.remove("PICopyTable"); //$NON-NLS-1$
                copyTableAction.setEnabled(table.getItemCount() > 0);
                item = new ActionContributionItem(copyTableAction);
                item.setVisible(true);
                editManager.prependToGroup(IIDEActionConstants.CUT_EXT, item);
            }

            // add to the File menu
            IMenuManager fileMenuManager = bars.getMenuManager().findMenuUsingPath(IIDEActionConstants.M_FILE);

            if (fileMenuManager instanceof SubMenuManager) {
                IContributionManager fileManager = ((SubMenuManager) fileMenuManager).getParent();
                ActionContributionItem item;

                fileMenuManager.remove("PISaveTable"); //$NON-NLS-1$
                saveTableAction.setEnabled(table.getItemCount() > 0);
                item = new ActionContributionItem(saveTableAction);
                item.setVisible(true);
                fileManager.insertAfter("saveAll", item); //$NON-NLS-1$
            }
        }

        public void focusLost(org.eclipse.swt.events.FocusEvent arg0) {
            IActionBars bars = PIPageEditor.getActionBars();
            bars.setGlobalActionHandler(ActionFactory.COPY.getId(), oldCopyAction);
            bars.setGlobalActionHandler(ActionFactory.SELECT_ALL.getId(), oldSelectAllAction);
            bars.updateActionBars();

            SubMenuManager editMenuManager = (SubMenuManager) PIPageEditor.getMenuManager()
                    .find(IIDEActionConstants.M_EDIT);
            editMenuManager.remove("PICopyTable"); //$NON-NLS-1$
            editMenuManager.update();

            SubMenuManager fileMenuManager = (SubMenuManager) PIPageEditor.getMenuManager()
                    .find(IIDEActionConstants.M_FILE);
            fileMenuManager.remove("PISaveTable"); //$NON-NLS-1$
            fileMenuManager.update();
        }
    });

    tableViewer.refresh();
    table.redraw();
}