use of org.eclipse.ui.handlers.IHandlerService in project dbeaver by dbeaver.
the class AboutBoxDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
Color background = JFaceColors.getBannerBackground(parent.getDisplay());
// Color foreground = JFaceColors.getBannerForeground(parent.getDisplay());
parent.setBackground(background);
Composite group = new Composite(parent, SWT.NONE);
group.setBackground(background);
GridLayout layout = new GridLayout(1, false);
layout.marginHeight = 20;
layout.marginWidth = 20;
group.setLayout(layout);
GridData gd;
IProduct product = Platform.getProduct();
{
Label nameLabel = new Label(group, SWT.NONE);
nameLabel.setBackground(background);
nameLabel.setFont(NAME_FONT);
nameLabel.setText(product.getName());
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalAlignment = GridData.CENTER;
nameLabel.setLayoutData(gd);
}
Label titleLabel = new Label(group, SWT.NONE);
titleLabel.setBackground(background);
titleLabel.setFont(TITLE_FONT);
titleLabel.setText(product.getProperty(PRODUCT_PROP_SUB_TITLE));
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalAlignment = GridData.CENTER;
titleLabel.setLayoutData(gd);
titleLabel.addMouseListener(new MouseAdapter() {
@Override
public void mouseDoubleClick(MouseEvent e) {
BusyIndicator.showWhile(getShell().getDisplay(), new Runnable() {
@Override
public void run() {
// Do not create InstallationDialog directly
// but execute "org.eclipse.ui.help.installationDialog" command
IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
IHandlerService service = workbenchWindow.getService(IHandlerService.class);
if (service != null) {
try {
// $NON-NLS-1$
service.executeCommand("org.eclipse.ui.help.installationDialog", null);
} catch (Exception e1) {
// just ignore error
}
}
}
});
}
});
Label imageLabel = new Label(group, SWT.NONE);
imageLabel.setBackground(background);
gd = new GridData();
gd.verticalAlignment = GridData.BEGINNING;
gd.horizontalAlignment = GridData.CENTER;
gd.grabExcessHorizontalSpace = false;
imageLabel.setLayoutData(gd);
imageLabel.setImage(ABOUT_IMAGE);
Label versionLabel = new Label(group, SWT.NONE);
versionLabel.setBackground(background);
versionLabel.setText(CoreMessages.dialog_about_label_version + GeneralUtils.getProductVersion().toString());
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalAlignment = GridData.CENTER;
versionLabel.setLayoutData(gd);
Label releaseTimeLabel = new Label(group, SWT.NONE);
releaseTimeLabel.setBackground(background);
releaseTimeLabel.setText(DateFormat.getDateInstance(DateFormat.LONG).format(GeneralUtils.getProductReleaseDate()));
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalAlignment = GridData.CENTER;
releaseTimeLabel.setLayoutData(gd);
Label authorLabel = new Label(group, SWT.NONE);
authorLabel.setBackground(background);
authorLabel.setText(product.getProperty(PRODUCT_PROP_COPYRIGHT));
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalAlignment = GridData.CENTER;
authorLabel.setLayoutData(gd);
Link siteLink = UIUtils.createLink(group, UIUtils.makeAnchor(product.getProperty(PRODUCT_PROP_WEBSITE)), new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
UIUtils.launchProgram(e.text);
}
});
siteLink.setBackground(background);
gd = new GridData();
gd.horizontalAlignment = GridData.CENTER;
siteLink.setLayoutData(gd);
return parent;
}
use of org.eclipse.ui.handlers.IHandlerService in project core by jcryptool.
the class ShowEditorsPulldownMenuAction method run.
/**
* Rhe implementation of the on click action.
*/
public void run(IAction action) {
// connects to the extension point
// $NON-NLS-1$
IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint("org.jcryptool.core.editorButton");
IExtension extension = point.getExtensions()[0];
IConfigurationElement element = extension.getConfigurationElements()[0];
final IHandlerService handlerService = (IHandlerService) PlatformUI.getWorkbench().getService(IHandlerService.class);
IEvaluationContext evaluationContext = handlerService.createContextSnapshot(true);
ExecutionEvent event = new ExecutionEvent(null, Collections.EMPTY_MAP, null, evaluationContext);
try {
// runs the defined action
// $NON-NLS-1$
IHandler handler = (IHandler) element.createExecutableExtension("OnClickClass");
handler.execute(event);
} catch (CoreException ex) {
LogUtil.logError(CorePlugin.PLUGIN_ID, ex);
} catch (ExecutionException ex) {
LogUtil.logError(CorePlugin.PLUGIN_ID, ex);
}
}
use of org.eclipse.ui.handlers.IHandlerService in project org.csstudio.display.builder by kasemir.
the class SearchView method configureActions.
/**
* React to selections, button presses, ...
*/
private void configureActions() {
// Start a channel search
search.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
searchForChannels();
}
});
// Channel Table: Allow dragging of PVs with archive
final Table table = channel_table.getTable();
new ControlSystemDragSource(table) {
@Override
public Object getSelection() {
final IStructuredSelection selection = (IStructuredSelection) channel_table.getSelection();
// To allow transfer of array, the data must be
// of the actual array type, not Object[]
final Object[] objs = selection.toArray();
final ChannelInfo[] channels = Arrays.copyOf(objs, objs.length, ChannelInfo[].class);
return channels;
}
};
// Double-clicks should have the same effect as context menu -> Data Browser
getSite().setSelectionProvider(channel_table);
channel_table.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
// casting is needed for RAP
IHandlerService handlerService = getSite().getService(IHandlerService.class);
try {
handlerService.executeCommand("org.csstudio.trends.databrowser3.OpenDataBrowserPopup", null);
} catch (CommandException ex) {
// $NON-NLS-1$
Activator.getLogger().log(Level.WARNING, "Failed to open data browser", ex);
}
}
});
// Add context menu for object contributions
final MenuManager menu = new MenuManager();
menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
table.setMenu(menu.createContextMenu(table));
getSite().registerContextMenu(menu, channel_table);
}
use of org.eclipse.ui.handlers.IHandlerService in project mylyn.docs by eclipse.
the class MarkupEditorOutline method configureActionBars.
private void configureActionBars(IPageSite site) {
IActionBars actionBars = site.getActionBars();
IToolBarManager toolBarManager = actionBars.getToolBarManager();
IHandlerService handlerService = (IHandlerService) site.getService(IHandlerService.class);
CollapseAllAction collapseAllAction = new CollapseAllAction(getTreeViewer());
toolBarManager.add(collapseAllAction);
handlerService.activateHandler(CollapseAllHandler.COMMAND_ID, new ActionHandler(collapseAllAction));
actionBars.updateActionBars();
}
use of org.eclipse.ui.handlers.IHandlerService in project egit by eclipse.
the class CommonUtils method runCommand.
/**
* Programatically run command based on it id and given selection
*
* @param commandId
* id of command that should be run
* @param selection
* given selection
* @return {@code true} when command was successfully executed,
* {@code false} otherwise
*/
public static boolean runCommand(String commandId, IStructuredSelection selection) {
ICommandService commandService = CommonUtils.getService(PlatformUI.getWorkbench(), ICommandService.class);
Command cmd = commandService.getCommand(commandId);
if (!cmd.isDefined())
return false;
IHandlerService handlerService = CommonUtils.getService(PlatformUI.getWorkbench(), IHandlerService.class);
EvaluationContext c = null;
if (selection != null) {
c = new EvaluationContext(handlerService.createContextSnapshot(false), selection.toList());
c.addVariable(ISources.ACTIVE_CURRENT_SELECTION_NAME, selection);
c.removeVariable(ISources.ACTIVE_MENU_SELECTION_NAME);
}
try {
if (c != null)
handlerService.executeCommandInContext(new ParameterizedCommand(cmd, null), null, c);
else
handlerService.executeCommand(commandId, null);
return true;
} catch (CommandException ignored) {
// Ignored
}
return false;
}
Aggregations