use of org.eclipse.ui.IWorkbenchPart in project yamcs-studio by yamcs.
the class ScrollLockHandler method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IWorkbenchPart part = HandlerUtil.getActivePartChecked(event);
CommandHistoryView view = (CommandHistoryView) part;
ICommandService service = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);
Command command = service.getCommand("org.yamcs.studio.commanding.cmdhist.scrollLockCommand");
boolean oldState = HandlerUtil.toggleCommandState(command);
view.enableScrollLock(!oldState);
return null;
}
use of org.eclipse.ui.IWorkbenchPart in project yamcs-studio by yamcs.
the class ShowCommandHistoryEntryDetailsHandler method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IWorkbenchPart part = HandlerUtil.getActivePartChecked(event);
CommandHistoryView view = (CommandHistoryView) part;
ISelection sel = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().getSelection();
if (sel != null && sel instanceof IStructuredSelection) {
IStructuredSelection selection = (IStructuredSelection) sel;
Iterator<?> it = selection.iterator();
if (it.hasNext()) {
CommandHistoryRecord rec = (CommandHistoryRecord) it.next();
Shell shell = HandlerUtil.getActiveShellChecked(event);
CommandHistoryEntryDetailsDialog dialog = new CommandHistoryEntryDetailsDialog(shell, view, rec);
dialog.create();
dialog.open();
}
}
return null;
}
use of org.eclipse.ui.IWorkbenchPart in project yamcs-studio by yamcs.
the class AnnotateArchiveHandler method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IWorkbenchPart part = HandlerUtil.getActivePartChecked(event);
SwingUtilities.invokeLater(() -> {
ArchiveView view = (ArchiveView) part;
view.archivePanel.getDataViewer().tagSelectedRange();
});
return null;
}
use of org.eclipse.ui.IWorkbenchPart in project erlide_eclipse by erlang.
the class NewErlangProjectWizard method selectAndReveal.
/**
* Attempts to select and reveal the specified resource in all parts within the
* supplied workbench window's active page.
* <p>
* Checks all parts in the active page to see if they implement
* <code>ISetSelectionTarget</code>, either directly or as an adapter. If so, tells
* the part to select and reveal the specified resource.
* </p>
*
* @param resource
* the resource to be selected and revealed
* @param window
* the workbench window to select and reveal the resource
*
* @see ISetSelectionTarget
*/
public static void selectAndReveal(final IResource resource, final IWorkbenchWindow window) {
// validate the input
if (window == null || resource == null) {
return;
}
final IWorkbenchPage page = window.getActivePage();
if (page == null) {
return;
}
// get all the view and editor parts
final List<IWorkbenchPart> parts = Lists.newArrayList();
IWorkbenchPartReference[] refs = page.getViewReferences();
for (IWorkbenchPartReference ref1 : refs) {
final IWorkbenchPart part = ref1.getPart(false);
if (part != null) {
parts.add(part);
}
}
refs = page.getEditorReferences();
for (IWorkbenchPartReference ref : refs) {
if (ref.getPart(false) != null) {
parts.add(ref.getPart(false));
}
}
final ISelection selection = new StructuredSelection(resource);
for (IWorkbenchPart part : parts) {
// get the part's ISetSelectionTarget implementation
ISetSelectionTarget target = null;
if (part instanceof ISetSelectionTarget) {
target = (ISetSelectionTarget) part;
} else {
target = part.getAdapter(ISetSelectionTarget.class);
}
if (target != null) {
// select and reveal resource
final ISetSelectionTarget finalTarget = target;
window.getShell().getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
finalTarget.selectReveal(selection);
}
});
}
}
}
use of org.eclipse.ui.IWorkbenchPart in project erlide_eclipse by erlang.
the class ErlangEditor method getActivePart.
private IWorkbenchPart getActivePart() {
final IWorkbenchWindow window = getSite().getWorkbenchWindow();
final IPartService service = window.getPartService();
final IWorkbenchPart part = service.getActivePart();
return part;
}
Aggregations