diff --git a/gse-app/src/main/java/com/powsybl/gse/app/ProjectPane.java b/gse-app/src/main/java/com/powsybl/gse/app/ProjectPane.java index 4449171d..b1939349 100644 --- a/gse-app/src/main/java/com/powsybl/gse/app/ProjectPane.java +++ b/gse-app/src/main/java/com/powsybl/gse/app/ProjectPane.java @@ -13,6 +13,8 @@ import com.powsybl.afs.storage.AppStorage; import com.powsybl.afs.storage.NodeInfo; import com.powsybl.afs.storage.events.*; +import com.powsybl.commons.config.ModuleConfig; +import com.powsybl.commons.config.PlatformConfig; import com.powsybl.commons.util.ServiceLoaderCache; import com.powsybl.gse.copy_paste.afs.CopyManager; import com.powsybl.gse.copy_paste.afs.CopyService; @@ -87,6 +89,7 @@ public class ProjectPane extends Tab { private final Map lCache = new HashMap<>(); private final CopyManager localArchiveManager = CopyManager.getInstance(); private final AppStorageListener appStorageListener; + private List blackListExtensions = new ArrayList<>(); public ProjectPane(Scene scene, Project project, GseContext context) { this.project = Objects.requireNonNull(project); @@ -97,6 +100,12 @@ public ProjectPane(Scene scene, Project project, GseContext context) { copyService = initCopyService(); treeView = createProjectTreeview(); + ModuleConfig extensionsModuleConfig = PlatformConfig.defaultConfig().getOptionalModuleConfig("extensions").orElse(null); + if (extensionsModuleConfig != null && extensionsModuleConfig.hasProperty("disabled")) { + List disabledExtensions = extensionsModuleConfig.getStringListProperty("disabled"); + blackListExtensions.addAll(disabledExtensions); + } + appStorageListener = eventList -> eventList.getEvents().forEach(this::handleEvent); project.getFileSystem().getEventBus().addListener(appStorageListener); @@ -1154,7 +1163,7 @@ private ContextMenu createFolderContextMenu(TreeItem selectedTreeItem) { items.add(createCreateFolderItem(selectedTreeItem, folder).order(99)); for (Class type : project.getFileSystem().getData().getProjectFileClasses()) { for (ProjectFileCreatorExtension creatorExtension : findCreatorExtension(type)) { - if (creatorExtension != null) { + if (creatorExtension != null && isCreatorExtensionEnabled(creatorExtension)) { GseMenuItem menuItem = new GseMenuItem(creatorExtension.getMenuText()); menuItem.setOrder(creatorExtension.getMenuOrder()); menuItem.setGraphic(creatorExtension.getMenuGraphic()); @@ -1184,6 +1193,10 @@ private ContextMenu createFolderContextMenu(TreeItem selectedTreeItem) { return contextMenu; } + private boolean isCreatorExtensionEnabled(ProjectFileCreatorExtension creatorExtension) { + return !blackListExtensions.contains(creatorExtension.getClass().getName()); + } + public void dispose() { taskItems.dispose(); closeViews();