use of org.eclipse.ui.commands.ICommandService in project translationstudio8 by heartsome.
the class ApplicationWorkbenchWindowAdvisor method postWindowOpen.
@Override
public void postWindowOpen() {
IWorkbenchWindow workbenchWindow = getWindowConfigurer().getWindow();
// workbenchWindow.getShell().setMaximized(true);
restorEditorHistory();
saveEditorHistory();
final ICommandService commandService = (ICommandService) workbenchWindow.getService(ICommandService.class);
// 在程序主体窗口打开之前,更新打开工具栏的菜单,让它初始化菜单图片 --robert 2012-03-19
commandService.refreshElements("net.heartsome.cat.ts.openToolBarCommand", null);
// 添加监听
addViewPartVisibleListener(workbenchWindow);
addWorkplaceListener();
// 自动检查更新
automaticCheckUpdate();
// 设置将文件拖到导航视图时的模式为直接复制
setDragModle();
setListenerToPespective(commandService);
setIdToHelpSystem();
setProgressIndicatorVisible(false);
setInitLinkEnable();
// 处理 hunspell 内置词典内置文件
try {
CommonFunction.unZipHunspellDics();
} catch (Exception e) {
e.printStackTrace();
}
}
use of org.eclipse.ui.commands.ICommandService 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.commands.ICommandService in project translationstudio8 by heartsome.
the class OpenStatusBarHandler method execute.
public Object execute(ExecutionEvent event) throws ExecutionException {
IPreferenceStore preferenceStore = Activator.getDefault().getPreferenceStore();
boolean oldValue = preferenceStore.getBoolean(TsPreferencesConstant.TS_statusBar_status);
ApplicationWorkbenchWindowAdvisor configurer = ApplicationWorkbenchAdvisor.WorkbenchWindowAdvisor;
configurer.setStatusVisible(!oldValue);
preferenceStore.setValue(TsPreferencesConstant.TS_statusBar_status, !oldValue);
ICommandService commandService = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);
commandService.refreshElements(event.getCommand().getId(), null);
return null;
}
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;
}
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();
}
}
Aggregations