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());
}
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;
}
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 };
}
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;
}
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;
}
}
}
}
}
Aggregations