use of org.eclipse.ui.services.IServiceLocator in project translationstudio8 by heartsome.
the class CommandsPropertyTester method test.
public boolean test(final Object receiver, final String property, final Object[] args, final Object expectedValue) {
if (receiver instanceof IServiceLocator && args.length == 1 && args[0] instanceof String) {
final IServiceLocator locator = (IServiceLocator) receiver;
if (TOGGLE_PROPERTY_NAME.equals(property)) {
final String commandId = args[0].toString();
final ICommandService commandService = (ICommandService) locator.getService(ICommandService.class);
final Command command = commandService.getCommand(commandId);
final State state = command.getState(RegistryToggleState.STATE_ID);
if (state != null) {
return state.getValue().equals(expectedValue);
}
}
}
return false;
}
use of org.eclipse.ui.services.IServiceLocator in project tdq-studio-se by Talend.
the class AbstractOSGIServiceUtils method initService.
protected void initService(boolean isNeedDownload) {
BundleContext context = CWMPlugin.getDefault().getBundleContext();
if (context == null) {
return;
}
ServiceReference serviceReference = context.getServiceReference(getServiceName());
if (serviceReference != null) {
setService(context, serviceReference);
} else if (isNeedDownload) {
if (!hasShowDownloadWizard) {
// show download jar dialog
IServiceLocator serviceLocator = PlatformUI.getWorkbench();
ICommandService commandService = (ICommandService) serviceLocator.getService(ICommandService.class);
try {
Command command = commandService.getCommand(COMMAND_ID);
command.executeWithChecks(new ExecutionEvent());
hasShowDownloadWizard = true;
} catch (Exception e) {
log.error(e);
}
} else {
log.error(Messages.getString(getMissingMessageName()));
}
}
}
use of org.eclipse.ui.services.IServiceLocator in project dbeaver by serge-rider.
the class NodeListControl method openNodeEditor.
protected void openNodeEditor(DBNNode node) {
IServiceLocator serviceLocator = workbenchSite != null ? workbenchSite : UIUtils.getActiveWorkbenchWindow();
NavigatorUtils.executeNodeAction(DBXTreeNodeHandler.Action.open, node, serviceLocator);
}
use of org.eclipse.ui.services.IServiceLocator in project dbeaver by dbeaver.
the class NodeListControl method openNodeEditor.
protected void openNodeEditor(DBNNode node) {
IServiceLocator serviceLocator = workbenchSite != null ? workbenchSite : UIUtils.getActiveWorkbenchWindow();
NavigatorUtils.executeNodeAction(DBXTreeNodeHandler.Action.open, node, serviceLocator);
}
use of org.eclipse.ui.services.IServiceLocator in project core by jcryptool.
the class ApplicationActionBarAdvisor method createWindowMenu.
private IMenuManager createWindowMenu() {
MenuManager menu = new MenuManager(Messages.applicationActionBarAdvisor_Menu_Window, IWorkbenchActionConstants.M_WINDOW);
IServiceLocator serviceLocator = PlatformUI.getWorkbench();
// create actions for "open perspective" menu
perspectiveMenu = new MenuManager(Messages.applicationActionBarAdvisor_Menu_Open_Perspective, // $NON-NLS-1$
"openPerspective");
perspectiveMenu.add(ContributionItemFactory.PERSPECTIVES_SHORTLIST.create(window));
// create actions for "open view" menu
// $NON-NLS-1$
showViewMenu = new MenuManager(Messages.applicationActionBarAdvisor_Menu_Show_View, "showView");
showViewMenu.add(ContributionItemFactory.VIEWS_SHORTLIST.create(window));
menu.add(perspectiveMenu);
menu.add(showViewMenu);
menu.add(new Separator());
menu.add(createContributionItem(serviceLocator, null, IWorkbenchCommandConstants.WINDOW_CUSTOMIZE_PERSPECTIVE));
menu.add(createContributionItem(serviceLocator, null, IWorkbenchCommandConstants.WINDOW_RESET_PERSPECTIVE));
if (OS_MAC_OS_X.equalsIgnoreCase(OS)) {
// hide the preferences action, Mac OS X adds this automatically
hiddenMenu.add(createContributionItem(serviceLocator, null, IWorkbenchCommandConstants.WINDOW_PREFERENCES));
} else {
menu.add(new Separator());
menu.add(createContributionItem(serviceLocator, null, IWorkbenchCommandConstants.WINDOW_PREFERENCES));
}
menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
return menu;
}
Aggregations