Skip to content
This repository has been archived by the owner on Oct 13, 2021. It is now read-only.

Remove create contingencies menu item #278

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion gse-app/src/main/java/com/powsybl/gse/app/ProjectPane.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -87,6 +89,7 @@ public class ProjectPane extends Tab {
private final Map<String, ProjectPaneProjectFolderListener> lCache = new HashMap<>();
private final CopyManager localArchiveManager = CopyManager.getInstance();
private final AppStorageListener appStorageListener;
private List<String> blackListExtensions = new ArrayList<>();

public ProjectPane(Scene scene, Project project, GseContext context) {
this.project = Objects.requireNonNull(project);
Expand All @@ -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<String> disabledExtensions = extensionsModuleConfig.getStringListProperty("disabled");
blackListExtensions.addAll(disabledExtensions);
}

appStorageListener = eventList -> eventList.getEvents().forEach(this::handleEvent);
project.getFileSystem().getEventBus().addListener(appStorageListener);

Expand Down Expand Up @@ -1154,7 +1163,7 @@ private ContextMenu createFolderContextMenu(TreeItem<Object> selectedTreeItem) {
items.add(createCreateFolderItem(selectedTreeItem, folder).order(99));
for (Class<? extends ProjectFile> 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());
Expand Down Expand Up @@ -1184,6 +1193,10 @@ private ContextMenu createFolderContextMenu(TreeItem<Object> selectedTreeItem) {
return contextMenu;
}

private boolean isCreatorExtensionEnabled(ProjectFileCreatorExtension creatorExtension) {
return !blackListExtensions.contains(creatorExtension.getClass().getName());
}

public void dispose() {
taskItems.dispose();
closeViews();
Expand Down