1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
/*******************************************************************************
* Copyright (c) 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
******************************************************************************/
package org.eclipse.e4.core.commands.internal;
import java.util.Map;
import javax.inject.Inject;
import org.eclipse.core.commands.Category;
import org.eclipse.core.commands.Command;
import org.eclipse.core.commands.CommandManager;
import org.eclipse.core.commands.IParameter;
import org.eclipse.core.commands.ParameterizedCommand;
import org.eclipse.e4.core.commands.ECommandService;
/**
*
*/
public class CommandServiceImpl implements ECommandService {
private CommandManager commandManager;
@Inject
public void setManager(CommandManager m) {
commandManager = m;
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.e4.core.commands.ECommandService#createCommand(org.eclipse.core.commands.Command,
* java.util.Map)
*/
public ParameterizedCommand createCommand(String id, Map parameters) {
Command command = getCommand(id);
if (command == null) {
return null;
}
return ParameterizedCommand.generateCommand(command, parameters);
}
/*
* (non-Javadoc)
*
* @see org.eclipse.e4.core.commands.ECommandService#defineCategory(java.lang.String,
* java.lang.String, java.lang.String)
*/
public Category defineCategory(String id, String name, String description) {
Category cat = commandManager.getCategory(id);
if (!cat.isDefined()) {
cat.define(name, description);
}
return cat;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.e4.core.commands.ECommandService#defineCommand(java.lang.String,
* java.lang.String, java.lang.String, org.eclipse.core.commands.Category)
*/
public Command defineCommand(String id, String name, String description, Category category,
IParameter[] parameters) {
Command cmd = commandManager.getCommand(id);
if (!cmd.isDefined()) {
cmd.define(name, description, category, parameters);
cmd.setHandler(HandlerServiceImpl.getHandler(id));
}
return cmd;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.e4.core.commands.ECommandService#getCategory(java.lang.String)
*/
public Category getCategory(String categoryId) {
return commandManager.getCategory(categoryId);
}
/*
* (non-Javadoc)
*
* @see org.eclipse.e4.core.commands.ECommandService#getCommand(java.lang.String)
*/
public Command getCommand(String commandId) {
return commandManager.getCommand(commandId);
}
}
|