要反映对可用于 CARMA 成员或容器的状态和操作所作的修改,您将需要修改 Activator 类。
要修改 Java™ Activator 类,请执行下列操作:
- 打开 Java Activator 类。在包编辑器视图中,展开 com.ibm.carma.plugin.disable.programatically > src > com.ibm.carma.plugin.disable.programatically。双击 Activator.java 类以将它打开。
- 在 Activator 类中向下滚动,找到 start 方法声明。 您将需要提供代码用于修改 GAMActionRegistry(可用的操作及其状态就存储在其中),以禁用打开方式选项。您还将需要标识要将修改应用于的特定 RAM。这可以通过 RAM 的 uniqueId 或 ramId 来完成。以下示例假定您将使用 RAM 的 uniqueId。
样本代码:
public void start(BundleContext context) throws Exception
{
RAMActionRegistry myRegistry = RAMActionRegistry.getRegistry();
myRegistry.setUniqueRAMActionState("com.ibm.carma.sample.PDSRAM",
"com.ibm.carma.action.remove",
RAMActionState.DISABLED);
}
注: 如果您选择使用
ramId 作为 RAM 标识,那么将代码的第四行更改为:
myRegistry.setRAMActionState("ramId",
"com.ibm.carma.action.openWith",
RAMActionState.DISABLED);
并提供适当的
ramId。
- 导入所需要的类和包,它们让 Activator 类知道在何处可以找到代码中所提到的其他类型。在编辑器中单击右键,然后选择源代码 > 对 import 语句进行组织,并验证要导入的包。 请确保导入了下列包。需要时,向 Activator 类顶部的 import 命令添加任何包:
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
import com.ibm.carma.ui.view.*;
- 保存源代码,并解决存在的任何错误。