use of org.eclipse.ui.commands.ICommandService in project translationstudio8 by heartsome.
the class XLIFFEditorImplWithNatTable method changeLayout.
/**
* 改变当前布局 ;
*/
public void changeLayout() {
isHorizontalLayout = !isHorizontalLayout;
changeLayout(isHorizontalLayout);
// 刷新工具栏的改变布局按钮的图片
ICommandService commandService = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);
commandService.refreshElements("net.heartsome.cat.ts.ui.handlers.ChangeXliffEditorModelCommand", null);
}
use of org.eclipse.ui.commands.ICommandService in project translationstudio8 by heartsome.
the class BindingModel2 method init.
/**
* The initialization only.
* @param locator
* @param manager
* @param model
*/
public void init(IServiceLocator locator, BindingManager manager, ContextModel model) {
Set cmdsForBindings = new HashSet();
bindingToElement = new HashMap();
commandToElement = new HashMap();
bindingElements = new HashSet();
bindingManager = manager;
Iterator i = manager.getActiveBindingsDisregardingContextFlat().iterator();
while (i.hasNext()) {
Binding b = (Binding) i.next();
BindingElement be = new BindingElement(controller);
be.init(b, model);
be.setParent(this);
bindingElements.add(be);
bindingToElement.put(b, be);
cmdsForBindings.add(b.getParameterizedCommand());
}
ICommandService commandService = (ICommandService) locator.getService(ICommandService.class);
final Collection commandIds = commandService.getDefinedCommandIds();
allParameterizedCommands = new HashSet();
final Iterator commandIdItr = commandIds.iterator();
while (commandIdItr.hasNext()) {
final String currentCommandId = (String) commandIdItr.next();
final Command currentCommand = commandService.getCommand(currentCommandId);
try {
allParameterizedCommands.addAll(ParameterizedCommand.generateCombinations(currentCommand));
} catch (final NotDefinedException e) {
// It is safe to just ignore undefined commands.
}
}
i = allParameterizedCommands.iterator();
while (i.hasNext()) {
ParameterizedCommand cmd = (ParameterizedCommand) i.next();
if (!cmdsForBindings.contains(cmd)) {
BindingElement be = new BindingElement(controller);
be.init(cmd);
be.setParent(this);
bindingElements.add(be);
commandToElement.put(cmd, be);
}
}
}
use of org.eclipse.ui.commands.ICommandService in project translationstudio8 by heartsome.
the class ConverterCommandTrigger method openDialog.
private static void openDialog(IWorkbenchWindow window, IFile file, String commandId) {
IWorkbench workbench = window.getWorkbench();
ICommandService commandService = (ICommandService) workbench.getService(ICommandService.class);
Command command = commandService.getCommand(commandId);
try {
EvaluationContext context = new EvaluationContext(null, IEvaluationContext.UNDEFINED_VARIABLE);
context.addVariable(ISources.ACTIVE_WORKBENCH_WINDOW_NAME, window);
if (file != null) {
StructuredSelection selection = new StructuredSelection(file);
context.addVariable(ISources.ACTIVE_CURRENT_SELECTION_NAME, selection);
}
command.executeWithChecks(new ExecutionEvent(command, Collections.EMPTY_MAP, null, context));
} catch (ExecutionException e) {
LOGGER.error("", e);
} catch (NotDefinedException e) {
LOGGER.error("", e);
} catch (NotEnabledException e) {
LOGGER.error("", e);
} catch (NotHandledException e) {
LOGGER.error("", e);
}
}
use of org.eclipse.ui.commands.ICommandService in project translationstudio8 by heartsome.
the class AbstractShieldCommandStartup method earlyStartup.
public void earlyStartup() {
Set<String> unusedCommand = getUnusedCommandSet();
IWorkbench workbench = PlatformUI.getWorkbench();
ICommandService commandService = (ICommandService) workbench.getService(ICommandService.class);
Command command;
for (String commandId : unusedCommand) {
command = commandService.getCommand(commandId);
command.undefine();
}
}
use of org.eclipse.ui.commands.ICommandService in project translationstudio8 by heartsome.
the class NewHandler method execute.
public Object execute(ExecutionEvent event) throws ExecutionException {
String parameter = event.getParameter("wizardParameter");
Command command = null;
ICommandService commandService = (ICommandService) HandlerUtil.getActiveSite(event).getService(ICommandService.class);
if (parameter == null || parameter.equalsIgnoreCase("project")) {
command = commandService.getCommand("net.heartsome.cat.ts.ui.command.newProject");
} else if (parameter.equalsIgnoreCase("folder")) {
command = commandService.getCommand("net.heartsome.cat.ts.ui.command.newFolder");
} else if (parameter.equalsIgnoreCase("tm")) {
command = commandService.getCommand("net.heartsome.cat.database.ui.tm.command.newTM");
} else if (parameter.equalsIgnoreCase("tb")) {
command = commandService.getCommand("net.heartsome.cat.database.ui.tb.command.newTB");
}
if (command == null) {
return null;
}
IEvaluationService evalService = (IEvaluationService) HandlerUtil.getActiveSite(event).getService(IEvaluationService.class);
IEvaluationContext currentState = evalService.getCurrentState();
ExecutionEvent executionEvent = new ExecutionEvent(command, Collections.EMPTY_MAP, this, currentState);
try {
command.executeWithChecks(executionEvent);
} catch (NotDefinedException e) {
LOGGER.error("", e);
} catch (NotEnabledException e) {
LOGGER.error("", e);
} catch (NotHandledException e) {
LOGGER.error("", e);
}
return null;
}
Aggregations