这与一个工具(Software AG Web Designer)相关,该工具以插件的形式在 Eclipse IDE 之上添加了功能。
如下所示,自定义导航器称为Package Navigator
。
还可以看到在顶部节点上选择的Refresh
按钮(在本例中为Default
名称)。
有没有办法以编程方式从我正在开发的自定义插件中调用Refresh
功能?
更新
我能找到的就是以下内容-
<extension
point="org.eclipse.ui.popupMenus">
<objectContribution
adaptable="false"
id="com.softwareag.is.ui.navigator.actions.refresh"
objectClass="com.softwareag.is.ui.navigator.model.ISLazyTreeParent">
<action
class="com.softwareag.is.ui.navigator.actions.RefreshFromServerAction"
definitionId="org.eclipse.ui.file.refresh"
enablesFor="1"
helpContextId="org.eclipse.ui.edit.delete"
icon="icons/tree/refresh.gif"
id="com.softwareag.is.ui.navigator.actions.refresh"
label="%refresh_label"
menubarPath="group.edit"
tooltip="%refresh_tooltip">
</action>
<enablement>
<or>
<test property="com.softwareag.is.navigator.property.vcsEnabled"
value="true" forcePluginActivation="true"/>
<test property="com.softwareag.is.navigator.property.vcsNotEnabled"
value="true" forcePluginActivation="true"/>
</or>
</enablement>
</objectContribution>
该类是RefreshFromServerAction
-
public class RefreshFromServerAction extends Action implements IActionDelegate {
private IStructuredSelection selection;
public RefreshFromServerAction() {
this.selection = StructuredSelection.EMPTY;
this.setId(ActionFactory.REFRESH.getId());
this.setActionDefinitionId("org.eclipse.ui.file.refresh");
}
public void selectionChanged(IAction action, ISelection sel) {
if (sel instanceof IStructuredSelection) {
this.selection = (IStructuredSelection) sel;
} else {
this.selection = StructuredSelection.EMPTY;
}
}
public void run() {
this.run((IAction) null);
}
public void run(IAction action) {
ISServerNode[] servers = AssetUtils.getSelectedServersFromSelection(this.selection);
if (servers != null) {
NavigatorHelper.getInstance().setExpandAllPath((ISServerObjectBase) null, (ISServerNode) null);
List<ISServerNode> refreshedServers = new ArrayList();
for (int i = 0; i < servers.length; ++i) {
if (!refreshedServers.contains(servers[i])) {
ServerConnection serverConnection = servers[i].getServerConnection();
if (serverConnection != null && !serverConnection.isConnected()) {
return;
}
ISTreeParent[] selectedAssetsFromSelection = AssetUtils
.getSelectedAssetsFromSelection(this.selection);
ISTreeParent[] var7 = selectedAssetsFromSelection;
int var8 = selectedAssetsFromSelection.length;
for (int var9 = 0; var9 < var8; ++var9) {
ISTreeParent isTreeParent = var7[var9];
ServerElementsCache.getInstance().clearCache(serverConnection, isTreeParent);
}
if ((new ISAssetSaver()).askAndSaveDirtyEditors(servers[i].getServerConnection())) {
ISNavigatorPlugin.getDefault().notifyListeners(new NavigatorEvent(5, servers[i], this));
refreshedServers.add(servers[i]);
}
}
}
}
}
}
是否需要先创建它的对象,然后再执行需要的操作。或者有没有标准的方法来调用命令?
最佳答案
此操作似乎正在实现 org.eclipse.ui.file.refresh 命令的处理程序。因此,您应该能够使用 IHandlerService
来执行该命令。
您将需要调用该 View 的处理程序服务,因为其他 View /编辑器对此命令将具有不同的处理程序。
IViewPart view = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView("view id");
IHandlerService handlerService = view.getSite().getService(IHandlerService.class);
handlerService.executeCommand("org.eclipse.ui.file.refresh", null);
关于java - 如何以编程方式调用自定义导航器中节点上的 `Refresh` 功能?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60599139/