use of org.eclipse.ui.IWorkbenchPart in project dbeaver by dbeaver.
the class NavigatorHandlerObjectGoto method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
DBCExecutionContext context = null;
DBSObject container = null;
IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
if (activePart instanceof DBPContextProvider) {
context = ((DBPContextProvider) activePart).getExecutionContext();
} else if (activePart instanceof INavigatorModelView) {
final ISelection selection = HandlerUtil.getCurrentSelection(event);
if (selection instanceof IStructuredSelection) {
Object element = ((IStructuredSelection) selection).getFirstElement();
if (element instanceof DBSWrapper) {
DBSObject object = ((DBSWrapper) element).getObject();
if (object != null) {
container = object;
while (container instanceof DBSFolder) {
container = container.getParentObject();
}
DBPDataSource dataSource = object.getDataSource();
if (dataSource != null) {
context = dataSource.getDefaultContext(true);
}
}
}
}
}
if (context == null) {
DBUserInterface.getInstance().showError("Go to object", "No active datasource");
return null;
}
IWorkbenchWindow workbenchWindow = HandlerUtil.getActiveWorkbenchWindow(event);
GotoObjectDialog dialog = new GotoObjectDialog(HandlerUtil.getActiveShell(event), context, container);
dialog.open();
Object[] objectsToOpen = dialog.getResult();
if (!ArrayUtils.isEmpty(objectsToOpen)) {
Collection<DBNDatabaseNode> nodes = NavigatorHandlerObjectBase.getNodesByObjects(Arrays.asList(objectsToOpen));
for (DBNDatabaseNode node : nodes) {
NavigatorUtils.openNavigatorNode(node, workbenchWindow);
}
}
return null;
}
use of org.eclipse.ui.IWorkbenchPart in project yamcs-studio by yamcs.
the class ImportCommandStackHandler method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
FileDialog dialog = new FileDialog(Display.getCurrent().getActiveShell(), SWT.OPEN);
dialog.setFilterExtensions(new String[] { "*.xml" });
String importFile = dialog.open();
if (importFile == null) {
// cancelled
return null;
}
log.log(Level.INFO, "Importing command stack from file: " + importFile);
// get command stack object
IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
IWorkbenchPart part = window.getActivePage().findView(CommandStackView.ID);
CommandStackView commandStackView = (CommandStackView) part;
// import new commands
for (StackedCommand sc : parseCommandStack(importFile)) {
commandStackView.addTelecommand(sc);
}
return null;
}
use of org.eclipse.ui.IWorkbenchPart in project yamcs-studio by yamcs.
the class AddManualEventHandler method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IWorkbenchPart part = HandlerUtil.getActivePartChecked(event);
EventLogView view = (EventLogView) part;
String action = event.getParameter(EVENT_ADD_ACTION);
if (action.equals(EVENT_ADD)) {
AddManualEventDialog addManualEventDialog = new AddManualEventDialog(part.getSite().getShell());
int result = addManualEventDialog.open();
} else {
// action.equals(EVENT_INSERT)
ISelection sel = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().getSelection();
// get selected event and open a manual event dialog using the selected generation time.
if (sel != null && sel instanceof IStructuredSelection) {
IStructuredSelection selection = (IStructuredSelection) sel;
Iterator<?> it = selection.iterator();
Event rec = (Event) it.next();
long generationTime = rec.getGenerationTime();
AddManualEventDialog addManualEventDialog = new AddManualEventDialog(part.getSite().getShell(), generationTime);
int result = addManualEventDialog.open();
}
}
return null;
}
use of org.eclipse.ui.IWorkbenchPart in project yamcs-studio by yamcs.
the class RefreshArchiveHandler method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
// Disable refresh button, to prevent double-click from the user
RefreshStateProvider provider = RCPUtils.findSourceProvider(event, RefreshStateProvider.STATE_KEY_ENABLED, RefreshStateProvider.class);
provider.setEnabled(false);
IWorkbenchPart part = HandlerUtil.getActivePartChecked(event);
// We trust on the ArchiveView to re-enable the commandState (on the swt-thread) once it's done
SwingUtilities.invokeLater(() -> ((ArchiveView) part).refreshData());
return null;
}
use of org.eclipse.ui.IWorkbenchPart in project yamcs-studio by yamcs.
the class ClearCommandHistoryHandler method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IWorkbenchPart part = HandlerUtil.getActivePartChecked(event);
CommandHistoryView view = (CommandHistoryView) part;
view.clear();
return null;
}
Aggregations