Search in sources :

Example 71 with IAction

use of org.eclipse.jface.action.IAction in project linuxtools by eclipse.

the class ChartTests method byteScalingHelper.

private void byteScalingHelper(int ix, long times, long bytes, String testName) throws Exception {
    ILaunchConfiguration config = createConfiguration(proj.getProject());
    ILaunchConfigurationWorkingCopy wc = config.getWorkingCopy();
    wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, // $NON-NLS-1$
    String.valueOf(bytes) + " " + String.valueOf(times));
    wc.setAttribute(MassifLaunchConstants.ATTR_MASSIF_TIMEUNIT, MassifLaunchConstants.TIME_B);
    config = wc.doSave();
    doLaunch(config, testName);
    IAction chartAction = getChartAction();
    assertNotNull(chartAction);
    chartAction.run();
    IEditorPart part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
    assertTrue(part.getEditorInput() instanceof ChartEditorInput);
    ChartEditorInput input = (ChartEditorInput) part.getEditorInput();
    HeapChart chart = input.getChart();
    assertEquals(HeapChart.getByteUnits()[ix], chart.getXUnits());
}
Also used : HeapChart(org.eclipse.linuxtools.internal.valgrind.massif.charting.HeapChart) ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) IAction(org.eclipse.jface.action.IAction) ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) IEditorPart(org.eclipse.ui.IEditorPart) ChartEditorInput(org.eclipse.linuxtools.internal.valgrind.massif.charting.ChartEditorInput)

Example 72 with IAction

use of org.eclipse.jface.action.IAction in project linuxtools by eclipse.

the class VagrantToolBarContributionItem method getApplicableActions.

private List<IAction> getApplicableActions(IVagrantVM vm) {
    final EnumVMStatus containerStatus = EnumVMStatus.fromStatusMessage(vm.state());
    List<IAction> list = new ArrayList<>();
    if (containerStatus == EnumVMStatus.RUNNING) {
        list.add(createAction(Messages.VagrantToolBarContributionItem_stop, // $NON-NLS-1$
        "org.eclipse.linuxtools.vagrant.ui.commands.stopVM", SWTImagesFactory.DESC_STOP, vm));
        list.add(createAction(Messages.VagrantToolBarContributionItem_destroy, // $NON-NLS-1$
        "org.eclipse.linuxtools.vagrant.ui.commands.destroyVM", SWTImagesFactory.DESC_REMOVE, vm));
        list.add(createAction(Messages.VagrantToolBarContributionItem_ssh, // $NON-NLS-1$
        "org.eclipse.linuxtools.vagrant.ui.commands.sshVM", SWTImagesFactory.DESC_CONSOLE, vm));
    } else {
        list.add(createAction(Messages.VagrantToolBarContributionItem_start, // $NON-NLS-1$
        "org.eclipse.linuxtools.vagrant.ui.commands.startVM", SWTImagesFactory.DESC_START, vm));
    }
    list.add(createAction(Messages.VagrantToolBarContributionItem_package, // $NON-NLS-1$
    "org.eclipse.linuxtools.vagrant.ui.commands.packageVM", SWTImagesFactory.DESC_BUILD, vm));
    list.add(createAction(Messages.VagrantToolBarContributionItem_open, // $NON-NLS-1$
    "org.eclipse.linuxtools.vagrant.ui.commands.openVFile", SWTImagesFactory.DESC_FILE, vm));
    return list;
}
Also used : IAction(org.eclipse.jface.action.IAction) ArrayList(java.util.ArrayList) EnumVMStatus(org.eclipse.linuxtools.vagrant.core.EnumVMStatus)

Example 73 with IAction

use of org.eclipse.jface.action.IAction in project linuxtools by eclipse.

the class MassifViewPart method getToolbarActions.

@Override
public IAction[] getToolbarActions() {
    pidAction = new MassifPidMenuAction(this);
    pidAction.setId(PID_ACTION);
    Action chartAction = new Action(// $NON-NLS-1$
    Messages.getString("MassifViewPart.Display_Heap_Allocation"), // $NON-NLS-1$
    IAction.AS_PUSH_BUTTON) {

        @Override
        public void run() {
            ChartEditorInput input = getChartInput(pid);
            if (input != null) {
                displayChart(input);
            }
        }
    };
    chartAction.setId(CHART_ACTION);
    chartAction.setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(MassifPlugin.PLUGIN_ID, // $NON-NLS-1$
    "icons/linecharticon.gif"));
    chartAction.setToolTipText(Messages.getString(// $NON-NLS-1$
    "MassifViewPart.Display_Heap_Allocation"));
    saveChartAction = new SaveChartAction();
    saveChartAction.setId(SAVE_CHART_ACTION);
    treeAction = new Action(// $NON-NLS-1$
    Messages.getString("MassifViewPart.Show_Heap_Tree"), // $NON-NLS-1$
    IAction.AS_CHECK_BOX) {

        @Override
        public void run() {
            if (isChecked()) {
                stackLayout.topControl = treeViewer.getViewer().getControl();
                top.layout();
            } else {
                stackLayout.topControl = viewer.getControl();
                top.layout();
            }
        }
    };
    treeAction.setId(TREE_ACTION);
    treeAction.setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(MassifPlugin.PLUGIN_ID, // $NON-NLS-1$
    "icons/call_hierarchy.gif"));
    treeAction.setToolTipText(Messages.getString(// $NON-NLS-1$
    "MassifViewPart.Show_Heap_Tree"));
    return new IAction[] { pidAction, chartAction, saveChartAction, treeAction };
}
Also used : IAction(org.eclipse.jface.action.IAction) SaveChartAction(org.eclipse.linuxtools.dataviewers.charts.actions.SaveChartAction) Action(org.eclipse.jface.action.Action) SaveChartAction(org.eclipse.linuxtools.dataviewers.charts.actions.SaveChartAction) IAction(org.eclipse.jface.action.IAction) ChartEditorInput(org.eclipse.linuxtools.internal.valgrind.massif.charting.ChartEditorInput)

Example 74 with IAction

use of org.eclipse.jface.action.IAction in project linuxtools by eclipse.

the class ValgrindViewPart method createDynamicContent.

/**
 * Returns a refreshable view specific of a Valgrind tool.
 *
 * @param description     the content description
 * @param toolID          the Valgrind tool identifier
 * @return                the Valgrind tool view
 * @throws CoreException  the toolbar is disposed
 */
public IValgrindToolView createDynamicContent(String description, String toolID) throws CoreException {
    setContentDescription(description);
    // remove tool specific toolbar controls
    IToolBarManager toolbar = getViewSite().getActionBars().getToolBarManager();
    ToolBar tb = ((ToolBarManager) toolbar).getControl();
    if (tb == null || tb.isDisposed()) {
        // $NON-NLS-1$
        throw new CoreException(new Status(IStatus.ERROR, ValgrindUIPlugin.PLUGIN_ID, "Toolbar is disposed"));
    }
    if (dynamicActions != null) {
        for (ActionContributionItem item : dynamicActions) {
            toolbar.remove(item);
        }
    }
    // remove old view controls
    if (dynamicView != null) {
        dynamicView.dispose();
    }
    // remove old messages
    if (messages != null) {
        messagesViewer.getTreeViewer().setInput(null);
        messages = null;
    }
    for (Control child : dynamicViewHolder.getChildren()) {
        if (!child.isDisposed()) {
            child.dispose();
        }
    }
    if (toolID != null) {
        dynamicView = ValgrindUIPlugin.getDefault().getToolView(toolID);
        dynamicView.createPartControl(dynamicViewHolder);
        // create toolbar items
        IAction[] actions = dynamicView.getToolbarActions();
        if (actions != null) {
            dynamicActions = new ActionContributionItem[actions.length];
            for (int i = 0; i < actions.length; i++) {
                dynamicActions[i] = new ActionContributionItem(actions[i]);
                toolbar.appendToGroup(TOOLBAR_LOC_GROUP_ID, dynamicActions[i]);
            }
        }
    } else {
        dynamicView = null;
    }
    // remove old menu items
    IMenuManager menu = getViewSite().getActionBars().getMenuManager();
    menu.removeAll();
    // was content was created?
    hasDynamicContent = dynamicViewHolder.getChildren().length > 0;
    if (hasDynamicContent) {
        menu.add(showCoreAction);
        menu.add(showToolAction);
    }
    menu.update(true);
    toolbar.update(true);
    // Update to notify the workbench items have been changed
    getViewSite().getActionBars().updateActionBars();
    dynamicViewHolder.layout(true);
    return dynamicView;
}
Also used : Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) ActionContributionItem(org.eclipse.jface.action.ActionContributionItem) Control(org.eclipse.swt.widgets.Control) CoreException(org.eclipse.core.runtime.CoreException) IAction(org.eclipse.jface.action.IAction) IToolBarManager(org.eclipse.jface.action.IToolBarManager) ToolBar(org.eclipse.swt.widgets.ToolBar) IMenuManager(org.eclipse.jface.action.IMenuManager) IToolBarManager(org.eclipse.jface.action.IToolBarManager) ToolBarManager(org.eclipse.jface.action.ToolBarManager)

Example 75 with IAction

use of org.eclipse.jface.action.IAction in project linuxtools by eclipse.

the class GcovTest method testGcovSummary.

private void testGcovSummary(final String filename, String binPath, final boolean testProducedReference) {
    openGcovResult(project.getFile(filename), binPath, true);
    IViewPart vp = window.getActivePage().findView("org.eclipse.linuxtools.gcov.view");
    // No IDs on toolbar items, so explicitly check each one for tooltip texts
    List<String> sortTypes = new ArrayList<>(Arrays.asList("function", "file", "folder"));
    IContributionItem[] items = vp.getViewSite().getActionBars().getToolBarManager().getItems();
    STExportToCSVAction csvAction = null;
    for (IContributionItem item : items) {
        if (item instanceof ActionContributionItem && ((ActionContributionItem) item).getAction() instanceof STExportToCSVAction) {
            csvAction = (STExportToCSVAction) ((ActionContributionItem) item).getAction();
        }
    }
    Assert.assertNotNull("CSV-Export toolbar button does not exist.", csvAction);
    for (IContributionItem item : items) {
        if (item instanceof ActionContributionItem) {
            final IAction action = ((ActionContributionItem) item).getAction();
            for (int i = 0, n = sortTypes.size(); i < n; i++) {
                String sortType = sortTypes.get(i);
                if (action.getText().equals("Sort coverage per " + sortType)) {
                    dumpCSV(action, csvAction, sortType, testProducedReference);
                    if (sortTypes.size() == 1) {
                        return;
                    }
                    sortTypes.remove(i);
                    break;
                }
            }
        }
    }
}
Also used : IViewPart(org.eclipse.ui.IViewPart) ActionContributionItem(org.eclipse.jface.action.ActionContributionItem) STExportToCSVAction(org.eclipse.linuxtools.dataviewers.actions.STExportToCSVAction) IAction(org.eclipse.jface.action.IAction) IContributionItem(org.eclipse.jface.action.IContributionItem) ArrayList(java.util.ArrayList)

Aggregations

IAction (org.eclipse.jface.action.IAction)387 Action (org.eclipse.jface.action.Action)147 ImageDescriptor (org.eclipse.jface.resource.ImageDescriptor)79 IWorkbenchAction (org.eclipse.ui.actions.ActionFactory.IWorkbenchAction)57 Separator (org.eclipse.jface.action.Separator)55 WebLaunchAction (com.centurylink.mdw.plugin.actions.WebLaunchActions.WebLaunchAction)50 MenuManager (org.eclipse.jface.action.MenuManager)39 IMenuManager (org.eclipse.jface.action.IMenuManager)37 ArrayList (java.util.ArrayList)36 ActionContributionItem (org.eclipse.jface.action.ActionContributionItem)35 IContributionItem (org.eclipse.jface.action.IContributionItem)31 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)26 WorkflowElement (com.centurylink.mdw.plugin.designer.model.WorkflowElement)22 WorkflowProject (com.centurylink.mdw.plugin.project.model.WorkflowProject)18 ActionRegistry (org.eclipse.gef.ui.actions.ActionRegistry)16 IToolBarManager (org.eclipse.jface.action.IToolBarManager)16 IEditorPart (org.eclipse.ui.IEditorPart)15 Point (org.eclipse.swt.graphics.Point)14 Iterator (java.util.Iterator)13 Menu (org.eclipse.swt.widgets.Menu)13